Beispiel #1
0
  private static String retrieveOFileNameRemote(String[] cmdArray) {
    JsonArrayBuilder jab = Json.createArrayBuilder();
    for (String s : cmdArray) {
      jab.add(s);
    }

    // add jobId for server side database
    // jab.add(OCSSW.getJobId());
    JsonArray remoteCmdArray = jab.build();

    OCSSWClient ocsswClient = new OCSSWClient();
    WebTarget target = ocsswClient.getOcsswWebTarget();
    final Response response =
        target
            .path("ocssw")
            .path("computeNextLevelFileName")
            .path(OCSSW.getJobId())
            .request(MediaType.APPLICATION_JSON_TYPE)
            .post(Entity.entity(remoteCmdArray, MediaType.APPLICATION_JSON_TYPE));

    String ofileName =
        target
            .path("ocssw")
            .path("retrieveNextLevelFileName")
            .path(OCSSW.getJobId())
            .request(MediaType.TEXT_PLAIN)
            .get(String.class);
    if (ofileName != null) {
      return ofileName;
    } else {
      return "output";
    }
  }
Beispiel #2
0
  public static Process executeLocal(String[] cmdArray, File ifileDir) {
    // System.out.println("local execution!" + " "  + Arrays.toString(cmdArray) );
    ProcessBuilder processBuilder = new ProcessBuilder(cmdArray);
    Map<String, String> env = processBuilder.environment();
    if (!env.containsKey(OCSSW_ROOT_VAR) && OCSSW.isOCSSWExist()) {
      env.put(OCSSW_ROOT_VAR, OCSSW.getOcsswEnv());
    }
    if (ifileDir != null) {
      processBuilder.directory(ifileDir);
    } else {
      processBuilder.directory(getDefaultDir());
    }

    Process process = null;
    try {
      process = processBuilder.start();
      int exitValue = process.waitFor();
    } catch (Exception e) {
      VisatApp.getApp()
          .showErrorDialog(
              "OCSSW execution error from SeaDAS application! \n"
                  + cmdArray[0]
                  + "  program is not executed correctly.");
      e.printStackTrace();
    }
    return process;
  }
Beispiel #3
0
  private static String[] getCmdArrayForNextLevelNameFinder(String ifileName, String programName) {
    String[] cmdArray = new String[6];
    cmdArray[0] = OCSSW.getOcsswScriptPath();
    cmdArray[1] = "--ocsswroot";
    cmdArray[2] = OCSSW.getOcsswEnv();
    cmdArray[3] = NEXT_LEVEL_NAME_FINDER_PROGRAM_NAME;
    cmdArray[4] =
        RuntimeContext.getConfig()
                .getContextProperty(OCSSW.OCSSW_LOCATION_PROPERTY)
                .equals(OCSSW.SEADAS_OCSSW_LOCATION_LOCAL)
            ? ifileName
            : getIfileNameforRemoteServer(ifileName);

    cmdArray[5] = programName;
    return cmdArray;
  }
Beispiel #4
0
  public static String findNextLevelFileName(String ifileName, String programName, String suite) {
    if (ifileName == null || programName == null) {
      return null;
    }
    if (programName.equals("l3bindump")) {
      return ifileName + ".xml";
    }
    debug("Program name is " + programName);
    Debug.assertNotNull(ifileName);
    // todo Add suite, also check calling program the make sure ProcessorModel call is right

    String[] cmdArray = new String[6];
    cmdArray[0] = OCSSW.getOcsswScriptPath();
    cmdArray[1] = "--ocsswroot";
    cmdArray[2] = OCSSW.getOcsswEnv();
    cmdArray[3] = NEXT_LEVEL_NAME_FINDER_PROGRAM_NAME;
    cmdArray[4] =
        RuntimeContext.getConfig()
                .getContextProperty(OCSSW.OCSSW_LOCATION_PROPERTY)
                .equals(OCSSW.SEADAS_OCSSW_LOCATION_LOCAL)
            ? ifileName
            : getIfileNameforRemoteServer(ifileName);
    cmdArray[5] = programName;
    // cmdArray[6] = "--suite="+suite;

    String ifileDir =
        ifileName.substring(0, ifileName.lastIndexOf(System.getProperty("file.separator")));

    if (RuntimeContext.getConfig()
        .getContextProperty(OCSSW.OCSSW_LOCATION_PROPERTY)
        .equals(OCSSW.SEADAS_OCSSW_LOCATION_LOCAL)) {
      return retrieveOFileNameLocal(cmdArray, ifileDir);
    } else {
      return retrieveOFileNameRemote(cmdArray);
    }
  }
Beispiel #5
0
  public static Process executeLocal(ProcessorModel processorModel) {
    // System.out.println("local execution!" + " " +
    // Arrays.toString(processorModel.getProgramCmdArray()));
    ProcessBuilder processBuilder = new ProcessBuilder(processorModel.getProgramCmdArray());
    Map<String, String> env = processBuilder.environment();

    if (!env.containsKey(OCSSW_ROOT_VAR) && OCSSW.isOCSSWExist()) {
      // System.out.println("error checkpoint!");
      env.put(OCSSW_ROOT_VAR, OCSSW.getOcsswEnv());
    }

    if (processorModel.getIFileDir() != null) {
      processBuilder.directory(processorModel.getIFileDir());
    } else {
      // processBuilder.directory(getDefaultDir());
    }
    Process process = null;
    try {
      process = processBuilder.start();
    } catch (IOException ioe) {

    }
    return process;
  }
Beispiel #6
0
 private static String getIfileNameforRemoteServer(String ifileName) {
   String newIfileName =
       ifileName.replace(OCSSW.getOCSSWClientSharedDirName(), OCSSW.getServerSharedDirName());
   return newIfileName;
 }
Beispiel #7
0
  public OCSSWRunner() {

    environment.put(OCSSW_ROOT_VAR, OCSSW.getOcsswEnvArray());
  }