Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring
This commit is contained in:
commit
1941500034
|
@ -51,12 +51,12 @@
|
|||
<dependency>
|
||||
<groupId>org.opencdmp</groupId>
|
||||
<artifactId>repositorydepositbase</artifactId>
|
||||
<version>2.0.12</version>
|
||||
<version>2.0.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.opencdmp</groupId>
|
||||
<artifactId>common-models</artifactId>
|
||||
<version>0.0.15</version>
|
||||
<version>0.0.16</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gr.cite</groupId>
|
||||
|
@ -66,7 +66,7 @@
|
|||
<dependency>
|
||||
<groupId>org.opencdmp</groupId>
|
||||
<artifactId>file-transformer-base</artifactId>
|
||||
<version>0.0.19</version>
|
||||
<version>0.0.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gr.cite</groupId>
|
||||
|
|
|
@ -323,7 +323,7 @@ public class DepositServiceImpl implements DepositService {
|
|||
doiPersist.setDoi(doi);
|
||||
doiPersist.setEntityId(dmpEntity.getId());
|
||||
this.sendNotification(dmpEntity);
|
||||
return this.doiService.persist(doiPersist, dmpDepositModel.getProject());
|
||||
return this.doiService.persist(doiPersist, true, dmpDepositModel.getProject());
|
||||
}
|
||||
|
||||
private void sendNotification(DmpEntity dmpEntity) throws InvalidApplicationException {
|
||||
|
|
|
@ -1,21 +1,19 @@
|
|||
package org.opencdmp.service.entitydoi;
|
||||
|
||||
import org.opencdmp.model.DescriptionTemplateType;
|
||||
import org.opencdmp.model.EntityDoi;
|
||||
import org.opencdmp.model.persist.DescriptionTemplateTypePersist;
|
||||
import org.opencdmp.model.persist.EntityDoiPersist;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.exception.MyForbiddenException;
|
||||
import gr.cite.tools.exception.MyNotFoundException;
|
||||
import gr.cite.tools.exception.MyValidationException;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import org.opencdmp.model.EntityDoi;
|
||||
import org.opencdmp.model.persist.EntityDoiPersist;
|
||||
|
||||
import javax.management.InvalidApplicationException;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface EntityDoiService {
|
||||
|
||||
EntityDoi persist(EntityDoiPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException;
|
||||
EntityDoi persist(EntityDoiPersist model, boolean disableAuthorization, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException;
|
||||
|
||||
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;
|
||||
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
package org.opencdmp.service.entitydoi;
|
||||
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.exception.MyForbiddenException;
|
||||
import gr.cite.tools.exception.MyNotFoundException;
|
||||
import gr.cite.tools.exception.MyValidationException;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import org.opencdmp.authorization.AuthorizationFlags;
|
||||
import org.opencdmp.authorization.Permission;
|
||||
import org.opencdmp.commons.enums.EntityType;
|
||||
|
@ -14,17 +25,6 @@ import org.opencdmp.model.EntityDoi;
|
|||
import org.opencdmp.model.builder.EntityDoiBuilder;
|
||||
import org.opencdmp.model.deleter.EntityDoiDeleter;
|
||||
import org.opencdmp.model.persist.EntityDoiPersist;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.builder.BuilderFactory;
|
||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||
import gr.cite.tools.exception.MyApplicationException;
|
||||
import gr.cite.tools.exception.MyForbiddenException;
|
||||
import gr.cite.tools.exception.MyNotFoundException;
|
||||
import gr.cite.tools.exception.MyValidationException;
|
||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||
import gr.cite.tools.fieldset.FieldSet;
|
||||
import gr.cite.tools.logging.LoggerService;
|
||||
import gr.cite.tools.logging.MapLogEntry;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
|
@ -77,17 +77,17 @@ public class EntityDoiServiceImpl implements EntityDoiService {
|
|||
this.eventBroker = eventBroker;
|
||||
}
|
||||
|
||||
public EntityDoi persist(EntityDoiPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException {
|
||||
public EntityDoi persist(EntityDoiPersist model, boolean disableAuthorization, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException {
|
||||
logger.debug(new MapLogEntry("persisting data EntityDoi").And("model", model).And("fields", fields));
|
||||
|
||||
this.authorizationService.authorizeForce(Permission.EditEntityDoi);
|
||||
if (!disableAuthorization) this.authorizationService.authorizeForce(Permission.EditEntityDoi);
|
||||
|
||||
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
|
||||
|
||||
EntityDoiEntity data;
|
||||
if (isUpdate) {
|
||||
data = this.entityManager.find(EntityDoiEntity.class, model.getId());
|
||||
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), EntityDoi.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), EntityDoi.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
||||
} else {
|
||||
data = new EntityDoiEntity();
|
||||
|
|
|
@ -105,7 +105,7 @@ public class EntityDoiController {
|
|||
@ValidationFilterAnnotation(validator = EntityDoiPersist.EntityDoiPersistValidator.ValidatorName, argumentName = "model")
|
||||
public EntityDoi Persist(@RequestBody EntityDoiPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
|
||||
logger.debug(new MapLogEntry("persisting" + DescriptionTemplateType.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||
EntityDoi persisted = this.entityDoiService.persist(model, fieldSet);
|
||||
EntityDoi persisted = this.entityDoiService.persist(model, false, fieldSet);
|
||||
|
||||
this.auditService.track(AuditableAction.EntityDoi_Persist, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("model", model),
|
||||
|
|
Loading…
Reference in New Issue