mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 05:53:08 +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
|
@Override
|
||||||
public WorkspaceItem create(Context context, Collection collection, boolean template)
|
public WorkspaceItem create(Context context, Collection collection, boolean template)
|
||||||
throws AuthorizeException, SQLException {
|
throws AuthorizeException, SQLException {
|
||||||
return create(context, collection, null, template);
|
return create(context, collection, null, template, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 {
|
throws AuthorizeException, SQLException {
|
||||||
// Check the user has permission to ADD to the collection
|
// Check the user has permission to ADD to the collection
|
||||||
authorizeService.authorizeAction(context, collection, Constants.ADD);
|
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
|
// 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
|
// 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()
|
if (DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||||
.getBooleanProperty("identifiers.submission.register", false)) {
|
.getBooleanProperty("identifiers.submission.register", false) && !isNewVersion) {
|
||||||
try {
|
try {
|
||||||
// Get map of filters to use for identifier types, while the item is in progress
|
// Get map of filters to use for identifier types, while the item is in progress
|
||||||
Map<Class<? extends Identifier>, Filter> filters = FilterUtils.getIdentifierFilters(true);
|
Map<Class<? extends Identifier>, Filter> filters = FilterUtils.getIdentifierFilters(true);
|
||||||
|
@@ -503,7 +503,7 @@ public class PackageUtils {
|
|||||||
wsi = workspaceItemService.create(context, (Collection)parent, params.useCollectionTemplate());
|
wsi = workspaceItemService.create(context, (Collection)parent, params.useCollectionTemplate());
|
||||||
} else {
|
} else {
|
||||||
wsi = workspaceItemService.create(context, (Collection)parent,
|
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,
|
// 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)
|
public WorkspaceItem create(Context context, Collection collection, boolean template)
|
||||||
throws AuthorizeException, SQLException;
|
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
|
* Create a new workspace item, with a new ID. An Item is also created. The
|
||||||
* submitter is the current user in the context.
|
* 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 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
|
* @param template if <code>true</code>, the workspace item starts as a copy
|
||||||
* of the collection's template item
|
* 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
|
* @return the newly created workspace item
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization 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;
|
throws AuthorizeException, SQLException;
|
||||||
|
|
||||||
public WorkspaceItem create(Context c, WorkflowItem wfi) throws SQLException, AuthorizeException;
|
public WorkspaceItem create(Context c, WorkflowItem wfi) throws SQLException, AuthorizeException;
|
||||||
|
@@ -52,7 +52,9 @@ public class DefaultItemVersionProvider extends AbstractVersionProvider implemen
|
|||||||
@Override
|
@Override
|
||||||
public Item createNewItemAndAddItInWorkspace(Context context, Item nativeItem) {
|
public Item createNewItemAndAddItInWorkspace(Context context, Item nativeItem) {
|
||||||
try {
|
try {
|
||||||
WorkspaceItem workspaceItem = workspaceItemService.create(context, nativeItem.getOwningCollection(), false);
|
WorkspaceItem workspaceItem = workspaceItemService.create(context, nativeItem.getOwningCollection(),
|
||||||
|
false,
|
||||||
|
true);
|
||||||
Item itemNew = workspaceItem.getItem();
|
Item itemNew = workspaceItem.getItem();
|
||||||
itemService.update(context, itemNew);
|
itemService.update(context, itemNew);
|
||||||
return itemNew;
|
return itemNew;
|
||||||
|
@@ -159,7 +159,7 @@ public class PackagerIT extends AbstractIntegrationTestWithDatabase {
|
|||||||
performExportScript(article.getHandle(), tempFile);
|
performExportScript(article.getHandle(), tempFile);
|
||||||
UUID id = article.getID();
|
UUID id = article.getID();
|
||||||
itemService.delete(context, article);
|
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");
|
installItemService.installItem(context, workspaceItem, "123456789/0100");
|
||||||
performImportNoForceScript(tempFile);
|
performImportNoForceScript(tempFile);
|
||||||
Iterator<Item> items = itemService.findByCollection(context, col1);
|
Iterator<Item> items = itemService.findByCollection(context, col1);
|
||||||
|
Reference in New Issue
Block a user