add public description
This commit is contained in:
parent
1324029804
commit
0e1408e532
|
@ -39,6 +39,8 @@ public class AuditableAction {
|
|||
public static final EventId Description_Lookup = new EventId(6001, "Description_Lookup");
|
||||
public static final EventId Description_Persist = new EventId(6002, "Description_Persist");
|
||||
public static final EventId Description_Delete = new EventId(6003, "Description_Delete");
|
||||
public static final EventId Description_PublicQuery = new EventId(6004, "Description_PublicQuery");
|
||||
public static final EventId Description_PublicLookup = new EventId(6005, "Description_PublicLookup");
|
||||
|
||||
public static final EventId Reference_Query = new EventId(7000, "Reference_Query");
|
||||
public static final EventId Reference_Lookup = new EventId(7001, "Reference_Lookup");
|
||||
|
|
|
@ -10,6 +10,7 @@ import eu.eudat.data.DescriptionEntity;
|
|||
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.model.Description;
|
||||
import eu.eudat.model.PublicDescription;
|
||||
import eu.eudat.query.utils.BuildSubQueryInput;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
|
@ -158,7 +159,7 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
|||
if (userId != null || usePublic ) {
|
||||
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DescriptionEntity._dmpDescriptionTemplateId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)));
|
||||
}
|
||||
if (predicates.size() > 0) {
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
|
@ -219,17 +220,17 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
|||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(Description._id)) return DescriptionEntity._id;
|
||||
else if (item.match(Description._label)) return DescriptionEntity._label;
|
||||
if (item.match(Description._id) || item.match(PublicDescription._id)) return DescriptionEntity._id;
|
||||
else if (item.match(Description._label) || item.match(PublicDescription._label)) return DescriptionEntity._label;
|
||||
else if (item.prefix(Description._properties)) return DescriptionEntity._properties;
|
||||
else if (item.match(Description._status)) return DescriptionEntity._status;
|
||||
else if (item.match(Description._description)) return DescriptionEntity._description;
|
||||
else if (item.match(Description._status) || item.match(PublicDescription._status)) return DescriptionEntity._status;
|
||||
else if (item.match(Description._description) || item.match(PublicDescription._description)) return DescriptionEntity._description;
|
||||
else if (item.match(Description._createdBy)) return DescriptionEntity._createdById;
|
||||
else if (item.match(Description._createdAt)) return DescriptionEntity._createdAt;
|
||||
else if (item.match(Description._updatedAt)) return DescriptionEntity._updatedAt;
|
||||
else if (item.match(Description._createdAt) || item.match(PublicDescription._createdAt)) return DescriptionEntity._createdAt;
|
||||
else if (item.match(Description._updatedAt) || item.match(PublicDescription._updatedAt)) return DescriptionEntity._updatedAt;
|
||||
else if (item.match(Description._isActive)) return DescriptionEntity._isActive;
|
||||
else if (item.match(Description._finalizedAt)) return DescriptionEntity._finalizedAt;
|
||||
else if (item.match(Description._dmpDescriptionTemplate)) return DescriptionEntity._dmpDescriptionTemplateId;
|
||||
else if (item.match(Description._finalizedAt) || item.match(PublicDescription._finalizedAt)) return DescriptionEntity._finalizedAt;
|
||||
else if (item.prefix(Description._dmpDescriptionTemplate) || item.prefix(PublicDescription._dmpDescriptionTemplate)) return DescriptionEntity._dmpDescriptionTemplateId;
|
||||
else if (item.prefix(Description._dmp)) return DescriptionEntity._dmpId;
|
||||
else return null;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import eu.eudat.data.DmpDescriptionTemplateEntity;
|
|||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.data.DmpUserEntity;
|
||||
import eu.eudat.model.DmpDescriptionTemplate;
|
||||
import eu.eudat.model.PublicDmpDescriptionTemplate;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
|
@ -161,7 +162,7 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
|||
if (userId != null || usePublic ) {
|
||||
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpDescriptionTemplateEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)));
|
||||
}
|
||||
if (predicates.size() > 0) {
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
|
@ -229,9 +230,9 @@ public class DmpDescriptionTemplateQuery extends QueryBase<DmpDescriptionTemplat
|
|||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(DmpDescriptionTemplate._id)) return DmpDescriptionTemplateEntity._id;
|
||||
else if (item.prefix(DmpDescriptionTemplate._dmp)) return DmpDescriptionTemplateEntity._dmpId;
|
||||
else if (item.prefix(DmpDescriptionTemplate._descriptionTemplate)) return DmpDescriptionTemplateEntity._descriptionTemplateId;
|
||||
if (item.match(DmpDescriptionTemplate._id) || item.match(PublicDmpDescriptionTemplate._id)) return DmpDescriptionTemplateEntity._id;
|
||||
else if (item.prefix(DmpDescriptionTemplate._dmp) || item.prefix(PublicDmpDescriptionTemplate._dmp)) return DmpDescriptionTemplateEntity._dmpId;
|
||||
else if (item.prefix(DmpDescriptionTemplate._descriptionTemplate) || item.prefix(PublicDmpDescriptionTemplate._descriptionTemplate)) return DmpDescriptionTemplateEntity._descriptionTemplateId;
|
||||
else if (item.match(DmpDescriptionTemplate._sectionId)) return DmpDescriptionTemplateEntity._sectionId;
|
||||
else if (item.match(DmpDescriptionTemplate._createdAt)) return DmpDescriptionTemplateEntity._createdAt;
|
||||
else if (item.match(DmpDescriptionTemplate._updatedAt)) return DmpDescriptionTemplateEntity._updatedAt;
|
||||
|
|
|
@ -9,10 +9,12 @@ import eu.eudat.commons.scope.user.UserScope;
|
|||
import eu.eudat.data.DmpEntity;
|
||||
import eu.eudat.data.DmpUserEntity;
|
||||
import eu.eudat.model.Dmp;
|
||||
import eu.eudat.model.PublicDmp;
|
||||
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.*;
|
||||
import jakarta.persistence.AccessType;
|
||||
import jakarta.persistence.Tuple;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
|
@ -38,6 +40,7 @@ public class DmpQuery extends QueryBase<DmpEntity> {
|
|||
private Collection<IsActive> isActives;
|
||||
|
||||
private Collection<DmpStatus> statuses;
|
||||
private Collection<DmpAccessType> accessTypes;
|
||||
|
||||
private Collection<Integer> versions;
|
||||
|
||||
|
@ -105,6 +108,21 @@ public class DmpQuery extends QueryBase<DmpEntity> {
|
|||
return this;
|
||||
}
|
||||
|
||||
public DmpQuery accessTypes(DmpAccessType value) {
|
||||
this.accessTypes = List.of(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DmpQuery accessTypes(DmpAccessType... value) {
|
||||
this.accessTypes = Arrays.asList(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public DmpQuery accessTypes(Collection<DmpAccessType> values) {
|
||||
this.accessTypes = values;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DmpQuery statuses(DmpStatus value) {
|
||||
this.statuses = List.of(value);
|
||||
return this;
|
||||
|
@ -157,7 +175,7 @@ public class DmpQuery extends QueryBase<DmpEntity> {
|
|||
|
||||
@Override
|
||||
protected Boolean isFalseQuery() {
|
||||
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.statuses);
|
||||
return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.accessTypes)|| this.isEmpty(this.statuses);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -184,7 +202,7 @@ public class DmpQuery extends QueryBase<DmpEntity> {
|
|||
userId != null ? queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._id)).value(this.queryUtilsService.buildDmpUserAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId)) : queryContext.CriteriaBuilder.or() //Creates a false query
|
||||
));
|
||||
}
|
||||
if (predicates.size() > 0) {
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
|
@ -222,6 +240,12 @@ public class DmpQuery extends QueryBase<DmpEntity> {
|
|||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.accessTypes != null) {
|
||||
CriteriaBuilder.In<DmpAccessType> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._accessType));
|
||||
for (DmpAccessType item : this.accessTypes)
|
||||
inClause.value(item);
|
||||
predicates.add(inClause);
|
||||
}
|
||||
if (this.versions != null) {
|
||||
CriteriaBuilder.In<Integer> inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpEntity._version));
|
||||
for (Integer item : this.versions)
|
||||
|
@ -244,17 +268,17 @@ public class DmpQuery extends QueryBase<DmpEntity> {
|
|||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(Dmp._id)) return DmpEntity._id;
|
||||
else if (item.match(Dmp._label)) return DmpEntity._label;
|
||||
else if (item.match(Dmp._version)) return DmpEntity._version;
|
||||
if (item.match(Dmp._id) || item.match(PublicDmp._id)) return DmpEntity._id;
|
||||
else if (item.match(Dmp._label) || item.match(PublicDmp._label)) return DmpEntity._label;
|
||||
else if (item.match(Dmp._version) || item.match(PublicDmp._version)) return DmpEntity._version;
|
||||
else if (item.match(Dmp._status)) return DmpEntity._status;
|
||||
else if (item.match(Dmp._properties)) return DmpEntity._properties;
|
||||
else if (item.match(Dmp._groupId)) return DmpEntity._groupId;
|
||||
else if (item.match(Dmp._description)) return DmpEntity._description;
|
||||
else if (item.match(Dmp._description) || item.match(PublicDmp._description)) return DmpEntity._description;
|
||||
else if (item.match(Dmp._createdAt)) return DmpEntity._createdAt;
|
||||
else if (item.match(Dmp._updatedAt)) return DmpEntity._updatedAt;
|
||||
else if (item.match(Dmp._isActive) ) return DmpEntity._isActive;
|
||||
else if (item.match(Dmp._finalizedAt)) return DmpEntity._finalizedAt;
|
||||
else if (item.match(Dmp._finalizedAt) || item.match(PublicDmp._finalizedAt)) return DmpEntity._finalizedAt;
|
||||
else if (item.match(Dmp._accessType)) return DmpEntity._accessType;
|
||||
else if (item.match(Dmp._creator)) return DmpEntity._creator;
|
||||
else if (item.match(Dmp._blueprint)) return DmpEntity._blueprint;
|
||||
|
|
|
@ -8,6 +8,7 @@ import eu.eudat.data.DescriptionEntity;
|
|||
import eu.eudat.data.DescriptionReferenceEntity;
|
||||
import eu.eudat.data.DmpReferenceEntity;
|
||||
import eu.eudat.model.DmpReference;
|
||||
import eu.eudat.model.PublicDmpReference;
|
||||
import eu.eudat.query.utils.BuildSubQueryInput;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
|
@ -142,7 +143,7 @@ public class DmpReferenceQuery extends QueryBase<DmpReferenceEntity> {
|
|||
if (userId != null || usePublic ) {
|
||||
predicates.add(queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpReferenceEntity._dmpId)).value(queryUtilsService.buildDmpAuthZSubQuery(queryContext.Query, queryContext.CriteriaBuilder, userId, usePublic)));
|
||||
}
|
||||
if (predicates.size() > 0) {
|
||||
if (!predicates.isEmpty()) {
|
||||
Predicate[] predicatesArray = predicates.toArray(new Predicate[0]);
|
||||
return queryContext.CriteriaBuilder.and(predicatesArray);
|
||||
} else {
|
||||
|
@ -199,9 +200,9 @@ public class DmpReferenceQuery extends QueryBase<DmpReferenceEntity> {
|
|||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(DmpReference._id)) return DmpReferenceEntity._id;
|
||||
else if (item.prefix(DmpReference._dmp)) return DmpReferenceEntity._dmpId;
|
||||
else if (item.prefix(DmpReference._reference)) return DmpReferenceEntity._referenceId;
|
||||
if (item.match(DmpReference._id) || item.match(PublicDmpReference._id)) return DmpReferenceEntity._id;
|
||||
else if (item.prefix(DmpReference._dmp) || item.prefix(PublicDmpReference._dmp)) return DmpReferenceEntity._dmpId;
|
||||
else if (item.prefix(DmpReference._reference) || item.prefix(PublicDmpReference._reference)) return DmpReferenceEntity._referenceId;
|
||||
else if (item.match(DmpReference._data)) return DmpReferenceEntity._data;
|
||||
else if (item.match(DmpReference._createdAt)) return DmpReferenceEntity._createdAt;
|
||||
else if (item.match(DmpReference._updatedAt)) return DmpReferenceEntity._updatedAt;
|
||||
|
|
|
@ -7,6 +7,7 @@ import eu.eudat.commons.enums.IsActive;
|
|||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.DmpUserEntity;
|
||||
import eu.eudat.model.DmpUser;
|
||||
import eu.eudat.model.PublicDmpUser;
|
||||
import eu.eudat.query.utils.QueryUtilsService;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
|
@ -221,10 +222,10 @@ public class DmpUserQuery extends QueryBase<DmpUserEntity> {
|
|||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(DmpUser._id)) return DmpUserEntity._id;
|
||||
else if (item.prefix(DmpUser._dmp)) return DmpUserEntity._dmp;
|
||||
else if (item.prefix(DmpUser._user)) return DmpUserEntity._user;
|
||||
else if (item.match(DmpUser._role)) return DmpUserEntity._role;
|
||||
if (item.match(DmpUser._id) || item.match(PublicDmpUser._id)) return DmpUserEntity._id;
|
||||
else if (item.prefix(DmpUser._dmp) || item.prefix(PublicDmpUser._dmp)) return DmpUserEntity._dmp;
|
||||
else if (item.prefix(DmpUser._user) || item.prefix(PublicDmpUser._user)) return DmpUserEntity._user;
|
||||
else if (item.match(DmpUser._role) || item.match(PublicDmpUser._role)) return DmpUserEntity._role;
|
||||
else if (item.match(DmpUser._createdAt)) return DmpUserEntity._createdAt;
|
||||
else if (item.match(DmpUser._updatedAt)) return DmpUserEntity._updatedAt;
|
||||
else return null;
|
||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.commons.enums.IsActive;
|
|||
import eu.eudat.commons.enums.ReferenceSourceType;
|
||||
import eu.eudat.commons.scope.user.UserScope;
|
||||
import eu.eudat.data.ReferenceEntity;
|
||||
import eu.eudat.model.PublicReference;
|
||||
import eu.eudat.model.Reference;
|
||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||
import gr.cite.tools.data.query.FieldResolver;
|
||||
|
@ -205,18 +206,18 @@ public class ReferenceQuery extends QueryBase<ReferenceEntity> {
|
|||
|
||||
@Override
|
||||
protected String fieldNameOf(FieldResolver item) {
|
||||
if (item.match(ReferenceEntity._id)) return ReferenceEntity._id;
|
||||
else if (item.match(Reference._label)) return ReferenceEntity._label;
|
||||
else if (item.match(Reference._description)) return ReferenceEntity._description;
|
||||
if (item.match(Reference._id) || item.match(PublicReference._id)) return ReferenceEntity._id;
|
||||
else if (item.match(Reference._label) || item.match(PublicReference._label)) return ReferenceEntity._label;
|
||||
else if (item.match(Reference._description) || item.match(PublicReference._description)) return ReferenceEntity._description;
|
||||
else if (item.match(Reference._createdAt)) return ReferenceEntity._createdAt;
|
||||
else if (item.match(Reference._updatedAt)) return ReferenceEntity._updatedAt;
|
||||
else if (item.match(Reference._isActive)) return ReferenceEntity._isActive;
|
||||
else if (item.match(Reference._definition)) return ReferenceEntity._definition;
|
||||
else if (item.match(Reference._abbreviation)) return ReferenceEntity._abbreviation;
|
||||
else if (item.match(Reference._reference)) return ReferenceEntity._reference;
|
||||
else if (item.match(Reference._reference) || item.match(PublicReference._reference)) return ReferenceEntity._reference;
|
||||
else if (item.match(Reference._source)) return ReferenceEntity._source;
|
||||
else if (item.match(Reference._sourceType)) return ReferenceEntity._sourceType;
|
||||
else if (item.match(Reference._type)) return ReferenceEntity._type;
|
||||
else if (item.match(Reference._type) || item.match(PublicReference._type)) return ReferenceEntity._type;
|
||||
//else if (item.prefix(Reference._createdBy)) return ReferenceEntity._createdBy;
|
||||
else return null;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.query.lookup;
|
||||
|
||||
import eu.eudat.commons.enums.DmpAccessType;
|
||||
import eu.eudat.commons.enums.DmpStatus;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.query.DmpQuery;
|
||||
|
@ -20,6 +21,7 @@ public class DmpLookup extends Lookup {
|
|||
private List<IsActive> isActive;
|
||||
|
||||
private List<DmpStatus> statuses;
|
||||
private List<DmpAccessType> accessTypes;
|
||||
|
||||
private List<Integer> versions;
|
||||
|
||||
|
@ -71,11 +73,20 @@ public class DmpLookup extends Lookup {
|
|||
this.versions = versions;
|
||||
}
|
||||
|
||||
public List<DmpAccessType> getAccessTypes() {
|
||||
return accessTypes;
|
||||
}
|
||||
|
||||
public void setAccessTypes(List<DmpAccessType> accessTypes) {
|
||||
this.accessTypes = accessTypes;
|
||||
}
|
||||
|
||||
public DmpQuery enrich(QueryFactory queryFactory) {
|
||||
DmpQuery query = queryFactory.query(DmpQuery.class);
|
||||
if (this.like != null) query.like(this.like);
|
||||
if (this.ids != null) query.ids(this.ids);
|
||||
if (this.excludedIds != null) query.excludedIds(this.excludedIds);
|
||||
if (this.accessTypes != null) query.accessTypes(this.accessTypes);
|
||||
if (this.isActive != null) query.isActive(this.isActive);
|
||||
if (this.statuses != null) query.statuses(this.statuses);
|
||||
if (this.versions != null) query.versions(this.versions);
|
||||
|
|
|
@ -2,14 +2,21 @@ package eu.eudat.controllers.v2;
|
|||
|
||||
import eu.eudat.audit.AuditableAction;
|
||||
import eu.eudat.authorization.AuthorizationFlags;
|
||||
import eu.eudat.commons.enums.DmpAccessType;
|
||||
import eu.eudat.commons.enums.DmpStatus;
|
||||
import eu.eudat.commons.enums.IsActive;
|
||||
import eu.eudat.data.DescriptionEntity;
|
||||
import eu.eudat.model.Description;
|
||||
import eu.eudat.model.Dmp;
|
||||
import eu.eudat.model.PublicDescription;
|
||||
import eu.eudat.model.builder.DescriptionBuilder;
|
||||
import eu.eudat.model.builder.PublicDescriptionBuilder;
|
||||
import eu.eudat.model.censorship.DescriptionCensor;
|
||||
import eu.eudat.model.censorship.PublicDescriptionCensor;
|
||||
import eu.eudat.model.persist.DescriptionPersist;
|
||||
import eu.eudat.model.result.QueryResult;
|
||||
import eu.eudat.query.DescriptionQuery;
|
||||
import eu.eudat.query.DmpQuery;
|
||||
import eu.eudat.query.lookup.DescriptionLookup;
|
||||
import eu.eudat.service.description.DescriptionService;
|
||||
import gr.cite.tools.auditing.AuditService;
|
||||
|
@ -33,6 +40,8 @@ import javax.management.InvalidApplicationException;
|
|||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static eu.eudat.authorization.AuthorizationFlags.Public;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(path = "api/description")
|
||||
public class DescriptionController {
|
||||
|
@ -66,8 +75,44 @@ public class DescriptionController {
|
|||
this.messageSource = messageSource;
|
||||
}
|
||||
|
||||
@PostMapping("public/query")
|
||||
public QueryResult<PublicDescription> publicQuery(@RequestBody DescriptionLookup lookup) throws MyApplicationException, MyForbiddenException {
|
||||
logger.debug("querying {}", Description.class.getSimpleName());
|
||||
|
||||
this.censorFactory.censor(PublicDescriptionCensor.class).censor(lookup.getProject());
|
||||
|
||||
DescriptionQuery query = lookup.enrich(this.queryFactory).authorize(EnumSet.of(Public)).dmpSubQuery(this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public));
|
||||
|
||||
List<DescriptionEntity> data = query.collectAs(lookup.getProject());
|
||||
List<PublicDescription> models = this.builderFactory.builder(PublicDescriptionBuilder.class).authorize(EnumSet.of(Public)).build(lookup.getProject(), data);
|
||||
long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size();
|
||||
|
||||
this.auditService.track(AuditableAction.Description_PublicQuery, "lookup", lookup);
|
||||
|
||||
return new QueryResult<>(models, count);
|
||||
}
|
||||
|
||||
@GetMapping("public/{id}")
|
||||
public Description publicGet(@PathVariable("id") UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
||||
logger.debug(new MapLogEntry("retrieving" + Description.class.getSimpleName()).And("id", id).And("fields", fieldSet));
|
||||
|
||||
this.censorFactory.censor(DescriptionCensor.class).censor(fieldSet, null);
|
||||
|
||||
DescriptionQuery query = this.queryFactory.query(DescriptionQuery.class).authorize(EnumSet.of(Public)).ids(id).dmpSubQuery(this.queryFactory.query(DmpQuery.class).isActive(IsActive.Active).statuses(DmpStatus.Finalized).accessTypes(DmpAccessType.Public));
|
||||
|
||||
Description model = this.builderFactory.builder(DescriptionBuilder.class).authorize(EnumSet.of(Public)).build(fieldSet, query.firstAs(fieldSet));
|
||||
if (model == null) throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, Dmp.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
|
||||
this.auditService.track(AuditableAction.Description_PublicLookup, Map.ofEntries(
|
||||
new AbstractMap.SimpleEntry<String, Object>("id", id),
|
||||
new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
|
||||
));
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
@PostMapping("query")
|
||||
public QueryResult<Description> Query(@RequestBody DescriptionLookup lookup) throws MyApplicationException, MyForbiddenException {
|
||||
public QueryResult<Description> query(@RequestBody DescriptionLookup lookup) throws MyApplicationException, MyForbiddenException {
|
||||
logger.debug("querying {}", Description.class.getSimpleName());
|
||||
|
||||
this.censorFactory.censor(DescriptionCensor.class).censor(lookup.getProject(), null);
|
||||
|
@ -83,8 +128,9 @@ public class DescriptionController {
|
|||
return new QueryResult<>(models, count);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("{id}")
|
||||
public Description Get(@PathVariable("id") UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
||||
public Description get(@PathVariable("id") UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
|
||||
logger.debug(new MapLogEntry("retrieving" + Description.class.getSimpleName()).And("id", id).And("fields", fieldSet));
|
||||
|
||||
this.censorFactory.censor(DescriptionCensor.class).censor(fieldSet, null);
|
||||
|
@ -104,7 +150,7 @@ public class DescriptionController {
|
|||
|
||||
@PostMapping("persist")
|
||||
@Transactional
|
||||
public Description Persist(@MyValidate @RequestBody DescriptionPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
|
||||
public Description persist(@MyValidate @RequestBody DescriptionPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
|
||||
logger.debug(new MapLogEntry("persisting" + Description.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
|
||||
Description persisted = this.descriptionService.persist(model, fieldSet);
|
||||
|
||||
|
@ -118,7 +164,7 @@ public class DescriptionController {
|
|||
|
||||
@DeleteMapping("{id}")
|
||||
@Transactional
|
||||
public void Delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException, IOException {
|
||||
public void delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException, IOException {
|
||||
logger.debug(new MapLogEntry("retrieving" + Description.class.getSimpleName()).And("id", id));
|
||||
|
||||
this.descriptionService.deleteAndSave(id);
|
||||
|
|
|
@ -2,7 +2,7 @@ web:
|
|||
security:
|
||||
enabled: true
|
||||
authorized-endpoints: [ api ]
|
||||
allowed-endpoints: [ api/public ]
|
||||
allowed-endpoints: [ api/public, api/description/public ]
|
||||
idp:
|
||||
api-key:
|
||||
enabled: true
|
||||
|
|
Loading…
Reference in New Issue