1 17 package org.alfresco.repo.configuration; 18 19 import java.util.List ; 20 21 import org.alfresco.model.ContentModel; 22 import org.alfresco.service.cmr.repository.ChildAssociationRef; 23 import org.alfresco.service.cmr.repository.NodeRef; 24 import org.alfresco.service.cmr.repository.NodeService; 25 import org.alfresco.service.namespace.RegexQNamePattern; 26 27 30 public class ConfigurableServiceImpl implements ConfigurableService 31 { 32 private NodeService nodeService; 33 34 public void setNodeService(NodeService nodeService) 35 { 36 this.nodeService = nodeService; 37 } 38 39 public boolean isConfigurable(NodeRef nodeRef) 40 { 41 return this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_CONFIGURABLE); 42 } 43 44 public void makeConfigurable(NodeRef nodeRef) 45 { 46 if (isConfigurable(nodeRef) == false) 47 { 48 this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_CONFIGURABLE, null); 50 51 this.nodeService.createNode( 53 nodeRef, 54 ContentModel.ASSOC_CONFIGURATIONS, 55 ContentModel.ASSOC_CONFIGURATIONS, 56 ContentModel.TYPE_CONFIGURATIONS); 57 } 58 } 59 60 public NodeRef getConfigurationFolder(NodeRef nodeRef) 61 { 62 NodeRef result = null; 63 if (isConfigurable(nodeRef) == true) 64 { 65 List <ChildAssociationRef> assocs = this.nodeService.getChildAssocs( 66 nodeRef, 67 RegexQNamePattern.MATCH_ALL, 68 ContentModel.ASSOC_CONFIGURATIONS); 69 if (assocs.size() != 0) 70 { 71 ChildAssociationRef assoc = assocs.get(0); 72 result = assoc.getChildRef(); 73 } 74 } 75 return result; 76 } 77 78 } 79 | Popular Tags |