teichmann@5835: package org.dive4elements.river.client.server; ingo@526: ingo@530: import org.w3c.dom.Document; ingo@530: ingo@1367: import org.apache.log4j.Logger; ingo@1367: teichmann@5835: import org.dive4elements.artifacts.common.utils.ClientProtocolUtils; ingo@530: teichmann@5835: import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException; teichmann@5835: import org.dive4elements.artifacts.httpclient.http.HttpClient; teichmann@5835: import org.dive4elements.artifacts.httpclient.http.HttpClientImpl; teichmann@5835: import org.dive4elements.artifacts.httpclient.http.response.DocumentResponseHandler; ingo@530: teichmann@5835: import org.dive4elements.river.client.shared.exceptions.ServerException; teichmann@5835: import org.dive4elements.river.client.shared.model.Collection; ingo@526: teichmann@5835: import org.dive4elements.river.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@1367: private static final Logger logger = ingo@1367: Logger.getLogger(CollectionAttributeServiceImpl.class); ingo@1367: ingo@1367: ingo@530: public static final String ERROR_UPDATING_COLLECTION_ATTRIBUTE = ingo@530: "error_update_collection_attribute"; ingo@530: ingo@530: raimund@1425: public Collection update(Collection collection, String locale) ingo@526: throws ServerException ingo@526: { ingo@1367: logger.info("CollectionAttributeServiceImpl.update"); ingo@526: raimund@1425: String url = getServletContext().getInitParameter("server-url"); raimund@1425: 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@1367: logger.debug("Collection attribute successfully set."); ingo@530: raimund@1425: return describe(collection.identifier(), locale); ingo@526: } ingo@530: catch (ConnectionException ce) { ingo@1367: logger.error(ce, ce); 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 :