Fix for ALF-10559 - unable to save/edit user dashboards since Site (st:sites) folder permission changes.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30842 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2011-09-29 09:45:29 +00:00
parent a4a389a11f
commit 465013fa9f

View File

@@ -326,13 +326,41 @@ public class ADMRemoteStore extends BaseRemoteStore
final int off = encpath.lastIndexOf('/'); final int off = encpath.lastIndexOf('/');
if (off != -1) if (off != -1)
{ {
FileInfo parentFolder = resolveNodePath(encpath, true, false); // check we actually are the user we are creating a user specific path for
FileInfo fileInfo = this.fileFolderService.create( String runAsUser = AuthenticationUtil.getFullyAuthenticatedUser();
parentFolder.getNodeRef(), encpath.substring(off + 1), ContentModel.TYPE_CONTENT); String userId = null;
this.contentService.getWriter( Matcher matcher;
fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true).putContent(content); if ((matcher = USER_PATTERN_1.matcher(path)).matches())
if (logger.isDebugEnabled()) {
logger.debug("createDocument: " + fileInfo.toString()); userId = matcher.group(1);
}
else if ((matcher = USER_PATTERN_2.matcher(path)).matches())
{
userId = matcher.group(1);
}
if (userId != null && userId.equals(runAsUser))
{
runAsUser = AuthenticationUtil.getSystemUserName();
}
AuthenticationUtil.runAs(new RunAsWork<Void>()
{
@SuppressWarnings("synthetic-access")
public Void doWork() throws Exception
{
final FileInfo parentFolder = resolveNodePath(encpath, true, false);
if (parentFolder == null)
{
throw new IllegalStateException("Unable to aquire parent folder reference for path: " + path);
}
FileInfo fileInfo = fileFolderService.create(
parentFolder.getNodeRef(), encpath.substring(off + 1), ContentModel.TYPE_CONTENT);
contentService.getWriter(
fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true).putContent(content);
if (logger.isDebugEnabled())
logger.debug("createDocument: " + fileInfo.toString());
return null;
}
}, runAsUser);
} }
} }
catch (AccessDeniedException ae) catch (AccessDeniedException ae)
@@ -592,6 +620,7 @@ public class ADMRemoteStore extends BaseRemoteStore
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
logger.debug("Resolving path: " + path); logger.debug("Resolving path: " + path);
FileInfo result = null; FileInfo result = null;
if (path != null) if (path != null)
{ {