diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java index 280d117562f8cc6f28b934a173cd5046277c1c79..83a59fc0b9c7642d77d51d355e25b2801a62c9b4 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -44,10 +44,11 @@ public class OAIPMHImpl implements OAIPMHProducer{ private ListIdentifiersType listIDs = new ListIdentifiersType(); private OAI_ESClient oaiEsClient; private static String[] fields; + private RepIdentification rep; - - public OAIPMHImpl(OAI_ESClient oaiEsClient){ + public OAIPMHImpl(OAI_ESClient oaiEsClient, RepIdentification rep){ this.oaiEsClient=oaiEsClient; + this.rep = rep; } /** @@ -133,21 +134,29 @@ public class OAIPMHImpl implements OAIPMHProducer{ public JAXBElement<OAIPMHType> identifyRequest(ObjectFactory obf, OAIPMHType oai, RequestType request){ List<String> errorValues = new ArrayList<String>(); JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai); - RepIdentification repIdentification = new RepIdentification(); + //RepIdentification repIdentification = new RepIdentification(); IdentifyType tgRepIdentificationRequest = new IdentifyType(); - if(repIdentification.requestChecker(request)){ - tgRepIdentificationRequest.setBaseURL(repIdentification.getBaseUrl()); - tgRepIdentificationRequest.setDeletedRecord(repIdentification.getDeletedRecordStatus()); - tgRepIdentificationRequest.setEarliestDatestamp(repIdentification.getEarliestDatestamp()); - tgRepIdentificationRequest.setGranularity(repIdentification.getGranularity()); - tgRepIdentificationRequest.setRepositoryName(repIdentification.getRepositoryName()); - tgRepIdentificationRequest.setProtocolVersion(repIdentification.getProtocolVersion()); - tgRepIdentificationRequest.getAdminEmail().add(repIdentification.getAdminMaiAddresss()); + //if(rep.requestChecker(request)){ + //tgRepIdentificationRequest.setBaseURL(repIdentification.getBaseUrl()); + //tgRepIdentificationRequest.setDeletedRecord(repIdentification.getDeletedRecordStatus()); + //tgRepIdentificationRequest.setEarliestDatestamp(repIdentification.getEarliestDatestamp()); + //tgRepIdentificationRequest.setGranularity(repIdentification.getGranularity()); + //tgRepIdentificationRequest.setRepositoryName(repIdentification.getRepositoryName()); + //tgRepIdentificationRequest.setProtocolVersion(repIdentification.getProtocolVersion()); + //tgRepIdentificationRequest.getAdminEmail().add(repIdentification.getAdminMaiAddresss()); + + tgRepIdentificationRequest.setBaseURL(rep.getBaseUrl()); + tgRepIdentificationRequest.setDeletedRecord(rep.getDeletedRecordStatus()); + tgRepIdentificationRequest.setEarliestDatestamp(rep.getEarliestDatestamp()); + tgRepIdentificationRequest.setGranularity(rep.getGranularity()); + tgRepIdentificationRequest.setRepositoryName(rep.getRepositoryName()); + tgRepIdentificationRequest.setProtocolVersion(rep.getProtocolVersion()); + tgRepIdentificationRequest.getAdminEmail().add(rep.getAdminMaiAddresss()); oai.setIdentify(tgRepIdentificationRequest); - } + /*} else{ if(request.getIdentifier()!=null){ errorValues.add("identifier"); @@ -165,7 +174,7 @@ public class OAIPMHImpl implements OAIPMHProducer{ error.setError(TGConstants.OAI_BAD_ARGUMENT).setValue("The request includes illegal arguments: " + errorValues); oai.getError().add(error.setError(TGConstants.OAI_BAD_ARGUMENT)); - } + }*/ return oaipmhRoot; } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RepIdentification.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RepIdentification.java index 06947ba8db10259914bf3929aaa60cf36f13de59..b48bc4fc2f87b1c301e92452f4e92e6309332e36 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RepIdentification.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RepIdentification.java @@ -19,21 +19,42 @@ public class RepIdentification { private DeletedRecordType tgDeletetObjects = DeletedRecordType.NO; private GranularityType tgRepGranulartiry = GranularityType.YYYY_MM_DD_THH_MM_SS_Z; - /** - * Returning the Identify values as o complete Identifiy element - * @return tgRepInfo - */ - public IdentifyType getTGRepInfo(){ + private String RepositoryName; + private String BaseUrl; + private String EarliestDatestamp; + private String ProtocolVersion; + private String AdminMailAdress; + + + public RepIdentification(String RepositoryName, + String BaseUrl, + DeletedRecordType DeletedRecordInfo, + String EarliestDatestamp, + GranularityType Granularity, + String ProtocolVersion, + String AdminMail){ - return tgRepInfo; + setRepositoryName(RepositoryName); + setBaseUrl(BaseUrl); + setDeletedRecordStatus(DeletedRecordInfo); + setEarliestDatestamp(EarliestDatestamp); + setGranularity(Granularity); + setProtocolVersion(ProtocolVersion); + setAdminMailAddress(AdminMail); } + /** * * @return TGConstants.TG_REP_NAME; */ public String getRepositoryName(){ - return TGConstants.TG_REP_NAME; + //return TGConstants.TG_REP_NAME; + return RepositoryName; + } + + public void setRepositoryName(String RepositoryName){ + this.RepositoryName = RepositoryName; } /** @@ -41,8 +62,14 @@ public class RepIdentification { * @return TGConstants.TG_REP_BASEURL */ public String getBaseUrl(){ - return TGConstants.TG_REP_BASEURL; + //return TGConstants.TG_REP_BASEURL; + return BaseUrl; + } + + public void setBaseUrl(String BaseUrl){ + this.BaseUrl = BaseUrl; } + /** * * @return tgDeletetObjects @@ -50,12 +77,22 @@ public class RepIdentification { public DeletedRecordType getDeletedRecordStatus(){ return tgDeletetObjects; } + + public void setDeletedRecordStatus(DeletedRecordType tgDeletetObjects){ + this.tgDeletetObjects = tgDeletetObjects; + } + /** * * @return "2011-06-11T2:32:40Z" */ public String getEarliestDatestamp(){ - return "2011-06-11T02:32:40Z"; + //return "2011-06-11T02:32:40Z"; + return EarliestDatestamp; + } + + public void setEarliestDatestamp(String earliestDatestamp){ + this.EarliestDatestamp = earliestDatestamp; } /** @@ -66,12 +103,21 @@ public class RepIdentification { return tgRepGranulartiry; } + public void setGranularity(GranularityType tgRepGranulartiry){ + this.tgRepGranulartiry = tgRepGranulartiry; + } + /** * * @return TGConstants.TG_REP_OAIPMH_PROTOCOL_VERSION; */ public String getProtocolVersion(){ - return TGConstants.TG_REP_OAIPMH_PROTOCOL_VERSION; + //return TGConstants.TG_REP_OAIPMH_PROTOCOL_VERSION; + return ProtocolVersion; + } + + public void setProtocolVersion(String protocolVersion){ + this.ProtocolVersion = protocolVersion; } /** @@ -79,7 +125,12 @@ public class RepIdentification { * @return TGConstants.TEXTGRID_REP_ADMIN_CONTACT.get(0) */ public String getAdminMaiAddresss(){ - return TGConstants.TEXTGRID_REP_ADMIN_CONTACT.get(0); + //return TGConstants.TEXTGRID_REP_ADMIN_CONTACT.get(0); + return AdminMailAdress; + } + + public void setAdminMailAddress(String adminMailAddress){ + this.AdminMailAdress = adminMailAddress; } /** diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java index f2baeb9c7f6156189762fe174601e577db4c56f9..9b7d44e8353cf6b5033a4ae03239bda59d3b0bb5 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java @@ -1,7 +1,13 @@ package info.textgrid.middleware; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; import java.text.ParseException; +import java.util.Properties; +import info.textgrid.middleware.oaipmh.DeletedRecordType; +import info.textgrid.middleware.oaipmh.GranularityType; import info.textgrid.middleware.oaipmh.OAIPMHType; import javax.xml.bind.JAXB; @@ -16,8 +22,13 @@ import org.junit.Test; public class OaiPmhTest { private static OAI_ESClient oaiEsClient; - private OAIPMHImpl testRequest = new OAIPMHImpl(oaiEsClient); + DeletedRecordType bla = DeletedRecordType.NO; + GranularityType bla2 = GranularityType.YYYY_MM_DD_THH_MM_SS_Z; + private RepIdentification rep = new RepIdentification("TextGrid-Repository", "www.textgridrep.de", bla, "2011-06-11T02:32:40Z", bla2, "2.0", "textgrid-support@gwdg.de"); + private OAIPMHImpl testRequest = new OAIPMHImpl(oaiEsClient, rep); + + @BeforeClass public static void setUp() throws Exception { @@ -28,7 +39,7 @@ public class OaiPmhTest { } @Test - //@Ignore + @Ignore public void testDateNow() throws DatatypeConfigurationException { System.out.println("---------------Now Version-----------------"); XMLGregorianCalendar nowTest = OAIPMHUtillities @@ -38,7 +49,7 @@ public class OaiPmhTest { } @Test - //@Ignore + @Ignore public void testDateGregorianType() throws ParseException, DatatypeConfigurationException { String dateformatbefore = "2012-02-06T20:48:39.614+01:00"; @@ -52,7 +63,7 @@ public class OaiPmhTest { } @Test - //@Ignore + @Ignore public void testDateStringType() throws ParseException, DatatypeConfigurationException { String dateformatbefore = "2012-02-06T20:48:39.614+01:00"; @@ -68,8 +79,7 @@ public class OaiPmhTest { //@Ignore public void testGetRequestIdentify() throws ParseException { - System.out - .println("Test for the verb \"Identify\" with succesfull response"); + System.out.println("Test for the verb \"Identify\" with succesfull response"); JAXBElement<OAIPMHType> r = testRequest.getRequest("Identify", "", "", "", "", "", ""); JAXB.marshal(r, System.out); @@ -77,7 +87,7 @@ public class OaiPmhTest { } @Test - //@Ignore + @Ignore public void testGetRequestIdentifyVerbError() throws ParseException { JAXBElement<OAIPMHType> t = testRequest.getRequest("Identify", "", "a", "", "", "", ""); @@ -86,7 +96,7 @@ public class OaiPmhTest { } @Test - //@Ignore + @Ignore public void testGetRequestIdentifyArgumentError() throws ParseException { System.out .println("Test for the verb \"Identify\" with error response"); diff --git a/oaipmh-webapp/pom.xml b/oaipmh-webapp/pom.xml index b60d765a22a7b826e792fab4cc2ba92a80ad2c19..675fd8b1f5390983336447a2a56ce6ba5fe480b1 100644 --- a/oaipmh-webapp/pom.xml +++ b/oaipmh-webapp/pom.xml @@ -79,6 +79,17 @@ <target>${jdk.version}</target> </configuration> </plugin> + <plugin> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-maven-plugin</artifactId> + <version>9.0.7.v20131107</version> + <configuration> + <scanIntervalSeconds>1</scanIntervalSeconds> + <webAppConfig> + <contextPath>tgsearch-public.war</contextPath> + </webAppConfig> + </configuration> + </plugin> </plugins> </build> </project> diff --git a/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml b/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml index 518d54b425f066c2ca1d1033cd1ec1e59e696407..8273a6889bb17deb86b1a1bb4594298bb56ce0fd 100644 --- a/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml +++ b/oaipmh-webapp/src/main/webapp/WEB-INF/beans.xml @@ -24,9 +24,8 @@ http://www.springframework.org/schema/util/spring-util-3.1.xsd class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> - <value>/WEB-INF/oaipmh.properties</value> + <!--value>/WEB-INF/oaipmh.properties</value--> <value>file:/etc/textgrid/oaipmh/oaipmh.properties</value> - <value>file:/etc/dariah/oaipmh/oaipmh.properties</value> </list> </property> <property name="ignoreResourceNotFound" value="true" /> @@ -46,7 +45,49 @@ http://www.springframework.org/schema/util/spring-util-3.1.xsd <property name="esIndex" value="${elasticSearch.index}" /> <property name="esType" value="${elasticSearch.type}" /> </bean> + + <!--bean id="drc" class="info.textgrid.middleware.oaipmh.${DeletedRecordInfo}"--> + + <bean id="RepIdentification" class="info.textgrid.middleware.RepIdentification"> + <constructor-arg index="0"> + <value>${RepositoryName}</value> + </constructor-arg> + <constructor-arg index="1"> + <value>${BaseUrl}</value> + </constructor-arg> + <constructor-arg index="2"> + <value>${DeletedRecordInfo}</value> + </constructor-arg> + <constructor-arg index="3"> + <value>${EarliestDateStamp}</value> + </constructor-arg> + <constructor-arg index="4"> + <value>${Granularity}</value> + </constructor-arg> + <constructor-arg index="5"> + <value>${ProtocolVersion}</value> + </constructor-arg> + <constructor-arg index="6"> + <value>${AdminMail}</value> + </constructor-arg> + </bean> + + <!-- bean id="RecordList" class="info.textgrid.middleware.RecordListDeliverer"> + <constructor-arg index="0"> + <value>${esFields}</value> + </constructor-arg> + <constructor-arg index="1"> + <value>${esWorkFields}</value> + </constructor-arg> + <constructor-arg index="2"> + <value>${textgridFields}</value> + </constructor-arg> + <constructor-arg index="3"> + <value>${dariahFields}</value> + </constructor-arg> + </bean --> + <!-- REST Interface --> <bean id="rest" class="info.textgrid.middleware.Rest" /> @@ -59,7 +100,9 @@ http://www.springframework.org/schema/util/spring-util-3.1.xsd <bean id="oai" class="info.textgrid.middleware.OAIPMHImpl"> <constructor-arg ref="ElasticSearchClient" /> + <constructor-arg ref="RepIdentification"/> </bean> + <jaxrs:server id="root" address="/root" publishedEndpointUrl="${RS_ENDPOINT}">