Merged in CST-12864-notifyservice-unique-ldnurl (pull request #1430)

CST-12864 notifyservice unique ldnurl
This commit is contained in:
Francesco Bacchelli
2023-12-11 11:10:48 +00:00
5 changed files with 40 additions and 1 deletions

View File

@@ -0,0 +1,14 @@
--
-- The contents of this file are subject to the license and copyright
-- detailed in the LICENSE and NOTICE files at the root of the source
-- tree and available online at
--
-- http://www.dspace.org/license/
--
-----------------------------------------------------------------------------------
-- ADD CONSTRAINT on notifyservice table: ldn_url as unique
-----------------------------------------------------------------------------------
ALTER TABLE notifyservice ADD CONSTRAINT ldn_url_unique UNIQUE (ldn_url);

View File

@@ -0,0 +1,14 @@
--
-- The contents of this file are subject to the license and copyright
-- detailed in the LICENSE and NOTICE files at the root of the source
-- tree and available online at
--
-- http://www.dspace.org/license/
--
-----------------------------------------------------------------------------------
-- ADD CONSTRAINT on notifyservice table: ldn_url as unique
-----------------------------------------------------------------------------------
ALTER TABLE notifyservice ADD CONSTRAINT ldn_url_unique UNIQUE (ldn_url);

View File

@@ -106,6 +106,11 @@ public class NotifyServiceRestRepository extends DSpaceRestRepository<NotifyServ
} }
} }
if (notifyService.findByLdnUrl(context,notifyServiceRest.getLdnUrl()) != null) {
throw new UnprocessableEntityException(format("LDN url already in use %s",
notifyServiceRest.getLdnUrl()));
}
NotifyServiceEntity notifyServiceEntity = notifyService.create(context); NotifyServiceEntity notifyServiceEntity = notifyService.create(context);
notifyServiceEntity.setName(notifyServiceRest.getName()); notifyServiceEntity.setName(notifyServiceRest.getName());
notifyServiceEntity.setDescription(notifyServiceRest.getDescription()); notifyServiceEntity.setDescription(notifyServiceRest.getDescription());

View File

@@ -7,6 +7,8 @@
*/ */
package org.dspace.app.rest.repository.patch.operation.ldn; package org.dspace.app.rest.repository.patch.operation.ldn;
import static java.lang.String.format;
import java.sql.SQLException; import java.sql.SQLException;
import org.dspace.app.ldn.NotifyServiceEntity; import org.dspace.app.ldn.NotifyServiceEntity;
@@ -50,6 +52,11 @@ public class NotifyServiceLdnUrlReplaceOperation extends PatchOperation<NotifySe
throw new UnprocessableEntityException("The /ldnurl value must be a string"); throw new UnprocessableEntityException("The /ldnurl value must be a string");
} }
if (notifyService.findByLdnUrl(context,(String) ldnUrl) != null) {
throw new UnprocessableEntityException(format("LDN url already in use %s",
(String) ldnUrl));
}
checkModelForExistingValue(notifyServiceEntity); checkModelForExistingValue(notifyServiceEntity);
notifyServiceEntity.setLdnUrl((String) ldnUrl); notifyServiceEntity.setLdnUrl((String) ldnUrl);
notifyService.update(context, notifyServiceEntity); notifyService.update(context, notifyServiceEntity);

View File

@@ -780,7 +780,6 @@ event.dispatcher.default.class = org.dspace.event.BasicDispatcher
# Add rdf here, if you are using dspace-rdf to export your repository content as RDF. # Add rdf here, if you are using dspace-rdf to export your repository content as RDF.
# Add iiif here, if you are using dspace-iiif. # Add iiif here, if you are using dspace-iiif.
# Add orcidqueue here, if the integration with ORCID is configured and wish to enable the synchronization queue functionality # Add orcidqueue here, if the integration with ORCID is configured and wish to enable the synchronization queue functionality
event.dispatcher.default.consumers = versioning, discovery, eperson, submissionconfig, qaeventsdelete, ldnmessage event.dispatcher.default.consumers = versioning, discovery, eperson, submissionconfig, qaeventsdelete, ldnmessage
# The noindex dispatcher will not create search or browse indexes (useful for batch item imports) # The noindex dispatcher will not create search or browse indexes (useful for batch item imports)