mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
SHA-1867 : Unable to create links in Shared Files / My Files root node from the Search Results page
- Added method WebScriptUtil.resolveNodeReference() which will resolve nodeRef git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@132544 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1847,6 +1847,7 @@
|
|||||||
<property name="siteService" ref="SiteService" />
|
<property name="siteService" ref="SiteService" />
|
||||||
<property name="documentLinkService" ref="DocumentLinkService" />
|
<property name="documentLinkService" ref="DocumentLinkService" />
|
||||||
<property name="activityService" ref="activityService"/>
|
<property name="activityService" ref="activityService"/>
|
||||||
|
<property name="serviceRegistry" ref="ServiceRegistry"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="webscript.org.alfresco.repository.doclink.doclinks.delete"
|
<bean id="webscript.org.alfresco.repository.doclink.doclinks.delete"
|
||||||
|
@@ -34,8 +34,13 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import org.alfresco.repo.nodelocator.CompanyHomeNodeLocator;
|
||||||
|
import org.alfresco.repo.nodelocator.NodeLocatorService;
|
||||||
|
import org.alfresco.repo.nodelocator.SharedHomeNodeLocator;
|
||||||
|
import org.alfresco.repo.nodelocator.SitesHomeNodeLocator;
|
||||||
|
import org.alfresco.repo.nodelocator.UserHomeNodeLocator;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.util.ISO8601DateFormat;
|
import org.alfresco.util.ISO8601DateFormat;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@@ -149,6 +154,31 @@ public class WebScriptUtil
|
|||||||
}
|
}
|
||||||
return new NodeRef(protocol, storeId, nodeId);
|
return new NodeRef(protocol, storeId, nodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static NodeRef resolveNodeReference(String reference, NodeLocatorService nodeLocatorService)
|
||||||
|
{
|
||||||
|
NodeRef nodeRef = null;
|
||||||
|
switch (reference)
|
||||||
|
{
|
||||||
|
case "alfresco://company/home":
|
||||||
|
nodeRef = nodeLocatorService.getNode(CompanyHomeNodeLocator.NAME, null, null);
|
||||||
|
break;
|
||||||
|
case "alfresco://user/home":
|
||||||
|
nodeRef = nodeLocatorService.getNode(UserHomeNodeLocator.NAME, null, null);
|
||||||
|
break;
|
||||||
|
case "alfresco://company/shared":
|
||||||
|
nodeRef = nodeLocatorService.getNode(SharedHomeNodeLocator.NAME, null, null);
|
||||||
|
break;
|
||||||
|
case "alfresco://sites/home":
|
||||||
|
nodeRef = nodeLocatorService.getNode(SitesHomeNodeLocator.NAME, null, null);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
nodeRef = new NodeRef(reference);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -30,9 +30,8 @@ import java.util.Map;
|
|||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.web.scripts.links.AbstractLinksWebScript;
|
import org.alfresco.service.ServiceRegistry;
|
||||||
import org.alfresco.service.cmr.activities.ActivityService;
|
import org.alfresco.service.cmr.activities.ActivityService;
|
||||||
import org.alfresco.service.cmr.links.LinkInfo;
|
|
||||||
import org.alfresco.service.cmr.repository.DocumentLinkService;
|
import org.alfresco.service.cmr.repository.DocumentLinkService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
@@ -42,12 +41,9 @@ import org.alfresco.util.ParameterCheck;
|
|||||||
import org.alfresco.util.PropertyCheck;
|
import org.alfresco.util.PropertyCheck;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.json.JSONStringer;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||||
import org.springframework.extensions.webscripts.Status;
|
import org.springframework.extensions.webscripts.Status;
|
||||||
import org.springframework.extensions.webscripts.WebScriptException;
|
import org.springframework.extensions.webscripts.WebScriptException;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
|
||||||
import org.springframework.extensions.webscripts.json.JSONWriter;
|
import org.springframework.extensions.webscripts.json.JSONWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,6 +67,7 @@ public abstract class AbstractDocLink extends DeclarativeWebScript
|
|||||||
protected SiteService siteService;
|
protected SiteService siteService;
|
||||||
protected DocumentLinkService documentLinkService;
|
protected DocumentLinkService documentLinkService;
|
||||||
protected ActivityService activityService;
|
protected ActivityService activityService;
|
||||||
|
protected ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
private static Log logger = LogFactory.getLog(AbstractDocLink.class);
|
private static Log logger = LogFactory.getLog(AbstractDocLink.class);
|
||||||
|
|
||||||
@@ -190,4 +187,10 @@ public abstract class AbstractDocLink extends DeclarativeWebScript
|
|||||||
{
|
{
|
||||||
this.activityService = activityService;
|
this.activityService = activityService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setServiceRegistry(ServiceRegistry serviceRegistry)
|
||||||
|
{
|
||||||
|
this.serviceRegistry = serviceRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -36,6 +36,7 @@ import org.alfresco.model.ContentModel;
|
|||||||
import org.alfresco.repo.activities.ActivityType;
|
import org.alfresco.repo.activities.ActivityType;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||||
|
import org.alfresco.repo.web.scripts.WebScriptUtil;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.util.ParameterCheck;
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
@@ -99,7 +100,7 @@ public class DocLinkPost extends AbstractDocLink
|
|||||||
/* Parse the destination NodeRef parameter */
|
/* Parse the destination NodeRef parameter */
|
||||||
String destinationNodeParam = (String) json.get(PARAM_DESTINATION_NODE);
|
String destinationNodeParam = (String) json.get(PARAM_DESTINATION_NODE);
|
||||||
ParameterCheck.mandatoryString("destinationNodeParam", destinationNodeParam);
|
ParameterCheck.mandatoryString("destinationNodeParam", destinationNodeParam);
|
||||||
destinationNodeRef = new NodeRef(destinationNodeParam);
|
destinationNodeRef = WebScriptUtil.resolveNodeReference(destinationNodeParam, serviceRegistry.getNodeLocatorService());
|
||||||
|
|
||||||
List<NodeRef> nodeRefs = new ArrayList<NodeRef>();
|
List<NodeRef> nodeRefs = new ArrayList<NodeRef>();
|
||||||
if (json.containsKey(PARAM_MULTIPLE_FILES))
|
if (json.containsKey(PARAM_MULTIPLE_FILES))
|
||||||
|
@@ -34,12 +34,14 @@ import java.util.Map;
|
|||||||
import org.alfresco.model.ApplicationModel;
|
import org.alfresco.model.ApplicationModel;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
|
import org.alfresco.repo.dictionary.DictionaryModelTypeTest;
|
||||||
import org.alfresco.repo.node.archive.NodeArchiveService;
|
import org.alfresco.repo.node.archive.NodeArchiveService;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.site.SiteModel;
|
import org.alfresco.repo.site.SiteModel;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
||||||
|
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
@@ -69,6 +71,10 @@ import org.springframework.extensions.webscripts.TestWebScriptServer.Response;
|
|||||||
public class NodeWebScripTest extends BaseWebScriptTest
|
public class NodeWebScripTest extends BaseWebScriptTest
|
||||||
{
|
{
|
||||||
private static Log logger = LogFactory.getLog(NodeWebScripTest.class);
|
private static Log logger = LogFactory.getLog(NodeWebScripTest.class);
|
||||||
|
|
||||||
|
private static String CREATE_LINK_API = "/api/node/doclink/";
|
||||||
|
private static String DESTINATION_NODE_REF_PARAM = "destinationNodeRef";
|
||||||
|
private static String MULTIPLE_FILES_PARAM = "multipleFiles";
|
||||||
|
|
||||||
private String TEST_SITE_NAME = "TestNodeSite";
|
private String TEST_SITE_NAME = "TestNodeSite";
|
||||||
private SiteInfo TEST_SITE;
|
private SiteInfo TEST_SITE;
|
||||||
@@ -79,6 +85,7 @@ public class NodeWebScripTest extends BaseWebScriptTest
|
|||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private NodeArchiveService nodeArchiveService;
|
private NodeArchiveService nodeArchiveService;
|
||||||
|
private CheckOutCheckInService checkOutCheckInService;
|
||||||
|
|
||||||
private static final String USER_ONE = "UserOneSecondToo";
|
private static final String USER_ONE = "UserOneSecondToo";
|
||||||
private static final String USER_TWO = "UserTwoSecondToo";
|
private static final String USER_TWO = "UserTwoSecondToo";
|
||||||
@@ -97,6 +104,7 @@ public class NodeWebScripTest extends BaseWebScriptTest
|
|||||||
this.siteService = (SiteService)ctx.getBean("SiteService");
|
this.siteService = (SiteService)ctx.getBean("SiteService");
|
||||||
this.nodeService = (NodeService)ctx.getBean("NodeService");
|
this.nodeService = (NodeService)ctx.getBean("NodeService");
|
||||||
this.nodeArchiveService = (NodeArchiveService)ctx.getBean("nodeArchiveService");
|
this.nodeArchiveService = (NodeArchiveService)ctx.getBean("nodeArchiveService");
|
||||||
|
this.checkOutCheckInService = (CheckOutCheckInService)ctx.getBean("checkOutCheckInService");
|
||||||
|
|
||||||
// Do the setup as admin
|
// Do the setup as admin
|
||||||
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
|
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
|
||||||
@@ -402,7 +410,7 @@ public class NodeWebScripTest extends BaseWebScriptTest
|
|||||||
JSONArray jsonLinkNodes = null;
|
JSONArray jsonLinkNodes = null;
|
||||||
JSONObject jsonLinkNode = null;
|
JSONObject jsonLinkNode = null;
|
||||||
|
|
||||||
//Create files in the folder
|
//Create files in the testFolder1
|
||||||
NodeRef testFile1 = createNode(testFolder1, "testingLinkCreationFile1", ContentModel.TYPE_CONTENT,
|
NodeRef testFile1 = createNode(testFolder1, "testingLinkCreationFile1", ContentModel.TYPE_CONTENT,
|
||||||
AuthenticationUtil.getAdminUserName());
|
AuthenticationUtil.getAdminUserName());
|
||||||
NodeRef testFile2 = createNode(testFolder1, "testingLinkCreationFile2", ContentModel.TYPE_CONTENT,
|
NodeRef testFile2 = createNode(testFolder1, "testingLinkCreationFile2", ContentModel.TYPE_CONTENT,
|
||||||
@@ -410,21 +418,21 @@ public class NodeWebScripTest extends BaseWebScriptTest
|
|||||||
NodeRef testFile3 = createNode(testFolder1, "testingLinkCreationFile3", ContentModel.TYPE_CONTENT,
|
NodeRef testFile3 = createNode(testFolder1, "testingLinkCreationFile3", ContentModel.TYPE_CONTENT,
|
||||||
AuthenticationUtil.getAdminUserName());
|
AuthenticationUtil.getAdminUserName());
|
||||||
|
|
||||||
//Create another folder in the folder
|
//Create testFolder2 in the testFolder1
|
||||||
String testFolder2Name = "testingLinkCreationFolder2";
|
String testFolder2Name = "testingLinkCreationFolder2";
|
||||||
testFolderProps = new HashMap<QName, Serializable>();
|
testFolderProps = new HashMap<QName, Serializable>();
|
||||||
testFolderProps.put(ContentModel.PROP_NAME, testFolder2Name);
|
testFolderProps.put(ContentModel.PROP_NAME, testFolder2Name);
|
||||||
NodeRef testFolder2 = nodeService.createNode(siteDocLib, ContentModel.ASSOC_CONTAINS,
|
NodeRef testFolder2 = nodeService.createNode(siteDocLib, ContentModel.ASSOC_CONTAINS,
|
||||||
QName.createQName("testingLinkCreationFolder2"), ContentModel.TYPE_FOLDER, testFolderProps).getChildRef();
|
QName.createQName("testingLinkCreationFolder2"), ContentModel.TYPE_FOLDER, testFolderProps).getChildRef();
|
||||||
|
|
||||||
// Create link to file1 in same folder
|
// Create link to file1 in same folder - testFolder1
|
||||||
Request req = new Request("POST", "/api/node/doclink/" + testFile1.getStoreRef().getProtocol() + "/"
|
Request req = new Request("POST", CREATE_LINK_API + testFile1.getStoreRef().getProtocol() + "/"
|
||||||
+ testFile1.getStoreRef().getIdentifier() + "/" + testFile1.getId());
|
+ testFile1.getStoreRef().getIdentifier() + "/" + testFile1.getId());
|
||||||
jsonReq = new JSONObject();
|
jsonReq = new JSONObject();
|
||||||
jsonReq.put("destinationNodeRef", testFolder1.toString());
|
jsonReq.put(DESTINATION_NODE_REF_PARAM, testFolder1.toString());
|
||||||
|
|
||||||
jsonArray.add(testFile1.toString());
|
jsonArray.add(testFile1.toString());
|
||||||
jsonReq.put("multipleFiles", jsonArray);
|
jsonReq.put(MULTIPLE_FILES_PARAM, jsonArray);
|
||||||
req.setBody(jsonReq.toString().getBytes());
|
req.setBody(jsonReq.toString().getBytes());
|
||||||
req.setType(MimetypeMap.MIMETYPE_JSON);
|
req.setType(MimetypeMap.MIMETYPE_JSON);
|
||||||
|
|
||||||
@@ -447,13 +455,13 @@ public class NodeWebScripTest extends BaseWebScriptTest
|
|||||||
assertEquals(false, nodeService.hasAspect(testFile1, ApplicationModel.ASPECT_LINKED));
|
assertEquals(false, nodeService.hasAspect(testFile1, ApplicationModel.ASPECT_LINKED));
|
||||||
|
|
||||||
//Create link to testFolder2 in same folder (testFolder1)
|
//Create link to testFolder2 in same folder (testFolder1)
|
||||||
req = new Request("POST", "/api/node/doclink/" + testFolder2.getStoreRef().getProtocol() + "/"
|
req = new Request("POST", CREATE_LINK_API + testFolder2.getStoreRef().getProtocol() + "/"
|
||||||
+ testFolder2.getStoreRef().getIdentifier() + "/" + testFolder2.getId());
|
+ testFolder2.getStoreRef().getIdentifier() + "/" + testFolder2.getId());
|
||||||
jsonReq = new JSONObject();
|
jsonReq = new JSONObject();
|
||||||
jsonReq.put("destinationNodeRef", testFolder1.toString());
|
jsonReq.put(DESTINATION_NODE_REF_PARAM, testFolder1.toString());
|
||||||
jsonArray = new JSONArray();
|
jsonArray = new JSONArray();
|
||||||
jsonArray.add(testFolder2.toString());
|
jsonArray.add(testFolder2.toString());
|
||||||
jsonReq.put("multipleFiles", jsonArray);
|
jsonReq.put(MULTIPLE_FILES_PARAM, jsonArray);
|
||||||
req.setBody(jsonReq.toString().getBytes());
|
req.setBody(jsonReq.toString().getBytes());
|
||||||
req.setType(MimetypeMap.MIMETYPE_JSON);
|
req.setType(MimetypeMap.MIMETYPE_JSON);
|
||||||
|
|
||||||
@@ -472,13 +480,13 @@ public class NodeWebScripTest extends BaseWebScriptTest
|
|||||||
assertEquals(true, nodeService.exists(folder2Link));
|
assertEquals(true, nodeService.exists(folder2Link));
|
||||||
|
|
||||||
// create another link of testFolder2 in siteDocLib
|
// create another link of testFolder2 in siteDocLib
|
||||||
req = new Request("POST", "/api/node/doclink/" + testFolder2.getStoreRef().getProtocol() + "/"
|
req = new Request("POST", CREATE_LINK_API + testFolder2.getStoreRef().getProtocol() + "/"
|
||||||
+ testFolder2.getStoreRef().getIdentifier() + "/" + testFolder2.getId());
|
+ testFolder2.getStoreRef().getIdentifier() + "/" + testFolder2.getId());
|
||||||
jsonReq = new JSONObject();
|
jsonReq = new JSONObject();
|
||||||
jsonReq.put("destinationNodeRef", siteDocLib.toString());
|
jsonReq.put(DESTINATION_NODE_REF_PARAM, siteDocLib.toString());
|
||||||
jsonArray = new JSONArray();
|
jsonArray = new JSONArray();
|
||||||
jsonArray.add(testFolder2.toString());
|
jsonArray.add(testFolder2.toString());
|
||||||
jsonReq.put("multipleFiles", jsonArray);
|
jsonReq.put(MULTIPLE_FILES_PARAM, jsonArray);
|
||||||
req.setBody(jsonReq.toString().getBytes());
|
req.setBody(jsonReq.toString().getBytes());
|
||||||
req.setType(MimetypeMap.MIMETYPE_JSON);
|
req.setType(MimetypeMap.MIMETYPE_JSON);
|
||||||
|
|
||||||
@@ -502,15 +510,15 @@ public class NodeWebScripTest extends BaseWebScriptTest
|
|||||||
assertEquals(false, nodeService.hasAspect(testFolder2, ApplicationModel.ASPECT_LINKED));
|
assertEquals(false, nodeService.hasAspect(testFolder2, ApplicationModel.ASPECT_LINKED));
|
||||||
|
|
||||||
// Create link to testFile1, testFile2 and testFile3 in same testFolder1
|
// Create link to testFile1, testFile2 and testFile3 in same testFolder1
|
||||||
req = new Request("POST", "/api/node/doclink/" + testFolder1.getStoreRef().getProtocol() + "/"
|
req = new Request("POST", CREATE_LINK_API + testFolder1.getStoreRef().getProtocol() + "/"
|
||||||
+ testFolder1.getStoreRef().getIdentifier() + "/" + testFolder1.getId());
|
+ testFolder1.getStoreRef().getIdentifier() + "/" + testFolder1.getId());
|
||||||
jsonReq = new JSONObject();
|
jsonReq = new JSONObject();
|
||||||
jsonReq.put("destinationNodeRef", testFolder1.toString());
|
jsonReq.put(DESTINATION_NODE_REF_PARAM, testFolder1.toString());
|
||||||
jsonArray = new JSONArray();
|
jsonArray = new JSONArray();
|
||||||
jsonArray.add(testFile1.toString());
|
jsonArray.add(testFile1.toString());
|
||||||
jsonArray.add(testFile2.toString());
|
jsonArray.add(testFile2.toString());
|
||||||
jsonArray.add(testFile3.toString());
|
jsonArray.add(testFile3.toString());
|
||||||
jsonReq.put("multipleFiles", jsonArray);
|
jsonReq.put(MULTIPLE_FILES_PARAM, jsonArray);
|
||||||
req.setBody(jsonReq.toString().getBytes());
|
req.setBody(jsonReq.toString().getBytes());
|
||||||
req.setType(MimetypeMap.MIMETYPE_JSON);
|
req.setType(MimetypeMap.MIMETYPE_JSON);
|
||||||
|
|
||||||
@@ -532,15 +540,15 @@ public class NodeWebScripTest extends BaseWebScriptTest
|
|||||||
fileLinks.add(fileLink);
|
fileLinks.add(fileLink);
|
||||||
assertEquals(true, nodeService.exists(fileLink));
|
assertEquals(true, nodeService.exists(fileLink));
|
||||||
}
|
}
|
||||||
|
|
||||||
//try to create another link in the same location - an exception should be thrown
|
//try to create another link in the same location - an exception should be thrown
|
||||||
req = new Request("POST", "/api/node/doclink/" + testFolder1.getStoreRef().getProtocol() + "/"
|
req = new Request("POST", CREATE_LINK_API + testFolder1.getStoreRef().getProtocol() + "/"
|
||||||
+ testFolder1.getStoreRef().getIdentifier() + "/" + testFolder1.getId());
|
+ testFolder1.getStoreRef().getIdentifier() + "/" + testFolder1.getId());
|
||||||
jsonReq = new JSONObject();
|
jsonReq = new JSONObject();
|
||||||
jsonReq.put("destinationNodeRef", testFolder1.toString());
|
jsonReq.put(DESTINATION_NODE_REF_PARAM, testFolder1.toString());
|
||||||
jsonArray = new JSONArray();
|
jsonArray = new JSONArray();
|
||||||
jsonArray.add(testFile1.toString());
|
jsonArray.add(testFile1.toString());
|
||||||
jsonReq.put("multipleFiles", jsonArray);
|
jsonReq.put(MULTIPLE_FILES_PARAM, jsonArray);
|
||||||
req.setBody(jsonReq.toString().getBytes());
|
req.setBody(jsonReq.toString().getBytes());
|
||||||
req.setType(MimetypeMap.MIMETYPE_JSON);
|
req.setType(MimetypeMap.MIMETYPE_JSON);
|
||||||
|
|
||||||
@@ -555,17 +563,17 @@ public class NodeWebScripTest extends BaseWebScriptTest
|
|||||||
assertEquals(false, nodeService.exists(linkNodeRef));
|
assertEquals(false, nodeService.exists(linkNodeRef));
|
||||||
}
|
}
|
||||||
|
|
||||||
//try create a link to a site
|
//try create a link to a site - shouldn't be possible
|
||||||
SiteInfo site2 = createSite("Site2TestingNodeCreateLink");
|
SiteInfo site2 = createSite("Site2TestingNodeCreateLink");
|
||||||
NodeRef siteNodeRef = site2.getNodeRef();
|
NodeRef siteNodeRef = site2.getNodeRef();
|
||||||
|
|
||||||
req = new Request("POST", "/api/node/doclink/" + testFolder1.getStoreRef().getProtocol() + "/"
|
req = new Request("POST", CREATE_LINK_API + testFolder1.getStoreRef().getProtocol() + "/"
|
||||||
+ testFolder1.getStoreRef().getIdentifier() + "/" + testFolder1.getId());
|
+ testFolder1.getStoreRef().getIdentifier() + "/" + testFolder1.getId());
|
||||||
jsonReq = new JSONObject();
|
jsonReq = new JSONObject();
|
||||||
jsonReq.put("destinationNodeRef", testFolder1.toString());
|
jsonReq.put(DESTINATION_NODE_REF_PARAM, testFolder1.toString());
|
||||||
jsonArray = new JSONArray();
|
jsonArray = new JSONArray();
|
||||||
jsonArray.add(siteNodeRef.toString());
|
jsonArray.add(siteNodeRef.toString());
|
||||||
jsonReq.put("multipleFiles", jsonArray);
|
jsonReq.put(MULTIPLE_FILES_PARAM, jsonArray);
|
||||||
req.setBody(jsonReq.toString().getBytes());
|
req.setBody(jsonReq.toString().getBytes());
|
||||||
req.setType(MimetypeMap.MIMETYPE_JSON);
|
req.setType(MimetypeMap.MIMETYPE_JSON);
|
||||||
|
|
||||||
@@ -573,6 +581,61 @@ public class NodeWebScripTest extends BaseWebScriptTest
|
|||||||
|
|
||||||
siteService.deleteSite(site2.getShortName());
|
siteService.deleteSite(site2.getShortName());
|
||||||
nodeArchiveService.purgeArchivedNode(nodeArchiveService.getArchivedNode(siteNodeRef));
|
nodeArchiveService.purgeArchivedNode(nodeArchiveService.getArchivedNode(siteNodeRef));
|
||||||
|
|
||||||
|
//Links can be created in Shared Files, My Files and Repository
|
||||||
|
NodeRef testFile4 = createNode(testFolder1, "testingLinkCreationFile4", ContentModel.TYPE_CONTENT,
|
||||||
|
AuthenticationUtil.getAdminUserName());
|
||||||
|
req = new Request("POST", CREATE_LINK_API + testFile4.getStoreRef().getProtocol() + "/"
|
||||||
|
+ testFile4.getStoreRef().getIdentifier() + "/" + testFile4.getId());
|
||||||
|
jsonReq = new JSONObject();
|
||||||
|
jsonReq.put(DESTINATION_NODE_REF_PARAM, "alfresco://company/shared");
|
||||||
|
|
||||||
|
jsonArray = new JSONArray();
|
||||||
|
jsonArray.add(testFile4.toString());
|
||||||
|
jsonReq.put(MULTIPLE_FILES_PARAM, jsonArray);
|
||||||
|
req.setBody(jsonReq.toString().getBytes());
|
||||||
|
req.setType(MimetypeMap.MIMETYPE_JSON);
|
||||||
|
|
||||||
|
json = asJSON(sendRequest(req, Status.STATUS_OK));
|
||||||
|
|
||||||
|
req = new Request("POST", CREATE_LINK_API + testFile4.getStoreRef().getProtocol() + "/"
|
||||||
|
+ testFile4.getStoreRef().getIdentifier() + "/" + testFile4.getId());
|
||||||
|
jsonReq = new JSONObject();
|
||||||
|
jsonReq.put(DESTINATION_NODE_REF_PARAM, "alfresco://user/home");
|
||||||
|
|
||||||
|
jsonArray = new JSONArray();
|
||||||
|
jsonArray.add(testFile4.toString());
|
||||||
|
jsonReq.put(MULTIPLE_FILES_PARAM, jsonArray);
|
||||||
|
req.setBody(jsonReq.toString().getBytes());
|
||||||
|
req.setType(MimetypeMap.MIMETYPE_JSON);
|
||||||
|
|
||||||
|
json = asJSON(sendRequest(req, Status.STATUS_OK));
|
||||||
|
|
||||||
|
//create link in Repository as Admin
|
||||||
|
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
|
||||||
|
req = new Request("POST", CREATE_LINK_API + testFile4.getStoreRef().getProtocol() + "/"
|
||||||
|
+ testFile4.getStoreRef().getIdentifier() + "/" + testFile4.getId());
|
||||||
|
jsonReq = new JSONObject();
|
||||||
|
jsonReq.put(DESTINATION_NODE_REF_PARAM, "alfresco://company/home");
|
||||||
|
|
||||||
|
jsonArray = new JSONArray();
|
||||||
|
jsonArray.add(testFile4.toString());
|
||||||
|
jsonReq.put(MULTIPLE_FILES_PARAM, jsonArray);
|
||||||
|
req.setBody(jsonReq.toString().getBytes());
|
||||||
|
req.setType(MimetypeMap.MIMETYPE_JSON);
|
||||||
|
|
||||||
|
json = asJSON(sendRequest(req, Status.STATUS_OK));
|
||||||
|
|
||||||
|
//all 3 links are created with success, delete all links
|
||||||
|
req = new Request("DELETE", CREATE_LINK_API + testFile4.getStoreRef().getProtocol() + "/"
|
||||||
|
+ testFile4.getStoreRef().getIdentifier() + "/" + testFile4.getId() + "/delete");
|
||||||
|
req.setType(MimetypeMap.MIMETYPE_JSON);
|
||||||
|
json = asJSON(sendRequest(req, Status.STATUS_OK));
|
||||||
|
|
||||||
|
//all links are removed with success marker aspect should be removed too
|
||||||
|
assertEquals(false, nodeService.hasAspect(testFile4, ApplicationModel.ASPECT_LINKED));
|
||||||
|
|
||||||
|
AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private NodeRef createNode(NodeRef parentNode, String nodeCmName, QName nodeType, String ownerUserName)
|
private NodeRef createNode(NodeRef parentNode, String nodeCmName, QName nodeType, String ownerUserName)
|
||||||
|
Reference in New Issue
Block a user