// ******************************************
// NEW: use new client utility class
String baseURL =
protocol + "://" + hp[0] + ":"
+ Integer.parseInt(hp[1]) + "/" + context;
FedoraClient fc = new FedoraClient(baseURL, args[4], args[5]);
FedoraAPIAMTOM targetRepoAPIA = fc.getAPIAMTOM();
FedoraAPIMMTOM targetRepoAPIM = fc.getAPIMMTOM();
fc.shutdown();
//*******************************************
String pid =
Ingest.oneFromFile(f,
ingestFormat,
targetRepoAPIA,
targetRepoAPIM,
logMessage);
if (pid == null) {
System.out.print("ERROR: ingest failed for file: "
+ args[1]);
} else {
System.out.println("Ingested pid: " + pid);
}
} else if (kind == 'd') {
// USAGE: fedora-ingest d[ir] path format targetHost:targetPort targetUser targetPassword targetProtocol [log] [context]
if (args.length < 7 || args.length > 9) {
Ingest.badArgs("Wrong number of arguments (" + args.length
+ ") for directory ingest.");
System.out
.println("USAGE: fedora-ingest d[ir] path format targetHost:targetPort targetUser targetPassword targetProtocol [log] [context]");
}
File d = new File(args[1]);
String ingestFormat = args[2];
String logMessage = null;
if (args.length == 8) {
logMessage = args[7];
}
if (args.length == 9 && !args[8].equals("")) {
context = args[8];
}
String protocol = args[6];
String[] hp = args[3].split(":");
// ******************************************
// NEW: use new client utility class
String baseURL =
protocol + "://" + hp[0] + ":"
+ Integer.parseInt(hp[1]) + "/" + context;
FedoraClient fc = new FedoraClient(baseURL, args[4], args[5]);
FedoraAPIAMTOM targetRepoAPIA = fc.getAPIAMTOM();
FedoraAPIMMTOM targetRepoAPIM = fc.getAPIMMTOM();
//*******************************************
logRootName = "ingest-from-dir";
logFile = IngestLogger.newLogFile(logRootName);
log =
new PrintStream(new FileOutputStream(logFile),
true,
"UTF-8");
IngestLogger.openLog(log, logRootName);
Ingest.multiFromDirectory(d,
ingestFormat,
targetRepoAPIA,
targetRepoAPIM,
logMessage,
log,
counter);
IngestLogger.closeLog(log, logRootName);
summarize(counter, logFile);
} else if (kind == 'r') {
// USAGE: fedora-ingest r[epos] sourceHost:sourcePort sourceUser sourcePassword pid|* targetHost:targetPort targetUser targetPassword sourceProtocol targetProtocol [log] [context]
if (args.length < 10 || args.length > 12) {
Ingest.badArgs("Wrong number of arguments for repository ingest.");
}
String logMessage = null;
if (args.length == 11) {
logMessage = args[10];
}
if (args.length == 12 && !args[11].equals("")) {
context = args[11];
}
//Source repository
String[] shp = args[1].split(":");
String source_host = shp[0];
String source_port = shp[1];
String source_user = args[2];
String source_password = args[3];
String source_protocol = args[8];
// ******************************************
// NEW: use new client utility class
String sourceBaseURL =
source_protocol + "://" + source_host + ":"
+ Integer.parseInt(source_port) + "/" + context;
FedoraClient sfc =
new FedoraClient(sourceBaseURL,
source_user,
source_password);
FedoraAPIAMTOM sourceRepoAPIA = sfc.getAPIAMTOM();
FedoraAPIMMTOM sourceRepoAPIM = sfc.getAPIMMTOM();
//*******************************************
//Target repository
String[] thp = args[5].split(":");
String target_host = thp[0];
String target_port = thp[1];
String target_user = args[6];
String target_password = args[7];
String target_protocol = args[9];
// ******************************************
// NEW: use new client utility class
String targetBaseURL =
target_protocol + "://" + target_host + ":"
+ Integer.parseInt(target_port) + "/" + context;
FedoraClient tfc =
new FedoraClient(targetBaseURL,
target_user,
target_password);
FedoraAPIAMTOM targetRepoAPIA = tfc.getAPIAMTOM();
FedoraAPIMMTOM targetRepoAPIM = tfc.getAPIMMTOM();
//*******************************************
// Determine export format
RepositoryInfo repoinfo = sourceRepoAPIA.describeRepository();
System.out