Mercurial > hg > eSciDocMPIWGServicesRestlet
changeset 0:1aac45997235
first ingest
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.classpath Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JVM 1.6.0 (MacOS X Default)"> + <attributes> + <attribute name="owner.project.facets" value="java"/> + </attributes> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0"> + <attributes> + <attribute name="owner.project.facets" value="jst.web"/> + </attributes> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> + <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> + <classpathentry kind="lib" path="libs/org.restlet.jar"/> + <classpathentry kind="lib" path="libs/log4j-1.2.15.jar"/> + <classpathentry kind="lib" path="libs/org.restlet.ext.servlet.jar"/> + <classpathentry kind="lib" path="libs/httpclient-4.0.1.jar"/> + <classpathentry kind="lib" path="libs/httpcore-4.0.1.jar"/> + <classpathentry kind="lib" path="libs/jaxen-1.1.1.jar"/> + <classpathentry kind="lib" path="libs/jdom-1.0.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/eSciDocImport"/> + <classpathentry combineaccessrules="false" kind="src" path="/eSciDocTools"/> + <classpathentry kind="output" path="build/classes"/> +</classpath>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,3 @@ + +syntax: regexp +^src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/config/eScidocServer\.config$ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.project Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>eSciDocMPIWGServicesRestlet</name> + <comment></comment> + <projects> + <project>MetaDataManager</project> + <project>eSciDocTools</project> + <project>eSciDocImport</project> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.wst.jsdt.core.javascriptValidator</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.wst.common.project.facet.core.builder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.wst.validation.validationbuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jem.workbench.JavaEMFNature</nature> + <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> + <nature>org.eclipse.wst.common.project.facet.core.nature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.wst.jsdt.core.jsNature</nature> + </natures> +</projectDescription>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.settings/.jsdtscope Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="WebContent"/> + <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject"> + <attributes> + <attribute name="hide" value="true"/> + </attributes> + </classpathentry> + <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/> + <classpathentry kind="output" path=""/> +</classpath>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.settings/org.eclipse.core.resources.prefs Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,3 @@ +#Fri Aug 20 08:10:10 CEST 2010 +eclipse.preferences.version=1 +encoding//src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/PID.html=UTF-8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.settings/org.eclipse.jdt.core.prefs Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,8 @@ +#Mon Aug 16 10:21:43 CEST 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.settings/org.eclipse.wst.common.component Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project-modules id="moduleCoreId" project-version="1.5.0"> + <wb-module deploy-name="eScidocMPIWGServicesRestlet"> + <wb-resource deploy-path="/" source-path="/WebContent"/> + <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/> + <dependent-module archiveName="jdom-1.0.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/eSciDocMPIWGServicesRestlet/libs/jdom-1.0.jar"> + <dependency-type>uses</dependency-type> + </dependent-module> + <dependent-module archiveName="httpcore-4.0.1.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/eSciDocMPIWGServicesRestlet/libs/httpcore-4.0.1.jar"> + <dependency-type>uses</dependency-type> + </dependent-module> + <dependent-module archiveName="jaxen-1.1.1.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/eSciDocMPIWGServicesRestlet/libs/jaxen-1.1.1.jar"> + <dependency-type>uses</dependency-type> + </dependent-module> + <dependent-module archiveName="httpclient-4.0.1.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/eSciDocMPIWGServicesRestlet/libs/httpclient-4.0.1.jar"> + <dependency-type>uses</dependency-type> + </dependent-module> + <dependent-module archiveName="log4j-1.2.15.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/eSciDocMPIWGServicesRestlet/libs/log4j-1.2.15.jar"> + <dependency-type>uses</dependency-type> + </dependent-module> + <dependent-module archiveName="org.restlet.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/eSciDocMPIWGServicesRestlet/libs/org.restlet.jar"> + <dependency-type>uses</dependency-type> + </dependent-module> + <dependent-module archiveName="org.restlet.ext.servlet.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/eSciDocMPIWGServicesRestlet/libs/org.restlet.ext.servlet.jar"> + <dependency-type>uses</dependency-type> + </dependent-module> + <dependent-module archiveName="MetaDataManager.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/MetaDataManager/MetaDataManager"> + <dependency-type>uses</dependency-type> + </dependent-module> + <dependent-module archiveName="eSciDocTools.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/eSciDocTools/eSciDocTools"> + <dependency-type>uses</dependency-type> + </dependent-module> + <dependent-module archiveName="eSciDocImport.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/eSciDocImport/eSciDocImport"> + <dependency-type>uses</dependency-type> + </dependent-module> + <dependent-module archiveName="xmlrpc-client-3.1.2.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/eSciDocImport/libs/xmlrpc-client-3.1.2.jar"> + <dependency-type>uses</dependency-type> + </dependent-module> + <dependent-module archiveName="xmlrpc-common-3.1.2.jar" deploy-path="/WEB-INF/lib" handle="module:/classpath/lib/eSciDocImport/libs/xmlrpc-common-3.1.2.jar"> + <dependency-type>uses</dependency-type> + </dependent-module> + <property name="java-output-path" value="/eScidocMPIWGServicesRestlet/build/classes"/> + <property name="context-root" value="eScidocMPIWGServicesRestlet"/> + </wb-module> +</project-modules>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<faceted-project> + <runtime name="Apache Tomcat v6.0"/> + <fixed facet="jst.web"/> + <fixed facet="java"/> + <fixed facet="wst.jsdt.web"/> + <installed facet="java" version="1.6"/> + <installed facet="jst.web" version="2.5"/> + <installed facet="wst.jsdt.web" version="1.0"/> +</faceted-project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,1 @@ +Window \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebContent/META-INF/MANIFEST.MF Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebContent/WEB-INF/web.xml Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app id="WebApp_ID" version="2.4" +xmlns="http://java.sun.com/xml/ns/j2ee" +xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee +http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> +<display-name>RESTfulJavaWebServices-Restlet</display-name> +<!-- Application classname --> +<context-param> +<param-name>org.restlet.application</param-name> +<param-value>de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.RestServer</param-value> +</context-param> + + +<!-- Restletadapter --> +<servlet> +<servlet-name>RestletServlet</servlet-name> +<servlet-class> +org.restlet.ext.servlet.ServerServlet +</servlet-class> +</servlet> + +<!-- Catchallrequests --> +<servlet-mapping> +<servlet-name>RestletServlet</servlet-name> +<url-pattern>/*</url-pattern> +</servlet-mapping> +</web-app> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/RestServer.java Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,52 @@ +package de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet; + +import org.apache.log4j.BasicConfigurator; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.restlet.Application; +import org.restlet.Context; +import org.restlet.Restlet; +import org.restlet.routing.Router; +import org.restlet.routing.Template; +import org.restlet.routing.TemplateRoute; + +import de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.display.DisplayContainer; +import de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.redirect.DigilibRedirector; +import de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.redirect.DisplayRedirector; +import de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.redirect.ECHORedirector; +import de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.redirect.IndexMetaRedirector; +import de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.redirect.OrigRefRedirector; +import de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.search.SimpleSearch; + + + + +public class RestServer extends Application { + + public RestServer(Context parentContext){ + super(parentContext); + + Logger rl = Logger.getRootLogger(); + BasicConfigurator.configure(); + rl.setLevel(Level.DEBUG); + + + } + + public synchronized Restlet createInboundRoot(){ + Router router = new Router(getContext()); + router.attach("/search",SimpleSearch.class); + router.attach("/container/{escidocId}",DisplayContainer.class); + router.attach("/resultOverview.css",ResultOverviewCSS.class); // zeigt den image ordner im digilib standard display an + router.attach("/{escidocId}",ECHORedirector.class); // redirected zur webseite die in echo angebeben ist + router.attach("/{escidocId}/echo",ECHORedirector.class); // redirected zur ECHO Seite, diese redirected eventuell, direct wieder + router.attach("/{escidocId}/display",DisplayRedirector.class); // redirected zur display_url die in ECHO angegeben ist, wenn dort keine steht dann wird der image ordner im generischen viewer angezeigt + router.attach("/{escidocId}/images",DigilibRedirector.class); // zeigt den image ordner im digilib standard display an + router.attach("/{escidocId}/indexMeta",IndexMetaRedirector.class); // zeigt die in ESCIDOC abegespeicherten index_meta an + router.attach("/{escidocId}/origRef",OrigRefRedirector.class); // zeigt die original Quelle der Metadaten an, in der Regel das IndexMeta file auf der Foxridge + + + return router; + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/ResultOverviewCSS.java Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,20 @@ +package de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet; + +import java.io.InputStream; + +import org.restlet.data.MediaType; +import org.restlet.representation.InputRepresentation; +import org.restlet.representation.Representation; +import org.restlet.resource.Get; +import org.restlet.resource.ServerResource; + +public class ResultOverviewCSS extends ServerResource{ + + @Get("html") + public Representation getHtml(){ + + InputStream in = getClass().getResourceAsStream("/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/resultOverview.css"); + + return new InputRepresentation(in, MediaType.TEXT_CSS); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/services/display/DisplayContainer.java Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,127 @@ +package de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.display; + +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.TransformerFactoryConfigurationError; +import javax.xml.transform.stream.StreamSource; + +import org.apache.http.HttpResponse; +import org.apache.log4j.Logger; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.jdom.output.XMLOutputter; +import org.jdom.transform.JDOMResult; +import org.jdom.transform.JDOMSource; +import org.restlet.data.MediaType; +import org.restlet.data.Status; +import org.restlet.representation.InputRepresentation; +import org.restlet.representation.Representation; +import org.restlet.representation.StringRepresentation; +import org.restlet.resource.Get; +import org.restlet.resource.ServerResource; + +import de.mpiwg.itgroup.eSciDoc.Tools.EScidocBasicHandler; + +public class DisplayContainer extends ServerResource { + + private Logger logger = Logger.getRootLogger(); + private String eScidocServer; + private String eScidocPort; + + public DisplayContainer() throws IOException{ + InputStream is = getClass().getResourceAsStream("/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/config/eScidocServer.config"); + Properties prop = new Properties(); + prop.load(is); + eScidocServer = (String)prop.get("eScidocServer"); + eScidocPort = (String)prop.get("eScidocPort"); + } + @Get("html") + public Representation getHtml() throws IOException, JDOMException, TransformerFactoryConfigurationError, TransformerException{ + + + + String id = (String)getRequest().getAttributes().get("escidocId"); + + EScidocBasicHandler handler = new EScidocBasicHandler(eScidocServer, Integer.valueOf(eScidocPort),"dwinter","weikiki7"); + HttpResponse result = handler.eScidocGet("/ir/container/"+id); + + if (result.getStatusLine().getStatusCode()!=200){ + setStatus(Status.SERVER_ERROR_INTERNAL); + return new StringRepresentation("<error>error</error>"); + } + InputStream in = result.getEntity().getContent(); + Document doc = new SAXBuilder().build(in); + + + + InputStream xslt = getClass().getResourceAsStream("/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/displayContainerHeader.xsl"); + + + Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(xslt)); + + // get header + JDOMSource inxml = new JDOMSource(doc); + JDOMResult out = new JDOMResult(); + transformer.transform(inxml, out); + logger.debug(printXML(doc)); + + List<Element> results = out.getResult(); + Element headerTag=null; + if (results!=null && results.size()>0){ + headerTag = results.get(0); + } + + //get structmap + + + result = handler.eScidocGet("/ir/container/"+id+"/resources/members"); + + if (result.getStatusLine().getStatusCode()!=200){ + setStatus(Status.SERVER_ERROR_INTERNAL); + return new StringRepresentation("<error>error</error>"); + } + in = result.getEntity().getContent(); + doc = new SAXBuilder().build(in); + xslt = getClass().getResourceAsStream("/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/collectionDisplay.xsl"); + transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(xslt)); + + + inxml = new JDOMSource(doc); + out = new JDOMResult(); + transformer.transform(inxml, out); + logger.debug(printXML(doc)); + + results = out.getResult(); + Element listTag=null; + if (results!=null && results.size()>0){ + listTag = results.get(0); + } + + + return new StringRepresentation("<html><body>"+printXML(headerTag)+printXML(listTag)+"</html></body>",MediaType.TEXT_HTML); + } + + private String printXML(Element headerTag) { + XMLOutputter out = new XMLOutputter(); + + String string = out.outputString(headerTag); + return string; + + } + public String printXML(Document dom) throws IOException{ + XMLOutputter out = new XMLOutputter(); + + String string = out.outputString(dom); + return string; + +} +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/services/redirect/ComponentURLRedirector.java Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,107 @@ +package de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.redirect; + + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.apache.http.HttpResponse; +import org.jdom.Attribute; +import org.jdom.Document; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.jdom.xpath.XPath; +import org.restlet.data.Status; +import org.restlet.representation.Representation; +import org.restlet.representation.StringRepresentation; +import org.restlet.resource.Get; +import org.restlet.resource.ServerResource; + +import de.mpiwg.itgroup.eSciDoc.Tools.EScidocBasicHandler; +import de.mpiwg.itgroup.eSciDoc.Tools.EScidocTools; + + +public class ComponentURLRedirector extends ServerResource{ + + private String eScidocServer; + private String eScidocPort; + private String content_cat; + private String eScidocUser; + private String eScidocUserPW; + + public ComponentURLRedirector(String content_cat) throws IOException{ + this.content_cat = content_cat; + InputStream is = getClass().getResourceAsStream("/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/config/eScidocServer.config"); + Properties prop = new Properties(); + prop.load(is); + + eScidocServer= (String)prop.get("eScidocServer"); + eScidocPort=(String)prop.get("eScidocPort"); + eScidocUser = (String)prop.get("eScidocUser"); + eScidocUserPW=(String)prop.get("eScidocUserPW"); + + } + @Get("html") + public Representation getHtml() + { + String id = (String)getRequest().getAttributes().get("escidocId"); + EScidocBasicHandler handler = null; + if (getContext().getAttributes().containsKey("escidocHandler")){ + handler = (EScidocBasicHandler) getContext().getAttributes().get("escidocHandler"); + } + + if (handler==null){ + handler = new EScidocBasicHandler(eScidocServer, Integer.valueOf(eScidocPort),eScidocUser,eScidocUserPW); + } + + + HttpResponse resp; + try { + resp = handler.eScidocGet("/ir/item/"+id); + } catch (IOException e) { + setStatus(Status.SERVER_ERROR_INTERNAL); + return new StringRepresentation("<html><body>error1</body></html>"); + } + int code = resp.getStatusLine().getStatusCode(); + if (code!=200){ + setStatus(new Status(code)); + return new StringRepresentation("<html><body>error2</body></html>"); + + } + + Document doc; + String url; + try { + doc = new SAXBuilder().build(resp.getEntity().getContent()); + + + XPath xp= EScidocTools.getESciDocXpath("//escidocComponents:component[escidocComponents:properties/prop:content-category[text()='"+content_cat+"']]/escidocComponents:content/@xlink:href"); + Attribute item = (Attribute)xp.selectSingleNode(doc); + url = item.getValue(); + + } catch (Exception e) { + + if (content_cat.equals("display_url")) // wemm display und error dann versuche genrische anzeige der bilder + { + url="./images"; + StringRepresentation repr = new StringRepresentation(url); + getResponse().redirectPermanent(url); + return repr; + + } else { + setStatus(Status.SERVER_ERROR_INTERNAL); + + return new StringRepresentation("<html><body>error3a</body></html>"); + } + } + + + if (!url.startsWith("http")) { // relative url + url="http://"+eScidocServer+":"+eScidocPort+url; + } + + StringRepresentation repr = new StringRepresentation(url); + getResponse().redirectPermanent(url); + return repr; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/services/redirect/DigilibRedirector.java Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,91 @@ +package de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.redirect; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.apache.http.HttpResponse; +import org.jdom.Attribute; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.jdom.xpath.XPath; +import org.restlet.data.Status; +import org.restlet.representation.Representation; +import org.restlet.representation.StringRepresentation; +import org.restlet.resource.Get; +import org.restlet.resource.ServerResource; + +import de.mpiwg.itgroup.eSciDoc.Tools.EScidocBasicHandler; +import de.mpiwg.itgroup.eSciDoc.Tools.EScidocTools; +import de.mpiwg.itgroup.eSciDoc.echoObjects.ECHORessource; + + +public class DigilibRedirector extends ServerResource{ + + private String eScidocServer; + private String eScidocPort; + private String digilibPath; + private String eScidocUser; + private String eScidocUserPW; + public DigilibRedirector() throws IOException{ + InputStream is = getClass().getResourceAsStream("/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/config/eScidocServer.config"); + Properties prop = new Properties(); + prop.load(is); + eScidocServer= (String)prop.get("eScidocServer"); + eScidocPort=(String)prop.get("eScidocPort"); + digilibPath=(String)prop.get("digilibPath"); + eScidocUser=(String)prop.get("eScidocUser"); + eScidocUserPW=(String)prop.get("eScidocUserPW"); + + } + @Get("html") + public Representation getHtml() + { + String id = (String)getRequest().getAttributes().get("escidocId"); + EScidocBasicHandler handler = null; + if (getContext().getAttributes().containsKey("escidocHandler")){ + handler = (EScidocBasicHandler) getContext().getAttributes().get("escidocHandler"); + } + + if (handler==null){ + handler = new EScidocBasicHandler(eScidocServer, Integer.valueOf(eScidocPort),eScidocUser,eScidocUserPW); + } + + + HttpResponse resp; + try { + resp = handler.eScidocGet("/ir/item/"+id); + } catch (IOException e) { + setStatus(Status.SERVER_ERROR_INTERNAL); + return new StringRepresentation("<html><body>error1</body></html>"); + } + int code = resp.getStatusLine().getStatusCode(); + if (code!=200){ + setStatus(new Status(code)); + return new StringRepresentation("<html><body>error2</body></html>"); + + } + + Document doc; + String path; + try { + doc = new SAXBuilder().build(resp.getEntity().getContent()); + + + XPath xp= EScidocTools.getESciDocXpath("//metadataRecords:md-record[@xlink:title='mpiwg-admin']/mpiwg:admin/mpiwg:imageFolder"); + Element item = (Element)xp.selectSingleNode(doc); + path = item.getTextTrim(); + path= ECHORessource.correct(path); // nur pfad nach online + } catch (Exception e) { + setStatus(Status.SERVER_ERROR_INTERNAL); + return new StringRepresentation("<html><body>error3</body></html>"); + } + + + StringRepresentation repr = new StringRepresentation(digilibPath+path); + getResponse().redirectPermanent(digilibPath+path); + return repr; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/services/redirect/DisplayRedirector.java Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,13 @@ +package de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.redirect; + +import java.io.IOException; + + +public class DisplayRedirector extends ComponentURLRedirector { + + public DisplayRedirector() throws IOException { + super("display_url"); + // TODO Auto-generated constructor stub + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/services/redirect/ECHORedirector.java Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,13 @@ +package de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.redirect; + +import java.io.IOException; + + + +public class ECHORedirector extends ComponentURLRedirector{ + + public ECHORedirector() throws IOException { + super("web_page"); + } + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/services/redirect/IndexMetaRedirector.java Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,14 @@ +package de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.redirect; + +import java.io.IOException; + + + +public class IndexMetaRedirector extends ComponentURLRedirector{ + + public IndexMetaRedirector() throws IOException { + super("index_meta"); + // TODO Auto-generated constructor stub + } + +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/services/redirect/OrigRefRedirector.java Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,133 @@ +package de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.redirect; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.TransformerFactoryConfigurationError; +import javax.xml.transform.stream.StreamSource; + +import org.apache.http.HttpResponse; +import org.jdom.Attribute; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.jdom.output.XMLOutputter; +import org.jdom.transform.JDOMResult; +import org.jdom.transform.JDOMSource; +import org.jdom.xpath.XPath; +import org.restlet.data.Form; +import org.restlet.data.MediaType; +import org.restlet.data.Status; +import org.restlet.representation.Representation; +import org.restlet.representation.StringRepresentation; +import org.restlet.resource.Get; +import org.restlet.resource.ServerResource; + +import de.mpiwg.itgroup.eSciDoc.Tools.EScidocBasicHandler; +import de.mpiwg.itgroup.eSciDoc.Tools.EScidocTools; +import de.mpiwg.itgroup.eSciDoc.echoObjects.ECHORessource; + + +public class OrigRefRedirector extends ServerResource{ + + private String eScidocServer; + private String eScidocPort; + + private String eScidocUser; + private String eScidocUserPW; + public OrigRefRedirector() throws IOException{ + InputStream is = getClass().getResourceAsStream("/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/config/eScidocServer.config"); + Properties prop = new Properties(); + prop.load(is); + eScidocServer= (String)prop.get("eScidocServer"); + eScidocPort=(String)prop.get("eScidocPort"); + eScidocUser=(String)prop.get("eScidocUser"); + eScidocUserPW=(String)prop.get("eScidocUserPW"); + + } + @Get("html") + public Representation getHtml() throws JDOMException, IOException, TransformerFactoryConfigurationError, TransformerException + { + + Form form = getRequest().getResourceRef().getQueryAsForm(); + + String mode=form.getValues("mode"); //xml or html default is html + if(mode==null | mode.equals("")) + mode="xml"; + + String id = (String)getRequest().getAttributes().get("escidocId"); + EScidocBasicHandler handler = null; + if (getContext().getAttributes().containsKey("escidocHandler")){ + handler = (EScidocBasicHandler) getContext().getAttributes().get("escidocHandler"); + } + + if (handler==null){ + handler = new EScidocBasicHandler(eScidocServer, Integer.valueOf(eScidocPort),eScidocUser,eScidocUserPW); + } + + + HttpResponse resp; + try { + resp = handler.eScidocGet("/ir/item/"+id); + } catch (IOException e) { + setStatus(Status.SERVER_ERROR_INTERNAL); + return new StringRepresentation("<html><body>error1</body></html>"); + } + int code = resp.getStatusLine().getStatusCode(); + if (code!=200){ + setStatus(new Status(code)); + return new StringRepresentation("<html><body>error2</body></html>"); + + } + + Document doc; + String path; + try { + doc = new SAXBuilder().build(resp.getEntity().getContent()); + + + XPath xp= EScidocTools.getESciDocXpath("//metadataRecords:md-record[@xlink:title='mpiwg-admin']/mpiwg:admin/mpiwg:orig-ref/@xlink:href"); + Attribute item = (Attribute)xp.selectSingleNode(doc); + path = item.getValue(); + } catch (Exception e) { + setStatus(Status.SERVER_ERROR_INTERNAL); + return new StringRepresentation("<html><body>error3</body></html>"); + } + + if(mode.equals("xml")) + { + StringRepresentation repr = new StringRepresentation(path); + getResponse().redirectPermanent(path); + return repr; + } else if (mode.equals("html")){ + Document indexMeta = new SAXBuilder().build(path); + InputStream xslt= getClass().getResourceAsStream("/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/formatIndexMeta.xsl"); + //Document styleDoc = new SAXBuilder().build(xslt); + + Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(xslt)); + JDOMSource inxml = new JDOMSource(indexMeta); + JDOMResult out = new JDOMResult(); + transformer.transform(inxml, out); + //logger.debug(printXML(doc)); + + Document docresult = out.getDocument(); + return new StringRepresentation(printXML(docresult),MediaType.TEXT_HTML); + } else { + setStatus(Status.CLIENT_ERROR_BAD_REQUEST); + return new StringRepresentation("<html><body>wrong value for parameter mode, only html or xml allowed.</body></html>"); + } + } + + public String printXML(Document dom) throws IOException{ + XMLOutputter out = new XMLOutputter(); + + String string = out.outputString(dom); + return string; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/services/search/SimpleSearch.java Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,201 @@ +package de.mpiwg.itgroup.escidoc.MPIWGServices.Restlet.services.search; + + + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Properties; + +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.TransformerFactoryConfigurationError; +import javax.xml.transform.stream.StreamSource; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpResponse; +import org.apache.log4j.Logger; +import org.jdom.Document; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.jdom.output.XMLOutputter; +import org.jdom.transform.JDOMResult; +import org.jdom.transform.JDOMSource; +import org.jdom.transform.XSLTransformer; +import org.restlet.data.Form; +import org.restlet.data.MediaType; +import org.restlet.data.Status; +import org.restlet.representation.InputRepresentation; +import org.restlet.representation.Representation; +import org.restlet.representation.StreamRepresentation; +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 org.w3c.dom.Entity; + +import de.mpiwg.itgroup.eSciDoc.Tools.EScidocBasicHandler; + +public class SimpleSearch extends ServerResource{ + + private String eScidocServer; + private String eScidocPort; + private Logger logger= Logger.getRootLogger(); + private String eScidocUser; + private String eScidocUserPW; + + public SimpleSearch() throws IOException{ + InputStream is = getClass().getResourceAsStream("/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/config/eScidocServer.config"); + Properties prop = new Properties(); + prop.load(is); + eScidocServer= (String)prop.get("eScidocServer"); + eScidocPort=(String)prop.get("eScidocPort"); + eScidocUser=(String)prop.get("eScidocUser"); + eScidocUserPW=(String)prop.get("eScidocUserPW"); + } + @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(){ + + // response header fuer cross-site.scripting + 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", "*"); + + Form form = getRequest().getResourceRef().getQueryAsForm(); + + Representation returnRepr = doSearch(form); + if (returnRepr==null){ + InputStream in = getClass().getResourceAsStream("/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/search.html"); + + return new InputRepresentation(in, MediaType.TEXT_HTML); + } + else + return returnRepr; + + } + + + /** + * Bearbeite das Suchformular, gibt null zurueck, wenn das formular leer ist. + * @param searchForm + * @return + */ + public Representation doSearch(Form searchForm){ + + + String searchAll=searchForm.getValues("allMetadata"); + String searchTitle=searchForm.getValues("title"); + String searchAuthor=searchForm.getValues("author"); + + String queryString =""; + Boolean isSearch=false; + if (searchAll!=null && !searchAll.equals("")){ + queryString="escidoc.metadata="+searchAll; + isSearch=true; + } else if (searchTitle!=null && !searchTitle.equals("")){ + queryString="escidoc.any-title="+searchTitle; + isSearch=true; + } else if (searchAuthor!=null && !searchAuthor.equals("")){ + queryString="escidoc.creator="+searchAuthor; + isSearch=true; + } + if (!isSearch) return null; + + String query; + try { + query = "/srw/search/escidoc_all?maximumRecords=3&query="+URLEncoder.encode(queryString,"utf-8"); + } catch (UnsupportedEncodingException e) { + logger.error("do Search, cannot encode:"+queryString); + setStatus(Status.SERVER_ERROR_INTERNAL); + return new StringRepresentation("<error>error</error>"); + } + + EScidocBasicHandler handler = new EScidocBasicHandler(eScidocServer, Integer.valueOf(eScidocPort),eScidocUser,eScidocUserPW); + + HttpResponse result; + try { + result = handler.eScidocGet(query); + } catch (IOException e) { + logger.error("do Search, cannot encode:"+queryString); + setStatus(Status.SERVER_ERROR_INTERNAL); + return new StringRepresentation("<error>error</error>"); + } + + if (result.getStatusLine().getStatusCode()!=200){ + setStatus(Status.SERVER_ERROR_INTERNAL); + logger.error("do Search, got Error:"+queryString); + + HttpEntity ent = result.getEntity(); + if (ent!=null){ + InputStream in; + try { + in = ent.getContent(); + } catch (Exception e) { + return new StringRepresentation("<error>error</error>"); + } + + return new InputRepresentation(in); + } + else { + return new StringRepresentation("<error>error</error>"); + } + } + + InputStream in; + try { + in = result.getEntity().getContent(); + + Document doc = new SAXBuilder().build(in); + InputStream xslt= getClass().getResourceAsStream("/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/searchResult.xsl"); + //Document styleDoc = new SAXBuilder().build(xslt); + + Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(xslt)); + JDOMSource inxml = new JDOMSource(doc); + JDOMResult out = new JDOMResult(); + transformer.transform(inxml, out); + //logger.debug(printXML(doc)); + + Document docresult = out.getDocument(); + return new StringRepresentation(printXML(docresult),MediaType.TEXT_HTML); + + } catch (Exception e) { + logger.trace(e); + return new StringRepresentation("<error>error</error>"); + } + + + + + } + + public String printXML(Document dom) throws IOException{ + XMLOutputter out = new XMLOutputter(); + + String string = out.outputString(dom); + return string; + +} +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/PID.html Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,7 @@ +<html> +<body> +<h1>PID Generator</h1> +<p>Erzeugt PIDs für den Gebrauch am MPIWG</p> +<p>Usage: POST /PID, zurück kommt eine ID als Plain-Text. +</body> +</html> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/collectionDisplay.xsl Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,51 @@ +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +xmlns:srw="http://www.loc.gov/zing/srw/" +xmlns:search-result="http://www.escidoc.de/schemas/searchresult/0.8" +xmlns:escidocComponents="http://www.escidoc.de/schemas/components/0.9" + xmlns:escidocContentStreams="http://www.escidoc.de/schemas/contentstreams/0.7" + xmlns:escidocItem="http://www.escidoc.de/schemas/item/0.9" + xmlns:escidocMetadataRecords="http://www.escidoc.de/schemas/metadatarecords/0.5" + xmlns:prop="http://escidoc.de/core/01/properties/" + xmlns:relations="http://www.escidoc.de/schemas/relations/0.3" + xmlns:release="http://escidoc.de/core/01/properties/release/" + xmlns:srel="http://escidoc.de/core/01/structural-relations/" + xmlns:version="http://escidoc.de/core/01/properties/version/" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:xlink="http://www.w3.org/1999/xlink" + + xmlns:container="http://www.escidoc.de/schemas/container/0.8" +> + + <xsl:template match="/"> + <div class="content"> + <xsl:apply-templates select="//srw:recordData"/> + </div> + </xsl:template> + + <xsl:template match="srw:recordData"> + <hr/> + <!-- <xsl:apply-templates select="//escidocItem:item"/> + <xsl:apply-templates select="//container:container"/>--> + <xsl:apply-templates select="(escidocItem:item) | (container:container)" mode="content"/> + + </xsl:template> + <xsl:template match="search-result:text-fragment-data"> + <xsl:copy/> + </xsl:template> + <xsl:template match="escidocItem:item" mode="content"> + <div class="resultTitle"><xsl:value-of select=".//dc:title"/></div> + <div class="resultDescription"><xsl:value-of select=".//dc:description"/></div> + <!-- <xsl:apply-templates select=".//search-result:text-fragment-data"/>--> + <div class="showEntry"><a><xsl:attribute name="href"><xsl:value-of select=".//escidocComponents:component[escidocComponents:properties/prop:content-category[text()='web_page']]/escidocComponents:content/@xlink:href"/> + </xsl:attribute>show</a></div> + </xsl:template> + + <xsl:template match="container:container" mode="content"> + <div class="resultTitle"><xsl:value-of select=".//dc:title"/></div> + <div class="resultDescription"><xsl:value-of select=".//dc:description"/></div> + <!-- <xsl:apply-templates select=".//search-result:text-fragment-data"/>--> + <div class="showEntry"><a><xsl:attribute name="href">container/<xsl:value-of select="@objid"/> + </xsl:attribute>show</a></div> + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/displayContainerHeader.xsl Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,27 @@ +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +xmlns:srw="http://www.loc.gov/zing/srw/" +xmlns:search-result="http://www.escidoc.de/schemas/searchresult/0.8" +xmlns:escidocComponents="http://www.escidoc.de/schemas/components/0.9" + xmlns:escidocContentStreams="http://www.escidoc.de/schemas/contentstreams/0.7" + xmlns:escidocItem="http://www.escidoc.de/schemas/item/0.9" + xmlns:escidocMetadataRecords="http://www.escidoc.de/schemas/metadatarecords/0.5" + xmlns:prop="http://escidoc.de/core/01/properties/" + xmlns:relations="http://www.escidoc.de/schemas/relations/0.3" + xmlns:release="http://escidoc.de/core/01/properties/release/" + xmlns:srel="http://escidoc.de/core/01/structural-relations/" + xmlns:version="http://escidoc.de/core/01/properties/version/" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:container="http://www.escidoc.de/schemas/container/0.8" +> + + <xsl:template match="/"> + <div class="header"> + <div class="resultTitle"><xsl:value-of select=".//dc:title"/></div> + <div class="resultDescription"><xsl:value-of select=".//dc:description"/></div> + </div> + + <xsl:apply-templates select="//search-result:search-result-record"/> + + </xsl:template> + </xsl:stylesheet> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/formatIndexMeta.xsl Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,338 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- based on Resurce2Html.xsl, copyright by Max Planck Digital Library --> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:prop="http://escidoc.de/core/01/properties/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + version="1.0" xmlns:xlink="http://www.w3.org/1999/xlink"> + <xsl:output encoding="iso-8859-1" indent="yes" method="html" /> + + <!-- display serialized java.util.Properties nicely --> + <xsl:template match="/properties"> + <xsl:for-each select="entry"> + <ul> + <b> + <xsl:value-of select="@key" /> + : + </b> + <xsl:value-of select="./text()" /> + </ul> + </xsl:for-each> + </xsl:template> + + <xsl:template match="/"> + <html> + <head> + <title>eSciDoc<xsl:if test="*/@xlink:title != ''"> - <xsl:value-of select="*/@xlink:title"/></xsl:if><xsl:if test="*/@xlink:href"> - <xsl:value-of select="*/@xlink:href"/></xsl:if></title> + + </head> + <body bgcolor="#eeeeee"> + <img src="http://www.mpiwg-berlin.mpg.de/en/images/logo.png" /> + <br /> + <!-- + <xsl:choose> + <xsl:when test="item-list-refs"> + <xsl:for-each select="item-list-refs"> + <xsl:call-template name="item-list-refs" /> + </xsl:for-each> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates /> + </xsl:otherwise> + </xsl:choose> + --> + <xsl:apply-templates/> + </body> + </html> + </xsl:template> + <xsl:template match="item-ref-list|item-list-refs"> + <xsl:variable name="theBase"> + <xsl:value-of select="@xml:base" /> + </xsl:variable> + <h2> + <xsl:value-of select="@xlink:title" /> + </h2> + <xsl:for-each select="*"> + <li> + <a> + <xsl:attribute name="href"> + <xsl:value-of select="$theBase" /> + <xsl:value-of select="@xlink:href" /> + </xsl:attribute> + <xsl:value-of select="@objid" /> + </a> + </li> + </xsl:for-each> + </xsl:template> + <xsl:template match="exception"> + <h1><xsl:value-of select="title"/></h1> + <blockquote> + <P><xsl:value-of select="class"/></P> + <xsl:variable name="UID">message<xsl:value-of select="count(ancestor::*)"/></xsl:variable> + <P> + <xsl:attribute name="onClick">toggleVisibility('<xsl:value-of select="$UID"/>');</xsl:attribute> + <xsl:attribute name="id"> + <xsl:value-of select="$UID"/> + </xsl:attribute> + <xsl:attribute name="style">border: 0px solid #000000;</xsl:attribute> + <font style="color: #0000ff;">Message</font> + </P> + <pre style="display: none; visibility: hidden;"> + <xsl:attribute name="id"><xsl:value-of select="$UID"/>-body</xsl:attribute> + <xsl:value-of select="message"/> + </pre> + + <xsl:variable name="UID2">stacktrace<xsl:value-of select="count(ancestor::*)"/></xsl:variable> + <P> + <xsl:attribute name="onClick">toggleVisibility('<xsl:value-of select="$UID2"/>');</xsl:attribute> + <xsl:attribute name="id"> + <xsl:value-of select="$UID2"/> + </xsl:attribute> + <xsl:attribute name="style">border: 0px solid #000000;</xsl:attribute> + <font style="color: #0000ff;">Stack Trace</font> + </P> + <pre style="display: none; visibility: hidden;"> + <xsl:attribute name="id"><xsl:value-of select="$UID2"/>-body</xsl:attribute> + <xsl:value-of select="stack-trace"/> + </pre> + + <xsl:variable name="UID3">more<xsl:value-of select="count(ancestor::*)"/></xsl:variable> + <xsl:if test="cause/exception"> + <P> + <xsl:attribute name="onClick">toggleVisibility('<xsl:value-of select="$UID3"/>');</xsl:attribute> + <xsl:attribute name="id"> + <xsl:value-of select="$UID3"/> + </xsl:attribute> + <xsl:attribute name="style">border: 0px solid #000000;</xsl:attribute> + <font style="color: #0000ff;">Nested Exceptions</font> + </P> + <pre style="display: none; visibility: hidden;"> + <xsl:attribute name="id"><xsl:value-of select="$UID3"/>-body</xsl:attribute> + <xsl:apply-templates select="cause/exception"/> + </pre> + </xsl:if> + </blockquote> + </xsl:template> + + <!-- + <xsl:template match="rdf:RDF"> + <h3>From RDF representation:</h3> + <ul> + <xsl:apply-templates/> + </ul> + </xsl:template> + <xsl:template match="rdf:Description"> + <li><a><xsl:attribute name="href">/ir/item/<xsl:value-of select="substring-after(@rdf:about, '/')"/></xsl:attribute><xsl:value-of select="*[local-name() = 'title']"/></a> + <ul> + <li>created by<xsl:text> </xsl:text><b><xsl:value-of select="*[local-name() = 'created-by-title']"/></b></li> + <li>status is<xsl:text> </xsl:text><b><xsl:value-of select="*[local-name() = 'latest-version-status']"/></b> + <xsl:if test="*[local-name() = 'public-status' and text() = 'released']"> + and is <b>public available</b> + </xsl:if> + </li> + <li>known PIDs: + <xsl:for-each select="*[local-name() = 'identifier']"> +    <b><xsl:value-of select="."/></b> + </xsl:for-each> + </li> + </ul> + </li> + </xsl:template> + --> + + <xsl:template match="identifier"> + </xsl:template> + + <xsl:template match="*"> + <xsl:variable name="theBase"> + <xsl:value-of select="@xml:base" /> + </xsl:variable> + <!-- Base-URL is <xsl:value-of select="$theBase"/> --> + <h3> + <xsl:value-of select="@xlink:title" /> + ( + <xsl:value-of select="local-name()" /> + <xsl:choose> + <xsl:when test="@objid"> + - + <xsl:value-of select="@objid" /> + </xsl:when> + <xsl:when test="@name"> + - + <xsl:value-of select="@name" /> + </xsl:when> + <xsl:when test="@id"> + - + <xsl:value-of select="@id" /> + </xsl:when> + </xsl:choose> + ) + </h3> + <xsl:if test="./*/*[local-name() = 'version']"> + <p> + This version: + <a> + <xsl:attribute name="href"> + <xsl:value-of select="$theBase" /> + <xsl:value-of + select="./*/*[local-name() = 'version']/@xlink:href" /> + </xsl:attribute> + <xsl:value-of + select="./*/*[local-name() = 'version']/@xlink:href" /> + </a> + ( + <xsl:value-of + select="./*/*[local-name() = 'version']/*[local-name() = 'date']" /> + ) + <xsl:if test="./*/*[local-name() = 'latest-version']"> + <br /> + Latest version: + <a> + <xsl:attribute name="href"> + <xsl:value-of select="$theBase" /> + <xsl:value-of + select="./*/*[local-name() = 'latest-version']/@xlink:href" /> + </xsl:attribute> + <xsl:value-of + select="./*/*[local-name() = 'latest-version']/@xlink:href" /> + </a> + ( + <xsl:value-of + select="./*/*[local-name() = 'latest-version']/*[local-name() = 'date']" /> + ) + </xsl:if> + <xsl:if test="./*/*[local-name() = 'latest-release']"> + <br /> + Latest release: + <a> + <xsl:attribute name="href"> + <xsl:value-of select="$theBase" /> + <xsl:value-of + select="./*/*[local-name() = 'latest-release']/@xlink:href" /> + </xsl:attribute> + <xsl:value-of + select="./*/*[local-name() = 'latest-release']/@xlink:href" /> + </a> + ( + <xsl:value-of + select="./*/*[local-name() = 'latest-release']/*[local-name() = 'date']" /> + ) + </xsl:if> + </p> + </xsl:if> + <ul> + <xsl:for-each select="./*[@xlink:href]"> + <xsl:variable name="contentLink" select="@xlink:href"/> + <li> + <a> + <xsl:attribute name="href"> + <xsl:if test="not(starts-with(@xlink:href, 'http'))"> + <xsl:value-of select="$theBase" /> + </xsl:if> + <xsl:value-of select="@xlink:href" /> + </xsl:attribute> + <xsl:value-of select="local-name()" /> + </a> + <xsl:if test="@predicate"> + - <xsl:value-of select="@predicate"/> + </xsl:if> + <xsl:choose> + <xsl:when test="@xlink:title"> + - + <xsl:value-of select="@xlink:title" /> + </xsl:when> + <xsl:when test="@objid"> + - + <xsl:value-of select="@objid" /> + </xsl:when> + <xsl:when test="@name"> + - + <xsl:value-of select="@name" /> + </xsl:when> + <xsl:when test="@id"> + - + <xsl:value-of select="@id" /> + </xsl:when> + </xsl:choose> + <!-- xsl:if test="local-name()='content'" --> + <xsl:if test="@storage = 'internal-managed'"> + <xsl:variable name = "mimeType" select="//prop:mime-type"/> + <xsl:if test="starts-with($mimeType, 'image')"> + <br /> ( Image service: + <a> + <xsl:attribute name="href"> + <xsl:value-of select="$theBase" /> + <xsl:value-of select="$contentLink" /> + /digilib/digimage + </xsl:attribute> + digimage + </a>) + </xsl:if> + </xsl:if> + <xsl:if + test="local-name() = 'current-version' or local-name() = 'version'"> + <xsl:for-each select="./*"> + <xsl:call-template name="keynval" /> + </xsl:for-each> + </xsl:if> + </li> + </xsl:for-each> + </ul> + <xsl:for-each select="./*[not(@xlink:href)]"> + <xsl:call-template name="keynval" /> + </xsl:for-each> + </xsl:template> + + <!-- + <xsl:template match="mdr:md-record"> + <h3><xsl:value-of select="@xlink:title"/> (<xsl:value-of select="local-name()"/> + <xsl:choose> + <xsl:when test="@objid"> - <xsl:value-of select="@objid"/></xsl:when> + <xsl:when test="@name"> - <xsl:value-of select="@name"/></xsl:when> + <xsl:when test="@id"> - <xsl:value-of select="@id"/></xsl:when> + </xsl:choose>)</h3> + <xsl:call-template name="keynval"/> + </xsl:template> + --> + + <xsl:template name="keynval"> + <ul> + <b> + <xsl:value-of select="local-name()" /> + : + </b> + <xsl:choose> + <xsl:when test="@xlink:href"> + <a> + <xsl:attribute name="href"> + <xsl:value-of select="@xlink:href" /> + </xsl:attribute> + <xsl:value-of select="@xlink:href" /> + </a> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="./text()" /> + <xsl:for-each select="@*"> + <xsl:text> @</xsl:text> + <b><xsl:value-of select="local-name()"/></b> + <xsl:text>=</xsl:text> + <xsl:value-of select="."/> + </xsl:for-each> + </xsl:otherwise> + </xsl:choose> + <br /> + <xsl:for-each select="./*"> + <xsl:call-template name="keynval" /> + </xsl:for-each> + </ul> + </xsl:template> + + <!-- + <xsl:template match="*"> + <xsl:param name="theBase"/> + <xsl:value-of select="local-name()"/>: <a> + <xsl:attribute name="href"> + <xsl:value-of select="$theBase"/> + <xsl:value-of select="@xlink:href"/> + </xsl:attribute> link </a><br/> + </xsl:template> + --> + +</xsl:stylesheet>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/resultOverview.css Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,40 @@ +.searchResultRecord { + border-bottom-style: solid; + border-bottom-color: black; + } +.dcMetaData { +} + +.result { + display: inline-block; + white-space: normal; + padding-left: 10px; + vertical-align: top; + font-size:10pt; +} + +.searchLogo{ + width:50pt; + } + +.displayType{ + width:50pt; + } + +.resultTitle{ + width:150pt; + } + +.resultAuthor{ + width:100pt; + } +.resultDescription{ + width:200pt; + font-size: 8pt; + } +.resultYear, .resultDate{ + width:100pt; + } +.textFragmentData{ + display: none; + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/search.html Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,18 @@ +<html> +<body> +<form method="get" > +<div class="searchAll">Search all:<input name="allMetadata" size="80"/></div> +<div class="searchTitle">Search Title:<input name="title" size="80"/></div> +<div class="searchAuthor">Search Author:<input name="author" size="80"/></div> +<div><input type="submit"/></div> + +<p> You can use </p> +<ul> +<li> wild cards; like vitr*</li> +<li> boolean search like: vitr* and 1614 </li> +</ul> + +<p>Instead of <b>"umlauts"</b> use the vowel the umlaut is derived from: i.e. ü -> u, ä -> a</p> +</form> +</body> +</html> \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/de/mpiwg/itgroup/escidoc/MPIWGServices/Restlet/staticPages/searchResult.xsl Wed Dec 01 17:35:51 2010 +0100 @@ -0,0 +1,89 @@ +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" +xmlns:srw="http://www.loc.gov/zing/srw/" +xmlns:search-result="http://www.escidoc.de/schemas/searchresult/0.8" +xmlns:escidocComponents="http://www.escidoc.de/schemas/components/0.9" + xmlns:escidocContentStreams="http://www.escidoc.de/schemas/contentstreams/0.7" + xmlns:escidocItem="http://www.escidoc.de/schemas/item/0.9" + xmlns:escidocMetadataRecords="http://www.escidoc.de/schemas/metadatarecords/0.5" + xmlns:prop="http://escidoc.de/core/01/properties/" + xmlns:relations="http://www.escidoc.de/schemas/relations/0.3" + xmlns:release="http://escidoc.de/core/01/properties/release/" + xmlns:srel="http://escidoc.de/core/01/structural-relations/" + xmlns:version="http://escidoc.de/core/01/properties/version/" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:container="http://www.escidoc.de/schemas/container/0.8" +> + + <xsl:template match="/"> + <html> + <head> + <link rel="stylesheet" type="text/css" href="resultOverview.css"/> + </head><body> + <xsl:apply-templates select="//search-result:search-result-record"/> + </body></html> + </xsl:template> + + <xsl:template match="search-result:search-result-record"> + <div class="searchResultRecord"> + <div class="result escidocId"> + <xsl:value-of select=".//prop:latest-version/@objid"/> + </div> + <xsl:apply-templates select=".//srel:context"/> + + <xsl:apply-templates select=".//search-result:text-fragment-data"/> + <xsl:apply-templates select="(escidocItem:item[escidocItem:properties/srel:content-model[@objid='escidoc:11003']]) | (container:container)" mode="content"/> + <xsl:apply-templates select="(escidocItem:item[escidocItem:properties/srel:content-model[@objid='escidoc:13001']]) | (container:container)" mode="content"/> + </div> + </xsl:template> + + <xsl:template match="escidocItem:item" mode="content"> + <div class="result displayType">Item</div> + <xsl:apply-templates select=".//dc-md" mode="dc"/> + + <div class="result showEntry"><a><xsl:attribute name="href"><xsl:value-of select=".//escidocComponents:component[escidocComponents:properties/prop:content-category[text()='web_page']]/escidocComponents:content/@xlink:href"/> + </xsl:attribute>web</a></div> + <div class="result showEntry"> + <a><xsl:attribute name="href"> + ./<xsl:value-of select=".//prop:latest-version/@objid"/>/indexMeta + </xsl:attribute>metaData</a><br/> + <a><xsl:attribute name="href"> + ./<xsl:value-of select=".//prop:latest-version/@objid"/>/origRef + </xsl:attribute>md-fox</a><a><xsl:attribute name="href"> + ./<xsl:value-of select=".//prop:latest-version/@objid"/>/origRef?mode=html + </xsl:attribute>(html)</a> + </div> + <div class="result showEntry"><a><xsl:attribute name="href"> + ./<xsl:value-of select=".//prop:latest-version/@objid"/>/display + </xsl:attribute>display</a></div> + </xsl:template> + + <xsl:template match="container:container" mode="content"> + <div class="result displayType">Collection</div> + <xsl:apply-templates select=".//dc-md" mode="dc"/> + <div class="result showEntry"><a><xsl:attribute name="href">container/<xsl:value-of select="@objid"/> + </xsl:attribute>show</a></div> + </xsl:template> + + <xsl:template match="search-result:text-fragment-data"> + <div class="textFragmentData"> + <xsl:copy-of select="."/> + </div> + </xsl:template> + + <xsl:template match="srel:context"> + <xsl:if test="@objid='escidoc:1001'"><div class="result searchLogo"><img height="40px" src="http://echo.mpiwg-berlin.mpg.de/home/img/echo_sm.gif"/></div></xsl:if> + <xsl:if test="@objid='escidoc:12001'"><div class="result searchLogo"><img height="40px" src="http://www.mpiwg-berlin.mpg.de/en/images/logo.png"/></div></xsl:if> + <xsl:if test="@objid='escidoc:40001'"><div class="result searchLogo"><img height="40px" src="http://libcoll.mpiwg-berlin.mpg.de/lib_coll_image"/></div></xsl:if> + </xsl:template> + <xsl:template match="dc-md" mode="dc"> + + <div class="result resultTitle"><xsl:value-of select="dc:title"/> </div> + <div class="result resultAuthor"><xsl:value-of select="dc:creator"/> </div> + <div class="result resultDescription"><xsl:value-of select="dc:description"/> </div> + <div class="result resultYear"><xsl:value-of select="dc:year"/> </div> + <div class="result resultDate"><xsl:value-of select="dc:date"/> </div> + + </xsl:template> + +</xsl:stylesheet> \ No newline at end of file