summaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/util/client/omsp
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2014-10-16 09:01:39 +0200
committerThomas Lenz <thomas.lenz@egiz.gv.at>2014-10-16 09:01:39 +0200
commit2f3b7f180511a5e0af674e3a25ddbaabaa38d36c (patch)
treec6837f2224eceb77df85a731410db62580472113 /src/main/java/at/gv/util/client/omsp
parent74c85b426a1a690ac4492f65abcab201b5220c94 (diff)
downloadegovutils-2f3b7f180511a5e0af674e3a25ddbaabaa38d36c.tar.gz
egovutils-2f3b7f180511a5e0af674e3a25ddbaabaa38d36c.tar.bz2
egovutils-2f3b7f180511a5e0af674e3a25ddbaabaa38d36c.zip
update to Apache commons-http 4.3
Diffstat (limited to 'src/main/java/at/gv/util/client/omsp')
-rw-r--r--src/main/java/at/gv/util/client/omsp/OMSPClient.java39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/main/java/at/gv/util/client/omsp/OMSPClient.java b/src/main/java/at/gv/util/client/omsp/OMSPClient.java
index 42ef55a..3cab58e 100644
--- a/src/main/java/at/gv/util/client/omsp/OMSPClient.java
+++ b/src/main/java/at/gv/util/client/omsp/OMSPClient.java
@@ -1,15 +1,21 @@
package at.gv.util.client.omsp;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.utils.URIBuilder;
+import org.apache.http.impl.client.HttpClients;
import at.gv.util.MiscUtil;
import at.gv.util.xsd.omsp.SignedStatusResponse;
@@ -19,28 +25,33 @@ public class OMSPClient {
public static SignedStatusResponse checkMandateStatus(String serviceURL, String mandateId, Date date) throws OMSPClientException {
MiscUtil.assertNotNull(serviceURL, "serviceURL");
MiscUtil.assertNotNull(mandateId, "mandateId");
- HttpClient httpclient = new HttpClient();
- GetMethod method = new GetMethod(serviceURL);
- String queryString = mandateId;
+ HttpClient httpclient = HttpClients.createDefault();
+ HttpGet method = new HttpGet(serviceURL);
if (date != null) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
mandateId += "+" + sdf.format(date);
}
- method.setQueryString(queryString);
try {
- int code = httpclient.executeMethod(method);
- if (code != 200) {
- throw new OMSPClientException("Response code " + code + " returned. Must be 200.");
+ URI uri = new URIBuilder(method.getURI()).addParameter("", mandateId).build();
+ method.setURI(uri);
+
+ HttpResponse response = httpclient.execute(method);
+
+ if (response.getStatusLine().getStatusCode() != 200) {
+ throw new OMSPClientException("Response code " + response.getStatusLine().getStatusCode() + " returned. Must be 200.");
+
}
+
JAXBContext ctx = JAXBContext.newInstance(SignedStatusResponse.class.getPackage().getName());
- return (SignedStatusResponse) ctx.createUnmarshaller().unmarshal(method.getResponseBodyAsStream());
- } catch (HttpException e) {
- throw new OMSPClientException(e);
+ return (SignedStatusResponse) ctx.createUnmarshaller().unmarshal(response.getEntity().getContent());
+
} catch (IOException e) {
throw new OMSPClientException(e);
} catch (JAXBException e) {
throw new OMSPClientException(e);
- }
+ } catch (URISyntaxException e) {
+ throw new OMSPClientException(e);
+ }
}
}