Il seguente frammento di schema specifica il contenuto previsto contenuto in questa classe.
+ *
+ *
> nameOrNamespace;
+
+ /**
+ * Gets the value of the nameOrNamespace property.
+ *
+ *
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a set
method for the nameOrNamespace property.
+ *
+ *
+ * For example, to add a new item, do as follows:
+ *
+ * getNameOrNamespace().add(newItem);
+ *
+ *
+ *
+ *
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ public List> getNameOrNamespace() {
+ if (nameOrNamespace == null) {
+ nameOrNamespace = new ArrayList>();
+ }
+ return this.nameOrNamespace;
+ }
+
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DcSchemaBuilder.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DcSchemaBuilder.java
new file mode 100644
index 000000000000..fe7144bda854
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DcSchemaBuilder.java
@@ -0,0 +1,39 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.model;
+
+import javax.xml.bind.JAXBElement;
+
+/**
+ * @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com)
+ **/
+public class DcSchemaBuilder extends AbstractJaxbBuilder {
+
+ protected DcSchemaBuilder() {
+ super(DcSchema.class);
+ }
+
+ public static DcSchemaBuilder createBuilder() {
+ return new DcSchemaBuilder();
+ }
+
+ public DcSchemaBuilder withName(String name) {
+ this.addChildElement(name, objectFactory::createName);
+ return this;
+ }
+
+ public DcSchemaBuilder withNamespace(String namespace) {
+ this.addChildElement(namespace, objectFactory::createNamespace);
+ return this;
+ }
+
+ @Override
+ protected void addChildElement(JAXBElement v) {
+ getObejct().getNameOrNamespace().add(v);
+ }
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DcType.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DcType.java
new file mode 100644
index 000000000000..bff2fc77978a
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DcType.java
@@ -0,0 +1,86 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * Classe Java per anonymous complex type.
+ *
+ *
Il seguente frammento di schema specifica il contenuto previsto contenuto in questa classe.
+ *
+ *
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice maxOccurs="unbounded" minOccurs="0">
+ * <element ref="{}schema"/>
+ * <element ref="{}element"/>
+ * <element ref="{}qualifier"/>
+ * <element ref="{}scope_note"/>
+ * </choice>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "schemaOrElementOrQualifier"
+})
+@XmlRootElement(name = "dc-type")
+public class DcType {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "schema", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "element", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "qualifier", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "scope_note", type = JAXBElement.class, required = false)
+ })
+ protected List> schemaOrElementOrQualifier;
+
+ /**
+ * Gets the value of the schemaOrElementOrQualifier property.
+ *
+ *
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a set
method for the schemaOrElementOrQualifier property.
+ *
+ *
+ * For example, to add a new item, do as follows:
+ *
+ * getSchemaOrElementOrQualifier().add(newItem);
+ *
+ *
+ *
+ *
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ public List> getSchemaOrElementOrQualifier() {
+ if (schemaOrElementOrQualifier == null) {
+ schemaOrElementOrQualifier = new ArrayList>();
+ }
+ return this.schemaOrElementOrQualifier;
+ }
+
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DcTypeBuilder.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DcTypeBuilder.java
new file mode 100644
index 000000000000..47fd64763ead
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DcTypeBuilder.java
@@ -0,0 +1,49 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.model;
+
+import javax.xml.bind.JAXBElement;
+
+/**
+ * @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com)
+ **/
+public class DcTypeBuilder extends AbstractJaxbBuilder {
+
+ protected DcTypeBuilder() {
+ super(DcType.class);
+ }
+
+ public static DcTypeBuilder createBuilder() {
+ return new DcTypeBuilder();
+ }
+
+ public DcTypeBuilder withSchema(String schema) {
+ addChildElement(schema, objectFactory::createSchema);
+ return this;
+ }
+
+ public DcTypeBuilder withElement(String element) {
+ addChildElement(element, objectFactory::createElement);
+ return this;
+ }
+
+ public DcTypeBuilder withQualifier(String qualifier) {
+ addChildElement(qualifier, objectFactory::createQualifier);
+ return this;
+ }
+
+ public DcTypeBuilder withScopeNote(String scopeNote) {
+ addChildElement(scopeNote, objectFactory::createScopeNote);
+ return this;
+ }
+
+ @Override
+ protected void addChildElement(JAXBElement v) {
+ getObejct().getSchemaOrElementOrQualifier().add(v);
+ }
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DspaceDcTypes.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DspaceDcTypes.java
new file mode 100644
index 000000000000..4cba081a8a30
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DspaceDcTypes.java
@@ -0,0 +1,82 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * Classe Java per anonymous complex type.
+ *
+ *
Il seguente frammento di schema specifica il contenuto previsto contenuto in questa classe.
+ *
+ *
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice maxOccurs="unbounded" minOccurs="0">
+ * <element ref="{}dspace-header"/>
+ * <element ref="{}dc-schema"/>
+ * <element ref="{}dc-type"/>
+ * </choice>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "dspaceHeaderOrDcSchemaOrDcType"
+})
+@XmlRootElement(name = "dspace-dc-types")
+public class DspaceDcTypes {
+
+ @XmlElements({
+ @XmlElement(name = "dspace-header", type = DspaceHeader.class),
+ @XmlElement(name = "dc-schema", type = DcSchema.class),
+ @XmlElement(name = "dc-type", type = DcType.class)
+ })
+ protected List dspaceHeaderOrDcSchemaOrDcType;
+
+ /**
+ * Gets the value of the dspaceHeaderOrDcSchemaOrDcType property.
+ *
+ *
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a set
method for the dspaceHeaderOrDcSchemaOrDcType property.
+ *
+ *
+ * For example, to add a new item, do as follows:
+ *
+ * getDspaceHeaderOrDcSchemaOrDcType().add(newItem);
+ *
+ *
+ *
+ *
+ * Objects of the following type(s) are allowed in the list
+ * {@link DspaceHeader }
+ * {@link DcSchema }
+ * {@link DcType }
+ */
+ public List getDspaceHeaderOrDcSchemaOrDcType() {
+ if (dspaceHeaderOrDcSchemaOrDcType == null) {
+ dspaceHeaderOrDcSchemaOrDcType = new ArrayList();
+ }
+ return this.dspaceHeaderOrDcSchemaOrDcType;
+ }
+
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DspaceDcTypesBuilder.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DspaceDcTypesBuilder.java
new file mode 100644
index 000000000000..1e4cdb83393c
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DspaceDcTypesBuilder.java
@@ -0,0 +1,59 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.model;
+
+import java.util.Collection;
+
+/**
+ * @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com)
+ **/
+public class DspaceDcTypesBuilder {
+
+ private DspaceDcTypes dcTypes;
+
+ private final ObjectFactory objectFactory = new ObjectFactory();
+
+ private DspaceDcTypes getDcTypes() {
+ if (dcTypes == null) {
+ dcTypes = new DspaceDcTypes();
+ }
+ return dcTypes;
+ }
+
+ private DspaceDcTypesBuilder() {
+ }
+
+ public static DspaceDcTypesBuilder createBuilder() {
+ return new DspaceDcTypesBuilder();
+ }
+
+ public DspaceDcTypesBuilder witheader(DspaceHeader header) {
+ this.getDcTypes().getDspaceHeaderOrDcSchemaOrDcType().add(header);
+ return this;
+ }
+
+ public DspaceDcTypesBuilder withSchema(DcSchema schema) {
+ this.getDcTypes().getDspaceHeaderOrDcSchemaOrDcType().add(schema);
+ return this;
+ }
+
+ public DspaceDcTypesBuilder withDcType(DcType dcType) {
+ this.getDcTypes().getDspaceHeaderOrDcSchemaOrDcType().add(dcType);
+ return this;
+ }
+
+ public DspaceDcTypesBuilder withDcTypes(Collection dcTypes) {
+ this.getDcTypes().getDspaceHeaderOrDcSchemaOrDcType().addAll(dcTypes);
+ return this;
+ }
+
+ public DspaceDcTypes build() {
+ return dcTypes;
+ }
+
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DspaceHeader.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DspaceHeader.java
new file mode 100644
index 000000000000..151c8b28292d
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DspaceHeader.java
@@ -0,0 +1,92 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.model;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlElementRefs;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * Classe Java per anonymous complex type.
+ *
+ *
Il seguente frammento di schema specifica il contenuto previsto contenuto in questa classe.
+ *
+ *
+ * <complexType>
+ * <complexContent>
+ * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * <choice maxOccurs="unbounded" minOccurs="0">
+ * <element ref="{}title"/>
+ * <element ref="{}contributor.author"/>
+ * <element ref="{}contributor.editor"/>
+ * <element ref="{}date.created"/>
+ * <element ref="{}description"/>
+ * <element ref="{}description.version"/>
+ * </choice>
+ * </restriction>
+ * </complexContent>
+ * </complexType>
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "titleOrContributorAuthorOrContributorEditor"
+})
+@XmlRootElement(name = "dspace-header")
+public class DspaceHeader {
+
+ @XmlElementRefs({
+ @XmlElementRef(name = "title", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "contributor.author", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "contributor.editor", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "date.created", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "description", type = JAXBElement.class, required = false),
+ @XmlElementRef(name = "description.version", type = JAXBElement.class, required = false)
+ })
+ protected List> titleOrContributorAuthorOrContributorEditor;
+
+ /**
+ * Gets the value of the titleOrContributorAuthorOrContributorEditor property.
+ *
+ *
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a set
method for the titleOrContributorAuthorOrContributorEditor property.
+ *
+ *
+ * For example, to add a new item, do as follows:
+ *
+ * getTitleOrContributorAuthorOrContributorEditor().add(newItem);
+ *
+ *
+ *
+ *
+ * Objects of the following type(s) are allowed in the list
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ * {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ public List> getTitleOrContributorAuthorOrContributorEditor() {
+ if (titleOrContributorAuthorOrContributorEditor == null) {
+ titleOrContributorAuthorOrContributorEditor = new ArrayList>();
+ }
+ return this.titleOrContributorAuthorOrContributorEditor;
+ }
+
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DspaceHeaderBuilder.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DspaceHeaderBuilder.java
new file mode 100644
index 000000000000..fb4028a2057b
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/DspaceHeaderBuilder.java
@@ -0,0 +1,59 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.model;
+
+import javax.xml.bind.JAXBElement;
+
+/**
+ * @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com)
+ **/
+public class DspaceHeaderBuilder extends AbstractJaxbBuilder {
+
+ protected DspaceHeaderBuilder() {
+ super(DspaceHeader.class);
+ }
+
+ public static DspaceHeaderBuilder createBuilder() {
+ return new DspaceHeaderBuilder();
+ }
+
+ public DspaceHeaderBuilder withTitle(String title) {
+ addChildElement(title, objectFactory::createTitle);
+ return this;
+ }
+
+ public DspaceHeaderBuilder withContributorAuthor(String contributorAuthor) {
+ addChildElement(contributorAuthor, objectFactory::createContributorAuthor);
+ return this;
+ }
+
+ public DspaceHeaderBuilder withContributorEditor(String contributorEditor) {
+ addChildElement(contributorEditor, objectFactory::createContributorEditor);
+ return this;
+ }
+
+ public DspaceHeaderBuilder withDateCreated(String dateCreated) {
+ addChildElement(dateCreated, objectFactory::createDateCreated);
+ return this;
+ }
+
+ public DspaceHeaderBuilder withDescription(String description) {
+ addChildElement(description, objectFactory::createDescription);
+ return this;
+ }
+
+ public DspaceHeaderBuilder withDescriptionVersion(String descriptionVersion) {
+ addChildElement(descriptionVersion, objectFactory::createDescriptionVersion);
+ return this;
+ }
+
+ @Override
+ protected void addChildElement(JAXBElement v) {
+ getObejct().getTitleOrContributorAuthorOrContributorEditor().add(v);
+ }
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/model/ObjectFactory.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/ObjectFactory.java
new file mode 100644
index 000000000000..085e8af5f81b
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/model/ObjectFactory.java
@@ -0,0 +1,212 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.model;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.annotation.XmlElementDecl;
+import javax.xml.bind.annotation.XmlRegistry;
+import javax.xml.namespace.QName;
+
+
+/**
+ * This object contains factory methods for each
+ * Java content interface and Java element interface
+ * generated in the org.dspace.app.metadata.export.model package.
+ * An ObjectFactory allows you to programatically
+ * construct new instances of the Java representation
+ * for XML content. The Java representation of XML
+ * content can consist of schema derived interfaces
+ * and classes representing the binding of schema
+ * type definitions, element declarations and model
+ * groups. Factory methods for each of these are
+ * provided in this class.
+ */
+@XmlRegistry
+public class ObjectFactory {
+
+ private final static QName _Title_QNAME = new QName("", "title");
+ private final static QName _ContributorAuthor_QNAME = new QName("", "contributor.author");
+ private final static QName _ContributorEditor_QNAME = new QName("", "contributor.editor");
+ private final static QName _DateCreated_QNAME = new QName("", "date.created");
+ private final static QName _Description_QNAME = new QName("", "description");
+ private final static QName _DescriptionVersion_QNAME = new QName("", "description.version");
+ private final static QName _Name_QNAME = new QName("", "name");
+ private final static QName _Namespace_QNAME = new QName("", "namespace");
+ private final static QName _Schema_QNAME = new QName("", "schema");
+ private final static QName _Element_QNAME = new QName("", "element");
+ private final static QName _Qualifier_QNAME = new QName("", "qualifier");
+ private final static QName _ScopeNote_QNAME = new QName("", "scope_note");
+
+ /**
+ * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org
+ * .dspace.app.metadata.export.model
+ */
+ public ObjectFactory() {
+ }
+
+ /**
+ * Create an instance of {@link DspaceDcTypes }
+ */
+ public DspaceDcTypes createDspaceDcTypes() {
+ return new DspaceDcTypes();
+ }
+
+ /**
+ * Create an instance of {@link DspaceHeader }
+ */
+ public DspaceHeader createDspaceHeader() {
+ return new DspaceHeader();
+ }
+
+ /**
+ * Create an instance of {@link DcSchema }
+ */
+ public DcSchema createDcSchema() {
+ return new DcSchema();
+ }
+
+ /**
+ * Create an instance of {@link DcType }
+ */
+ public DcType createDcType() {
+ return new DcType();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ * @param value Java instance representing xml element's value.
+ * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ @XmlElementDecl(namespace = "", name = "title")
+ public JAXBElement createTitle(String value) {
+ return new JAXBElement(_Title_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ * @param value Java instance representing xml element's value.
+ * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ @XmlElementDecl(namespace = "", name = "contributor.author")
+ public JAXBElement createContributorAuthor(String value) {
+ return new JAXBElement(_ContributorAuthor_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ * @param value Java instance representing xml element's value.
+ * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ @XmlElementDecl(namespace = "", name = "contributor.editor")
+ public JAXBElement createContributorEditor(String value) {
+ return new JAXBElement(_ContributorEditor_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ * @param value Java instance representing xml element's value.
+ * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ @XmlElementDecl(namespace = "", name = "date.created")
+ public JAXBElement createDateCreated(String value) {
+ return new JAXBElement(_DateCreated_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ * @param value Java instance representing xml element's value.
+ * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ @XmlElementDecl(namespace = "", name = "description")
+ public JAXBElement createDescription(String value) {
+ return new JAXBElement(_Description_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ * @param value Java instance representing xml element's value.
+ * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ @XmlElementDecl(namespace = "", name = "description.version")
+ public JAXBElement createDescriptionVersion(String value) {
+ return new JAXBElement(_DescriptionVersion_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ * @param value Java instance representing xml element's value.
+ * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ @XmlElementDecl(namespace = "", name = "name")
+ public JAXBElement createName(String value) {
+ return new JAXBElement(_Name_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ * @param value Java instance representing xml element's value.
+ * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ @XmlElementDecl(namespace = "", name = "namespace")
+ public JAXBElement createNamespace(String value) {
+ return new JAXBElement(_Namespace_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ * @param value Java instance representing xml element's value.
+ * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ @XmlElementDecl(namespace = "", name = "schema")
+ public JAXBElement createSchema(String value) {
+ return new JAXBElement(_Schema_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ * @param value Java instance representing xml element's value.
+ * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ @XmlElementDecl(namespace = "", name = "element")
+ public JAXBElement createElement(String value) {
+ return new JAXBElement(_Element_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ * @param value Java instance representing xml element's value.
+ * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ @XmlElementDecl(namespace = "", name = "qualifier")
+ public JAXBElement createQualifier(String value) {
+ return new JAXBElement(_Qualifier_QNAME, String.class, null, value);
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ *
+ * @param value Java instance representing xml element's value.
+ * @return the new instance of {@link JAXBElement }{@code <}{@link String }{@code >}
+ */
+ @XmlElementDecl(namespace = "", name = "scope_note")
+ public JAXBElement createScopeNote(String value) {
+ return new JAXBElement(_ScopeNote_QNAME, String.class, null, value);
+ }
+
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataExportServiceFactory.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataExportServiceFactory.java
new file mode 100644
index 000000000000..3553cbcba2fd
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataExportServiceFactory.java
@@ -0,0 +1,28 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.service;
+
+import org.dspace.services.factory.DSpaceServicesFactory;
+
+/**
+ * Factory for the export services related to metadata-schema and metadata-fields.
+ *
+ * @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com)
+ **/
+public abstract class MetadataExportServiceFactory {
+
+ public static MetadataExportServiceFactory getInstance() {
+ return DSpaceServicesFactory
+ .getInstance().getServiceManager()
+ .getServiceByName("metadataExportServiceFactory", MetadataExportServiceFactory.class);
+ }
+
+ public abstract MetadataSchemaExportService getMetadataSchemaExportService();
+ public abstract MetadataFieldExportService getMetadataFieldExportService();
+
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataExportServiceFactoryImpl.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataExportServiceFactoryImpl.java
new file mode 100644
index 000000000000..a69d5dfd0fde
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataExportServiceFactoryImpl.java
@@ -0,0 +1,31 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com)
+ **/
+public class MetadataExportServiceFactoryImpl extends MetadataExportServiceFactory {
+
+ @Autowired
+ private MetadataSchemaExportService metadataSchemaExportService;
+ @Autowired
+ private MetadataFieldExportService metadataFieldExportService;
+
+ @Override
+ public MetadataSchemaExportService getMetadataSchemaExportService() {
+ return metadataSchemaExportService;
+ }
+
+ @Override
+ public MetadataFieldExportService getMetadataFieldExportService() {
+ return metadataFieldExportService;
+ }
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataFieldExportService.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataFieldExportService.java
new file mode 100644
index 000000000000..ace312885230
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataFieldExportService.java
@@ -0,0 +1,35 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.service;
+
+import java.sql.SQLException;
+import java.util.List;
+
+import org.dspace.app.metadata.export.model.DcType;
+import org.dspace.content.MetadataField;
+import org.dspace.content.MetadataSchema;
+import org.dspace.core.Context;
+
+/**
+ * Exports {@code MetadataField} into {@code DcType}
+ *
+ * @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com)
+ **/
+public interface MetadataFieldExportService {
+
+ /**
+ * Creates a one {@link DCType} for each {@link MetadataField}
+ * in the given {@link MetadataSchema}, and returns them in a list
+ *
+ * @param context
+ * @param metadataSchema
+ * @return
+ * @throws SQLException
+ */
+ List exportMetadataFieldsBy(Context context, MetadataSchema metadataSchema) throws SQLException;
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataFieldExportServiceImpl.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataFieldExportServiceImpl.java
new file mode 100644
index 000000000000..1ace35f4e45d
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataFieldExportServiceImpl.java
@@ -0,0 +1,49 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.service;
+
+import java.sql.SQLException;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.dspace.app.metadata.export.model.DcType;
+import org.dspace.app.metadata.export.model.DcTypeBuilder;
+import org.dspace.content.MetadataField;
+import org.dspace.content.MetadataSchema;
+import org.dspace.content.factory.ContentServiceFactory;
+import org.dspace.content.service.MetadataFieldService;
+import org.dspace.core.Context;
+
+/**
+ * @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com)
+ **/
+public class MetadataFieldExportServiceImpl implements MetadataFieldExportService {
+
+ private MetadataFieldService metadataFieldService =
+ ContentServiceFactory.getInstance().getMetadataFieldService();
+
+ public List exportMetadataFieldsBy(Context context, MetadataSchema metadataSchema) throws SQLException {
+ return metadataFieldService
+ .findAllInSchema(context, metadataSchema)
+ .stream()
+ .map(this::toDcType)
+ .collect(Collectors.toList());
+ }
+
+ private DcType toDcType(MetadataField metadataField) {
+ return DcTypeBuilder
+ .createBuilder()
+ .withSchema(metadataField.getMetadataSchema().getName())
+ .withElement(metadataField.getElement())
+ .withQualifier(metadataField.getQualifier())
+ .withScopeNote(metadataField.getScopeNote())
+ .build();
+ }
+
+}
+
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataSchemaExportService.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataSchemaExportService.java
new file mode 100644
index 000000000000..cd1f35e2ef9b
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataSchemaExportService.java
@@ -0,0 +1,68 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.service;
+
+import java.io.File;
+import java.sql.SQLException;
+
+import org.dspace.app.metadata.export.DspaceExportMetadataSchemaException;
+import org.dspace.app.metadata.export.model.DspaceDcTypes;
+import org.dspace.content.MetadataSchema;
+import org.dspace.core.Context;
+
+/**
+ * @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com)
+ **/
+public interface MetadataSchemaExportService {
+
+ /**
+ * Exports the given {@code schemaId} into a {@link DspaceDcTypes} entity
+ *
+ * @param context
+ * @param schemaId
+ * @return
+ * @throws SQLException
+ */
+ DspaceDcTypes exportMetadataSchema(Context context, int schemaId) throws SQLException;
+
+ /**
+ * Exports the given {@code metadataSchema} into a {@link DspaceDcTypes} entity
+ *
+ * @param context
+ * @param metadataSchema
+ * @return
+ * @throws SQLException
+ */
+ DspaceDcTypes exportMetadataSchema(Context context, MetadataSchema metadataSchema) throws SQLException;
+
+ /**
+ * Exports the given {@code metadataSchema} to a temporary {@code File},
+ * that will respect the {@code registry} xml format of dspace
+ *
+ * @param context
+ * @param metadataSchema
+ * @return
+ * @throws DspaceExportMetadataSchemaException
+ */
+ File exportMetadataSchemaToFile(Context context, MetadataSchema metadataSchema)
+ throws DspaceExportMetadataSchemaException;
+
+ /**
+ * Exports the given {@code metadataSchema} to a target {@code File},
+ * that will respect the {@code registry} xml format of dspace
+ *
+ * @param context
+ * @param metadataSchema
+ * @param file
+ * @return
+ * @throws DspaceExportMetadataSchemaException
+ */
+ File exportMetadataSchemaToFile(Context context, MetadataSchema metadataSchema, File file)
+ throws DspaceExportMetadataSchemaException;
+
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataSchemaExportServiceImpl.java b/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataSchemaExportServiceImpl.java
new file mode 100644
index 000000000000..eea9a09f7970
--- /dev/null
+++ b/dspace-api/src/main/java/org/dspace/app/metadata/export/service/MetadataSchemaExportServiceImpl.java
@@ -0,0 +1,107 @@
+/**
+ * The contents of this file are subject to the license and copyright
+ * detailed in the LICENSE and NOTICE files at the root of the source
+ * tree and available online at
+ *
+ * http://www.dspace.org/license/
+ */
+package org.dspace.app.metadata.export.service;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+
+import org.dspace.app.metadata.export.DspaceExportMetadataSchemaException;
+import org.dspace.app.metadata.export.model.DcSchema;
+import org.dspace.app.metadata.export.model.DcSchemaBuilder;
+import org.dspace.app.metadata.export.model.DspaceDcTypes;
+import org.dspace.app.metadata.export.model.DspaceDcTypesBuilder;
+import org.dspace.content.MetadataSchema;
+import org.dspace.content.factory.ContentServiceFactory;
+import org.dspace.content.service.MetadataSchemaService;
+import org.dspace.core.Context;
+
+/**
+ * This service can be used to export a target schema into a registry-file
+ *
+ * @author Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com)
+ **/
+public class MetadataSchemaExportServiceImpl implements MetadataSchemaExportService {
+
+ private MetadataSchemaService metadataSchemaService =
+ ContentServiceFactory.getInstance().getMetadataSchemaService();
+
+ @Override
+ public DspaceDcTypes exportMetadataSchema(Context context, int schemaId) throws SQLException {
+ return this.exportMetadataSchema(context, metadataSchemaService.find(context, schemaId));
+ }
+
+ @Override
+ public DspaceDcTypes exportMetadataSchema(Context context, MetadataSchema metadataSchema) throws SQLException {
+ return DspaceDcTypesBuilder
+ .createBuilder()
+ .withSchema(this.mapToDcSchema(metadataSchema))
+ .withDcTypes(
+ MetadataExportServiceFactory.getInstance()
+ .getMetadataFieldExportService()
+ .exportMetadataFieldsBy(context, metadataSchema)
+ )
+ .build();
+ }
+
+ @Override
+ public File exportMetadataSchemaToFile(Context context, MetadataSchema metadataSchema)
+ throws DspaceExportMetadataSchemaException {
+ File tempFile;
+ try {
+ tempFile =
+ File.createTempFile(
+ metadataSchema.getName() + "-" + metadataSchema.getID(),
+ ".xml"
+ );
+ tempFile.deleteOnExit();
+ return this.exportMetadataSchemaToFile(context, metadataSchema, tempFile);
+ } catch (IOException e) {
+ throw new DspaceExportMetadataSchemaException(
+ "Probelm occured during while exporting to temporary file!",
+ e
+ );
+ }
+ }
+
+ @Override
+ public File exportMetadataSchemaToFile(Context context, MetadataSchema metadataSchema, File file)
+ throws DspaceExportMetadataSchemaException {
+ try {
+ DspaceDcTypes dspaceDcTypes = this.exportMetadataSchema(context, metadataSchema);
+
+ JAXBContext jaxb = JAXBContext.newInstance(DspaceDcTypes.class);
+ Marshaller jaxbMarshaller = jaxb.createMarshaller();
+ jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+ jaxbMarshaller.marshal(dspaceDcTypes, file);
+ } catch (SQLException e) {
+ throw new DspaceExportMetadataSchemaException(
+ "Problem occured while retrieving data from DB!",
+ e
+ );
+ } catch (JAXBException e) {
+ throw new DspaceExportMetadataSchemaException(
+ "Problem occured during the export to XML file!",
+ e
+ );
+ }
+ return file;
+ }
+
+ private DcSchema mapToDcSchema(MetadataSchema metadataSchema) {
+ return DcSchemaBuilder
+ .createBuilder()
+ .withName(metadataSchema.getName())
+ .withNamespace(metadataSchema.getNamespace())
+ .build();
+ }
+
+}
diff --git a/dspace-api/src/main/java/org/dspace/app/nbevent/service/impl/NBEventServiceImpl.java b/dspace-api/src/main/java/org/dspace/app/nbevent/service/impl/NBEventServiceImpl.java
index 4df11b054e67..e07fb16c72ca 100644
--- a/dspace-api/src/main/java/org/dspace/app/nbevent/service/impl/NBEventServiceImpl.java
+++ b/dspace-api/src/main/java/org/dspace/app/nbevent/service/impl/NBEventServiceImpl.java
@@ -8,14 +8,17 @@
package org.dspace.app.nbevent.service.impl;
import java.io.IOException;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
+import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
+import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.solr.client.solrj.SolrClient;
@@ -33,6 +36,7 @@
import org.dspace.app.nbevent.NBTopic;
import org.dspace.app.nbevent.dao.impl.NBEventsDaoImpl;
import org.dspace.app.nbevent.service.NBEventService;
+import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Item;
import org.dspace.content.NBEvent;
import org.dspace.content.service.ItemService;
@@ -316,18 +320,38 @@ private String getResourceUUID(Context context, String originalId) throws Except
String id = getHandleFromOriginalId(originalId);
if (id != null) {
Item item = (Item) handleService.resolveToObject(context, id);
+
if (item != null) {
final String itemUuid = item.getID().toString();
context.uncacheEntity(item);
return itemUuid;
} else {
- return null;
+ item = fromLegacyIdentifier(context, originalId);
+ return item == null ? null : item.getID().toString();
}
} else {
throw new RuntimeException("Malformed originalId " + originalId);
}
}
+ private Item fromLegacyIdentifier(Context context, String legacyIdentifier) {
+ if (StringUtils.isBlank(legacyIdentifier)) {
+ return null;
+ }
+ try {
+ Iterator-
+ iterator = itemService.findUnfilteredByMetadataField(
+ context, "dspace", "legacy", "oai-identifier",
+ legacyIdentifier);
+ if (!iterator.hasNext()) {
+ return null;
+ }
+ return iterator.next();
+ } catch (AuthorizeException | SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
// oai:www.openstarts.units.it:10077/21486
private String getHandleFromOriginalId(String originalId) {
Integer startPosition = originalId.lastIndexOf(':');
diff --git a/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItemEmailNotifier.java b/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItemEmailNotifier.java
index 384f33decaf2..6499c45a7830 100644
--- a/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItemEmailNotifier.java
+++ b/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItemEmailNotifier.java
@@ -11,55 +11,59 @@
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
+import javax.annotation.ManagedBean;
+import javax.inject.Inject;
+import javax.inject.Singleton;
import javax.mail.MessagingException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.dspace.app.requestitem.factory.RequestItemServiceFactory;
import org.dspace.app.requestitem.service.RequestItemService;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Bitstream;
import org.dspace.content.Bundle;
import org.dspace.content.Item;
-import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.BitstreamService;
import org.dspace.core.Context;
import org.dspace.core.Email;
import org.dspace.core.I18nUtil;
import org.dspace.core.LogHelper;
import org.dspace.eperson.EPerson;
-import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService;
import org.dspace.services.ConfigurationService;
-import org.dspace.services.factory.DSpaceServicesFactory;
/**
* Send item requests and responses by email.
*
+ *
The "strategy" by which approvers are chosen is in an implementation of
+ * {@link RequestItemAuthorExtractor} which is injected by the name
+ * {@code requestItemAuthorExtractor}. See the DI configuration documents.
+ *
* @author Mark H. Wood
*/
+@Singleton
+@ManagedBean
public class RequestItemEmailNotifier {
private static final Logger LOG = LogManager.getLogger();
- private static final BitstreamService bitstreamService
- = ContentServiceFactory.getInstance().getBitstreamService();
+ @Inject
+ protected BitstreamService bitstreamService;
- private static final ConfigurationService configurationService
- = DSpaceServicesFactory.getInstance().getConfigurationService();
+ @Inject
+ protected ConfigurationService configurationService;
- private static final HandleService handleService
- = HandleServiceFactory.getInstance().getHandleService();
+ @Inject
+ protected HandleService handleService;
- private static final RequestItemService requestItemService
- = RequestItemServiceFactory.getInstance().getRequestItemService();
+ @Inject
+ protected RequestItemService requestItemService;
- private static final RequestItemAuthorExtractor requestItemAuthorExtractor
- = DSpaceServicesFactory.getInstance()
- .getServiceManager()
- .getServiceByName("requestItemAuthorExtractor",
- RequestItemAuthorExtractor.class);
+ protected final RequestItemAuthorExtractor requestItemAuthorExtractor;
- private RequestItemEmailNotifier() {}
+ @Inject
+ public RequestItemEmailNotifier(RequestItemAuthorExtractor requestItemAuthorExtractor) {
+ this.requestItemAuthorExtractor = requestItemAuthorExtractor;
+ }
/**
* Send the request to the approver(s).
@@ -70,7 +74,7 @@ private RequestItemEmailNotifier() {}
* @throws IOException passed through.
* @throws SQLException if the message was not sent.
*/
- static public void sendRequest(Context context, RequestItem ri, String responseLink)
+ public void sendRequest(Context context, RequestItem ri, String responseLink)
throws IOException, SQLException {
// Who is making this request?
List authors = requestItemAuthorExtractor
@@ -147,12 +151,38 @@ static public void sendRequest(Context context, RequestItem ri, String responseL
* @param message email body (may be empty).
* @throws IOException if sending failed.
*/
- static public void sendResponse(Context context, RequestItem ri, String subject,
+ public void sendResponse(Context context, RequestItem ri, String subject,
String message)
throws IOException {
+ // Who granted this request?
+ List grantors;
+ try {
+ grantors = requestItemAuthorExtractor.getRequestItemAuthor(context, ri.getItem());
+ } catch (SQLException e) {
+ LOG.warn("Failed to get grantor's name and address: {}", e.getMessage());
+ grantors = List.of();
+ }
+
+ String grantorName;
+ String grantorAddress;
+ if (grantors.isEmpty()) {
+ grantorName = configurationService.getProperty("mail.admin.name");
+ grantorAddress = configurationService.getProperty("mail.admin");
+ } else {
+ RequestItemAuthor grantor = grantors.get(0); // XXX Cannot know which one
+ grantorName = grantor.getFullName();
+ grantorAddress = grantor.getEmail();
+ }
+
// Build an email back to the requester.
- Email email = new Email();
- email.setContent("body", message);
+ Email email = Email.getEmail(I18nUtil.getEmailFilename(context.getCurrentLocale(),
+ ri.isAccept_request() ? "request_item.granted" : "request_item.rejected"));
+ email.addArgument(ri.getReqName()); // {0} requestor's name
+ email.addArgument(handleService.getCanonicalForm(ri.getItem().getHandle())); // {1} URL of the requested Item
+ email.addArgument(ri.getItem().getName()); // {2} title of the requested Item
+ email.addArgument(grantorName); // {3} name of the grantor
+ email.addArgument(grantorAddress); // {4} email of the grantor
+ email.addArgument(message); // {5} grantor's optional message
email.setSubject(subject);
email.addRecipient(ri.getReqEmail());
// Attach bitstreams.
@@ -167,17 +197,25 @@ static public void sendResponse(Context context, RequestItem ri, String subject,
if (!bitstream.getFormat(context).isInternal() &&
requestItemService.isRestricted(context,
bitstream)) {
- email.addAttachment(bitstreamService.retrieve(context,
- bitstream), bitstream.getName(),
+ // #8636 Anyone receiving the email can respond to the
+ // request without authenticating into DSpace
+ context.turnOffAuthorisationSystem();
+ email.addAttachment(
+ bitstreamService.retrieve(context, bitstream),
+ bitstream.getName(),
bitstream.getFormat(context).getMIMEType());
+ context.restoreAuthSystemState();
}
}
}
} else {
Bitstream bitstream = ri.getBitstream();
+ // #8636 Anyone receiving the email can respond to the request without authenticating into DSpace
+ context.turnOffAuthorisationSystem();
email.addAttachment(bitstreamService.retrieve(context, bitstream),
bitstream.getName(),
bitstream.getFormat(context).getMIMEType());
+ context.restoreAuthSystemState();
}
email.send();
} else {
@@ -207,7 +245,7 @@ static public void sendResponse(Context context, RequestItem ri, String subject,
* @throws IOException if the message body cannot be loaded or the message
* cannot be sent.
*/
- static public void requestOpenAccess(Context context, RequestItem ri)
+ public void requestOpenAccess(Context context, RequestItem ri)
throws IOException {
Email message = Email.getEmail(I18nUtil.getEmailFilename(context.getCurrentLocale(),
"request_item.admin"));
diff --git a/dspace-api/src/main/java/org/dspace/app/requestitem/package-info.java b/dspace-api/src/main/java/org/dspace/app/requestitem/package-info.java
index 5886f16fde1a..fa7c15b23060 100644
--- a/dspace-api/src/main/java/org/dspace/app/requestitem/package-info.java
+++ b/dspace-api/src/main/java/org/dspace/app/requestitem/package-info.java
@@ -12,10 +12,15 @@
* e-mailed to a responsible party for consideration and action. Find details
* in the user documentation under the rubric "Request a Copy".
*
- * This package includes several "strategy" classes which discover responsible
- * parties in various ways. See {@link RequestItemSubmitterStrategy} and the
- * classes which extend it. A strategy class must be configured and identified
- * as {@link RequestItemAuthorExtractor} for injection into code which requires
- * Request a Copy services.
+ *
Mailing is handled by {@link RequestItemEmailNotifier}. Responsible
+ * parties are represented by {@link RequestItemAuthor}
+ *
+ *
This package includes several "strategy" classes which discover
+ * responsible parties in various ways. See
+ * {@link RequestItemSubmitterStrategy} and the classes which extend it, and
+ * others which implement {@link RequestItemAuthorExtractor}. A strategy class
+ * must be configured and identified as {@link requestItemAuthorExtractor}
+ * (note capitalization ) for injection into code which requires Request
+ * a Copy services.
*/
package org.dspace.app.requestitem;
diff --git a/dspace-api/src/main/java/org/dspace/app/sitemap/GenerateSitemaps.java b/dspace-api/src/main/java/org/dspace/app/sitemap/GenerateSitemaps.java
index 6188272aca47..90962d12aa75 100644
--- a/dspace-api/src/main/java/org/dspace/app/sitemap/GenerateSitemaps.java
+++ b/dspace-api/src/main/java/org/dspace/app/sitemap/GenerateSitemaps.java
@@ -7,20 +7,11 @@
*/
package org.dspace.app.sitemap;
-import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLEncoder;
import java.sql.SQLException;
import java.util.Date;
-import java.util.Iterator;
import java.util.List;
-import java.util.Optional;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
@@ -30,13 +21,8 @@
import org.apache.commons.cli.ParseException;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger;
-import org.dspace.app.customurl.CustomUrlService;
-import org.dspace.content.Collection;
-import org.dspace.content.Community;
-import org.dspace.content.Item;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.CollectionService;
import org.dspace.content.service.CommunityService;
@@ -45,12 +31,12 @@
import org.dspace.core.LogHelper;
import org.dspace.discovery.DiscoverQuery;
import org.dspace.discovery.DiscoverResult;
+import org.dspace.discovery.IndexableObject;
import org.dspace.discovery.SearchService;
import org.dspace.discovery.SearchServiceException;
import org.dspace.discovery.SearchUtils;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
-import org.dspace.utils.DSpace;
/**
* Command-line utility for generating HTML and Sitemaps.org protocol Sitemaps.
@@ -71,8 +57,7 @@ public class GenerateSitemaps {
private static final ConfigurationService configurationService =
DSpaceServicesFactory.getInstance().getConfigurationService();
private static final SearchService searchService = SearchUtils.getSearchService();
-
- private static final CustomUrlService customUrlService = new DSpace().getSingletonService(CustomUrlService.class);
+ private static final int PAGE_SIZE = 100;
/**
* Default constructor
@@ -92,11 +77,6 @@ public static void main(String[] args) throws Exception {
"do not generate sitemaps.org protocol sitemap");
options.addOption("b", "no_htmlmap", false,
"do not generate a basic HTML sitemap");
- options.addOption("a", "ping_all", false,
- "ping configured search engines");
- options
- .addOption("p", "ping", true,
- "ping specified search engine URL");
options
.addOption("d", "delete", false,
"delete sitemaps dir and its contents");
@@ -121,14 +101,13 @@ public static void main(String[] args) throws Exception {
}
/*
- * Sanity check -- if no sitemap generation or pinging to do, or deletion, print usage
+ * Sanity check -- if no sitemap generation or deletion, print usage
*/
if (line.getArgs().length != 0 || line.hasOption('d') || line.hasOption('b')
&& line.hasOption('s') && !line.hasOption('g')
- && !line.hasOption('m') && !line.hasOption('y')
- && !line.hasOption('p')) {
+ && !line.hasOption('m') && !line.hasOption('y')) {
System.err
- .println("Nothing to do (no sitemap to generate, no search engines to ping)");
+ .println("Nothing to do (no sitemap to generate)");
hf.printHelp(usage, options);
System.exit(1);
}
@@ -142,20 +121,6 @@ public static void main(String[] args) throws Exception {
deleteSitemaps();
}
- if (line.hasOption('a')) {
- pingConfiguredSearchEngines();
- }
-
- if (line.hasOption('p')) {
- try {
- pingSearchEngine(line.getOptionValue('p'));
- } catch (MalformedURLException me) {
- System.err
- .println("Bad search engine URL (include all except sitemap URL)");
- System.exit(1);
- }
- }
-
System.exit(0);
}
@@ -194,7 +159,10 @@ public static void deleteSitemaps() throws IOException {
*/
public static void generateSitemaps(boolean makeHTMLMap, boolean makeSitemapOrg) throws SQLException, IOException {
String uiURLStem = configurationService.getProperty("dspace.ui.url");
- String sitemapStem = uiURLStem + "/sitemap";
+ if (!uiURLStem.endsWith("/")) {
+ uiURLStem = uiURLStem + '/';
+ }
+ String sitemapStem = uiURLStem + "sitemap";
File outputDir = new File(configurationService.getProperty("sitemap.dir"));
if (!outputDir.exists() && !outputDir.mkdir()) {
@@ -213,186 +181,113 @@ public static void generateSitemaps(boolean makeHTMLMap, boolean makeSitemapOrg)
}
Context c = new Context(Context.Mode.READ_ONLY);
+ int offset = 0;
+ long commsCount = 0;
+ long collsCount = 0;
+ long itemsCount = 0;
- List comms = communityService.findAll(c);
-
- for (Community comm : comms) {
- String url = uiURLStem + "/communities/" + comm.getID();
-
- if (makeHTMLMap) {
- html.addURL(url, null);
- }
- if (makeSitemapOrg) {
- sitemapsOrg.addURL(url, null);
- }
-
- c.uncacheEntity(comm);
- }
-
- List colls = collectionService.findAll(c);
-
- for (Collection coll : colls) {
- String url = uiURLStem + "/collections/" + coll.getID();
-
- if (makeHTMLMap) {
- html.addURL(url, null);
- }
- if (makeSitemapOrg) {
- sitemapsOrg.addURL(url, null);
- }
-
- c.uncacheEntity(coll);
- }
-
- Iterator- allItems = itemService.findAll(c);
- int itemCount = 0;
-
- while (allItems.hasNext()) {
- Item i = allItems.next();
-
- Optional
customUrl = customUrlService.getCustomUrl(i);
- if (customUrl.isPresent()) {
-
- String url = uiURLStem + "/entities/" + StringUtils.lowerCase(itemService.getEntityTypeLabel(i))
- + "/" + customUrl.get();
-
- if (makeHTMLMap) {
- html.addURL(url, null);
- }
- if (makeSitemapOrg) {
- sitemapsOrg.addURL(url, null);
- }
-
- }
-
- DiscoverQuery entityQuery = new DiscoverQuery();
- entityQuery.setQuery("search.uniqueid:\"Item-" + i.getID() + "\" and entityType:*");
- entityQuery.addSearchField("entityType");
-
- try {
- DiscoverResult discoverResult = searchService.search(c, entityQuery);
-
- String url;
- if (CollectionUtils.isNotEmpty(discoverResult.getIndexableObjects())
- && CollectionUtils.isNotEmpty(discoverResult.getSearchDocument(
- discoverResult.getIndexableObjects().get(0)).get(0).getSearchFieldValues("entityType"))
- && StringUtils.isNotBlank(discoverResult.getSearchDocument(
- discoverResult.getIndexableObjects().get(0)).get(0).getSearchFieldValues("entityType").get(0))
- ) {
- url = uiURLStem + "/entities/" + StringUtils.lowerCase(discoverResult.getSearchDocument(
- discoverResult.getIndexableObjects().get(0))
- .get(0).getSearchFieldValues("entityType").get(0)) + "/" + i.getID();
- } else {
- url = uiURLStem + "/items/" + i.getID();
+ try {
+ DiscoverQuery discoveryQuery = new DiscoverQuery();
+ discoveryQuery.setMaxResults(PAGE_SIZE);
+ discoveryQuery.setQuery("search.resourcetype:Community");
+ do {
+ discoveryQuery.setStart(offset);
+ DiscoverResult discoverResult = searchService.search(c, discoveryQuery);
+ List docs = discoverResult.getIndexableObjects();
+ commsCount = discoverResult.getTotalSearchResults();
+
+ for (IndexableObject doc : docs) {
+ String url = uiURLStem + "communities/" + doc.getID();
+ c.uncacheEntity(doc.getIndexedObject());
+
+ if (makeHTMLMap) {
+ html.addURL(url, null);
+ }
+ if (makeSitemapOrg) {
+ sitemapsOrg.addURL(url, null);
+ }
}
- Date lastMod = i.getLastModified();
-
- if (makeHTMLMap) {
- html.addURL(url, lastMod);
+ offset += PAGE_SIZE;
+ } while (offset < commsCount);
+
+ offset = 0;
+ discoveryQuery = new DiscoverQuery();
+ discoveryQuery.setMaxResults(PAGE_SIZE);
+ discoveryQuery.setQuery("search.resourcetype:Collection");
+ do {
+ discoveryQuery.setStart(offset);
+ DiscoverResult discoverResult = searchService.search(c, discoveryQuery);
+ List docs = discoverResult.getIndexableObjects();
+ collsCount = discoverResult.getTotalSearchResults();
+
+ for (IndexableObject doc : docs) {
+ String url = uiURLStem + "collections/" + doc.getID();
+ c.uncacheEntity(doc.getIndexedObject());
+
+ if (makeHTMLMap) {
+ html.addURL(url, null);
+ }
+ if (makeSitemapOrg) {
+ sitemapsOrg.addURL(url, null);
+ }
}
- if (makeSitemapOrg) {
- sitemapsOrg.addURL(url, lastMod);
+ offset += PAGE_SIZE;
+ } while (offset < collsCount);
+
+ offset = 0;
+ discoveryQuery = new DiscoverQuery();
+ discoveryQuery.setMaxResults(PAGE_SIZE);
+ discoveryQuery.setQuery("search.resourcetype:Item");
+ discoveryQuery.addSearchField("search.entitytype");
+ do {
+
+ discoveryQuery.setStart(offset);
+ DiscoverResult discoverResult = searchService.search(c, discoveryQuery);
+ List docs = discoverResult.getIndexableObjects();
+ itemsCount = discoverResult.getTotalSearchResults();
+
+ for (IndexableObject doc : docs) {
+ String url;
+ List