[CDO] IllegalStateException when saving custom Permission [message #1764420] |
Mon, 29 May 2017 14:53 |
Bastien BARET Messages: 12 Registered: February 2017 |
Junior Member |
|
|
Hello,
I want to create my own Permission to allow access to a particular Object in my resource because ResourceFilter is not enough fine-grained for my needs. To do that, I extended the CDO security model and I created a new EClass in my ecore which extends Permission from the security ecore model and I reimplemented the isApplicable method.
Here is how I create this new object and how I add it to the security model:
MyPermission permission = MyModelFactory.eINSTANCE.createMyPermission();
// Set "permission" attributes needed
role.getPermissions().add(permission);
When I commit the transaction (at the end of the modified method from my security manager), I got a DBStore rollback because of an IllegalStateException "Missing ID mapping for oid...".
I'm using an H2 DB.
I guess I'm missing something crucial but I can't get it.
Thank you!
[Updated on: Mon, 29 May 2017 15:02] Report message to a moderator
|
|
|
|
|
|
Re: [CDO] IllegalStateException when saving custom Permission [message #1764659 is a reply to message #1764533] |
Thu, 01 June 2017 08:39 |
Bastien BARET Messages: 12 Registered: February 2017 |
Junior Member |
|
|
Ok, I found where exactly I got the TimeoutException: when I try to retrieve an EObject in my isApplicable method: view.getObject(someCDOID)). The strange thing is that the Timeout doesn't appear in the first execution of this method but after some execution.
Basically, I just want to achieve per object permission with inheritance. For example, when I create a permission, I want all contained objects (subtree) to be affected by this permission. However, I want to be able to stop this inheritance at some point.
To do that, I added a boolean attribute to all of my EObject (MyObject is a supertype of all my model) to know if the current object inherits permission from his parent (eContainer).
Implementation of the isAplicable method of my custom PermissionFilter (I retrieve the object using the code from ObjectFilterImpl):
@Override
public boolean isApplicable(CDORevision cdoRevision, CDORevisionProvider cdoRevisionProvider, CDOBranchPoint cdoBranchPoint, int i) throws Exception {
CDOView view = PermissionUtil.getView(cdoRevisionProvider);
if (view == null)
return false;
CDOObject currentObject = view.getObject(cdoRevision.getID()); //Timeout right here after some execution (stack trace in my previous message)
if (currentObject == null)
return false;
CDOObject target = this.getTarget(); //Reference of the object affected by this permission
if (target == null)
return false;
if (cible.cdoID().equals(objetConcerne.cdoID())) //Easy case: this permission target the current object
return true;
// Here, we try to find if a parent has the permission (inheritance) by testing recursively all parents only if the boolean inheritedPermission is true
while (currentObject instanceof MyObject && ((MyObject) currentObject).isInheritedPermission() && currentObject.eContainer() != null) {
currentObject = (CDOObject) currentObject.eContainer();
if (currentObject.cdoID().equals(target.cdoID()))
return true;
}
return false;
}
Maybe It's the wrong way to do that, I don't know.
By the way, I upgraded to CDO 4.5
[Updated on: Thu, 01 June 2017 08:41] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03657 seconds