ingo@99: package de.intevation.flys.client.server; ingo@99: ingo@99: import org.w3c.dom.Document; ingo@99: ingo@1367: import org.apache.log4j.Logger; ingo@1367: ingo@99: import com.google.gwt.user.server.rpc.RemoteServiceServlet; ingo@99: ingo@99: import de.intevation.artifacts.common.utils.ClientProtocolUtils; ingo@99: ingo@99: import de.intevation.artifacts.httpclient.exceptions.ConnectionException; ingo@99: import de.intevation.artifacts.httpclient.http.HttpClient; ingo@99: import de.intevation.artifacts.httpclient.http.HttpClientImpl; ingo@99: import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; ingo@99: ingo@215: import de.intevation.flys.client.shared.exceptions.ServerException; ingo@99: import de.intevation.flys.client.shared.model.Collection; ingo@905: ingo@99: import de.intevation.flys.client.client.services.DescribeCollectionService; ingo@99: ingo@99: ingo@99: /** ingo@99: * This service implements a method that queries the DESCRIBE document of a ingo@99: * specific collection and returns a Collection object with the information of ingo@99: * the document. ingo@99: * ingo@99: * @author Ingo Weinzierl ingo@99: */ ingo@99: public class DescribeCollectionServiceImpl ingo@99: extends RemoteServiceServlet ingo@99: implements DescribeCollectionService ingo@99: { ingo@1367: private static final Logger logger = ingo@1367: Logger.getLogger(DescribeCollectionServiceImpl.class); ingo@1367: ingo@1367: ingo@215: /** The error message key that is thrown if an error occured while ingo@215: * describe() a Collection.*/ ingo@215: public static final String ERROR_DESCRIBE_COLLECTION = ingo@215: "error_describe_collection"; ingo@215: ingo@215: raimund@1425: public Collection describe(String uuid, String locale) ingo@215: throws ServerException ingo@215: { ingo@1367: logger.info("DescribeCollectionServiceImpl.describe"); ingo@99: raimund@1425: String url = getServletContext().getInitParameter("server-url"); raimund@1425: ingo@99: Document describe = ClientProtocolUtils.newDescribeCollectionDocument( ingo@99: uuid); ingo@99: raimund@1425: HttpClient client = new HttpClientImpl(url, locale); ingo@99: ingo@99: try { ingo@99: Document response = (Document) client.doCollectionAction( ingo@99: describe, uuid, new DocumentResponseHandler()); ingo@99: ingo@905: Collection c = CollectionHelper.parseCollection(response); ingo@99: ingo@99: if (c == null) { ingo@215: throw new ServerException(ERROR_DESCRIBE_COLLECTION); ingo@99: } ingo@99: ingo@1367: logger.debug("Collection successfully parsed."); ingo@524: ingo@99: return c; ingo@99: } ingo@99: catch (ConnectionException ce) { ingo@1367: logger.error(ce, ce); ingo@99: } ingo@99: ingo@215: throw new ServerException(ERROR_DESCRIBE_COLLECTION); ingo@99: } ingo@99: } ingo@99: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :