CST-12864 notifyservice ldn_url uniqueness backend check

This commit is contained in:
frabacche
2023-12-11 12:01:32 +01:00
parent c0c7216d5c
commit 3ff40f03e1
2 changed files with 12 additions and 0 deletions

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.setName(notifyServiceRest.getName());
notifyServiceEntity.setDescription(notifyServiceRest.getDescription());

View File

@@ -7,6 +7,8 @@
*/
package org.dspace.app.rest.repository.patch.operation.ldn;
import static java.lang.String.format;
import java.sql.SQLException;
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");
}
if (notifyService.findByLdnUrl(context,(String) ldnUrl) != null) {
throw new UnprocessableEntityException(format("LDN url already in use %s",
(String) ldnUrl));
}
checkModelForExistingValue(notifyServiceEntity);
notifyServiceEntity.setLdnUrl((String) ldnUrl);
notifyService.update(context, notifyServiceEntity);