Java Code Examples for org.alfresco.service.cmr.repository.StoreRef

The following examples show how to use org.alfresco.service.cmr.repository.StoreRef. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@Before
public void before() throws Exception
{
	this.nodeService = (NodeService)this.applicationContext.getBean("nodeService");
	this.serviceRegistry = (ServiceRegistry)this.applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
	this.configurableService = (ConfigurableService)this.applicationContext.getBean("configurableService");
	
	this.testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
       this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef);
       
       // Create the node used for tests
       this.nodeRef = this.nodeService.createNode(
               this.rootNodeRef,
			ContentModel.ASSOC_CHILDREN,
               ContentModel.ASSOC_CHILDREN,
               ContentModel.TYPE_CONTAINER).getChildRef();
}
 
Example 2
/**
 * Retrieve an unsorted instance of a {@link CannedQuery} based on parameters including 
 * request for a total count (up to a given max)
 *
 * @param storeRef           the store to search in, if requested
 * @param aspectQNames       qnames of aspects to search for
 * @param pagingRequest      skipCount, maxItems - optionally queryExecutionId and requestTotalCountMax
 * 
 * @return                   an implementation that will execute the query
 */
public CannedQuery<NodeRef> getCannedQuery(StoreRef storeRef, Set<QName> aspectQNames, PagingRequest pagingRequest)
{
    ParameterCheck.mandatory("aspectQNames",  aspectQNames);
    ParameterCheck.mandatory("pagingRequest", pagingRequest);
    
    int requestTotalCountMax = pagingRequest.getRequestTotalCountMax();
    
    // specific query params - context (parent) and inclusive filters (child types, property values)
    GetNodesWithAspectCannedQueryParams paramBean = new GetNodesWithAspectCannedQueryParams(storeRef, aspectQNames);

    // page details
    CannedQueryPageDetails cqpd = new CannedQueryPageDetails(pagingRequest.getSkipCount(), pagingRequest.getMaxItems(), CannedQueryPageDetails.DEFAULT_PAGE_NUMBER, CannedQueryPageDetails.DEFAULT_PAGE_COUNT);
    
    // no sort details - no sorting done
    
    // create query params holder
    CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, null, requestTotalCountMax, pagingRequest.getQueryExecutionId());
    
    // return canned query instance
    return getCannedQuery(params);
}
 
Example 3
/**
 * Called at the beginning of all tests
 */
@Before
protected void before() throws Exception
{
    this.checkOutCheckInService = (CheckOutCheckInService) this.applicationContext.getBean("checkOutCheckInService");
    this.nodeService = (NodeService)this.applicationContext.getBean("nodeService");
    this.ruleService = (RuleService)this.applicationContext.getBean("ruleService");
    this.actionService = (ActionService)this.applicationContext.getBean("actionService");
    transactionHelper = (RetryingTransactionHelper)applicationContext.getBean("retryingTransactionHelper");
    fileFolderService = applicationContext.getBean("fileFolderService", FileFolderService.class);
    contentService = applicationContext.getBean("contentService", ContentService.class);
    
    AuthenticationComponent authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
    authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
    
    // Create the store and get the root node
    this.testStoreRef = this.nodeService.createStore(
            StoreRef.PROTOCOL_WORKSPACE, "Test_"
                    + System.currentTimeMillis());
    this.rootNodeRef = this.nodeService.getRootNode(this.testStoreRef);

    // Get the executer instance 
    this.executer = (ExecuteAllRulesActionExecuter)this.applicationContext.getBean(ExecuteAllRulesActionExecuter.NAME);
}
 
Example 4
/**
 * @see org.alfresco.service.cmr.tagging.TaggingService#deleteTag(org.alfresco.service.cmr.repository.StoreRef, java.lang.String)
 */
