Merged JAMAL/MNT-16371 (5.1.2) to 5.1.N (5.1.2)

128626 jkaabimofrad: MNT-16371: Turned off Inherit Permissions and explicitly added the Site Manager role for the Site to the surf-config folder when it is first created. Also, revoked ownership privileges for surf-config contents.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@128649 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2016-07-08 12:54:34 +00:00
parent 89ab3b57ab
commit cc6549f253

View File

@@ -125,69 +125,105 @@ public class FileFolderUtil
List<PathElementDetails> pathElementDetails, QName folderTypeQName, BehaviourFilter behaviourFilter, List<PathElementDetails> pathElementDetails, QName folderTypeQName, BehaviourFilter behaviourFilter,
Set<QName> parentBehavioursToDisable) Set<QName> parentBehavioursToDisable)
{ {
validate(pathElementDetails, service, folderTypeQName); return makeFolders(service, nodeService, parentNodeRef, pathElementDetails, folderTypeQName, behaviourFilter, parentBehavioursToDisable, null);
}
NodeRef currentParentRef = parentNodeRef;
// just loop and create if necessary /**
for (PathElementDetails pathElement : pathElementDetails) * Checks for the presence of, and creates as necessary, the folder
{ * structure in the provided paths with the following options:
// does it exist? * <ul>
// Navigation should not check permissions * <li>Option to disable parent behaviour(s) when creating sub-folder.</li>
NodeRef nodeRef = AuthenticationUtil.runAs( * <li>Each folder has the option to have its own set of aspects</li>
new SearchAsSystem(service, currentParentRef, pathElement.getFolderName()), *</ul>
AuthenticationUtil.getSystemUserName()); *
* @param service the FileFolderService object
if (nodeRef == null) * @param nodeService the NodeService object
{ * @param parentNodeRef the node under which the path will be created
if ((behaviourFilter != null) && (parentBehavioursToDisable != null)) * @param pathElementDetails the list of folder hierarchy where each folder
{ * can have its own set of aspects - may not be empty
for (QName parentBehaviourToDisable : parentBehavioursToDisable) * @param folderTypeQName the types of nodes to create. This must be a valid
{ * subtype of {@link org.alfresco.model.ContentModel#TYPE_FOLDER
behaviourFilter.disableBehaviour(currentParentRef, parentBehaviourToDisable); * they folder type}
} * @param behaviourFilter the BehaviourFilter object
} * @param parentBehavioursToDisable the set of behaviours that must be
* disabled
try * @param allFoldersRefsInThePath (Optional) if an instance of a Set is provided,
{ * then it'd be populated with nodeRefs of all
// not present - make it * the folders that have been specified in the path
// If this uses the public service it will check create * elements details.({@code pathElementDetails}).
// permissions * @return Returns the {@code FileInfo} of the last folder in the path.
FileInfo createdFileInfo = service.create(currentParentRef, pathElement.getFolderName(), folderTypeQName); */
currentParentRef = createdFileInfo.getNodeRef(); public static FileInfo makeFolders(FileFolderService service, NodeService nodeService, NodeRef parentNodeRef,
List<PathElementDetails> pathElementDetails, QName folderTypeQName, BehaviourFilter behaviourFilter,
Map<QName, Map<QName, Serializable>> requireddAspects = pathElement.getAspects(); Set<QName> parentBehavioursToDisable, Set<NodeRef> allFoldersRefsInThePath)
if (requireddAspects.size() > 0 && nodeService != null) {
{ validate(pathElementDetails, service, folderTypeQName);
for (QName aspect : requireddAspects.keySet())
{ NodeRef currentParentRef = parentNodeRef;
nodeService.addAspect(currentParentRef, aspect, requireddAspects.get(aspect)); // just loop and create if necessary
} for (PathElementDetails pathElement : pathElementDetails)
} {
} // does it exist?
finally // Navigation should not check permissions
{ NodeRef nodeRef = AuthenticationUtil.runAs(
if ((behaviourFilter != null) && (parentBehavioursToDisable != null)) new SearchAsSystem(service, currentParentRef, pathElement.getFolderName()),
{ AuthenticationUtil.getSystemUserName());
for (QName parentBehaviourToDisable : parentBehavioursToDisable)
{ if (nodeRef == null)
behaviourFilter.enableBehaviour(currentParentRef, parentBehaviourToDisable); {
} if ((behaviourFilter != null) && (parentBehavioursToDisable != null))
} {
} for (QName parentBehaviourToDisable : parentBehavioursToDisable)
} {
else behaviourFilter.disableBehaviour(currentParentRef, parentBehaviourToDisable);
{ }
// it exists }
currentParentRef = nodeRef;
} try
} {
// done // not present - make it
// Used to call toFileInfo((currentParentRef, true); // If this uses the public service it will check create
// If this uses the public service this will check the final read access // permissions
FileInfo fileInfo = service.getFileInfo(currentParentRef); FileInfo createdFileInfo = service.create(currentParentRef, pathElement.getFolderName(), folderTypeQName);
currentParentRef = createdFileInfo.getNodeRef();
// Should we check the type?
return fileInfo; Map<QName, Map<QName, Serializable>> requireddAspects = pathElement.getAspects();
if (requireddAspects.size() > 0 && nodeService != null)
{
for (QName aspect : requireddAspects.keySet())
{
nodeService.addAspect(currentParentRef, aspect, requireddAspects.get(aspect));
}
}
}
finally
{
if ((behaviourFilter != null) && (parentBehavioursToDisable != null))
{
for (QName parentBehaviourToDisable : parentBehavioursToDisable)
{
behaviourFilter.enableBehaviour(currentParentRef, parentBehaviourToDisable);
}
}
}
}
else
{
// it exists
currentParentRef = nodeRef;
}
if (allFoldersRefsInThePath != null)
{
allFoldersRefsInThePath.add(currentParentRef);
}
}
// done
// Used to call toFileInfo((currentParentRef, true);
// If this uses the public service this will check the final read access
FileInfo fileInfo = service.getFileInfo(currentParentRef);
// Should we check the type?
return fileInfo;
} }
private static <T> void validate(List<T> pathElements, FileFolderService service, QName folderTypeQName) private static <T> void validate(List<T> pathElements, FileFolderService service, QName folderTypeQName)