mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-29 15:21:53 +00:00
Compare commits
38 Commits
25.1.0.64
...
fix/APPS-3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1cb0f98c6 | ||
|
|
9877b8a9f1 | ||
|
|
e58df0ab6f | ||
|
|
1ef208546f | ||
|
|
28307d7c91 | ||
|
|
0c0a95d095 | ||
|
|
41db40b6a2 | ||
|
|
ec78a1486c | ||
|
|
7749f7b80d | ||
|
|
1cec73b176 | ||
|
|
58902c77f1 | ||
|
|
b1f689ed42 | ||
|
|
ac74222562 | ||
|
|
6b959f8901 | ||
|
|
1fac054c08 | ||
|
|
eaf18d3b9d | ||
|
|
05195d84e7 | ||
|
|
2e2b41f879 | ||
|
|
cf0463a24d | ||
|
|
ed80663a07 | ||
|
|
31343c5177 | ||
|
|
f3492d16cf | ||
|
|
5fb5e19434 | ||
|
|
49d346a5c4 | ||
|
|
ae699b37d0 | ||
|
|
cc078037f7 | ||
|
|
9b7eb95463 | ||
|
|
5e560213bb | ||
|
|
a1d8aa7b48 | ||
|
|
b7e1daaac9 | ||
|
|
d70295a8de | ||
|
|
082770d73d | ||
|
|
2f81d382fd | ||
|
|
70438d4a51 | ||
|
|
91aaee9f78 | ||
|
|
d46162de7a | ||
|
|
ba0c9e471a | ||
|
|
40deb11173 |
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
</project>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<organization>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
||||
6
pom.xml
6
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>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Alfresco Community Repo Parent</name>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
<dependency.alfresco-server-root.version>7.0.1</dependency.alfresco-server-root.version>
|
||||
<dependency.activiti-engine.version>5.23.0</dependency.activiti-engine.version>
|
||||
<dependency.activiti.version>5.23.0</dependency.activiti.version>
|
||||
<dependency.alfresco-transform-core.version>5.1.7-A.3</dependency.alfresco-transform-core.version>
|
||||
<dependency.alfresco-transform-core.version>5.1.7-A.4</dependency.alfresco-transform-core.version>
|
||||
<dependency.alfresco-transform-service.version>4.1.7-A.1</dependency.alfresco-transform-service.version>
|
||||
<dependency.alfresco-greenmail.version>7.1</dependency.alfresco-greenmail.version>
|
||||
<dependency.acs-event-model.version>1.0.2</dependency.acs-event-model.version>
|
||||
@@ -155,7 +155,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>25.1.0.64</tag>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* #%L
|
||||
* Alfresco Remote API
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2020 Alfresco Software Limited
|
||||
* Copyright (C) 2005 - 2025 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,17 +26,38 @@
|
||||
|
||||
package org.alfresco.rest.api.tests;
|
||||
|
||||
import static org.alfresco.rest.api.tests.util.RestApiUtil.toJsonAsString;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import static org.alfresco.rest.api.tests.util.RestApiUtil.toJsonAsString;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.collect.Ordering;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.transform.swf.SWFTransformationOptions;
|
||||
import org.alfresco.repo.rendition2.RenditionService2Impl;
|
||||
import org.alfresco.repo.rendition2.SynchronousTransformClient;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.rest.api.model.Site;
|
||||
import org.alfresco.rest.api.nodes.NodesEntityResource;
|
||||
import org.alfresco.rest.api.tests.RepoService.TestNetwork;
|
||||
@@ -54,23 +75,11 @@ import org.alfresco.rest.api.tests.util.MultiPartBuilder.FileData;
|
||||
import org.alfresco.rest.api.tests.util.MultiPartBuilder.MultiPartRequest;
|
||||
import org.alfresco.rest.api.tests.util.RestApiUtil;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
import org.alfresco.service.cmr.thumbnail.ThumbnailService;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* V1 REST API tests for Renditions
|
||||
@@ -93,17 +102,20 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
* Private site of user one from network one
|
||||
*/
|
||||
private Site userOneN1Site;
|
||||
|
||||
|
||||
private final static long DELAY_IN_MS = 500;
|
||||
|
||||
protected static ContentService contentService;
|
||||
private static SynchronousTransformClient synchronousTransformClient;
|
||||
private RetryingTransactionHelper transactionHelper;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception
|
||||
{
|
||||
contentService = applicationContext.getBean("contentService", ContentService.class);
|
||||
synchronousTransformClient = applicationContext.getBean("synchronousTransformClient", SynchronousTransformClient.class);
|
||||
transactionHelper = (RetryingTransactionHelper) this.applicationContext
|
||||
.getBean("retryingTransactionHelper");
|
||||
networkN1 = repoService.createNetworkWithAlias("ping", true);
|
||||
networkN1.create();
|
||||
userOneN1 = networkN1.createUser();
|
||||
@@ -123,14 +135,16 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
|
||||
/**
|
||||
* Tests get node renditions.
|
||||
* <p>GET:</p>
|
||||
* <p>
|
||||
* GET:
|
||||
* </p>
|
||||
* {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/nodes/<nodeId>/renditions}
|
||||
*/
|
||||
@Test
|
||||
public void testListNodeRenditions() throws Exception
|
||||
{
|
||||
setRequestContext(networkN1.getId(), userOneN1.getId(), null);
|
||||
|
||||
|
||||
// Create a folder within the site document's library
|
||||
String folderName = "folder" + System.currentTimeMillis();
|
||||
String folder_Id = addToDocumentLibrary(userOneN1Site, folderName, TYPE_CM_FOLDER, userOneN1.getId());
|
||||
@@ -263,14 +277,16 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
|
||||
/**
|
||||
* Tests get node rendition.
|
||||
* <p>GET:</p>
|
||||
* <p>
|
||||
* GET:
|
||||
* </p>
|
||||
* {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/nodes/<nodeId>/renditions/<renditionId>}
|
||||
*/
|
||||
@Test
|
||||
public void testGetNodeRendition() throws Exception
|
||||
{
|
||||
setRequestContext(networkN1.getId(), userOneN1.getId(), null);
|
||||
|
||||
|
||||
// Create a folder within the site document's library
|
||||
String folderName = "folder" + System.currentTimeMillis();
|
||||
String folder_Id = addToDocumentLibrary(userOneN1Site, folderName, TYPE_CM_FOLDER, userOneN1.getId());
|
||||
@@ -331,8 +347,8 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
String jpgFileName = "quick.jpg";
|
||||
File jpgFile = getResourceFile(fileName);
|
||||
reqBody = MultiPartBuilder.create()
|
||||
.setFileData(new FileData(jpgFileName, jpgFile))
|
||||
.build();
|
||||
.setFileData(new FileData(jpgFileName, jpgFile))
|
||||
.build();
|
||||
|
||||
// Upload quick.jpg file into 'folder'
|
||||
response = post(getNodeChildrenUrl(folder_Id), reqBody.getBody(), null, reqBody.getContentType(), 201);
|
||||
@@ -352,14 +368,16 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
|
||||
/**
|
||||
* Tests create rendition.
|
||||
* <p>POST:</p>
|
||||
* <p>
|
||||
* POST:
|
||||
* </p>
|
||||
* {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/nodes/<nodeId>/renditions}
|
||||
*/
|
||||
@Test
|
||||
public void testCreateRendition() throws Exception
|
||||
{
|
||||
setRequestContext(networkN1.getId(), userOneN1.getId(), null);
|
||||
|
||||
|
||||
// Create a folder within the site document's library
|
||||
String folderName = "folder" + System.currentTimeMillis();
|
||||
String folder_Id = addToDocumentLibrary(userOneN1Site, folderName, TYPE_CM_FOLDER, userOneN1.getId());
|
||||
@@ -411,24 +429,24 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
|
||||
if (areLocalTransformsAvailable())
|
||||
{
|
||||
// Create a node without any content
|
||||
String emptyContentNodeId = addToDocumentLibrary(userOneN1Site, "emptyDoc.txt", TYPE_CM_CONTENT, userOneN1.getId());
|
||||
post(getNodeRenditionsUrl(emptyContentNodeId), toJsonAsString(renditionRequest), 202);
|
||||
// Create a node without any content
|
||||
String emptyContentNodeId = addToDocumentLibrary(userOneN1Site, "emptyDoc.txt", TYPE_CM_CONTENT, userOneN1.getId());
|
||||
post(getNodeRenditionsUrl(emptyContentNodeId), toJsonAsString(renditionRequest), 202);
|
||||
|
||||
// Rendition for binary content
|
||||
String content = "The quick brown fox jumps over the lazy dog.";
|
||||
file = TempFileProvider.createTempFile(new ByteArrayInputStream(content.getBytes()), getClass().getSimpleName(), ".bin");
|
||||
multiPartBuilder = MultiPartBuilder.create().setFileData(new FileData("binaryFileName", file));
|
||||
reqBody = multiPartBuilder.build();
|
||||
response = post(getNodeChildrenUrl(folder_Id), reqBody.getBody(), null, reqBody.getContentType(), 201);
|
||||
Document binaryDocument = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||
post(getNodeRenditionsUrl(binaryDocument.getId()), toJsonAsString(renditionRequest), 202);
|
||||
// Rendition for binary content
|
||||
String content = "The quick brown fox jumps over the lazy dog.";
|
||||
file = TempFileProvider.createTempFile(new ByteArrayInputStream(content.getBytes()), getClass().getSimpleName(), ".bin");
|
||||
multiPartBuilder = MultiPartBuilder.create().setFileData(new FileData("binaryFileName", file));
|
||||
reqBody = multiPartBuilder.build();
|
||||
response = post(getNodeChildrenUrl(folder_Id), reqBody.getBody(), null, reqBody.getContentType(), 201);
|
||||
Document binaryDocument = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||
post(getNodeRenditionsUrl(binaryDocument.getId()), toJsonAsString(renditionRequest), 202);
|
||||
}
|
||||
|
||||
//
|
||||
// -ve Tests
|
||||
//
|
||||
|
||||
|
||||
// The rendition requested already exists
|
||||
response = post(getNodeRenditionsUrl(contentNodeId), toJsonAsString(new Rendition().setId("imgpreview")), 409);
|
||||
ExpectedErrorResponse errorResponse = RestApiUtil.parseErrorResponse(response.getJsonResponse());
|
||||
@@ -563,7 +581,9 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
/**
|
||||
* Tests create rendition when on upload/create of a file
|
||||
*
|
||||
* <p>POST:</p>
|
||||
* <p>
|
||||
* POST:
|
||||
* </p>
|
||||
* {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/nodes/<nodeId>/children}
|
||||
*/
|
||||
@Test
|
||||
@@ -619,25 +639,11 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
assertRenditionCreatedWithWait(contentNodeId, renditionName);
|
||||
}
|
||||
|
||||
/* RA-834: commented-out since not currently applicable for empty file
|
||||
Document d1 = new Document();
|
||||
d1.setName("d1.txt");
|
||||
d1.setNodeType("cm:content");
|
||||
ContentInfo ci = new ContentInfo();
|
||||
ci.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN);
|
||||
d1.setContent(ci);
|
||||
|
||||
// create empty file including request to generate a thumbnail
|
||||
renditionName = "doclib";
|
||||
response = post(getNodeChildrenUrl(folder_Id), userId, toJsonAsStringNonNull(d1), "?renditions="+renditionName, 201);
|
||||
Document documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||
String d1Id = documentResp.getId();
|
||||
|
||||
// wait and check that rendition is created ...
|
||||
rendition = waitAndGetRendition(userId, d1Id, renditionName);
|
||||
assertNotNull(rendition);
|
||||
assertEquals(RenditionStatus.CREATED, rendition.getStatus());
|
||||
*/
|
||||
/* RA-834: commented-out since not currently applicable for empty file Document d1 = new Document(); d1.setName("d1.txt"); d1.setNodeType("cm:content"); ContentInfo ci = new ContentInfo(); ci.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN); d1.setContent(ci);
|
||||
*
|
||||
* // create empty file including request to generate a thumbnail renditionName = "doclib"; response = post(getNodeChildrenUrl(folder_Id), userId, toJsonAsStringNonNull(d1), "?renditions="+renditionName, 201); Document documentResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class); String d1Id = documentResp.getId();
|
||||
*
|
||||
* // wait and check that rendition is created ... rendition = waitAndGetRendition(userId, d1Id, renditionName); assertNotNull(rendition); assertEquals(RenditionStatus.CREATED, rendition.getStatus()); */
|
||||
|
||||
// Multiple renditions requested
|
||||
reqBody = MultiPartBuilder.create()
|
||||
@@ -694,9 +700,9 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
public void testCreateRenditionForNewVersion() throws Exception
|
||||
{
|
||||
String PROP_LTM = "cm:lastThumbnailModification";
|
||||
|
||||
|
||||
String RENDITION_NAME = "imgpreview";
|
||||
|
||||
|
||||
String userId = userOneN1.getId();
|
||||
setRequestContext(networkN1.getId(), userOneN1.getId(), null);
|
||||
|
||||
@@ -718,7 +724,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
String contentNodeId = document1.getId();
|
||||
assertNotNull(document1.getProperties());
|
||||
assertNull(document1.getProperties().get(PROP_LTM));
|
||||
|
||||
|
||||
// pause briefly
|
||||
Thread.sleep(DELAY_IN_MS);
|
||||
|
||||
@@ -730,8 +736,8 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
|
||||
params = new HashMap<>();
|
||||
params.put("placeholder", "false");
|
||||
getSingle(getNodeRenditionsUrl(contentNodeId), (RENDITION_NAME+"/content"), params, 404);
|
||||
|
||||
getSingle(getNodeRenditionsUrl(contentNodeId), (RENDITION_NAME + "/content"), params, 404);
|
||||
|
||||
// TODO add test to request creation of rendition as another user (that has read-only access on the content, not write)
|
||||
|
||||
// Create and get 'imgpreview' rendition
|
||||
@@ -747,24 +753,24 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
|
||||
params = new HashMap<>();
|
||||
params.put("placeholder", "false");
|
||||
response = getSingle(getNodeRenditionsUrl(contentNodeId), (RENDITION_NAME+"/content"), params, 200);
|
||||
|
||||
response = getSingle(getNodeRenditionsUrl(contentNodeId), (RENDITION_NAME + "/content"), params, 200);
|
||||
|
||||
byte[] renditionBytes1 = response.getResponseAsBytes();
|
||||
assertNotNull(renditionBytes1);
|
||||
|
||||
|
||||
// check node details ...
|
||||
params = Collections.singletonMap("include", "properties");
|
||||
response = getSingle(NodesEntityResource.class, contentNodeId, params, 200);
|
||||
Document document1b = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||
|
||||
// assertEquals(document1b.getModifiedAt(), document1.getModifiedAt());
|
||||
|
||||
// assertEquals(document1b.getModifiedAt(), document1.getModifiedAt());
|
||||
assertEquals(document1b.getModifiedByUser().getId(), document1.getModifiedByUser().getId());
|
||||
assertEquals(document1b.getModifiedByUser().getDisplayName(), document1.getModifiedByUser().getDisplayName());
|
||||
|
||||
|
||||
assertNotEquals(document1b.getProperties().get(PROP_LTM), document1.getProperties().get(PROP_LTM));
|
||||
|
||||
|
||||
// upload another version of "quick.pdf" and check again
|
||||
|
||||
|
||||
fileName = "quick-2.pdf";
|
||||
file = getResourceFile(fileName);
|
||||
reqBody = MultiPartBuilder.create()
|
||||
@@ -781,9 +787,9 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
|
||||
params = new HashMap<>();
|
||||
params.put("placeholder", "false");
|
||||
response = getSingle(getNodeRenditionsUrl(contentNodeId), (RENDITION_NAME+"/content"), params, 200);
|
||||
response = getSingle(getNodeRenditionsUrl(contentNodeId), (RENDITION_NAME + "/content"), params, 200);
|
||||
assertNotNull(response.getResponseAsBytes());
|
||||
|
||||
|
||||
// check rendition binary has changed
|
||||
assertNotEquals(renditionBytes1, response.getResponseAsBytes());
|
||||
|
||||
@@ -792,24 +798,26 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
response = getSingle(NodesEntityResource.class, contentNodeId, params, 200);
|
||||
Document document2b = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||
|
||||
// assertTrue(document2b.getModifiedAt().after(document1.getModifiedAt()));
|
||||
// assertTrue(document2b.getModifiedAt().after(document1.getModifiedAt()));
|
||||
assertEquals(document2b.getModifiedByUser().getId(), document1.getModifiedByUser().getId());
|
||||
assertEquals(document2b.getModifiedByUser().getDisplayName(), document1.getModifiedByUser().getDisplayName());
|
||||
|
||||
|
||||
// check last thumbnail modification property has changed ! (REPO-1644)
|
||||
assertNotEquals(document2b.getProperties().get(PROP_LTM), document1b.getProperties().get(PROP_LTM));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests download rendition.
|
||||
* <p>GET:</p>
|
||||
* <p>
|
||||
* GET:
|
||||
* </p>
|
||||
* {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/nodes/<nodeId>/renditions/<renditionId>/content}
|
||||
*/
|
||||
@Test
|
||||
public void testDownloadRendition() throws Exception
|
||||
{
|
||||
setRequestContext(networkN1.getId(), userOneN1.getId(), null);
|
||||
|
||||
|
||||
// Create a folder within the site document's library
|
||||
String folderName = "folder" + System.currentTimeMillis();
|
||||
String folder_Id = addToDocumentLibrary(userOneN1Site, folderName, TYPE_CM_FOLDER, userOneN1.getId());
|
||||
@@ -818,7 +826,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
String fileName = "quick.pdf";
|
||||
File file = getResourceFile(fileName);
|
||||
MultiPartBuilder multiPartBuilder = MultiPartBuilder.create()
|
||||
.setFileData(new FileData(fileName, file));
|
||||
.setFileData(new FileData(fileName, file));
|
||||
MultiPartRequest reqBody = multiPartBuilder.build();
|
||||
|
||||
// Upload quick.pdf file into 'folder'
|
||||
@@ -928,8 +936,8 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
// the old fileName and setting overwrite field to true
|
||||
file = getResourceFile("quick-2.pdf");
|
||||
multiPartBuilder = MultiPartBuilder.create()
|
||||
.setFileData(new FileData(fileName, file))
|
||||
.setOverwrite(true);
|
||||
.setFileData(new FileData(fileName, file))
|
||||
.setOverwrite(true);
|
||||
reqBody = multiPartBuilder.build();
|
||||
|
||||
// Update quick.pdf
|
||||
@@ -937,7 +945,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
|
||||
// The requested "If-Modified-Since" date is older than rendition modified date
|
||||
response = getSingleWithDelayRetry(getNodeRenditionsUrl(contentNodeId), "doclib/content", params, headers, MAX_RETRY,
|
||||
PAUSE_TIME, 200);
|
||||
PAUSE_TIME, 200);
|
||||
assertNotNull(response);
|
||||
responseHeaders = response.getHeaders();
|
||||
assertNotNull(responseHeaders);
|
||||
@@ -945,7 +953,7 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
assertNotNull(newLastModifiedHeader);
|
||||
assertNotEquals(lastModifiedHeader, newLastModifiedHeader);
|
||||
|
||||
//-ve tests
|
||||
// -ve tests
|
||||
// nodeId in the path parameter does not represent a file
|
||||
getSingle(getNodeRenditionsUrl(folder_Id), "doclib/content", 400);
|
||||
|
||||
@@ -958,8 +966,8 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
InputStream inputStream = new ByteArrayInputStream("The quick brown fox jumps over the lazy dog".getBytes());
|
||||
file = TempFileProvider.createTempFile(inputStream, "RenditionsTest-", ".abcdef");
|
||||
reqBody = MultiPartBuilder.create()
|
||||
.setFileData(new FileData(file.getName(), file))
|
||||
.build();
|
||||
.setFileData(new FileData(file.getName(), file))
|
||||
.build();
|
||||
// Upload temp file into 'folder'
|
||||
response = post(getNodeChildrenUrl(folder_Id), reqBody.getBody(), null, reqBody.getContentType(), 201);
|
||||
document = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||
@@ -981,6 +989,72 @@ public class RenditionsTest extends AbstractBaseApiTest
|
||||
getSingle(getNodeRenditionsUrl(emptyContentNodeId), "doclib/content", params, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test recreation of rendition2 aspect.
|
||||
* <p>
|
||||
* POST:
|
||||
* </p>
|
||||
* <p>
|
||||
* DELETE:
|
||||
* </p>
|
||||
* {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/nodes/<nodeId>/renditions} {@literal <host>:<port>/alfresco/api/<networkId>/public/alfresco/versions/1/nodes/<nodeId>/renditions/{renditionID}
|
||||
*/
|
||||
@Test
|
||||
public void testRecreationOfRendition2() throws Exception
|
||||
{
|
||||
setRequestContext(networkN1.getId(), userOneN1.getId(), null);
|
||||
|
||||
// Create a folder within the site document's library
|
||||
String folderName = "folder" + System.currentTimeMillis();
|
||||
String folderId = addToDocumentLibrary(userOneN1Site, folderName, TYPE_CM_FOLDER, userOneN1.getId());
|
||||
|
||||
// Create multipart request.
|
||||
String renditionName = "pdf";
|
||||
String fileName = "quick.pdf";
|
||||
File file = getResourceFile(fileName);
|
||||
MultiPartRequest reqBody = MultiPartBuilder.create()
|
||||
.setFileData(new FileData(fileName, file))
|
||||
.setRenditions(Collections.singletonList(renditionName))
|
||||
.build();
|
||||
|
||||
// Upload quick.pdf file into 'folder'
|
||||
HttpResponse response = post(getNodeChildrenUrl(folderId), reqBody.getBody(), null, reqBody.getContentType(), 201);
|
||||
Document document = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
|
||||
String contentNodeId = document.getId();
|
||||
|
||||
// wait and check that rendition is created ...
|
||||
Rendition rendition = waitAndGetRendition(contentNodeId, null, renditionName);
|
||||
assertNotNull(rendition);
|
||||
assertEquals(Rendition.RenditionStatus.CREATED, rendition.getStatus());
|
||||
|
||||
Thread.sleep(DELAY_IN_MS);
|
||||
|
||||
delete(getNodeRenditionIdUrl(contentNodeId, renditionName), null, null, null, null, 204);
|
||||
// retry to double-check deletion
|
||||
delete(getNodeRenditionIdUrl(contentNodeId, renditionName), null, null, null, null, 404);
|
||||
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
|
||||
ThumbnailService thumbnailService = applicationContext.getBean("thumbnailService", ThumbnailService.class);
|
||||
|
||||
SWFTransformationOptions swfTransformationOptions = new SWFTransformationOptions();
|
||||
swfTransformationOptions.setUse("pdf");
|
||||
|
||||
NodeRef thumbNode = transactionHelper
|
||||
.doInTransaction(
|
||||
() -> thumbnailService.createThumbnail(getFolderNodeRef(contentNodeId), ContentModel.PROP_CONTENT,
|
||||
MimetypeMap.MIMETYPE_PDF, swfTransformationOptions, "pdf"));
|
||||
|
||||
assertNotNull(thumbNode);
|
||||
assertNotEquals("Both, we are getting same rendition Id's", rendition.getId(), thumbNode.getId());
|
||||
|
||||
}
|
||||
|
||||
private NodeRef getFolderNodeRef(String folderId)
|
||||
{
|
||||
return new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, folderId);
|
||||
}
|
||||
|
||||
private String addToDocumentLibrary(Site testSite, String name, String nodeType, String userId) throws Exception
|
||||
{
|
||||
String parentId = getSiteContainerNodeId(testSite.getId(), "documentLibrary");
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>25.1.0.64</version>
|
||||
<version>25.1.0.68-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -57,7 +57,7 @@ public class NodeSizeDetailsServiceImpl implements NodeSizeDetailsService, Initi
|
||||
{
|
||||
private static final Logger LOG = LoggerFactory.getLogger(NodeSizeDetailsServiceImpl.class);
|
||||
private static final String FIELD_FACET = "content.size";
|
||||
private static final String FACET_QUERY = "{!afts}content.size:[0 TO " + Integer.MAX_VALUE + "]";
|
||||
private static final String FACET_QUERY = "{!afts key='extra large'}content.size:[0 TO " + Integer.MAX_VALUE + "]";
|
||||
private SearchService searchService;
|
||||
private SimpleCache<Serializable, NodeSizeDetails> simpleCache;
|
||||
private TransactionService transactionService;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,11 +28,17 @@ package org.alfresco.repo.workflow.activiti.script;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.delegate.VariableScope;
|
||||
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.activiti.engine.impl.context.Context;
|
||||
import org.activiti.engine.impl.el.Expression;
|
||||
import org.activiti.engine.impl.persistence.entity.DeploymentEntity;
|
||||
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.workflow.WorkflowDeployer;
|
||||
@@ -45,13 +51,12 @@ import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowException;
|
||||
|
||||
/**
|
||||
* Base class for execution scripts, using {@link ScriptService} as part of
|
||||
* activiti workflow.
|
||||
* Base class for execution scripts, using {@link ScriptService} as part of activiti workflow.
|
||||
*
|
||||
* @author Frederik Heremans
|
||||
* @since 3.4.e
|
||||
*/
|
||||
public class ActivitiScriptBase
|
||||
public class ActivitiScriptBase
|
||||
{
|
||||
protected static final String PERSON_BINDING_NAME = "person";
|
||||
protected static final String USERHOME_BINDING_NAME = "userhome";
|
||||
@@ -61,17 +66,19 @@ public class ActivitiScriptBase
|
||||
protected Expression runAs;
|
||||
protected Expression scriptProcessor;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ActivitiScriptBase.class);
|
||||
|
||||
protected Object executeScript(String theScript, Map<String, Object> model, String scriptProcessorName, String runAsUser)
|
||||
{
|
||||
String user = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||
|
||||
|
||||
Object scriptResult = null;
|
||||
if (runAsUser == null && user != null)
|
||||
{
|
||||
// Just execute the script using the current user
|
||||
scriptResult = executeScript(theScript, model, scriptProcessorName);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (runAsUser != null)
|
||||
{
|
||||
@@ -87,26 +94,25 @@ public class ActivitiScriptBase
|
||||
}
|
||||
return scriptResult;
|
||||
}
|
||||
|
||||
|
||||
protected Object executeScriptAsUser(final String theScript, final Map<String, Object> model, final String scriptProcessorName, final String runAsUser)
|
||||
{
|
||||
// execute as specified runAsUser
|
||||
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Object>()
|
||||
{
|
||||
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<>() {
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
return executeScript(theScript, model, scriptProcessorName);
|
||||
}
|
||||
}, runAsUser);
|
||||
}
|
||||
|
||||
|
||||
protected Object executeScript(String theScript, Map<String, Object> model, String scriptProcessorName)
|
||||
{
|
||||
// Execute the script using the appropriate processor
|
||||
Object scriptResult = null;
|
||||
|
||||
// Checks if current workflow is secure
|
||||
boolean secure = isSecure();
|
||||
boolean secure = isSecure(model);
|
||||
|
||||
if (scriptProcessorName != null)
|
||||
{
|
||||
@@ -117,11 +123,11 @@ public class ActivitiScriptBase
|
||||
// Use default script-processor
|
||||
scriptResult = getServiceRegistry().getScriptService().executeScriptString(theScript, model, secure);
|
||||
}
|
||||
|
||||
|
||||
return scriptResult;
|
||||
}
|
||||
|
||||
protected String getStringValue(Expression expression, VariableScope scope)
|
||||
|
||||
protected String getStringValue(Expression expression, VariableScope scope)
|
||||
{
|
||||
if (expression != null)
|
||||
{
|
||||
@@ -133,15 +139,15 @@ public class ActivitiScriptBase
|
||||
protected ServiceRegistry getServiceRegistry()
|
||||
{
|
||||
ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration();
|
||||
if (config != null)
|
||||
if (config != null)
|
||||
{
|
||||
// Fetch the registry that is injected in the activiti spring-configuration
|
||||
ServiceRegistry registry = (ServiceRegistry) config.getBeans().get(ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
|
||||
if (registry == null)
|
||||
{
|
||||
throw new RuntimeException(
|
||||
"Service-registry not present in ProcessEngineConfiguration beans, expected ServiceRegistry with key" +
|
||||
ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
|
||||
"Service-registry not present in ProcessEngineConfiguration beans, expected ServiceRegistry with key" +
|
||||
ActivitiConstants.SERVICE_REGISTRY_BEAN_KEY);
|
||||
}
|
||||
return registry;
|
||||
}
|
||||
@@ -149,42 +155,136 @@ public class ActivitiScriptBase
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the workflow must be considered secure or not - based on {@link DeploymentEntity} category.
|
||||
* If it is not considered secure, the workflow will be executed in sandbox context with more restrictions
|
||||
* Checks whether the workflow must be considered secure or not - based on {@link DeploymentEntity} category. If it is not considered secure, the workflow will be executed in sandbox context with more restrictions
|
||||
*
|
||||
* @return true if workflow is considered secure, false otherwise
|
||||
*/
|
||||
private boolean isSecure()
|
||||
private boolean isSecure(Map<String, Object> model)
|
||||
{
|
||||
String category = getDeploymentCategory(model);
|
||||
|
||||
// iF The deployment category matches the condition (either internal or full access) the workflow is considered secure
|
||||
return category != null && (WorkflowDeployer.CATEGORY_ALFRESCO_INTERNAL.equals(category) || WorkflowDeployer.CATEGORY_FULL_ACCESS.equals(category));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the deployment category from the execution context. If no execution context is available, a query to obtain the deployment is performed so the category can be returned.
|
||||
*
|
||||
* @param model
|
||||
* a map with workflow model
|
||||
* @return the deployment category
|
||||
*/
|
||||
private String getDeploymentCategory(Map<String, Object> model)
|
||||
{
|
||||
String category = getDeploymentCategoryFromContext();
|
||||
|
||||
if (category == null)
|
||||
{
|
||||
String deploymentId = null;
|
||||
String processDefinitionId = null;
|
||||
|
||||
if (model != null && model.containsKey(EXECUTION_BINDING_NAME) && model.get(EXECUTION_BINDING_NAME) instanceof ExecutionEntity)
|
||||
{
|
||||
ExecutionEntity executionEntity = (ExecutionEntity) model.get(EXECUTION_BINDING_NAME);
|
||||
deploymentId = executionEntity.getDeploymentId();
|
||||
processDefinitionId = executionEntity.getProcessDefinitionId();
|
||||
}
|
||||
|
||||
category = getDeploymentCategoryFromQuery(deploymentId, processDefinitionId);
|
||||
}
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the deployment category from current execution context
|
||||
*
|
||||
* @return the category for current execution deployment, otherwise null
|
||||
*/
|
||||
private String getDeploymentCategoryFromContext()
|
||||
{
|
||||
String category = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (Context.isExecutionContextActive())
|
||||
{
|
||||
category = Context.getExecutionContext().getDeployment().getCategory();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("No execution context available");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// No action required
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("Could not obtain deployment category from execution context: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// If the workflow is considered secure, the deployment entity category matches the condition (either internal or full access)
|
||||
return category != null && (WorkflowDeployer.CATEGORY_ALFRESCO_INTERNAL.equals(category) || WorkflowDeployer.CATEGORY_FULL_ACCESS.equals(category));
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the specified 'runAs' field
|
||||
* specifies a valid username.
|
||||
* Obtains the deployment category through a query
|
||||
*
|
||||
* @param deploymentId
|
||||
* the deployment id to obtain the category from
|
||||
* @param processDefinitionId
|
||||
* if no deployment id is provided, the process definition id can be used to obtain the deployment
|
||||
* @return the category for the obtained deployment, otherwise null
|
||||
*/
|
||||
private void validateRunAsUser(final String runAsUser)
|
||||
private String getDeploymentCategoryFromQuery(String deploymentId, String processDefinitionId)
|
||||
{
|
||||
Boolean runAsExists = AuthenticationUtil.runAs(new RunAsWork<Boolean>()
|
||||
String category = null;
|
||||
|
||||
try
|
||||
{
|
||||
RepositoryService repositoryService = Context.getProcessEngineConfiguration().getRepositoryService();
|
||||
|
||||
if (deploymentId == null && processDefinitionId != null)
|
||||
{
|
||||
ProcessDefinition processDefnition = repositoryService.getProcessDefinition(processDefinitionId);
|
||||
if (processDefnition != null)
|
||||
{
|
||||
deploymentId = processDefnition.getDeploymentId();
|
||||
}
|
||||
}
|
||||
|
||||
if (deploymentId != null)
|
||||
{
|
||||
DeploymentEntity deployment = (DeploymentEntity) repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
|
||||
if (deployment != null)
|
||||
{
|
||||
category = deployment.getCategory();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("Could not obtain deployment category through a query: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the specified 'runAs' field specifies a valid username.
|
||||
*/
|
||||
private void validateRunAsUser(final String runAsUser)
|
||||
{
|
||||
Boolean runAsExists = AuthenticationUtil.runAs(new RunAsWork<>() {
|
||||
// Validate using System user to ensure sufficient permissions available to access person node.
|
||||
|
||||
public Boolean doWork() throws Exception
|
||||
@Override
|
||||
public Boolean doWork() throws Exception
|
||||
{
|
||||
return getServiceRegistry().getPersonService().personExists(runAsUser);
|
||||
}
|
||||
@@ -195,21 +295,21 @@ public class ActivitiScriptBase
|
||||
throw new WorkflowException("runas user '" + runAsUser + "' does not exist.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected ActivitiScriptNode getPersonNode(String runAsUser)
|
||||
{
|
||||
String userName = null;
|
||||
if (runAsUser != null)
|
||||
if (runAsUser != null)
|
||||
{
|
||||
userName = runAsUser;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
userName = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||
}
|
||||
|
||||
|
||||
// The "System" user is a special case, which has no person object associated with it.
|
||||
if(userName != null && !AuthenticationUtil.SYSTEM_USER_NAME.equals(userName))
|
||||
if (userName != null && !AuthenticationUtil.SYSTEM_USER_NAME.equals(userName))
|
||||
{
|
||||
ServiceRegistry services = getServiceRegistry();
|
||||
PersonService personService = services.getPersonService();
|
||||
@@ -221,18 +321,18 @@ public class ActivitiScriptBase
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setScript(Expression script)
|
||||
|
||||
public void setScript(Expression script)
|
||||
{
|
||||
this.script = script;
|
||||
}
|
||||
|
||||
public void setRunAs(Expression runAs)
|
||||
public void setRunAs(Expression runAs)
|
||||
{
|
||||
this.runAs = runAs;
|
||||
}
|
||||
|
||||
public void setScriptProcessor(Expression scriptProcessor)
|
||||
public void setScriptProcessor(Expression scriptProcessor)
|
||||
{
|
||||
this.scriptProcessor = scriptProcessor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user