From 0c62289cd552d2f57dea265ce9e0a36253b44655 Mon Sep 17 00:00:00 2001 From: Ancuta Morarasu Date: Wed, 11 May 2016 11:00:21 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20HEAD=20(5.2)=20to=205.2.N=20(5.2.1)=20?= =?UTF-8?q?=20=20=20126392=20jkaabimofrad:=20Merged=20FILE-FOLDER-API=20(5?= =?UTF-8?q?.2.0)=20to=20HEAD=20(5.2)=20=20=20=20=20=20=20120603=20jkaabimo?= =?UTF-8?q?frad:=20FileFolder=20API=20=E2=80=93=20cleanup=20+=20minor=20mo?= =?UTF-8?q?dification=20to=20satisfy=20the=20IDEA's=20code=20analysis.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126738 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../org/alfresco/rest/api/impl/NodesImpl.java | 72 +++---------------- 1 file changed, 11 insertions(+), 61 deletions(-) diff --git a/source/java/org/alfresco/rest/api/impl/NodesImpl.java b/source/java/org/alfresco/rest/api/impl/NodesImpl.java index ceb69bdbb2..3479d6de02 100644 --- a/source/java/org/alfresco/rest/api/impl/NodesImpl.java +++ b/source/java/org/alfresco/rest/api/impl/NodesImpl.java @@ -127,8 +127,8 @@ public class NodesImpl implements Nodes private static enum Type { // Note: ordered - DOCUMENT, FOLDER; - }; + DOCUMENT, FOLDER + } private final static String PARAM_RELATIVE_PATH = "relativePath"; // TODO wip @@ -151,7 +151,7 @@ public class NodesImpl implements Nodes private Set defaultIgnoreTypes; private Set ignoreTypeQNames; - private Set nonAttachContentTypes = Collections.EMPTY_SET; // pre-configured whitelist, eg. images & pdf + private Set nonAttachContentTypes = Collections.emptySet(); // pre-configured whitelist, eg. images & pdf public void setNonAttachContentTypes(Set nonAttachWhiteList) { @@ -661,59 +661,7 @@ public class NodesImpl implements Nodes protected PathInfo lookupPathInfo(NodeRef nodeRefIn) { - // TODO which implementation? - return getPathInfo(nodeRefIn); - - // List elements = new ArrayList<>(5); - // - // NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome(); - // boolean isComplete = true; - // - // NodeRef pNodeRef = nodeRefIn; - // while (pNodeRef != null) - // { - // if (pNodeRef.equals(companyHomeNodeRef)) - // { - // pNodeRef = null; - // } - // else { - // pNodeRef = nodeService.getPrimaryParent(pNodeRef).getParentRef(); - // - // if (pNodeRef == null) - // { - // // belts-and-braces - is it even possible to get here ? - // isComplete = false; - // } - // else - // { - // if (permissionService.hasPermission(pNodeRef, PermissionService.READ) - // == AccessStatus.ALLOWED) - // { - // String name = (String) nodeService.getProperty(pNodeRef, - // ContentModel.PROP_NAME); - // elements.add(0, new ElementInfo(pNodeRef, name)); - // } - // else - // { - // isComplete = false; - // pNodeRef = null; - // } - // } - // } - // } - // - // StringBuilder sb = new StringBuilder(); - // for (PathInfo.ElementInfo e : elements) - // { - // sb.append("/").append(e.getName()); - // } - // - // return new PathInfo(sb.toString(), isComplete, elements); - } - - private PathInfo getPathInfo(NodeRef nodeRef) - { - final Path nodePath = nodeService.getPath(nodeRef); + final Path nodePath = nodeService.getPath(nodeRefIn); List pathElements = new ArrayList<>(); Boolean isComplete = Boolean.TRUE; @@ -1189,9 +1137,11 @@ public class NodesImpl implements Nodes String name = (String)nodeProps.get(ContentModel.PROP_NAME); org.alfresco.rest.framework.resource.content.ContentInfo ci = null; + String mimeType = null; if (cd != null) { - ci = new org.alfresco.rest.framework.resource.content.ContentInfoImpl(cd.getMimetype(), cd.getEncoding(), cd.getSize(), cd.getLocale()); + mimeType = cd.getMimetype(); + ci = new org.alfresco.rest.framework.resource.content.ContentInfoImpl(mimeType, cd.getEncoding(), cd.getSize(), cd.getLocale()); } // By default set attachment header (with filename) unless attachment=false *and* content type is pre-configured as non-attach @@ -1199,16 +1149,16 @@ public class NodesImpl implements Nodes String attachment = parameters.getParameter("attachment"); if (attachment != null) { - Boolean a = new Boolean(attachment); - if ((a != null) && (a == false)) + Boolean a = Boolean.valueOf(attachment); + if (!a) { - if (nonAttachContentTypes.contains(cd.getMimetype())) + if (nonAttachContentTypes.contains(mimeType)) { attach = false; } else { - logger.warn("Ignored attachment=false for "+fileNodeId+" since "+cd.getMimetype()+" is not in the whitelist for non-attach content types"); + logger.warn("Ignored attachment=false for "+fileNodeId+" since "+mimeType+" is not in the whitelist for non-attach content types"); } } }