Package org.serviceconnector.service

Examples of org.serviceconnector.service.FileSession


      // code for type session service is below switch statement
      break;
    case FILE_SERVICE:
      FileService fileService = (FileService) abstractService;
      // create file session
      FileSession fileSession = new FileSession(sessionInfo, ipAddressList, fileService.getPath(),
          fileService.getUploadFileScriptName(), fileService.getGetFileListScriptName());
      fileSession.setService(fileService);
      FileServer fileServer = fileService.allocateFileServerAndCreateSession(fileSession);
      // add server to session
      fileSession.setServer(fileServer);
      fileSession.setSessionTimeoutMillis(eciInMillis * basicConf.getEchoIntervalMultiplier());
      // finally add file session to the registry
      this.sessionRegistry.addSession(fileSession.getId(), fileSession);
      // reply to client
      SCMPMessage reply = new SCMPMessage();
      reply.setIsReply(true);
      reply.setMessageType(getKey());
      reply.setSessionId(fileSession.getId());
      response.setSCMP(reply);
      responderCallback.responseCallback(request, response);
      return;
    default:
      // code for other types of services is below
View Full Code Here


    default:
      // code for other types of services is below
      break;
    }

    FileSession session = (FileSession) this.getSessionById(message.getSessionId());
    // reset session timeout to OTI+ECI - during wait for server reply
    int otiOnSCMillis = (int) (oti * basicConf.getOperationTimeoutMultiplier());
    double otiOnSCSeconds = (otiOnSCMillis / Constants.SEC_TO_MILLISEC_FACTOR);
    this.sessionRegistry.resetSessionTimeout(session, (otiOnSCSeconds + session.getSessionTimeoutMillis()));
    SCMPMessage reply = null;
    try {
      String remoteFileName = message.getHeader(SCMPHeaderAttributeKey.REMOTE_FILE_NAME);
      FileServer fileServer = session.getFileServer();
      reply = fileServer.serverUploadFile(session, message, remoteFileName, oti);
    } catch (Exception e) {
      SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.FILE_UPLOAD_FAILED,
          "Error occured in file server on SC.");
      scmpCommandException.setMessageType(getKey());
      throw scmpCommandException;
    }
    reply.setIsReply(true);
    reply.setMessageType(getKey());
    response.setSCMP(reply);
    // reset session timeout to ECI
    this.sessionRegistry.resetSessionTimeout(session, session.getSessionTimeoutMillis());
    responderCallback.responseCallback(request, response);
  }
View Full Code Here

   * @param reason
   *            the reason
   */
  @Override
  public void abortSession(AbstractSession session, String reason) {
    FileSession fileSession = (FileSession) session;
    SessionLogger.logAbortSession(fileSession, reason);
    HttpURLConnection httpURLConnection = fileSession.getHttpURLConnection();
    if (httpURLConnection != null) {
      httpURLConnection.disconnect();
    }
    this.sessions.remove(session);
  }
View Full Code Here

    default:
      // code for other types of services is below
      break;
    }

    FileSession session = (FileSession) this.getSessionById(message.getSessionId());
    // reset session timeout to OTI+ECI - during wait for server reply
    int otiOnSCMillis = (int) (oti * basicConf.getOperationTimeoutMultiplier());
    double otiOnSCSeconds = (otiOnSCMillis / Constants.SEC_TO_MILLISEC_FACTOR);
    this.sessionRegistry.resetSessionTimeout(session, (otiOnSCSeconds + session.getSessionTimeoutMillis()));

    SCMPMessage reply = null;
    try {
      String remoteFileName = message.getHeader(SCMPHeaderAttributeKey.REMOTE_FILE_NAME);

      FileServer fileServer = session.getFileServer();
      reply = fileServer.serverDownloadFile(session, message, remoteFileName, oti);
    } catch (Exception e) {
      reply = new SCMPMessage();
      SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.FILE_DOWNLOAD_FAILED,
          "Error occured in file server on SC.");
      scmpCommandException.setMessageType(getKey());
      throw scmpCommandException;
    }
    reply.setIsReply(true);
    reply.setMessageType(getKey());
    response.setSCMP(reply);
    // reset session timeout to ECI
    this.sessionRegistry.resetSessionTimeout(session, session.getSessionTimeoutMillis());
    responderCallback.responseCallback(request, response);
  }
View Full Code Here

      // code for type session service is below switch statement
      break;
    case FILE_SERVICE:
      FileService fileService = (FileService) abstractService;
      // create file session
      FileSession fileSession = new FileSession(sessionInfo, ipAddressList, fileService.getPath(),
          fileService.getUploadFileScriptName(), fileService.getGetFileListScriptName());
      fileSession.setService(fileService);
      FileServer fileServer = fileService.allocateFileServerAndCreateSession(fileSession);
      // add server to session
      fileSession.setServer(fileServer);
      fileSession.setSessionTimeoutMillis(eciInMillis * basicConf.getEchoIntervalMultiplier());
      // finally add file session to the registry
      this.sessionRegistry.addSession(fileSession.getId(), fileSession);
      // reply to client
      SCMPMessage reply = new SCMPMessage();
      reply.setIsReply(true);
      reply.setMessageType(getKey());
      reply.setSessionId(fileSession.getId());
      response.setSCMP(reply);
      responderCallback.responseCallback(request, response);
      return;
    default:
      // code for other types of services is below
View Full Code Here

    default:
      // code for other types of services is below
      break;
    }

    FileSession session = (FileSession) this.getSessionById(message.getSessionId());
    // sets the time of last execution
    session.resetExecuteTime();
    // reset session timeout to OTI+ECI - during wait for server reply
    int otiOnSCMillis = (int) (oti * basicConf.getOperationTimeoutMultiplier());
    double otiOnSCSeconds = (otiOnSCMillis / Constants.SEC_TO_MILLISEC_FACTOR);
    this.sessionRegistry.resetSessionTimeout(session, (otiOnSCSeconds + session.getSessionTimeoutMillis()));

    SCMPMessage reply = null;
    try {
      String remoteFileName = message.getHeader(SCMPHeaderAttributeKey.REMOTE_FILE_NAME);

      FileServer fileServer = session.getFileServer();
      reply = fileServer.serverDownloadFile(session, message, remoteFileName, oti);
    } catch (Exception e) {
      // SCMP Version request
      reply = new SCMPMessage(message.getSCMPVersion());
      SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.FILE_DOWNLOAD_FAILED,
          "Error occured in file server on SC.");
      scmpCommandException.setMessageType(getKey());
      throw scmpCommandException;
    }
    reply.setIsReply(true);
    reply.setMessageType(getKey());
    response.setSCMP(reply);
    // reset session timeout to ECI
    this.sessionRegistry.resetSessionTimeout(session, session.getSessionTimeoutMillis());
    responderCallback.responseCallback(request, response);
  }
View Full Code Here

      // code for type session service is below switch statement
      break;
    case FILE_SERVICE:
      FileService fileService = (FileService) abstractService;
      // create file session
      FileSession fileSession = new FileSession(sessionInfo, ipAddressList, fileService.getPath(),
          fileService.getUploadFileScriptName(), fileService.getGetFileListScriptName());
      fileSession.setService(fileService);
      FileServer fileServer = fileService.allocateFileServerAndCreateSession(fileSession);
      // add server to session
      fileSession.setServer(fileServer);
      fileSession.setSessionTimeoutMillis(eciInMillis * basicConf.getEchoIntervalMultiplier());
      // finally add file session to the registry
      this.sessionRegistry.addSession(fileSession.getId(), fileSession);
      // reply to client - SCMP Version request
      SCMPMessage reply = new SCMPMessage(reqMessage.getSCMPVersion());
      reply.setIsReply(true);
      reply.setMessageType(getKey());
      reply.setSessionId(fileSession.getId());
      response.setSCMP(reply);
      responderCallback.responseCallback(request, response);
      return;
    default:
      // code for other types of services is below
View Full Code Here

      // code for type session service is below switch statement
      break;
    case FILE_SERVICE:
      FileService fileService = (FileService) abstractService;
      // create file session
      FileSession fileSession = new FileSession(sessionInfo, ipAddressList, fileService.getPath(),
          fileService.getUploadFileScriptName(), fileService.getGetFileListScriptName());
      fileSession.setService(fileService);
      FileServer fileServer = fileService.allocateFileServerAndCreateSession(fileSession);
      // add server to session
      fileSession.setServer(fileServer);
      fileSession.setSessionTimeoutMillis(eciInMillis * basicConf.getEchoIntervalMultiplier());
      // finally add file session to the registry
      this.sessionRegistry.addSession(fileSession.getId(), fileSession);
      // reply to client - SCMP Version request
      SCMPMessage reply = new SCMPMessage(reqMessage.getSCMPVersion());
      reply.setIsReply(true);
      reply.setMessageType(getKey());
      reply.setSessionId(fileSession.getId());
      response.setSCMP(reply);
      responderCallback.responseCallback(request, response);
      return;
    default:
      // code for other types of services is below
View Full Code Here

    default:
      // code for other types of services is below
      break;
    }

    FileSession session = (FileSession) this.getSessionById(message.getSessionId());
    // sets the time of last execution
    session.resetExecuteTime();
    // reset session timeout to OTI+ECI - during wait for server reply
    int otiOnSCMillis = (int) (oti * basicConf.getOperationTimeoutMultiplier());
    double otiOnSCSeconds = (otiOnSCMillis / Constants.SEC_TO_MILLISEC_FACTOR);
    this.sessionRegistry.resetSessionTimeout(session, (otiOnSCSeconds + session.getSessionTimeoutMillis()));
    SCMPMessage reply = null;
    try {
      String remoteFileName = message.getHeader(SCMPHeaderAttributeKey.REMOTE_FILE_NAME);
      FileServer fileServer = session.getFileServer();
      reply = fileServer.serverUploadFile(session, message, remoteFileName, oti);
    } catch (Exception e) {
      SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.FILE_UPLOAD_FAILED,
          "Error occured in file server on SC.");
      scmpCommandException.setMessageType(getKey());
      throw scmpCommandException;
    }
    reply.setIsReply(true);
    reply.setMessageType(getKey());
    response.setSCMP(reply);
    // reset session timeout to ECI
    this.sessionRegistry.resetSessionTimeout(session, session.getSessionTimeoutMillis());
    responderCallback.responseCallback(request, response);
  }
View Full Code Here

   * @param reason
   *            the reason
   */
  @Override
  public void abortSession(AbstractSession session, String reason) {
    FileSession fileSession = (FileSession) session;
    SessionLogger.logAbortSession(fileSession, reason);
    HttpURLConnection httpURLConnection = fileSession.getHttpURLConnection();
    if (httpURLConnection != null) {
      httpURLConnection.disconnect();
    }
    this.sessions.remove(session);
  }
View Full Code Here

TOP

Related Classes of org.serviceconnector.service.FileSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.