diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/search/personsearch.get.atom.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/search/personsearch.get.atom.ftl index 048a33ef9f..a5084f31ab 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/search/personsearch.get.atom.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/search/personsearch.get.atom.ftl @@ -1,7 +1,7 @@ Alfresco (${server.edition}) - Alfresco Person Search: ${search.searchTerms} + Alfresco Person Search: ${search.searchTerms?xml} ${xmldate(date)} ${absurl(url.context)}/images/logo/AlfrescoLogo16.ico @@ -11,7 +11,7 @@ ${search.totalResults} ${search.startIndex} ${search.itemsPerPage} - + <#if search.startPage > 1> @@ -25,7 +25,7 @@ <#list search.results as row> - <#if row.properties.firstName??>${row.properties.firstName}</#if> <#if row.properties.lastName??>${row.properties.lastName}</#if> + <#if row.properties.firstName??>${row.properties.firstName?xml}</#if> <#if row.properties.lastName??>${row.properties.lastName?xml}</#if> <#if row.assocs["cm:avatar"]?exists> ${absurl(url.context)}${row.assocs["cm:avatar"][0].url} @@ -35,10 +35,10 @@ urn:uuid:${row.id} ${xmldate(row.properties.modified)} - <#if row.properties.jobtitle??>${row.properties.jobtitle}, - <#if row.properties.organization??>${row.properties.organization}, - <#if row.properties.location??>${row.properties.location}, - <#if row.properties.persondescription??>${row.properties.persondescription.content} + <#if row.properties.jobtitle??>${row.properties.jobtitle?xml}, + <#if row.properties.organization??>${row.properties.organization?xml}, + <#if row.properties.location??>${row.properties.location?xml}, + <#if row.properties.persondescription??>${row.properties.persondescription.content?xml} ${row.score} diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/filters.lib.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/filters.lib.js index 556f5ce8a2..3015f119c7 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/filters.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary-v2/filters.lib.js @@ -218,7 +218,8 @@ var Filters = { filterData = filterData.slice(0, -1); } - filterParams.query = "+PATH:\"/cm:generalclassifiable" + Filters.iso9075EncodePath(filterData) + "/member\""; + filterQuery = this.constructPathQuery(parsedArgs); + filterParams.query = filterQuery + " +PATH:\"/cm:generalclassifiable" + Filters.iso9075EncodePath(filterData) + "/member\""; break; case "aspect": 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 da37938e7a..7d40c3b2bd 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 @@ -216,7 +216,8 @@ var Filters = { filterData = filterData.slice(0, -1); } - filterParams.query = "+PATH:\"/cm:generalclassifiable" + Filters.iso9075EncodePath(filterData) + "/member\""; + filterQuery = this.constructPathQuery(parsedArgs); + filterParams.query = filterQuery + " +PATH:\"/cm:generalclassifiable" + Filters.iso9075EncodePath(filterData) + "/member\""; break; default: // "path" diff --git a/source/java/org/alfresco/repo/web/scripts/comment/CommentsApiTest.java b/source/java/org/alfresco/repo/web/scripts/comment/CommentsApiTest.java new file mode 100644 index 0000000000..9defb28657 --- /dev/null +++ b/source/java/org/alfresco/repo/web/scripts/comment/CommentsApiTest.java @@ -0,0 +1,130 @@ +package org.alfresco.repo.web.scripts.comment; + +import java.text.MessageFormat; +import java.util.List; + +import javax.transaction.UserTransaction; + +import org.alfresco.error.AlfrescoRuntimeException; +import org.alfresco.model.ContentModel; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.web.scripts.BaseWebScriptTest; +import org.alfresco.service.cmr.model.FileFolderService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.StoreRef; +import org.alfresco.service.cmr.search.SearchService; +import org.alfresco.service.cmr.version.VersionService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.transaction.TransactionService; +import org.springframework.context.ApplicationContext; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest; +import org.springframework.extensions.webscripts.TestWebScriptServer.Response; + +public class CommentsApiTest extends BaseWebScriptTest +{ + private static final String URL_POST_COMMENT = "api/node/{0}/{1}/{2}/comments"; + + private static final String JSON = "application/json"; + + private FileFolderService fileFolderService; + private TransactionService transactionService; + private SearchService searchService; + private NodeService nodeService; + private NamespaceService namespaceService; + private VersionService versionService; + + private NodeRef rootNodeRef; + private NodeRef nodeRef; + + private UserTransaction txn; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + ApplicationContext appContext = getServer().getApplicationContext(); + + fileFolderService = (FileFolderService)appContext.getBean("fileFolderService"); + transactionService = (TransactionService)appContext.getBean("transactionService"); + searchService = (SearchService)appContext.getBean("SearchService"); + nodeService = (NodeService)appContext.getBean("nodeService"); + namespaceService = (NamespaceService)appContext.getBean("namespaceService"); + versionService = (VersionService)appContext.getBean("versionService"); + + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + + txn = transactionService.getUserTransaction(); + txn.begin(); + + rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); + List results = searchService.selectNodes(rootNodeRef, "/app:company_home", null, namespaceService, false); + if (results.size() == 0) + { + throw new AlfrescoRuntimeException("Can't find /app:company_home"); + } + + NodeRef companyHomeNodeRef = results.get(0); + + results = searchService.selectNodes(rootNodeRef, "/app:company_home/cm:Commenty", null, namespaceService, false); + if (results.size() > 0) + { + fileFolderService.delete(results.get(0)); + } + + nodeRef = fileFolderService.create(companyHomeNodeRef, "Commenty", ContentModel.TYPE_CONTENT).getNodeRef(); + versionService.ensureVersioningEnabled(nodeRef, null); + nodeService.setProperty(nodeRef, ContentModel.PROP_AUTO_VERSION_PROPS, true); + + txn.commit(); + + AuthenticationUtil.clearCurrentSecurityContext(); + } + + /* (non-Javadoc) + * @see junit.framework.TestCase#tearDown() + */ + @Override + protected void tearDown() throws Exception + { + super.tearDown(); + } + + private void addComment(NodeRef nodeRef) throws Exception + { + Response response = null; + + UserTransaction txn = transactionService.getUserTransaction(); + txn.begin(); + + // Not allowed if you're not an admin + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + + StringBuilder body = new StringBuilder("{"); + body.append("'title' : 'Test Title', "); + body.append("'content' : 'Test Comment'"); + body.append("}"); + + response = sendRequest(new PostRequest(MessageFormat.format(URL_POST_COMMENT, new Object[] {nodeRef.getStoreRef().getProtocol(), nodeRef.getStoreRef().getIdentifier(), nodeRef.getId()}), body.toString(), JSON), Status.STATUS_OK); + assertEquals(Status.STATUS_OK, response.getStatus()); + + txn.commit(); + } + + private String getCurrentVersion(NodeRef nodeRef) throws Exception + { + String version = versionService.getCurrentVersion(nodeRef).getVersionLabel(); + return version; + } + + public void testCommentDoesNotVersion() throws Exception + { + AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); + + String versionBefore = getCurrentVersion(nodeRef); + addComment(nodeRef); + String versionAfter = getCurrentVersion(nodeRef); + assertEquals(versionBefore, versionAfter); + } +} diff --git a/source/java/org/alfresco/repo/web/scripts/solr/NodeContentGet.java b/source/java/org/alfresco/repo/web/scripts/solr/NodeContentGet.java index 7799842072..93b855b892 100644 --- a/source/java/org/alfresco/repo/web/scripts/solr/NodeContentGet.java +++ b/source/java/org/alfresco/repo/web/scripts/solr/NodeContentGet.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2011 Alfresco Software Limited. + * Copyright (C) 2005-2012 Alfresco Software Limited. * * This file is part of Alfresco * @@ -151,12 +151,7 @@ public class NodeContentGet extends StreamContent res.setStatus(HttpStatus.SC_NO_CONTENT); return; } - - // Perform transformation catering for mimetype AND encoding - ContentWriter writer = contentService.getTempWriter(); - writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); - writer.setEncoding("UTF-8"); // Expect transformers to produce UTF-8 - + ContentTransformer transformer = contentService.getTransformer(reader.getMimetype(), MimetypeMap.MIMETYPE_TEXT_PLAIN); if(transformer == null) { @@ -164,7 +159,12 @@ public class NodeContentGet extends StreamContent res.setStatus(HttpStatus.SC_NO_CONTENT); return; } - + + // Perform transformation catering for mimetype AND encoding + ContentWriter writer = contentService.getTempWriter(); + writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); + writer.setEncoding("UTF-8"); // Expect transformers to produce UTF-8 + try { long start = System.currentTimeMillis(); diff --git a/source/java/org/alfresco/repo/webdav/PutMethod.java b/source/java/org/alfresco/repo/webdav/PutMethod.java index e70c0187bb..a3d5425a12 100644 --- a/source/java/org/alfresco/repo/webdav/PutMethod.java +++ b/source/java/org/alfresco/repo/webdav/PutMethod.java @@ -219,14 +219,7 @@ public class PutMethod extends WebDAVMethod ContentWriter writer = fileFolderService.getWriter(contentNodeInfo.getNodeRef()); // set content properties - if (m_strContentType != null) - { - writer.setMimetype(m_strContentType); - } - else - { - writer.guessMimetype(contentNodeInfo.getName()); - } + writer.guessMimetype(contentNodeInfo.getName()); writer.guessEncoding(); // Get the input stream from the request data