-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
776 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
wfe-core/src/main/java/ru/runa/wfe/definition/validation/DefinitionUpdateValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package ru.runa.wfe.definition.validation; | ||
|
||
/** | ||
* @author azyablin | ||
*/ | ||
public interface DefinitionUpdateValidator { | ||
|
||
void validate(DeploymentUpdateData deploymentUpdateData); | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
...ore/src/main/java/ru/runa/wfe/definition/validation/DefinitionUpdateValidatorManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package ru.runa.wfe.definition.validation; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
import ru.runa.wfe.commons.SystemProperties; | ||
import ru.runa.wfe.commons.TimeMeasurer; | ||
import ru.runa.wfe.execution.Process; | ||
import ru.runa.wfe.execution.ProcessFilter; | ||
import ru.runa.wfe.execution.dao.ProcessDao; | ||
import ru.runa.wfe.lang.ProcessDefinition; | ||
|
||
/** | ||
* @author azyablin | ||
*/ | ||
@Component | ||
public class DefinitionUpdateValidatorManager { | ||
private static final Log log = LogFactory.getLog(DefinitionUpdateValidatorManager.class); | ||
@Autowired | ||
private List<DefinitionUpdateValidator> validators; | ||
@Autowired | ||
private ProcessDao processDao; | ||
|
||
public void validate(ProcessDefinition oldDefinition, ProcessDefinition newDefinition) { | ||
if (!SystemProperties.isDefinitionCompatibilityCheckEnabled()) { | ||
return; | ||
} | ||
TimeMeasurer timeMeasurer = new TimeMeasurer(log); | ||
timeMeasurer.jobStarted(); | ||
ProcessFilter filter = new ProcessFilter(); | ||
filter.setDefinitionName(oldDefinition.getName()); | ||
filter.setDefinitionVersion(oldDefinition.getDeployment().getVersion()); | ||
filter.setFinished(false); | ||
List<Process> processes = processDao.getProcesses(filter); | ||
timeMeasurer.jobEnded("Loading " + processes.size() + " active processes"); | ||
timeMeasurer.jobStarted(); | ||
validate(oldDefinition, newDefinition, processes); | ||
timeMeasurer.jobEnded("Validation of " + oldDefinition); | ||
} | ||
|
||
public void validate(ProcessDefinition oldDefinition, ProcessDefinition newDefinition, Process process) { | ||
if (!SystemProperties.isDefinitionCompatibilityCheckEnabled()) { | ||
return; | ||
} | ||
validate(oldDefinition, newDefinition, Collections.singletonList(process)); | ||
} | ||
|
||
private void validate(ProcessDefinition oldDefinition, ProcessDefinition newDefinition, List<Process> processes) { | ||
DeploymentUpdateData deploymentUpdateData = new DeploymentUpdateData(oldDefinition, newDefinition, processes); | ||
for (DefinitionUpdateValidator validator : validators) { | ||
validator.validate(deploymentUpdateData); | ||
} | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
wfe-core/src/main/java/ru/runa/wfe/definition/validation/DeploymentUpdateData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ru.runa.wfe.definition.validation; | ||
|
||
import java.util.List; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import ru.runa.wfe.execution.Process; | ||
import ru.runa.wfe.lang.ProcessDefinition; | ||
|
||
/** | ||
* Contains information about old and new definition for process definition compatibility check. | ||
* | ||
* @author azyablin | ||
*/ | ||
@RequiredArgsConstructor | ||
@Getter | ||
@Setter | ||
public class DeploymentUpdateData { | ||
private final ProcessDefinition oldDefinition; | ||
private final ProcessDefinition newDefinition; | ||
private final List<Process> processes; | ||
} |
22 changes: 22 additions & 0 deletions
22
.../main/java/ru/runa/wfe/definition/validation/ProcessDefinitionNotCompatibleException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package ru.runa.wfe.definition.validation; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.ToString; | ||
import ru.runa.wfe.InternalApplicationException; | ||
|
||
/** | ||
* @author azyablin | ||
*/ | ||
@RequiredArgsConstructor | ||
@Getter | ||
@ToString | ||
public class ProcessDefinitionNotCompatibleException extends InternalApplicationException { | ||
public static final String NODE_EXISTENCE = "node.existence"; | ||
public static final String PARALLEL_GATEWAY_MISTYPED = "parallel.gateway.mistyped"; | ||
public static final String PARALLEL_GATEWAY_TRANSITIONS = "parallel.gateway.transitions"; | ||
private static final long serialVersionUID = 1L; | ||
private final String type; | ||
private final String[] args; | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...n/java/ru/runa/wfe/definition/validation/impl/NodeExistenceDefinitionUpdateValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package ru.runa.wfe.definition.validation.impl; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
import ru.runa.wfe.definition.validation.DefinitionUpdateValidator; | ||
import ru.runa.wfe.definition.validation.DeploymentUpdateData; | ||
import ru.runa.wfe.definition.validation.ProcessDefinitionNotCompatibleException; | ||
import ru.runa.wfe.execution.Token; | ||
import ru.runa.wfe.execution.dao.TokenDao; | ||
|
||
/** | ||
* Checks that all nodes with tokens in active processes exist in new process definition. | ||
* | ||
* @author azyablin | ||
*/ | ||
@Component | ||
public class NodeExistenceDefinitionUpdateValidator implements DefinitionUpdateValidator { | ||
@Autowired | ||
TokenDao tokenDao; | ||
|
||
@Override | ||
public void validate(DeploymentUpdateData deploymentUpdateData) { | ||
for (ru.runa.wfe.execution.Process process : deploymentUpdateData.getProcesses()) { | ||
for (Token token : tokenDao.findByProcessAndExecutionStatusIsNotEnded(process)) { | ||
String nodeId = token.getNodeId(); | ||
if (deploymentUpdateData.getNewDefinition().getNode(nodeId) == null) { | ||
throw new ProcessDefinitionNotCompatibleException(ProcessDefinitionNotCompatibleException.NODE_EXISTENCE, | ||
new String[] { nodeId, token.getProcess().getId().toString() }); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.