Skip to content

Commit

Permalink
Update dependencies to latest versions (#439)
Browse files Browse the repository at this point in the history
* Update dependencies to latest versions

This includes updates to ModelServer.
Because of API changes in the ModelServer,
some code changes were necessary.

Fix #437, #438

* Update missing plugins in launch configs

Co-authored-by: Nina Doschek <[email protected]>
  • Loading branch information
eneufeld and ndoschek authored May 4, 2022
1 parent 4ebc695 commit 1d2799d
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 178 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,25 @@
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emfcloud.modelserver.emf.common.RecordingModelResourceManager;
import org.eclipse.emfcloud.modelserver.emf.common.watchers.ModelWatchersManager;
import org.eclipse.emfcloud.modelserver.emf.configuration.EPackageConfiguration;
import org.eclipse.emfcloud.modelserver.emf.configuration.ServerConfiguration;
import org.eclipse.emfcloud.modelserver.emf.util.JsonPatchHelper;
import org.eclipse.emfcloud.modelserver.glsp.notation.epackage.NotationUtil;

import com.google.common.base.Strings;
import com.google.inject.Inject;
import com.google.inject.Provider;

public class CoffeeModelResourceManager extends RecordingModelResourceManager {

@Inject
public CoffeeModelResourceManager(Set<EPackageConfiguration> configurations, AdapterFactory adapterFactory,
ServerConfiguration serverConfiguration,final ModelWatchersManager watchersManager) {
super(configurations, adapterFactory, serverConfiguration, watchersManager);
ServerConfiguration serverConfiguration,final ModelWatchersManager watchersManager, final Provider<JsonPatchHelper> jsonPatchHelper) {
super(configurations, adapterFactory, serverConfiguration, watchersManager, jsonPatchHelper);
}

@Override
public String adaptModelUri(final String modelUri) {
URI uri = URI.createURI(modelUri, true);
if (uri.isRelative()) {
if (serverConfiguration.getWorkspaceRootURI().isFile()) {
return uri.resolve(serverConfiguration.getWorkspaceRootURI()).toString();
}
return URI.createFileURI(modelUri).toString();
}
// Create file URI from path if modelUri is already absolute path (file:/ or
// full path file:///)
// to ensure consistent usage of org.eclipse.emf.common.util.URI
if (uri.hasDevice() && !Strings.isNullOrEmpty(uri.device())) {
return URI.createFileURI(uri.device() + uri.path()).toString();
}
// In case of Windows: we cannot skip the scheme (e.g. C:)
// therefore we check if scheme is no file: scheme and then use the whole uri as
// fileURI
if (URI.validScheme(uri.scheme()) && !uri.isFile()) {
return URI.createFileURI(uri.toString()).toString();
}
return URI.createFileURI(uri.path()).toString();
}


@Override
protected void loadSourceResources(final String directoryPath) {
Expand All @@ -72,14 +50,11 @@ protected void loadSourceResources(final String directoryPath) {
if (isSourceDirectory(file)) {
loadSourceResources(file.getAbsolutePath());
} else if (file.isFile()) {
URI absolutePath = createURI(file.getAbsolutePath());
if (CoffeeResource.FILE_EXTENSION.equals(absolutePath.fileExtension())) {
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
.put(CoffeeResource.FILE_EXTENSION, CoffeeResource.Factory.INSTANCE);
resourceSets.put(absolutePath, resourceSet);
}
loadResource(absolutePath.toString());
URI modelURI = createURI(file.getAbsolutePath());
if (modelURI.fileExtension().equals(CoffeeResource.FILE_EXTENSION)) {
resourceSets.put(modelURI, resourceSetFactory.createResourceSet(modelURI));
}
loadResource(modelURI.toString());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,121 +11,27 @@
package org.eclipse.emfcloud.coffee.modelserver;

import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

import org.apache.log4j.Logger;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emfcloud.modelserver.client.ModelServerClient;
import org.eclipse.emfcloud.modelserver.client.ModelServerNotification;
import org.eclipse.emfcloud.modelserver.client.Response;
import org.eclipse.emfcloud.modelserver.client.SubscriptionListener;
import org.eclipse.emfcloud.modelserver.common.ModelServerPathParameters;
import org.eclipse.emfcloud.modelserver.client.v1.ModelServerClientV1;
import org.eclipse.emfcloud.modelserver.common.ModelServerPathParametersV1;
import org.eclipse.emfcloud.modelserver.common.codecs.DecodingException;
import org.eclipse.emfcloud.modelserver.common.codecs.Codec;
import org.eclipse.emfcloud.modelserver.common.codecs.DefaultJsonCodec;
import org.eclipse.emfcloud.modelserver.common.codecs.XmiCodec;
import org.eclipse.emfcloud.modelserver.emf.common.JsonResponseMember;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.eclipse.emfcloud.modelserver.emf.configuration.EPackageConfiguration;

import com.google.common.collect.ImmutableSet;
public class CoffeeModelServerClient extends ModelServerClientV1 {

import okhttp3.Request;
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;

public class CoffeeModelServerClient extends ModelServerClient {
private static final Map<String, Codec> SUPPORTED_COFFEE_FORMATS = Map.of(
ModelServerPathParametersV1.FORMAT_JSON, new DefaultJsonCodec(),
ModelServerPathParametersV1.FORMAT_XMI, new XmiCodec(),
CoffeeResource.FILE_EXTENSION, new CoffeeCodec());

private Map<String, List<WebSocket>> coffeeOpenSockets = new HashMap<>();

private static final Set<String> DEFAULT_SUPPORTED_FORMATS = ImmutableSet.of(ModelServerPathParameters.FORMAT_JSON,
ModelServerPathParameters.FORMAT_XMI, CoffeeResource.FILE_EXTENSION);

private static Logger LOGGER = Logger.getLogger(CoffeeModelServerClient.class.getSimpleName());

public CoffeeModelServerClient(final String baseUrl) throws MalformedURLException {
super(baseUrl);
}

@Override
protected boolean isSupportedFormat(final String format) {
return DEFAULT_SUPPORTED_FORMATS.contains(format);
}

@Override
public Optional<EObject> decode(final String payload, final String format) {
try {
if (format.equals(CoffeeResource.FILE_EXTENSION)) {
return new CoffeeCodec().decode(payload);
} else if (format.equals(ModelServerPathParametersV1.FORMAT_XMI)) {
return new XmiCodec().decode(payload);
}
return new DefaultJsonCodec().decode(payload);
} catch (DecodingException e) {
LOGGER.error("Decoding of " + payload + " with " + format + " format failed");
}
return Optional.empty();
}

protected void doSubscribe(final String modelUri, final SubscriptionListener subscriptionListener,
final Request request) {
final WebSocket socket = client.newWebSocket(request, new WebSocketListener() {
@Override
public void onOpen(@NotNull final WebSocket webSocket, @NotNull final okhttp3.Response response) {
subscriptionListener.onOpen(new Response<>(response, body -> require(Optional.ofNullable(body))));
}

@Override
public void onMessage(@NotNull final WebSocket webSocket, @NotNull final String text) {
Optional<String> type = CoffeeModelServerClient.this.parseJsonField(text, JsonResponseMember.TYPE);
Optional<String> data = CoffeeModelServerClient.this.parseJsonField(text, JsonResponseMember.DATA);
subscriptionListener.onNotification(new ModelServerNotification(type.orElse("unknown"), data));
}

@Override
public void onClosing(@NotNull final WebSocket webSocket, final int code, @NotNull final String reason) {
subscriptionListener.onClosing(code, reason);
}

@Override
public void onClosed(@NotNull final WebSocket webSocket, final int code, @NotNull final String reason) {
subscriptionListener.onClosed(code, reason);
}

@Override
public void onFailure(@NotNull final WebSocket webSocket, @NotNull final Throwable t,
@Nullable final okhttp3.Response response) {
if (response != null) {
subscriptionListener.onFailure(t, new Response<>(response));
} else {
subscriptionListener.onFailure(t);
}
}
});
List<WebSocket> list = coffeeOpenSockets.get(modelUri);
if (list == null) {
List<WebSocket> arrayList = new ArrayList<WebSocket>();
arrayList.add(socket);
coffeeOpenSockets.put(modelUri, arrayList);
} else {
list.add(socket);
coffeeOpenSockets.put(modelUri, list);
}
}

@Override
public boolean unsubscribe(final String modelUri) {
final List<WebSocket> webSocket = coffeeOpenSockets.get(modelUri);
if (webSocket != null) {
webSocket.forEach(socket -> socket.close(1000, "Websocket closed by client."));
return true;
}
return false;
}
public CoffeeModelServerClient(final String baseUrl, final EPackageConfiguration... configurations)
throws MalformedURLException {
super(baseUrl, SUPPORTED_COFFEE_FORMATS, configurations);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emfcloud.modelserver.glsp.notation.model;bundle-version="0.7.0",
org.eclipse.emfcloud.modelserver.glsp.notation.commands;bundle-version="0.7.0"
Export-Package: org.eclipse.emfcloud.coffee.workflow.glsp.server
Import-Package: org.eclipse.emfcloud.modelserver.emf.common
Import-Package: org.eclipse.emfcloud.modelserver.emf.common,
org.eclipse.emfcloud.modelserver.emf.configuration

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import org.eclipse.emfcloud.coffee.modelserver.CoffeeModelServerClient;
import org.eclipse.emfcloud.coffee.modelserver.CoffeeResource;
import org.eclipse.emfcloud.modelserver.client.ModelServerClient;
import org.eclipse.emfcloud.modelserver.client.v1.ModelServerClientV1;
import org.eclipse.emfcloud.modelserver.glsp.EMSGLSPServer;
import org.eclipse.emfcloud.modelserver.glsp.notation.epackage.NotationUtil;
import org.eclipse.glsp.server.protocol.DisposeClientSessionParameters;
Expand All @@ -26,13 +26,13 @@
public class WorkflowGLSPServer extends EMSGLSPServer {

@Override
protected ModelServerClient createModelServerClient(final String modelServerURL) throws MalformedURLException {
protected ModelServerClientV1 createModelServerClient(final String modelServerURL) throws MalformedURLException {
return new CoffeeModelServerClient(modelServerURL);
}

@Override
public CompletableFuture<Void> disposeClientSession(final DisposeClientSessionParameters params) {
Optional<ModelServerClient> modelServerClient = modelServerClientProvider.get();
Optional<ModelServerClientV1> modelServerClient = modelServerClientProvider.get();
if (modelServerClient.isPresent()) {
String sourceURI = ClientOptionsUtil.getSourceUri(params.getArgs())
.orElseThrow(() -> new GLSPServerException("No source URI given to dispose client session!"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
import org.eclipse.emfcloud.coffee.modelserver.commands.contributions.SetFlowSourceCommandContribution;
import org.eclipse.emfcloud.coffee.modelserver.commands.contributions.SetFlowTargetCommandContribution;
import org.eclipse.emfcloud.coffee.modelserver.commands.util.SemanticCommandUtil;
import org.eclipse.emfcloud.modelserver.client.ModelServerClient;
import org.eclipse.emfcloud.modelserver.client.Response;
import org.eclipse.emfcloud.modelserver.client.v1.ModelServerClientV1;
import org.eclipse.emfcloud.modelserver.command.CCommand;
import org.eclipse.emfcloud.modelserver.command.CCompoundCommand;
import org.eclipse.emfcloud.modelserver.emf.common.EMFFacetConstraints;
Expand All @@ -60,7 +60,7 @@ public class WorkflowModelServerAccess extends EMSNotationModelServerAccess {

private ValidationFramework validationFramework;

public WorkflowModelServerAccess(String sourceURI, ModelServerClient modelServerClient,
public WorkflowModelServerAccess(String sourceURI, ModelServerClientV1 modelServerClient,
ActionDispatcher actionDispatcher) {
super(sourceURI, modelServerClient, CoffeeResource.FILE_EXTENSION, NotationUtil.NOTATION_EXTENSION);
Preconditions.checkNotNull(modelServerClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Optional;

import org.apache.log4j.Logger;
import org.eclipse.emfcloud.modelserver.client.ModelServerClient;
import org.eclipse.emfcloud.modelserver.client.v1.ModelServerClientV1;
import org.eclipse.emfcloud.modelserver.glsp.model.EMSModelSourceLoader;
import org.eclipse.glsp.server.features.core.model.RequestModelAction;
import org.eclipse.glsp.server.model.GModelState;
Expand All @@ -32,7 +32,7 @@ public void loadSourceModel(final RequestModelAction action) {
LOGGER.error("No source URI given to load source models");
return;
}
Optional<ModelServerClient> modelServerClient = modelServerClientProvider.get();
Optional<ModelServerClientV1> modelServerClient = modelServerClientProvider.get();
if (modelServerClient.isEmpty()) {
LOGGER.error("Connection to modelserver could not be initialized");
return;
Expand All @@ -58,7 +58,7 @@ public void loadSourceModel(final RequestModelAction action) {
}

@Override
public WorkflowModelServerAccess createModelServerAccess(String sourceURI, ModelServerClient modelServerClient) {
public WorkflowModelServerAccess createModelServerAccess(String sourceURI, ModelServerClientV1 modelServerClient) {
return new WorkflowModelServerAccess(sourceURI, modelServerClient, actionDispatcher);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
<plugin id="org.eclipse.equinox.registry"/>
<plugin id="org.eclipse.equinox.security"/>
<plugin id="org.eclipse.equinox.security.linux" fragment="true"/>
<plugin id="org.eclipse.equinox.security.linux.x86_64" fragment="true"/>
<plugin id="org.eclipse.equinox.security.ui"/>
<plugin id="org.eclipse.equinox.simpleconfigurator"/>
<plugin id="org.eclipse.glsp.graph"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<setEntry value="org.apache.commons.logging@default:default"/>
<setEntry value="org.apache.felix.scr@1:true"/>
<setEntry value="org.apache.log4j@default:default"/>
<setEntry value="org.apache.logging.log4j@default:default"/>
<setEntry value="org.apache.xmlgraphics@default:default"/>
<setEntry value="org.eclipse.ant.core@default:default"/>
<setEntry value="org.eclipse.compare.core@default:default"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<setAttribute key="deselected_workspace_bundles"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../runtime-workflowanalyzer.product"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
Expand All @@ -41,6 +42,7 @@
<setEntry value="org.apache.commons.lang@default:default"/>
<setEntry value="org.apache.commons.logging@default:default"/>
<setEntry value="org.apache.log4j@default:default"/>
<setEntry value="org.apache.logging.log4j@default:default"/>
<setEntry value="org.apiguardian@default:default"/>
<setEntry value="org.eclipse.core.contenttype@default:default"/>
<setEntry value="org.eclipse.core.expressions@default:default"/>
Expand Down Expand Up @@ -103,6 +105,7 @@
<setEntry value="org.junit.platform.launcher@default:default"/>
<setEntry value="org.junit.platform.runner@default:default"/>
<setEntry value="org.junit.platform.suite.api@default:default"/>
<setEntry value="org.junit.platform.suite.commons@default:default"/>
<setEntry value="org.junit.vintage.engine@default:default"/>
<setEntry value="org.junit@default:default"/>
<setEntry value="org.objectweb.asm@default:default"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<setAttribute key="deselected_workspace_bundles"/>
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location" value="${workspace_loc}/../runtime-workflowdsl.product"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
Expand Down Expand Up @@ -43,6 +44,7 @@
<setEntry value="org.apache.commons.logging@default:default"/>
<setEntry value="org.apache.felix.scr@2:true"/>
<setEntry value="org.apache.log4j@default:default"/>
<setEntry value="org.apache.logging.log4j@default:default"/>
<setEntry value="org.eclipse.core.contenttype@default:default"/>
<setEntry value="org.eclipse.core.expressions@default:default"/>
<setEntry value="org.eclipse.core.filesystem.linux.x86_64@default:false"/>
Expand Down Expand Up @@ -97,7 +99,6 @@
<setEntry value="org.eclipse.xtext.xbase.lib@default:default"/>
<setEntry value="org.eclipse.xtext.xbase@default:default"/>
<setEntry value="org.eclipse.xtext@default:default"/>
<setEntry value="org.emfjson.jackson@default:default"/>
<setEntry value="org.objectweb.asm@default:default"/>
<setEntry value="org.slf4j.api@default:default"/>
</setAttribute>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<setEntry value="org.apache.commons.logging@default:default"/>
<setEntry value="org.apache.felix.scr@1:true"/>
<setEntry value="org.apache.log4j@default:default"/>
<setEntry value="org.apache.logging.log4j@default:default"/>
<setEntry value="org.apache.xmlgraphics@default:default"/>
<setEntry value="org.eclipse.ant.core@default:default"/>
<setEntry value="org.eclipse.compare.core@default:default"/>
Expand Down Expand Up @@ -164,7 +165,6 @@
<setEntry value="org.eclipse.urischeme@default:default"/>
<setEntry value="org.eclipse.xtext.logging@default:false"/>
<setEntry value="org.eclipse.xtext.xbase.lib@default:default"/>
<setEntry value="org.emfjson.jackson@default:default"/>
<setEntry value="org.hamcrest.core@default:default"/>
<setEntry value="org.hamcrest.integration@default:default"/>
<setEntry value="org.hamcrest.library@default:default"/>
Expand Down
Loading

0 comments on commit 1d2799d

Please sign in to comment.