Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/maven/fixes/9.0' into maven/rele…
Browse files Browse the repository at this point in the history
…ase/9.0
  • Loading branch information
metaventis-build committed Nov 8, 2024
2 parents e271445 + 4a56714 commit a0cd8ec
Showing 1 changed file with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package org.edu_sharing.alfresco.policy;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.alfresco.model.ContentModel;
import org.alfresco.repo.model.Repository;
import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy;
Expand All @@ -15,14 +11,18 @@
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.ResultSetRow;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
import org.apache.log4j.Logger;
import org.edu_sharing.alfresco.service.AuthorityService;
import org.edu_sharing.repository.client.tools.CCConstants;
import org.edu_sharing.repository.server.tools.cache.EduGroupCache;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

public class OnCreateNodePolicyOrgAdministrators implements OnCreateNodePolicy, OnMoveNodePolicy {

PermissionService permissionService;
Expand Down Expand Up @@ -88,15 +88,24 @@ private String getAdminGroup(ChildAssociationRef childRef) {
}

if(organisationNode != null){

Map<QName, Serializable> eduGroupProps = EduGroupCache.getByEduGroupfolder(organisationNode);
NodeRef eduGroupNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, (String)eduGroupProps.get(ContentModel.PROP_NODE_UUID));
List<ChildAssociationRef> childGroups = nodeService.getChildAssocs(eduGroupNodeRef);
for(ChildAssociationRef childGroup : childGroups){
String grouptype = (String)nodeService.getProperty(childGroup.getChildRef(), QName.createQName(CCConstants.CCM_PROP_GROUPEXTENSION_GROUPTYPE));
if(CCConstants.ADMINISTRATORS_GROUP_TYPE.equals(grouptype)){
String authorityName = (String)nodeService.getProperty(childGroup.getChildRef(), QName.createQName(CCConstants.CM_PROP_AUTHORITY_AUTHORITYNAME));
return authorityName;
NodeRef eduGroupNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, (String) eduGroupProps.get(ContentModel.PROP_NODE_UUID));
try {
String name = PermissionService.GROUP_PREFIX + AuthorityService.getGroupName(AuthorityService.ADMINISTRATORS_GROUP, (String) eduGroupProps.get(ContentModel.PROP_AUTHORITY_NAME));
String grouptype = (String)nodeService.getProperty(serviceRegistry.getAuthorityService().getAuthorityNodeRef(name), QName.createQName(CCConstants.CCM_PROP_GROUPEXTENSION_GROUPTYPE));
if(CCConstants.ADMINISTRATORS_GROUP_TYPE.equals(grouptype)) {
return name;
}
} catch (Throwable t) {
Logger.getLogger(OnCreateNodePolicyOrgAdministrators.class).warn(t);
// this is much, much slower
List<ChildAssociationRef> childGroups = nodeService.getChildAssocs(eduGroupNodeRef);
for(ChildAssociationRef childGroup : childGroups){
String grouptype = (String)nodeService.getProperty(childGroup.getChildRef(), QName.createQName(CCConstants.CCM_PROP_GROUPEXTENSION_GROUPTYPE));
if(CCConstants.ADMINISTRATORS_GROUP_TYPE.equals(grouptype)){
return (String)nodeService.getProperty(childGroup.getChildRef(), QName.createQName(CCConstants.CM_PROP_AUTHORITY_AUTHORITYNAME));
}
}
}
}
Expand Down

0 comments on commit a0cd8ec

Please sign in to comment.