1 package nl.hippo.cms.workflows.reviewedactions; 2 3 import com.opensymphony.module.propertyset.PropertySet; 4 import com.opensymphony.workflow.WorkflowException; 5 import java.io.IOException ; 6 import java.util.Map ; 7 import nl.hippo.cms.Constants; 8 import nl.hippo.cms.workflows.shared.URIUtil; 9 import nl.hippo.cocoon.webdav.WebDAVHelper; 10 import org.apache.commons.httpclient.HttpState; 11 12 public class VersionOnPublicationActionIfNeededFunction extends VersionCreatingComponent 13 { 14 15 public VersionOnPublicationActionIfNeededFunction() 16 { 17 super(); 18 } 19 20 public void executeImpl(final Map transientVars, Map args, PropertySet ps) 21 throws WorkflowException 22 { 23 String location = URIUtil.getHTTPURI((String ) transientVars.get("location")); 24 HttpState httpState = (HttpState) transientVars.get("httpstate"); 25 String enablingProperty = (String ) args.get("enablingProperty"); 26 boolean shouldMakeCopyOfLiveLocation = Boolean.valueOf((String )args.get("makeCopyOfLiveLocation")).booleanValue(); 27 String shouldVersionBeCreated = ""; 28 try 29 { 30 shouldVersionBeCreated = WebDAVHelper.propfindAsString(location, Constants.CMS_1_0_NAMESPACE, 31 enablingProperty, httpState); 32 } 33 catch (IOException e) 34 { 35 } 37 if (shouldVersionBeCreated != null && shouldVersionBeCreated.equals("true")) 38 { 39 String action = (String ) args.get("action"); 40 String comment = ""; 41 String user = ""; 42 try 43 { 44 user = WebDAVHelper.propfindAsString(location, Constants.CMS_1_0_NAMESPACE, 45 Constants.LAST_WORKFLOW_USER_PROPERTY_NAME, httpState); 46 } 47 catch (IOException e) 48 { 49 } 51 createVersion(transientVars, user, action, comment, shouldMakeCopyOfLiveLocation); 52 } 53 } 54 55 } | Popular Tags |