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.workflows.shared.FunctionProviderComponent; 8 import nl.hippo.cms.workflows.shared.URIUtil; 9 import org.apache.commons.httpclient.HttpClient; 10 import org.apache.commons.httpclient.HttpState; 11 import org.apache.commons.httpclient.methods.DeleteMethod; 12 13 public class RemoveObjectFromLiveRepositoryFunction extends FunctionProviderComponent 14 { 15 16 public RemoveObjectFromLiveRepositoryFunction() 17 { 18 super(); 19 } 20 21 public void executeImpl(Map transientVars, Map args, PropertySet ps) throws WorkflowException 22 { 23 DeleteMethod delete = null; 24 try 25 { 26 String previewLocation = (String ) transientVars.get("location"); 27 String liveLocation = URIUtil.getHTTPURI(URIUtil.getLiveURI(previewLocation)); 28 HttpState httpState = (HttpState) transientVars.get("httpstate"); 29 HttpClient httpClient = new HttpClient(); 30 httpClient.setState(httpState); 31 delete = new DeleteMethod(liveLocation); 32 delete.setDoAuthentication(true); 33 int deleteResult = httpClient.executeMethod(delete); 34 RepositoryHelper.deletePathIfDangling(liveLocation, httpClient); 36 } 37 catch (IOException e) 38 { 39 throw new WorkflowException(e); 40 } 41 finally 42 { 43 if (delete != null) 44 { 45 delete.releaseConnection(); 46 } 47 } 48 } 49 50 } | Popular Tags |