comparison gwt-client/src/main/java/org/dive4elements/river/client/server/CollectionAttributeServiceImpl.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-client/src/main/java/org/dive4elements/river/client/server/CollectionAttributeServiceImpl.java@821a02bbfb4e
children 172338b1407f
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.client.server;
2
3 import org.w3c.dom.Document;
4
5 import org.apache.log4j.Logger;
6
7 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils;
8
9 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException;
10 import org.dive4elements.artifacts.httpclient.http.HttpClient;
11 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl;
12 import org.dive4elements.artifacts.httpclient.http.response.DocumentResponseHandler;
13
14 import org.dive4elements.river.client.shared.exceptions.ServerException;
15 import org.dive4elements.river.client.shared.model.Collection;
16
17 import org.dive4elements.river.client.client.services.CollectionAttributeService;
18
19
20 /**
21 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
22 */
23 public class CollectionAttributeServiceImpl
24 extends DescribeCollectionServiceImpl
25 implements CollectionAttributeService
26 {
27 private static final Logger logger =
28 Logger.getLogger(CollectionAttributeServiceImpl.class);
29
30
31 public static final String ERROR_UPDATING_COLLECTION_ATTRIBUTE =
32 "error_update_collection_attribute";
33
34
35 public Collection update(Collection collection, String locale)
36 throws ServerException
37 {
38 logger.info("CollectionAttributeServiceImpl.update");
39
40 String url = getServletContext().getInitParameter("server-url");
41
42 Document attribute = CollectionHelper.createAttribute(collection);
43 Document action = ClientProtocolUtils.newSetAttributeDocument(
44 collection.identifier(),
45 attribute);
46
47 try {
48 HttpClient http = new HttpClientImpl(url, locale);
49 Document res = (Document) http.doCollectionAction(
50 action,
51 collection.identifier(),
52 new DocumentResponseHandler());
53
54 logger.debug("Collection attribute successfully set.");
55
56 return describe(collection.identifier(), locale);
57 }
58 catch (ConnectionException ce) {
59 logger.error(ce, ce);
60 }
61
62 throw new ServerException(ERROR_UPDATING_COLLECTION_ATTRIBUTE);
63 }
64 }
65 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org