Skip to content

Commit

Permalink
Merge branch 'master' into github
Browse files Browse the repository at this point in the history
  • Loading branch information
dofs197 committed Aug 2, 2020
2 parents 43760fb + bd2c672 commit 0166a12
Show file tree
Hide file tree
Showing 150 changed files with 3,112 additions and 2,230 deletions.
7 changes: 7 additions & 0 deletions plugins/ru.runa.gpd.app/gpd.product
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
<feature id="ru.runa.gpd.form.quick.feature" version="4.4.0.qualifier"/>
</features>

<configurations>
<plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="4" />
<plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="2" />
<plugin id="org.eclipse.osgi" autoStart="true" startLevel="0" />
</configurations>

<preferencesInfo>
<targetfile overwrite="false"/>
Expand Down
5 changes: 2 additions & 3 deletions plugins/ru.runa.gpd.connector.wfe.ws/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
<?eclipse version="3.4"?>
<plugin>
<extension
point="ru.runa.gpd.wfeConnectors">
point="ru.runa.gpd.wfeServerConnectors">
<connector
class="ru.runa.gpd.connector.wfe.ws.WildflyWebServicesConnector"
defaultPort="8080"
class="ru.runa.gpd.connector.wfe.ws.WildflyWebServiceWfeServerConnector"
description="%wildfly.ws.connector.description"
id="wildfly.ws"
name="%wildfly.ws.connector.name">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
package ru.runa.gpd.connector.wfe.ws;

import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.CharStreams;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.List;
import java.util.Map;

import javax.xml.ws.soap.SOAPFaultException;

import org.eclipse.core.runtime.IProgressMonitor;

import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.CharStreams;

import ru.runa.gpd.Activator;
import ru.runa.gpd.PluginLogger;
import ru.runa.gpd.wfe.WFEServerConnector;
import ru.runa.gpd.sync.WfeServerConnector;
import ru.runa.wfe.bot.Bot;
import ru.runa.wfe.bot.BotStation;
import ru.runa.wfe.bot.BotStationDoesNotExistException;
Expand All @@ -25,6 +18,8 @@
import ru.runa.wfe.definition.DefinitionDoesNotExistException;
import ru.runa.wfe.definition.DefinitionNameMismatchException;
import ru.runa.wfe.definition.dto.WfDefinition;
import ru.runa.wfe.user.Actor;
import ru.runa.wfe.user.Group;
import ru.runa.wfe.webservice.AuthenticationAPI;
import ru.runa.wfe.webservice.AuthenticationWebService;
import ru.runa.wfe.webservice.BotAPI;
Expand All @@ -33,66 +28,28 @@
import ru.runa.wfe.webservice.DataSourceWebService;
import ru.runa.wfe.webservice.DefinitionAPI;
import ru.runa.wfe.webservice.DefinitionWebService;
import ru.runa.wfe.webservice.Executor;
import ru.runa.wfe.webservice.ExecutorAPI;
import ru.runa.wfe.webservice.ExecutorWebService;
import ru.runa.wfe.webservice.Relation;
import ru.runa.wfe.webservice.RelationAPI;
import ru.runa.wfe.webservice.RelationWebService;
import ru.runa.wfe.webservice.SystemAPI;
import ru.runa.wfe.webservice.SystemWebService;
import ru.runa.wfe.webservice.User;
import ru.runa.wfe.webservice.WfExecutor;

public abstract class AbstractWebServicesConnector extends WFEServerConnector {
public abstract class AbstractWebServiceWfeServerConnector extends WfeServerConnector {
private User user;

protected abstract URL getUrl(String serviceName);

protected String getBaseUrl() {
final String PROTOCOL_SPLITTER = "://";
String host = Activator.getPrefString(P_WFE_CONNECTION_HOST);
String port = Activator.getPrefString(P_WFE_CONNECTION_PORT);
String protocol = Activator.getPrefString(P_WFE_CONNECTION_PROTOCOL);
if (protocol == null) {
protocol = "http";
}
if (host != null) {
String[] hostProtocol = host.split(PROTOCOL_SPLITTER);
if (hostProtocol.length == 1) {
host = protocol + PROTOCOL_SPLITTER + host;
}
}
return host + ":" + port;
}

protected String getVersion() {
String version = Activator.getPrefString(P_WFE_CONNECTION_VERSION);
if ("auto".equalsIgnoreCase(version)) {
String url = getBaseUrl() + "/wfe/version";
try {
InputStreamReader reader = new InputStreamReader(new URL(url).openStream());
version = CharStreams.toString(reader);
int colonIndex = version.indexOf(":");
if (colonIndex != -1) {
version = version.substring(colonIndex + 1);
}
reader.close();
} catch (Exception e) {
throw new RuntimeException("Unable to acquire version using " + url);
}
}
return version;
}

@Override
public void connect() {
AuthenticationAPI authenticationAPI = new AuthenticationWebService(getUrl("Authentication")).getAuthenticationAPIPort();
if (LOGIN_MODE_LOGIN_PASSWORD.equals(Activator.getPrefString(P_WFE_CONNECTION_LOGIN_MODE))) {
String login = Activator.getPrefString(P_WFE_CONNECTION_LOGIN);
String password = getPassword();
if (AUTHENTICATION_TYPE_LOGIN_PASSWORD.equals(settings.getAuthenticationType())) {
String password = settings.getPassword();
if (password == null) {
return;
}
user = authenticationAPI.authenticateByLoginPassword(login, password);
user = authenticationAPI.authenticateByLoginPassword(settings.getLogin(), password);
} else {
user = authenticationAPI.authenticateByKerberos(getKerberosToken());
}
Expand All @@ -103,34 +60,17 @@ public void disconnect() throws Exception {
user = null;
}

private User getUser() {
if (user == null) {
connect();
} else {
try {
// check user is up to date
getExecutorService().getExecutor(user, user.getActor().getId());
} catch (SOAPFaultException e) {
if (e.getMessage() == null || !e.getMessage().contains("Error in subject decryption")) {
Throwables.propagate(e);
}
connect();
}
}
return user;
}

private ExecutorAPI getExecutorService() {
return new ExecutorWebService(getUrl("Executor")).getExecutorAPIPort();
}

@Override
public Map<String, Boolean> getExecutors() {
List executors = getExecutorService().getExecutors(getUser(), null);
List<WfExecutor> executors = getExecutorService().getExecutors(getUser(), null);
Map<String, Boolean> result = Maps.newHashMapWithExpectedSize(executors.size());
for (Executor executor : (List<WfExecutor>) executors) {
// group sign
result.put(executor.getName(), executor.getFullName() == null);
for (WfExecutor executor : executors) {
if (Actor.class.getName().equals(executor.getExecutorClassName())) {
result.put(executor.getName(), false);
}
if (Group.class.getName().equals(executor.getExecutorClassName())) {
result.put(executor.getName(), true);
}
}
return result;
}
Expand All @@ -146,33 +86,20 @@ public List<String> getRelationNames() {
return result;
}

private DefinitionAPI getDefinitionService() {
return new DefinitionWebService(getUrl("Definition")).getDefinitionAPIPort();
@Override
public List<WfDefinition> getProcessDefinitions() {
DefinitionAPI api = getDefinitionService();
return WfDefinitionAdapter.toDTOs(api.getProcessDefinitions(getUser(), null, false));
}

@Override
public Map<WfDefinition, List<WfDefinition>> getProcessDefinitions(IProgressMonitor monitor) {
public List<WfDefinition> getProcessDefinitionHistory(WfDefinition definition) {
DefinitionAPI api = getDefinitionService();
List<WfDefinition> latestDefinitions = WfDefinitionAdapter.toDTOs(api.getProcessDefinitions(getUser(), null, false));
Map<WfDefinition, List<WfDefinition>> result = Maps.newHashMapWithExpectedSize(latestDefinitions.size());
monitor.worked(30);
double perDefinition = (double) 70 / latestDefinitions.size();
for (WfDefinition latestDefinition : latestDefinitions) {
List<WfDefinition> historyDefinitions = Lists.newArrayList();
if (isLoadProcessDefinitionsHistory()) {
try {
historyDefinitions = WfDefinitionAdapter.toDTOs(api.getProcessDefinitionHistory(getUser(), latestDefinition.getName()));
if (!historyDefinitions.isEmpty()) {
historyDefinitions.remove(0);
}
} catch (Exception e) {
PluginLogger.logErrorWithoutDialog("definition '" + latestDefinition.getName() + "' sync", e);
}
}
result.put(latestDefinition, historyDefinitions);
monitor.internalWorked(perDefinition);
List<WfDefinition> list = WfDefinitionAdapter.toDTOs(api.getProcessDefinitionHistory(getUser(), definition.getName()));
if (!list.isEmpty()) {
list.remove(0);
}
return result;
return list;
}

@Override
Expand Down Expand Up @@ -230,17 +157,14 @@ public WfDefinition redeployProcessDefinitionArchive(Long definitionId, byte[] p
}
}

private BotAPI getBotService() {
return new BotWebService(getUrl("Bot")).getBotAPIPort();
}

@Override
public Map<Bot, List<BotTask>> getBots() {
User user = getUser();
Map<Bot, List<BotTask>> result = Maps.newHashMap();
List<BotStation> botStations = BotStationAdapter.toDTOs(getBotService().getBotStations());
for (BotStation botStation : botStations) {
for (Bot bot : BotAdapter.toDTOs(getBotService().getBots(getUser(), botStation.getId()))) {
result.put(bot, BotTaskAdapter.toDTOs(getBotService().getBotTasks(getUser(), bot.getId())));
for (Bot bot : BotAdapter.toDTOs(getBotService().getBots(user, botStation.getId()))) {
result.put(bot, BotTaskAdapter.toDTOs(getBotService().getBotTasks(user, bot.getId())));
}
}
return result;
Expand Down Expand Up @@ -280,10 +204,6 @@ public List<BotStation> getBotStations() {
return BotStationAdapter.toDTOs(getBotService().getBotStations());
}

private DataSourceAPI getDataSourceService() {
return new DataSourceWebService(getUrl("DataSource")).getDataSourceAPIPort();
}

@Override
public void deployDataSourceArchive(byte[] archive) {
getDataSourceService().importDataSource(getUser(), archive);
Expand All @@ -299,4 +219,63 @@ public List<String> getDataSourceNames() {
return getDataSourceService().getNames();
}

protected abstract URL getUrl(String serviceName);

protected String getVersion() {
String version = settings.getVersion();
if (version == null) {
String url = settings.getUrl() + "/wfe/version";
try {
InputStreamReader reader = new InputStreamReader(new URL(url).openStream());
version = CharStreams.toString(reader);
int colonIndex = version.indexOf(":");
if (colonIndex != -1) {
version = version.substring(colonIndex + 1);
}
reader.close();
} catch (Exception e) {
throw new RuntimeException("Unable to acquire version using " + url);
}
settings.setVersion(version);
}
return version;
}

private User getUser() {
if (user == null) {
connect();
} else {
try {
// check user is up to date
getSystemService().login(user);
} catch (SOAPFaultException e) {
if (e.getMessage() == null || !e.getMessage().contains("Error in subject decryption")) {
Throwables.propagate(e);
}
connect();
}
}
return user;
}

private ExecutorAPI getExecutorService() {
return new ExecutorWebService(getUrl("Executor")).getExecutorAPIPort();
}

private DefinitionAPI getDefinitionService() {
return new DefinitionWebService(getUrl("Definition")).getDefinitionAPIPort();
}

private BotAPI getBotService() {
return new BotWebService(getUrl("Bot")).getBotAPIPort();
}

private DataSourceAPI getDataSourceService() {
return new DataSourceWebService(getUrl("DataSource")).getDataSourceAPIPort();
}

private SystemAPI getSystemService() {
return new SystemWebService(getUrl("System")).getSystemAPIPort();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
import java.net.MalformedURLException;
import java.net.URL;

public class WildflyWebServicesConnector extends AbstractWebServicesConnector {
public class WildflyWebServiceWfeServerConnector extends AbstractWebServiceWfeServerConnector {

@Override
protected URL getUrl(String serviceName) {
try {
String version = getVersion();
return new URL(getBaseUrl() + "/wfe-service-" + version + "/" + serviceName + "WebService/" + serviceName + "API?wsdl");
return new URL(settings.getUrl() + "/wfe-service-" + version + "/" + serviceName + "WebService/" + serviceName + "API?wsdl");
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import ru.runa.gpd.formeditor.ftl.ComponentTypeRegistry;
import ru.runa.gpd.formeditor.resources.Messages;
import ru.runa.gpd.formeditor.settings.PreferencePage;
import ru.runa.gpd.ui.custom.SWTUtils;
import ru.runa.gpd.ui.custom.SwtUtils;
import ru.runa.gpd.ui.dialog.ChooseComponentLabelDialog;

public class ComponentParametersDialog extends Dialog {
Expand Down Expand Up @@ -80,7 +80,7 @@ protected Control createDialogArea(Composite parent) {
final Composite parametersComposite = (Composite) super.createDialogArea(scrolledComposite);
parametersComposite.setLayout(new GridLayout());

SWTUtils.createLabel(parametersComposite, Messages.getString("ComponentParametersDialog.component"));
SwtUtils.createLabel(parametersComposite, Messages.getString("ComponentParametersDialog.component"));
Composite compComposite = new Composite(parametersComposite, SWT.NONE);
compComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
compComposite.setLayout(new GridLayout(2, false));
Expand Down Expand Up @@ -144,7 +144,7 @@ public void widgetSelected(SelectionEvent e) {
private void drawParameters(Composite parametersComposite) {
parameterEditors.clear();
for (final ComponentParameter componentParameter : component.getType().getParameters()) {
SWTUtils.createLabel(parametersComposite, componentParameter.getLabel()).setToolTipText(componentParameter.getDescription());
SwtUtils.createLabel(parametersComposite, componentParameter.getLabel()).setToolTipText(componentParameter.getDescription());
Object editor = componentParameter.getType().createEditor(parametersComposite, component, componentParameter,
component.getParameterValue(componentParameter), new PropertyChangeListener() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import ru.runa.gpd.Localization;
import ru.runa.gpd.formeditor.resources.Messages;
import ru.runa.gpd.ui.custom.LoggingSelectionAdapter;
import ru.runa.gpd.ui.custom.SWTUtils;
import ru.runa.gpd.ui.custom.SwtUtils;

import com.google.common.collect.Lists;

Expand Down Expand Up @@ -57,10 +57,10 @@ protected Control createDialogArea(Composite parent) {
java.util.List<String> availableList = Lists.newArrayList(availableNames);
availableList.removeAll(selectedValues);
availableItems = createList(area, availableList, true);
addButton = SWTUtils.createButton(area, Localization.getString("button.add"), new AddRemoveVariableSelectionListener(true));
removeButton = SWTUtils.createButton(area, Localization.getString("button.delete"), new AddRemoveVariableSelectionListener(false));
moveUpButton = SWTUtils.createButton(area, Localization.getString("button.up"), new MoveVariableSelectionListener(true));
moveDownButton = SWTUtils.createButton(area, Localization.getString("button.down"), new MoveVariableSelectionListener(false));
addButton = SwtUtils.createButton(area, Localization.getString("button.add"), new AddRemoveVariableSelectionListener(true));
removeButton = SwtUtils.createButton(area, Localization.getString("button.delete"), new AddRemoveVariableSelectionListener(false));
moveUpButton = SwtUtils.createButton(area, Localization.getString("button.up"), new MoveVariableSelectionListener(true));
moveDownButton = SwtUtils.createButton(area, Localization.getString("button.down"), new MoveVariableSelectionListener(false));
selectedItems = createList(area, selectedValues, false);
return area;
}
Expand Down
Loading

0 comments on commit 0166a12

Please sign in to comment.