cancel
Showing results for 
Search instead for 
Did you mean: 

lockStore in RunAs context

vincent-kali
Star Contributor
Star Contributor
Hi
I'm trying to develop a Web Script to lock/unlock contents on behalf
of different users. To do this, I first tried to execute LockStore methods
in 'RunAs' mode. After reading the code I discovered that LockStore methods
are using FullyAuthenticatedUser instead of RunAsUser.
Then I started to develop my own LockStore class (ks2LockStore) to make use of RunAsUser.
This class is a copy of existing LockStore class, with some minor modification.
The class is declared in core-services-context.xml as follow:
 
    <bean id="ks2LockStoreFactory" class="org.alfresco.repo.lock.mem.ks2.Ks2DefaultLockStoreFactory"/>

    <bean id="ks2LockStore" factory-bean="ks2LockStoreFactory" factory-method="createLockStore"/>

    <bean id="ks2LockableAspectInterceptor" class="org.alfresco.repo.lock.mem.ks2.Ks2LockableAspectInterceptor">
        <property name="nodeService" ref="mlAwareNodeService"/>
        <property name="ks2LockStore" ref="ks2LockStore"/>
        <property name="authenticationService" ref="authenticationService"/>
    </bean>

Then I call ks2LockStore from my webscript. Everything seems to work fine except that LockableAspectInterceptor
does not do the job: locks are set in memory, but cm:aspect isn't spoofed by LockableAspectInterceptor.
Then content is not seen as locked in share interface.

If I understand correctly, I thing that I need to modify lockService to inject ks2LockStore into it. But I'd like
to avoid modifying lockService source code as it may have unexpectable side effects.

Any suggestion is welcome,
Thanks for your help,
Vincent






4 REPLIES 4

vincent-kali
Star Contributor
Star Contributor
Hi,
I think the only way to do that (using RunAs user in LockStore 'set' method) is to override the spring beans
of lockStore.
Could somebody confirm that ?
I just don't know how to do that. Could somebody help me ?
Some examples ?

Thanks,
Vincent


vincent-kali
Star Contributor
Star Contributor

Hi
Some updates regarding my issue above:
I'm now trying to override the 'org.alfresco.repo.lock.mem' package with 'org.alfresco.repo.lock.mem.ks2',
to make use of RunAs user in code.

I put the following declaration in module-context.xml file


   <bean id="lockStoreFactory" class="org.alfresco.repo.lock.mem.ks2.DefaultLockStoreFactory"/>
    <bean id="lockStore" factory-bean="lockStoreFactory" factory-method="createLockStore"/>
    <bean id="lockableAspectInterceptor" class="org.alfresco.repo.lock.mem.ks2.LockableAspectInterceptor">
        <property name="nodeService" ref="mlAwareNodeService"/>
        <property name="lockStore" ref="lockStore"/>
        <property name="authenticationService" ref="authenticationService"/>
    </bean>

And I get the following error at startup:

      
Error creating bean with name 'org.springframework.aop.framework.ProxyFactoryBean#250ee2f3': FactoryBean threw exception
on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'lockableAspectInterceptor' defined in class path resource [alfresco/core-services-context.xml]: Initialization of bean failed;
nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type
'org.alfresco.repo.lock.mem.ks2.LockStoreImpl' to required type 'org.alfresco.repo.lock.mem.LockStore' for property 'lockStore';
nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.alfresco.repo.lock.mem.ks2.LockStoreImpl]
to required type [org.alfresco.repo.lock.mem.LockStore] for property 'lockStore': no matching editors or conversion strategy found


I just don't know how to proceed…..
One simple question: is it just possible to override LockService/LockStore ?
If yes, please advice.

Thanks,
Vincent

mrogers
Star Contributor
Star Contributor
Why are you trying to use the lock store directly?    What's wrong with the Lock Service?



I want to lock/unlock nodes on behalf of other users.
When dealing with EPHEMERAL locks (which is my case) LockService is calling LockStore to get/set LockState from/to memory.
As LockState is using the FullyAuthenticatedUser, I can't set a LockState to renew a lock or unlock a node already locked.
This is my problem. That's why I want to modify the setLockState method to allow impersonate using RunAs user.
I'm now trying to override the corresponding class (LockStoreImpl), and package as an AMP module..
Do you thing it's would be a "correct" way to proceed ?

Thanks,
Vincent