Last posts…

As of beginning 2013 I no longer work with Alfresco. This page will be kept online, but no new posts will be added by myself. Thanks for reading ! Michiel


Copy a Noderef – either Non-Recursive or Recursive

I am replacing the CrossRepositoryCopyService().copy action since we are going from multiple repo’s to one. So I am replacing this service..

// RECURSIVE copy – but specific for multiple repo’s.
serviceRegistry.getCrossRepositoryCopyService() .copy(src, dst,new_name);


So I started by re-using the FileFolderService to copy a node from A to B. This works great, but it only copies the node & leaves all children of the source untouched (and more importantly un-copied)  => Non-recursive copy. The FileFolderService() has no recursive copy action available.

// Non-RECURSIVE copy of one node
FileInfo finf = serviceRegistry.getFileFolderService().copy(src, dst, new_name);
return finf.getNodeRef();
There are quite a lot of copy actions available in Alfresco, but this one seems quite elegant. Also the service name alone gives me some hope of giving me what i need.
Enter the CopyService()



NodeRef copy2 = serviceRegistry.getCopyService().copy(src, dst, ContentModel.ASSOC_CHILDREN, QName.createQName(new_name), true);

and since I am here now – it also has a usefull


NodeRef copy = this.copyService.copy(src, dst, ContentModel.ASSOC_CHILDREN, QName.createQName(“newname”));
Big thanks to :

Override authentication component

Change this authentication component;

<bean id=”authenticationComponent” parent=”authenticationComponentBase”>
<property name=”accept” value=”true” />
<property name=”supportNtlm” value=”true” />
<property name=”allowGuestLogin”> <value>${alfresco.authentication.allowGuestLogin}</value>  </property>
<property name=”nodeService”>  <ref bean=”nodeService” />  </property>
<property name=”personService”>  <ref bean=”personService” />  </property>
<property name=”transactionService”>  <ref bean=”transactionService” />  </property>
<property name=”defaultAdministratorUserNames”>  <set>  <value>${alfresco_user_store.adminusername}</value>   <value>admin</value>     </set>  </property>
<property name=”defaultGuestUserNames”>    <set>        <value>${alfresco_user_store.guestusername}</value>     </set>  </property>

Skips the authentication.
Accepts all passwords.
Login as admin to reset admin password.
Re-enable the authentication.

I`ll keep this post here – but I can’t get it to work..

Running java code as a different user.

We run into quite some issues with security – this is due to our solution. Our task based security solution needs to update files/folder (noderefs) from user X while the system (the workflow task) is currently assigned to user Y.

This construction helped us somewhat;

String test = AuthenticationUtil.runAs(new RunAsWork<String>() {
                public String doWork() throws Exception {

                          …. do some stuff ….

                 } // end public doWork
            }, AuthenticationUtil.getSystemUserName());


But now I also found this blog – this also helps me with current sys user settings.