public void deleteTag(StoreRef storeRef, String tag)
{
    // Lower the case of the tag
    tag = tag.toLowerCase();
    
    // Find nodes which are tagged with the 'soon to be deleted' tag.
    List<NodeRef> taggedNodes = this.findTaggedNodes(storeRef, tag);
    
    // Clear the tag from the found nodes
    for (NodeRef taggedNode : taggedNodes)
    {
        this.removeTag(taggedNode, tag);
    }
    
    NodeRef tagNodeRef = getTagNodeRef(storeRef, tag);
    if (tagNodeRef != null)
    {
        this.categoryService.deleteCategory(tagNodeRef);
    }
}
 
Example 5
/**
 * Gets the node reference for a given tag.
 * <p>
 * Returns null if tag is not present and not created.
 * 
 * @param storeRef      store reference
 * @param tag           tag
 * @param create        create a node if one doesn't exist?
 * @return NodeRef      tag node reference or null not exist
 */
private NodeRef getTagNodeRef(StoreRef storeRef, String tag, boolean create)
{
    for (String forbiddenSequence : FORBIDDEN_TAGS_SEQUENCES)
    {
        if (create && tag.contains(forbiddenSequence))
        {
            throw new IllegalArgumentException("Tag name must not contain " + StringEscapeUtils.escapeJava(forbiddenSequence) + " char sequence");
        }
    }
    
    NodeRef tagNodeRef = null;
    Collection<ChildAssociationRef> results = this.categoryService.getRootCategories(storeRef, ContentModel.ASPECT_TAGGABLE, tag, create);
    if (!results.isEmpty())
    {
        tagNodeRef = results.iterator().next().getChildRef();
    }
    return tagNodeRef;
}
 
