String itemname, PrintWriter mapOut) throws Exception
String itemname, PrintWriter mapOut, boolean template) throws Exception
    private Item addItem(Context c, Collection[] mycollections, String path,            String itemname, PrintWriter mapOut) throws Exception    {        String mapOutput = null;        System.out.println("Adding item from directory " + itemname);        // create workspace item        Item myitem = null;        WorkspaceItem wi = null;        if (!isTest)        {            wi = WorkspaceItem.create(c, mycollections[0], false);            myitem = wi.getItem();        }        // now fill out dublin core for item        loadMetadata(c, myitem, path + File.separatorChar + itemname                + File.separatorChar);        // and the bitstreams from the contents file        // process contents file, add bistreams and bundles        processContentsFile(c, myitem, path + File.separatorChar + itemname,                "contents");        if (useWorkflow)        {            // don't process handle file            // start up a workflow            if (!isTest)            {                WorkflowManager.startWithoutNotify(c, wi);                // send ID to the mapfile                mapOutput = itemname + " " + myitem.getID();            }        }        else        {            // only process handle file if not using workflow system            String myhandle = processHandleFile(c, myitem, path                    + File.separatorChar + itemname, "handle");            // put item in system            if (!isTest)            {                InstallItem.installItem(c, wi, myhandle);                // find the handle, and output to map file                myhandle = HandleManager.findHandle(c, myitem);                mapOutput = itemname + " " + myhandle;            }        }        // now add to multiple collections if requested        if (mycollections.length > 1)        {            for (int i = 1; i < mycollections.length; i++)            {                if (!isTest)                {                    mycollections[i].addItem(myitem);                }            }        }        // made it this far, everything is fine, commit transaction        if (mapOut != null)        {            mapOut.println(mapOutput);        }        c.commit();        return myitem;    }