comparison flys-client/src/main/java/de/intevation/flys/client/server/CollectionAttributeServiceImpl.java @ 530:26e38b79658d

Connected the CollectionAttributeService with the artifact server - Collection modifications will now be stored in the artifact databae. flys-client/trunk@2018 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 27 May 2011 08:59:26 +0000
parents 96e60e0a4345
children ab8eb2f544f2
comparison
equal deleted inserted replaced
529:a1048d310829 530:26e38b79658d
1 package de.intevation.flys.client.server; 1 package de.intevation.flys.client.server;
2
3 import org.w3c.dom.Document;
4
5 import de.intevation.artifacts.common.utils.ClientProtocolUtils;
6
7 import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
8 import de.intevation.artifacts.httpclient.http.HttpClient;
9 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
10 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler;
2 11
3 import de.intevation.flys.client.shared.exceptions.ServerException; 12 import de.intevation.flys.client.shared.exceptions.ServerException;
4 import de.intevation.flys.client.shared.model.Collection; 13 import de.intevation.flys.client.shared.model.Collection;
5 14
6 import de.intevation.flys.client.client.services.CollectionAttributeService; 15 import de.intevation.flys.client.client.services.CollectionAttributeService;
11 */ 20 */
12 public class CollectionAttributeServiceImpl 21 public class CollectionAttributeServiceImpl
13 extends DescribeCollectionServiceImpl 22 extends DescribeCollectionServiceImpl
14 implements CollectionAttributeService 23 implements CollectionAttributeService
15 { 24 {
25 public static final String ERROR_UPDATING_COLLECTION_ATTRIBUTE =
26 "error_update_collection_attribute";
27
28
16 public Collection update(Collection collection, String url, String locale) 29 public Collection update(Collection collection, String url, String locale)
17 throws ServerException 30 throws ServerException
18 { 31 {
19 System.out.println("CollectionAttributeServiceImpl.update"); 32 System.out.println("CollectionAttributeServiceImpl.update");
20 33
21 // TODO Implement the correct update process here! 34 Document attribute = CollectionHelper.createAttribute(collection);
35 Document action = ClientProtocolUtils.newSetAttributeDocument(
36 collection.identifier(),
37 attribute);
38
22 try { 39 try {
23 Thread.currentThread().sleep(5000); 40 HttpClient http = new HttpClientImpl(url, locale);
41 Document res = (Document) http.doCollectionAction(
42 action,
43 collection.identifier(),
44 new DocumentResponseHandler());
45
46 System.out.println("Collection attribute successfully set.");
47
48 return describe(collection.identifier(), url, locale);
24 } 49 }
25 catch (InterruptedException ie) { 50 catch (ConnectionException ce) {
26 // do nothing 51 System.err.println(ce.getLocalizedMessage());
27 } 52 }
28 53
29 return describe(collection.identifier(), url, locale); 54 throw new ServerException(ERROR_UPDATING_COLLECTION_ATTRIBUTE);
30 } 55 }
31 } 56 }
32 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 57 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org