org.fcrepo.client.batch.AutoBatchBuildIngest Maven / Gradle / Ivy
/* The contents of this file are subject to the license and copyright terms
* detailed in the license directory at the root of the source tree (also
* available online at http://fedora-commons.org/license/).
*/
package org.fcrepo.client.batch;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Properties;
import org.fcrepo.common.Constants;
/**
* Auto Batch Build Ingest.
*
* @author Ross Wayland
*/
public class AutoBatchBuildIngest
implements Constants {
private final Properties batchProperties = new Properties();
public AutoBatchBuildIngest(String objectTemplate,
String objectSpecificDir,
String objectDir,
String logFile,
String logFormat,
String objectFormat,
String host,
String port,
String username,
String password,
String protocol,
String context)
throws Exception {
batchProperties.setProperty("merge-objects", "yes");
batchProperties.setProperty("ingest", "yes");
batchProperties.setProperty("template", objectTemplate);
batchProperties.setProperty("specifics", objectSpecificDir);
batchProperties.setProperty("objects", objectDir);
batchProperties.setProperty("ingested-pids", logFile);
batchProperties.setProperty("pids-format", logFormat);
batchProperties.setProperty("object-format", objectFormat);
batchProperties.setProperty("server-fqdn", host);
batchProperties.setProperty("server-port", port);
batchProperties.setProperty("server-context", context);
batchProperties.setProperty("username", username);
batchProperties.setProperty("password", password);
batchProperties.setProperty("server-protocol", protocol);
BatchTool batchTool = new BatchTool(batchProperties, null, null);
batchTool.prep();
batchTool.process();
}
public static final void main(String[] args) throws Exception {
System.setProperty("java.awt.headless", "true");
boolean errors = false;
String context = "/" + Constants.FEDORA_DEFAULT_APP_CONTEXT;
String objectFormat = null;
if (args.length == 9 || args.length == 10) {
if (!new File(args[0]).exists() && !new File(args[0]).isFile()) {
System.out.println("Specified object template file path: \""
+ args[0] + "\" does not exist.");
errors = true;
}
if (!new File(args[1]).isDirectory()) {
System.out.println("Specified object specific directory: \""
+ args[1] + "\" is not directory.");
errors = true;
}
if (!new File(args[2]).isDirectory()) {
System.out.println("Specified object directory: \"" + args[2]
+ "\" is not a directory.");
errors = true;
}
if (!args[4].equals("xml") && !args[4].equals("text")) {
System.out
.println("Format for log file must must be either: \""
+ "\"xml\" or \"txt\"");
errors = true;
}
String[] server = args[5].split(":");
if (server.length != 2) {
System.out.println("Specified server name does not specify "
+ "port number: \"" + args[5] + "\" .");
errors = true;
}
if (!args[8].equals("http") && !args[8].equals("https")) {
System.out.println("Protocl must be either: \""
+ "\"http\" or \"https\"");
errors = true;
}
if (args.length == 10 && !args[9].equals("")){
context = "/" + args[9];
}
// Verify format of template file to see if it is a METS or FOXML template
BufferedReader br = new BufferedReader(new FileReader(args[0]));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
if (line.indexOf("
© 2015 - 2025 Weber Informatics LLC | Privacy Policy