mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
ACS-3563 Workflow Licence Check (#1422)
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -46,6 +46,7 @@ import org.alfresco.service.cmr.repository.NodeService;
|
|||||||
import org.alfresco.service.cmr.repository.Path;
|
import org.alfresco.service.cmr.repository.Path;
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
|
import org.alfresco.service.cmr.workflow.FailedWorkflowDeployment;
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowAdminService;
|
import org.alfresco.service.cmr.workflow.WorkflowAdminService;
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowDeployment;
|
import org.alfresco.service.cmr.workflow.WorkflowDeployment;
|
||||||
@@ -62,11 +63,14 @@ import org.springframework.core.io.ClassPathResource;
|
|||||||
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
||||||
|
|
||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alfresco bootstrap Process deployment.
|
* Alfresco bootstrap Process deployment.
|
||||||
@@ -314,8 +318,10 @@ public class WorkflowDeployer extends AbstractLifecycleBean
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WorkflowDeployment deployment = workflowService.deployDefinition(engineId, workflowResource.getInputStream(), mimetype, workflowResource.getFilename(), true);
|
final InputStream workflowInputStream = workflowResource.getInputStream();
|
||||||
logDeployment(location, deployment);
|
final Optional<WorkflowDeployment> possibleDeployment = tryToDeploy(() ->
|
||||||
|
workflowService.deployDefinition(engineId, workflowInputStream, mimetype, workflowResource.getFilename(), true));
|
||||||
|
possibleDeployment.ifPresent(deployment -> logDeployment(location, deployment));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -402,10 +408,9 @@ public class WorkflowDeployer extends AbstractLifecycleBean
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// deploy / re-deploy
|
// deploy / re-deploy
|
||||||
WorkflowDeployment deployment = workflowService.deployDefinition(nodeRef);
|
tryToDeploy(() -> workflowService.deployDefinition(nodeRef)).ifPresent(deployment ->
|
||||||
logDeployment(nodeRef, deployment);
|
|
||||||
if (deployment != null)
|
|
||||||
{
|
{
|
||||||
|
logDeployment(nodeRef, deployment);
|
||||||
WorkflowDefinition def = deployment.getDefinition();
|
WorkflowDefinition def = deployment.getDefinition();
|
||||||
|
|
||||||
// Update the meta data for the model
|
// Update the meta data for the model
|
||||||
@@ -424,7 +429,7 @@ public class WorkflowDeployer extends AbstractLifecycleBean
|
|||||||
}
|
}
|
||||||
|
|
||||||
nodeService.setProperties(nodeRef, props);
|
nodeService.setProperties(nodeRef, props);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -441,6 +446,20 @@ public class WorkflowDeployer extends AbstractLifecycleBean
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Optional<WorkflowDeployment> tryToDeploy(Supplier<WorkflowDeployment> workflowDeployment)
|
||||||
|
{
|
||||||
|
final WorkflowDeployment deployment = workflowDeployment.get();
|
||||||
|
final Optional<String> possibleFailure = FailedWorkflowDeployment.getFailure(deployment);
|
||||||
|
|
||||||
|
if (possibleFailure.isEmpty())
|
||||||
|
{
|
||||||
|
return Optional.ofNullable(deployment);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.warn("Failed to deploy a workflow. " + possibleFailure.get());
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate that the workflow definition node is a child of the correct
|
* Validate that the workflow definition node is a child of the correct
|
||||||
* workflow location node, e.g. "/Company Home/Data Dictionary/Workflows"
|
* workflow location node, e.g. "/Company Home/Data Dictionary/Workflows"
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* #%L
|
* #%L
|
||||||
* Alfresco Repository
|
* Alfresco Repository
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2022 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
@@ -105,7 +105,7 @@ public class ActivitiWorkflowManagerFactory implements FactoryBean<ActivitiWorkf
|
|||||||
ActivitiPropertyConverter propertyConverter = new ActivitiPropertyConverter(activitiUtil, factory, handlerRegistry, authorityManager, messageService, nodeConverter);
|
ActivitiPropertyConverter propertyConverter = new ActivitiPropertyConverter(activitiUtil, factory, handlerRegistry, authorityManager, messageService, nodeConverter);
|
||||||
ActivitiTypeConverter typeConverter = new ActivitiTypeConverter(processEngine, factory, propertyConverter, deployWorkflowsInTenant);
|
ActivitiTypeConverter typeConverter = new ActivitiTypeConverter(processEngine, factory, propertyConverter, deployWorkflowsInTenant);
|
||||||
|
|
||||||
ActivitiWorkflowEngine workflowEngine = new ActivitiWorkflowEngine();
|
ActivitiWorkflowEngine workflowEngine = instantiateWorkflowEngine();
|
||||||
workflowEngine.setActivitiUtil(activitiUtil);
|
workflowEngine.setActivitiUtil(activitiUtil);
|
||||||
workflowEngine.setAuthorityManager(authorityManager);
|
workflowEngine.setAuthorityManager(authorityManager);
|
||||||
workflowEngine.setBPMEngineRegistry(bpmEngineRegistry);
|
workflowEngine.setBPMEngineRegistry(bpmEngineRegistry);
|
||||||
@@ -124,6 +124,11 @@ public class ActivitiWorkflowManagerFactory implements FactoryBean<ActivitiWorkf
|
|||||||
return new ActivitiWorkflowManager(workflowEngine, propertyConverter, handlerRegistry, nodeConverter, authorityManager);
|
return new ActivitiWorkflowManager(workflowEngine, propertyConverter, handlerRegistry, nodeConverter, authorityManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ActivitiWorkflowEngine instantiateWorkflowEngine()
|
||||||
|
{
|
||||||
|
return new ActivitiWorkflowEngine();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param tenantService the tenantService to set
|
* @param tenantService the tenantService to set
|
||||||
*/
|
*/
|
||||||
|
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
* #%L
|
||||||
|
* Alfresco Repository
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 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.service.cmr.workflow;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The goal of this class is to provide a support for workflow deployment failure. Since {@link WorkflowDeployment} is
|
||||||
|
* part of the public API we don't want to change it.
|
||||||
|
*/
|
||||||
|
public final class FailedWorkflowDeployment
|
||||||
|
{
|
||||||
|
private FailedWorkflowDeployment()
|
||||||
|
{
|
||||||
|
//no instantiation
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WorkflowDeployment deploymentForbidden(String workflowName, String reason)
|
||||||
|
{
|
||||||
|
return new DeploymentFailure(workflowName, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<String> getFailure(WorkflowDeployment workflowDeployment)
|
||||||
|
{
|
||||||
|
if (!(workflowDeployment instanceof DeploymentFailure))
|
||||||
|
{
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Optional.of(workflowDeployment.getProblems()[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class DeploymentFailure extends WorkflowDeployment
|
||||||
|
{
|
||||||
|
private static final String UNDEFINED = "undefined";
|
||||||
|
|
||||||
|
private DeploymentFailure(String workflowName, String problemDescription)
|
||||||
|
{
|
||||||
|
super(failedDefinition(workflowName), problemDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static WorkflowDefinition failedDefinition(String workflowName)
|
||||||
|
{
|
||||||
|
final String definitionName = workflowName == null ? UNDEFINED : workflowName;
|
||||||
|
return new WorkflowDefinition(UNDEFINED, definitionName, UNDEFINED, UNDEFINED, UNDEFINED, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -135,6 +135,26 @@
|
|||||||
<bean id="siteLoadBootstrap-Spaces" parent="spacesStoreImporter"/>
|
<bean id="siteLoadBootstrap-Spaces" parent="spacesStoreImporter"/>
|
||||||
<bean id="siteLoadBootstrap-Users" parent="userStoreImporter"/>
|
<bean id="siteLoadBootstrap-Users" parent="userStoreImporter"/>
|
||||||
|
|
||||||
|
<!-- Descriptor Service -->
|
||||||
|
<bean id="descriptorComponent" class="org.alfresco.repo.descriptor.DescriptorServiceImpl">
|
||||||
|
<property name="serverDescriptorDAO">
|
||||||
|
<ref bean="serverDescriptorDAO"/>
|
||||||
|
</property>
|
||||||
|
<property name="currentRepoDescriptorDAO">
|
||||||
|
<ref bean="currentRepoDescriptorDAO"/>
|
||||||
|
</property>
|
||||||
|
<property name="installedRepoDescriptorDAO">
|
||||||
|
<ref bean="installedRepoDescriptorDAO"/>
|
||||||
|
</property>
|
||||||
|
<property name="transactionService">
|
||||||
|
<ref bean="transactionService"/>
|
||||||
|
</property>
|
||||||
|
<property name="hbDataCollectorService">
|
||||||
|
<ref bean="hbDataCollectorService"/>
|
||||||
|
</property>
|
||||||
|
<property name="repoUsageComponent" ref="repoUsageComponent"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="workflowBootstrap" parent="workflowDeployer">
|
<bean id="workflowBootstrap" parent="workflowDeployer">
|
||||||
<property name="workflowDefinitions">
|
<property name="workflowDefinitions">
|
||||||
<list>
|
<list>
|
||||||
@@ -255,26 +275,6 @@
|
|||||||
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Descriptor Service -->
|
|
||||||
<bean id="descriptorComponent" class="org.alfresco.repo.descriptor.DescriptorServiceImpl">
|
|
||||||
<property name="serverDescriptorDAO">
|
|
||||||
<ref bean="serverDescriptorDAO"/>
|
|
||||||
</property>
|
|
||||||
<property name="currentRepoDescriptorDAO">
|
|
||||||
<ref bean="currentRepoDescriptorDAO"/>
|
|
||||||
</property>
|
|
||||||
<property name="installedRepoDescriptorDAO">
|
|
||||||
<ref bean="installedRepoDescriptorDAO"/>
|
|
||||||
</property>
|
|
||||||
<property name="transactionService">
|
|
||||||
<ref bean="transactionService"/>
|
|
||||||
</property>
|
|
||||||
<property name="hbDataCollectorService">
|
|
||||||
<ref bean="hbDataCollectorService"/>
|
|
||||||
</property>
|
|
||||||
<property name="repoUsageComponent" ref="repoUsageComponent"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- Bootstrap MT (multi-tenancy) if applicable -->
|
<!-- Bootstrap MT (multi-tenancy) if applicable -->
|
||||||
<bean id="multiTenantBootstrap" class="org.alfresco.repo.tenant.MultiTenantBootstrap" >
|
<bean id="multiTenantBootstrap" class="org.alfresco.repo.tenant.MultiTenantBootstrap" >
|
||||||
<property name="tenantAdminService" ref="tenantAdminService"/>
|
<property name="tenantAdminService" ref="tenantAdminService"/>
|
||||||
|
Reference in New Issue
Block a user