ingo@32: package de.intevation.flys.client.server; ingo@32: ingo@32: import org.w3c.dom.Document; ingo@32: ingo@32: import com.google.gwt.user.server.rpc.RemoteServiceServlet; ingo@32: ingo@32: import de.intevation.artifacts.common.ArtifactNamespaceContext; ingo@32: import de.intevation.artifacts.common.utils.ClientProtocolUtils; ingo@32: import de.intevation.artifacts.common.utils.XMLUtils; ingo@32: ingo@32: import de.intevation.artifacts.httpclient.exceptions.ConnectionException; ingo@32: import de.intevation.artifacts.httpclient.http.HttpClient; ingo@32: import de.intevation.artifacts.httpclient.http.HttpClientImpl; ingo@32: import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; ingo@32: ingo@32: import de.intevation.flys.client.shared.model.Artifact; ingo@32: import de.intevation.flys.client.client.services.AdvanceService; ingo@32: ingo@32: ingo@32: /** ingo@32: * This interface provides artifact specific operation ADVANCE. ingo@32: * ingo@32: * @author Ingo Weinzierl ingo@32: */ ingo@32: public class AdvanceServiceImpl ingo@32: extends RemoteServiceServlet ingo@32: implements AdvanceService ingo@32: { ingo@32: public static final String XPATH_RESULT = "/art:result/text()"; ingo@32: ingo@32: public static final String OPERATION_FAILURE = "FAILED"; ingo@32: ingo@32: ingo@32: public Artifact advance(String serverUrl, Artifact artifact, String target){ ingo@32: Document advance = ClientProtocolUtils.newAdvanceDocument( ingo@32: artifact.getUuid(), ingo@32: artifact.getHash(), ingo@32: target); ingo@32: ingo@32: HttpClient client = new HttpClientImpl(serverUrl); ingo@32: ingo@32: try { ingo@32: Document description = (Document) client.advance( ingo@32: new de.intevation.artifacts.httpclient.objects.Artifact( ingo@32: artifact.getUuid(), ingo@32: artifact.getHash()), ingo@32: advance, ingo@32: new DocumentResponseHandler()); ingo@32: ingo@32: if (description == null) { ingo@32: return null; ingo@32: } ingo@32: ingo@32: String result = XMLUtils.xpathString( ingo@32: description, ingo@32: XPATH_RESULT, ingo@32: ArtifactNamespaceContext.INSTANCE); ingo@32: ingo@32: if (result == null || !result.equals(OPERATION_FAILURE)) { ingo@32: return (Artifact) new FLYSArtifactCreator().create(description); ingo@32: } ingo@32: } ingo@32: catch (ConnectionException ce) { ingo@32: System.err.println(ce.getLocalizedMessage()); ingo@32: } ingo@32: ingo@32: return null; ingo@32: } ingo@32: } ingo@32: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :