Example #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]);
    }
  }
Example #2
0
  private static ExportServiceParams parseExportParams() {
    ExportServiceParams exportParam = new ExportServiceParams();

    if ("zip".equalsIgnoreCase(fileType)) {
      exportParam.setFileType(TypeEnum.ZIP);
    } else if ("warc".equalsIgnoreCase(fileType)) {
      exportParam.setFileType(TypeEnum.WARC_RESOURCE);
    } else if ("arc".equalsIgnoreCase(fileType)) {
      exportParam.setFileType(TypeEnum.ARC_RESOURCE);
    } else if (fileType != null && fileType.length() > 0) {
      System.out.println("The requested file format is not supported");
      System.exit(EXIT_CODE_FAIL);
    }

    if (maxFileSize != null && maxFileSize.length() > 0) {
      try {
        exportParam.setMaxSize(Long.parseLong(maxFileSize));
      } catch (NumberFormatException e) {
        System.out.println(maxFileSize + " is not an integer value.");
      }
    }
    if ("false".equalsIgnoreCase(compress)) {
      exportParam.setCompress(false);
    } else {
      exportParam.setCompress(true);
    }

    return exportParam;
  }