Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] IllegalStateException when saving custom Permission
[CDO] IllegalStateException when saving custom Permission [message #1764420] Mon, 29 May 2017 14:53 Go to next message
Bastien BARET is currently offline Bastien BARETFriend
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 #1764451 is a reply to message #1764420] Tue, 30 May 2017 04:04 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
It's better to create an implementation of org.eclipse.emf.cdo.security.PermissionFilter and use it with org.eclipse.emf.cdo.security.FilterPermission. What CDO version are you using?

Re: [CDO] IllegalStateException when saving custom Permission [message #1764506 is a reply to message #1764451] Tue, 30 May 2017 15:12 Go to previous messageGo to next message
Bastien BARET is currently offline Bastien BARETFriend
Messages: 12
Registered: February 2017
Junior Member
Thank you for your help! I really appreciate it.

Ok, I will try to use PermissionFilter. I'm using CDO 4.4.
Since my last post, I successfully solved the previous exception (I forgot to specify my ID...) but now I got a TimeoutException when I'm trying to log in with another user than Administrator which hasn't the role "All Objects Writer".
The error appears when I try to read the content of a CDOResource:
EObject root = transaction.getOrCreateResource(myFile).getContents().get(0);


Stack :
Quote:

[ERROR] java.util.concurrent.TimeoutException
org.eclipse.emf.cdo.common.util.TransportException: java.util.concurrent.TimeoutException
at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol.send(CDOClientProtocol.java:565)
at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol.send(CDOClientProtocol.java:590)
at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol.loadRevisions(CDOClientProtocol.java:202)
at org.eclipse.emf.cdo.internal.common.revision.CDORevisionManagerImpl.loadRevisions(CDORevisionManagerImpl.java:431)
at org.eclipse.emf.cdo.internal.common.revision.CDORevisionManagerImpl.getRevisions(CDORevisionManagerImpl.java:309)
at org.eclipse.emf.cdo.internal.common.revision.CDORevisionManagerImpl.getRevision(CDORevisionManagerImpl.java:291)
at org.eclipse.emf.cdo.internal.common.revision.CDORevisionManagerImpl.getRevision(CDORevisionManagerImpl.java:284)
at org.eclipse.emf.internal.cdo.view.CDOViewImpl.getRevision(CDOViewImpl.java:775)
at org.eclipse.emf.internal.cdo.view.AbstractCDOView.createObject(AbstractCDOView.java:1271)
at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getObject(AbstractCDOView.java:1168)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.getObject(CDOTransactionImpl.java:1233)
at org.eclipse.emf.internal.cdo.view.AbstractCDOView.convertIDToObject(AbstractCDOView.java:1516)
at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertIDToObject(CDOStoreImpl.java:689)
at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertToEMF(CDOStoreImpl.java:657)
at org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper.getValueFromRevision(CDOLegacyWrapper.java:825)
at org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper.revisionToInstanceFeature(CDOLegacyWrapper.java:620)
at org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper.revisionToInstance(CDOLegacyWrapper.java:494)
at org.eclipse.emf.internal.cdo.object.CDOLegacyWrapper.cdoInternalPostLoad(CDOLegacyWrapper.java:369)
at org.eclipse.emf.internal.cdo.view.AbstractCDOView.cleanObject(AbstractCDOView.java:1375)
at org.eclipse.emf.internal.cdo.view.AbstractCDOView.createObject(AbstractCDOView.java:1290)
at org.eclipse.emf.internal.cdo.view.AbstractCDOView.getObject(AbstractCDOView.java:1168)
at org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl.getObject(CDOTransactionImpl.java:1233)
at org.eclipse.emf.internal.cdo.view.AbstractCDOView.convertIDToObject(AbstractCDOView.java:1516)
at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertIDToObject(CDOStoreImpl.java:689)
at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.convertToEMF(CDOStoreImpl.java:657)
at org.eclipse.emf.internal.cdo.view.CDOStoreImpl.get(CDOStoreImpl.java:170)
at org.eclipse.emf.ecore.impl.EStoreEObjectImpl$BasicEStoreEList.delegateGet(EStoreEObjectImpl.java:241)
at org.eclipse.emf.common.util.DelegatingEList.get(DelegatingEList.java:230)
at com.some.package.SomeClass.someMethod(SomeClass.java:42)

Caused by: java.util.concurrent.TimeoutException
at org.eclipse.net4j.util.io.IOTimeoutException.createTimeoutException(IOTimeoutException.java:46)
at org.eclipse.net4j.signal.Signal.runSync(Signal.java:279)
at org.eclipse.net4j.signal.SignalProtocol.startSignal(SignalProtocol.java:466)
at org.eclipse.net4j.signal.RequestWithConfirmation.doSend(RequestWithConfirmation.java:89)
at org.eclipse.net4j.signal.RequestWithConfirmation.send(RequestWithConfirmation.java:75)
at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientProtocol.send(CDOClientProtocol.java:557)
... 38 more
Caused by: org.eclipse.net4j.util.io.IOTimeoutException
at org.eclipse.net4j.buffer.BufferInputStream.computeTimeout(BufferInputStream.java:250)
at org.eclipse.net4j.buffer.BufferInputStream.ensureBuffer(BufferInputStream.java:210)
at org.eclipse.net4j.buffer.BufferInputStream.read(BufferInputStream.java:132)
at java.io.DataInputStream.readBoolean(DataInputStream.java:242)
at org.eclipse.net4j.util.io.ExtendedDataInput$Delegating.readBoolean(ExtendedDataInput.java:67)
at org.eclipse.emf.cdo.spi.common.protocol.CDODataInputImpl.readCDORevision(CDODataInputImpl.java:430)
at org.eclipse.emf.cdo.spi.common.protocol.CDODataInputImpl.readCDORevision(CDODataInputImpl.java:425)
at org.eclipse.emf.cdo.spi.common.revision.RevisionInfo.readRevision(RevisionInfo.java:225)
at org.eclipse.emf.cdo.spi.common.revision.RevisionInfo.readResult(RevisionInfo.java:165)
at org.eclipse.emf.cdo.internal.net4j.protocol.LoadRevisionsRequest.confirming(LoadRevisionsRequest.java:142)
at org.eclipse.emf.cdo.internal.net4j.protocol.LoadRevisionsRequest.confirming(LoadRevisionsRequest.java:1)
at org.eclipse.emf.cdo.internal.net4j.protocol.CDOClientRequest.confirming(CDOClientRequest.java:97)
at org.eclipse.net4j.signal.RequestWithConfirmation.doExtendedInput(RequestWithConfirmation.java:125)
at org.eclipse.net4j.signal.Signal.doInput(Signal.java:369)
at org.eclipse.net4j.signal.RequestWithConfirmation.doExecute(RequestWithConfirmation.java:105)
at org.eclipse.net4j.signal.SignalActor.execute(SignalActor.java:53)
at org.eclipse.net4j.signal.Signal.runSync(Signal.java:275)
... 42 more


Curiously, it doesn't appear when MyPermission.isApplicable return always true. I'm just comparing the given object ID with the attribute of MMPermission:

@Override
public boolean isApplicable(CDORevision cdoRevision, CDORevisionProvider cdoRevisionProvider, CDOBranchPoint cdoBranchPoint) {

     return PermissionUtil.getView(cdoRevisionProvider).getObject(cdoRevision.getID()).cdoID().equals(this.getTargetID());
}
Re: [CDO] IllegalStateException when saving custom Permission [message #1764533 is a reply to message #1764506] Wed, 31 May 2017 04:37 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
There's nothing that immediately pops into my mind. I'd need to try to reproduce the problem. Can you submit a bugzilla and attach an executable piece of code that demonstrates the problem?

And please upgrade to at least CDO 4.5. If a bug fix will be needed it will be applied to CDO 4.6, which is to be released very soon.


Re: [CDO] IllegalStateException when saving custom Permission [message #1764659 is a reply to message #1764533] Thu, 01 June 2017 08:39 Go to previous message
Bastien BARET is currently offline Bastien BARETFriend
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

Previous Topic:XML serialization
Next Topic:AddCommand Undo
Goto Forum:
  


Current Time: Sat Apr 20 04:25:23 GMT 2024

Powered by FUDForum. Page generated in 0.03657 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top