diff --git a/dspace-api/pom.xml b/dspace-api/pom.xml
index 4fd555c583..2ea9722bad 100644
--- a/dspace-api/pom.xml
+++ b/dspace-api/pom.xml
@@ -12,7 +12,7 @@
org.dspace
dspace-parent
- 4.0-rc2-SNAPSHOT
+ 4.0-rc3-SNAPSHOT
..
diff --git a/dspace-api/src/main/java/org/dspace/app/bulkedit/DSpaceCSV.java b/dspace-api/src/main/java/org/dspace/app/bulkedit/DSpaceCSV.java
index 2b1920aeef..fef548e0be 100644
--- a/dspace-api/src/main/java/org/dspace/app/bulkedit/DSpaceCSV.java
+++ b/dspace-api/src/main/java/org/dspace/app/bulkedit/DSpaceCSV.java
@@ -385,6 +385,11 @@ public class DSpaceCSV implements Serializable
*/
public final void addItem(Item i) throws Exception
{
+ // If the item is not in the archive, the call to get its handle below will fail
+ if (i.isWithdrawn() || !i.isArchived() || i.getOwningCollection() == null) {
+ return;
+ }
+
// Create the CSV line
DSpaceCSVLine line = new DSpaceCSVLine(i.getID());
diff --git a/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImport.java b/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImport.java
index 71d7234b5b..d4c88d6038 100644
--- a/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImport.java
+++ b/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImport.java
@@ -1340,11 +1340,33 @@ public class ItemImport
+ sRegistrationLine);
continue;
}
- registerBitstream(c, i, iAssetstore, sFilePath, sBundle);
+
+ // look for descriptions
+ boolean descriptionExists = false;
+ String descriptionMarker = "\tdescription:";
+ int dMarkerIndex = line.indexOf(descriptionMarker);
+ int dEndIndex = 0;
+ if (dMarkerIndex > 0)
+ {
+ dEndIndex = line.indexOf("\t", dMarkerIndex + 1);
+ if (dEndIndex == -1)
+ {
+ dEndIndex = line.length();
+ }
+ descriptionExists = true;
+ }
+ String sDescription = "";
+ if (descriptionExists)
+ {
+ sDescription = line.substring(dMarkerIndex, dEndIndex);
+ sDescription = sDescription.replaceFirst("description:", "");
+ }
+
+ registerBitstream(c, i, iAssetstore, sFilePath, sBundle, sDescription);
System.out.println("\tRegistering Bitstream: " + sFilePath
+ "\tAssetstore: " + iAssetstore
+ "\tBundle: " + sBundle
- + "\tDescription: " + sBundle);
+ + "\tDescription: " + sDescription);
continue; // process next line in contents file
}
@@ -1571,7 +1593,7 @@ public class ItemImport
* @throws AuthorizeException
*/
private void registerBitstream(Context c, Item i, int assetstore,
- String bitstreamPath, String bundleName )
+ String bitstreamPath, String bundleName, String description )
throws SQLException, IOException, AuthorizeException
{
// TODO validate assetstore number
@@ -1622,6 +1644,7 @@ public class ItemImport
// FIXME - guessing format guesses license.txt incorrectly as a text file format!
BitstreamFormat bf = FormatIdentifier.guessFormat(c, bs);
bs.setFormat(bf);
+ bs.setDescription(description);
bs.update();
}
diff --git a/dspace-api/src/main/java/org/dspace/app/statistics/LogAnalyser.java b/dspace-api/src/main/java/org/dspace/app/statistics/LogAnalyser.java
index e8a3bd0df2..ce057c5a29 100644
--- a/dspace-api/src/main/java/org/dspace/app/statistics/LogAnalyser.java
+++ b/dspace-api/src/main/java/org/dspace/app/statistics/LogAnalyser.java
@@ -18,17 +18,9 @@ import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -1031,7 +1023,8 @@ public class LogAnalyser
public static String unParseDate(Date date)
{
// Use SimpleDateFormat
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'MM'-'dd");
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'MM'-'dd'T'hh:mm:ss'Z'");
+ sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
return sdf.format(date);
}
@@ -1205,28 +1198,33 @@ public class LogAnalyser
if (oracle)
{
dateQuery.append(" AND TO_TIMESTAMP( TO_CHAR(text_value), "+
- "'yyyy-mm-dd\"T\"hh24:mi:ss\"Z\"' ) > TO_DATE('" +
- unParseDate(startDate) + "', 'yyyy-MM-dd') ");
+ "'yyyy-mm-dd\"T\"hh24:mi:ss\"Z\"' ) >= TO_DATE('" +
+ unParseDate(startDate) + "', 'yyyy-MM-dd\"T\"hh24:mi:ss\"Z\"') ");
}
else
{
- dateQuery.append(" AND text_value::timestamp > '" +
+ dateQuery.append(" AND text_value::timestamp >= '" +
unParseDate(startDate) + "'::timestamp ");
}
}
if (endDate != null)
{
+ // adjust end date to account for timestamp comparison
+ GregorianCalendar realEndDate = new GregorianCalendar();
+ realEndDate.setTime(endDate);
+ realEndDate.add(Calendar.DAY_OF_MONTH, 1);
+ Date queryEndDate = realEndDate.getTime();
if (oracle)
{
dateQuery.append(" AND TO_TIMESTAMP( TO_CHAR(text_value), "+
"'yyyy-mm-dd\"T\"hh24:mi:ss\"Z\"' ) < TO_DATE('" +
- unParseDate(endDate) + "', 'yyyy-MM-dd') ");
+ unParseDate(queryEndDate) + "', 'yyyy-MM-dd\"T\"hh24:mi:ss\"Z\"') ");
}
else
{
dateQuery.append(" AND text_value::timestamp < '" +
- unParseDate(endDate) + "'::timestamp ");
+ unParseDate(queryEndDate) + "'::timestamp ");
}
}
diff --git a/dspace-api/src/main/java/org/dspace/authenticate/LDAPAuthentication.java b/dspace-api/src/main/java/org/dspace/authenticate/LDAPAuthentication.java
index 75e0ca7c4e..492dad166a 100644
--- a/dspace-api/src/main/java/org/dspace/authenticate/LDAPAuthentication.java
+++ b/dspace-api/src/main/java/org/dspace/authenticate/LDAPAuthentication.java
@@ -252,13 +252,18 @@ public class LDAPAuthentication
// If there is no email and the email domain is set, add it to the netid
String email = ldap.ldapEmail;
- if (((email == null) || ("".equals(email))) &&
- (!"".equals(ConfigurationManager.getProperty("authentication-ldap", "netid_email_domain"))))
+
+ if ((StringUtils.isEmpty(email)) &&
+ (StringUtils.isNotEmpty(ConfigurationManager.getProperty("authentication-ldap", "netid_email_domain"))))
{
email = netid + ConfigurationManager.getProperty("authentication-ldap", "netid_email_domain");
}
+ else
+ {
+ email = netid;
+ }
- if ((email != null) && (!"".equals(email)))
+ if (StringUtils.isNotEmpty(email))
{
try
{
@@ -288,19 +293,19 @@ public class LDAPAuthentication
{
context.setIgnoreAuthorization(true);
eperson = EPerson.create(context);
- if ((email != null) && (!"".equals(email)))
+ if (StringUtils.isNotEmpty(email))
{
eperson.setEmail(email);
}
- if ((ldap.ldapGivenName!=null) && (!ldap.ldapGivenName.equals("")))
+ if (StringUtils.isNotEmpty(ldap.ldapGivenName))
{
eperson.setFirstName(ldap.ldapGivenName);
}
- if ((ldap.ldapSurname!=null) && (!ldap.ldapSurname.equals("")))
+ if (StringUtils.isNotEmpty(ldap.ldapSurname))
{
eperson.setLastName(ldap.ldapSurname);
}
- if ((ldap.ldapPhone!=null)&&(!ldap.ldapPhone.equals("")))
+ if (StringUtils.isNotEmpty(ldap.ldapPhone))
{
eperson.setMetadata("phone", ldap.ldapPhone);
}
diff --git a/dspace-api/src/main/java/org/dspace/content/Collection.java b/dspace-api/src/main/java/org/dspace/content/Collection.java
index 4b026fa91c..06ed1386dd 100644
--- a/dspace-api/src/main/java/org/dspace/content/Collection.java
+++ b/dspace-api/src/main/java/org/dspace/content/Collection.java
@@ -90,6 +90,13 @@ public class Collection extends DSpaceObject
/** The default group of administrators */
private Group admins;
+ // Keys for accessing Collection metadata
+ public static final String COPYRIGHT_TEXT = "copyright_text";
+ public static final String INTRODUCTORY_TEXT = "introductory_text";
+ public static final String SHORT_DESCRIPTION = "short_description";
+ public static final String SIDEBAR_TEXT = "side_bar_text";
+ public static final String PROVENANCE_TEXT = "provenance_description";
+
/**
* Construct a collection with the given table row
*
diff --git a/dspace-api/src/main/java/org/dspace/identifier/DOIIdentifierProvider.java b/dspace-api/src/main/java/org/dspace/identifier/DOIIdentifierProvider.java
index f692ec7bb3..b0669c89dd 100644
--- a/dspace-api/src/main/java/org/dspace/identifier/DOIIdentifierProvider.java
+++ b/dspace-api/src/main/java/org/dspace/identifier/DOIIdentifierProvider.java
@@ -276,22 +276,7 @@ public class DOIIdentifierProvider
+ "is marked as DELETED.", DOIIdentifierException.DOI_IS_DELETED);
}
- // check if DOI is reserved at the registration agency
- if (connector.isDOIReserved(context, doi))
- {
- // if doi is registered for this object we still should check its
- // status in our database (see below).
- // if it is registered for another object we should notify an admin
- if (!connector.isDOIReserved(context, dso, doi))
- {
- log.warn("DOI {} is reserved for another object already.", doi);
- throw new DOIIdentifierException(DOIIdentifierException.DOI_ALREADY_EXISTS);
- }
- }
- else
- {
- connector.reserveDOI(context, dso, doi);
- }
+ connector.reserveDOI(context, dso, doi);
doiRow.setColumn("status", IS_RESERVED);
DatabaseManager.update(context, doiRow);
@@ -311,52 +296,21 @@ public class DOIIdentifierProvider
+ "is marked as DELETED.", DOIIdentifierException.DOI_IS_DELETED);
}
- // check if the DOI is already registered online
- if (connector.isDOIRegistered(context, doi))
- {
- // if doi is registered for this object we still should check its
- // status in our database (see below).
- // if it is registered for another object we should notify an admin
- if (!connector.isDOIRegistered(context, dso, doi))
- {
- // DOI is reserved for another object
- log.warn("DOI {} is registered for another object already.", doi);
- throw new DOIIdentifierException(DOIIdentifierException.DOI_ALREADY_EXISTS);
- }
+ // register DOI Online
+ try {
+ connector.registerDOI(context, dso, doi);
}
- else
+ catch (DOIIdentifierException die)
{
- // check if doi is reserved for this specific dso
- if (!connector.isDOIReserved(context, dso, doi))
+ // do we have to reserve DOI before we can register it?
+ if (die.getCode() == DOIIdentifierException.RESERVE_FIRST)
{
- // check if doi is already reserved for another dso
- if (connector.isDOIReserved(context, doi))
- {
- log.warn("Trying to register DOI {}, that is reserved for "
- + "another dso.", doi);
- throw new DOIIdentifierException("Trying to register a DOI "
- + "that is reserved for another object.",
- DOIIdentifierException.DOI_ALREADY_EXISTS);
- }
-
- connector.reserveDOI(context, dso, doi);
- }
- // register DOI Online
- try {
+ this.reserveOnline(context, dso, identifier);
connector.registerDOI(context, dso, doi);
}
- catch (DOIIdentifierException die)
+ else
{
- // do we have to reserve DOI before we can register it?
- if (die.getCode() == DOIIdentifierException.REGISTER_FIRST)
- {
- this.reserveOnline(context, dso, identifier);
- connector.registerDOI(context, dso, doi);
- }
- else
- {
- throw die;
- }
+ throw die;
}
}
@@ -375,7 +329,6 @@ public class DOIIdentifierProvider
doiRow.setColumn("status", IS_REGISTERED);
DatabaseManager.update(context, doiRow);
-
}
public void updateMetadata(Context context, DSpaceObject dso, String identifier)
@@ -451,23 +404,9 @@ public class DOIIdentifierProvider
if (DELETED == doiRow.getIntColumn("status") ||
TO_BE_DELETED == doiRow.getIntColumn("status"))
{
- throw new DOIIdentifierException("You tried to register a DOI that "
- + "is marked as DELETED.", DOIIdentifierException.DOI_IS_DELETED);
- }
-
-
- // check if doi is reserved for this specific dso
- if (connector.isDOIReserved(context, identifier))
- {
- // check if doi is reserved for this specific dso
- if (!connector.isDOIReserved(context, dso, doi))
- {
- log.warn("Trying to update metadata for DOI {}, that is reserved"
- + " for another dso.", doi);
- throw new DOIIdentifierException("Trying to update metadta for "
- + "a DOI that is reserved for another object.",
- DOIIdentifierException.DOI_ALREADY_EXISTS);
- }
+ throw new DOIIdentifierException("You tried to update the metadata"
+ + "of a DOI that is marked as DELETED.",
+ DOIIdentifierException.DOI_IS_DELETED);
}
connector.updateMetadata(context, dso, doi);
diff --git a/dspace-api/src/main/java/org/dspace/identifier/doi/DOIConnector.java b/dspace-api/src/main/java/org/dspace/identifier/doi/DOIConnector.java
index 51b864091b..666d69d825 100644
--- a/dspace-api/src/main/java/org/dspace/identifier/doi/DOIConnector.java
+++ b/dspace-api/src/main/java/org/dspace/identifier/doi/DOIConnector.java
@@ -14,7 +14,12 @@ import org.dspace.core.Context;
/**
* A DOIConnector handles all calls to the API of your DOI registry.
*
- * Please pay attention to the method {@link #purgeCachedInformation()}!
+ * A DOIConnector should care about rules of the registration agency. For
+ * example, if the registration agency wants us to reserve a DOI before we can
+ * register it, the DOIConnector should check if a DOI is reserved. Use a
+ * {@link DOIIdenfierException} and set its error code in case of any errors.
+ * For the given example you should use
+ * {@code DOIIdentifierException.RESERVER_FIRST} as error code.
*
* @author Pascal-Nicolas Becker
*/
@@ -38,14 +43,6 @@ public interface DOIConnector {
* identifiers they should never be deleted. For example, if you send a HTTP
* DELETE request to the DataCite Metadata API directly, it will set the DOI
* to inactive.
- *
- * A DOIConnector does not have to check whether the DOI is reserved,
- * registered or not. It will only send the request and return the answer in
- * form of a boolean weather the deletion was successful or not. It may even
- * throw an DOIIdentifierException in case you are not allowed to delete a
- * DOI, the DOI does not exist, ... So please be sure that the deletion of a
- * DOI is conform with the rules of the registry and that the DOI is in the
- * appropriate state (f.e. reserved but not registered).
*
* @param context
* @param doi
@@ -57,12 +54,11 @@ public interface DOIConnector {
/**
* Sends a request to the DOI registry to reserve a DOI.
- *
- * Please check on your own if the DOI is already reserved or even
- * registered before you try to reserve it. You can use
- * {@link isDOIRegistered} and {@link isDOIReserved} for it. The
- * DOIConnector won't do any tests and throws an DOIIdentifierException in
- * case of any problems with the DOI you want to reserve.
+ *
+ * The DOIConnector should check weather this DOI is reserved for another
+ * object already. In this case it should throw an {@link
+ * DOIIdentifierException} and set the error code to {@code
+ * DOIIdentifierException.DOI_ALREADY_EXISTS}.
*
* @param context
* @param dso
@@ -75,12 +71,11 @@ public interface DOIConnector {
/**
* Sends a request to the DOI registry to register a DOI.
*
- * Please check on your own if the DOI is already reserved or even
- * registered before you try to register it. You can use the methods
- * {@code DOIConnector.isDOIRegistered(...)} and
- * {@code DOIConnector.isDOIReserved(...)} for it. The DOIConnector won't
- * do any tests and throws an DOIIdentifierException in case of any problems
- * with the DOI you want to register.
+ * The DOIConnector ensures compliance with the workflow of the registration
+ * agency. For example, if a DOI has to be reserved before it can be
+ * registered the DOIConnector has to check if it is reserved. In this case
+ * you can throw an DOIIdentifierExcpetion and set the error code to
+ * {@link DOIIdentifierException.RESERVE_FIRST}.
*
* @param context
* @param dso
@@ -92,9 +87,10 @@ public interface DOIConnector {
throws DOIIdentifierException;
/**
- * Sends a request to the DOI registry to update Metadata for a DOI.
- * The DOIConnector won't do any tests and throws an IdentifierException
- * in case of any problems with the DOI you want to update the metadata.
+ * Sends a request to the DOI registry to update metadata for a DOI.
+ *
+ * The DOIConnector should check weather the DOI is reserved or registered
+ * for the specified DSpace Object before it sends the metadata update.
*
* @param context
* @param dso
diff --git a/dspace-api/src/main/java/org/dspace/identifier/doi/DOIIdentifierException.java b/dspace-api/src/main/java/org/dspace/identifier/doi/DOIIdentifierException.java
index 34afe036e8..a5d3be6560 100644
--- a/dspace-api/src/main/java/org/dspace/identifier/doi/DOIIdentifierException.java
+++ b/dspace-api/src/main/java/org/dspace/identifier/doi/DOIIdentifierException.java
@@ -49,7 +49,7 @@ public class DOIIdentifierException extends IdentifierException {
* be registered. This error code signals that a unreserved DOI should be
* registered and that the registration agency denied it.
*/
- public static final int REGISTER_FIRST = 6;
+ public static final int RESERVE_FIRST = 6;
/**
* Error while authenticating against the registration agency.
*/
@@ -97,7 +97,7 @@ public class DOIIdentifierException extends IdentifierException {
return "FOREIGN_DOI";
case BAD_ANSWER:
return "BAD_ANSWER";
- case REGISTER_FIRST:
+ case RESERVE_FIRST:
return "REGISTER_FIRST";
case AUTHENTICATION_ERROR:
return "AUTHENTICATION_ERROR";
diff --git a/dspace-api/src/main/java/org/dspace/identifier/doi/DataCiteConnector.java b/dspace-api/src/main/java/org/dspace/identifier/doi/DataCiteConnector.java
index 63717274ec..736ede53ad 100644
--- a/dspace-api/src/main/java/org/dspace/identifier/doi/DataCiteConnector.java
+++ b/dspace-api/src/main/java/org/dspace/identifier/doi/DataCiteConnector.java
@@ -65,12 +65,12 @@ implements DOIConnector
* Stores the scheme used to connect to the DataCite server. It will be set
* by spring dependency injection.
*/
- private String SCHEME;
+ protected String SCHEME;
/**
* Stores the hostname of the DataCite server. Set by spring dependency
* injection.
*/
- private String HOST;
+ protected String HOST;
/**
* Path on the DataCite server used to generate DOIs. Set by spring
@@ -188,7 +188,7 @@ implements DOIConnector
this.CROSSWALK_NAME = CROSSWALK_NAME;
}
- private void prepareXwalk()
+ protected void prepareXwalk()
{
if (null != this.xwalk)
return;
@@ -203,7 +203,7 @@ implements DOIConnector
}
}
- private String getUsername()
+ protected String getUsername()
{
if (null == this.USERNAME)
{
@@ -218,7 +218,7 @@ implements DOIConnector
return this.USERNAME;
}
- private String getPassword()
+ protected String getPassword()
{
if (null == this.PASSWORD)
{
@@ -450,7 +450,22 @@ implements DOIConnector
@Override
public void reserveDOI(Context context, DSpaceObject dso, String doi)
throws DOIIdentifierException
- {
+ {
+ // check if DOI is reserved at the registration agency
+ if (this.isDOIReserved(context, doi))
+ {
+ // if doi is registered for this object we still should check its
+ // status in our database (see below).
+ // if it is registered for another object we should notify an admin
+ if (!this.isDOIReserved(context, dso, doi))
+ {
+ log.warn("DOI {} is reserved for another object already.", doi);
+ throw new DOIIdentifierException(DOIIdentifierException.DOI_ALREADY_EXISTS);
+ }
+ // the DOI is reserved for this Object. We use {@code reserveDOI} to
+ // send metadata updates, so don't return here!
+ }
+
this.prepareXwalk();
if (!this.xwalk.canDisseminate(dso))
@@ -557,7 +572,40 @@ implements DOIConnector
public void registerDOI(Context context, DSpaceObject dso, String doi)
throws DOIIdentifierException
{
- log.debug("Want to register DOI {}!", doi);
+ // check if the DOI is already registered online
+ if (this.isDOIRegistered(context, doi))
+ {
+ // if it is registered for another object we should notify an admin
+ if (!this.isDOIRegistered(context, dso, doi))
+ {
+ // DOI is reserved for another object
+ log.warn("DOI {} is registered for another object already.", doi);
+ throw new DOIIdentifierException(DOIIdentifierException.DOI_ALREADY_EXISTS);
+ }
+ // doi is registered for this object, we're done
+ return;
+ }
+ else
+ {
+ // DataCite wants us to reserve a DOI before we can register it
+ if (!this.isDOIReserved(context, dso, doi))
+ {
+ // check if doi is already reserved for another dso
+ if (this.isDOIReserved(context, doi))
+ {
+ log.warn("Trying to register DOI {}, that is reserved for "
+ + "another dso.", doi);
+ throw new DOIIdentifierException("Trying to register a DOI "
+ + "that is reserved for another object.",
+ DOIIdentifierException.DOI_ALREADY_EXISTS);
+ }
+
+ // the DOIIdentifierProvider should catch and handle this
+ throw new DOIIdentifierException("You need to reserve a DOI "
+ + "before you can register it.",
+ DOIIdentifierException.RESERVE_FIRST);
+ }
+ }
// send doi=\nurl= to mds/doi
DataCiteResponse resp = null;
@@ -600,7 +648,7 @@ implements DOIConnector
+ "of DOIs. The DOI we wanted to register had not been "
+ "reserved in advance. Please contact the administrator "
+ "or take a look in DSpace log file.",
- DOIIdentifierException.REGISTER_FIRST);
+ DOIIdentifierException.RESERVE_FIRST);
}
// Catch all other http status code in case we forgot one.
default :
@@ -619,18 +667,27 @@ implements DOIConnector
public void updateMetadata(Context context, DSpaceObject dso, String doi)
throws DOIIdentifierException
{
+ // check if doi is reserved for another object
+ if (!this.isDOIReserved(context, dso, doi) && this.isDOIReserved(context, doi))
+ {
+ log.warn("Trying to update metadata for DOI {}, that is reserved"
+ + " for another dso.", doi);
+ throw new DOIIdentifierException("Trying to update metadta for "
+ + "a DOI that is reserved for another object.",
+ DOIIdentifierException.DOI_ALREADY_EXISTS);
+ }
// We can use reserveDOI to update metadata. Datacite API uses the same
// request for reservartion as for updating metadata.
this.reserveDOI(context, dso, doi);
}
- private DataCiteResponse sendDOIPostRequest(String doi, String url)
+ protected DataCiteResponse sendDOIPostRequest(String doi, String url)
throws DOIIdentifierException
{
// post mds/doi/
// body must contaion "doi=\nurl=}n"
URIBuilder uribuilder = new URIBuilder();
- uribuilder.setScheme("https").setHost(HOST).setPath(DOI_PATH);
+ uribuilder.setScheme(SCHEME).setHost(HOST).setPath(DOI_PATH);
HttpPost httppost = null;
try
@@ -641,7 +698,7 @@ implements DOIConnector
{
log.error("The URL we constructed to check a DOI "
+ "produced a URISyntaxException. Please check the configuration parameters!");
- log.error("The URL was {}.", "https://" + HOST +
+ log.error("The URL was {}.", SCHEME + "://" + HOST +
DOI_PATH + "/" + doi.substring(DOI.SCHEME.length()));
throw new RuntimeException("The URL we constructed to check a DOI "
+ "produced a URISyntaxException. Please check the configuration parameters!", e);
@@ -674,12 +731,12 @@ implements DOIConnector
}
- private DataCiteResponse sendMetadataDeleteRequest(String doi)
+ protected DataCiteResponse sendMetadataDeleteRequest(String doi)
throws DOIIdentifierException
{
// delete mds/metadata/
URIBuilder uribuilder = new URIBuilder();
- uribuilder.setScheme("https").setHost(HOST).setPath(METADATA_PATH
+ uribuilder.setScheme(SCHEME).setHost(HOST).setPath(METADATA_PATH
+ doi.substring(DOI.SCHEME.length()));
HttpDelete httpdelete = null;
@@ -691,7 +748,7 @@ implements DOIConnector
{
log.error("The URL we constructed to check a DOI "
+ "produced a URISyntaxException. Please check the configuration parameters!");
- log.error("The URL was {}.", "https://" + HOST +
+ log.error("The URL was {}.", SCHEME + "://" + HOST +
DOI_PATH + "/" + doi.substring(DOI.SCHEME.length()));
throw new RuntimeException("The URL we constructed to check a DOI "
+ "produced a URISyntaxException. Please check the configuration parameters!", e);
@@ -699,23 +756,23 @@ implements DOIConnector
return sendHttpRequest(httpdelete, doi);
}
- private DataCiteResponse sendDOIGetRequest(String doi)
+ protected DataCiteResponse sendDOIGetRequest(String doi)
throws DOIIdentifierException
{
return sendGetRequest(doi, DOI_PATH);
}
- private DataCiteResponse sendMetadataGetRequest(String doi)
+ protected DataCiteResponse sendMetadataGetRequest(String doi)
throws DOIIdentifierException
{
return sendGetRequest(doi, METADATA_PATH);
}
- private DataCiteResponse sendGetRequest(String doi, String path)
+ protected DataCiteResponse sendGetRequest(String doi, String path)
throws DOIIdentifierException
{
URIBuilder uribuilder = new URIBuilder();
- uribuilder.setScheme("https").setHost(HOST).setPath(path
+ uribuilder.setScheme(SCHEME).setHost(HOST).setPath(path
+ doi.substring(DOI.SCHEME.length()));
HttpGet httpget = null;
@@ -727,7 +784,7 @@ implements DOIConnector
{
log.error("The URL we constructed to check a DOI "
+ "produced a URISyntaxException. Please check the configuration parameters!");
- log.error("The URL was {}.", "https://" + HOST +
+ log.error("The URL was {}.", SCHEME + "://" + HOST +
DOI_PATH + "/" + doi.substring(DOI.SCHEME.length()));
throw new RuntimeException("The URL we constructed to check a DOI "
+ "produced a URISyntaxException. Please check the configuration parameters!", e);
@@ -735,7 +792,7 @@ implements DOIConnector
return sendHttpRequest(httpget, doi);
}
- private DataCiteResponse sendMetadataPostRequest(String doi, Element metadataRoot)
+ protected DataCiteResponse sendMetadataPostRequest(String doi, Element metadataRoot)
throws DOIIdentifierException
{
Format format = Format.getCompactFormat();
@@ -744,13 +801,13 @@ implements DOIConnector
return sendMetadataPostRequest(doi, xout.outputString(new Document(metadataRoot)));
}
- private DataCiteResponse sendMetadataPostRequest(String doi, String metadata)
+ protected DataCiteResponse sendMetadataPostRequest(String doi, String metadata)
throws DOIIdentifierException
{
// post mds/metadata/
// body must contain metadata in DataCite-XML.
URIBuilder uribuilder = new URIBuilder();
- uribuilder.setScheme("https").setHost(HOST).setPath(METADATA_PATH);
+ uribuilder.setScheme(SCHEME).setHost(HOST).setPath(METADATA_PATH);
HttpPost httppost = null;
try
@@ -761,7 +818,7 @@ implements DOIConnector
{
log.error("The URL we constructed to check a DOI "
+ "produced a URISyntaxException. Please check the configuration parameters!");
- log.error("The URL was {}.", "https://" + HOST +
+ log.error("The URL was {}.", SCHEME + "://" + HOST +
DOI_PATH + "/" + doi.substring(DOI.SCHEME.length()));
throw new RuntimeException("The URL we constructed to check a DOI "
+ "produced a URISyntaxException. Please check the configuration parameters!", e);
@@ -799,7 +856,7 @@ implements DOIConnector
* @return
* @throws DOIIdentifierException
*/
- private DataCiteResponse sendHttpRequest(HttpUriRequest req, String doi)
+ protected DataCiteResponse sendHttpRequest(HttpUriRequest req, String doi)
throws DOIIdentifierException
{
DefaultHttpClient httpclient = new DefaultHttpClient();
@@ -923,7 +980,7 @@ implements DOIConnector
}
// returns null or handle
- private String extractAlternateIdentifier(Context context, String content)
+ protected String extractAlternateIdentifier(Context context, String content)
throws SQLException, DOIIdentifierException
{
if (content == null)
@@ -969,12 +1026,12 @@ implements DOIConnector
return handle;
}
- private String extractDOI(Element root) {
+ protected String extractDOI(Element root) {
Element doi = root.getChild("identifier", root.getNamespace());
return (null == doi) ? null : doi.getTextTrim();
}
- private Element addDOI(String doi, Element root) {
+ protected Element addDOI(String doi, Element root) {
if (null != extractDOI(root))
{
return root;
@@ -985,7 +1042,7 @@ implements DOIConnector
return root.addContent(0, identifier);
}
- private class DataCiteResponse
+ protected class DataCiteResponse
{
private final int statusCode;
private final String content;
diff --git a/dspace-api/src/main/java/org/dspace/submit/lookup/ArXivService.java b/dspace-api/src/main/java/org/dspace/submit/lookup/ArXivService.java
index c2c3a8e393..42e3b1de08 100644
--- a/dspace-api/src/main/java/org/dspace/submit/lookup/ArXivService.java
+++ b/dspace-api/src/main/java/org/dspace/submit/lookup/ArXivService.java
@@ -76,124 +76,75 @@ public class ArXivService
}
private List search(String query, String arxivid, int max_result)
- throws IOException, HttpException
- {
- List results = new ArrayList();
- if (!ConfigurationManager.getBooleanProperty(SubmissionLookupService.CFG_MODULE, "remoteservice.demo"))
- {
- GetMethod method = null;
- try
- {
- HttpClient client = new HttpClient();
- client.setTimeout(timeout);
- method = new GetMethod("http://export.arxiv.org/api/query");
- NameValuePair id = new NameValuePair("id_list", arxivid);
- NameValuePair queryParam = new NameValuePair("search_query",
- query);
- NameValuePair count = new NameValuePair("max_results",
- String.valueOf(max_result));
- method.setQueryString(new NameValuePair[] { id, queryParam,
- count });
- // Execute the method.
- int statusCode = client.executeMethod(method);
+ throws IOException, HttpException
+ {
+ List results = new ArrayList();
+ GetMethod method = null;
+ try
+ {
+ HttpClient client = new HttpClient();
+ client.setTimeout(timeout);
+ method = new GetMethod("http://export.arxiv.org/api/query");
+ NameValuePair id = new NameValuePair("id_list", arxivid);
+ NameValuePair queryParam = new NameValuePair("search_query",
+ query);
+ NameValuePair count = new NameValuePair("max_results",
+ String.valueOf(max_result));
+ method.setQueryString(new NameValuePair[] { id, queryParam,
+ count });
+ // Execute the method.
+ int statusCode = client.executeMethod(method);
- if (statusCode != HttpStatus.SC_OK)
- {
- if (statusCode == HttpStatus.SC_BAD_REQUEST)
- throw new RuntimeException("arXiv query is not valid");
- else
- throw new RuntimeException("Http call failed: "
- + method.getStatusLine());
- }
+ if (statusCode != HttpStatus.SC_OK)
+ {
+ if (statusCode == HttpStatus.SC_BAD_REQUEST)
+ throw new RuntimeException("arXiv query is not valid");
+ else
+ throw new RuntimeException("Http call failed: "
+ + method.getStatusLine());
+ }
- try
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- factory.setValidating(false);
- factory.setIgnoringComments(true);
- factory.setIgnoringElementContentWhitespace(true);
+ try
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ factory.setValidating(false);
+ factory.setIgnoringComments(true);
+ factory.setIgnoringElementContentWhitespace(true);
- DocumentBuilder db = factory.newDocumentBuilder();
- Document inDoc = db.parse(method.getResponseBodyAsStream());
+ DocumentBuilder db = factory.newDocumentBuilder();
+ Document inDoc = db.parse(method.getResponseBodyAsStream());
- Element xmlRoot = inDoc.getDocumentElement();
- List dataRoots = XMLUtils.getElementList(xmlRoot,
- "entry");
+ Element xmlRoot = inDoc.getDocumentElement();
+ List dataRoots = XMLUtils.getElementList(xmlRoot,
+ "entry");
- for (Element dataRoot : dataRoots)
- {
- Record crossitem = ArxivUtils
- .convertArxixDomToRecord(dataRoot);
- if (crossitem != null)
- {
- results.add(crossitem);
- }
- }
- }
- catch (Exception e)
- {
- throw new RuntimeException(
- "ArXiv identifier is not valid or not exist");
- }
- }
- finally
- {
- if (method != null)
- {
- method.releaseConnection();
- }
- }
- }
- else
- {
- InputStream stream = null;
- try
- {
- File file = new File(
- ConfigurationManager.getProperty("dspace.dir")
- + "/config/crosswalks/demo/arxiv.xml");
- stream = new FileInputStream(file);
- try
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- factory.setValidating(false);
- factory.setIgnoringComments(true);
- factory.setIgnoringElementContentWhitespace(true);
- DocumentBuilder db = factory.newDocumentBuilder();
- Document inDoc = db.parse(stream);
+ for (Element dataRoot : dataRoots)
+ {
+ Record crossitem = ArxivUtils
+ .convertArxixDomToRecord(dataRoot);
+ if (crossitem != null)
+ {
+ results.add(crossitem);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(
+ "ArXiv identifier is not valid or not exist");
+ }
+ }
+ finally
+ {
+ if (method != null)
+ {
+ method.releaseConnection();
+ }
+ }
- Element xmlRoot = inDoc.getDocumentElement();
- List dataRoots = XMLUtils.getElementList(xmlRoot,
- "entry");
- for (Element dataRoot : dataRoots)
- {
- Record crossitem = ArxivUtils
- .convertArxixDomToRecord(dataRoot);
-
- if (crossitem != null)
- {
- results.add(crossitem);
- }
- }
- }
- catch (Exception e)
- {
- throw new RuntimeException(
- "ArXiv identifier is not valid or not exist");
- }
- }
- finally
- {
- if (stream != null)
- {
- stream.close();
- }
- }
- }
- return results;
- }
+ return results;
+ }
public Record getByArXivIDs(String raw) throws HttpException, IOException
{
diff --git a/dspace-api/src/main/java/org/dspace/submit/lookup/CrossRefOnlineDataLoader.java b/dspace-api/src/main/java/org/dspace/submit/lookup/CrossRefOnlineDataLoader.java
index c5c379088f..ec86ac45ec 100644
--- a/dspace-api/src/main/java/org/dspace/submit/lookup/CrossRefOnlineDataLoader.java
+++ b/dspace-api/src/main/java/org/dspace/submit/lookup/CrossRefOnlineDataLoader.java
@@ -35,6 +35,9 @@ public class CrossRefOnlineDataLoader extends NetworkSubmissionLookupDataLoader
private boolean searchProvider = true;
+ private String apiKey = null;
+ private int maxResults = 10;
+
public void setSearchProvider(boolean searchProvider)
{
this.searchProvider = searchProvider;
@@ -60,9 +63,14 @@ public class CrossRefOnlineDataLoader extends NetworkSubmissionLookupDataLoader
Set dois = keys.get(DOI);
List items = null;
List results = new ArrayList();
+
+ if (getApiKey() == null){
+ throw new RuntimeException("No CrossRef API key is specified!");
+ }
+
try
{
- items = crossrefService.search(context, dois);
+ items = crossrefService.search(context, dois, getApiKey());
}
catch (JDOMException e)
{
@@ -89,8 +97,12 @@ public class CrossRefOnlineDataLoader extends NetworkSubmissionLookupDataLoader
public List search(Context context, String title, String author,
int year) throws HttpException, IOException
{
+ if (getApiKey() == null){
+ throw new RuntimeException("No CrossRef API key is specified!");
+ }
+
List items = crossrefService.search(context, title, author,
- year, 10);
+ year, getMaxResults(), getApiKey());
return items;
}
@@ -99,4 +111,20 @@ public class CrossRefOnlineDataLoader extends NetworkSubmissionLookupDataLoader
{
return searchProvider;
}
+
+ public String getApiKey() {
+ return apiKey;
+ }
+
+ public void setApiKey(String apiKey) {
+ this.apiKey = apiKey;
+ }
+
+ public int getMaxResults() {
+ return maxResults;
+ }
+
+ public void setMaxResults(int maxResults) {
+ this.maxResults = maxResults;
+ }
}
diff --git a/dspace-api/src/main/java/org/dspace/submit/lookup/CrossRefService.java b/dspace-api/src/main/java/org/dspace/submit/lookup/CrossRefService.java
index 79338d508b..32a5fa19ce 100644
--- a/dspace-api/src/main/java/org/dspace/submit/lookup/CrossRefService.java
+++ b/dspace-api/src/main/java/org/dspace/submit/lookup/CrossRefService.java
@@ -29,7 +29,6 @@ import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.dspace.app.util.XMLUtils;
-import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.jdom.JDOMException;
@@ -58,7 +57,7 @@ public class CrossRefService
this.timeout = timeout;
}
- public List search(Context context, Set dois)
+ public List search(Context context, Set dois, String apiKey)
throws HttpException, IOException, JDOMException,
ParserConfigurationException, SAXException
{
@@ -67,84 +66,77 @@ public class CrossRefService
{
for (String record : dois)
{
- try
- {
- if (!ConfigurationManager
- .getBooleanProperty(SubmissionLookupService.CFG_MODULE, "remoteservice.demo"))
- {
- GetMethod method = null;
- try
- {
- String apiKey = ConfigurationManager
- .getProperty(SubmissionLookupService.CFG_MODULE, "crossref.api-key");
+ try
+ {
+ GetMethod method = null;
+ try
+ {
+ HttpClient client = new HttpClient();
+ client.setConnectionTimeout(timeout);
+ method = new GetMethod(
+ "http://www.crossref.org/openurl/");
- HttpClient client = new HttpClient();
- client.setConnectionTimeout(timeout);
- method = new GetMethod(
- "http://www.crossref.org/openurl/");
+ NameValuePair pid = new NameValuePair("pid", apiKey);
+ NameValuePair noredirect = new NameValuePair(
+ "noredirect", "true");
+ NameValuePair id = new NameValuePair("id", record);
+ method.setQueryString(new NameValuePair[] { pid,
+ noredirect, id });
+ // Execute the method.
+ int statusCode = client.executeMethod(method);
- NameValuePair pid = new NameValuePair("pid", apiKey);
- NameValuePair noredirect = new NameValuePair(
- "noredirect", "true");
- NameValuePair id = new NameValuePair("id", record);
- method.setQueryString(new NameValuePair[] { pid,
- noredirect, id });
- // Execute the method.
- int statusCode = client.executeMethod(method);
+ if (statusCode != HttpStatus.SC_OK)
+ {
+ throw new RuntimeException("Http call failed: "
+ + method.getStatusLine());
+ }
- if (statusCode != HttpStatus.SC_OK)
- {
- throw new RuntimeException("Http call failed: "
- + method.getStatusLine());
- }
+ Record crossitem;
+ try
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ factory.setValidating(false);
+ factory.setIgnoringComments(true);
+ factory.setIgnoringElementContentWhitespace(true);
- Record crossitem;
- try
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- factory.setValidating(false);
- factory.setIgnoringComments(true);
- factory.setIgnoringElementContentWhitespace(true);
+ DocumentBuilder db = factory
+ .newDocumentBuilder();
+ Document inDoc = db.parse(method
+ .getResponseBodyAsStream());
- DocumentBuilder db = factory
- .newDocumentBuilder();
- Document inDoc = db.parse(method
- .getResponseBodyAsStream());
+ Element xmlRoot = inDoc.getDocumentElement();
+ Element queryResult = XMLUtils.getSingleElement(xmlRoot, "query_result");
+ Element body = XMLUtils.getSingleElement(queryResult, "body");
+ Element dataRoot = XMLUtils.getSingleElement(body, "query");
- Element xmlRoot = inDoc.getDocumentElement();
- Element queryResult = XMLUtils.getSingleElement(xmlRoot, "query_result");
- Element body = XMLUtils.getSingleElement(queryResult, "body");
- Element dataRoot = XMLUtils.getSingleElement(body, "query");
-
- crossitem = CrossRefUtils
- .convertCrossRefDomToRecord(dataRoot);
- results.add(crossitem);
- }
- catch (Exception e)
- {
- log.warn(LogManager
- .getHeader(
- context,
- "retrieveRecordDOI",
- record
- + " DOI is not valid or not exist: "
- + e.getMessage()));
- }
- }
- finally
- {
- if (method != null)
- {
- method.releaseConnection();
- }
- }
- }
- }
- catch (RuntimeException rt)
- {
- log.error(rt.getMessage(), rt);
- }
+ crossitem = CrossRefUtils
+ .convertCrossRefDomToRecord(dataRoot);
+ results.add(crossitem);
+ }
+ catch (Exception e)
+ {
+ log.warn(LogManager
+ .getHeader(
+ context,
+ "retrieveRecordDOI",
+ record
+ + " DOI is not valid or not exist: "
+ + e.getMessage()));
+ }
+ }
+ finally
+ {
+ if (method != null)
+ {
+ method.releaseConnection();
+ }
+ }
+ }
+ catch (RuntimeException rt)
+ {
+ log.error(rt.getMessage(), rt);
+ }
}
}
return results;
@@ -176,7 +168,7 @@ public class CrossRefService
}
public List search(Context context, String title, String authors,
- int year, int count) throws IOException, HttpException
+ int year, int count, String apiKey) throws IOException, HttpException
{
GetMethod method = null;
try
@@ -210,7 +202,7 @@ public class CrossRefService
}
method.releaseConnection();
- return search(context, dois);
+ return search(context, dois, apiKey);
}
catch (Exception e)
{
diff --git a/dspace-api/src/main/java/org/dspace/submit/lookup/PubmedFileDataLoader.java b/dspace-api/src/main/java/org/dspace/submit/lookup/PubmedFileDataLoader.java
index 393e67a20e..d8a99fad38 100644
--- a/dspace-api/src/main/java/org/dspace/submit/lookup/PubmedFileDataLoader.java
+++ b/dspace-api/src/main/java/org/dspace/submit/lookup/PubmedFileDataLoader.java
@@ -93,7 +93,7 @@ public class PubmedFileDataLoader extends FileDataLoader
Record record = null;
try
{
- record = PubmedUtils.convertCrossRefDomToRecord(xmlArticle);
+ record = PubmedUtils.convertPubmedDomToRecord(xmlArticle);
recordSet.addRecord(convertFields(record));
}
catch (Exception e)
diff --git a/dspace-api/src/main/java/org/dspace/submit/lookup/PubmedService.java b/dspace-api/src/main/java/org/dspace/submit/lookup/PubmedService.java
index aa438259fa..d493672f34 100644
--- a/dspace-api/src/main/java/org/dspace/submit/lookup/PubmedService.java
+++ b/dspace-api/src/main/java/org/dspace/submit/lookup/PubmedService.java
@@ -212,128 +212,71 @@ public class PubmedService
throws HttpException, IOException, ParserConfigurationException,
SAXException
{
- List results = new ArrayList();
- if (!ConfigurationManager.getBooleanProperty(SubmissionLookupService.CFG_MODULE, "remoteservice.demo"))
- {
- GetMethod method = null;
- try
- {
- HttpClient client = new HttpClient();
- client.setTimeout(5 * timeout);
- method = new GetMethod(
- "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi");
+ List results = new ArrayList();
+ GetMethod method = null;
+ try
+ {
+ HttpClient client = new HttpClient();
+ client.setTimeout(5 * timeout);
+ method = new GetMethod(
+ "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi");
- NameValuePair db = new NameValuePair("db", "pubmed");
- NameValuePair retmode = new NameValuePair("retmode", "xml");
- NameValuePair rettype = new NameValuePair("rettype", "full");
- NameValuePair id = new NameValuePair("id", StringUtils.join(
- pubmedIDs.iterator(), ","));
- method.setQueryString(new NameValuePair[] { db, retmode,
- rettype, id });
- // Execute the method.
- int statusCode = client.executeMethod(method);
+ NameValuePair db = new NameValuePair("db", "pubmed");
+ NameValuePair retmode = new NameValuePair("retmode", "xml");
+ NameValuePair rettype = new NameValuePair("rettype", "full");
+ NameValuePair id = new NameValuePair("id", StringUtils.join(
+ pubmedIDs.iterator(), ","));
+ method.setQueryString(new NameValuePair[] { db, retmode,
+ rettype, id });
+ // Execute the method.
+ int statusCode = client.executeMethod(method);
- if (statusCode != HttpStatus.SC_OK)
- {
- throw new RuntimeException("WS call failed: "
- + method.getStatusLine());
- }
+ if (statusCode != HttpStatus.SC_OK)
+ {
+ throw new RuntimeException("WS call failed: "
+ + method.getStatusLine());
+ }
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- factory.setValidating(false);
- factory.setIgnoringComments(true);
- factory.setIgnoringElementContentWhitespace(true);
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ factory.setValidating(false);
+ factory.setIgnoringComments(true);
+ factory.setIgnoringElementContentWhitespace(true);
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document inDoc = builder
- .parse(method.getResponseBodyAsStream());
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document inDoc = builder
+ .parse(method.getResponseBodyAsStream());
- Element xmlRoot = inDoc.getDocumentElement();
- List pubArticles = XMLUtils.getElementList(xmlRoot,
- "PubmedArticle");
+ Element xmlRoot = inDoc.getDocumentElement();
+ List pubArticles = XMLUtils.getElementList(xmlRoot,
+ "PubmedArticle");
- for (Element xmlArticle : pubArticles)
- {
- Record pubmedItem = null;
- try
- {
- pubmedItem = PubmedUtils
- .convertCrossRefDomToRecord(xmlArticle);
- results.add(pubmedItem);
- }
- catch (Exception e)
- {
- throw new RuntimeException(
- "PubmedID is not valid or not exist: "
- + e.getMessage(), e);
- }
- }
+ for (Element xmlArticle : pubArticles)
+ {
+ Record pubmedItem = null;
+ try
+ {
+ pubmedItem = PubmedUtils
+ .convertPubmedDomToRecord(xmlArticle);
+ results.add(pubmedItem);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(
+ "PubmedID is not valid or not exist: "
+ + e.getMessage(), e);
+ }
+ }
- return results;
- }
- finally
- {
- if (method != null)
- {
- method.releaseConnection();
- }
- }
- }
- else
- {
- InputStream stream = null;
- try
- {
- File file = new File(
- ConfigurationManager.getProperty("dspace.dir")
- + "/config/crosswalks/demo/pubmed.xml");
- stream = new FileInputStream(file);
-
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- factory.setValidating(false);
- factory.setIgnoringComments(true);
- factory.setIgnoringElementContentWhitespace(true);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document inDoc = builder.parse(stream);
-
- Element xmlRoot = inDoc.getDocumentElement();
- List pubArticles = XMLUtils.getElementList(xmlRoot,
- "PubmedArticle");
-
- for (Element xmlArticle : pubArticles)
- {
- Record pubmedItem = null;
- try
- {
- pubmedItem = PubmedUtils
- .convertCrossRefDomToRecord(xmlArticle);
- results.add(pubmedItem);
- }
- catch (Exception e)
- {
- throw new RuntimeException(
- "PubmedID is not valid or not exist: "
- + e.getMessage(), e);
- }
- }
-
- return results;
- }
- catch (Exception e)
- {
- throw new RuntimeException(e.getMessage(), e);
- }
- finally
- {
- if (stream != null)
- {
- stream.close();
- }
- }
- }
+ return results;
+ }
+ finally
+ {
+ if (method != null)
+ {
+ method.releaseConnection();
+ }
+ }
}
public List search(String doi, String pmid) throws HttpException,
diff --git a/dspace-api/src/main/java/org/dspace/submit/lookup/PubmedUtils.java b/dspace-api/src/main/java/org/dspace/submit/lookup/PubmedUtils.java
index 7d54c3d664..552db676ef 100644
--- a/dspace-api/src/main/java/org/dspace/submit/lookup/PubmedUtils.java
+++ b/dspace-api/src/main/java/org/dspace/submit/lookup/PubmedUtils.java
@@ -34,7 +34,7 @@ import org.w3c.dom.Element;
public class PubmedUtils
{
- public static Record convertCrossRefDomToRecord(Element pubArticle)
+ public static Record convertPubmedDomToRecord(Element pubArticle)
{
MutableRecord record = new SubmissionLookupPublication("");
diff --git a/dspace-api/src/main/java/org/dspace/submit/lookup/SubmissionLookupService.java b/dspace-api/src/main/java/org/dspace/submit/lookup/SubmissionLookupService.java
index 512bf4197e..b3a6334d55 100644
--- a/dspace-api/src/main/java/org/dspace/submit/lookup/SubmissionLookupService.java
+++ b/dspace-api/src/main/java/org/dspace/submit/lookup/SubmissionLookupService.java
@@ -55,6 +55,8 @@ public class SubmissionLookupService
private TransformationEngine phase1TransformationEngine;
private TransformationEngine phase2TransformationEngine;
+
+ private List detailFields = null;
public void setPhase2TransformationEngine(
TransformationEngine phase2TransformationEngine)
@@ -212,4 +214,12 @@ public class SubmissionLookupService
{
return this.fileProviders;
}
+
+ public List getDetailFields() {
+ return detailFields;
+ }
+
+ public void setDetailFields(List detailFields) {
+ this.detailFields = detailFields;
+ }
}
diff --git a/dspace-api/src/main/resources/Messages.properties b/dspace-api/src/main/resources/Messages.properties
index f75d0e297b..249041d4f6 100644
--- a/dspace-api/src/main/resources/Messages.properties
+++ b/dspace-api/src/main/resources/Messages.properties
@@ -78,6 +78,8 @@ itemlist.dc.type.degree = Degree
itemlist.et-al = et al
itemlist.thumbnail = Preview
+itemlist.title.undefined = Undefined
+
jsp.adminhelp =
jsp.administer = Administer
jsp.admintools = Admin Tools
diff --git a/dspace-api/src/test/java/org/dspace/identifier/MockDOIConnector.java b/dspace-api/src/test/java/org/dspace/identifier/MockDOIConnector.java
index 2517b6dadf..db0f1d9fea 100644
--- a/dspace-api/src/test/java/org/dspace/identifier/MockDOIConnector.java
+++ b/dspace-api/src/test/java/org/dspace/identifier/MockDOIConnector.java
@@ -125,7 +125,7 @@ implements org.dspace.identifier.doi.DOIConnector
if (!reserved.containsKey(doi))
{
throw new DOIIdentifierException("Trying to register an unreserverd "
- + "DOI.", DOIIdentifierException.REGISTER_FIRST);
+ + "DOI.", DOIIdentifierException.RESERVE_FIRST);
}
if (reserved.get(doi).intValue() != dso.getID())
diff --git a/dspace-jspui/pom.xml b/dspace-jspui/pom.xml
index 705dfd37cc..75f88ba28a 100644
--- a/dspace-jspui/pom.xml
+++ b/dspace-jspui/pom.xml
@@ -13,7 +13,7 @@
org.dspace
dspace-parent
- 4.0-rc2-SNAPSHOT
+ 4.0-rc3-SNAPSHOT
..
diff --git a/dspace-jspui/src/main/java/org/dspace/app/webui/json/SubmissionLookupJSONRequest.java b/dspace-jspui/src/main/java/org/dspace/app/webui/json/SubmissionLookupJSONRequest.java
index 404173b70b..aa2aef6172 100644
--- a/dspace-jspui/src/main/java/org/dspace/app/webui/json/SubmissionLookupJSONRequest.java
+++ b/dspace-jspui/src/main/java/org/dspace/app/webui/json/SubmissionLookupJSONRequest.java
@@ -329,7 +329,7 @@ public class SubmissionLookupJSONRequest extends JSONRequest
private Map getDetails(ItemSubmissionLookupDTO item,
Context context)
{
- List fieldOrder = getFieldOrderFromConfiguration();
+ List fieldOrder = getFieldOrder();
Record totalData = item.getTotalPublication(service.getProviders());
Set availableFields = totalData.getFields();
List fieldsLabels = new ArrayList();
@@ -339,10 +339,8 @@ public class SubmissionLookupJSONRequest extends JSONRequest
{
try
{
- fieldsLabels.add(new String[] {
- f,
- I18nUtil.getMessage("jsp.submission-lookup.detail."
- + f, context) });
+ if (totalData.getValues(f)!=null && totalData.getValues(f).size()>0)
+ fieldsLabels.add(new String[] {f, I18nUtil.getMessage("jsp.submission-lookup.detail."+ f, context) });
}
catch (MissingResourceException e)
{
@@ -368,24 +366,37 @@ public class SubmissionLookupJSONRequest extends JSONRequest
return data;
}
- private List getFieldOrderFromConfiguration()
+ private List getFieldOrder()
{
- String config = ConfigurationManager
- .getProperty("submission-lookup.detail.fields");
- if (config == null)
- {
- config = "title,authors,editors,years,doi,pmid,eid,arxiv,journal,jissn,jeissn,volume,issue,serie,sissn,seissn,abstract,mesh,keywords,subtype";
- }
- List result = new ArrayList();
- String[] split = config.split(",");
- for (String s : split)
- {
- if (StringUtils.isNotBlank(s))
- {
- result.add(s.trim());
- }
- }
- return result;
+ if (service.getDetailFields()!=null){
+ return service.getDetailFields();
+ }
+
+ //Default values, in case the property is not set
+ List defaultValues = new ArrayList();
+ defaultValues.add("title");
+ defaultValues.add("authors");
+ defaultValues.add("editors");
+ defaultValues.add("translators");
+ defaultValues.add("chairs");
+ defaultValues.add("issued");
+ defaultValues.add("abstract");
+ defaultValues.add("doi");
+ defaultValues.add("journal");
+ defaultValues.add("volume");
+ defaultValues.add("issue");
+ defaultValues.add("publisher");
+ defaultValues.add("jissn");
+ defaultValues.add("pisbn");
+ defaultValues.add("eisbn");
+ defaultValues.add("arxivCategory");
+ defaultValues.add("keywords");
+ defaultValues.add("mesh");
+ defaultValues.add("language");
+ defaultValues.add("subtype");
+ defaultValues.add("translators");
+
+ return defaultValues;
}
private List