You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2011/07/20 19:01:52 UTC
svn commit: r1148852 - in /incubator/stanbol/trunk/entityhub:
generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/
query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/
site/linkeddata/src/main/java/org/apache/stanb...
Author: rwesten
Date: Wed Jul 20 17:01:51 2011
New Revision: 1148852
URL: http://svn.apache.org/viewvc?rev=1148852&view=rev
Log:
FieldMappings
* Corrected a Bug that caused the default namespace (http://schema.org) to be added as prefix to global (empty) or wildcard ('*') paths.
* This was the cause that in some situations locally cached versions of retrieved Entities had an empty representation
SparqlQueryUtils:
* Empty search strings are now ignored for Virtruoso server optimised SPARQL queries
SPARQL Dereferencer and Searcher:
* Improved Errorhandling for IOExceptions so that the Error Content (Content send by the server for 4** and 5** responses) is included as Message of the Exception.
Modified:
incubator/stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/FieldMappingUtils.java
incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlQueryUtils.java
incubator/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlEndpointUtils.java
Modified: incubator/stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/FieldMappingUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/FieldMappingUtils.java?rev=1148852&r1=1148851&r2=1148852&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/FieldMappingUtils.java (original)
+++ incubator/stanbol/trunk/entityhub/generic/core/src/main/java/org/apache/stanbol/entityhub/core/mapping/FieldMappingUtils.java Wed Jul 20 17:01:51 2011
@@ -151,7 +151,12 @@ public final class FieldMappingUtils {
String[] parts = mapping.split(" "); //TODO: maybe we should not use the spaces here
List<String> mappedTo = Collections.emptyList();
- String fieldPattern = NamespaceEnum.getFullName(parts[0]);
+ String fieldPattern;
+ if(!parts[0].isEmpty() && !parts[0].equals("*")){
+ fieldPattern = NamespaceEnum.getFullName(parts[0]);
+ } else {
+ fieldPattern = parts[0];
+ }
Constraint filter = null;
for(int i=1;i<parts.length;i++){
if("|".equals(parts[i]) && parts.length > i+1){
@@ -246,9 +251,11 @@ public final class FieldMappingUtils {
private static List<String> parseMappings(String[] parts, int start) {
ArrayList<String> mappings = new ArrayList<String>(parts.length-start);
for(int i=start;i<parts.length;i++){
- String act = NamespaceEnum.getFullName(parts[i]);
- if(!act.isEmpty()){ //needed to remove two spaces in a row
- mappings.add(act);
+ if(!parts[i].isEmpty()){ //needed to remove two spaces in a row
+ String act = NamespaceEnum.getFullName(parts[i]);
+// if(!act.isEmpty()){
+ mappings.add(act);
+ // }
}
}
return mappings;
Modified: incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlQueryUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlQueryUtils.java?rev=1148852&r1=1148851&r2=1148852&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlQueryUtils.java (original)
+++ incubator/stanbol/trunk/entityhub/query/clerezza/src/main/java/org/apache/stanbol/entityhub/query/clerezza/SparqlQueryUtils.java Wed Jul 20 17:01:51 2011
@@ -599,12 +599,15 @@ public final class SparqlQueryUtils {
boolean firstWord = true;;
//TODO: maybe we should use a better word tokenizer
for(String word : constraint.getText().split(" ")){
- if(firstWord){
- firstWord = false;
- } else {
- queryString.append(" AND ");
+ word = word.trim();
+ if(!word.isEmpty()){
+ if(firstWord){
+ firstWord = false;
+ } else {
+ queryString.append(" AND ");
+ }
+ queryString.append('"').append(word).append('"');
}
- queryString.append('"').append(word).append('"');
}
queryString.append('\'');
// queryString.append(String.format("?%s bif:contains '\"%s\"'", var,constraint.getText()
Modified: incubator/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlEndpointUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlEndpointUtils.java?rev=1148852&r1=1148851&r2=1148852&view=diff
==============================================================================
--- incubator/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlEndpointUtils.java (original)
+++ incubator/stanbol/trunk/entityhub/site/linkeddata/src/main/java/org/apache/stanbol/entityhub/site/linkeddata/impl/SparqlEndpointUtils.java Wed Jul 20 17:01:51 2011
@@ -18,12 +18,15 @@ package org.apache.stanbol.entityhub.sit
import java.io.IOException;
import java.io.InputStream;
+import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URLConnection;
import javax.ws.rs.core.UriBuilder;
+import org.apache.commons.io.IOUtils;
+
public final class SparqlEndpointUtils {
private SparqlEndpointUtils() {/* Do not create instances of utility classes*/}
@@ -46,7 +49,26 @@ public final class SparqlEndpointUtils {
.build(query, contentType);
final URLConnection con = dereferenceUri.toURL().openConnection();
con.addRequestProperty("Accept", contentType);
- return con.getInputStream();
+ try {
+ return con.getInputStream();
+ } catch (IOException e) {
+ if(con instanceof HttpURLConnection){
+ //try to create a better Error Message
+ InputStream reason = ((HttpURLConnection)con).getErrorStream();
+ String errorMessage = null;
+ try {
+ errorMessage = IOUtils.toString(reason);
+ } catch (IOException e1) {
+ //ignore ...
+ }
+ if(errorMessage != null && !errorMessage.isEmpty()){
+ throw new IOException(((HttpURLConnection)con).getRequestMethod()+" with Content: \n"+errorMessage,e);
+ }
+ IOUtils.closeQuietly(reason);
+ }
+ //if still here re-throw the original exception
+ throw e;
+ }
}
}