org.alfresco.repo.nodelocator.NodeLocatorService Java Examples

The following examples show how to use org.alfresco.repo.nodelocator.NodeLocatorService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PolicyComponentTransactionTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception
{
    applicationContext = ApplicationContextHelper.getApplicationContext();
    // initialise policy test model
    DictionaryBootstrap bootstrap = new DictionaryBootstrap();
    List<String> bootstrapModels = new ArrayList<String>();
    bootstrapModels.add(TEST_MODEL);
    bootstrap.setModels(bootstrapModels);
    bootstrap.setDictionaryDAO((DictionaryDAO)applicationContext.getBean("dictionaryDAO"));
    bootstrap.setTenantService((TenantService)applicationContext.getBean("tenantService"));
    bootstrap.bootstrap();
    
    // retrieve policy component
    this.policyComponent = (PolicyComponent)applicationContext.getBean("policyComponent");
    this.behaviourFilter = (BehaviourFilter) applicationContext.getBean("policyBehaviourFilter");
    this.trxService = (TransactionService) applicationContext.getBean("transactionComponent");
    this.nodeService = (NodeService) applicationContext.getBean("nodeService");
    this.nodeLocatorService = (NodeLocatorService) applicationContext.getBean("nodeLocatorService");
    this.authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
    this.authenticationComponent.setSystemUserAsCurrentUser();
    
    // Register Policy
    if (sideEffectDelegate == null)
    {
     sideEffectDelegate = policyComponent.registerClassPolicy(SideEffectTestPolicy.class);
	
     // Bind Behaviour to side effect policy
     QName policyName = QName.createQName(TEST_NAMESPACE, "sideEffect");
     Behaviour baseBehaviour = new JavaBehaviour(this, "sideEffectTest", NotificationFrequency.TRANSACTION_COMMIT);
     this.policyComponent.bindClassBehaviour(policyName, BASE_TYPE, baseBehaviour);
    }

    this.companyHome = nodeLocatorService.getNode(CompanyHomeNodeLocator.NAME, null, null);
    createAndEnableBehaviours();
}
 
Example #2
Source File: ServiceDescriptorRegistry.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public NodeLocatorService getNodeLocatorService() 
{
    return (NodeLocatorService)getService(NODE_LOCATOR_SERVICE);
}
 
Example #3
Source File: ScriptUtils.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Use the Node Locator Service to find the a node reference from a number of possible locator types.
 * This method is responsible for determining the locator type and then calling the Service as the
 * Service does not know how to guess which locator to use.
 * <p>
 * This service supports 'virtual' nodes including the following:
 * <p>
 * alfresco://company/home      The Company Home root node<br>
 * alfresco://user/home         The User Home node under Company Home<br>
 * alfresco://company/shared    The Shared node under Company Home<br>
 * alfresco://sites/home        The Sites home node under Company Home<br>
 * workspace://.../...          Any standard NodeRef<br>
 * /app:company_home/cm:...     XPath QName style node reference<br>
 * 
 * @param reference     The node reference - See above for list of possible node references supported.
 * 
 * @return ScriptNode representing the node or null if not found
 */
public ScriptNode resolveNodeReference(final String reference)
{
    if (reference == null)
    {
        throw new IllegalArgumentException("Node 'reference' argument is mandatory.");
    }
    
    final NodeLocatorService locatorService = this.services.getNodeLocatorService();
    
    NodeRef nodeRef = null;
    
    switch (reference)
    {
        case "alfresco://company/home":
            nodeRef = locatorService.getNode(CompanyHomeNodeLocator.NAME, null, null);
            break;
        case "alfresco://user/home":
            nodeRef = locatorService.getNode(UserHomeNodeLocator.NAME, null, null);
            break;
        case "alfresco://company/shared":
            nodeRef = locatorService.getNode(SharedHomeNodeLocator.NAME, null, null);
            break;
        case "alfresco://sites/home":
            nodeRef = locatorService.getNode(SitesHomeNodeLocator.NAME, null, null);
            break;
        default:
            if (reference.indexOf("://") > 0)
            {
                NodeRef ref = new NodeRef(reference);
                if (this.services.getNodeService().exists(ref) && 
                    this.services.getPermissionService().hasPermission(ref, PermissionService.READ) == AccessStatus.ALLOWED)
                {
                    nodeRef = ref;
                }
            }
            else if (reference.startsWith("/"))
            {
                final Map<String, Serializable> params = new HashMap<>(1, 1.0f);
                params.put(XPathNodeLocator.QUERY_KEY, reference);
                nodeRef = locatorService.getNode(XPathNodeLocator.NAME, null, params);
            }
            break;
    }
    
    return nodeRef != null ? (ScriptNode)new ValueConverter().convertValueForScript(this.services, getScope(), null, nodeRef) : null;
}
 
Example #4
Source File: MockedTestServiceRegistry.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public NodeLocatorService getNodeLocatorService()
{
    // A mock response
    return null;
}
 
Example #5
Source File: NodeLocatorGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @param locatorService the locatorService to set
 */
public void setNodeLocatorService(NodeLocatorService locatorService)
{
    this.locatorService = locatorService;
}
 
Example #6
Source File: DemoComponent.java    From alfresco-sdk with Apache License 2.0 4 votes vote down vote up
public void setNodeLocatorService(NodeLocatorService nodeLocatorService) {
    this.nodeLocatorService = nodeLocatorService;
}
 
Example #7
Source File: DemoComponent.java    From alfresco-sdk with Apache License 2.0 4 votes vote down vote up
public void setNodeLocatorService(NodeLocatorService nodeLocatorService) {
    this.nodeLocatorService = nodeLocatorService;
}
 
Example #8
Source File: ServiceRegistry.java    From alfresco-repository with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Get the node locator service (or null if one is not provided)
 */
@NotAuditable
NodeLocatorService getNodeLocatorService();