ingo@526: package de.intevation.flys.client.server; ingo@526: ingo@530: import org.w3c.dom.Document; ingo@530: ingo@530: import de.intevation.artifacts.common.utils.ClientProtocolUtils; ingo@530: ingo@530: import de.intevation.artifacts.httpclient.exceptions.ConnectionException; ingo@530: import de.intevation.artifacts.httpclient.http.HttpClient; ingo@530: import de.intevation.artifacts.httpclient.http.HttpClientImpl; ingo@530: import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; ingo@530: ingo@526: import de.intevation.flys.client.shared.exceptions.ServerException; ingo@526: import de.intevation.flys.client.shared.model.Collection; ingo@526: ingo@526: import de.intevation.flys.client.client.services.CollectionAttributeService; ingo@526: ingo@526: ingo@526: /** ingo@526: * @author Ingo Weinzierl ingo@526: */ ingo@526: public class CollectionAttributeServiceImpl ingo@526: extends DescribeCollectionServiceImpl ingo@526: implements CollectionAttributeService ingo@526: { ingo@530: public static final String ERROR_UPDATING_COLLECTION_ATTRIBUTE = ingo@530: "error_update_collection_attribute"; ingo@530: ingo@530: ingo@526: public Collection update(Collection collection, String url, String locale) ingo@526: throws ServerException ingo@526: { ingo@526: System.out.println("CollectionAttributeServiceImpl.update"); ingo@526: ingo@530: Document attribute = CollectionHelper.createAttribute(collection); ingo@530: Document action = ClientProtocolUtils.newSetAttributeDocument( ingo@530: collection.identifier(), ingo@530: attribute); ingo@530: ingo@526: try { ingo@530: HttpClient http = new HttpClientImpl(url, locale); ingo@530: Document res = (Document) http.doCollectionAction( ingo@530: action, ingo@530: collection.identifier(), ingo@530: new DocumentResponseHandler()); ingo@530: ingo@530: System.out.println("Collection attribute successfully set."); ingo@530: ingo@530: return describe(collection.identifier(), url, locale); ingo@526: } ingo@530: catch (ConnectionException ce) { ingo@530: System.err.println(ce.getLocalizedMessage()); ingo@526: } ingo@526: ingo@530: throw new ServerException(ERROR_UPDATING_COLLECTION_ATTRIBUTE); ingo@526: } ingo@526: } ingo@526: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :