ingo@26: package de.intevation.flys.client.server; ingo@26: ingo@26: import org.w3c.dom.Document; ingo@26: ingo@26: import com.google.gwt.core.client.GWT; ingo@26: import com.google.gwt.user.server.rpc.RemoteServiceServlet; ingo@26: ingo@26: import de.intevation.artifacts.common.ArtifactNamespaceContext; ingo@26: import de.intevation.artifacts.common.utils.ClientProtocolUtils; ingo@26: import de.intevation.artifacts.common.utils.XMLUtils; ingo@26: ingo@26: import de.intevation.artifacts.httpclient.exceptions.ConnectionException; ingo@26: import de.intevation.artifacts.httpclient.http.HttpClient; ingo@26: import de.intevation.artifacts.httpclient.http.HttpClientImpl; ingo@26: import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; ingo@26: ingo@26: import de.intevation.flys.client.client.services.CreateCollectionService; ingo@26: ingo@26: ingo@26: /** ingo@26: * This interface provides the createCollection service to create new ingo@26: * collections in the artifact server. ingo@26: * ingo@26: * @author Ingo Weinzierl ingo@26: */ ingo@26: public class CreateCollectionServiceImpl ingo@26: extends RemoteServiceServlet ingo@26: implements CreateCollectionService ingo@26: { ingo@26: /** XPath to figure out the uuid of the created collection.*/ ingo@26: public static final String XPATH_COLLECTION_UUID = ingo@26: "/art:result/art:artifact-collection/@art:uuid"; ingo@26: ingo@26: ingo@26: public String create(String serverUrl, String ownerId) { ingo@26: GWT.log("Start creating a new collection."); ingo@26: ingo@26: Document create = ClientProtocolUtils.newCreateDocument(null); ingo@26: HttpClient client = new HttpClientImpl(serverUrl); ingo@26: ingo@26: try { ingo@26: Document doc = (Document) client.createCollection( ingo@26: create, ownerId, new DocumentResponseHandler()); ingo@26: ingo@26: return XMLUtils.xpathString( ingo@26: doc, XPATH_COLLECTION_UUID, ArtifactNamespaceContext.INSTANCE); ingo@26: } ingo@26: catch (ConnectionException ce) { ingo@26: System.err.println(ce.getLocalizedMessage()); ingo@26: } ingo@26: ingo@26: return null; ingo@26: } ingo@26: } ingo@26: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :