Skip to content

Commit

Permalink
Merge branch 'master' into github
Browse files Browse the repository at this point in the history
# Conflicts:
#	wfe-web/src/main/java/ru/runa/common/WebResources.java
#	wfe-web/src/main/webapp/css/main.css
  • Loading branch information
dofs197 committed May 15, 2023
2 parents 1796ec5 + 88025af commit 0ff9770
Show file tree
Hide file tree
Showing 83 changed files with 1,058 additions and 552 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,13 @@ public Object getVariable(String scriptingName) {
}
Object value = getVariableFromProcess(scriptingName);
log.debug("Passing to script '" + scriptingName + "' as '" + value + "'" + (value != null ? " of " + value.getClass() : ""));
setVariable(scriptingName, value);
if (value instanceof Serializable) {
startValues.put(scriptingName, clone((Serializable) value));
startValues.put(scriptingName, value);
setVariable(scriptingName, clone((Serializable) value));
} else {
setVariable(scriptingName, value);
}
return value;
return super.getVariable(scriptingName);
}

protected Object getVariableFromProcess(String scriptingName) {
Expand Down
34 changes: 30 additions & 4 deletions wfe-core/src/main/java/ru/runa/wfe/commons/SystemProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Date;
import java.util.List;
import ru.runa.wfe.execution.logic.ProcessExecutionListener;
import ru.runa.wfe.execution.logic.TaskExecutionListener;
import ru.runa.wfe.lang.NodeType;
import ru.runa.wfe.security.ApplicablePermissions;
import ru.runa.wfe.security.Permission;
Expand All @@ -24,6 +25,7 @@ public class SystemProperties {
public static final String DEPRECATED_PREFIX = "deprecated.";

private static volatile List<ProcessExecutionListener> processExecutionListeners = null;
private static volatile List<TaskExecutionListener> taskExecutionListeners = null;

static {
setSystemProperties("javamelody.disabled", "javamelody.datasources");
Expand Down Expand Up @@ -222,10 +224,18 @@ public static boolean isDefinitionDeploymentWithEmptyCommentsAllowed() {
return RESOURCES.getBooleanProperty("definition.comments.empty.allowed", true);
}

public static boolean deleteTokensInMissingNodesOnDefinitionUpdate() {
return RESOURCES.getBooleanProperty("definition.update.delete.tokens.for.missing.nodes", false);
}

public static boolean isDefinitionCompatibilityCheckEnabled() {
return RESOURCES.getBooleanProperty("definition.compatibility.check.enabled", true);
}

public static int getDefinitionCompatibilityCheckProcessesLimit() {
return RESOURCES.getIntegerProperty("definition.compatibility.check.processes.limit", -1);
}

public static boolean isCheckProcessStartPermissions() {
return RESOURCES.getBooleanProperty("check.process.start.permissions", true);
}
Expand Down Expand Up @@ -336,6 +346,26 @@ public static List<ProcessExecutionListener> getProcessExecutionListeners() {
return processExecutionListeners;
}

public static List<TaskExecutionListener> getTaskExecutionListeners() {
if (taskExecutionListeners == null) {
synchronized (SystemProperties.class) {
if (taskExecutionListeners == null) {
taskExecutionListeners = Lists.newArrayList();
for (String className : RESOURCES.getMultipleStringProperty("task.execution.listeners")) {
try {
TaskExecutionListener listener = ClassLoaderUtil.instantiate(className);
taskExecutionListeners.add(listener);
} catch (Throwable th) {
taskExecutionListeners = null;
Throwables.propagate(th);
}
}
}
}
}
return taskExecutionListeners;
}

public static List<String> getRequiredValidatorNames() {
return RESOURCES.getMultipleStringProperty("required.validator.names");
}
Expand Down Expand Up @@ -433,10 +463,6 @@ public static boolean isProcessLogCleanButtonEnabled() {
return RESOURCES.getBooleanProperty("processLog.cleanButton.enabled", false);
}

public static int getDefinitionCompatibilityCheckProcessesLimit() {
return RESOURCES.getIntegerProperty("definition.compatibility.check.processes.limit", -1);
}

public static boolean isGlobalObjectsEnabled() {
return RESOURCES.getBooleanProperty("global.objects.enabled", true);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ru.runa.wfe.commons.dbmigration;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -46,25 +48,26 @@ public boolean isWfeConstantsDropped() {
private HashSet<String> queryAppliedMigrationNames() throws Exception {
return txManager.callInTransaction(new ManualTransactionManager.TxCallable<HashSet<String>>() {
@Override
public HashSet<String> call(Connection conn) {
public HashSet<String> call(Connection conn) throws Exception {
HashSet<String> result = null;
try (val stmt = conn.createStatement()) {
val rs = stmt.executeQuery("select name, when_finished from db_migration");
ResultSet rs = null;
try {
rs = stmt.executeQuery("select name, when_finished from db_migration");
} catch (SQLException e) {
return null;
}
// Table exists:
result = new HashSet<>();
while (rs.next()) {
String name = rs.getString(1);
if (rs.getTimestamp(2) == null) {
throw new Exception("Migration \"" + name + "\" was unfinished, database is possibly inconsistent, aborting.");
log.error("Migration \"" + name + "\" was unfinished, database is possibly inconsistent, aborting.");
throw new RuntimeException("Migration \"" + name + "\" was unfinished, database is possibly inconsistent, aborting.");
}
result.add(name);
}
return result;
} catch (Throwable e) {
if (result != null) {
throw new RuntimeException("Failed to fetch DB_MIGRATION table", e);
}
return null;
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import ru.runa.wfe.commons.dbmigration.impl.AddProcessAndTokenExecutionStatusPatch;
import ru.runa.wfe.commons.dbmigration.impl.AddProcessExternalData;
import ru.runa.wfe.commons.dbmigration.impl.AddProcessLogCleanBeforeDateColumnPatch;
import ru.runa.wfe.commons.dbmigration.impl.AddTransitionNameForTaskPatch;
import ru.runa.wfe.commons.dbmigration.impl.AddSequentialFlagToBot;
import ru.runa.wfe.commons.dbmigration.impl.AddSettingsTable;
import ru.runa.wfe.commons.dbmigration.impl.AddSubProcessIndexColumn;
Expand All @@ -31,6 +30,7 @@
import ru.runa.wfe.commons.dbmigration.impl.AddTokenMessageSelectorPatch;
import ru.runa.wfe.commons.dbmigration.impl.AddTokenNodeNameAndNodeEnterDateColumnsPatch;
import ru.runa.wfe.commons.dbmigration.impl.AddTransactionalBotSupport;
import ru.runa.wfe.commons.dbmigration.impl.AddTransitionNameForTaskPatch;
import ru.runa.wfe.commons.dbmigration.impl.AddUuidAndDropBytesChatMessageFilePatch;
import ru.runa.wfe.commons.dbmigration.impl.AddVariableUniqueKeyPatch;
import ru.runa.wfe.commons.dbmigration.impl.CorrectChatRoomViewRenameColumn;
Expand All @@ -41,6 +41,8 @@
import ru.runa.wfe.commons.dbmigration.impl.CreateSignalListenerAggregatedLogTable;
import ru.runa.wfe.commons.dbmigration.impl.CreateStatisticReportTable;
import ru.runa.wfe.commons.dbmigration.impl.CreateTimerAggregatedLogTable;
import ru.runa.wfe.commons.dbmigration.impl.DeleteBatchPresentationsRm3017;
import ru.runa.wfe.commons.dbmigration.impl.DeleteBatchPresentationsRm3056;
import ru.runa.wfe.commons.dbmigration.impl.DropMessageNotNullConstraintPatch;
import ru.runa.wfe.commons.dbmigration.impl.DropQuotedMessageIdsPatch;
import ru.runa.wfe.commons.dbmigration.impl.EnlargeMessageMaxSizePatch;
Expand Down Expand Up @@ -164,6 +166,8 @@ public ArrayList<Class<? extends DbMigration>> dbMigrations() {
dbMigrations.add(CorrectChatRoomViewRenameColumn.class);
dbMigrations.add(AddAsyncForTaskAndSubprocess.class);
dbMigrations.add(AddTransitionNameForTaskPatch.class);
dbMigrations.add(DeleteBatchPresentationsRm3017.class);
dbMigrations.add(DeleteBatchPresentationsRm3056.class);
return dbMigrations;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ public class InitializerLogic implements ApplicationListener<ContextRefreshedEve
public void onApplicationEvent(ContextRefreshedEvent event) {
try {
val mmContext = dbMigrationManager.checkDbInitialized();
if (!mmContext.isDbInitialized()) {
boolean isDbInitialized = mmContext.isDbInitialized();
if (!isDbInitialized) {
dbMigrationManager.runDbMigration0();
dbTransactionalInitializer.insertInitialData();
}
val appliedMigrations = dbMigrationManager.runAll(mmContext, dbMigrations);
if (!isDbInitialized) {
dbTransactionalInitializer.insertInitialData();
}
dbTransactionalInitializer.initPermissions();
postProcessPatches(appliedMigrations);
dbTransactionalInitializer.initLocalizations();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.runa.wfe.commons.dbmigration.impl;

import ru.runa.wfe.commons.dbmigration.DbMigration;

public class DeleteBatchPresentationsRm3017 extends DbMigration {

@Override
protected void executeDDLBefore() {
executeUpdates("DELETE FROM BATCH_PRESENTATION WHERE CATEGORY = 'listProcessesDefinitionsHistoryForm'");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package ru.runa.wfe.commons.dbmigration.impl;

import ru.runa.wfe.commons.dbmigration.DbMigration;

public class DeleteBatchPresentationsRm3056 extends DbMigration {

@Override
protected void executeDDLBefore() {
executeUpdates("DELETE FROM BATCH_PRESENTATION WHERE CATEGORY = 'listTokenErrorsForm'");
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package ru.runa.wfe.commons.email;

import com.google.common.base.Charsets;
import com.google.common.base.Throwables;
import com.google.common.io.ByteStreams;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import org.dom4j.Element;

import ru.runa.wfe.InternalApplicationException;
import ru.runa.wfe.commons.ClassLoaderUtil;
import ru.runa.wfe.commons.xml.XmlUtils;

import com.google.common.base.Charsets;
import com.google.common.base.Throwables;
import com.google.common.io.ByteStreams;

@SuppressWarnings("unchecked")
public class EmailConfigParser {

Expand Down Expand Up @@ -47,6 +44,9 @@ public static EmailConfig parse(String configuration, boolean loadPropertiesFrom
for (Element element : commonParamElements) {
String name = element.attributeValue(NAME_ATTR);
String value = element.attributeValue(VALUE_ATTR);
if (value == null && element.hasContent()) {
value = element.getTextTrim();
}
config.getCommonProperties().put(name, value);
}
}
Expand All @@ -64,6 +64,9 @@ public static EmailConfig parse(String configuration, boolean loadPropertiesFrom
for (Element element : paramElements) {
String name = element.attributeValue(NAME_ATTR);
String value = element.attributeValue(VALUE_ATTR);
if (value == null && element.hasContent()) {
value = element.getTextTrim();
}
config.getConnectionProperties().put(name, value);
}
}
Expand All @@ -73,6 +76,9 @@ public static EmailConfig parse(String configuration, boolean loadPropertiesFrom
for (Element element : paramElements) {
String name = element.attributeValue(NAME_ATTR);
String value = element.attributeValue(VALUE_ATTR);
if (value == null && element.hasContent()) {
value = element.getTextTrim();
}
config.getHeaderProperties().put(name, value);
}
}
Expand All @@ -86,6 +92,9 @@ public static EmailConfig parse(String configuration, boolean loadPropertiesFrom
for (Element element : paramElements) {
String name = element.attributeValue(NAME_ATTR);
String value = element.attributeValue(VALUE_ATTR);
if (value == null && element.hasContent()) {
value = element.getTextTrim();
}
config.getContentProperties().put(name, value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;
import javax.mail.util.ByteArrayDataSource;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import ru.runa.wfe.ConfigurationException;
Expand All @@ -47,7 +48,7 @@
import ru.runa.wfe.var.file.FileVariable;

public class EmailUtils {
private static final Log log = LogFactory.getLog(EmailConfig.class);
private static final Log log = LogFactory.getLog(EmailUtils.class);
private static MimetypesFileTypeMap fileTypeMap = new MimetypesFileTypeMap();

/**
Expand Down Expand Up @@ -88,6 +89,7 @@ public static void sendMessage(EmailConfig config) throws Exception {

if (config.getHeaderProperties().containsKey("Subject")) {
String subject = config.getHeaderProperties().get("Subject");
subject = StringUtils.normalizeSpace(subject);
subject = MimeUtility.encodeText(subject, Charsets.UTF_8.name(), null);
config.getHeaderProperties().put("Subject", subject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import ru.runa.wfe.presentation.DefaultDbSource;
import ru.runa.wfe.presentation.FieldDescriptor;
import ru.runa.wfe.presentation.FieldFilterMode;
import ru.runa.wfe.presentation.filter.AnywhereStringFilterCriteria;
import ru.runa.wfe.security.Permission;

import static ru.runa.wfe.presentation.BatchPresentationConsts.DESC;

public class TokenErrorClassPresentation extends ClassPresentation {
public static final String PROCESS_ID = "processId";
public static final String PROCESS_TYPE = "processType";
public static final String PROCESS_NAME = "processName";
public static final String PROCESS_VERSION = "processVersion";
public static final String NODE_ID = "nodeId";
Expand All @@ -32,6 +34,8 @@ private TokenErrorClassPresentation() {
new FieldDescriptor[] {
new FieldDescriptor(PROCESS_ID, Integer.class.getName(), new DefaultDbSource(Token.class, "process.id"), true, 1, DESC,
FieldFilterMode.DATABASE, "ru.runa.common.web.html.PropertyTdBuilder", new Object[]{Permission.READ, "processId"}),
new FieldDescriptor(PROCESS_TYPE, String.class.getName(), new DefaultDbSource(Token.class, "process.deployment.category"), true,
FieldFilterMode.DATABASE, "ru.runa.common.web.html.PropertyTdBuilder", new Object[]{Permission.READ, "processType"}),
new FieldDescriptor(PROCESS_NAME, String.class.getName(), new DefaultDbSource(Token.class, "process.deployment.name"), true,
FieldFilterMode.DATABASE, "ru.runa.common.web.html.PropertyTdBuilder", new Object[]{Permission.READ, "processName"}),
new FieldDescriptor(PROCESS_VERSION, Integer.class.getName(), new DefaultDbSource(Token.class, "process.deployment.version"), true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import ru.runa.wfe.commons.ApplicationContextFactory;
import ru.runa.wfe.execution.ExecutionStatus;
import ru.runa.wfe.execution.Token;
import ru.runa.wfe.lang.NodeType;
import ru.runa.wfe.lang.ProcessDefinition;
import ru.runa.wfe.security.SecuredObjectBase;
import ru.runa.wfe.security.SecuredObjectType;

Expand All @@ -17,6 +19,7 @@ public class WfTokenError extends SecuredObjectBase {
private static final long serialVersionUID = 1L;
private Long id;
private Long processId;
private String processType;
private String processName;
private Long processVersion;
private ExecutionStatus processExecutionStatus;
Expand All @@ -31,8 +34,11 @@ public class WfTokenError extends SecuredObjectBase {
public WfTokenError(Token token, String stackTrace) {
this.id = token.getId();
this.processId = token.getProcess().getId();
this.processName = token.getProcess().getDeployment().getName();
this.processVersion = token.getProcess().getDeployment().getVersion();
ProcessDefinition processDefinition = ApplicationContextFactory.getProcessDefinitionLoader()
.getDefinition(token.getProcess().getDeployment().getId());
this.processType = processDefinition.getDeployment().getCategory();
this.processName = processDefinition.getName();
this.processVersion = processDefinition.getDeployment().getVersion();
this.processExecutionStatus = token.getProcess().getExecutionStatus();
this.nodeId = token.getNodeId();
this.nodeName = token.getNodeName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static Date evaluateDueDate(VariableProvider variableProvider, String exp
public static long evaluateDuration(VariableProvider variableProvider, String expression) {
Date dueDate = evaluateDueDate(variableProvider, expression);
long duration = new CalendarInterval(new Date(), dueDate).getLengthInMillis();
return duration;
return duration > 0 ? duration : 0;
}

public static Object evaluateVariableNotNull(VariableProvider variableProvider, String expression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package ru.runa.wfe.definition;

import ru.runa.wfe.presentation.BatchPresentationConsts;

import java.util.Date;
import ru.runa.wfe.presentation.ClassPresentation;
import ru.runa.wfe.presentation.DefaultDbSource;
Expand Down Expand Up @@ -52,8 +54,8 @@ private DefinitionHistoryClassPresentation() {
FieldFilterMode.DATABASE, "ru.runa.common.web.html.PropertyTdBuilder", new Object[] {
Permission.START_PROCESS, "name" }),
new FieldDescriptor(VERSION, Integer.class.getName(), new DefaultDbSource(Deployment.class, "version"), true,
FieldFilterMode.DATABASE, "ru.runa.common.web.html.PropertyTdBuilder", new Object[] { Permission.READ,
"version" }),
1, BatchPresentationConsts.DESC, FieldFilterMode.DATABASE, "ru.runa.common.web.html.PropertyTdBuilder",
new Object[] { Permission.READ, "version" }),
new FieldDescriptor(DESCRIPTION, String.class.getName(), new DefaultDbSource(Deployment.class, "description"), true,
FieldFilterMode.DATABASE, "ru.runa.wf.web.html.DescriptionProcessTdBuilder", new Object[] {}),
new FieldDescriptor(TYPE, AnywhereStringFilterCriteria.class.getName(), new DefaultDbSource(Deployment.class, "category"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ public Long findDeploymentIdLatestVersionBeforeDate(String name, Date date) {

/**
* queries the database for all versions of process definitions with the given name, ordered by version (descending).
*
* @deprecated use findAllDeploymentVersionIds
*/
@Deprecated
public List<Deployment> findAllDeploymentVersions(String name) {
QDeployment d = QDeployment.deployment;
return queryFactory.selectFrom(d).where(d.name.eq(name)).orderBy(d.version.desc()).fetch();
Expand Down
Loading

0 comments on commit 0ff9770

Please sign in to comment.