Mercurial > hg > NamedIdentityManager
diff src/de/mpiwg/itgroup/nimanager/persons/PersonByNameService.java @ 2:e3ecb88314a5
minor bugs
ontologies added
author | dwinter |
---|---|
date | Fri, 02 Dec 2011 08:37:03 +0100 |
parents | 1384a0d382fa |
children | f986e74583eb |
line wrap: on
line diff
--- a/src/de/mpiwg/itgroup/nimanager/persons/PersonByNameService.java Thu Jun 30 12:43:35 2011 +0200 +++ b/src/de/mpiwg/itgroup/nimanager/persons/PersonByNameService.java Fri Dec 02 08:37:03 2011 +0100 @@ -2,8 +2,6 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; -import java.net.URLEncoder; -import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; @@ -15,6 +13,7 @@ import org.openrdf.repository.RepositoryException; import org.openrdf.repository.RepositoryResult; import org.restlet.Context; +import org.restlet.data.ClientInfo; import org.restlet.data.Form; import org.restlet.data.MediaType; import org.restlet.data.Status; @@ -27,7 +26,6 @@ import org.restlet.resource.ServerResource; import virtuoso.jdbc4.VirtuosoResultSet; - import de.mpiwg.itgroup.nimanager.exceptions.TripleStoreHandlerException; import de.mpiwg.itgroup.nimanager.owl.TripleStoreHandler; @@ -91,11 +89,11 @@ String id = (String) getRequest().getAttributes().get("name"); id = URLDecoder.decode(id, "utf-8"); String queryPersonWPMD="sparql select DISTINCT * "+ - "FROM <file://mpiwg_persons.rdf>"+ + "FROM <"+PERSONS_CONTEXT+"> "+ "FROM <file://newpersonsFromProjects>"+ " FROM <file://personendataWikipedia>"+ " where { " + - "{GRAPH <file://mpiwg_persons.rdf>" + + "{GRAPH <"+PERSONS_CONTEXT+">" + "{"+ "?person <"+RELATION_FOR_NAME_SEARCH+"> \""+id+"\"@en."+ " ?ident <http://ontologies.mpiwg-berlin.mpg.de/authorities/namedIdentities/identifies_NamedEntity> ?person."+ @@ -162,7 +160,13 @@ public Representation getXML() { List<MediaType> supported=new ArrayList<MediaType>(); supported.add(MediaType.APPLICATION_JSON); + + ClientInfo ci = getRequest().getClientInfo(); + if(ci==null){ //don't know why this can happen, but sometimes does + setStatus(Status.SERVER_ERROR_INTERNAL); + return null; + } MediaType types = getRequest().getClientInfo().getPreferredMediaType(supported); if (types.equals(MediaType.APPLICATION_JSON)) return getJson(); @@ -205,9 +209,16 @@ List<MediaType> supported=new ArrayList<MediaType>(); supported.add(MediaType.APPLICATION_JSON); - MediaType types = getRequest().getClientInfo().getPreferredMediaType(supported); - if (types.equals(MediaType.APPLICATION_JSON)) - return getJson(); + ClientInfo ci = getRequest().getClientInfo(); + + if(ci==null){ //don't know why this can happen, but sometimes does + setStatus(Status.SERVER_ERROR_INTERNAL); + return null; + } + MediaType types = ci.getPreferredMediaType(supported); + if (types!=null) + if (types.equals(MediaType.APPLICATION_JSON)) + return getJson(); Form responseHeaders = (Form) getResponse().getAttributes().get( "org.restlet.http.headers"); @@ -225,7 +236,7 @@ // th.createLiteral(id, "en"), PERSONS_CONTEXT); String ret = "<html><body><div id=\"resultNames\">"; String queryPersonWPMD="sparql select * "+ -"FROM <file://mpiwg_persons.rdf>"+ +"FROM <"+PERSONS_CONTEXT+"> "+ " FROM <file://personendataWikipedia>"+ " where { "+ " ?person <"+RELATION_FOR_NAME_SEARCH+"> \""+id+"\"@en."+