mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
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:
@@ -362,6 +362,34 @@ public class WorkspaceItem implements InProgressSubmission
|
|||||||
return wsItems.toArray(new WorkspaceItem[wsItems.size()]);
|
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
|
* Get all workspace items in the whole system
|
||||||
*
|
*
|
||||||
|
@@ -29,6 +29,7 @@ import org.dspace.content.Community;
|
|||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.FormatIdentifier;
|
import org.dspace.content.FormatIdentifier;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
|
import org.dspace.content.WorkspaceItem;
|
||||||
import org.dspace.content.crosswalk.CrosswalkException;
|
import org.dspace.content.crosswalk.CrosswalkException;
|
||||||
import org.dspace.content.crosswalk.MetadataValidationException;
|
import org.dspace.content.crosswalk.MetadataValidationException;
|
||||||
import org.dspace.core.ConfigurationManager;
|
import org.dspace.core.ConfigurationManager;
|
||||||
@@ -36,7 +37,6 @@ import org.dspace.core.Constants;
|
|||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.LogManager;
|
import org.dspace.core.LogManager;
|
||||||
import org.dspace.handle.HandleManager;
|
import org.dspace.handle.HandleManager;
|
||||||
import org.dspace.workflow.WorkflowItem;
|
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -459,24 +459,34 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
manifest.crosswalkObjectOtherAdminMD(context, params, dso, callback);
|
manifest.crosswalkObjectOtherAdminMD(context, params, dso, callback);
|
||||||
|
|
||||||
// -- Step 4 --
|
// -- 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
|
// Add all content files as bitstreams on new DSpace Object
|
||||||
if (type == Constants.ITEM)
|
if (type == Constants.ITEM)
|
||||||
{
|
{
|
||||||
Item item = (Item) dso;
|
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
|
// Get collection this item is being submitted to
|
||||||
Collection collection = item.getOwningCollection();
|
Collection collection = item.getOwningCollection();
|
||||||
if (collection == null)
|
if (collection == null)
|
||||||
{
|
{
|
||||||
// If an item doesn't have an owning-collection, that means it
|
// Get the collection this workspace item belongs to
|
||||||
// has entered a workflow (and is not fully in the archive yet)
|
if (wsi != null)
|
||||||
WorkflowItem wfi = WorkflowItem.findByItem(context, item);
|
|
||||||
|
|
||||||
// Get the collection this workflow item belongs to
|
|
||||||
if (wfi != 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.
|
// have subclass manage license since it may be extra package file.
|
||||||
addLicense(context, item, license, collection, params);
|
addLicense(context, item, license, collection, params);
|
||||||
|
|
||||||
// XXX FIXME
|
// Finally, if item is still in the workspace, then we actually need
|
||||||
// should set lastModifiedTime e.g. when ingesting AIP.
|
// to install it into the archive & assign its handle.
|
||||||
// maybe only do it in the finishObject() callback for AIP.
|
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
|
} // end if ITEM
|
||||||
else if (type == Constants.COLLECTION || type == Constants.COMMUNITY)
|
else if (type == Constants.COLLECTION || type == Constants.COMMUNITY)
|
||||||
@@ -519,17 +534,6 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
+ String.valueOf(type));
|
+ 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 --
|
// -- Step 6 --
|
||||||
// Finish things up!
|
// Finish things up!
|
||||||
|
|
||||||
@@ -635,7 +639,6 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
if (dso.getType() == Constants.ITEM)
|
if (dso.getType() == Constants.ITEM)
|
||||||
{
|
{
|
||||||
Item item = (Item) dso;
|
Item item = (Item) dso;
|
||||||
// @TODO: maybe add an option to apply template Item on ingest??
|
|
||||||
|
|
||||||
// save manifest as a bitstream in Item if desired
|
// save manifest as a bitstream in Item if desired
|
||||||
if (preserveManifest())
|
if (preserveManifest())
|
||||||
|
@@ -345,7 +345,7 @@ public class PackageUtils
|
|||||||
* generic like ".xml", to accidentally get set to this format.
|
* generic like ".xml", to accidentally get set to this format.
|
||||||
* @param context - the context.
|
* @param context - the context.
|
||||||
* @param shortDesc - short descriptive name, used to locate existing format.
|
* @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 desc - long description
|
||||||
* @param internal value for the 'internal' flag of a new format if created.
|
* @param internal value for the 'internal' flag of a new format if created.
|
||||||
* @return BitstreamFormat object that was found or created. Never null.
|
* @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)
|
//(Note: Handle is not set until item is finished)
|
||||||
WorkspaceItem wsi = WorkspaceItem.create(context, (Collection)parent, params.useCollectionTemplate());
|
WorkspaceItem wsi = WorkspaceItem.create(context, (Collection)parent, params.useCollectionTemplate());
|
||||||
|
|
||||||
// Finish creating item with specified handle
|
// Please note that we are returning an Item which is *NOT* yet in the Archive,
|
||||||
// (this will either install item immediately or start a workflow, based on params)
|
// and doesn't yet have a handle assigned.
|
||||||
dso = finishCreateItem(context, wsi, handle, params);
|
// This Item will remain "incomplete" until 'PackageUtils.finishCreateItem()' is called
|
||||||
|
return wsi.getItem();
|
||||||
return dso;
|
|
||||||
|
|
||||||
case Constants.SITE:
|
case Constants.SITE:
|
||||||
return Site.find(context, Site.SITE_ID);
|
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)
|
// default: skip workflow, but otherwise normal submission (i.e. package treated like a SIP)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Intall item immediately with the specified handle
|
// Install item immediately with the specified handle
|
||||||
InstallItem.installItem(context, wsi, handle);
|
InstallItem.installItem(context, wsi, handle);
|
||||||
|
|
||||||
// return newly installed item
|
// return newly installed item
|
||||||
@@ -802,7 +801,7 @@ public class PackageUtils
|
|||||||
* Also see the translateGroupNameForImport() method which does the opposite
|
* Also see the translateGroupNameForImport() method which does the opposite
|
||||||
* of this method.
|
* of this method.
|
||||||
*
|
*
|
||||||
* @param relatedDso DSpaceObject associated with group
|
* @param context current DSpace Context
|
||||||
* @param groupName Group's name
|
* @param groupName Group's name
|
||||||
* @return the group name, with any internal IDs translated to Handles
|
* @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
|
* Also see the translateGroupNameForExport() method which does the opposite
|
||||||
* of this method.
|
* of this method.
|
||||||
*
|
*
|
||||||
* @param relatedDso DSpaceObject associated with group
|
* @param context current DSpace Context
|
||||||
* @param groupName Group's name
|
* @param groupName Group's name
|
||||||
* @return the group name, with any Handles translated to internal IDs
|
* @return the group name, with any Handles translated to internal IDs
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user