From c37a4ba527b261a553e2924af0fec919ee7e1f86 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Tue, 14 Jun 2011 11:22:04 +0000 Subject: [PATCH] =?UTF-8?q?Swift=20=E2=80=93=20SE.S21=20Share=20-=20DM=20R?= =?UTF-8?q?emote=20Store=20-=20WIP=20=20-=20listpattern=20method=20now=20w?= =?UTF-8?q?orking=20for=20site=20and=20user=20dashboards=20=20-=20inherite?= =?UTF-8?q?d=20permissions=20correctly=20block=20invalid=20users=20from=20?= =?UTF-8?q?modifying=20or=20removing=20dashboard=20and=20component=20confi?= =?UTF-8?q?g=20for=20sites=20and=20users,=20private=20sites=20automaticall?= =?UTF-8?q?y=20hide=20child=20surf-config=20folder=20also=20=20-=20added?= =?UTF-8?q?=20surf-config=20folder=20to=20sites=20bootstrap=20descriptor?= 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/HEAD/root@28382 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/web/scripts/bean/ADMRemoteStore.java | 43 ++++++++++++++----- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/source/java/org/alfresco/repo/web/scripts/bean/ADMRemoteStore.java b/source/java/org/alfresco/repo/web/scripts/bean/ADMRemoteStore.java index 34ca406902..70fe63d5ab 100644 --- a/source/java/org/alfresco/repo/web/scripts/bean/ADMRemoteStore.java +++ b/source/java/org/alfresco/repo/web/scripts/bean/ADMRemoteStore.java @@ -461,7 +461,7 @@ public class ADMRemoteStore extends BaseRemoteStore * * @param store the store id * @param path document path - * @param pattern file pattern to match - allows wildcards e.g. *.xml or site*.xml + * @param pattern file pattern to match - allows wildcards e.g. page.*.site.xml * * @throws IOException if an error occurs listing the documents */ @@ -476,25 +476,27 @@ public class ADMRemoteStore extends BaseRemoteStore { res.setContentType("text/plain;charset=UTF-8"); - final FileInfo fileInfo = resolveNodePath(path, false, true); - if (fileInfo == null || !fileInfo.isFolder()) - { - res.setStatus(Status.STATUS_NOT_FOUND); - return null; - } - String filePattern = pattern; if (filePattern == null || filePattern.length() == 0) { filePattern = "*"; } + // ensure we pass in the file pattern as it is used as part of the folder match - i.e. + // for a site component set e.g. /alfresco/site-data/components/page.*.site~xyz~dashboard.xml + final FileInfo fileInfo = resolveNodePath(path, pattern, false, true); + if (fileInfo == null || !fileInfo.isFolder()) + { + res.setStatus(Status.STATUS_NOT_FOUND); + return null; + } + if (logger.isDebugEnabled()) logger.debug("listDocuments() pattern: " + pattern); try { - outputFileNodes(res.getWriter(), fileInfo, aquireSurfConfigRef(path, false), pattern, false); + outputFileNodes(res.getWriter(), fileInfo, aquireSurfConfigRef(path + "/" + pattern, false), pattern, false); } catch (AccessDeniedException ae) { @@ -521,7 +523,7 @@ public class ADMRemoteStore extends BaseRemoteStore return resolveNodePath(path, false, false); } - /** + /** * @param path cm:name based root relative path * example: /alfresco/site-data/pages/customise-user-dashboard.xml * /alfresco/site-data/components @@ -534,6 +536,25 @@ public class ADMRemoteStore extends BaseRemoteStore * parameter above) or null if the supplied path does not exist in the store. */ private FileInfo resolveNodePath(final String path, final boolean create, final boolean isFolder) + { + return resolveNodePath(path, null, create, isFolder); + } + + /** + * @param path cm:name based root relative path + * example: /alfresco/site-data/pages/customise-user-dashboard.xml + * /alfresco/site-data/components + * @param pattern optional pattern that is used as part of the match to aquire the surf-config + * folder under the appropriate sites or user location. + * @param create if true create the config and folder dirs for the given path returning + * the FileInfo for the last parent in the path, if false only attempt to + * resolve the folder path if it exists returning the last element. + * @param isFolder True if the path is for a folder, false if it ends in a filename + * + * @return FileInfo representing the file/folder at the specified path location (see create + * parameter above) or null if the supplied path does not exist in the store. + */ + private FileInfo resolveNodePath(final String path, final String pattern, final boolean create, final boolean isFolder) { if (logger.isDebugEnabled()) logger.debug("Resolving path: " + path); @@ -554,7 +575,7 @@ public class ADMRemoteStore extends BaseRemoteStore pathElements.add(t.nextToken()); } - NodeRef surfConfigRef = aquireSurfConfigRef(path, create); + NodeRef surfConfigRef = aquireSurfConfigRef(path + (pattern != null ? ("/" + pattern) : ""), create); try { if (create)