added vre folder to group creator workspace
This commit is contained in:
parent
e08984af23
commit
eb3daa0a26
|
@ -138,11 +138,11 @@ public class GroupManager {
|
|||
groupId = createdGroup.getID();
|
||||
|
||||
User user = (User)usrManager.getAuthorizable(folderOwner);
|
||||
|
||||
createdGroup.addMember(user);
|
||||
|
||||
|
||||
createVreFolder(groupId, session, accessType!=null?accessType:AccessType.WRITE_OWNER, folderOwner);
|
||||
|
||||
|
||||
this.internalAddUserToGroup(session, createdGroup, user);
|
||||
|
||||
session.save();
|
||||
}catch(Exception e) {
|
||||
log.error("jcr error creating group {}", group, e);
|
||||
|
@ -351,14 +351,7 @@ public class GroupManager {
|
|||
if (group.isMember(user))
|
||||
throw new InvalidCallParameters("user "+userId+" is already member of group "+groupId);
|
||||
|
||||
success = group.addMember(user);
|
||||
|
||||
String folderName = group.getPrincipal().getName();
|
||||
Node folder = getVreFolderNode(session, folderName);
|
||||
|
||||
String userPath = String.format("%s%s/%s",Utils.getWorkspacePath(user.getPrincipal().getName()).toPath(),Constants.VRE_FOLDER_PARENT_NAME, folderName);
|
||||
log.debug("creating folder in user path {}", userPath );
|
||||
session.getWorkspace().clone(session.getWorkspace().getName(), folder.getPath(),userPath , false);
|
||||
this.internalAddUserToGroup(session, group, user);
|
||||
|
||||
session.save();
|
||||
}catch(StorageHubException she ){
|
||||
|
@ -375,6 +368,18 @@ public class GroupManager {
|
|||
return success;
|
||||
}
|
||||
|
||||
private boolean internalAddUserToGroup(JackrabbitSession session, Group group, User user) throws RepositoryException, StorageHubException {
|
||||
boolean success = group.addMember(user);
|
||||
|
||||
String folderName = group.getPrincipal().getName();
|
||||
Node folder = getVreFolderNode(session, folderName);
|
||||
|
||||
String userPath = String.format("%s%s/%s",Utils.getWorkspacePath(user.getPrincipal().getName()).toPath(),Constants.VRE_FOLDER_PARENT_NAME, folderName);
|
||||
log.debug("creating folder in user path {}", userPath );
|
||||
session.getWorkspace().clone(session.getWorkspace().getName(), folder.getPath(),userPath , false);
|
||||
return success;
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{groupId}/users/{userId}")
|
||||
@AuthorizationControl(allowedRoles={VREMANAGER_ROLE, INFRASTRUCTURE_MANAGER_ROLE}, exception=MyAuthException.class)
|
||||
|
@ -475,11 +480,13 @@ public class GroupManager {
|
|||
private void createVreFolder(String groupId, JackrabbitSession session, AccessType defaultAccessType, String owner ) throws Exception{
|
||||
|
||||
Node sharedRootNode = session.getNode(Constants.SHARED_FOLDER_PATH);
|
||||
|
||||
|
||||
String name = groupId;
|
||||
|
||||
String title = groupId.substring(groupId.lastIndexOf("-")+1);
|
||||
|
||||
|
||||
log.info("creating vreFolder with name {} and title {} and owner {}", name, title, owner);
|
||||
|
||||
Node folder= Utils.createFolderInternally(session, sharedRootNode, name, "VREFolder for "+groupId, false, owner, null);
|
||||
folder.setPrimaryType(PrimaryNodeType.NT_WORKSPACE_SHARED_FOLDER);
|
||||
folder.setProperty(NodeProperty.IS_VRE_FOLDER.toString(), true);
|
||||
|
@ -515,7 +522,7 @@ public class GroupManager {
|
|||
NodeIterator nodes = sharedRootNode.getNodes();
|
||||
while (nodes.hasNext()) {
|
||||
Node node = nodes.nextNode();
|
||||
if (node.getProperty(NodeProperty.TITLE.toString()).getString().equals(name)) {
|
||||
if (node.hasProperty(NodeProperty.TITLE.toString()) && node.getProperty(NodeProperty.TITLE.toString()).getString().equals(name)) {
|
||||
vreFolder= node;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue