Skip to content

Instantly share code, notes, and snippets.

@jreijn
Created July 18, 2012 10:59
Show Gist options
  • Save jreijn/3135554 to your computer and use it in GitHub Desktop.
Save jreijn/3135554 to your computer and use it in GitHub Desktop.
import java.rmi.RemoteException;
import java.util.Map;
import java.util.TreeMap;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import org.hippoecm.repository.api.MappingException;
import org.hippoecm.repository.api.WorkflowContext;
import org.hippoecm.repository.api.WorkflowException;
import org.hippoecm.repository.standardworkflow.FolderWorkflowImpl;
/**
* @author Jeroen Reijn
*/
public class CustomFolderWorkflowImpl extends FolderWorkflowImpl {
private Node currentFolderNode;
public CustomFolderWorkflowImpl(WorkflowContext context, Session userSession, Session rootSession, Node subject) throws RemoteException, RepositoryException {
super(context, userSession, rootSession, subject);
}
@Override
public String add(final String category, final String template, final Map<String, String> arguments) throws WorkflowException, MappingException, RepositoryException, RemoteException {
Map<String, String> extended = new TreeMap<String, String>(arguments);
String dynamicPropertyValue = "somevalue";
//the first argument should match the name of the argument within the hippostd:modify property value after the $ sign
//so in this case it should be generatedid because it's matching the $generatedid property in the query template
extended.put("generatedid",dynamicPropertyValue);
return super.add(category, template, extended);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" sv:name="new-address">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hippostd:templatequery</sv:value>
</sv:property>
<sv:property sv:name="jcr:mixinTypes" sv:type="Name">
<sv:value>hippo:translated</sv:value>
<sv:value>hippostd:translated</sv:value>
</sv:property>
<sv:property sv:name="jcr:statement" sv:type="String">
<sv:value>hippo:namespaces/address/document/hipposysedit:prototypes/hipposysedit:prototype</sv:value>
</sv:property>
<sv:property sv:name="hippostd:modify" sv:type="String">
<sv:value>./hippotranslation:locale</sv:value>
<sv:value>$inherited</sv:value>
<sv:value>./hippotranslation:id</sv:value>
<sv:value>$uuid</sv:value>
<sv:value>./address:generatedproperty</sv:value>
<sv:value>$generatedid</sv:value>
</sv:property>
<sv:property sv:name="jcr:language" sv:type="String">
<sv:value>xpath</sv:value>
</sv:property>
<sv:property sv:name="hippostd:icon" sv:type="String">
<sv:value>adddocument_ico</sv:value>
</sv:property>
<sv:node sv:name="hippo:translation">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hippo:translation</sv:value>
</sv:property>
<sv:property sv:name="hippo:language" sv:type="String">
<sv:value>nl</sv:value>
</sv:property>
<sv:property sv:name="hippo:message" sv:type="String">
<sv:value>adres</sv:value>
</sv:property>
</sv:node>
<sv:node sv:name="hippo:translation">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hippo:translation</sv:value>
</sv:property>
<sv:property sv:name="hippo:language" sv:type="String">
<sv:value>en</sv:value>
</sv:property>
<sv:property sv:name="hippo:message" sv:type="String">
<sv:value>address</sv:value>
</sv:property>
</sv:node>
</sv:node>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment