# HG changeset patch # User Thomas Arendsen Hein # Date 1348827314 -7200 # Node ID 04b2df3d54843e6f3c99a1e52c386ada7aee011d # Parent 90ec118dd5072858dd2631ce129a9ec50ec6af3a# Parent 58918534747d56098949194674a7f1a77fbb7c79 dummy merge for repo head diff -r 58918534747d -r 04b2df3d5484 ChangeLog --- a/ChangeLog Tue Jun 28 07:59:28 2011 +0000 +++ b/ChangeLog Fri Sep 28 12:15:14 2012 +0200 @@ -1,3 +1,72 @@ +2012-09-17 Ingo Weinzierl + + Taggd RELEASE 2.9.1 + +2012-09-10 Sascha L. Teichmann + + * pom.xml: Java 1.5 -> 1.6 + +2012-09-07 Ingo Weinzierl + + Taggd RELEASE 2.9 + +2012-08-24 Björn Ricks + + * src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java, + src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java: + Added new method findUser. With the new method it is possible to get a + user document by an account name. + +2012-07-27 Ingo Weinzierl + + Taggd RELEASE 2.8.1 + +2012-07-16 Ingo Weinzierl + + Taggd RELEASE 2.8 + +2012-07-13 Björn Ricks + + * src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java + src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java: + Implemented a createUser method for HttpClient. + With the new method its possible to create new users via the HttpClient. + +2012-04-16 Sascha L. Teichmann + + * src/main/java/de/intevation/artifacts/httpclient/http/response/StringResponseHandler.java, + src/main/java/de/intevation/artifacts/httpclient/http/response/StreamResponseHandler.java, + src/main/java/de/intevation/artifacts/httpclient/http/response/DocumentResponseHandler.java: + Added Override annotations. + +2011-09-19 Ingo Weinzierl + + Tagged pre2.7-2012-03-16 + +2011-09-19 Ingo Weinzierl + + Taggd RELEASE 0.5 + + * Changes: Prepared changes for the release. + +2011-08-23 Sascha L. Teichmann + + * src/main/java/de/intevation/artifacts/httpclient/utils/ArtifactProtocolUtils.java + (createFeedDocument): Directly iterate over the entry set of the map. Do not + use the more expensive 'for all key in keys: value = get(key)' + +2011-08-23 Sascha L. Teichmann + + * src/main/java/de/intevation/artifacts/httpclient/utils/ArtifactProtocolUtils.java: + Replaced some XPath attribute extraction by simple DOM getAttributeNS() calls. + +2011-07-04 Ingo Weinzierl + + * src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java, + src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java: + Added a method to call a service with a ResponseHandler. This allows us + to access the InputStream directly. + 2011-06-28 Ingo Weinzierl Tagged RELEASE 0.4 diff -r 58918534747d -r 04b2df3d5484 Changes --- a/Changes Tue Jun 28 07:59:28 2011 +0000 +++ b/Changes Fri Sep 28 12:15:14 2012 +0200 @@ -1,3 +1,13 @@ +2011-09-19 RELEASE 0.5 + + NEW: + + * Performance improvements in ArtifactProtocolUtils. + + * Improved the HttpClient interface and its default implementation: + enabled calling a service with a ResponseHandler. + + 2011-06-27 RELEASE 0.4 New: diff -r 58918534747d -r 04b2df3d5484 pom.xml --- a/pom.xml Tue Jun 28 07:59:28 2011 +0000 +++ b/pom.xml Fri Sep 28 12:15:14 2012 +0200 @@ -21,8 +21,8 @@ maven-compiler-plugin 2.0.2 - 1.5 - 1.5 + 1.6 + 1.6 diff -r 58918534747d -r 04b2df3d5484 src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java --- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java Tue Jun 28 07:59:28 2011 +0000 +++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClient.java Fri Sep 28 12:15:14 2012 +0200 @@ -59,6 +59,13 @@ Document callService(String url, String service, Document input) throws ConnectionException; + Object callService( + String url, + String service, + Document input, + ResponseHandler handler) + throws ConnectionException; + /******************************* * Collections API @@ -99,5 +106,11 @@ Document listUserCollections(String userid) throws ConnectionException; + + Document createUser(Document doc) + throws ConnectionException; + + Document findUser(Document doc) + throws ConnectionException; } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: diff -r 58918534747d -r 04b2df3d5484 src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java --- a/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java Tue Jun 28 07:59:28 2011 +0000 +++ b/src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java Fri Sep 28 12:15:14 2012 +0200 @@ -54,6 +54,12 @@ * user.*/ public static final String PATH_USER_COLLECTIONS = "/list-collections"; + /** The URL part og the resource to create a new user on the server.*/ + public static final String PATH_CREATE_USER = "/create-user"; + + /** The URL part og the resource to find an existing user on the server.*/ + public static final String PATH_FIND_USER = "/find-user"; + /** The URL part of the resource to call a specific service.*/ public static final String PATH_SERVICE = "/service"; @@ -475,23 +481,33 @@ public Document callService(String url, String service, Document input) throws ConnectionException { - if (logger.isDebugEnabled()) { - logger.debug("Start service call to '" + service + "'"); - } - DocumentResponseHandler handler = new DocumentResponseHandler(); - try { - String serverUrl = url + PATH_SERVICE + "/" + service; - return (Document) handler.handle(doPost(serverUrl, input)); - } - catch (IOException ioe) { - throw new ConnectionException( - "Connection to server failed: " + ioe.getMessage()); - } + return (Document) callService(url, service, input, handler); } + public Object callService( + String url, + String service, + Document input, + ResponseHandler handler) + throws ConnectionException { + if (logger.isDebugEnabled()) { + logger.debug("Start service call to '" + service + "'"); + } + + try { + String serverUrl = url + PATH_SERVICE + "/" + service; + return handler.handle(doPost(serverUrl, input)); + } + catch (IOException ioe) { + throw new ConnectionException( + "Connection to server failed: " + ioe.getMessage()); + } + } + + /******************************* * Users API *******************************/ @@ -525,5 +541,37 @@ throw new ConnectionException(ioe.getMessage(), ioe); } } + + @Override + public Document createUser(Document doc) + throws ConnectionException { + ResponseHandler handler = new DocumentResponseHandler(); + + String url = this.serverUrl + PATH_CREATE_USER; + + try { + return (Document) handler.handle(doPost(url, doc)); + } + catch (IOException ioe) { + throw new ConnectionException( + "Connection to server failed: " + ioe.getMessage()); + } + } + + @Override + public Document findUser(Document doc) + throws ConnectionException { + ResponseHandler handler = new DocumentResponseHandler(); + + String url = this.serverUrl + PATH_FIND_USER; + + try { + return (Document) handler.handle(doPost(url, doc)); + } + catch (IOException ioe) { + throw new ConnectionException( + "Connection to server failed: " + ioe.getMessage()); + } + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: diff -r 58918534747d -r 04b2df3d5484 src/main/java/de/intevation/artifacts/httpclient/http/response/DocumentResponseHandler.java --- a/src/main/java/de/intevation/artifacts/httpclient/http/response/DocumentResponseHandler.java Tue Jun 28 07:59:28 2011 +0000 +++ b/src/main/java/de/intevation/artifacts/httpclient/http/response/DocumentResponseHandler.java Fri Sep 28 12:15:14 2012 +0200 @@ -23,6 +23,7 @@ public DocumentResponseHandler() { } + @Override public Object handle(Response response) throws IOException { Representation output = response.getEntity(); return XMLUtils.readDocument(output.getStream()); diff -r 58918534747d -r 04b2df3d5484 src/main/java/de/intevation/artifacts/httpclient/http/response/StreamResponseHandler.java --- a/src/main/java/de/intevation/artifacts/httpclient/http/response/StreamResponseHandler.java Tue Jun 28 07:59:28 2011 +0000 +++ b/src/main/java/de/intevation/artifacts/httpclient/http/response/StreamResponseHandler.java Fri Sep 28 12:15:14 2012 +0200 @@ -21,6 +21,7 @@ public StreamResponseHandler() { } + @Override public Object handle(Response response) throws IOException { Representation output = response.getEntity(); return output.getStream(); diff -r 58918534747d -r 04b2df3d5484 src/main/java/de/intevation/artifacts/httpclient/http/response/StringResponseHandler.java --- a/src/main/java/de/intevation/artifacts/httpclient/http/response/StringResponseHandler.java Tue Jun 28 07:59:28 2011 +0000 +++ b/src/main/java/de/intevation/artifacts/httpclient/http/response/StringResponseHandler.java Fri Sep 28 12:15:14 2012 +0200 @@ -22,6 +22,7 @@ public StringResponseHandler() { } + @Override public Object handle(Response response) throws IOException { InputStream in = (InputStream) super.handle(response); OutputStream out = new ByteArrayOutputStream(); diff -r 58918534747d -r 04b2df3d5484 src/main/java/de/intevation/artifacts/httpclient/utils/ArtifactProtocolUtils.java --- a/src/main/java/de/intevation/artifacts/httpclient/utils/ArtifactProtocolUtils.java Tue Jun 28 07:59:28 2011 +0000 +++ b/src/main/java/de/intevation/artifacts/httpclient/utils/ArtifactProtocolUtils.java Fri Sep 28 12:15:14 2012 +0200 @@ -7,9 +7,7 @@ */ package de.intevation.artifacts.httpclient.utils; -import java.util.Iterator; import java.util.Map; -import java.util.Set; import javax.xml.xpath.XPathConstants; @@ -17,7 +15,6 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; import org.w3c.dom.NodeList; import de.intevation.artifacts.httpclient.objects.Artifact; @@ -42,12 +39,14 @@ ArtifactFactory[] facs = new ArtifactFactory[elements.getLength()]; - for (int idx = 0; idx < elements.getLength(); idx++) { - Node factory = elements.item(idx); - String desc = XMLUtils.getStringXPath(factory, "@art:description"); - String name = XMLUtils.getStringXPath(factory, "@art:name"); + String uri = ArtifactNamespaceContext.NAMESPACE_URI; - if (name != null) { + for (int idx = 0; idx < facs.length; idx++) { + Element factory = (Element)elements.item(idx); + String desc = factory.getAttributeNS(uri, "description"); + String name = factory.getAttributeNS(uri, "name"); + + if (name.length() != 0) { facs[idx] = new ArtifactFactory(name, desc); } } @@ -139,11 +138,11 @@ Element action = createArtifactAction(creator, artifact, "feed"); Element data = creator.create("data"); - Set keys = attr.keySet(); - Iterator iter = keys.iterator(); - while (iter.hasNext()) { - String key = (String) iter.next(); - Object values = attr.get(key); + for (Map.Entry entry: + ((Map)attr).entrySet()) { + + String key = entry.getKey(); + Object values = entry.getValue(); if (values instanceof Object[]) { appendInputNodes(creator, data, key, (Object[]) values); @@ -151,7 +150,6 @@ else { appendInputNodes(creator, data, key, values); } - } action.appendChild(data);