All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fcrepo.client.batch.AutoBatchBuild Maven / Gradle / Ivy

There is a newer version: 3.8.1
Show newest version
/* 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.
 * 
 * @author Ross Wayland
 */
public class AutoBatchBuild
        implements Constants {

    private final Properties batchProperties = new Properties();

    public AutoBatchBuild(String objectTemplate,
                          String objectSpecificDir,
                          String objectDir,
                          String logFile,
                          String logFormat,
                          String objectFormat)
            throws Exception {

        batchProperties.setProperty("template", objectTemplate);
        batchProperties.setProperty("merge-objects", "yes");
        batchProperties.setProperty("specifics", objectSpecificDir);
        batchProperties.setProperty("objects", objectDir);
        batchProperties.setProperty("pids-format", logFormat);
        batchProperties.setProperty("ingested-pids", logFile);
        batchProperties.setProperty("object-format", objectFormat);

        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 objectFormat = null;
        if (args.length == 5) {
            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;
            }
            // 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