ingo@865: package de.intevation.flys.client.server; ingo@865: ingo@865: import org.w3c.dom.Document; ingo@865: ingo@1367: import org.apache.log4j.Logger; ingo@1367: ingo@865: import com.google.gwt.user.server.rpc.RemoteServiceServlet; ingo@865: ingo@865: import de.intevation.artifacts.common.utils.ClientProtocolUtils; ingo@865: ingo@865: import de.intevation.artifacts.httpclient.exceptions.ConnectionException; ingo@865: import de.intevation.artifacts.httpclient.http.HttpClient; ingo@865: import de.intevation.artifacts.httpclient.http.HttpClientImpl; ingo@865: import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; ingo@865: ingo@865: import de.intevation.flys.client.shared.exceptions.ServerException; ingo@865: import de.intevation.flys.client.shared.model.Artifact; ingo@865: import de.intevation.flys.client.client.services.DescribeArtifactService; ingo@865: ingo@865: ingo@865: /** ingo@865: * This interface provides artifact specific operation DESCRIBE. ingo@865: * ingo@865: * @author Ingo Weinzierl ingo@865: */ ingo@865: public class DescribeArtifactServiceImpl ingo@865: extends RemoteServiceServlet ingo@865: implements DescribeArtifactService ingo@865: { ingo@1367: private static final Logger logger = ingo@1367: Logger.getLogger(DescribeArtifactServiceImpl.class); ingo@1367: ingo@1367: ingo@865: public static final String ERROR_DESCRIBE_ARTIFACT = ingo@865: "error_describe_artifact"; ingo@865: ingo@865: ingo@865: public Artifact describe(String url, String locale, Artifact artifact) ingo@865: throws ServerException ingo@865: { ingo@1367: logger.info("DescribeArtifactServiceImpl.describe"); ingo@865: ingo@865: Document describe = ClientProtocolUtils.newDescribeDocument( ingo@865: artifact.getUuid(), ingo@865: artifact.getHash(), ingo@865: true); ingo@865: ingo@865: HttpClient client = new HttpClientImpl(url, locale); ingo@865: ingo@865: try { ingo@1367: logger.debug("Start Http request now."); ingo@865: ingo@865: Document description = (Document) client.describe( ingo@865: new de.intevation.artifacts.httpclient.objects.Artifact( ingo@865: artifact.getUuid(), ingo@865: artifact.getHash()), ingo@865: describe, ingo@865: new DocumentResponseHandler()); ingo@865: ingo@865: if (description != null) { ingo@1367: logger.debug("Finished Http request sucessfully!"); ingo@865: ingo@865: return (Artifact) new FLYSArtifactCreator().create(description); ingo@865: } ingo@865: } ingo@865: catch (ConnectionException ce) { ingo@865: ce.printStackTrace(); ingo@865: } ingo@865: ingo@865: throw new ServerException(ERROR_DESCRIBE_ARTIFACT); ingo@865: } ingo@865: } ingo@865: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :