Ejemplo n.º 1
0
  public static void main(String[] args) {
    parseCommandLineOptions(args);
    ExportServiceParams exportParam = parseExportParams();
    String[] auIdsList = null;
    if (auIdsFileList != null && auIdsFileList.length() > 0) {
      try {
        auIdsList = getAuIdsListFromFile();
      } catch (IOException e) {
        System.out.println("There is a problem reading from :" + auIdsFileList);
        e.printStackTrace();
        System.exit(EXIT_CODE_FAIL);
      }
    } else if (auId != null && auId.length() > 0) {
      auIdsList = new String[] {auId};
    } else {
      System.out.println("AU id or AU id file list is missing.");
      System.exit(EXIT_CODE_FAIL);
    }

    ExportService port = null;
    try {
      port = defineWSLocator();
    } catch (ServiceException e) {
      System.out.println("Probleming in accessing WS");
      e.printStackTrace();
      System.exit(EXIT_CODE_FAIL);
    }
    for (int i = 0; i < auIdsList.length; i++) {
      System.out.println("Starting download " + auIdsList[i]);
      exportParam.setAuid(auIdsList[i]);
      exportParam.setFilePrefix(getFilePrefixFromAUId(auIdsList[i]));

      ExportServiceWsResult result = null;
      try {
        result = port.createExportFiles(exportParam);
      } catch (RemoteException e) {
        System.out.println("Problem in accessing the createExportfiles");
        e.printStackTrace();
      }
      try {
        writeFiles(result);
      } catch (FileNotFoundException e) {
        System.out.println("Problem in writting the files");
        e.printStackTrace();
      } catch (IOException e) {
        System.out.println("Problem in writting the files");
        e.printStackTrace();
      }
      System.out.println("Download completed successfully for " + auIdsList[i]);
    }
  }