Example 6
@Test
public void coreNamesAreTrimmed_oneCoreNameAtTime() {
    AlfrescoCoreAdminHandler spy = spy(new AlfrescoCoreAdminHandler() {
        @Override
        protected NamedList<Object> newCore(String coreName, int numShards, StoreRef storeRef, String templateName, int replicationFactor, int nodeInstance, int numNodes, String shardIds, Properties extraProperties)
        {
            // Do nothing here otherwise we cannot spy it
            return new SimpleOrderedMap<>();
        }
    });

    // First let's try a list of names, one by one
    final List<String> coreNames =
            asList(
                    ARCHIVE_CORE_NAME + "  ", // whitespace char at the end
                    "\t " + ALFRESCO_CORE_NAME, // whitespace chars at the beginning
                    "   " + VERSION_CORE_NAME + "  \t", // beginning and end
                    "   \t"); // empty name

    coreNames.forEach(spy::setupNewDefaultCores);

    verify(spy).newCore(eq(ARCHIVE_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ARCHIVE_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null));
    verify(spy).newCore(eq(ALFRESCO_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(ALFRESCO_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null));
    verify(spy).newCore(eq(VERSION_CORE_NAME), eq(1), eq(STORE_REF_MAP.get(VERSION_CORE_NAME)), anyString(), eq(1), eq(1), eq(1), eq(null), eq(null));
}
 
Example 7
/**
 * Get the locks given a store and query string.
 * 
 * @param storeRef      the store reference
 * @param query         the query string
 * @return              the locked nodes
 * @deprecated Uses search and does not report on ephemeral locks.
 */
@Deprecated
private List<NodeRef> getLocks(StoreRef storeRef, String query)
{
    List<NodeRef> result = new ArrayList<NodeRef>();
    ResultSet resultSet = null;
    try
    {
        resultSet = this.searchService.query(
                storeRef,
                SearchService.LANGUAGE_LUCENE, 
                query);
        result = resultSet.getNodeRefs();
    }
    finally
    {
        if (resultSet != null)
        {
            resultSet.close();
        }
    }
    return result;
}
 
Example 8
public void testGetNodesSimple()
{
    long startTime = 0L;

    List<Transaction> txns = getTransactions(null, startTime, null, null, 500);

    List<Long> txnIds = toTxnIds(txns);

    NodeParameters nodeParameters = new NodeParameters();
    nodeParameters.setTransactionIds(txnIds);
    nodeParameters.setStoreProtocol(StoreRef.PROTOCOL_WORKSPACE);
    nodeParameters.setStoreIdentifier(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE.getIdentifier());
    
    List<Node> nodes = getNodes(nodeParameters);
    assertTrue("Expect 'some' nodes associated with txns", nodes.size() > 0);
}
 
Example 9
@Before
public void before() throws Exception
{
    this.nodeService = (NodeService)this.applicationContext.getBean("nodeService");
    this.namespaceService = (NamespaceService)this.applicationContext.getBean("namespaceService");
    this.personService = (PersonService)this.applicationContext.getBean("personService");
    
    AuthenticationComponent authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
    authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
    
    // Create the store and get the root node
    rootNodeRef = nodeService.getRootNode(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"));
    this.nodeRef = this.nodeService.createNode(
            this.rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName("{test}testnode"),
            ContentModel.TYPE_CONTENT).getChildRef();
    
    // Get the executer instance 
    this.executer = (StartWorkflowActionExecuter)this.applicationContext.getBean(StartWorkflowActionExecuter.NAME);
}
 
Example 10
/**
 * Round-trip of export then import will result in the imported content having the same categories
 * assigned to it as for the exported content -- provided the source and destination stores are the same.
 */
@SuppressWarnings("unchecked")
@Category(RedundantTests.class)
@Test
public void testRoundTripKeepsCategoriesWhenWithinSameStore() throws Exception
{   
    // Use a store ref that has the bootstrapped categories
    StoreRef storeRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
    NodeRef rootNode = nodeService.getRootNode(storeRef);
    
    ChildAssociationRef contentChildAssocRef = createContentWithCategories(storeRef, rootNode);
    
    // Export/import
    File acpFile = exportContent(contentChildAssocRef.getParentRef());
    FileInfo importFolderFileInfo = importContent(acpFile, rootNode);
    
    // Check categories
    NodeRef importedFileNode = fileFolderService.searchSimple(importFolderFileInfo.getNodeRef(), "test.txt");
    assertNotNull("Couldn't find imported file: test.txt", importedFileNode);
    assertTrue(nodeService.hasAspect(importedFileNode, ContentModel.ASPECT_GEN_CLASSIFIABLE));
    List<NodeRef> importedFileCategories = (List<NodeRef>)
        nodeService.getProperty(importedFileNode, ContentModel.PROP_CATEGORIES);
    assertCategoriesEqual(importedFileCategories,
                "Regions",
                "Software Document Classification");
}
 
Example 11
/**
 * Test for <a href="https://issues.alfresco.com/jira/browse/MNT-16748">MNT-16748</a> <br>
 * Use {@link SearchService#query(StoreRef, String, String)} to perform a query.
 */
public void testAuditSearchServiceQuery() throws Exception
{
    // Run as admin
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();

    // Perform a search
    @SuppressWarnings("unused")
    ResultSet rs = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<ResultSet>()
    {
        @Override
        public ResultSet execute() throws Throwable
        {
            return searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_XPATH, "/app:company_home");
        }

    }, true, false);

    // Check the audit entries
    checkAuditEntries(APPLICATION_NAME_MNT_16748, SearchService.LANGUAGE_XPATH, "/app:company_home", 1);
}
 
