DS-821 fix (AbstractMETSIngester creates an item before adding descriptive metadata). This fix essentially reorganizes logic in AbstractMETSIngester.ingestObject(), to ensure that item is not officially *installed* in DSpace until all of the Descriptive Metadata crosswalks and files are attached. See DS-821 for more info. I've tested this fix via both SWORD ingest and via AIP Ingest, and both seem to work perfectly.

git-svn-id: http://scm.dspace.org/svn/repo/dspace/trunk@6136 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Tim Donohue
2011-03-14 19:10:43 +00:00
parent 3790e662f9
commit 03ab1fd6fd
3 changed files with 63 additions and 33 deletions

View File

@@ -362,6 +362,34 @@ public class WorkspaceItem implements InProgressSubmission
return wsItems.toArray(new WorkspaceItem[wsItems.size()]);
}
/**
* Check to see if a particular item is currently still in a user's Workspace.
* If so, its WorkspaceItem is returned. If not, null is returned
*
* @param context
* the context object
* @param i
* the item
*
* @return workflow item corresponding to the item, or null
*/
public static WorkspaceItem findByItem(Context context, Item i)
throws SQLException
{
// Look for the unique workspaceitem entry where 'item_id' references this item
TableRow row = DatabaseManager.findByUnique(context, "workspaceitem", "item_id", i.getID());
if (row == null)
{
return null;
}
else
{
return new WorkspaceItem(context, row);
}
}
/**
* Get all workspace items in the whole system
*

View File

@@ -29,6 +29,7 @@ import org.dspace.content.Community;
import org.dspace.content.DSpaceObject;
import org.dspace.content.FormatIdentifier;
import org.dspace.content.Item;
import org.dspace.content.WorkspaceItem;
import org.dspace.content.crosswalk.CrosswalkException;
import org.dspace.content.crosswalk.MetadataValidationException;
import org.dspace.core.ConfigurationManager;
@@ -36,7 +37,6 @@ import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.handle.HandleManager;
import org.dspace.workflow.WorkflowItem;
import org.jdom.Element;
/**
@@ -459,24 +459,34 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
manifest.crosswalkObjectOtherAdminMD(context, params, dso, callback);
// -- Step 4 --
// Run our Descriptive metadata (dublin core, etc) crosswalks!
crosswalkObjectDmd(context, dso, manifest, callback, manifest
.getItemDmds(), params);
// For Items, also sanity-check the metadata for minimum requirements.
if (type == Constants.ITEM)
{
PackageUtils.checkItemMetadata((Item) dso);
}
// -- Step 5 --
// Add all content files as bitstreams on new DSpace Object
if (type == Constants.ITEM)
{
Item item = (Item) dso;
// @TODO: maybe add an option to apply template Item on ingest??
//Check if this item is still in a user's workspace.
//It should be, as we haven't completed its install yet.
WorkspaceItem wsi = WorkspaceItem.findByItem(context, item);
// Get collection this item is being submitted to
Collection collection = item.getOwningCollection();
if (collection == null)
{
// If an item doesn't have an owning-collection, that means it
// has entered a workflow (and is not fully in the archive yet)
WorkflowItem wfi = WorkflowItem.findByItem(context, item);
// Get the collection this workflow item belongs to
if (wfi != null)
// Get the collection this workspace item belongs to
if (wsi != null)
{
collection = wfi.getCollection();
collection = wsi.getCollection();
}
}
@@ -492,9 +502,14 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
// have subclass manage license since it may be extra package file.
addLicense(context, item, license, collection, params);
// XXX FIXME
// should set lastModifiedTime e.g. when ingesting AIP.
// maybe only do it in the finishObject() callback for AIP.
// Finally, if item is still in the workspace, then we actually need
// to install it into the archive & assign its handle.
if(wsi!=null)
{
// Finish creating the item. This actually assigns the handle,
// and will either install item immediately or start a workflow, based on params
PackageUtils.finishCreateItem(context, wsi, handle, params);
}
} // end if ITEM
else if (type == Constants.COLLECTION || type == Constants.COMMUNITY)
@@ -519,17 +534,6 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
+ String.valueOf(type));
}
// -- Step 5 --
// Run our Descriptive metadata (dublin core, etc) crosswalks!
crosswalkObjectDmd(context, dso, manifest, callback, manifest
.getItemDmds(), params);
// For Items, also sanity-check the metadata for minimum requirements.
if (type == Constants.ITEM)
{
PackageUtils.checkItemMetadata((Item) dso);
}
// -- Step 6 --
// Finish things up!
@@ -635,7 +639,6 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
if (dso.getType() == Constants.ITEM)
{
Item item = (Item) dso;
// @TODO: maybe add an option to apply template Item on ingest??
// save manifest as a bitstream in Item if desired
if (preserveManifest())

View File

@@ -345,7 +345,7 @@ public class PackageUtils
* generic like ".xml", to accidentally get set to this format.
* @param context - the context.
* @param shortDesc - short descriptive name, used to locate existing format.
* @param MIMEtype - mime content-type
* @param MIMEType - mime content-type
* @param desc - long description
* @param internal value for the 'internal' flag of a new format if created.
* @return BitstreamFormat object that was found or created. Never null.
@@ -472,11 +472,10 @@ public class PackageUtils
//(Note: Handle is not set until item is finished)
WorkspaceItem wsi = WorkspaceItem.create(context, (Collection)parent, params.useCollectionTemplate());
// Finish creating item with specified handle
// (this will either install item immediately or start a workflow, based on params)
dso = finishCreateItem(context, wsi, handle, params);
return dso;
// Please note that we are returning an Item which is *NOT* yet in the Archive,
// and doesn't yet have a handle assigned.
// This Item will remain "incomplete" until 'PackageUtils.finishCreateItem()' is called
return wsi.getItem();
case Constants.SITE:
return Site.find(context, Site.SITE_ID);
@@ -528,7 +527,7 @@ public class PackageUtils
// default: skip workflow, but otherwise normal submission (i.e. package treated like a SIP)
else
{
// Intall item immediately with the specified handle
// Install item immediately with the specified handle
InstallItem.installItem(context, wsi, handle);
// return newly installed item
@@ -802,7 +801,7 @@ public class PackageUtils
* Also see the translateGroupNameForImport() method which does the opposite
* of this method.
*
* @param relatedDso DSpaceObject associated with group
* @param context current DSpace Context
* @param groupName Group's name
* @return the group name, with any internal IDs translated to Handles
*/
@@ -886,7 +885,7 @@ public class PackageUtils
* Also see the translateGroupNameForExport() method which does the opposite
* of this method.
*
* @param relatedDso DSpaceObject associated with group
* @param context current DSpace Context
* @param groupName Group's name
* @return the group name, with any Handles translated to internal IDs
*/