ingo@69: package de.intevation.flys.client.server; ingo@69: ingo@69: import org.w3c.dom.Document; ingo@69: ingo@69: import de.intevation.artifacts.common.utils.ClientProtocolUtils; ingo@69: ingo@69: import de.intevation.artifacts.httpclient.exceptions.ConnectionException; ingo@69: import de.intevation.artifacts.httpclient.http.HttpClient; ingo@69: import de.intevation.artifacts.httpclient.http.HttpClientImpl; ingo@69: import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; ingo@69: ingo@215: import de.intevation.flys.client.shared.exceptions.ServerException; ingo@69: import de.intevation.flys.client.shared.model.Artifact; ingo@69: import de.intevation.flys.client.shared.model.Collection; ingo@69: import de.intevation.flys.client.client.services.AddArtifactService; ingo@69: ingo@69: ingo@69: /** ingo@69: * @author Ingo Weinzierl ingo@69: */ ingo@69: public class AddArtifactServiceImpl ingo@99: extends DescribeCollectionServiceImpl ingo@69: implements AddArtifactService ingo@69: { ingo@215: public static final String ERROR_ADD_ARTIFACT = "error_add_artifact"; ingo@215: ingo@229: public Collection add( ingo@229: Collection collection, ingo@229: Artifact artifact, ingo@229: String url, ingo@229: String locale) ingo@215: throws ServerException ingo@215: { ingo@99: System.out.println("AddArtifactServiceImpl.add"); ingo@69: ingo@69: Document add = ClientProtocolUtils.newAddArtifactDocument( ingo@69: artifact.getUuid(), null); ingo@69: ingo@229: HttpClient client = new HttpClientImpl(url, locale); ingo@69: ingo@69: try { ingo@69: Document response = (Document) client.doCollectionAction( ingo@69: add, collection.identifier(), new DocumentResponseHandler()); ingo@69: ingo@69: Collection c = parseCollection(response); ingo@69: ingo@69: if (c == null) { ingo@215: throw new ServerException(ERROR_ADD_ARTIFACT); ingo@69: } ingo@69: ingo@69: return c; ingo@69: } ingo@69: catch (ConnectionException ce) { ingo@69: System.err.println(ce.getLocalizedMessage()); ingo@69: } ingo@69: ingo@215: throw new ServerException(ERROR_ADD_ARTIFACT); ingo@69: } ingo@69: } ingo@69: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :