sascha@262: package de.intevation.flys.client.server; sascha@262: sascha@276: import org.w3c.dom.Document; sascha@276: import org.w3c.dom.Element; sascha@262: sascha@262: import com.google.gwt.user.server.rpc.RemoteServiceServlet; sascha@262: sascha@276: import de.intevation.artifacts.common.ArtifactNamespaceContext; sascha@276: sascha@276: import de.intevation.artifacts.common.utils.XMLUtils; sascha@276: sascha@262: import de.intevation.flys.client.shared.exceptions.ServerException; sascha@262: sascha@262: import de.intevation.flys.client.client.services.MetaDataService; sascha@262: sascha@276: import de.intevation.artifacts.httpclient.exceptions.ConnectionException; sascha@276: sascha@276: import de.intevation.artifacts.httpclient.http.HttpClient; sascha@276: import de.intevation.artifacts.httpclient.http.HttpClientImpl; sascha@276: sascha@278: import de.intevation.flys.client.shared.model.DataCageTree; sascha@278: sascha@286: import de.intevation.flys.client.server.meta.Converter; sascha@286: sascha@262: public class MetaDataServiceImpl sascha@262: extends RemoteServiceServlet sascha@262: implements MetaDataService sascha@262: { sascha@276: public static final String ERROR_NO_META_DATA_FOUND = sascha@276: "error_no_meta_data_found"; sascha@276: sascha@827: @Override sascha@811: public DataCageTree getMetaData( sascha@811: String url, sascha@811: String locale, sascha@811: String artifactId, sascha@827: String userId, sascha@827: String outs sascha@811: ) throws ServerException sascha@262: { sascha@812: System.out.println("MetaDataService.getMetaData"); sascha@276: sascha@276: Document doc = XMLUtils.newDocument(); sascha@276: sascha@276: XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( sascha@276: doc, sascha@276: ArtifactNamespaceContext.NAMESPACE_URI, sascha@276: ArtifactNamespaceContext.NAMESPACE_PREFIX); sascha@276: sascha@812: Element meta = ec.create("meta"); sascha@276: sascha@811: if (artifactId != null) { sascha@811: Element artifactEl = ec.create("artifact-id"); sascha@811: artifactEl.setAttribute("value", artifactId); sascha@812: meta.appendChild(artifactEl); sascha@811: } sascha@276: sascha@811: if (userId != null) { sascha@811: Element userEl = ec.create("user-id"); sascha@811: userEl.setAttribute("value", userId); sascha@812: meta.appendChild(userEl); sascha@811: } sascha@276: sascha@827: if (outs != null) { sascha@827: Element outsEl = ec.create("outs"); sascha@827: outsEl.setAttribute("value", outs); sascha@827: meta.appendChild(outsEl); sascha@827: } sascha@827: sascha@812: doc.appendChild(meta); sascha@812: sascha@276: HttpClient client = new HttpClientImpl(url, locale); sascha@276: sascha@276: try { sascha@286: Converter converter = new Converter(); sascha@286: return converter.convert(client.callService(url, "metadata", doc)); sascha@276: } sascha@276: catch (ConnectionException ce) { sascha@812: ce.printStackTrace(); sascha@276: } sascha@276: sascha@276: throw new ServerException(ERROR_NO_META_DATA_FOUND); sascha@262: } sascha@262: } sascha@262: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :