1 17 package org.alfresco.repo.security.permissions.impl.model; 18 19 import java.util.Collections ; 20 import java.util.HashSet ; 21 import java.util.Iterator ; 22 import java.util.Set ; 23 24 import org.alfresco.repo.security.permissions.NodePermissionEntry; 25 import org.alfresco.repo.security.permissions.PermissionEntry; 26 import org.alfresco.service.cmr.repository.NodeRef; 27 import org.alfresco.service.namespace.NamespacePrefixResolver; 28 import org.dom4j.Attribute; 29 import org.dom4j.Element; 30 31 35 public class NodePermission implements NodePermissionEntry, XMLModelInitialisable 36 { 37 39 private static final String NODE_REF = "nodeRef"; 40 41 private static final String NODE_PERMISSION = "nodePermission"; 42 43 private static final String INHERIT_FROM_PARENT = "inheritFromParent"; 44 45 47 private NodeRef nodeRef; 49 50 private Set <PermissionEntry> permissionEntries = new HashSet <PermissionEntry>(); 51 52 private boolean inheritPermissionsFromParent; 53 54 public NodePermission() 55 { 56 super(); 57 } 58 59 public NodeRef getNodeRef() 60 { 61 return nodeRef; 62 } 63 64 public boolean inheritPermissions() 65 { 66 return inheritPermissionsFromParent; 67 } 68 69 public Set <PermissionEntry> getPermissionEntries() 70 { 71 return Collections.unmodifiableSet(permissionEntries); 72 } 73 74 public void initialise(Element element, NamespacePrefixResolver nspr, PermissionModel permissionModel) 75 { 76 Attribute nodeRefAttribute = element.attribute(NODE_REF); 77 if(nodeRefAttribute != null) 78 { 79 nodeRef = new NodeRef(nodeRefAttribute.getStringValue()); 80 } 81 82 Attribute inheritFromParentAttribute = element.attribute(INHERIT_FROM_PARENT); 83 if(inheritFromParentAttribute != null) 84 { 85 inheritPermissionsFromParent = Boolean.parseBoolean(inheritFromParentAttribute.getStringValue()); 86 } 87 else 88 { 89 inheritPermissionsFromParent = true; 90 } 91 92 94 for (Iterator npit = element.elementIterator(NODE_PERMISSION); npit.hasNext(); ) 95 { 96 Element permissionEntryElement = (Element) npit.next(); 97 ModelPermissionEntry permissionEntry = new ModelPermissionEntry(nodeRef); 98 permissionEntry.initialise(permissionEntryElement, nspr, permissionModel); 99 permissionEntries.add(permissionEntry); 100 } 101 102 } 103 104 105 106 } 107 | Popular Tags |