+ String.valueOf(wi.getID()));
+ String.valueOf(wfi.getID())); else System.out.println("Created and installed item, handle="+handle);
    public static void main(String[] argv) throws Exception    {        Options options = new Options();        options.addOption("c", "collection", true,                "destination collection(s) Handle (repeatable)");        options.addOption("e", "eperson", true,                "email address of eperson doing importing");        options                .addOption(                        "w",                        "install",                        false,                        "disable workflow; install immediately without going through collection's workflow");        options.addOption("t", "type", true, "package type or MIMEtype");        options                .addOption("o", "option", true,                        "Packager option to pass to plugin, \"name=value\" (repeatable)");        options.addOption("d", "disseminate", false,                "Disseminate package (output); default is to submit.");        options.addOption("i", "item", true, "Handle of item to disseminate.");        options.addOption("h", "help", false, "help");        CommandLineParser parser = new PosixParser();        CommandLine line = parser.parse(options, argv);        String sourceFile = null;        String eperson = null;        String[] collections = null;        boolean useWorkflow = true;        String packageType = null;        boolean submit = true;        String itemHandle = null;        PackageParameters pkgParams = new PackageParameters();        if (line.hasOption('h'))        {            HelpFormatter myhelp = new HelpFormatter();            myhelp.printHelp("Packager  [options]  package-file|-\n",                    options);            System.out.println("\nAvailable Submission Package (SIP) types:");            String pn[] = PluginManager                    .getAllPluginNames(PackageIngester.class);            for (int i = 0; i < pn.length; ++i)                System.out.println("  " + pn[i]);            System.out                    .println("\nAvailable Dissemination Package (DIP) types:");            pn = PluginManager.getAllPluginNames(PackageDisseminator.class);            for (int i = 0; i < pn.length; ++i)                System.out.println("  " + pn[i]);            System.exit(0);        }        if (line.hasOption('w'))            useWorkflow = false;        if (line.hasOption('e'))            eperson = line.getOptionValue('e');        if (line.hasOption('c'))            collections = line.getOptionValues('c');        if (line.hasOption('t'))            packageType = line.getOptionValue('t');        if (line.hasOption('i'))            itemHandle = line.getOptionValue('i');        String files[] = line.getArgs();        if (files.length > 0)            sourceFile = files[0];        if (line.hasOption('d'))            submit = false;        if (line.hasOption('o'))        {            String popt[] = line.getOptionValues('o');            for (int i = 0; i < popt.length; ++i)            {                String pair[] = popt[i].split("\\=", 2);                if (pair.length == 2)                    pkgParams.addProperty(pair[0].trim(), pair[1].trim());                else if (pair.length == 1)                    pkgParams.addProperty(pair[0].trim(), "");                else                    System.err                            .println("Warning: Illegal package option format: \""                                    + popt[i] + "\"");            }        }        // Sanity checks on arg list: required args        if (sourceFile == null || eperson == null || packageType == null                || (submit && collections == null))        {            System.err                    .println("Error - missing a REQUIRED argument or option.\n");            HelpFormatter myhelp = new HelpFormatter();            myhelp.printHelp("PackageManager  [options]  package-file|-\n",                    options);            System.exit(0);        }        // find the EPerson, assign to context        Context context = new Context();        EPerson myEPerson = null;        myEPerson = EPerson.findByEmail(context, eperson);        if (myEPerson == null)            usageError("Error, eperson cannot be found: " + eperson);        context.setCurrentUser(myEPerson);        if (submit)        {            // make sure we have an input file            InputStream source = (sourceFile.equals("-")) ? System.in                    : new FileInputStream(sourceFile);            PackageIngester sip = (PackageIngester) PluginManager                    .getNamedPlugin(PackageIngester.class, packageType);            if (sip == null)                usageError("Error, Unknown package type: " + packageType);            // find collections            Collection[] mycollections = null;            System.out.println("Destination collections:");            // validate each collection arg to see if it's a real collection            mycollections = new Collection[collections.length];            for (int i = 0; i < collections.length; i++)            {                // sanity check: did handle resolve, and to a collection?                DSpaceObject dso = HandleManager.resolveToObject(context,                        collections[i]);                if (dso == null)                    throw new IllegalArgumentException(                            "Bad collection list -- "                                    + "Cannot resolve collection handle \""                                    + collections[i] + "\"");                else if (dso.getType() != Constants.COLLECTION)                    throw new IllegalArgumentException(                            "Bad collection list -- " + "Object at handle \""                                    + collections[i]                                    + "\" is not a collection!");                mycollections[i] = (Collection) dso;                System.out.println((i == 0 ? "  Owning " : "  ")                        + " Collection: "                        + mycollections[i].getMetadata("name"));            }            try            {                WorkspaceItem wi = sip.ingest(context, mycollections[0],                        source, pkgParams, null);                if (useWorkflow)                {                    WorkflowManager.startWithoutNotify(context, wi);                    System.out.println("Created Workflow item, ID="                            + String.valueOf(wi.getID()));                }                else                {                    InstallItem.installItem(context, wi);                    System.out.println("Created and installed item, handle="                            + HandleManager.findHandle(context, wi.getItem()));                }                context.complete();                System.exit(0);            }            catch (Exception e)            {                // abort all operations                context.abort();                e.printStackTrace();                System.out.println(e);            }        }        else        {            OutputStream dest = (sourceFile.equals("-")) ? (OutputStream) System.out                    : (OutputStream) (new FileOutputStream(sourceFile));            PackageDisseminator dip = (PackageDisseminator) PluginManager                    .getNamedPlugin(PackageDisseminator.class, packageType);            if (dip == null)                usageError("Error, Unknown package type: " + packageType);            DSpaceObject dso = HandleManager.resolveToObject(context,                    itemHandle);            if (dso == null)                throw new IllegalArgumentException("Bad Item handle -- "                        + "Cannot resolve handle \"" + itemHandle);            dip.disseminate(context, dso, pkgParams, dest);        }    }