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 :


Date Calendar GregorianCalendar

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;


If I extract a date from a node in Alfresco, I cannot cast directly to Calendar or GregorianCalendar. So I cast the Serializable return type from Alfresco to the Date class.
Date d = (java.util.Date) nodeService.getProperty(nr, INCENTROmodel.STARTDATE);


But java.util.Date is depricated since Java 1.1
The date.getTime() function still works.
It return the amount of ms since the beginning of time (aka 1 jan 1970)
long gt = d.getTime();


And the GregorianCalendar knows this. So
GregorianCalendar gc = new GregorianCalendar();

Post no. 3_million_and_1 about the java.util.Date / java.util.Calendar / java.util.GregorianCalendar

Custom Behaviour

I`m trying to make my own custom behaviour in alfresco 3.4.4
This led me to a great example from the ECMArchitect – Jeff Potts.

Last week I got stuck on setting up & configuring his examples code.
I installed ANT and got that running, but Jeff’s example told me I had to configure the file.

(original version) 


After some searching I changed it into this : 


I didn’t have the SDK from alfresco installed, but now I downloaded it from the WIKI
( you should get this one: “Software Development Kit, including the source files” )

Unzipped to c: and referred the links to there. Then apparently we need to change windows backslashes (\\\\\\\\) into linux forwardslashes (////////)
Go figure….

So far so good, but I got some errors running ant in the C:\behavior-article\ folder.
This was solved by adjusting this line in the build.xml file :


<javac srcdir="${source.dir}" destdir="${bin.dir}" source="1.5" target="1.5" debug="on" fork="yes">
	<classpath refid="classpath"/>

(my new version)

<javac srcdir="${source.dir}" destdir="${bin.dir}" source="1.5" target="1.5" includeantruntime="true" >
	<classpath refid="classpath"/>

And so after adjusting this, it compiled correctly.
The ant deploy as described in jeff’s article worked in one go.
( as it should, but i was happy to see it working now)

And so now I get to play around the custom behaviour example….