From 734b9ccf68a29220f80170af2c3c5702ec231a96 Mon Sep 17 00:00:00 2001 From: alessandroGalasso <45561775+alessandroGalasso@users.noreply.github.com> Date: Thu, 6 Dec 2018 01:52:40 +0100 Subject: [PATCH] [VIVO-1649] fix for RDFServiceSparql.executeUpdate method (#97) Resolves: https://jira.duraspace.org/browse/VIVO-1649 --- .../webapp/rdfservice/impl/sparql/RDFServiceSparql.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/rdfservice/impl/sparql/RDFServiceSparql.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/rdfservice/impl/sparql/RDFServiceSparql.java index db7e22237..1fd9c2442 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/rdfservice/impl/sparql/RDFServiceSparql.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/rdfservice/impl/sparql/RDFServiceSparql.java @@ -19,6 +19,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.http.Consts; import org.apache.http.HttpResponse; import org.apache.http.auth.AuthScope; import org.apache.http.auth.AuthenticationException; @@ -495,8 +496,8 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService { protected void executeUpdate(String updateString) throws RDFServiceException { try { HttpPost meth = new HttpPost(updateEndpointURI); - meth.addHeader("Content-Type", "application/x-www-form-urlencoded"); - meth.setEntity(new UrlEncodedFormEntity(Arrays.asList(new BasicNameValuePair("update", updateString)))); + meth.addHeader("Content-Type", "application/x-www-form-urlencoded; charset="+Consts.UTF_8); + meth.setEntity(new UrlEncodedFormEntity(Arrays.asList(new BasicNameValuePair("update", updateString)),Consts.UTF_8)); HttpContext context = getContext(meth); HttpResponse response = context != null ? httpClient.execute(meth, context) : httpClient.execute(meth); try { @@ -510,6 +511,7 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService { EntityUtils.consume(response.getEntity()); } } catch (Exception e) { + log.debug("update string: \n" + updateString); throw new RDFServiceException("Unable to perform change set update", e); } }