comparison src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java @ 3:19a617578b88

Added a new method to the HttpClient that triggers the creation of a new artifact collection. http-client/trunk@1398 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 04 Mar 2011 11:49:49 +0000
parents 2fdfa20cfa63
children 19b3ba7f2568
comparison
equal deleted inserted replaced
2:2fdfa20cfa63 3:19a617578b88
40 */ 40 */
41 public class HttpClientImpl implements HttpClient { 41 public class HttpClientImpl implements HttpClient {
42 42
43 private static final Logger logger = Logger.getLogger(HttpClient.class); 43 private static final Logger logger = Logger.getLogger(HttpClient.class);
44 44
45 /** The URL path of the resource to create new artifact collections.*/
46 public static final String PATH_CREATE_COLLECTION = "/create-collection";
47
45 private String serverUrl; 48 private String serverUrl;
46 49
47 50
48 public HttpClientImpl(String serverUrl) { 51 public HttpClientImpl(String serverUrl) {
49 this.serverUrl = serverUrl; 52 this.serverUrl = serverUrl;
95 : creator.create(result); 98 : creator.create(result);
96 } 99 }
97 catch (IOException ioe) { 100 catch (IOException ioe) {
98 throw new ConnectionException( 101 throw new ConnectionException(
99 "Connection to server failed. No Artifact created."); 102 "Connection to server failed. No Artifact created.");
103 }
104 }
105
106
107 /**
108 * This method triggers the artifact servers resource to create a new
109 * artifact collection.
110 *
111 * @param create The CREATE document for the collection.
112 * @param ownerId The uuid of the creator.
113 * @param handler The handler that is used to create the result object.
114 *
115 * @return a result object created by <i>handler</i>.
116 */
117 public Object createCollection(
118 Document create,
119 String ownerId,
120 ResponseHandler handler)
121 throws ConnectionException
122 {
123 String url = serverUrl + PATH_CREATE_COLLECTION + "/" + ownerId;
124
125 try {
126 return handler.handle(doPost(url, create));
127 }
128 catch (IOException ioe) {
129 throw new ConnectionException(ioe.getMessage(), ioe);
100 } 130 }
101 } 131 }
102 132
103 133
104 @Override 134 @Override

http://dive4elements.wald.intevation.org