Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring
# Conflicts: # dmp-frontend/src/assets/i18n/en.json
This commit is contained in:
commit
e7cb7f44d3
|
@ -42,9 +42,10 @@ queue:
|
||||||
options:
|
options:
|
||||||
exchange: null
|
exchange: null
|
||||||
tenant-removal-topic: tenant.remove
|
tenant-removal-topic: tenant.remove
|
||||||
tenant-touched-topic: tenant.touch
|
tenant-touch-topic: tenant.touch
|
||||||
user-removal-topic: user.remove
|
user-removal-topic: user.remove
|
||||||
user-touched-topic: user.touch
|
user-touch-topic: user.touch
|
||||||
|
annotation-entity-touch-topic: annotation.entity.touch
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
enable: false
|
enable: false
|
||||||
interval-seconds: 30
|
interval-seconds: 30
|
||||||
|
|
|
@ -51,4 +51,9 @@ public class AuditableAction {
|
||||||
public static final EventId Annotation_Persist = new EventId(24002, "Annotation_Persist");
|
public static final EventId Annotation_Persist = new EventId(24002, "Annotation_Persist");
|
||||||
public static final EventId Annotation_Delete = new EventId(24003, "Annotation_Delete");
|
public static final EventId Annotation_Delete = new EventId(24003, "Annotation_Delete");
|
||||||
|
|
||||||
|
public static final EventId Entity_User_Query = new EventId(25000, "Entity_User_Query");
|
||||||
|
public static final EventId Entity_User_Lookup = new EventId(25001, "Entity_User_Lookup");
|
||||||
|
public static final EventId Entity_User_Persist = new EventId(25002, "Entity_User_Persist");
|
||||||
|
public static final EventId Entity_User_Delete = new EventId(25003, "Entity_User_Delete");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package gr.cite.annotation.common.validation;
|
||||||
|
|
||||||
|
import gr.cite.annotation.convention.ConventionService;
|
||||||
|
import gr.cite.annotation.errorcode.ErrorThesaurusProperties;
|
||||||
|
import gr.cite.annotation.integrationevent.inbox.annotationentitytouch.AnnotationEntityTouchedIntegrationEvent;
|
||||||
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component(UuidValidator.ValidatorName)
|
||||||
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class UuidValidator extends BaseValidator<UUID> {
|
||||||
|
|
||||||
|
public static final String ValidatorName = "UuidValidator";
|
||||||
|
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
|
protected UuidValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource) {
|
||||||
|
super(conventionService, errors);
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<UUID> modelClass() {
|
||||||
|
return UUID.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Specification> specifications(UUID item) {
|
||||||
|
return Arrays.asList(
|
||||||
|
this.spec()
|
||||||
|
.must(() -> this.isValidGuid(item))
|
||||||
|
.failOn("uuid").failWith(messageSource.getMessage("Validation_Required", new Object[]{"uuid"}, LocaleContextHolder.getLocale()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,6 @@ public class AnnotationEntity {
|
||||||
|
|
||||||
public static final String _id = "id";
|
public static final String _id = "id";
|
||||||
|
|
||||||
@Id
|
|
||||||
@Column(name = "entity_id", columnDefinition = "uuid", nullable = false)
|
@Column(name = "entity_id", columnDefinition = "uuid", nullable = false)
|
||||||
private UUID entityId;
|
private UUID entityId;
|
||||||
|
|
||||||
|
|
|
@ -12,19 +12,17 @@ import java.util.UUID;
|
||||||
public class EntityUserEntity {
|
public class EntityUserEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
@Column(name = "\"id\"", columnDefinition = "uuid", updatable = false, nullable = false)
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
public static final String _id = "id";
|
public static final String _id = "id";
|
||||||
|
|
||||||
@Id
|
@Column(name = "\"entity_id\"", columnDefinition = "uuid", nullable = false)
|
||||||
@Column(name = "id", columnDefinition = "uuid", nullable = false)
|
|
||||||
private UUID entityId;
|
private UUID entityId;
|
||||||
|
|
||||||
public static final String _entityId = "entityId";
|
public static final String _entityId = "entityId";
|
||||||
|
|
||||||
@Id
|
@Column(name = "\"user_id\"", columnDefinition = "uuid", nullable = false)
|
||||||
@Column(name = "id", columnDefinition = "uuid", nullable = false)
|
|
||||||
private UUID userId;
|
private UUID userId;
|
||||||
|
|
||||||
public static final String _userId = "userId";
|
public static final String _userId = "userId";
|
||||||
|
|
|
@ -33,9 +33,10 @@ public class AppRabbitConfigurer extends RabbitConfigurer {
|
||||||
public InboxBindings inboxBindingsCreator() {
|
public InboxBindings inboxBindingsCreator() {
|
||||||
List<String> bindingItems = new ArrayList<>();
|
List<String> bindingItems = new ArrayList<>();
|
||||||
bindingItems.addAll(this.inboxProperties.getTenantRemovalTopic());
|
bindingItems.addAll(this.inboxProperties.getTenantRemovalTopic());
|
||||||
bindingItems.addAll(this.inboxProperties.getTenantTouchedTopic());
|
bindingItems.addAll(this.inboxProperties.getTenantTouchTopic());
|
||||||
bindingItems.addAll(this.inboxProperties.getUserRemovalTopic());
|
bindingItems.addAll(this.inboxProperties.getUserRemovalTopic());
|
||||||
bindingItems.addAll(this.inboxProperties.getUserTouchedTopic());
|
bindingItems.addAll(this.inboxProperties.getUserTouchTopic());
|
||||||
|
bindingItems.addAll(this.inboxProperties.getAnnotationEntityTouchTopic());
|
||||||
|
|
||||||
return new InboxBindings(bindingItems);
|
return new InboxBindings(bindingItems);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,39 +11,47 @@ public class InboxProperties {
|
||||||
|
|
||||||
private final List<String> tenantRemovalTopic;
|
private final List<String> tenantRemovalTopic;
|
||||||
|
|
||||||
private final List<String> tenantTouchedTopic;
|
private final List<String> tenantTouchTopic;
|
||||||
|
|
||||||
private final List<String> userRemovalTopic;
|
private final List<String> userRemovalTopic;
|
||||||
|
|
||||||
private final List<String> userTouchedTopic;
|
private final List<String> userTouchTopic;
|
||||||
|
|
||||||
|
private final List<String> annotationEntityTouchTopic;
|
||||||
|
|
||||||
public InboxProperties(
|
public InboxProperties(
|
||||||
String exchange,
|
String exchange,
|
||||||
List<String> tenantRemovalTopic,
|
List<String> tenantRemovalTopic,
|
||||||
List<String> tenantTouchedTopic,
|
List<String> tenantTouchTopic,
|
||||||
List<String> userRemovalTopic,
|
List<String> userRemovalTopic,
|
||||||
List<String> userTouchedTopic) {
|
List<String> userTouchTopic,
|
||||||
|
List<String> annotationEntityTouchTopic) {
|
||||||
this.exchange = exchange;
|
this.exchange = exchange;
|
||||||
this.tenantRemovalTopic = tenantRemovalTopic;
|
this.tenantRemovalTopic = tenantRemovalTopic;
|
||||||
this.tenantTouchedTopic = tenantTouchedTopic;
|
this.tenantTouchTopic = tenantTouchTopic;
|
||||||
this.userRemovalTopic = userRemovalTopic;
|
this.userRemovalTopic = userRemovalTopic;
|
||||||
this.userTouchedTopic = userTouchedTopic;
|
this.userTouchTopic = userTouchTopic;
|
||||||
|
this.annotationEntityTouchTopic = annotationEntityTouchTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getTenantRemovalTopic() {
|
public List<String> getTenantRemovalTopic() {
|
||||||
return tenantRemovalTopic;
|
return tenantRemovalTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getTenantTouchedTopic() {
|
public List<String> getTenantTouchTopic() {
|
||||||
return tenantTouchedTopic;
|
return tenantTouchTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getUserRemovalTopic() {
|
public List<String> getUserRemovalTopic() {
|
||||||
return userRemovalTopic;
|
return userRemovalTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getUserTouchedTopic() {
|
public List<String> getUserTouchTopic() {
|
||||||
return userTouchedTopic;
|
return userTouchTopic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getAnnotationEntityTouchTopic() {
|
||||||
|
return annotationEntityTouchTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getExchange() {
|
public String getExchange() {
|
||||||
|
|
|
@ -5,10 +5,11 @@ import gr.cite.annotation.common.enums.IsActive;
|
||||||
import gr.cite.annotation.common.scope.fake.FakeRequestScope;
|
import gr.cite.annotation.common.scope.fake.FakeRequestScope;
|
||||||
import gr.cite.annotation.data.QueueInboxEntity;
|
import gr.cite.annotation.data.QueueInboxEntity;
|
||||||
import gr.cite.annotation.integrationevent.TrackedEvent;
|
import gr.cite.annotation.integrationevent.TrackedEvent;
|
||||||
|
import gr.cite.annotation.integrationevent.inbox.annotationentitytouch.AnnotationEntityTouchedIntegrationEventHandler;
|
||||||
import gr.cite.annotation.integrationevent.inbox.tenantremoval.TenantRemovalIntegrationEventHandler;
|
import gr.cite.annotation.integrationevent.inbox.tenantremoval.TenantRemovalIntegrationEventHandler;
|
||||||
import gr.cite.annotation.integrationevent.inbox.tenanttouched.TenantTouchedIntegrationEventHandler;
|
import gr.cite.annotation.integrationevent.inbox.tenanttouch.TenantTouchedIntegrationEventHandler;
|
||||||
import gr.cite.annotation.integrationevent.inbox.userremoval.UserRemovalIntegrationEventHandler;
|
import gr.cite.annotation.integrationevent.inbox.userremoval.UserRemovalIntegrationEventHandler;
|
||||||
import gr.cite.annotation.integrationevent.inbox.usertouched.UserTouchedIntegrationEventHandler;
|
import gr.cite.annotation.integrationevent.inbox.usertouch.UserTouchedIntegrationEventHandler;
|
||||||
import gr.cite.annotation.query.QueueInboxQuery;
|
import gr.cite.annotation.query.QueueInboxQuery;
|
||||||
import gr.cite.queueinbox.entity.QueueInbox;
|
import gr.cite.queueinbox.entity.QueueInbox;
|
||||||
import gr.cite.queueinbox.entity.QueueInboxStatus;
|
import gr.cite.queueinbox.entity.QueueInboxStatus;
|
||||||
|
@ -325,12 +326,14 @@ public class InboxRepositoryImpl implements InboxRepository {
|
||||||
logger.debug("Processing message with routing key '{}'", routingKey);
|
logger.debug("Processing message with routing key '{}'", routingKey);
|
||||||
if (this.routingKeyMatched(routingKey, this.inboxProperties.getTenantRemovalTopic()))
|
if (this.routingKeyMatched(routingKey, this.inboxProperties.getTenantRemovalTopic()))
|
||||||
handler = this.applicationContext.getBean(TenantRemovalIntegrationEventHandler.class);
|
handler = this.applicationContext.getBean(TenantRemovalIntegrationEventHandler.class);
|
||||||
else if (this.routingKeyMatched(routingKey, this.inboxProperties.getTenantTouchedTopic()))
|
else if (this.routingKeyMatched(routingKey, this.inboxProperties.getTenantTouchTopic()))
|
||||||
handler = this.applicationContext.getBean(TenantTouchedIntegrationEventHandler.class);
|
handler = this.applicationContext.getBean(TenantTouchedIntegrationEventHandler.class);
|
||||||
else if (this.routingKeyMatched(routingKey, this.inboxProperties.getUserRemovalTopic()))
|
else if (this.routingKeyMatched(routingKey, this.inboxProperties.getUserRemovalTopic()))
|
||||||
handler = this.applicationContext.getBean(UserRemovalIntegrationEventHandler.class);
|
handler = this.applicationContext.getBean(UserRemovalIntegrationEventHandler.class);
|
||||||
else if (this.routingKeyMatched(routingKey, this.inboxProperties.getUserTouchedTopic()))
|
else if (this.routingKeyMatched(routingKey, this.inboxProperties.getUserTouchTopic()))
|
||||||
handler = this.applicationContext.getBean(UserTouchedIntegrationEventHandler.class);
|
handler = this.applicationContext.getBean(UserTouchedIntegrationEventHandler.class);
|
||||||
|
else if (this.routingKeyMatched(routingKey, this.inboxProperties.getAnnotationEntityTouchTopic()))
|
||||||
|
handler = this.applicationContext.getBean(AnnotationEntityTouchedIntegrationEventHandler.class);
|
||||||
else {
|
else {
|
||||||
logger.error("No handler found for message routing key '{}'. Discarding.", routingKey);
|
logger.error("No handler found for message routing key '{}'. Discarding.", routingKey);
|
||||||
handler = null;
|
handler = null;
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
package gr.cite.annotation.integrationevent.inbox.annotationentitytouch;
|
||||||
|
|
||||||
|
import gr.cite.annotation.common.validation.BaseValidator;
|
||||||
|
import gr.cite.annotation.common.validation.UuidValidator;
|
||||||
|
import gr.cite.annotation.convention.ConventionService;
|
||||||
|
import gr.cite.annotation.errorcode.ErrorThesaurusProperties;
|
||||||
|
import gr.cite.annotation.integrationevent.TrackedEvent;
|
||||||
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class AnnotationEntityTouchedIntegrationEvent extends TrackedEvent {
|
||||||
|
|
||||||
|
private UUID entityId;
|
||||||
|
|
||||||
|
public static final String _entityId = "entityId";
|
||||||
|
|
||||||
|
private List<UUID> userIds;
|
||||||
|
|
||||||
|
public static final String _userIds = "userIds";
|
||||||
|
|
||||||
|
public UUID getEntityId() {
|
||||||
|
return entityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntityId(UUID entityId) {
|
||||||
|
this.entityId = entityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getUserIds() {
|
||||||
|
return userIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserIds(List<UUID> userIds) {
|
||||||
|
this.userIds = userIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component(AnnotationEntityTouchedIntegrationEvent.AnnotationEntityTouchedIntegrationEventValidator.ValidatorName)
|
||||||
|
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public static class AnnotationEntityTouchedIntegrationEventValidator extends BaseValidator<AnnotationEntityTouchedIntegrationEvent> {
|
||||||
|
|
||||||
|
public static final String ValidatorName = "AnnotationEntityTouchedIntegrationEventValidator";
|
||||||
|
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
|
private final ValidatorFactory validatorFactory;
|
||||||
|
|
||||||
|
protected AnnotationEntityTouchedIntegrationEventValidator(ConventionService conventionService, ErrorThesaurusProperties errors, MessageSource messageSource, ValidatorFactory validatorFactory) {
|
||||||
|
super(conventionService, errors);
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
this.validatorFactory = validatorFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<AnnotationEntityTouchedIntegrationEvent> modelClass() {
|
||||||
|
return AnnotationEntityTouchedIntegrationEvent.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<Specification> specifications(AnnotationEntityTouchedIntegrationEvent item) {
|
||||||
|
return Arrays.asList(
|
||||||
|
this.spec()
|
||||||
|
.iff(() -> !this.isNull(item.getEntityId()))
|
||||||
|
.must(() -> this.isValidGuid(item.getEntityId()))
|
||||||
|
.failOn(AnnotationEntityTouchedIntegrationEvent._entityId).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationEntityTouchedIntegrationEvent._entityId}, LocaleContextHolder.getLocale())),
|
||||||
|
this.spec()
|
||||||
|
.must(() -> !this.isListNullOrEmpty(item.getUserIds()))
|
||||||
|
.failOn(AnnotationEntityTouchedIntegrationEvent._userIds).failWith(messageSource.getMessage("Validation_Required", new Object[]{AnnotationEntityTouchedIntegrationEvent._userIds}, LocaleContextHolder.getLocale())),
|
||||||
|
this.navSpec()
|
||||||
|
.iff(() -> !this.isListNullOrEmpty(item.getUserIds()))
|
||||||
|
.on(AnnotationEntityTouchedIntegrationEvent._userIds)
|
||||||
|
.over(item.getUserIds())
|
||||||
|
.using((i) -> this.validatorFactory.validator(UuidValidator.class))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package gr.cite.annotation.integrationevent.inbox.annotationentitytouch;
|
||||||
|
|
||||||
|
import gr.cite.annotation.integrationevent.inbox.IntegrationEventHandler;
|
||||||
|
|
||||||
|
public interface AnnotationEntityTouchedIntegrationEventHandler extends IntegrationEventHandler {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,149 @@
|
||||||
|
package gr.cite.annotation.integrationevent.inbox.annotationentitytouch;
|
||||||
|
|
||||||
|
import gr.cite.annotation.audit.AuditableAction;
|
||||||
|
import gr.cite.annotation.common.JsonHandlingService;
|
||||||
|
import gr.cite.annotation.common.enums.IsActive;
|
||||||
|
import gr.cite.annotation.common.scope.fake.FakeRequestScope;
|
||||||
|
import gr.cite.annotation.data.EntityUserEntity;
|
||||||
|
import gr.cite.annotation.integrationevent.inbox.EventProcessingStatus;
|
||||||
|
import gr.cite.annotation.integrationevent.inbox.InboxPrincipal;
|
||||||
|
import gr.cite.annotation.integrationevent.inbox.IntegrationEventProperties;
|
||||||
|
import gr.cite.annotation.query.EntityUserQuery;
|
||||||
|
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
|
||||||
|
import gr.cite.tools.auditing.AuditService;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
import jakarta.persistence.EntityManagerFactory;
|
||||||
|
import jakarta.persistence.EntityTransaction;
|
||||||
|
import jakarta.persistence.OptimisticLockException;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class AnnotationEntityTouchedIntegrationEventHandlerImpl implements AnnotationEntityTouchedIntegrationEventHandler {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(AnnotationEntityTouchedIntegrationEventHandlerImpl.class));
|
||||||
|
|
||||||
|
private final JsonHandlingService jsonHandlingService;
|
||||||
|
|
||||||
|
private final ValidatorFactory validatorFactory;
|
||||||
|
|
||||||
|
private final ApplicationContext applicationContext;
|
||||||
|
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
|
public AnnotationEntityTouchedIntegrationEventHandlerImpl(JsonHandlingService jsonHandlingService, ValidatorFactory validatorFactory, ApplicationContext applicationContext, QueryFactory queryFactory) {
|
||||||
|
this.jsonHandlingService = jsonHandlingService;
|
||||||
|
this.validatorFactory = validatorFactory;
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EventProcessingStatus handle(IntegrationEventProperties properties, String message) {
|
||||||
|
AnnotationEntityTouchedIntegrationEvent event = this.jsonHandlingService.fromJsonSafe(AnnotationEntityTouchedIntegrationEvent.class, message);
|
||||||
|
if (event == null)
|
||||||
|
return EventProcessingStatus.Error;
|
||||||
|
|
||||||
|
logger.debug("Handling {}", AnnotationEntityTouchedIntegrationEvent.class.getSimpleName());
|
||||||
|
|
||||||
|
this.validatorFactory.validator(AnnotationEntityTouchedIntegrationEvent.AnnotationEntityTouchedIntegrationEventValidator.class).validateForce(event);
|
||||||
|
|
||||||
|
EntityManager entityManager = null;
|
||||||
|
EntityTransaction transaction = null;
|
||||||
|
try (FakeRequestScope ignored = new FakeRequestScope()) {
|
||||||
|
try {
|
||||||
|
// QueryFactory queryFactory = this.applicationContext.getBean(QueryFactory.class);
|
||||||
|
// TenantScope scope = this.applicationContext.getBean(TenantScope.class);
|
||||||
|
// if (scope.isMultitenant() && event.getTenant() != null) {
|
||||||
|
// TenantEntity tenant = queryFactory.query(TenantQuery.class).ids(event.getTenant()).firstAs(new BaseFieldSet().ensure(Tenant._id).ensure(Tenant._code));
|
||||||
|
// if (tenant == null) {
|
||||||
|
// logger.error("missing tenant from event message");
|
||||||
|
// return EventProcessingStatus.Error;
|
||||||
|
// }
|
||||||
|
// scope.setTenant(event.getTenant(), tenant.getCode());
|
||||||
|
// } else if (scope.isMultitenant()) {
|
||||||
|
// logger.error("missing tenant from event message");
|
||||||
|
// return EventProcessingStatus.Error;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ValidationService validator = this.applicationContext.getBean(ValidationService.class);
|
||||||
|
// validator.validateForce(model);
|
||||||
|
|
||||||
|
CurrentPrincipalResolver currentPrincipalResolver = this.applicationContext.getBean(CurrentPrincipalResolver.class);
|
||||||
|
currentPrincipalResolver.push(InboxPrincipal.build(properties));
|
||||||
|
|
||||||
|
EntityManagerFactory entityManagerFactory = this.applicationContext.getBean(EntityManagerFactory.class);
|
||||||
|
entityManager = entityManagerFactory.createEntityManager();
|
||||||
|
|
||||||
|
transaction = entityManager.getTransaction();
|
||||||
|
transaction.begin();
|
||||||
|
|
||||||
|
try {
|
||||||
|
EntityUserQuery entityUserQuery = this.queryFactory.query(EntityUserQuery.class);
|
||||||
|
List<EntityUserEntity> associatedUsersEntities = entityUserQuery
|
||||||
|
.entityIds(event.getEntityId())
|
||||||
|
.isActive(IsActive.Active)
|
||||||
|
.collect();
|
||||||
|
List<UUID> associatedUsers = associatedUsersEntities.stream()
|
||||||
|
.map(EntityUserEntity::getUserId)
|
||||||
|
.toList();
|
||||||
|
for (UUID user : event.getUserIds()) {
|
||||||
|
if (!associatedUsers.contains(user)) {
|
||||||
|
EntityUserEntity entityUserEntity = new EntityUserEntity();
|
||||||
|
entityUserEntity.setId(UUID.randomUUID());
|
||||||
|
entityUserEntity.setEntityId(event.getEntityId());
|
||||||
|
entityUserEntity.setUserId(user);
|
||||||
|
entityUserEntity.setCreatedAt(Instant.now());
|
||||||
|
entityUserEntity.setUpdatedAt(Instant.now());
|
||||||
|
entityUserEntity.setIsActive(IsActive.Active);
|
||||||
|
|
||||||
|
entityManager.persist(entityUserEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AuditService auditService = this.applicationContext.getBean(AuditService.class);
|
||||||
|
|
||||||
|
auditService.track(AuditableAction.User_Persist, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("model", event)
|
||||||
|
));
|
||||||
|
|
||||||
|
transaction.commit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
transaction.rollback();
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
currentPrincipalResolver.pop();
|
||||||
|
}
|
||||||
|
} catch (OptimisticLockException ex) {
|
||||||
|
// we get this if/when someone else already modified the notifications. We want to essentially ignore this, and keep working
|
||||||
|
logger.debug("Concurrency exception getting queue outbox. Skipping: {} ", ex.getMessage());
|
||||||
|
if (transaction != null)
|
||||||
|
transaction.rollback();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("Problem getting list of queue outbox. Skipping: {}", ex.getMessage(), ex);
|
||||||
|
if (transaction != null)
|
||||||
|
transaction.rollback();
|
||||||
|
} finally {
|
||||||
|
if (entityManager != null)
|
||||||
|
entityManager.close();
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.error("Problem getting list of queue outbox. Skipping: {}", ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
return EventProcessingStatus.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package gr.cite.annotation.integrationevent.inbox.tenanttouched;
|
package gr.cite.annotation.integrationevent.inbox.tenanttouch;
|
||||||
|
|
||||||
import gr.cite.annotation.integrationevent.TrackedEvent;
|
import gr.cite.annotation.integrationevent.TrackedEvent;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package gr.cite.annotation.integrationevent.inbox.tenanttouched;
|
package gr.cite.annotation.integrationevent.inbox.tenanttouch;
|
||||||
|
|
||||||
import gr.cite.annotation.integrationevent.inbox.IntegrationEventHandler;
|
import gr.cite.annotation.integrationevent.inbox.IntegrationEventHandler;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package gr.cite.annotation.integrationevent.inbox.tenanttouched;
|
package gr.cite.annotation.integrationevent.inbox.tenanttouch;
|
||||||
|
|
||||||
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
|
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
|
||||||
import gr.cite.annotation.audit.AuditableAction;
|
import gr.cite.annotation.audit.AuditableAction;
|
|
@ -1,4 +1,4 @@
|
||||||
package gr.cite.annotation.integrationevent.inbox.usertouched;
|
package gr.cite.annotation.integrationevent.inbox.usertouch;
|
||||||
|
|
||||||
import gr.cite.annotation.common.enums.ContactInfoType;
|
import gr.cite.annotation.common.enums.ContactInfoType;
|
||||||
import gr.cite.annotation.common.validation.BaseValidator;
|
import gr.cite.annotation.common.validation.BaseValidator;
|
|
@ -1,4 +1,4 @@
|
||||||
package gr.cite.annotation.integrationevent.inbox.usertouched;
|
package gr.cite.annotation.integrationevent.inbox.usertouch;
|
||||||
|
|
||||||
import gr.cite.annotation.integrationevent.inbox.IntegrationEventHandler;
|
import gr.cite.annotation.integrationevent.inbox.IntegrationEventHandler;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package gr.cite.annotation.integrationevent.inbox.usertouched;
|
package gr.cite.annotation.integrationevent.inbox.usertouch;
|
||||||
|
|
||||||
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
|
import gr.cite.commons.web.oidc.principal.CurrentPrincipalResolver;
|
||||||
import gr.cite.annotation.audit.AuditableAction;
|
import gr.cite.annotation.audit.AuditableAction;
|
|
@ -3,7 +3,7 @@ package gr.cite.annotation.model.persist;
|
||||||
import gr.cite.annotation.common.validation.BaseValidator;
|
import gr.cite.annotation.common.validation.BaseValidator;
|
||||||
import gr.cite.annotation.convention.ConventionService;
|
import gr.cite.annotation.convention.ConventionService;
|
||||||
import gr.cite.annotation.errorcode.ErrorThesaurusProperties;
|
import gr.cite.annotation.errorcode.ErrorThesaurusProperties;
|
||||||
import gr.cite.annotation.integrationevent.inbox.usertouched.UserTouchedIntegrationEvent;
|
import gr.cite.annotation.integrationevent.inbox.usertouch.UserTouchedIntegrationEvent;
|
||||||
import gr.cite.tools.validation.specification.Specification;
|
import gr.cite.tools.validation.specification.Specification;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
|
|
|
@ -0,0 +1,146 @@
|
||||||
|
package gr.cite.annotation.query;
|
||||||
|
|
||||||
|
import gr.cite.annotation.authorization.AuthorizationFlags;
|
||||||
|
import gr.cite.annotation.common.enums.IsActive;
|
||||||
|
import gr.cite.annotation.data.EntityUserEntity;
|
||||||
|
import gr.cite.tools.data.query.FieldResolver;
|
||||||
|
import gr.cite.tools.data.query.QueryBase;
|
||||||
|
import gr.cite.tools.data.query.QueryContext;
|
||||||
|
import jakarta.persistence.Tuple;
|
||||||
|
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||||
|
import jakarta.persistence.criteria.Predicate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.annotation.RequestScope;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequestScope
|
||||||
|
public class EntityUserQuery extends QueryBase<EntityUserEntity> {
|
||||||
|
|
||||||
|
private Collection<UUID> ids, entityIds, userIds;
|
||||||
|
|
||||||
|
private Collection<IsActive> isActives;
|
||||||
|
|
||||||
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
|
||||||
|
public EntityUserQuery ids(UUID value) {
|
||||||
|
this.ids = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityUserQuery ids(UUID... value) {
|
||||||
|
this.ids = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityUserQuery ids(Collection<UUID> values) {
|
||||||
|
this.ids = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityUserQuery entityIds(UUID value) {
|
||||||
|
this.entityIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityUserQuery entityIds(UUID... value) {
|
||||||
|
this.entityIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityUserQuery entityIds(Collection<UUID> values) {
|
||||||
|
this.entityIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityUserQuery userIds(UUID value) {
|
||||||
|
this.userIds = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityUserQuery userIds(UUID... value) {
|
||||||
|
this.userIds = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityUserQuery userIds(Collection<UUID> values) {
|
||||||
|
this.userIds = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityUserQuery isActive(IsActive value) {
|
||||||
|
this.isActives = List.of(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityUserQuery isActive(IsActive... value) {
|
||||||
|
this.isActives = Arrays.asList(value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityUserQuery isActive(Collection<IsActive> values) {
|
||||||
|
this.isActives = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityUserQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
|
this.authorize = values;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Boolean isFalseQuery() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<EntityUserEntity> entityClass() {
|
||||||
|
return EntityUserEntity.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||||
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
if (this.ids != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityUserEntity._id));
|
||||||
|
for (UUID item : this.ids)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.entityIds != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityUserEntity._entityId));
|
||||||
|
for (UUID item : this.entityIds)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.userIds != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityUserEntity._userId));
|
||||||
|
for (UUID item : this.userIds)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.isActives != null) {
|
||||||
|
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityUserEntity._isActive));
|
||||||
|
for (IsActive item : this.isActives)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (!predicates.isEmpty()) {
|
||||||
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
|
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String fieldNameOf(FieldResolver item) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected EntityUserEntity convert(Tuple tuple, Set<String> columns) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package gr.cite.annotation.query;
|
package gr.cite.annotation.query;
|
||||||
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.annotation.authorization.AuthorizationFlags;
|
import gr.cite.annotation.authorization.AuthorizationFlags;
|
||||||
import gr.cite.annotation.authorization.Permission;
|
import gr.cite.annotation.authorization.Permission;
|
||||||
import gr.cite.annotation.common.enums.IsActive;
|
import gr.cite.annotation.common.enums.IsActive;
|
||||||
|
@ -8,6 +7,7 @@ import gr.cite.annotation.common.scope.user.UserScope;
|
||||||
import gr.cite.annotation.data.UserEntity;
|
import gr.cite.annotation.data.UserEntity;
|
||||||
import gr.cite.annotation.model.User;
|
import gr.cite.annotation.model.User;
|
||||||
import gr.cite.annotation.model.user.PublicUser;
|
import gr.cite.annotation.model.user.PublicUser;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.query.FieldResolver;
|
import gr.cite.tools.data.query.FieldResolver;
|
||||||
import gr.cite.tools.data.query.QueryBase;
|
import gr.cite.tools.data.query.QueryBase;
|
||||||
import gr.cite.tools.data.query.QueryContext;
|
import gr.cite.tools.data.query.QueryContext;
|
||||||
|
@ -24,136 +24,151 @@ import java.util.*;
|
||||||
@RequestScope
|
@RequestScope
|
||||||
public class UserQuery extends QueryBase<UserEntity> {
|
public class UserQuery extends QueryBase<UserEntity> {
|
||||||
|
|
||||||
private String like;
|
private String like;
|
||||||
private Collection<UUID> ids;
|
|
||||||
private Collection<IsActive> isActives;
|
|
||||||
|
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private Collection<UUID> ids;
|
||||||
|
|
||||||
private final UserScope userScope;
|
private Collection<IsActive> isActives;
|
||||||
private final AuthorizationService authService;
|
|
||||||
|
|
||||||
public UserQuery(
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
UserScope userScope,
|
|
||||||
AuthorizationService authService
|
|
||||||
) {
|
|
||||||
this.userScope = userScope;
|
|
||||||
this.authService = authService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserQuery like(String value) {
|
private final UserScope userScope;
|
||||||
this.like = value;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserQuery ids(UUID value) {
|
private final AuthorizationService authService;
|
||||||
this.ids = List.of(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserQuery ids(UUID... value) {
|
public UserQuery(
|
||||||
this.ids = Arrays.asList(value);
|
UserScope userScope,
|
||||||
return this;
|
AuthorizationService authService
|
||||||
}
|
) {
|
||||||
|
this.userScope = userScope;
|
||||||
|
this.authService = authService;
|
||||||
|
}
|
||||||
|
|
||||||
public UserQuery ids(Collection<UUID> values) {
|
public UserQuery like(String value) {
|
||||||
this.ids = values;
|
this.like = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserQuery isActive(IsActive value) {
|
public UserQuery ids(UUID value) {
|
||||||
this.isActives = List.of(value);
|
this.ids = List.of(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserQuery isActive(IsActive... value) {
|
public UserQuery ids(UUID... value) {
|
||||||
this.isActives = Arrays.asList(value);
|
this.ids = Arrays.asList(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserQuery isActive(Collection<IsActive> values) {
|
public UserQuery ids(Collection<UUID> values) {
|
||||||
this.isActives = values;
|
this.ids = values;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserQuery authorize(EnumSet<AuthorizationFlags> values) {
|
public UserQuery isActive(IsActive value) {
|
||||||
this.authorize = values;
|
this.isActives = List.of(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public UserQuery isActive(IsActive... value) {
|
||||||
protected Class<UserEntity> entityClass() {
|
this.isActives = Arrays.asList(value);
|
||||||
return UserEntity.class;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public UserQuery isActive(Collection<IsActive> values) {
|
||||||
protected Boolean isFalseQuery() {
|
this.isActives = values;
|
||||||
return this.isEmpty(this.ids) || this.isEmpty(this.isActives);
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public UserQuery authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
protected <X, Y> Predicate applyAuthZ(QueryContext<X, Y> queryContext) {
|
this.authorize = values;
|
||||||
if (this.authorize.contains(AuthorizationFlags.None)) return null;
|
return this;
|
||||||
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) return null;
|
}
|
||||||
UUID ownerId = null;
|
|
||||||
if (this.authorize.contains(AuthorizationFlags.Owner)) ownerId = this.userScope.getUserIdSafe();
|
|
||||||
|
|
||||||
List<Predicate> predicates = new ArrayList<>();
|
@Override
|
||||||
if (ownerId != null) {
|
protected Class<UserEntity> entityClass() {
|
||||||
predicates.add(queryContext.CriteriaBuilder.equal(queryContext.Root.get(User._id), ownerId));
|
return UserEntity.class;
|
||||||
}
|
}
|
||||||
if (predicates.size() > 0) {
|
|
||||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
|
||||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
|
||||||
} else {
|
|
||||||
return queryContext.CriteriaBuilder.or(); //Creates a false query
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
protected Boolean isFalseQuery() {
|
||||||
List<Predicate> predicates = new ArrayList<>();
|
return this.isEmpty(this.ids) || this.isEmpty(this.isActives);
|
||||||
if (this.ids != null) {
|
}
|
||||||
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id));
|
|
||||||
for (UUID item : this.ids) inClause.value(item);
|
|
||||||
predicates.add(inClause);
|
|
||||||
}
|
|
||||||
if (this.like != null && !this.like.isEmpty()) {
|
|
||||||
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(UserEntity._name), this.like));
|
|
||||||
}
|
|
||||||
if (this.isActives != null) {
|
|
||||||
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._isActive));
|
|
||||||
for (IsActive item : this.isActives) inClause.value(item);
|
|
||||||
predicates.add(inClause);
|
|
||||||
}
|
|
||||||
if (predicates.size() > 0) {
|
|
||||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
|
||||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected UserEntity convert(Tuple tuple, Set<String> columns) {
|
protected <X, Y> Predicate applyAuthZ(QueryContext<X, Y> queryContext) {
|
||||||
UserEntity item = new UserEntity();
|
if (this.authorize.contains(AuthorizationFlags.None))
|
||||||
item.setId(QueryBase.convertSafe(tuple, columns, UserEntity._id, UUID.class));
|
return null;
|
||||||
item.setName(QueryBase.convertSafe(tuple, columns, UserEntity._name, String.class));
|
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser))
|
||||||
item.setAdditionalInfo(QueryBase.convertSafe(tuple, columns, UserEntity._additionalInfo, String.class));
|
return null;
|
||||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserEntity._createdAt, Instant.class));
|
UUID ownerId = null;
|
||||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, UserEntity._updatedAt, Instant.class));
|
if (this.authorize.contains(AuthorizationFlags.Owner))
|
||||||
item.setIsActive(QueryBase.convertSafe(tuple, columns, UserEntity._isActive, IsActive.class));
|
ownerId = this.userScope.getUserIdSafe();
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
protected String fieldNameOf(FieldResolver item) {
|
if (ownerId != null) {
|
||||||
if (item.match(User._id) || item.match(PublicUser._id)) return UserEntity._id;
|
predicates.add(queryContext.CriteriaBuilder.equal(queryContext.Root.get(User._id), ownerId));
|
||||||
else if (item.match(User._name) || item.match(PublicUser._name)) return UserEntity._name;
|
}
|
||||||
else if (item.match(User._createdAt) ) return UserEntity._createdAt;
|
if (!predicates.isEmpty()) {
|
||||||
else if (item.match(User._updatedAt)) return UserEntity._updatedAt;
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
else if (item.match(User._hash)) return UserEntity._updatedAt;
|
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||||
else if (item.match(User._isActive)) return UserEntity._isActive;
|
} else {
|
||||||
else return null;
|
return queryContext.CriteriaBuilder.or(); //Creates a false query
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||||
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
if (this.ids != null) {
|
||||||
|
CriteriaBuilder.In<UUID> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id));
|
||||||
|
for (UUID item : this.ids)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (this.like != null && !this.like.isEmpty()) {
|
||||||
|
predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(UserEntity._name), this.like));
|
||||||
|
}
|
||||||
|
if (this.isActives != null) {
|
||||||
|
CriteriaBuilder.In<IsActive> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._isActive));
|
||||||
|
for (IsActive item : this.isActives)
|
||||||
|
inClause.value(item);
|
||||||
|
predicates.add(inClause);
|
||||||
|
}
|
||||||
|
if (!predicates.isEmpty()) {
|
||||||
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
|
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected UserEntity convert(Tuple tuple, Set<String> columns) {
|
||||||
|
UserEntity item = new UserEntity();
|
||||||
|
item.setId(QueryBase.convertSafe(tuple, columns, UserEntity._id, UUID.class));
|
||||||
|
item.setName(QueryBase.convertSafe(tuple, columns, UserEntity._name, String.class));
|
||||||
|
item.setAdditionalInfo(QueryBase.convertSafe(tuple, columns, UserEntity._additionalInfo, String.class));
|
||||||
|
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, UserEntity._createdAt, Instant.class));
|
||||||
|
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, UserEntity._updatedAt, Instant.class));
|
||||||
|
item.setIsActive(QueryBase.convertSafe(tuple, columns, UserEntity._isActive, IsActive.class));
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String fieldNameOf(FieldResolver item) {
|
||||||
|
if (item.match(User._id) || item.match(PublicUser._id))
|
||||||
|
return UserEntity._id;
|
||||||
|
else if (item.match(User._name) || item.match(PublicUser._name))
|
||||||
|
return UserEntity._name;
|
||||||
|
else if (item.match(User._createdAt))
|
||||||
|
return UserEntity._createdAt;
|
||||||
|
else if (item.match(User._updatedAt))
|
||||||
|
return UserEntity._updatedAt;
|
||||||
|
else if (item.match(User._hash))
|
||||||
|
return UserEntity._updatedAt;
|
||||||
|
else if (item.match(User._isActive))
|
||||||
|
return UserEntity._isActive;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package gr.cite.annotation.service.user;
|
package gr.cite.annotation.service.user;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import gr.cite.annotation.integrationevent.inbox.usertouched.UserTouchedIntegrationEvent;
|
import gr.cite.annotation.integrationevent.inbox.usertouch.UserTouchedIntegrationEvent;
|
||||||
import gr.cite.annotation.model.User;
|
import gr.cite.annotation.model.User;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.exception.MyForbiddenException;
|
import gr.cite.tools.exception.MyForbiddenException;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import gr.cite.annotation.convention.ConventionService;
|
||||||
import gr.cite.annotation.data.UserContactInfoEntity;
|
import gr.cite.annotation.data.UserContactInfoEntity;
|
||||||
import gr.cite.annotation.data.UserCredentialEntity;
|
import gr.cite.annotation.data.UserCredentialEntity;
|
||||||
import gr.cite.annotation.data.UserEntity;
|
import gr.cite.annotation.data.UserEntity;
|
||||||
import gr.cite.annotation.integrationevent.inbox.usertouched.UserTouchedIntegrationEvent;
|
import gr.cite.annotation.integrationevent.inbox.usertouch.UserTouchedIntegrationEvent;
|
||||||
import gr.cite.annotation.model.User;
|
import gr.cite.annotation.model.User;
|
||||||
import gr.cite.annotation.model.builder.UserBuilder;
|
import gr.cite.annotation.model.builder.UserBuilder;
|
||||||
import gr.cite.annotation.model.deleter.UserDeleter;
|
import gr.cite.annotation.model.deleter.UserDeleter;
|
||||||
|
|
|
@ -50,12 +50,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.cite.opendmp</groupId>
|
<groupId>gr.cite.opendmp</groupId>
|
||||||
<artifactId>common-models</artifactId>
|
<artifactId>common-models</artifactId>
|
||||||
<version>0.0.2</version>
|
<version>0.0.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.cite.opendmp</groupId>
|
<groupId>gr.cite.opendmp</groupId>
|
||||||
<artifactId>file-transformer-base</artifactId>
|
<artifactId>file-transformer-base</artifactId>
|
||||||
<version>0.0.5</version>
|
<version>0.0.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.cite</groupId>
|
<groupId>gr.cite</groupId>
|
||||||
|
|
|
@ -40,7 +40,8 @@ public class AuditableAction {
|
||||||
public static final EventId Dmp_Invite_Users = new EventId(5008, "Dmp_Invite_Users");
|
public static final EventId Dmp_Invite_Users = new EventId(5008, "Dmp_Invite_Users");
|
||||||
public static final EventId Dmp_Invite_Accept = new EventId(5009, "Dmp_Invite_Accept");
|
public static final EventId Dmp_Invite_Accept = new EventId(5009, "Dmp_Invite_Accept");
|
||||||
public static final EventId Dmp_PublicQuery = new EventId(5010, "Dmp_PublicQuery");
|
public static final EventId Dmp_PublicQuery = new EventId(5010, "Dmp_PublicQuery");
|
||||||
public static final EventId Dmp_PublicLookup = new EventId(5011, "Dmp_PublicLookup");
|
public static final EventId Dmp_Export = new EventId(5011, "Dmp_Export");
|
||||||
|
public static final EventId Dmp_PublicLookup = new EventId(5012, "Dmp_PublicLookup");
|
||||||
|
|
||||||
public static final EventId Description_Query = new EventId(6000, "Description_Query");
|
public static final EventId Description_Query = new EventId(6000, "Description_Query");
|
||||||
public static final EventId Description_Lookup = new EventId(6001, "Description_Lookup");
|
public static final EventId Description_Lookup = new EventId(6001, "Description_Lookup");
|
||||||
|
|
|
@ -4,5 +4,5 @@ import java.util.EnumSet;
|
||||||
|
|
||||||
public enum AuthorizationFlags {
|
public enum AuthorizationFlags {
|
||||||
None, Permission, DmpAssociated, Public, Owner;
|
None, Permission, DmpAssociated, Public, Owner;
|
||||||
public static final EnumSet<AuthorizationFlags> OwnerOrDmpAssociatedOrPermissionOrPublic = EnumSet.of(DmpAssociated, Permission, Public, Owner);
|
public static final EnumSet<AuthorizationFlags> OwnerOrDmpAssociatedOrPermission = EnumSet.of(DmpAssociated, Permission, Owner);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,19 +3,15 @@ package eu.eudat.authorization;
|
||||||
public final class Permission {
|
public final class Permission {
|
||||||
/////// Should Remove after Refactor
|
/////// Should Remove after Refactor
|
||||||
|
|
||||||
public static String AnonymousRole = "AnonymousRole";
|
|
||||||
public static String AdminRole = "AdminRole";
|
public static String AdminRole = "AdminRole";
|
||||||
public static String ManagerRole = "ManagerRole";
|
|
||||||
public static String UserRole = "UserRole";
|
|
||||||
public static String AuthenticatedRole = "AuthenticatedRole";
|
public static String AuthenticatedRole = "AuthenticatedRole";
|
||||||
public static String PublicRole = "PublicRole";
|
|
||||||
public static String DatasetProfileManagerRole = "DatasetProfileManagerRole";
|
|
||||||
|
|
||||||
/////
|
/////
|
||||||
|
public static String DeferredAffiliation = "DeferredAffiliation";
|
||||||
|
|
||||||
//Public
|
//Public
|
||||||
public static String PublicBrowseDescription = "PublicBrowseDescription";
|
public static String PublicBrowseDescription = "PublicBrowseDescription";
|
||||||
public static String PublicBrowseDescriptionTemplate = "BrowseDescriptionTemplate";
|
public static String PublicBrowseDescriptionTemplate = "PublicBrowseDescriptionTemplate";
|
||||||
public static String PublicBrowseDmp = "PublicBrowseDmp";
|
public static String PublicBrowseDmp = "PublicBrowseDmp";
|
||||||
public static String PublicBrowseDmpReference = "PublicBrowseDmpReference";
|
public static String PublicBrowseDmpReference = "PublicBrowseDmpReference";
|
||||||
public static String PublicBrowseDmpUser = "PublicBrowseDmpUser";
|
public static String PublicBrowseDmpUser = "PublicBrowseDmpUser";
|
||||||
|
@ -73,6 +69,8 @@ public final class Permission {
|
||||||
//Dmp
|
//Dmp
|
||||||
public static String BrowseDmp = "BrowseDmp";
|
public static String BrowseDmp = "BrowseDmp";
|
||||||
public static String EditDmp = "EditDmp";
|
public static String EditDmp = "EditDmp";
|
||||||
|
public static String NewDmp = "NewDmp";
|
||||||
|
|
||||||
public static String DeleteDmp = "DeleteDmp";
|
public static String DeleteDmp = "DeleteDmp";
|
||||||
public static String CloneDmp = "CloneDmp";
|
public static String CloneDmp = "CloneDmp";
|
||||||
public static String CreateNewVersionDmp = "CreateNewVersionDmp";
|
public static String CreateNewVersionDmp = "CreateNewVersionDmp";
|
||||||
|
|
|
@ -9,7 +9,8 @@ public enum StorageType implements DatabaseEnum<Short> {
|
||||||
|
|
||||||
Temp((short) 0),
|
Temp((short) 0),
|
||||||
Main((short) 1),
|
Main((short) 1),
|
||||||
Transformer((short)2);
|
Transformer((short)2),
|
||||||
|
Deposit((short)3);
|
||||||
|
|
||||||
private final Short value;
|
private final Short value;
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ public class DepositProperties {
|
||||||
private String clientId;
|
private String clientId;
|
||||||
private String clientSecret;
|
private String clientSecret;
|
||||||
private String scope;
|
private String scope;
|
||||||
|
private String pdfTransformerId;
|
||||||
|
private String rdaTransformerId;
|
||||||
|
|
||||||
public String getRepositoryId() {
|
public String getRepositoryId() {
|
||||||
return repositoryId;
|
return repositoryId;
|
||||||
|
@ -74,5 +76,21 @@ public class DepositProperties {
|
||||||
public void setScope(String scope) {
|
public void setScope(String scope) {
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPdfTransformerId() {
|
||||||
|
return pdfTransformerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPdfTransformerId(String pdfTransformerId) {
|
||||||
|
this.pdfTransformerId = pdfTransformerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRdaTransformerId() {
|
||||||
|
return rdaTransformerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRdaTransformerId(String rdaTransformerId) {
|
||||||
|
this.rdaTransformerId = rdaTransformerId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ public class TransformerProperties {
|
||||||
public static class TransformerSource {
|
public static class TransformerSource {
|
||||||
|
|
||||||
private final String url;
|
private final String url;
|
||||||
|
private final String transformerId;
|
||||||
private final List<String> codes;
|
private final List<String> codes;
|
||||||
private final String issuerUrl;
|
private final String issuerUrl;
|
||||||
private final String clientId;
|
private final String clientId;
|
||||||
|
@ -29,9 +30,10 @@ public class TransformerProperties {
|
||||||
private final String scope;
|
private final String scope;
|
||||||
|
|
||||||
@ConstructorBinding
|
@ConstructorBinding
|
||||||
public TransformerSource(String url, List<String> codes, String issuerUrl, String clientId, String clientSecret, String scope) {
|
public TransformerSource(String url, String transformerId, List<String> codes, String issuerUrl, String clientId, String clientSecret, String scope) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.codes = codes;
|
this.transformerId = transformerId;
|
||||||
|
this.codes = codes;
|
||||||
this.issuerUrl = issuerUrl;
|
this.issuerUrl = issuerUrl;
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
this.clientSecret = clientSecret;
|
this.clientSecret = clientSecret;
|
||||||
|
@ -61,5 +63,9 @@ public class TransformerProperties {
|
||||||
public List<String> getCodes() {
|
public List<String> getCodes() {
|
||||||
return codes;
|
return codes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTransformerId() {
|
||||||
|
return transformerId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class ReferenceEntity extends TenantScopedBaseEntity {
|
||||||
@Column(name = "created_by", columnDefinition = "uuid")
|
@Column(name = "created_by", columnDefinition = "uuid")
|
||||||
private UUID createdById;
|
private UUID createdById;
|
||||||
|
|
||||||
public static final String _createdById = "createdBy";
|
public static final String _createdById = "createdById";
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|
|
@ -27,6 +27,8 @@ public class OutboxIntegrationEvent extends IntegrationEvent {
|
||||||
|
|
||||||
public static final String DESCRIPTION_TOUCH = "DESCRIPTION_TOUCH";
|
public static final String DESCRIPTION_TOUCH = "DESCRIPTION_TOUCH";
|
||||||
|
|
||||||
|
public static final String ANNOTATION_ENTITY_TOUCH = "ANNOTATION_ENTITY_TOUCH";
|
||||||
|
|
||||||
public static final String WHAT_YOU_KNOW_ABOUT_ME_COMPLETED = "WHAT_YOU_KNOW_ABOUT_ME_COMPLETED";
|
public static final String WHAT_YOU_KNOW_ABOUT_ME_COMPLETED = "WHAT_YOU_KNOW_ABOUT_ME_COMPLETED";
|
||||||
|
|
||||||
public static final String GENERATE_FILE = "GENERATE_FILE";
|
public static final String GENERATE_FILE = "GENERATE_FILE";
|
||||||
|
|
|
@ -23,6 +23,8 @@ public class OutboxProperties {
|
||||||
|
|
||||||
private final String descriptionTouchTopic;
|
private final String descriptionTouchTopic;
|
||||||
|
|
||||||
|
private final String annotationEntityTouchTopic;
|
||||||
|
|
||||||
private final String notifyTopic;
|
private final String notifyTopic;
|
||||||
|
|
||||||
private final String forgetMeCompletedTopic;
|
private final String forgetMeCompletedTopic;
|
||||||
|
@ -37,7 +39,10 @@ public class OutboxProperties {
|
||||||
String tenantReactivationTopic,
|
String tenantReactivationTopic,
|
||||||
String tenantUserInviteTopic,
|
String tenantUserInviteTopic,
|
||||||
String userRemovalTopic,
|
String userRemovalTopic,
|
||||||
String userTouchTopic, String dmpTouchTopic, String descriptionTouchTopic,
|
String userTouchTopic,
|
||||||
|
String dmpTouchTopic,
|
||||||
|
String descriptionTouchTopic,
|
||||||
|
String annotationEntityTouchTopic,
|
||||||
String notifyTopic,
|
String notifyTopic,
|
||||||
String forgetMeCompletedTopic,
|
String forgetMeCompletedTopic,
|
||||||
String whatYouKnowAboutMeCompletedTopic,
|
String whatYouKnowAboutMeCompletedTopic,
|
||||||
|
@ -52,6 +57,7 @@ public class OutboxProperties {
|
||||||
this.userTouchTopic = userTouchTopic;
|
this.userTouchTopic = userTouchTopic;
|
||||||
this.dmpTouchTopic = dmpTouchTopic;
|
this.dmpTouchTopic = dmpTouchTopic;
|
||||||
this.descriptionTouchTopic = descriptionTouchTopic;
|
this.descriptionTouchTopic = descriptionTouchTopic;
|
||||||
|
this.annotationEntityTouchTopic = annotationEntityTouchTopic;
|
||||||
this.notifyTopic = notifyTopic;
|
this.notifyTopic = notifyTopic;
|
||||||
this.forgetMeCompletedTopic = forgetMeCompletedTopic;
|
this.forgetMeCompletedTopic = forgetMeCompletedTopic;
|
||||||
this.whatYouKnowAboutMeCompletedTopic = whatYouKnowAboutMeCompletedTopic;
|
this.whatYouKnowAboutMeCompletedTopic = whatYouKnowAboutMeCompletedTopic;
|
||||||
|
@ -94,6 +100,10 @@ public class OutboxProperties {
|
||||||
return descriptionTouchTopic;
|
return descriptionTouchTopic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAnnotationEntityTouchTopic() {
|
||||||
|
return annotationEntityTouchTopic;
|
||||||
|
}
|
||||||
|
|
||||||
public String getNotifyTopic() {
|
public String getNotifyTopic() {
|
||||||
return notifyTopic;
|
return notifyTopic;
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,6 +415,10 @@ public class OutboxRepositoryImpl implements OutboxRepository {
|
||||||
routingKey = this.outboxProperties.getDescriptionTouchTopic();
|
routingKey = this.outboxProperties.getDescriptionTouchTopic();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case OutboxIntegrationEvent.ANNOTATION_ENTITY_TOUCH: {
|
||||||
|
routingKey = this.outboxProperties.getAnnotationEntityTouchTopic();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case OutboxIntegrationEvent.FORGET_ME_COMPLETED: {
|
case OutboxIntegrationEvent.FORGET_ME_COMPLETED: {
|
||||||
routingKey = this.outboxProperties.getForgetMeCompletedTopic();
|
routingKey = this.outboxProperties.getForgetMeCompletedTopic();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package eu.eudat.integrationevent.outbox.annotationentitytouch;
|
||||||
|
|
||||||
|
import eu.eudat.integrationevent.TrackedEvent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class AnnotationEntityTouchedIntegrationEvent extends TrackedEvent {
|
||||||
|
|
||||||
|
private UUID entityId;
|
||||||
|
|
||||||
|
private List<UUID> userIds;
|
||||||
|
|
||||||
|
public UUID getEntityId() {
|
||||||
|
return entityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEntityId(UUID entityId) {
|
||||||
|
this.entityId = entityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getUserIds() {
|
||||||
|
return userIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserIds(List<UUID> userIds) {
|
||||||
|
this.userIds = userIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package eu.eudat.integrationevent.outbox.annotationentitytouch;
|
||||||
|
|
||||||
|
import eu.eudat.integrationevent.outbox.dmptouched.DmpTouchedIntegrationEvent;
|
||||||
|
import eu.eudat.model.persist.DmpPersist;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface AnnotationEntityTouchedIntegrationEventHandler {
|
||||||
|
|
||||||
|
void handle(AnnotationEntityTouchedIntegrationEvent event);
|
||||||
|
|
||||||
|
static AnnotationEntityTouchedIntegrationEvent buildEventFromPersistModel(DmpPersist persist) {
|
||||||
|
AnnotationEntityTouchedIntegrationEvent event = new AnnotationEntityTouchedIntegrationEvent();
|
||||||
|
event.setEntityId(persist.getId());
|
||||||
|
List<UUID> users = new ArrayList<>();
|
||||||
|
persist.getUsers().forEach(dmpUserPersist -> {
|
||||||
|
users.add(dmpUserPersist.getUser());
|
||||||
|
});
|
||||||
|
event.setUserIds(users);
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package eu.eudat.integrationevent.outbox.annotationentitytouch;
|
||||||
|
|
||||||
|
import eu.eudat.integrationevent.outbox.OutboxIntegrationEvent;
|
||||||
|
import eu.eudat.integrationevent.outbox.OutboxService;
|
||||||
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||||
|
public class AnnotationEntityTouchedIntegrationEventHandlerImpl implements AnnotationEntityTouchedIntegrationEventHandler {
|
||||||
|
|
||||||
|
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(AnnotationEntityTouchedIntegrationEventHandlerImpl.class));
|
||||||
|
|
||||||
|
private final OutboxService outboxService;
|
||||||
|
|
||||||
|
public AnnotationEntityTouchedIntegrationEventHandlerImpl(OutboxService outboxService) {
|
||||||
|
this.outboxService = outboxService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(AnnotationEntityTouchedIntegrationEvent event) {
|
||||||
|
OutboxIntegrationEvent message = new OutboxIntegrationEvent();
|
||||||
|
message.setMessageId(UUID.randomUUID());
|
||||||
|
message.setType(OutboxIntegrationEvent.ANNOTATION_ENTITY_TOUCH);
|
||||||
|
message.setEvent(event);
|
||||||
|
this.outboxService.publish(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -37,7 +37,16 @@ public class PublicDmp {
|
||||||
|
|
||||||
public static final String _publishedAt = "publishedAt";
|
public static final String _publishedAt = "publishedAt";
|
||||||
|
|
||||||
private List<PublicDmpUser> users;
|
private DmpStatus status;
|
||||||
|
public static final String _status = "status";
|
||||||
|
|
||||||
|
private UUID groupId;
|
||||||
|
public static final String _groupId = "groupId";
|
||||||
|
|
||||||
|
private DmpAccessType accessType;
|
||||||
|
public static final String _accessType = "accessType";
|
||||||
|
|
||||||
|
private List<PublicDmpUser> dmpUsers;
|
||||||
|
|
||||||
public static final String _dmpUsers = "dmpUsers";
|
public static final String _dmpUsers = "dmpUsers";
|
||||||
|
|
||||||
|
@ -104,12 +113,36 @@ public class PublicDmp {
|
||||||
this.publishedAt = publishedAt;
|
this.publishedAt = publishedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PublicDmpUser> getUsers() {
|
public DmpStatus getStatus() {
|
||||||
return users;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsers(List<PublicDmpUser> users) {
|
public void setStatus(DmpStatus status) {
|
||||||
this.users = users;
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getGroupId() {
|
||||||
|
return groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupId(UUID groupId) {
|
||||||
|
this.groupId = groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DmpAccessType getAccessType() {
|
||||||
|
return accessType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccessType(DmpAccessType accessType) {
|
||||||
|
this.accessType = accessType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PublicDmpUser> getDmpUsers() {
|
||||||
|
return dmpUsers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDmpUsers(List<PublicDmpUser> dmpUsers) {
|
||||||
|
this.dmpUsers = dmpUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PublicDmpReference> getDmpReferences() {
|
public List<PublicDmpReference> getDmpReferences() {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package eu.eudat.model;
|
package eu.eudat.model;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -14,6 +16,9 @@ public class PublicDmpReference {
|
||||||
private PublicReference reference;
|
private PublicReference reference;
|
||||||
public static final String _reference = "reference";
|
public static final String _reference = "reference";
|
||||||
|
|
||||||
|
private IsActive isActive;
|
||||||
|
public static final String _isActive = "isActive";
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -37,4 +42,12 @@ public class PublicDmpReference {
|
||||||
public void setReference(PublicReference reference) {
|
public void setReference(PublicReference reference) {
|
||||||
this.reference = reference;
|
this.reference = reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IsActive getIsActive() {
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsActive(IsActive isActive) {
|
||||||
|
this.isActive = isActive;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,9 +74,13 @@ public class PublicDmpBuilder extends BaseBuilder<PublicDmp, DmpEntity> {
|
||||||
if (fields.hasField(this.asIndexer(PublicDmp._description))) m.setDescription(d.getDescription());
|
if (fields.hasField(this.asIndexer(PublicDmp._description))) m.setDescription(d.getDescription());
|
||||||
if (fields.hasField(this.asIndexer(PublicDmp._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
|
if (fields.hasField(this.asIndexer(PublicDmp._finalizedAt))) m.setFinalizedAt(d.getFinalizedAt());
|
||||||
if (fields.hasField(this.asIndexer(PublicDmp._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
if (fields.hasField(this.asIndexer(PublicDmp._updatedAt))) m.setUpdatedAt(d.getUpdatedAt());
|
||||||
|
if (fields.hasField(this.asIndexer(PublicDmp._accessType))) m.setAccessType(d.getAccessType());
|
||||||
|
if (fields.hasField(this.asIndexer(PublicDmp._status))) m.setStatus(d.getStatus());
|
||||||
|
if (fields.hasField(this.asIndexer(PublicDmp._groupId))) m.setGroupId(d.getGroupId());
|
||||||
|
if (fields.hasField(this.asIndexer(PublicDmp._accessType))) m.setAccessType(d.getAccessType());
|
||||||
|
|
||||||
if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId()));
|
if (dmpReferenceMap != null && !dmpReferenceMap.isEmpty() && dmpReferenceMap.containsKey(d.getId())) m.setDmpReferences(dmpReferenceMap.get(d.getId()));
|
||||||
if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setUsers(dmpUsersMap.get(d.getId()));
|
if (dmpUsersMap != null && !dmpUsersMap.isEmpty() && dmpUsersMap.containsKey(d.getId())) m.setDmpUsers(dmpUsersMap.get(d.getId()));
|
||||||
if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId()));
|
if (descriptionsMap != null && !descriptionsMap.isEmpty() && descriptionsMap.containsKey(d.getId())) m.setDescriptions(descriptionsMap.get(d.getId()));
|
||||||
|
|
||||||
models.add(m);
|
models.add(m);
|
||||||
|
@ -109,7 +113,7 @@ public class PublicDmpBuilder extends BaseBuilder<PublicDmp, DmpEntity> {
|
||||||
this.logger.debug("checking related - {}", PublicDmpUser.class.getSimpleName());
|
this.logger.debug("checking related - {}", PublicDmpUser.class.getSimpleName());
|
||||||
|
|
||||||
Map<UUID, List<PublicDmpUser>> itemMap = null;
|
Map<UUID, List<PublicDmpUser>> itemMap = null;
|
||||||
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDmpUser._user, PublicDmp._id));
|
FieldSet clone = new BaseFieldSet(fields.getFields()).ensure(this.asIndexer(PublicDmpUser._dmp, PublicDmp._id));
|
||||||
DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
DmpUserQuery query = this.queryFactory.query(DmpUserQuery.class).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(PublicDmpUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId());
|
itemMap = this.builderFactory.builder(PublicDmpUserBuilder.class).authorize(this.authorize).asMasterKey(query, clone, x -> x.getDmp().getId());
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ public class PublicDmpReferenceBuilder extends BaseBuilder<PublicDmpReference, D
|
||||||
for (DmpReferenceEntity d : data) {
|
for (DmpReferenceEntity d : data) {
|
||||||
PublicDmpReference m = new PublicDmpReference();
|
PublicDmpReference m = new PublicDmpReference();
|
||||||
if (fields.hasField(this.asIndexer(PublicDmpReference._id))) m.setId(d.getId());
|
if (fields.hasField(this.asIndexer(PublicDmpReference._id))) m.setId(d.getId());
|
||||||
|
if (fields.hasField(this.asIndexer(PublicDmpReference._isActive))) m.setIsActive(d.getIsActive());
|
||||||
if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())) m.setReference(referenceItemsMap.get(d.getReferenceId()));
|
if (!referenceFields.isEmpty() && referenceItemsMap != null && referenceItemsMap.containsKey(d.getReferenceId())) m.setReference(referenceItemsMap.get(d.getReferenceId()));
|
||||||
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));
|
if (!dmpFields.isEmpty() && dmpItemsMap != null && dmpItemsMap.containsKey(d.getDmpId())) m.setDmp(dmpItemsMap.get(d.getDmpId()));
|
||||||
models.add(m);
|
models.add(m);
|
||||||
|
|
|
@ -64,6 +64,13 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder<Descri
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean useSharedStorage;
|
||||||
|
public DescriptionCommonModelBuilder useSharedStorage(boolean useSharedStorage) {
|
||||||
|
this.useSharedStorage = useSharedStorage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<DescriptionModel, DescriptionEntity>> buildInternal(List<DescriptionEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<DescriptionModel, DescriptionEntity>> buildInternal(List<DescriptionEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
@ -95,7 +102,7 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder<Descri
|
||||||
if (d.getProperties() != null){
|
if (d.getProperties() != null){
|
||||||
//TODO Update with the new logic of property definition
|
//TODO Update with the new logic of property definition
|
||||||
PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties());
|
PropertyDefinitionEntity propertyDefinition = this.jsonHandlingService.fromJsonSafe(PropertyDefinitionEntity.class, d.getProperties());
|
||||||
m.setProperties(this.builderFactory.builder(PropertyDefinitionCommonModelBuilder.class).withDefinition(definitionEntityMap != null ? definitionEntityMap.getOrDefault(d.getDescriptionTemplateId(), null) : null).authorize(this.authorize).build(propertyDefinition));
|
m.setProperties(this.builderFactory.builder(PropertyDefinitionCommonModelBuilder.class).useSharedStorage(useSharedStorage).withDefinition(definitionEntityMap != null ? definitionEntityMap.getOrDefault(d.getDescriptionTemplateId(), null) : null).authorize(this.authorize).build(propertyDefinition));
|
||||||
}
|
}
|
||||||
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
}
|
}
|
||||||
|
@ -143,7 +150,7 @@ public class DescriptionCommonModelBuilder extends BaseCommonModelBuilder<Descri
|
||||||
|
|
||||||
Map<UUID, DmpModel> itemMap;
|
Map<UUID, DmpModel> itemMap;
|
||||||
DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList()));
|
DmpQuery q = this.queryFactory.query(DmpQuery.class).authorize(this.authorize).ids(data.stream().map(DescriptionEntity::getDmpId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(DmpCommonModelBuilder.class).setDisableDescriptions(true).authorize(this.authorize).asForeignKey(q, DmpEntity::getId);
|
itemMap = this.builderFactory.builder(DmpCommonModelBuilder.class).useSharedStorage(useSharedStorage).setDisableDescriptions(true).authorize(this.authorize).asForeignKey(q, DmpEntity::getId);
|
||||||
|
|
||||||
return itemMap;
|
return itemMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,42 @@
|
||||||
package eu.eudat.model.builder.commonmodels.description;
|
package eu.eudat.model.builder.commonmodels.description;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.commonmodels.models.FileEnvelopeModel;
|
||||||
import eu.eudat.commonmodels.models.description.FieldModel;
|
import eu.eudat.commonmodels.models.description.FieldModel;
|
||||||
import eu.eudat.commonmodels.models.reference.ReferenceModel;
|
import eu.eudat.commonmodels.models.reference.ReferenceModel;
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import eu.eudat.commons.enums.FieldType;
|
||||||
|
import eu.eudat.commons.enums.StorageType;
|
||||||
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.commons.types.description.FieldEntity;
|
import eu.eudat.commons.types.description.FieldEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.ReferenceEntity;
|
import eu.eudat.data.ReferenceEntity;
|
||||||
|
import eu.eudat.data.StorageFileEntity;
|
||||||
import eu.eudat.model.Reference;
|
import eu.eudat.model.Reference;
|
||||||
|
import eu.eudat.model.StorageFile;
|
||||||
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
import eu.eudat.model.builder.commonmodels.BaseCommonModelBuilder;
|
||||||
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
import eu.eudat.model.builder.commonmodels.CommonModelBuilderItemResponse;
|
||||||
import eu.eudat.model.builder.commonmodels.reference.ReferenceCommonModelBuilder;
|
import eu.eudat.model.builder.commonmodels.reference.ReferenceCommonModelBuilder;
|
||||||
|
import eu.eudat.model.persist.StorageFilePersist;
|
||||||
import eu.eudat.query.ReferenceQuery;
|
import eu.eudat.query.ReferenceQuery;
|
||||||
|
import eu.eudat.query.StorageFileQuery;
|
||||||
|
import eu.eudat.service.storage.StorageFileProperties;
|
||||||
|
import eu.eudat.service.storage.StorageFileService;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -32,24 +47,38 @@ public class FieldCommonModelBuilder extends BaseCommonModelBuilder<FieldModel,
|
||||||
private final QueryFactory queryFactory;
|
private final QueryFactory queryFactory;
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
private eu.eudat.commons.types.descriptiontemplate.FieldEntity fieldEntity;
|
private eu.eudat.commons.types.descriptiontemplate.FieldEntity fieldEntity;
|
||||||
|
private final StorageFileService storageFileService;
|
||||||
|
private final UserScope userScope;
|
||||||
|
private final ValidatorFactory validatorFactory;
|
||||||
|
private final StorageFileProperties storageFileProperties;
|
||||||
@Autowired
|
@Autowired
|
||||||
public FieldCommonModelBuilder(
|
public FieldCommonModelBuilder(
|
||||||
ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory
|
ConventionService conventionService, BuilderFactory builderFactory, QueryFactory queryFactory, StorageFileService storageFileService, UserScope userScope, ValidatorFactory validatorFactory, StorageFileProperties storageFileProperties
|
||||||
) {
|
) {
|
||||||
super(conventionService, new LoggerService(LoggerFactory.getLogger(FieldCommonModelBuilder.class)));
|
super(conventionService, new LoggerService(LoggerFactory.getLogger(FieldCommonModelBuilder.class)));
|
||||||
this.builderFactory = builderFactory;
|
this.builderFactory = builderFactory;
|
||||||
this.queryFactory = queryFactory;
|
this.queryFactory = queryFactory;
|
||||||
|
this.storageFileService = storageFileService;
|
||||||
|
this.userScope = userScope;
|
||||||
|
this.validatorFactory = validatorFactory;
|
||||||
|
this.storageFileProperties = storageFileProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
public FieldCommonModelBuilder authorize(EnumSet<AuthorizationFlags> values) {
|
||||||
this.authorize = values;
|
this.authorize = values;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FieldCommonModelBuilder withFieldEntity(eu.eudat.commons.types.descriptiontemplate.FieldEntity fieldEntity) {
|
public FieldCommonModelBuilder withFieldEntity(eu.eudat.commons.types.descriptiontemplate.FieldEntity fieldEntity) {
|
||||||
this.fieldEntity = fieldEntity;
|
this.fieldEntity = fieldEntity;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean useSharedStorage;
|
||||||
|
public FieldCommonModelBuilder useSharedStorage(boolean useSharedStorage) {
|
||||||
|
this.useSharedStorage = useSharedStorage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<FieldModel, FieldEntity>> buildInternal(List<FieldEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<FieldModel, FieldEntity>> buildInternal(List<FieldEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
@ -72,6 +101,24 @@ public class FieldCommonModelBuilder extends BaseCommonModelBuilder<FieldModel,
|
||||||
if (referenceItemsMap.containsKey(referenceId)) m.getReferences().add(referenceItemsMap.get(referenceId));
|
if (referenceItemsMap.containsKey(referenceId)) m.getReferences().add(referenceItemsMap.get(referenceId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (FieldType.UPLOAD.equals(fieldType) && d.getTextValue() != null && !d.getTextValue().isEmpty()) {
|
||||||
|
try {
|
||||||
|
byte[] bytes = this.storageFileService.readAsBytesSafe(UUID.fromString(d.getTextValue()));
|
||||||
|
FileEnvelopeModel fileEnvelopeModel = new FileEnvelopeModel();
|
||||||
|
StorageFileEntity storageFile = this.queryFactory.query(StorageFileQuery.class).ids(UUID.fromString(d.getTextValue())).first();
|
||||||
|
fileEnvelopeModel.setFile(bytes);
|
||||||
|
fileEnvelopeModel.setFilename(storageFile.getName() + (storageFile.getExtension().startsWith(".") ? "" : ".") + storageFile.getExtension());
|
||||||
|
fileEnvelopeModel.setMimeType(storageFile.getMimeType());
|
||||||
|
if (!useSharedStorage){
|
||||||
|
fileEnvelopeModel.setFile(bytes);
|
||||||
|
} else {
|
||||||
|
fileEnvelopeModel.setFileRef(this.addFileToSharedStorage(bytes, storageFile));
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
if (d.getExternalIdentifier() != null && FieldType.isExternalIdentifierType(fieldType)) m.setExternalIdentifier(this.builderFactory.builder(ExternalIdentifierCommonModelBuilder.class).authorize(this.authorize).build(d.getExternalIdentifier()));
|
if (d.getExternalIdentifier() != null && FieldType.isExternalIdentifierType(fieldType)) m.setExternalIdentifier(this.builderFactory.builder(ExternalIdentifierCommonModelBuilder.class).authorize(this.authorize).build(d.getExternalIdentifier()));
|
||||||
|
|
||||||
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
@ -82,6 +129,19 @@ public class FieldCommonModelBuilder extends BaseCommonModelBuilder<FieldModel,
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String addFileToSharedStorage(byte[] bytes, StorageFileEntity storageFile) throws IOException {
|
||||||
|
StorageFilePersist storageFilePersist = new StorageFilePersist();
|
||||||
|
storageFilePersist.setName(FilenameUtils.removeExtension(storageFile.getName()));
|
||||||
|
storageFilePersist.setExtension(FilenameUtils.getExtension(storageFile.getExtension()));
|
||||||
|
storageFilePersist.setMimeType(URLConnection.guessContentTypeFromName(storageFile.getName() + (storageFile.getExtension().startsWith(".") ? "" : ".") + storageFile.getExtension()));
|
||||||
|
storageFilePersist.setOwnerId(this.userScope.getUserIdSafe());
|
||||||
|
storageFilePersist.setStorageType(StorageType.Temp);
|
||||||
|
storageFilePersist.setLifetime(Duration.ofSeconds(this.storageFileProperties.getTempStoreLifetimeSeconds())); //TODO
|
||||||
|
this.validatorFactory.validator(StorageFilePersist.StorageFilePersistValidator.class).validateForce(storageFilePersist);
|
||||||
|
StorageFile persisted = this.storageFileService.persistBytes(storageFilePersist, bytes, new BaseFieldSet(StorageFile._id, StorageFile._fileRef));
|
||||||
|
return persisted.getFileRef();
|
||||||
|
}
|
||||||
|
|
||||||
private Map<UUID, ReferenceModel> collectReferences(List<FieldEntity> data) throws MyApplicationException {
|
private Map<UUID, ReferenceModel> collectReferences(List<FieldEntity> data) throws MyApplicationException {
|
||||||
if (data.isEmpty())
|
if (data.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -42,6 +42,13 @@ public class PropertyDefinitionCommonModelBuilder extends BaseCommonModelBuilder
|
||||||
this.definition = definition;
|
this.definition = definition;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean useSharedStorage;
|
||||||
|
public PropertyDefinitionCommonModelBuilder useSharedStorage(boolean useSharedStorage) {
|
||||||
|
this.useSharedStorage = useSharedStorage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<PropertyDefinitionModel, PropertyDefinitionEntity>> buildInternal(List<PropertyDefinitionEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<PropertyDefinitionModel, PropertyDefinitionEntity>> buildInternal(List<PropertyDefinitionEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
@ -53,7 +60,7 @@ public class PropertyDefinitionCommonModelBuilder extends BaseCommonModelBuilder
|
||||||
m.setFieldSets(new HashMap<>());
|
m.setFieldSets(new HashMap<>());
|
||||||
for (String key : d.getFieldSets().keySet()){
|
for (String key : d.getFieldSets().keySet()){
|
||||||
FieldSetEntity fieldSetEntity = definition != null ? definition.getFieldSetById(key).stream().findFirst().orElse(null) : null;
|
FieldSetEntity fieldSetEntity = definition != null ? definition.getFieldSetById(key).stream().findFirst().orElse(null) : null;
|
||||||
m.getFieldSets().put(key, this.builderFactory.builder(PropertyDefinitionFieldSetCommonModelBuilder.class).authorize(this.authorize).withFieldSetEntity(fieldSetEntity).build(d.getFieldSets().get(key)));
|
m.getFieldSets().put(key, this.builderFactory.builder(PropertyDefinitionFieldSetCommonModelBuilder.class).useSharedStorage(useSharedStorage).authorize(this.authorize).withFieldSetEntity(fieldSetEntity).build(d.getFieldSets().get(key)));
|
||||||
}
|
}
|
||||||
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,13 @@ public class PropertyDefinitionFieldSetCommonModelBuilder extends BaseCommonMode
|
||||||
this.fieldSetEntity = fieldSetEntity;
|
this.fieldSetEntity = fieldSetEntity;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean useSharedStorage;
|
||||||
|
public PropertyDefinitionFieldSetCommonModelBuilder useSharedStorage(boolean useSharedStorage) {
|
||||||
|
this.useSharedStorage = useSharedStorage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<PropertyDefinitionFieldSetModel, PropertyDefinitionFieldSetEntity>> buildInternal(List<PropertyDefinitionFieldSetEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<PropertyDefinitionFieldSetModel, PropertyDefinitionFieldSetEntity>> buildInternal(List<PropertyDefinitionFieldSetEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
@ -50,7 +57,7 @@ public class PropertyDefinitionFieldSetCommonModelBuilder extends BaseCommonMode
|
||||||
List<CommonModelBuilderItemResponse<PropertyDefinitionFieldSetModel, PropertyDefinitionFieldSetEntity>> models = new ArrayList<>();
|
List<CommonModelBuilderItemResponse<PropertyDefinitionFieldSetModel, PropertyDefinitionFieldSetEntity>> models = new ArrayList<>();
|
||||||
for (PropertyDefinitionFieldSetEntity d : data) {
|
for (PropertyDefinitionFieldSetEntity d : data) {
|
||||||
PropertyDefinitionFieldSetModel m = new PropertyDefinitionFieldSetModel();
|
PropertyDefinitionFieldSetModel m = new PropertyDefinitionFieldSetModel();
|
||||||
if (d.getItems() != null) m.setItems(this.builderFactory.builder(PropertyDefinitionFieldSetItemModelCommonModelBuilder.class).withFieldSetEntity(this.fieldSetEntity).authorize(this.authorize).build(d.getItems()));
|
if (d.getItems() != null) m.setItems(this.builderFactory.builder(PropertyDefinitionFieldSetItemModelCommonModelBuilder.class).useSharedStorage(useSharedStorage).withFieldSetEntity(this.fieldSetEntity).authorize(this.authorize).build(d.getItems()));
|
||||||
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,13 @@ public class PropertyDefinitionFieldSetItemModelCommonModelBuilder extends BaseC
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean useSharedStorage;
|
||||||
|
public PropertyDefinitionFieldSetItemModelCommonModelBuilder useSharedStorage(boolean useSharedStorage) {
|
||||||
|
this.useSharedStorage = useSharedStorage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<PropertyDefinitionFieldSetItemModel, PropertyDefinitionFieldSetItemEntity>> buildInternal(List<PropertyDefinitionFieldSetItemEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<PropertyDefinitionFieldSetItemModel, PropertyDefinitionFieldSetItemEntity>> buildInternal(List<PropertyDefinitionFieldSetItemEntity> data) throws MyApplicationException {
|
||||||
|
@ -60,7 +67,7 @@ public class PropertyDefinitionFieldSetItemModelCommonModelBuilder extends BaseC
|
||||||
m.setFields(new HashMap<>());
|
m.setFields(new HashMap<>());
|
||||||
for (String key : d.getFields().keySet()){
|
for (String key : d.getFields().keySet()){
|
||||||
FieldEntity fieldEntity = fieldSetEntity != null ? fieldSetEntity.getAllField().stream().findFirst().orElse(null) : null;
|
FieldEntity fieldEntity = fieldSetEntity != null ? fieldSetEntity.getAllField().stream().findFirst().orElse(null) : null;
|
||||||
m.getFields().put(key, this.builderFactory.builder(FieldCommonModelBuilder.class).authorize(this.authorize).withFieldEntity(fieldEntity).build(d.getFields().get(key)));
|
m.getFields().put(key, this.builderFactory.builder(FieldCommonModelBuilder.class).useSharedStorage(useSharedStorage).authorize(this.authorize).withFieldEntity(fieldEntity).build(d.getFields().get(key)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
models.add(new CommonModelBuilderItemResponse<>(m, d));
|
||||||
|
|
|
@ -11,7 +11,6 @@ import eu.eudat.commonmodels.models.description.DescriptionModel;
|
||||||
import eu.eudat.commonmodels.models.dmp.DmpModel;
|
import eu.eudat.commonmodels.models.dmp.DmpModel;
|
||||||
import eu.eudat.commonmodels.models.dmpblueprint.DmpBlueprintModel;
|
import eu.eudat.commonmodels.models.dmpblueprint.DmpBlueprintModel;
|
||||||
import eu.eudat.commonmodels.models.dmpreference.DmpReferenceModel;
|
import eu.eudat.commonmodels.models.dmpreference.DmpReferenceModel;
|
||||||
import eu.eudat.commonmodels.models.reference.ReferenceModel;
|
|
||||||
import eu.eudat.commons.JsonHandlingService;
|
import eu.eudat.commons.JsonHandlingService;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.types.dmp.DmpPropertiesEntity;
|
import eu.eudat.commons.types.dmp.DmpPropertiesEntity;
|
||||||
|
@ -22,7 +21,6 @@ import eu.eudat.model.builder.commonmodels.*;
|
||||||
import eu.eudat.model.builder.commonmodels.description.DescriptionCommonModelBuilder;
|
import eu.eudat.model.builder.commonmodels.description.DescriptionCommonModelBuilder;
|
||||||
import eu.eudat.model.builder.commonmodels.dmpblueprint.DmpBlueprintCommonModelBuilder;
|
import eu.eudat.model.builder.commonmodels.dmpblueprint.DmpBlueprintCommonModelBuilder;
|
||||||
import eu.eudat.model.builder.commonmodels.dmpreference.DmpReferenceCommonModelBuilder;
|
import eu.eudat.model.builder.commonmodels.dmpreference.DmpReferenceCommonModelBuilder;
|
||||||
import eu.eudat.model.builder.commonmodels.reference.ReferenceCommonModelBuilder;
|
|
||||||
import eu.eudat.query.*;
|
import eu.eudat.query.*;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.Ordering;
|
import gr.cite.tools.data.query.Ordering;
|
||||||
|
@ -49,7 +47,6 @@ public class DmpCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, DmpE
|
||||||
private final JsonHandlingService jsonHandlingService;
|
private final JsonHandlingService jsonHandlingService;
|
||||||
private FileEnvelopeModel pdfFile;
|
private FileEnvelopeModel pdfFile;
|
||||||
private FileEnvelopeModel rdaJsonFile;
|
private FileEnvelopeModel rdaJsonFile;
|
||||||
private FileEnvelopeModel supportingFilesZip;
|
|
||||||
private String repositoryId;
|
private String repositoryId;
|
||||||
private boolean disableDescriptions;
|
private boolean disableDescriptions;
|
||||||
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
private EnumSet<AuthorizationFlags> authorize = EnumSet.of(AuthorizationFlags.None);
|
||||||
|
@ -79,11 +76,6 @@ public class DmpCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, DmpE
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DmpCommonModelBuilder setSupportingFilesZip(FileEnvelopeModel supportingFilesZip) {
|
|
||||||
this.supportingFilesZip = supportingFilesZip;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DmpCommonModelBuilder setRepositoryId(String repositoryId) {
|
public DmpCommonModelBuilder setRepositoryId(String repositoryId) {
|
||||||
this.repositoryId = repositoryId;
|
this.repositoryId = repositoryId;
|
||||||
return this;
|
return this;
|
||||||
|
@ -94,6 +86,13 @@ public class DmpCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, DmpE
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean useSharedStorage;
|
||||||
|
public DmpCommonModelBuilder useSharedStorage(boolean useSharedStorage) {
|
||||||
|
this.useSharedStorage = useSharedStorage;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<CommonModelBuilderItemResponse<DmpModel, DmpEntity>> buildInternal(List<DmpEntity> data) throws MyApplicationException {
|
protected List<CommonModelBuilderItemResponse<DmpModel, DmpEntity>> buildInternal(List<DmpEntity> data) throws MyApplicationException {
|
||||||
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
this.logger.debug("building for {}", Optional.ofNullable(data).map(List::size).orElse(0));
|
||||||
|
@ -134,7 +133,6 @@ public class DmpCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, DmpE
|
||||||
m.setUpdatedAt(d.getUpdatedAt());
|
m.setUpdatedAt(d.getUpdatedAt());
|
||||||
m.setPdfFile(this.pdfFile);
|
m.setPdfFile(this.pdfFile);
|
||||||
m.setRdaJsonFile(this.rdaJsonFile);
|
m.setRdaJsonFile(this.rdaJsonFile);
|
||||||
m.setSupportingFilesZip(this.supportingFilesZip);
|
|
||||||
if (d.getVersion() > (short)1) m.setPreviousDOI(this.getPreviousDOI(d.getGroupId(), d.getId()));
|
if (d.getVersion() > (short)1) m.setPreviousDOI(this.getPreviousDOI(d.getGroupId(), d.getId()));
|
||||||
switch (d.getAccessType()){
|
switch (d.getAccessType()){
|
||||||
case Public -> m.setAccessType(DmpAccessType.Public);
|
case Public -> m.setAccessType(DmpAccessType.Public);
|
||||||
|
@ -197,7 +195,7 @@ public class DmpCommonModelBuilder extends BaseCommonModelBuilder<DmpModel, DmpE
|
||||||
|
|
||||||
Map<UUID, List<DescriptionModel>> itemMap;
|
Map<UUID, List<DescriptionModel>> itemMap;
|
||||||
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).isActive(IsActive.Active).authorize(this.authorize).dmpIds(data.stream().map(DmpEntity::getId).distinct().collect(Collectors.toList()));
|
||||||
itemMap = this.builderFactory.builder(DescriptionCommonModelBuilder.class).authorize(this.authorize).asMasterKey(query, DescriptionEntity::getDmpId);
|
itemMap = this.builderFactory.builder(DescriptionCommonModelBuilder.class).useSharedStorage(useSharedStorage).authorize(this.authorize).asMasterKey(query, DescriptionEntity::getDmpId);
|
||||||
|
|
||||||
return itemMap;
|
return itemMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class DescriptionCensor extends BaseCensor {
|
||||||
if (fields == null || fields.isEmpty())
|
if (fields == null || fields.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseDescription);
|
this.authService.authorizeForce(Permission.BrowseDescription, Permission.DeferredAffiliation);
|
||||||
|
|
||||||
FieldSet descriptionReferenceFields = fields.extractPrefixed(this.asIndexerPrefix(Description._descriptionReferences));
|
FieldSet descriptionReferenceFields = fields.extractPrefixed(this.asIndexerPrefix(Description._descriptionReferences));
|
||||||
this.censorFactory.censor(DescriptionReferenceCensor.class).censor(descriptionReferenceFields, userId);
|
this.censorFactory.censor(DescriptionReferenceCensor.class).censor(descriptionReferenceFields, userId);
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class DmpCensor extends BaseCensor {
|
||||||
if (fields.isEmpty())
|
if (fields.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseDmp);
|
this.authService.authorizeForce(Permission.BrowseDmp, Permission.DeferredAffiliation);
|
||||||
|
|
||||||
FieldSet dmpUsersFields = fields.extractPrefixed(this.asIndexerPrefix(Dmp._dmpUsers));
|
FieldSet dmpUsersFields = fields.extractPrefixed(this.asIndexerPrefix(Dmp._dmpUsers));
|
||||||
this.censorFactory.censor(DmpUserCensor.class).censor(dmpUsersFields, userId);
|
this.censorFactory.censor(DmpUserCensor.class).censor(dmpUsersFields, userId);
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class DmpDescriptionTemplateCensor extends BaseCensor{
|
||||||
if (fields == null || fields.isEmpty())
|
if (fields == null || fields.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseDescription);
|
this.authService.authorizeForce(Permission.BrowseDescription, Permission.DeferredAffiliation);
|
||||||
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._dmp));
|
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._dmp));
|
||||||
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
||||||
FieldSet descriptionTemplatesFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._descriptionTemplates));
|
FieldSet descriptionTemplatesFields = fields.extractPrefixed(this.asIndexerPrefix(DmpDescriptionTemplate._descriptionTemplates));
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class DmpReferenceCensor extends BaseCensor {
|
||||||
if (fields == null || fields.isEmpty())
|
if (fields == null || fields.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseDmpDescriptionTemplate);
|
this.authService.authorizeForce(Permission.BrowseDmpDescriptionTemplate, Permission.DeferredAffiliation);
|
||||||
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._dmp));
|
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._dmp));
|
||||||
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
||||||
FieldSet templateFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._reference));
|
FieldSet templateFields = fields.extractPrefixed(this.asIndexerPrefix(DmpReference._reference));
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class DmpUserCensor extends BaseCensor {
|
||||||
if (fields == null || fields.isEmpty())
|
if (fields == null || fields.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseDmpUser);
|
this.authService.authorizeForce(Permission.BrowseDmpUser, Permission.DeferredAffiliation);
|
||||||
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpUser._dmp));
|
FieldSet dmpFields = fields.extractPrefixed(this.asIndexerPrefix(DmpUser._dmp));
|
||||||
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
this.censorFactory.censor(DmpCensor.class).censor(dmpFields, userId);
|
||||||
FieldSet userFields = fields.extractPrefixed(this.asIndexerPrefix(DmpUser._user));
|
FieldSet userFields = fields.extractPrefixed(this.asIndexerPrefix(DmpUser._user));
|
||||||
|
|
|
@ -31,6 +31,6 @@ public class EntityDoiCensor extends BaseCensor{
|
||||||
if (fields == null || fields.isEmpty())
|
if (fields == null || fields.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseEntityDoi);
|
this.authService.authorizeForce(Permission.BrowseEntityDoi, Permission.DeferredAffiliation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class ReferenceTypeCensor extends BaseCensor {
|
||||||
if (fields == null || fields.isEmpty())
|
if (fields == null || fields.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.authService.authorizeForce(Permission.BrowseReferenceType);
|
this.authService.authorizeForce(Permission.BrowseReferenceType, Permission.DeferredAffiliation);
|
||||||
FieldSet definitionFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceType._definition));
|
FieldSet definitionFields = fields.extractPrefixed(this.asIndexerPrefix(ReferenceType._definition));
|
||||||
this.censorFactory.censor(ReferenceTypeDefinitionCensor.class).censor(definitionFields, userId);
|
this.censorFactory.censor(ReferenceTypeDefinitionCensor.class).censor(definitionFields, userId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class UserCensor extends BaseCensor {
|
||||||
logger.debug(new DataLogEntry("censoring fields", fields));
|
logger.debug(new DataLogEntry("censoring fields", fields));
|
||||||
if (fields == null || fields.isEmpty())
|
if (fields == null || fields.isEmpty())
|
||||||
return;
|
return;
|
||||||
this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseUser);
|
this.authService.authorizeAtLeastOneForce(userId != null ? List.of(new OwnedResource(userId)) : null, Permission.BrowseUser, Permission.DeferredAffiliation);
|
||||||
|
|
||||||
FieldSet rolesFields = fields.extractPrefixed(this.asIndexerPrefix(User._roles));
|
FieldSet rolesFields = fields.extractPrefixed(this.asIndexerPrefix(User._roles));
|
||||||
this.censorFactory.censor(UserRoleCensor.class).censor(rolesFields, userId);
|
this.censorFactory.censor(UserRoleCensor.class).censor(rolesFields, userId);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.UUID;
|
||||||
public class ExportRequestModel {
|
public class ExportRequestModel {
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
private String repositoryId;
|
||||||
private String format;
|
private String format;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
|
@ -22,4 +23,12 @@ public class ExportRequestModel {
|
||||||
public void setFormat(String format) {
|
public void setFormat(String format) {
|
||||||
this.format = format;
|
this.format = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRepositoryId() {
|
||||||
|
return repositoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRepositoryId(String repositoryId) {
|
||||||
|
this.repositoryId = repositoryId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,12 @@ import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.enums.DmpUserRole;
|
import eu.eudat.commons.enums.DmpUserRole;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import eu.eudat.data.DmpReferenceEntity;
|
||||||
import eu.eudat.data.DmpUserEntity;
|
import eu.eudat.data.DmpUserEntity;
|
||||||
|
import eu.eudat.data.ReferenceEntity;
|
||||||
import eu.eudat.model.DmpUser;
|
import eu.eudat.model.DmpUser;
|
||||||
import eu.eudat.model.PublicDmpUser;
|
import eu.eudat.model.PublicDmpUser;
|
||||||
|
import eu.eudat.query.utils.BuildSubQueryInput;
|
||||||
import eu.eudat.query.utils.QueryUtilsService;
|
import eu.eudat.query.utils.QueryUtilsService;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.query.FieldResolver;
|
import gr.cite.tools.data.query.FieldResolver;
|
||||||
|
@ -173,7 +176,7 @@ public class DmpUserQuery extends QueryBase<DmpUserEntity> {
|
||||||
if (userId != null || usePublic ) {
|
if (userId != null || usePublic ) {
|
||||||
predicates.add(queryContext.CriteriaBuilder.or(
|
predicates.add(queryContext.CriteriaBuilder.or(
|
||||||
usePublic ? queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._dmpId)).value(queryUtilsService.buildPublicDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, usePublic)) : queryContext.CriteriaBuilder.or(), //Creates a false query
|
usePublic ? queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._dmpId)).value(queryUtilsService.buildPublicDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, usePublic)) : queryContext.CriteriaBuilder.or(), //Creates a false query
|
||||||
userId != null ? queryContext.CriteriaBuilder.equal(queryContext.Root.get(DmpUserEntity._userId), userId) : queryContext.CriteriaBuilder.or() //Creates a false query
|
userId != null ? queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._dmpId)).value(queryUtilsService.buildDmpUserAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId)) : queryContext.CriteriaBuilder.or() //Creates a false query
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if (!predicates.isEmpty()) {
|
if (!predicates.isEmpty()) {
|
||||||
|
@ -183,7 +186,7 @@ public class DmpUserQuery extends QueryBase<DmpUserEntity> {
|
||||||
return queryContext.CriteriaBuilder.or(); //Creates a false query
|
return queryContext.CriteriaBuilder.or(); //Creates a false query
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||||
List<Predicate> predicates = new ArrayList<>();
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
package eu.eudat.query;
|
package eu.eudat.query;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.enums.EntityType;
|
import eu.eudat.commons.enums.EntityType;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.*;
|
||||||
import eu.eudat.data.EntityDoiEntity;
|
|
||||||
import eu.eudat.model.Dmp;
|
import eu.eudat.model.Dmp;
|
||||||
import eu.eudat.model.EntityDoi;
|
import eu.eudat.model.EntityDoi;
|
||||||
|
import eu.eudat.query.utils.BuildSubQueryInput;
|
||||||
|
import eu.eudat.query.utils.QueryUtilsService;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.query.FieldResolver;
|
import gr.cite.tools.data.query.FieldResolver;
|
||||||
import gr.cite.tools.data.query.QueryBase;
|
import gr.cite.tools.data.query.QueryBase;
|
||||||
|
@ -151,10 +153,19 @@ public class EntityDoiQuery extends QueryBase<EntityDoiEntity> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final UserScope userScope;
|
||||||
|
|
||||||
|
private final AuthorizationService authService;
|
||||||
|
|
||||||
|
private final QueryUtilsService queryUtilsService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public EntityDoiQuery(
|
public EntityDoiQuery(
|
||||||
) {
|
UserScope userScope, AuthorizationService authService, QueryUtilsService queryUtilsService) {
|
||||||
|
this.userScope = userScope;
|
||||||
|
this.authService = authService;
|
||||||
|
this.queryUtilsService = queryUtilsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -167,6 +178,27 @@ public class EntityDoiQuery extends QueryBase<EntityDoiEntity> {
|
||||||
return this.isEmpty(this.ids) || this.isEmpty(this.isActives)|| this.isEmpty(this.repositoryIds) || this.isEmpty(this.excludedIds) || this.isEmpty(this.types);
|
return this.isEmpty(this.ids) || this.isEmpty(this.isActives)|| this.isEmpty(this.repositoryIds) || this.isEmpty(this.excludedIds) || this.isEmpty(this.types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <X, Y> Predicate applyAuthZ(QueryContext<X, Y> queryContext) {
|
||||||
|
if (this.authorize.contains(AuthorizationFlags.None)) return null;
|
||||||
|
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) return null;
|
||||||
|
UUID userId;
|
||||||
|
if (this.authorize.contains(AuthorizationFlags.Owner)) userId = this.userScope.getUserIdSafe();
|
||||||
|
else userId = null;
|
||||||
|
|
||||||
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
boolean usePublic = this.authorize.contains(AuthorizationFlags.Public);
|
||||||
|
if (userId != null || usePublic) {
|
||||||
|
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(EntityDoiEntity._entityId)).value( queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpUserEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))));
|
||||||
|
}
|
||||||
|
if (!predicates.isEmpty()) {
|
||||||
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
|
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||||
|
} else {
|
||||||
|
return queryContext.CriteriaBuilder.or(); //Creates a false query
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||||
List<Predicate> predicates = new ArrayList<>();
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
|
|
@ -1,12 +1,21 @@
|
||||||
package eu.eudat.query;
|
package eu.eudat.query;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.commons.enums.DmpAccessType;
|
||||||
|
import eu.eudat.commons.enums.DmpStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.enums.ReferenceSourceType;
|
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||||
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.DmpReferenceEntity;
|
import eu.eudat.data.DmpReferenceEntity;
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.ReferenceEntity;
|
import eu.eudat.data.ReferenceEntity;
|
||||||
import eu.eudat.model.PublicReference;
|
import eu.eudat.model.PublicReference;
|
||||||
import eu.eudat.model.Reference;
|
import eu.eudat.model.Reference;
|
||||||
|
import eu.eudat.query.utils.BuildSubQueryInput;
|
||||||
|
import eu.eudat.query.utils.QueryUtilsService;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.query.FieldResolver;
|
import gr.cite.tools.data.query.FieldResolver;
|
||||||
import gr.cite.tools.data.query.QueryBase;
|
import gr.cite.tools.data.query.QueryBase;
|
||||||
import gr.cite.tools.data.query.QueryContext;
|
import gr.cite.tools.data.query.QueryContext;
|
||||||
|
@ -163,9 +172,16 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
||||||
this.authorize = values;
|
this.authorize = values;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
private final UserScope userScope;
|
||||||
|
|
||||||
|
private final AuthorizationService authService;
|
||||||
|
private final QueryUtilsService queryUtilsService;
|
||||||
|
|
||||||
public ReferenceQuery(
|
public ReferenceQuery(
|
||||||
) {
|
UserScope userScope, AuthorizationService authService, QueryUtilsService queryUtilsService) {
|
||||||
|
this.userScope = userScope;
|
||||||
|
this.authService = authService;
|
||||||
|
this.queryUtilsService = queryUtilsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -178,6 +194,38 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
||||||
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.sources) ||this.isEmpty(this.excludedIds) || this.isEmpty(this.typeIds) || this.isEmpty(this.referenceSourceTypes)|| this.isFalseQuery(this.dmpReferenceQuery);
|
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.sources) ||this.isEmpty(this.excludedIds) || this.isEmpty(this.typeIds) || this.isEmpty(this.referenceSourceTypes)|| this.isFalseQuery(this.dmpReferenceQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected <X, Y> Predicate applyAuthZ(QueryContext<X, Y> queryContext) {
|
||||||
|
if (this.authorize.contains(AuthorizationFlags.None)) return null;
|
||||||
|
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseReference)) return null;
|
||||||
|
UUID userId;
|
||||||
|
boolean usePublic = this.authorize.contains(AuthorizationFlags.Public);
|
||||||
|
if (this.authorize.contains(AuthorizationFlags.DmpAssociated)) userId = this.userScope.getUserIdSafe();
|
||||||
|
else userId = null;
|
||||||
|
|
||||||
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
if (userId != null || usePublic ) {
|
||||||
|
predicates.add(queryContext.CriteriaBuilder.or(
|
||||||
|
queryContext.CriteriaBuilder.isNull(queryContext.Root.get(ReferenceEntity._createdById)),
|
||||||
|
userId != null ? queryContext.CriteriaBuilder.equal(queryContext.Root.get(ReferenceEntity._createdById), userId) : queryContext.CriteriaBuilder.or(), //Creates a false query
|
||||||
|
userId != null ? queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._id)).value(queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(DmpReferenceEntity.class, UUID.class)
|
||||||
|
.query(queryContext.Query)
|
||||||
|
.criteriaBuilder(queryContext.CriteriaBuilder)
|
||||||
|
.keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpReferenceEntity._referenceId))
|
||||||
|
.filterFunc((subQueryRoot, cb) ->
|
||||||
|
cb.in(subQueryRoot.get(DmpReferenceEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic))
|
||||||
|
)
|
||||||
|
))) : queryContext.CriteriaBuilder.or() //Creates a false query
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if (!predicates.isEmpty()) {
|
||||||
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
|
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||||
|
} else {
|
||||||
|
return queryContext.CriteriaBuilder.or(); //Creates a false query
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
protected <X, Y> Predicate applyFilters(QueryContext<X, Y> queryContext) {
|
||||||
List<Predicate> predicates = new ArrayList<>();
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
|
|
|
@ -150,11 +150,24 @@ public class UserQuery extends QueryBase<UserEntity> {
|
||||||
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) return null;
|
if (this.authorize.contains(AuthorizationFlags.Permission) && this.authService.authorize(Permission.BrowseUser)) return null;
|
||||||
UUID userId;
|
UUID userId;
|
||||||
if (this.authorize.contains(AuthorizationFlags.Owner)) userId = this.userScope.getUserIdSafe();
|
if (this.authorize.contains(AuthorizationFlags.Owner)) userId = this.userScope.getUserIdSafe();
|
||||||
|
if (this.authorize.contains(AuthorizationFlags.Public)) userId = this.userScope.getUserIdSafe();
|
||||||
else userId = null;
|
else userId = null;
|
||||||
|
|
||||||
List<Predicate> predicates = new ArrayList<>();
|
List<Predicate> predicates = new ArrayList<>();
|
||||||
if (userId != null) {
|
boolean usePublic = this.authorize.contains(AuthorizationFlags.Public);
|
||||||
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)).value(userId));
|
if (userId != null || usePublic) {
|
||||||
|
UUID finalUserId = userId;
|
||||||
|
predicates.add(queryContext.CriteriaBuilder.or(
|
||||||
|
userId != null ? queryContext.CriteriaBuilder.in(queryContext.Root.get(UserEntity._id)).value(userId) : queryContext.CriteriaBuilder.or(), //Creates a false query
|
||||||
|
queryContext.CriteriaBuilder.in(queryContext.Root.get(ReferenceEntity._id)).value(queryUtilsService.buildSubQuery(new BuildSubQueryInput<>(new BuildSubQueryInput.Builder<>(DmpUserEntity.class, UUID.class)
|
||||||
|
.query(queryContext.Query)
|
||||||
|
.criteriaBuilder(queryContext.CriteriaBuilder)
|
||||||
|
.keyPathFunc((subQueryRoot) -> subQueryRoot.get(DmpUserEntity._userId))
|
||||||
|
.filterFunc((subQueryRoot, cb) ->
|
||||||
|
cb.in(subQueryRoot.get(DmpUserEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, finalUserId, usePublic))
|
||||||
|
)
|
||||||
|
)))
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if (!predicates.isEmpty()) {
|
if (!predicates.isEmpty()) {
|
||||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||||
|
|
|
@ -52,7 +52,8 @@ public class QueryUtilsServiceImpl implements QueryUtilsService {
|
||||||
.filterFunc((subQueryRoot, cb) -> cb.or(
|
.filterFunc((subQueryRoot, cb) -> cb.or(
|
||||||
usePublic ? cb.and(
|
usePublic ? cb.and(
|
||||||
cb.equal(subQueryRoot.get(DescriptionEntity._status), DescriptionStatus.Finalized),
|
cb.equal(subQueryRoot.get(DescriptionEntity._status), DescriptionStatus.Finalized),
|
||||||
cb.equal(subQueryRoot.get(DescriptionEntity._isActive), IsActive.Active)
|
cb.equal(subQueryRoot.get(DescriptionEntity._isActive), IsActive.Active),
|
||||||
|
cb.in(subQueryRoot.get(DescriptionEntity._dmpId)).value(this.buildDmpAuthZSubQuery(query, criteriaBuilder, userId, usePublic))
|
||||||
): cb.or(), //Creates a false query
|
): cb.or(), //Creates a false query
|
||||||
userId != null ? cb.equal(subQueryRoot.get(DescriptionEntity._createdById), userId) : cb.or() //Creates a false query
|
userId != null ? cb.equal(subQueryRoot.get(DescriptionEntity._createdById), userId) : cb.or() //Creates a false query
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,14 +3,10 @@ package eu.eudat.service.dashborad;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.authorization.OwnedResource;
|
import eu.eudat.authorization.OwnedResource;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.JsonHandlingService;
|
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
|
||||||
import eu.eudat.commons.enums.*;
|
import eu.eudat.commons.enums.*;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.commons.types.dashborad.RecentActivityItemEntity;
|
import eu.eudat.commons.types.dashborad.RecentActivityItemEntity;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
|
||||||
import eu.eudat.event.EventBroker;
|
|
||||||
import eu.eudat.model.*;
|
import eu.eudat.model.*;
|
||||||
import eu.eudat.model.builder.PublicReferenceTypeBuilder;
|
import eu.eudat.model.builder.PublicReferenceTypeBuilder;
|
||||||
import eu.eudat.model.builder.RecentActivityItemBuilder;
|
import eu.eudat.model.builder.RecentActivityItemBuilder;
|
||||||
|
@ -21,15 +17,12 @@ import eu.eudat.query.lookup.DmpLookup;
|
||||||
import eu.eudat.service.elastic.ElasticQueryHelperService;
|
import eu.eudat.service.elastic.ElasticQueryHelperService;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.MessageSource;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
|
@ -76,14 +69,14 @@ public class DashboardServiceImpl implements DashboardService {
|
||||||
List<RecentActivityItemEntity> recentActivityItemEntities = new ArrayList<>();
|
List<RecentActivityItemEntity> recentActivityItemEntities = new ArrayList<>();
|
||||||
DescriptionLookup descriptionLookup = model.asDescriptionLookup();
|
DescriptionLookup descriptionLookup = model.asDescriptionLookup();
|
||||||
descriptionLookup.getPage().setOffset(0);
|
descriptionLookup.getPage().setOffset(0);
|
||||||
QueryResult<Description> descriptions = this.elasticQueryHelperService.collect(descriptionLookup, AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic, new BaseFieldSet().ensure(Description._id).ensure(Description._updatedAt).ensure(Description._status).ensure(Description._label));
|
QueryResult<Description> descriptions = this.elasticQueryHelperService.collect(descriptionLookup, AuthorizationFlags.OwnerOrDmpAssociatedOrPermission, new BaseFieldSet().ensure(Description._id).ensure(Description._updatedAt).ensure(Description._status).ensure(Description._label));
|
||||||
if (!this.conventionService.isListNullOrEmpty(descriptions.getItems())) {
|
if (!this.conventionService.isListNullOrEmpty(descriptions.getItems())) {
|
||||||
for (Description description : descriptions.getItems()) recentActivityItemEntities.add(new RecentActivityItemEntity(RecentActivityItemType.Description, description.getId(), description.getUpdatedAt(), description.getLabel(), description.getStatus().getValue()));
|
for (Description description : descriptions.getItems()) recentActivityItemEntities.add(new RecentActivityItemEntity(RecentActivityItemType.Description, description.getId(), description.getUpdatedAt(), description.getLabel(), description.getStatus().getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DmpLookup dmpLookup = model.asDmpLookup();
|
DmpLookup dmpLookup = model.asDmpLookup();
|
||||||
dmpLookup.getPage().setOffset(0);
|
dmpLookup.getPage().setOffset(0);
|
||||||
QueryResult<Dmp> dmps = this.elasticQueryHelperService.collect(dmpLookup, AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic, new BaseFieldSet().ensure(Dmp._id).ensure(Dmp._updatedAt).ensure(Dmp._label).ensure(Dmp._status));
|
QueryResult<Dmp> dmps = this.elasticQueryHelperService.collect(dmpLookup, AuthorizationFlags.OwnerOrDmpAssociatedOrPermission, new BaseFieldSet().ensure(Dmp._id).ensure(Dmp._updatedAt).ensure(Dmp._label).ensure(Dmp._status));
|
||||||
if (!this.conventionService.isListNullOrEmpty(dmps.getItems())) {
|
if (!this.conventionService.isListNullOrEmpty(dmps.getItems())) {
|
||||||
for (Dmp dmp : dmps.getItems()) recentActivityItemEntities.add(new RecentActivityItemEntity(RecentActivityItemType.Dmp, dmp.getId(), dmp.getUpdatedAt(), dmp.getLabel(), dmp.getStatus().getValue()));
|
for (Dmp dmp : dmps.getItems()) recentActivityItemEntities.add(new RecentActivityItemEntity(RecentActivityItemType.Dmp, dmp.getId(), dmp.getUpdatedAt(), dmp.getLabel(), dmp.getStatus().getValue()));
|
||||||
}
|
}
|
||||||
|
@ -102,7 +95,7 @@ public class DashboardServiceImpl implements DashboardService {
|
||||||
if (model.getPage() != null){
|
if (model.getPage() != null){
|
||||||
recentActivityItemEntities = recentActivityItemEntities.stream().skip(model.getPage().getOffset()).limit(model.getPage().getSize()).toList();
|
recentActivityItemEntities = recentActivityItemEntities.stream().skip(model.getPage().getOffset()).limit(model.getPage().getSize()).toList();
|
||||||
}
|
}
|
||||||
return this.builderFactory.builder(RecentActivityItemBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(model.getProject()), recentActivityItemEntities);
|
return this.builderFactory.builder(RecentActivityItemBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(model.getProject()), recentActivityItemEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,18 +4,26 @@ import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commonmodels.models.FileEnvelopeModel;
|
import eu.eudat.commonmodels.models.FileEnvelopeModel;
|
||||||
import eu.eudat.commonmodels.models.dmp.DmpModel;
|
import eu.eudat.commonmodels.models.dmp.DmpModel;
|
||||||
|
import eu.eudat.commons.enums.StorageType;
|
||||||
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.configurations.deposit.DepositProperties;
|
import eu.eudat.configurations.deposit.DepositProperties;
|
||||||
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DmpEntity;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.depositinterface.repository.DepositClient;
|
import eu.eudat.depositinterface.repository.DepositClient;
|
||||||
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
import eu.eudat.depositinterface.repository.DepositConfiguration;
|
||||||
import eu.eudat.model.EntityDoi;
|
import eu.eudat.model.EntityDoi;
|
||||||
|
import eu.eudat.model.StorageFile;
|
||||||
import eu.eudat.model.builder.commonmodels.DepositConfigurationBuilder;
|
import eu.eudat.model.builder.commonmodels.DepositConfigurationBuilder;
|
||||||
import eu.eudat.model.builder.commonmodels.dmp.DmpCommonModelBuilder;
|
import eu.eudat.model.builder.commonmodels.dmp.DmpCommonModelBuilder;
|
||||||
|
import eu.eudat.model.persist.StorageFilePersist;
|
||||||
import eu.eudat.model.persist.deposit.DepositAuthenticateRequest;
|
import eu.eudat.model.persist.deposit.DepositAuthenticateRequest;
|
||||||
import eu.eudat.model.persist.deposit.DepositRequest;
|
import eu.eudat.model.persist.deposit.DepositRequest;
|
||||||
import eu.eudat.model.persist.EntityDoiPersist;
|
import eu.eudat.model.persist.EntityDoiPersist;
|
||||||
import eu.eudat.query.DmpQuery;
|
import eu.eudat.query.DmpQuery;
|
||||||
import eu.eudat.service.entitydoi.EntityDoiService;
|
import eu.eudat.service.entitydoi.EntityDoiService;
|
||||||
|
import eu.eudat.service.storage.StorageFileProperties;
|
||||||
|
import eu.eudat.service.storage.StorageFileService;
|
||||||
|
import eu.eudat.service.transformer.FileTransformerService;
|
||||||
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService;
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction;
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction;
|
||||||
|
@ -23,7 +31,10 @@ import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeModel;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
|
import gr.cite.tools.validation.ValidatorFactory;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -32,11 +43,11 @@ import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.net.URLConnection;
|
||||||
import java.util.HashMap;
|
import java.time.Duration;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DepositServiceImpl implements DepositService {
|
public class DepositServiceImpl implements DepositService {
|
||||||
|
@ -52,7 +63,12 @@ public class DepositServiceImpl implements DepositService {
|
||||||
private final MessageSource messageSource;
|
private final MessageSource messageSource;
|
||||||
private final BuilderFactory builderFactory;
|
private final BuilderFactory builderFactory;
|
||||||
private final DepositConfigurationCacheService depositConfigurationCacheService;
|
private final DepositConfigurationCacheService depositConfigurationCacheService;
|
||||||
|
private final FileTransformerService fileTransformerService;
|
||||||
|
private final StorageFileService storageFileService;
|
||||||
|
private final UserScope userScope;
|
||||||
|
private final ValidatorFactory validatorFactory;
|
||||||
|
private final StorageFileProperties storageFileProperties;
|
||||||
|
private final ConventionService conventionService;
|
||||||
@Autowired
|
@Autowired
|
||||||
public DepositServiceImpl(DepositProperties depositProperties,
|
public DepositServiceImpl(DepositProperties depositProperties,
|
||||||
TokenExchangeCacheService tokenExchangeCacheService,
|
TokenExchangeCacheService tokenExchangeCacheService,
|
||||||
|
@ -61,7 +77,7 @@ public class DepositServiceImpl implements DepositService {
|
||||||
EntityDoiService doiService,
|
EntityDoiService doiService,
|
||||||
QueryFactory queryFactory,
|
QueryFactory queryFactory,
|
||||||
MessageSource messageSource,
|
MessageSource messageSource,
|
||||||
BuilderFactory builderFactory, DepositConfigurationCacheService depositConfigurationCacheService) {
|
BuilderFactory builderFactory, DepositConfigurationCacheService depositConfigurationCacheService, FileTransformerService fileTransformerService, StorageFileService storageFileService, UserScope userScope, ValidatorFactory validatorFactory, StorageFileProperties storageFileProperties, ConventionService conventionService) {
|
||||||
this.depositProperties = depositProperties;
|
this.depositProperties = depositProperties;
|
||||||
this.tokenExchangeCacheService = tokenExchangeCacheService;
|
this.tokenExchangeCacheService = tokenExchangeCacheService;
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
|
@ -71,6 +87,12 @@ public class DepositServiceImpl implements DepositService {
|
||||||
this.messageSource = messageSource;
|
this.messageSource = messageSource;
|
||||||
this.builderFactory = builderFactory;
|
this.builderFactory = builderFactory;
|
||||||
this.depositConfigurationCacheService = depositConfigurationCacheService;
|
this.depositConfigurationCacheService = depositConfigurationCacheService;
|
||||||
|
this.fileTransformerService = fileTransformerService;
|
||||||
|
this.storageFileService = storageFileService;
|
||||||
|
this.userScope = userScope;
|
||||||
|
this.validatorFactory = validatorFactory;
|
||||||
|
this.storageFileProperties = storageFileProperties;
|
||||||
|
this.conventionService = conventionService;
|
||||||
this.clients = new HashMap<>();
|
this.clients = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,29 +152,31 @@ public class DepositServiceImpl implements DepositService {
|
||||||
|
|
||||||
//GK: Forth make the required files to be uploaded with the deposit
|
//GK: Forth make the required files to be uploaded with the deposit
|
||||||
//TODO: Properly create required files
|
//TODO: Properly create required files
|
||||||
FileEnvelopeModel docEnvelope = new FileEnvelopeModel();
|
DepositProperties.DepositSource source = depositProperties.getSources().stream().filter(depositSource -> depositSource.getRepositoryId().equals(dmpDepositModel.getRepositoryId())).findFirst().orElse(null);
|
||||||
|
if (source == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpDepositModel.getRepositoryId(), DepositProperties.DepositSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
eu.eudat.model.file.FileEnvelope pdfFile = this.fileTransformerService.exportDmp(dmpEntity.getId(), source.getPdfTransformerId(),"pdf");
|
||||||
|
eu.eudat.model.file.FileEnvelope rda = this.fileTransformerService.exportDmp(dmpEntity.getId(), source.getRdaTransformerId(),"json");
|
||||||
|
|
||||||
FileEnvelopeModel pdfEnvelope = new FileEnvelopeModel();
|
FileEnvelopeModel pdfEnvelope = new FileEnvelopeModel();
|
||||||
FileEnvelopeModel jsonEnvelope = new FileEnvelopeModel();
|
FileEnvelopeModel jsonEnvelope = new FileEnvelopeModel();
|
||||||
FileEnvelopeModel zip = new FileEnvelopeModel();
|
|
||||||
//TODO: Create Files
|
pdfEnvelope.setFilename(pdfFile.getFilename());
|
||||||
// File zip = new File(environment.getProperty("temp.temp") + UUID.randomUUID() + ".zip");
|
jsonEnvelope.setMimeType("application/pdf");
|
||||||
// try {
|
jsonEnvelope.setFilename(rda.getFilename());
|
||||||
// docEnvelope.setFilename("test.docx");
|
jsonEnvelope.setMimeType("application/json");
|
||||||
// docEnvelope.setFile(this.storageFileService.getH2020TemplateFile());
|
if (!depositClient.getConfiguration().isUseSharedStorage()){
|
||||||
// File pdfFile = PDFUtils.convertToPDF(docEnvelope, environment);
|
pdfEnvelope.setFile(pdfFile.getFile());
|
||||||
// pdfEnvelope.setFilename("test.pdf");
|
jsonEnvelope.setFile(rda.getFile());
|
||||||
// pdfEnvelope.setFile(pdfFile);
|
} else {
|
||||||
// File jsonFile = new File(this.environment.getProperty("temp.temp") + UUID.randomUUID() + ".json");
|
pdfEnvelope.setFileRef(this.addFileToSharedStorage(pdfFile));
|
||||||
// jsonEnvelope.setFilename("test.json");
|
jsonEnvelope.setFileRef(this.addFileToSharedStorage(rda));
|
||||||
// jsonEnvelope.setFile(jsonFile);
|
}
|
||||||
//
|
|
||||||
// } catch (IOException e) {
|
|
||||||
// logger.error(e.getMessage(), e);
|
|
||||||
// }
|
|
||||||
|
|
||||||
//GK: Fifth Transform them to the DepositModel
|
//GK: Fifth Transform them to the DepositModel
|
||||||
DmpModel depositModel = this.builderFactory.builder(DmpCommonModelBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic)
|
DmpModel depositModel = this.builderFactory.builder(DmpCommonModelBuilder.class).useSharedStorage(depositClient.getConfiguration().isUseSharedStorage()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission)
|
||||||
.setRepositoryId(dmpDepositModel.getRepositoryId()).setPdfFile(pdfEnvelope).setRdaJsonFile(jsonEnvelope).setSupportingFilesZip(zip).build(dmpEntity);
|
.setRepositoryId(dmpDepositModel.getRepositoryId()).setPdfFile(pdfEnvelope).setRdaJsonFile(jsonEnvelope).build(dmpEntity);
|
||||||
|
|
||||||
|
|
||||||
//GK: Sixth Perform the deposit
|
//GK: Sixth Perform the deposit
|
||||||
String doi = depositClient.deposit(depositModel, dmpDepositModel.getAccessToken());
|
String doi = depositClient.deposit(depositModel, dmpDepositModel.getAccessToken());
|
||||||
|
@ -165,6 +189,19 @@ public class DepositServiceImpl implements DepositService {
|
||||||
doiPersist.setEntityId(dmpEntity.getId());
|
doiPersist.setEntityId(dmpEntity.getId());
|
||||||
return doiService.persist(doiPersist, dmpDepositModel.getProject());
|
return doiService.persist(doiPersist, dmpDepositModel.getProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String addFileToSharedStorage(eu.eudat.model.file.FileEnvelope file) throws IOException {
|
||||||
|
StorageFilePersist storageFilePersist = new StorageFilePersist();
|
||||||
|
storageFilePersist.setName(FilenameUtils.removeExtension(file.getFilename()));
|
||||||
|
storageFilePersist.setExtension(FilenameUtils.getExtension(file.getFilename()));
|
||||||
|
storageFilePersist.setMimeType(URLConnection.guessContentTypeFromName(file.getFilename()));
|
||||||
|
storageFilePersist.setOwnerId(this.userScope.getUserIdSafe());
|
||||||
|
storageFilePersist.setStorageType(StorageType.Temp);
|
||||||
|
storageFilePersist.setLifetime(Duration.ofSeconds(this.storageFileProperties.getTempStoreLifetimeSeconds())); //TODO
|
||||||
|
this.validatorFactory.validator(StorageFilePersist.StorageFilePersistValidator.class).validateForce(storageFilePersist);
|
||||||
|
StorageFile persisted = this.storageFileService.persistBytes(storageFilePersist, file.getFile(), new BaseFieldSet(StorageFile._id, StorageFile._fileRef));
|
||||||
|
return persisted.getFileRef();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLogo(String repositoryId) {
|
public String getLogo(String repositoryId) {
|
||||||
|
|
|
@ -20,7 +20,6 @@ import eu.eudat.data.*;
|
||||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||||
import eu.eudat.event.DescriptionTouchedEvent;
|
import eu.eudat.event.DescriptionTouchedEvent;
|
||||||
import eu.eudat.event.EventBroker;
|
import eu.eudat.event.EventBroker;
|
||||||
import eu.eudat.integrationevent.outbox.descriptiontouched.DescriptionTouchedIntegrationEvent;
|
|
||||||
import eu.eudat.integrationevent.outbox.descriptiontouched.DescriptionTouchedIntegrationEventHandler;
|
import eu.eudat.integrationevent.outbox.descriptiontouched.DescriptionTouchedIntegrationEventHandler;
|
||||||
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
|
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
|
||||||
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
|
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
|
||||||
|
@ -208,7 +207,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
this.descriptionTouchedIntegrationEventHandler.handle(DescriptionTouchedIntegrationEventHandler.buildEventFromPersistModel(model));
|
this.descriptionTouchedIntegrationEventHandler.handle(DescriptionTouchedIntegrationEventHandler.buildEventFromPersistModel(model));
|
||||||
|
|
||||||
this.elasticService.persistDescription(data);
|
this.elasticService.persistDescription(data);
|
||||||
return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Description._id), data);
|
return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Description._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendNotification(DescriptionEntity description) throws InvalidApplicationException {
|
private void sendNotification(DescriptionEntity description) throws InvalidApplicationException {
|
||||||
|
@ -358,7 +357,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
this.elasticService.persistDescription(data);
|
this.elasticService.persistDescription(data);
|
||||||
this.eventBroker.emit(new DescriptionTouchedEvent(data.getId()));
|
this.eventBroker.emit(new DescriptionTouchedEvent(data.getId()));
|
||||||
}
|
}
|
||||||
return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Description._id), data);
|
return this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Description._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull PropertyDefinitionEntity buildPropertyDefinitionEntity(PropertyDefinitionPersist persist, eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition, Map<String, List<UUID>> fieldToReferenceMap){
|
private @NotNull PropertyDefinitionEntity buildPropertyDefinitionEntity(PropertyDefinitionPersist persist, eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition, Map<String, List<UUID>> fieldToReferenceMap){
|
||||||
|
@ -746,7 +745,7 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
public StorageFile uploadFieldFile(DescriptionFieldFilePersist model, MultipartFile file, FieldSet fields) throws IOException {
|
public StorageFile uploadFieldFile(DescriptionFieldFilePersist model, MultipartFile file, FieldSet fields) throws IOException {
|
||||||
this.authorizationService.authorizeForce(Permission.EditDescription);
|
this.authorizationService.authorizeForce(Permission.EditDescription);
|
||||||
|
|
||||||
DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).ids(model.getDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).first();
|
DescriptionTemplateEntity descriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).ids(model.getDescriptionTemplateId()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).first();
|
||||||
if (descriptionTemplate == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (descriptionTemplate == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDescriptionTemplateId(), DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplate.getDefinition());
|
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplate.getDefinition());
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
this.entityManager.persist(data);
|
this.entityManager.persist(data);
|
||||||
|
|
||||||
this.persistUsers(data.getId(), model.getUsers());
|
this.persistUsers(data.getId(), model.getUsers());
|
||||||
if (!isUpdate)
|
if (this.conventionService.isListNullOrEmpty(model.getUsers()))
|
||||||
this.addOwner(data);
|
this.addOwner(data);
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
@ -211,7 +211,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
return this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, DescriptionTemplate._id), data);
|
return this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, DescriptionTemplate._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateVersionStatusAndSave(DescriptionTemplateEntity data, DescriptionTemplateStatus previousStatus, DescriptionTemplateStatus newStatus) {
|
private void updateVersionStatusAndSave(DescriptionTemplateEntity data, DescriptionTemplateStatus previousStatus, DescriptionTemplateStatus newStatus) {
|
||||||
|
@ -260,9 +260,9 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
this.sendDescriptionTemplateInvitationEvent(data, NotificationContactType.EMAIL);
|
this.sendDescriptionTemplateInvitationEvent(data, NotificationContactType.EMAIL);
|
||||||
this.sendDescriptionTemplateInvitationEvent(data, NotificationContactType.IN_APP);
|
this.sendDescriptionTemplateInvitationEvent(data, NotificationContactType.IN_APP);
|
||||||
}
|
}
|
||||||
updatedCreatedIds.add(data.getId());
|
updatedCreatedIds.add(data.getUserId());
|
||||||
}
|
}
|
||||||
List<UserDescriptionTemplateEntity> toDelete = items.stream().filter(x -> updatedCreatedIds.stream().noneMatch(y -> y.equals(x.getId()))).collect(Collectors.toList());
|
List<UserDescriptionTemplateEntity> toDelete = items.stream().filter(x -> updatedCreatedIds.stream().noneMatch(y -> y.equals(x.getUserId()))).collect(Collectors.toList());
|
||||||
|
|
||||||
this.deleterFactory.deleter(UserDescriptionTemplateDeleter.class).delete(toDelete);
|
this.deleterFactory.deleter(UserDescriptionTemplateDeleter.class).delete(toDelete);
|
||||||
}
|
}
|
||||||
|
@ -470,8 +470,8 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.CloneDescriptionTemplate);
|
this.authorizationService.authorizeForce(Permission.CloneDescriptionTemplate);
|
||||||
|
|
||||||
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
DescriptionTemplate model = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fields, query.firstAs(fields));
|
DescriptionTemplate model = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fields, query.firstAs(fields));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
@ -603,7 +603,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
return this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, DescriptionTemplate._id), data);
|
return this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, DescriptionTemplate._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class DescriptionTemplateTypeServiceImpl implements DescriptionTemplateTy
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
this.eventBroker.emit(new DescriptionTemplateTypeTouchedEvent(data.getId()));
|
this.eventBroker.emit(new DescriptionTemplateTypeTouchedEvent(data.getId()));
|
||||||
return this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, DescriptionTemplateType._id), data);
|
return this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, DescriptionTemplateType._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||||
|
|
|
@ -34,7 +34,7 @@ public interface DmpService {
|
||||||
List<DmpUser> assignUsers(UUID dmp, List<DmpUserPersist> model, FieldSet fields) throws InvalidApplicationException, IOException;
|
List<DmpUser> assignUsers(UUID dmp, List<DmpUserPersist> model, FieldSet fields) throws InvalidApplicationException, IOException;
|
||||||
Dmp removeUser(DmpUserRemovePersist model, FieldSet fields) throws InvalidApplicationException, IOException;
|
Dmp removeUser(DmpUserRemovePersist model, FieldSet fields) throws InvalidApplicationException, IOException;
|
||||||
|
|
||||||
ResponseEntity<byte[]> export(UUID id, String exportType) throws InvalidApplicationException, IOException;
|
ResponseEntity<byte[]> export(UUID id, String transformerId, String exportType) throws InvalidApplicationException, IOException;
|
||||||
|
|
||||||
void inviteUsers(UUID id, List<DmpUserPersist> users) throws InvalidApplicationException, JAXBException, IOException;
|
void inviteUsers(UUID id, List<DmpUserPersist> users) throws InvalidApplicationException, JAXBException, IOException;
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import eu.eudat.data.*;
|
||||||
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
import eu.eudat.errorcode.ErrorThesaurusProperties;
|
||||||
import eu.eudat.event.DmpTouchedEvent;
|
import eu.eudat.event.DmpTouchedEvent;
|
||||||
import eu.eudat.event.EventBroker;
|
import eu.eudat.event.EventBroker;
|
||||||
|
import eu.eudat.integrationevent.outbox.annotationentitytouch.AnnotationEntityTouchedIntegrationEventHandler;
|
||||||
import eu.eudat.integrationevent.outbox.dmptouched.DmpTouchedIntegrationEventHandler;
|
import eu.eudat.integrationevent.outbox.dmptouched.DmpTouchedIntegrationEventHandler;
|
||||||
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
|
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEvent;
|
||||||
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
|
import eu.eudat.integrationevent.outbox.notification.NotifyIntegrationEventHandler;
|
||||||
|
@ -74,7 +75,6 @@ import javax.management.InvalidApplicationException;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -123,6 +123,8 @@ public class DmpServiceImpl implements DmpService {
|
||||||
|
|
||||||
private final DmpTouchedIntegrationEventHandler dmpTouchedIntegrationEventHandler;
|
private final DmpTouchedIntegrationEventHandler dmpTouchedIntegrationEventHandler;
|
||||||
|
|
||||||
|
private final AnnotationEntityTouchedIntegrationEventHandler annotationEntityTouchedIntegrationEventHandler;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DmpServiceImpl(
|
public DmpServiceImpl(
|
||||||
EntityManager entityManager,
|
EntityManager entityManager,
|
||||||
|
@ -143,7 +145,9 @@ public class DmpServiceImpl implements DmpService {
|
||||||
ActionConfirmationService actionConfirmationService,
|
ActionConfirmationService actionConfirmationService,
|
||||||
FileTransformerService fileTransformerService,
|
FileTransformerService fileTransformerService,
|
||||||
ValidatorFactory validatorFactory,
|
ValidatorFactory validatorFactory,
|
||||||
ElasticService elasticService, DmpTouchedIntegrationEventHandler dmpTouchedIntegrationEventHandler) {
|
ElasticService elasticService,
|
||||||
|
DmpTouchedIntegrationEventHandler dmpTouchedIntegrationEventHandler,
|
||||||
|
AnnotationEntityTouchedIntegrationEventHandler annotationEntityTouchedIntegrationEventHandler) {
|
||||||
this.entityManager = entityManager;
|
this.entityManager = entityManager;
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
this.deleterFactory = deleterFactory;
|
this.deleterFactory = deleterFactory;
|
||||||
|
@ -164,6 +168,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
this.validatorFactory = validatorFactory;
|
this.validatorFactory = validatorFactory;
|
||||||
this.elasticService = elasticService;
|
this.elasticService = elasticService;
|
||||||
this.dmpTouchedIntegrationEventHandler = dmpTouchedIntegrationEventHandler;
|
this.dmpTouchedIntegrationEventHandler = dmpTouchedIntegrationEventHandler;
|
||||||
|
this.annotationEntityTouchedIntegrationEventHandler = annotationEntityTouchedIntegrationEventHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dmp persist(DmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, IOException {
|
public Dmp persist(DmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException, JAXBException, IOException {
|
||||||
|
@ -184,15 +189,33 @@ public class DmpServiceImpl implements DmpService {
|
||||||
|
|
||||||
this.dmpTouchedIntegrationEventHandler.handle(DmpTouchedIntegrationEventHandler.buildEventFromPersistModel(model));
|
this.dmpTouchedIntegrationEventHandler.handle(DmpTouchedIntegrationEventHandler.buildEventFromPersistModel(model));
|
||||||
|
|
||||||
|
this.annotationEntityTouchedIntegrationEventHandler.handle(AnnotationEntityTouchedIntegrationEventHandler.buildEventFromPersistModel(model));
|
||||||
|
|
||||||
this.sendNotification(data);
|
this.sendNotification(data);
|
||||||
|
|
||||||
this.elasticService.persistDmp(data);
|
|
||||||
|
|
||||||
if (!this.conventionService.isListNullOrEmpty(model.getUsers())){
|
if (!this.conventionService.isListNullOrEmpty(model.getUsers())){
|
||||||
this.inviteUsers(data.getId(), model.getUsers());
|
this.inviteUsers(data.getId(), model.getUsers());
|
||||||
|
}else{
|
||||||
|
this.assignUsers(data.getId(), new ArrayList<>(), null);
|
||||||
|
this.addOwner(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.elasticService.persistDmp(data);
|
||||||
|
|
||||||
return this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Dmp._id, Dmp._hash), data);
|
return this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Dmp._id, Dmp._hash), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addOwner(DmpEntity dmpEntity) throws InvalidApplicationException {
|
||||||
|
DmpUserEntity data = new DmpUserEntity();
|
||||||
|
data.setId(UUID.randomUUID());
|
||||||
|
data.setIsActive(IsActive.Active);
|
||||||
|
data.setCreatedAt(Instant.now());
|
||||||
|
data.setUpdatedAt(Instant.now());
|
||||||
|
data.setRole(DmpUserRole.Owner);
|
||||||
|
data.setUserId(userScope.getUserId());
|
||||||
|
data.setDmpId(dmpEntity.getId());
|
||||||
|
|
||||||
|
this.entityManager.persist(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendNotification(DmpEntity dmp) throws InvalidApplicationException {
|
private void sendNotification(DmpEntity dmp) throws InvalidApplicationException {
|
||||||
|
@ -368,7 +391,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
public Dmp buildClone(CloneDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException, InvalidApplicationException {
|
public Dmp buildClone(CloneDmpPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, IOException, InvalidApplicationException {
|
||||||
this.authorizationService.authorizeForce(Permission.CloneDmp);
|
this.authorizationService.authorizeForce(Permission.CloneDmp);
|
||||||
|
|
||||||
DmpEntity existingDmpEntity = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(model.getId()).firstAs(fields);
|
DmpEntity existingDmpEntity = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(model.getId()).firstAs(fields);
|
||||||
if (!this.conventionService.isValidGuid(model.getId()) || existingDmpEntity == null)
|
if (!this.conventionService.isValidGuid(model.getId()) || existingDmpEntity == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
@ -493,7 +516,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
this.elasticService.persistDmp(dmpEntity);
|
this.elasticService.persistDmp(dmpEntity);
|
||||||
return this.builderFactory.builder(DmpUserBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fieldSet, DmpUser._id, DmpUser._hash), persisted);
|
return this.builderFactory.builder(DmpUserBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fieldSet, DmpUser._id, DmpUser._hash), persisted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -514,14 +537,14 @@ public class DmpServiceImpl implements DmpService {
|
||||||
if (dmpEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (dmpEntity == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getDmpId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
this.elasticService.persistDmp(dmpEntity);
|
this.elasticService.persistDmp(dmpEntity);
|
||||||
|
|
||||||
return this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Dmp._id, Dmp._hash), data);
|
return this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Dmp._id, Dmp._hash), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<byte[]> export(UUID id, String exportType) throws InvalidApplicationException, IOException {
|
public ResponseEntity<byte[]> export(UUID id, String transformerId, String exportType) throws InvalidApplicationException, IOException {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
|
||||||
FileEnvelope fileEnvelope = this.fileTransformerService.exportDmp(id, exportType);
|
FileEnvelope fileEnvelope = this.fileTransformerService.exportDmp(id, transformerId, exportType);
|
||||||
headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename());
|
headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename());
|
||||||
byte[] data = fileEnvelope.getFile();
|
byte[] data = fileEnvelope.getFile();
|
||||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||||
|
@ -532,7 +555,6 @@ public class DmpServiceImpl implements DmpService {
|
||||||
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
|
Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
|
||||||
|
|
||||||
DmpEntity data;
|
DmpEntity data;
|
||||||
DmpUserEntity dmpUserEntity = new DmpUserEntity();
|
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
data = this.entityManager.find(DmpEntity.class, model.getId());
|
data = this.entityManager.find(DmpEntity.class, model.getId());
|
||||||
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (data == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
@ -553,17 +575,10 @@ public class DmpServiceImpl implements DmpService {
|
||||||
data.setBlueprintId(model.getBlueprint());
|
data.setBlueprintId(model.getBlueprint());
|
||||||
data.setIsActive(IsActive.Active);
|
data.setIsActive(IsActive.Active);
|
||||||
data.setCreatedAt(Instant.now());
|
data.setCreatedAt(Instant.now());
|
||||||
|
|
||||||
dmpUserEntity.setId(UUID.randomUUID());
|
|
||||||
dmpUserEntity.setDmpId(data.getId());
|
|
||||||
dmpUserEntity.setUserId(userScope.getUserId());
|
|
||||||
dmpUserEntity.setRole(DmpUserRole.Owner);
|
|
||||||
dmpUserEntity.setCreatedAt(Instant.now());
|
|
||||||
dmpUserEntity.setUpdatedAt(Instant.now());
|
|
||||||
dmpUserEntity.setIsActive(IsActive.Active);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data.setLabel(model.getLabel());
|
data.setLabel(model.getLabel());
|
||||||
|
data.setLanguage(model.getLanguage());
|
||||||
data.setProperties(this.jsonHandlingService.toJson(this.buildDmpPropertiesEntity(model.getProperties())));
|
data.setProperties(this.jsonHandlingService.toJson(this.buildDmpPropertiesEntity(model.getProperties())));
|
||||||
data.setDescription(model.getDescription());
|
data.setDescription(model.getDescription());
|
||||||
data.setAccessType(model.getAccessType());
|
data.setAccessType(model.getAccessType());
|
||||||
|
@ -572,7 +587,6 @@ public class DmpServiceImpl implements DmpService {
|
||||||
this.entityManager.merge(data);
|
this.entityManager.merge(data);
|
||||||
else {
|
else {
|
||||||
this.entityManager.persist(data);
|
this.entityManager.persist(data);
|
||||||
this.entityManager.persist(dmpUserEntity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
@ -796,6 +810,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
throw new InvalidApplicationException("Dmp does not exist!");
|
throw new InvalidApplicationException("Dmp does not exist!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<DmpUserPersist> usersToAssign = new ArrayList<>();
|
||||||
for (DmpUserPersist user :users) {
|
for (DmpUserPersist user :users) {
|
||||||
UUID userId = null;
|
UUID userId = null;
|
||||||
if (user.getUser() != null){
|
if (user.getUser() != null){
|
||||||
|
@ -808,7 +823,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
}
|
}
|
||||||
if (userId != null){
|
if (userId != null){
|
||||||
user.setUser(userId);
|
user.setUser(userId);
|
||||||
this.assignUsers(id, List.of(user), null);
|
usersToAssign.add(user);
|
||||||
if (this.userScope.getUserId() != userId){
|
if (this.userScope.getUserId() != userId){
|
||||||
this.sendDmpInvitationExistingUser(user.getUser(), dmp, user.getRole());
|
this.sendDmpInvitationExistingUser(user.getUser(), dmp, user.getRole());
|
||||||
}
|
}
|
||||||
|
@ -817,6 +832,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if(!usersToAssign.isEmpty()) this.assignUsers(id, usersToAssign, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendDmpInvitationExistingUser(UUID userId, DmpEntity dmp, DmpUserRole role) throws InvalidApplicationException {
|
private void sendDmpInvitationExistingUser(UUID userId, DmpEntity dmp, DmpUserRole role) throws InvalidApplicationException {
|
||||||
|
@ -900,10 +916,17 @@ public class DmpServiceImpl implements DmpService {
|
||||||
}
|
}
|
||||||
|
|
||||||
DmpInvitationEntity dmpInvitation = this.xmlHandlingService.fromXmlSafe(DmpInvitationEntity.class, action.getData());
|
DmpInvitationEntity dmpInvitation = this.xmlHandlingService.fromXmlSafe(DmpInvitationEntity.class, action.getData());
|
||||||
DmpUserPersist model = new DmpUserPersist();
|
|
||||||
model.setUser(this.userScope.getUserIdSafe());
|
DmpUserEntity data = new DmpUserEntity();
|
||||||
model.setRole(dmpInvitation.getRole());
|
data.setId(UUID.randomUUID());
|
||||||
this.assignUsers(dmpInvitation.getDmpId(), List.of(model), null);
|
data.setIsActive(IsActive.Active);
|
||||||
|
data.setCreatedAt(Instant.now());
|
||||||
|
data.setUpdatedAt(Instant.now());
|
||||||
|
data.setRole(dmpInvitation.getRole());
|
||||||
|
data.setUserId(this.userScope.getUserIdSafe());
|
||||||
|
data.setDmpId(dmpInvitation.getDmpId());
|
||||||
|
this.entityManager.persist(data);
|
||||||
|
|
||||||
action.setStatus(ActionConfirmationStatus.Accepted);
|
action.setStatus(ActionConfirmationStatus.Accepted);
|
||||||
this.entityManager.merge(action);
|
this.entityManager.merge(action);
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
return this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, DmpBlueprint._id), data);
|
return this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, DmpBlueprint._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateVersionStatusAndSave(DmpBlueprintEntity data, DmpBlueprintStatus previousStatus, DmpBlueprintStatus newStatus) {
|
private void updateVersionStatusAndSave(DmpBlueprintEntity data, DmpBlueprintStatus previousStatus, DmpBlueprintStatus newStatus) {
|
||||||
|
@ -336,8 +336,8 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
|
|
||||||
this.authorizationService.authorizeForce(Permission.CloneDmpBlueprint);
|
this.authorizationService.authorizeForce(Permission.CloneDmpBlueprint);
|
||||||
|
|
||||||
DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
DmpBlueprint model = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fields, query.firstAs(fields));
|
DmpBlueprint model = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fields, query.firstAs(fields));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
@ -435,7 +435,7 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
return this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, DmpBlueprint._id), data);
|
return this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, DmpBlueprint._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class EntityDoiServiceImpl implements EntityDoiService {
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
this.eventBroker.emit(new EntityDoiTouchedEvent(data.getId()));
|
this.eventBroker.emit(new EntityDoiTouchedEvent(data.getId()));
|
||||||
return this.builderFactory.builder(EntityDoiBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, EntityDoi._id), data);
|
return this.builderFactory.builder(EntityDoiBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, EntityDoi._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||||
|
|
|
@ -25,16 +25,13 @@ import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import org.hibernate.FlushMode;
|
import org.hibernate.FlushMode;
|
||||||
import org.hibernate.annotations.FlushModeType;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -99,7 +96,7 @@ public class LanguageServiceImpl implements LanguageService {
|
||||||
//
|
//
|
||||||
// this.entityManager.flush();
|
// this.entityManager.flush();
|
||||||
|
|
||||||
return this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Language._id), data);
|
return this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Language._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPayload(String code) throws IOException {
|
public String getPayload(String code) throws IOException {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import eu.eudat.model.builder.LockBuilder;
|
||||||
import eu.eudat.model.deleter.LockDeleter;
|
import eu.eudat.model.deleter.LockDeleter;
|
||||||
import eu.eudat.model.persist.LockPersist;
|
import eu.eudat.model.persist.LockPersist;
|
||||||
import eu.eudat.query.LockQuery;
|
import eu.eudat.query.LockQuery;
|
||||||
import eu.eudat.query.lookup.LockLookup;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.deleter.DeleterFactory;
|
import gr.cite.tools.data.deleter.DeleterFactory;
|
||||||
|
@ -104,11 +103,11 @@ public class LockServiceImpl implements LockService {
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
return this.builderFactory.builder(LockBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Lock._id), data);
|
return this.builderFactory.builder(LockBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Lock._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLocked(UUID target) throws InvalidApplicationException {
|
public boolean isLocked(UUID target) throws InvalidApplicationException {
|
||||||
LockQuery query = this.queryFactory.query(LockQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).targetIds(target);
|
LockQuery query = this.queryFactory.query(LockQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).targetIds(target);
|
||||||
if (query.count() == 1) {
|
if (query.count() == 1) {
|
||||||
LockEntity lock = query.first();
|
LockEntity lock = query.first();
|
||||||
if (lock.getLockedBy().equals(this.userScope.getUserId())) {
|
if (lock.getLockedBy().equals(this.userScope.getUserId())) {
|
||||||
|
@ -128,7 +127,7 @@ public class LockServiceImpl implements LockService {
|
||||||
|
|
||||||
private Long forceUnlock(UUID target) throws InvalidApplicationException {
|
private Long forceUnlock(UUID target) throws InvalidApplicationException {
|
||||||
|
|
||||||
LockQuery query = this.queryFactory.query(LockQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).targetIds(target);
|
LockQuery query = this.queryFactory.query(LockQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).targetIds(target);
|
||||||
Long availableLocks = query.count();
|
Long availableLocks = query.count();
|
||||||
long deletedLocks = 0L;
|
long deletedLocks = 0L;
|
||||||
if (availableLocks > 0) {
|
if (availableLocks > 0) {
|
||||||
|
@ -154,7 +153,7 @@ public class LockServiceImpl implements LockService {
|
||||||
|
|
||||||
public void unlock(UUID target) throws InvalidApplicationException {
|
public void unlock(UUID target) throws InvalidApplicationException {
|
||||||
|
|
||||||
LockQuery query = this.queryFactory.query(LockQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).targetIds(target);
|
LockQuery query = this.queryFactory.query(LockQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).targetIds(target);
|
||||||
if (query.count() == 1) {
|
if (query.count() == 1) {
|
||||||
LockEntity lock = query.first();
|
LockEntity lock = query.first();
|
||||||
if (!lock.getLockedBy().equals(this.userScope.getUserId())) {
|
if (!lock.getLockedBy().equals(this.userScope.getUserId())) {
|
||||||
|
|
|
@ -144,7 +144,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
return this.builderFactory.builder(PrefillingSourceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, PrefillingSource._id), data);
|
return this.builderFactory.builder(PrefillingSourceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, PrefillingSource._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull PrefillingSourceDefinitionEntity buildDefinitionEntity(PrefillingSourceDefinitionPersist persist) {
|
private @NotNull PrefillingSourceDefinitionEntity buildDefinitionEntity(PrefillingSourceDefinitionPersist persist) {
|
||||||
|
@ -361,7 +361,7 @@ public class PrefillingSourceServiceImpl implements PrefillingSourceService {
|
||||||
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinition = this.xmlHandlingService.fromXml(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition());
|
eu.eudat.commons.types.descriptiontemplate.DefinitionEntity descriptionTemplateDefinition = this.xmlHandlingService.fromXml(eu.eudat.commons.types.descriptiontemplate.DefinitionEntity.class, descriptionTemplateEntity.getDefinition());
|
||||||
|
|
||||||
Description description = new Description();
|
Description description = new Description();
|
||||||
description.setDescriptionTemplate(this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, descriptionTemplateEntity));
|
description.setDescriptionTemplate(this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, descriptionTemplateEntity));
|
||||||
return mapPrefilledEntityToDescription(description, descriptionTemplateDefinition, prefillingSourceDefinition, prefillingSourceEntity.getLabel(), externalData.getResults().getFirst());//TODO
|
return mapPrefilledEntityToDescription(description, descriptionTemplateDefinition, prefillingSourceDefinition, prefillingSourceEntity.getLabel(), externalData.getResults().getFirst());//TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class ReferenceServiceImpl implements ReferenceService {
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
return this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Reference._id), data);
|
return this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Reference._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull DefinitionEntity buildDefinitionEntity(DefinitionPersist persist){
|
private @NotNull DefinitionEntity buildDefinitionEntity(DefinitionPersist persist){
|
||||||
|
@ -187,7 +187,7 @@ public class ReferenceServiceImpl implements ReferenceService {
|
||||||
ReferenceEntity referenceEntity = buildReferenceEntityFromExternalData(result, data);
|
ReferenceEntity referenceEntity = buildReferenceEntityFromExternalData(result, data);
|
||||||
referenceEntities.add(referenceEntity);
|
referenceEntities.add(referenceEntity);
|
||||||
}
|
}
|
||||||
externalModels = this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), referenceEntities);
|
externalModels = this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), referenceEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Reference> models = this.fetchReferenceFromDb(lookup);
|
List<Reference> models = this.fetchReferenceFromDb(lookup);
|
||||||
|
@ -236,10 +236,10 @@ public class ReferenceServiceImpl implements ReferenceService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Reference> fetchReferenceFromDb(ReferenceSearchLookup lookup){
|
private List<Reference> fetchReferenceFromDb(ReferenceSearchLookup lookup){
|
||||||
ReferenceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).sourceTypes(ReferenceSourceType.Internal).typeIds(lookup.getTypeId());
|
ReferenceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).sourceTypes(ReferenceSourceType.Internal).typeIds(lookup.getTypeId());
|
||||||
|
|
||||||
List<ReferenceEntity> data = query.collectAs(lookup.getProject());
|
List<ReferenceEntity> data = query.collectAs(lookup.getProject());
|
||||||
return this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
return this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ExternalDataResult getReferenceData(ReferenceTypeEntity referenceType, ExternalReferenceCriteria externalReferenceCriteria, String key) {
|
private ExternalDataResult getReferenceData(ReferenceTypeEntity referenceType, ExternalReferenceCriteria externalReferenceCriteria, String key) {
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class ReferenceTypeServiceImpl implements ReferenceTypeService {
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
return this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, ReferenceType._id), data);
|
return this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, ReferenceType._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull ReferenceTypeDefinitionEntity buildDefinitionEntity(ReferenceTypeDefinitionPersist persist){
|
private @NotNull ReferenceTypeDefinitionEntity buildDefinitionEntity(ReferenceTypeDefinitionPersist persist){
|
||||||
|
|
|
@ -197,19 +197,7 @@ public class StorageFileProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class StaticFilesConfig{
|
public static class StaticFilesConfig{
|
||||||
private String externalUrls;
|
|
||||||
private String semantics;
|
private String semantics;
|
||||||
private String h2020Template;
|
|
||||||
private String h2020DescriptionTemplate;
|
|
||||||
private String pidLinks;
|
|
||||||
|
|
||||||
public String getExternalUrls() {
|
|
||||||
return externalUrls;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExternalUrls(String externalUrls) {
|
|
||||||
this.externalUrls = externalUrls;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSemantics() {
|
public String getSemantics() {
|
||||||
return semantics;
|
return semantics;
|
||||||
|
@ -219,29 +207,6 @@ public class StorageFileProperties {
|
||||||
this.semantics = semantics;
|
this.semantics = semantics;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getH2020Template() {
|
|
||||||
return h2020Template;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setH2020Template(String h2020Template) {
|
|
||||||
this.h2020Template = h2020Template;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getH2020DescriptionTemplate() {
|
|
||||||
return h2020DescriptionTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setH2020DescriptionTemplate(String h2020DescriptionTemplate) {
|
|
||||||
this.h2020DescriptionTemplate = h2020DescriptionTemplate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPidLinks() {
|
|
||||||
return pidLinks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPidLinks(String pidLinks) {
|
|
||||||
this.pidLinks = pidLinks;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,12 +33,6 @@ public interface StorageFileService extends ApplicationListener<ApplicationReady
|
||||||
|
|
||||||
byte[] getSemanticsFile();
|
byte[] getSemanticsFile();
|
||||||
|
|
||||||
byte[] getPidLinksFile();
|
|
||||||
|
|
||||||
byte[] getH2020TemplateFile();
|
|
||||||
|
|
||||||
byte[] getH2020DescriptionTemplateFile();
|
|
||||||
|
|
||||||
byte[] getSupportiveMaterial(SupportiveMaterialFieldType type, String language);
|
byte[] getSupportiveMaterial(SupportiveMaterialFieldType type, String language);
|
||||||
|
|
||||||
byte[] getUserGuide(String language);
|
byte[] getUserGuide(String language);
|
||||||
|
|
|
@ -7,7 +7,6 @@ import eu.eudat.commons.enums.StorageType;
|
||||||
import eu.eudat.commons.enums.SupportiveMaterialFieldType;
|
import eu.eudat.commons.enums.SupportiveMaterialFieldType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.StorageFileEntity;
|
import eu.eudat.data.StorageFileEntity;
|
||||||
import eu.eudat.model.Description;
|
|
||||||
import eu.eudat.model.StorageFile;
|
import eu.eudat.model.StorageFile;
|
||||||
import eu.eudat.model.builder.StorageFileBuilder;
|
import eu.eudat.model.builder.StorageFileBuilder;
|
||||||
import eu.eudat.model.persist.StorageFilePersist;
|
import eu.eudat.model.persist.StorageFilePersist;
|
||||||
|
@ -94,7 +93,7 @@ public class StorageFileServiceImpl implements StorageFileService {
|
||||||
|
|
||||||
this.entityManager.persist(storageFile);
|
this.entityManager.persist(storageFile);
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
return this.builderFactory.builder(StorageFileBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, StorageFile._id), storageFile);
|
return this.builderFactory.builder(StorageFileBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, StorageFile._id), storageFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -142,7 +141,7 @@ public class StorageFileServiceImpl implements StorageFileService {
|
||||||
file.delete();
|
file.delete();
|
||||||
|
|
||||||
this.entityManager.merge(storageFile);
|
this.entityManager.merge(storageFile);
|
||||||
return this.builderFactory.builder(StorageFileBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, StorageFile._id), storageFile);
|
return this.builderFactory.builder(StorageFileBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, StorageFile._id), storageFile);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
logger.warn("problem reading byte content of storage file " + fileId, ex);
|
logger.warn("problem reading byte content of storage file " + fileId, ex);
|
||||||
|
@ -181,7 +180,7 @@ public class StorageFileServiceImpl implements StorageFileService {
|
||||||
this.entityManager.persist(data);
|
this.entityManager.persist(data);
|
||||||
|
|
||||||
this.entityManager.merge(storageFile);
|
this.entityManager.merge(storageFile);
|
||||||
return this.builderFactory.builder(StorageFileBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, StorageFile._id), storageFile);
|
return this.builderFactory.builder(StorageFileBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, StorageFile._id), storageFile);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
|
@ -334,38 +333,7 @@ public class StorageFileServiceImpl implements StorageFileService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getPidLinksFile() {
|
|
||||||
try {
|
|
||||||
return this.readFileBytes(this.config.getStaticFiles().getPidLinks());
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
logger.warn("problem reading PidLinks file", ex);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getH2020TemplateFile() {
|
|
||||||
try {
|
|
||||||
return this.readFileBytes(this.config.getStaticFiles().getH2020Template());
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
logger.warn("problem reading H2020Template file", ex);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getH2020DescriptionTemplateFile() {
|
|
||||||
try {
|
|
||||||
return this.readFileBytes(this.config.getStaticFiles().getH2020DescriptionTemplate());
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
logger.warn("problem reading H2020DescriptionTemplate file", ex);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//endregion
|
//endregion
|
||||||
|
|
||||||
//region materials
|
//region materials
|
||||||
|
|
|
@ -30,21 +30,12 @@ import jakarta.xml.bind.JAXBException;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.http.HttpHeaders;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
import java.io.*;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@ -104,7 +95,7 @@ public class SupportiveMaterialServiceImpl implements SupportiveMaterialService{
|
||||||
if (d == null)
|
if (d == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), SupportiveMaterial.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), SupportiveMaterial.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
} else {
|
} else {
|
||||||
List<SupportiveMaterialEntity> data = this.queryFactory.query(SupportiveMaterialQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).languageCodes(model.getLanguageCode()).types(model.getType()).collect();
|
List<SupportiveMaterialEntity> data = this.queryFactory.query(SupportiveMaterialQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).languageCodes(model.getLanguageCode()).types(model.getType()).collect();
|
||||||
|
|
||||||
if(data != null && !data.isEmpty()){
|
if(data != null && !data.isEmpty()){
|
||||||
throw new MyApplicationException("Could not create a new Data with same type and lang code !");
|
throw new MyApplicationException("Could not create a new Data with same type and lang code !");
|
||||||
|
@ -126,7 +117,7 @@ public class SupportiveMaterialServiceImpl implements SupportiveMaterialService{
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
return this.builderFactory.builder(SupportiveMaterialBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, SupportiveMaterial._id), d);
|
return this.builderFactory.builder(SupportiveMaterialBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, SupportiveMaterial._id), d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class TagServiceImpl implements TagService {
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
this.eventBroker.emit(new TagTouchedEvent(data.getId()));
|
this.eventBroker.emit(new TagTouchedEvent(data.getId()));
|
||||||
return this.builderFactory.builder(TagBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Tag._id), data);
|
return this.builderFactory.builder(TagBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Tag._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class TenantServiceImpl implements TenantService {
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
return this.builderFactory.builder(TenantBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, Tenant._id), data);
|
return this.builderFactory.builder(TenantBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, Tenant._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull TenantConfigEntity buildConfigEntity(TenantConfigPersist persist) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
|
private @NotNull TenantConfigEntity buildConfigEntity(TenantConfigPersist persist) throws InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
|
||||||
|
|
|
@ -1,177 +1,14 @@
|
||||||
package eu.eudat.service.transformer;
|
package eu.eudat.service.transformer;
|
||||||
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.cache.transformer.FileTransformerConfigurationCache;
|
|
||||||
import eu.eudat.commonmodels.models.FileEnvelopeModel;
|
|
||||||
import eu.eudat.commonmodels.models.description.DescriptionModel;
|
|
||||||
import eu.eudat.commonmodels.models.dmp.DmpModel;
|
|
||||||
import eu.eudat.commons.enums.StorageType;
|
|
||||||
import eu.eudat.configurations.transformer.TransformerProperties;
|
|
||||||
import eu.eudat.file.transformer.interfaces.FileTransformerConfiguration;
|
|
||||||
import eu.eudat.file.transformer.models.misc.FileFormat;
|
import eu.eudat.file.transformer.models.misc.FileFormat;
|
||||||
import eu.eudat.model.Description;
|
|
||||||
import eu.eudat.model.Dmp;
|
|
||||||
import eu.eudat.model.builder.commonmodels.description.DescriptionCommonModelBuilder;
|
|
||||||
import eu.eudat.model.builder.commonmodels.dmp.DmpCommonModelBuilder;
|
|
||||||
import eu.eudat.model.file.TransformerCacheModel;
|
|
||||||
import eu.eudat.query.DescriptionQuery;
|
|
||||||
import eu.eudat.query.DmpQuery;
|
|
||||||
import eu.eudat.repository.TransformerRepository;
|
|
||||||
import eu.eudat.service.storage.StorageFileService;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService;
|
|
||||||
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction;
|
|
||||||
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeModel;
|
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.MessageSource;
|
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
|
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
|
||||||
import reactor.core.publisher.Mono;
|
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import java.util.List;
|
||||||
import java.io.IOException;
|
import java.util.UUID;
|
||||||
import java.net.URI;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
@Service
|
public interface FileTransformerService {
|
||||||
public class FileTransformerService {
|
List<FileFormat> getAvailableExportFileFormats();
|
||||||
private static final Logger logger = LoggerFactory.getLogger(FileTransformerService.class);
|
|
||||||
|
|
||||||
private final TransformerProperties transformerProperties;
|
eu.eudat.model.file.FileEnvelope exportDmp(UUID dmpId, String repositoryId, String format);
|
||||||
private final Map<String, TransformerRepository> clients;
|
|
||||||
private final TokenExchangeCacheService tokenExchangeCacheService;
|
|
||||||
private final FileTransformerConfigurationCache fileTransformerConfigurationCache;
|
|
||||||
private final AuthorizationService authorizationService;
|
|
||||||
private final WebClient.Builder webClientBuilder;
|
|
||||||
private final QueryFactory queryFactory;
|
|
||||||
private final BuilderFactory builderFactory;
|
|
||||||
private final StorageFileService storageFileService;
|
|
||||||
private final MessageSource messageSource;
|
|
||||||
|
|
||||||
@Autowired
|
eu.eudat.model.file.FileEnvelope exportDescription(UUID descriptionId, String format);
|
||||||
public FileTransformerService(TransformerProperties transformerProperties, TokenExchangeCacheService tokenExchangeCacheService, FileTransformerConfigurationCache fileTransformerConfigurationCache, WebClient.Builder builder, AuthorizationService authorizationService,
|
|
||||||
QueryFactory queryFactory, BuilderFactory builderFactory, StorageFileService storageFileService, MessageSource messageSource) {
|
|
||||||
this.transformerProperties = transformerProperties;
|
|
||||||
this.tokenExchangeCacheService = tokenExchangeCacheService;
|
|
||||||
this.fileTransformerConfigurationCache = fileTransformerConfigurationCache;
|
|
||||||
this.authorizationService = authorizationService;
|
|
||||||
this.webClientBuilder = builder;
|
|
||||||
this.queryFactory = queryFactory;
|
|
||||||
this.builderFactory = builderFactory;
|
|
||||||
this.storageFileService = storageFileService;
|
|
||||||
this.messageSource = messageSource;
|
|
||||||
this.clients = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private TransformerRepository getRepository(String repoId) {
|
|
||||||
if (this.clients.containsKey(repoId)) return this.clients.get(repoId);
|
|
||||||
|
|
||||||
//GK: It's register time
|
|
||||||
TransformerProperties.TransformerSource source = transformerProperties.getSources().stream().filter(depositSource -> depositSource.getCodes().contains(repoId)).findFirst().orElse(null);
|
|
||||||
if (source != null) {
|
|
||||||
String host = URI.create(source.getUrl()).getHost();
|
|
||||||
TokenExchangeModel tokenExchangeModel = new TokenExchangeModel(host + "_" + source.getClientId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope());
|
|
||||||
TokenExchangeFilterFunction tokenExchangeFilterFunction = new TokenExchangeFilterFunction(this.tokenExchangeCacheService, tokenExchangeModel);
|
|
||||||
TransformerRepository repository = new TransformerRepository(webClientBuilder.baseUrl(source.getUrl() + "/api/file-transformer").filters(exchangeFilterFunctions -> {
|
|
||||||
exchangeFilterFunctions.add(tokenExchangeFilterFunction);
|
|
||||||
exchangeFilterFunctions.add(logRequest());
|
|
||||||
}).build());
|
|
||||||
source.getCodes().forEach(code -> this.clients.put(code, repository));
|
|
||||||
return repository;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<FileFormat> getAvailableExportFileFormats() {
|
|
||||||
List<FileFormat> formats = new ArrayList<>();
|
|
||||||
List<FileTransformerConfiguration> configurations = this.getAvailableConfigurations();
|
|
||||||
if(configurations != null){
|
|
||||||
for (FileTransformerConfiguration configuration : configurations){
|
|
||||||
if (configuration != null && configuration.getExportVariants() != null) formats.addAll(configuration.getExportVariants());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return formats;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<FileTransformerConfiguration> getAvailableConfigurations() {
|
|
||||||
TransformerCacheModel configs = fileTransformerConfigurationCache.lookup("base");
|
|
||||||
if (configs == null) {
|
|
||||||
List<FileTransformerConfiguration> configurations = new ArrayList<>();
|
|
||||||
//GK: So much for lazy loading
|
|
||||||
List<TransformerRepository> repositories = transformerProperties.getSources().stream().map(depositSource -> getRepository(depositSource.getCodes().getFirst())).toList();
|
|
||||||
|
|
||||||
repositories = new ArrayList<>(repositories);
|
|
||||||
repositories.forEach((client) -> {
|
|
||||||
try {
|
|
||||||
FileTransformerConfiguration repositoryConfig = client.getConfiguration();
|
|
||||||
if (repositoryConfig != null) {
|
|
||||||
configurations.add(repositoryConfig);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.warn(e.getLocalizedMessage(), e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
configs = new TransformerCacheModel(configurations);
|
|
||||||
this.fileTransformerConfigurationCache.put("base", configs);
|
|
||||||
}
|
|
||||||
|
|
||||||
return configs.getConfigurations();
|
|
||||||
}
|
|
||||||
|
|
||||||
public eu.eudat.model.file.FileEnvelope exportDmp(UUID dmpId, String format) throws InvalidApplicationException, IOException {
|
|
||||||
this.authorizationService.authorize(Permission.EditDmp);
|
|
||||||
//GK: First get the right client
|
|
||||||
TransformerRepository repository = getRepository(format);
|
|
||||||
if (repository == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{format, TransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
||||||
//GK: Second get the Target Data Management Plan
|
|
||||||
DmpQuery query = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(dmpId);
|
|
||||||
DmpModel dmpFileTransformerModel = this.builderFactory.builder(DmpCommonModelBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(query.first());
|
|
||||||
if (dmpFileTransformerModel == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpId, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
||||||
|
|
||||||
FileEnvelopeModel fileEnvelope = repository.exportDmp(dmpFileTransformerModel, format);
|
|
||||||
eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope();
|
|
||||||
|
|
||||||
byte[] data = repository.getConfiguration().isUseSharedStorage() ? storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFileRef(), StorageType.Transformer) : fileEnvelope.getFile();
|
|
||||||
result.setFile(data);
|
|
||||||
result.setFilename(fileEnvelope.getFilename());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public eu.eudat.model.file.FileEnvelope exportDescription(UUID descriptionId, String format) {
|
|
||||||
this.authorizationService.authorize(Permission.EditDmp);
|
|
||||||
//GK: First get the right client
|
|
||||||
TransformerRepository repository = getRepository(format);
|
|
||||||
if (repository == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{format, TransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
||||||
|
|
||||||
//GK: Second get the Target Data Management Plan
|
|
||||||
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(descriptionId);
|
|
||||||
DescriptionModel descriptionFileTransformerModel = this.builderFactory.builder(DescriptionCommonModelBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(query.first());
|
|
||||||
if (descriptionFileTransformerModel == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{descriptionId, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
|
||||||
|
|
||||||
FileEnvelopeModel fileEnvelope = repository.exportDescription(descriptionFileTransformerModel, format);
|
|
||||||
eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope();
|
|
||||||
byte[] data = repository.getConfiguration().isUseSharedStorage() ? storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFileRef(), StorageType.Transformer) : fileEnvelope.getFile(); //TODO: shared storage should be per repository
|
|
||||||
result.setFile(data);
|
|
||||||
result.setFilename(fileEnvelope.getFilename());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This method returns filter function which will log request data
|
|
||||||
private static ExchangeFilterFunction logRequest() {
|
|
||||||
return ExchangeFilterFunction.ofRequestProcessor(clientRequest -> {
|
|
||||||
logger.info("Request: {} {}", clientRequest.method(), clientRequest.url());
|
|
||||||
clientRequest.headers().forEach((name, values) -> values.forEach(value -> logger.info("{}={}", name, value)));
|
|
||||||
return Mono.just(clientRequest);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,178 @@
|
||||||
|
package eu.eudat.service.transformer;
|
||||||
|
|
||||||
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.cache.transformer.FileTransformerConfigurationCache;
|
||||||
|
import eu.eudat.commonmodels.models.FileEnvelopeModel;
|
||||||
|
import eu.eudat.commonmodels.models.description.DescriptionModel;
|
||||||
|
import eu.eudat.commonmodels.models.dmp.DmpModel;
|
||||||
|
import eu.eudat.commons.enums.StorageType;
|
||||||
|
import eu.eudat.configurations.transformer.TransformerProperties;
|
||||||
|
import eu.eudat.file.transformer.interfaces.FileTransformerConfiguration;
|
||||||
|
import eu.eudat.file.transformer.models.misc.FileFormat;
|
||||||
|
import eu.eudat.model.Description;
|
||||||
|
import eu.eudat.model.Dmp;
|
||||||
|
import eu.eudat.model.builder.commonmodels.description.DescriptionCommonModelBuilder;
|
||||||
|
import eu.eudat.model.builder.commonmodels.dmp.DmpCommonModelBuilder;
|
||||||
|
import eu.eudat.model.file.TransformerCacheModel;
|
||||||
|
import eu.eudat.query.DescriptionQuery;
|
||||||
|
import eu.eudat.query.DmpQuery;
|
||||||
|
import eu.eudat.repository.TransformerRepository;
|
||||||
|
import eu.eudat.service.storage.StorageFileService;
|
||||||
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeCacheService;
|
||||||
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeFilterFunction;
|
||||||
|
import gr.cite.commons.web.oidc.filter.webflux.TokenExchangeModel;
|
||||||
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.reactive.function.client.ExchangeFilterFunction;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class FileTransformerServiceImpl implements FileTransformerService {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FileTransformerServiceImpl.class);
|
||||||
|
|
||||||
|
private final TransformerProperties transformerProperties;
|
||||||
|
private final Map<String, TransformerRepository> clients;
|
||||||
|
private final TokenExchangeCacheService tokenExchangeCacheService;
|
||||||
|
private final FileTransformerConfigurationCache fileTransformerConfigurationCache;
|
||||||
|
private final AuthorizationService authorizationService;
|
||||||
|
private final WebClient.Builder webClientBuilder;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
private final BuilderFactory builderFactory;
|
||||||
|
private final StorageFileService storageFileService;
|
||||||
|
private final MessageSource messageSource;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public FileTransformerServiceImpl(TransformerProperties transformerProperties, TokenExchangeCacheService tokenExchangeCacheService, FileTransformerConfigurationCache fileTransformerConfigurationCache, WebClient.Builder builder, AuthorizationService authorizationService,
|
||||||
|
QueryFactory queryFactory, BuilderFactory builderFactory, StorageFileService storageFileService, MessageSource messageSource) {
|
||||||
|
this.transformerProperties = transformerProperties;
|
||||||
|
this.tokenExchangeCacheService = tokenExchangeCacheService;
|
||||||
|
this.fileTransformerConfigurationCache = fileTransformerConfigurationCache;
|
||||||
|
this.authorizationService = authorizationService;
|
||||||
|
this.webClientBuilder = builder;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
|
this.builderFactory = builderFactory;
|
||||||
|
this.storageFileService = storageFileService;
|
||||||
|
this.messageSource = messageSource;
|
||||||
|
this.clients = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private TransformerRepository getRepository(String repoId) {
|
||||||
|
if (this.clients.containsKey(repoId)) return this.clients.get(repoId);
|
||||||
|
|
||||||
|
//GK: It's register time
|
||||||
|
TransformerProperties.TransformerSource source = transformerProperties.getSources().stream().filter(depositSource -> depositSource.getCodes().contains(repoId)).findFirst().orElse(null);
|
||||||
|
if (source != null) {
|
||||||
|
String host = URI.create(source.getUrl()).getHost();
|
||||||
|
TokenExchangeModel tokenExchangeModel = new TokenExchangeModel(host + "_" + source.getClientId(), source.getIssuerUrl(), source.getClientId(), source.getClientSecret(), source.getScope());
|
||||||
|
TokenExchangeFilterFunction tokenExchangeFilterFunction = new TokenExchangeFilterFunction(this.tokenExchangeCacheService, tokenExchangeModel);
|
||||||
|
TransformerRepository repository = new TransformerRepository(webClientBuilder.baseUrl(source.getUrl() + "/api/file-transformer").filters(exchangeFilterFunctions -> {
|
||||||
|
exchangeFilterFunctions.add(tokenExchangeFilterFunction);
|
||||||
|
exchangeFilterFunctions.add(logRequest());
|
||||||
|
}).build());
|
||||||
|
source.getCodes().forEach(code -> this.clients.put(code, repository));
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<FileFormat> getAvailableExportFileFormats() {
|
||||||
|
List<FileFormat> formats = new ArrayList<>();
|
||||||
|
List<FileTransformerConfiguration> configurations = this.getAvailableConfigurations();
|
||||||
|
if(configurations != null){
|
||||||
|
for (FileTransformerConfiguration configuration : configurations){
|
||||||
|
if (configuration != null && configuration.getExportVariants() != null) formats.addAll(configuration.getExportVariants());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return formats;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<FileTransformerConfiguration> getAvailableConfigurations() {
|
||||||
|
TransformerCacheModel configs = fileTransformerConfigurationCache.lookup("base");
|
||||||
|
if (configs == null) {
|
||||||
|
List<FileTransformerConfiguration> configurations = new ArrayList<>();
|
||||||
|
//GK: So much for lazy loading
|
||||||
|
List<TransformerRepository> repositories = transformerProperties.getSources().stream().map(depositSource -> getRepository(depositSource.getCodes().getFirst())).toList();
|
||||||
|
|
||||||
|
repositories = new ArrayList<>(repositories);
|
||||||
|
repositories.forEach((client) -> {
|
||||||
|
try {
|
||||||
|
FileTransformerConfiguration repositoryConfig = client.getConfiguration();
|
||||||
|
if (repositoryConfig != null) {
|
||||||
|
configurations.add(repositoryConfig);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn(e.getLocalizedMessage(), e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
configs = new TransformerCacheModel(configurations);
|
||||||
|
this.fileTransformerConfigurationCache.put("base", configs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return configs.getConfigurations();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public eu.eudat.model.file.FileEnvelope exportDmp(UUID dmpId, String repositoryId, String format) {
|
||||||
|
this.authorizationService.authorize(Permission.EditDmp);
|
||||||
|
//GK: First get the right client
|
||||||
|
TransformerRepository repository = getRepository(repositoryId);
|
||||||
|
if (repository == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{repositoryId, TransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
//GK: Second get the Target Data Management Plan
|
||||||
|
DmpQuery query = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(dmpId);
|
||||||
|
DmpModel dmpFileTransformerModel = this.builderFactory.builder(DmpCommonModelBuilder.class).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(query.first());
|
||||||
|
if (dmpFileTransformerModel == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{dmpId, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
FileEnvelopeModel fileEnvelope = repository.exportDmp(dmpFileTransformerModel, format);
|
||||||
|
eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope();
|
||||||
|
|
||||||
|
byte[] data = repository.getConfiguration().isUseSharedStorage() ? storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFileRef(), StorageType.Transformer) : fileEnvelope.getFile();
|
||||||
|
result.setFile(data);
|
||||||
|
result.setFilename(fileEnvelope.getFilename());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public eu.eudat.model.file.FileEnvelope exportDescription(UUID descriptionId, String format) {
|
||||||
|
this.authorizationService.authorize(Permission.EditDmp);
|
||||||
|
//GK: First get the right client
|
||||||
|
TransformerRepository repository = getRepository(format);
|
||||||
|
if (repository == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{format, TransformerRepository.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
//GK: Second get the Target Data Management Plan
|
||||||
|
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(descriptionId);
|
||||||
|
DescriptionModel descriptionFileTransformerModel = this.builderFactory.builder(DescriptionCommonModelBuilder.class).useSharedStorage(repository.getConfiguration().isUseSharedStorage()).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(query.first());
|
||||||
|
if (descriptionFileTransformerModel == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{descriptionId, Description.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
FileEnvelopeModel fileEnvelope = repository.exportDescription(descriptionFileTransformerModel, format);
|
||||||
|
eu.eudat.model.file.FileEnvelope result = new eu.eudat.model.file.FileEnvelope();
|
||||||
|
byte[] data = repository.getConfiguration().isUseSharedStorage() ? storageFileService.readByFileRefAsBytesSafe(fileEnvelope.getFileRef(), StorageType.Transformer) : fileEnvelope.getFile(); //TODO: shared storage should be per repository
|
||||||
|
result.setFile(data);
|
||||||
|
result.setFilename(fileEnvelope.getFilename());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method returns filter function which will log request data
|
||||||
|
private static ExchangeFilterFunction logRequest() {
|
||||||
|
return ExchangeFilterFunction.ofRequestProcessor(clientRequest -> {
|
||||||
|
logger.info("Request: {} {}", clientRequest.method(), clientRequest.url());
|
||||||
|
clientRequest.headers().forEach((name, values) -> values.forEach(value -> logger.info("{}={}", name, value)));
|
||||||
|
return Mono.just(clientRequest);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -178,7 +178,7 @@ public class UserServiceImpl implements UserService {
|
||||||
this.eventBroker.emit(new UserTouchedEvent(data.getId()));
|
this.eventBroker.emit(new UserTouchedEvent(data.getId()));
|
||||||
|
|
||||||
this.userTouchedIntegrationEventHandler.handle(data.getId());
|
this.userTouchedIntegrationEventHandler.handle(data.getId());
|
||||||
return this.builderFactory.builder(UserBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, User._id), data);
|
return this.builderFactory.builder(UserBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, User._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private @NotNull AdditionalInfoEntity buildAdditionalInfoEntity(UserAdditionalInfoPersist persist){
|
private @NotNull AdditionalInfoEntity buildAdditionalInfoEntity(UserAdditionalInfoPersist persist){
|
||||||
|
@ -276,7 +276,7 @@ public class UserServiceImpl implements UserService {
|
||||||
this.eventBroker.emit(new UserTouchedEvent(data.getId()));
|
this.eventBroker.emit(new UserTouchedEvent(data.getId()));
|
||||||
|
|
||||||
this.userTouchedIntegrationEventHandler.handle(data.getId());
|
this.userTouchedIntegrationEventHandler.handle(data.getId());
|
||||||
return this.builderFactory.builder(UserBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, User._id), data);
|
return this.builderFactory.builder(UserBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, User._id), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//region mine
|
//region mine
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class UserSettingsServiceImpl implements UserSettingsService {
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
return this.builderFactory.builder(UserSettingsBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(BaseFieldSet.build(fields, UserSettings._id, UserSettings._key), data);
|
return this.builderFactory.builder(UserSettingsBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(BaseFieldSet.build(fields, UserSettings._id, UserSettings._key), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>gr.cite.opendmp</groupId>
|
<groupId>gr.cite.opendmp</groupId>
|
||||||
<artifactId>file-transformer-base</artifactId>
|
<artifactId>file-transformer-base</artifactId>
|
||||||
<version>0.0.5</version>
|
<version>0.0.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -2,19 +2,15 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.audit.AuditableAction;
|
import eu.eudat.audit.AuditableAction;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.authorization.Permission;
|
|
||||||
import eu.eudat.commons.enums.DmpAccessType;
|
import eu.eudat.commons.enums.DmpAccessType;
|
||||||
import eu.eudat.commons.enums.DmpStatus;
|
import eu.eudat.commons.enums.DmpStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.enums.StorageType;
|
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.StorageFileEntity;
|
import eu.eudat.data.StorageFileEntity;
|
||||||
import eu.eudat.model.StorageFile;
|
import eu.eudat.model.StorageFile;
|
||||||
import eu.eudat.model.builder.PublicDescriptionBuilder;
|
import eu.eudat.model.builder.PublicDescriptionBuilder;
|
||||||
import eu.eudat.model.persist.DescriptionFieldFilePersist;
|
import eu.eudat.model.persist.DescriptionFieldFilePersist;
|
||||||
import eu.eudat.model.persist.StorageFilePersist;
|
|
||||||
import eu.eudat.service.storage.StorageFileService;
|
import eu.eudat.service.storage.StorageFileService;
|
||||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
|
||||||
import gr.cite.tools.validation.ValidationFilterAnnotation;
|
import gr.cite.tools.validation.ValidationFilterAnnotation;
|
||||||
import eu.eudat.model.Description;
|
import eu.eudat.model.Description;
|
||||||
import eu.eudat.model.Dmp;
|
import eu.eudat.model.Dmp;
|
||||||
|
@ -40,7 +36,6 @@ import gr.cite.tools.exception.MyNotFoundException;
|
||||||
import gr.cite.tools.fieldset.FieldSet;
|
import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
@ -54,8 +49,6 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URLConnection;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static eu.eudat.authorization.AuthorizationFlags.Public;
|
import static eu.eudat.authorization.AuthorizationFlags.Public;
|
||||||
|
@ -138,7 +131,7 @@ public class DescriptionController {
|
||||||
|
|
||||||
this.censorFactory.censor(DescriptionCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(DescriptionCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
QueryResult<Description> queryResult = this.elasticQueryHelperService.collect(lookup, AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic, null);
|
QueryResult<Description> queryResult = this.elasticQueryHelperService.collect(lookup, AuthorizationFlags.OwnerOrDmpAssociatedOrPermission, null);
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Description_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.Description_Query, "lookup", lookup);
|
||||||
|
|
||||||
|
@ -152,8 +145,8 @@ public class DescriptionController {
|
||||||
|
|
||||||
this.censorFactory.censor(DescriptionCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(DescriptionCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
Description model = this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
Description model = this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
|
|
@ -85,10 +85,10 @@ public class DescriptionTemplateController {
|
||||||
|
|
||||||
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
DescriptionTemplateQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
DescriptionTemplateQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission);
|
||||||
|
|
||||||
List<DescriptionTemplateEntity> data = query.collectAs(lookup.getProject());
|
List<DescriptionTemplateEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<DescriptionTemplate> models = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
List<DescriptionTemplate> models = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), data);
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.DescriptionTemplate_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.DescriptionTemplate_Query, "lookup", lookup);
|
||||||
|
@ -102,8 +102,8 @@ public class DescriptionTemplateController {
|
||||||
|
|
||||||
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(DescriptionTemplateCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
DescriptionTemplateQuery query = this.queryFactory.query(DescriptionTemplateQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
DescriptionTemplate model = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
DescriptionTemplate model = this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplate.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import gr.cite.tools.validation.ValidationFilterAnnotation;
|
import gr.cite.tools.validation.ValidationFilterAnnotation;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -69,10 +68,10 @@ public class DescriptionTemplateTypeController {
|
||||||
|
|
||||||
this.censorFactory.censor(DescriptionTemplateTypeCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(DescriptionTemplateTypeCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
DescriptionTemplateTypeQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
DescriptionTemplateTypeQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission);
|
||||||
|
|
||||||
List<DescriptionTemplateTypeEntity> data = query.collectAs(lookup.getProject());
|
List<DescriptionTemplateTypeEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<DescriptionTemplateType> models = this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
List<DescriptionTemplateType> models = this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), data);
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.DescriptionTemplateType_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.DescriptionTemplateType_Query, "lookup", lookup);
|
||||||
|
@ -87,8 +86,8 @@ public class DescriptionTemplateTypeController {
|
||||||
|
|
||||||
this.censorFactory.censor(DescriptionTemplateTypeCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(DescriptionTemplateTypeCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
DescriptionTemplateTypeQuery query = this.queryFactory.query(DescriptionTemplateTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
DescriptionTemplateTypeQuery query = this.queryFactory.query(DescriptionTemplateTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
DescriptionTemplateType model = this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
DescriptionTemplateType model = this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplateType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DescriptionTemplateType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
|
|
@ -81,10 +81,10 @@ public class DmpBlueprintController {
|
||||||
logger.debug("querying {}", DmpBlueprint.class.getSimpleName());
|
logger.debug("querying {}", DmpBlueprint.class.getSimpleName());
|
||||||
|
|
||||||
this.censorFactory.censor(DmpBlueprintCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(DmpBlueprintCensor.class).censor(lookup.getProject(), null);
|
||||||
DmpBlueprintQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
DmpBlueprintQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission);
|
||||||
|
|
||||||
List<DmpBlueprintEntity> data = query.collectAs(lookup.getProject());
|
List<DmpBlueprintEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<DmpBlueprint> models = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
List<DmpBlueprint> models = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), data);
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.DmpBlueprint_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.DmpBlueprint_Query, "lookup", lookup);
|
||||||
|
@ -98,8 +98,8 @@ public class DmpBlueprintController {
|
||||||
|
|
||||||
this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
DmpBlueprintQuery query = this.queryFactory.query(DmpBlueprintQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
DmpBlueprint model = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
DmpBlueprint model = this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,7 @@ import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.enums.DmpAccessType;
|
import eu.eudat.commons.enums.DmpAccessType;
|
||||||
import eu.eudat.commons.enums.DmpStatus;
|
import eu.eudat.commons.enums.DmpStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.model.builder.DescriptionBuilder;
|
|
||||||
import eu.eudat.model.builder.PublicDmpBuilder;
|
import eu.eudat.model.builder.PublicDmpBuilder;
|
||||||
import eu.eudat.model.censorship.PublicDescriptionCensor;
|
|
||||||
import eu.eudat.query.DescriptionQuery;
|
|
||||||
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
|
||||||
import gr.cite.tools.validation.ValidationFilterAnnotation;
|
import gr.cite.tools.validation.ValidationFilterAnnotation;
|
||||||
import eu.eudat.model.*;
|
import eu.eudat.model.*;
|
||||||
import eu.eudat.model.builder.DmpBuilder;
|
import eu.eudat.model.builder.DmpBuilder;
|
||||||
|
@ -123,8 +119,7 @@ public class DmpController {
|
||||||
|
|
||||||
this.censorFactory.censor(DmpCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(DmpCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
|
QueryResult<Dmp> queryResult = this.elasticQueryHelperService.collect(lookup, AuthorizationFlags.OwnerOrDmpAssociatedOrPermission, null);
|
||||||
QueryResult<Dmp> queryResult = this.elasticQueryHelperService.collect(lookup, AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic, null);
|
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Dmp_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.Dmp_Query, "lookup", lookup);
|
||||||
|
|
||||||
|
@ -137,8 +132,8 @@ public class DmpController {
|
||||||
|
|
||||||
this.censorFactory.censor(DmpCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(DmpCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
DmpQuery query = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
DmpQuery query = this.queryFactory.query(DmpQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
Dmp model = this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
Dmp model = this.builderFactory.builder(DmpBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
@ -242,11 +237,17 @@ public class DmpController {
|
||||||
return new QueryResult<>(persisted);
|
return new QueryResult<>(persisted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("{id}/export/{type}")
|
@GetMapping("{id}/export/{transformerId}/{type}")
|
||||||
public ResponseEntity<byte[]> export(@PathVariable("id") UUID id, @PathVariable("type") String exportType) throws InvalidApplicationException, IOException {
|
public ResponseEntity<byte[]> export(@PathVariable("id") UUID id, @PathVariable("transformerId") String transformerId, @PathVariable("type") String exportType) throws InvalidApplicationException, IOException {
|
||||||
logger.debug(new MapLogEntry("exporting dmp"));
|
logger.debug(new MapLogEntry("exporting dmp").And("id", id).And("transformerId", transformerId).And("exportType", exportType));
|
||||||
|
|
||||||
return this.dmpService.export(id, exportType);
|
ResponseEntity<byte[]> bytes = this.dmpService.export(id, transformerId, exportType);
|
||||||
|
this.auditService.track(AuditableAction.Dmp_Export, Map.ofEntries(
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("transformerId", transformerId),
|
||||||
|
new AbstractMap.SimpleEntry<String, Object>("exportType", exportType)
|
||||||
|
));
|
||||||
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("{id}/invite-users")
|
@PostMapping("{id}/invite-users")
|
||||||
|
|
|
@ -75,10 +75,10 @@ public class EntityDoiController {
|
||||||
|
|
||||||
this.censorFactory.censor(EntityDoiCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(EntityDoiCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
EntityDoiQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
EntityDoiQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission);
|
||||||
|
|
||||||
List<EntityDoiEntity> data = query.collectAs(lookup.getProject());
|
List<EntityDoiEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<EntityDoi> models = this.builderFactory.builder(EntityDoiBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
List<EntityDoi> models = this.builderFactory.builder(EntityDoiBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), data);
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.EntityDoi_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.EntityDoi_Query, "lookup", lookup);
|
||||||
|
@ -92,8 +92,8 @@ public class EntityDoiController {
|
||||||
|
|
||||||
this.censorFactory.censor(EntityDoiCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(EntityDoiCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
EntityDoiQuery query = this.queryFactory.query(EntityDoiQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
EntityDoi model = this.builderFactory.builder(EntityDoiBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
EntityDoi model = this.builderFactory.builder(EntityDoiBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, EntityDoi.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, EntityDoi.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class FileTransformerController {
|
||||||
logger.debug(new MapLogEntry("exporting dmp"));
|
logger.debug(new MapLogEntry("exporting dmp"));
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
|
||||||
FileEnvelope fileEnvelope = this.fileTransformerService.exportDmp(requestModel.getId(), requestModel.getFormat());
|
FileEnvelope fileEnvelope = this.fileTransformerService.exportDmp(requestModel.getId(), requestModel.getRepositoryId(), requestModel.getFormat());
|
||||||
headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename());
|
headers.add("Content-Disposition", "attachment;filename=" + fileEnvelope.getFilename());
|
||||||
byte[] data = fileEnvelope.getFile();
|
byte[] data = fileEnvelope.getFile();
|
||||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||||
|
|
|
@ -6,7 +6,6 @@ import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import gr.cite.tools.validation.ValidationFilterAnnotation;
|
import gr.cite.tools.validation.ValidationFilterAnnotation;
|
||||||
import eu.eudat.data.LanguageEntity;
|
import eu.eudat.data.LanguageEntity;
|
||||||
import eu.eudat.model.Language;
|
import eu.eudat.model.Language;
|
||||||
import eu.eudat.model.UserContactInfo;
|
|
||||||
import eu.eudat.model.builder.LanguageBuilder;
|
import eu.eudat.model.builder.LanguageBuilder;
|
||||||
import eu.eudat.model.censorship.LanguageCensor;
|
import eu.eudat.model.censorship.LanguageCensor;
|
||||||
import eu.eudat.model.persist.LanguagePersist;
|
import eu.eudat.model.persist.LanguagePersist;
|
||||||
|
@ -35,12 +34,11 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.AbstractMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static eu.eudat.authorization.AuthorizationFlags.Public;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(path = {"api/language"})
|
@RequestMapping(path = {"api/language"})
|
||||||
public class LanguageController {
|
public class LanguageController {
|
||||||
|
@ -81,9 +79,9 @@ public class LanguageController {
|
||||||
|
|
||||||
this.censorFactory.censor(LanguageCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(LanguageCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
LanguageQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
LanguageQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission);
|
||||||
List<LanguageEntity> data = query.collectAs(lookup.getProject());
|
List<LanguageEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<Language> models = this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
List<Language> models = this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), data);
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Language_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.Language_Query, "lookup", lookup);
|
||||||
|
@ -97,8 +95,8 @@ public class LanguageController {
|
||||||
|
|
||||||
this.censorFactory.censor(LanguageCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(LanguageCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
LanguageQuery query = this.queryFactory.query(LanguageQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
LanguageQuery query = this.queryFactory.query(LanguageQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
Language model = this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
Language model = this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Language.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Language.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
@ -116,8 +114,8 @@ public class LanguageController {
|
||||||
|
|
||||||
this.censorFactory.censor(LanguageCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(LanguageCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
LanguageQuery query = this.queryFactory.query(LanguageQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).codes(code);
|
LanguageQuery query = this.queryFactory.query(LanguageQuery.class).authorize(EnumSet.of(Public)).codes(code);
|
||||||
Language model = this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
Language model = this.builderFactory.builder(LanguageBuilder.class).authorize(EnumSet.of(Public)).build(fieldSet, query.firstAs(fieldSet));
|
||||||
|
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{code, Language.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{code, Language.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
@ -139,10 +137,10 @@ public class LanguageController {
|
||||||
|
|
||||||
this.censorFactory.censor(LanguageCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(LanguageCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
LanguageQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
LanguageQuery query = lookup.enrich(this.queryFactory).authorize(EnumSet.of(Public));
|
||||||
query.setOrder(new Ordering().addAscending(Language._ordinal));
|
query.setOrder(new Ordering().addAscending(Language._ordinal));
|
||||||
List<LanguageEntity> data = query.collectAs(lookup.getProject());
|
List<LanguageEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<Language> models = this.builderFactory.builder(LanguageBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
List<Language> models = this.builderFactory.builder(LanguageBuilder.class).authorize(EnumSet.of(Public)).build(lookup.getProject(), data);
|
||||||
|
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
|
|
|
@ -85,9 +85,9 @@ public class LockController {
|
||||||
|
|
||||||
this.censorFactory.censor(LockCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(LockCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
LockQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
LockQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission);
|
||||||
List<LockEntity> data = query.collectAs(lookup.getProject());
|
List<LockEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<Lock> models = this.builderFactory.builder(LockBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
List<Lock> models = this.builderFactory.builder(LockBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), data);
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Lock_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.Lock_Query, "lookup", lookup);
|
||||||
|
@ -101,8 +101,8 @@ public class LockController {
|
||||||
|
|
||||||
this.censorFactory.censor(LockCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(LockCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
LockQuery query = this.queryFactory.query(LockQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
LockQuery query = this.queryFactory.query(LockQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
Lock model = this.builderFactory.builder(LockBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
Lock model = this.builderFactory.builder(LockBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Lock.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Lock.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
@ -137,8 +137,8 @@ public class LockController {
|
||||||
|
|
||||||
this.censorFactory.censor(LockCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(LockCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
LockQuery query = this.queryFactory.query(LockQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).targetIds(targetId);
|
LockQuery query = this.queryFactory.query(LockQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).targetIds(targetId);
|
||||||
Lock model = this.builderFactory.builder(LockBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
Lock model = this.builderFactory.builder(LockBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{targetId, Lock.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{targetId, Lock.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
|
|
@ -89,9 +89,9 @@ public class PrefillingSourceController {
|
||||||
|
|
||||||
this.censorFactory.censor(PrefillingSourceCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(PrefillingSourceCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
PrefillingSourceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
PrefillingSourceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission);
|
||||||
List<PrefillingSourceEntity> data = query.collectAs(lookup.getProject());
|
List<PrefillingSourceEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<PrefillingSource> models = this.builderFactory.builder(PrefillingSourceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
List<PrefillingSource> models = this.builderFactory.builder(PrefillingSourceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), data);
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.PrefillingSource_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.PrefillingSource_Query, "lookup", lookup);
|
||||||
|
@ -105,8 +105,8 @@ public class PrefillingSourceController {
|
||||||
|
|
||||||
this.censorFactory.censor(PrefillingSourceCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(PrefillingSourceCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
PrefillingSourceQuery query = this.queryFactory.query(PrefillingSourceQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
PrefillingSourceQuery query = this.queryFactory.query(PrefillingSourceQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
PrefillingSource model = this.builderFactory.builder(PrefillingSourceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
PrefillingSource model = this.builderFactory.builder(PrefillingSourceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, PrefillingSource.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
|
|
@ -81,9 +81,9 @@ public class ReferenceController {
|
||||||
|
|
||||||
this.censorFactory.censor(ReferenceCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(ReferenceCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
ReferenceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
ReferenceQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission);
|
||||||
List<ReferenceEntity> data = query.collectAs(lookup.getProject());
|
List<ReferenceEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<Reference> models = this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
List<Reference> models = this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), data);
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Reference_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.Reference_Query, "lookup", lookup);
|
||||||
|
@ -111,8 +111,8 @@ public class ReferenceController {
|
||||||
|
|
||||||
this.censorFactory.censor(ReferenceCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(ReferenceCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
ReferenceQuery query = this.queryFactory.query(ReferenceQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
Reference model = this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
Reference model = this.builderFactory.builder(ReferenceBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Reference.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import eu.eudat.audit.AuditableAction;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import gr.cite.tools.validation.ValidationFilterAnnotation;
|
import gr.cite.tools.validation.ValidationFilterAnnotation;
|
||||||
import eu.eudat.data.ReferenceTypeEntity;
|
import eu.eudat.data.ReferenceTypeEntity;
|
||||||
import eu.eudat.model.Reference;
|
|
||||||
import eu.eudat.model.ReferenceType;
|
import eu.eudat.model.ReferenceType;
|
||||||
import eu.eudat.model.builder.ReferenceTypeBuilder;
|
import eu.eudat.model.builder.ReferenceTypeBuilder;
|
||||||
import eu.eudat.model.censorship.ReferenceTypeCensor;
|
import eu.eudat.model.censorship.ReferenceTypeCensor;
|
||||||
|
@ -81,9 +80,9 @@ public class ReferenceTypeController{
|
||||||
|
|
||||||
this.censorFactory.censor(ReferenceTypeCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(ReferenceTypeCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
ReferenceTypeQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
ReferenceTypeQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission);
|
||||||
List<ReferenceTypeEntity> data = query.collectAs(lookup.getProject());
|
List<ReferenceTypeEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<ReferenceType> models = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
List<ReferenceType> models = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), data);
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.ReferenceType_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.ReferenceType_Query, "lookup", lookup);
|
||||||
|
@ -97,8 +96,8 @@ public class ReferenceTypeController{
|
||||||
|
|
||||||
this.censorFactory.censor(ReferenceTypeCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(ReferenceTypeCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
ReferenceType model = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
ReferenceType model = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
@ -116,8 +115,8 @@ public class ReferenceTypeController{
|
||||||
|
|
||||||
this.censorFactory.censor(ReferenceTypeCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(ReferenceTypeCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).codes(code);
|
ReferenceTypeQuery query = this.queryFactory.query(ReferenceTypeQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).codes(code);
|
||||||
ReferenceType model = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
ReferenceType model = this.builderFactory.builder(ReferenceTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{code, ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{code, ReferenceType.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.tdunning.math.stats.Sort;
|
|
||||||
import eu.eudat.audit.AuditableAction;
|
import eu.eudat.audit.AuditableAction;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.commons.enums.SupportiveMaterialFieldType;
|
import eu.eudat.commons.enums.SupportiveMaterialFieldType;
|
||||||
import eu.eudat.service.storage.StorageFileService;
|
|
||||||
import gr.cite.tools.fieldset.BaseFieldSet;
|
import gr.cite.tools.fieldset.BaseFieldSet;
|
||||||
import gr.cite.tools.validation.ValidationFilterAnnotation;
|
import gr.cite.tools.validation.ValidationFilterAnnotation;
|
||||||
import eu.eudat.data.SupportiveMaterialEntity;
|
import eu.eudat.data.SupportiveMaterialEntity;
|
||||||
|
@ -17,7 +15,6 @@ import eu.eudat.model.result.QueryResult;
|
||||||
import eu.eudat.query.SupportiveMaterialQuery;
|
import eu.eudat.query.SupportiveMaterialQuery;
|
||||||
import eu.eudat.query.lookup.SupportiveMaterialLookup;
|
import eu.eudat.query.lookup.SupportiveMaterialLookup;
|
||||||
import eu.eudat.service.supportivematerial.SupportiveMaterialService;
|
import eu.eudat.service.supportivematerial.SupportiveMaterialService;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
|
||||||
import gr.cite.tools.auditing.AuditService;
|
import gr.cite.tools.auditing.AuditService;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.censor.CensorFactory;
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
|
@ -83,9 +80,9 @@ public class SupportiveMaterialController {
|
||||||
|
|
||||||
this.censorFactory.censor(SupportiveMaterialCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(SupportiveMaterialCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
SupportiveMaterialQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
SupportiveMaterialQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission);
|
||||||
List<SupportiveMaterialEntity> data = query.collectAs(lookup.getProject());
|
List<SupportiveMaterialEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<SupportiveMaterial> models = this.builderFactory.builder(SupportiveMaterialBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
List<SupportiveMaterial> models = this.builderFactory.builder(SupportiveMaterialBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), data);
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.SupportiveMaterial_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.SupportiveMaterial_Query, "lookup", lookup);
|
||||||
|
@ -99,8 +96,8 @@ public class SupportiveMaterialController {
|
||||||
|
|
||||||
this.censorFactory.censor(SupportiveMaterialCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(SupportiveMaterialCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
SupportiveMaterialQuery query = this.queryFactory.query(SupportiveMaterialQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
SupportiveMaterialQuery query = this.queryFactory.query(SupportiveMaterialQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
SupportiveMaterial model = this.builderFactory.builder(SupportiveMaterialBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
SupportiveMaterial model = this.builderFactory.builder(SupportiveMaterialBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, SupportiveMaterial.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, SupportiveMaterial.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
@ -117,7 +114,7 @@ public class SupportiveMaterialController {
|
||||||
logger.debug("querying {}", SupportiveMaterial.class.getSimpleName());
|
logger.debug("querying {}", SupportiveMaterial.class.getSimpleName());
|
||||||
|
|
||||||
|
|
||||||
SupportiveMaterialQuery query = this.queryFactory.query(SupportiveMaterialQuery.class).types(SupportiveMaterialFieldType.of(type)).languageCodes(language).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
SupportiveMaterialQuery query = this.queryFactory.query(SupportiveMaterialQuery.class).types(SupportiveMaterialFieldType.of(type)).languageCodes(language).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission);
|
||||||
List<SupportiveMaterialEntity> data = query.collectAs(new BaseFieldSet().ensure(SupportiveMaterial._id).ensure(SupportiveMaterial._payload));
|
List<SupportiveMaterialEntity> data = query.collectAs(new BaseFieldSet().ensure(SupportiveMaterial._id).ensure(SupportiveMaterial._payload));
|
||||||
byte[] content;
|
byte[] content;
|
||||||
if (data.size() == 1) content = data.getFirst().getPayload().getBytes();
|
if (data.size() == 1) content = data.getFirst().getPayload().getBytes();
|
||||||
|
|
|
@ -23,7 +23,6 @@ import gr.cite.tools.fieldset.FieldSet;
|
||||||
import gr.cite.tools.logging.LoggerService;
|
import gr.cite.tools.logging.LoggerService;
|
||||||
import gr.cite.tools.logging.MapLogEntry;
|
import gr.cite.tools.logging.MapLogEntry;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -71,10 +70,10 @@ public class TagController {
|
||||||
|
|
||||||
this.censorFactory.censor(TagCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(TagCensor.class).censor(lookup.getProject(), null);
|
||||||
|
|
||||||
TagQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
TagQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission);
|
||||||
|
|
||||||
List<TagEntity> data = query.collectAs(lookup.getProject());
|
List<TagEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<Tag> models = this.builderFactory.builder(TagBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
List<Tag> models = this.builderFactory.builder(TagBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), data);
|
||||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||||
|
|
||||||
this.auditService.track(AuditableAction.Tag_Query, "lookup", lookup);
|
this.auditService.track(AuditableAction.Tag_Query, "lookup", lookup);
|
||||||
|
@ -88,8 +87,8 @@ public class TagController {
|
||||||
|
|
||||||
this.censorFactory.censor(TagCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(TagCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
TagQuery query = this.queryFactory.query(TagQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
TagQuery query = this.queryFactory.query(TagQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
Tag model = this.builderFactory.builder(TagBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
Tag model = this.builderFactory.builder(TagBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Tag.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Tag.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
|
|
@ -82,10 +82,10 @@ public class TenantController {
|
||||||
logger.debug("querying {}", Tenant.class.getSimpleName());
|
logger.debug("querying {}", Tenant.class.getSimpleName());
|
||||||
|
|
||||||
this.censorFactory.censor(TenantCensor.class).censor(lookup.getProject(), null);
|
this.censorFactory.censor(TenantCensor.class).censor(lookup.getProject(), null);
|
||||||
TenantQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic);
|
TenantQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission);
|
||||||
|
|
||||||
List<TenantEntity> data = query.collectAs(lookup.getProject());
|
List<TenantEntity> data = query.collectAs(lookup.getProject());
|
||||||
List<Tenant> models = this.builderFactory.builder(TenantBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(lookup.getProject(), data);
|
List<Tenant> models = this.builderFactory.builder(TenantBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(lookup.getProject(), data);
|
||||||
for (Tenant model : models) {
|
for (Tenant model : models) {
|
||||||
models.set(models.indexOf(model), this.tenantService.decryptTenant(model));
|
models.set(models.indexOf(model), this.tenantService.decryptTenant(model));
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,8 @@ public class TenantController {
|
||||||
|
|
||||||
this.censorFactory.censor(TenantCensor.class).censor(fieldSet, null);
|
this.censorFactory.censor(TenantCensor.class).censor(fieldSet, null);
|
||||||
|
|
||||||
TenantQuery query = this.queryFactory.query(TenantQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).ids(id);
|
TenantQuery query = this.queryFactory.query(TenantQuery.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).ids(id);
|
||||||
Tenant model = this.builderFactory.builder(TenantBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermissionOrPublic).build(fieldSet, query.firstAs(fieldSet));
|
Tenant model = this.builderFactory.builder(TenantBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, query.firstAs(fieldSet));
|
||||||
if (model == null)
|
if (model == null)
|
||||||
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Tenant.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Tenant.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue