KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nl > hippo > cms > workflows > multiplesitesdocument > RemoveObjectFromEditorRepositoryFunction


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 JavaDoc;
6 import java.util.Map JavaDoc;
7 import nl.hippo.cms.repositorylocation.CommonRepositoryLocationRoles;
8 import nl.hippo.cms.repositorylocation.RepositoryInformation;
9 import nl.hippo.cms.repositorylocation.RepositoryLocation;
10 import nl.hippo.cms.workflows.shared.FunctionProviderComponent;
11 import org.apache.avalon.framework.service.ServiceException;
12 import org.apache.commons.httpclient.HttpClient;
13 import org.apache.commons.httpclient.HttpState;
14 import org.apache.commons.httpclient.methods.DeleteMethod;
15
16 public class RemoveObjectFromEditorRepositoryFunction extends FunctionProviderComponent
17 {
18
19     public RemoveObjectFromEditorRepositoryFunction()
20     {
21         super();
22     }
23
24     public void executeImpl(Map JavaDoc transientVars, Map JavaDoc args, PropertySet ps) throws WorkflowException
25     {
26         DeleteMethod delete = null;
27         try
28         {
29             String JavaDoc relativeUri = ps.getString("location");
30             RepositoryLocation editorRepoLocation= (RepositoryLocation) m_manager.lookup(CommonRepositoryLocationRoles.EDITOR_REPOSITORY_LOCATION_ROLE);
31             try
32             {
33                 RepositoryInformation editorRepoInformation = editorRepoLocation.getRepositoryInformation();
34                 String JavaDoc editorLocation = editorRepoInformation
35                         .getAbsoluteUri(relativeUri);
36                 HttpState httpState = (HttpState) transientVars.get("httpstate");
37                 HttpClient httpClient = new HttpClient();
38                 httpClient.setState(httpState);
39                 delete = new DeleteMethod(editorLocation);
40                 delete.setDoAuthentication(true);
41                 int deleteResult = httpClient.executeMethod(delete);
42                 // TODO: handle result
43
}
44             finally
45             {
46                 m_manager.release(editorRepoLocation);
47             }
48         }
49         catch (IOException JavaDoc e)
50         {
51             throw new WorkflowException(e);
52         }
53         catch (ServiceException e)
54         {
55             throw new WorkflowException(e);
56         }
57         finally
58         {
59             if (delete != null)
60             {
61                 delete.releaseConnection();
62             }
63         }
64     }
65
66 }
Popular Tags