[VIVO-1649] fix for RDFServiceSparql.executeUpdate method (#97)

Resolves: https://jira.duraspace.org/browse/VIVO-1649
This commit is contained in:
alessandroGalasso 2018-12-06 01:52:40 +01:00 committed by Andrew Woods
parent d2c34ddf46
commit 734b9ccf68

View file

@ -19,6 +19,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.http.Consts;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope; import org.apache.http.auth.AuthScope;
import org.apache.http.auth.AuthenticationException; import org.apache.http.auth.AuthenticationException;
@ -495,8 +496,8 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService {
protected void executeUpdate(String updateString) throws RDFServiceException { protected void executeUpdate(String updateString) throws RDFServiceException {
try { try {
HttpPost meth = new HttpPost(updateEndpointURI); HttpPost meth = new HttpPost(updateEndpointURI);
meth.addHeader("Content-Type", "application/x-www-form-urlencoded"); meth.addHeader("Content-Type", "application/x-www-form-urlencoded; charset="+Consts.UTF_8);
meth.setEntity(new UrlEncodedFormEntity(Arrays.asList(new BasicNameValuePair("update", updateString)))); meth.setEntity(new UrlEncodedFormEntity(Arrays.asList(new BasicNameValuePair("update", updateString)),Consts.UTF_8));
HttpContext context = getContext(meth); HttpContext context = getContext(meth);
HttpResponse response = context != null ? httpClient.execute(meth, context) : httpClient.execute(meth); HttpResponse response = context != null ? httpClient.execute(meth, context) : httpClient.execute(meth);
try { try {
@ -510,6 +511,7 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService {
EntityUtils.consume(response.getEntity()); EntityUtils.consume(response.getEntity());
} }
} catch (Exception e) { } catch (Exception e) {
log.debug("update string: \n" + updateString);
throw new RDFServiceException("Unable to perform change set update", e); throw new RDFServiceException("Unable to perform change set update", e);
} }
} }