Example 12
@SuppressWarnings("deprecation")
@Override
public void setUp() throws Exception
{
    auditModelRegistry = (AuditModelRegistryImpl) ctx.getBean("auditModel.modelRegistry");
    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    auditComponent = (AuditComponent) ctx.getBean("auditComponent");
    auditService = serviceRegistry.getAuditService();
    transactionService = serviceRegistry.getTransactionService();
    transactionServiceImpl = (TransactionServiceImpl) ctx.getBean("transactionService");
    nodeService = serviceRegistry.getNodeService();
    searchService = serviceRegistry.getSearchService();

    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
    nodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);

    // Register the models
    URL modelUrlMnt11072 = ResourceUtils.getURL("classpath:alfresco/testaudit/alfresco-audit-test-mnt-11072.xml");
    URL modelUrlMnt16748 = ResourceUtils.getURL("classpath:alfresco/testaudit/alfresco-audit-test-mnt-16748.xml");
    auditModelRegistry.registerModel(modelUrlMnt11072);
    auditModelRegistry.registerModel(modelUrlMnt16748);
    auditModelRegistry.loadAuditModels();
}
 
Example 13
@Override
public CollectionWithPagingInfo<Node> listDeleted(Parameters parameters)
{
    PagingRequest pagingRequest = Util.getPagingRequest(parameters.getPaging());
    NodeRef archiveStoreRootNodeRef = nodeService.getStoreArchiveNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);

    // Create canned query
    ArchivedNodesCannedQueryBuilder queryBuilder = new ArchivedNodesCannedQueryBuilder.Builder(
            archiveStoreRootNodeRef, pagingRequest).sortOrderAscending(false).build();

    // Query the DB
    PagingResults<NodeRef> result = nodeArchiveService.listArchivedNodes(queryBuilder);

    Integer totalItems = result.getTotalResultCount().getFirst();

    List<Node> nodesFound = new ArrayList<Node>(result.getPage().size());
    Map mapUserInfo = new HashMap<>();
    for (NodeRef nRef:result.getPage())
    {
        Node foundNode = nodes.getFolderOrDocument(nRef, null, null, parameters.getInclude(), mapUserInfo);
        mapArchiveInfo(foundNode,mapUserInfo);
        nodesFound.add(foundNode);
    }

    return CollectionWithPagingInfo.asPaged(parameters.getPaging(), nodesFound, result.hasMoreItems(), (totalItems == null ? null : totalItems.intValue()));
}
 
Example 14
public void testBasicDenyStore() throws Exception
{
    runAs("andy");

    Object o = new ClassWithMethods();
    Method method = o.getClass().getMethod("echoStoreRef", new Class[] { StoreRef.class });

    AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();

    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("AFTER_ACL_NODE.sys:base.Read")));
    proxyFactory.setTargetSource(new SingletonTargetSource(o));
    Object proxy = proxyFactory.getProxy();

    try
    {
        Object answer = method.invoke(proxy, new Object[] { rootNodeRef.getStoreRef() });
        assertNotNull(answer);
    }
    catch (InvocationTargetException e)
    {

    }
}
 
Example 15
private <Q, S, E extends Throwable> String getValueAsString(LuceneQueryParserAdaptor<Q, S, E> lqpa, Serializable value)
{
	String nodeRefStr = null;
    if(!NodeRef.isNodeRef((String)value))
    {
        // assume the object id is the node guid
        StoreRef storeRef = getStore(lqpa);
    	nodeRefStr = storeRef.toString() + "/" + (String)value;
    }
    else
    {
    	nodeRefStr = (String)value;
    }

    Object converted = DefaultTypeConverter.INSTANCE.convert(dictionaryService.getDataType(DataTypeDefinition.NODE_REF), nodeRefStr);
    String asString = DefaultTypeConverter.INSTANCE.convert(String.class, converted);
    return asString;
}
 
Example 16
private void createNothingToDoScript(String scriptName)
{
    NodeRef storeRootNodeRef = nodeService.getRootNode(new StoreRef("workspace://SpacesStore"));
    NodeRef scriptFolderRef = searchService.selectNodes(storeRootNodeRef, "/app:company_home/app:dictionary/app:scripts", null, namespaceService, false).get(0);
    
    try
    {
        FileInfo fileInfo = fileFolderService.create(scriptFolderRef, scriptName, ContentModel.TYPE_CONTENT);

        ContentWriter writer = fileFolderService.getWriter(fileInfo.getNodeRef());
        assertNotNull("Writer is null", writer);
        // write some content
        String content = "function main(){}\nmain();";
        writer.putContent(content);
    }
    catch (FileExistsException exc)
    {
        // file was created before
    }
}
 
Example 17
@SuppressWarnings("unchecked")
private LuceneIndexer getThreadLocalIndexer(StoreRef storeRef)
{
    Map<StoreRef, LuceneIndexer> indexers = (Map<StoreRef, LuceneIndexer>) AlfrescoTransactionSupport.getResource(indexersKey);
    if (indexers == null)
    {
        indexers = new HashMap<StoreRef, LuceneIndexer>();
        AlfrescoTransactionSupport.bindResource(indexersKey, indexers);
    }
    LuceneIndexer indexer = indexers.get(storeRef);
    if (indexer == null)
    {
        indexer = createIndexer(storeRef, GUID.generate());
        indexers.put(storeRef, indexer);
    }
    return indexer;
}
 
Example 18
private NodeRef getSummaryReportsParentFolder(String transferSummaryReportLocation)
{
    NodeRef reportParentFolder = null;
    log.debug("Trying to find transfer summary report records folder: " + transferSummaryReportLocation);
    List<NodeRef> refs = searchService.selectNodes(nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE),
            transferSummaryReportLocation, null, namespaceService, false);
    if (refs.size() > 0)
    {
        reportParentFolder = refs.get(0);

        log.debug("Found transfer summary report records folder: " + reportParentFolder);
    }
    return reportParentFolder;
}
 
Example 19
private StoreRef getStore(LuceneQueryBuilderContext<Q, S, E> luceneContext)
{
	ArrayList<StoreRef> stores = luceneContext.getLuceneQueryParserAdaptor().getSearchParameters().getStores();
	if(stores.size() < 1)
	{
		// default
		return StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
	}
	return stores.get(0);
}
 
Example 20
public ResourceBundle getRepoResourceBundle(
        final StoreRef storeRef,
        final String path,
        final Locale locale) throws IOException
{   
    // TODO - need to replace basic strategy with a more complete
    // search & instantiation strategy similar to ResourceBundle.getBundle()
    // Consider search query with basename* and then apply strategy ...
    
    // Avoid permission exceptions
    RunAsWork<ResourceBundle> getBundleWork = new RunAsWork<ResourceBundle>()
    {
        @Override
        public ResourceBundle doWork() throws Exception
        {
            NodeRef rootNode = nodeService.getRootNode(storeRef);

            // first attempt - with locale        
            NodeRef nodeRef = getNode(rootNode, path+"_"+locale+PROPERTIES_FILE_SUFFIX);
            
            if (nodeRef == null)
            {
                // second attempt - basename 
                nodeRef = getNode(rootNode, path+PROPERTIES_FILE_SUFFIX);
            }
            
            if (nodeRef == null)
            {
                logger.debug("Could not find message resource bundle " + storeRef + "/" + path);
                return null;
            }
            
            ContentReader cr = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT);
            ResourceBundle resBundle = new MessagePropertyResourceBundle(
                    new InputStreamReader(cr.getContentInputStream(), cr.getEncoding()));
            return resBundle;
        }
    };
    return AuthenticationUtil.runAs(getBundleWork, AuthenticationUtil.getSystemUserName());
}
 
Example 21
@Before
public void setup() throws SystemException, NotSupportedException
{
    try
    {
        nodeService = (NodeService)ctx.getBean("nodeService");
        fileFolderService = (FileFolderService)ctx.getBean("fileFolderService");
        transactionService = (TransactionService)ctx.getBean("transactionService");
        bulkImporter = (MultiThreadedBulkFilesystemImporter)ctx.getBean("bulkFilesystemImporter");
        contentService = (ContentService)ctx.getBean("contentService");
        actionService = (ActionService)ctx.getBean("actionService");
        ruleService = (RuleService)ctx.getBean("ruleService");
        versionService = (VersionService)ctx.getBean("versionService");

        AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

        String s = "BulkFilesystemImport" + System.currentTimeMillis();

        txn = transactionService.getUserTransaction();
        txn.begin();

        AuthenticationUtil.pushAuthentication();
        AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

        StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, s);
        rootNodeRef = nodeService.getRootNode(storeRef);
        top = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}top"), ContentModel.TYPE_FOLDER).getChildRef();
        
        topLevelFolder = fileFolderService.create(top, s, ContentModel.TYPE_FOLDER);

        txn.commit();
    }
    catch(Throwable e)
    {
        fail(e.getMessage());
    }
}
 
Example 22
@Test
public void testBootstrap()
{
    StoreRef bootstrapStoreRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
    importerBootstrap.setStoreUrl(bootstrapStoreRef.toString());
    importerBootstrap.bootstrap();
    authenticationComponent.setSystemUserAsCurrentUser();
    System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, bootstrapStoreRef));
}
 
Example 23
@Override
public List<NodeRef.Status> getTxnChangesForStore(StoreRef storeRef, Long txnId)
{
    Long storeId = (storeRef == null) ? null : getStoreNotNull(storeRef).getId();
    List<NodeEntity> nodes = selectTxnChanges(txnId, storeId);
    // Convert
    List<NodeRef.Status> nodeStatuses = new ArrayList<NodeRef.Status>(nodes.size());
    for (NodeEntity node : nodes)
    {
        nodeStatuses.add(node.getNodeStatus(qnameDAO));
    }
    
    // Done
    return nodeStatuses;
}
 
Example 24
@Override
protected void setUp() throws Exception
{
    super.setUp();

    query = new VirtualQueryImpl(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE.toString(),
                                 SearchService.LANGUAGE_FTS_ALFRESCO,
                                 QUERY_TEST_STRING_QUERY);

    mockitoActualEnvironment = Mockito.mock(ActualEnvironment.class);
    Mockito.when(mockitoActualEnvironment.query(Mockito.any(SearchParameters.class)))
                    .thenReturn(new EmptyResultSet());

    mockitoPrefixResolver = Mockito.mock(NamespacePrefixResolver.class);
    Mockito.when(mockitoPrefixResolver.getNamespaceURI(TST_PREFIX)).thenReturn(TEST_URI);
    Mockito.when(mockitoPrefixResolver.getPrefixes(TEST_URI)).thenReturn(Arrays.asList(TST_PREFIX));

    Mockito.when(mockitoActualEnvironment.getNamespacePrefixResolver()).thenReturn(mockitoPrefixResolver);

    testQName1 = QName.createQName(TST_PREFIX,
                                   TEST_LOCAL_NAME_1,
                                   mockitoPrefixResolver);

    testQName2 = QName.createQName(TST_PREFIX,
                                   TEST_LOCAL_NAME_2,
                                   mockitoPrefixResolver);

    NodeRef n1 = new NodeRef("workspace://SpacesStore/17c8f11d-0936-4295-88a0-12b85764c76f");
    NodeRef n2 = new NodeRef("workspace://SpacesStore/27c8f11d-0936-4295-88a0-12b85764c76f");
    nodeOneReference = ((VirtualProtocol) Protocols.VIRTUAL.protocol).newReference(n1,
                                                                                   "/1",
                                                                                   n2);
}
 
Example 25
/**
 * {@inheritDoc}
 */
