Skip to content

Commit 64a6f48

Browse files
committed
[#19515] Permission issue when two models conforming the same language are executed at same time
This path should be reverted when https://support.jira.obeo.fr/browse/VP-2710 will be fixed Bug: 19515
1 parent e78e825 commit 64a6f48

File tree

3 files changed

+35
-15
lines changed
  • framework
    • execution_framework/plugins
    • framework_commons/plugins/org.gemoc.xdsmlframework.api/src/org/gemoc/xdsmlframework/api/core

3 files changed

+35
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.gemoc.executionframework.engine.core;
22

33
import org.eclipse.emf.common.command.CommandStack;
4+
import org.eclipse.emf.ecore.resource.ResourceSet;
45
import org.eclipse.emf.transaction.RecordingCommand;
56
import org.eclipse.emf.transaction.TransactionalEditingDomain;
67
import org.gemoc.xdsmlframework.api.core.IExecutionCheckpoint;
@@ -12,23 +13,23 @@ private CommandExecution() {
1213

1314
public static Object execute(TransactionalEditingDomain editingDomain, RecordingCommand command) {
1415
final CommandStack commandStack = editingDomain.getCommandStack();
15-
IExecutionCheckpoint checkpoint = IExecutionCheckpoint.CHECKPOINTS.get(editingDomain.getResourceSet());
16+
ResourceSet rs = editingDomain.getResourceSet();
17+
IExecutionCheckpoint checkpoint = IExecutionCheckpoint.CHECKPOINTS.get(rs);
1618
Object result = null;
1719
try {
1820
if (checkpoint != null) {
19-
checkpoint.allow(true);
21+
checkpoint.allow(rs, true);
2022
}
2123
commandStack.execute(command);
2224
if (command.getResult() != null && command.getResult().size() == 1) {
2325
result = command.getResult().iterator().next();
2426
}
2527
} finally {
2628
if (checkpoint != null) {
27-
checkpoint.allow(false);
29+
checkpoint.allow(rs, false);
2830
}
2931
}
3032
return result;
3133
}
3234

33-
3435
}

framework/execution_framework/plugins/org.gemoc.executionframework.extensions.sirius/src/org/gemoc/executionframework/extensions/sirius/modelloader/DebugPermissionAuthority.java

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package org.gemoc.executionframework.extensions.sirius.modelloader;
22

33
import java.util.Collection;
4+
import java.util.HashMap;
5+
import java.util.Map;
46

57
import org.eclipse.emf.ecore.EObject;
8+
import org.eclipse.emf.ecore.resource.ResourceSet;
69
import org.eclipse.sirius.ecore.extender.business.api.permission.IAuthorityListener;
710
import org.eclipse.sirius.ecore.extender.business.api.permission.LockStatus;
811
import org.eclipse.sirius.ecore.extender.business.internal.permission.AbstractPermissionAuthority;
@@ -13,35 +16,49 @@ public class DebugPermissionAuthority extends AbstractPermissionAuthority
1316

1417
/**
1518
* Strictly positive if allowed.
19+
* FIXME we use a map here because of https://support.jira.obeo.fr/browse/VP-2710
1620
*/
17-
private int allow;
21+
private static final Map<ResourceSet, Integer> allow = new HashMap<ResourceSet, Integer>();
1822

19-
public void allow(boolean allow) {
23+
public void allow(ResourceSet rs, boolean allow) {
24+
Integer integer = this.allow.get(rs);
2025
if (allow) {
21-
this.allow++;
26+
if (integer == null) {
27+
this.allow.put(rs, Integer.valueOf(1));
28+
} else {
29+
this.allow.put(rs, Integer.valueOf(integer.intValue() + 1));
30+
}
2231
} else {
23-
this.allow--;
32+
if (integer == null) {
33+
this.allow.put(rs, Integer.valueOf(-1));
34+
} else {
35+
this.allow.put(rs, Integer.valueOf(integer.intValue() - 1));
36+
}
2437
}
2538
}
2639

2740
@Override
2841
public boolean canEditFeature(EObject eObj, String featureName) {
29-
return allow > 0;
42+
Integer integer = allow.get(eObj.eResource().getResourceSet());
43+
return integer != null && integer.intValue() > 0;
3044
}
3145

3246
@Override
3347
public boolean canEditInstance(EObject eObj) {
34-
return allow > 0;
48+
Integer integer = allow.get(eObj.eResource().getResourceSet());
49+
return integer != null && integer.intValue() > 0;
3550
}
36-
51+
3752
@Override
3853
public boolean canCreateIn(EObject eObj) {
39-
return allow > 0;
54+
Integer integer = allow.get(eObj.eResource().getResourceSet());
55+
return integer != null && integer.intValue() > 0;
4056
}
4157

4258
@Override
4359
public boolean canDeleteInstance(EObject target) {
44-
return allow > 0;
60+
Integer integer = allow.get(target.eResource().getResourceSet());
61+
return integer != null && integer.intValue() > 0;
4562
}
4663

4764
@Override
@@ -63,7 +80,7 @@ public void notifyInstanceDeletion(EObject instance) {
6380
public void setReportIssues(boolean report) {
6481
// nothing to do here
6582
}
66-
83+
6784
@Override
6885
public void notifyLock(Collection<? extends EObject> elements) {
6986
for (IAuthorityListener listener : listeners) {

framework/framework_commons/plugins/org.gemoc.xdsmlframework.api/src/org/gemoc/xdsmlframework/api/core/IExecutionCheckpoint.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ public interface IExecutionCheckpoint {
2121
/**
2222
* Tells if execution is allowed.
2323
*
24+
* @param rs
25+
* the {@link ResourceSet} to allow/forbid
2426
* @param allow
2527
* if <code>true</code> execution is allowed, forbidden otherwise
2628
*/
27-
void allow(boolean allow);
29+
void allow(ResourceSet rs, boolean allow);
2830
}

0 commit comments

Comments
 (0)