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

The following examples show how to use org.alfresco.service.cmr.repository.StoreRef#STORE_REF_WORKSPACE_SPACESSTORE . 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: DeletedNodesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Node getDeletedNode(String originalId, Parameters parameters, boolean fullnode, Map<String, UserInfo> mapUserInfo)
{
    //First check the node is valid and has been archived.
    NodeRef validatedNodeRef = nodes.validateNode(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, originalId);

    //Now get the Node
    NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, validatedNodeRef.getId());
    NodeRef archivedNodeRef = nodeArchiveService.getArchivedNode(nodeRef);

    Node foundNode = null;
    if (fullnode)
    {
        foundNode = nodes.getFolderOrDocumentFullInfo(archivedNodeRef, null, null, parameters, mapUserInfo);
    }
    else
    {
        foundNode = nodes.getFolderOrDocument(archivedNodeRef, null, null, parameters.getInclude(), mapUserInfo);
    }

    if (foundNode != null) mapArchiveInfo(foundNode,null);
    return foundNode;
}
 
Example 2
Source File: ExporterComponentTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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 3
Source File: ExporterComponentTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * If the source and destination stores are not the same, then a round-trip of export then import
 * will result in the imported content not having the categories assigned to it that were present
 * on the exported content.
 */
@SuppressWarnings("unchecked")
@Category(RedundantTests.class)
@Test
public void testRoundTripLosesCategoriesImportingToDifferentStore() 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
    File acpFile = exportContent(contentChildAssocRef.getParentRef());
    // Import - destination store is different from export store.
    NodeRef destRootNode = nodeService.getRootNode(this.storeRef);
    FileInfo importFolderFileInfo = importContent(acpFile, destRootNode);
    
    // 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);
    assertEquals("No categories should have been imported for the content", 0, importedFileCategories.size());
}
 
Example 4
Source File: StoreMapper.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Work out which StoreRef this store belongs to.
 * @param String representing a store
 * @return StoreRef
 */
public StoreRef getStoreRef(String store)
{
    if (store != null && !store.isEmpty())
    {
        switch (store.toLowerCase())
        {
            case LIVE_NODES:
                return StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
            case VERSIONS:
                return STORE_REF_VERSION2_SPACESSTORE;
            case DELETED:
                return StoreRef.STORE_REF_ARCHIVE_SPACESSTORE;
            case HISTORY:
                return STORE_REF_HISTORY;
        }
    }
    throw new InvalidArgumentException(InvalidArgumentException.DEFAULT_MESSAGE_ID,
                new Object[] { ": scope allowed values: nodes,deleted-nodes,versions" });
}
 
Example 5
Source File: LuceneChild.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 6
Source File: Jackson2NodeRefDeserializer.java    From alfresco-mvc with Apache License 2.0 5 votes vote down vote up
@Override
public NodeRef deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {

	String id = jp.getText();
	if (NodeRef.isNodeRef(id)) {
		return new NodeRef(id);
	}
	return new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, id);
}
 
Example 7
Source File: NodeRenditionsRelation.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@WebApiDescription(title = "Create rendition", successStatus = Status.STATUS_ACCEPTED)
@Override
public List<Rendition> create(String nodeId, List<Rendition> entity, Parameters parameters)
{
    NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeId);
    renditions.createRenditions(nodeRef, entity, parameters);
    return null;
}
 
Example 8
Source File: DeletedNodesImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Node restoreArchivedNode(String archivedId, NodeTargetAssoc nodeTargetAssoc)
{
    //First check the node is valid and has been archived.
    NodeRef validatedNodeRef = nodes.validateNode(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE, archivedId);

    RestoreNodeReport restored = null;

    if (nodeTargetAssoc != null)
    {
        NodeRef targetNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeTargetAssoc.getTargetParentId());
        QName assocType = nodes.getAssocType(nodeTargetAssoc.getAssocType());
        restored = nodeArchiveService.restoreArchivedNode(validatedNodeRef, targetNodeRef, assocType, null);
    }
    else
    {
        restored = nodeArchiveService.restoreArchivedNode(validatedNodeRef);
    }

    switch (restored.getStatus())
    {
    case SUCCESS:
        return nodes.getFolderOrDocumentFullInfo(restored.getRestoredNodeRef(), null, null, null, null);
    case FAILURE_PERMISSION:
        throw new PermissionDeniedException();
    case FAILURE_INTEGRITY:
        throw new IntegrityException("Restore failed due to an integrity error", null);
    case FAILURE_DUPLICATE_CHILD_NODE_NAME:
        throw new ConstraintViolatedException("Name already exists in target");
    case FAILURE_INVALID_ARCHIVE_NODE:
        throw new EntityNotFoundException(archivedId);
    case FAILURE_INVALID_PARENT:
        throw new NotFoundException("Invalid parent id "+restored.getTargetParentNodeRef());
    default:
        throw new ApiException("Unable to restore node "+archivedId);
    }
}
 
Example 9
Source File: QueriesNodesApiTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
private NodeRef getNodeRef(String id)
{
    AuthenticationUtil.setFullyAuthenticatedUser(user1);
    // The following call to new NodeRef(...) returns a NodeRef like:
    //    workspace://SpacesStore/9db76769-96de-4de4-bdb4-a127130af362
    // We call tenantService.getName(nodeRef) to get a fully qualified NodeRef as Solr returns this.
    // They look like:
    //    workspace://@org.alfresco.rest.api.tests.queriespeopleapitest@SpacesStore/9db76769-96de-4de4-bdb4-a127130af362
    NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, id);
    nodeRef = tenantService.getName(nodeRef);
    return nodeRef;
}
 
Example 10
Source File: ObjectIdLuceneBuilder.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
private <Q, S, E extends Throwable> StoreRef getStore(LuceneQueryParserAdaptor<Q, S, E> lqpa)
{
	ArrayList<StoreRef> stores = lqpa.getSearchParameters().getStores();
	if(stores.size() < 1)
	{
		// default
		return StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
	}
	return stores.get(0);
}
 
Example 11
Source File: ParentLuceneBuilder.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
private <Q, S, E extends Throwable> StoreRef getStore(LuceneQueryParserAdaptor<Q, S, E> lqpa)
{
	ArrayList<StoreRef> stores = lqpa.getSearchParameters().getStores();
	if(stores.size() < 1)
	{
		// default
		return StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
	}
	return stores.get(0);
}
 
Example 12
Source File: LuceneDescendant.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 13
Source File: NodeVersionRenditionsRelation.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public CollectionWithPagingInfo<Rendition> readAll(String nodeId, Parameters parameters)
{
    String versionId = parameters.getRelationshipId();

    NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeId);
    return renditions.getRenditions(nodeRef, versionId, parameters);
}
 
Example 14
Source File: EmailHelperTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Before
public void setup() throws Exception
{
    this.dummyTemplateNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate());
    // Mock the required services
    this.serviceRegistryMock = mock(ServiceRegistry.class);
    this.nodeServiceMock = mock(NodeService.class);
    this.searchServiceMock = mock(SearchService.class);
    this.namespaceServiceMock = mock(NamespaceService.class);
    this.fileFolderServiceMock = mock(FileFolderService.class);
    this.personServiceMock = mock(PersonService.class);
    this.preferenceServiceMock = mock(PreferenceService.class);
    this.repositoryHelperMock = mock(Repository.class);
    this.templateLoaderMock = mock(TemplateLoader.class);

    when(serviceRegistryMock.getNodeService()).thenReturn(nodeServiceMock);
    when(serviceRegistryMock.getSearchService()).thenReturn(searchServiceMock);
    when(serviceRegistryMock.getNamespaceService()).thenReturn(namespaceServiceMock);
    when(serviceRegistryMock.getFileFolderService()).thenReturn(fileFolderServiceMock);
    when(serviceRegistryMock.getPersonService()).thenReturn(personServiceMock);
    when(serviceRegistryMock.getContentService()).thenReturn(mock(ContentService.class));
    when(repositoryHelperMock.getRootHome()).thenReturn(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, GUID.generate()));
    when(fileFolderServiceMock.getLocalizedSibling(dummyTemplateNodeRef)).thenReturn(dummyTemplateNodeRef);

    this.emailHelper = new EmailHelper();
    emailHelper.setServiceRegistry(serviceRegistryMock);
    emailHelper.setPreferenceService(preferenceServiceMock);
    emailHelper.setRepositoryHelper(repositoryHelperMock);
    emailHelper.setCompanyHomeChildName("app:company_home");
    //test init
    emailHelper.init();
    // Note: set the template loader after the init method
    emailHelper.setTemplateLoader(templateLoaderMock);
}
 
Example 15
Source File: NodeVersionRenditionsRelation.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@WebApiDescription(title = "Create rendition", successStatus = Status.STATUS_ACCEPTED)
@Override
public List<Rendition> create(String nodeId, List<Rendition> entity, Parameters parameters)
{
    String versionId = parameters.getRelationshipId();

    NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeId);
    renditions.createRenditions(nodeRef, versionId, entity, parameters);
    return null;
}
 
Example 16
Source File: RepoTransferReceiverImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @return
 */
private TransferManifestNormalNode createContentNode(/*String transferId*/) throws Exception
{
    TransferManifestNormalNode node = new TransferManifestNormalNode();
    String uuid = GUID.generate();
    NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, uuid);
    node.setNodeRef(nodeRef);
    node.setUuid(uuid);
    byte[] dummyContent = "This is some dummy content.".getBytes("UTF-8");

    node.setType(ContentModel.TYPE_CONTENT);
    
    /**
     * Get guest home
     */
    NodeRef parentFolder = guestHome;

    String nodeName = uuid + ".testnode" + getNameSuffix();

    List<ChildAssociationRef> parents = new ArrayList<ChildAssociationRef>();
    ChildAssociationRef primaryAssoc = new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, parentFolder, QName
            .createQName(NamespaceService.CONTENT_MODEL_1_0_URI, nodeName), node.getNodeRef(), true, -1);
    parents.add(primaryAssoc);
    node.setParentAssocs(parents);
    node.setParentPath(nodeService.getPath(parentFolder));
    node.setPrimaryParentAssoc(primaryAssoc);

    Map<QName, Serializable> props = new HashMap<QName, Serializable>();
    props.put(ContentModel.PROP_NODE_UUID, uuid);
    props.put(ContentModel.PROP_NAME, nodeName);
    ContentData contentData = new ContentData("/" + uuid, "text/plain", dummyContent.length, "UTF-8");
    props.put(ContentModel.PROP_CONTENT, contentData);
    node.setProperties(props);

    return node;
}
 
Example 17
Source File: ZeroReferenceParser.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Creates a {@link RepositoryNodeRef} reference from the default
 * {@link StoreRef}, SpacesStore and from the node id given by the cursor's
 * current token.
 * 
 * @param cursor
 * @return A {@link RepositoryNodeRef} reference.
 */
private RepositoryNodeRef parseRepositoryNode(Cursor cursor)
{
    String id = cursor.tokens[cursor.i];
    cursor.i++;

    return new RepositoryNodeRef(new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
                                             id));
}
 
