ingo@99: package de.intevation.flys.client.server; ingo@99: ingo@99: import org.w3c.dom.Document; ingo@99: 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@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: ingo@229: public Collection describe(String uuid, String serverUrl, String locale) ingo@215: throws ServerException ingo@215: { ingo@99: System.out.println("DescribeCollectionServiceImpl.describe"); ingo@99: ingo@99: Document describe = ClientProtocolUtils.newDescribeCollectionDocument( ingo@99: uuid); ingo@99: ingo@229: HttpClient client = new HttpClientImpl(serverUrl, 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@524: System.out.println("Collection successfully parsed."); ingo@524: ingo@99: return c; ingo@99: } ingo@99: catch (ConnectionException ce) { ingo@99: System.err.println(ce.getLocalizedMessage()); 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 :