From cd7b6d00e60d20783f61ce2ac85b56a956f71cb5 Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Wed, 19 Feb 2014 12:02:53 +0000 Subject: [PATCH] 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 --- .../alfresco/slingshot/search/search.lib.js | 21 +++++++-- .../scripts/search/AdvancedSearchTest.java | 47 +++++++++++++++---- 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.lib.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.lib.js index bd3fd906aa..a484fcfa4c 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.lib.js @@ -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 ]); } diff --git a/source/test-java/org/alfresco/repo/web/scripts/search/AdvancedSearchTest.java b/source/test-java/org/alfresco/repo/web/scripts/search/AdvancedSearchTest.java index 4bc2c9c1ed..1d0e065b33 100644 --- a/source/test-java/org/alfresco/repo/web/scripts/search/AdvancedSearchTest.java +++ b/source/test-java/org/alfresco/repo/web/scripts/search/AdvancedSearchTest.java @@ -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 results = searchService.selectNodes(rootNodeRef, "/app:company_home", null, namespaceService, false); + List 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 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); + + } + }