diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/TagDao.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/TagDao.java index e6f37a2d..fe780e36 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/TagDao.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/TagDao.java @@ -215,16 +215,15 @@ public class TagDao { StringBuilder sb = new StringBuilder("select t.TAG_ID_C as c0, t.TAG_NAME_C as c1, t.TAG_COLOR_C as c2, t.TAG_IDPARENT_C as c3 "); sb.append(" from T_TAG t "); - // TODO Use ACLs // Add search criterias if (criteria.getId() != null) { criteriaList.add("t.TAG_ID_C = :id"); parameterMap.put("id", criteria.getId()); } - if (criteria.getUserId() != null) { - criteriaList.add("t.TAG_IDUSER_C = :userId"); - parameterMap.put("userId", criteria.getUserId()); + if (criteria.getTargetIdList() != null) { + sb.append(" left join T_ACL a on a.ACL_TARGETID_C in (:targetIdList) and a.ACL_SOURCEID_C = t.TAG_ID_C and a.ACL_PERM_C = 'READ' and a.ACL_DELETEDATE_D is null "); + parameterMap.put("targetIdList", criteria.getTargetIdList()); } if (criteria.getDocumentId() != null) { sb.append(" join T_DOCUMENT_TAG dt on dt.DOT_IDTAG_C = t.TAG_ID_C and dt.DOT_DELETEDATE_D is null "); diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/criteria/TagCriteria.java b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/criteria/TagCriteria.java index 9bb7be9d..2665a205 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/criteria/TagCriteria.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/jpa/criteria/TagCriteria.java @@ -1,5 +1,7 @@ package com.sismics.docs.core.dao.jpa.criteria; +import java.util.List; + /** * Tag criteria. * @@ -12,9 +14,9 @@ public class TagCriteria { private String id; /** - * User ID. + * ACL target ID list. */ - private String userId; + private List targetIdList; /** * Document ID. @@ -40,12 +42,12 @@ public class TagCriteria { return this; } - public String getUserId() { - return userId; + public List getTargetIdList() { + return targetIdList; } - public TagCriteria setUserId(String userId) { - this.userId = userId; + public TagCriteria setTargetIdList(List targetIdList) { + this.targetIdList = targetIdList; return this; } diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java index a3420324..acb156e7 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/DocumentResource.java @@ -116,7 +116,7 @@ public class DocumentResource extends BaseResource { } else { // Add tags added by the current user on this document TagDao tagDao = new TagDao(); - List tagDtoList = tagDao.findByCriteria(new TagCriteria().setUserId(principal.getId()).setDocumentId(documentId), new SortCriteria(1, true)); + List tagDtoList = tagDao.findByCriteria(new TagCriteria().setTargetIdList(getTargetIdList(null)).setDocumentId(documentId), new SortCriteria(1, true)); JsonArrayBuilder tags = Json.createArrayBuilder(); for (TagDto tagDto : tagDtoList) { tags.add(Json.createObjectBuilder() @@ -292,7 +292,7 @@ public class DocumentResource extends BaseResource { for (DocumentDto documentDto : paginatedList.getResultList()) { // Get tags added by the current user on this document - List tagDtoList = tagDao.findByCriteria(new TagCriteria().setUserId(principal.getId()).setDocumentId(documentDto.getId()), new SortCriteria(1, true)); + List tagDtoList = tagDao.findByCriteria(new TagCriteria().setTargetIdList(getTargetIdList(null)).setDocumentId(documentDto.getId()), new SortCriteria(1, true)); JsonArrayBuilder tags = Json.createArrayBuilder(); for (TagDto tagDto : tagDtoList) { tags.add(Json.createObjectBuilder() @@ -355,7 +355,7 @@ public class DocumentResource extends BaseResource { switch (params[0]) { case "tag": // New tag criteria - List tagDtoList = tagDao.findByCriteria(new TagCriteria().setUserId(principal.getId()).setNameLike(params[1]), null); + List tagDtoList = tagDao.findByCriteria(new TagCriteria().setTargetIdList(getTargetIdList(null)).setNameLike(params[1]), null); if (documentCriteria.getTagIdList() == null) { documentCriteria.setTagIdList(new ArrayList()); } @@ -657,7 +657,7 @@ public class DocumentResource extends BaseResource { TagDao tagDao = new TagDao(); Set tagSet = new HashSet<>(); Set tagIdSet = new HashSet<>(); - List tagDtoList = tagDao.findByCriteria(new TagCriteria().setUserId(principal.getId()), null); + List tagDtoList = tagDao.findByCriteria(new TagCriteria().setTargetIdList(getTargetIdList(null)), null); for (TagDto tagDto : tagDtoList) { tagIdSet.add(tagDto.getId()); } diff --git a/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java b/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java index 63c3bf79..9891b816 100644 --- a/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java +++ b/docs-web/src/main/java/com/sismics/docs/rest/resource/TagResource.java @@ -50,7 +50,7 @@ public class TagResource extends BaseResource { } TagDao tagDao = new TagDao(); - List tagDtoList = tagDao.findByCriteria(new TagCriteria().setUserId(principal.getId()), null); + List tagDtoList = tagDao.findByCriteria(new TagCriteria().setTargetIdList(getTargetIdList(null)), null); JsonArrayBuilder items = Json.createArrayBuilder(); for (TagDto tagDto : tagDtoList) { items.add(Json.createObjectBuilder() @@ -125,7 +125,7 @@ public class TagResource extends BaseResource { if (StringUtils.isEmpty(parentId)) { parentId = null; } else { - List tagDtoList = tagDao.findByCriteria(new TagCriteria().setUserId(principal.getId()).setId(parentId), null); + List tagDtoList = tagDao.findByCriteria(new TagCriteria().setTargetIdList(getTargetIdList(null)).setId(parentId), null); if (tagDtoList.size() == 0) { throw new ClientException("ParentNotFound", MessageFormat.format("Parent not found: {0}", parentId)); } @@ -190,7 +190,7 @@ public class TagResource extends BaseResource { // Get the tag TagDao tagDao = new TagDao(); - List tagDtoList = tagDao.findByCriteria(new TagCriteria().setUserId(principal.getId()).setId(id), null); + List tagDtoList = tagDao.findByCriteria(new TagCriteria().setTargetIdList(getTargetIdList(null)).setId(id), null); if (tagDtoList.size() == 0) { throw new ClientException("TagNotFound", MessageFormat.format("Tag not found: {0}", id)); } @@ -199,7 +199,7 @@ public class TagResource extends BaseResource { if (StringUtils.isEmpty(parentId)) { parentId = null; } else { - tagDtoList = tagDao.findByCriteria(new TagCriteria().setUserId(principal.getId()).setId(parentId), null); + tagDtoList = tagDao.findByCriteria(new TagCriteria().setTargetIdList(getTargetIdList(null)).setId(parentId), null); if (tagDtoList.size() == 0) { throw new ClientException("ParentNotFound", MessageFormat.format("Parent not found: {0}", parentId)); } @@ -240,7 +240,7 @@ public class TagResource extends BaseResource { // Get the tag TagDao tagDao = new TagDao(); - List tagDtoList = tagDao.findByCriteria(new TagCriteria().setUserId(principal.getId()).setId(id), null); + List tagDtoList = tagDao.findByCriteria(new TagCriteria().setTargetIdList(getTargetIdList(null)).setId(id), null); if (tagDtoList.size() == 0) { throw new ClientException("TagNotFound", MessageFormat.format("Tag not found: {0}", id)); } diff --git a/docs-parent/pom.xml b/pom.xml similarity index 98% rename from docs-parent/pom.xml rename to pom.xml index 81362ea6..64c8b8e7 100644 --- a/docs-parent/pom.xml +++ b/pom.xml @@ -120,9 +120,9 @@ - ../docs-core - ../docs-web-common - ../docs-web + docs-core + docs-web-common + docs-web @@ -374,8 +374,9 @@ org.apache.poi.xwpf.converter.pdf ${fr.opensagres.xdocreport.version} - - + + + com.twelvemonkeys.servlet servlet ${com.twelvemonkeys.imageio.version} @@ -389,7 +390,8 @@ - + + com.twelvemonkeys.imageio imageio-jpeg ${com.twelvemonkeys.imageio.version}