use of org.alfresco.service.cmr.repository.StoreRef in project alfresco-remote-api by Alfresco.
the class StreamContent method createObjectReferenceFromUrl.
protected ObjectReference createObjectReferenceFromUrl(Map<String, String> args, Map<String, String> templateArgs) {
String objectId = args.get("noderef");
if (objectId != null) {
return new ObjectReference(objectId);
}
StoreRef storeRef = null;
String store_type = templateArgs.get("store_type");
String store_id = templateArgs.get("store_id");
if (store_type != null && store_id != null) {
storeRef = new StoreRef(store_type, store_id);
}
String id = templateArgs.get("id");
if (storeRef != null && id != null) {
return new ObjectReference(storeRef, id);
}
String nodepath = templateArgs.get("nodepath");
if (nodepath == null) {
nodepath = args.get("nodepath");
}
if (storeRef != null && nodepath != null) {
return new ObjectReference(storeRef, nodepath.split("/"));
}
return null;
}
use of org.alfresco.service.cmr.repository.StoreRef in project alfresco-remote-api by Alfresco.
the class NodeArchiveServiceRestApiTest method createTestStoreAndGetRootNode.
private NodeRef createTestStoreAndGetRootNode() {
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
StoreRef workStoreRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, getName() + System.currentTimeMillis());
workStoreRootNodeRef = nodeService.getRootNode(workStoreRef);
StoreRef archiveStoreRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "archive" + getName() + System.currentTimeMillis());
archiveMap.put(workStoreRef, archiveStoreRef);
createdStores.add(workStoreRef);
createdStores.add(archiveStoreRef);
return workStoreRootNodeRef;
}
use of org.alfresco.service.cmr.repository.StoreRef in project alfresco-remote-api by Alfresco.
the class NodeArchiveServiceRestApiTest method tearDown.
@Override
public void tearDown() throws Exception {
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
super.tearDown();
// Tidy up any test nodes that are hanging around.
transactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() {
public Void execute() throws Throwable {
AuthenticationUtil.runAs(new RunAsWork<Void>() {
public Void doWork() throws Exception {
for (NodeRef nodeRef : createdNodes) {
if (nodeRef != null && nodeService.exists(nodeRef)) {
nodeService.deleteNode(nodeRef);
}
}
for (StoreRef store : createdStores) {
if (store != null && nodeService.exists(store)) {
nodeService.deleteStore(store);
}
}
return null;
}
}, AuthenticationUtil.getSystemUserName());
return null;
}
});
// Delete users
for (String userName : this.createdPeople) {
personService.deletePerson(userName);
}
// Clear the lists
this.createdPeople.clear();
this.createdNodes.clear();
this.createdStores.clear();
AuthenticationUtil.clearCurrentSecurityContext();
}
use of org.alfresco.service.cmr.repository.StoreRef in project alfresco-remote-api by Alfresco.
the class WebDAVMethodTest method checkLockedNodeTestTenantWork.
private void checkLockedNodeTestTenantWork() throws Exception {
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 DELETE
String corruptedLockToken = lockMethod.lockToken + "corr";
req.addHeader(WebDAV.HEADER_IF, "(<" + corruptedLockToken + ">)");
deleteMethod = new DeleteMethod();
deleteMethod.setDetails(req, resp, webDAVHelper, rootNodeRef);
deleteMethod.parseRequestHeaders();
deleteMethod.m_strPath = strPath;
// can't be deleted with corrupted lockTocken
try {
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>() {
@Override
public Object execute() throws Throwable {
deleteMethod.executeImpl();
return null;
}
});
fail("Locked node shouldn't be deleted");
} catch (Exception e) {
if (!(e.getCause() instanceof WebDAVServerException)) {
throw e;
}
}
req = new MockHttpServletRequest();
req.addHeader(WebDAV.HEADER_LOCK_TOKEN, lockMethod.lockToken);
unlockMethod = new UnlockMethod();
unlockMethod.setDetails(req, resp, webDAVHelper, rootNodeRef);
unlockMethod.parseRequestHeaders();
unlockMethod.m_strPath = strPath;
// unlock the node
try {
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>() {
@Override
public Object execute() throws Throwable {
unlockMethod.executeImpl();
return null;
}
});
} catch (Exception e) {
fail("Locked node should be unlocked with correct lockTocken " + e.getCause());
}
// Lock it again
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>() {
@Override
public Object execute() throws Throwable {
lockMethod.executeImpl();
return null;
}
});
req.addHeader(WebDAV.HEADER_IF, "(<" + lockMethod.lockToken + ">)");
deleteMethod = new DeleteMethod();
deleteMethod.setDetails(req, resp, webDAVHelper, rootNodeRef);
deleteMethod.parseRequestHeaders();
deleteMethod.m_strPath = strPath;
// can be deleted with correct lockTocken
try {
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>() {
@Override
public Object execute() throws Throwable {
deleteMethod.executeImpl();
return null;
}
});
} catch (Exception e) {
fail("Locked node should be deleted with correct lockTocken " + e.getCause());
}
}
use of org.alfresco.service.cmr.repository.StoreRef in project alfresco-remote-api by Alfresco.
the class NodeLocatorWebScriptTest method makeUrl.
private String makeUrl(NodeRef node, String locatorName) {
StoreRef storeRef = node.getStoreRef();
StringBuilder url = new StringBuilder("/api/");
url.append(storeRef.getProtocol()).append("/").append(storeRef.getIdentifier()).append("/").append(node.getId()).append("/").append("nodelocator").append("/").append(locatorName);
return url.toString();
}
Aggregations