ingo@1365: package de.intevation.flys.client.server; ingo@1365: ingo@1365: import java.io.InputStream; ingo@1365: import java.io.IOException; ingo@1365: ingo@1365: import org.w3c.dom.Document; ingo@1365: ingo@1367: import org.apache.log4j.Logger; ingo@1367: ingo@1365: import com.google.gwt.user.server.rpc.RemoteServiceServlet; ingo@1365: ingo@1365: import de.intevation.artifacts.common.utils.ClientProtocolUtils; ingo@1365: import de.intevation.artifacts.common.utils.XMLUtils; ingo@1365: ingo@1365: import de.intevation.artifacts.httpclient.http.HttpClient; ingo@1365: import de.intevation.artifacts.httpclient.http.HttpClientImpl; ingo@1365: import de.intevation.artifacts.httpclient.exceptions.ConnectionException; ingo@1365: ingo@1365: import de.intevation.flys.client.shared.exceptions.ServerException; ingo@1365: import de.intevation.flys.client.shared.model.Collection; ingo@1376: import de.intevation.flys.client.shared.model.MapConfig; ingo@1365: ingo@1365: import de.intevation.flys.client.client.services.MapOutputService; ingo@1365: ingo@1365: ingo@1365: public class MapOutputServiceImpl ingo@1365: extends RemoteServiceServlet ingo@1365: implements MapOutputService ingo@1365: { ingo@1365: ingo@1367: private static final Logger logger = ingo@1367: Logger.getLogger(MapOutputServiceImpl.class); ingo@1367: ingo@1367: ingo@1376: public static final String ERROR_NO_MAP_CONFIG = "error_no_map_config"; ingo@1376: ingo@1376: ingo@1376: public MapConfig doOut(Collection collection) ingo@1365: throws ServerException ingo@1365: { ingo@1367: logger.info("MapOutputServiceImpl.doOut"); ingo@1365: ingo@1370: String url = getServletContext().getInitParameter("server-url"); ingo@1365: String uuid = collection.identifier(); ingo@1365: ingo@1365: try { ingo@1365: Document request = ClientProtocolUtils.newOutCollectionDocument( ingo@1365: uuid, "floodmap", "floodmap"); ingo@1365: ingo@1370: HttpClient client = new HttpClientImpl(url); ingo@1365: InputStream is = client.collectionOut(request, uuid, "floodmap"); ingo@1365: ingo@1365: Document response = XMLUtils.parseDocument(is); ingo@1365: ingo@1376: return MapHelper.parseConfig(response); ingo@1365: } ingo@1365: catch (ConnectionException e) { ingo@1367: logger.error(e, e); ingo@1365: } ingo@1365: catch (IOException ioe) { ingo@1367: logger.error(ioe, ioe); ingo@1365: } ingo@1376: ingo@1376: throw new ServerException(ERROR_NO_MAP_CONFIG); ingo@1365: } ingo@1365: } ingo@1365: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :