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);
}
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;
}
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);
}
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);
}
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;
}
});
}
Aggregations