Search in sources :

Example 76 with NodeRef

use of org.alfresco.service.cmr.repository.NodeRef in project alfresco-remote-api by Alfresco.

the class NodeLocatorWebScriptTest method testSitesHomeNodeLocator.

public void testSitesHomeNodeLocator() throws Exception {
    String url = baseURL + SitesHomeNodeLocator.NAME;
    NodeRef sitesHome = siteService.getSiteRoot();
    checkNodeLocator(url, sitesHome);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef)

Example 77 with NodeRef

use of org.alfresco.service.cmr.repository.NodeRef in project alfresco-remote-api by Alfresco.

the class PersonServiceTest method addTextContent.

private NodeRef addTextContent(NodeRef folderRef, String name, String textData) {
    Map<QName, Serializable> contentProps = new HashMap<QName, Serializable>();
    contentProps.put(ContentModel.PROP_NAME, name);
    ChildAssociationRef association = nodeService.createNode(folderRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name), ContentModel.TYPE_CONTENT, contentProps);
    NodeRef content = association.getChildRef();
    ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    writer.setEncoding("UTF-8");
    writer.putContent(textData);
    return content;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) ContentWriter(org.alfresco.service.cmr.repository.ContentWriter) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 78 with NodeRef

use of org.alfresco.service.cmr.repository.NodeRef in project alfresco-remote-api by Alfresco.

the class WebDAVLockServiceImplTest method testSessionDestroyed.

@Test
public void testSessionDestroyed() {
    List<Pair<String, NodeRef>> lockedNodes = new ArrayList<Pair<String, NodeRef>>(2);
    lockedNodes.add(new Pair<String, NodeRef>("some_user_name", nodeRef1));
    lockedNodes.add(new Pair<String, NodeRef>("another_user_name", nodeRef2));
    Mockito.when(sessionList.size()).thenReturn(2);
    Mockito.when(sessionList.iterator()).thenReturn(lockedNodes.iterator());
    Mockito.when(nodeService.exists(nodeRef1)).thenReturn(true);
    Mockito.when(nodeService.exists(nodeRef2)).thenReturn(true);
    Mockito.when(lockService.getLockStatus(nodeRef1)).thenReturn(LockStatus.LOCKED);
    Mockito.when(lockService.getLockStatus(nodeRef2)).thenReturn(LockStatus.LOCKED);
    // We're not going to do anything with nodeRef2
    NodeRef wcNodeRef2 = new NodeRef("workspace://SpacesStore/a6e3f82a-cfef-363d-9fca-3986a14180a0");
    Mockito.when(cociService.getWorkingCopy(nodeRef2)).thenReturn(wcNodeRef2);
    davLockService.sessionDestroyed();
    // nodeRef1 is unlocked
    Mockito.verify(lockService).unlock(nodeRef1);
    // nodeRef2 is not unlocked
    Mockito.verify(lockService, Mockito.never()).unlock(nodeRef2);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ArrayList(java.util.ArrayList) Pair(org.alfresco.util.Pair) Test(org.junit.Test)

Example 79 with NodeRef

use of org.alfresco.service.cmr.repository.NodeRef in project alfresco-remote-api by Alfresco.

the class WebDAVLockServiceImplTest method canGetLockInfo.

@Test
public void canGetLockInfo() {
    NodeRef nodeRef3 = new NodeRef("workspace://SpacesStore/a6a4371c-99b9-4618-8cd2-e71d28374859");
    Mockito.when(lockService.getLockState(nodeRef1)).thenReturn(lockState1);
    Mockito.when(lockService.getLockState(nodeRef2)).thenReturn(lockState2);
    Mockito.when(lockService.getLockState(nodeRef3)).thenReturn(null);
    // nodeRef1
    LockInfo lockInfo = davLockService.getLockInfo(nodeRef1);
    assertEquals(null, lockInfo.getExpires());
    assertEquals("user1", lockInfo.getOwner());
    // nodeRef2
    lockInfo = davLockService.getLockInfo(nodeRef2);
    assertEquals(new Date(999L), lockInfo.getExpires());
    assertEquals("user2", lockInfo.getOwner());
    assertEquals("a-random-token", lockInfo.getExclusiveLockToken());
    assertEquals("infinity", lockInfo.getDepth());
    assertEquals(WebDAV.XML_EXCLUSIVE, lockInfo.getScope());
    // nodeRef3
    lockInfo = davLockService.getLockInfo(nodeRef3);
    assertEquals(null, lockInfo);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Date(java.util.Date) Test(org.junit.Test)

Example 80 with NodeRef

use of org.alfresco.service.cmr.repository.NodeRef in project alfresco-remote-api by Alfresco.

the class WebDAVMethodTest method checkLockedNodeTestWork.

private void checkLockedNodeTestWork() throws WebDAVServerException {
    req = new MockHttpServletRequest();
    resp = new MockHttpServletResponse();
    String rootPath = "/app:company_home";
    String storeName = "workspace://SpacesStore";
    StoreRef storeRef = new StoreRef(storeName);
    NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);
    List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, rootPath, null, namespaceService, false);
    NodeRef defaultRootNode = nodeRefs.get(0);
    lockMethod = new LockMethod();
    NodeRef rootNodeRef = tenantService.getRootNode(nodeService, searchService, namespaceService, rootPath, defaultRootNode);
    String strPath = "/" + "testLockedNode" + GUID.generate();
    lockMethod.createExclusive = true;
    lockMethod.setDetails(req, resp, webDAVHelper, rootNodeRef);
    lockMethod.m_strPath = strPath;
    // Lock the node (will create a new one).
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>() {

        @Override
        public Object execute() throws Throwable {
            lockMethod.executeImpl();
            return null;
        }
    });
    // Prepare for PUT
    req.addHeader(WebDAV.HEADER_IF, "(<" + lockMethod.lockToken + ">)");
    putMethod = new PutMethod();
    putMethod.setDetails(req, resp, webDAVHelper, rootNodeRef);
    putMethod.parseRequestHeaders();
    putMethod.m_strPath = strPath;
    String content = "test content stream";
    req.setContent(content.getBytes());
    // Issue a put request
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>() {

        @Override
        public Object execute() throws Throwable {
            putMethod.executeImpl();
            return null;
        }
    });
}
Also used : StoreRef(org.alfresco.service.cmr.repository.StoreRef) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) NodeRef(org.alfresco.service.cmr.repository.NodeRef) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse)

Aggregations

NodeRef (org.alfresco.service.cmr.repository.NodeRef)1239 HashMap (java.util.HashMap)244 QName (org.alfresco.service.namespace.QName)242 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)209 Test (org.junit.Test)195 ArrayList (java.util.ArrayList)159 Serializable (java.io.Serializable)136 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)104 BaseUnitTest (org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)101 FileInfo (org.alfresco.service.cmr.model.FileInfo)82 Map (java.util.Map)81 Node (org.alfresco.web.bean.repository.Node)81 JSONObject (org.json.JSONObject)80 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)74 FacesContext (javax.faces.context.FacesContext)61 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)59 List (java.util.List)58 IOException (java.io.IOException)55 ContentWriter (org.alfresco.service.cmr.repository.ContentWriter)52 Date (java.util.Date)51