@Override
protected void setUp() throws Exception
{
    ApplicationContext appContext = ApplicationContextHelper.getApplicationContext();
    this.repo = (RepositoryService) appContext.getBean("activitiRepositoryService");
    this.runtime = (RuntimeService) appContext.getBean("activitiRuntimeService");
    
    ServiceRegistry serviceRegistry = (ServiceRegistry) appContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
    authenticationComponent = (AuthenticationComponent) appContext.getBean("authenticationComponent");
    TransactionService transactionService = serviceRegistry.getTransactionService();
    nodeService = serviceRegistry.getNodeService();
    txnHelper = transactionService.getRetryingTransactionHelper();

    // authenticate
    authenticationComponent.setSystemUserAsCurrentUser();
    
    StoreRef storeRef = nodeService.createStore(
            StoreRef.PROTOCOL_WORKSPACE,
            "test-" + getName() + "-" + System.currentTimeMillis());
    NodeRef rootNodeRef = nodeService.getRootNode(storeRef);
    // Create a node to work on
    workingNodeRef = nodeService.createNode(
            rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, getName()),
            ContentModel.TYPE_CMOBJECT).getChildRef();

    String resource = "activiti/testTransaction.bpmn20.xml";
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    InputStream input= classLoader.getResourceAsStream(resource);
    this.deployment = repo.createDeployment()
    .addInputStream(resource, input)
    .deploy();
}
 
Example 26
/**
 * returns the nodeRef from  web script request
 * @param req
 * @return
 */
protected NodeRef parseRequestForNodeRef(WebScriptRequest req)
{
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    String storeType = templateVars.get("store_type");
    String storeId = templateVars.get("store_id");
    String nodeId = templateVars.get("id");

    // create the NodeRef and ensure it is valid
    StoreRef storeRef = new StoreRef(storeType, storeId);
    return new NodeRef(storeRef, nodeId);
}
 
Example 27
@Override
@Extend(traitAPI = PermissionServiceTrait.class, extensionAPI = PermissionServiceExtension.class)
public void clearPermission(StoreRef storeRef, String authority)
{
    permissionsDaoComponent.deletePermissions(storeRef, authority);
    accessCache.clear();
}
 
Example 28
/**
 * Set the default store reference
 * 
 * @param   storeRef the default store reference
 */
public void setStoreUrl(String storeRef)
{
    // ensure this is not set again by a script instance!
    if (this.storeRef != null)
    {
        throw new IllegalStateException("Default store URL can only be set once.");
    }
    this.storeRef = new StoreRef(storeRef);
}
 
Example 29
@Test public void testRootAspect() throws Exception
{
    final NodeRef workspaceRootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    final NodeRef[] nodes = new NodeRef[6];
    buildNodeHierarchy(workspaceRootNodeRef, nodes);

    Set<NodeRef> allRootNodes = nodeService.getAllRootNodes(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    int initialNumRootNodes = allRootNodes.size();

    nodeService.addAspect(nodes[1], ContentModel.ASPECT_ROOT, null);
    nodeService.addAspect(nodes[3], ContentModel.ASPECT_ROOT, null);
    nodeService.addAspect(nodes[4], ContentModel.ASPECT_ROOT, null);

    allRootNodes = nodeService.getAllRootNodes(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    assertEquals("", 3, allRootNodes.size() - initialNumRootNodes);
    List<Path> paths = nodeService.getPaths(nodes[5], false);
    assertEquals("", 4, paths.size());

    nodeService.removeAspect(nodes[3], ContentModel.ASPECT_ROOT);
    allRootNodes = nodeService.getAllRootNodes(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    assertEquals("", 2, allRootNodes.size() - initialNumRootNodes);
    paths = nodeService.getPaths(nodes[5], false);
    for(Path path : paths)
    {
        System.out.println("Path = " + path.toString());
    }
    assertEquals("", 3, paths.size());
}
 
Example 30
@Override
public Pair<Long, NodeRef> getRootNode(StoreRef storeRef)
{
    Pair<StoreRef, Node> rootNodePair = rootNodesCache.getByKey(storeRef);
    if (rootNodePair == null)
    {
        throw new InvalidStoreRefException(storeRef);
    }
    else
    {
        return rootNodePair.getSecond().getNodePair();
    }
}