diff --git a/Jenkinsfile b/Jenkinsfile index 605b12f4566cc22b078e5264b1128979cdfc4a53..8db9903a093cab02775c2da5a523dda4c73365a0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,7 @@ node { } stage('Build') { - sh "'${mvnHome}/bin/mvn' -U clean verify deploy -Pdhrep.deb" + sh "'${mvnHome}/bin/mvn' -U clean deploy -Pdhrep.deb" } stage('Publish') { diff --git a/docs_tgrep/index.rst b/docs_tgrep/index.rst index c433d30599dc8b1fb7ee305f91bd8759e72067a8..f560b180ef7ad1c3dcdc9ecbc5c30d8f4e0bf14a 100644 --- a/docs_tgrep/index.rst +++ b/docs_tgrep/index.rst @@ -3,8 +3,8 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -TG-oaipmh -========= +TextGrid OAI-PMH +================ OAI-PMH is the service to harvest all metadata from the editions stored in the textgrid repository diff --git a/oaipmh-core/pom.xml b/oaipmh-core/pom.xml index 75ebe37ff6efe54ab1c38e8a4aec520f0c3ff923..6f638a287fed46623fc95487938d16deb4728269 100644 --- a/oaipmh-core/pom.xml +++ b/oaipmh-core/pom.xml @@ -5,7 +5,7 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>3.2.0-SNAPSHOT</version> + <version>3.3.0-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-core</artifactId> @@ -50,10 +50,10 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.elasticsearch.client</groupId> - <artifactId>elasticsearch-rest-high-level-client</artifactId> - <version>${elasticsearch.version}</version> - </dependency> + <groupId>org.elasticsearch.client</groupId> + <artifactId>elasticsearch-rest-high-level-client</artifactId> + <version>${elasticsearch.version}</version> + </dependency> <dependency> <groupId>info.textgrid.utils</groupId> <artifactId>httpclients</artifactId> @@ -91,11 +91,11 @@ <artifactId>package-info-maven-plugin</artifactId> <version>1.4.5</version> </dependency> -<dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - <version>2.8.5</version> -</dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + <version>2.8.5</version> + </dependency> </dependencies> <build> <pluginManagement> @@ -103,7 +103,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.5.1</version> + <version>${maven-compiler-plugin.version}</version> </plugin> </plugins> </pluginManagement> @@ -159,68 +159,32 @@ </executions> </plugin> <plugin> - <!-- We use this plugin to ensure that our usage of the maven-jaxb2-plugin - is JDK 8 compatible in absence of a fix for https://java.net/jira/browse/MAVEN_JAXB2_PLUGIN-80. --> - <groupId>org.codehaus.mojo</groupId> - <artifactId>properties-maven-plugin</artifactId> - <version>1.0-alpha-2</version> + <groupId>org.jvnet.jaxb2.maven2</groupId> + <artifactId>maven-jaxb2-plugin</artifactId> + <version>0.14.0</version> <executions> <execution> - <id>set-additional-system-properties</id> - <goals> - <goal>set-system-properties</goal> - </goals> - </execution> - </executions> - <configuration> - <properties> - <property> - <name>javax.xml.accessExternalSchema</name> - <value>file,http</value> - </property> - </properties> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>jaxb2-maven-plugin</artifactId> - <version>2.4</version> - <executions> - <execution> - <id>oaipmhDCSchema-xjc</id> - <goals> - <goal>xjc</goal> - </goals> - <configuration> - <schemaFile>oai_dc.xsd</schemaFile> - <packageName>info.textgrid.middleware.oaidc</packageName> - <schemaDirectory>src/main/xsd</schemaDirectory> - <schemaIncludes> - <include>oai_dc.xsd</include> - </schemaIncludes> - <generateDirectory>${project.build.directory}/generated-sources/xjc1</generateDirectory> - <staleFile>${project.build.directory}/jaxb2/.oaiDCSchemaXjcStaleFlag</staleFile> - <clearOutputDir>false</clearOutputDir> - </configuration> - </execution> - <execution> - <id>oaipmhSchema-xjc</id> + <id>generate-oaipmh</id> <goals> - <goal>xjc</goal> + <goal>generate</goal> </goals> <configuration> - <schemaFile>oai_pmh.xsd</schemaFile> - <packageName>info.textgrid.middleware.oaipmh</packageName> - <schemaDirectory>src/main/xsd</schemaDirectory> - <schemaIncludes> - <include>oai_pmh.xsd</include> - </schemaIncludes> - <generateDirectory>${project.build.directory}/generated-sources/xjc2</generateDirectory> - <staleFile>${project.build.directory}/jaxb2/.oaipmhSchemaXjcStaleFlag</staleFile> - <clearOutputDir>false</clearOutputDir> + <generatePackage>info.textgrid.middleware.oaipmh</generatePackage> + <generateDirectory>${project.build.directory}/generated-sources/oaipmh</generateDirectory> + <args> + <arg>-extension</arg> + <arg>-Xnamespace-prefix</arg> + </args> </configuration> </execution> </executions> + <dependencies> + <dependency> + <groupId>org.jvnet.jaxb2_commons</groupId> + <artifactId>jaxb2-namespace-prefix</artifactId> + <version>1.3</version> + </dependency> + </dependencies> </plugin> </plugins> </build> diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/DARIAHConstants.java b/oaipmh-core/src/main/java/info/textgrid/middleware/DARIAHConstants.java index f3a0ae2b6889d514a2131bf281244418f39552e4..35fd6de95723ad75da30714d03a3504a8eae86bb 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/DARIAHConstants.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/DARIAHConstants.java @@ -11,72 +11,77 @@ import java.util.List; public final class DARIAHConstants { - private DARIAHConstants() { - // not called - } + private DARIAHConstants() { + // not called + } - public static final String ITEM_IDENTIFIER_PREFIX = "hdl:"; - public static final String COLLECTIONREGISTRY_PREFIX = "dariah:collection:"; - public static final String COLLECTION_MIMETYPE = "text/vnd.dariah.dhrep.collection+turtle"; - public static final List<String> TEXTGRID_REP_ADMIN_CONTACT = Arrays.asList("support@de.dariah.eu"); + public static final String ITEM_IDENTIFIER_PREFIX = "hdl:"; + public static final String COLLECTIONREGISTRY_PREFIX = "dariah:collection:"; + public static final String COLLECTION_MIMETYPE = "text/vnd.dariah.dhrep.collection+turtle"; + public static final List<String> TEXTGRID_REP_ADMIN_CONTACT = + Arrays.asList("support@de.dariah.eu"); - /* - * Rep Identification String Constants - */ + /* + * Rep Identification String Constants + */ - public static final String DARIAH_REP_BASEURL = "repository.de.dariah.eu"; - public static final String METADATA_DC_PREFIX = "rdf:RDF/rdf:Description"; + public static final String DARIAH_REP_BASEURL = "repository.de.dariah.eu"; + public static final String METADATA_DC_PREFIX = "rdf:RDF/rdf:Description"; - /* - * Error String Constants - */ + /* + * Error String Constants + */ - public static final String OAI_BAD_ARGUMENT = "BadArgument"; - public static final String OAI_METADATA_FORMAT_ERROR = "FormatError"; - public static final String OAI_NO_RECORD_MATCH = "RecordMatchError"; - public static final String OAI_NO_SET_HIERARCHY = "SetHierarchyError"; + public static final String OAI_BAD_ARGUMENT = "BadArgument"; + public static final String OAI_METADATA_FORMAT_ERROR = "FormatError"; + public static final String OAI_NO_RECORD_MATCH = "RecordMatchError"; + public static final String OAI_NO_SET_HIERARCHY = "SetHierarchyError"; - /* - * TextGrid Metadata Fields for OAI-PMH Request (Mapping to DC) - */ + /* + * TextGrid Metadata Fields for OAI-PMH Request (Mapping to DC) + */ - public static final String CREATED = "descriptiveMetadata.dc:date"; - public static final String FORMAT = "descriptiveMetadata.dc:format"; - public static final String IDENTIFIER = "administrativeMetadata.dcterms:identifier"; - public static final String DATA_CONTRIBUTOR = "descriptiveMetadata.dc:contributor"; + public static final String CREATED = "descriptiveMetadata.dc:date"; + public static final String FORMAT = "descriptiveMetadata.dc:format"; + public static final String IDENTIFIER = "administrativeMetadata.dcterms:identifier"; + public static final String DATA_CONTRIBUTOR = "descriptiveMetadata.dc:contributor"; - public static final String[] DARIAHFields = { - "descriptiveMetadata.dc:contributor", "descriptiveMetadata.dc:coverage", - "administrativeMetadata.dcterms:created", "administrativeMetadata.dcterms:modified", - "descriptiveMetadata.dc:description", "descriptiveMetadata.dc:format", - "descriptiveMetadata.dc:identifier", "descriptiveMetadata.dc:language", - "descriptiveMetadata.dc:publisher", "descriptiveMetadata.dc:relation", - "descriptiveMetadata.dc:rights", "descriptiveMetadata.:source", "descriptiveMetadata.dc:subject", - "descriptiveMetadata.dc:title", "descriptiveMetadata.dc:type", "administrativeMetadata.dcterms:identifier" }; + public static final String[] DARIAHFields = { + "descriptiveMetadata.dc:contributor", "descriptiveMetadata.dc:coverage", + "administrativeMetadata.dcterms:created", "administrativeMetadata.dcterms:modified", + "descriptiveMetadata.dc:description", "descriptiveMetadata.dc:format", + "descriptiveMetadata.dc:identifier", "descriptiveMetadata.dc:language", + "descriptiveMetadata.dc:publisher", "descriptiveMetadata.dc:relation", + "descriptiveMetadata.dc:rights", "descriptiveMetadata.:source", + "descriptiveMetadata.dc:subject", + "descriptiveMetadata.dc:title", "descriptiveMetadata.dc:type", + "administrativeMetadata.dcterms:identifier"}; - public static final String[] DARIAHCollectionFields = { "metadata.dc:title" }; + public static final String[] DARIAHCollectionFields = {"metadata.dc:title"}; - /* - * String Arrays to define which TextGrid fields belongs to the regarding DC - * fields - */ + /* + * String Arrays to define which TextGrid fields belongs to the regarding DC fields + */ - public static final String[] CONTRIBUTOR_LIST = { "descriptiveMetadata.dc:contributor" }; - public static final String[] COVERAGE_LIST = { "descriptiveMetadata.dc:coverage" }; - public static final String[] CREATOR_LIST = { "descriptiveMetadata.dc:cretor" }; - public static final String[] DATE_LIST = { "administrativeMetadata.dcterms:modified" }; - public static final String[] DESCRIPTION_LIST = { "descriptiveMetadata.dc:description" }; - public static final String[] FORMAT_LIST = { "descriptiveMetadata.dc:format" }; - public static final String[] IDENTIFIER_LIST = { "descriptiveMetadata.dc:identifier" }; - public static final String[] LANGUAGE_LIST = { "descriptiveMetadata.dc:language" }; - public static final String[] PUBLISHER_LIST = { "descriptiveMetadata.dc:publisher" }; - public static final String[] RELATIONS_LIST = { "descriptiveMetadata.dc:relation" }; - public static final String[] RIGHTS_LIST = { "descriptiveMetadata.dc:rights" }; - public static final String[] SOURCE_LIST = { "descriptiveMetadata.dc:source" }; - public static final String[] SUBJECT_LIST = { "descriptiveMetadata.dc:subject" }; - public static final String[] TITLE_LIST = { "descriptiveMetadata.dc:title" }; - public static final String[] TYPE_LIST = { "descriptiveMetadata.dc:type" }; - public static final String[] IDENTIFIER_LIST_FIELDS = { "administrativeMetadata.dcterms:identifier","administrativeMetadata.dcterms:modified", "descriptiveMetadata.dc:identifier", "descriptiveMetadata.dc:date", "descriptiveMetadata.dc:format" }; - public static final String RANGE_FIELD = "administrativeMetadata.dcterms:modified"; - public static final String MODIFIED_FIELD = "administrativeMetadata.dcterms:modified"; + public static final String[] CONTRIBUTOR_LIST = {"descriptiveMetadata.dc:contributor"}; + public static final String[] COVERAGE_LIST = {"descriptiveMetadata.dc:coverage"}; + public static final String[] CREATOR_LIST = {"descriptiveMetadata.dc:cretor"}; + public static final String[] DATE_LIST = {"administrativeMetadata.dcterms:modified"}; + public static final String[] DESCRIPTION_LIST = {"descriptiveMetadata.dc:description"}; + public static final String[] FORMAT_LIST = {"descriptiveMetadata.dc:format"}; + public static final String[] IDENTIFIER_LIST = {"descriptiveMetadata.dc:identifier"}; + public static final String[] LANGUAGE_LIST = {"descriptiveMetadata.dc:language"}; + public static final String[] PUBLISHER_LIST = {"descriptiveMetadata.dc:publisher"}; + public static final String[] RELATIONS_LIST = {"descriptiveMetadata.dc:relation"}; + public static final String[] RIGHTS_LIST = {"descriptiveMetadata.dc:rights"}; + public static final String[] SOURCE_LIST = {"descriptiveMetadata.dc:source"}; + public static final String[] SUBJECT_LIST = {"descriptiveMetadata.dc:subject"}; + public static final String[] TITLE_LIST = {"descriptiveMetadata.dc:title"}; + public static final String[] TYPE_LIST = {"descriptiveMetadata.dc:type"}; + public static final String[] IDENTIFIER_LIST_FIELDS = + {"administrativeMetadata.dcterms:identifier", "administrativeMetadata.dcterms:modified", + "descriptiveMetadata.dc:identifier", "descriptiveMetadata.dc:date", + "descriptiveMetadata.dc:format"}; + public static final String RANGE_FIELD = "administrativeMetadata.dcterms:modified"; + public static final String MODIFIED_FIELD = "administrativeMetadata.dcterms:modified"; } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreBuilder.java b/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreBuilder.java index fc47cfa09ab4c39ee954b86a5bd75df16f292736..fefc729da89cd9e6262f7387b788f57e40cd764a 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreBuilder.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/DublinCoreBuilder.java @@ -1,338 +1,336 @@ package info.textgrid.middleware; +import java.util.List; +import javax.xml.bind.JAXBElement; import info.textgrid.middleware.oaipmh.ElementType; import info.textgrid.middleware.oaipmh.MetadataType; import info.textgrid.middleware.oaipmh.OaiDcType; import info.textgrid.middleware.oaipmh.ObjectFactory; -import java.util.List; -import javax.xml.bind.JAXBElement; /** * <p> * The DublinCoreBuilder is responsible for generating a List of JAXBElements in DublinCore * standard. Each function get a list of strings representing the mapped textgrid metadata for the - * specific DC-field + * specific DC-field. * </p> * - * @author Maximilian Brodhun SUB - * @version 1.1 - * @since 18.02.2014 + * @author Maximilian Brodhun, SUB Göttingen + * @author Stefan E. Funk, SUB Göttingen + * @version 2019-10-17 + * @since 2014-02.18 */ public final class DublinCoreBuilder { - private OaiDcType tgMappedDC = new OaiDcType(); - private ObjectFactory oaiDcObj = new ObjectFactory(); + // Object factory for all the DC elements. + private static ObjectFactory oaiDcObj = new ObjectFactory(); + + // MetadataType of OAI schema. private MetadataType metadata = new MetadataType(); + // OAI_DC type of oai_dc schema. + private OaiDcType tgMappedDC = new OaiDcType(); - /** * <p> - * s * Constructor to build an DublinCore element for an OAIPMH request by getting TextGrid - * metadata + * Constructor to build an DublinCore element for an OAIPMH request by getting TextGrid metadata. * </p> - * - * @param tgMappedDC - * @param oaiDcObj2 */ public DublinCoreBuilder() { - + // } /** - * Each of the following functions for generating the DC-XML file - * produces an ElementType for the DC-field and puts each - * element of the list into the corresponding XML-tag + * <p> + * Each of the following functions for generating the DC-XML file produces an ElementType for the + * DC-field and puts each element of the list into the corresponding XML-tag. + * </p> */ - + /** * <p> - * Takes a string list containing the contributors and build the specific dublinCore element for - * each + * Takes a string list containing the contributors and build the specific DublinCore element for + * each list entry. * </p> * * @param contributors */ public void setContributor(List<String> contributors) { - for (String dccontributor : contributors) { ElementType contributorElement = new ElementType(); - JAXBElement<ElementType> dcCoreContributor = - getOaiDcObj().createContributor(contributorElement); + JAXBElement<ElementType> dcCoreContributor = oaiDcObj.createContributor(contributorElement); contributorElement.setValue(dccontributor); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreContributor); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreContributor); } } /** * <p> - * Takes a string list containing the creators and build the specific dublinCore element for each + * Takes a string list containing the creators and build the specific DublinCore element for each + * list entry. * </p> * * @param creators */ public void setCreator(List<String> creators) { - for (String dccreator : creators) { ElementType creatorElement = new ElementType(); - JAXBElement<ElementType> dcCoreCreator = getOaiDcObj().createCreator(creatorElement); creatorElement.setValue(dccreator); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreCreator); + JAXBElement<ElementType> dcCoreCreator = oaiDcObj.createCreator(creatorElement); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreCreator); } } /** * <P> - * Takes a string list containing the coverages and build the specific dublinCore element for each + * Takes a string list containing the coverages and build the specific DublinCore element for each + * list entry. * </p> * * @param coverages */ public void setCoverage(List<String> coverages) { - for (String dccoverage : coverages) { ElementType coverageElement = new ElementType(); - JAXBElement<ElementType> dcCoreCoverage = getOaiDcObj().createCoverage(coverageElement); coverageElement.setValue(dccoverage); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreCoverage); + JAXBElement<ElementType> dcCoreCoverage = oaiDcObj.createCoverage(coverageElement); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreCoverage); } } /** * <p> - * Takes a string list containing the dates and build the specific dublinCore element for each + * Takes a string list containing the dates and build the specific DublinCore element for each + * list entry. * </p> * * @param dates */ public void setDate(List<String> dates) { - for (String dcdate : dates) { ElementType dateElement = new ElementType(); - JAXBElement<ElementType> dcCoreDate = getOaiDcObj().createDate(dateElement); + JAXBElement<ElementType> dcCoreDate = oaiDcObj.createDate(dateElement); dateElement.setValue(dcdate); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreDate); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreDate); } } /** * <p> - * Takes a string list containing the descriptions and build the specific dublinCore element for - * each + * Takes a string list containing the descriptions and build the specific DublinCore element for + * each list entry. * </p> * * @param descriptions */ public void setDescription(List<String> descriptions) { - for (String dcdescription : descriptions) { ElementType descriptionElement = new ElementType(); - JAXBElement<ElementType> dcCoreDescription = - getOaiDcObj().createDescription(descriptionElement); descriptionElement.setValue(dcdescription); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreDescription); + JAXBElement<ElementType> dcCoreDescription = oaiDcObj.createDescription(descriptionElement); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreDescription); } } /** * <p> - * Takes a string list containing the formats and build the specific dublinCore element for each + * Takes a string list containing the formats and build the specific DublinCore element for each + * list entry. * </p> * * @param formats */ public void setFormat(List<String> formats) { - for (String dcformat : formats) { ElementType formatElement = new ElementType(); - JAXBElement<ElementType> dcCoreFormat = getOaiDcObj().createFormat(formatElement); formatElement.setValue(dcformat); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreFormat); + JAXBElement<ElementType> dcCoreFormat = oaiDcObj.createFormat(formatElement); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreFormat); } } /** * <p> - * Takes a string list containing the identifiers and build the specific dublinCore element for - * each + * Takes a string list containing the identifiers and build the specific DublinCore element for + * each list entry. * </p> * * @param identifiers */ public void setIdentifier(List<String> identifiers) { - for (String dcidentifier : identifiers) { ElementType identifierElement = new ElementType(); - JAXBElement<ElementType> dcCoreIdentifier = getOaiDcObj().createIdentifier(identifierElement); identifierElement.setValue(dcidentifier); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreIdentifier); + JAXBElement<ElementType> dcCoreIdentifier = oaiDcObj.createIdentifier(identifierElement); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreIdentifier); } } /** * <p> - * Takes a string list containing the languages and build the specific dublinCore element for each + * Takes a string list containing the languages and build the specific DublinCore element for each + * list entry. * </p> * * @param languages */ public void setLanguage(List<String> languages) { - for (String dclanguage : languages) { ElementType languageElement = new ElementType(); - JAXBElement<ElementType> dcCoreLanguage = getOaiDcObj().createLanguage(languageElement); languageElement.setValue(dclanguage); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreLanguage); + JAXBElement<ElementType> dcCoreLanguage = oaiDcObj.createLanguage(languageElement); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreLanguage); } } /** * <p> - * Takes a string list containing the publishers and build the specific dublinCore element for - * each + * Takes a string list containing the publishers and build the specific DublinCore element for + * list entry. each * </p> * * @param publishers */ public void setPublisher(List<String> publishers) { - for (String dcpublisher : publishers) { ElementType publisherElement = new ElementType(); - JAXBElement<ElementType> dcCorePublisher = getOaiDcObj().createPublisher(publisherElement); publisherElement.setValue(dcpublisher); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCorePublisher); + JAXBElement<ElementType> dcCorePublisher = oaiDcObj.createPublisher(publisherElement); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCorePublisher); } } /** * <p> - * Takes a string list containing the relations and build the specific dublinCore element for each + * Takes a string list containing the relations and build the specific DublinCore element for each + * list entry. * </p> * * @param relations */ public void setRelation(List<String> relations) { - for (String dcrelation : relations) { ElementType relationElement = new ElementType(); - JAXBElement<ElementType> dcCoreRelation = getOaiDcObj().createRelation(relationElement); relationElement.setValue(dcrelation); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreRelation); + JAXBElement<ElementType> dcCoreRelation = oaiDcObj.createRelation(relationElement); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreRelation); } } /** * <p> - * Takes a string list containing the rights and build the specific dublinCore element for each + * Takes a string list containing the rights and build the specific DublinCore element for each + * list entry. * </p> * * @param rights */ public void setRights(List<String> rights) { - for (String dcrights : rights) { ElementType rightsElement = new ElementType(); - JAXBElement<ElementType> dcCoreRights = getOaiDcObj().createRights(rightsElement); rightsElement.setValue(dcrights); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreRights); + JAXBElement<ElementType> dcCoreRights = oaiDcObj.createRights(rightsElement); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreRights); } } /** * <p> - * Takes a string list containing the sources and build the specific dublinCore element for each + * Takes a string list containing the sources and build the specific DublinCore element for each + * list entry. * </p> * * @param sources */ public void setSource(List<String> sources) { - for (String dcsource : sources) { ElementType sourcesElement = new ElementType(); - JAXBElement<ElementType> dcCoreSource = getOaiDcObj().createSource(sourcesElement); sourcesElement.setValue(dcsource); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreSource); + JAXBElement<ElementType> dcCoreSource = oaiDcObj.createSource(sourcesElement); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreSource); } } /** * <p> - * Takes a string list containing the subjects and build the specific dublinCore element for each + * Takes a string list containing the subjects and build the specific DublinCore element for each + * list entry. * </p> * * @param subjects */ public void setSubject(List<String> subjects) { - for (String dcsubject : subjects) { ElementType subjectElement = new ElementType(); - JAXBElement<ElementType> dcCoreSubject = getOaiDcObj().createSubject(subjectElement); subjectElement.setValue(dcsubject); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreSubject); + JAXBElement<ElementType> dcCoreSubject = oaiDcObj.createSubject(subjectElement); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreSubject); } } /** * <p> - * Takes a string list containing the titles and build the specific dublinCore element for each + * Takes a string list containing the titles and build the specific DublinCore element for each + * list entry. * </p> * * @param titles */ public void setTitle(List<String> titles) { - for (String dctitle : titles) { ElementType titlesElement = new ElementType(); - JAXBElement<ElementType> dcCoreTitle = getOaiDcObj().createTitle(titlesElement); titlesElement.setValue(dctitle); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreTitle); + JAXBElement<ElementType> dcCoreTitle = oaiDcObj.createTitle(titlesElement); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreTitle); } } /** * <p> - * Takes a string list containing the types and build the specific dublinCore element for each + * Takes a string list containing the types and build the specific DublinCore element for each + * list entry. * </p> * * @param types */ public void setType(List<String> types) { - for (String dctype : types) { ElementType typeElement = new ElementType(); - JAXBElement<ElementType> dcCoreType = getOaiDcObj().createType(typeElement); typeElement.setValue(dctype); - getTgMappedDC().getTitleOrCreatorOrSubject().add(dcCoreType); + JAXBElement<ElementType> dcCoreType = oaiDcObj.createType(typeElement); + this.tgMappedDC.getTitleOrCreatorOrSubject().add(dcCoreType); } } /** * <p> - * Fetching dublinCore element and putting it into the metadata element for the OAIPMH record + * Fetching DublinCore element and putting it into the metadata element for the OAIPMH record * response. * </p> * * @return metadata element with the dublinCore values for a specific object */ public MetadataType getDC() { - this.metadata.setAny(getOaiDcObj().createDc(getTgMappedDC())); + this.metadata.setAny(oaiDcObj.createDc(this.tgMappedDC)); + return this.metadata; } /** - * * @return tgMappedDc + * @deprecated */ + @Deprecated public OaiDcType getTgMappedDC() { return this.tgMappedDC; } /** - * * @return oaiDcObj + * @deprecated */ + @Deprecated public ObjectFactory getOaiDcObj() { - return this.oaiDcObj; + return oaiDcObj; } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/ErrorHandler.java b/oaipmh-core/src/main/java/info/textgrid/middleware/ErrorHandler.java index f3b28cd589085484db093994850cc8b6a857cfa1..0179698bacf690b712cdebaf30228a6e3d8c6ff7 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/ErrorHandler.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/ErrorHandler.java @@ -26,33 +26,33 @@ public class ErrorHandler { public void setError(String errorDescription, String errorValue) { if (errorDescription.equals("BadArgument")) { - errorCode = OAIPMHerrorcodeType.BAD_ARGUMENT; + this.errorCode = OAIPMHerrorcodeType.BAD_ARGUMENT; } else if (errorDescription.equals("ResumptionTokenError")) { - errorCode = OAIPMHerrorcodeType.BAD_RESUMPTION_TOKEN; + this.errorCode = OAIPMHerrorcodeType.BAD_RESUMPTION_TOKEN; } else if (errorDescription.equals("VerbError")) { - errorCode = OAIPMHerrorcodeType.BAD_VERB; - error.setValue("Illegal OAI-PMH verb"); + this.errorCode = OAIPMHerrorcodeType.BAD_VERB; + this.error.setValue("Illegal OAI-PMH verb"); } else if (errorDescription.equals("FormatError")) { - errorCode = OAIPMHerrorcodeType.CANNOT_DISSEMINATE_FORMAT; + this.errorCode = OAIPMHerrorcodeType.CANNOT_DISSEMINATE_FORMAT; } else if (errorDescription.equals("IDError")) { - errorCode = OAIPMHerrorcodeType.ID_DOES_NOT_EXIST; + this.errorCode = OAIPMHerrorcodeType.ID_DOES_NOT_EXIST; } else if (errorDescription.equals("MetadataFormatError")) { - error.setValue("There are no metadata formats available for the specified item."); + this.error.setValue("There are no metadata formats available for the specified item."); } else if (errorDescription.equals("RecordMatchError")) { - errorCode = OAIPMHerrorcodeType.NO_RECORDS_MATCH; + this.errorCode = OAIPMHerrorcodeType.NO_RECORDS_MATCH; } else if (errorDescription.equals("SetHierarchyError")) { - errorCode = OAIPMHerrorcodeType.NO_SET_HIERARCHY; + this.errorCode = OAIPMHerrorcodeType.NO_SET_HIERARCHY; } - error.setCode(errorCode); - error.setValue(errorValue); + this.error.setCode(this.errorCode); + this.error.setValue(errorValue); } /** * @return */ public OAIPMHerrorType getError() { - return error; + return this.error; } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java index 8489a98505e961e141fe4347c34dcc27372fc633..4162bed96cb6c49e5a1369c5045bebb713fae1fc 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/IdentifierListDelivererDC.java @@ -4,7 +4,6 @@ import info.textgrid.middleware.oaipmh.HeaderType; import info.textgrid.middleware.oaipmh.ListIdentifiersType; import info.textgrid.middleware.oaipmh.ResumptionTokenType; import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; - import java.io.IOException; import java.text.ParseException; import java.util.Hashtable; @@ -23,21 +22,27 @@ import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; - - +import info.textgrid.middleware.oaipmh.HeaderType; +import info.textgrid.middleware.oaipmh.ListIdentifiersType; +import info.textgrid.middleware.oaipmh.ResumptionTokenType; +import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; /** - * Class to build the Element for a ListIdentifiers request + * <p> + * Class to build the Element for a ListIdentifiers request. + * </p> * - * @author Maximilian Brodhun, SUB - * @version 1.0 - * @since 20.02.2014 + * @author Maximilian Brodhun, SUB Göttingen + * @version 2019-10-28 + * @since 2014-02-20 */ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { private static org.apache.commons.logging.Log log = LogFactory.getLog(IdentifierListDelivererDC.class); + public static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); + private String datestamp; private boolean idExist = true; private OAI_ESClient oaiEsClient; @@ -48,27 +53,24 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { private String repositoryObjectURIPrefix; // private String identifierField; private static final int lifeTimeResToken = 100; - - public static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>(); - private int searchResponseSize; private long resultSize; /** + * <p> * In OAIPMH a ListIdentifiers request is answered by responding the datestamp and the identifier - * of an object Both will be responded in a header element. This function build the header element + * of an object Both will be responded in a header element. This function build the header + * element. + * </p> * * @param datestamp taken from the elasticSearch index (created element) * @param identifier taken from the elasticSearch index (textgridUri) * @return the ListIdentifierElement with the responded header element */ - public IdentifierListDelivererDC(boolean textgrid, boolean dariah) { super(textgrid, dariah); } - - /** * @param datestamp * @param identifier @@ -94,17 +96,20 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { } /** + * <p> * To get the required values for the ListIdentifiers request this function will ask ElasticSearch * for a specific textgridUri the values "created" and "textgridUri". + * </p> * + * <p> * Since the ListIdentifiers request enables the possibility the limit the request in a specific - * time interval, it is necessary to perform a range query on the ElasticSearch index + * time interval, it is necessary to perform a range query on the ElasticSearch index.</p * * @param from : start value for the range query * @param to : end value to the range query * @return after calling the function "setListIdentifierHeader" the return value is the whole * ListIdentifiers element - * @throws IOException + * @throws IOException */ public ListIdentifiersType processIdentifierList(String from, String to, String set, String resumptionToken) throws IOException { @@ -113,33 +118,30 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { ListIdentifiersType lit = new ListIdentifiersType(); QueryBuilder query = setOrNot(set, from, to); - SearchResponse listListIdentiferValues; - + SearchResponse listListIdentiferValues; + String[] includes = this.identifierListFields; String[] excludes = Strings.EMPTY_ARRAY; - FetchSourceContext fetchSourceContext = - new FetchSourceContext(true, includes, excludes); - - - SearchRequest searchRequest = new SearchRequest(OAI_ESClient.getEsIndex()).searchType(SearchType.QUERY_THEN_FETCH); - + FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); + + SearchRequest searchRequest = + new SearchRequest(OAI_ESClient.getEsIndex()).searchType(SearchType.QUERY_THEN_FETCH); + SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); searchSourceBuilder.query(query); searchSourceBuilder.size(this.searchResponseSize); searchSourceBuilder.fetchSource(includes, excludes); - if (resumptionToken != null) { - SearchScrollRequest scrollRequest = new SearchScrollRequest(resumptionToken); scrollRequest.scroll(TimeValue.timeValueSeconds(lifeTimeResToken)); - listListIdentiferValues = OAI_ESClient.getEsClient().scroll(scrollRequest, RequestOptions.DEFAULT); - + listListIdentiferValues = + OAI_ESClient.getEsClient().scroll(scrollRequest, RequestOptions.DEFAULT); } else { - searchRequest.source(searchSourceBuilder); - searchRequest.scroll(TimeValue.timeValueMinutes(lifeTimeResToken)); - listListIdentiferValues = OAI_ESClient.getEsClient() - .search(searchRequest, RequestOptions.DEFAULT); + searchRequest.source(searchSourceBuilder); + searchRequest.scroll(TimeValue.timeValueMinutes(lifeTimeResToken)); + listListIdentiferValues = + OAI_ESClient.getEsClient().search(searchRequest, RequestOptions.DEFAULT); } listListIdentiferValues = hitHandling(listListIdentiferValues, lit, set, listListIdentiferValues.getScrollId()); @@ -162,7 +164,7 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { for (SearchHit hit : listFurtherValues.getHits().getHits()) { i++; if (this.textgrid) { - //hit.getSourceAsMap().get(this.dateOfObjectCreation).toString(); + // hit.getSourceAsMap().get(this.dateOfObjectCreation).toString(); String datestamp = hit.getSourceAsMap().get(this.dateOfObjectCreation).toString(); try { datestamp = OAIPMHUtillities.convertDateFormat(datestamp).toXMLFormat(); @@ -378,16 +380,18 @@ public class IdentifierListDelivererDC extends IdentifierListDelivererAbstract { this.oaiEsClient = oaiEsClient; } + /** + * @return + */ + public long getResultSize() { + return this.resultSize; + } - -public long getResultSize() { - return resultSize; -} - - - -public void setResultSize(long resultSize) { - this.resultSize = resultSize; -} + /** + * @param resultSize + */ + public void setResultSize(long resultSize) { + this.resultSize = resultSize; + } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/MetadataFormatListDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/MetadataFormatListDeliverer.java index 66d92ec3abc373bbf9f037142c07d0ad295030c1..acc971a1f6036b9b936565c8063cea6fedb3a948 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/MetadataFormatListDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/MetadataFormatListDeliverer.java @@ -1,7 +1,6 @@ package info.textgrid.middleware; import java.io.IOException; - import org.elasticsearch.action.get.GetAction; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetRequestBuilder; @@ -9,104 +8,121 @@ import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.common.Strings; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; - import info.textgrid.middleware.oaipmh.ListMetadataFormatsType; import info.textgrid.middleware.oaipmh.MetadataFormatType; import info.textgrid.middleware.oaipmh.RequestType; +/** + * + */ public class MetadataFormatListDeliverer { - - private boolean idExist = true; - - public MetadataFormatListDeliverer(){ - - } - - public ListMetadataFormatsType setMetadataFormatList(String id){ - - String[] includes = new String[]{TGConstants.URI}; - String[] excludes = Strings.EMPTY_ARRAY; - FetchSourceContext fetchSourceContext = - new FetchSourceContext(true, includes, excludes); - - ListMetadataFormatsType lmft = new ListMetadataFormatsType(); - MetadataFormatType mft = new MetadataFormatType(); - GetRequest getRequest = new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), id).fetchSourceContext(fetchSourceContext); - - - /* - GetRequestBuilder recordById = OAI_ESClient.getEsClient().get(getRequest, GetAction.INSTANCE) - .setIndex(OAI_ESClient.getEsIndex()) - .setType(OAI_ESClient.getEsType()) - .setFields(TGConstants.URI) - .setId(id); */ - - GetResponse tgObject = null; - - try { - tgObject=OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - if(tgObject.isExists()){ - setIdExist(true); - mft.setMetadataNamespace("http://www.openarchives.org/OAI/2.0/oai_dc/"); - mft.setMetadataPrefix(TGConstants.METADATA_DC_PREFIX); - mft.setSchema("http://www.openarchives.org/OAI/2.0/oai_dc.xsd"); - lmft.getMetadataFormat().add(mft); - }else{ - setIdExist(false); - lmft=null; - } - - return lmft; - } - - public ListMetadataFormatsType setMetadataFormatListWithoutId(){ - - ListMetadataFormatsType lmft = new ListMetadataFormatsType(); - MetadataFormatType mft = new MetadataFormatType(); - MetadataFormatType mftIdiomMets = new MetadataFormatType(); - - mft.setMetadataNamespace("http://www.openarchives.org/OAI/2.0/oai_dc/"); - mft.setMetadataPrefix(TGConstants.METADATA_DC_PREFIX); - mft.setSchema("http://www.openarchives.org/OAI/2.0/oai_dc.xsd"); - lmft.getMetadataFormat().add(mft); - - mftIdiomMets.setMetadataNamespace("http://www.loc.gov/METS/"); - mftIdiomMets.setMetadataPrefix(TGConstants.METADATA_IDIOM_PREFIX); - mftIdiomMets.setSchema("http://www.loc.gov/standards/mets/mets.xsd"); - lmft.getMetadataFormat().add(mftIdiomMets); - return lmft; - - } - - public boolean requestChecker(RequestType request){ - boolean requestCheck = true; - - if(request.getFrom()!=null || - request.getMetadataPrefix()!=null || - request.getResumptionToken()!=null){ - - requestCheck = false; - - }else if(request.getSet()!=null || - request.getUntil()!=null){ - requestCheck = false; - } - - return requestCheck; - - } - - public boolean isIdExist() { - return idExist; - } - - public void setIdExist(boolean idExist) { - this.idExist = idExist; - } - + + private boolean idExist = true; + + /** + * + */ + public MetadataFormatListDeliverer() { + // + } + + /** + * @param id + * @return + */ + public ListMetadataFormatsType setMetadataFormatList(String id) { + + String[] includes = new String[] {TGConstants.URI}; + String[] excludes = Strings.EMPTY_ARRAY; + FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); + + ListMetadataFormatsType lmft = new ListMetadataFormatsType(); + MetadataFormatType mft = new MetadataFormatType(); + GetRequest getRequest = new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), id) + .fetchSourceContext(fetchSourceContext); + + /* + * GetRequestBuilder recordById = OAI_ESClient.getEsClient().get(getRequest, GetAction.INSTANCE) + * .setIndex(OAI_ESClient.getEsIndex()) .setType(OAI_ESClient.getEsType()) + * .setFields(TGConstants.URI) .setId(id); + */ + + GetResponse tgObject = null; + try { + tgObject = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + if (tgObject.isExists()) { + setIdExist(true); + mft.setMetadataNamespace("http://www.openarchives.org/OAI/2.0/oai_dc/"); + mft.setMetadataPrefix(TGConstants.METADATA_DC_PREFIX); + mft.setSchema("https://www.openarchives.org/OAI/2.0/oai_dc.xsd"); + lmft.getMetadataFormat().add(mft); + } else { + setIdExist(false); + lmft = null; + } + + return lmft; + } + + /** + * @return + */ + public ListMetadataFormatsType setMetadataFormatListWithoutId() { + + ListMetadataFormatsType lmft = new ListMetadataFormatsType(); + MetadataFormatType mft = new MetadataFormatType(); + MetadataFormatType mftIdiomMets = new MetadataFormatType(); + + mft.setMetadataNamespace("http://www.openarchives.org/OAI/2.0/oai_dc/"); + mft.setMetadataPrefix(TGConstants.METADATA_DC_PREFIX); + mft.setSchema("https://www.openarchives.org/OAI/2.0/oai_dc.xsd"); + lmft.getMetadataFormat().add(mft); + + mftIdiomMets.setMetadataNamespace("http://www.loc.gov/METS/"); + mftIdiomMets.setMetadataPrefix(TGConstants.METADATA_IDIOM_PREFIX); + mftIdiomMets.setSchema("https://www.loc.gov/standards/mets/mets.xsd"); + lmft.getMetadataFormat().add(mftIdiomMets); + + return lmft; + } + + /** + * @param request + * @return + */ + public boolean requestChecker(RequestType request) { + + boolean requestCheck = true; + + if (request.getFrom() != null + || request.getMetadataPrefix() != null + || request.getResumptionToken() != null) { + requestCheck = false; + } else if (request.getSet() != null || + request.getUntil() != null) { + requestCheck = false; + } + + return requestCheck; + } + + /** + * @return + */ + public boolean isIdExist() { + return this.idExist; + } + + /** + * @param idExist + */ + public void setIdExist(boolean idExist) { + this.idExist = idExist; + } + } 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 173fe454ba6023886ca03329a3da7302f78044e2..fb74d235e1d9e65d8fb0977235884375f9be2bbc 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHImpl.java @@ -1,12 +1,17 @@ package info.textgrid.middleware; import java.io.IOException; +import java.io.StringWriter; import java.text.ParseException; import java.util.ArrayList; import java.util.List; +import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.XMLGregorianCalendar; +import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import info.textgrid.middleware.oaipmh.GetRecordType; import info.textgrid.middleware.oaipmh.IdentifyType; @@ -14,9 +19,7 @@ import info.textgrid.middleware.oaipmh.ListIdentifiersType; import info.textgrid.middleware.oaipmh.ListMetadataFormatsType; import info.textgrid.middleware.oaipmh.ListRecordsType; import info.textgrid.middleware.oaipmh.ListSetsType; -import info.textgrid.middleware.oaipmh.OAIPMHType; -import info.textgrid.middleware.oaipmh.OAIPMHerrorType; -import info.textgrid.middleware.oaipmh.OAIPMHerrorcodeType; +import info.textgrid.middleware.oaipmh.OAIPMHtype; import info.textgrid.middleware.oaipmh.ObjectFactory; import info.textgrid.middleware.oaipmh.RequestType; import info.textgrid.middleware.oaipmh.VerbType; @@ -28,15 +31,36 @@ import info.textgrid.middleware.oaipmh.VerbType; * </p> * * @author Maximilian Brodhun, SUB Göttingen - * @version 2019-05-28 + * @author Stefan E. Funk, SUB Göttingen + * @version 2019-10-28 * @since 2014-01-29 */ public class OAIPMHImpl implements OAIPMHProducer { + // ** + // FINALS + // ** + + private static final String OAIPMH_SCHEMA_LOCATION = + "http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd"; + private static final String OAIDC_SCHEMA_LOCATION = + "http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"; + private static final String DC_SCHEMA_LOCATION = + "http://purl.org/dc/elements/1.1/ https://dublincore.org/schemas/xmls/simpledc20021212.xsd"; + + // ** + // STATICS + // ** + + private static ObjectFactory obf = new ObjectFactory(); + + // ** + // PRIVATES + // ** + private ErrorHandler error = new ErrorHandler(); - private org.apache.commons.logging.Log log = LogFactory.getLog(OAIPMHImpl.class); + private Log log = LogFactory.getLog(OAIPMHImpl.class); private RepIdentification rep; - private RecordListDelivererDC recordListDC; private RecordListDelivererIDIOM recordListIDIOM; @@ -49,11 +73,13 @@ public class OAIPMHImpl implements OAIPMHProducer { private MetadataFormatListDeliverer metadataFormatList; private SetDeliverer setList; + // ** + // PUBLIC + // ** + public boolean textgrid; public boolean dariah; - ListIdentifiersType lit = new ListIdentifiersType(); - /** * @param rep * @param recDelivDC @@ -83,13 +109,24 @@ public class OAIPMHImpl implements OAIPMHProducer { /* * (non-Javadoc) - * - * @see info.textgrid.middleware.OAIPMHProducer#getRequest(java.lang.String, java.lang.String, + * + * @see info.textgrid.middleware.OAIPMHProducer#postRequest(java.lang.String, java.lang.String, * java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ - public JAXBElement<OAIPMHType> postRequest(String verb, String identifier, String metadataPrefix, - String set, String from, String until, String resumptionToken) { - return handleRequest(verb, identifier, metadataPrefix, set, from, until, resumptionToken); + public String postRequest(String verb, String identifier, String metadataPrefix, String set, + String from, String until, String resumptionToken) { + + String result = ""; + + try { + result = getStringFromJAXBOAIElement(verb, + handleRequest(verb, identifier, metadataPrefix, set, from, until, resumptionToken)); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return result; } /* @@ -98,33 +135,43 @@ public class OAIPMHImpl implements OAIPMHProducer { * @see info.textgrid.middleware.OAIPMHProducer#getRequest(java.lang.String, java.lang.String, * java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String) */ - public JAXBElement<OAIPMHType> getRequest(String verb, String identifier, String metadataPrefix, + public String getRequest(String verb, String identifier, String metadataPrefix, String set, String from, String until, String resumptionToken) { - return handleRequest(verb, identifier, metadataPrefix, set, from, until, resumptionToken); + + String result = ""; + + try { + result = getStringFromJAXBOAIElement(verb, + handleRequest(verb, identifier, metadataPrefix, set, from, until, resumptionToken)); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return result; } /** * @return */ public String getVersion() { - return OaipmhServiceVersion.BUILDNAME + "-" + OaipmhServiceVersion.VERSION + "." + return OaipmhServiceVersion.BUILDNAME + "-" + OaipmhServiceVersion.VERSION + "+" + OaipmhServiceVersion.BUILDDATE; } /** - * checks the Identify request of correctness and response including errors in case of an - * incorrect request + * <p> + * Checks the Identify request of correctness and response including errors in case of an + * incorrect request. + * </p> * - * @param obf - * @param oai + * @param oaipmhRoot * @param request * @return */ - public JAXBElement<OAIPMHType> identifyRequest(ObjectFactory obf, OAIPMHType oai, - RequestType request) { + public OAIPMHtype identifyRequest(OAIPMHtype oaipmhRoot, RequestType request) { List<String> errorValues = new ArrayList<String>(); - JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai); IdentifyType tgRepIdentificationRequest = new IdentifyType(); if (this.rep.requestChecker(request)) { @@ -136,7 +183,7 @@ public class OAIPMHImpl implements OAIPMHProducer { tgRepIdentificationRequest.setRepositoryName(this.rep.getRepositoryName()); tgRepIdentificationRequest.setProtocolVersion(this.rep.getProtocolVersion()); tgRepIdentificationRequest.getAdminEmail().add(this.rep.getAdminMaiAddresss()); - oai.setIdentify(tgRepIdentificationRequest); + oaipmhRoot.setIdentify(tgRepIdentificationRequest); } else { if (request.getIdentifier() != null) { @@ -160,35 +207,31 @@ public class OAIPMHImpl implements OAIPMHProducer { this.error.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments: " + errorValues); - oai.getError().add(this.error.getError()); + oaipmhRoot.getError().add(this.error.getError()); } return oaipmhRoot; } /** - * checks the GetRecord request of correctness and response including errors in case of an - * incorrect request + * <p> + * Checks the GetRecord request of correctness and response including errors in case of an + * incorrect request. + * </p> * - * @param obf - * @param oai + * @param oaipmhRoot * @param request * @return */ - public JAXBElement<OAIPMHType> getRecordRequest(ObjectFactory obf, OAIPMHType oai, - RequestType request) { - - JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai); + public OAIPMHtype getRecordRequest(OAIPMHtype oaipmhRoot, RequestType request) { - /** - * Check request. In GetRecord: allowed parameters: identifier, metadataPrefix, verb forbidden: - * resumptionToken, from, till, set optional: no one - */ + // Check request. In GetRecord: allowed parameters: identifier, metadataPrefix, verb forbidden: + // resumptionToken, from, till, set optional: no one. ErrorHandler requestErrors = RecordDelivererAbstract.requestChecker(request); if (requestErrors.getError().getCode() != null) { - oai.getError().add(requestErrors.getError()); + oaipmhRoot.getError().add(requestErrors.getError()); } // Get Record Request is done HERE! @@ -209,12 +252,12 @@ public class OAIPMHImpl implements OAIPMHProducer { getRecord = recDeliv.getRecordById(id); if (getRecord != null) { - oai.setGetRecord(getRecord); + oaipmhRoot.setGetRecord(getRecord); } else { ErrorHandler idError = new ErrorHandler(); idError.setError(TGConstants.OAI_NO_RECORD_MATCH, "The value of the identifier: " + request.getIdentifier() + " is unknown or illegal in this repository"); - oai.getError().add(idError.getError()); + oaipmhRoot.getError().add(idError.getError()); } } @@ -222,23 +265,23 @@ public class OAIPMHImpl implements OAIPMHProducer { } /** - * checks the ListIdentifiers request of correctness and response including errors in case of an - * incorrect request + * <p> + * Checks the ListIdentifiers request of correctness and response including errors in case of an + * incorrect request. + * </p> * - * @param obf * @param oai * @param request * @return * @throws ParseException */ - public JAXBElement<OAIPMHType> listIdentifiersRequest(ObjectFactory obf, OAIPMHType oai, - RequestType request) throws ParseException { + public OAIPMHtype listIdentifiersRequest(OAIPMHtype oaipmhRoot, RequestType request) + throws ParseException { - JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai); ErrorHandler requestErrors = IdentifierListDelivererAbstract.requestChecker(request); if (requestErrors.getError().getValue() != null) { - oai.getError().add(requestErrors.getError()); + oaipmhRoot.getError().add(requestErrors.getError()); } else { // If metadataFormat IS SET, set recordListDeliverer accordingly. @@ -266,67 +309,63 @@ public class OAIPMHImpl implements OAIPMHProducer { } } - ListIdentifiersType listIdentifiers=null; - try { - listIdentifiers = idListDeliv.processIdentifierList(request.getFrom(), - request.getUntil(), request.getSet(), request.getResumptionToken()); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + ListIdentifiersType listIdentifiers = null; + try { + listIdentifiers = idListDeliv.processIdentifierList(request.getFrom(), request.getUntil(), + request.getSet(), request.getResumptionToken()); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } if (listIdentifiers != null) { - if(identifierListDC.getResultSize()==0) { - requestErrors.setError("RecordMatchError", "The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list."); - oai.getError().add(requestErrors.getError()); - }else { - oai.setListIdentifiers(listIdentifiers); - } - } - //} else { - /*ErrorHandler idError = new ErrorHandler(); + if (this.identifierListDC.getResultSize() == 0) { + requestErrors.setError("RecordMatchError", + "The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list."); + oaipmhRoot.getError().add(requestErrors.getError()); + } else { + oaipmhRoot.setListIdentifiers(listIdentifiers); + } + } else { + ErrorHandler idError = new ErrorHandler(); idError.setError(TGConstants.OAI_NO_RECORD_MATCH, "The value of the identifier: " + request.getIdentifier() + " is unknown or illegal in this repository"); - oai.getError().add(idError.getError());*/ - //} + oaipmhRoot.getError().add(idError.getError()); + } } return oaipmhRoot; } /** - * checks the ListSets request of correctness and response including errors in case of an - * incorrect request + * <p> + * Checks the ListSets request of correctness and response including errors in case of an + * incorrect request. + * </p> * - * @param obf * @param oai * @param request * @return */ - public JAXBElement<OAIPMHType> listSetsRequest(ObjectFactory obf, OAIPMHType oai, - RequestType request) { + public OAIPMHtype listSetsRequest(OAIPMHtype oaipmhRoot, RequestType request) { - ListSetsType sl = new ListSetsType(); - JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai); - sl = this.setList.setListBuilder(); - oai.setListSets(sl); + ListSetsType sl = this.setList.setListBuilder(); + oaipmhRoot.setListSets(sl); return oaipmhRoot; } /** * @param id - * @param obf - * @param oai + * @param oaipmhRoot * @param request * @return */ - public JAXBElement<OAIPMHType> listMetadataFormatsRequest(String id, ObjectFactory obf, - OAIPMHType oai, RequestType request) { + public OAIPMHtype listMetadataFormatsRequest(String id, OAIPMHtype oaipmhRoot, + RequestType request) { List<String> errorValues = new ArrayList<String>(); ListMetadataFormatsType listMF = new ListMetadataFormatsType(); - JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai); if (this.metadataFormatList.requestChecker(request)) { @@ -337,14 +376,16 @@ public class OAIPMHImpl implements OAIPMHProducer { } if (listMF != null) { - - oai.setListMetadataFormats(listMF); + oaipmhRoot.setListMetadataFormats(listMF); } else { this.error.setError(TGConstants.OAI_NO_RECORD_MATCH, "The value of the identifier: " + request.getIdentifier() + " is unknown or illegal in this repository"); - oai.getError().add(this.error.getError()); + oaipmhRoot.getError().add(this.error.getError()); } - } else { + } + + else { + if (request.getFrom() != null) { errorValues.add("from"); } @@ -363,29 +404,24 @@ public class OAIPMHImpl implements OAIPMHProducer { this.error.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal " + "arguments or is missing required arguments: " + errorValues); - oai.getError().add(this.error.getError()); + oaipmhRoot.getError().add(this.error.getError()); } return oaipmhRoot; } /** - * @param obf * @param oai * @param request * @return */ - public JAXBElement<OAIPMHType> listRecordsRequest(ObjectFactory obf, OAIPMHType oai, - RequestType request) { - - // Create OAIPMH root object. - JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(oai); + public OAIPMHtype listRecordsRequest(OAIPMHtype oaipmhRoot, RequestType request) { // Check request's syntax. ErrorHandler requestErrors = RecordListDelivererAbstract.requestChecker(request); if (requestErrors.getError().getCode() != null) { - oai.getError().add(requestErrors.getError()); + oaipmhRoot.getError().add(requestErrors.getError()); } else { // If metadataFormat IS SET, set recordListDeliverer accordingly. @@ -393,7 +429,6 @@ public class OAIPMHImpl implements OAIPMHProducer { if (request.getMetadataPrefix() != null) { if (request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX)) { recListDeliv = this.recordListDC; - } else { recListDeliv = this.recordListIDIOM; } @@ -416,14 +451,14 @@ public class OAIPMHImpl implements OAIPMHProducer { ListRecordsType listRecords = recListDeliv.getRecords(request.getFrom(), request.getUntil(), request.getSet(), request.getResumptionToken()); - if (listRecords != null ) { - if(recordListDC.getResultSize()==0) { - requestErrors.setError("RecordMatchError", "The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list."); - oai.getError().add(requestErrors.getError()); - }else { - oai.setListRecords(listRecords); - } - + if (listRecords != null) { + if (this.recordListDC.getResultSize() == 0) { + requestErrors.setError("RecordMatchError", + "The combination of the values of the from, until, set and metadataPrefix arguments results in an empty list."); + oaipmhRoot.getError().add(requestErrors.getError()); + } else { + oaipmhRoot.setListRecords(listRecords); + } } } @@ -431,7 +466,9 @@ public class OAIPMHImpl implements OAIPMHProducer { } /** - * Taking the sting from the REST request and converting into an OAIPMH verb type + * <p> + * Taking the sting from the REST request and converting into an OAIPMH verb type. + * </p> * * @param verb : what is to within the repository * @return verbParam: the verbParam as an OAIPMH verb type @@ -457,7 +494,7 @@ public class OAIPMHImpl implements OAIPMHProducer { } else if (verb != null && verb.equals("GetRecord")) { verbParam = VerbType.GET_RECORD; } else { - // FIXME + // FIXME What must be fixed here? --fu this.error.setError("VerbError", "Illegal OAI verb"); } @@ -465,11 +502,12 @@ public class OAIPMHImpl implements OAIPMHProducer { } /** - * Setting the from value for the request + * <p> + * Setting the from value for the request. + * </p> * * @param from */ - public void setFromRequestValue(String from, RequestType request) { if (!from.isEmpty()) { request.setFrom(from); @@ -477,7 +515,9 @@ public class OAIPMHImpl implements OAIPMHProducer { } /** - * Setting the until value for the request + * <p> + * Setting the until value for the request. + * </p> * * @param until */ @@ -488,7 +528,9 @@ public class OAIPMHImpl implements OAIPMHProducer { } /** - * Setting the identifier value for the request + * <p> + * Setting the identifier value for the request. + * </p> * * @param identifier */ @@ -499,7 +541,9 @@ public class OAIPMHImpl implements OAIPMHProducer { } /** - * Setting the metadataPrefix value for the request + * <p> + * Setting the metadataPrefix value for the request. + * </p> * * @param metadataPrefix */ @@ -510,7 +554,9 @@ public class OAIPMHImpl implements OAIPMHProducer { } /** - * Setting the resumptionToken value for the request + * <p> + * Setting the resumptionToken value for the request. + * </p> * * @param resumptionToken */ @@ -561,17 +607,19 @@ public class OAIPMHImpl implements OAIPMHProducer { * @param until * @param resumptionToken * @return + * @throws ParseException */ - private JAXBElement<OAIPMHType> handleRequest(String verb, String identifier, - String metadataPrefix, String set, String from, String until, String resumptionToken) { + private JAXBElement<OAIPMHtype> handleRequest(String verb, String identifier, + String metadataPrefix, String set, String from, String until, String resumptionToken) + throws ParseException { + + JAXBElement<OAIPMHtype> result; - ObjectFactory obf = new ObjectFactory(); - OAIPMHType response = new OAIPMHType(); - JAXBElement<OAIPMHType> oaipmhRoot = obf.createOAIPMH(response); + OAIPMHtype response = new OAIPMHtype(); VerbType verbParam = setVerb(verb); RequestType request = new RequestType(); - /*----Setting the responseDate of today-----*/ + // Set the responseDate of today. try { XMLGregorianCalendar convertedDateFormat; convertedDateFormat = OAIPMHUtillities @@ -580,11 +628,10 @@ public class OAIPMHImpl implements OAIPMHProducer { } catch (ParseException e) { this.log.debug("can not parse date format"); } catch (DatatypeConfigurationException e) { - this.log.debug("Datatype configuration failed"); + this.log.debug("datatype configuration failed"); } - /* converting the request values */ - + // Convert the request values. setFromRequestValue(from, request); setUntilRequestValue(until, request); setIdentifierRequestValue(identifier, request); @@ -602,22 +649,17 @@ public class OAIPMHImpl implements OAIPMHProducer { if (verbParam != null) { if (verbParam.value().equals("Identify")) { - oaipmhRoot = identifyRequest(obf, response, request); + response = identifyRequest(response, request); } else if (verbParam.value().equals("GetRecord")) { - oaipmhRoot = getRecordRequest(obf, response, request); + response = getRecordRequest(response, request); } else if (verbParam.value().equals("ListIdentifiers")) { - try { - oaipmhRoot = listIdentifiersRequest(obf, response, request); - } catch (ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + response = listIdentifiersRequest(response, request); } else if (verbParam.value().equals("ListSets")) { - oaipmhRoot = listSetsRequest(obf, response, request); + response = listSetsRequest(response, request); } else if (verbParam.value().equals("ListMetadataFormats")) { - oaipmhRoot = listMetadataFormatsRequest(identifier, obf, response, request); + response = listMetadataFormatsRequest(identifier, response, request); } else if (verbParam.value().equals("ListRecords")) { - oaipmhRoot = listRecordsRequest(obf, response, request); + response = listRecordsRequest(response, request); } } else { this.error.setError("VerbError", "Illegal OAI verb"); @@ -625,10 +667,56 @@ public class OAIPMHImpl implements OAIPMHProducer { } response.setRequest(request); + result = obf.createOAIPMH(response); - oaipmhRoot.setValue(response); + return result; + } - return oaipmhRoot; + /** + * <p> + * Transforms the JaxB element into a string that contains the xsi:schemaLocation attribute. No + * other way has been working here! I tried EVERYTHING else! Really! + * </p> + * + * @param theVerb + * @param theJAXBOAIElement + * @return + */ + private static String getStringFromJAXBOAIElement(final String theVerb, + final JAXBElement<OAIPMHtype> theJAXBOAIElement) { + + String result = ""; + + // Always add OAIPMH schema location. + String schemaLocations = OAIPMH_SCHEMA_LOCATION; + // Add OAI_DC and DC schema location if needed. + if (theVerb.equals("GetRecord") || theVerb.endsWith("ListRecords")) { + schemaLocations += OAIDC_SCHEMA_LOCATION + " " + DC_SCHEMA_LOCATION; + } + + // PLEASE NOTE We always get oai_dc and dc prefixes defined in the root element due to the + // bindings.xml file. Seems to be no problem for the time being. + + try { + // OBACHT! GEMOKEL! Add schemaLocations to OAI root element here! + JAXBContext jc = JAXBContext.newInstance(OAIPMHtype.class); + + Marshaller marshaller = jc.createMarshaller(); + // Comment out if one-line-output wanted! + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, schemaLocations); + + StringWriter sw = new StringWriter(); + marshaller.marshal(theJAXBOAIElement, sw); + result = sw.toString(); + sw.close(); + + } catch (JAXBException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return result; } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHProducer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHProducer.java index b015fb84cd3b1fbb02fc9a86b1118d26f445dcfa..77d71174979a2f2d8d61427441f1336c57c09fda 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHProducer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHProducer.java @@ -1,15 +1,13 @@ package info.textgrid.middleware; -import info.textgrid.middleware.oaipmh.OAIPMHType; +import javax.ws.rs.DefaultValue; +import javax.ws.rs.FormParam; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.FormParam; import javax.ws.rs.core.MediaType; -import javax.xml.bind.JAXBElement; /** * <p> @@ -46,7 +44,7 @@ public interface OAIPMHProducer { @GET @Path("/") @Produces(MediaType.TEXT_XML) - JAXBElement<OAIPMHType> getRequest(@QueryParam("verb") String verb, + String getRequest(@QueryParam("verb") String verb, @QueryParam("identifier") @DefaultValue("") String identifier, @QueryParam("metadataPrefix") @DefaultValue("") String metadataPrefix, @QueryParam("set") @DefaultValue("") String set, @@ -78,7 +76,7 @@ public interface OAIPMHProducer { @POST @Path("/") @Produces(MediaType.TEXT_XML) - JAXBElement<OAIPMHType> postRequest(@FormParam("verb") String verb, + String postRequest(@FormParam("verb") String verb, @FormParam("identifier") @DefaultValue("") String identifier, @FormParam("metadataPrefix") @DefaultValue("") String metadataPrefix, @FormParam("set") @DefaultValue("") String set, diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtillities.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtillities.java index ca24395d0ffe7352f93481c7e28bcecc453fdf08..3fb618339e11c2d6a310704680367f0ed3209985 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtillities.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAIPMHUtillities.java @@ -1,8 +1,5 @@ package info.textgrid.middleware; -import info.textgrid.middleware.oaipmh.ListMetadataFormatsType; -import info.textgrid.middleware.oaipmh.MetadataFormatType; -import info.textgrid.middleware.oaipmh.ResumptionTokenType; import java.math.BigInteger; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -14,6 +11,9 @@ import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; import org.apache.commons.logging.LogFactory; +import info.textgrid.middleware.oaipmh.ListMetadataFormatsType; +import info.textgrid.middleware.oaipmh.MetadataFormatType; +import info.textgrid.middleware.oaipmh.ResumptionTokenType; /** * <p> @@ -50,7 +50,9 @@ public class OAIPMHUtillities { } /** - * producing the list of all metadata formats + * <p> + * Producing the list of all metadata formats. + * </p> * * @return tgRepMetadaFormats */ @@ -64,7 +66,9 @@ public class OAIPMHUtillities { } /** - * calculating the current date and give it back as XMLGregorianCalendar + * <p> + * Calculating the current date and give it back as XMLGregorianCalendar. + * </p> * * @return now * @throws DatatypeConfigurationException @@ -80,8 +84,10 @@ public class OAIPMHUtillities { } /** + * <p> * Converting a given string representing a date value into the date format required for OAIPMH - * and give it back as XMLGregorianCalendar + * and give it back as XMLGregorianCalendar. + * </p> * * @param originalDateTimeString * @return xmlCal @@ -102,8 +108,10 @@ public class OAIPMHUtillities { } /** + * <p> * Converting a given string representing a date value into the date format required for OAIPMH - * and give it back as string + * and give it back as string. + * </p> * * @param originalDateTimeString * @return dateOutputAsString diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OAI_ESClient.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OAI_ESClient.java index b6d68b2686f0fed709817210b329899cfc8e297f..38e447e440a5d1ec6bd6a02b3dc65c2491c048f8 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OAI_ESClient.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OAI_ESClient.java @@ -2,166 +2,147 @@ package info.textgrid.middleware; import java.util.ArrayList; import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.http.HttpHost; -import org.elasticsearch.client.Client; -import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestHighLevelClient; -import org.elasticsearch.common.settings.Settings; - - /** - * Establishing to connection to an ElasticSearch client + * <p> + * Establishing to connection to an ElasticSearch client. + * </p> * - * @author Maximilian Brodhun - * @version 1.0 - * @since 09.01.2014 - * + * @author Maximilian Brodhun, SUB Göttingen + * @author Stefan E. Funk, SUB Göttingen + * @version 2019-10-28 + * @since 2014-01-09 */ public class OAI_ESClient { - private Log log = LogFactory.getLog(OAI_ESClient.class); - private static String url; - //private static int port; - private static int[] ports; - private static String esCluster; - private static String esIndex; - private static String esType; - //public static Client oaiESClient; - private static RestHighLevelClient esClient; - - /** - * Constructor for the connection to an ElasticSearch index - * @param url address for the ELasticSearch connection - * @param port for the ElasticSearch connection - * @param clusterName indicating the name of the cluster where the index exists - */ - - public OAI_ESClient(String url, int[] ports, int itemLimit){ - - //int port = Integer.parseInt(thePort); - - /*this.log.info("ElasticSearch connection settings:"); - this.log.info("url = " + url); - this.log.info("port = " + port); - this.log.info("cluster name = " + clusterName);*/ - - OAI_ESClient.setUrl(url); - - OAI_ESClient.setPorts(ports); - - - List<HttpHost> hosts = new ArrayList<HttpHost>(); - for(int port : ports) { - hosts.add(new HttpHost(url, port, "http")); - } - - setEsClient(new RestHighLevelClient( - RestClient.builder( - hosts.toArray(new HttpHost[hosts.size()])))); - } - - /** - * - * @return esIndex - */ - public static String getEsIndex() { - return esIndex; - } - - /** - * - * @param esIndex - */ - public static void setEsIndex(String esIndex) { - OAI_ESClient.esIndex = esIndex; - } - - /** - * - * @return esType - */ - public static String getEsType() { - return esType; - } - - /** - * - * @param esType - */ - public static void setEsType(String esType) { - OAI_ESClient.esType = esType; - } - - - - /** - * - * @return esCluster - */ - public static String getClusterName() { - return esCluster; - } - - /** - * - * @param esCluster - */ - public static void setClusterName(String esCluster) { - OAI_ESClient.esCluster = esCluster; - } - - /** - * - * @return url - */ - public static String getUrl() { - return url; - } - - /** - * - * @param url - */ - public static void setUrl(String url) { - OAI_ESClient.url = url; - } - - /** - * - * @return port - */ - public static int[] getPort() { - return ports; - } - - /** - * - * @param port - */ - public static void setPorts(int ports[]) { - // System.out.println("SETTER OF PORTS: " +ports[0]); - OAI_ESClient.ports = ports; - } - - /** - * - * @param oaiClient - */ - public static void setOaiESClient(RestHighLevelClient theOaiClient){ - OAI_ESClient.esClient = theOaiClient; - } - - public static RestHighLevelClient getEsClient() { - return esClient; - } - - public static void setEsClient(RestHighLevelClient esClient) { - OAI_ESClient.esClient = esClient; - } + private static String url; + private static int[] ports; + private static String esCluster; + private static String esIndex; + private static String esType; + private static RestHighLevelClient esClient; + + /** + * <p> + * Constructor for the connection to an ElasticSearch index. + * </p> + * + * @param url address for the ELasticSearch connection + * @param port for the ElasticSearch connection + * @param clusterName indicating the name of the cluster where the index exists + */ + public OAI_ESClient(String url, int[] ports, int itemLimit) { + + /* + * this.log.info("ElasticSearch connection settings:"); this.log.info("url = " + url); + * this.log.info("port = " + port); this.log.info("cluster name = " + clusterName); + */ + + OAI_ESClient.setUrl(url); + OAI_ESClient.setPorts(ports); + + List<HttpHost> hosts = new ArrayList<HttpHost>(); + for (int port : ports) { + hosts.add(new HttpHost(url, port, "http")); + } + + setEsClient( + new RestHighLevelClient(RestClient.builder(hosts.toArray(new HttpHost[hosts.size()])))); + } + + /** + * @return esIndex + */ + public static String getEsIndex() { + return esIndex; + } + + /** + * @param esIndex + */ + public static void setEsIndex(String esIndex) { + OAI_ESClient.esIndex = esIndex; + } + + /** + * @return esType + */ + public static String getEsType() { + return esType; + } + + /** + * @param esType + */ + public static void setEsType(String esType) { + OAI_ESClient.esType = esType; + } + + /** + * @return esCluster + */ + public static String getClusterName() { + return esCluster; + } + + /** + * @param esCluster + */ + public static void setClusterName(String esCluster) { + OAI_ESClient.esCluster = esCluster; + } + + /** + * @return url + */ + public static String getUrl() { + return url; + } + + /** + * @param url + */ + public static void setUrl(String url) { + OAI_ESClient.url = url; + } + + /** + * @return port + */ + public static int[] getPort() { + return ports; + } + + /** + * + * @param port + */ + public static void setPorts(int ports[]) { + OAI_ESClient.ports = ports; + } + + /** + * @param oaiClient + */ + public static void setOaiESClient(RestHighLevelClient theOaiClient) { + OAI_ESClient.esClient = theOaiClient; + } + + /** + * @return + */ + public static RestHighLevelClient getEsClient() { + return esClient; + } + + /** + * @param esClient + */ + public static void setEsClient(RestHighLevelClient esClient) { + OAI_ESClient.esClient = esClient; + } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/OaiPmhClient.java b/oaipmh-core/src/main/java/info/textgrid/middleware/OaiPmhClient.java index 599f86daf17f5769cbbd8a6916c4686df48b3112..299b78fb99c2eeb6909d50c44ef2d315501e9b1f 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/OaiPmhClient.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/OaiPmhClient.java @@ -1,15 +1,10 @@ package info.textgrid.middleware; -import info.textgrid.middleware.oaipmh.OAIPMHType; - import java.text.ParseException; - import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import javax.xml.bind.JAXBElement; - import org.apache.cxf.jaxrs.client.JAXRSClientFactory; /** @@ -17,42 +12,40 @@ import org.apache.cxf.jaxrs.client.JAXRSClientFactory; */ public class OaiPmhClient { - private String identifier; - private String metadataPrefix; - private String set; - private String from; - private String until; - private String resumptionToken; - private OAIPMHProducer producer; - - /** - * @param endpoint - */ - public OaiPmhClient(String endpoint) { - this.producer = JAXRSClientFactory.create(endpoint + "/oai",OAIPMHProducer.class); - } - - /** - * @param verb - * @return - * @throws ParseException - */ - public JAXBElement<OAIPMHType> request(String verb) throws ParseException { - return producer.getRequest(verb, identifier, metadataPrefix, set, from, - until, resumptionToken); - - } - - /** - * @return - */ - @GET - @Path("/version") - @Produces(MediaType.TEXT_PLAIN) - public String getVersion() { - return OaipmhServiceVersion.BUILDNAME + "-" - + OaipmhServiceVersion.VERSION + "." - + OaipmhServiceVersion.BUILDDATE; - } + private String identifier; + private String metadataPrefix; + private String set; + private String from; + private String until; + private String resumptionToken; + private OAIPMHProducer producer; + + /** + * @param endpoint + */ + public OaiPmhClient(String endpoint) { + this.producer = JAXRSClientFactory.create(endpoint + "/oai", OAIPMHProducer.class); + } + + /** + * @param verb + * @return + * @throws ParseException + */ + public String request(String verb) throws ParseException { + return this.producer.getRequest(verb, this.identifier, this.metadataPrefix, this.set, this.from, + this.until, this.resumptionToken); + } + + /** + * @return + */ + @GET + @Path("/version") + @Produces(MediaType.TEXT_PLAIN) + public String getVersion() { + return OaipmhServiceVersion.BUILDNAME + "-" + OaipmhServiceVersion.VERSION + "+" + + OaipmhServiceVersion.BUILDDATE; + } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java index e93754a6db6dab4a687a070db7ba3b2a9b4f26b1..abf24cc680d48c7469fe4b0935536cf6a0a5d3de 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererDC.java @@ -3,35 +3,32 @@ package info.textgrid.middleware; import java.io.IOException; import java.text.ParseException; import java.util.Map; - import javax.swing.plaf.synth.SynthSpinnerUI; import javax.xml.datatype.DatatypeConfigurationException; import org.apache.commons.logging.LogFactory; import org.elasticsearch.action.get.GetRequest; +import org.elasticsearch.action.get.GetRequestBuilder; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.common.Strings; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; - import info.textgrid.middleware.oaipmh.GetRecordType; import info.textgrid.middleware.oaipmh.HeaderType; import info.textgrid.middleware.oaipmh.RecordType; - import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; - /** * FIXME * - * @author Maximilian Brodhun SUB - * @version 1.1 - * @since 17.02.2014 + * @author Maximilian Brodhun, SUB Göttingen + * @author Stefan E. Funk, SUB Göttingen + * @version 2019-10-28 + * @since 2014-02-17 */ - public class RecordDelivererDC extends RecordDelivererAbstract { private String[] fields; @@ -67,9 +64,7 @@ public class RecordDelivererDC extends RecordDelivererAbstract { private String[] typeList; private String textGridObjectAsJSON; - private static org.apache.commons.logging.Log log = LogFactory.getLog(RecordDelivererDC.class); - private OAI_ESClient oaiEsClient; /** @@ -87,11 +82,10 @@ public class RecordDelivererDC extends RecordDelivererAbstract { */ public GetRecordType getRecordById(String id) { - String[] includes = this.fields; - String[] excludes = Strings.EMPTY_ARRAY; - FetchSourceContext fetchSourceContext = - new FetchSourceContext(true, includes, excludes); - + String[] includes = this.fields; + String[] excludes = Strings.EMPTY_ARRAY; + FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); + GetRecordType getRecordType = new GetRecordType(); RecordType record = new RecordType(); String changedId = id; @@ -100,22 +94,20 @@ public class RecordDelivererDC extends RecordDelivererAbstract { if (id.startsWith(this.repositoryObjectURIPrefix)) { changedId = changedId.replace(this.repositoryObjectURIPrefix, ""); } - - GetRequest getRequest = new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), changedId).fetchSourceContext(fetchSourceContext); - GetResponse esResultObject=null; - try { + GetRequest getRequest = + new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), changedId) + .fetchSourceContext(fetchSourceContext); + GetResponse esResultObject = null; - esResultObject = - OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); - Gson gson = new GsonBuilder().create(); - textGridObjectAsJSON=esResultObject.getSourceAsString(); - - - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } + try { + esResultObject = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); + Gson gson = new GsonBuilder().create(); + this.textGridObjectAsJSON = esResultObject.getSourceAsString(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } if (esResultObject.isExists()) { @@ -145,30 +137,31 @@ public class RecordDelivererDC extends RecordDelivererAbstract { setRecordHeader(dateOfCreation, identifier, record, dublinCoreBuilder); } - if (this.textgrid == true && esResultObject.getSourceAsMap().get(this.formatField).equals(this.formatToFilter)) { - - String[] requestedField = relationToFurtherMetadataObject.split("\\."); - - Map<String, Object> nestedMap = esResultObject.getSourceAsMap(); - String valueOfRequestedField=null; - Map<String, Object> nestedMap2 = null; - for(int i=0; i<requestedField.length; i++) { - - if(i<requestedField.length-1) { - nestedMap2 = (Map<String, Object>)nestedMap.get(requestedField[i]); - } - if(i==requestedField.length-1) { - valueOfRequestedField =nestedMap2.get(requestedField[i]).toString(); - } - } - - //Map<String, Object> nestedMap2 = (Map<String, Object>)nestedMap.get("edition"); - + if (this.textgrid == true + && esResultObject.getSourceAsMap().get(this.formatField).equals(this.formatToFilter)) { + + String[] requestedField = this.relationToFurtherMetadataObject.split("\\."); + + Map<String, Object> nestedMap = esResultObject.getSourceAsMap(); + String valueOfRequestedField = null; + Map<String, Object> nestedMap2 = null; + for (int i = 0; i < requestedField.length; i++) { + + if (i < requestedField.length - 1) { + nestedMap2 = (Map<String, Object>) nestedMap.get(requestedField[i]); + } + if (i == requestedField.length - 1) { + valueOfRequestedField = nestedMap2.get(requestedField[i]).toString(); + } + } + + // Map<String, Object> nestedMap2 = (Map<String, Object>)nestedMap.get("edition"); + String workUri = nestedMap2.get("isEditionOf").toString(); workUri = workUri.substring(this.repositoryObjectURIPrefix.length()); dublinCoreBuilder = putContentIntoDCFieldLists(esResultObject, furtherDCElements(workUri)); identifier = esResultObject.getSourceAsMap().get(this.identifierField).toString(); - String dateOfCreation = + String dateOfCreation = esResultObject.getSourceAsMap().get(this.dateOfObjectCreation).toString(); setRecordHeader(dateOfCreation, identifier, record, dublinCoreBuilder); record.setMetadata(dublinCoreBuilder.getDC()); @@ -201,6 +194,12 @@ public class RecordDelivererDC extends RecordDelivererAbstract { recordHeader.setIdentifier(identifier); recordHeader.setDatestamp(dateOfCreation); + + // FIXME Do add set spec here! + // if (set != null) { + // recordHeader.getSetSpec().add(set); + // } + record.setMetadata(dbc.getDC()); record.setHeader(recordHeader); @@ -213,33 +212,25 @@ public class RecordDelivererDC extends RecordDelivererAbstract { */ private GetResponse furtherDCElements(String id) { - String[] includes = this.workFields; - String[] excludes = Strings.EMPTY_ARRAY; - FetchSourceContext fetchSourceContext = - new FetchSourceContext(true, includes, excludes); + String[] includes = this.workFields; + String[] excludes = Strings.EMPTY_ARRAY; + FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); if (!id.endsWith(".0")) { id = id.concat(".0"); } - - GetRequest getRequest = new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), id).fetchSourceContext(fetchSourceContext); - GetResponse responseWorkValues=null; - + GetRequest getRequest = new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), id) + .fetchSourceContext(fetchSourceContext); + GetResponse responseWorkValues = null; try { - responseWorkValues = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); - - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - + responseWorkValues = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } // FIXME MAX!!! DO WE NEED THST DATE??? - // FIXME MAX!!! DO WE NEED THST DATE??? - // FIXME MAX!!! DO WE NEED THST DATE??? - // try { // if (responseWorkValues.getField(this.dateOfObjectCreation) != null) { // this.dates.add(OAIPMHUtillities.convertDateFormat( diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java index 9e62806a567c2371b1617884dd8839261e9ae56e..151274386d7c1dbb5ef006660c6211125170bd4d 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RecordDelivererIDIOM.java @@ -3,13 +3,10 @@ package info.textgrid.middleware; import java.io.IOException; import java.io.StringReader; import java.text.ParseException; - import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; - import org.w3c.dom.Document; import org.xml.sax.InputSource; - import org.apache.commons.logging.LogFactory; import org.classicmayan.tools.ClassicMayanMetsMods; import org.elasticsearch.action.get.GetRequest; @@ -18,18 +15,16 @@ import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.common.Strings; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; - import info.textgrid.middleware.oaipmh.GetRecordType; import info.textgrid.middleware.oaipmh.HeaderType; import info.textgrid.middleware.oaipmh.MetadataType; import info.textgrid.middleware.oaipmh.RecordType; /** - * * @author Maximilian Brodhun, SUB Göttingen - * @since 2019-03-08 + * @author Stefan E. Funk, SUB Göttingen + * @since 2019-10-28 * @version 2019-03-12 - * */ public class RecordDelivererIDIOM extends RecordDelivererAbstract { @@ -37,11 +32,11 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { private String dateOfObjectCreation; private String dateOfLastOblectModification; private OAI_ESClient oaiEsClient; - + static MetadataType metadataMets = new MetadataType(); RecordType record = new RecordType(); ClassicMayanMetsMods metsmods; - + private static org.apache.commons.logging.Log log = LogFactory.getLog(RecordDelivererIDIOM.class); /** @@ -51,137 +46,139 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract { public RecordDelivererIDIOM(boolean textgrid, boolean dariah) { super(textgrid, dariah); } - + /* * (non-Javadoc) * * @see info.textgrid.middleware.RecordDelivererInterface#getRecordById(java.lang.String) */ - + /** - * ElasticSearch request in non-public index to get the datestamps for - * the object creation and last modification date in TextGrid-Repo - * + * <p> + * ElasticSearch request in non-public index to get the datestamps for the object creation and + * last modification date in TextGrid-Repo. + * </p> + * * @param idInDatabase */ - public void setDatestamps(String idInDatabase) { - String changedId = idInDatabase; - - String[] includes = new String[] {TGConstants.CREATED, TGConstants.MODIFIED_FIELD}; - String[] excludes = Strings.EMPTY_ARRAY; - FetchSourceContext fetchSourceContext = - new FetchSourceContext(true, includes, excludes); - - if(idInDatabase.startsWith("textgrid:")) { - changedId = idInDatabase.substring("textgrid:".length()); - } - - if(!idInDatabase.contains(".0")) { - changedId = changedId + ".0"; - } - - GetRequest getRequest = new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), changedId).fetchSourceContext(fetchSourceContext); - GetResponse objectInDatabase=null; - - try { - objectInDatabase = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - dateOfObjectCreation = objectInDatabase.getField(TGConstants.CREATED).getValue().toString(); - dateOfLastOblectModification = objectInDatabase.getField(TGConstants.MODIFIED_FIELD).getValue().toString(); + + String changedId = idInDatabase; + + String[] includes = new String[] {TGConstants.CREATED, TGConstants.MODIFIED_FIELD}; + String[] excludes = Strings.EMPTY_ARRAY; + FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes); + + if (idInDatabase.startsWith("textgrid:")) { + changedId = idInDatabase.substring("textgrid:".length()); + } + + if (!idInDatabase.contains(".0")) { + changedId = changedId + ".0"; + } + + GetRequest getRequest = + new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), changedId) + .fetchSourceContext(fetchSourceContext); + GetResponse objectInDatabase = null; + + try { + objectInDatabase = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + this.dateOfObjectCreation = + objectInDatabase.getField(TGConstants.CREATED).getValue().toString(); + this.dateOfLastOblectModification = + objectInDatabase.getField(TGConstants.MODIFIED_FIELD).getValue().toString(); } - + /** - * building the record XML object for the OAI-PMH response + * building the record XML object for the OAI-PMH response */ - public GetRecordType getRecordById(String id) { - + GetRecordType grt = new GetRecordType(); - + setDatestamps(id); String textgridBaseURI_FromID; - if(!id.startsWith("textgrid:")) { - textgridBaseURI_FromID = "textgrid:" + id.replace(".0", ""); - }else { - textgridBaseURI_FromID = id; + if (!id.startsWith("textgrid:")) { + textgridBaseURI_FromID = "textgrid:" + id.replace(".0", ""); + } else { + textgridBaseURI_FromID = id; } log.info("ID for generating the METS/MODS file is: " + textgridBaseURI_FromID); - metsmods = new ClassicMayanMetsMods( - textgridBaseURI_FromID, - dateOfObjectCreation, - dateOfLastOblectModification); - record.setMetadata(idiomMets()); + this.metsmods = new ClassicMayanMetsMods( + textgridBaseURI_FromID, + this.dateOfObjectCreation, + this.dateOfLastOblectModification); + this.record.setMetadata(idiomMets()); try { - if(!id.startsWith("textgrid:")) { - setRecordHeader(dateOfObjectCreation, "textgrid:" + id); - }else { - setRecordHeader(dateOfObjectCreation, id); - } - } catch (ParseException e) { - e.printStackTrace(); - log.error(e.toString()); - } - - grt.setRecord(record); + if (!id.startsWith("textgrid:")) { + setRecordHeader(this.dateOfObjectCreation, "textgrid:" + id); + } else { + setRecordHeader(this.dateOfObjectCreation, id); + } + } catch (ParseException e) { + e.printStackTrace(); + log.error(e.toString()); + } + + grt.setRecord(this.record); return grt; } - + // ** // PRIVATE METHODS // ** - + /** - * Getting the Mets/Mods object for the ClassicMayan artefact - * and put them into metadata element of the OAI-PMH response - * @return metadata XML-Elment + * <p> + * Getting the Mets/Mods object for the ClassicMayan artifact and put them into metadata element + * of the OAI-PMH response. + * </p> + * + * @return */ - - private MetadataType idiomMets(){ - - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder; - - try - { - builder = factory.newDocumentBuilder(); - Document doc = builder.parse( new InputSource( new StringReader( metsmods.getMets() ) ) ); - metadataMets.setAny(doc.getDocumentElement()); - } catch (Exception e) { - e.printStackTrace(); + private MetadataType idiomMets() { + + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder; + + try { + builder = factory.newDocumentBuilder(); + Document doc = builder.parse(new InputSource(new StringReader(this.metsmods.getMets()))); + metadataMets.setAny(doc.getDocumentElement()); + } catch (Exception e) { + e.printStackTrace(); } - + return metadataMets; } - - /** * @param dateOfCreation * @param identifier - * @return - * @throws ParseException + * @throws ParseException */ private void setRecordHeader(String dateOfCreation, String identifier) throws ParseException { HeaderType recordHeader = new HeaderType(); recordHeader.setIdentifier(identifier); recordHeader.setDatestamp(OAIPMHUtillities.datestampAsString(dateOfCreation)); - record.setHeader(recordHeader); - //return recordHeader; + this.record.setHeader(recordHeader); + // return recordHeader; } -public OAI_ESClient getOaiEsClient() { - return oaiEsClient; -} + public OAI_ESClient getOaiEsClient() { + return this.oaiEsClient; + } -public void setOaiEsClient(OAI_ESClient oaiEsClient) { - this.oaiEsClient = oaiEsClient; -} + public void setOaiEsClient(OAI_ESClient oaiEsClient) { + this.oaiEsClient = oaiEsClient; + } } 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 179520f72ab32cd946cb780e8be35492f6e42ba9..8594579ad76fba78a7e09ec1e567775980d735dc 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/RepIdentification.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/RepIdentification.java @@ -5,156 +5,174 @@ import info.textgrid.middleware.oaipmh.GranularityType; import info.textgrid.middleware.oaipmh.RequestType; /** - * Handling the "Identify" request from an OAIPMH client + * <p> + * Handling the "Identify" request from an OAIPMH client. + * </p> * * @author Maximilian Brodhun, SUB * @version 1.0 * @since 11.02.2014 - * */ public class RepIdentification { - private DeletedRecordType tgDeletetObjects = DeletedRecordType.NO; - private GranularityType tgRepGranulartiry = GranularityType.YYYY_MM_DD_THH_MM_SS_Z; - - 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){ - - setRepositoryName(RepositoryName); - setBaseUrl(BaseUrl); - setDeletedRecordStatus(DeletedRecordInfo); - setEarliestDatestamp(EarliestDatestamp); - setGranularity(Granularity); - setProtocolVersion(ProtocolVersion); - setAdminMailAddress(AdminMail); - } - - - /** - * - * @return TGConstants.TG_REP_NAME; - */ - public String getRepositoryName(){ - return RepositoryName; - } - - public void setRepositoryName(String RepositoryName){ - this.RepositoryName = RepositoryName; - } - - /** - * - * @return TGConstants.TG_REP_BASEURL - */ - public String getBaseUrl(){ - return BaseUrl; - } - - public void setBaseUrl(String BaseUrl){ - this.BaseUrl = BaseUrl; - } - - /** - * - * @return tgDeletetObjects - */ - 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 EarliestDatestamp; - } - - public void setEarliestDatestamp(String earliestDatestamp){ - this.EarliestDatestamp = earliestDatestamp; - } - - /** - * - * @return tgRepGranulartiry - */ - public GranularityType getGranularity(){ - 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 ProtocolVersion; - } - - public void setProtocolVersion(String protocolVersion){ - this.ProtocolVersion = protocolVersion; - } - - /** - * - * @return TGConstants.TEXTGRID_REP_ADMIN_CONTACT.get(0) - */ - public String getAdminMaiAddresss(){ - //return TGConstants.TEXTGRID_REP_ADMIN_CONTACT.get(0); - return AdminMailAdress; - } - - public void setAdminMailAddress(String adminMailAddress){ - this.AdminMailAdress = adminMailAddress; - } - - /** - * checking the request if all necessary values are set or not allowed values are not set - * @param request the initially request from the OAIPMG client - * @return a boolean indicating the correctness of the request - */ - - public boolean requestChecker(RequestType request){ - - boolean noArguments; - - if( request.getFrom()!=null || - request.getIdentifier()!=null || - request.getMetadataPrefix()!=null - ){ - noArguments=false; - } - else if(request.getResumptionToken()!=null || - request.getSet()!=null || - request.getUntil()!=null){ - - noArguments=false; - } - else{ - noArguments=true; - } - return noArguments; - } - + private DeletedRecordType tgDeletetObjects = DeletedRecordType.NO; + private GranularityType tgRepGranulartiry = GranularityType.YYYY_MM_DD_THH_MM_SS_Z; + + private String RepositoryName; + private String BaseUrl; + private String EarliestDatestamp; + private String ProtocolVersion; + private String AdminMailAdress; + + /** + * @param RepositoryName + * @param BaseUrl + * @param DeletedRecordInfo + * @param EarliestDatestamp + * @param Granularity + * @param ProtocolVersion + * @param AdminMail + */ + public RepIdentification(String RepositoryName, String BaseUrl, + DeletedRecordType DeletedRecordInfo, String EarliestDatestamp, GranularityType Granularity, + String ProtocolVersion, String AdminMail) { + + setRepositoryName(RepositoryName); + setBaseUrl(BaseUrl); + setDeletedRecordStatus(DeletedRecordInfo); + setEarliestDatestamp(EarliestDatestamp); + setGranularity(Granularity); + setProtocolVersion(ProtocolVersion); + setAdminMailAddress(AdminMail); + } + + /** + * @return TGConstants.TG_REP_NAME; + */ + public String getRepositoryName() { + return this.RepositoryName; + } + + /** + * @param RepositoryName + */ + public void setRepositoryName(String RepositoryName) { + this.RepositoryName = RepositoryName; + } + + /** + * @return TGConstants.TG_REP_BASEURL + */ + public String getBaseUrl() { + return this.BaseUrl; + } + + /** + * @param BaseUrl + */ + public void setBaseUrl(String BaseUrl) { + this.BaseUrl = BaseUrl; + } + + /** + * @return tgDeletetObjects + */ + public DeletedRecordType getDeletedRecordStatus() { + return this.tgDeletetObjects; + } + + /** + * @param 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 this.EarliestDatestamp; + } + + /** + * @param earliestDatestamp + */ + public void setEarliestDatestamp(String earliestDatestamp) { + this.EarliestDatestamp = earliestDatestamp; + } + + /** + * @return tgRepGranulartiry + */ + public GranularityType getGranularity() { + return this.tgRepGranulartiry; + } + + /** + * @param 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 this.ProtocolVersion; + } + + /** + * @param protocolVersion + */ + public void setProtocolVersion(String protocolVersion) { + this.ProtocolVersion = protocolVersion; + } + + /** + * @return TGConstants.TEXTGRID_REP_ADMIN_CONTACT.get(0) + */ + public String getAdminMaiAddresss() { + // return TGConstants.TEXTGRID_REP_ADMIN_CONTACT.get(0); + return this.AdminMailAdress; + } + + /** + * @param adminMailAddress + */ + public void setAdminMailAddress(String adminMailAddress) { + this.AdminMailAdress = adminMailAddress; + } + + /** + * <p> + * Checking the request if all necessary values are set or not allowed values are not set. + * </p> + * + * @param request the initially request from the OAIPMG client + * @return a boolean indicating the correctness of the request + */ + public boolean requestChecker(RequestType request) { + + boolean noArguments; + + if (request.getFrom() != null || + request.getIdentifier() != null || + request.getMetadataPrefix() != null) { + noArguments = false; + } else if (request.getResumptionToken() != null || + request.getSet() != null || + request.getUntil() != null) { + + noArguments = false; + } else { + noArguments = true; + } + + return noArguments; + } + } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/Rest.java b/oaipmh-core/src/main/java/info/textgrid/middleware/Rest.java index 391f12fa45aaf1f306a98938bdb6db976282f857..84c2adfa500a76199a33ed18c6238ac9baacd51c 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/Rest.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/Rest.java @@ -1,8 +1,5 @@ package info.textgrid.middleware; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; @@ -16,49 +13,20 @@ import info.textgrid.utils.httpclient.TGHttpConnection; */ public class Rest { - private Log log = LogFactory.getLog(Rest.class); + private Log log = LogFactory.getLog(Rest.class); - /** - * @return - */ - @GET - @Path("/buildinfo") - @Produces("text/html") - public String getBuildInfo() { + /** + * @return + */ + @GET + @Path("/cmstat") + @Produces("text/plain") + public Response getConManStat() { - InputStream is = this.getClass().getResourceAsStream("buildinfo.txt"); - Properties prop = new Properties(); - try { - prop.load(is); - } catch (IOException e) { - return "Error opening buildinfo.txt"; - } finally { - try { - is.close(); - } catch (IOException e) { - this.log.error("error closing stream", e); - } - } + String[] routes = {}; + String cmstats = TGHttpConnection.generateInfoString(routes); - String info = "This is oaipmh " + prop.get("version") + " built " - + prop.get("time") + " from git: " + prop.get("branch") - + " (rev:" + prop.get("build") + ")"; - - return info; - } - - /** - * @return - */ - @GET - @Path("/cmstat") - @Produces("text/plain") - public Response getConManStat() { - - String[] routes = {}; - String cmstats = TGHttpConnection.generateInfoString(routes); - - return Response.ok(cmstats).build(); - } + return Response.ok(cmstats).build(); + } } diff --git a/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java b/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java index 7db564dbc6e0434e910a7194287676c28f49dd7b..e2a29c71a5160d348d4aa0e1297e5d3154367545 100644 --- a/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java +++ b/oaipmh-core/src/main/java/info/textgrid/middleware/SetDeliverer.java @@ -8,7 +8,6 @@ import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; - import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.search.SearchRequest; @@ -22,7 +21,6 @@ import org.elasticsearch.search.aggregations.AggregationBuilder; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; - import info.textgrid.middleware.oaipmh.ListSetsType; import info.textgrid.middleware.oaipmh.SetType; import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; @@ -49,7 +47,7 @@ public class SetDeliverer { * @param textgrid * @param dariah */ - public SetDeliverer(boolean textgrid, boolean dariah) { + public SetDeliverer(boolean textgrid, boolean dariah) { this.textgrid = textgrid; this.dariah = dariah; } @@ -61,55 +59,62 @@ public class SetDeliverer { ListSetsType setList = new ListSetsType(); QueryBuilder aggQuery; - + SearchRequest request = new SearchRequest(OAI_ESClient.getEsIndex()); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); AggregationBuilder agg = null; - if (this.textgrid) { - agg = AggregationBuilders - .terms("project.value.untouched") - .field("project.value.untouched") - .size(10000); + if (this.textgrid) { + agg = AggregationBuilders + .terms("project.value.untouched") + .field("project.value.untouched") + .size(10000); } else { aggQuery = QueryBuilders.matchPhraseQuery("descriptiveMetadata.dc:format", TextGridMimetypes.DARIAH_COLLECTION); } - searchSourceBuilder.aggregation(agg); searchSourceBuilder.size(10000); request.source(searchSourceBuilder); - SearchResponse getRecordListItems=null; - - try { - getRecordListItems = OAI_ESClient.getEsClient().search(request, RequestOptions.DEFAULT); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } + SearchResponse getRecordListItems = null; + + try { + getRecordListItems = OAI_ESClient.getEsClient().search(request, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + // SearchRequestBuilder request = OAI_ESClient.getOaiESClient() + // .prepareSearch(OAI_ESClient.getEsIndex()).setTypes(OAI_ESClient.getEsType()) + // .setQuery(aggQuery).addField(this.formatField).addField(this.identifierField) + // .addField("project.value").addField("project.id").setSize(100000); + // SearchResponse getRecordListItems = request.execute().actionGet(); for (SearchHit hit : getRecordListItems.getHits().getHits()) { - + if (this.dariah == false && hit.getSourceAsMap().get(this.identifierField) .toString().startsWith("hdl:")) { - + String pid = hit.getFields().get(this.identifierField).getValues().get(0).toString(); this.identifier.add(pid); } - + if (this.textgrid == true) { - - String[] projectFields = new String[] {"project.value", "project.id"}; + String[] projectFields = new String[] {"project.value", "project.id"}; String projectName = DublinCoreFieldLoader.fillList(hit, projectFields).get(0); String projectID = DublinCoreFieldLoader.fillList(hit, projectFields).get(1); - //String projectSetSpec = projectName.concat(":").concat(projectID); - SetDeliverer.setSet.put(projectID, projectName); + + // FIXME Why is that set spec thing commented out?? + // String projectSetSpec = projectName.concat(":").concat(projectID); + // FIXME setSet remained from develop branch. + // SetDeliverer.setSet.put(projectID, projectName); } } - - if (this.textgrid == true) { - + + if (this.textgrid == true) { + Iterator<?> it = setSet.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); @@ -131,21 +136,23 @@ public class SetDeliverer { id = identifierSetSpec.substring(this.repositoryObjectURIPrefix.length()); - String[] includes2 = new String[] {this.specField}; - String[] excludes2 = Strings.EMPTY_ARRAY; - FetchSourceContext fetchSourceContext2 = - new FetchSourceContext(true, includes2, excludes2); - - GetRequest getRequest = new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), id).fetchSourceContext(fetchSourceContext2); + String[] includes2 = new String[] {this.specField}; + String[] excludes2 = Strings.EMPTY_ARRAY; + FetchSourceContext fetchSourceContext2 = + new FetchSourceContext(true, includes2, excludes2); + + GetRequest getRequest = + new GetRequest(OAI_ESClient.getEsIndex(), OAI_ESClient.getEsType(), id) + .fetchSourceContext(fetchSourceContext2); GetResponse setSpec = null; - + try { - setSpec=OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - + setSpec = OAI_ESClient.getEsClient().get(getRequest, RequestOptions.DEFAULT); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String setName = ""; if (setSpec != null && setSpec.isExists()) { if (setSpec.getField(this.specField) != null) { @@ -274,5 +281,4 @@ public class SetDeliverer { this.dariah = dariah; } - } diff --git a/oaipmh-core/src/main/resources/bindings.xjb b/oaipmh-core/src/main/resources/bindings.xjb new file mode 100644 index 0000000000000000000000000000000000000000..a85bd2428058235ab071d54921f098ec53819781 --- /dev/null +++ b/oaipmh-core/src/main/resources/bindings.xjb @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<jxb:bindings version="1.0" + xmlns:jxb="http://java.sun.com/xml/ns/jaxb" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix" + xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb https://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd + http://jaxb2-commons.dev.java.net/namespace-prefix https://raw.githubusercontent.com/Siggen/jaxb2-namespace-prefix/master/src/main/resources/prefix-namespace-schema.xsd"> + <jxb:bindings schemaLocation="oai_pmh.xsd"> + <jxb:schemaBindings> + <jxb:package name="info.textgrid.middleware.oaipmh" /> + </jxb:schemaBindings> + <jxb:bindings> + <!-- We want no prefix for default namespace... --> + <namespace:prefix name="" /> + </jxb:bindings> + <jxb:bindings> + <!-- ...but we want prefixes for oai_dc and dc! --> + <namespace:prefix + namespaceURI="http://www.openarchives.org/OAI/2.0/oai_dc/" + name="oai_dc" /> + <namespace:prefix + namespaceURI="http://purl.org/dc/elements/1.1/" name="dc" /> + </jxb:bindings> + </jxb:bindings> +</jxb:bindings> diff --git a/oaipmh-core/src/main/xsd/oai_dc.xsd b/oaipmh-core/src/main/resources/oai_dc.xsd similarity index 100% rename from oaipmh-core/src/main/xsd/oai_dc.xsd rename to oaipmh-core/src/main/resources/oai_dc.xsd diff --git a/oaipmh-core/src/main/xsd/oai_pmh.xsd b/oaipmh-core/src/main/resources/oai_pmh.xsd similarity index 99% rename from oaipmh-core/src/main/xsd/oai_pmh.xsd rename to oaipmh-core/src/main/resources/oai_pmh.xsd index 834bb391c33803dcfaebd72495929fa29d7a543a..3fce3b59db458399dfaee104587694ebd9c8805e 100644 --- a/oaipmh-core/src/main/xsd/oai_pmh.xsd +++ b/oaipmh-core/src/main/resources/oai_pmh.xsd @@ -21,9 +21,9 @@ </documentation> </annotation> - <element name="OAI-PMH" type="oai:OAI-PMHType"/> + <element name="OAI-PMH" type="oai:OAI-PMHtype"/> - <complexType name="OAI-PMHType"> + <complexType name="OAI-PMHtype"> <sequence> <element name="responseDate" type="dateTime"/> <element name="request" type="oai:requestType"/> @@ -314,4 +314,4 @@ </restriction> </simpleType> -</schema> \ No newline at end of file +</schema> diff --git a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDARIAHTest.java b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDARIAHTest.java index c31ac96dd41584451d7846a274ac63ce8500d02a..033854366e26aa3eb3286de91606674e5ca79c09 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDARIAHTest.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhDARIAHTest.java @@ -1,14 +1,11 @@ package info.textgrid.middleware; import java.text.ParseException; -import javax.xml.bind.JAXB; -import javax.xml.bind.JAXBElement; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; import info.textgrid.middleware.oaipmh.DeletedRecordType; import info.textgrid.middleware.oaipmh.GranularityType; -import info.textgrid.middleware.oaipmh.OAIPMHType; import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; /** @@ -66,8 +63,8 @@ public class OaiPmhDARIAHTest { public void testGetRequestIdentify() throws ParseException { System.out.println("Test for the verb \"Identify\" with succesfull response"); - JAXBElement<OAIPMHType> r = this.request.getRequest("Identify", "", "", "", "", "", ""); - JAXB.marshal(r, System.out); + String r = this.request.getRequest("Identify", "", "", "", "", "", ""); + System.out.println(r); System.out.println("-----------------------------------\n"); } @@ -100,9 +97,9 @@ public class OaiPmhDARIAHTest { OaiPmhDARIAHTest.record.setIdentifierField("administrativeMetadata.dcterms:identifier"); System.out.println("Test for the verb \"GetRecord\" for DARIAH with succesfull response"); - JAXBElement<OAIPMHType> p = this.request.getRequest("GetRecord", - "hdl:21.T11991/0000-0005-E1AA-D", "oai_dc", "", "", "", ""); - JAXB.marshal(p, System.out); + String p = this.request.getRequest("GetRecord", "hdl:21.T11991/0000-0005-E1AA-D", "oai_dc", "", + "", "", ""); + System.out.println(p); System.out.println("-----------------------------------\n"); } @@ -138,9 +135,9 @@ public class OaiPmhDARIAHTest { .setRelationToFurtherMetadataObject("descriptiveMetadata.dc:relation"); OaiPmhDARIAHTest.recordList.setSearchResponseSize("100"); - JAXBElement<OAIPMHType> r = this.request.getRequest("ListRecords", "", "oai_dc", - "21.T11991/0000-0003-718E-E", "", "", ""); - JAXB.marshal(r, System.out); + String r = this.request.getRequest("ListRecords", "", "oai_dc", "21.T11991/0000-0003-718E-E", + "", "", ""); + System.out.println(r); System.out.println("-----------------------------------\n"); } @@ -158,8 +155,8 @@ public class OaiPmhDARIAHTest { OaiPmhDARIAHTest.setListDARIAH.setIdentifierField("administrativeMetadata.dcterms:identifier"); OaiPmhDARIAHTest.setListDARIAH.setSpecField("descriptiveMetadata.dc:title"); OaiPmhDARIAHTest.setListDARIAH.setSpecFieldPrefix(DARIAHConstants.COLLECTIONREGISTRY_PREFIX); - JAXBElement<OAIPMHType> r = this.request.getRequest("ListSets", "", "", "", "", "", ""); - JAXB.marshal(r, System.out); + String r = this.request.getRequest("ListSets", "", "", "", "", "", ""); + System.out.println(r); System.out.println("-----------------------------------\n"); } @@ -177,9 +174,8 @@ public class OaiPmhDARIAHTest { .setRepositoryObjectURIPrefix(DARIAHConstants.ITEM_IDENTIFIER_PREFIX); OaiPmhDARIAHTest.identifierList.setIdentifierField("administrativeMetadata.dcterms:identifier"); OaiPmhDARIAHTest.identifierList.setSearchResponseSize("100"); - JAXBElement<OAIPMHType> r = - this.request.getRequest("ListIdentifiers", "", "oai_dc", "", "", "", ""); - JAXB.marshal(r, System.out); + String r = this.request.getRequest("ListIdentifiers", "", "oai_dc", "", "", "", ""); + System.out.println(r); System.out.println("-----------------------------------\n"); } 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 6f8157d53d1c1e311b52e1c07931cae6fc719bf8..b5c91e93b7e3dfb9b074a808a3189fdc94863415 100644 --- a/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java +++ b/oaipmh-core/src/test/java/info/textgrid/middleware/OaiPmhTest.java @@ -1,11 +1,7 @@ package info.textgrid.middleware; import java.text.ParseException; -import java.util.HashMap; import java.util.Map; - -import javax.xml.bind.JAXB; -import javax.xml.bind.JAXBElement; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.XMLGregorianCalendar; import org.junit.BeforeClass; @@ -13,70 +9,80 @@ import org.junit.Ignore; import org.junit.Test; import info.textgrid.middleware.oaipmh.DeletedRecordType; import info.textgrid.middleware.oaipmh.GranularityType; -import info.textgrid.middleware.oaipmh.OAIPMHType; import info.textgrid.namespaces.middleware.tgcrud.common.TextGridMimetypes; /** - * * @author Maximilian Brodhun, SUB Göttingen * @author Stefan E. Funk, SUB Göttingen - * */ public class OaiPmhTest { - public static OAI_ESClient 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", - this.bla, "2011-06-11T02:32:40Z", this.bla2, "2.0", "textgrid-support@gwdg.de"); + // ** + // STATICS + // ** + public static OAI_ESClient oaiEsClient; private static RecordDelivererDC record; private static RecordDelivererIDIOM recordIDIOM; private static RecordListDelivererDC recordList; private static RecordListDelivererIDIOM recordListIDIOM; - private static IdentifierListDelivererDC identifierList = new IdentifierListDelivererDC(true, false); - private static IdentifierListDelivererIDIOM identifierListIDIOM = new IdentifierListDelivererIDIOM(true, false); - private MetadataFormatListDeliverer metadataFormatList = new MetadataFormatListDeliverer(); - // private SetDeliverer setListDARIAH = new SetDeliverer(false, true); + private static IdentifierListDelivererDC identifierList = + new IdentifierListDelivererDC(true, false); + private static IdentifierListDelivererIDIOM identifierListIDIOM = + new IdentifierListDelivererIDIOM(true, false); private static SetDeliverer setListTextGrid; - + + // ** + // CLASS + // ** + + private DeletedRecordType bla = DeletedRecordType.NO; + private GranularityType bla2 = GranularityType.YYYY_MM_DD_THH_MM_SS_Z; + private RepIdentification rep = new RepIdentification("TextGrid-Repository", "www.textgridrep.de", + this.bla, "2011-06-11T02:32:40Z", this.bla2, "2.0", "textgrid-support@gwdg.de"); + private MetadataFormatListDeliverer metadataFormatList = new MetadataFormatListDeliverer(); + // FIXME Why is setdeliverer commented out here again? + // private SetDeliverer setListDARIAH = new SetDeliverer(false, true); private OAIPMHImpl request = new OAIPMHImpl( - this.rep, OaiPmhTest.record, OaiPmhTest.recordIDIOM, OaiPmhTest.recordList, - OaiPmhTest.recordListIDIOM, this.metadataFormatList, - OaiPmhTest.setListTextGrid, OaiPmhTest.identifierList, OaiPmhTest.identifierListIDIOM); + this.rep, OaiPmhTest.record, OaiPmhTest.recordIDIOM, OaiPmhTest.recordList, + OaiPmhTest.recordListIDIOM, this.metadataFormatList, + OaiPmhTest.setListTextGrid, OaiPmhTest.identifierList, OaiPmhTest.identifierListIDIOM); + // FIXME from develop branch... not needed? + // private SetDeliverer setListDARIAH = new SetDeliverer(false, true); + // private SetDeliverer setListTextGrid = new SetDeliverer(true, false); /** * @throws Exception */ @BeforeClass public static void setUp() throws Exception { - int[] ports = new int[] {9202}; - oaiEsClient = new OAI_ESClient("localhost", ports, 100); + int[] ports = new int[] {9202}; + oaiEsClient = new OAI_ESClient("localhost", ports, 100); OAI_ESClient.setEsIndex("textgrid-public"); - OAI_ESClient.setEsType("metadata"); + OAI_ESClient.setEsType("metadata"); OAI_ESClient.setPorts(ports); record = new RecordDelivererDC(true, false); record.setOaiEsClient(oaiEsClient); record.setWorkFields(TGConstants.TGWorkFields); - + recordIDIOM = new RecordDelivererIDIOM(true, false); - recordIDIOM.setOaiEsClient(oaiEsClient); - + recordIDIOM.setOaiEsClient(oaiEsClient); + recordList = new RecordListDelivererDC(true, false); recordList.setFields(TGConstants.TGFields); recordList.setWorkFields(TGConstants.TGWorkFields); recordList.setOaiEsClient(oaiEsClient); recordList.setSearchResponseSize("100"); - + recordListIDIOM = new RecordListDelivererIDIOM(true, false); - recordListIDIOM.setOaiEsClient(oaiEsClient); - + recordListIDIOM.setOaiEsClient(oaiEsClient); + identifierList = new IdentifierListDelivererDC(true, false); identifierList.setOaiEsClient(oaiEsClient); identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS); - + setListTextGrid = new SetDeliverer(true, false); } @@ -98,10 +104,8 @@ public class OaiPmhTest { */ @Test @Ignore - public void testDateGregorianType() throws ParseException, - DatatypeConfigurationException { + public void testDateGregorianType() throws ParseException, DatatypeConfigurationException { String dateformatbefore = "2012-02-06T20:48:39.614+01:00"; - System.out.println("--------- Test Datestamp Parsing with a given date ---------------"); System.out.println("Original date: " + dateformatbefore); XMLGregorianCalendar testDate = OAIPMHUtillities.convertDateFormat(dateformatbefore); @@ -115,10 +119,8 @@ public class OaiPmhTest { */ @Test @Ignore - public void testDateStringType() throws ParseException, - DatatypeConfigurationException { + public void testDateStringType() throws ParseException, DatatypeConfigurationException { String dateformatbefore = "2012-02-06T20:48:39.614+01:00"; - System.out.println("------------String Version-------------------"); System.out.println("Original date: " + dateformatbefore); String testDate = OAIPMHUtillities.datestampAsString(dateformatbefore); @@ -132,11 +134,9 @@ public class OaiPmhTest { @Test @Ignore public void testGetRequestIdentify() throws ParseException { - System.out.println("Test for the verb \"Identify\" with succesfull response"); - JAXBElement<OAIPMHType> r = - this.request.getRequest("Identify", "", "", "", "", "", ""); - JAXB.marshal(r, System.out); + String r = this.request.getRequest("Identify", "", "", "", "", "", ""); + System.out.println(r); System.out.println("-----------------------------------\n"); } @@ -144,12 +144,11 @@ public class OaiPmhTest { * @throws ParseException */ @Test - @Ignore + @Ignore public void testGetRequestIdentifyVerbError() throws ParseException { - System.out.println("Test for the verb \"Identify\" with error response (MetadaFormat)"); - JAXBElement<OAIPMHType> t = - this.request.getRequest("Identify", "", "a", "", "", "", ""); - JAXB.marshal(t, System.out); + System.out.println("Test for the verb \"Identify\" with error response (MetadaFormat)"); + String t = this.request.getRequest("Identify", "", "a", "", "", "", ""); + System.out.println(t); System.out.println("-----------------------------------\n"); } @@ -160,9 +159,8 @@ public class OaiPmhTest { @Ignore public void testGetRequestIdentifyArgumentError() throws ParseException { System.out.println("Test for the verb \"Identify\" with error response (Until and Identifier)"); - JAXBElement<OAIPMHType> z = - this.request.getRequest("Identify", "a", "", "", "", "a", ""); - JAXB.marshal(z, System.out); + String z = this.request.getRequest("Identify", "a", "", "", "", "a", ""); + System.out.println(z); System.out.println("-----------------------------------\n"); } @@ -172,7 +170,6 @@ public class OaiPmhTest { @Test @Ignore public void testGetRequestGetRecordTextGrid() throws ParseException { - record.setContributor(TGConstants.CONTRIBUTOR_LIST); record.setCoverage(TGConstants.COVERAGE_LIST); record.setCreator(TGConstants.CREATOR_LIST); @@ -194,13 +191,12 @@ public class OaiPmhTest { record.setFormatToFilter(TextGridMimetypes.EDITION); record.setDateOfObjectCreation(TGConstants.CREATED); record.setRelationToFurtherMetadataObject(TGConstants.EDITION_ISEDITIONOF); - record.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); + record.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); record.setIdentifierField("textgridUri"); System.out.println("Test for the verb \"GetRecord\" with succesfull response"); - JAXBElement<OAIPMHType> p = - this.request.getRequest("GetRecord", "textgrid:vqn0.0", "oai_dc", "", "", "", ""); - JAXB.marshal(p, System.out); + String p = this.request.getRequest("GetRecord", "textgrid:vqn0.0", "oai_dc", "", "", "", ""); + System.out.println(p); System.out.println("-----------------------------------\n"); } @@ -210,28 +206,23 @@ public class OaiPmhTest { @Test @Ignore public void testGetRequestGetRecordIDIOM() throws ParseException { - System.out.println("Test for the verb \"GetRecord\" with succesfull response"); - JAXBElement<OAIPMHType> p = - this.request.getRequest("GetRecord", "textgrid:2rcj2", TGConstants.METADATA_IDIOM_PREFIX, "", "", "", ""); - JAXB.marshal(p, System.out); + String p = this.request.getRequest("GetRecord", "textgrid:2rcj2", + TGConstants.METADATA_IDIOM_PREFIX, "", "", "", ""); + System.out.println(p); System.out.println("-----------------------------------\n"); } - - + /** * @throws ParseException */ @Test @Ignore public void testGetRequestGetRecordErrorIdentifierMissing() throws ParseException { - System.out - .println("Test for the verb \"GetRecord\" with errpr response (Identifier Missing)"); - JAXBElement<OAIPMHType> p = this.request.getRequest("GetRecord", "", - "", "", "", "", ""); - JAXB.marshal(p, System.out); + System.out.println("Test for the verb \"GetRecord\" with errpr response (Identifier Missing)"); + String p = this.request.getRequest("GetRecord", "", "", "", "", "", ""); + System.out.println(p); System.out.println("-----------------------------------\n"); - } /** @@ -240,7 +231,6 @@ public class OaiPmhTest { @Test @Ignore public void testListIdentifierSetsDC() throws ParseException { - OaiPmhTest.identifierList.setFieldForRange(TGConstants.RANGE_FIELD); OaiPmhTest.identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS); OaiPmhTest.identifierList.setDateOfObjectCreation(TGConstants.CREATED); @@ -248,16 +238,18 @@ public class OaiPmhTest { OaiPmhTest.identifierList.setIdentifierField("textgridUri"); OaiPmhTest.identifierList.setSearchResponseSize("100"); System.out.println("Test for the verb \"ListIdentifiers\" with succesfull response"); - JAXBElement<OAIPMHType> p = this.request.getRequest("ListIdentifiers", "", "oai_dc", - "project:TGPR-372fe6dc-57f2-6cd4-01b5-2c4bbefcfd3c", "", "", ""); - JAXB.marshal(p, System.out); + String p = this.request.getRequest("ListIdentifiers", "", "oai_dc", + "project:TGPR-26236625-1acc-b921-a5fa-53567c3eeb80", "", "", ""); + System.out.println(p); System.out.println("-----------------------------------\n"); } - + + /** + * @throws ParseException + */ @Test @Ignore public void testListIdentifierWithResumptionTokenDC() throws ParseException { - OaiPmhTest.identifierList.setFieldForRange(TGConstants.RANGE_FIELD); OaiPmhTest.identifierList.setIdentifierListFields(TGConstants.IDENTIFIER_LIST_FIELDS); OaiPmhTest.identifierList.setDateOfObjectCreation(TGConstants.CREATED); @@ -265,63 +257,58 @@ public class OaiPmhTest { OaiPmhTest.identifierList.setIdentifierField("textgridUri"); OaiPmhTest.identifierList.setSearchResponseSize("100"); System.out.println("Test for the verb \"ListIdentifiers\" with succesfull response"); - JAXBElement<OAIPMHType> p = this.request.getRequest("ListIdentifiers", "", "oai_dc", - "", "", "", ""); - JAXB.marshal(p, System.out); - - - String resToken =""; - for(Map.Entry<String, Integer> entry : IdentifierListDelivererDC.cursorCollector.entrySet()) { - resToken = entry.getKey(); - } + String p = this.request.getRequest("ListIdentifiers", "", "oai_dc", "", "", "", ""); + System.out.println(p); + String resToken = ""; + for (Map.Entry<String, Integer> entry : IdentifierListDelivererDC.cursorCollector.entrySet()) { + resToken = entry.getKey(); + } System.out.println("HASH MAP BEFORE: "); System.out.println(IdentifierListDelivererDC.cursorCollector); System.out.println(resToken); - JAXBElement<OAIPMHType> p2 = this.request.getRequest("ListIdentifiers", "", "", - "", "", "", resToken); - JAXB.marshal(p2, System.out); + String p2 = this.request.getRequest("ListIdentifiers", "", "", "", "", "", resToken); + System.out.println(p2); System.out.println("HASH MAP AFTER: "); System.out.println(IdentifierListDelivererDC.cursorCollector); - System.out.println("-----------------------------------\n"); } + /** + * @throws ParseException + */ @Test @Ignore public void testListIdentifierIDIOMInvalidResumptionToken() throws ParseException { - - System.out.println("Test for the verb \"ListIdentifiers\" in IDIOM with an invalid resumption token"); - JAXBElement<OAIPMHType> p = this.request.getRequest("ListIdentifiers", "", "", - "", "", "", "45d8b524-b69e-44e8-81a9-a3634005a430"); - JAXB.marshal(p, System.out); + System.out + .println("Test for the verb \"ListIdentifiers\" in IDIOM with an invalid resumption token"); + String p = this.request.getRequest("ListIdentifiers", "", "", "", "", "", + "45d8b524-b69e-44e8-81a9-a3634005a430"); + System.out.println(p); System.out.println("-----------------------------------\n"); } - + + /** + * @throws ParseException + */ @Test @Ignore public void testListIdentifierIDIOMWithResumptionToken() throws ParseException { - System.out.println("Test for the verb \"ListIdentifiers\" in IDIOM with successfull response"); - - JAXBElement<OAIPMHType> p = this.request.getRequest("ListIdentifiers", "", TGConstants.METADATA_IDIOM_PREFIX, - "", "", "", ""); - JAXB.marshal(p, System.out); - - String resToken =""; - for(Map.Entry<String, Integer> entry : IdentifierListDelivererIDIOM.cursorCollector.entrySet()) { - resToken = entry.getKey(); - } - - JAXBElement<OAIPMHType> p2 = this.request.getRequest("ListIdentifiers", "", "", - "", "", "", resToken); - JAXB.marshal(p2, System.out); + String p = this.request.getRequest("ListIdentifiers", "", TGConstants.METADATA_IDIOM_PREFIX, "", + "", "", ""); + System.out.println(p); + String resToken = ""; + for (Map.Entry<String, Integer> entry : IdentifierListDelivererIDIOM.cursorCollector + .entrySet()) { + resToken = entry.getKey(); + } + String p2 = this.request.getRequest("ListIdentifiers", "", "", "", "", "", resToken); + System.out.println(p2); System.out.println("HASH MAP AFTER: "); System.out.println(IdentifierListDelivererIDIOM.cursorCollector); - System.out.println("-----------------------------------\n"); - } - + /** * @throws ParseException */ @@ -351,65 +338,52 @@ public class OaiPmhTest { OaiPmhTest.recordList.setRepositoryObjectURIPrefix(TGConstants.ITEM_IDENTIFIER_PREFIX); OaiPmhTest.recordList.setFieldForRange(TGConstants.CREATED); OaiPmhTest.recordList.setModifiedField(TGConstants.MODIFIED_FIELD); - OaiPmhTest.recordList.setIdentifierField("textgridUri"); - + OaiPmhTest.recordList.setIdentifierField("textgridUri"); + System.out.println("Test for the verb \"ListRecords\" with sets with succesfull response"); - JAXBElement<OAIPMHType> p = - this.request.getRequest("ListRecords", "", "oai_dc", "", "", "", ""); - JAXB.marshal(p, System.out); - - String resToken =""; - for(Map.Entry<String, Integer> entry : RecordListDelivererDC.cursorCollector.entrySet()) { - resToken = entry.getKey(); - } - - JAXBElement<OAIPMHType> p2 = this.request.getRequest("ListRecords", "", "", - "", "", "", resToken); - JAXB.marshal(p2, System.out); + String p = this.request.getRequest("ListRecords", "", "oai_dc", "", "", "", ""); + System.out.println(p); + String resToken = ""; + for (Map.Entry<String, Integer> entry : RecordListDelivererDC.cursorCollector.entrySet()) { + resToken = entry.getKey(); + } + String p2 = this.request.getRequest("ListRecords", "", "", "", "", "", resToken); + System.out.println(p2); System.out.println("HASH MAP AFTER: "); System.out.println(RecordListDelivererDC.cursorCollector); - - System.out.println("-----------------------------------\n"); - } + /** + * @throws ParseException + */ @Test @Ignore public void testListRecordWithResumptionTokenForIDIOM() throws ParseException { - System.out.println("Test for the verb \"ListRecords\" for IDIOM with succesfull response"); - JAXBElement<OAIPMHType> p = - this.request.getRequest("ListRecords", "", TGConstants.METADATA_IDIOM_PREFIX, "", "", "", ""); - JAXB.marshal(p, System.out); - - - String resToken =""; - for(Map.Entry<String, Integer> entry : RecordListDelivererIDIOM.cursorCollector.entrySet()) { - resToken = entry.getKey(); - } - - JAXBElement<OAIPMHType> p2 = this.request.getRequest("ListRecords", "", "", - "", "", "", resToken); - JAXB.marshal(p2, System.out); + String p = this.request.getRequest("ListRecords", "", TGConstants.METADATA_IDIOM_PREFIX, "", "", + "", ""); + System.out.println(p); + String resToken = ""; + for (Map.Entry<String, Integer> entry : RecordListDelivererIDIOM.cursorCollector.entrySet()) { + resToken = entry.getKey(); + } + String p2 = this.request.getRequest("ListRecords", "", "", "", "", "", resToken); + System.out.println(p2); System.out.println("HASH MAP AFTER: "); System.out.println(RecordListDelivererIDIOM.cursorCollector); - System.out.println("-----------------------------------\n"); - } - - + /** * @throws ParseException */ @Test @Ignore public void testListRecords() throws ParseException { - - JAXBElement<OAIPMHType> r = - this.request.getRequest("ListRecords", "", "oai_dc", "", "", "", ""); - JAXB.marshal(r, System.out); + String r = + this.request.getRequest("ListRecords", "", "oai_dc", "", "2011-02-06T20:48:39", "", ""); + System.out.println(r); System.out.println("-----------------------------------\n"); } @@ -419,7 +393,6 @@ public class OaiPmhTest { @Test @Ignore public void testListRecords2() throws ParseException { - OaiPmhTest.recordList.setContributor(TGConstants.CONTRIBUTOR_LIST); OaiPmhTest.recordList.setCoverage(TGConstants.COVERAGE_LIST); OaiPmhTest.recordList.setCreators(TGConstants.CREATOR_LIST); @@ -445,24 +418,23 @@ public class OaiPmhTest { OaiPmhTest.recordList.setModifiedField(TGConstants.CREATED); OaiPmhTest.recordList.setIdentifierField(TGConstants.URI); OaiPmhTest.recordList.setSearchResponseSize("100"); - - JAXBElement<OAIPMHType> r = - this.request.getRequest("ListRecords", "", "oai_dc", "project:TGPR-ed7c757e-1ead-69d4-7c17-554a3581925c", "", "", ""); - JAXB.marshal(r, System.out); + // FIXME Left over from develop branch... needed? + // JAXBElement<OAIPMHType> r = + // this.request.getRequest("ListRecords", "", "oai_dc", + // "project:TGPR-ed7c757e-1ead-69d4-7c17-554a3581925c", "", "", ""); + String r = this.request.getRequest("ListRecords", "", "oai_dc", "", "", "", ""); + System.out.println(r); System.out.println("-----------------------------------\n"); } - - /** * @throws ParseException */ @Test @Ignore public void testListMetadataFormatsForIdentifier() throws ParseException { - JAXBElement<OAIPMHType> r = this.request.getRequest( - "ListMetadataFormats", "7t.0", "", "", "", "", ""); - JAXB.marshal(r, System.out); + String r = this.request.getRequest("ListMetadataFormats", "7t.0", "", "", "", "", ""); + System.out.println(r); System.out.println("-----------------------------------\n"); } @@ -472,9 +444,8 @@ public class OaiPmhTest { @Test @Ignore public void testListMetadataFormatsWithoutID() throws ParseException { - JAXBElement<OAIPMHType> r = this.request.getRequest( - "ListMetadataFormats", "", "", "", "", "", ""); - JAXB.marshal(r, System.out); + String r = this.request.getRequest("ListMetadataFormats", "", "", "", "", "", ""); + System.out.println(r); System.out.println("-----------------------------------\n"); } @@ -483,19 +454,32 @@ public class OaiPmhTest { */ @Test @Ignore - public void testListSets() throws ParseException { - - OaiPmhTest.setListTextGrid.setFormatField("format"); - OaiPmhTest.setListTextGrid.setFormatToFilter(TextGridMimetypes.EDITION); - OaiPmhTest.setListTextGrid.setIdentifierField("textgridUri"); - OaiPmhTest.setListTextGrid.setRepositoryObjectURIPrefix("textgrid:"); - JAXBElement<OAIPMHType> r = this.request.getRequest("ListSets", "", "", "", "", "", ""); - - JAXB.marshal(r, System.out); + public void testListSetsTG() throws ParseException { + OaiPmhTest.setListTextGrid.setFormatField("format"); + OaiPmhTest.setListTextGrid.setFormatToFilter(TextGridMimetypes.EDITION); + OaiPmhTest.setListTextGrid.setIdentifierField("textgridUri"); + OaiPmhTest.setListTextGrid.setRepositoryObjectURIPrefix("textgrid:"); + String r = this.request.getRequest("ListSets", "", "", "", "", "", ""); + System.out.println(r); System.out.println("-----------------------------------\n"); } + /** + * @throws ParseException + */ + public void testListSetsDH() throws ParseException { + OaiPmhTest.setListTextGrid.setFormatField("format"); + OaiPmhTest.setListTextGrid.setFormatToFilter(TextGridMimetypes.DARIAH_COLLECTION); + OaiPmhTest.setListTextGrid.setIdentifierField("textgridUri"); + OaiPmhTest.setListTextGrid.setRepositoryObjectURIPrefix("textgrid:"); + String r = this.request.getRequest("ListSets", "", "", "", "", "", ""); + System.out.println(r); + System.out.println("-----------------------------------\n"); + } + /** + * @throws ParseException + */ @Test @Ignore public void testEmptyRequest() throws ParseException { @@ -505,8 +489,8 @@ public class OaiPmhTest { OaiPmhTest.identifierList.setIdentifierField("textgridUri"); OaiPmhTest.identifierList.setRepositoryObjectURIPrefix("textgrid:"); OaiPmhTest.identifierList.setSearchResponseSize("100"); - JAXBElement<OAIPMHType> r = this.request.getRequest("", "", "", "", "", "", ""); - JAXB.marshal(r, System.out); + String r = this.request.getRequest("", "", "", "", "", "", ""); + System.out.println(r); System.out.println("-----------------------------------\n"); } diff --git a/oaipmh-webapp/.gitignore b/oaipmh-webapp/.gitignore index 10d81e8c69b7a6700576643dcd104b107a5a66df..d814cc021d52b3d8f53a33cd412248ef54f8e242 100644 --- a/oaipmh-webapp/.gitignore +++ b/oaipmh-webapp/.gitignore @@ -2,3 +2,4 @@ /.project /.settings/ /target/ +/bin/ diff --git a/oaipmh-webapp/pom.xml b/oaipmh-webapp/pom.xml index c24f2a73f4fdcd61f38776c4f10609b6ad1bfb15..86fcdedfa2d5a6419d0f2bda607a5670e2f022f1 100644 --- a/oaipmh-webapp/pom.xml +++ b/oaipmh-webapp/pom.xml @@ -5,7 +5,7 @@ <parent> <artifactId>oaipmh</artifactId> <groupId>info.textgrid.middleware</groupId> - <version>3.2.0-SNAPSHOT</version> + <version>3.3.0-SNAPSHOT</version> </parent> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh-webapp</artifactId> @@ -81,19 +81,19 @@ <build> <finalName>oaipmh</finalName> <plugins> + <!-- Do not deploy WAR and DEB files to the Nexus repository --> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.0</version> + <artifactId>maven-deploy-plugin</artifactId> + <version>${maven-deploy-plugin.version}</version> <configuration> - <source>${jdk.version}</source> - <target>${jdk.version}</target> + <skip>true</skip> </configuration> </plugin> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> - <version>9.4.12.v20180830</version> + <version>${jetty-maven-plugin.version}</version> <configuration> <scanIntervalSeconds>1</scanIntervalSeconds> <webApp> diff --git a/pom.xml b/pom.xml index ad5eff49b77e48accda0b6afeea20c56ad71e3b3..e27f7ed4838a81fcf8415300b46f49fa5f5901ae 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>info.textgrid.middleware</groupId> <artifactId>oaipmh</artifactId> - <version>3.2.0-SNAPSHOT</version> + <version>3.3.0-SNAPSHOT</version> <packaging>pom</packaging> <name>DARIAHDE :: OAI-PMH DataProvider</name> <properties> @@ -20,6 +20,12 @@ <junit.version>4.11</junit.version> <jdk.version>1.8</jdk.version> <maven-antrun-plugin.version>1.3</maven-antrun-plugin.version> + <jaxb2-maven-plugin.version>2.5.0</jaxb2-maven-plugin.version> + <maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version> + <maven-compiler-plugin.version>3.0</maven-compiler-plugin.version> + <jetty-maven-plugin.version>9.4.12.v20180830</jetty-maven-plugin.version> + <maven-eclipse-plugin.version>2.9</maven-eclipse-plugin.version> + <properties-maven-plugin.version>1.0-alpha-2</properties-maven-plugin.version> </properties> <url>https://projects.gwdg.de/projects/oai-pmh</url> <scm> @@ -48,7 +54,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>2.0.2</version> + <version>${maven-compiler-plugin.version}</version> <configuration> <source>${jdk.version}</source> <target>${jdk.version}</target> @@ -61,12 +67,17 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> - <version>2.9</version> + <version>${maven-eclipse-plugin.version}</version> <configuration> <downloadSources>true</downloadSources> <downloadJavadocs>true</downloadJavadocs> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>${maven-deploy-plugin.version}</version> + </plugin> </plugins> </build> <modules> @@ -74,26 +85,22 @@ <module>oaipmh-webapp</module> </modules> <repositories> - <repository> - <id>nexus.dariah</id> - <name>DARIAH Nexus Public Repository</name> - <url>https://ci.de.dariah.eu/nexus/content/groups/public</url> - <releases> - <enabled>true</enabled> - </releases> - <snapshots> - <enabled>true</enabled> - </snapshots> + <repository> + <id>maven-dariah-public</id> + <name>GWDG Nexus DARIAH-DE Repository</name> + <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> </repository> </repositories> <distributionManagement> <snapshotRepository> - <id>dariah.nexus.snapshots</id> - <url>https://ci.de.dariah.eu/nexus/content/repositories/snapshots</url> + <id>maven-dariah-public</id> + <name>GWDG Nexus DARIAH-DE Repository</name> + <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> </snapshotRepository> <repository> - <id>dariah.nexus.releases</id> - <url>https://ci.de.dariah.eu/nexus/content/repositories/releases</url> + <id>maven-dariah-public</id> + <name>GWDG Nexus DARIAH-DE Repository</name> + <url>https://nexus.gwdg.de/repository/maven-dariah-public/</url> </repository> </distributionManagement> </project>