Merged HEAD-BUG-FIX (Cloud/4.3) to HEAD (Cloud/4.3)

62533: MNT-10030: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX
     61363: MNT-10030 Links on Share Repository search page show incorrect link name; do not work when root-node is defined
       - New fix for MNT-9056.
     62392: MNT-10030 Links on Share Repository search page show incorrect link name; do not work when root-node is defined
       - In AdvancedSearchTest was added testSearchInSites test.
       - In search.lib.js in splitQNamePath() was added check: (rootNodeQNamePath != null && path.indexOf(rootNodeQNamePath) === 0).


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@62792 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2014-02-19 12:02:53 +00:00
parent 3bd8f068c0
commit cd7b6d00e6
2 changed files with 54 additions and 14 deletions

View File

@@ -534,18 +534,16 @@ function splitQNamePath(node, rootNodeDisplayPath, rootNodeQNamePath, qnameOnly)
{
var path = node.qnamePath,
displayPath = qnameOnly ? null : utils.displayPath(node).split("/"),
parts = null;
parts = null,
overriden = false;
// restructure the display path of the node if we have an overriden root node
if (!qnameOnly && rootNodeDisplayPath != null && path.indexOf(rootNodeQNamePath) === 0)
{
var nodeDisplayPath = utils.displayPath(node).split("/");
nodeDisplayPath = nodeDisplayPath.splice(rootNodeDisplayPath.length);
for (var i = 0; i < rootNodeQNamePath.split("/").length-1; i++)
{
nodeDisplayPath.unshift(null);
}
displayPath = nodeDisplayPath;
overriden = true;
}
if (path.match("^"+SITES_SPACE_QNAME_PATH) == SITES_SPACE_QNAME_PATH)
@@ -554,6 +552,14 @@ function splitQNamePath(node, rootNodeDisplayPath, rootNodeQNamePath, qnameOnly)
pos = tmp.indexOf('/');
if (pos >= 1)
{
if (rootNodeQNamePath != null && path.indexOf(rootNodeQNamePath) === 0)
{
for (var i = 0; i < rootNodeQNamePath.split("/").length-1; i++)
{
nodeDisplayPath.unshift(null);
}
displayPath = nodeDisplayPath;
}
var siteQName = Packages.org.alfresco.util.ISO9075.decode(tmp.split("/")[0]);
siteId = siteQName.substring(siteQName.indexOf(":") + 1);
tmp = tmp.substring(pos + 1);
@@ -569,6 +575,11 @@ function splitQNamePath(node, rootNodeDisplayPath, rootNodeQNamePath, qnameOnly)
}
}
if (overriden && parts == null)
{
displayPath.unshift("");
}
return (parts !== null ? parts : [ null, null, displayPath ]);
}

View File

@@ -26,7 +26,9 @@ public class AdvancedSearchTest extends BaseWebScriptTest
{
private static final String TEST_FILE_NAME1 = "qwe iop.txt";
private static final String TEST_FILE_NAME2 = "qwe yu iop.txt";
private static final String TEST_IN_SITES_FILE_NAME = "qwesiteiop";
private static final String SEARCH_NAME = "qwe iop";
private static final String SEARCH_IN_SITES = "qwesiteiop";
private static final String TEST_FOLDER = "test_folder-" + System.currentTimeMillis();
private TransactionService transactionService;
@@ -38,6 +40,7 @@ public class AdvancedSearchTest extends BaseWebScriptTest
private NodeRef testNodeRef1;
private NodeRef testNodeRef2;
private NodeRef folderNodeRef;
private NodeRef rootNodeRef;
@Override
protected void setUp() throws Exception
@@ -52,9 +55,9 @@ public class AdvancedSearchTest extends BaseWebScriptTest
this.authenticationComponent.setSystemUserAsCurrentUser();
NodeRef rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
this.rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
List<NodeRef> results = searchService.selectNodes(rootNodeRef, "/app:company_home", null, namespaceService, false);
List<NodeRef> results = searchService.selectNodes(this.rootNodeRef, "/app:company_home", null, namespaceService, false);
if (results.size() == 0)
{
throw new AlfrescoRuntimeException("Can't find /app:company_home");
@@ -72,6 +75,14 @@ public class AdvancedSearchTest extends BaseWebScriptTest
assertNotNull(testNodeRef2);
}
private void deleteNodeIfExists(NodeRef nodeRef)
{
if (nodeService.exists(nodeRef))
{
nodeService.deleteNode(nodeRef);
}
}
@Override
protected void tearDown() throws Exception
{
@@ -87,13 +98,6 @@ public class AdvancedSearchTest extends BaseWebScriptTest
return null;
}
private void deleteNodeIfExists(NodeRef nodeRef)
{
if (nodeService.exists(nodeRef))
{
nodeService.deleteNode(nodeRef);
}
}
};
this.transactionService.getRetryingTransactionHelper().doInTransaction(deleteCallback);
this.authenticationComponent.clearCurrentSecurityContext();
@@ -113,4 +117,29 @@ public class AdvancedSearchTest extends BaseWebScriptTest
assertEquals(1, result.getInt("totalRecords"));
}
public void testSearchInSites() throws IOException, JSONException
{
List<NodeRef> results = searchService.selectNodes(this.rootNodeRef, "/app:company_home/st:sites", null, namespaceService, false);
if (results.size() == 0)
{
throw new AlfrescoRuntimeException("Can't find /app:company_home/st:sites");
}
NodeRef sitesNodeRef = results.get(0);
long time = System.currentTimeMillis();
NodeRef sitefolderNodeRef = fileFolderService.create(sitesNodeRef, TEST_FOLDER, ContentModel.TYPE_FOLDER).getNodeRef();
NodeRef nodeRef = fileFolderService.create(sitefolderNodeRef, TEST_IN_SITES_FILE_NAME + time, ContentModel.TYPE_CONTENT).getNodeRef();
// String url = "/slingshot/search?site=&term=" + SEARCH_NAME + "&tag=&maxResults=251&sort=&query=&repo=false&rootNode=alfresco%3A%2F%2Fcompany%2Fhome&pageSize=50&startIndex=0";
String url = "/slingshot/search?site=&term=&tag=&maxResults=251&sort=&query={\"prop_cm_name\":\"" + SEARCH_IN_SITES + time + "\",\"datatype\":\"cm:content\"}&repo=true&rootNode=alfresco://company/home";
Response res = sendRequest(new GetRequest(url), Status.STATUS_OK);
JSONObject result = new JSONObject(res.getContentAsString());
assertEquals(1, result.getInt("totalRecords"));
deleteNodeIfExists(nodeRef);
deleteNodeIfExists(sitefolderNodeRef);
}
}