1 package nl.hippo.cms.workflows.multiplesitesdocument; 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.repositorylocation.CommonRepositoryLocationRoles; 9 import nl.hippo.cms.repositorylocation.RepositoryLocation; 10 import nl.hippo.cocoon.webdav.WebDAVHelper; 11 import org.apache.avalon.framework.service.ServiceException; 12 import org.apache.commons.httpclient.HttpState; 13 14 public class SaveDraftFunction extends VersionCreatingComponent 15 { 16 17 public SaveDraftFunction() 18 { 19 super(); 20 } 21 22 public void executeImpl(Map transientVars, Map args, PropertySet ps) 23 throws WorkflowException 24 { 25 String action = "save draft"; 26 String comment = (String ) transientVars.get("versionComment"); 27 if (comment == null) 28 { 29 comment = ""; 30 } 31 try 32 { 33 RepositoryLocation editorRepo = (RepositoryLocation) m_manager 34 .lookup(CommonRepositoryLocationRoles.EDITOR_REPOSITORY_LOCATION_ROLE); 35 try 36 { 37 String location = editorRepo.getRepositoryInformation().getAbsoluteUri(ps.getString("location")); 38 HttpState httpState = (HttpState) transientVars.get("httpstate"); 39 String user = ""; 40 try 41 { 42 user = WebDAVHelper.propfindAsString(location, Constants.CMS_1_0_NAMESPACE, 43 Constants.LAST_WORKFLOW_USER_PROPERTY_NAME, httpState); 44 } 45 catch (IOException e) 46 { 47 } 49 createVersion(transientVars, ps, user, action, comment); 50 } 51 finally 52 { 53 m_manager.release(editorRepo); 54 } 55 } 56 catch (ServiceException e) 57 { 58 throw new WorkflowException(e); 59 } 60 } 61 62 } | Popular Tags |