mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-09-10 14:11:58 +00:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
525a9dea0b | ||
|
987895e4f0 | ||
|
1e9d005f7f | ||
|
ce518bdb76 | ||
|
588b421f34 | ||
|
2a38bd0c7d | ||
|
95e88cb8ed | ||
|
e9d90d94f2 | ||
|
5799c0943c | ||
|
9defe1c2ed | ||
|
10f2894503 |
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@@ -385,18 +385,24 @@ jobs:
|
||||
pom-dir: tas-email
|
||||
- test-name: "WebDAV TAS tests"
|
||||
pom-dir: tas-webdav
|
||||
- test-name: "Integration TAS tests"
|
||||
- test-name: "Integration TAS tests (Java 17)"
|
||||
pom-dir: tas-integration
|
||||
- test-name: "Integration TAS tests (Java 11)"
|
||||
pom-dir: tas-integration
|
||||
jre-version: 11
|
||||
env:
|
||||
REQUIRES_LOCAL_IMAGES: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0
|
||||
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0
|
||||
with:
|
||||
java-version: ${{ matrix.jre-version || '17' }}
|
||||
- name: "Build"
|
||||
timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }}
|
||||
run: |
|
||||
bash ./scripts/ci/init.sh
|
||||
export BUILD_OPTIONS="-Ddocker.buildArg.JRE_VERSION=${{ matrix.jre-version }} ${BUILD_OPTIONS}"
|
||||
bash ./scripts/ci/build.sh
|
||||
- name: "Set up the environment"
|
||||
run: |
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-automation-community-repo</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-parent</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -5,7 +5,7 @@
|
||||
# Version label
|
||||
version.major=7
|
||||
version.minor=4
|
||||
version.revision=2
|
||||
version.revision=1
|
||||
version.label=
|
||||
|
||||
# Edition label
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-governance-services-community-repo-parent</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-amps</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -9,6 +9,6 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
</project>
|
||||
|
@@ -1,6 +1,8 @@
|
||||
ARG JRE_VERSION=17
|
||||
|
||||
# Fetch image based on Tomcat 9.0, Java 17 and Rocky Linux 8
|
||||
# More infos about this image: https://github.com/Alfresco/alfresco-docker-base-tomcat
|
||||
FROM alfresco/alfresco-base-tomcat:tomcat9-jre17-rockylinux8-202303081618
|
||||
FROM alfresco/alfresco-base-tomcat:tomcat9-jre${JRE_VERSION}-rockylinux8-202303081618
|
||||
|
||||
# Set default docker_context.
|
||||
ARG resource_path=target
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<organization>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-tests</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<developers>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo-packaging</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
12
pom.xml
12
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>22.1</version>
|
||||
<version>21.17</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>4</acs.version.minor>
|
||||
<acs.version.revision>2</acs.version.revision>
|
||||
<acs.version.revision>1</acs.version.revision>
|
||||
<acs.version.label />
|
||||
<amp.min.version>${acs.version.major}.0.0</amp.min.version>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<dependency.jackson.version>2.15.0-rc1</dependency.jackson.version>
|
||||
<dependency.cxf.version>3.5.5</dependency.cxf.version>
|
||||
<dependency.opencmis.version>1.0.0</dependency.opencmis.version>
|
||||
<dependency.webscripts.version>8.44</dependency.webscripts.version>
|
||||
<dependency.webscripts.version>8.47</dependency.webscripts.version>
|
||||
<dependency.bouncycastle.version>1.70</dependency.bouncycastle.version>
|
||||
<dependency.mockito-core.version>4.9.0</dependency.mockito-core.version>
|
||||
<dependency.assertj.version>3.24.2</dependency.assertj.version>
|
||||
@@ -111,8 +111,8 @@
|
||||
<dependency.json-smart.version>2.4.10</dependency.json-smart.version>
|
||||
<dependency.jakarta-rpc-api.version>1.1.4</dependency.jakarta-rpc-api.version>
|
||||
|
||||
<alfresco.googledrive.version>3.4.0</alfresco.googledrive.version>
|
||||
<alfresco.aos-module.version>1.6.0</alfresco.aos-module.version>
|
||||
<alfresco.googledrive.version>3.4.2</alfresco.googledrive.version>
|
||||
<alfresco.aos-module.version>1.6.2</alfresco.aos-module.version>
|
||||
<alfresco.api-explorer.version>7.4.0</alfresco.api-explorer.version> <!-- Also in alfresco-enterprise-share -->
|
||||
|
||||
<alfresco.maven-plugin.version>2.2.0</alfresco.maven-plugin.version>
|
||||
@@ -150,7 +150,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>22.1</tag>
|
||||
<tag>21.17</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -68,7 +68,6 @@ import org.alfresco.repo.policy.BehaviourFilter;
|
||||
import org.alfresco.repo.rendition2.RenditionDefinition2;
|
||||
import org.alfresco.repo.rendition2.RenditionDefinitionRegistry2;
|
||||
import org.alfresco.repo.rendition2.RenditionService2;
|
||||
import org.alfresco.repo.rule.RuleModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
@@ -149,7 +148,6 @@ import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.Path.Element;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
@@ -218,7 +216,6 @@ public class NodesImpl implements Nodes
|
||||
private LockService lockService;
|
||||
private VirtualStore smartStore; // note: remove as part of REPO-1173
|
||||
private ClassDefinitionMapper classDefinitionMapper;
|
||||
private RuleService ruleService;
|
||||
|
||||
private enum Activity_Type
|
||||
{
|
||||
@@ -341,11 +338,6 @@ public class NodesImpl implements Nodes
|
||||
this.classDefinitionMapper = classDefinitionMapper;
|
||||
}
|
||||
|
||||
public void setRuleService(RuleService ruleService)
|
||||
{
|
||||
this.ruleService = ruleService;
|
||||
}
|
||||
|
||||
// excluded namespaces (aspects, properties, assoc types)
|
||||
private static final List<String> EXCLUDED_NS = Arrays.asList(NamespaceService.SYSTEM_MODEL_1_0_URI);
|
||||
|
||||
@@ -2551,8 +2543,6 @@ public class NodesImpl implements Nodes
|
||||
Set<QName> aspectsToAdd = new HashSet<>(3);
|
||||
Set<QName> aspectsToRemove = new HashSet<>(3);
|
||||
|
||||
boolean hasRules = ruleService.hasRules(nodeRef);
|
||||
|
||||
for (QName aspectQName : aspectQNames)
|
||||
{
|
||||
if (EXCLUDED_NS.contains(aspectQName.getNamespaceURI()) || excludedAspects.contains(aspectQName) || aspectQName.equals(ContentModel.ASPECT_AUDITABLE))
|
||||
@@ -2568,7 +2558,7 @@ public class NodesImpl implements Nodes
|
||||
|
||||
for (QName existingAspect : existingAspects)
|
||||
{
|
||||
if (EXCLUDED_NS.contains(existingAspect.getNamespaceURI()) || excludedAspects.contains(existingAspect) || existingAspect.equals(ContentModel.ASPECT_AUDITABLE) || existingAspect.equals(RuleModel.ASPECT_RULES) && hasRules)
|
||||
if (EXCLUDED_NS.contains(existingAspect.getNamespaceURI()) || excludedAspects.contains(existingAspect) || existingAspect.equals(ContentModel.ASPECT_AUDITABLE))
|
||||
{
|
||||
continue; // ignore
|
||||
}
|
||||
|
@@ -537,7 +537,6 @@
|
||||
<property name="poster" ref="activitiesPoster" />
|
||||
<property name="smartStore" ref="smartStore"/>
|
||||
<property name="classDefinitionMapper" ref="classDefinitionMapper" />
|
||||
<property name="ruleService" ref="RuleService" />
|
||||
</bean>
|
||||
|
||||
<bean id="Nodes" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
|
@@ -49,10 +49,8 @@ import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
|
||||
import org.alfresco.repo.content.ContentLimitProvider.SimpleFixedLimitProvider;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.rule.RuleModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.repo.tenant.TenantUtil;
|
||||
@@ -85,16 +83,11 @@ import org.alfresco.rest.api.tests.util.MultiPartBuilder;
|
||||
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.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionService;
|
||||
import org.alfresco.service.cmr.lock.LockType;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.rule.Rule;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.rule.RuleType;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
@@ -137,8 +130,7 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
||||
protected AuthorityService authorityService;
|
||||
private NodeService nodeService;
|
||||
private NamespaceService namespaceService;
|
||||
private RuleService ruleService;
|
||||
private ActionService actionService;
|
||||
|
||||
|
||||
private String rootGroupName = null;
|
||||
private String groupA = null;
|
||||
@@ -153,8 +145,6 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
||||
authorityService = (AuthorityService) applicationContext.getBean("AuthorityService");
|
||||
nodeService = applicationContext.getBean("NodeService", NodeService.class);
|
||||
namespaceService= (NamespaceService) applicationContext.getBean("NamespaceService");
|
||||
ruleService = (RuleService) applicationContext.getBean("RuleService", RuleService.class);
|
||||
actionService = (ActionService) applicationContext.getBean("ActionService", ActionService.class);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -6408,42 +6398,5 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
|
||||
setRequestContext(user1);
|
||||
deleteSite(site1Id, true, 204);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRuleAspectAfterUpdate() throws Exception
|
||||
{
|
||||
// Change to User1 context
|
||||
setRequestContext(networkOne.getId(), user1, null);
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(user1);
|
||||
|
||||
// Create folder
|
||||
String folderId = createUniqueFolder(getMyNodeId());
|
||||
NodeRef folderNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, folderId);
|
||||
|
||||
assertFalse("Folder shouldn't have the rule aspect", nodeService.hasAspect(folderNodeRef, RuleModel.ASPECT_RULES));
|
||||
|
||||
// Create Rule
|
||||
Rule rule = new Rule();
|
||||
rule.setTitle("My Rule");
|
||||
rule.setRuleType(RuleType.INBOUND);
|
||||
Action action = this.actionService.createAction(AddFeaturesActionExecuter.NAME);
|
||||
action.setParameterValue(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_CLASSIFIABLE);
|
||||
rule.setAction(action);
|
||||
this.ruleService.saveRule(folderNodeRef, rule);
|
||||
|
||||
assertTrue("Folder should have the rule aspect", nodeService.hasAspect(folderNodeRef, RuleModel.ASPECT_RULES));
|
||||
|
||||
// Update folder with empty aspectNames
|
||||
Folder folderUpdate = new Folder();
|
||||
folderUpdate.setAspectNames(Arrays.asList());
|
||||
|
||||
put(URL_NODES, folderId, toJsonAsStringNonNull(folderUpdate), null, 200);
|
||||
|
||||
assertTrue("Folder should have the rule aspect", nodeService.hasAspect(folderNodeRef, RuleModel.ASPECT_RULES));
|
||||
assertEquals("Folder should have 1 rule.", 1, ruleService.countRules(folderNodeRef));
|
||||
|
||||
// Cleanup
|
||||
delete(URL_NODES, folderId, 204);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.alfresco</groupId>
|
||||
<artifactId>alfresco-community-repo</artifactId>
|
||||
<version>22.1</version>
|
||||
<version>21.17</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@@ -25,19 +25,16 @@
|
||||
*/
|
||||
package org.alfresco.schedule;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.alfresco.repo.lock.JobLockService;
|
||||
import org.alfresco.repo.lock.JobLockService.JobLockRefreshCallback;
|
||||
import org.alfresco.repo.lock.LockAcquisitionException;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.VmShutdownListener.VmShutdownException;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.alfresco.repo.lock.JobLockService;
|
||||
import org.alfresco.repo.lock.LockAcquisitionException;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.alfresco.util.VmShutdownListener.VmShutdownException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
/**
|
||||
* This class encapsulates the {@link org.alfresco.repo.lock.JobLockService JobLockService}
|
||||
@@ -59,7 +56,7 @@ public class ScheduledJobLockExecuter
|
||||
{
|
||||
private static final long LOCK_TTL = 30000L;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ScheduledJobLockExecuter.class);
|
||||
private static Log logger = LogFactory.getLog(ScheduledJobLockExecuter.class.getName());
|
||||
private static ThreadLocal<Pair<Long, String>> lockThreadLocal = new ThreadLocal<Pair<Long, String>>();
|
||||
|
||||
private final JobLockService jobLockService;
|
||||
@@ -86,43 +83,52 @@ public class ScheduledJobLockExecuter
|
||||
* @throws JobExecutionException thrown if the job fails to execute
|
||||
*/
|
||||
public void execute(JobExecutionContext jobContext) throws JobExecutionException
|
||||
{
|
||||
LockCallback lockCallback = new LockCallback();
|
||||
String lockName = lockQName.getLocalName();
|
||||
{
|
||||
try
|
||||
{
|
||||
LOGGER.debug(" Job {} started.", lockName);
|
||||
refreshLock(lockCallback);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(String.format(" Job %s started.", lockQName.getLocalName()));
|
||||
}
|
||||
refreshLock();
|
||||
job.executeJob(jobContext);
|
||||
LOGGER.debug(" Job {} completed.", lockName);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(String.format(" Job %s completed.", lockQName.getLocalName()));
|
||||
}
|
||||
}
|
||||
catch (LockAcquisitionException e)
|
||||
{
|
||||
// Job being done by another process
|
||||
LOGGER.debug(" Job {} already underway.", lockName);
|
||||
// Job being done by another process
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(String.format(" Job %s already underway.", lockQName.getLocalName()));
|
||||
}
|
||||
}
|
||||
catch (VmShutdownException e)
|
||||
{
|
||||
// Aborted
|
||||
LOGGER.debug(" Job {} aborted.", lockName);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(String.format(" Job %s aborted.", lockQName.getLocalName()));
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
releaseLock(lockCallback);
|
||||
releaseLock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazily update the job lock
|
||||
*/
|
||||
private void refreshLock(LockCallback lockCallback)
|
||||
private void refreshLock()
|
||||
{
|
||||
Pair<Long, String> lockPair = lockThreadLocal.get();
|
||||
if (lockPair == null)
|
||||
{
|
||||
String lockToken = jobLockService.getLock(lockQName, LOCK_TTL);
|
||||
jobLockService.refreshLock(lockToken, lockQName, LOCK_TTL, lockCallback);
|
||||
Long lastLock = Long.valueOf(System.currentTimeMillis());
|
||||
String lockToken = jobLockService.getLock(lockQName, LOCK_TTL);
|
||||
Long lastLock = new Long(System.currentTimeMillis());
|
||||
// We have not locked before
|
||||
lockPair = new Pair<Long, String>(lastLock, lockToken);
|
||||
lockThreadLocal.set(lockPair);
|
||||
@@ -135,7 +141,7 @@ public class ScheduledJobLockExecuter
|
||||
// Only refresh the lock if we are past a threshold
|
||||
if (now - lastLock > (long) (LOCK_TTL / 2L))
|
||||
{
|
||||
jobLockService.refreshLock(lockToken, lockQName, LOCK_TTL, lockCallback);
|
||||
jobLockService.refreshLock(lockToken, lockQName, LOCK_TTL);
|
||||
lastLock = System.currentTimeMillis();
|
||||
lockPair = new Pair<Long, String>(lastLock, lockToken);
|
||||
lockThreadLocal.set(lockPair);
|
||||
@@ -146,13 +152,8 @@ public class ScheduledJobLockExecuter
|
||||
/**
|
||||
* Release the lock after the job completes
|
||||
*/
|
||||
private void releaseLock(LockCallback lockCallback)
|
||||
{
|
||||
if (lockCallback != null)
|
||||
{
|
||||
lockCallback.running.set(false);
|
||||
}
|
||||
|
||||
private void releaseLock()
|
||||
{
|
||||
Pair<Long, String> lockPair = lockThreadLocal.get();
|
||||
if (lockPair != null)
|
||||
{
|
||||
@@ -168,23 +169,5 @@ public class ScheduledJobLockExecuter
|
||||
}
|
||||
}
|
||||
// else: We can't release without a token
|
||||
}
|
||||
|
||||
private class LockCallback implements JobLockRefreshCallback
|
||||
{
|
||||
final AtomicBoolean running = new AtomicBoolean(true);
|
||||
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
return running.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lockReleased()
|
||||
{
|
||||
running.set(false);
|
||||
LOGGER.debug("Lock release notification: {}", lockQName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
repository.name=Main Repository
|
||||
|
||||
# Schema number
|
||||
version.schema=18200
|
||||
version.schema=18100
|
||||
|
||||
# Directory configuration
|
||||
|
||||
|
@@ -38,15 +38,6 @@ import org.junit.runners.Suite;
|
||||
@RunWith(Categories.class)
|
||||
@Categories.ExcludeCategory({DBTests.class, NonBuildTests.class})
|
||||
@Suite.SuiteClasses({
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// testScheduleContext [classpath:alfresco/application-context.xml, classpath:alfresco/schedule/test-schedule-context.xml]
|
||||
//
|
||||
// This test needs to be first as it will clean nodes from trashcan, if order is changed, then it will take lot of time
|
||||
// to remove all the nodes from previous tests
|
||||
// ----------------------------------------------------------------------
|
||||
org.alfresco.schedule.AbstractScheduledLockedJobTest.class,
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// globalIntegrationTestContext [classpath:alfresco/application-context.xml, classpath:alfresco/test/global-integration-test-context.xml]
|
||||
// ----------------------------------------------------------------------
|
||||
|
@@ -1,209 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 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.schedule;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.model.Repository;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.BaseSpringTest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.quartz.SchedulerAccessorBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tiago Salvado
|
||||
*/
|
||||
@ContextConfiguration({"classpath:alfresco/application-context.xml", "classpath:alfresco/schedule/test-schedule-context.xml"})
|
||||
public class AbstractScheduledLockedJobTest extends BaseSpringTest
|
||||
{
|
||||
private static final int TOTAL_NODES = 9;
|
||||
private static final int NUM_THREADS = 2;
|
||||
private static final long JOB_EXECUTER_LOCK_TTL = 30000L;
|
||||
private static final String ARCHIVE_STORE_URL = "archive://SpacesStore";
|
||||
|
||||
private NodeService nodeService;
|
||||
private TransactionService transactionService;
|
||||
private Repository repository;
|
||||
|
||||
private SchedulerAccessorBean testCleanerAccessor;
|
||||
private JobDetail testCleanerJobDetail;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractScheduledLockedJobTest.class);
|
||||
|
||||
/**
|
||||
* Sets services and job beans
|
||||
*/
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
nodeService = (NodeService) applicationContext.getBean("nodeService");
|
||||
transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
|
||||
repository = (Repository) applicationContext.getBean("repositoryHelper");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws SchedulerException, InterruptedException
|
||||
{
|
||||
createAndDeleteNodes(TOTAL_NODES);
|
||||
|
||||
assertTrue("Expected nodes haven't been created", getNumberOfNodesInTrashcan() >= TOTAL_NODES);
|
||||
|
||||
CleanerThread[] threads = new CleanerThread[NUM_THREADS];
|
||||
|
||||
for (int i = 0; i < NUM_THREADS; i++)
|
||||
{
|
||||
CleanerThread t = new CleanerThread(i);
|
||||
threads[i] = t;
|
||||
t.start();
|
||||
Thread.sleep(JOB_EXECUTER_LOCK_TTL);
|
||||
}
|
||||
|
||||
for (Thread t : threads)
|
||||
{
|
||||
t.join();
|
||||
}
|
||||
|
||||
while (getNumberOfNodesInTrashcan() > 0)
|
||||
{
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
|
||||
for (CleanerThread t : threads)
|
||||
{
|
||||
if (t.hasErrors())
|
||||
{
|
||||
fail("An error has occurred when executing multiple cleaner jobs at the same time");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and deletes the specified number of nodes.
|
||||
*
|
||||
* @param archivedNodes
|
||||
* Number of nodes to be created and added to trashcan
|
||||
*/
|
||||
private void createAndDeleteNodes(int archivedNodes)
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(() -> {
|
||||
RetryingTransactionHelper.RetryingTransactionCallback<Void> txnWork = () -> {
|
||||
for (int i = 0; i < archivedNodes; i++)
|
||||
{
|
||||
addNodeToTrashcan();
|
||||
}
|
||||
return null;
|
||||
};
|
||||
return transactionService.getRetryingTransactionHelper().doInTransaction(txnWork);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and deletes nodes
|
||||
*/
|
||||
private void addNodeToTrashcan()
|
||||
{
|
||||
NodeRef companyHome = repository.getCompanyHome();
|
||||
String name = "Sample (" + UUID.randomUUID().toString() + ")";
|
||||
|
||||
ChildAssociationRef association = nodeService.createNode(companyHome, ContentModel.ASSOC_CONTAINS,
|
||||
QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, name), ContentModel.TYPE_CONTENT,
|
||||
ImmutableMap.of(ContentModel.PROP_NAME, name));
|
||||
|
||||
NodeRef parent = association.getChildRef();
|
||||
|
||||
nodeService.deleteNode(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* It returns the number of nodes present on trashcan.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private long getNumberOfNodesInTrashcan()
|
||||
{
|
||||
StoreRef storeRef = new StoreRef(ARCHIVE_STORE_URL);
|
||||
NodeRef archiveRoot = nodeService.getRootNode(storeRef);
|
||||
return nodeService.getChildAssocs(archiveRoot, ContentModel.ASSOC_CHILDREN, RegexQNamePattern.MATCH_ALL).size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Thread to start the cleaner job for the test.
|
||||
*/
|
||||
private class CleanerThread extends Thread
|
||||
{
|
||||
private int threadNum;
|
||||
private boolean started;
|
||||
private Cleaner testCleaner;
|
||||
|
||||
CleanerThread(int threadNum)
|
||||
{
|
||||
super(CleanerThread.class.getSimpleName() + "-" + threadNum);
|
||||
this.threadNum = threadNum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
testCleanerAccessor = (SchedulerAccessorBean) applicationContext.getBean("testSchedulerAccessor");
|
||||
testCleanerJobDetail = (JobDetail) applicationContext.getBean("testCleanerJobDetail");
|
||||
testCleaner = (Cleaner) testCleanerJobDetail.getJobDataMap().get("testCleaner");
|
||||
testCleanerAccessor.getScheduler().triggerJob(testCleanerJobDetail.getKey());
|
||||
LOGGER.info("Thread {} has started", this.threadNum);
|
||||
this.started = true;
|
||||
}
|
||||
catch (SchedulerException e)
|
||||
{
|
||||
this.started = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasErrors()
|
||||
{
|
||||
return !started || testCleaner != null && testCleaner.hasErrors();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,174 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 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.schedule;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A test implementation similar to the trash can cleaner job implementation that will be used in
|
||||
* {@link AbstractScheduledLockedJobTest}
|
||||
*
|
||||
* @author Tiago Salvado
|
||||
*/
|
||||
public class Cleaner
|
||||
{
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Cleaner.class);
|
||||
|
||||
private final NodeService nodeService;
|
||||
private final TransactionService transactionService;
|
||||
|
||||
private static final String ARCHIVE_STORE_URL = "archive://SpacesStore";
|
||||
private final int deleteBatchCount;
|
||||
private List<NodeRef> nodesToClean;
|
||||
|
||||
private int numErrors;
|
||||
|
||||
private static final int REMOVAL_WAIT_TIME_MS = 5000;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nodeService
|
||||
* @param transactionService
|
||||
* @param deleteBatchCount
|
||||
*/
|
||||
public Cleaner(NodeService nodeService, TransactionService transactionService, int deleteBatchCount)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
this.transactionService = transactionService;
|
||||
this.deleteBatchCount = deleteBatchCount;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* It deletes the {@link java.util.List List} of {@link org.alfresco.service.cmr.repository.NodeRef NodeRef}
|
||||
* received as argument.
|
||||
*
|
||||
* @param nodes
|
||||
*
|
||||
* return The number of deleted nodes
|
||||
*/
|
||||
private int deleteNodes(List<NodeRef> nodes)
|
||||
{
|
||||
AtomicInteger deletedNodes = new AtomicInteger();
|
||||
for (NodeRef nodeRef : nodes)
|
||||
{
|
||||
// create a new transaction for each deletion so the transactions are smaller and the progress of the
|
||||
// cleaner is not lost in case of any problems encountered during the job execution
|
||||
AuthenticationUtil.runAsSystem(() -> {
|
||||
RetryingTransactionCallback<Void> txnWork = () -> {
|
||||
try
|
||||
{
|
||||
nodeService.deleteNode(nodeRef);
|
||||
}
|
||||
catch (InvalidNodeRefException inre)
|
||||
{
|
||||
numErrors++;
|
||||
}
|
||||
deletedNodes.getAndIncrement();
|
||||
// Waiting REMOVAL_WAIT_TIME_MS seconds for next deletion so we don't need to have many nodes on the trash can
|
||||
Thread.sleep(REMOVAL_WAIT_TIME_MS);
|
||||
return null;
|
||||
};
|
||||
return transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, false, true);
|
||||
});
|
||||
}
|
||||
return deletedNodes.get();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* It returns the {@link java.util.List List} of {@link org.alfresco.service.cmr.repository.NodeRef NodeRef} of the
|
||||
* archive store set to be deleted according to configuration for <b>deleteBatchCount</b>.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<NodeRef> getBatchToDelete()
|
||||
{
|
||||
return getChildAssocs().stream().map(ChildAssociationRef::getChildRef).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* It will return the first {@link #deleteBatchCount}
|
||||
* {@link org.alfresco.service.cmr.repository.ChildAssociationRef}s of type {@link ContentModel}.ASSOC_CHILDREN from
|
||||
* the archive store set.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<ChildAssociationRef> getChildAssocs()
|
||||
{
|
||||
StoreRef archiveStore = new StoreRef(ARCHIVE_STORE_URL);
|
||||
NodeRef archiveRoot = nodeService.getRootNode(archiveStore);
|
||||
return nodeService.getChildAssocs(archiveRoot, ContentModel.ASSOC_CHILDREN, RegexQNamePattern.MATCH_ALL, deleteBatchCount,
|
||||
false);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* The method that will clean the specified <b>archiveStoreUrl</b> to the limits defined by the values set for
|
||||
* <b>deleteBatchCount</b>.
|
||||
*/
|
||||
public void clean()
|
||||
{
|
||||
LOGGER.info("Running TestCleaner");
|
||||
|
||||
// Retrieve in a new read-only transaction the list of nodes to be deleted by the TestCleaner
|
||||
AuthenticationUtil.runAsSystem(() -> {
|
||||
RetryingTransactionCallback<Void> txnWork = () -> {
|
||||
nodesToClean = getBatchToDelete();
|
||||
|
||||
LOGGER.info(String.format("Number of nodes to delete: %s", nodesToClean.size()));
|
||||
|
||||
return null;
|
||||
};
|
||||
return transactionService.getRetryingTransactionHelper().doInTransaction(txnWork, true, true);
|
||||
});
|
||||
|
||||
int deletedNodes = deleteNodes(nodesToClean);
|
||||
|
||||
LOGGER.info("TestCleaner finished. Number of deleted nodes: {}", deletedNodes);
|
||||
}
|
||||
|
||||
public boolean hasErrors()
|
||||
{
|
||||
return numErrors > 0;
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Repository
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2023 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.schedule;
|
||||
|
||||
import org.quartz.JobExecutionContext;
|
||||
|
||||
/**
|
||||
* Test job that will execute {@link Cleaner}
|
||||
*
|
||||
* @author Tiago Salvado
|
||||
*
|
||||
* @see AbstractScheduledLockedJob
|
||||
*/
|
||||
public class CleanerJob extends AbstractScheduledLockedJob
|
||||
{
|
||||
@Override
|
||||
public void executeJob(JobExecutionContext jobContext)
|
||||
{
|
||||
Cleaner testCleaner = (Cleaner) jobContext.getJobDetail().getJobDataMap().get("testCleaner");
|
||||
testCleaner.clean();
|
||||
}
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean id="testCleaner" class="org.alfresco.schedule.Cleaner">
|
||||
<constructor-arg ref="nodeService" />
|
||||
<constructor-arg ref="transactionService" />
|
||||
<constructor-arg value="100" />
|
||||
</bean>
|
||||
|
||||
<bean id="testSchedulerAccessor" class="org.springframework.scheduling.quartz.SchedulerAccessorBean">
|
||||
<property name="scheduler" ref="schedulerFactory"/>
|
||||
<property name="triggers">
|
||||
<list>
|
||||
<ref bean="testCleanerTrigger"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="testCleanerTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
|
||||
<property name="cronExpression" value="* * * * * ? 2099"/>
|
||||
<property name="jobDetail" ref="testCleanerJobDetail"/>
|
||||
</bean>
|
||||
|
||||
<bean id="testCleanerJobDetail" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
|
||||
<property name="jobClass" value="org.alfresco.schedule.CleanerJob"/>
|
||||
<property name="jobDataAsMap">
|
||||
<map>
|
||||
<entry key="testCleaner" value-ref="testCleaner" />
|
||||
<entry key="jobLockService" value-ref="jobLockService" />
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
Reference in New Issue
Block a user