Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
Issue imixs#168
  • Loading branch information
rsoika committed Feb 6, 2023
1 parent f48eb7b commit dbb78ab
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.eclipse.glsp.server.features.core.model.SourceModelStorage;
import org.eclipse.glsp.server.model.GModelState;
import org.eclipse.glsp.server.utils.ClientOptionsUtil;
import org.eclipse.glsp.server.utils.MapUtil;
import org.openbpmn.bpmn.BPMNModel;
import org.openbpmn.bpmn.exceptions.BPMNModelException;
import org.openbpmn.bpmn.util.BPMNModelFactory;
Expand Down Expand Up @@ -60,7 +61,13 @@ public void loadSourceModel(final RequestModelAction action) {
logger.fine("loading BPMN Meta model....");
Map<String, String> options = action.getOptions();
boolean bNeedsClientLayout = Boolean.parseBoolean(options.get("needsClientLayout"));
String uri = options.get("uri");
// resolve file location....
String uri = MapUtil.getValue(options, "sourceUri").orElse(null);
if (uri == null || uri.isEmpty()) {
// fallback
uri = options.get("uri");
}

String diagramType = options.get("diagramType");
if (bNeedsClientLayout && uri != null && BPMNDiagramConfiguration.DIAGRAM_TYPE.equals(diagramType)) {
final File file = convertToFile(modelState);
Expand All @@ -79,17 +86,25 @@ public void loadSourceModel(final RequestModelAction action) {

@Override
public void saveSourceModel(final SaveModelAction action) {

Map<String, String> options = modelState.getClientOptions();
String filePath = options.get("uri");
// resolve file location....
String uri = MapUtil.getValue(options, "sourceUri").orElse(null);
if (uri == null || uri.isEmpty()) {
// fallback
uri = options.get("uri");
}
Optional<String> uriOpt = action.getFileUri();
if (uriOpt.isPresent() && !uriOpt.isEmpty()) {
// we got a new URI which means we have a 'saveAs' situaiton!
filePath = uriOpt.get();
uri = uriOpt.get();
}
BPMNModel model = modelState.getBpmnModel();
try {
java.net.URI targetURI = new URI(filePath);
// check protocol
if (!uri.contains("://")) {
uri = "file://" + uri;
}
java.net.URI targetURI = new URI(uri);
model.save(targetURI);
} catch (URISyntaxException e) {
logger.severe("Invalid Target URI: " + e.getMessage());
Expand Down

0 comments on commit dbb78ab

Please sign in to comment.