Example 18
Source File: CheckOutCheckInServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Test
public void testDeleteAndRestore()
{
    authenticationComponent.setSystemUserAsCurrentUser();

    StoreRef spacesStoreRef = StoreRef.STORE_REF_WORKSPACE_SPACESSTORE;
    NodeRef spacesRootNodeRef = nodeService.getRootNode(spacesStoreRef);
    NodeRef archiveRootNodeRef = nodeService.getStoreArchiveNode(spacesStoreRef);

    permissionService.setPermission(spacesRootNodeRef, userName, PermissionService.ALL_PERMISSIONS, true);

    authenticationComponent.setCurrentUser(userName);

    // create folder and some content within the the folder
    NodeRef folderRef = createFolder(spacesRootNodeRef, "testDeleteAndRestore-folder-"+System.currentTimeMillis());
    NodeRef contentRef = createContent("testDeleteAndRestore-content", folderRef);
    
    String initialText = "initial text";
    ContentWriter contentWriter = contentService.getWriter(contentRef, ContentModel.PROP_CONTENT, true);
    contentWriter.setMimetype("text/plain");
    contentWriter.setEncoding("UTF-8");
    contentWriter.putContent(initialText);

    assertFalse(nodeService.hasAspect(contentRef, ContentModel.ASPECT_CHECKED_OUT));

    // checkout content node
    NodeRef workingCopyRef = cociService.checkout(contentRef, folderRef, ContentModel.ASSOC_CHILDREN, QName.createQName("workingCopy"));

    assertNotNull(workingCopyRef);
    assertTrue(nodeService.hasAspect(workingCopyRef, ContentModel.ASPECT_WORKING_COPY));
    assertTrue(nodeService.hasAspect(workingCopyRef, ContentModel.ASPECT_COPIEDFROM));
    assertTrue(nodeService.hasAspect(contentRef, ContentModel.ASPECT_CHECKED_OUT));

    String updatedText = "updated text";
    contentWriter = contentService.getWriter(workingCopyRef, ContentModel.PROP_CONTENT, true);
    contentWriter.setMimetype("text/plain");
    contentWriter.setEncoding("UTF-8");
    contentWriter.putContent(updatedText);

    assertTrue(nodeService.exists(folderRef));
    assertTrue(nodeService.exists(contentRef));
    assertTrue(nodeService.exists(workingCopyRef));

    // delete folder
    nodeService.deleteNode(folderRef);

    assertFalse(nodeService.exists(folderRef));
    assertFalse(nodeService.exists(contentRef));
    assertFalse(nodeService.exists(workingCopyRef));

    // restore folder
    NodeRef archiveNodeRef = new NodeRef(archiveRootNodeRef.getStoreRef(), folderRef.getId());
    nodeService.restoreNode(archiveNodeRef, null, null, null);

    assertTrue(nodeService.exists(folderRef));
    assertTrue(nodeService.exists(contentRef));
    assertTrue(nodeService.exists(workingCopyRef));

    assertTrue(nodeService.hasAspect(workingCopyRef, ContentModel.ASPECT_WORKING_COPY));
    assertTrue(nodeService.hasAspect(workingCopyRef, ContentModel.ASPECT_COPIEDFROM));
    assertTrue(nodeService.hasAspect(contentRef, ContentModel.ASPECT_CHECKED_OUT));

    assertEquals(initialText, contentService.getReader(contentRef, ContentModel.PROP_CONTENT).getContentString());
    assertEquals(updatedText, contentService.getReader(workingCopyRef, ContentModel.PROP_CONTENT).getContentString());
    
    // belts-and-braces - also show that we can move a folder with checked-out item
    NodeRef folderRef2 = createFolder(spacesRootNodeRef, "testDeleteAndRestore-folder2-"+System.currentTimeMillis());
    
    nodeService.moveNode(folderRef, folderRef2, ContentModel.ASSOC_CONTAINS, ContentModel.ASSOC_CONTAINS);

    // checkin content node (working copy)
    cociService.checkin(workingCopyRef, null);

    assertFalse(nodeService.exists(workingCopyRef));

    assertEquals(updatedText, contentService.getReader(contentRef, ContentModel.PROP_CONTENT).getContentString());
}
 
Example 19
Source File: NodeRenditionsRelation.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Rendition readById(String nodeId, String renditionId, Parameters parameters)
{
    NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, nodeId);
    return renditions.getRendition(nodeRef, renditionId, parameters);
}
 
Example 20
Source File: RuleServiceTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
private NodeRef createRuleNodeRef(NodeRef folder, String title) throws Exception
{
    JSONObject jsonRule = createRule(folder, title);
    String id = jsonRule.getJSONObject("data").getString("id");
    return new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, id);
}