mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 07:23:08 +00:00
Merge branch 'master' into DS-4097_item-mapper-squashed-final
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
# This image will be published as dspace/dspace
|
# This image will be published as dspace/dspace
|
||||||
# See https://dspace-labs.github.io/DSpace-Docker-Images/ for usage details
|
# See https://dspace-labs.github.io/DSpace-Docker-Images/ for usage details
|
||||||
#
|
#
|
||||||
# This version is JDK8 compatible
|
# This version is JDK8 compatible
|
||||||
# - tomcat:8-jre8
|
# - tomcat:8-jre8
|
||||||
# - ANT 1.10.5
|
# - ANT 1.10.5
|
||||||
# - maven:3-jdk-8
|
# - maven:3-jdk-8
|
||||||
# - note:
|
# - note:
|
||||||
# - default tag for branch: dspace/dspace: dspace/dspace:dspace-7_x-jdk8
|
# - default tag for branch: dspace/dspace: dspace/dspace:dspace-7_x-jdk8
|
||||||
|
|
||||||
# Step 1 - Run Maven Build
|
# Step 1 - Run Maven Build
|
||||||
@@ -55,6 +55,6 @@ EXPOSE 8080 8009
|
|||||||
ENV JAVA_OPTS=-Xmx2000m
|
ENV JAVA_OPTS=-Xmx2000m
|
||||||
|
|
||||||
RUN mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT.bk && \
|
RUN mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT.bk && \
|
||||||
ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/ROOT && \
|
ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/ROOT && \
|
||||||
ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/spring-rest && \
|
ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/server && \
|
||||||
ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest
|
ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
# This image will be published as dspace/dspace
|
# This image will be published as dspace/dspace
|
||||||
# See https://dspace-labs.github.io/DSpace-Docker-Images/ for usage details
|
# See https://dspace-labs.github.io/DSpace-Docker-Images/ for usage details
|
||||||
#
|
#
|
||||||
# This version is JDK8 compatible
|
# This version is JDK8 compatible
|
||||||
# - tomcat:8-jre8
|
# - tomcat:8-jre8
|
||||||
# - ANT 1.10.5
|
# - ANT 1.10.5
|
||||||
# - maven:3-jdk-8
|
# - maven:3-jdk-8
|
||||||
# - note:
|
# - note:
|
||||||
# - default tag for branch: dspace/dspace: dspace/dspace:dspace-7_x-jdk8-test
|
# - default tag for branch: dspace/dspace: dspace/dspace:dspace-7_x-jdk8-test
|
||||||
|
|
||||||
# Step 1 - Run Maven Build
|
# Step 1 - Run Maven Build
|
||||||
@@ -55,8 +55,8 @@ EXPOSE 8080 8009
|
|||||||
ENV JAVA_OPTS=-Xmx2000m
|
ENV JAVA_OPTS=-Xmx2000m
|
||||||
|
|
||||||
RUN mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT.bk && \
|
RUN mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT.bk && \
|
||||||
ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/ROOT && \
|
ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/ROOT && \
|
||||||
ln -s $DSPACE_INSTALL/webapps/spring-rest /usr/local/tomcat/webapps/spring-rest && \
|
ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/server && \
|
||||||
ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest
|
ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest
|
||||||
|
|
||||||
COPY dspace/src/main/docker/test/rest_web.xml $DSPACE_INSTALL/webapps/rest/WEB-INF/web.xml
|
COPY dspace/src/main/docker/test/rest_web.xml $DSPACE_INSTALL/webapps/rest/WEB-INF/web.xml
|
||||||
|
@@ -14,7 +14,7 @@ For more information, visit http://www.dspace.org/
|
|||||||
|
|
||||||
***
|
***
|
||||||
:warning: **Work on DSpace 7 has begun on our `master` branch.** This means that there is temporarily NO user interface on this `master` branch. DSpace 7 will feature a new, unified [Angular](https://angular.io/) user interface, along with an enhanced, rebuilt REST API. The latest status of this work can be found on the [DSpace 7 UI Working Group](https://wiki.duraspace.org/display/DSPACE/DSpace+7+UI+Working+Group) page. Additionally, the codebases can be found in the following places:
|
:warning: **Work on DSpace 7 has begun on our `master` branch.** This means that there is temporarily NO user interface on this `master` branch. DSpace 7 will feature a new, unified [Angular](https://angular.io/) user interface, along with an enhanced, rebuilt REST API. The latest status of this work can be found on the [DSpace 7 UI Working Group](https://wiki.duraspace.org/display/DSPACE/DSpace+7+UI+Working+Group) page. Additionally, the codebases can be found in the following places:
|
||||||
* DSpace 7 REST API work is occurring on the [`master` branch](https://github.com/DSpace/DSpace/tree/master/dspace-spring-rest) of this repository.
|
* DSpace 7 REST API work is occurring on the [`master` branch](https://github.com/DSpace/DSpace/tree/master/dspace-server-webapp) of this repository.
|
||||||
* The REST Contract is being documented at https://github.com/DSpace/Rest7Contract
|
* The REST Contract is being documented at https://github.com/DSpace/Rest7Contract
|
||||||
* DSpace 7 Angular UI work is occurring at https://github.com/DSpace/dspace-angular
|
* DSpace 7 Angular UI work is occurring at https://github.com/DSpace/dspace-angular
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ run automatically by [Travis CI](https://travis-ci.org/DSpace/DSpace/) for all P
|
|||||||
mvn clean install
|
mvn clean install
|
||||||
|
|
||||||
# Then, move into a module subdirectory, and run the test command
|
# Then, move into a module subdirectory, and run the test command
|
||||||
cd [dspace-src]/dspace-spring-rest
|
cd [dspace-src]/dspace-server-webapp
|
||||||
# Choose your test command from the lists above
|
# Choose your test command from the lists above
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@@ -334,6 +334,16 @@
|
|||||||
<groupId>org.dspace</groupId>
|
<groupId>org.dspace</groupId>
|
||||||
<artifactId>handle</artifactId>
|
<artifactId>handle</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty.aggregate</groupId>
|
||||||
|
<artifactId>jetty-all</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>javax.servlet</artifactId>
|
||||||
|
<groupId>org.eclipse.jetty.orbit</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dspace</groupId>
|
<groupId>org.dspace</groupId>
|
||||||
<artifactId>jargon</artifactId>
|
<artifactId>jargon</artifactId>
|
||||||
@@ -749,6 +759,13 @@
|
|||||||
<version>20180130</version>
|
<version>20180130</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.velocity</groupId>
|
||||||
|
<artifactId>velocity-engine-core</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
<type>jar</type>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.xmlunit</groupId>
|
<groupId>org.xmlunit</groupId>
|
||||||
<artifactId>xmlunit-matchers</artifactId>
|
<artifactId>xmlunit-matchers</artifactId>
|
||||||
|
@@ -67,7 +67,7 @@ public class DailyReportEmailer {
|
|||||||
email.setSubject(
|
email.setSubject(
|
||||||
"Checksum checker Report - " + numberOfBitstreams + " Bitstreams found with POSSIBLE issues on " +
|
"Checksum checker Report - " + numberOfBitstreams + " Bitstreams found with POSSIBLE issues on " +
|
||||||
hostname);
|
hostname);
|
||||||
email.setContent("report is attached ...");
|
email.setContent("Checker Report", "report is attached ...");
|
||||||
email.addAttachment(attachment, "checksum_checker_report.txt");
|
email.addAttachment(attachment, "checksum_checker_report.txt");
|
||||||
email.addRecipient(ConfigurationManager.getProperty("mail.admin"));
|
email.addRecipient(ConfigurationManager.getProperty("mail.admin"));
|
||||||
email.send();
|
email.send();
|
||||||
|
@@ -71,7 +71,7 @@ public class BitstreamFormat implements Serializable, ReloadableEntity<Integer>
|
|||||||
@Column(name = "internal")
|
@Column(name = "internal")
|
||||||
private boolean internal = false;
|
private boolean internal = false;
|
||||||
|
|
||||||
@ElementCollection(fetch = FetchType.LAZY)
|
@ElementCollection(fetch = FetchType.EAGER)
|
||||||
@CollectionTable(name = "fileextension", joinColumns = @JoinColumn(name = "bitstream_format_id"))
|
@CollectionTable(name = "fileextension", joinColumns = @JoinColumn(name = "bitstream_format_id"))
|
||||||
@CollectionId(
|
@CollectionId(
|
||||||
columns = @Column(name = "file_extension_id"),
|
columns = @Column(name = "file_extension_id"),
|
||||||
|
@@ -270,4 +270,4 @@ public class BitstreamFormatServiceImpl implements BitstreamFormatService {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -128,4 +128,4 @@ public interface BitstreamFormatService extends DSpaceCRUDService<BitstreamForma
|
|||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
public BitstreamFormat guessFormat(Context context, Bitstream bitstream) throws SQLException;
|
public BitstreamFormat guessFormat(Context context, Bitstream bitstream) throws SQLException;
|
||||||
}
|
}
|
@@ -16,12 +16,14 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.text.MessageFormat;
|
import java.io.StringWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
import javax.activation.DataHandler;
|
import javax.activation.DataHandler;
|
||||||
import javax.activation.DataSource;
|
import javax.activation.DataSource;
|
||||||
import javax.activation.FileDataSource;
|
import javax.activation.FileDataSource;
|
||||||
@@ -39,7 +41,15 @@ import javax.mail.internet.MimeMessage;
|
|||||||
import javax.mail.internet.MimeMultipart;
|
import javax.mail.internet.MimeMultipart;
|
||||||
import javax.mail.internet.ParseException;
|
import javax.mail.internet.ParseException;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.apache.velocity.Template;
|
||||||
|
import org.apache.velocity.VelocityContext;
|
||||||
|
import org.apache.velocity.app.Velocity;
|
||||||
|
import org.apache.velocity.app.VelocityEngine;
|
||||||
|
import org.apache.velocity.runtime.resource.loader.StringResourceLoader;
|
||||||
|
import org.apache.velocity.runtime.resource.util.StringResourceRepository;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||||
|
|
||||||
@@ -60,26 +70,23 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
|||||||
* <code>dspace-dir/config/emails/</code> (which also includes the subject.)
|
* <code>dspace-dir/config/emails/</code> (which also includes the subject.)
|
||||||
* <code>arg0</code> and <code>arg1</code> are arguments to fill out the
|
* <code>arg0</code> and <code>arg1</code> are arguments to fill out the
|
||||||
* message with.
|
* message with.
|
||||||
* </p>
|
* <P>
|
||||||
* <p>
|
* Emails are formatted using Apache Velocity. Headers such as Subject may be
|
||||||
* Emails are formatted using <code>java.text.MessageFormat.</code>
|
* supplied by the template, by defining them using #set(). Example:
|
||||||
* Additionally, comment lines (starting with '#') are stripped, and if a line
|
|
||||||
* starts with "Subject:" the text on the right of the colon is used for the
|
|
||||||
* subject line. For example:
|
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
* # This is a comment line which is stripped
|
* ## This is a comment line which is stripped
|
||||||
* #
|
* ##
|
||||||
* # Parameters: {0} is a person's name
|
* ## Parameters: {0} is a person's name
|
||||||
* # {1} is the name of a submission
|
* ## {1} is the name of a submission
|
||||||
* #
|
* ##
|
||||||
* Subject: Example e-mail
|
* #set($subject = 'Example e-mail')
|
||||||
*
|
*
|
||||||
* Dear {0},
|
* Dear ${params[0]},
|
||||||
*
|
*
|
||||||
* Thank you for sending us your submission "{1}".
|
* Thank you for sending us your submission "${params[1]}".
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
@@ -97,11 +104,6 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
|||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* <p>
|
|
||||||
* Note that parameters like <code>{0}</code> cannot be placed in the subject
|
|
||||||
* of the e-mail; they won't get filled out.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Robert Tansley
|
* @author Robert Tansley
|
||||||
* @author Jim Downing - added attachment handling code
|
* @author Jim Downing - added attachment handling code
|
||||||
* @author Adan Roman Ruiz at arvo.es - added inputstream attachment handling code
|
* @author Adan Roman Ruiz at arvo.es - added inputstream attachment handling code
|
||||||
@@ -111,6 +113,7 @@ public class Email {
|
|||||||
* The content of the message
|
* The content of the message
|
||||||
*/
|
*/
|
||||||
private String content;
|
private String content;
|
||||||
|
private String contentName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The subject of the message
|
* The subject of the message
|
||||||
@@ -120,37 +123,56 @@ public class Email {
|
|||||||
/**
|
/**
|
||||||
* The arguments to fill out
|
* The arguments to fill out
|
||||||
*/
|
*/
|
||||||
private List<Object> arguments;
|
private final List<Object> arguments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The recipients
|
* The recipients
|
||||||
*/
|
*/
|
||||||
private List<String> recipients;
|
private final List<String> recipients;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reply to field, if any
|
* Reply to field, if any
|
||||||
*/
|
*/
|
||||||
private String replyTo;
|
private String replyTo;
|
||||||
|
|
||||||
private List<FileAttachment> attachments;
|
private final List<FileAttachment> attachments;
|
||||||
private List<InputStreamAttachment> moreAttachments;
|
private final List<InputStreamAttachment> moreAttachments;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The character set this message will be sent in
|
* The character set this message will be sent in
|
||||||
*/
|
*/
|
||||||
private String charset;
|
private String charset;
|
||||||
|
|
||||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(Email.class);
|
private static final Logger LOG = LogManager.getLogger();
|
||||||
|
|
||||||
|
/** Velocity template settings. */
|
||||||
|
private static final String RESOURCE_REPOSITORY_NAME = "Email";
|
||||||
|
private static final Properties VELOCITY_PROPERTIES = new Properties();
|
||||||
|
static {
|
||||||
|
VELOCITY_PROPERTIES.put(Velocity.RESOURCE_LOADER, "string");
|
||||||
|
VELOCITY_PROPERTIES.put("string.resource.loader.description",
|
||||||
|
"Velocity StringResource loader");
|
||||||
|
VELOCITY_PROPERTIES.put("string.resource.loader.class",
|
||||||
|
StringResourceLoader.class.getName());
|
||||||
|
VELOCITY_PROPERTIES.put("string.resource.loader.repository.name",
|
||||||
|
RESOURCE_REPOSITORY_NAME);
|
||||||
|
VELOCITY_PROPERTIES.put("string.resource.loader.repository.static",
|
||||||
|
"false");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Velocity template for a message body */
|
||||||
|
private Template template;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new email message.
|
* Create a new email message.
|
||||||
*/
|
*/
|
||||||
public Email() {
|
public Email() {
|
||||||
arguments = new ArrayList<Object>(50);
|
arguments = new ArrayList<>(50);
|
||||||
recipients = new ArrayList<String>(50);
|
recipients = new ArrayList<>(50);
|
||||||
attachments = new ArrayList<FileAttachment>(10);
|
attachments = new ArrayList<>(10);
|
||||||
moreAttachments = new ArrayList<InputStreamAttachment>(10);
|
moreAttachments = new ArrayList<>(10);
|
||||||
subject = "";
|
subject = "";
|
||||||
|
template = null;
|
||||||
content = "";
|
content = "";
|
||||||
replyTo = null;
|
replyTo = null;
|
||||||
charset = null;
|
charset = null;
|
||||||
@@ -166,15 +188,17 @@ public class Email {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the content of the message. Setting this "resets" the message
|
* Set the content of the message. Setting this also "resets" the message
|
||||||
* formatting -<code>addArgument</code> will start. Comments and any
|
* formatting - <code>addArgument</code> will start over. Comments and any
|
||||||
* "Subject:" line must be stripped.
|
* "Subject:" line must be stripped.
|
||||||
*
|
*
|
||||||
|
* @param name a name for this message body
|
||||||
* @param cnt the content of the message
|
* @param cnt the content of the message
|
||||||
*/
|
*/
|
||||||
public void setContent(String cnt) {
|
public void setContent(String name, String cnt) {
|
||||||
content = cnt;
|
content = cnt;
|
||||||
arguments = new ArrayList<Object>();
|
contentName = name;
|
||||||
|
arguments.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -213,14 +237,14 @@ public class Email {
|
|||||||
|
|
||||||
public void addAttachment(InputStream is, String name, String mimetype) {
|
public void addAttachment(InputStream is, String name, String mimetype) {
|
||||||
if (null == mimetype) {
|
if (null == mimetype) {
|
||||||
log.error("Null MIME type replaced with '" + DEFAULT_ATTACHMENT_TYPE
|
LOG.error("Null MIME type replaced with '" + DEFAULT_ATTACHMENT_TYPE
|
||||||
+ "' for attachment '" + name + "'");
|
+ "' for attachment '" + name + "'");
|
||||||
mimetype = DEFAULT_ATTACHMENT_TYPE;
|
mimetype = DEFAULT_ATTACHMENT_TYPE;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
new ContentType(mimetype); // Just try to parse it.
|
new ContentType(mimetype); // Just try to parse it.
|
||||||
} catch (ParseException ex) {
|
} catch (ParseException ex) {
|
||||||
log.error("Bad MIME type '" + mimetype
|
LOG.error("Bad MIME type '" + mimetype
|
||||||
+ "' replaced with '" + DEFAULT_ATTACHMENT_TYPE
|
+ "' replaced with '" + DEFAULT_ATTACHMENT_TYPE
|
||||||
+ "' for attachment '" + name + "'", ex);
|
+ "' for attachment '" + name + "'", ex);
|
||||||
mimetype = DEFAULT_ATTACHMENT_TYPE;
|
mimetype = DEFAULT_ATTACHMENT_TYPE;
|
||||||
@@ -235,26 +259,35 @@ public class Email {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "Reset" the message. Clears the arguments and recipients, but leaves the
|
* "Reset" the message. Clears the arguments, attachments and recipients,
|
||||||
* subject and content intact.
|
* but leaves the subject and content intact.
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
arguments = new ArrayList<Object>(50);
|
arguments.clear();
|
||||||
recipients = new ArrayList<String>(50);
|
recipients.clear();
|
||||||
attachments = new ArrayList<FileAttachment>(10);
|
attachments.clear();
|
||||||
moreAttachments = new ArrayList<InputStreamAttachment>(10);
|
moreAttachments.clear();
|
||||||
replyTo = null;
|
replyTo = null;
|
||||||
charset = null;
|
charset = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends the email.
|
* Sends the email. If the template defines a Velocity context property
|
||||||
|
* named among the values of DSpace configuration property
|
||||||
|
* {@code mail.message.headers} then that name and its value will be added
|
||||||
|
* to the message's headers.
|
||||||
|
*
|
||||||
|
* <p>"subject" is treated specially: if {@link setSubject()} has not been called,
|
||||||
|
* the value of any "subject" property will be used as if setSubject had
|
||||||
|
* been called with that value. Thus a template may define its subject, but
|
||||||
|
* the caller may override it.
|
||||||
*
|
*
|
||||||
* @throws MessagingException if there was a problem sending the mail.
|
* @throws MessagingException if there was a problem sending the mail.
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
*/
|
*/
|
||||||
public void send() throws MessagingException, IOException {
|
public void send() throws MessagingException, IOException {
|
||||||
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
|
ConfigurationService config
|
||||||
|
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||||
|
|
||||||
// Get the mail configuration properties
|
// Get the mail configuration properties
|
||||||
String from = config.getProperty("mail.from.address");
|
String from = config.getProperty("mail.from.address");
|
||||||
@@ -279,20 +312,55 @@ public class Email {
|
|||||||
i.next()));
|
i.next()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format the mail message
|
// Format the mail message body
|
||||||
Object[] args = arguments.toArray();
|
VelocityEngine templateEngine = new VelocityEngine();
|
||||||
String fullMessage = MessageFormat.format(content, args);
|
templateEngine.init(VELOCITY_PROPERTIES);
|
||||||
Date date = new Date();
|
|
||||||
|
|
||||||
|
VelocityContext vctx = new VelocityContext();
|
||||||
|
vctx.put("config", new UnmodifiableConfigurationService(config));
|
||||||
|
vctx.put("params", Collections.unmodifiableList(arguments));
|
||||||
|
|
||||||
|
if (null == template) {
|
||||||
|
if (StringUtils.isBlank(content)) {
|
||||||
|
// No template and no content -- PANIC!!!
|
||||||
|
throw new MessagingException("Email has no body");
|
||||||
|
}
|
||||||
|
// No template, so use a String of content.
|
||||||
|
StringResourceRepository repo = (StringResourceRepository)
|
||||||
|
templateEngine.getApplicationAttribute(RESOURCE_REPOSITORY_NAME);
|
||||||
|
repo.putStringResource(contentName, content);
|
||||||
|
// Turn content into a template.
|
||||||
|
template = templateEngine.getTemplate(contentName);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringWriter writer = new StringWriter();
|
||||||
|
template.merge(vctx, writer);
|
||||||
|
String fullMessage = writer.toString();
|
||||||
|
|
||||||
|
// Set some message header fields
|
||||||
|
Date date = new Date();
|
||||||
message.setSentDate(date);
|
message.setSentDate(date);
|
||||||
message.setFrom(new InternetAddress(from));
|
message.setFrom(new InternetAddress(from));
|
||||||
|
|
||||||
// Set the subject of the email (may contain parameters)
|
// Get headers defined by the template.
|
||||||
String fullSubject = MessageFormat.format(subject, args);
|
for (String headerName : config.getArrayProperty("mail.message.headers")) {
|
||||||
|
String headerValue = (String) vctx.get(headerName);
|
||||||
|
if ("subject".equalsIgnoreCase(headerName)) {
|
||||||
|
if (null != subject) {
|
||||||
|
subject = headerValue;
|
||||||
|
}
|
||||||
|
} else if ("charset".equalsIgnoreCase(headerName)) {
|
||||||
|
charset = headerValue;
|
||||||
|
} else {
|
||||||
|
message.setHeader(headerName, headerValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the subject of the email.
|
||||||
if (charset != null) {
|
if (charset != null) {
|
||||||
message.setSubject(fullSubject, charset);
|
message.setSubject(subject, charset);
|
||||||
} else {
|
} else {
|
||||||
message.setSubject(fullSubject);
|
message.setSubject(subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add attachments
|
// Add attachments
|
||||||
@@ -305,39 +373,33 @@ public class Email {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Multipart multipart = new MimeMultipart();
|
Multipart multipart = new MimeMultipart();
|
||||||
|
|
||||||
// create the first part of the email
|
// create the first part of the email
|
||||||
BodyPart messageBodyPart = new MimeBodyPart();
|
BodyPart messageBodyPart = new MimeBodyPart();
|
||||||
messageBodyPart.setText(fullMessage);
|
messageBodyPart.setText(fullMessage);
|
||||||
multipart.addBodyPart(messageBodyPart);
|
multipart.addBodyPart(messageBodyPart);
|
||||||
if (!attachments.isEmpty()) {
|
|
||||||
for (Iterator<FileAttachment> iter = attachments.iterator(); iter.hasNext(); ) {
|
// Add file attachments
|
||||||
FileAttachment f = iter.next();
|
for (FileAttachment attachment : attachments) {
|
||||||
// add the file
|
// add the file
|
||||||
messageBodyPart = new MimeBodyPart();
|
messageBodyPart = new MimeBodyPart();
|
||||||
messageBodyPart.setDataHandler(new DataHandler(
|
messageBodyPart.setDataHandler(new DataHandler(
|
||||||
new FileDataSource(f.file)));
|
new FileDataSource(attachment.file)));
|
||||||
messageBodyPart.setFileName(f.name);
|
messageBodyPart.setFileName(attachment.name);
|
||||||
multipart.addBodyPart(messageBodyPart);
|
multipart.addBodyPart(messageBodyPart);
|
||||||
}
|
|
||||||
message.setContent(multipart);
|
|
||||||
}
|
}
|
||||||
if (!moreAttachments.isEmpty()) {
|
|
||||||
for (Iterator<InputStreamAttachment> iter = moreAttachments.iterator(); iter.hasNext(); ) {
|
// Add stream attachments
|
||||||
InputStreamAttachment isa = iter.next();
|
for (InputStreamAttachment attachment : moreAttachments) {
|
||||||
// add the stream
|
// add the stream
|
||||||
messageBodyPart = new MimeBodyPart();
|
messageBodyPart = new MimeBodyPart();
|
||||||
messageBodyPart.setDataHandler(
|
messageBodyPart.setDataHandler(new DataHandler(
|
||||||
new DataHandler(new InputStreamDataSource(
|
new InputStreamDataSource(attachment.name,attachment.mimetype,attachment.is)));
|
||||||
isa.name,
|
messageBodyPart.setFileName(attachment.name);
|
||||||
isa.mimetype,
|
multipart.addBodyPart(messageBodyPart);
|
||||||
isa.is)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
messageBodyPart.setFileName(isa.name);
|
|
||||||
multipart.addBodyPart(messageBodyPart);
|
|
||||||
}
|
|
||||||
message.setContent(multipart);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message.setContent(multipart);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replyTo != null) {
|
if (replyTo != null) {
|
||||||
@@ -347,7 +409,7 @@ public class Email {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
StringBuffer text = new StringBuffer(
|
StringBuilder text = new StringBuilder(
|
||||||
"Message not sent due to mail.server.disabled:\n");
|
"Message not sent due to mail.server.disabled:\n");
|
||||||
|
|
||||||
Enumeration<String> headers = message.getAllHeaderLines();
|
Enumeration<String> headers = message.getAllHeaderLines();
|
||||||
@@ -365,19 +427,21 @@ public class Email {
|
|||||||
|
|
||||||
text.append('\n').append(fullMessage);
|
text.append('\n').append(fullMessage);
|
||||||
|
|
||||||
log.info(text);
|
LOG.info(text.toString());
|
||||||
} else {
|
} else {
|
||||||
Transport.send(message);
|
Transport.send(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the template for an email message. The message is suitable for
|
* Get the VTL template for an email message. The message is suitable
|
||||||
* inserting values using <code>java.text.MessageFormat</code>.
|
* for inserting values using Apache Velocity.
|
||||||
|
*
|
||||||
|
* @param emailFile
|
||||||
|
* full name for the email template, for example "/dspace/config/emails/register".
|
||||||
|
*
|
||||||
|
* @return the email object, configured with subject and body.
|
||||||
*
|
*
|
||||||
* @param emailFile full name for the email template, for example "/dspace/config/emails/register".
|
|
||||||
* @return the email object, with the content and subject filled out from
|
|
||||||
* the template
|
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
* if the template couldn't be found, or there was some other
|
* if the template couldn't be found, or there was some other
|
||||||
* error reading the template
|
* error reading the template
|
||||||
@@ -385,55 +449,25 @@ public class Email {
|
|||||||
public static Email getEmail(String emailFile)
|
public static Email getEmail(String emailFile)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
String charset = null;
|
String charset = null;
|
||||||
String subject = "";
|
|
||||||
StringBuilder contentBuffer = new StringBuilder();
|
StringBuilder contentBuffer = new StringBuilder();
|
||||||
InputStream is = null;
|
try (
|
||||||
InputStreamReader ir = null;
|
InputStream is = new FileInputStream(emailFile);
|
||||||
BufferedReader reader = null;
|
InputStreamReader ir = new InputStreamReader(is, "UTF-8");
|
||||||
try {
|
BufferedReader reader = new BufferedReader(ir);
|
||||||
is = new FileInputStream(emailFile);
|
) {
|
||||||
ir = new InputStreamReader(is, "UTF-8");
|
|
||||||
reader = new BufferedReader(ir);
|
|
||||||
boolean more = true;
|
boolean more = true;
|
||||||
while (more) {
|
while (more) {
|
||||||
String line = reader.readLine();
|
String line = reader.readLine();
|
||||||
if (line == null) {
|
if (line == null) {
|
||||||
more = false;
|
more = false;
|
||||||
} else if (line.toLowerCase().startsWith("subject:")) {
|
} else {
|
||||||
subject = line.substring(8).trim();
|
|
||||||
} else if (line.toLowerCase().startsWith("charset:")) {
|
|
||||||
charset = line.substring(8).trim();
|
|
||||||
} else if (!line.startsWith("#")) {
|
|
||||||
contentBuffer.append(line);
|
contentBuffer.append(line);
|
||||||
contentBuffer.append("\n");
|
contentBuffer.append("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
if (reader != null) {
|
|
||||||
try {
|
|
||||||
reader.close();
|
|
||||||
} catch (IOException ioe) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ir != null) {
|
|
||||||
try {
|
|
||||||
ir.close();
|
|
||||||
} catch (IOException ioe) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is != null) {
|
|
||||||
try {
|
|
||||||
is.close();
|
|
||||||
} catch (IOException ioe) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Email email = new Email();
|
Email email = new Email();
|
||||||
email.setSubject(subject);
|
email.setContent(emailFile, contentBuffer.toString());
|
||||||
email.setContent(contentBuffer.toString());
|
|
||||||
if (charset != null) {
|
if (charset != null) {
|
||||||
email.setCharset(charset);
|
email.setCharset(charset);
|
||||||
}
|
}
|
||||||
@@ -452,24 +486,36 @@ public class Email {
|
|||||||
/**
|
/**
|
||||||
* Test method to send an email to check email server settings
|
* Test method to send an email to check email server settings
|
||||||
*
|
*
|
||||||
* @param args the command line arguments given
|
* @param args command line arguments. The first is the path to an email
|
||||||
|
* template file; the rest are the positional arguments for the
|
||||||
|
* template. If there are no arguments, a short, plain test
|
||||||
|
* message is sent.
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
|
ConfigurationService config
|
||||||
|
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||||
String to = config.getProperty("mail.admin");
|
String to = config.getProperty("mail.admin");
|
||||||
String subject = "DSpace test email";
|
String subject = "DSpace test email";
|
||||||
String server = config.getProperty("mail.server");
|
String server = config.getProperty("mail.server");
|
||||||
String url = config.getProperty("dspace.url");
|
String url = config.getProperty("dspace.url");
|
||||||
Email e = new Email();
|
Email message;
|
||||||
e.setSubject(subject);
|
|
||||||
e.addRecipient(to);
|
|
||||||
e.content = "This is a test email sent from DSpace: " + url;
|
|
||||||
System.out.println("\nAbout to send test email:");
|
|
||||||
System.out.println(" - To: " + to);
|
|
||||||
System.out.println(" - Subject: " + subject);
|
|
||||||
System.out.println(" - Server: " + server);
|
|
||||||
boolean disabled = config.getBooleanProperty("mail.server.disabled", false);
|
|
||||||
try {
|
try {
|
||||||
|
if (args.length <= 0) {
|
||||||
|
message = new Email();
|
||||||
|
message.setContent("testing", "This is a test email sent from DSpace: " + url);
|
||||||
|
} else {
|
||||||
|
message = Email.getEmail(args[0]);
|
||||||
|
for (int i = 1; i < args.length; i++) {
|
||||||
|
message.addArgument(args[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message.setSubject(subject);
|
||||||
|
message.addRecipient(to);
|
||||||
|
System.out.println("\nAbout to send test email:");
|
||||||
|
System.out.println(" - To: " + to);
|
||||||
|
System.out.println(" - Subject: " + subject);
|
||||||
|
System.out.println(" - Server: " + server);
|
||||||
|
boolean disabled = config.getBooleanProperty("mail.server.disabled", false);
|
||||||
if (disabled) {
|
if (disabled) {
|
||||||
System.err.println("\nError sending email:");
|
System.err.println("\nError sending email:");
|
||||||
System.err.println(" - Error: cannot test email because mail.server.disabled is set to true");
|
System.err.println(" - Error: cannot test email because mail.server.disabled is set to true");
|
||||||
@@ -478,16 +524,10 @@ public class Email {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.send();
|
message.send();
|
||||||
} catch (MessagingException me) {
|
} catch (MessagingException | IOException ex) {
|
||||||
System.err.println("\nError sending email:");
|
System.err.println("\nError sending email:");
|
||||||
System.err.println(" - Error: " + me);
|
System.err.format(" - Error: %s%n", ex);
|
||||||
System.err.println("\nPlease see the DSpace documentation for assistance.\n");
|
|
||||||
System.err.println("\n");
|
|
||||||
System.exit(1);
|
|
||||||
} catch (IOException e1) {
|
|
||||||
System.err.println("\nError sending email:");
|
|
||||||
System.err.println(" - Error: " + e1);
|
|
||||||
System.err.println("\nPlease see the DSpace documentation for assistance.\n");
|
System.err.println("\nPlease see the DSpace documentation for assistance.\n");
|
||||||
System.err.println("\n");
|
System.err.println("\n");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
@@ -532,9 +572,9 @@ public class Email {
|
|||||||
* @author arnaldo
|
* @author arnaldo
|
||||||
*/
|
*/
|
||||||
public class InputStreamDataSource implements DataSource {
|
public class InputStreamDataSource implements DataSource {
|
||||||
private String name;
|
private final String name;
|
||||||
private String contentType;
|
private final String contentType;
|
||||||
private ByteArrayOutputStream baos;
|
private final ByteArrayOutputStream baos;
|
||||||
|
|
||||||
InputStreamDataSource(String name, String contentType, InputStream inputStream) throws IOException {
|
InputStreamDataSource(String name, String contentType, InputStream inputStream) throws IOException {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -568,4 +608,30 @@ public class Email {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap ConfigurationService to prevent templates from modifying
|
||||||
|
* the configuration.
|
||||||
|
*/
|
||||||
|
public class UnmodifiableConfigurationService {
|
||||||
|
private final ConfigurationService configurationService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swallow an instance of ConfigurationService.
|
||||||
|
*
|
||||||
|
* @param cs the real instance, to be wrapped.
|
||||||
|
*/
|
||||||
|
public UnmodifiableConfigurationService(ConfigurationService cs) {
|
||||||
|
configurationService = cs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Look up a key in the actual ConfigurationService.
|
||||||
|
*
|
||||||
|
* @param key to be looked up in the DSpace configuration.
|
||||||
|
* @return whatever value ConfigurationService associates with {@code key}.
|
||||||
|
*/
|
||||||
|
public String get(String key) {
|
||||||
|
return configurationService.getProperty(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,13 +14,14 @@ import java.util.Iterator;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.cnri.util.StreamTable;
|
||||||
import net.handle.hdllib.Encoder;
|
import net.handle.hdllib.Encoder;
|
||||||
import net.handle.hdllib.HandleException;
|
import net.handle.hdllib.HandleException;
|
||||||
import net.handle.hdllib.HandleStorage;
|
import net.handle.hdllib.HandleStorage;
|
||||||
import net.handle.hdllib.HandleValue;
|
import net.handle.hdllib.HandleValue;
|
||||||
import net.handle.hdllib.ScanCallback;
|
import net.handle.hdllib.ScanCallback;
|
||||||
import net.handle.hdllib.Util;
|
import net.handle.hdllib.Util;
|
||||||
import net.handle.util.StreamTable;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.handle.factory.HandleServiceFactory;
|
import org.dspace.handle.factory.HandleServiceFactory;
|
||||||
|
@@ -4,8 +4,9 @@
|
|||||||
<artifactId>dspace-rest</artifactId>
|
<artifactId>dspace-rest</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>7.0-SNAPSHOT</version>
|
<version>7.0-SNAPSHOT</version>
|
||||||
<name>DSpace REST :: API and Implementation</name>
|
<name>DSpace (Deprecated) REST Webapp</name>
|
||||||
<description>DSpace RESTful Web Services API</description>
|
<description>DSpace RESTful Web Services API. NOTE: this REST API is DEPRECATED.
|
||||||
|
Please consider using the REST API in the dspace-server-webapp instead!</description>
|
||||||
<url>http://demo.dspace.org</url>
|
<url>http://demo.dspace.org</url>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
# DSpace7 REST Webapp
|
# DSpace Server Webapp
|
||||||
> This is the new REST webapp for DSpace 7 build with Spring MVC + HATEOAS with a focus on the [JSON HAL format](http://stateless.co/hal_specification.html) ([formal specification](https://tools.ietf.org/html/draft-kelly-json-hal-08))
|
> This is the new server webapp for DSpace 7 built with Spring Boot, MVC + HATEOAS with a focus on the [JSON HAL format](http://stateless.co/hal_specification.html) ([formal specification](https://tools.ietf.org/html/draft-kelly-json-hal-08))
|
||||||
|
|
||||||
This webapp uses the following technologies:
|
This webapp uses the following technologies:
|
||||||
- [Spring Boot](https://projects.spring.io/spring-boot/)
|
- [Spring Boot](https://projects.spring.io/spring-boot/)
|
||||||
@@ -15,8 +15,8 @@ Check the infomation available on the DSpace Official Wiki page for the [DSpace
|
|||||||
[DSpace 7 REST: Coding DSpace Objects](https://wiki.duraspace.org/display/DSPACE/DSpace+7+REST%3A+Coding+DSpace+Objects)
|
[DSpace 7 REST: Coding DSpace Objects](https://wiki.duraspace.org/display/DSPACE/DSpace+7+REST%3A+Coding+DSpace+Objects)
|
||||||
|
|
||||||
## How to run
|
## How to run
|
||||||
The only tested way right now is to run this webapp inside your IDE (Eclipse). Just create a new Tomcat 8 server and deploy the dspace-spring-rest maven module to it.
|
The only tested way right now is to run this webapp inside your IDE (Eclipse). Just create a new Tomcat 8 server and deploy the dspace-server-webapp maven module to it.
|
||||||
> The *dspace.dir* is configured in the *dspace-spring-rest/src/main/resources/application.properties* file
|
> The *dspace.dir* is configured in the *dspace-server-webapp/src/main/resources/application.properties* file
|
||||||
[currently](src/main/resources/application.properties#L25)
|
[currently](src/main/resources/application.properties#L25)
|
||||||
|
|
||||||
> dspace.dir = d:/install/dspace7
|
> dspace.dir = d:/install/dspace7
|
@@ -1,11 +1,11 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.dspace</groupId>
|
<groupId>org.dspace</groupId>
|
||||||
<artifactId>dspace-spring-rest</artifactId>
|
<artifactId>dspace-server-webapp</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<name>DSpace Spring Rest (Boot MVC + HATEOAS)</name>
|
<name>DSpace Server Webapp</name>
|
||||||
<description>
|
<description>
|
||||||
DSpace new Rest API
|
DSpace Server Webapp (Spring Boot)
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<!--
|
<!--
|
@@ -44,7 +44,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
* The mapping for requested endpoint try to resolve a valid UUID, for example
|
* The mapping for requested endpoint try to resolve a valid UUID, for example
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* https://<dspace.url>/dspace-spring-rest/api/core/bitstreams/26453b4d-e513-44e8-8d5b-395f62972eff/content
|
* https://<dspace.server.url>/api/core/bitstreams/26453b4d-e513-44e8-8d5b-395f62972eff/content
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
@@ -174,12 +174,12 @@ public class RestResourceController implements InitializingBean {
|
|||||||
* Note that the regular expression in the request mapping accept a string as identifier but not the other kind
|
* Note that the regular expression in the request mapping accept a string as identifier but not the other kind
|
||||||
* of identifier;
|
* of identifier;
|
||||||
*
|
*
|
||||||
* http://<dspace.url>/dspace-spring-rest/api/{apiCategory}/{model}/{id}
|
* http://<dspace.server.url>/api/{apiCategory}/{model}/{id}
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* http://<dspace.url>/dspace-spring-rest/api/config/submissionsections/collection
|
* http://<dspace.server.url>/api/config/submissionsections/collection
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
@@ -336,19 +336,19 @@ public class RestResourceController implements InitializingBean {
|
|||||||
* Note that the regular expression in the request mapping accept a string as identifier but not the other kind
|
* Note that the regular expression in the request mapping accept a string as identifier but not the other kind
|
||||||
* of identifier;
|
* of identifier;
|
||||||
*
|
*
|
||||||
* http://<dspace.url>/dspace-spring-rest/api/{apiCategory}/{model}/{id}/{rel}/{relid}
|
* http://<dspace.server.url>/api/{apiCategory}/{model}/{id}/{rel}/{relid}
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* http://<dspace.url>/dspace-spring-rest/api/integration/authorities/SRJournalTitle/entryValues/1479-9995
|
* http://<dspace.server.url>/api/integration/authorities/SRJournalTitle/entryValues/1479-9995
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* http://<dspace.url>/dspace-spring-rest/api/integration/authorities/srsc/entries/VR110111
|
* http://<dspace.server.url>/api/integration/authorities/srsc/entries/VR110111
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
@@ -378,12 +378,12 @@ public class RestResourceController implements InitializingBean {
|
|||||||
/**
|
/**
|
||||||
* Execute a POST request;
|
* Execute a POST request;
|
||||||
*
|
*
|
||||||
* curl -X POST -H "Content-Type:application/json" http://<dspace.url>/dspace-spring-rest/api/{apiCategory}/{model}
|
* curl -X POST -H "Content-Type:application/json" http://<dspace.server.url>/api/{apiCategory}/{model}
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* curl -X POST -H "Content-Type:application/json" http://<dspace.url>/dspace-spring-rest/api/submission/workspaceitems
|
* curl -X POST -H "Content-Type:application/json" http://<dspace.server.url>/api/submission/workspaceitems
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
@@ -403,12 +403,12 @@ public class RestResourceController implements InitializingBean {
|
|||||||
/**
|
/**
|
||||||
* Execute a POST request;
|
* Execute a POST request;
|
||||||
*
|
*
|
||||||
* curl -X POST -H "Content-Type:text/uri-list" http://<dspace.url>/dspace-spring-rest/api/{apiCategory}/{model}
|
* curl -X POST -H "Content-Type:text/uri-list" http://<dspace.server.url>/api/{apiCategory}/{model}
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* curl -X POST -H "Content-Type:text/uri-list" http://<dspace.url>/dspace-spring-rest/api/submission/workspaceitems
|
* curl -X POST -H "Content-Type:text/uri-list" http://<dspace.server.url>/api/submission/workspaceitems
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
@@ -1110,12 +1110,12 @@ public class RestResourceController implements InitializingBean {
|
|||||||
/**
|
/**
|
||||||
* Execute a PUT request for an entity with id of type Integer;
|
* Execute a PUT request for an entity with id of type Integer;
|
||||||
*
|
*
|
||||||
* curl -X PUT -H "Content-Type:application/json" http://<dspace.url>/dspace-spring-rest/api/{apiCategory}/{model}/{id}
|
* curl -X PUT -H "Content-Type:application/json" http://<dspace.server.url>/api/{apiCategory}/{model}/{id}
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* curl -X PUT -H "Content-Type:application/json" http://<dspace.url>/dspace-spring-rest/api/core/metadatafield/1
|
* curl -X PUT -H "Content-Type:application/json" http://<dspace.server.url>/api/core/metadatafield/1
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
@@ -1138,12 +1138,12 @@ public class RestResourceController implements InitializingBean {
|
|||||||
/**
|
/**
|
||||||
* Execute a PUT request for an entity with id of type Integer;
|
* Execute a PUT request for an entity with id of type Integer;
|
||||||
*
|
*
|
||||||
* curl -X PUT -H "Content-Type:text/uri-list" http://<dspace.url>/dspace-spring-rest/api/{apiCategory}/{model}/{id}
|
* curl -X PUT -H "Content-Type:text/uri-list" http://<dspace.server.url>/api/{apiCategory}/{model}/{id}
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* <pre>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* curl -X PUT -H "Content-Type:text/uri-list" http://<dspace.url>/dspace-spring-rest/api/core/metadatafield/1
|
* curl -X PUT -H "Content-Type:text/uri-list" http://<dspace.server.url>/api/core/metadatafield/1
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
@@ -1210,4 +1210,4 @@ public class RestResourceController implements InitializingBean {
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -9,6 +9,8 @@ package org.dspace.app.rest.converter;
|
|||||||
|
|
||||||
import org.dspace.app.rest.model.BitstreamFormatRest;
|
import org.dspace.app.rest.model.BitstreamFormatRest;
|
||||||
import org.dspace.content.BitstreamFormat;
|
import org.dspace.content.BitstreamFormat;
|
||||||
|
import org.dspace.content.service.BitstreamFormatService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,15 +21,24 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class BitstreamFormatConverter implements DSpaceConverter<BitstreamFormat, BitstreamFormatRest> {
|
public class BitstreamFormatConverter implements DSpaceConverter<BitstreamFormat, BitstreamFormatRest> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
BitstreamFormatService bitstreamFormatService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BitstreamFormatRest fromModel(BitstreamFormat obj) {
|
public BitstreamFormatRest fromModel(BitstreamFormat obj) {
|
||||||
BitstreamFormatRest bf = new BitstreamFormatRest();
|
BitstreamFormatRest bf = new BitstreamFormatRest();
|
||||||
bf.setDescription(obj.getDescription());
|
|
||||||
bf.setExtensions(bf.getExtensions());
|
|
||||||
bf.setId(obj.getID());
|
bf.setId(obj.getID());
|
||||||
bf.setMimetype(obj.getMIMEType());
|
|
||||||
bf.setShortDescription(obj.getShortDescription());
|
bf.setShortDescription(obj.getShortDescription());
|
||||||
|
bf.setDescription(obj.getDescription());
|
||||||
|
bf.setMimetype(obj.getMIMEType());
|
||||||
bf.setInternal(obj.isInternal());
|
bf.setInternal(obj.isInternal());
|
||||||
|
if (obj.getSupportLevel() > 0) {
|
||||||
|
bf.setSupportLevel(bitstreamFormatService.getSupportLevelText(obj));
|
||||||
|
} else {
|
||||||
|
bf.setSupportLevel("UNKNOWN");
|
||||||
|
}
|
||||||
|
bf.setExtensions(obj.getExtensions());
|
||||||
return bf;
|
return bf;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user