mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Merge pull request #9448 from DSpace/backport-9271-to-dspace-7_x
[Port dspace-7_x] Fix generating versioned identifiers if pre-registration is enabled
This commit is contained in:
@@ -96,11 +96,18 @@ public class WorkspaceItemServiceImpl implements WorkspaceItemService {
|
||||
@Override
|
||||
public WorkspaceItem create(Context context, Collection collection, boolean template)
|
||||
throws AuthorizeException, SQLException {
|
||||
return create(context, collection, null, template);
|
||||
return create(context, collection, null, template, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkspaceItem create(Context context, Collection collection, UUID uuid, boolean template)
|
||||
public WorkspaceItem create(Context context, Collection collection, boolean template, boolean isNewVersion)
|
||||
throws AuthorizeException, SQLException {
|
||||
return create(context, collection, null, template, isNewVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkspaceItem create(Context context, Collection collection, UUID uuid, boolean template,
|
||||
boolean isNewVersion)
|
||||
throws AuthorizeException, SQLException {
|
||||
// Check the user has permission to ADD to the collection
|
||||
authorizeService.authorizeAction(context, collection, Constants.ADD);
|
||||
@@ -174,8 +181,10 @@ public class WorkspaceItemServiceImpl implements WorkspaceItemService {
|
||||
|
||||
// If configured, register identifiers (eg handle, DOI) now. This is typically used with the Show Identifiers
|
||||
// submission step which previews minted handles and DOIs during the submission process. Default: false
|
||||
// Additional check needed: if we are creating a new version of an existing item we skip the identifier
|
||||
// generation here, as this will be performed when the new version is created in VersioningServiceImpl
|
||||
if (DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||
.getBooleanProperty("identifiers.submission.register", false)) {
|
||||
.getBooleanProperty("identifiers.submission.register", false) && !isNewVersion) {
|
||||
try {
|
||||
// Get map of filters to use for identifier types, while the item is in progress
|
||||
Map<Class<? extends Identifier>, Filter> filters = FilterUtils.getIdentifierFilters(true);
|
||||
|
@@ -503,7 +503,7 @@ public class PackageUtils {
|
||||
wsi = workspaceItemService.create(context, (Collection)parent, params.useCollectionTemplate());
|
||||
} else {
|
||||
wsi = workspaceItemService.create(context, (Collection)parent,
|
||||
uuid, params.useCollectionTemplate());
|
||||
uuid, params.useCollectionTemplate(), false);
|
||||
}
|
||||
|
||||
// Please note that we are returning an Item which is *NOT* yet in the Archive,
|
||||
|
@@ -56,6 +56,23 @@ public interface WorkspaceItemService extends InProgressSubmissionService<Worksp
|
||||
public WorkspaceItem create(Context context, Collection collection, boolean template)
|
||||
throws AuthorizeException, SQLException;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new workspace item, with a new ID. An Item is also created. The
|
||||
* submitter is the current user in the context.
|
||||
*
|
||||
* @param context DSpace context object
|
||||
* @param collection Collection being submitted to
|
||||
* @param template if <code>true</code>, the workspace item starts as a copy
|
||||
* of the collection's template item
|
||||
* @param isNewVersion whether we are creating a new workspace item version of an existing item
|
||||
* @return the newly created workspace item
|
||||
* @throws SQLException if database error
|
||||
* @throws AuthorizeException if authorization error
|
||||
*/
|
||||
public WorkspaceItem create(Context context, Collection collection, boolean template, boolean isNewVersion)
|
||||
throws AuthorizeException, SQLException;
|
||||
|
||||
/**
|
||||
* Create a new workspace item, with a new ID. An Item is also created. The
|
||||
* submitter is the current user in the context.
|
||||
@@ -65,11 +82,13 @@ public interface WorkspaceItemService extends InProgressSubmissionService<Worksp
|
||||
* @param uuid the preferred uuid of the new item (used if restoring an item and retaining old uuid)
|
||||
* @param template if <code>true</code>, the workspace item starts as a copy
|
||||
* of the collection's template item
|
||||
* @param isNewVersion whether we are creating a new workspace item version of an existing item
|
||||
* @return the newly created workspace item
|
||||
* @throws SQLException if database error
|
||||
* @throws AuthorizeException if authorization error
|
||||
*/
|
||||
public WorkspaceItem create(Context context, Collection collection, UUID uuid, boolean template)
|
||||
public WorkspaceItem create(Context context, Collection collection, UUID uuid, boolean template,
|
||||
boolean isNewVersion)
|
||||
throws AuthorizeException, SQLException;
|
||||
|
||||
public WorkspaceItem create(Context c, WorkflowItem wfi) throws SQLException, AuthorizeException;
|
||||
|
@@ -52,7 +52,9 @@ public class DefaultItemVersionProvider extends AbstractVersionProvider implemen
|
||||
@Override
|
||||
public Item createNewItemAndAddItInWorkspace(Context context, Item nativeItem) {
|
||||
try {
|
||||
WorkspaceItem workspaceItem = workspaceItemService.create(context, nativeItem.getOwningCollection(), false);
|
||||
WorkspaceItem workspaceItem = workspaceItemService.create(context, nativeItem.getOwningCollection(),
|
||||
false,
|
||||
true);
|
||||
Item itemNew = workspaceItem.getItem();
|
||||
itemService.update(context, itemNew);
|
||||
return itemNew;
|
||||
|
@@ -159,7 +159,7 @@ public class PackagerIT extends AbstractIntegrationTestWithDatabase {
|
||||
performExportScript(article.getHandle(), tempFile);
|
||||
UUID id = article.getID();
|
||||
itemService.delete(context, article);
|
||||
WorkspaceItem workspaceItem = workspaceItemService.create(context, col1, id, false);
|
||||
WorkspaceItem workspaceItem = workspaceItemService.create(context, col1, id, false, false);
|
||||
installItemService.installItem(context, workspaceItem, "123456789/0100");
|
||||
performImportNoForceScript(tempFile);
|
||||
Iterator<Item> items = itemService.findByCollection(context, col1);
|
||||
|
Reference in New Issue
Block a user