diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/tagging/node.tags.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/tagging/node.tags.get.json.ftl index 2e4aa788ce..8ac9a57c02 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/tagging/node.tags.get.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/tagging/node.tags.get.json.ftl @@ -1,5 +1,5 @@ [ <#list tags as tag> - ${jsonUtils.encodeJSONString(tag)}<#if tag_has_next>, + "${jsonUtils.encodeJSONString(tag)}"<#if tag_has_next>, ] \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/tagging/node.tags.post.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/tagging/node.tags.post.json.ftl index 2e4aa788ce..8ac9a57c02 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/tagging/node.tags.post.json.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/tagging/node.tags.post.json.ftl @@ -1,5 +1,5 @@ [ <#list tags as tag> - ${jsonUtils.encodeJSONString(tag)}<#if tag_has_next>, + "${jsonUtils.encodeJSONString(tag)}"<#if tag_has_next>, ] \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-contents.get.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-contents.get.js index 80eddc93db..bdb91f0bf1 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-contents.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-contents.get.js @@ -29,10 +29,12 @@ function getWikiPages() function getDiscussions() { var q = " +TYPE:\"{http://www.alfresco.org/model/forum/1.0}post\"" + - " +PATH:\"/app:company_home/st:sites/*/cm:discussions//*\"" + + " +PATH:\"/app:company_home/st:sites/*/cm:discussions/*/*\"" + " +@cm\\:creator:\"" + person.properties.userName + '"'; - nodes = search.luceneSearch(q, 'cm:modified', false, 3); + // NOTE: pull back all posts as first reply on each post will also find the root post + // the posts will be discarded until the root post for each topic is found. + nodes = search.luceneSearch(q, 'cm:modified', false); return processResults(nodes, 3); } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/doclist.lib.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/doclist.lib.js index 8dddd34b5b..6ac36a0fbc 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/doclist.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/doclist.lib.js @@ -185,14 +185,25 @@ function doclist_main() item.location = location; // Check: thumbnail type is registered && node is a cm:content subtype && valid inputStream for content property - if (isThumbnailNameRegistered && item.node.isSubType("cm:content") && item.node.properties.content.inputStream != null) + var is = item.node.properties.content.inputStream; + try { - // Make sure we have a thumbnail. - thumbnail = item.node.getThumbnail(THUMBNAIL_NAME); - if (thumbnail === null) + if (isThumbnailNameRegistered && item.node.isSubType("cm:content") && (null != is)) { - // No thumbnail, so queue creation - item.node.createThumbnail(THUMBNAIL_NAME, true); + // Make sure we have a thumbnail. + thumbnail = item.node.getThumbnail(THUMBNAIL_NAME); + if (thumbnail === null) + { + // No thumbnail, so queue creation + item.node.createThumbnail(THUMBNAIL_NAME, true); + } + } + } + finally + { + if (null != is) + { + is.close(); } } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/node.get.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/node.get.js index 97b9c2bfcc..627d055043 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/node.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/node.get.js @@ -51,14 +51,25 @@ function getDoclist() } // Check: thumbnail type is registered && node is a cm:content subtype && valid inputStream for content property - if (isThumbnailNameRegistered && item.node.isSubType("cm:content") && item.node.properties.content.inputStream != null) + var is = item.node.properties.content.inputStream; + try { - // Make sure we have a thumbnail. - thumbnail = item.node.getThumbnail(THUMBNAIL_NAME); - if (thumbnail === null) + if (isThumbnailNameRegistered && item.node.isSubType("cm:content") && (null != is)) { - // No thumbnail, so queue creation - item.node.createThumbnail(THUMBNAIL_NAME, true); + // Make sure we have a thumbnail. + thumbnail = item.node.getThumbnail(THUMBNAIL_NAME); + if (thumbnail === null) + { + // No thumbnail, so queue creation + item.node.createThumbnail(THUMBNAIL_NAME, true); + } + } + } + finally + { + if (null != is) + { + is.close(); } } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js index 29c4875a50..ee89086880 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js @@ -31,7 +31,16 @@ function getDoclist() { favourites: favourites }), - query = filterParams.query; + query = filterParams.query, + allSites = (parsedArgs.nodeRef == "alfresco://sites/home"); + + if (logger.isLoggingEnabled()) + logger.log("doclist.get.js - NodeRef: " + parsedArgs.nodeRef + " Query: " + query); + + var totalItemCount = filterParams.limitResults ? parseInt(filterParams.limitResults, 10) : -1; + // For all sites documentLibrary query we pull in all available results and post filter + if (totalItemCount === 0) totalItemCount = -1; + else if (allSites) totalItemCount = -1; if ((filter || "path") == "path") { @@ -77,7 +86,7 @@ function getDoclist() language: filterParams.language, page: { - maxItems: (filterParams.limitResults ? parseInt(filterParams.limitResults, 10) : 0) + maxItems: totalItemCount }, sort: filterParams.sort, templates: filterParams.templates, @@ -87,28 +96,48 @@ function getDoclist() totalRecords = allNodes.length; } } - + if (logger.isLoggingEnabled()) + logger.log("doclist.get.js - query results: " + allNodes.length); + // Generate the qname path match regex required for all sites 'documentLibrary' results match + var pathRegex; + if (allSites) + { + // escape the forward slash characters in the qname path + // TODO: replace with java.lang.String regex match for performance + var pathMatch = new String(parsedArgs.rootNode.qnamePath).replace(/\//g, '\\/') + "\\/.*\\/cm:documentLibrary\\/.*"; + pathRegex = new RegExp(pathMatch, "gi"); + if (logger.isLoggingEnabled()) + logger.log("doclist.get.js - will match results using regex: " + pathMatch); + } + // Ensure folders and folderlinks appear at the top of the list var folderNodes = [], documentNodes = []; - + for each (node in allNodes) { - try + if (totalItemCount !== 0) { - if (node.isContainer || node.isLinkToContainer) + try { - folderNodes.push(node); + if (!allSites || node.qnamePath.match(pathRegex)) + { + totalItemCount--; + if (node.isContainer || node.isLinkToContainer) + { + folderNodes.push(node); + } + else + { + documentNodes.push(node); + } + } } - else + catch (e) { - documentNodes.push(node); + // Possibly an old indexed node - ignore it } - } - catch (e) - { - // Possibly an old indexed node - ignore it - } + } else break; } // Node type counts @@ -193,14 +222,25 @@ function getDoclist() item.location = location; // Is our thumbnail type registered? - if (isThumbnailNameRegistered && item.node.isSubType("cm:content") && item.node.properties.content.inputStream != null) + var is = item.node.properties.content.inputStream; + try { - // Make sure we have a thumbnail. - thumbnail = item.node.getThumbnail(THUMBNAIL_NAME); - if (thumbnail === null) + if (isThumbnailNameRegistered && item.node.isSubType("cm:content") && (null != is)) { - // No thumbnail, so queue creation - item.node.createThumbnail(THUMBNAIL_NAME, true); + // Make sure we have a thumbnail. + thumbnail = item.node.getThumbnail(THUMBNAIL_NAME); + if (thumbnail === null) + { + // No thumbnail, so queue creation + item.node.createThumbnail(THUMBNAIL_NAME, true); + } + } + } + finally + { + if (null != is) + { + is.close(); } } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/filters.lib.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/filters.lib.js index 7d40c3b2bd..48c2bf8aef 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/filters.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/filters.lib.js @@ -53,7 +53,7 @@ var Filters = { var filterParams = { - query: "+PATH:\"" + parsedArgs.pathNode.qnamePath + "/*\"", + query: "", limitResults: null, sort: [ { @@ -170,21 +170,23 @@ var Filters = break; case "favourites": - var foundOne = false; - for (var favourite in favourites) { - if (foundOne) + if (filterQuery) { filterQuery += " OR "; } - foundOne = true; filterQuery += "ID:\"" + favourite + "\""; } - if (filterQuery.length > 0) + if (filterQuery.length !== 0) { - filterQuery = "+(" + filterQuery + ") " + this.constructPathQuery(parsedArgs); + filterQuery = "+(" + filterQuery + ")"; + // no need to specify path here for all sites - IDs are exact matches + if (parsedArgs.nodeRef != "alfresco://sites/home") + { + filterQuery += ' +PATH:"' + parsedArgs.rootNode.qnamePath + '//*"'; + } } else { @@ -241,12 +243,7 @@ var Filters = var pathQuery = ""; if (parsedArgs.nodeRef != "alfresco://company/home") { - pathQuery = "+PATH:\"" + parsedArgs.rootNode.qnamePath; - if (parsedArgs.nodeRef == "alfresco://sites/home") - { - pathQuery += "/*/cm:documentLibrary"; - } - pathQuery += "//*\""; + pathQuery = '+PATH:"' + parsedArgs.rootNode.qnamePath + '//*"'; } return pathQuery; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.js index 01543e6392..46d4318e8d 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.js @@ -60,14 +60,25 @@ function getDoclist() } // Is our thumbnail type registered? - if (isThumbnailNameRegistered && item.node.isSubType("cm:content") && item.node.properties.content.inputStream != null) + var is = item.node.properties.content.inputStream; + try { - // Make sure we have a thumbnail. - thumbnail = item.node.getThumbnail(THUMBNAIL_NAME); - if (thumbnail === null) + if (isThumbnailNameRegistered && item.node.isSubType("cm:content") && (null != is)) { - // No thumbnail, so queue creation - item.node.createThumbnail(THUMBNAIL_NAME, true); + // Make sure we have a thumbnail. + thumbnail = item.node.getThumbnail(THUMBNAIL_NAME); + if (thumbnail === null) + { + // No thumbnail, so queue creation + item.node.createThumbnail(THUMBNAIL_NAME, true); + } + } + } + finally + { + if (null != is) + { + is.close(); } } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.get.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.get.js index 6612e1a87c..c9c3c9d1cb 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.get.js @@ -9,6 +9,7 @@ function main() term: (args.term !== null) ? args.term : null, tag: (args.tag !== null) ? args.tag : null, query: (args.query !== null) ? args.query : null, + rootNode: (args.rootNode !== null) ? args.rootNode : null, sort: (args.sort !== null) ? args.sort : null, maxResults: (args.maxResults !== null) ? parseInt(args.maxResults, 10) : DEFAULT_MAX_RESULTS }; 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 094d35e5bd..281bd2377a 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 @@ -515,12 +515,21 @@ function getItem(siteId, containerId, pathParts, node) * [1] = container or null if the node does not match * [2] = remaining part of the cm:name based path to the object - as an array */ -function splitQNamePath(node) +function splitQNamePath(node, rootNodeDisplayPath, rootNodeQNamePath) { var path = node.qnamePath, displayPath = node.displayPath.split("/"), parts = null; + // restructure the display path of the node if we have an overriden root node + if (rootNodeDisplayPath != null && path.indexOf(rootNodeQNamePath) === 0) + { + var nodeDisplayPath = node.displayPath.split("/"); + nodeDisplayPath = nodeDisplayPath.splice(rootNodeDisplayPath.length); + nodeDisplayPath.unshift(""); + displayPath = nodeDisplayPath; + } + if (path.match("^"+SITES_SPACE_QNAME_PATH) == SITES_SPACE_QNAME_PATH) { var tmp = path.substring(SITES_SPACE_QNAME_PATH.length), @@ -550,7 +559,7 @@ function splitQNamePath(node) * * @return the final search results object */ -function processResults(nodes, maxResults) +function processResults(nodes, maxResults, rootNode) { // empty cache state processedCache = {}; @@ -559,18 +568,19 @@ function processResults(nodes, maxResults) parts, item, failed = 0, - i, j; + rootNodeDisplayPath = rootNode ? rootNode.displayPath.split("/") : null, + rootNodeQNamePath = rootNode ? rootNode.qnamePath : null; if (logger.isLoggingEnabled()) logger.log("Processing resultset of length: " + nodes.length); - for (i = 0, j = nodes.length; i < j && added < maxResults; i++) + for (var i = 0, j = nodes.length; i < j && added < maxResults; i++) { /** * For each node we extract the site/container qname path and then * let the per-container helper function decide what to do. */ - parts = splitQNamePath(nodes[i]); + parts = splitQNamePath(nodes[i], rootNodeDisplayPath, rootNodeQNamePath); item = getItem(parts[0], parts[1], parts[2], nodes[i]); if (item !== null) { @@ -679,6 +689,28 @@ function processMultiValue(propName, propValue, operand, pseudo) return formQuery; } +function resolveRootNode(reference) +{ + var node; + if (reference == "alfresco://company/home") + { + node = null; + } + else if (reference == "alfresco://user/home") + { + node = userhome; + } + else if (reference == "alfresco://sites/home") + { + node = companyhome.childrenByXPath("st:sites")[0]; + } + else if (reference.indexOf("://") > 0) + { + node = search.findNode(reference); + } + return node; +} + /** * Return Search results with the given search terms. * @@ -693,7 +725,8 @@ function getSearchResults(params) ftsQuery = "", term = params.term, tag = params.tag, - formData = params.query; + formData = params.query, + rootNode = resolveRootNode(params.rootNode); // Simple keyword search and tag specific search if (term !== null && term.length !== 0) @@ -879,12 +912,16 @@ function getSearchResults(params) } } - if (path !== null) + // root node - generally used for overridden Repository root in Share + if (rootNode !== null) { - ftsQuery = 'PATH:"' + path + '/*" AND (' + ftsQuery + ') '; + ftsQuery = 'PATH:"' + rootNode.qnamePath + '//*" AND (' + ftsQuery + ')'; + } + else if (path !== null) + { + ftsQuery = 'PATH:"' + path + '/*" AND (' + ftsQuery + ')'; } ftsQuery = '(' + ftsQuery + ') AND -TYPE:"cm:thumbnail" AND -TYPE:"cm:failedThumbnail" AND -TYPE:"cm:rating"'; - ftsQuery = '(' + ftsQuery + ') AND NOT ASPECT:"sys:hidden"'; // sort field - expecting field to in one of the following formats: @@ -946,7 +983,7 @@ function getSearchResults(params) nodes = []; } - return processResults(nodes, params.maxResults); + return processResults(nodes, params.maxResults, rootNode); } /** diff --git a/source/meta-inf/cxf/org.apache.cxf.Logger b/source/META-INF/cxf/org.apache.cxf.Logger similarity index 100% rename from source/meta-inf/cxf/org.apache.cxf.Logger rename to source/META-INF/cxf/org.apache.cxf.Logger diff --git a/source/meta-inf/services/org.apache.axis.deployment.wsdd.Provider b/source/META-INF/services/org.apache.axis.deployment.wsdd.Provider similarity index 100% rename from source/meta-inf/services/org.apache.axis.deployment.wsdd.Provider rename to source/META-INF/services/org.apache.axis.deployment.wsdd.Provider diff --git a/source/java/org/alfresco/repo/remoteconnector/LocalWebScriptConnectorServiceImpl.java b/source/java/org/alfresco/repo/remoteconnector/LocalWebScriptConnectorServiceImpl.java index 7ed460a5d9..598a33697f 100644 --- a/source/java/org/alfresco/repo/remoteconnector/LocalWebScriptConnectorServiceImpl.java +++ b/source/java/org/alfresco/repo/remoteconnector/LocalWebScriptConnectorServiceImpl.java @@ -28,8 +28,10 @@ import java.util.Map; import net.sf.acegisecurity.Authentication; +import org.alfresco.service.cmr.remoteconnector.RemoteConnectorClientException; import org.alfresco.service.cmr.remoteconnector.RemoteConnectorRequest; import org.alfresco.service.cmr.remoteconnector.RemoteConnectorResponse; +import org.alfresco.service.cmr.remoteconnector.RemoteConnectorServerException; import org.alfresco.service.cmr.remoteconnector.RemoteConnectorService; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.repo.security.authentication.AuthenticationException; @@ -132,7 +134,8 @@ public class LocalWebScriptConnectorServiceImpl implements RemoteConnectorServic /** * Executes the specified request, and return the response */ - public RemoteConnectorResponse executeRequest(RemoteConnectorRequest request) throws IOException, AuthenticationException + public RemoteConnectorResponse executeRequest(RemoteConnectorRequest request) + throws IOException, AuthenticationException, RemoteConnectorClientException, RemoteConnectorServerException { // Convert the request object RemoteConnectorRequestImpl requestImpl = (RemoteConnectorRequestImpl)request; @@ -196,7 +199,7 @@ public class LocalWebScriptConnectorServiceImpl implements RemoteConnectorServic if (logger.isInfoEnabled()) logger.info("Response to request was " + resp.getStatus() + " - " + resp); - // Check the status + // Check the status for specific typed exceptions if (resp.getStatus() == Status.STATUS_UNAUTHORIZED) { throw new AuthenticationException("Not Authorized to access this resource"); @@ -205,7 +208,16 @@ public class LocalWebScriptConnectorServiceImpl implements RemoteConnectorServic { throw new AuthenticationException("Forbidden to access this resource"); } - // TODO Handle others too + + // Check for some general ones + if (resp.getStatus() >= 400 && resp.getStatus() <= 499) + { + throw new RemoteConnectorClientException(resp.getStatus(), "(not available)", null); + } + if (resp.getStatus() >= 500 && resp.getStatus() <= 599) + { + throw new RemoteConnectorServerException(resp.getStatus(), "(not available)"); + } // Convert the response String charset = null; @@ -219,7 +231,8 @@ public class LocalWebScriptConnectorServiceImpl implements RemoteConnectorServic InputStream body = new ByteArrayInputStream(resp.getContentAsByteArray()); Header[] respHeaders = new Header[0]; // TODO Can't easily get the list... - RemoteConnectorResponse response = new RemoteConnectorResponseImpl(request, contentType, charset, respHeaders, body); + RemoteConnectorResponse response = new RemoteConnectorResponseImpl( + request, contentType, charset, resp.getStatus(), respHeaders, body); return response; }