Mercurial > hg > MetaDataManagerRestlet
changeset 3:dfd72ea936ff
search by ids nd names of persons
author | dwinter |
---|---|
date | Thu, 29 Dec 2011 15:19:29 +0100 |
parents | f13ac4acbb0d |
children | aae47a713589 |
files | .project .settings/org.eclipse.wst.common.component src/de/mpiwg/itgroup/metaDataManagerRestlet/RestServer.java src/de/mpiwg/itgroup/metaDataManagerRestlet/staticPages/generalInfo.html src/de/mpiwg/itgroup/metaDataManagerRestlet/staticPages/searchPersons.html src/de/mpiwg/itgroup/metaDataManagerRestlet/ui/GeneralInfo.java src/de/mpiwg/itgroup/metaDataManagerRestlet/ui/SearchPersons.java |
diffstat | 7 files changed, 147 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/.project Fri Dec 02 08:38:08 2011 +0100 +++ b/.project Thu Dec 29 15:19:29 2011 +0100 @@ -7,6 +7,7 @@ <project>NamedIdentityManager</project> <project>protege</project> <project>protege-core</project> + <project>TripleStoreManager</project> </projects> <buildSpec> <buildCommand>
--- a/.settings/org.eclipse.wst.common.component Fri Dec 02 08:38:08 2011 +0100 +++ b/.settings/org.eclipse.wst.common.component Thu Dec 29 15:19:29 2011 +0100 @@ -132,6 +132,9 @@ <dependent-module archiveName="lucene-core-3.1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/NamedIdentityManager/libs/lucene-3.1.0/lucene-core-3.1.0.jar"> <dependency-type>uses</dependency-type> </dependent-module> + <dependent-module archiveName="TripleStoreManager.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/TripleStoreManager/TripleStoreManager"> + <dependency-type>uses</dependency-type> + </dependent-module> <property name="java-output-path" value="/MetaDaterManagerRestlet/build/classes"/> <property name="context-root" value="MetaDataManagerRestlet"/> </wb-module>
--- a/src/de/mpiwg/itgroup/metaDataManagerRestlet/RestServer.java Fri Dec 02 08:38:08 2011 +0100 +++ b/src/de/mpiwg/itgroup/metaDataManagerRestlet/RestServer.java Thu Dec 29 15:19:29 2011 +0100 @@ -11,8 +11,11 @@ import org.restlet.routing.TemplateRoute; import de.mpiwg.itgroup.metaDataManagerRestlet.pid.PIDcreator; +import de.mpiwg.itgroup.metaDataManagerRestlet.ui.GeneralInfo; +import de.mpiwg.itgroup.metaDataManagerRestlet.ui.SearchPersons; import de.mpiwg.itgroup.metadataManager.indexMeta.server.IndexMetaProvider; import de.mpiwg.itgroup.nimanager.persons.PersonByNameService; +import de.mpiwg.itgroup.nimanager.persons.PersonByIDService; import de.mpiwg.itgroup.nimanager.persons.PersonListService; //import de.mpiwg.itgroup.nimanager.persons.PersonService; import de.mpiwg.itgroup.nimanager.persons.PersonService; @@ -34,11 +37,14 @@ public synchronized Restlet createInboundRoot(){ Router router = new Router(getContext()); + router.attach("/",GeneralInfo.class); router.attach("/PID",PIDcreator.class); + router.attach("/searchPersons",SearchPersons.class); router.attach("/person/name/{name}",PersonByNameService.class); router.attach("/persons",PersonListService.class); router.attach("/person/id/{personId}",PersonService.class); router.attach("/person/id/{personId}/{graphId}",PersonService.class); + router.attach("/ids",PersonByIDService.class); TemplateRoute route = router.attach("/indexMeta", IndexMetaProvider.class); route.setMatchingMode(Template.MODE_STARTS_WITH);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/metaDataManagerRestlet/staticPages/generalInfo.html Thu Dec 29 15:19:29 2011 +0100 @@ -0,0 +1,6 @@ +<html> +<h2>MPIWG Metadata Manager</h2> + +<a href="./searchPersons">SearchPersons</a> +<a href="./ids">ids</a> +</html> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/metaDataManagerRestlet/staticPages/searchPersons.html Thu Dec 29 15:19:29 2011 +0100 @@ -0,0 +1,27 @@ +<html> +<body> +<h2>MPIWG norm data search service</h2> +<h3>Search in name or firstname</h3> +<p>The only currently implemented search mode is "begins with" of parts of a name. Search is not case sensitive.</p> +<p>i.e. Search for "einst" gives, Einstein and Fiala-Einstein, but not Feinstein...</p> +<form method="get" action="./persons"> +<input name="term" size="100"/> +<input type="submit"> +</form> + + +<h3>Search Person by ID</h3> +<p>This services searches the MPIWG authority server for id of person names. +<p>This can be either +<ul> +<li>an MPIWG internal ID e.g. http://ontologies.mpiwg-berlin.mpg.de/authorities/namedIdentities/Person:11195</li> +<li>an ID from <a href="http://www.d-nb.de/standardisierung/normdateien/gnd.htm"> Gemeinsame Normdatei (GND) of the German National Libary</a> e.g. http://d-nb.info/gnd/118529579 </li> +<li>an ID from <a href="http://viaf.org">VIAF: Virtual International Authority File</a> e.g. http://viaf.org/viaf/75121530</li> +<li>an ID from <a href="http://http://dbpedia.org">DBPedia</a> e.g. http://dbpedia.org/resource/Albert_Einstein </li> +</ul> +</p> +<p>Search: +<form action="./ids">id: <input type="text" size="100" name="id"/><input type="submit"/></form> +</p> +</body> +</html> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/metaDataManagerRestlet/ui/GeneralInfo.java Thu Dec 29 15:19:29 2011 +0100 @@ -0,0 +1,52 @@ +package de.mpiwg.itgroup.metaDataManagerRestlet.ui; + +import java.io.InputStream; + +import org.apache.log4j.Logger; +import org.restlet.data.Form; +import org.restlet.data.MediaType; +import org.restlet.representation.InputRepresentation; +import org.restlet.representation.Representation; +import org.restlet.representation.StringRepresentation; +import org.restlet.resource.Get; +import org.restlet.resource.Options; +import org.restlet.resource.Post; +import org.restlet.resource.ServerResource; + +import de.mpiwg.itgroup.metadataManager.pid.PidGenerator; + + + +public class GeneralInfo extends ServerResource { + +private Logger logger = Logger.getRootLogger(); + + /** + * Erlaubt cross scripting bei Aufruf aus Javascript + * @param entity + */ + @Options + public void doOptions(Representation entity) { + Form responseHeaders = (Form) getResponse().getAttributes().get("org.restlet.http.headers"); + if (responseHeaders == null) { + responseHeaders = new Form(); + getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders); + } + responseHeaders.add("Access-Control-Allow-Origin", "*"); + responseHeaders.add("Access-Control-Allow-Methods", "POST,OPTIONS,GET"); + responseHeaders.add("Access-Control-Allow-Headers", "Content-Type"); + responseHeaders.add("Access-Control-Allow-Credentials", "false"); + responseHeaders.add("Access-Control-Max-Age", "60"); + } + + + @Get("html") + public Representation getHTML(){ + InputStream is = getClass().getResourceAsStream("/de/mpiwg/itgroup/metaDataManagerRestlet/staticPages/generalInfo.html"); + + Representation rep = new InputRepresentation(is,MediaType.TEXT_HTML); + return rep; + + } + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/metaDataManagerRestlet/ui/SearchPersons.java Thu Dec 29 15:19:29 2011 +0100 @@ -0,0 +1,52 @@ +package de.mpiwg.itgroup.metaDataManagerRestlet.ui; + +import java.io.InputStream; + +import org.apache.log4j.Logger; +import org.restlet.data.Form; +import org.restlet.data.MediaType; +import org.restlet.representation.InputRepresentation; +import org.restlet.representation.Representation; +import org.restlet.representation.StringRepresentation; +import org.restlet.resource.Get; +import org.restlet.resource.Options; +import org.restlet.resource.Post; +import org.restlet.resource.ServerResource; + +import de.mpiwg.itgroup.metadataManager.pid.PidGenerator; + + + +public class SearchPersons extends ServerResource { + +private Logger logger = Logger.getRootLogger(); + + /** + * Erlaubt cross scripting bei Aufruf aus Javascript + * @param entity + */ + @Options + public void doOptions(Representation entity) { + Form responseHeaders = (Form) getResponse().getAttributes().get("org.restlet.http.headers"); + if (responseHeaders == null) { + responseHeaders = new Form(); + getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders); + } + responseHeaders.add("Access-Control-Allow-Origin", "*"); + responseHeaders.add("Access-Control-Allow-Methods", "POST,OPTIONS,GET"); + responseHeaders.add("Access-Control-Allow-Headers", "Content-Type"); + responseHeaders.add("Access-Control-Allow-Credentials", "false"); + responseHeaders.add("Access-Control-Max-Age", "60"); + } + + + @Get("html") + public Representation getHTML(){ + InputStream is = getClass().getResourceAsStream("/de/mpiwg/itgroup/metaDataManagerRestlet/staticPages/searchPersons.html"); + + Representation rep = new InputRepresentation(is,MediaType.TEXT_HTML); + return rep; + + } + +}