mirror of
				https://github.com/Alfresco/alfresco-community-repo.git
				synced 2025-10-22 15:12:38 +00:00 
			
		
		
		
	Compare commits
	
		
			46 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 9ee0f4a234 | ||
|  | 8f8743f4b5 | ||
|  | d9489cedc4 | ||
|  | c4e4c43668 | ||
|  | b0fa6b3736 | ||
|  | 4d801ed962 | ||
|  | 138947af7f | ||
|  | 2ba28bae10 | ||
|  | 9ebcd0193a | ||
|  | afbf52413f | ||
|  | ad67088017 | ||
|  | 4c29d23ac0 | ||
|  | ed8b18c576 | ||
|  | c9b49789c7 | ||
|  | d28d4873be | ||
|  | 44d7c2328c | ||
|  | 073338afa7 | ||
|  | 3e53467ac8 | ||
|  | 0d5ffdac2e | ||
|  | ac03eb7642 | ||
|  | 2ff5b7dd0a | ||
|  | b0d7e6dfba | ||
|  | 3304a62a35 | ||
|  | 763591c1a3 | ||
|  | 6de5a507fe | ||
|  | 3990bc9db4 | ||
|  | f2207fe43e | ||
|  | f48db84334 | ||
|  | 98d73b7200 | ||
|  | acd4b1efcb | ||
|  | 4433dd009a | ||
|  | d1a9794ec8 | ||
|  | bf848ff882 | ||
|  | 69ebccfc20 | ||
|  | 600b50fce1 | ||
|  | 37e8586658 | ||
|  | 4b12ed5a51 | ||
|  | e379b7704d | ||
|  | 297be122a6 | ||
|  | ca28024ad8 | ||
|  | cfd3255aa7 | ||
|  | 4e436160cc | ||
|  | bf0ca4ca83 | ||
|  | e23a97960f | ||
|  | 2d2371a792 | ||
|  | 0ea69dd4ef | 
| @@ -157,10 +157,10 @@ jobs: | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -Ddb.name=alfresco -Ddb.url=jdbc:mariadb://localhost:3307/alfresco?useUnicode=yes\&characterEncoding=UTF-8 -Ddb.username=alfresco -Ddb.password=alfresco -Ddb.driver=org.mariadb.jdbc.Driver | ||||
|  | ||||
|     - name: "Repository - MySQL 5.7.23 tests" | ||||
|     - name: "Repository - MySQL 5.7.28 tests" | ||||
|       if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip db\]/ AND type != pull_request) OR commit_message =~ /\[db\]/ | ||||
|       before_script: | ||||
|         - docker run -d -p 3307:3306 -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco  mysql:5.7.23 --transaction-isolation='READ-COMMITTED' --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci | ||||
|         - docker run -d -p 3307:3306 -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco  mysql:5.7.28 --transaction-isolation='READ-COMMITTED' --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci | ||||
|         - docker run -d -p 61616:61616 -p 5672:5672 alfresco/alfresco-activemq:5.16.1 | ||||
|       script: travis_wait 20 mvn -B test -pl repository -Dtest=AllDBTestsTestSuite -Ddb.driver=com.mysql.jdbc.Driver -Ddb.name=alfresco -Ddb.url=jdbc:mysql://localhost:3307/alfresco -Ddb.username=alfresco -Ddb.password=alfresco | ||||
|  | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-community-repo-amps</artifactId> | ||||
|       <version>14.146-SNAPSHOT</version> | ||||
|       <version>16.13</version> | ||||
|    </parent> | ||||
|  | ||||
|    <modules> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-governance-services-community-parent</artifactId> | ||||
|       <version>14.146-SNAPSHOT</version> | ||||
|       <version>16.13</version> | ||||
|    </parent> | ||||
|  | ||||
|    <modules> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-governance-services-automation-community-repo</artifactId> | ||||
|       <version>14.146-SNAPSHOT</version> | ||||
|       <version>16.13</version> | ||||
|    </parent> | ||||
|  | ||||
|    <build> | ||||
|   | ||||
| @@ -318,8 +318,8 @@ public class DeleteRecordTests extends BaseRMRestTest | ||||
|         RecordCategoryChild recFolder = createFolder(recordCategory.getId(), getRandomName("recFolder")); | ||||
|         RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(recFolder.getId()).build(); | ||||
|         Record recordFiled = getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, testFile.getNodeRefWithoutVersion()); | ||||
|         getRestAPIFactory().getRecordsAPI().completeRecord(recordFiled.getId()); | ||||
|         assertStatusCode(CREATED); | ||||
|         completeRecord(recordFiled.getId()); | ||||
|         assertStatusCode(OK); | ||||
|  | ||||
|         STEP("Execute the disposition schedule steps."); | ||||
|         rmRolesAndActionsAPI.executeAction(getAdminUser().getUsername(), getAdminUser().getUsername(), recordFiled.getName(), | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-governance-services-community-parent</artifactId> | ||||
|       <version>14.146-SNAPSHOT</version> | ||||
|       <version>16.13</version> | ||||
|    </parent> | ||||
|  | ||||
|    <modules> | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-governance-services-community-repo-parent</artifactId> | ||||
|       <version>14.146-SNAPSHOT</version> | ||||
|       <version>16.13</version> | ||||
|    </parent> | ||||
|  | ||||
|    <properties> | ||||
|   | ||||
| @@ -4,8 +4,8 @@ | ||||
|  | ||||
| # Version label | ||||
| version.major=7 | ||||
| version.minor=0 | ||||
| version.revision=0 | ||||
| version.minor=2 | ||||
| version.revision=2 | ||||
| version.label= | ||||
|  | ||||
| # Edition label | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-governance-services-community-repo-parent</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <build> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <modules> | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-amps</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <properties> | ||||
|   | ||||
| @@ -176,7 +176,6 @@ public class NodeBrowserScript extends NodeBrowserPost implements Serializable | ||||
| 			{ | ||||
| 				status.setCode(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); | ||||
| 				status.setMessage(e.getMessage()); | ||||
| 				status.setException(e); | ||||
| 				status.setRedirect(true); | ||||
| 			} | ||||
|     		return tmplMap; | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| /* | ||||
|  * Copyright 2005 - 2020 Alfresco Software Limited. | ||||
|  * Copyright 2005 - 2022 Alfresco Software Limited. | ||||
|  * | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of the paid license agreement will prevail. | ||||
| @@ -40,6 +40,7 @@ import org.json.JSONObject; | ||||
| import org.junit.Assert; | ||||
| import org.springframework.extensions.webscripts.TestWebScriptServer; | ||||
| import org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest; | ||||
| import org.springframework.extensions.webscripts.TestWebScriptServer.Response; | ||||
|  | ||||
| import java.io.Serializable; | ||||
| import java.util.ArrayList; | ||||
| @@ -194,13 +195,13 @@ public class SlingshotContentGetTest extends BaseWebScriptTest | ||||
|  | ||||
|         NodeRef rootFolder = createNode(companyHome, "rootFolder", ContentModel.TYPE_FOLDER); | ||||
|  | ||||
|         NodeRef doc1 = createNodeWithTextContent(rootFolder, "doc1", ContentModel.TYPE_CONTENT, "doc1 file content"); | ||||
|         NodeRef doc1 = createNodeWithTextContent(rootFolder, "doc1", ContentModel.TYPE_CONTENT, "doc1 file content", MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|  | ||||
|         NodeRef folderX = createNode(rootFolder, "X", ContentModel.TYPE_FOLDER); | ||||
|         NodeRef folderY = createNode(folderX, "Y", ContentModel.TYPE_FOLDER); | ||||
|         NodeRef folderZ = createNode(folderY, "Z", ContentModel.TYPE_FOLDER); | ||||
|  | ||||
|         NodeRef doc2 = createNodeWithTextContent(folderZ, "doc2", ContentModel.TYPE_CONTENT, "doc2 file content"); | ||||
|         NodeRef doc2 = createNodeWithTextContent(folderZ, "doc2", ContentModel.TYPE_CONTENT, "doc2 file content", MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|  | ||||
|         // uri with relative path at the end | ||||
|         String uri = URL_CONTENT_DOWNLOAD + doc1.getId() + "/X/Y/Z/doc2"; | ||||
| @@ -212,7 +213,50 @@ public class SlingshotContentGetTest extends BaseWebScriptTest | ||||
|         nodeService.deleteNode(rootFolder); | ||||
|     } | ||||
|  | ||||
|     public NodeRef createNodeWithTextContent(NodeRef parentNode, String nodeCmName, QName nodeType, String content) | ||||
|     public void testForcedAttachment() throws Exception | ||||
|     { | ||||
|         Repository repositoryHelper = (Repository) getServer().getApplicationContext().getBean("repositoryHelper"); | ||||
|         NodeRef companyHome = repositoryHelper.getCompanyHome(); | ||||
|  | ||||
|         NodeRef rootFolder = createNode(companyHome, "rootFolder", ContentModel.TYPE_FOLDER); | ||||
|         NodeRef testhtml = createNodeWithTextContent(rootFolder, "testhtml", ContentModel.TYPE_CONTENT, "testhtml content", MimetypeMap.MIMETYPE_HTML); | ||||
|         NodeRef testpdf = createNodeWithTextContent(rootFolder, "testpdf", ContentModel.TYPE_CONTENT, "testpdf content", MimetypeMap.MIMETYPE_PDF); | ||||
|  | ||||
|         String uri = URL_CONTENT_DOWNLOAD + testhtml.getId() + "?a=false"; | ||||
|         GetRequest req = new GetRequest(uri); | ||||
|         Response res = sendRequest(req, 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testhtml.getId(); | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testhtml.getId() + "?a=true"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId() + "?a=false"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertNull(res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId(); | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertNull(res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId() + "?a=true"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         nodeService.deleteNode(rootFolder); | ||||
|     } | ||||
|  | ||||
|     public NodeRef createNodeWithTextContent(NodeRef parentNode, String nodeCmName, QName nodeType, String content, String mimetype) | ||||
|     { | ||||
|         NodeRef nodeRef = createNode(parentNode, nodeCmName, nodeType); | ||||
|  | ||||
| @@ -220,7 +264,7 @@ public class SlingshotContentGetTest extends BaseWebScriptTest | ||||
|         if (content != null) | ||||
|         { | ||||
|             ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); | ||||
|             writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|             writer.setMimetype(mimetype); | ||||
|             writer.setEncoding("UTF-8"); | ||||
|             writer.putContent(content); | ||||
|         } | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|    <parent> | ||||
|       <groupId>org.alfresco</groupId> | ||||
|       <artifactId>alfresco-community-repo</artifactId> | ||||
|       <version>14.146-SNAPSHOT</version> | ||||
|       <version>16.13</version> | ||||
|    </parent> | ||||
|  | ||||
|    <dependencies> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <properties> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <dependencies> | ||||
|   | ||||
| @@ -9,6 +9,6 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
| </project> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <properties> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <modules> | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <modules> | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
|   | ||||
| @@ -16,7 +16,7 @@ import org.testng.annotations.Test; | ||||
|  */ | ||||
| public class GetProcessSanityTests extends RestTest | ||||
| { | ||||
|     private UserModel userWhoStartsProcess, assignee; | ||||
|     private UserModel userWhoStartsProcess, assignee, user; | ||||
|     private RestProcessModel addedProcess, process; | ||||
|  | ||||
|     @BeforeClass(alwaysRun = true) | ||||
| @@ -24,6 +24,7 @@ public class GetProcessSanityTests extends RestTest | ||||
|     { | ||||
|         userWhoStartsProcess = dataUser.createRandomTestUser(); | ||||
|         assignee = dataUser.createRandomTestUser(); | ||||
|         user = dataUser.createRandomTestUser(); | ||||
|         addedProcess = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.High); | ||||
|     } | ||||
|  | ||||
| @@ -59,4 +60,13 @@ public class GetProcessSanityTests extends RestTest | ||||
|         process.assertThat().field("id").is(addedProcess.getId()) | ||||
|                 .and().field("startUserId").is(addedProcess.getStartUserId()); | ||||
|     } | ||||
|  | ||||
|     @TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.SANITY, | ||||
|             description = "Verify User that is not involved in a process cannot get that process using REST API and status code is FORBIDDEN (403)") | ||||
|     @Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.SANITY }) | ||||
|     public void shouldNotGetProcessesByNotInvolvedUser() throws Exception | ||||
|     { | ||||
|         process = restClient.authenticateUser(user).withWorkflowAPI().usingProcess(addedProcess).getProcess(); | ||||
|         restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-tests</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <developers> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo-packaging</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <properties> | ||||
|   | ||||
							
								
								
									
										18
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								pom.xml
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ | ||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||
|     <modelVersion>4.0.0</modelVersion> | ||||
|     <artifactId>alfresco-community-repo</artifactId> | ||||
|     <version>14.146-SNAPSHOT</version>  | ||||
|     <version>16.13</version> | ||||
|     <packaging>pom</packaging> | ||||
|     <name>Alfresco Community Repo Parent</name> | ||||
|  | ||||
| @@ -25,7 +25,7 @@ | ||||
|     <properties> | ||||
|         <acs.version.major>7</acs.version.major> | ||||
|         <acs.version.minor>2</acs.version.minor> | ||||
|         <acs.version.revision>0</acs.version.revision> | ||||
|         <acs.version.revision>2</acs.version.revision> | ||||
|         <acs.version.label /> | ||||
|         <amp.min.version>${acs.version.major}.0.0</amp.min.version> | ||||
|  | ||||
| @@ -55,19 +55,19 @@ | ||||
|         <dependency.alfresco-greenmail.version>6.2</dependency.alfresco-greenmail.version> | ||||
|         <dependency.acs-event-model.version>0.0.13</dependency.acs-event-model.version> | ||||
|  | ||||
|         <dependency.spring.version>5.3.15</dependency.spring.version> | ||||
|         <dependency.spring.version>5.3.18</dependency.spring.version> | ||||
|         <dependency.antlr.version>3.5.2</dependency.antlr.version> | ||||
|         <dependency.jackson.version>2.13.1</dependency.jackson.version> | ||||
|         <dependency.jackson-databind.version>2.13.1</dependency.jackson-databind.version> | ||||
|         <dependency.jackson.version>2.13.3</dependency.jackson.version> | ||||
|         <dependency.jackson-databind.version>2.13.3</dependency.jackson-databind.version> | ||||
|         <dependency.cxf.version>3.5.0</dependency.cxf.version> | ||||
|         <dependency.opencmis.version>1.0.0</dependency.opencmis.version> | ||||
|         <dependency.webscripts.version>8.28</dependency.webscripts.version> | ||||
|         <dependency.webscripts.version>8.31</dependency.webscripts.version> | ||||
|         <dependency.bouncycastle.version>1.70</dependency.bouncycastle.version> | ||||
|         <dependency.mockito-core.version>3.11.2</dependency.mockito-core.version> | ||||
|         <dependency.org-json.version>20211205</dependency.org-json.version> | ||||
|         <dependency.commons-dbcp.version>2.9.0</dependency.commons-dbcp.version> | ||||
|         <dependency.commons-io.version>2.11.0</dependency.commons-io.version> | ||||
|         <dependency.gson.version>2.8.5</dependency.gson.version> | ||||
|         <dependency.gson.version>2.8.9</dependency.gson.version> | ||||
|         <dependency.httpclient.version>4.5.13</dependency.httpclient.version> | ||||
|         <dependency.httpcore.version>4.4.15</dependency.httpcore.version> | ||||
|         <dependency.commons-httpclient.version>3.1-HTTPCLIENT-1265</dependency.commons-httpclient.version> | ||||
| @@ -107,7 +107,7 @@ | ||||
|  | ||||
|         <alfresco.googledrive.version>3.2.1.3</alfresco.googledrive.version> | ||||
|         <alfresco.aos-module.version>1.4.1</alfresco.aos-module.version>  | ||||
|         <alfresco.api-explorer.version>7.2.0</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share --> | ||||
|         <alfresco.api-explorer.version>7.2.1</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share --> | ||||
|  | ||||
|         <alfresco.maven-plugin.version>2.2.0</alfresco.maven-plugin.version> | ||||
|         <license-maven-plugin.version>2.0.1.alfresco-2</license-maven-plugin.version> | ||||
| @@ -146,7 +146,7 @@ | ||||
|         <connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection> | ||||
|         <developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection> | ||||
|         <url>https://github.com/Alfresco/alfresco-community-repo</url> | ||||
|         <tag>HEAD</tag> | ||||
|         <tag>16.13</tag> | ||||
|     </scm> | ||||
|  | ||||
|     <distributionManagement> | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <dependencies> | ||||
|   | ||||
| @@ -0,0 +1,64 @@ | ||||
| /* | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software. | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of | ||||
|  * the paid license agreement will prevail.  Otherwise, the software is | ||||
|  * provided under the following open source license terms: | ||||
|  * | ||||
|  * Alfresco is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU Lesser General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * Alfresco is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU Lesser General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU Lesser General Public License | ||||
|  * along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | ||||
|  * #L% | ||||
|  */ | ||||
| package org.alfresco.repo.web.scripts; | ||||
|  | ||||
| import org.alfresco.repo.content.MimetypeMap; | ||||
| import org.alfresco.service.cmr.repository.ContentReader; | ||||
| import org.alfresco.service.cmr.repository.MimetypeService; | ||||
| import org.springframework.extensions.webscripts.WebScriptRequest; | ||||
|  | ||||
| public class MimeTypeUtil | ||||
| { | ||||
|  | ||||
|     /** | ||||
|      * Get the file mimetype from the file ContentReader, and if its null then set the mimetype to binary by default | ||||
|      * and try to get the correct one from file extension | ||||
|      * | ||||
|      * | ||||
|      * @param reader            reader of the file in the request | ||||
|      * @param req               request relating to the file | ||||
|      * @param mimetypeService   MimetypeService | ||||
|      * | ||||
|      * @return  mimetype of the file as a string | ||||
|      */ | ||||
|     public static String determineMimetype(ContentReader reader, WebScriptRequest req, MimetypeService mimetypeService) | ||||
|     { | ||||
|         String mimetype = reader.getMimetype(); | ||||
|         if (mimetype == null || mimetype.length() == 0) | ||||
|         { | ||||
|             String extensionPath = req.getExtensionPath(); | ||||
|             mimetype = MimetypeMap.MIMETYPE_BINARY; | ||||
|             int extIndex = extensionPath.lastIndexOf('.'); | ||||
|             if (extIndex != -1) | ||||
|             { | ||||
|                 String ext = extensionPath.substring(extIndex + 1); | ||||
|                 mimetype = mimetypeService.getMimetype(ext); | ||||
|             } | ||||
|         } | ||||
|         return mimetype; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -2,7 +2,7 @@ | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
| @@ -26,14 +26,18 @@ | ||||
| package org.alfresco.repo.web.scripts.content; | ||||
|  | ||||
| import java.io.IOException; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import javax.servlet.ServletContext; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
|  | ||||
| import org.alfresco.model.ContentModel; | ||||
| import org.alfresco.repo.web.scripts.MimeTypeUtil; | ||||
| import org.alfresco.service.cmr.dictionary.DictionaryService; | ||||
| import org.alfresco.service.cmr.repository.ContentReader; | ||||
| import org.alfresco.service.cmr.repository.ContentService; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.namespace.NamespaceService; | ||||
| @@ -65,6 +69,19 @@ public class ContentGet extends StreamContent implements ServletContextAware | ||||
|     private NamespaceService namespaceService; | ||||
|     private ContentService contentService; | ||||
|  | ||||
|     private List<String> nonAttachContentTypes = Collections.emptyList(); | ||||
|  | ||||
|     /** | ||||
|      * @param nonAttachContentTypes List<String> | ||||
|      */ | ||||
|     public void setNonAttachContentTypes(List<String> nonAttachContentTypes) | ||||
|     { | ||||
|         if (nonAttachContentTypes != null && !nonAttachContentTypes.isEmpty()) | ||||
|         { | ||||
|             this.nonAttachContentTypes = nonAttachContentTypes; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param servletContext ServletContext | ||||
|      */ | ||||
| @@ -122,8 +139,6 @@ public class ContentGet extends StreamContent implements ServletContextAware | ||||
|             throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString()); | ||||
|         } | ||||
|  | ||||
|         // determine attachment | ||||
|         boolean attach = Boolean.valueOf(req.getParameter("a")); | ||||
|          | ||||
|         // render content | ||||
|         QName propertyQName = ContentModel.PROP_CONTENT; | ||||
| @@ -140,6 +155,19 @@ public class ContentGet extends StreamContent implements ServletContextAware | ||||
|                 propertyQName = QName.createQName(propertyName, namespaceService); | ||||
|             } | ||||
|         } | ||||
|         // determine attachment and force download for specific mimetypes - see PRODSEC-5862 | ||||
|         boolean attach = Boolean.valueOf(req.getParameter("a")); | ||||
|         ContentReader reader = contentService.getReader(nodeRef, propertyQName); | ||||
|         String mimetype = MimeTypeUtil.determineMimetype(reader, req, mimetypeService); | ||||
|  | ||||
|         if (!attach) | ||||
|         { | ||||
|             if (nonAttachContentTypes == null || !nonAttachContentTypes.contains(mimetype)) | ||||
|             { | ||||
|                 attach = true; | ||||
|                 logger.warn("Ignored a=false for " + nodeRef.getId() + " since " + mimetype + " is not in the whitelist for non-attach content types"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // Stream the content | ||||
|         streamContentLocal(req, res, nodeRef, attach, propertyQName, null); | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
| @@ -33,7 +33,7 @@ import java.util.Map; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
|  | ||||
| import org.alfresco.model.ContentModel; | ||||
| import org.alfresco.repo.content.MimetypeMap; | ||||
| import org.alfresco.repo.web.scripts.MimeTypeUtil; | ||||
| import org.alfresco.service.cmr.repository.ContentReader; | ||||
| import org.alfresco.service.cmr.repository.NodeRef; | ||||
| import org.alfresco.service.namespace.QName; | ||||
| @@ -79,18 +79,7 @@ public class ContentInfo extends StreamContent | ||||
|         delegate.setAttachment(req, res, attach, attachFileName); | ||||
|  | ||||
|         // establish mimetype | ||||
|         String mimetype = reader.getMimetype(); | ||||
|         String extensionPath = req.getExtensionPath(); | ||||
|         if (mimetype == null || mimetype.length() == 0) | ||||
|         { | ||||
|             mimetype = MimetypeMap.MIMETYPE_BINARY; | ||||
|             int extIndex = extensionPath.lastIndexOf('.'); | ||||
|             if (extIndex != -1) | ||||
|             { | ||||
|                 String ext = extensionPath.substring(extIndex + 1); | ||||
|                 mimetype = mimetypeService.getMimetype(ext); | ||||
|             } | ||||
|         } | ||||
|         String mimetype = MimeTypeUtil.determineMimetype(reader, req, mimetypeService); | ||||
|  | ||||
|         // set mimetype for the content and the character encoding + length for the stream | ||||
|         res.setContentType(mimetype); | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
| @@ -43,6 +43,7 @@ import javax.servlet.http.HttpServletResponse; | ||||
| import org.alfresco.model.ContentModel; | ||||
| import org.alfresco.repo.content.MimetypeMap; | ||||
| import org.alfresco.repo.content.filestore.FileContentReader; | ||||
| import org.alfresco.repo.web.scripts.MimeTypeUtil; | ||||
| import org.alfresco.sync.repo.events.EventPublisher; | ||||
| import org.alfresco.repo.web.util.HttpRangeProcessor; | ||||
| import org.alfresco.rest.framework.resource.content.CacheDirective; | ||||
| @@ -361,18 +362,7 @@ public class ContentStreamer implements ResourceLoaderAware | ||||
|         setAttachment(req, res, attach, attachFileName); | ||||
|      | ||||
|         // establish mimetype | ||||
|         String mimetype = reader.getMimetype(); | ||||
|         String extensionPath = req.getExtensionPath(); | ||||
|         if (mimetype == null || mimetype.length() == 0) | ||||
|         { | ||||
|             mimetype = MimetypeMap.MIMETYPE_BINARY; | ||||
|             int extIndex = extensionPath.lastIndexOf('.'); | ||||
|             if (extIndex != -1) | ||||
|             { | ||||
|                 String ext = extensionPath.substring(extIndex + 1); | ||||
|                 mimetype = mimetypeService.getMimetype(ext); | ||||
|             } | ||||
|         } | ||||
|         String mimetype = MimeTypeUtil.determineMimetype(reader, req, mimetypeService); | ||||
|          | ||||
|         res.setHeader(HEADER_ACCEPT_RANGES, "bytes"); | ||||
|         try | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2021 Alfresco Software Limited | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
| @@ -713,6 +713,7 @@ public class CustomModelsImpl implements CustomModels | ||||
|         try | ||||
|         { | ||||
|             NodeRef nodeRef = customModelService.createDownloadNode(modelName, withForm); | ||||
|             nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, modelName + DownloadsImpl.DEFAULT_ARCHIVE_EXTENSION); | ||||
|             return new CustomModelDownload(nodeRef); | ||||
|         } | ||||
|         catch (Exception ex) | ||||
|   | ||||
| @@ -512,6 +512,8 @@ public class ProcessesImpl extends WorkflowRestImpl implements Processes | ||||
|             throw new InvalidArgumentException("processId is required to get the process info"); | ||||
|         } | ||||
|  | ||||
|         validateIfUserAllowedToWorkWithProcess(processId); | ||||
|  | ||||
|         HistoricProcessInstance processInstance = activitiProcessEngine | ||||
|                 .getHistoryService() | ||||
|                 .createHistoricProcessInstanceQuery() | ||||
|   | ||||
| @@ -3,6 +3,7 @@ function main() | ||||
|  | ||||
| // Get the args | ||||
| var filter = args["filter"]; | ||||
| if (filter!==null && !filter.includes(":")) {filter += " [hint:useCQ]";} | ||||
| var maxResults = args["maxResults"]; | ||||
| var skipCountStr = args["skipCount"]; | ||||
| var skipCount = skipCountStr != null ? parseInt(skipCountStr) : -1; | ||||
|   | ||||
| @@ -3,7 +3,7 @@ function main() | ||||
|    // Get the args | ||||
|    var siteShortName = url.templateArgs.shortname, | ||||
|       site = siteService.getSite(siteShortName), | ||||
|       filter = (args.filter != null) ? args.filter : (args.shortNameFilter != null) ? args.shortNameFilter : "", | ||||
|       filter = ((args.filter != null) ? args.filter : (args.shortNameFilter != null) ? args.shortNameFilter : "" )+ " [hint:useCQ]", | ||||
|       maxResults = (args.maxResults == null) ? 10 : parseInt(args.maxResults, 10), | ||||
|       authorityType = args.authorityType, | ||||
|       zone = args.zone, | ||||
|   | ||||
| @@ -249,6 +249,7 @@ | ||||
|       <property name="delegate" ref="webscript.content.streamer" /> | ||||
|       <property name="contentService" ref="contentService" /> | ||||
|       <property name="repository" ref="repositoryHelper" /> | ||||
|       <property name="nonAttachContentTypes" value="#{T(java.util.Arrays).asList('${content.nonAttach.mimetypes}')}" /> | ||||
|    </bean> | ||||
|     | ||||
|    <!--  Content Info --> | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  * #%L | ||||
|  * Alfresco Share Services AMP | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
| @@ -66,13 +66,17 @@ public class ContentGetTest extends BaseWebScriptTest | ||||
|     { | ||||
|         super.setUp(); | ||||
|  | ||||
|         this.authenticationService = (MutableAuthenticationService) getServer().getApplicationContext() | ||||
|                 .getBean("AuthenticationService"); | ||||
|         this.authenticationService = (MutableAuthenticationService)getServer().getApplicationContext().getBean("AuthenticationService"); | ||||
|         this.personService = (PersonService) getServer().getApplicationContext().getBean("PersonService"); | ||||
|         this.nodeService = (NodeService) getServer().getApplicationContext().getBean("NodeService"); | ||||
|         this.contentService = (ContentService) getServer().getApplicationContext().getBean("ContentService"); | ||||
|         AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); | ||||
|         createUser(USER_ONE); | ||||
|  | ||||
|         Repository repositoryHelper = (Repository) getServer().getApplicationContext().getBean("repositoryHelper"); | ||||
|         NodeRef companyHome = repositoryHelper.getCompanyHome(); | ||||
|  | ||||
|         rootFolder = createNode(companyHome, "rootFolder", ContentModel.TYPE_FOLDER); | ||||
|     } | ||||
|  | ||||
|     private void createUser(String userName) | ||||
| @@ -117,18 +121,13 @@ public class ContentGetTest extends BaseWebScriptTest | ||||
|      */ | ||||
|     public void testRelativePath() throws Exception | ||||
|     { | ||||
|         Repository repositoryHelper = (Repository) getServer().getApplicationContext().getBean("repositoryHelper"); | ||||
|         NodeRef companyHome = repositoryHelper.getCompanyHome(); | ||||
|  | ||||
|         rootFolder = createNode(companyHome, "rootFolder", ContentModel.TYPE_FOLDER); | ||||
|  | ||||
|         NodeRef doc1 = createNodeWithTextContent(rootFolder, "doc1", ContentModel.TYPE_CONTENT, "doc1 file content"); | ||||
|         NodeRef doc1 = createNodeWithTextContent(rootFolder, "doc1", ContentModel.TYPE_CONTENT, "doc1 file content", MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|  | ||||
|         NodeRef folderX = createNode(rootFolder, "X", ContentModel.TYPE_FOLDER); | ||||
|         NodeRef folderY = createNode(folderX, "Y", ContentModel.TYPE_FOLDER); | ||||
|         NodeRef folderZ = createNode(folderY, "Z", ContentModel.TYPE_FOLDER); | ||||
|  | ||||
|         NodeRef doc2 = createNodeWithTextContent(folderZ, "doc2", ContentModel.TYPE_CONTENT, "doc2 file content"); | ||||
|         NodeRef doc2 = createNodeWithTextContent(folderZ, "doc2", ContentModel.TYPE_CONTENT, "doc2 file content", MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|  | ||||
|         // uri with relative path at the end | ||||
|         String uri = URL_CONTENT_DOWNLOAD + doc1.getId() + "/X/Y/Z/doc2"; | ||||
| @@ -138,7 +137,46 @@ public class ContentGetTest extends BaseWebScriptTest | ||||
|         Assert.assertEquals("doc2 file content", resp.getContentAsString()); | ||||
|     } | ||||
|  | ||||
|     public NodeRef createNodeWithTextContent(NodeRef parentNode, String nodeCmName, QName nodeType, String content) | ||||
|  | ||||
|  | ||||
|     public void testForcedAttachment() throws Exception | ||||
|     { | ||||
|         NodeRef testhtml = createNodeWithTextContent(rootFolder, "testhtml", ContentModel.TYPE_CONTENT, "testhtml content", MimetypeMap.MIMETYPE_HTML); | ||||
|         NodeRef testpdf = createNodeWithTextContent(rootFolder, "testpdf", ContentModel.TYPE_CONTENT, "testpdf content", MimetypeMap.MIMETYPE_PDF); | ||||
|  | ||||
|         String uri = URL_CONTENT_DOWNLOAD + testhtml.getId() + "?a=false"; | ||||
|         GetRequest req = new GetRequest(uri); | ||||
|         Response res = sendRequest(req, 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testhtml.getId(); | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testhtml.getId() + "?a=true"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_HTML + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId() + "?a=false"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertNull(res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId(); | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertNull(res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|  | ||||
|         uri = URL_CONTENT_DOWNLOAD + testpdf.getId() + "?a=true"; | ||||
|         res = sendRequest(new GetRequest(uri), 200); | ||||
|         assertEquals("attachment", res.getHeader("Content-Disposition")); | ||||
|         assertEquals(MimetypeMap.MIMETYPE_PDF + ";charset=UTF-8", res.getContentType()); | ||||
|     } | ||||
|  | ||||
|     public NodeRef createNodeWithTextContent(NodeRef parentNode, String nodeCmName, QName nodeType, String content, String mimetype) | ||||
|     { | ||||
|         NodeRef nodeRef = createNode(parentNode, nodeCmName, nodeType); | ||||
|  | ||||
| @@ -146,7 +184,7 @@ public class ContentGetTest extends BaseWebScriptTest | ||||
|         if (content != null) | ||||
|         { | ||||
|             ContentWriter writer = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true); | ||||
|             writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN); | ||||
|             writer.setMimetype(mimetype); | ||||
|             writer.setEncoding("UTF-8"); | ||||
|             writer.putContent(content); | ||||
|         } | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  * #%L | ||||
|  * Alfresco Remote API | ||||
|  * %% | ||||
|  * Copyright (C) 2005 - 2016 Alfresco Software Limited | ||||
|  * Copyright (C) 2005 - 2022 Alfresco Software Limited | ||||
|  * %% | ||||
|  * This file is part of the Alfresco software.  | ||||
|  * If the software was purchased under a paid Alfresco license, the terms of  | ||||
| @@ -52,7 +52,6 @@ import org.alfresco.service.namespace.QName; | ||||
| import org.alfresco.service.transaction.TransactionService; | ||||
| import org.alfresco.util.GUID; | ||||
| import org.alfresco.util.PropertyMap; | ||||
| import org.alfresco.util.testing.category.LuceneTests; | ||||
| import org.apache.commons.lang3.RandomStringUtils; | ||||
| import org.json.JSONArray; | ||||
| import org.json.JSONObject; | ||||
| @@ -86,7 +85,6 @@ import static org.mockito.Mockito.when; | ||||
|  *  | ||||
|  * @author Glen Johnson | ||||
|  */ | ||||
| @Category(LuceneTests.class) | ||||
| public class PersonServiceTest extends BaseWebScriptTest | ||||
| {     | ||||
|     private MutableAuthenticationService authenticationService; | ||||
| @@ -340,7 +338,7 @@ public class PersonServiceTest extends BaseWebScriptTest | ||||
|  | ||||
|         // Ensure that the REST call with no filter will always be routed to a DB canned query rather than a FTS | ||||
|         // (see ALF-18876 for details) | ||||
|         String filter = "*%20[hint:useCQ]"; | ||||
|         String filter = "*"; | ||||
|  | ||||
|         Response response = sendRequest(new GetRequest(URL_PEOPLE + "?filter=" + filter), 200); | ||||
|         JSONObject res = new JSONObject(response.getContentAsString()); | ||||
| @@ -386,7 +384,6 @@ public class PersonServiceTest extends BaseWebScriptTest | ||||
|                         "&startIndex=" + 0 + | ||||
|                         "&pageSize=" + 6 | ||||
|                 ), Status.STATUS_OK); | ||||
|         assertSearchQuery(filter, true); | ||||
|         JSONObject res = new JSONObject(response.getContentAsString()); | ||||
|         JSONArray peopleAsc = res.getJSONArray("people"); | ||||
|         assertEquals("The number of returned results is not correct.", 6, peopleAsc.length()); | ||||
| @@ -398,7 +395,6 @@ public class PersonServiceTest extends BaseWebScriptTest | ||||
|                         "&startIndex=" + 0 + | ||||
|                         "&pageSize=" + 2 | ||||
|                 ), Status.STATUS_OK); | ||||
|         assertSearchQuery(filter, true); | ||||
|         res = new JSONObject(response.getContentAsString()); | ||||
|         peopleAsc = res.getJSONArray("people"); | ||||
|         assertEquals("The number of returned results is not correct.", 2, peopleAsc.length()); | ||||
| @@ -416,7 +412,6 @@ public class PersonServiceTest extends BaseWebScriptTest | ||||
|                         "&startIndex=" + 2 + | ||||
|                         "&pageSize=" + 2 | ||||
|                 ), Status.STATUS_OK); | ||||
|         assertSearchQuery(filter, true); | ||||
|         res = new JSONObject(response.getContentAsString()); | ||||
|         peopleAsc = res.getJSONArray("people"); | ||||
|         assertEquals("The number of returned results is not correct.", 2, peopleAsc.length()); | ||||
| @@ -434,7 +429,6 @@ public class PersonServiceTest extends BaseWebScriptTest | ||||
|                         "&startIndex=" + 4 + | ||||
|                         "&pageSize=" + 2 | ||||
|                 ), Status.STATUS_OK); | ||||
|         assertSearchQuery(filter, true); | ||||
|         res = new JSONObject(response.getContentAsString()); | ||||
|         peopleAsc = res.getJSONArray("people"); | ||||
|         assertEquals("The number of returned results is not correct.", 2, peopleAsc.length()); | ||||
| @@ -452,7 +446,6 @@ public class PersonServiceTest extends BaseWebScriptTest | ||||
|                         "&startIndex=" + 3 + | ||||
|                         "&pageSize=" + 5 | ||||
|                 ), Status.STATUS_OK); | ||||
|         assertSearchQuery(filter, true); | ||||
|         res = new JSONObject(response.getContentAsString()); | ||||
|         peopleAsc = res.getJSONArray("people"); | ||||
|         assertEquals("The number of returned results is not correct.", 3, peopleAsc.length()); | ||||
| @@ -476,6 +469,7 @@ public class PersonServiceTest extends BaseWebScriptTest | ||||
|     public void testGetPeopleSorting() throws Exception | ||||
|     { | ||||
|         String filter = GUID.generate(); | ||||
|         String filterByJob = "jobtitle:job"; | ||||
|         String usernameA = filter + "-aaa-"; | ||||
|         String usernameB = filter + "-BBB-"; | ||||
|         String usernameC = filter + "-ccc-"; | ||||
| @@ -496,12 +490,17 @@ public class PersonServiceTest extends BaseWebScriptTest | ||||
|         addUserUsageContent(usernameD, 50); | ||||
|         userUsageTrackingComponent.execute(); | ||||
|  | ||||
|         //check sorting for CQ | ||||
|         checkSorting(filter, SORT_BY_USERNAME, usernameA, usernameB, usernameC, usernameD); | ||||
|         checkSorting(filter, SORT_BY_FULLNAME, usernameA, usernameB, usernameC, usernameD); | ||||
|         checkSorting(filter, SORT_BY_JOBTITLE, usernameA, usernameB, usernameC, usernameD); | ||||
|         checkSorting(filter, SORT_BY_EMAIL, usernameA, usernameB, usernameC, usernameD); | ||||
|         checkSorting(filter, SORT_BY_QUOTA, usernameA, usernameB, usernameC, usernameD); | ||||
|         checkSorting(filter, SORT_BY_USAGE, usernameA, usernameB, usernameC, usernameD); | ||||
|  | ||||
|         //since CQ search only sorts by fullname and username test the other sorts by filtering for a job which bypasses CQ (MNT 22905) | ||||
|         checkSorting(filterByJob, SORT_BY_USERNAME, usernameA, usernameB, usernameC, usernameD); | ||||
|         checkSorting(filterByJob, SORT_BY_FULLNAME, usernameA, usernameB, usernameC, usernameD); | ||||
|         checkSorting(filterByJob, SORT_BY_JOBTITLE, usernameA, usernameB, usernameC, usernameD); | ||||
|         checkSorting(filterByJob, SORT_BY_EMAIL, usernameA, usernameB, usernameC, usernameD); | ||||
|         checkSorting(filterByJob, SORT_BY_QUOTA, usernameA, usernameB, usernameC, usernameD); | ||||
|         checkSorting(filterByJob, SORT_BY_USAGE, usernameA, usernameB, usernameC, usernameD); | ||||
|     } | ||||
|  | ||||
|     private void checkSorting(String filter, String sortBy, String... usernames) throws Exception | ||||
| @@ -519,7 +518,6 @@ public class PersonServiceTest extends BaseWebScriptTest | ||||
|                         "&filter=" + filter + | ||||
|                         "&dir=" + ASC_DIR | ||||
|                 ), Status.STATUS_OK); | ||||
|         assertSearchQuery(filter, true); | ||||
|         JSONObject res = new JSONObject(response.getContentAsString()); | ||||
|         JSONArray peopleAsc = res.getJSONArray("people"); | ||||
|         assertEquals(usernames.length, peopleAsc.length()); | ||||
| @@ -530,7 +528,6 @@ public class PersonServiceTest extends BaseWebScriptTest | ||||
|                         "&filter=" + filter + | ||||
|                         "&dir=" + DESC_DIR | ||||
|                 ), Status.STATUS_OK); | ||||
|         assertSearchQuery(filter, true); | ||||
|         res = new JSONObject(response.getContentAsString()); | ||||
|         JSONArray peopleDesc = res.getJSONArray("people"); | ||||
|         assertEquals(usernames.length, peopleDesc.length()); | ||||
| @@ -541,7 +538,11 @@ public class PersonServiceTest extends BaseWebScriptTest | ||||
|             assertEquals(peopleAsc.getJSONObject(i).getString("userName"), | ||||
|                     peopleDesc.getJSONObject(peopleAsc.length() - i - 1).getString("userName")); | ||||
|         } | ||||
|         assertCorrectSort(sortBy, peopleAsc); | ||||
|     } | ||||
|  | ||||
|     private void assertCorrectSort(String sortBy, JSONArray peopleAsc) | ||||
|     { | ||||
|         // Check Asc sorting for each field | ||||
|         for (int i = 0; i < peopleAsc.length() - 1; i++) | ||||
|         { | ||||
| @@ -766,6 +767,51 @@ public class PersonServiceTest extends BaseWebScriptTest | ||||
|                         "myJobTitle", "firstName.lastName@email.com", "myBio", "images/avatar.jpg", 0, | ||||
|                         Status.STATUS_BAD_REQUEST);         | ||||
|     } | ||||
|  | ||||
|     public void testUserNameCaseSensitivityCQ() throws Exception | ||||
|     { | ||||
|         String upperCaseUserName = "PersonServiceTest.MixedCaseUser"; | ||||
|         String lowerCaseUserName = upperCaseUserName.toLowerCase(); | ||||
|         // Create a new person | ||||
|  | ||||
|         String currentUser = this.authenticationComponent.getCurrentUserName(); | ||||
|         try | ||||
|         { | ||||
|             /** | ||||
|              *  simulate cloud with lower case user names | ||||
|              */ | ||||
|             createPerson(lowerCaseUserName, "myTitle", "myFirstName", "myLastName", "myOrganisation", | ||||
|                     "myJobTitle", "firstName.lastName@email.com", "myBio", "images/avatar.jpg", 0, | ||||
|                     Status.STATUS_OK); | ||||
|  | ||||
|             String adminUser = this.authenticationComponent.getSystemUserName(); | ||||
|             this.authenticationComponent.setCurrentUser(adminUser); | ||||
|             personService.setCreateMissingPeople(false); | ||||
|  | ||||
|             //try with canned query | ||||
|             String filter = "PerSOnSerVIceTest.MixEDCasEUseR"; | ||||
|             assertPersonIsFound(filter); | ||||
|  | ||||
|             filter = "MyFiRsTnAmE"; | ||||
|             assertPersonIsFound(filter); | ||||
|  | ||||
|             filter = "MyLaStNaMe"; | ||||
|             assertPersonIsFound(filter); | ||||
|         } | ||||
|         finally | ||||
|         { | ||||
|             this.authenticationComponent.setCurrentUser(currentUser); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void assertPersonIsFound(String filter) throws Exception | ||||
|     { | ||||
|         Response response = sendRequest(new GetRequest(URL_PEOPLE + "?filter=" + filter), 200); | ||||
|         JSONObject res = new JSONObject(response.getContentAsString()); | ||||
|         int peopleFound = res.getJSONArray("people").length(); | ||||
|         assertTrue("No people found", peopleFound > 0); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      *  | ||||
|      * @throws Exception | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|     <parent> | ||||
|         <groupId>org.alfresco</groupId> | ||||
|         <artifactId>alfresco-community-repo</artifactId> | ||||
|         <version>14.146-SNAPSHOT</version> | ||||
|         <version>16.13</version> | ||||
|     </parent> | ||||
|  | ||||
|     <dependencies> | ||||
| @@ -236,7 +236,7 @@ | ||||
|         <dependency> | ||||
|             <groupId>org.freemarker</groupId> | ||||
|             <artifactId>freemarker</artifactId> | ||||
|             <version>2.3.20-alfresco-patched-20200421</version> | ||||
|             <version>2.3.20-alfresco-patched-20220413</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.apache.xmlbeans</groupId> | ||||
|   | ||||
| @@ -267,8 +267,12 @@ public class SolrJSONResultSet implements SearchEngineResultSet { | ||||
|                         ArrayList<Pair<String, Integer>> facetValues = new ArrayList<Pair<String, Integer>>(facetArraySize/2); | ||||
|                         for(int i = 0; i < facetArraySize; i+=2) | ||||
|                         { | ||||
|                             String facetEntryName = facets.getString(i); | ||||
|                             Integer facetEntryCount = Integer.valueOf(facets.getInt(i+1)); | ||||
|                             String facetEntryName = "Null"; | ||||
|                             if(!facets.isNull(i)) | ||||
|                             { | ||||
|                                 facetEntryName = facets.getString(i); | ||||
|                             } | ||||
|                             Integer facetEntryCount = Integer.valueOf(facets.getInt(i + 1)); | ||||
|                             Pair<String, Integer> pair = new Pair<String, Integer>(facetEntryName, facetEntryCount); | ||||
|                             facetValues.add(pair); | ||||
|                         } | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| repository.name=Main Repository | ||||
|  | ||||
| # Schema number | ||||
| version.schema=16000 | ||||
| version.schema=16200 | ||||
|  | ||||
| # Directory configuration | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user