diff --git a/.travis.yml b/.travis.yml index 0581138cef..8c006d0a0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,9 +38,10 @@ script: # -P !assembly => Skip normal assembly (as it can be memory intensive) # -B => Maven batch/non-interactive mode (recommended for CI) # -V => Display Maven version info before build - - "mvn clean install license:check -Dmaven.test.skip=false -DskipITs=false -P !assembly -B -V" + # -Dsurefire.rerunFailingTestsCount=2 => try again for flakey tests, and keep track of/report on number of retries + - "mvn clean install license:check -Dmaven.test.skip=false -DskipITs=false -P !assembly -B -V -Dsurefire.rerunFailingTestsCount=2" # 2. [Assemble DSpace] Ensure assembly process works (from [src]/dspace/), including Mirage 2 # -Dmirage2.on=true => Build Mirage2 # -Dmirage2.deps.included=false => Don't include Mirage2 build dependencies (We installed them in before_install) # -P !assembly => SKIP the actual building of [src]/dspace/dspace-installer (as it can be memory intensive) - - "cd dspace && mvn package -Dmirage2.on=true -Dmirage2.deps.included=false -P !assembly -B -V" + - "cd dspace && mvn package -Dmirage2.on=true -Dmirage2.deps.included=false -P !assembly -B -V -Dsurefire.rerunFailingTestsCount=2" diff --git a/dspace-api/pom.xml b/dspace-api/pom.xml index 089b98d3ed..1ce9be2d2e 100644 --- a/dspace-api/pom.xml +++ b/dspace-api/pom.xml @@ -12,7 +12,7 @@ org.dspace dspace-parent - 6.0-rc2-SNAPSHOT + 6.0-rc3-SNAPSHOT .. @@ -683,13 +683,15 @@ org.apache.ws.commons.axiom axiom-impl - 1.2.17 + + 1.2.14 org.apache.ws.commons.axiom axiom-api - 1.2.17 + + 1.2.14 org.glassfish.jersey.core diff --git a/dspace-api/src/main/java/org/apache/solr/handler/extraction/ExtractingParams.java b/dspace-api/src/main/java/org/apache/solr/handler/extraction/ExtractingParams.java index 60d53822a2..68319795a6 100644 --- a/dspace-api/src/main/java/org/apache/solr/handler/extraction/ExtractingParams.java +++ b/dspace-api/src/main/java/org/apache/solr/handler/extraction/ExtractingParams.java @@ -36,7 +36,7 @@ public interface ExtractingParams { /** * The param prefix for mapping Tika metadata to Solr fields. - *

+ *

* To map a field, add a name like: *

fmap.title=solr.title
* @@ -48,7 +48,7 @@ public interface ExtractingParams { /** * The boost value for the name of the field. The boost can be specified by a name mapping. - *

+ *

* For example *

    * map.title=solr.title
@@ -73,9 +73,9 @@ public interface ExtractingParams {
    * Restrict the extracted parts of a document to be indexed
    *  by passing in an XPath expression.  All content that satisfies the XPath expr.
    * will be passed to the {@link SolrContentHandler}.
-   * 

+ *

* See Tika's docs for what the extracted document looks like. - *

+ *

* @see #CAPTURE_ELEMENTS */ public static final String XPATH_EXPRESSION = "xpath"; @@ -104,11 +104,11 @@ public interface ExtractingParams { /** * Capture the specified fields (and everything included below it that isn't capture by some other capture field) separately from the default. This is different * then the case of passing in an XPath expression. - *

+ *

* The Capture field is based on the localName returned to the {@link SolrContentHandler} * by Tika, not to be confused by the mapped field. The field name can then * be mapped into the index schema. - *

+ *

* For instance, a Tika document may look like: *

    *  <html>
diff --git a/dspace-api/src/main/java/org/dspace/administer/CommunityFiliator.java b/dspace-api/src/main/java/org/dspace/administer/CommunityFiliator.java
index 8e7ece9464..08f6c54aa2 100644
--- a/dspace-api/src/main/java/org/dspace/administer/CommunityFiliator.java
+++ b/dspace-api/src/main/java/org/dspace/administer/CommunityFiliator.java
@@ -46,6 +46,11 @@ public class CommunityFiliator
         handleService = HandleServiceFactory.getInstance().getHandleService();
     }
 
+    /**
+     *
+     * @param argv arguments
+     * @throws Exception if error
+     */
     public static void main(String[] argv) throws Exception
     {
         // create an options object and populate it
@@ -174,6 +179,15 @@ public class CommunityFiliator
         }
     }
 
+    /**
+     *
+     * @param c context
+     * @param parent parent Community
+     * @param child child community
+     * @throws SQLException if database error
+     * @throws AuthorizeException if authorize error
+     * @throws IOException if IO error
+     */
     public void filiate(Context c, Community parent, Community child)
             throws SQLException, AuthorizeException, IOException
     {
@@ -212,6 +226,15 @@ public class CommunityFiliator
                 + "' is parent of community: '" + child.getID() + "'");
     }
 
+    /**
+     *
+     * @param c context
+     * @param parent parent Community
+     * @param child child community
+     * @throws SQLException if database error
+     * @throws AuthorizeException if authorize error
+     * @throws IOException if IO error
+     */
     public void defiliate(Context c, Community parent, Community child)
             throws SQLException, AuthorizeException, IOException
     {
@@ -250,6 +273,13 @@ public class CommunityFiliator
                 + "'");
     }
 
+    /**
+     * Find a community by ID
+     * @param c context
+     * @param communityID community ID
+     * @return Community object
+     * @throws SQLException if database error
+     */
     protected Community resolveCommunity(Context c, String communityID)
             throws SQLException
     {
diff --git a/dspace-api/src/main/java/org/dspace/administer/CreateAdministrator.java b/dspace-api/src/main/java/org/dspace/administer/CreateAdministrator.java
index cb722769a0..b4dbb592c1 100644
--- a/dspace-api/src/main/java/org/dspace/administer/CreateAdministrator.java
+++ b/dspace-api/src/main/java/org/dspace/administer/CreateAdministrator.java
@@ -59,6 +59,7 @@ public final class CreateAdministrator
      * 
      * @param argv
      *            command-line arguments
+     * @throws Exception if error
      */
     public static void main(String[] argv)
     	throws Exception
@@ -92,7 +93,7 @@ public final class CreateAdministrator
     /** 
      * constructor, which just creates and object with a ready context
      * 
-     * @throws Exception
+     * @throws Exception if error
      */
     protected CreateAdministrator()
     	throws Exception
@@ -106,7 +107,7 @@ public final class CreateAdministrator
      * Method which will negotiate with the user via the command line to 
      * obtain the administrator's details
      * 
-     * @throws Exception
+     * @throws Exception if error
      */
     protected void negotiateAdministratorDetails()
     	throws Exception
@@ -228,7 +229,7 @@ public final class CreateAdministrator
      * @param language preferred language
      * @param pw	desired password
      * 
-     * @throws Exception
+     * @throws Exception if error
      */
     protected void createAdministrator(String email, String first, String last,
     		String language, String pw)
diff --git a/dspace-api/src/main/java/org/dspace/administer/MetadataExporter.java b/dspace-api/src/main/java/org/dspace/administer/MetadataExporter.java
index 70529f0255..d21acc038e 100644
--- a/dspace-api/src/main/java/org/dspace/administer/MetadataExporter.java
+++ b/dspace-api/src/main/java/org/dspace/administer/MetadataExporter.java
@@ -7,19 +7,7 @@
  */
 package org.dspace.administer;
 
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.cli.PosixParser;
+import org.apache.commons.cli.*;
 import org.apache.xml.serialize.Method;
 import org.apache.xml.serialize.OutputFormat;
 import org.apache.xml.serialize.XMLSerializer;
@@ -31,6 +19,14 @@ import org.dspace.content.service.MetadataSchemaService;
 import org.dspace.core.Context;
 import org.xml.sax.SAXException;
 
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 
 /**
  * @author Graham Triggs
@@ -39,13 +35,14 @@ import org.xml.sax.SAXException;
  * from the metadata schemas for the repository.
  * 
  * The form of the XML is as follows
- * 
+ * {@code
  * 
  *   
  *     dc
  *     http://dublincore.org/documents/dcmi-terms/
  *   
  * 
+ * }
  */
 public class MetadataExporter
 {
@@ -54,12 +51,12 @@ public class MetadataExporter
     protected static MetadataFieldService metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService();
 
     /**
-     * @param args
-     * @throws ParseException 
-     * @throws SAXException 
-     * @throws IOException 
-     * @throws SQLException 
-     * @throws RegistryExportException 
+     * @param args commandline arguments
+     * @throws ParseException if parser error 
+     * @throws SAXException if XML parse error
+     * @throws IOException if IO error
+     * @throws SQLException if database error
+     * @throws RegistryExportException if export error
      */
     public static void main(String[] args) throws ParseException, SQLException, IOException, SAXException, RegistryExportException
     {
@@ -91,6 +88,15 @@ public class MetadataExporter
         saveRegistry(file, schema);
     }
 
+    /**
+     * Save a registry to a filepath
+     * @param file filepath
+     * @param schema schema definition to save
+     * @throws SQLException if database error
+     * @throws IOException if IO error
+     * @throws SAXException if XML error
+     * @throws RegistryExportException if export error
+     */
     public static void saveRegistry(String file, String schema) throws SQLException, IOException, SAXException, RegistryExportException
     {
         // create a context
@@ -145,12 +151,12 @@ public class MetadataExporter
     
     /**
      * Serialize the schema registry. If the parameter 'schema' is null or empty, save all schemas
-     * @param context
-     * @param xmlSerializer
-     * @param schema
-     * @throws SQLException
-     * @throws SAXException
-     * @throws RegistryExportException
+     * @param context DSpace Context
+     * @param xmlSerializer XML serializer
+     * @param schema schema (may be null to save all)
+     * @throws SQLException if database error
+     * @throws SAXException if XML error
+     * @throws RegistryExportException if export error
      */
     public static void saveSchema(Context context, XMLSerializer xmlSerializer, String schema) throws SQLException, SAXException, RegistryExportException
     {
@@ -176,10 +182,10 @@ public class MetadataExporter
     /**
      * Serialize a single schema (namespace) registry entry
      * 
-     * @param xmlSerializer
-     * @param mdSchema
-     * @throws SAXException
-     * @throws RegistryExportException
+     * @param xmlSerializer XML serializer
+     * @param mdSchema DSpace metadata schema
+     * @throws SAXException if XML error
+     * @throws RegistryExportException if export error
      */
     private static void saveSchema(XMLSerializer xmlSerializer, MetadataSchema mdSchema) throws SAXException, RegistryExportException
     {
@@ -223,13 +229,13 @@ public class MetadataExporter
     /**
      * Serialize a single metadata field registry entry to xml
      * 
-     * @param context
-     * @param xmlSerializer
-     * @param mdField
-     * @throws SAXException
-     * @throws RegistryExportException
-     * @throws SQLException
-     * @throws IOException 
+     * @param context DSpace context
+     * @param xmlSerializer xml serializer
+     * @param mdField DSpace metadata field
+     * @throws SAXException if XML error
+     * @throws RegistryExportException if export error
+     * @throws SQLException if database error
+     * @throws IOException if IO error
      */
     private static void saveType(Context context, XMLSerializer xmlSerializer, MetadataField mdField) throws SAXException, RegistryExportException, SQLException, IOException
     {
@@ -291,24 +297,29 @@ public class MetadataExporter
         xmlSerializer.endElement("dc-type");
     }
     
+    static Map schemaMap = new HashMap();
     /**
      * Helper method to retrieve a schema name for the field.
      * Caches the name after looking up the id.
+     * @param context DSpace Context
+     * @param mdField DSpace metadata field
+     * @return name of schema
+     * @throws SQLException if database error
+     * @throws RegistryExportException if export error
      */
-    static Map schemaMap = new HashMap();
     private static String getSchemaName(Context context, MetadataField mdField) throws SQLException, RegistryExportException
     {
         // Get name from cache
-        String name = schemaMap.get(mdField.getMetadataSchema().getSchemaID());
+        String name = schemaMap.get(mdField.getMetadataSchema().getID());
 
         if (name == null)
         {
             // Name not retrieved before, so get the schema now
-            MetadataSchema mdSchema = metadataSchemaService.find(context, mdField.getMetadataSchema().getSchemaID());
+            MetadataSchema mdSchema = metadataSchemaService.find(context, mdField.getMetadataSchema().getID());
             if (mdSchema != null)
             {
                 name = mdSchema.getName();
-                schemaMap.put(mdSchema.getSchemaID(), name);
+                schemaMap.put(mdSchema.getID(), name);
             }
             else
             {
diff --git a/dspace-api/src/main/java/org/dspace/administer/MetadataImporter.java b/dspace-api/src/main/java/org/dspace/administer/MetadataImporter.java
index 490301fb26..1e1882d7ae 100644
--- a/dspace-api/src/main/java/org/dspace/administer/MetadataImporter.java
+++ b/dspace-api/src/main/java/org/dspace/administer/MetadataImporter.java
@@ -47,6 +47,7 @@ import org.xml.sax.SAXException;
  * 
  * The format of the XML file is as follows:
  * 
+ * {@code
  * 
  *   
  *     icadmin
@@ -58,6 +59,7 @@ import org.xml.sax.SAXException;
  *   [....]
  *   
  * 
+ * }
  */
 public class MetadataImporter
 {
@@ -67,9 +69,19 @@ public class MetadataImporter
     /** logging category */
     private static final Logger log = LoggerFactory.getLogger(MetadataImporter.class);
 
-	/**
-	 * main method for reading user input from the command line
-	 */
+    /**
+     * main method for reading user input from the command line
+     * @param args arguments
+     * @throws ParseException if parse error
+     * @throws SQLException if database error
+     * @throws IOException if IO error
+     * @throws TransformerException if transformer error
+     * @throws ParserConfigurationException if config error
+     * @throws AuthorizeException if authorization error
+     * @throws SAXException if parser error
+     * @throws NonUniqueMetadataException if duplicate metadata
+     * @throws RegistryImportException if import fails
+     **/
     public static void main(String[] args)
     	throws ParseException, SQLException, IOException, TransformerException,
     			ParserConfigurationException, AuthorizeException, SAXException,
@@ -103,6 +115,15 @@ public class MetadataImporter
      * Load the data from the specified file path into the database
      * 
      * @param 	file	the file path containing the source data
+     * @param   forceUpdate whether to force update
+     * @throws SQLException if database error
+     * @throws IOException if IO error
+     * @throws TransformerException if transformer error
+     * @throws ParserConfigurationException if config error
+     * @throws AuthorizeException if authorization error
+     * @throws SAXException if parser error
+     * @throws NonUniqueMetadataException if duplicate metadata
+     * @throws RegistryImportException if import fails
      */
     public static void loadRegistry(String file, boolean forceUpdate)
     	throws SQLException, IOException, TransformerException, ParserConfigurationException, 
@@ -158,7 +179,12 @@ public class MetadataImporter
      *            DSpace context object
      * @param node
      *            the node in the DOM tree
-     * @throws NonUniqueMetadataException
+     * @throws SQLException if database error
+     * @throws IOException if IO error
+     * @throws TransformerException if transformer error
+     * @throws AuthorizeException if authorization error
+     * @throws NonUniqueMetadataException if duplicate metadata
+     * @throws RegistryImportException if import fails
      */
     private static void loadSchema(Context context, Node node, boolean updateExisting)
         throws SQLException, IOException, TransformerException,
@@ -221,7 +247,12 @@ public class MetadataImporter
      *            DSpace context object
      * @param node
      *            the node in the DOM tree
-     * @throws NonUniqueMetadataException
+     * @throws SQLException if database error
+     * @throws IOException if IO error
+     * @throws TransformerException if transformer error
+     * @throws AuthorizeException if authorization error
+     * @throws NonUniqueMetadataException if duplicate metadata
+     * @throws RegistryImportException if import fails
      */
     private static void loadType(Context context, Node node)
             throws SQLException, IOException, TransformerException,
diff --git a/dspace-api/src/main/java/org/dspace/administer/RegistryExportException.java b/dspace-api/src/main/java/org/dspace/administer/RegistryExportException.java
index 5f2ea7e227..d40a11ec19 100644
--- a/dspace-api/src/main/java/org/dspace/administer/RegistryExportException.java
+++ b/dspace-api/src/main/java/org/dspace/administer/RegistryExportException.java
@@ -25,7 +25,7 @@ public class RegistryExportException extends Exception
     /**
      * create an exception with only a message
      * 
-     * @param message
+     * @param message exception message
      */
     public RegistryExportException(String message)
     {
@@ -35,8 +35,8 @@ public class RegistryExportException extends Exception
     /**
      * create an exception with an inner exception and a message
      * 
-     * @param   message
-     * @param   e
+     * @param message exception message
+     * @param e reference to Throwable
      */
     public RegistryExportException(String message, Throwable e)
     {
@@ -46,7 +46,7 @@ public class RegistryExportException extends Exception
     /**
      * create an exception with an inner exception
      * 
-     * @param   e
+     * @param e reference to Throwable
      */
     public RegistryExportException(Throwable e)
     {
diff --git a/dspace-api/src/main/java/org/dspace/administer/RegistryImportException.java b/dspace-api/src/main/java/org/dspace/administer/RegistryImportException.java
index b49bc4111b..5a15631dfb 100644
--- a/dspace-api/src/main/java/org/dspace/administer/RegistryImportException.java
+++ b/dspace-api/src/main/java/org/dspace/administer/RegistryImportException.java
@@ -25,7 +25,7 @@ public class RegistryImportException extends Exception
     /**
      * create an exception with only a message
      * 
-     * @param message
+     * @param message error message
      */
     public RegistryImportException(String message)
     {
@@ -35,8 +35,8 @@ public class RegistryImportException extends Exception
     /**
      * create an exception with an inner exception and a message
      * 
-     * @param	message
-     * @param	e
+     * @param	message error message
+     * @param	e throwable
      */
     public RegistryImportException(String message, Throwable e)
     {
@@ -46,7 +46,7 @@ public class RegistryImportException extends Exception
     /**
      * create an exception with an inner exception
      * 
-     * @param	e
+     * @param	e throwable
      */
     public RegistryImportException(Throwable e)
     {
diff --git a/dspace-api/src/main/java/org/dspace/administer/RegistryImporter.java b/dspace-api/src/main/java/org/dspace/administer/RegistryImporter.java
index 6f34eae3cd..b8a7c2456a 100644
--- a/dspace-api/src/main/java/org/dspace/administer/RegistryImporter.java
+++ b/dspace-api/src/main/java/org/dspace/administer/RegistryImporter.java
@@ -40,6 +40,9 @@ public class RegistryImporter
      *            the filename to load from
      * 
      * @return the DOM representation of the XML file
+     * @throws IOException if IO error
+     * @throws ParserConfigurationException if configuration parse error
+     * @throws SAXException if XML parse error
      */
     public static Document loadXML(String filename) 
     	throws IOException, ParserConfigurationException, SAXException
@@ -68,7 +71,7 @@ public class RegistryImporter
      *            the element, whose child element you want the CDATA from
      * @param childName
      *            the name of the element you want the CDATA from
-     * 
+     * @throws TransformerException if error
      * @return the CDATA as a String
      */
     public static String getElementData(Node parentElement, String childName)
@@ -116,7 +119,7 @@ public class RegistryImporter
      *            the element, whose child element you want the CDATA from
      * @param childName
      *            the name of the element you want the CDATA from
-     * 
+     * @throws TransformerException if error
      * @return the CDATA as a String
      */
     public static String[] getRepeatedElementData(Node parentElement,
diff --git a/dspace-api/src/main/java/org/dspace/administer/RegistryLoader.java b/dspace-api/src/main/java/org/dspace/administer/RegistryLoader.java
index 3246506c7e..092a61e145 100644
--- a/dspace-api/src/main/java/org/dspace/administer/RegistryLoader.java
+++ b/dspace-api/src/main/java/org/dspace/administer/RegistryLoader.java
@@ -56,6 +56,7 @@ public class RegistryLoader
      * 
      * @param argv
      *            command-line arguments
+     * @throws Exception if error
      */
     public static void main(String[] argv) throws Exception
     {
@@ -121,6 +122,12 @@ public class RegistryLoader
      *            DSpace context object
      * @param filename
      *            the filename of the XML file to load
+     * @throws SQLException if database error
+     * @throws IOException if IO error
+     * @throws TransformerException if transformer error
+     * @throws ParserConfigurationException if config error
+     * @throws AuthorizeException if authorization error
+     * @throws SAXException if parser error
      */
     public static void loadBitstreamFormats(Context context, String filename)
             throws SQLException, IOException, ParserConfigurationException,
@@ -151,6 +158,10 @@ public class RegistryLoader
      *            DSpace context object
      * @param node
      *            the node in the DOM tree
+     * @throws SQLException if database error
+     * @throws IOException if IO error
+     * @throws TransformerException if transformer error
+     * @throws AuthorizeException if authorization error
      */
     private static void loadFormat(Context context, Node node)
             throws SQLException, IOException, TransformerException,
@@ -206,7 +217,9 @@ public class RegistryLoader
      * 
      * @param filename
      *            the filename to load from
-     * 
+     * @throws IOException if IO error
+     * @throws ParserConfigurationException if config error
+     * @throws SAXException if parser error
      * @return the DOM representation of the XML file
      */
     private static Document loadXML(String filename) throws IOException,
@@ -234,7 +247,7 @@ public class RegistryLoader
      *            the element, whose child element you want the CDATA from
      * @param childName
      *            the name of the element you want the CDATA from
-     * 
+     * @throws TransformerException if transformer error
      * @return the CDATA as a String
      */
     private static String getElementData(Node parentElement, String childName)
@@ -282,7 +295,7 @@ public class RegistryLoader
      *            the element, whose child element you want the CDATA from
      * @param childName
      *            the name of the element you want the CDATA from
-     * 
+     * @throws TransformerException if transformer error
      * @return the CDATA as a String
      */
     private static String[] getRepeatedElementData(Node parentElement,
diff --git a/dspace-api/src/main/java/org/dspace/administer/StructBuilder.java b/dspace-api/src/main/java/org/dspace/administer/StructBuilder.java
index 5ee16eee38..e90d4ae962 100644
--- a/dspace-api/src/main/java/org/dspace/administer/StructBuilder.java
+++ b/dspace-api/src/main/java/org/dspace/administer/StructBuilder.java
@@ -46,7 +46,7 @@ import org.xml.sax.SAXException;
  * an XML file.
  * 
  * The XML file structure needs to be:
- * 
+ * {@code
  * 
  *     
  *         ....
@@ -56,7 +56,7 @@ import org.xml.sax.SAXException;
  *         
  *     
  * 
- * 
+ * }
  * it can be arbitrarily deep, and supports all the metadata elements
  * that make up the community and collection metadata.  See the system
  * documentation for more details
@@ -88,10 +88,12 @@ public class StructBuilder
      * 
      * This is of the form:
      * 
-     * StructBuilder -f [xml source] -e [administrator email] -o [output file]
+     * {@code StructBuilder -f [xml source] -e [administrator email] -o [output file]}
      * 
      * The output file will contain exactly the same as the source xml document, but
      * with the handle for each imported item added as an attribute.
+     * @param argv commandline arguments
+     * @throws Exception if an error occurs
      */
     public static void main(String[] argv) 
     	throws Exception
@@ -203,7 +205,7 @@ public class StructBuilder
      * fails it generates an error and ceases execution
      * 
      * @param	document	the XML document object
-     * @throws TransformerException
+     * @throws TransformerException if transformer error
      * 
      */
     private static void validate(org.w3c.dom.Document document)
diff --git a/dspace-api/src/main/java/org/dspace/app/bulkedit/DSpaceCSVLine.java b/dspace-api/src/main/java/org/dspace/app/bulkedit/DSpaceCSVLine.java
index b71f7c7c24..d8d793f063 100644
--- a/dspace-api/src/main/java/org/dspace/app/bulkedit/DSpaceCSVLine.java
+++ b/dspace-api/src/main/java/org/dspace/app/bulkedit/DSpaceCSVLine.java
@@ -150,7 +150,7 @@ public class DSpaceCSVLine implements Serializable
      * Write this line out as a CSV formatted string, in the order given by the headings provided
      *
      * @param headings The headings which define the order the elements must be presented in
-     * @param fieldSeparator
+     * @param fieldSeparator field separator
      * @return The CSV formatted String
      */
     protected String toCSV(List headings, String fieldSeparator)
@@ -179,7 +179,7 @@ public class DSpaceCSVLine implements Serializable
      * Internal method to create a CSV formatted String joining a given set of elements
      *
      * @param values The values to create the string from
-     * @param valueSeparator
+     * @param valueSeparator value separator
      * @return The line as a CSV formatted String
      */
     protected String valueToCSV(List values, String valueSeparator)
diff --git a/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataExport.java b/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataExport.java
index cb79723370..319535b003 100644
--- a/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataExport.java
+++ b/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataExport.java
@@ -71,7 +71,7 @@ public class MetadataExport
         try
         {
             // Try to export the community
-            this.toExport = buildFromCommunity(c, toExport, new ArrayList(), 0);
+            this.toExport = buildFromCommunity(c, toExport, 0);
             this.exportAll = exportAll;
         }
         catch (SQLException sqle)
@@ -86,13 +86,13 @@ public class MetadataExport
     /**
      * Build an array list of item ids that are in a community (include sub-communities and collections)
      *
+     * @param context DSpace context
      * @param community The community to build from
-     * @param itemIDs The itemID (used for recursion - use an empty ArrayList)
      * @param indent How many spaces to use when writing out the names of items added
      * @return The list of item ids
-     * @throws SQLException
+     * @throws SQLException if database error
      */
-    protected Iterator buildFromCommunity(Context context, Community community, List itemIDs, int indent)
+    protected Iterator buildFromCommunity(Context context, Community community, int indent)
                                                                                throws SQLException
     {
         // Add all the collections
@@ -106,12 +106,7 @@ public class MetadataExport
             }
 
             Iterator items = itemService.findByCollection(context, collection);
-            if(result == null)
-            {
-                result = items;
-            }else{
-                result = Iterators.concat(result, items);
-            }
+            result = addItemsToResult(result,items);
 
         }
         // Add all the sub-communities
@@ -122,7 +117,19 @@ public class MetadataExport
             {
                 System.out.print(" ");
             }
-            buildFromCommunity(context, subCommunity, itemIDs, indent + 1);
+            Iterator items = buildFromCommunity(context, subCommunity, indent + 1);
+            result = addItemsToResult(result,items);
+        }
+
+        return result;
+    }
+
+    private Iterator addItemsToResult(Iterator result, Iterator items) {
+        if(result == null)
+        {
+            result = items;
+        }else{
+            result = Iterators.concat(result, items);
         }
 
         return result;
@@ -176,6 +183,7 @@ public class MetadataExport
 	 * main method to run the metadata exporter
 	 *
 	 * @param argv the command line arguments given
+         * @throws Exception if error occurs
 	 */
     public static void main(String[] argv) throws Exception
     {
diff --git a/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataImport.java b/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataImport.java
index 323305fa23..82598b1c2e 100644
--- a/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataImport.java
+++ b/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataImport.java
@@ -420,8 +420,7 @@ public class MetadataImport
      * @param change Whether or not to make the update
      * @param md The element to compare
      * @param changes The changes object to populate
-     *
-     * @param line
+     * @param line line in CSV file
      * @throws SQLException if there is a problem accessing a Collection from the database, from its handle
      * @throws AuthorizeException if there is an authorization problem with permissions
      */
diff --git a/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataImportInvalidHeadingException.java b/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataImportInvalidHeadingException.java
index c1eb0db0d5..0ee4980909 100644
--- a/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataImportInvalidHeadingException.java
+++ b/dspace-api/src/main/java/org/dspace/app/bulkedit/MetadataImportInvalidHeadingException.java
@@ -41,6 +41,7 @@ public class MetadataImportInvalidHeadingException extends Exception
      *
      * @param message the error message
      * @param theType the type of the error
+     * @param theColumn column number
      */
     public MetadataImportInvalidHeadingException(String message, int theType, int theColumn)
     {
diff --git a/dspace-api/src/main/java/org/dspace/app/bulkedit/package-info.java b/dspace-api/src/main/java/org/dspace/app/bulkedit/package-info.java
index 5393ca8aa1..2a55f9cbd3 100644
--- a/dspace-api/src/main/java/org/dspace/app/bulkedit/package-info.java
+++ b/dspace-api/src/main/java/org/dspace/app/bulkedit/package-info.java
@@ -9,7 +9,6 @@
 /**
  * 

The DSpace Batch Metadata Editor, which uses a CSV file to export/import * item metadata.

- *

*

    *
  • works on items, communities, collections or the whole site
  • *
  • can also create new items, delete items and withdraw/restore them
  • diff --git a/dspace-api/src/main/java/org/dspace/app/checker/ChecksumChecker.java b/dspace-api/src/main/java/org/dspace/app/checker/ChecksumChecker.java index bdfc7a34f5..df8b1eddbf 100644 --- a/dspace-api/src/main/java/org/dspace/app/checker/ChecksumChecker.java +++ b/dspace-api/src/main/java/org/dspace/app/checker/ChecksumChecker.java @@ -29,7 +29,7 @@ import org.dspace.core.Utils; /** * Command line access to the checksum checker. Options are listed in the - * documentation for the main method.

    + * documentation for the main method. * * @author Jim Downing * @author Grace Carpenter @@ -72,6 +72,7 @@ public final class ChecksumChecker *
    -p
    *
    Don't prune results before running checker
    * + * @throws SQLException if error */ public static void main(String[] args) throws SQLException { // set up command line parser diff --git a/dspace-api/src/main/java/org/dspace/app/harvest/Harvest.java b/dspace-api/src/main/java/org/dspace/app/harvest/Harvest.java index c1e809e68c..3e74bc12e7 100644 --- a/dspace-api/src/main/java/org/dspace/app/harvest/Harvest.java +++ b/dspace-api/src/main/java/org/dspace/app/harvest/Harvest.java @@ -390,7 +390,8 @@ public class Harvest hc.setHarvestStartTime(null); harvestedCollectionService.update(context, hc); } - context.restoreAuthSystemState(); + context.restoreAuthSystemState(); + context.dispatchEvents(); } catch (Exception e) { System.out.println("Changes could not be committed"); diff --git a/dspace-api/src/main/java/org/dspace/app/itemexport/ItemExportCLITool.java b/dspace-api/src/main/java/org/dspace/app/itemexport/ItemExportCLITool.java index 6c94a462ed..9ed24ba433 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemexport/ItemExportCLITool.java +++ b/dspace-api/src/main/java/org/dspace/app/itemexport/ItemExportCLITool.java @@ -34,8 +34,8 @@ import java.util.*; * core in RDF schema / contents - text file, listing one file per line / file1 * - files contained in the item / file2 / ... *

    - * issues -doesn't handle special characters in metadata (needs to turn &'s into - * &, etc.) + * issues -doesn't handle special characters in metadata (needs to turn {@code &'s} into + * {@code &}, etc.) *

    * Modified by David Little, UCSD Libraries 12/21/04 to allow the registration * of files (bitstreams) into DSpace. diff --git a/dspace-api/src/main/java/org/dspace/app/itemexport/ItemExportServiceImpl.java b/dspace-api/src/main/java/org/dspace/app/itemexport/ItemExportServiceImpl.java index 39e86e2c9e..28181e6ea0 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemexport/ItemExportServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/app/itemexport/ItemExportServiceImpl.java @@ -57,8 +57,8 @@ import org.springframework.beans.factory.annotation.Autowired; * core in RDF schema / contents - text file, listing one file per line / file1 * - files contained in the item / file2 / ... *

    - * issues -doesn't handle special characters in metadata (needs to turn &'s into - * &, etc.) + * issues -doesn't handle special characters in metadata (needs to turn {@code &'s} into + * {@code &}, etc.) *

    * Modified by David Little, UCSD Libraries 12/21/04 to allow the registration * of files (bitstreams) into DSpace. @@ -180,10 +180,11 @@ public class ItemExportServiceImpl implements ItemExportService * Discover the different schemas in use and output a separate metadata XML * file for each schema. * - * @param c - * @param i - * @param destDir - * @throws Exception + * @param c DSpace context + * @param i DSpace Item + * @param destDir destination directory + * @param migrate Whether to use the migrate option or not + * @throws Exception if error */ protected void writeMetadata(Context c, Item i, File destDir, boolean migrate) throws Exception @@ -202,7 +203,15 @@ public class ItemExportServiceImpl implements ItemExportService } } - // output the item's dublin core into the item directory + /** + * output the item's dublin core into the item directory + * @param c DSpace context + * @param schema schema + * @param i DSpace Item + * @param destDir destination directory + * @param migrate Whether to use the migrate option or not + * @throws Exception if error + */ protected void writeMetadata(Context c, String schema, Item i, File destDir, boolean migrate) throws Exception { @@ -318,7 +327,13 @@ public class ItemExportServiceImpl implements ItemExportService } } - // create the file 'handle' which contains the handle assigned to the item + /** + * create the file 'handle' which contains the handle assigned to the item + * @param c DSpace Context + * @param i DSpace Item + * @param destDir destination directory + * @throws Exception if error + */ protected void writeHandle(Context c, Item i, File destDir) throws Exception { @@ -358,7 +373,9 @@ public class ItemExportServiceImpl implements ItemExportService * the item being exported * @param destDir * the item's export directory - * @throws Exception + * @param excludeBitstreams + * whether to exclude bitstreams + * @throws Exception if error * if there is any problem writing to the export directory */ protected void writeBitstreams(Context c, Item i, File destDir, @@ -531,7 +548,8 @@ public class ItemExportServiceImpl implements ItemExportService * - the dspace context * @param additionalEmail * - email address to cc in addition the the current user email - * @throws Exception + * @param toMigrate Whether to use the migrate option or not + * @throws Exception if error */ protected void processDownloadableExport(List dsObjects, Context context, final String additionalEmail, boolean toMigrate) throws Exception @@ -808,7 +826,7 @@ public class ItemExportServiceImpl implements ItemExportService "A dspace.cfg entry for 'org.dspace.app.itemexport.download.dir' does not exist."); } File result = new File(downloadDir + System.getProperty("file.separator") + ePerson.getID()); - if(!result.exists()) + if(!result.exists() && ePerson.getLegacyId()!=null) { //Check for the old identifier result = new File(downloadDir + System.getProperty("file.separator") + ePerson.getLegacyId()); @@ -868,6 +886,13 @@ public class ItemExportServiceImpl implements ItemExportService return file.length(); } + /** + * Attempt to find an EPerson based on string ID + * @param context DSpace context + * @param strID string identifier + * @return EPerson object (if found) + * @throws SQLException if database error + */ protected EPerson getEPersonFromString(Context context, String strID) throws SQLException { EPerson eperson; try{ @@ -1105,6 +1130,14 @@ public class ItemExportServiceImpl implements ItemExportService } } + /** + * + * @param cpFile file + * @param strSource source location + * @param strTarget target location + * @param cpZipOutputStream current zip outputstream + * @throws Exception if error + */ protected void zipFiles(File cpFile, String strSource, String strTarget, ZipOutputStream cpZipOutputStream) throws Exception @@ -1158,6 +1191,11 @@ public class ItemExportServiceImpl implements ItemExportService } } + /** + * Delete a directory + * @param path directory path + * @return true if successful, false otherwise + */ protected boolean deleteDirectory(File path) { if (path.exists()) diff --git a/dspace-api/src/main/java/org/dspace/app/itemexport/service/ItemExportService.java b/dspace-api/src/main/java/org/dspace/app/itemexport/service/ItemExportService.java index 141bc8e3db..e93a2f22b2 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemexport/service/ItemExportService.java +++ b/dspace-api/src/main/java/org/dspace/app/itemexport/service/ItemExportService.java @@ -30,8 +30,8 @@ import java.util.List; * core in RDF schema / contents - text file, listing one file per line / file1 * - files contained in the item / file2 / ... *

    - * issues -doesn't handle special characters in metadata (needs to turn &'s into - * &, etc.) + * issues -doesn't handle special characters in metadata (needs to turn {@code &'s} into + * {@code &}, etc.) *

    * Modified by David Little, UCSD Libraries 12/21/04 to allow the registration * of files (bitstreams) into DSpace. @@ -59,7 +59,8 @@ public interface ItemExportService { * @param zipFileName The name to save the zip file as * @param seqStart The first number in the sequence * @param migrate Whether to use the migrate option or not - * @throws Exception + * @param excludeBitstreams Whether to exclude bitstreams or not + * @throws Exception if error */ public void exportAsZip(Context context, Iterator items, String destDirName, String zipFileName, @@ -74,7 +75,8 @@ public interface ItemExportService { * - the dspace object to export * @param context * - the dspace context - * @throws Exception + * @param migrate Whether to use the migrate option or not + * @throws Exception if error */ public void createDownloadableExport(DSpaceObject dso, Context context, boolean migrate) throws Exception; @@ -87,7 +89,8 @@ public interface ItemExportService { * - List containing dspace objects * @param context * - the dspace context - * @throws Exception + * @param migrate Whether to use the migrate option or not + * @throws Exception if error */ public void createDownloadableExport(List dsObjects, Context context, boolean migrate) throws Exception; @@ -102,7 +105,8 @@ public interface ItemExportService { * - the dspace context * @param additionalEmail * - cc email to use - * @throws Exception + * @param migrate Whether to use the migrate option or not + * @throws Exception if error */ public void createDownloadableExport(DSpaceObject dso, Context context, String additionalEmail, boolean migrate) throws Exception; @@ -117,7 +121,8 @@ public interface ItemExportService { * - the dspace context * @param additionalEmail * - cc email to use - * @throws Exception + * @param migrate Whether to use the migrate option or not + * @throws Exception if error */ public void createDownloadableExport(List dsObjects, Context context, String additionalEmail, boolean migrate) throws Exception; @@ -126,13 +131,14 @@ public interface ItemExportService { /** * Create a file name based on the date and eperson * + * @param type Type of object (as string) * @param eperson * - eperson who requested export and will be able to download it * @param date * - the date the export process was created * @return String representing the file name in the form of * 'export_yyy_MMM_dd_count_epersonID' - * @throws Exception + * @throws Exception if error */ public String assembleFileName(String type, EPerson eperson, Date date) throws Exception; @@ -146,7 +152,7 @@ public interface ItemExportService { * - the eperson who requested export archive * @return String representing a directory in the form of * org.dspace.app.itemexport.download.dir/epersonID - * @throws Exception + * @throws Exception if error */ public String getExportDownloadDirectory(EPerson ePerson) throws Exception; @@ -157,7 +163,7 @@ public interface ItemExportService { * * @return String representing config file entry for * org.dspace.app.itemexport.work.dir - * @throws Exception + * @throws Exception if error */ public String getExportWorkDirectory() throws Exception; @@ -169,7 +175,7 @@ public interface ItemExportService { * @param eperson * the eperson requesting the download * @return an input stream of the file to be downloaded - * @throws Exception + * @throws Exception if error */ public InputStream getExportDownloadInputStream(String fileName, EPerson eperson) throws Exception; @@ -177,12 +183,24 @@ public interface ItemExportService { /** * Get the file size of the export archive represented by the file name. * + * @param context DSpace context * @param fileName * name of the file to get the size. - * @throws Exception + * @throws Exception if error + * @return size as long */ public long getExportFileSize(Context context, String fileName) throws Exception; + /** + * Get the last modified date of the export archive represented by the file name. + * + * @param context DSpace context + * @param fileName + * name of the file to get the size. + * @return date as long + * @see java.io.File#lastModified() + * @throws Exception if error + */ public long getExportFileLastModified(Context context, String fileName) throws Exception; @@ -203,10 +221,10 @@ public interface ItemExportService { * Reads the download directory for the eperson to see if any export * archives are available * - * @param eperson + * @param eperson EPerson object * @return a list of file names representing export archives that have been * processed - * @throws Exception + * @throws Exception if error */ public List getExportsAvailable(EPerson eperson) throws Exception; @@ -218,7 +236,7 @@ public interface ItemExportService { * * @param eperson * - the eperson to clean up - * @throws Exception + * @throws Exception if error */ public void deleteOldExportArchives(EPerson eperson) throws Exception; @@ -228,7 +246,7 @@ public interface ItemExportService { * determine if the current exports are too old and need purgeing * Removes all old exports, not just those for the person doing the export. * - * @throws Exception + * @throws Exception if error */ public void deleteOldExportArchives() throws Exception; @@ -245,7 +263,7 @@ public interface ItemExportService { * @param fileName * - the file name to be downloaded. It is added to the url in * the email - * @throws MessagingException + * @throws MessagingException if error */ public void emailSuccessMessage(Context context, EPerson eperson, String fileName) throws MessagingException; @@ -260,11 +278,17 @@ public interface ItemExportService { * - EPerson to send the error message to * @param error * - the error message - * @throws MessagingException + * @throws MessagingException if error */ public void emailErrorMessage(EPerson eperson, String error) throws MessagingException; + /** + * Zip source to target + * @param strSource source file + * @param target target file + * @throws Exception if error + */ public void zip(String strSource, String target) throws Exception; } diff --git a/dspace-api/src/main/java/org/dspace/app/itemimport/BTEBatchImportService.java b/dspace-api/src/main/java/org/dspace/app/itemimport/BTEBatchImportService.java index 1513eaecf4..df2a63eaa9 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemimport/BTEBatchImportService.java +++ b/dspace-api/src/main/java/org/dspace/app/itemimport/BTEBatchImportService.java @@ -20,7 +20,7 @@ import java.util.Map; /** - * This class acts as a Service in the procedure ot batch import using the Biblio-Transformation-Engine + * This class acts as a Service in the procedure to batch import using the Biblio-Transformation-Engine */ public class BTEBatchImportService { @@ -39,7 +39,7 @@ public class BTEBatchImportService /** * Setter method for dataLoaders parameter - * @param dataLoaders + * @param dataLoaders map of data loaders */ public void setDataLoaders(Map dataLoaders) { @@ -47,7 +47,7 @@ public class BTEBatchImportService } /** - * + * Get data loaders * @return the map of DataLoaders */ public Map getDataLoaders() @@ -56,7 +56,7 @@ public class BTEBatchImportService } /** - * + * Get output map * @return the outputMapping */ public Map getOutputMap() { @@ -65,20 +65,32 @@ public class BTEBatchImportService /** * Setter method for the outputMapping - * @param outputMapping + * @param outputMap the output mapping */ public void setOutputMap(Map outputMap) { this.outputMap = outputMap; } + /** + * Get transformation engine + * @return transformation engine + */ public TransformationEngine getTransformationEngine() { return transformationEngine; } + /** + * set transformation engine + * @param transformationEngine transformation engine + */ public void setTransformationEngine(TransformationEngine transformationEngine) { this.transformationEngine = transformationEngine; } + /** + * Getter of file data loaders + * @return List of file data loaders + */ public List getFileDataLoaders(){ List result = new ArrayList(); diff --git a/dspace-api/src/main/java/org/dspace/app/itemimport/BatchUpload.java b/dspace-api/src/main/java/org/dspace/app/itemimport/BatchUpload.java index 7fe492c945..58e40c6ab9 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemimport/BatchUpload.java +++ b/dspace-api/src/main/java/org/dspace/app/itemimport/BatchUpload.java @@ -7,9 +7,7 @@ */ package org.dspace.app.itemimport; -import java.io.BufferedReader; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.LineNumberReader; @@ -19,7 +17,6 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; -import java.util.Scanner; /** * @author kstamatis @@ -37,7 +34,8 @@ public class BatchUpload { private String errorMsgHTML = ""; /** - * + * Initialize with directory + * @param dirPath directory path */ public BatchUpload(String dirPath) { @@ -45,13 +43,20 @@ public class BatchUpload { } + /** + * Initialize with directory + * @param dir directory path + */ public BatchUpload(File dir) { this.initializeWithFile(dir); } - + /** + * Initialize with directory + * @param dir directory path + */ private void initializeWithFile(File dir){ this.dir = dir; @@ -89,6 +94,12 @@ public class BatchUpload { } } + /** + * Count lines in file + * @param filename file name + * @return lines in file + * @throws IOException if IO error + */ private int countLines(String filename) throws IOException { LineNumberReader reader = new LineNumberReader(new FileReader(filename)); int cnt = 0; @@ -106,6 +117,11 @@ public class BatchUpload { return cnt; } + /** + * Read a file + * @param filename file name + * @throws IOException if IO error + */ private void readFile(String filename) throws IOException { LineNumberReader reader = new LineNumberReader(new FileReader(filename)); String lineRead = ""; @@ -125,40 +141,76 @@ public class BatchUpload { reader.close(); } + /** + * Get date + * @return Date + */ public Date getDate() { return date; } + /** + * Get path to directory + * @return directory + */ public File getDir() { return dir; } + /** + * Whether successulf + * @return true or false + */ public boolean isSuccessful() { return successful; } + /** + * Get items imported + * @return number of items + */ public int getItemsImported() { return itemsImported; } + /** + * Get total items + * @return total + */ public int getTotalItems() { return totalItems; } + /** + * Get formatted date (DD/MM/YY) + * @return date as string + */ public String getDateFormatted(){ SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy - HH:mm"); return df.format(date); } + /** + * Get handles of imported files + * @return list of handles + */ public List getHandlesImported() { return handlesImported; } + /** + * Get error message + * @return error message + */ public String getErrorMsg() { return errorMsg; } + /** + * Get error message as HTML + * @return error message string as HTML + */ public String getErrorMsgHTML() { return errorMsgHTML; } diff --git a/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImportServiceImpl.java b/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImportServiceImpl.java index 8fa39910bb..2a564c3dda 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImportServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImportServiceImpl.java @@ -175,10 +175,10 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea * @param mycollections The collections the items are inserted to * @param sourceDir The filepath to the file to read data from * @param mapFile The filepath to mapfile to be generated - * @param template + * @param template whether to use collection template item as starting point * @param inputType The type of the input data (bibtex, csv, etc.) * @param workingDir The path to create temporary files (for command line or UI based) - * @throws Exception + * @throws Exception if error occurs */ @Override public void addBTEItems(Context c, List mycollections, @@ -457,10 +457,14 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea /** * item? try and add it to the archive. + * @param c current Context * @param mycollections - add item to these Collections. * @param path - directory containing the item directories. * @param itemname handle - non-null means we have a pre-defined handle already * @param mapOut - mapfile we're writing + * @param template whether to use collection template item as starting point + * @return Item + * @throws Exception if error occurs */ protected Item addItem(Context c, List mycollections, String path, String itemname, PrintWriter mapOut, boolean template) throws Exception @@ -765,6 +769,8 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea * @param path The path to the data directory for this item * @param filename The collections file filename. Should be "collections" * @return A list of collections in which to insert the item or null + * @throws IOException if IO error + * @throws SQLException if database error */ protected List processCollectionFile(Context c, String path, String filename) throws IOException, SQLException @@ -827,7 +833,12 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea } /** - * Read in the handle file or return null if empty or doesn't exist + * Read in the handle file contents or return null if empty or doesn't exist + * @param c DSpace context + * @param i DSpace item + * @param path path to handle file + * @param filename name of file + * @return handle file contents or null if doesn't exist */ protected String processHandleFile(Context c, Item i, String path, String filename) { @@ -886,6 +897,14 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea * Given a contents file and an item, stuffing it with bitstreams from the * contents file Returns a List of Strings with lines from the contents * file that request non-default bitstream permission + * @param c DSpace Context + * @param i DSpace item + * @param path path as string + * @param filename file name + * @return List of Strings + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error */ protected List processContentsFile(Context c, Item i, String path, String filename) throws SQLException, IOException, @@ -1129,14 +1148,15 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea /** * each entry represents a bitstream.... - * @param c - * @param i - * @param path - * @param fileName - * @param bundleName - * @throws SQLException - * @throws IOException - * @throws AuthorizeException + * @param c DSpace Context + * @param i Dspace Item + * @param path path to file + * @param fileName file name + * @param bundleName bundle name + * @param primary if primary bitstream + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error */ protected void processContentFileEntry(Context c, Item i, String path, String fileName, String bundleName, boolean primary) throws SQLException, @@ -1209,14 +1229,15 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea /** * Register the bitstream file into DSpace * - * @param c - * @param i - * @param assetstore + * @param c DSpace Context + * @param i DSpace Item + * @param assetstore assetstore number * @param bitstreamPath the full filepath expressed in the contents file - * @param bundleName - * @throws SQLException - * @throws IOException - * @throws AuthorizeException + * @param bundleName bundle name + * @param description bitstream description + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error */ protected void registerBitstream(Context c, Item i, int assetstore, String bitstreamPath, String bundleName, String description ) @@ -1281,19 +1302,21 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea * Process the Options to apply to the Item. The options are tab delimited * * Options: + * {@code * 48217870-MIT.pdf permissions: -r 'MIT Users' description: Full printable version (MIT only) * permissions:[r|w]-['group name'] * description: 'the description of the file' - * + * } * where: + * {@code * [r|w] (meaning: read|write) * ['MIT Users'] (the group name) - * - * @param c - * @param myItem - * @param options - * @throws SQLException - * @throws AuthorizeException + * } + * @param c DSpace Context + * @param myItem DSpace Item + * @param options List of option strings + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ protected void processOptions(Context c, Item myItem, List options) throws SQLException, AuthorizeException @@ -1447,12 +1470,13 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea /** * Set the Permission on a Bitstream. * - * @param c - * @param g - * @param actionID - * @param bs - * @throws SQLException - * @throws AuthorizeException + * @param c DSpace Context + * @param g Dspace Group + * @param actionID action identifier + * @param bs Bitstream + * @see org.dspace.core.Constants + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ protected void setPermission(Context c, Group g, int actionID, Bitstream bs) throws SQLException, AuthorizeException @@ -1488,9 +1512,9 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea // XML utility methods /** * Lookup an attribute from a DOM node. - * @param n - * @param name - * @return + * @param n node + * @param name attribute name + * @return attribute value */ private String getAttributeValue(Node n, String name) { @@ -1512,8 +1536,8 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea /** * Return the String value of a Node. - * @param node - * @return + * @param node node + * @return string value */ protected String getStringValue(Node node) { @@ -1539,6 +1563,9 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea * the filename to load from * * @return the DOM representation of the XML file + * @throws IOException if IO error + * @throws ParserConfigurationException if config error + * @throws SAXException if XML error */ protected Document loadXML(String filename) throws IOException, ParserConfigurationException, SAXException @@ -1721,7 +1748,8 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea * @param resumeDir In case of a resume request, the directory that containsthe old mapfile and data * @param inputType The input type of the data (bibtex, csv, etc.), in case of local file * @param context The context - * @throws Exception + * @param template whether to use template item + * @throws Exception if error */ @Override public void processUIImport(String filepath, Collection owningCollection, String[] otherCollections, String resumeDir, String inputType, Context context, final boolean template) throws Exception diff --git a/dspace-api/src/main/java/org/dspace/app/itemimport/service/ItemImportService.java b/dspace-api/src/main/java/org/dspace/app/itemimport/service/ItemImportService.java index 59a51ffdeb..6a6a1ed964 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemimport/service/ItemImportService.java +++ b/dspace-api/src/main/java/org/dspace/app/itemimport/service/ItemImportService.java @@ -36,15 +36,53 @@ import java.util.List; public interface ItemImportService { + /** + * + * @param c DSpace Context + * @param mycollections List of Collections + * @param sourceDir source location + * @param mapFile map file + * @param template whether to use template item + * @throws Exception if error + */ public void addItemsAtomic(Context c, List mycollections, String sourceDir, String mapFile, boolean template) throws Exception; + /** + * Add items + * @param c DSpace Context + * @param mycollections List of Collections + * @param sourceDir source location + * @param mapFile map file + * @param template whether to use template item + * @throws Exception if error + */ public void addItems(Context c, List mycollections, String sourceDir, String mapFile, boolean template) throws Exception; + /** + * Unzip a file + * @param zipfile file + * @return unzip location + * @throws IOException if error + */ public String unzip(File zipfile) throws IOException; + /** + * Unzip a file to a destination + * @param zipfile file + * @param destDir destination directory + * @return unzip location + * @throws IOException if error + */ public String unzip(File zipfile, String destDir) throws IOException; + /** + * Unzip a file in a specific source directory + * @param sourcedir source directory + * @param zipfilename file name + * @return unzip location + * @throws IOException if error + */ public String unzip(String sourcedir, String zipfilename) throws IOException; /** @@ -54,8 +92,10 @@ public interface ItemImportService { * @param owningCollection The owning collection the items will belong to * @param collections The collections the created items will be inserted to, apart from the owning one * @param resumeDir In case of a resume request, the directory that containsthe old mapfile and data + * @param inputType The input type of the data (bibtex, csv, etc.), in case of local file * @param context The context - * @throws Exception + * @param template whether to use template item + * @throws Exception if error */ public void processUIImport(String url, Collection owningCollection, String[] collections, String resumeDir, String inputType, Context context, boolean template) throws Exception; @@ -71,7 +111,7 @@ public interface ItemImportService { * - eperson to send the email to * @param fileName * - the filepath to the mapfile created by the batch import - * @throws javax.mail.MessagingException + * @throws MessagingException if error */ public void emailSuccessMessage(Context context, EPerson eperson, String fileName) throws MessagingException; @@ -86,39 +126,113 @@ public interface ItemImportService { * - EPerson to send the error message to * @param error * - the error message - * @throws MessagingException + * @throws MessagingException if error */ public void emailErrorMessage(EPerson eperson, String error) throws MessagingException; + /** + * Get imports available for a person + * @param eperson EPerson object + * @return List of batch uploads + * @throws Exception if error + */ public List getImportsAvailable(EPerson eperson) throws Exception; + /** + * Get import upload directory + * @param ePerson EPerson object + * @return directory + * @throws Exception if error + */ public String getImportUploadableDirectory(EPerson ePerson) throws Exception; + /** + * Delete a batch by ID + * @param c DSpace Context + * @param uploadId identifier + * @throws Exception if error + */ public void deleteBatchUpload(Context c, String uploadId) throws Exception; + /** + * Replace items + * @param c DSpace Context + * @param mycollections List of Collections + * @param sourcedir source directory + * @param mapfile map file + * @param template whether to use template item + * @throws Exception if error + */ public void replaceItems(Context c, List mycollections, String sourcedir, String mapfile, boolean template) throws Exception; + /** + * Delete items via mapfile + * @param c DSpace Context + * @param mapfile map file + * @throws Exception if error + */ public void deleteItems(Context c, String mapfile) throws Exception; + /** + * Add items + * @param c DSpace Context + * @param mycollections List of Collections + * @param sourcedir source directory + * @param mapfile map file + * @param template whether to use template item + * @param bteInputType The input type of the data (bibtex, csv, etc.), in case of local file + * @param workingDir working directory + * @throws Exception if error + */ public void addBTEItems(Context c, List mycollections, String sourcedir, String mapfile, boolean template, String bteInputType, String workingDir) throws Exception; + /** + * Get temporary work directory + * @return directory as string + */ public String getTempWorkDir(); + /** + * Get temporary work directory (as File) + * @return directory as File + */ public File getTempWorkDirFile(); + /** + * Cleanup + */ public void cleanupZipTemp(); + /** + * Set test flag + * @param isTest true or false + */ public void setTest(boolean isTest); + /** + * Set resume flag + * @param isResume true or false + */ public void setResume(boolean isResume); + /** + * Set use workflow + * @param useWorkflow whether to enable workflow + */ public void setUseWorkflow(boolean useWorkflow); - public void setUseWorkflowSendEmail(boolean useWorkflow); + /** + * @param useWorkflowSendMail whether to send mail + */ + public void setUseWorkflowSendEmail(boolean useWorkflowSendMail); + /** + * Set quiet flag + * @param isQuiet true or false + */ public void setQuiet(boolean isQuiet); } diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/ActionManager.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/ActionManager.java index abc81d302f..6a5579a958 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/ActionManager.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/ActionManager.java @@ -24,6 +24,13 @@ public class ActionManager implements Iterable { protected Map, UpdateAction> registry = new LinkedHashMap, UpdateAction>(); + /** + * Get update action + * @param actionClass UpdateAction class + * @return instantiation of UpdateAction class + * @throws InstantiationException if instantiation error + * @throws IllegalAccessException if illegal access error + */ public UpdateAction getUpdateAction(Class actionClass) throws InstantiationException, IllegalAccessException { diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/AddBitstreamsAction.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/AddBitstreamsAction.java index eebf8189a7..d78c73693b 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/AddBitstreamsAction.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/AddBitstreamsAction.java @@ -46,17 +46,17 @@ public class AddBitstreamsAction extends UpdateBitstreamsAction { } /** - * Adds bitstreams from the archive as listed in the contents file. + * Adds bitstreams from the archive as listed in the contents file. * - * @param context - * @param itarch - * @param isTest - * @param suppressUndo - * @throws IllegalArgumentException - * @throws ParseException - * @throws IOException - * @throws AuthorizeException - * @throws SQLException + * @param context DSpace Context + * @param itarch Item Archive + * @param isTest test flag + * @param suppressUndo undo flag + * @throws IOException if IO error + * @throws IllegalArgumentException if arg exception + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws ParseException if parse error */ @Override public void execute(Context context, ItemArchive itarch, boolean isTest, @@ -117,6 +117,22 @@ public class AddBitstreamsAction extends UpdateBitstreamsAction { } } + /** + * Add bitstream + * @param context DSpace Context + * @param itarch Item Archive + * @param item DSpace Item + * @param dir directory + * @param ce contents entry for bitstream + * @param suppressUndo undo flag + * @param isTest test flag + * @return bundle name + * @throws IOException if IO error + * @throws IllegalArgumentException if arg exception + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws ParseException if parse error + */ protected String addBitstream(Context context, ItemArchive itarch, Item item, File dir, ContentsEntry ce, boolean suppressUndo, boolean isTest) throws IOException, IllegalArgumentException, SQLException, AuthorizeException, ParseException diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/AddMetadataAction.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/AddMetadataAction.java index 1856791317..74aa8525b1 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/AddMetadataAction.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/AddMetadataAction.java @@ -31,14 +31,14 @@ public class AddMetadataAction extends UpdateMetadataAction { protected MetadataFieldService metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService(); /** - * Adds metadata specified in the source archive + * Adds metadata specified in the source archive * - * @param context - * @param itarch - * @param isTest - * @param suppressUndo - * @throws AuthorizeException - * @throws SQLException + * @param context DSpace Context + * @param itarch item archive + * @param isTest test flag + * @param suppressUndo undo flag + * @throws AuthorizeException if authorization error + * @throws SQLException if database error */ @Override public void execute(Context context, ItemArchive itarch, boolean isTest, diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilter.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilter.java index 617f2f50be..dd1cfccd7e 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilter.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilter.java @@ -26,16 +26,16 @@ public abstract class BitstreamFilter { /** * The filter method * - * @param bitstream + * @param bitstream Bitstream * @return whether the bitstream matches the criteria - * @throws BitstreamFilterException + * @throws BitstreamFilterException if filter error */ public abstract boolean accept(Bitstream bitstream) throws BitstreamFilterException; /** * * @param filepath - The complete path for the properties file - * @throws IOException + * @throws IOException if IO error */ public void initProperties(String filepath) throws IOException diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilterByBundleName.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilterByBundleName.java index a983561635..e24ea0c42b 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilterByBundleName.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilterByBundleName.java @@ -29,8 +29,8 @@ public class BitstreamFilterByBundleName extends BitstreamFilter { /** * Filter bitstream based on bundle name found in properties file * - * @param bitstream - * @throws BitstreamFilterException + * @param bitstream Bitstream + * @throws BitstreamFilterException if filter error * @return whether bitstream is in bundle * */ diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilterByFilename.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilterByFilename.java index ba6c374ffd..292db98897 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilterByFilename.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilterByFilename.java @@ -29,7 +29,9 @@ public class BitstreamFilterByFilename extends BitstreamFilter { * Tests bitstream by matching the regular expression in the * properties against the bitstream name * - * @return whether bitstream name matches the regular expression + * @param bitstream Bitstream + * @return whether bitstream name matches the regular expression + * @exception BitstreamFilterException if filter error */ @Override public boolean accept(Bitstream bitstream) throws BitstreamFilterException diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilterException.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilterException.java index d0971c564d..5126f7d5f3 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilterException.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/BitstreamFilterException.java @@ -17,10 +17,18 @@ public class BitstreamFilterException extends Exception private static final long serialVersionUID = 1L; public BitstreamFilterException() {} + /** + * + * @param msg exception message + */ public BitstreamFilterException(String msg) { super(msg); } + /** + * + * @param e exception + */ public BitstreamFilterException(Exception e) { super(e); diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/ContentsEntry.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/ContentsEntry.java index 83cbce746b..61c7ca3b77 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/ContentsEntry.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/ContentsEntry.java @@ -20,10 +20,12 @@ import org.dspace.core.Constants; * Lacking a spec or full documentation for the file format, * it looks from the source code that the ordering or elements is not fixed * - * e.g.: + * e.g.: + * {@code * 48217870-MIT.pdf\tbundle: bundlename\tpermissions: -r 'MIT Users'\tdescription: Full printable version (MIT only) * permissions: -[r|w] ['group name'] * description: + * } * * */ @@ -57,9 +59,9 @@ public class ContentsEntry /** * Factory method parses a line from the Contents Entry file * - * @param line + * @param line line as string * @return the parsed ContentsEntry object - * @throws ParseException + * @throws ParseException if parse error */ public static ContentsEntry parse(String line) throws ParseException diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/DeleteBitstreamsAction.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/DeleteBitstreamsAction.java index 6f9121fda2..2d44e3dc47 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/DeleteBitstreamsAction.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/DeleteBitstreamsAction.java @@ -30,15 +30,15 @@ public class DeleteBitstreamsAction extends UpdateBitstreamsAction /** * Delete bitstream from item * - * @param context - * @param itarch - * @param isTest - * @param suppressUndo - * @throws IllegalArgumentException - * @throws ParseException - * @throws IOException - * @throws AuthorizeException - * @throws SQLException + * @param context DSpace Context + * @param itarch item archive + * @param isTest test flag + * @param suppressUndo undo flag + * @throws IOException if IO error + * @throws IllegalArgumentException if arg exception + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws ParseException if parse error */ @Override public void execute(Context context, ItemArchive itarch, boolean isTest, diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/DeleteBitstreamsByFilterAction.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/DeleteBitstreamsByFilterAction.java index c5b959c510..8a0caaa24a 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/DeleteBitstreamsByFilterAction.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/DeleteBitstreamsByFilterAction.java @@ -35,7 +35,7 @@ public class DeleteBitstreamsByFilterAction extends UpdateBitstreamsAction { /** * Set filter * - * @param filter + * @param filter BitstreamFilter */ public void setBitstreamFilter(BitstreamFilter filter) { @@ -54,15 +54,15 @@ public class DeleteBitstreamsByFilterAction extends UpdateBitstreamsAction { /** * Delete bitstream * - * @param context - * @param itarch - * @param isTest - * @param suppressUndo - * @throws IllegalArgumentException - * @throws ParseException - * @throws IOException - * @throws AuthorizeException - * @throws SQLException + * @param context DSpace Context + * @param itarch item archive + * @param isTest test flag + * @param suppressUndo undo flag + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws ParseException if parse error + * @throws BitstreamFilterException if filter error */ @Override public void execute(Context context, ItemArchive itarch, boolean isTest, diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/DeleteMetadataAction.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/DeleteMetadataAction.java index 92b9f47772..a9a478efa4 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/DeleteMetadataAction.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/DeleteMetadataAction.java @@ -28,12 +28,13 @@ public class DeleteMetadataAction extends UpdateMetadataAction { /** * Delete metadata from item * - * @param context - * @param itarch - * @param isTest - * @param suppressUndo - * @throws ParseException - * @throws AuthorizeException + * @param context DSpace Context + * @param itarch Item Archive + * @param isTest test flag + * @param suppressUndo undo flag + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws ParseException if parse error */ @Override public void execute(Context context, ItemArchive itarch, boolean isTest, diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/DtoMetadata.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/DtoMetadata.java index 8ddd233306..2cdc72f1b1 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/DtoMetadata.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/DtoMetadata.java @@ -16,7 +16,7 @@ import org.dspace.content.Item; * * Adds some utility methods * - * Really not at all general enough but supports Dublin Core and the compound form notation .[.] + * Really not at all general enough but supports Dublin Core and the compound form notation {@code .[.]} * * Does not support wildcard for qualifier * @@ -47,8 +47,9 @@ class DtoMetadata * @param element not null, not empty * @param qualifier null; don't allow empty string or * indicating 'any' * @param language null or empty - * @param value + * @param value value * @return DtoMetadata object + * @throws IllegalArgumentException if arg error */ public static DtoMetadata create(String schema, String element, @@ -70,7 +71,9 @@ class DtoMetadata * * @param compoundForm of the form .[.] * @param language null or empty - * @param value + * @param value value + * @throws ParseException if parse error + * @throws IllegalArgumentException if arg error */ public static DtoMetadata create(String compoundForm, String language, String value) throws ParseException, IllegalArgumentException diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/ItemArchive.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/ItemArchive.java index 41146c9d20..3e4d32f7a2 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/ItemArchive.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/ItemArchive.java @@ -85,6 +85,8 @@ public class ItemArchive { * @param dir - The directory File in the source archive * @param itemField - The metadata field in which the Item identifier is located * if null, the default is the handle in the dc.identifier.uri field + * @return ItemArchive object + * @throws Exception if error * */ public static ItemArchive create(Context context, File dir, String itemField) @@ -137,6 +139,11 @@ public class ItemArchive { return builder; } + /** + * Getter for Transformer + * @return Transformer + * @throws TransformerConfigurationException if config error + */ protected Transformer getTransformer() throws TransformerConfigurationException { @@ -176,7 +183,7 @@ public class ItemArchive { /** * Add metadata field to undo list - * @param dtom + * @param dtom DtoMetadata (represents metadata field) */ public void addUndoMetadataField(DtoMetadata dtom) { @@ -194,7 +201,7 @@ public class ItemArchive { /** * Add bitstream id to delete contents file - * @param bitstreamId + * @param bitstreamId bitstream ID */ public void addUndoDeleteContents(UUID bitstreamId) { @@ -207,7 +214,9 @@ public class ItemArchive { * This is the default implementation * that uses the dc.identifier.uri metadatafield * that contains the item handle as its value - * + * @param context DSpace Context + * @throws SQLException if database error + * @throws Exception if error */ private Item itemFromHandleInput(Context context) throws SQLException, Exception @@ -250,8 +259,8 @@ public class ItemArchive { * * @param context - the DSpace context * @param itemField - the compound form of the metadata element .. - * @throws SQLException - * @throws Exception + * @throws SQLException if database error + * @throws Exception if error */ private Item itemFromMetadataField(Context context, String itemField) throws SQLException, AuthorizeException, Exception @@ -285,7 +294,11 @@ public class ItemArchive { return item; } - + /** + * Get DtoMetadata field + * @param compoundForm compound form + * @return DtoMetadata field + */ private DtoMetadata getMetadataField(String compoundForm) { for (DtoMetadata dtom : dtomList) @@ -301,8 +314,12 @@ public class ItemArchive { /** * write undo directory and files to Disk in archive format * - * * @param undoDir - the root directory of the undo archive + * @throws IOException if IO error + * @throws ParserConfigurationException if config error + * @throws TransformerConfigurationException if transformer config error + * @throws TransformerException if transformer error + * @throws FileNotFoundException if file not found */ public void writeUndo(File undoDir) throws IOException, ParserConfigurationException, TransformerConfigurationException, diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/ItemUpdate.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/ItemUpdate.java index 834893ae75..e0e8ec1ac5 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/ItemUpdate.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/ItemUpdate.java @@ -113,7 +113,7 @@ public class ItemUpdate { /** * - * @param argv + * @param argv commandline args */ public static void main(String[] argv) { @@ -392,6 +392,16 @@ public class ItemUpdate { System.exit(status); } + /** + * process an archive + * @param context DSpace Context + * @param sourceDirPath source path + * @param itemField item field + * @param metadataIndexName index name + * @param alterProvenance whether to alter provenance + * @param isTest test flag + * @throws Exception if error + */ protected void processArchive(Context context, String sourceDirPath, String itemField, String metadataIndexName, boolean alterProvenance, boolean isTest) throws Exception @@ -511,8 +521,8 @@ public class ItemUpdate { * * @param sourceDir - the original source directory * @return the directory of the undo archive - * @throws FileNotFoundException - * @throws IOException + * @throws FileNotFoundException if file doesn't exist + * @throws IOException if IO error */ protected File initUndoArchive(File sourceDir) throws FileNotFoundException, IOException @@ -555,6 +565,12 @@ public class ItemUpdate { //private void write + /** + * Set EPerson doing import + * @param context DSpace Context + * @param eperson EPerson obj + * @throws Exception if error + */ protected void setEPerson(Context context, String eperson) throws Exception { @@ -589,7 +605,7 @@ public class ItemUpdate { * poor man's logging * As with ItemImport, API logging goes through log4j to the DSpace.log files * whereas the batch logging goes to the console to be captured there. - * @param s + * @param s String */ static void pr(String s) { @@ -598,7 +614,7 @@ public class ItemUpdate { /** * print if verbose flag is set - * @param s + * @param s String */ static void prv(String s) { diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/MetadataUtilities.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/MetadataUtilities.java index a0929f12b5..c570de9e60 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/MetadataUtilities.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/MetadataUtilities.java @@ -48,7 +48,7 @@ import org.dspace.core.ConfigurationManager; /** - * Miscellaneous methods for metadata handling that build on the API + * Miscellaneous methods for metadata handling that build on the API * which might have general utility outside of the specific use * in context in ItemUpdate. * @@ -68,11 +68,11 @@ public class MetadataUtilities { clear (i.e. delete) all of these DCValues * add them back, minus the one to actually delete * - * - * @param item - * @param dtom - * @param isLanguageStrict - - * + * @param context DSpace Context + * @param item Item Object + * @param dtom metadata field + * @param isLanguageStrict whether strict or not + * @throws SQLException if database error * @return true if metadata field is found with matching value and was deleted */ public static boolean deleteMetadataByValue(Context context, Item item, DtoMetadata dtom, boolean isLanguageStrict) throws SQLException { @@ -122,11 +122,13 @@ public class MetadataUtilities { /** * Append text to value metadata field to item * - * @param item - * @param dtom - * @param isLanguageStrict - * @param textToAppend + * @param context DSpace Context + * @param item DSpace Item + * @param dtom metadata field + * @param isLanguageStrict if strict + * @param textToAppend text to append * @throws IllegalArgumentException - When target metadata field is not found + * @throws SQLException if database error */ public static void appendMetadata(Context context, Item item, DtoMetadata dtom, boolean isLanguageStrict, String textToAppend) @@ -184,15 +186,15 @@ public class MetadataUtilities { * Modification of method from ItemImporter.loadDublinCore * as a Factory method * - * @param docBuilder - + * @param docBuilder DocumentBuilder * @param is - InputStream of dublin_core.xml * @return list of DtoMetadata representing the metadata fields relating to an Item - * @throws SQLException - * @throws IOException - * @throws ParserConfigurationException - * @throws SAXException - * @throws TransformerException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws IOException if IO error + * @throws ParserConfigurationException if parser config error + * @throws SAXException if XML error + * @throws TransformerException if transformer error + * @throws AuthorizeException if authorization error */ public static List loadDublinCore(DocumentBuilder docBuilder, InputStream is) throws SQLException, IOException, ParserConfigurationException, @@ -269,12 +271,12 @@ public class MetadataUtilities { /** * Write dublin_core.xml * - * @param docBuilder - * @param dtomList + * @param docBuilder DocumentBuilder + * @param dtomList List of metadata fields * @return xml document - * @throws ParserConfigurationException - * @throws TransformerConfigurationException - * @throws TransformerException + * @throws ParserConfigurationException if parser config error + * @throws TransformerConfigurationException if transformer config error + * @throws TransformerException if transformer error */ public static Document writeDublinCore(DocumentBuilder docBuilder, List dtomList) throws ParserConfigurationException, TransformerConfigurationException, TransformerException @@ -313,11 +315,11 @@ public class MetadataUtilities { /** * write xml document to output stream - * @param doc - * @param transformer - * @param out - * @throws IOException - * @throws TransformerException + * @param doc XML Document + * @param transformer XML Transformer + * @param out OutputStream + * @throws IOException if IO Error + * @throws TransformerException if Transformer error */ public static void writeDocument(Document doc, Transformer transformer, OutputStream out) throws IOException, TransformerException @@ -332,9 +334,9 @@ public class MetadataUtilities { // XML utility methods /** * Lookup an attribute from a DOM node. - * @param n - * @param name - * @return + * @param n Node + * @param name name + * @return attribute value */ private static String getAttributeValue(Node n, String name) { @@ -355,8 +357,8 @@ public class MetadataUtilities { /** * Return the String value of a Node. - * @param node - * @return + * @param node node + * @return string value */ private static String getStringValue(Node node) { @@ -379,7 +381,11 @@ public class MetadataUtilities { * Rewrite of ItemImport's functionality * but just the parsing of the file, not the processing of its elements. * - * @validate flag to verify matching files in tree + * @param f file + * @return list of ContentsEntry + * @throws FileNotFoundException if file doesn't exist + * @throws IOException if IO error + * @throws ParseException if parse error */ public static List readContentsFile(File f) throws FileNotFoundException, IOException, ParseException @@ -421,9 +427,10 @@ public class MetadataUtilities { /** * - * @param f - * @throws FileNotFoundException - * @throws IOException + * @param f file + * @return list of lines as strings + * @throws FileNotFoundException if file doesn't exist + * @throws IOException if IO Error */ public static List readDeleteContentsFile(File f) throws FileNotFoundException, IOException @@ -466,7 +473,7 @@ public class MetadataUtilities { /** * Get display of Metadatum * - * @param dcv + * @param dcv MetadataValue * @return string displaying elements of the Metadatum */ public static String getDCValueString(MetadataValue dcv) @@ -478,7 +485,10 @@ public class MetadataUtilities { } /** - * + * Return compound form of a metadata field (i.e. schema.element.qualifier) + * @param schema schema + * @param element element + * @param qualifier qualifier * @return a String representation of the two- or three-part form of a metadata element * e.g. dc.identifier.uri */ @@ -495,9 +505,10 @@ public class MetadataUtilities { } /** - * Parses metadata field given in the form .[.|.*] + * Parses metadata field given in the form {@code .[.|.*]} * checks for correct number of elements (2 or 3) and for empty strings * + * @param compoundForm compound form of metadata field * @return String Array * @throws ParseException if validity checks fail * diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/OriginalBitstreamFilter.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/OriginalBitstreamFilter.java index 8ca370b917..c865bfb511 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/OriginalBitstreamFilter.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/OriginalBitstreamFilter.java @@ -27,10 +27,10 @@ public class OriginalBitstreamFilter extends BitstreamFilterByBundleName /** * Tests bitstreams for containment in an ORIGINAL bundle - * + * @param bitstream Bitstream * @return true if the bitstream is in the ORIGINAL bundle * - * @throws BitstreamFilterException + * @throws BitstreamFilterException if filter error */ @Override public boolean accept(Bitstream bitstream) diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/OriginalWithDerivativesBitstreamFilter.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/OriginalWithDerivativesBitstreamFilter.java index 084ae301bd..068a5a5e72 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/OriginalWithDerivativesBitstreamFilter.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/OriginalWithDerivativesBitstreamFilter.java @@ -30,8 +30,8 @@ public class OriginalWithDerivativesBitstreamFilter extends BitstreamFilter /** * Tests bitstream for membership in specified bundles (ORIGINAL, TEXT, THUMBNAIL) * - * @param bitstream - * @throws BitstreamFilterException + * @param bitstream Bitstream + * @throws BitstreamFilterException if error * @return true if bitstream is in specified bundles */ @Override diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/UpdateAction.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/UpdateAction.java index 30bffa409d..4fccfba1b7 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/UpdateAction.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/UpdateAction.java @@ -21,13 +21,13 @@ public interface UpdateAction /** - * Action to update item + * Action to update item * - * @param context - * @param itarch - * @param isTest - * @param suppressUndo - * @throws Exception + * @param context DSpace context + * @param itarch item archive + * @param isTest test flag + * @param suppressUndo undo flag + * @throws Exception if error */ public void execute(Context context, ItemArchive itarch, boolean isTest, boolean suppressUndo) throws Exception; diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/UpdateBitstreamsAction.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/UpdateBitstreamsAction.java index 360f771fbf..7acd7d06bd 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/UpdateBitstreamsAction.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/UpdateBitstreamsAction.java @@ -27,7 +27,7 @@ public abstract class UpdateBitstreamsAction implements UpdateAction { /** * Set variable to indicate that the dc.description.provenance field may * be changed as a result of Bitstream changes by ItemUpdate - * @param alterProvenance + * @param alterProvenance whether to alter provenance */ public void setAlterProvenance(boolean alterProvenance) { diff --git a/dspace-api/src/main/java/org/dspace/app/itemupdate/UpdateMetadataAction.java b/dspace-api/src/main/java/org/dspace/app/itemupdate/UpdateMetadataAction.java index 99b8557ed3..284a9cefb2 100644 --- a/dspace-api/src/main/java/org/dspace/app/itemupdate/UpdateMetadataAction.java +++ b/dspace-api/src/main/java/org/dspace/app/itemupdate/UpdateMetadataAction.java @@ -13,7 +13,7 @@ import java.util.Set; /** * This abstract subclass for metadata actions * maintains a collection for the target metadata fields - * expressed as a string in the compound notation ( .. ) + * expressed as a string in the compound notation ( {@code ..} ) * on which to apply the action when the method execute is called. * * Implemented as a Set to avoid problems with duplicates @@ -36,7 +36,7 @@ public abstract class UpdateMetadataAction implements UpdateAction { /** * Set target fields * - * @param targetFields + * @param targetFields Set of target fields to update */ public void addTargetFields(Set targetFields) { for (String tf : targetFields) @@ -48,7 +48,7 @@ public abstract class UpdateMetadataAction implements UpdateAction { /** * Add array of target fields to update - * @param targetFields + * @param targetFields array of target fields to update */ public void addTargetFields(String[] targetFields) { for (String tf : targetFields) @@ -61,7 +61,7 @@ public abstract class UpdateMetadataAction implements UpdateAction { /** * Add single field to update * - * @param targetField + * @param targetField target field to update */ public void addTargetField(String targetField) { this.targetFields.add(targetField); diff --git a/dspace-api/src/main/java/org/dspace/app/launcher/CommandRunner.java b/dspace-api/src/main/java/org/dspace/app/launcher/CommandRunner.java index c3c1ae9d55..5d7a05ead5 100644 --- a/dspace-api/src/main/java/org/dspace/app/launcher/CommandRunner.java +++ b/dspace-api/src/main/java/org/dspace/app/launcher/CommandRunner.java @@ -23,6 +23,12 @@ import org.jdom.Document; */ public class CommandRunner { + /** + * + * @param args commandline args + * @throws IOException if IO error + * @throws FileNotFoundException if file doesn't exist + */ public static void main(String[] args) throws FileNotFoundException, IOException { @@ -46,11 +52,10 @@ public class CommandRunner /** * Read a file of command lines and execute each in turn. * - * @param doc details of recognized commands. * @param script the file of command lines to be executed. - * @return - * @throws FileNotFoundException - * @throws IOException + * @return status code + * @throws IOException if IO error + * @throws FileNotFoundException if file doesn't exist */ static int runManyCommands(String script) throws FileNotFoundException, IOException diff --git a/dspace-api/src/main/java/org/dspace/app/launcher/ScriptLauncher.java b/dspace-api/src/main/java/org/dspace/app/launcher/ScriptLauncher.java index 88d5bf7cee..ede7ac4622 100644 --- a/dspace-api/src/main/java/org/dspace/app/launcher/ScriptLauncher.java +++ b/dspace-api/src/main/java/org/dspace/app/launcher/ScriptLauncher.java @@ -34,6 +34,8 @@ public class ScriptLauncher * Execute the DSpace script launcher * * @param args Any parameters required to be passed to the scripts it executes + * @throws IOException if IO error + * @throws FileNotFoundException if file doesn't exist */ public static void main(String[] args) throws FileNotFoundException, IOException @@ -90,8 +92,8 @@ public class ScriptLauncher /** * Recognize and execute a single command. - * @param doc - * @param args + * @param doc Document + * @param args arguments */ static int runOneCommand(Document commandConfigs, String[] args) { @@ -275,6 +277,7 @@ public class ScriptLauncher /** * Display the commands that the current launcher config file knows about + * @param commandConfigs configs as Document */ private static void display(Document commandConfigs) { diff --git a/dspace-api/src/main/java/org/dspace/app/mediafilter/BrandedPreviewJPEGFilter.java b/dspace-api/src/main/java/org/dspace/app/mediafilter/BrandedPreviewJPEGFilter.java index 1fe163fd99..fc0b8c9e26 100644 --- a/dspace-api/src/main/java/org/dspace/app/mediafilter/BrandedPreviewJPEGFilter.java +++ b/dspace-api/src/main/java/org/dspace/app/mediafilter/BrandedPreviewJPEGFilter.java @@ -7,14 +7,7 @@ */ package org.dspace.app.mediafilter; -import java.awt.Graphics2D; -import java.awt.Color; import java.awt.image.*; -import java.awt.RenderingHints; -import java.awt.Transparency; -import java.awt.Font; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.InputStream; import javax.imageio.ImageIO; @@ -29,7 +22,7 @@ import org.dspace.app.mediafilter.JPEGFilter; * thumbnail.maxwidth, thumbnail.maxheight, the size we want our thumbnail to be * no bigger than. Creates only JPEGs. * - * @author Jason Sherman + * @author Jason Sherman jsherman@usao.edu */ public class BrandedPreviewJPEGFilter extends MediaFilter { @@ -69,10 +62,13 @@ public class BrandedPreviewJPEGFilter extends MediaFilter /** + * @param currentItem item * @param source * source input stream + * @param verbose verbose mode * * @return InputStream the resulting input stream + * @throws Exception if error */ @Override public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose) diff --git a/dspace-api/src/main/java/org/dspace/app/mediafilter/ExcelFilter.java b/dspace-api/src/main/java/org/dspace/app/mediafilter/ExcelFilter.java index 0ed7e79f08..05b9049aa1 100644 --- a/dspace-api/src/main/java/org/dspace/app/mediafilter/ExcelFilter.java +++ b/dspace-api/src/main/java/org/dspace/app/mediafilter/ExcelFilter.java @@ -73,11 +73,14 @@ public class ExcelFilter extends MediaFilter } /** - * @param source - * source input stream + * @param item item + * @param source source input stream + * @param verbose verbose mode * * @return InputStream the resulting input stream + * @throws Exception if error */ + @Override public InputStream getDestinationStream(Item item, InputStream source, boolean verbose) throws Exception { diff --git a/dspace-api/src/main/java/org/dspace/app/mediafilter/FormatFilter.java b/dspace-api/src/main/java/org/dspace/app/mediafilter/FormatFilter.java index 86c900a4fd..702f65a8a6 100644 --- a/dspace-api/src/main/java/org/dspace/app/mediafilter/FormatFilter.java +++ b/dspace-api/src/main/java/org/dspace/app/mediafilter/FormatFilter.java @@ -50,10 +50,13 @@ public interface FormatFilter public String getDescription(); /** + * @param item Item * @param source * input stream + * @param verbose verbosity flag * * @return result of filter's transformation, written out to a bitstream + * @throws Exception if error */ public InputStream getDestinationStream(Item item, InputStream source, boolean verbose) throws Exception; @@ -67,15 +70,14 @@ public interface FormatFilter * for any reason. * * - * @param c - * context - * @param item - * item containing bitstream to process - * @param source - * source bitstream to be processed + * @param c context + * @param item item containing bitstream to process + * @param source source bitstream to be processed + * @param verbose verbose mode * * @return true if bitstream processing should continue, * false if this bitstream should be skipped + * @throws Exception if error */ public boolean preProcessBitstream(Context c, Item item, Bitstream source, boolean verbose) throws Exception; @@ -96,6 +98,7 @@ public interface FormatFilter * @param generatedBitstream * the bitstream which was generated by * this filter. + * @throws Exception if error */ public void postProcessBitstream(Context c, Item item, Bitstream generatedBitstream) throws Exception; diff --git a/dspace-api/src/main/java/org/dspace/app/mediafilter/HTMLFilter.java b/dspace-api/src/main/java/org/dspace/app/mediafilter/HTMLFilter.java index 576d520f3a..0a1c016a2c 100644 --- a/dspace-api/src/main/java/org/dspace/app/mediafilter/HTMLFilter.java +++ b/dspace-api/src/main/java/org/dspace/app/mediafilter/HTMLFilter.java @@ -59,10 +59,12 @@ public class HTMLFilter extends MediaFilter } /** - * @param source - * source input stream + * @param currentItem item + * @param source source input stream + * @param verbose verbose mode * * @return InputStream the resulting input stream + * @throws Exception if error */ @Override public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose) diff --git a/dspace-api/src/main/java/org/dspace/app/mediafilter/ImageMagickImageThumbnailFilter.java b/dspace-api/src/main/java/org/dspace/app/mediafilter/ImageMagickImageThumbnailFilter.java index 6698dbbe68..8959058acb 100644 --- a/dspace-api/src/main/java/org/dspace/app/mediafilter/ImageMagickImageThumbnailFilter.java +++ b/dspace-api/src/main/java/org/dspace/app/mediafilter/ImageMagickImageThumbnailFilter.java @@ -24,10 +24,12 @@ public class ImageMagickImageThumbnailFilter extends ImageMagickThumbnailFilter { /** - * @param source - * source input stream + * @param currentItem item + * @param source source input stream + * @param verbose verbose mode * * @return InputStream the resulting input stream + * @throws Exception if error */ @Override public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose) diff --git a/dspace-api/src/main/java/org/dspace/app/mediafilter/JPEGFilter.java b/dspace-api/src/main/java/org/dspace/app/mediafilter/JPEGFilter.java index 509dcd92eb..b4e409c261 100644 --- a/dspace-api/src/main/java/org/dspace/app/mediafilter/JPEGFilter.java +++ b/dspace-api/src/main/java/org/dspace/app/mediafilter/JPEGFilter.java @@ -27,7 +27,7 @@ import org.dspace.core.ConfigurationManager; * thumbnail.maxwidth, thumbnail.maxheight, the size we want our thumbnail to be * no bigger than. Creates only JPEGs. * - * @author Jason Sherman + * @author Jason Sherman jsherman@usao.edu */ public class JPEGFilter extends MediaFilter implements SelfRegisterInputFormats { @@ -66,10 +66,12 @@ public class JPEGFilter extends MediaFilter implements SelfRegisterInputFormats } /** - * @param source - * source input stream + * @param currentItem item + * @param source source input stream + * @param verbose verbose mode * * @return InputStream the resulting input stream + * @throws Exception if error */ @Override public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose) @@ -239,6 +241,8 @@ public class JPEGFilter extends MediaFilter implements SelfRegisterInputFormats * Convenience method that returns a blurred instance of the * provided {@code BufferedImage}. * + * @param buf buffered image + * @return updated BufferedImage */ public BufferedImage getBlurredInstance(BufferedImage buf) { diff --git a/dspace-api/src/main/java/org/dspace/app/mediafilter/MediaFilter.java b/dspace-api/src/main/java/org/dspace/app/mediafilter/MediaFilter.java index 24281a3f20..8e60a68155 100644 --- a/dspace-api/src/main/java/org/dspace/app/mediafilter/MediaFilter.java +++ b/dspace-api/src/main/java/org/dspace/app/mediafilter/MediaFilter.java @@ -29,15 +29,14 @@ public abstract class MediaFilter implements FormatFilter * for any reason. * * - * @param c - * context - * @param item - * item containing bitstream to process - * @param source - * source bitstream to be processed + * @param c context + * @param item item containing bitstream to process + * @param source source bitstream to be processed + * @param verbose verbose mode * * @return true if bitstream processing should continue, * false if this bitstream should be skipped + * @throws Exception if error */ @Override public boolean preProcessBitstream(Context c, Item item, Bitstream source, boolean verbose) @@ -62,6 +61,7 @@ public abstract class MediaFilter implements FormatFilter * @param generatedBitstream * the bitstream which was generated by * this filter. + * @throws java.lang.Exception */ @Override public void postProcessBitstream(Context c, Item item, Bitstream generatedBitstream) diff --git a/dspace-api/src/main/java/org/dspace/app/mediafilter/PDFBoxThumbnail.java b/dspace-api/src/main/java/org/dspace/app/mediafilter/PDFBoxThumbnail.java index 50ca4e69e6..f482914a58 100644 --- a/dspace-api/src/main/java/org/dspace/app/mediafilter/PDFBoxThumbnail.java +++ b/dspace-api/src/main/java/org/dspace/app/mediafilter/PDFBoxThumbnail.java @@ -7,13 +7,7 @@ */ package org.dspace.app.mediafilter; -import java.awt.Graphics2D; -import java.awt.Color; import java.awt.image.*; -import java.awt.RenderingHints; -import java.awt.Transparency; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.InputStream; import javax.imageio.ImageIO; @@ -22,7 +16,6 @@ import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.rendering.PDFRenderer; import org.dspace.content.Item; -import org.dspace.core.ConfigurationManager; import org.dspace.app.mediafilter.JPEGFilter; @@ -33,8 +26,8 @@ import org.dspace.app.mediafilter.JPEGFilter; * thumbnail.maxwidth, thumbnail.maxheight, the size we want our thumbnail to be * no bigger than. Creates only JPEGs. * - * @author Ivan Masár - * @author Jason Sherman + * @author Ivan Masár helix84@centrum.sk + * @author Jason Sherman jsherman@usao.edu */ public class PDFBoxThumbnail extends MediaFilter implements SelfRegisterInputFormats { @@ -73,10 +66,12 @@ public class PDFBoxThumbnail extends MediaFilter implements SelfRegisterInputFor } /** - * @param source - * source input stream + * @param currentItem item + * @param source source input stream + * @param verbose verbose mode * * @return InputStream the resulting input stream + * @throws Exception if error */ @Override public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose) diff --git a/dspace-api/src/main/java/org/dspace/app/mediafilter/PDFFilter.java b/dspace-api/src/main/java/org/dspace/app/mediafilter/PDFFilter.java index a2c8f686a6..b68d488813 100644 --- a/dspace-api/src/main/java/org/dspace/app/mediafilter/PDFFilter.java +++ b/dspace-api/src/main/java/org/dspace/app/mediafilter/PDFFilter.java @@ -68,10 +68,12 @@ public class PDFFilter extends MediaFilter } /** - * @param source - * source input stream + * @param currentItem item + * @param source source input stream + * @param verbose verbose mode * * @return InputStream the resulting input stream + * @throws Exception if error */ @Override public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose) diff --git a/dspace-api/src/main/java/org/dspace/app/mediafilter/PowerPointFilter.java b/dspace-api/src/main/java/org/dspace/app/mediafilter/PowerPointFilter.java index c44f9b5d7b..dc21e9ee00 100644 --- a/dspace-api/src/main/java/org/dspace/app/mediafilter/PowerPointFilter.java +++ b/dspace-api/src/main/java/org/dspace/app/mediafilter/PowerPointFilter.java @@ -64,10 +64,12 @@ public class PowerPointFilter extends MediaFilter } /** - * @param source - * source input stream + * @param currentItem item + * @param source source input stream + * @param verbose verbose mode * * @return InputStream the resulting input stream + * @throws Exception if error */ @Override public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose) diff --git a/dspace-api/src/main/java/org/dspace/app/mediafilter/WordFilter.java b/dspace-api/src/main/java/org/dspace/app/mediafilter/WordFilter.java index 9ca52fb211..8a1452941e 100644 --- a/dspace-api/src/main/java/org/dspace/app/mediafilter/WordFilter.java +++ b/dspace-api/src/main/java/org/dspace/app/mediafilter/WordFilter.java @@ -63,10 +63,12 @@ public class WordFilter extends MediaFilter } /** - * @param source - * source input stream + * @param currentItem item + * @param source source input stream + * @param verbose verbose mode * * @return InputStream the resulting input stream + * @throws Exception if error */ @Override public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose) diff --git a/dspace-api/src/main/java/org/dspace/app/mediafilter/service/MediaFilterService.java b/dspace-api/src/main/java/org/dspace/app/mediafilter/service/MediaFilterService.java index 0a8385928e..d88a22bce7 100644 --- a/dspace-api/src/main/java/org/dspace/app/mediafilter/service/MediaFilterService.java +++ b/dspace-api/src/main/java/org/dspace/app/mediafilter/service/MediaFilterService.java @@ -48,8 +48,11 @@ public interface MediaFilterService { * Iterate through the item's bitstreams in the ORIGINAL bundle, applying * filters if possible. * + * @param context context + * @param myItem item * @return true if any bitstreams processed, * false if none + * @throws Exception if error */ public boolean filterItem(Context context, Item myItem) throws Exception; @@ -60,8 +63,12 @@ public interface MediaFilterService { * instantiated. Exceptions from filtering will be logged to STDOUT and * swallowed. * + * @param c context + * @param myItem item + * @param myBitstream bitstream * @return true if bitstream processed, * false if no applicable filter or already processed + * @throws Exception if error */ public boolean filterBitstream(Context c, Item myItem, Bitstream myBitstream) throws Exception; @@ -72,7 +79,7 @@ public interface MediaFilterService { * already been filtered, and if not or if overWrite is set, invokes the * filter. * - * @param c + * @param context * context * @param item * item containing bitstream to process @@ -80,7 +87,7 @@ public interface MediaFilterService { * source bitstream to process * @param formatFilter * FormatFilter to perform filtering - * + * @throws Exception if error occurs * @return true if new rendition is created, false if rendition already * exists and overWrite is not set */ diff --git a/dspace-api/src/main/java/org/dspace/app/packager/Packager.java b/dspace-api/src/main/java/org/dspace/app/packager/Packager.java index 8affcb64cb..8a69dfd697 100644 --- a/dspace-api/src/main/java/org/dspace/app/packager/Packager.java +++ b/dspace-api/src/main/java/org/dspace/app/packager/Packager.java @@ -478,12 +478,12 @@ public class Packager * @param pkgParams Parameters to pass to individual packager instances * @param sourceFile location of the source package to ingest * @param parentObjs Parent DSpace object(s) to attach new object to - * @throws IOException - * @throws SQLException - * @throws FileNotFoundException - * @throws AuthorizeException - * @throws CrosswalkException - * @throws PackageException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws FileNotFoundException if file doesn't exist + * @throws AuthorizeException if authorization error + * @throws CrosswalkException if crosswalk error + * @throws PackageException if packaging error */ protected void ingest(Context context, PackageIngester sip, PackageParameters pkgParams, String sourceFile, DSpaceObject parentObjs[]) throws IOException, SQLException, FileNotFoundException, AuthorizeException, CrosswalkException, PackageException @@ -617,12 +617,12 @@ public class Packager * @param dso DSpace Object to disseminate as a package * @param pkgParams Parameters to pass to individual packager instances * @param outputFile File where final package should be saved - * @throws IOException - * @throws SQLException - * @throws FileNotFoundException - * @throws AuthorizeException - * @throws CrosswalkException - * @throws PackageException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws FileNotFoundException if file doesn't exist + * @throws AuthorizeException if authorization error + * @throws CrosswalkException if crosswalk error + * @throws PackageException if packaging error */ protected void disseminate(Context context, PackageDisseminator dip, DSpaceObject dso, PackageParameters pkgParams, @@ -699,12 +699,12 @@ public class Packager * @param pkgParams Parameters to pass to individual packager instances * @param sourceFile location of the source package to ingest as the replacement * @param objToReplace DSpace object to replace (may be null if it will be specified in the package itself) - * @throws IOException - * @throws SQLException - * @throws FileNotFoundException - * @throws AuthorizeException - * @throws CrosswalkException - * @throws PackageException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws FileNotFoundException if file doesn't exist + * @throws AuthorizeException if authorization error + * @throws CrosswalkException if crosswalk error + * @throws PackageException if packaging error */ protected void replace(Context context, PackageIngester sip, PackageParameters pkgParams, String sourceFile, DSpaceObject objToReplace) throws IOException, SQLException, FileNotFoundException, AuthorizeException, CrosswalkException, PackageException diff --git a/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItem.java b/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItem.java index 47346eca6c..0a549db077 100644 --- a/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItem.java +++ b/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItem.java @@ -10,6 +10,7 @@ package org.dspace.app.requestitem; import org.dspace.content.Bitstream; import org.dspace.content.Item; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import javax.persistence.*; import java.util.Date; @@ -19,7 +20,7 @@ import java.util.Date; */ @Entity @Table(name="requestitem") -public class RequestItem { +public class RequestItem implements ReloadableEntity { @Id @@ -76,7 +77,7 @@ public class RequestItem { { } - public int getID() { + public Integer getID() { return requestitem_id; } diff --git a/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItemHelpdeskStrategy.java b/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItemHelpdeskStrategy.java index cfe2f8cacb..ddd6d50ba5 100644 --- a/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItemHelpdeskStrategy.java +++ b/dspace-api/src/main/java/org/dspace/app/requestitem/RequestItemHelpdeskStrategy.java @@ -9,7 +9,6 @@ package org.dspace.app.requestitem; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.dspace.authorize.AuthorizeException; import org.dspace.content.Item; import org.dspace.core.ConfigurationManager; import org.dspace.core.Context; @@ -55,9 +54,10 @@ public class RequestItemHelpdeskStrategy extends RequestItemSubmitterStrategy { * Return a RequestItemAuthor object for the specified helpdesk email address. * It makes an attempt to find if there is a matching eperson for the helpdesk address, to use the name, * Otherwise it falls back to a helpdeskname key in the Messages.props. - * @param context - * @param helpDeskEmail - * @return + * @param context context + * @param helpDeskEmail email + * @return RequestItemAuthor + * @throws SQLException if database error */ public RequestItemAuthor getHelpDeskPerson(Context context, String helpDeskEmail) throws SQLException{ EPerson helpdeskEPerson = null; diff --git a/dspace-api/src/main/java/org/dspace/app/requestitem/dao/RequestItemDAO.java b/dspace-api/src/main/java/org/dspace/app/requestitem/dao/RequestItemDAO.java index de8e87bacc..386ded0bab 100644 --- a/dspace-api/src/main/java/org/dspace/app/requestitem/dao/RequestItemDAO.java +++ b/dspace-api/src/main/java/org/dspace/app/requestitem/dao/RequestItemDAO.java @@ -16,7 +16,7 @@ import java.sql.SQLException; /** * Database Access Object interface class for the RequestItem object. * The implementation of this class is responsible for all database calls for the RequestItem object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/app/requestitem/service/RequestItemService.java b/dspace-api/src/main/java/org/dspace/app/requestitem/service/RequestItemService.java index 7c7518701e..b3ac1b5004 100644 --- a/dspace-api/src/main/java/org/dspace/app/requestitem/service/RequestItemService.java +++ b/dspace-api/src/main/java/org/dspace/app/requestitem/service/RequestItemService.java @@ -24,9 +24,15 @@ public interface RequestItemService { /** * Generate a request item representing the request and put it into the DB - * @param context + * @param context context + * @param bitstream bitstream + * @param item item + * @param reqMessage message + * @param allFiles all files flag + * @param reqEmail email + * @param reqName name * @return the token of the request item - * @throws java.sql.SQLException + * @throws SQLException if database error */ public String createRequest(Context context, Bitstream bitstream, Item item, boolean allFiles, String reqEmail, String reqName, String reqMessage) throws SQLException; @@ -36,6 +42,7 @@ public interface RequestItemService { /** * Save updates to the record. Only accept_request, and decision_date are set-able. * @param context + * @param requestItem */ public void update(Context context, RequestItem requestItem); diff --git a/dspace-api/src/main/java/org/dspace/app/sfx/SFXFileReaderServiceImpl.java b/dspace-api/src/main/java/org/dspace/app/sfx/SFXFileReaderServiceImpl.java index 309ae667ab..2bef54187a 100644 --- a/dspace-api/src/main/java/org/dspace/app/sfx/SFXFileReaderServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/app/sfx/SFXFileReaderServiceImpl.java @@ -140,7 +140,7 @@ public class SFXFileReaderServiceImpl implements SFXFileReaderService { * @param e DOM node of the mapping pair in the XML file (field element) * @param item The item to process, from which metadata values will be taken * @return assembled OpenURL query. - * @throws IOException + * @throws IOException if IO error */ protected String processFields(Node e, Item item) throws IOException { NodeList cl = e.getChildNodes(); diff --git a/dspace-api/src/main/java/org/dspace/app/sfx/service/SFXFileReaderService.java b/dspace-api/src/main/java/org/dspace/app/sfx/service/SFXFileReaderService.java index 821870bd59..820abe4a97 100644 --- a/dspace-api/src/main/java/org/dspace/app/sfx/service/SFXFileReaderService.java +++ b/dspace-api/src/main/java/org/dspace/app/sfx/service/SFXFileReaderService.java @@ -36,7 +36,7 @@ public interface SFXFileReaderService { * @param item The item to process, from which metadata values will be taken * * @return the SFX string - * @throws java.io.IOException + * @throws IOException if IO error */ public String loadSFXFile(String fileName, Item item) throws IOException; @@ -53,7 +53,7 @@ public interface SFXFileReaderService { * @param node DOM node of the mapping pair in the XML file (field element) * @param item The item to process, from which metadata values will be taken * @return processed fields. - * @throws IOException + * @throws IOException if IO error */ public String doNodes(Node node, Item item) throws IOException; @@ -67,17 +67,24 @@ public interface SFXFileReaderService { /** * Is Empty text Node * + * @param nd node + * @return true or false */ public boolean isEmptyTextNode(Node nd); /** - * Returns the value of the node's attribute named + * Returns the value of the node's attribute named {@code } + * @param e node + * @param name name + * @return value */ public String getAttribute(Node e, String name); /** * Returns the value found in the Text node (if any) in the * node list that's passed in. + * @param node node + * @return value */ public String getValue(Node node); } \ No newline at end of file diff --git a/dspace-api/src/main/java/org/dspace/app/sherpa/submit/MetadataAuthorityISSNExtractor.java b/dspace-api/src/main/java/org/dspace/app/sherpa/submit/MetadataAuthorityISSNExtractor.java index 8da1fc017d..f068c36175 100644 --- a/dspace-api/src/main/java/org/dspace/app/sherpa/submit/MetadataAuthorityISSNExtractor.java +++ b/dspace-api/src/main/java/org/dspace/app/sherpa/submit/MetadataAuthorityISSNExtractor.java @@ -37,7 +37,10 @@ public class MetadataAuthorityISSNExtractor implements ISSNItemExtractor List dcvalues = itemService.getMetadataByMetadataString(item, metadata); for (MetadataValue dcvalue : dcvalues) { - values.add(dcvalue.getAuthority()); + String authority = dcvalue.getAuthority(); + if(authority !=null){ + values.add(authority); + } } } return values; diff --git a/dspace-api/src/main/java/org/dspace/app/sitemap/AbstractGenerator.java b/dspace-api/src/main/java/org/dspace/app/sitemap/AbstractGenerator.java index 5db05f43c6..8891943d08 100644 --- a/dspace-api/src/main/java/org/dspace/app/sitemap/AbstractGenerator.java +++ b/dspace-api/src/main/java/org/dspace/app/sitemap/AbstractGenerator.java @@ -74,7 +74,7 @@ public abstract class AbstractGenerator /** * Start writing a new sitemap file. * - * @throws IOException + * @throws IOException if IO error * if an error occurs creating the file */ protected void startNewFile() throws IOException @@ -102,7 +102,7 @@ public abstract class AbstractGenerator * Full URL to add * @param lastMod * Date URL was last modified, or {@code null} - * @throws IOException + * @throws IOException if IO error * if an error occurs writing */ public void addURL(String url, Date lastMod) throws IOException @@ -130,7 +130,7 @@ public abstract class AbstractGenerator /** * Finish with the current sitemap file. * - * @throws IOException + * @throws IOException if IO error * if an error occurs writing */ protected void closeCurrentFile() throws IOException @@ -147,7 +147,7 @@ public abstract class AbstractGenerator * * @return number of sitemap files written. * - * @throws IOException + * @throws IOException if IO error * if an error occurs writing */ public int finish() throws IOException @@ -246,7 +246,7 @@ public abstract class AbstractGenerator * stream to write the index to * @param sitemapCount * number of sitemaps that were generated - * @throws IOException + * @throws IOException if IO error * if an IO error occurs */ public abstract void writeIndex(PrintStream output, int sitemapCount) diff --git a/dspace-api/src/main/java/org/dspace/app/sitemap/GenerateSitemaps.java b/dspace-api/src/main/java/org/dspace/app/sitemap/GenerateSitemaps.java index 6f455d4c7f..652575aa80 100644 --- a/dspace-api/src/main/java/org/dspace/app/sitemap/GenerateSitemaps.java +++ b/dspace-api/src/main/java/org/dspace/app/sitemap/GenerateSitemaps.java @@ -152,9 +152,9 @@ public class GenerateSitemaps * if {@code true}, generate an HTML sitemap. * @param makeSitemapOrg * if {@code true}, generate an sitemap.org sitemap. - * @throws SQLException + * @throws SQLException if database error * if a database error occurs. - * @throws IOException + * @throws IOException if IO error * if IO error occurs. */ public static void generateSitemaps(boolean makeHTMLMap, diff --git a/dspace-api/src/main/java/org/dspace/app/statistics/CreateStatReport.java b/dspace-api/src/main/java/org/dspace/app/statistics/CreateStatReport.java index 73e32bd20e..0b836d5b44 100644 --- a/dspace-api/src/main/java/org/dspace/app/statistics/CreateStatReport.java +++ b/dspace-api/src/main/java/org/dspace/app/statistics/CreateStatReport.java @@ -25,9 +25,9 @@ import org.dspace.core.ConfigurationManager; /** * This class allows the running of the DSpace statistic tools * - * Usage: java CreateStatReport -r - * Available: - * + * Usage: {@code java CreateStatReport -r } + * Available: {@code + * } * * @author Chris Yates * @@ -95,7 +95,7 @@ public class CreateStatReport { context.setIgnoreAuthorization(true); //get paths to directories - outputLogDirectory = ConfigurationManager.getProperty("log.dir") + File.separator; + outputLogDirectory = ConfigurationManager.getProperty("log.report.dir") + File.separator; outputReportDirectory = ConfigurationManager.getProperty("report.dir") + File.separator; //read in command line variable to determine which statistic to run @@ -145,7 +145,7 @@ public class CreateStatReport { /** * This method generates a report from the first of the current month to the end of the current month. * - * @throws Exception + * @throws Exception if error */ private static void statMonthly() throws Exception { @@ -184,7 +184,7 @@ public class CreateStatReport { /** * This method generates a full report based on the full log period * - * @throws Exception + * @throws Exception if error */ private static void statGeneral() throws Exception { @@ -216,7 +216,7 @@ public class CreateStatReport { * This script starts from the year and month specified below and loops each month until the current month * generating a monthly aggregation files for the DStat system. * - * @throws Exception + * @throws Exception if error */ private static void statInitial() throws Exception { @@ -265,7 +265,7 @@ public class CreateStatReport { /** * This method generates a full report based on the full log period * - * @throws Exception + * @throws Exception if error */ private static void statReportGeneral() throws Exception { @@ -304,7 +304,7 @@ public class CreateStatReport { * This script starts from the year and month specified below and loops each month until the current month * generating monthly reports from the DStat aggregation files * - * @throws Exception + * @throws Exception if error */ private static void statReportInitial() throws Exception { @@ -349,7 +349,7 @@ public class CreateStatReport { /** * This method generates a report from the aggregation files which have been run for the most recent month * - * @throws Exception + * @throws Exception if error */ private static void statReportMonthly() throws Exception { diff --git a/dspace-api/src/main/java/org/dspace/app/statistics/HTMLReport.java b/dspace-api/src/main/java/org/dspace/app/statistics/HTMLReport.java index 173b90529e..29d5abc792 100644 --- a/dspace-api/src/main/java/org/dspace/app/statistics/HTMLReport.java +++ b/dspace-api/src/main/java/org/dspace/app/statistics/HTMLReport.java @@ -334,7 +334,7 @@ public class HTMLReport implements Report /** * output the report block based on the passed mapping, where the mapping - * sould be "name of report element" => "value", where both sides of the + * should be "name of report element" to "value", where both sides of the * mapping should be Strings. This class also assumes that the reference * is a linkable URL to the resource * 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 56ab0256d9..4459b5ace6 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 @@ -9,7 +9,6 @@ package org.dspace.app.statistics; import org.apache.commons.lang3.StringUtils; import org.dspace.core.ConfigurationManager; -import org.dspace.core.Constants; import org.dspace.core.Context; import org.dspace.core.LogManager; import org.dspace.discovery.DiscoverQuery; @@ -185,8 +184,8 @@ public class LogAnalyser //////////////////////// /** the log directory to be analysed */ - private static String logDir = ConfigurationManager.getProperty("log.dir"); - + private static String logDir = ConfigurationManager.getProperty("log.report.dir"); + /** the regex to describe the file name format */ private static String fileTemplate = "dspace\\.log.*"; @@ -196,7 +195,7 @@ public class LogAnalyser "dstat.cfg"; /** the output file to which to write aggregation data */ - private static String outFile = ConfigurationManager.getProperty("log.dir") + File.separator + "dstat.dat"; + private static String outFile = ConfigurationManager.getProperty("log.report.dir") + File.separator + "dstat.dat"; /** the starting date of the report */ private static Date startDate = null; @@ -213,6 +212,9 @@ public class LogAnalyser /** * main method to be run from command line. See usage information for * details as to how to use the command line flags (-help) + * @param argv arguments + * @throws Exception if error + * @throws SQLException if database error */ public static void main(String [] argv) throws Exception, SQLException @@ -294,6 +296,10 @@ public class LogAnalyser * @param myStartDate the desired start of the analysis. Starts from the beginning otherwise * @param myEndDate the desired end of the analysis. Goes to the end otherwise * @param myLookUp force a lookup of the database + * @return aggregate output + * @throws IOException if IO error + * @throws SQLException if database error + * @throws SearchServiceException if search error */ public static String processLogs(Context context, String myLogDir, String myFileTemplate, String myConfigFile, @@ -555,7 +561,7 @@ public class LogAnalyser { logDir = myLogDir; } - + if (myFileTemplate != null) { fileTemplate = myFileTemplate; @@ -587,6 +593,7 @@ public class LogAnalyser /** * generate the analyser's output to the specified out file + * @return output */ public static String createOutput() { @@ -866,6 +873,7 @@ public class LogAnalyser /** * Read in the current config file and populate the class globals. + * @throws IOException if IO error */ public static void readConfig() throws IOException { @@ -876,6 +884,7 @@ public class LogAnalyser * Read in the given config file and populate the class globals. * * @param configFile the config file to read in + * @throws IOException if IO error */ public static void readConfig(String configFile) throws IOException { @@ -1166,6 +1175,8 @@ public class LogAnalyser * @param type value for DC field 'type' (unqualified) * * @return an integer containing the relevant count + * @throws SQLException if database error + * @throws SearchServiceException if search error */ public static Integer getNumItems(Context context, String type) throws SQLException, SearchServiceException { @@ -1216,6 +1227,8 @@ public class LogAnalyser * * @return an Integer containing the number of items in the * archive + * @throws SQLException if database error + * @throws SearchServiceException if search error */ public static Integer getNumItems(Context context) throws SQLException, SearchServiceException { diff --git a/dspace-api/src/main/java/org/dspace/app/statistics/ReportGenerator.java b/dspace-api/src/main/java/org/dspace/app/statistics/ReportGenerator.java index 3b6ec4b5cb..039b516497 100644 --- a/dspace-api/src/main/java/org/dspace/app/statistics/ReportGenerator.java +++ b/dspace-api/src/main/java/org/dspace/app/statistics/ReportGenerator.java @@ -152,6 +152,9 @@ public class ReportGenerator /** * main method to be run from command line. See usage information for * details as to how to use the command line flags + * @param argv + * @throws java.lang.Exception + * @throws java.sql.SQLException */ public static void main(String [] argv) throws Exception, SQLException @@ -206,10 +209,13 @@ public class ReportGenerator * this method is retained for backwards compatibility, but delegates the actual * wprk to a new method * - * @param context the DSpace context in which this action is performed - * @param myFormat the desired output format (currently on HTML supported) - * @param myInput the aggregation file to be turned into a report - * @param myOutput the file into which to write the report + * @param context the DSpace context in which this action is performed + * @param myFormat the desired output format (currently on HTML supported) + * @param myInput the aggregation file to be turned into a report + * @param myOutput the file into which to write the report + * @param myMap the map + * @throws Exception if error + * @throws SQLException if database error */ public static void processReport(Context context, String myFormat, String myInput, String myOutput, @@ -242,6 +248,11 @@ public class ReportGenerator * using the pre-configuration information passed here, read in the * aggregation data and output a file containing the report in the * requested format + * @param context context + * @param report report + * @param myInput input + * @throws Exception if error + * @throws SQLException if database error */ public static void processReport(Context context, Report report, String myInput) @@ -527,6 +538,7 @@ public class ReportGenerator * actions which are more understandable to humans * * @param map the map file + * @throws IOException if IO error */ public static void readMap(String map) throws IOException @@ -612,6 +624,8 @@ public class ReportGenerator * The values that come from this file form the basis of the analysis report * * @param input the aggregator file + * @throws IOException if IO error + * @throws ParseException if parse error */ public static void readInput(String input) throws IOException, ParseException @@ -783,6 +797,7 @@ public class ReportGenerator * * @return a string containing a reference (almost citation) to the * article + * @throws SQLException if database error */ public static String getItemInfo(Context context, String handle) throws SQLException diff --git a/dspace-api/src/main/java/org/dspace/app/statistics/StatisticsLoader.java b/dspace-api/src/main/java/org/dspace/app/statistics/StatisticsLoader.java index c08cfc03ab..cc125897bb 100644 --- a/dspace-api/src/main/java/org/dspace/app/statistics/StatisticsLoader.java +++ b/dspace-api/src/main/java/org/dspace/app/statistics/StatisticsLoader.java @@ -66,6 +66,7 @@ public class StatisticsLoader /** * Get an array of the dates of the report files. + * @return array of dates */ public static Date[] getMonthlyReportDates() { @@ -74,6 +75,7 @@ public class StatisticsLoader /** * Get an array of the dates of the analysis files. + * @return array of dates */ public static Date[] getMonthlyAnalysisDates() { @@ -82,7 +84,8 @@ public class StatisticsLoader /** * Convert the formatted dates that are the keys of the map into a date array. - * @param monthlyMap + * @param monthlyMap map + * @return array of dates */ protected static Date[] getDatesFromMap(Map monthlyMap) { @@ -107,7 +110,7 @@ public class StatisticsLoader /** * Sort the date array in descending (reverse chronological) order. - * @param dates + * @param dates array of dates * @return sorted dates. */ protected static Date[] sortDatesDescending(Date[] dates) @@ -145,7 +148,8 @@ public class StatisticsLoader /** * Get the analysis file for a given date. - * @param date + * @param date date + * @return File */ public static File getAnalysisFor(String date) { @@ -156,7 +160,8 @@ public class StatisticsLoader /** * Get the report file for a given date. - * @param date + * @param date date + * @return File */ public static File getReportFor(String date) { @@ -167,6 +172,7 @@ public class StatisticsLoader /** * Get the current general analysis file. + * @return File */ public static File getGeneralAnalysis() { @@ -176,6 +182,7 @@ public class StatisticsLoader /** * Get the current general report file. + * @return File */ public static File getGeneralReport() { @@ -213,7 +220,7 @@ public class StatisticsLoader /** * Generate the cached file list from the array of files - * @param fileList + * @param fileList array of files */ private static synchronized void loadFileList(File[] fileList) { @@ -305,9 +312,10 @@ public class StatisticsLoader * formatters are used to identify the file as a particular type, * and extract the relevant information. If the file is not identified * by the formatter provided, then we return null. - * @param thisFile - * @param thisPattern - * @param sdf + * @param thisFile file + * @param thisPattern patter + * @param sdf date format + * @return StatsFile */ private static StatsFile makeStatsFile(File thisFile, Pattern thisPattern, DateFormat sdf) { @@ -336,10 +344,11 @@ public class StatisticsLoader /** * Get an array of all the analysis and report files. + * @return array of files */ private static File[] getAnalysisAndReportFileList() { - File reportDir = new File(ConfigurationManager.getProperty("log.dir")); + File reportDir = new File(ConfigurationManager.getProperty("log.report.dir")); if (reportDir != null) { return reportDir.listFiles(new AnalysisAndReportFilter()); diff --git a/dspace-api/src/main/java/org/dspace/app/util/AuthorizeUtil.java b/dspace-api/src/main/java/org/dspace/app/util/AuthorizeUtil.java index 735602e24b..c18dd0985f 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/AuthorizeUtil.java +++ b/dspace-api/src/main/java/org/dspace/app/util/AuthorizeUtil.java @@ -43,10 +43,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param bitstream * the bitstream that the policy refer to - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current context (current user) is not allowed to * manage the bitstream's policies - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeManageBitstreamPolicy(Context context, @@ -64,10 +64,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param bundle * the bundle that the policy refer to - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current context (current user) is not allowed to * manage the bundle's policies - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeManageBundlePolicy(Context context, @@ -85,10 +85,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param item * the item that the policy refer to - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current context (current user) is not allowed to * manage the item's policies - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeManageItemPolicy(Context context, Item item) @@ -124,10 +124,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param collection * the collection that the policy refer to - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current context (current user) is not allowed to * manage the collection's policies - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeManageCollectionPolicy(Context context, @@ -159,10 +159,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param community * the community that the policy refer to - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current context (current user) is not allowed to * manage the community's policies - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeManageCommunityPolicy(Context context, @@ -185,9 +185,9 @@ public class AuthorizeUtil * * @param context * the DSpace Context Object - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current user is not a System Admin - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void requireAdminRole(Context context) @@ -208,10 +208,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param item * the item that the CC License refer to - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current user is not allowed to * manage the item's CC License - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeManageCCLicense(Context context, Item item) @@ -254,10 +254,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param collection * the collection - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current user is not allowed to manage the collection's * template item - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeManageTemplateItem(Context context, @@ -296,10 +296,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param collection * the collection - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current user is not allowed to manage the collection's * submitters group - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeManageSubmittersGroup(Context context, @@ -331,10 +331,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param collection * the collection - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current user is not allowed to manage the collection's * workflow groups - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeManageWorkflowsGroup(Context context, @@ -368,10 +368,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param collection * the collection - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current user is not allowed to create/edit the * collection's admins group - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeManageAdminGroup(Context context, @@ -405,10 +405,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param collection * the collection - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current user is not allowed to remove the * collection's admins group - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeRemoveAdminGroup(Context context, @@ -439,10 +439,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param community * the community - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current user is not allowed to create/edit the * community's admins group - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeManageAdminGroup(Context context, @@ -470,10 +470,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param community * the community - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current user is not allowed to remove the * collection's admins group - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeRemoveAdminGroup(Context context, @@ -505,10 +505,10 @@ public class AuthorizeUtil * the DSpace Context Object * @param rp * a resource policy - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current context (current user) is not allowed to * remove/edit the policy - * @throws SQLException + * @throws SQLException if database error * if a db error occur */ public static void authorizeManagePolicy(Context c, ResourcePolicy rp) @@ -546,9 +546,9 @@ public class AuthorizeUtil * the DSpace Context Object * @param item * the item - * @throws SQLException + * @throws SQLException if database error * if a db error occur - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current user is not allowed to perform the item * withdraw */ @@ -589,9 +589,9 @@ public class AuthorizeUtil * the DSpace Context Object * @param item * the item - * @throws SQLException + * @throws SQLException if database error * if a db error occur - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if the current user is not allowed to perform the item * reinstatement */ diff --git a/dspace-api/src/main/java/org/dspace/app/util/CollectionDropDown.java b/dspace-api/src/main/java/org/dspace/app/util/CollectionDropDown.java index 0f8056a3ed..823f9390be 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/CollectionDropDown.java +++ b/dspace-api/src/main/java/org/dspace/app/util/CollectionDropDown.java @@ -27,6 +27,7 @@ public class CollectionDropDown { * @param col * Get full path for this collection * @return Full path to the collection + * @throws SQLException if database error */ public static String collectionPath(Collection col) throws SQLException { @@ -42,6 +43,7 @@ public class CollectionDropDown { * @param maxchars * Truncate the full path to maxchar characters. 0 means do not truncate. * @return Full path to the collection (truncated) + * @throws SQLException if database error */ public static String collectionPath(Collection col, int maxchars) throws SQLException { diff --git a/dspace-api/src/main/java/org/dspace/app/util/DCInput.java b/dspace-api/src/main/java/org/dspace/app/util/DCInput.java index f0c30ddf8e..f3281d284b 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/DCInput.java +++ b/dspace-api/src/main/java/org/dspace/app/util/DCInput.java @@ -415,12 +415,12 @@ public class DCInput * The closed attribute of the vocabulary tag for this field as set in * input-forms.xml * - * + * {@code * * ..... * nsrc * - * + * } * @return the closedVocabulary flags: true if the entry should be restricted * only to vocabulary terms, false otherwise */ diff --git a/dspace-api/src/main/java/org/dspace/app/util/DCInputSet.java b/dspace-api/src/main/java/org/dspace/app/util/DCInputSet.java index 38caadee9a..752fcb1cfe 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/DCInputSet.java +++ b/dspace-api/src/main/java/org/dspace/app/util/DCInputSet.java @@ -25,7 +25,11 @@ public class DCInputSet /** the inputs ordered by page and row position */ private DCInput[][] inputPages = null; - /** constructor */ + /** constructor + * @param formName form name + * @param pages pages + * @param listMap map + */ public DCInputSet(String formName, List>> pages, Map> listMap) { this.formName = formName; @@ -116,6 +120,7 @@ public class DCInputSet * Does the current input set define the named field? * Scan through every field in every page of the input set * + * @param fieldName * @return true if the current set has the named field */ public boolean isFieldPresent(String fieldName) @@ -141,6 +146,8 @@ public class DCInputSet * and is valid for the specified document type * Scan through every field in every page of the input set * + * @param fieldName field name + * @param documentType doc type * @return true if the current set has the named field */ public boolean isFieldPresent(String fieldName, String documentType) diff --git a/dspace-api/src/main/java/org/dspace/app/util/DCInputsReader.java b/dspace-api/src/main/java/org/dspace/app/util/DCInputsReader.java index 44c8602338..a9135f43d4 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/DCInputsReader.java +++ b/dspace-api/src/main/java/org/dspace/app/util/DCInputsReader.java @@ -82,6 +82,7 @@ public class DCInputsReader * level structures: a map between collections and forms, the definition for * each page of each form, and lists of pairs of values that populate * selection boxes. + * @throws DCInputsReaderException if input reader error */ public DCInputsReader() diff --git a/dspace-api/src/main/java/org/dspace/app/util/DSpaceWebappMXBean.java b/dspace-api/src/main/java/org/dspace/app/util/DSpaceWebappMXBean.java index 46c50b5744..05edc7b54c 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/DSpaceWebappMXBean.java +++ b/dspace-api/src/main/java/org/dspace/app/util/DSpaceWebappMXBean.java @@ -15,15 +15,27 @@ package org.dspace.app.util; */ public interface DSpaceWebappMXBean { - /** Is this webapp a user interface? False if machine interface such as SWORD. */ + /** + * Is this webapp a user interface? False if machine interface such as SWORD. + * @return true/false + */ public boolean isUI(); - /** What kind of webapp? XMLUI, OAI, etc. */ + /** + * What kind of webapp? XMLUI, OAI, etc. + * @return kind of webapp + */ public String getKind(); - /** What is the base URL of this application? */ + /** + * What is the base URL of this application? + * @return base url + */ public String getURL(); - /** When did this application start? */ + /** + * When did this application start? + * @return start time + */ public String getStarted(); } diff --git a/dspace-api/src/main/java/org/dspace/app/util/DailyFileAppender.java b/dspace-api/src/main/java/org/dspace/app/util/DailyFileAppender.java index ff2a567c23..f4a152b547 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/DailyFileAppender.java +++ b/dspace-api/src/main/java/org/dspace/app/util/DailyFileAppender.java @@ -235,7 +235,7 @@ public class DailyFileAppender extends FileAppender /** * This function is responsible for performing the actual file rollover. * @param pstrName The name of the new folder based on current system date. - * @throws IOException + * @throws IOException if IO error */ private static boolean deletingFiles = false; private void cleanupOldFiles() diff --git a/dspace-api/src/main/java/org/dspace/app/util/GoogleMetadata.java b/dspace-api/src/main/java/org/dspace/app/util/GoogleMetadata.java index a1ca8612a1..0a05620f4c 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/GoogleMetadata.java +++ b/dspace-api/src/main/java/org/dspace/app/util/GoogleMetadata.java @@ -31,10 +31,8 @@ import java.io.File; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.List; import java.util.Map.Entry; -import java.util.Set; import org.dspace.core.Constants; import org.dspace.core.Context; @@ -212,8 +210,9 @@ public class GoogleMetadata * Wrap the item, parse all configured fields and generate metadata field * values. * - * @param item - * - The item being viewed to extract metadata from + * @param context context + * @param item The item being viewed to extract metadata from + * @throws SQLException if database error */ public GoogleMetadata(Context context, Item item) throws SQLException { @@ -330,7 +329,7 @@ public class GoogleMetadata * * @param configFilter * @param returnType - * @return Array of configuration -> item-field matches + * @return Array of configuration to item-field matches */ protected ArrayList resolveMetadata(String configFilter, int returnType) @@ -658,7 +657,7 @@ public class GoogleMetadata /** * Using metadata field mappings contained in the loaded configuration, * parse through configured metadata fields, building valid Google metadata - * value strings. Field names & values contained in metadataMappings. + * value strings. Field names and values contained in metadataMappings. * */ protected void parseItem() @@ -769,8 +768,8 @@ public class GoogleMetadata * Fetch retaining the order of the values for any given key in which they * where added (like authors). * - * Usage: GoogleMetadata gmd = new GoogleMetadata(item); for(Entry mapping : googlemd.getMappings()) { ... } + * Usage: {@code GoogleMetadata gmd = new GoogleMetadata(item); for(Entry mapping : googlemd.getMappings()) ...} * * @return Iterable of metadata fields mapped to Google-formatted values */ @@ -781,6 +780,7 @@ public class GoogleMetadata /** * Produce meta elements that can easily be put into the head. + * @return List of elements */ public List disseminateList() { @@ -1047,7 +1047,7 @@ public class GoogleMetadata * Additionally, this bitstream must be publicly viewable. * @param item * @return - * @throws SQLException + * @throws SQLException if database error */ protected Bitstream findLinkableFulltext(Item item) throws SQLException { Bitstream bestSoFar = null; @@ -1089,9 +1089,9 @@ public class GoogleMetadata /** * * - * @param FIELD + * @param field * to aggregate all values of in a matching option - * @param delim + * @param delimiter * to delimit field values with */ protected void addAggregateValues(String field, String delimiter) diff --git a/dspace-api/src/main/java/org/dspace/app/util/IndexVersion.java b/dspace-api/src/main/java/org/dspace/app/util/IndexVersion.java index 81508ed878..3ef44fc11c 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/IndexVersion.java +++ b/dspace-api/src/main/java/org/dspace/app/util/IndexVersion.java @@ -21,10 +21,10 @@ import org.apache.lucene.util.Version; * so that they can be upgraded to the latest version. *

    * You must pass it the full path of the index directory, e.g. - * [dspace]/solr/statistics/data/index/ + * {@code [dspace]/solr/statistics/data/index/} *

    * The response is simply a version number (e.g. 4.4), as this is utilized by - * the "ant update_solr_indexes" target in [src]/dspace/src/main/config/build.xml + * the {@code ant update_solr_indexes} target in {@code [src]/dspace/src/main/config/build.xml} * * @author tdonohue */ @@ -106,7 +106,7 @@ public class IndexVersion * Full path of the Solr/Lucene index directory * @return version as a string (e.g. "4.4"), empty string ("") if index directory is empty, * or null if directory doesn't exist. - * @throws IOException + * @throws IOException if IO error */ public static String getIndexVersion(String indexDirPath) throws IOException @@ -218,14 +218,14 @@ public class IndexVersion *

    * NOTE: In case it is not obvious, software version numbering does NOT * behave like normal decimal numbers. For example, in software versions - * the following statement is TRUE: 4.1 < 4.4 < 4.5 < 4.10 < 4.21 < 4.51 + * the following statement is TRUE: {@code 4.1 < 4.4 < 4.5 < 4.10 < 4.21 < 4.51} * * @param firstVersion * First version to compare, as a String * @param secondVersion * Second version to compare as a String - * @return -1 if first < second, 1 if first > second, 0 if equal - * @throws IOException + * @return -1 if first less than second, 1 if first greater than second, 0 if equal + * @throws IOException if IO error */ public static int compareSoftwareVersions(String firstVersion, String secondVersion) throws IOException diff --git a/dspace-api/src/main/java/org/dspace/app/util/OpenSearchServiceImpl.java b/dspace-api/src/main/java/org/dspace/app/util/OpenSearchServiceImpl.java index def596d92c..7dc0695e26 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/OpenSearchServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/app/util/OpenSearchServiceImpl.java @@ -127,7 +127,7 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea @Override public String getResultsString(Context context, String format, String query, int totalResults, int start, int pageSize, - DSpaceObject scope, DSpaceObject[] results, + DSpaceObject scope, List results, Map labels) throws IOException { try @@ -143,7 +143,7 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea @Override public Document getResultsDoc(Context context, String format, String query, int totalResults, int start, int pageSize, - DSpaceObject scope, DSpaceObject[] results, Map labels) + DSpaceObject scope, List results, Map labels) throws IOException { try @@ -158,7 +158,7 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea } protected SyndicationFeed getResults(Context context, String format, String query, int totalResults, int start, int pageSize, - DSpaceObject scope, DSpaceObject[] results, Map labels) + DSpaceObject scope, List results, Map labels) { // Encode results in requested format if ("rss".equals(format)) @@ -283,7 +283,7 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea * Converts a JDOM document to a W3C one * @param jdomDoc * @return W3C Document object - * @throws IOException + * @throws IOException if IO error */ protected Document jDomToW3(org.jdom.Document jdomDoc) throws IOException { diff --git a/dspace-api/src/main/java/org/dspace/app/util/SubmissionConfigReader.java b/dspace-api/src/main/java/org/dspace/app/util/SubmissionConfigReader.java index 9ff36acf3b..e2956b00a7 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/SubmissionConfigReader.java +++ b/dspace-api/src/main/java/org/dspace/app/util/SubmissionConfigReader.java @@ -88,6 +88,7 @@ public class SubmissionConfigReader /** * Load Submission Configuration from the * item-submission.xml configuration file + * @throws ServletException if servlet error */ public SubmissionConfigReader() throws ServletException { @@ -206,7 +207,7 @@ public class SubmissionConfigReader /** * Returns a particular global step definition based on its ID. *

    - * Global step definitions are those defined in the + * Global step definitions are those defined in the {@code } * section of the configuration file. * * @param stepID diff --git a/dspace-api/src/main/java/org/dspace/app/util/SubmissionInfo.java b/dspace-api/src/main/java/org/dspace/app/util/SubmissionInfo.java index 4a34394006..14f0037ed9 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/SubmissionInfo.java +++ b/dspace-api/src/main/java/org/dspace/app/util/SubmissionInfo.java @@ -213,7 +213,7 @@ public class SubmissionInfo extends HashMap /** * Returns a particular global step definition based on its ID. *

    - * Global step definitions are those defined in the + * Global step definitions are those defined in the {@code } * section of the configuration file. * * @param stepID diff --git a/dspace-api/src/main/java/org/dspace/app/util/SubmissionStepConfig.java b/dspace-api/src/main/java/org/dspace/app/util/SubmissionStepConfig.java index eb26369983..cb7f97a862 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/SubmissionStepConfig.java +++ b/dspace-api/src/main/java/org/dspace/app/util/SubmissionStepConfig.java @@ -100,8 +100,8 @@ public class SubmissionStepConfig implements Serializable /** * Get the ID for this step. An ID is only defined if the step exists in the - * section. This ID field is used to reference special - * steps (like the required step with id="collection") + * {@code } section. This ID field is used to reference special + * steps (like the required step with {@code id="collection"}) * * @return the step ID */ diff --git a/dspace-api/src/main/java/org/dspace/app/util/SyndicationFeed.java b/dspace-api/src/main/java/org/dspace/app/util/SyndicationFeed.java index f2ac96cc5b..b492e1851e 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/SyndicationFeed.java +++ b/dspace-api/src/main/java/org/dspace/app/util/SyndicationFeed.java @@ -165,9 +165,14 @@ public class SyndicationFeed /** * Fills in the feed and entry-level metadata from DSpace objects. + * @param request request + * @param context context + * @param dso DSpaceObject + * @param items array of objects + * @param labels label map */ public void populate(HttpServletRequest request, Context context, DSpaceObject dso, - DSpaceObject items[], Map labels) + List items, Map labels) { String logoURL = null; String objectURL = null; @@ -450,6 +455,7 @@ public class SyndicationFeed * Sets the feed type for XML delivery, e.g. "rss_1.0", "atom_1.0" * Must match one of ROME's configured generators, see rome.properties * (currently rss_1.0, rss_2.0, atom_1.0, atom_0.3) + * @param feedType feed type */ public void setType(String feedType) { @@ -463,6 +469,7 @@ public class SyndicationFeed /** * @return the feed we built as DOM Document + * @throws FeedException if feed error */ public Document outputW3CDom() throws FeedException @@ -481,6 +488,7 @@ public class SyndicationFeed /** * @return the feed we built as serialized XML string + * @throws FeedException if feed error */ public String outputString() throws FeedException @@ -491,6 +499,9 @@ public class SyndicationFeed /** * send the output to designated Writer + * @param writer Writer + * @throws FeedException if feed error + * @throws IOException if IO error */ public void output(java.io.Writer writer) throws FeedException, IOException @@ -501,6 +512,7 @@ public class SyndicationFeed /** * Add a ROME plugin module (e.g. for OpenSearch) at the feed level. + * @param m module */ public void addModule(Module m) { @@ -523,17 +535,17 @@ public class SyndicationFeed logo.getID()+"/"+(name == null?"":name); } + protected String baseURL = null; // cache the result for null /** * Return a url to the DSpace object, either use the official * handle for the item or build a url based upon the current server. * * If the dspaceobject is null then a local url to the repository is generated. * + * @param request current servlet request * @param dso The object to reference, null if to the repository. - * @return + * @return URL */ - protected String baseURL = null; // cache the result for null - protected String resolveURL(HttpServletRequest request, DSpaceObject dso) { // If no object given then just link to the whole repository, diff --git a/dspace-api/src/main/java/org/dspace/app/util/Util.java b/dspace-api/src/main/java/org/dspace/app/util/Util.java index 81ce8d9f17..b355e9df93 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/Util.java +++ b/dspace-api/src/main/java/org/dspace/app/util/Util.java @@ -89,6 +89,7 @@ public class Util { * @param encoding * character encoding, e.g. UTF-8 * @return the encoded string + * @throws java.io.UnsupportedEncodingException if encoding error */ public static String encodeBitstreamName(String stringIn, String encoding) throws java.io.UnsupportedEncodingException { // FIXME: This should be moved elsewhere, as it is used outside the UI @@ -164,6 +165,7 @@ public class Util { * @param stringIn * input string to encode * @return the encoded string + * @throws java.io.UnsupportedEncodingException if encoding error */ public static String encodeBitstreamName(String stringIn) throws java.io.UnsupportedEncodingException { return encodeBitstreamName(stringIn, Constants.DEFAULT_ENCODING); @@ -455,7 +457,10 @@ public class Util { * A String with the element name of the metadata field * @param qualifier * A String with the qualifier name of the metadata field + * @param locale locale * @return A list of the respective "displayed-values" + * @throws SQLException if database error + * @throws DCInputsReaderException if reader error */ public static List getControlledVocabulariesDisplayValueLocalized( diff --git a/dspace-api/src/main/java/org/dspace/app/util/WebApp.java b/dspace-api/src/main/java/org/dspace/app/util/WebApp.java index 4c1adbc245..cb1aaf003e 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/WebApp.java +++ b/dspace-api/src/main/java/org/dspace/app/util/WebApp.java @@ -8,6 +8,7 @@ package org.dspace.app.util; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import javax.persistence.*; import java.util.Date; @@ -19,7 +20,7 @@ import java.util.Date; */ @Entity @Table(name="webapp") -public class WebApp { +public class WebApp implements ReloadableEntity { @Id @@ -50,7 +51,7 @@ public class WebApp { } - public Integer getId() { + public Integer getID() { return id; } diff --git a/dspace-api/src/main/java/org/dspace/app/util/XMLUtils.java b/dspace-api/src/main/java/org/dspace/app/util/XMLUtils.java index 7089f884ab..b5533767ca 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/XMLUtils.java +++ b/dspace-api/src/main/java/org/dspace/app/util/XMLUtils.java @@ -25,9 +25,9 @@ public class XMLUtils { /** * - * @param rootElement + * @param dataRoot * the starting node - * @param subElementName + * @param name * the name of the subelement to find * @return the list of all DOM Element with the provided name direct child * of the starting node diff --git a/dspace-api/src/main/java/org/dspace/app/util/dao/WebAppDAO.java b/dspace-api/src/main/java/org/dspace/app/util/dao/WebAppDAO.java index 0f2135c18f..671ebc6287 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/dao/WebAppDAO.java +++ b/dspace-api/src/main/java/org/dspace/app/util/dao/WebAppDAO.java @@ -13,7 +13,7 @@ import org.dspace.core.GenericDAO; /** * Database Access Object interface class for the WebApp object. * The implementation of this class is responsible for all database calls for the WebApp object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/app/util/service/MetadataExposureService.java b/dspace-api/src/main/java/org/dspace/app/util/service/MetadataExposureService.java index a7e32f60a6..dfd646ff2c 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/service/MetadataExposureService.java +++ b/dspace-api/src/main/java/org/dspace/app/util/service/MetadataExposureService.java @@ -58,7 +58,7 @@ public interface MetadataExposureService { * @param qualifier metadata field qualifier * * @return true (hidden) or false (exposed) - * @throws java.sql.SQLException + * @throws SQLException if database error */ public boolean isHidden(Context context, String schema, String element, String qualifier) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/app/util/service/OpenSearchService.java b/dspace-api/src/main/java/org/dspace/app/util/service/OpenSearchService.java index 0dee10d574..9b41d9c6f2 100644 --- a/dspace-api/src/main/java/org/dspace/app/util/service/OpenSearchService.java +++ b/dspace-api/src/main/java/org/dspace/app/util/service/OpenSearchService.java @@ -55,7 +55,7 @@ public interface OpenSearchService { * * @param scope - null for entire repository, or handle or community or collection * @return document the service document - * @throws java.io.IOException + * @throws IOException if IO error */ public Document getDescriptionDoc(String scope) throws IOException; @@ -71,6 +71,7 @@ public interface OpenSearchService { /** * Returns a formatted set of search results as a string * + * @param context DSpace Context * @param format results format - html, rss or atom * @param query - the search query * @param totalResults - the hit count @@ -80,14 +81,15 @@ public interface OpenSearchService { * @param results the retreived DSpace objects satisfying search * @param labels labels to apply - format specific * @return formatted search results - * @throws java.io.IOException + * @throws IOException if IO error */ public String getResultsString(Context context, String format, String query, int totalResults, int start, int pageSize, - DSpaceObject scope, DSpaceObject[] results, + DSpaceObject scope, List results, Map labels) throws IOException; /** * Returns a formatted set of search results as a document * + * @param context DSpace Context * @param format results format - html, rss or atom * @param query - the search query * @param totalResults - the hit count @@ -97,10 +99,10 @@ public interface OpenSearchService { * @param results the retreived DSpace objects satisfying search * @param labels labels to apply - format specific * @return formatted search results - * @throws IOException + * @throws IOException if IO error */ public Document getResultsDoc(Context context, String format, String query, int totalResults, int start, int pageSize, - DSpaceObject scope, DSpaceObject[] results, Map labels) + DSpaceObject scope, List results, Map labels) throws IOException; public DSpaceObject resolveScope(Context context, String scope) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/authenticate/AuthenticationMethod.java b/dspace-api/src/main/java/org/dspace/authenticate/AuthenticationMethod.java index 8efeb4871d..7424a11fe7 100644 --- a/dspace-api/src/main/java/org/dspace/authenticate/AuthenticationMethod.java +++ b/dspace-api/src/main/java/org/dspace/authenticate/AuthenticationMethod.java @@ -74,6 +74,7 @@ public interface AuthenticationMethod { * @param username * Username, if available. May be null. * @return true if new ePerson should be created. + * @throws SQLException if database error */ public boolean canSelfRegister(Context context, HttpServletRequest request, @@ -92,6 +93,7 @@ public interface AuthenticationMethod { * @param eperson * newly created EPerson record - email + information from the * registration form will have been filled out. + * @throws SQLException if database error */ public void initEPerson(Context context, HttpServletRequest request, @@ -111,6 +113,7 @@ public interface AuthenticationMethod { * @param username * Username, if available. May be null. * @return true if this method allows user to change ePerson password. + * @throws SQLException if database error */ public boolean allowSetPassword(Context context, HttpServletRequest request, @@ -149,6 +152,7 @@ public interface AuthenticationMethod { * * @return array of EPerson-group IDs, possibly 0-length, but never * null. + * @throws SQLException if database error */ public List getSpecialGroups(Context context, HttpServletRequest request) throws SQLException; @@ -185,6 +189,7 @@ public interface AuthenticationMethod { *
    CERT_REQUIRED - not allowed to login this way without X.509 cert. *
    NO_SUCH_USER - user not found using this method. *
    BAD_ARGS - user/pw not appropriate for this method + * @throws SQLException if database error */ public int authenticate(Context context, 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 9057fdb416..984904d35b 100644 --- a/dspace-api/src/main/java/org/dspace/authenticate/LDAPAuthentication.java +++ b/dspace-api/src/main/java/org/dspace/authenticate/LDAPAuthentication.java @@ -69,6 +69,7 @@ public class LDAPAuthentication /** * Let a real auth method return true if it wants. + * @throws SQLException if database error */ @Override public boolean canSelfRegister(Context context, @@ -81,7 +82,8 @@ public class LDAPAuthentication } /** - * Nothing here, initialization is done when auto-registering. + * Nothing here, initialization is done when auto-registering. + * @throws SQLException if database error */ @Override public void initEPerson(Context context, HttpServletRequest request, @@ -94,6 +96,7 @@ public class LDAPAuthentication /** * Cannot change LDAP password through dspace, right? + * @throws SQLException if database error */ @Override public boolean allowSetPassword(Context context, diff --git a/dspace-api/src/main/java/org/dspace/authenticate/PasswordAuthentication.java b/dspace-api/src/main/java/org/dspace/authenticate/PasswordAuthentication.java index cf0214abb3..c2050f1844 100644 --- a/dspace-api/src/main/java/org/dspace/authenticate/PasswordAuthentication.java +++ b/dspace-api/src/main/java/org/dspace/authenticate/PasswordAuthentication.java @@ -59,6 +59,8 @@ public class PasswordAuthentication *

    * Example - aber.ac.uk domain : @aber.ac.uk * Example - MIT domain and all .ac.uk domains: @mit.edu, .ac.uk + * @param email email + * @throws SQLException if database error */ @Override public boolean canSelfRegister(Context context, @@ -95,6 +97,7 @@ public class PasswordAuthentication /** * Nothing extra to initialize. + * @throws SQLException if database error */ @Override public void initEPerson(Context context, HttpServletRequest request, @@ -105,6 +108,7 @@ public class PasswordAuthentication /** * We always allow the user to change their password. + * @throws SQLException if database error */ @Override public boolean allowSetPassword(Context context, @@ -196,6 +200,7 @@ public class PasswordAuthentication *
    CERT_REQUIRED - not allowed to login this way without X.509 cert. *
    NO_SUCH_USER - no EPerson with matching email address. *
    BAD_ARGS - missing username, or user matched but cannot login. + * @throws SQLException if database error */ @Override public int authenticate(Context context, diff --git a/dspace-api/src/main/java/org/dspace/authenticate/ShibAuthentication.java b/dspace-api/src/main/java/org/dspace/authenticate/ShibAuthentication.java index 31e5793e39..d23c934f3a 100644 --- a/dspace-api/src/main/java/org/dspace/authenticate/ShibAuthentication.java +++ b/dspace-api/src/main/java/org/dspace/authenticate/ShibAuthentication.java @@ -159,6 +159,7 @@ public class ShibAuthentication implements AuthenticationMethod *
    * NO_SUCH_USER - user not found using this method.
    * BAD_ARGS - user/pw not appropriate for this method + * @throws SQLException if database error */ @Override public int authenticate(Context context, String username, String password, @@ -266,7 +267,7 @@ public class ShibAuthentication implements AuthenticationMethod * * The values extracted (a user may have multiple roles) will be used to look * up which groups to place the user into. The groups are defined as - * "authentication.shib.role." which is a comma separated list of + * {@code authentication.shib.role.} which is a comma separated list of * DSpace groups. * * @param context @@ -400,6 +401,7 @@ public class ShibAuthentication implements AuthenticationMethod * HTTP request, in case anything in that is used to decide * @param email * e-mail address of user attempting to register + * @throws SQLException if database error * */ @Override @@ -434,6 +436,7 @@ public class ShibAuthentication implements AuthenticationMethod * HTTP request, in case anything in that is used to decide * @param username * e-mail address of user attempting to register + * @throws SQLException if database error * */ @Override @@ -456,6 +459,7 @@ public class ShibAuthentication implements AuthenticationMethod * @param eperson * newly created EPerson record - email + information from the * registration form will have been filled out. + * @throws SQLException if database error * */ @Override @@ -578,6 +582,8 @@ public class ShibAuthentication implements AuthenticationMethod * @param context The DSpace database context * @param request The current HTTP Request * @return The EPerson identified or null. + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ protected EPerson findEPerson(Context context, HttpServletRequest request) throws SQLException, AuthorizeException { @@ -676,6 +682,8 @@ public class ShibAuthentication implements AuthenticationMethod * @param context The current DSpace database context * @param request The current HTTP Request * @return A new eperson object or null if unable to create a new eperson. + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ protected EPerson registerNewEPerson(Context context, HttpServletRequest request) throws SQLException, AuthorizeException { @@ -765,6 +773,8 @@ public class ShibAuthentication implements AuthenticationMethod * @param context The current DSpace database context * @param request The current HTTP Request * @param eperson The eperson object to update. + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ protected void updateEPerson(Context context, HttpServletRequest request, EPerson eperson) throws SQLException, AuthorizeException { @@ -855,6 +865,7 @@ public class ShibAuthentication implements AuthenticationMethod * @param password The password * @param request The HTTP Request * @return A valid DSpace Authentication Method status code. + * @throws SQLException if database error */ protected int swordCompatibility(Context context, String username, String password, HttpServletRequest request) throws SQLException { @@ -902,7 +913,8 @@ public class ShibAuthentication implements AuthenticationMethod * the field will be automatically created. * * It is safe to call this methods multiple times. - * @param context + * @param context context + * @throws SQLException if database error */ protected synchronized void initialize(Context context) throws SQLException { @@ -964,8 +976,9 @@ public class ShibAuthentication implements AuthenticationMethod * Check if a MetadataField for an eperson is available. * * @param metadataName The name of the metadata field. - * @param context + * @param context context * @return True if a valid metadata field, otherwise false. + * @throws SQLException if database error */ protected synchronized boolean checkIfEpersonMetadataFieldExists(Context context, String metadataName) throws SQLException { @@ -984,10 +997,12 @@ public class ShibAuthentication implements AuthenticationMethod protected final String COLUMN_NAME_REGEX = "^[_A-Za-z0-9]+$"; /** - * Automattically create a new metadataField for an eperson + * Automatically create a new metadataField for an eperson * + * @param context context * @param metadataName The name of the new metadata field. * @return True if successful, otherwise false. + * @throws SQLException if database error */ protected synchronized boolean autoCreateEpersonMetadataField(Context context, String metadataName) throws SQLException { diff --git a/dspace-api/src/main/java/org/dspace/authenticate/X509Authentication.java b/dspace-api/src/main/java/org/dspace/authenticate/X509Authentication.java index 2a99fc8047..dae6f3db71 100644 --- a/dspace-api/src/main/java/org/dspace/authenticate/X509Authentication.java +++ b/dspace-api/src/main/java/org/dspace/authenticate/X509Authentication.java @@ -387,6 +387,7 @@ public class X509Authentication implements AuthenticationMethod * configuration value. You'll probably want this to be true to take * advantage of a Web certificate infrastructure with many more users than * are already known by DSpace. + * @throws SQLException if database error */ @Override public boolean canSelfRegister(Context context, HttpServletRequest request, @@ -398,6 +399,7 @@ public class X509Authentication implements AuthenticationMethod /** * Nothing extra to initialize. + * @throws SQLException if database error */ @Override public void initEPerson(Context context, HttpServletRequest request, @@ -407,6 +409,7 @@ public class X509Authentication implements AuthenticationMethod /** * We don't use EPerson password so there is no reason to change it. + * @throws SQLException if database error */ @Override public boolean allowSetPassword(Context context, @@ -486,11 +489,12 @@ public class X509Authentication implements AuthenticationMethod * Return special groups configured in dspace.cfg for X509 certificate * authentication. * - * @param context + * @param context context * @param request * object potentially containing the cert * * @return An int array of group IDs + * @throws SQLException if database error * */ @Override @@ -558,6 +562,7 @@ public class X509Authentication implements AuthenticationMethod *

* * @return One of: SUCCESS, BAD_CREDENTIALS, NO_SUCH_USER, BAD_ARGS + * @throws SQLException if database error */ @Override public int authenticate(Context context, String username, String password, diff --git a/dspace-api/src/main/java/org/dspace/authenticate/service/AuthenticationService.java b/dspace-api/src/main/java/org/dspace/authenticate/service/AuthenticationService.java index db4113af90..a402fb26d6 100644 --- a/dspace-api/src/main/java/org/dspace/authenticate/service/AuthenticationService.java +++ b/dspace-api/src/main/java/org/dspace/authenticate/service/AuthenticationService.java @@ -128,13 +128,11 @@ public interface AuthenticationService { * Invokes canSelfRegister() of every authentication * method in the stack, and returns true if any of them is true. * - * @param context - * DSpace context - * @param request - * HTTP request, in case it's needed. Can be null. - * @param username - * Username, if available. Can be null. + * @param context DSpace context + * @param request HTTP request, in case it's needed. Can be null. + * @param username Username, if available. Can be null. * @return true if new ePerson should be created. + * @throws SQLException if database error */ public boolean canSelfRegister(Context context, HttpServletRequest request, @@ -145,13 +143,11 @@ public interface AuthenticationService { * Returns true if the allowSetPassword() method of any * member of the stack returns true. * - * @param context - * DSpace context - * @param request - * HTTP request, in case it's needed. Can be null. - * @param username - * Username, if available. Can be null. + * @param context DSpace context + * @param request HTTP request, in case it's needed. Can be null. + * @param username Username, if available. Can be null. * @return true if this method allows user to change ePerson password. + * @throws SQLException if database error */ public boolean allowSetPassword(Context context, HttpServletRequest request, @@ -168,15 +164,14 @@ public interface AuthenticationService { * Returns accumulation of groups of all the getSpecialGroups() * methods in the stack. * - * @param context - * A valid DSpace context. + * @param context A valid DSpace context. * - * @param request - * The request that started this operation, or null if not applicable. + * @param request The request that started this operation, or null if not applicable. * * @return Returns IDs of any groups the user authenticated by this * request is in implicitly -- checks for e.g. network-address dependent * groups. + * @throws SQLException if database error */ public List getSpecialGroups(Context context, HttpServletRequest request) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/authority/AuthoritySolrServiceImpl.java b/dspace-api/src/main/java/org/dspace/authority/AuthoritySolrServiceImpl.java index 9e6f58bd0b..84a553ffb1 100644 --- a/dspace-api/src/main/java/org/dspace/authority/AuthoritySolrServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/authority/AuthoritySolrServiceImpl.java @@ -107,7 +107,7 @@ public class AuthoritySolrServiceImpl implements AuthorityIndexingService, Autho /** * Write the document to the solr index * @param doc the solr document - * @throws java.io.IOException + * @throws IOException if IO error */ protected void writeDocument(SolrInputDocument doc) throws IOException { @@ -131,6 +131,7 @@ public class AuthoritySolrServiceImpl implements AuthorityIndexingService, Autho /** * Retrieves all the metadata fields which are indexed in the authority control * @return a list of metadata fields + * @throws Exception if error */ @Override public List getAllIndexedMetadataFields() throws Exception { diff --git a/dspace-api/src/main/java/org/dspace/authority/AuthorityValue.java b/dspace-api/src/main/java/org/dspace/authority/AuthorityValue.java index 0a085de0c0..5791fab9d4 100644 --- a/dspace-api/src/main/java/org/dspace/authority/AuthorityValue.java +++ b/dspace-api/src/main/java/org/dspace/authority/AuthorityValue.java @@ -148,6 +148,7 @@ public class AuthorityValue { /** * Generate a solr record from this instance + * @return SolrInputDocument */ public SolrInputDocument getSolrInputDocument() { @@ -164,6 +165,7 @@ public class AuthorityValue { /** * Initialize this instance based on a solr record + * @param document SolrDocument */ public void setValues(SolrDocument document) { this.id = String.valueOf(document.getFieldValue("id")); @@ -176,6 +178,11 @@ public class AuthorityValue { /** * Replace an item's DCValue with this authority + * @param context context + * @param value metadata value + * @param currentItem item + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void updateItem(Context context, Item currentItem, MetadataValue value) throws SQLException, AuthorizeException { value.setValue(getValue()); @@ -185,6 +192,7 @@ public class AuthorityValue { /** * Information that can be used the choice ui + * @return map */ public Map choiceSelectMap() { return new HashMap(); @@ -242,6 +250,7 @@ public class AuthorityValue { /** * Provides a string that will be allow a this AuthorityType to be recognized and provides information to create a new instance to be created using public AuthorityValue newInstance(String info). * See the implementation of com.atmire.org.dspace.authority.AuthorityValueGenerator#generateRaw(java.lang.String, java.lang.String) for more precisions. + * @return */ public String generateString() { return AuthorityValueServiceImpl.GENERATE; @@ -249,6 +258,8 @@ public class AuthorityValue { /** * Makes an instance of the AuthorityValue with the given information. + * @param info string info + * @return AuthorityValue */ public AuthorityValue newInstance(String info) { return new AuthorityValue(); @@ -262,6 +273,8 @@ public class AuthorityValue { * The regular equals() only checks if both AuthorityValues describe the same authority. * This method checks if the AuthorityValues have different information * E.g. it is used to decide when lastModified should be updated. + * @param o object + * @return true or false */ public boolean hasTheSameInformationAs(Object o) { if (this == o) { diff --git a/dspace-api/src/main/java/org/dspace/authority/AuthorityValueServiceImpl.java b/dspace-api/src/main/java/org/dspace/authority/AuthorityValueServiceImpl.java index 7a820ec01d..875c3da4b8 100644 --- a/dspace-api/src/main/java/org/dspace/authority/AuthorityValueServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/authority/AuthorityValueServiceImpl.java @@ -113,6 +113,9 @@ public class AuthorityValueServiceImpl implements AuthorityValueService{ /** * Item.ANY does not work here. + * @param context Context + * @param authorityID authority id + * @return AuthorityValue */ @Override public AuthorityValue findByUID(Context context, String authorityID) { diff --git a/dspace-api/src/main/java/org/dspace/authority/indexer/DSpaceAuthorityIndexer.java b/dspace-api/src/main/java/org/dspace/authority/indexer/DSpaceAuthorityIndexer.java index d0119af125..df8b23654c 100644 --- a/dspace-api/src/main/java/org/dspace/authority/indexer/DSpaceAuthorityIndexer.java +++ b/dspace-api/src/main/java/org/dspace/authority/indexer/DSpaceAuthorityIndexer.java @@ -26,15 +26,14 @@ import java.util.*; /** * DSpaceAuthorityIndexer is used in IndexClient, which is called by the AuthorityConsumer and the indexing-script. - *

+ *

* An instance of DSpaceAuthorityIndexer is bound to a list of items. * This can be one item or all items too depending on the init() method. - *

+ *

* DSpaceAuthorityIndexer lets you iterate over each metadata value * for each metadata field defined in dspace.cfg with 'authority.author.indexer.field' * for each item in the list. - *

- *

+ *

* * @author Antoine Snyers (antoine at atmire.com) * @author Kevin Van de Velde (kevin at atmire dot com) @@ -170,6 +169,8 @@ public class DSpaceAuthorityIndexer implements AuthorityIndexerInterface, Initia * * @param metadataField Is one of the fields defined in dspace.cfg to be indexed. * @param value Is one of the values of the given metadataField in one of the items being indexed. + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ protected void prepareNextValue(String metadataField, MetadataValue value) throws SQLException, AuthorizeException { diff --git a/dspace-api/src/main/java/org/dspace/authority/orcid/OrcidAuthorityValue.java b/dspace-api/src/main/java/org/dspace/authority/orcid/OrcidAuthorityValue.java index 245aec34e3..a36f4f5152 100644 --- a/dspace-api/src/main/java/org/dspace/authority/orcid/OrcidAuthorityValue.java +++ b/dspace-api/src/main/java/org/dspace/authority/orcid/OrcidAuthorityValue.java @@ -119,6 +119,8 @@ public class OrcidAuthorityValue extends PersonAuthorityValue { /** * Create an authority based on a given orcid bio + * @param bio Bio + * @return OrcidAuthorityValue */ public static OrcidAuthorityValue create(Bio bio) { OrcidAuthorityValue authority = OrcidAuthorityValue.create(); diff --git a/dspace-api/src/main/java/org/dspace/authority/orcid/xml/Converter.java b/dspace-api/src/main/java/org/dspace/authority/orcid/xml/Converter.java index b445013bc4..248720d95f 100644 --- a/dspace-api/src/main/java/org/dspace/authority/orcid/xml/Converter.java +++ b/dspace-api/src/main/java/org/dspace/authority/orcid/xml/Converter.java @@ -16,6 +16,7 @@ import org.w3c.dom.Document; * @author Kevin Van de Velde (kevin at atmire dot com) * @author Ben Bosman (ben at atmire dot com) * @author Mark Diggory (markd at atmire dot com) + * @param type */ public abstract class Converter { diff --git a/dspace-api/src/main/java/org/dspace/authority/rest/RestSource.java b/dspace-api/src/main/java/org/dspace/authority/rest/RestSource.java index f6d99b4a50..2278ac24b4 100644 --- a/dspace-api/src/main/java/org/dspace/authority/rest/RestSource.java +++ b/dspace-api/src/main/java/org/dspace/authority/rest/RestSource.java @@ -26,12 +26,6 @@ public abstract class RestSource { this.restConnector = new RESTConnector(url); } - /** - * TODO - * com.atmire.org.dspace.authority.rest.RestSource#queryAuthorities -> add field, so the source can decide whether to query /users or something else. - * -> implement subclasses - * -> implement usages - */ public abstract List queryAuthorities(String text, int max); public abstract AuthorityValue queryAuthorityID(String id); diff --git a/dspace-api/src/main/java/org/dspace/authority/util/XMLUtils.java b/dspace-api/src/main/java/org/dspace/authority/util/XMLUtils.java index 252d90584e..9a2861293d 100644 --- a/dspace-api/src/main/java/org/dspace/authority/util/XMLUtils.java +++ b/dspace-api/src/main/java/org/dspace/authority/util/XMLUtils.java @@ -41,8 +41,10 @@ public class XMLUtils { /** * @param xml The starting context (a Node or a Document, for example). + * @param singleNodeXPath xpath * @return node.getTextContent() on the node that matches singleNodeXPath * null if nothing matches the NodeListXPath + * @throws XPathExpressionException if xpath error */ public static String getTextContent(Node xml, String singleNodeXPath) throws XPathExpressionException { String text = null; @@ -56,8 +58,10 @@ public class XMLUtils { /** * @param xml The starting context (a Node or a Document, for example). + * @param NodeListXPath xpath * @return A Node matches the NodeListXPath * null if nothing matches the NodeListXPath + * @throws XPathExpressionException if xpath error */ public static Node getNode(Node xml, String NodeListXPath) throws XPathExpressionException { Node result = null; @@ -71,8 +75,10 @@ public class XMLUtils { /** * @param xml The starting context (a Node or a Document, for example). + * @param NodeListXPath xpath * @return A NodeList containing the nodes that match the NodeListXPath * null if nothing matches the NodeListXPath + * @throws XPathExpressionException if xpath error */ public static NodeList getNodeList(Node xml, String NodeListXPath) throws XPathExpressionException { NodeList nodeList = null; @@ -93,6 +99,8 @@ public class XMLUtils { * that are element nodes: * node.getNodeType() == Node.ELEMENT_NODE * node instanceof Element + * @param nodeList NodeList + * @return iterator over nodes */ public static Iterator getNodeListIterator(final NodeList nodeList) { return new Iterator() { diff --git a/dspace-api/src/main/java/org/dspace/authorize/AuthorizeConfiguration.java b/dspace-api/src/main/java/org/dspace/authorize/AuthorizeConfiguration.java index a879388236..6282a97c9d 100644 --- a/dspace-api/src/main/java/org/dspace/authorize/AuthorizeConfiguration.java +++ b/dspace-api/src/main/java/org/dspace/authorize/AuthorizeConfiguration.java @@ -174,6 +174,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to create new, not strictly community * related, group? + * @return true/false */ public static boolean canCommunityAdminPerformGroupCreation() { @@ -182,6 +183,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to create collections or subcommunities? + * @return true/false */ public static boolean canCommunityAdminPerformSubelementCreation() { @@ -190,6 +192,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to remove collections or subcommunities? + * @return true/false */ public static boolean canCommunityAdminPerformSubelementDeletion() { @@ -199,6 +202,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to manage the community's and * subcommunities' policies? + * @return true/false */ public static boolean canCommunityAdminManagePolicies() { @@ -208,6 +212,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to create/edit them community's and * subcommunities' admin groups? + * @return true/false */ public static boolean canCommunityAdminManageAdminGroup() { @@ -217,6 +222,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to create/edit the community's and * subcommunities' admin group? + * @return true/false */ public static boolean canCommunityAdminManageCollectionPolicies() { @@ -226,6 +232,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to manage the item template of them * collections? + * @return true/false */ public static boolean canCommunityAdminManageCollectionTemplateItem() { @@ -235,6 +242,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to manage (create/edit/remove) the * submitters group of them collections? + * @return true/false */ public static boolean canCommunityAdminManageCollectionSubmitters() { @@ -244,6 +252,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to manage (create/edit/remove) the workflows * group of them collections? + * @return true/false */ public static boolean canCommunityAdminManageCollectionWorkflows() { @@ -253,6 +262,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to manage (create/edit/remove) the admin * group of them collections? + * @return true/false */ public static boolean canCommunityAdminManageCollectionAdminGroup() { @@ -261,6 +271,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to remove an item from them collections? + * @return true/false */ public static boolean canCommunityAdminPerformItemDeletion() { @@ -269,6 +280,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to withdrawn an item from them collections? + * @return true/false */ public static boolean canCommunityAdminPerformItemWithdrawn() { @@ -278,6 +290,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to reinstate an item from them * collections? + * @return true/false */ public static boolean canCommunityAdminPerformItemReinstatiate() { @@ -287,6 +300,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to manage the policies of an item owned by * one of them collections? + * @return true/false */ public static boolean canCommunityAdminManageItemPolicies() { @@ -296,6 +310,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to add a bitstream to an item owned by one * of them collections? + * @return true/false */ public static boolean canCommunityAdminPerformBitstreamCreation() { @@ -305,6 +320,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to remove a bitstream from an item owned by * one of them collections? + * @return true/false */ public static boolean canCommunityAdminPerformBitstreamDeletion() { @@ -314,6 +330,7 @@ public class AuthorizeConfiguration /** * Are community admins allowed to perform CC License replace or addition to * an item owned by one of them collections? + * @return true/false */ public static boolean canCommunityAdminManageCCLicense() { @@ -322,6 +339,7 @@ public class AuthorizeConfiguration /** * Are collection admins allowed to manage the collection's policies? + * @return true/false */ public static boolean canCollectionAdminManagePolicies() { @@ -331,6 +349,7 @@ public class AuthorizeConfiguration /** * Are collection admins allowed to manage (create/edit/delete) the * collection's item template? + * @return true/false */ public static boolean canCollectionAdminManageTemplateItem() { @@ -340,6 +359,7 @@ public class AuthorizeConfiguration /** * Are collection admins allowed to manage (create/edit/delete) the * collection's submitters group? + * @return true/false */ public static boolean canCollectionAdminManageSubmitters() { @@ -349,6 +369,7 @@ public class AuthorizeConfiguration /** * Are collection admins allowed to manage (create/edit/delete) the * collection's workflows group? + * @return true/false */ public static boolean canCollectionAdminManageWorkflows() { @@ -358,6 +379,7 @@ public class AuthorizeConfiguration /** * Are collection admins allowed to manage (create/edit) the collection's * admins group? + * @return true/false */ public static boolean canCollectionAdminManageAdminGroup() { @@ -366,6 +388,7 @@ public class AuthorizeConfiguration /** * Are collection admins allowed to remove an item from the collection? + * @return true/false */ public static boolean canCollectionAdminPerformItemDeletion() { @@ -374,6 +397,7 @@ public class AuthorizeConfiguration /** * Are collection admins allowed to withdrawn an item from the collection? + * @return true/false */ public static boolean canCollectionAdminPerformItemWithdrawn() { @@ -383,6 +407,7 @@ public class AuthorizeConfiguration /** * Are collection admins allowed to reinstate an item from the * collection? + * @return true/false */ public static boolean canCollectionAdminPerformItemReinstatiate() { @@ -392,6 +417,7 @@ public class AuthorizeConfiguration /** * Are collection admins allowed to manage the policies of item owned by the * collection? + * @return true/false */ public static boolean canCollectionAdminManageItemPolicies() { @@ -401,6 +427,7 @@ public class AuthorizeConfiguration /** * Are collection admins allowed to add a bitstream to an item owned by the * collections? + * @return true/false */ public static boolean canCollectionAdminPerformBitstreamCreation() { @@ -410,6 +437,7 @@ public class AuthorizeConfiguration /** * Are collection admins allowed to remove a bitstream from an item owned by * the collections? + * @return true/false */ public static boolean canCollectionAdminPerformBitstreamDeletion() { @@ -419,6 +447,7 @@ public class AuthorizeConfiguration /** * Are collection admins allowed to replace or adding a CC License to an * item owned by the collections? + * @return true/false */ public static boolean canCollectionAdminManageCCLicense() { @@ -427,6 +456,7 @@ public class AuthorizeConfiguration /** * Are item admins allowed to manage the item's policies? + * @return true/false */ public static boolean canItemAdminManagePolicies() { @@ -435,6 +465,7 @@ public class AuthorizeConfiguration /** * Are item admins allowed to add bitstreams to the item? + * @return true/false */ public static boolean canItemAdminPerformBitstreamCreation() { @@ -443,6 +474,7 @@ public class AuthorizeConfiguration /** * Are item admins allowed to remove bitstreams from the item? + * @return true/false */ public static boolean canItemAdminPerformBitstreamDeletion() { @@ -451,6 +483,7 @@ public class AuthorizeConfiguration /** * Are item admins allowed to replace or adding CC License to the item? + * @return true/false */ public static boolean canItemAdminManageCCLicense() { diff --git a/dspace-api/src/main/java/org/dspace/authorize/AuthorizeException.java b/dspace-api/src/main/java/org/dspace/authorize/AuthorizeException.java index c6179d41d7..6aec1199df 100644 --- a/dspace-api/src/main/java/org/dspace/authorize/AuthorizeException.java +++ b/dspace-api/src/main/java/org/dspace/authorize/AuthorizeException.java @@ -59,6 +59,8 @@ public class AuthorizeException extends Exception * * @param message * the message + * @param o object + * @param a actionID */ public AuthorizeException(String message, DSpaceObject o, int a) { diff --git a/dspace-api/src/main/java/org/dspace/authorize/AuthorizeServiceImpl.java b/dspace-api/src/main/java/org/dspace/authorize/AuthorizeServiceImpl.java index a33f5e9033..81343b6074 100644 --- a/dspace-api/src/main/java/org/dspace/authorize/AuthorizeServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/authorize/AuthorizeServiceImpl.java @@ -228,7 +228,7 @@ public class AuthorizeServiceImpl implements AuthorizeService * object can be used * @return true if user is authorized to perform the given * action, false otherwise - * @throws SQLException + * @throws SQLException if database error */ protected boolean authorize(Context c, DSpaceObject o, int action, EPerson e, boolean useInheritance) throws SQLException { @@ -503,6 +503,8 @@ public class AuthorizeServiceImpl implements AuthorizeService throws SQLException, AuthorizeException { // now add them to the destination object + List newPolicies = new LinkedList<>(); + for (ResourcePolicy srp : policies) { ResourcePolicy rp = resourcePolicyService.create(c); @@ -517,21 +519,17 @@ public class AuthorizeServiceImpl implements AuthorizeService rp.setRpName(srp.getRpName()); rp.setRpDescription(srp.getRpDescription()); rp.setRpType(srp.getRpType()); - // and write out new policy - resourcePolicyService.update(c, rp); + + // and add policy to list of new policies + newPolicies.add(rp); } - serviceFactory.getDSpaceObjectService(dest).updateLastModified(c, dest); + resourcePolicyService.update(c, newPolicies); } @Override public void removeAllPolicies(Context c, DSpaceObject o) throws SQLException, AuthorizeException { - resourcePolicyService.removeAllPolicies(c, o, true); - } - - @Override - public void removeAllPolicies(Context c, DSpaceObject o, boolean updateLastModified) throws SQLException, AuthorizeException { - resourcePolicyService.removeAllPolicies(c, o, updateLastModified); + resourcePolicyService.removeAllPolicies(c, o); } @Override @@ -623,8 +621,8 @@ public class AuthorizeServiceImpl implements AuthorizeService * @param reason * @param dso * @param owningCollection - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void generateAutomaticPolicies(Context context, Date embargoDate, @@ -681,7 +679,6 @@ public class AuthorizeServiceImpl implements AuthorizeService myPolicy.setEPerson(eperson); myPolicy.setRpType(rpType); resourcePolicyService.update(context, myPolicy); - serviceFactory.getDSpaceObjectService(dso).updateLastModified(context, dso); return myPolicy; } diff --git a/dspace-api/src/main/java/org/dspace/authorize/FixDefaultPolicies.java b/dspace-api/src/main/java/org/dspace/authorize/FixDefaultPolicies.java index 5dd1232676..3862727c50 100644 --- a/dspace-api/src/main/java/org/dspace/authorize/FixDefaultPolicies.java +++ b/dspace-api/src/main/java/org/dspace/authorize/FixDefaultPolicies.java @@ -34,6 +34,8 @@ public class FixDefaultPolicies { /** * Command line interface to setPolicies - run to see arguments + * @param argv arguments + * @throws Exception if error */ public static void main(String[] argv) throws Exception { diff --git a/dspace-api/src/main/java/org/dspace/authorize/PolicySet.java b/dspace-api/src/main/java/org/dspace/authorize/PolicySet.java index 88a93c2f3f..6dbdcbeba4 100644 --- a/dspace-api/src/main/java/org/dspace/authorize/PolicySet.java +++ b/dspace-api/src/main/java/org/dspace/authorize/PolicySet.java @@ -43,6 +43,8 @@ public class PolicySet /** * Command line interface to setPolicies - run to see arguments + * @param argv arguments + * @throws Exception if error */ public static void main(String[] argv) throws Exception { @@ -111,9 +113,9 @@ public class PolicySet * @param clearOnly * if true, just delete policies for matching * objects - * @throws SQLException + * @throws SQLException if database error * if database problem - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if current user is not authorized to change these policies */ public static void setPolicies(Context c, int containerType, @@ -139,8 +141,8 @@ public class PolicySet * @param description * @param startDate * @param endDate - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public static void setPolicies(Context c, int containerType, UUID containerID, int contentType, int actionID, UUID groupID, @@ -175,9 +177,9 @@ public class PolicySet * objects * @param filter * if non-null, only process bitstreams whose names contain filter - * @throws SQLException + * @throws SQLException if database error * if database problem - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if current user is not authorized to change these policies */ public static void setPoliciesFilter(Context c, int containerType, @@ -215,9 +217,9 @@ public class PolicySet * @param description * @param startDate * @param endDate - * @throws SQLException + * @throws SQLException if database error * if database problem - * @throws AuthorizeException + * @throws AuthorizeException if authorization error * if current user is not authorized to change these policies */ public static void setPoliciesFilter(Context c, int containerType, diff --git a/dspace-api/src/main/java/org/dspace/authorize/ResourcePolicy.java b/dspace-api/src/main/java/org/dspace/authorize/ResourcePolicy.java index eb6d8f8809..4a11838d7b 100644 --- a/dspace-api/src/main/java/org/dspace/authorize/ResourcePolicy.java +++ b/dspace-api/src/main/java/org/dspace/authorize/ResourcePolicy.java @@ -10,6 +10,7 @@ package org.dspace.authorize; import org.apache.commons.lang.ObjectUtils; import org.dspace.content.DSpaceObject; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.dspace.eperson.EPerson; import org.dspace.eperson.Group; import org.hibernate.annotations.Type; @@ -25,7 +26,7 @@ import java.util.Date; */ @Entity @Table(name="resourcepolicy") -public class ResourcePolicy{ +public class ResourcePolicy implements ReloadableEntity { public static String TYPE_SUBMISSION = "TYPE_SUBMISSION"; public static String TYPE_WORKFLOW = "TYPE_WORKFLOW"; public static String TYPE_CUSTOM= "TYPE_CUSTOM"; @@ -203,6 +204,7 @@ public class ResourcePolicy{ /** * assign an EPerson to this policy + * @param eperson Eperson */ public void setEPerson(EPerson eperson) { @@ -221,6 +223,7 @@ public class ResourcePolicy{ /** * sets ID for Group referred to by this policy + * @param epersonGroup Group */ public void setGroup(Group epersonGroup) { diff --git a/dspace-api/src/main/java/org/dspace/authorize/ResourcePolicyServiceImpl.java b/dspace-api/src/main/java/org/dspace/authorize/ResourcePolicyServiceImpl.java index 8c9feafa00..0277902368 100644 --- a/dspace-api/src/main/java/org/dspace/authorize/ResourcePolicyServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/authorize/ResourcePolicyServiceImpl.java @@ -7,13 +7,9 @@ */ package org.dspace.authorize; -import java.sql.SQLException; -import java.util.Date; -import java.util.List; - +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.ObjectUtils; import org.apache.log4j.Logger; - import org.dspace.authorize.dao.ResourcePolicyDAO; import org.dspace.authorize.service.ResourcePolicyService; import org.dspace.content.DSpaceObject; @@ -24,6 +20,9 @@ import org.dspace.eperson.EPerson; import org.dspace.eperson.Group; import org.springframework.beans.factory.annotation.Autowired; +import java.sql.SQLException; +import java.util.*; + /** * Service implementation for the ResourcePolicy object. * This class is responsible for all business logic calls for the ResourcePolicy object and is autowired by spring. @@ -55,6 +54,7 @@ public class ResourcePolicyServiceImpl implements ResourcePolicyService * ID of the ResourcePolicy * * @return the ResourcePolicy format, or null if the ID is invalid. + * @throws SQLException if database error */ @Override public ResourcePolicy find(Context context, int id) throws SQLException @@ -67,6 +67,8 @@ public class ResourcePolicyServiceImpl implements ResourcePolicyService * * @param context * DSpace context object + * @return ResourcePolicy + * @throws SQLException if database error */ @Override public ResourcePolicy create(Context context) throws SQLException @@ -109,6 +111,10 @@ public class ResourcePolicyServiceImpl implements ResourcePolicyService /** * Delete an ResourcePolicy * + * @param context context + * @param resourcePolicy resource policy + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void delete(Context context, ResourcePolicy resourcePolicy) throws SQLException, AuthorizeException { @@ -125,6 +131,7 @@ public class ResourcePolicyServiceImpl implements ResourcePolicyService /** + * @param resourcePolicy resource policy * @return action text or 'null' if action row empty */ @Override @@ -144,6 +151,7 @@ public class ResourcePolicyServiceImpl implements ResourcePolicyService /** * figures out if the date is valid for the policy * + * @param resourcePolicy resource policy * @return true if policy has begun and hasn't expired yet (or no dates are * set) */ @@ -195,17 +203,7 @@ public class ResourcePolicyServiceImpl implements ResourcePolicyService @Override public void removeAllPolicies(Context c, DSpaceObject o) throws SQLException, AuthorizeException { - // FIXME: authorization check? - removeAllPolicies(c, o, true); - } - - @Override - public void removeAllPolicies(Context c, DSpaceObject o, boolean updateLastModified) throws SQLException, AuthorizeException { - // FIXME: authorization check? - if(updateLastModified) - { - contentServiceFactory.getDSpaceObjectService(o).updateLastModified(c, o); - } + contentServiceFactory.getDSpaceObjectService(o).updateLastModified(c, o); resourcePolicyDAO.deleteByDso(c, o); } @@ -253,15 +251,38 @@ public class ResourcePolicyServiceImpl implements ResourcePolicyService /** * Update the ResourcePolicy + * @param context context + * @param resourcePolicy resource policy + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void update(Context context, ResourcePolicy resourcePolicy) throws SQLException, AuthorizeException { - if(resourcePolicy.getdSpaceObject() != null){ - //A policy for a DSpace Object has been modified, fire a modify event on the DSpace object - contentServiceFactory.getDSpaceObjectService(resourcePolicy.getdSpaceObject()).updateLastModified(context, resourcePolicy.getdSpaceObject()); - } + update(context, Collections.singletonList(resourcePolicy)); + } - // FIXME: Check authorisation - resourcePolicyDAO.save(context, resourcePolicy); + /** + * Update the ResourcePolicies + */ + @Override + public void update(Context context, List resourcePolicies) throws SQLException, AuthorizeException { + if(CollectionUtils.isNotEmpty(resourcePolicies)) { + Set relatedDSpaceObjects = new HashSet<>(); + + for (ResourcePolicy resourcePolicy : resourcePolicies) { + if (resourcePolicy.getdSpaceObject() != null) { + relatedDSpaceObjects.add(resourcePolicy.getdSpaceObject()); + } + + // FIXME: Check authorisation + resourcePolicyDAO.save(context, resourcePolicy); + } + + //Update the last modified timestamp of all related DSpace Objects + for (DSpaceObject dSpaceObject : relatedDSpaceObjects) { + //A policy for a DSpace Object has been modified, fire a modify event on the DSpace object + contentServiceFactory.getDSpaceObjectService(dSpaceObject).updateLastModified(context, dSpaceObject); + } + } } } diff --git a/dspace-api/src/main/java/org/dspace/authorize/dao/ResourcePolicyDAO.java b/dspace-api/src/main/java/org/dspace/authorize/dao/ResourcePolicyDAO.java index 6c7fe656f9..a75628a5c3 100644 --- a/dspace-api/src/main/java/org/dspace/authorize/dao/ResourcePolicyDAO.java +++ b/dspace-api/src/main/java/org/dspace/authorize/dao/ResourcePolicyDAO.java @@ -20,7 +20,7 @@ import java.util.List; /** * Database Access Object interface class for the ResourcePolicy object. * The implementation of this class is responsible for all database calls for the ResourcePolicy object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/authorize/dao/impl/ResourcePolicyDAOImpl.java b/dspace-api/src/main/java/org/dspace/authorize/dao/impl/ResourcePolicyDAOImpl.java index 8cf3805a2b..bdb67edf07 100644 --- a/dspace-api/src/main/java/org/dspace/authorize/dao/impl/ResourcePolicyDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/authorize/dao/impl/ResourcePolicyDAOImpl.java @@ -113,9 +113,9 @@ public class ResourcePolicyDAOImpl extends AbstractHibernateDAO @Override public void deleteByDsoAndType(Context context, DSpaceObject dso, String type) throws SQLException { - String queryString = "delete from ResourcePolicy where dSpaceObject= :dso AND rptype = :rptype"; + String queryString = "delete from ResourcePolicy where dSpaceObject.id = :dsoId AND rptype = :rptype"; Query query = createQuery(context, queryString); - query.setParameter("dso", dso); + query.setParameter("dsoId", dso.getID()); query.setString("rptype", type); query.executeUpdate(); } diff --git a/dspace-api/src/main/java/org/dspace/authorize/service/AuthorizeService.java b/dspace-api/src/main/java/org/dspace/authorize/service/AuthorizeService.java index fd780c9e17..e6d4d02616 100644 --- a/dspace-api/src/main/java/org/dspace/authorize/service/AuthorizeService.java +++ b/dspace-api/src/main/java/org/dspace/authorize/service/AuthorizeService.java @@ -7,10 +7,6 @@ */ package org.dspace.authorize.service; -import java.sql.SQLException; -import java.util.Date; -import java.util.List; - import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.ResourcePolicy; import org.dspace.content.Collection; @@ -19,6 +15,10 @@ import org.dspace.core.Context; import org.dspace.eperson.EPerson; import org.dspace.eperson.Group; +import java.sql.SQLException; +import java.util.Date; +import java.util.List; + /** * AuthorizeManager handles all authorization checks for DSpace. For better * security, DSpace assumes that you do not have the right to do something @@ -41,16 +41,13 @@ public interface AuthorizeService { * perform all of the specified actions on the given object. An * AuthorizeException if all the authorizations fail. * - * @param c - * context with the current user - * @param o - * DSpace object user is attempting to perform action on - * @param actions - * array of action IDs from + * @param c context with the current user + * @param o DSpace object user is attempting to perform action on + * @param actions array of action IDs from * org.dspace.core.Constants - * @throws AuthorizeException - * if any one of the specified actions cannot be performed by - * the current user on the given object. + * @throws AuthorizeException if any one of the specified actions cannot be + * performed by the current user on the given object. + * @throws SQLException if database error */ public void authorizeAnyOf(Context c, DSpaceObject o, int[] actions) throws AuthorizeException, SQLException; @@ -59,14 +56,11 @@ public interface AuthorizeService { * the given object. Throws an exception if the user is not authorized, * otherwise the method call does nothing. * - * @param c - * context - * @param o - * a DSpaceObject - * @param action - * action to perform from org.dspace.core.Constants - * @throws AuthorizeException - * if the user is denied + * @param c context + * @param o a DSpaceObject + * @param action action to perform from org.dspace.core.Constants + * @throws AuthorizeException if the user is denied + * @throws SQLException if database error */ public void authorizeAction(Context c, DSpaceObject o, int action) throws AuthorizeException, SQLException; @@ -75,17 +69,14 @@ public interface AuthorizeService { * the given object. Throws an exception if the user is not authorized, * otherwise the method call does nothing. * - * @param c - * context - * @param o - * a DSpaceObject + * @param c context + * @param o a DSpaceObject * @param useInheritance * flag to say if ADMIN action on the current object or parent * object can be used - * @param action - * action to perform from org.dspace.core.Constants - * @throws AuthorizeException - * if the user is denied + * @param action action to perform from org.dspace.core.Constants + * @throws AuthorizeException if the user is denied + * @throws SQLException if database error */ public void authorizeAction(Context c, DSpaceObject o, int action, boolean useInheritance) throws AuthorizeException, SQLException; @@ -95,19 +86,15 @@ public interface AuthorizeService { * the given object. Throws an exception if the user is not authorized, * otherwise the method call does nothing. * - * @param c - * context - * @param e - * the eperson to use for the authorization check - * @param o - * a DSpaceObject + * @param c context + * @param e the eperson to use for the authorization check + * @param o a DSpaceObject * @param useInheritance * flag to say if ADMIN action on the current object or parent * object can be used - * @param action - * action to perform from org.dspace.core.Constants - * @throws AuthorizeException - * if the user is denied + * @param action action to perform from org.dspace.core.Constants + * @throws AuthorizeException if the user is denied + * @throws SQLException if database error */ public void authorizeAction(Context c, EPerson e, DSpaceObject o, int action, boolean useInheritance) throws AuthorizeException, SQLException; @@ -116,15 +103,13 @@ public interface AuthorizeService { * same authorize, returns boolean for those who don't want to deal with * catching exceptions. * - * @param c - * DSpace context, containing current user - * @param o - * DSpaceObject - * @param a - * action being attempted, from + * @param c DSpace context, containing current user + * @param o DSpaceObject + * @param a action being attempted, from * org.dspace.core.Constants * @return true if the current user in the context is * authorized to perform the given action on the given object + * @throws SQLException if database error */ public boolean authorizeActionBoolean(Context c, DSpaceObject o, int a) throws SQLException; @@ -132,18 +117,16 @@ public interface AuthorizeService { * same authorize, returns boolean for those who don't want to deal with * catching exceptions. * - * @param c - * DSpace context, containing current user - * @param o - * DSpaceObject - * @param a - * action being attempted, from + * @param c DSpace context, containing current user + * @param o DSpaceObject + * @param a action being attempted, from * org.dspace.core.Constants * @param useInheritance * flag to say if ADMIN action on the current object or parent * object can be used * @return true if the current user in the context is * authorized to perform the given action on the given object + * @throws SQLException if database error */ public boolean authorizeActionBoolean(Context c, DSpaceObject o, int a, boolean useInheritance) throws SQLException; @@ -151,20 +134,17 @@ public interface AuthorizeService { * same authorize with a specif eperson (not the current user), returns boolean for those who don't want to deal with * catching exceptions. * - * @param c - * DSpace context - * @param e - * EPerson to use in the check - * @param o - * DSpaceObject - * @param a - * action being attempted, from + * @param c DSpace context + * @param e EPerson to use in the check + * @param o DSpaceObject + * @param a action being attempted, from * org.dspace.core.Constants * @param useInheritance * flag to say if ADMIN action on the current object or parent * object can be used * @return true if the requested user is * authorized to perform the given action on the given object + * @throws SQLException if database error */ public boolean authorizeActionBoolean(Context c, EPerson e, DSpaceObject o, int a, boolean useInheritance) throws SQLException; @@ -177,14 +157,13 @@ public interface AuthorizeService { * within DSpace. Always return true if the user is a System * Admin * - * @param c - * current context - * @param o - * current DSpace Object, if null the call will be + * @param c current context + * @param o current DSpace Object, if null the call will be * equivalent to a call to the isAdmin(Context c) * method * @return true if user has administrative privileges on the * given DSpace object + * @throws SQLException if database error */ public boolean isAdmin(Context c, DSpaceObject o) throws SQLException; @@ -194,10 +173,10 @@ public interface AuthorizeService { * true if c.ignoreAuthorization is set. Anonymous users * can't be Admins (EPerson set to NULL) * - * @param c - * current context + * @param c current context * @return true if user is an admin or ignore authorization * flag set + * @throws SQLException if database error */ public boolean isAdmin(Context c) throws SQLException; @@ -208,16 +187,12 @@ public interface AuthorizeService { /** * Add a policy for an individual eperson * - * @param c - * context. Current user irrelevant - * @param o - * DSpaceObject to add policy to - * @param actionID - * ID of action from org.dspace.core.Constants - * @param e - * eperson who can perform the action - * @throws AuthorizeException - * if current user in context is not authorized to add policies + * @param c context. Current user irrelevant + * @param o DSpaceObject to add policy to + * @param actionID ID of action from org.dspace.core.Constants + * @param e eperson who can perform the action + * @throws SQLException if database error + * @throws AuthorizeException if current user in context is not authorized to add policies */ public void addPolicy(Context c, DSpaceObject o, int actionID, EPerson e) throws SQLException, AuthorizeException; @@ -225,175 +200,134 @@ public interface AuthorizeService { /** * Add a policy for an individual eperson * - * @param c - * context. Current user irrelevant - * @param o - * DSpaceObject to add policy to - * @param actionID - * ID of action from org.dspace.core.Constants - * @param e - * eperson who can perform the action - * @param type - * policy type, deafult types are declared in the ResourcePolicy class - * @throws AuthorizeException - * if current user in context is not authorized to add policies + * @param c context. Current user irrelevant + * @param o DSpaceObject to add policy to + * @param actionID ID of action from org.dspace.core.Constants + * @param e eperson who can perform the action + * @param type policy type, deafult types are declared in the ResourcePolicy class + * @throws SQLException if database error + * @throws AuthorizeException if current user in context is not authorized to add policies */ public void addPolicy(Context c, DSpaceObject o, int actionID, EPerson e, String type) throws SQLException, AuthorizeException; /** * Add a policy for a group * - * @param c - * current context - * @param o - * object to add policy for - * @param actionID - * ID of action from org.dspace.core.Constants - * @param g - * group to add policy for - * @throws SQLException - * if there's a database problem - * @throws AuthorizeException - * if the current user is not authorized to add this policy + * @param c current context + * @param o object to add policy for + * @param actionID ID of action from org.dspace.core.Constants + * @param g group to add policy for + * @throws SQLException if there's a database problem + * @throws AuthorizeException if the current user is not authorized to add this policy */ public void addPolicy(Context c, DSpaceObject o, int actionID, Group g) throws SQLException, AuthorizeException; /** * Add a policy for a group * - * @param c - * current context - * @param o - * object to add policy for - * @param actionID - * ID of action from org.dspace.core.Constants - * @param g - * group to add policy for - * @param type - * policy type, deafult types are declared in the ResourcePolicy class - * @throws SQLException - * if there's a database problem - * @throws AuthorizeException - * if the current user is not authorized to add this policy + * @param c current context + * @param o object to add policy for + * @param actionID ID of action from org.dspace.core.Constants + * @param g group to add policy for + * @param type policy type, deafult types are declared in the ResourcePolicy class + * @throws SQLException if there's a database problem + * @throws AuthorizeException if the current user is not authorized to add this policy */ public void addPolicy(Context c, DSpaceObject o, int actionID, Group g, String type) throws SQLException, AuthorizeException; /** * Return a List of the policies for an object * - * @param c - * current context - * @param o - * object to retrieve policies for + * @param c current context + * @param o object to retrieve policies for * @return List of ResourcePolicy objects + * @throws SQLException if database error */ public List getPolicies(Context c, DSpaceObject o) throws SQLException; /** * Return a List of the policies for an object * - * @param c - * current context - * @param o - * object to retrieve policies for + * @param c current context + * @param o object to retrieve policies for + * @param type type * @return List of ResourcePolicy objects + * @throws SQLException if database error */ public List findPoliciesByDSOAndType(Context c, DSpaceObject o, String type) throws SQLException; /** * Return a List of the policies for a group * - * @param c - * current context - * @param g - * group to retrieve policies for + * @param c current context + * @param g group to retrieve policies for * @return List of ResourcePolicy objects + * @@throws SQLException if database error */ public List getPoliciesForGroup(Context c, Group g) throws SQLException; /** * Return a list of policies for an object that match the action * - * @param c - * context - * @param o - * DSpaceObject policies relate to - * @param actionID - * action (defined in class Constants) - * @throws SQLException - * if there's a database problem + * @param c context + * @param o DSpaceObject policies relate to + * @param actionID action (defined in class Constants) + * @return list of resource policies + * @throws SQLException if there's a database problem */ public List getPoliciesActionFilter(Context c, DSpaceObject o, int actionID) throws SQLException; /** * Add policies to an object to match those from a previous object * - * @param c - * context - * @param src - * source of policies - * @param dest - * destination of inherited policies - * @throws SQLException - * if there's a database problem - * @throws AuthorizeException - * if the current user is not authorized to add these policies + * @param c context + * @param src source of policies + * @param dest destination of inherited policies + * @throws SQLException if there's a database problem + * @throws AuthorizeException if the current user is not authorized to add these policies */ public void inheritPolicies(Context c, DSpaceObject src, DSpaceObject dest) throws SQLException, AuthorizeException; /** * Copies policies from a list of resource policies to a given DSpaceObject * - * @param c - * DSpace context - * @param policies - * List of ResourcePolicy objects - * @param dest - * object to have policies added - * @throws SQLException - * if there's a database problem - * @throws AuthorizeException - * if the current user is not authorized to add these policies + * @param c DSpace context + * @param policies List of ResourcePolicy objects + * @param dest object to have policies added + * @throws SQLException if there's a database problem + * @throws AuthorizeException if the current user is not authorized to add these policies */ public void addPolicies(Context c, List policies, DSpaceObject dest) throws SQLException, AuthorizeException; /** * removes ALL policies for an object. FIXME doesn't check authorization * - * @param c - * DSpace context - * @param o - * object to remove policies for - * @throws SQLException - * if there's a database problem + * @param c DSpace context + * @param o object to remove policies for + * @throws SQLException if there's a database problem + * @throws AuthorizeException if authorization error */ public void removeAllPolicies(Context c, DSpaceObject o) throws SQLException, AuthorizeException; - public void removeAllPolicies(Context c, DSpaceObject o, boolean updateLastModified) throws SQLException, AuthorizeException; - /** * removes ALL policies for an object that are not of the input type. * - * @param c - * DSpace context - * @param o - * object to remove policies for - * @throws SQLException - * if there's a database problem + * @param c DSpace context + * @param o object to remove policies for + * @param type type + * @throws SQLException if there's a database problem + * @throws AuthorizeException if authorization error */ public void removeAllPoliciesByDSOAndTypeNotEqualsTo(Context c, DSpaceObject o, String type) throws SQLException, AuthorizeException; /** * removes policies * - * @param c - * DSpace context - * @param o - * object to remove policies for - * @param type - * policy type - * @throws SQLException - * if there's a database problem + * @param c DSpace context + * @param o object to remove policies for + * @param type policy type + * @throws SQLException if there's a database problem + * @throws AuthorizeException if authorization error */ public void removeAllPoliciesByDSOAndType(Context c, DSpaceObject o, String type) throws SQLException, AuthorizeException; @@ -401,15 +335,12 @@ public interface AuthorizeService { * Remove all policies from an object that match a given action. FIXME * doesn't check authorization * - * @param context - * current context - * @param dso - * object to remove policies from - * @param actionID - * ID of action to match from + * @param context current context + * @param dso object to remove policies from + * @param actionID ID of action to match from * org.dspace.core.Constants, or -1=all - * @throws SQLException - * if there's a database problem + * @throws SQLException if there's a database problem + * @throws AuthorizeException if authorization error */ public void removePoliciesActionFilter(Context context, DSpaceObject dso, int actionID) throws SQLException, AuthorizeException; @@ -417,12 +348,9 @@ public interface AuthorizeService { * Removes all policies relating to a particular group. FIXME doesn't check * authorization * - * @param c - * current context - * @param group - * the group - * @throws SQLException - * if there's a database problem + * @param c current context + * @param group the group + * @throws SQLException if there's a database problem */ public void removeGroupPolicies(Context c, Group group) throws SQLException; @@ -430,14 +358,11 @@ public interface AuthorizeService { * Removes all policies from a group for a particular object that belong to * a Group. FIXME doesn't check authorization * - * @param c - * current context - * @param o - * the object - * @param g - * the group - * @throws SQLException - * if there's a database problem + * @param c current context + * @param o the object + * @param g the group + * @throws SQLException if there's a database problem + * @throws AuthorizeException if authorization error */ public void removeGroupPolicies(Context c, DSpaceObject o, Group g) throws SQLException, AuthorizeException; @@ -445,14 +370,11 @@ public interface AuthorizeService { * Removes all policies from an eperson for a particular object that belong to * an EPerson. FIXME doesn't check authorization * - * @param c - * current context - * @param o - * the object - * @param e - * the eperson - * @throws java.sql.SQLException - * if there's a database problem + * @param c current context + * @param o the object + * @param e the eperson + * @throws SQLException if there's a database problem + * @throws AuthorizeException if authorization error */ public void removeEPersonPolicies(Context c, DSpaceObject o, EPerson e) throws SQLException, AuthorizeException; @@ -460,16 +382,12 @@ public interface AuthorizeService { * Returns all groups authorized to perform an action on an object. Returns * empty array if no matches. * - * @param c - * current context - * @param o - * object - * @param actionID - * ID of action from org.dspace.core.Constants + * @param c current context + * @param o object + * @param actionID ID of action from org.dspace.core.Constants * @return array of Groups that can perform the specified * action on the specified object - * @throws java.sql.SQLException - * if there's a database problem + * @throws SQLException if there's a database problem */ public List getAuthorizedGroups(Context c, DSpaceObject o, int actionID) throws java.sql.SQLException; @@ -479,17 +397,13 @@ public interface AuthorizeService { /** * Is a policy with the specified parameters already in place? * - * @param c - * current context - * @param o - * object - * @param actionID - * ID of action from org.dspace.core.Constants - * @param policyID - * ID of an existing policy. If -1 is specified, this parameter will be ignored + * @param c current context + * @param o object + * @param group group + * @param actionID ID of action from org.dspace.core.Constants + * @param policyID ID of an existing policy. If -1 is specified, this parameter will be ignored * @return true if such a policy exists, false otherwise - * @throws java.sql.SQLException - * if there's a database problem + * @throws SQLException if there's a database problem */ public boolean isAnIdenticalPolicyAlreadyInPlace(Context c, DSpaceObject o, Group group, int actionID, int policyID) throws SQLException; @@ -501,12 +415,12 @@ public interface AuthorizeService { * have right on the collection. E.g., if the anonymous can access the collection policies are assigned to anonymous. * * @param context current context - * @param embargoDate - * @param reason - * @param dso - * @param owningCollection - * @throws SQLException - * @throws AuthorizeException + * @param embargoDate date + * @param reason reason + * @param dso DSpaceObject + * @param owningCollection collection + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void generateAutomaticPolicies(Context context, Date embargoDate, String reason, DSpaceObject dso, Collection owningCollection) throws SQLException, AuthorizeException; diff --git a/dspace-api/src/main/java/org/dspace/authorize/service/ResourcePolicyService.java b/dspace-api/src/main/java/org/dspace/authorize/service/ResourcePolicyService.java index 71c0261fcb..15bb640ed7 100644 --- a/dspace-api/src/main/java/org/dspace/authorize/service/ResourcePolicyService.java +++ b/dspace-api/src/main/java/org/dspace/authorize/service/ResourcePolicyService.java @@ -45,8 +45,6 @@ public interface ResourcePolicyService extends DSpaceCRUDService public void removeAllPolicies(Context c, DSpaceObject o) throws SQLException, AuthorizeException; - public void removeAllPolicies(Context c, DSpaceObject o, boolean updateLastModified) throws SQLException, AuthorizeException; - public void removePolicies(Context c, DSpaceObject o, int actionId) throws SQLException, AuthorizeException; public void removePolicies(Context c, DSpaceObject o, String type) throws SQLException, AuthorizeException; diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowseDAO.java b/dspace-api/src/main/java/org/dspace/browse/BrowseDAO.java index 4e41ae2920..55051ca47a 100644 --- a/dspace-api/src/main/java/org/dspace/browse/BrowseDAO.java +++ b/dspace-api/src/main/java/org/dspace/browse/BrowseDAO.java @@ -44,7 +44,7 @@ public interface BrowseDAO * parameters you set. * * @return the integer value of the number of results found - * @throws BrowseException + * @throws BrowseException if browse error */ public int doCountQuery() throws BrowseException; @@ -55,7 +55,7 @@ public interface BrowseDAO * commonly used with a Distinct browse type. * * @return List of Strings representing the single value query results - * @throws BrowseException + * @throws BrowseException if browse error */ public List doValueQuery() throws BrowseException; @@ -64,7 +64,7 @@ public interface BrowseDAO * representing the results of a full item browse. * * @return List of BrowseItem objects - * @throws BrowseException + * @throws BrowseException if browse error */ public List doQuery() throws BrowseException; @@ -76,7 +76,7 @@ public interface BrowseDAO * @param table the table to query * @param itemID the item id * @return String representing the max value in the given column - * @throws BrowseException + * @throws BrowseException if browse error */ public String doMaxQuery(String column, String table, int itemID) throws BrowseException; @@ -88,7 +88,7 @@ public interface BrowseDAO * @param value the item id * @param isAscending browsing in ascending or descending order * @return the offset into the table - * @throws BrowseException + * @throws BrowseException if browse error */ public int doOffsetQuery(String column, String value, boolean isAscending) throws BrowseException; @@ -100,7 +100,7 @@ public interface BrowseDAO * @param value the item id * @param isAscending browsing in ascending or descending order * @return the offset into the table - * @throws BrowseException + * @throws BrowseException if browse error */ public int doDistinctOffsetQuery(String column, String value, boolean isAscending) throws BrowseException; @@ -117,8 +117,8 @@ public interface BrowseDAO /** * Set whether the query should use an equals comparator when doing less than or * greater than comparisons. That is, if true then comparisons will be made - * using the equivalent of "<=" and ">=", while if false it will use the - * equivalent of "<" and ">" + * using the equivalent of {@code <=} and {@code >=}, while if false it will use the + * equivalent of {@code <} and {@code >} * * @param equalsComparator true to use, false to not. */ @@ -189,7 +189,7 @@ public interface BrowseDAO * the browse. This will either be the "sort_value" field or one of the * additional sort fields defined by configuration * - * param focusField the name of the focus field + * @param focusField the name of the focus field */ public void setJumpToField(String focusField); diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowseDAOFactory.java b/dspace-api/src/main/java/org/dspace/browse/BrowseDAOFactory.java index 540a4db5bd..994404e55a 100644 --- a/dspace-api/src/main/java/org/dspace/browse/BrowseDAOFactory.java +++ b/dspace-api/src/main/java/org/dspace/browse/BrowseDAOFactory.java @@ -24,7 +24,7 @@ public class BrowseDAOFactory * * @param context the DSpace context * @return the relevant DAO - * @throws BrowseException + * @throws BrowseException if browse error */ public static BrowseDAO getInstance(Context context) throws BrowseException diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowseEngine.java b/dspace-api/src/main/java/org/dspace/browse/BrowseEngine.java index 4d070c0ea7..6eb3096678 100644 --- a/dspace-api/src/main/java/org/dspace/browse/BrowseEngine.java +++ b/dspace-api/src/main/java/org/dspace/browse/BrowseEngine.java @@ -53,7 +53,7 @@ public class BrowseEngine * for the Browse Engine, based on the brand of the provided DBMS. * * @param context the DSpace context - * @throws BrowseException + * @throws BrowseException if browse error */ public BrowseEngine(Context context) throws BrowseException @@ -73,7 +73,7 @@ public class BrowseEngine * * @param bs the scope of the browse * @return the results of the browse - * @throws BrowseException + * @throws BrowseException if browse error */ public BrowseInfo browse(BrowserScope bs) throws BrowseException @@ -111,6 +111,7 @@ public class BrowseEngine * * @param bs the scope of the browse * @return the results of the browse + * @throws BrowseException if browse error */ public BrowseInfo browseMini(BrowserScope bs) throws BrowseException @@ -196,7 +197,7 @@ public class BrowseEngine * * @param bs the scope of the browse * @return the results of the browse - * @throws BrowseException + * @throws BrowseException if browse error */ private BrowseInfo browseByItem(BrowserScope bs) throws BrowseException @@ -395,7 +396,7 @@ public class BrowseEngine * * @param bs the scope of the browse * @return the results of the browse - * @throws BrowseException + * @throws BrowseException if browse error */ private BrowseInfo browseByValue(BrowserScope bs) throws BrowseException @@ -562,7 +563,7 @@ public class BrowseEngine * Return the focus value. * * @return the focus value to use - * @throws BrowseException + * @throws BrowseException if browse error */ private String getJumpToValue() throws BrowseException @@ -627,8 +628,9 @@ public class BrowseEngine /** * Convert the value into an offset into the table for this browse * + * @param value value * @return the focus value to use - * @throws BrowseException + * @throws BrowseException if browse error */ private int getOffsetForValue(String value) throws BrowseException @@ -662,8 +664,9 @@ public class BrowseEngine /** * Convert the value into an offset into the table for this browse * + * @param value value * @return the focus value to use - * @throws BrowseException + * @throws BrowseException if browse error */ private int getOffsetForDistinctValue(String value) throws BrowseException @@ -685,7 +688,7 @@ public class BrowseEngine * * @param value a focus value to normalize * @return the normalized focus value - * @throws BrowseException + * @throws BrowseException if browse error */ private String normalizeJumpToValue(String value) throws BrowseException @@ -712,9 +715,9 @@ public class BrowseEngine * Get the total number of results for the browse. This is the same as * calling getTotalResults(false) * - * @return - * @throws SQLException - * @throws BrowseException + * @return total + * @throws SQLException if database error + * @throws BrowseException if browse error */ private int getTotalResults() throws SQLException, BrowseException @@ -728,8 +731,8 @@ public class BrowseEngine * * @param distinct is this a distinct browse or not * @return the total number of results available in this type of browse - * @throws SQLException - * @throws BrowseException + * @throws SQLException if database error + * @throws BrowseException if browse error */ private int getTotalResults(boolean distinct) throws SQLException, BrowseException diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowseIndex.java b/dspace-api/src/main/java/org/dspace/browse/BrowseIndex.java index 9e6dcd8f8b..0a39b9b748 100644 --- a/dspace-api/src/main/java/org/dspace/browse/BrowseIndex.java +++ b/dspace-api/src/main/java/org/dspace/browse/BrowseIndex.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.lang.StringUtils; import org.dspace.core.ConfigurationManager; import org.dspace.sort.SortOption; @@ -123,7 +122,7 @@ public final class BrowseIndex * * @param definition the configuration definition of this index * @param number the configuration number of this index - * @throws BrowseException + * @throws BrowseException if browse error */ private BrowseIndex(String definition, int number) throws BrowseException @@ -295,6 +294,7 @@ public final class BrowseIndex } /** + * @param idx index * @return Returns the mdBits. */ public String[] getMdBits(int idx) @@ -315,6 +315,11 @@ public final class BrowseIndex return metadataAll; } + /** + * + * @param idx index + * @return metadata + */ public String getMetadata(int idx) { return metadata[idx]; @@ -338,12 +343,17 @@ public final class BrowseIndex /** * Get the SortOption associated with this index. + * @return SortOption */ public SortOption getSortOption() { return sortOption; } + /** + * + * @return true or false + */ public boolean isDisplayFrequencies() { return displayFrequencies; } @@ -445,12 +455,12 @@ public final class BrowseIndex /** * Generate a table name from the given base - * @param baseName - * @param isCommunity - * @param isCollection - * @param isDistinct - * @param isMap - * @return + * @param baseName base name + * @param isCommunity whether this is a community constrained index (view) + * @param isCollection whether this is a collection constrained index (view) + * @param isDistinct whether this is a distinct table + * @param isMap whether this is a distinct map table + * @return table name */ private static String getTableName(String baseName, boolean isCommunity, boolean isCollection, boolean isDistinct, boolean isMap) { @@ -523,6 +533,8 @@ public final class BrowseIndex * * getTableName(false, false, false, false); * + * + * @return table name */ public String getTableName() { @@ -538,10 +550,11 @@ public final class BrowseIndex * getTableName(isCommunity, isCollection, isDistinct, false); * * - * @param isDistinct is this a distinct table - * @param isCommunity - * @param isCollection + * @param isCommunity whether this is a community constrained index (view) + * @param isCollection whether this is a collection constrained index (view) + * @param isDistinct whether this is a distinct table * @deprecated 1.5 + * @return table name */ public String getTableName(boolean isDistinct, boolean isCommunity, boolean isCollection) { @@ -554,6 +567,7 @@ public final class BrowseIndex * * getTableName(false, false, false, true); * + * @return table name */ public String getMapTableName() { @@ -566,6 +580,7 @@ public final class BrowseIndex * * getTableName(false, false, true, false); * + * @return table name */ public String getDistinctTableName() { @@ -661,7 +676,9 @@ public final class BrowseIndex /** * Get the field for sorting associated with this index. - * @throws BrowseException + * @param isSecondLevel whether second level browse + * @return sort field + * @throws BrowseException if browse error */ public String getSortField(boolean isSecondLevel) throws BrowseException { @@ -686,8 +703,9 @@ public final class BrowseIndex } /** + * @return array of tables * @deprecated - * @throws BrowseException + * @throws BrowseException if browse error */ public static String[] tables() throws BrowseException @@ -706,7 +724,7 @@ public final class BrowseIndex * Get an array of all the browse indices for the current configuration * * @return an array of all the current browse indices - * @throws BrowseException + * @throws BrowseException if browse error */ public static BrowseIndex[] getBrowseIndices() throws BrowseException @@ -738,7 +756,7 @@ public final class BrowseIndex * * @param name the name to retrieve * @return the specified browse index - * @throws BrowseException + * @throws BrowseException if browse error */ public static BrowseIndex getBrowseIndex(String name) throws BrowseException @@ -757,8 +775,9 @@ public final class BrowseIndex /** * Get the configured browse index that is defined to use this sort option. * - * @param so - * @throws BrowseException + * @param so sort option + * @return browse index + * @throws BrowseException if browse error */ public static BrowseIndex getBrowseIndex(SortOption so) throws BrowseException { @@ -775,6 +794,7 @@ public final class BrowseIndex /** * Get the internally defined browse index for archived items. + * @return browse index */ public static BrowseIndex getItemBrowseIndex() { @@ -783,13 +803,16 @@ public final class BrowseIndex /** * Get the internally defined browse index for withdrawn items. + * @return browse index */ public static BrowseIndex getWithdrawnBrowseIndex() { return BrowseIndex.withdrawnIndex; } - + /** + * @return browse index + */ public static BrowseIndex getPrivateBrowseIndex() { return BrowseIndex.privateIndex; @@ -804,6 +827,7 @@ public final class BrowseIndex * @param mfield the string representation of the metadata * @param init the default value of the array elements * @return a three element array with schema, element and qualifier respectively + * @throws IOException if IO error */ public String[] interpretField(String mfield, String init) throws IOException @@ -829,6 +853,7 @@ public final class BrowseIndex /** * Does this browse index represent one of the internal item indexes? + * @return true or false */ public boolean isInternalIndex() { @@ -837,13 +862,18 @@ public final class BrowseIndex /** * Generate a base table name. - * @param number + * @param number index number + * @return table name */ private static String makeTableBaseName(int number) { return "bi_" + Integer.toString(number); } + /** + * Is tag cloud enabled + * @return true or false + */ public boolean isTagCloudEnabled() { return ConfigurationManager.getBooleanProperty("webui.browse.index.tagcloud." + number); diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowseInfo.java b/dspace-api/src/main/java/org/dspace/browse/BrowseInfo.java index 719d1667ce..4d5f32948c 100644 --- a/dspace-api/src/main/java/org/dspace/browse/BrowseInfo.java +++ b/dspace-api/src/main/java/org/dspace/browse/BrowseInfo.java @@ -256,7 +256,7 @@ public class BrowseInfo * exception * * @param dso the container object; a Community or Collection - * @throws BrowseException + * @throws BrowseException if browse error */ public void setBrowseContainer(DSpaceObject dso) throws BrowseException @@ -575,6 +575,7 @@ public class BrowseInfo /** * True if this browse was cached. + * @return true/false */ public boolean wasCached() { @@ -684,6 +685,7 @@ public class BrowseInfo /** * Utility method for obtaining a string representation of the browse. This is * useful only for debug + * @return String representation */ public String toString() { @@ -836,7 +838,7 @@ public class BrowseInfo * * @param config * @return - * @throws SQLException + * @throws SQLException if database error */ private String fullListingString(ItemListConfig config) throws SQLException diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowseOutput.java b/dspace-api/src/main/java/org/dspace/browse/BrowseOutput.java index 4120fb5d2c..4a1bebd525 100644 --- a/dspace-api/src/main/java/org/dspace/browse/BrowseOutput.java +++ b/dspace-api/src/main/java/org/dspace/browse/BrowseOutput.java @@ -160,8 +160,8 @@ public class BrowseOutput * Pass in some SQL. If print is set to true this will output to the * screen. If file is set to true, this will write to the file specified. * - * @param sql - * @throws BrowseException + * @param sql SQL string + * @throws BrowseException if browse error */ public void sql(String sql) throws BrowseException { diff --git a/dspace-api/src/main/java/org/dspace/browse/BrowserScope.java b/dspace-api/src/main/java/org/dspace/browse/BrowserScope.java index 0ef1a8c486..3f7606cfde 100644 --- a/dspace-api/src/main/java/org/dspace/browse/BrowserScope.java +++ b/dspace-api/src/main/java/org/dspace/browse/BrowserScope.java @@ -96,7 +96,7 @@ public class BrowserScope * exception * * @param dso the container object; a Community or Collection - * @throws BrowseException + * @throws BrowseException if browse error */ public void setBrowseContainer(DSpaceObject dso) throws BrowseException @@ -184,6 +184,7 @@ public class BrowserScope /** * @param browseIndex The browseIndex to set. + * @throws BrowseException if error */ public void setBrowseIndex(BrowseIndex browseIndex) throws BrowseException @@ -370,6 +371,7 @@ public class BrowserScope /** * @param sortBy The sortBy to set. + * @throws BrowseException if error */ public void setSortBy(int sortBy) throws BrowseException @@ -397,7 +399,7 @@ public class BrowserScope * Obtain the sort option * * @return the sort option - * @throws BrowseException + * @throws BrowseException if browse error */ public SortOption getSortOption() throws BrowseException diff --git a/dspace-api/src/main/java/org/dspace/browse/CrossLinks.java b/dspace-api/src/main/java/org/dspace/browse/CrossLinks.java index 369b764464..1694d0324c 100644 --- a/dspace-api/src/main/java/org/dspace/browse/CrossLinks.java +++ b/dspace-api/src/main/java/org/dspace/browse/CrossLinks.java @@ -28,7 +28,7 @@ public class CrossLinks /** * Construct a new object which will obtain the configuration for itself. * - * @throws BrowseException + * @throws BrowseException if browse error */ public CrossLinks() throws BrowseException @@ -57,6 +57,7 @@ public class CrossLinks * Is there a link for the given canonical form of metadata (i.e. schema.element.qualifier)? * * @param metadata the metadata to check for a link on + * @return true/false */ public boolean hasLink(String metadata) { @@ -67,6 +68,7 @@ public class CrossLinks * Get the type of link that the bit of metadata has. * * @param metadata the metadata to get the link type for + * @return type */ public String getLinkType(String metadata) { diff --git a/dspace-api/src/main/java/org/dspace/browse/ItemCountDAO.java b/dspace-api/src/main/java/org/dspace/browse/ItemCountDAO.java index c3c1ec5990..ef3b329540 100644 --- a/dspace-api/src/main/java/org/dspace/browse/ItemCountDAO.java +++ b/dspace-api/src/main/java/org/dspace/browse/ItemCountDAO.java @@ -22,8 +22,8 @@ public interface ItemCountDAO /** * Set the DSpace Context to use during data access * - * @param context - * @throws ItemCountException + * @param context DSpace Context + * @throws ItemCountException if count error */ public void setContext(Context context) throws ItemCountException; @@ -32,8 +32,9 @@ public interface ItemCountDAO * only succeed if the DSpaceObject is an instance of either a Community or a * Collection. Otherwise it will throw an exception. * - * @param dso - * @throws ItemCountException + * @param dso Dspace Object + * @return count + * @throws ItemCountException if count error */ public int getCount(DSpaceObject dso) throws ItemCountException; } diff --git a/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOFactory.java b/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOFactory.java index 20131bbd39..5da1649802 100644 --- a/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOFactory.java +++ b/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOFactory.java @@ -24,8 +24,9 @@ public class ItemCountDAOFactory * Get an instance of ItemCountDAO which supports the correct storage backend * for the specific DSpace instance. * - * @param context - * @throws ItemCountException + * @param context DSpace Context + * @return DAO + * @throws ItemCountException if count error */ public static ItemCountDAO getInstance(Context context) throws ItemCountException diff --git a/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOSolr.java b/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOSolr.java index ef3ec38d62..e71e7e779a 100644 --- a/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOSolr.java +++ b/dspace-api/src/main/java/org/dspace/browse/ItemCountDAOSolr.java @@ -59,8 +59,8 @@ public class ItemCountDAOSolr implements ItemCountDAO /** * Set the dspace context to use * - * @param context - * @throws ItemCountException + * @param context DSpace Context + * @throws ItemCountException if count error */ @Override public void setContext(Context context) throws ItemCountException @@ -71,8 +71,9 @@ public class ItemCountDAOSolr implements ItemCountDAO /** * Get the count of the items in the given container. * - * @param dso - * @throws ItemCountException + * @param dso Dspace Context + * @return count + * @throws ItemCountException if count error */ @Override public int getCount(DSpaceObject dso) throws ItemCountException @@ -106,7 +107,7 @@ public class ItemCountDAOSolr implements ItemCountDAO * make sure that the counts are actually fetched from Solr (if haven't been * cached in a Map yet) * - * @throws ItemCountException + * @throws ItemCountException if count error */ private void loadCount() throws ItemCountException { diff --git a/dspace-api/src/main/java/org/dspace/browse/ItemCounter.java b/dspace-api/src/main/java/org/dspace/browse/ItemCounter.java index c80395f27d..e40a814e41 100644 --- a/dspace-api/src/main/java/org/dspace/browse/ItemCounter.java +++ b/dspace-api/src/main/java/org/dspace/browse/ItemCounter.java @@ -51,8 +51,8 @@ public class ItemCounter /** * Construct a new item counter which will use the give DSpace Context * - * @param context - * @throws ItemCountException + * @param context current context + * @throws ItemCountException if count error */ public ItemCounter(Context context) throws ItemCountException @@ -70,9 +70,9 @@ public class ItemCounter * cached value if it exists. If it is equal to 'false' it will count * the number of items in the container in real time. * - * @param dso - * @throws ItemCountException - * @throws SQLException + * @param dso DSpaceObject + * @return count + * @throws ItemCountException when error occurs */ public int getCount(DSpaceObject dso) throws ItemCountException diff --git a/dspace-api/src/main/java/org/dspace/browse/ItemListConfig.java b/dspace-api/src/main/java/org/dspace/browse/ItemListConfig.java index b7c0a64b00..7ad053f203 100644 --- a/dspace-api/src/main/java/org/dspace/browse/ItemListConfig.java +++ b/dspace-api/src/main/java/org/dspace/browse/ItemListConfig.java @@ -38,7 +38,7 @@ public class ItemListConfig * Create a new instance of the Item list configuration. This loads * all the required information from configuration * - * @throws BrowseException + * @throws BrowseException if count error */ public ItemListConfig() throws BrowseException @@ -97,7 +97,8 @@ public class ItemListConfig /** * What metadata is to go in the given column number? * - * @param col + * @param col column + * @return array of metadata */ public String[] getMetadata(int col) { @@ -113,6 +114,7 @@ public class ItemListConfig * @param mfield the string representation of the metadata * @param init the default value of the array elements * @return a three element array with schema, element and qualifier respectively + * @throws IOException if IO error */ public final String[] interpretField(String mfield, String init) throws IOException diff --git a/dspace-api/src/main/java/org/dspace/browse/LocaleOrderingFilter.java b/dspace-api/src/main/java/org/dspace/browse/LocaleOrderingFilter.java index 0f8788f4de..8024f3071b 100644 --- a/dspace-api/src/main/java/org/dspace/browse/LocaleOrderingFilter.java +++ b/dspace-api/src/main/java/org/dspace/browse/LocaleOrderingFilter.java @@ -72,6 +72,9 @@ public class LocaleOrderingFilter implements TextFilter /** * We don't need to use the language parameter, so map this to * the standard sort string filter + * @param str string + * @param lang language + * @return string */ @Override public String filter(String str, String lang) diff --git a/dspace-api/src/main/java/org/dspace/checker/BitstreamDispatcher.java b/dspace-api/src/main/java/org/dspace/checker/BitstreamDispatcher.java index 77dd31a02e..721ce04bfb 100644 --- a/dspace-api/src/main/java/org/dspace/checker/BitstreamDispatcher.java +++ b/dspace-api/src/main/java/org/dspace/checker/BitstreamDispatcher.java @@ -50,6 +50,7 @@ public interface BitstreamDispatcher * * @return the next bitstream id, or BitstreamDispatcher.SENTINEL if there * isn't another value + * @throws SQLException if database error * */ public Bitstream next() throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/checker/CheckerCommand.java b/dspace-api/src/main/java/org/dspace/checker/CheckerCommand.java index 417d5ebc0d..3309acab61 100644 --- a/dspace-api/src/main/java/org/dspace/checker/CheckerCommand.java +++ b/dspace-api/src/main/java/org/dspace/checker/CheckerCommand.java @@ -35,8 +35,8 @@ import org.dspace.storage.bitstore.service.BitstreamStorageService; * @author Nathan Sarr * * - * @todo the accessor methods are currently unused - are they useful? - * @todo check for any existing resource problems + * TODO the accessor methods are currently unused - are they useful? + * TODO check for any existing resource problems */ public final class CheckerCommand { @@ -73,6 +73,7 @@ public final class CheckerCommand /** * Default constructor uses DSpace plugin manager to construct dependencies. + * @param context Context */ public CheckerCommand(Context context) { @@ -94,6 +95,7 @@ public final class CheckerCommand * N.B. a valid BitstreamDispatcher must be provided using * setBitstreamDispatcher before calling this method *

+ * @throws SQLException if database error */ public void process() throws SQLException { LOG.debug("Begin Checker Processing"); @@ -136,6 +138,7 @@ public final class CheckerCommand * the bitstream * * @return the information about the bitstream and its checksum data + * @throws SQLException if database error */ protected MostRecentChecksum checkBitstream(final Bitstream bitstream) throws SQLException { // get bitstream info from bitstream table @@ -181,6 +184,7 @@ public final class CheckerCommand * the second checksum * * @return a result code (constants defined in Util) + * @throws SQLException if database error */ protected ChecksumResult compareChecksums(String checksumA, String checksumB) throws SQLException { ChecksumResult result = getChecksumResultByCode(ChecksumResultCode.CHECKSUM_NO_MATCH); @@ -205,6 +209,7 @@ public final class CheckerCommand * * @param info * a deleted bitstream. + * @throws SQLException if database error */ protected void processDeletedBitstream(MostRecentChecksum info) throws SQLException { info.setProcessStartDate(new Date()); @@ -222,7 +227,8 @@ public final class CheckerCommand * * @param info * A not found BitStreamInfo - * @todo is this method required? + * TODO is this method required? + * @throws SQLException if database error */ protected void processNullInfoBitstream(MostRecentChecksum info) throws SQLException { info.setInfoFound(false); @@ -241,11 +247,12 @@ public final class CheckerCommand * actual checksumming never took place. *

* - * @todo Why does bitstream have a timestamp indicating it's checked if + * TODO Why does bitstream have a timestamp indicating it's checked if * checksumming doesn't occur? * * @param info * BitstreamInfo to handle + * @throws SQLException if database error */ protected void processBitstream(MostRecentChecksum info) throws SQLException { info.setProcessStartDate(new Date()); diff --git a/dspace-api/src/main/java/org/dspace/checker/CheckerConsumer.java b/dspace-api/src/main/java/org/dspace/checker/CheckerConsumer.java index e7b5acb818..93eb7aa260 100644 --- a/dspace-api/src/main/java/org/dspace/checker/CheckerConsumer.java +++ b/dspace-api/src/main/java/org/dspace/checker/CheckerConsumer.java @@ -33,6 +33,7 @@ public class CheckerConsumer implements Consumer /** * Initialize - allocate any resources required to operate. * Called at the start of ANY sequence of event consume() calls. + * @throws Exception if error */ @Override public void initialize() throws Exception @@ -46,6 +47,7 @@ public class CheckerConsumer implements Consumer * @param ctx the execution context object * * @param event the content event + * @throws Exception if error */ @Override public void consume(Context ctx, Event event) throws Exception @@ -63,6 +65,8 @@ public class CheckerConsumer implements Consumer /** * Signal that there are no more events queued in this * event stream. + * @param ctx Context + * @throws Exception if error */ @Override public void end(Context ctx) throws Exception @@ -73,6 +77,8 @@ public class CheckerConsumer implements Consumer /** * Finish - free any allocated resources. * Called when consumer is being released + * @param ctx Context + * @throws Exception if error */ @Override public void finish(Context ctx) throws Exception diff --git a/dspace-api/src/main/java/org/dspace/checker/ChecksumHistory.java b/dspace-api/src/main/java/org/dspace/checker/ChecksumHistory.java index 5885250c12..10422c26bf 100644 --- a/dspace-api/src/main/java/org/dspace/checker/ChecksumHistory.java +++ b/dspace-api/src/main/java/org/dspace/checker/ChecksumHistory.java @@ -9,10 +9,10 @@ package org.dspace.checker; import org.dspace.core.Context; import org.dspace.content.Bitstream; +import org.dspace.core.ReloadableEntity; import javax.persistence.*; import java.util.Date; -import java.util.UUID; /** *

@@ -26,7 +26,7 @@ import java.util.UUID; */ @Entity @Table(name="checksum_history") -public class ChecksumHistory +public class ChecksumHistory implements ReloadableEntity { @@ -34,7 +34,7 @@ public class ChecksumHistory @Column(name="check_id") @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="checksum_history_check_id_seq") @SequenceGenerator(name="checksum_history_check_id_seq", sequenceName="checksum_history_check_id_seq", allocationSize = 1) - private long id; + private Long id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "bitstream_id") @@ -67,7 +67,7 @@ public class ChecksumHistory { } - public long getId() { + public Long getID() { return id; } @@ -169,6 +169,7 @@ public class ChecksumHistory /** * Return the processing result. + * @return result */ public ChecksumResult getResult() { diff --git a/dspace-api/src/main/java/org/dspace/checker/ChecksumHistoryServiceImpl.java b/dspace-api/src/main/java/org/dspace/checker/ChecksumHistoryServiceImpl.java index fec1a5841b..ec8e602ae7 100644 --- a/dspace-api/src/main/java/org/dspace/checker/ChecksumHistoryServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/checker/ChecksumHistoryServiceImpl.java @@ -88,13 +88,13 @@ public class ChecksumHistoryServiceImpl implements ChecksumHistoryService { /** * Delete the history records from the database. * + * @param context Context * @param retentionDate * any records older than this data are deleted. * @param checksumResultCode * result code records must have for them to be deleted. * @return number of records deleted. - * @throws java.sql.SQLException - * if database error occurs. + * @throws SQLException if database error occurs. */ @Override public int deleteByDateAndCode(Context context, Date retentionDate, ChecksumResultCode checksumResultCode) throws SQLException diff --git a/dspace-api/src/main/java/org/dspace/checker/ChecksumResultServiceImpl.java b/dspace-api/src/main/java/org/dspace/checker/ChecksumResultServiceImpl.java index b671e77a2e..3335ceafd0 100644 --- a/dspace-api/src/main/java/org/dspace/checker/ChecksumResultServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/checker/ChecksumResultServiceImpl.java @@ -35,9 +35,11 @@ public class ChecksumResultServiceImpl implements ChecksumResultService { /** * Get the result description for the given result code * + * @param context Context * @param code * to get the description for. * @return the found description. + * @throws SQLException if database error */ @Override public ChecksumResult findByCode(Context context, ChecksumResultCode code) throws SQLException @@ -48,7 +50,9 @@ public class ChecksumResultServiceImpl implements ChecksumResultService { /** * Get a list of all the possible result codes. * + * @param context Context * @return a list of all the result codes + * @throws SQLException if database error */ @Override public List findAll(Context context) throws SQLException { diff --git a/dspace-api/src/main/java/org/dspace/checker/ChecksumResultsCollector.java b/dspace-api/src/main/java/org/dspace/checker/ChecksumResultsCollector.java index 8821c29da1..615e30b28d 100644 --- a/dspace-api/src/main/java/org/dspace/checker/ChecksumResultsCollector.java +++ b/dspace-api/src/main/java/org/dspace/checker/ChecksumResultsCollector.java @@ -24,8 +24,10 @@ public interface ChecksumResultsCollector /** * Collects results. * + * @param context Context * @param info * BitstreamInfo representing the check results. + * @throws SQLException if database error */ void collect(Context context, MostRecentChecksum info) throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/checker/DailyReportEmailer.java b/dspace-api/src/main/java/org/dspace/checker/DailyReportEmailer.java index 126527ac31..6de0051651 100644 --- a/dspace-api/src/main/java/org/dspace/checker/DailyReportEmailer.java +++ b/dspace-api/src/main/java/org/dspace/checker/DailyReportEmailer.java @@ -61,10 +61,8 @@ public class DailyReportEmailer * @param numberOfBitstreams * the number of bitstreams reported * - * @throws IOException - * if IO exception occurs - * @throws javax.mail.MessagingException - * if message cannot be sent. + * @throws IOException if IO exception occurs + * @throws MessagingException if message cannot be sent. */ public void sendReport(File attachment, int numberOfBitstreams) throws IOException, javax.mail.MessagingException @@ -192,7 +190,7 @@ public class DailyReportEmailer int numBitstreams = 0; // create a temporary file in the log directory - String dirLocation = ConfigurationManager.getProperty("log.dir"); + String dirLocation = ConfigurationManager.getProperty("log.report.dir"); File directory = new File(dirLocation); if (directory.exists() && directory.isDirectory()) diff --git a/dspace-api/src/main/java/org/dspace/checker/HandleDispatcher.java b/dspace-api/src/main/java/org/dspace/checker/HandleDispatcher.java index f1897e1883..84e1f8c631 100644 --- a/dspace-api/src/main/java/org/dspace/checker/HandleDispatcher.java +++ b/dspace-api/src/main/java/org/dspace/checker/HandleDispatcher.java @@ -61,6 +61,7 @@ public class HandleDispatcher implements BitstreamDispatcher /** * Main constructor. * + * @param context Context * @param hdl * the handle to get bitstreams from. */ @@ -73,7 +74,7 @@ public class HandleDispatcher implements BitstreamDispatcher /** * Private initialization routine. * - * @throws SQLException + * @throws SQLException if database error * if database access fails. */ protected synchronized void init() throws SQLException { @@ -110,6 +111,7 @@ public class HandleDispatcher implements BitstreamDispatcher /** * Initializes this dispatcher on first execution. * + * @throws SQLException if database error * @see org.dspace.checker.BitstreamDispatcher#next() */ @Override diff --git a/dspace-api/src/main/java/org/dspace/checker/IteratorDispatcher.java b/dspace-api/src/main/java/org/dspace/checker/IteratorDispatcher.java index a5e6b2a67b..6d12ac922f 100644 --- a/dspace-api/src/main/java/org/dspace/checker/IteratorDispatcher.java +++ b/dspace-api/src/main/java/org/dspace/checker/IteratorDispatcher.java @@ -36,7 +36,7 @@ public class IteratorDispatcher implements BitstreamDispatcher /** * Main constructor. * - * @param bitstreamIds + * @param bitstreams bitstream iterator */ public IteratorDispatcher(Iterator bitstreams) { diff --git a/dspace-api/src/main/java/org/dspace/checker/LimitedCountDispatcher.java b/dspace-api/src/main/java/org/dspace/checker/LimitedCountDispatcher.java index 49e6021be8..9e18570890 100644 --- a/dspace-api/src/main/java/org/dspace/checker/LimitedCountDispatcher.java +++ b/dspace-api/src/main/java/org/dspace/checker/LimitedCountDispatcher.java @@ -67,6 +67,7 @@ public class LimitedCountDispatcher implements BitstreamDispatcher * Retreives the next bitstream to be checked. * * @return the bitstream + * @throws SQLException if database error */ @Override public Bitstream next() throws SQLException { diff --git a/dspace-api/src/main/java/org/dspace/checker/LimitedDurationDispatcher.java b/dspace-api/src/main/java/org/dspace/checker/LimitedDurationDispatcher.java index 763ae5a7d3..21547d280d 100644 --- a/dspace-api/src/main/java/org/dspace/checker/LimitedDurationDispatcher.java +++ b/dspace-api/src/main/java/org/dspace/checker/LimitedDurationDispatcher.java @@ -67,6 +67,7 @@ public class LimitedDurationDispatcher implements BitstreamDispatcher } /** + * @throws SQLException if database error * @see org.dspace.checker.BitstreamDispatcher#next() */ @Override diff --git a/dspace-api/src/main/java/org/dspace/checker/MostRecentChecksumServiceImpl.java b/dspace-api/src/main/java/org/dspace/checker/MostRecentChecksumServiceImpl.java index c5015a110c..efe9298168 100644 --- a/dspace-api/src/main/java/org/dspace/checker/MostRecentChecksumServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/checker/MostRecentChecksumServiceImpl.java @@ -60,11 +60,13 @@ public class MostRecentChecksumServiceImpl implements MostRecentChecksumService * Find all bitstreams that were set to not be processed for the specified * date range. * + * @param context Context * @param startDate * the start of the date range * @param endDate * the end of the date range * @return a list of BitstreamHistoryInfo objects + * @throws SQLException if database error */ @Override public List findNotProcessedBitstreamsReport(Context context, Date startDate, Date endDate) throws SQLException @@ -76,6 +78,7 @@ public class MostRecentChecksumServiceImpl implements MostRecentChecksumService * Select the most recent bitstream for a given date range with the * specified status. * + * @param context Context * @param startDate * the start date range * @param endDate @@ -84,6 +87,7 @@ public class MostRecentChecksumServiceImpl implements MostRecentChecksumService * the result code * * @return a list of BitstreamHistoryInfo objects + * @throws SQLException if database error */ @Override public List findBitstreamResultTypeReport(Context context, Date startDate, Date endDate, ChecksumResultCode resultCode) throws SQLException { @@ -94,6 +98,8 @@ public class MostRecentChecksumServiceImpl implements MostRecentChecksumService * Queries the bitstream table for bitstream IDs that are not yet in the * most_recent_checksum table, and inserts them into the * most_recent_checksum and checksum_history tables. + * @param context Context + * @throws SQLException if database error */ @Override public void updateMissingBitstreams(Context context) throws SQLException { @@ -161,7 +167,9 @@ public class MostRecentChecksumServiceImpl implements MostRecentChecksumService * Get the oldest most recent checksum record. If more than * one found the first one in the result set is returned. * + * @param context COntext * @return the oldest MostRecentChecksum or NULL if the table is empty + * @throws SQLException if database error * */ @Override @@ -174,8 +182,10 @@ public class MostRecentChecksumServiceImpl implements MostRecentChecksumService * Returns the oldest bitstream that in the set of bitstreams that are less * than the specified date. If no bitstreams are found -1 is returned. * - * @param lessThanDate + * @param context context + * @param lessThanDate date * @return id of olded bitstream or -1 if not bitstreams are found + * @throws SQLException if database error */ @Override public MostRecentChecksum findOldestRecord(Context context, Date lessThanDate) throws SQLException diff --git a/dspace-api/src/main/java/org/dspace/checker/ResultsLogger.java b/dspace-api/src/main/java/org/dspace/checker/ResultsLogger.java index 78a4b14374..8ae5364efe 100644 --- a/dspace-api/src/main/java/org/dspace/checker/ResultsLogger.java +++ b/dspace-api/src/main/java/org/dspace/checker/ResultsLogger.java @@ -83,9 +83,11 @@ public class ResultsLogger implements ChecksumResultsCollector /** * Collect a result for logging. * + * @param context Context * @param info * the BitstreamInfo representing the result. - * @see org.dspace.checker.ChecksumResultsCollector#collect(org.dspace.checker.MostRecentChecksum) + * @throws SQLException if database error + * @see org.dspace.checker.ChecksumResultsCollector#collect(org.dspace.core.Context, org.dspace.checker.MostRecentChecksum) */ @Override public void collect(Context context, MostRecentChecksum info) throws SQLException { diff --git a/dspace-api/src/main/java/org/dspace/checker/ResultsPruner.java b/dspace-api/src/main/java/org/dspace/checker/ResultsPruner.java index 92c216cdca..292728a668 100644 --- a/dspace-api/src/main/java/org/dspace/checker/ResultsPruner.java +++ b/dspace-api/src/main/java/org/dspace/checker/ResultsPruner.java @@ -49,6 +49,7 @@ public final class ResultsPruner * Factory method for the default results pruner configuration using * dspace.cfg * + * @param context Context * @return a ResultsPruner that represent the default retention policy */ public static ResultsPruner getDefaultPruner(Context context) @@ -69,10 +70,11 @@ public final class ResultsPruner /** * Factory method for ResultsPruners * + * @param context Context * @param propsFile * to configure the results pruner. * @return the configured results pruner. - * @throws FileNotFoundException + * @throws FileNotFoundException if file doesn't exist * it the configuration file cannot be found. */ public static ResultsPruner getPruner(Context context, String propsFile) @@ -112,8 +114,10 @@ public final class ResultsPruner * Factory method for ResultsPruners (used to load ConfigurationManager * properties. * - * @param props - * @throws FileNotFoundException + * @param context Context + * @param props Properties + * @return pruner + * @throws FileNotFoundException if file doesn't exist */ public static ResultsPruner getPruner(Context context, Properties props) throws FileNotFoundException @@ -177,6 +181,7 @@ public final class ResultsPruner /** * Default Constructor + * @param context Context */ public ResultsPruner(Context context) { @@ -211,8 +216,7 @@ public final class ResultsPruner * before bitstreams with the specified result type in the * checksum history is removed. * - * @throws ParseException - * if the duration cannot be parsed into a long value. + * @throws ParseException if the duration cannot be parsed into a long value. */ public void addInterested(ChecksumResultCode result, String duration) throws ParseException @@ -235,6 +239,7 @@ public final class ResultsPruner * registered with this object. * * @return number of results removed. + * @throws SQLException if database error */ public int prune() throws SQLException { ChecksumResultCode[] codes = ChecksumResultCode.values(); diff --git a/dspace-api/src/main/java/org/dspace/checker/SimpleDispatcher.java b/dspace-api/src/main/java/org/dspace/checker/SimpleDispatcher.java index ab8b7c0aec..9b3ea00a22 100644 --- a/dspace-api/src/main/java/org/dspace/checker/SimpleDispatcher.java +++ b/dspace-api/src/main/java/org/dspace/checker/SimpleDispatcher.java @@ -47,6 +47,7 @@ public class SimpleDispatcher implements BitstreamDispatcher /** * Creates a new SimpleDispatcher. * + * @param context Context * @param startTime * timestamp for beginning of checker process * @param looping @@ -71,6 +72,7 @@ public class SimpleDispatcher implements BitstreamDispatcher /** * Selects the next candidate bitstream. * + * @throws SQLException if database error * @see org.dspace.checker.BitstreamDispatcher#next() */ @Override diff --git a/dspace-api/src/main/java/org/dspace/checker/SimpleReporterServiceImpl.java b/dspace-api/src/main/java/org/dspace/checker/SimpleReporterServiceImpl.java index f11fa28a5f..daeba9c0f1 100644 --- a/dspace-api/src/main/java/org/dspace/checker/SimpleReporterServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/checker/SimpleReporterServiceImpl.java @@ -30,7 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired; * @author Grace Carpenter * @author Nathan Sarr * - * @todo estimate string buffer sizes. + * TODO estimate string buffer sizes. */ public class SimpleReporterServiceImpl implements SimpleReporterService { @@ -55,6 +55,7 @@ public class SimpleReporterServiceImpl implements SimpleReporterService * Sends the Deleted bitstream report to an administrator. for the * specified date range. * + * @param context context * @param startDate * the start date for the range * @param endDate @@ -64,8 +65,9 @@ public class SimpleReporterServiceImpl implements SimpleReporterService * * @return number of bitstreams found * - * @throws IOException + * @throws IOException if IO error * if io error occurs + * @throws SQLException if database error */ @Override public int getDeletedBitstreamReport(Context context, Date startDate, Date endDate, @@ -100,6 +102,7 @@ public class SimpleReporterServiceImpl implements SimpleReporterService /** * Send the checksum changed report for the specified date range. * + * @param context context * @param startDate * the start date for the range * @param endDate @@ -109,8 +112,9 @@ public class SimpleReporterServiceImpl implements SimpleReporterService * * @return number of bitstreams found * - * @throws IOException + * @throws IOException if IO error * if io error occurs + * @throws SQLException if database error */ @Override public int getChangedChecksumReport(Context context, Date startDate, Date endDate, @@ -147,6 +151,7 @@ public class SimpleReporterServiceImpl implements SimpleReporterService /** * Send the bitstream not found report for the specified date range. * + * @param context context * @param startDate * the start date for the range. * @param endDate @@ -156,8 +161,9 @@ public class SimpleReporterServiceImpl implements SimpleReporterService * * @return number of bitstreams found * - * @throws IOException + * @throws IOException if IO error * if io error occurs + * @throws SQLException if database error */ @Override public int getBitstreamNotFoundReport(Context context, Date startDate, Date endDate, @@ -193,6 +199,7 @@ public class SimpleReporterServiceImpl implements SimpleReporterService * Send the bitstreams that were set to not be processed report for the * specified date range. * + * @param context context * @param startDate * the start date for the range * @param endDate @@ -202,8 +209,9 @@ public class SimpleReporterServiceImpl implements SimpleReporterService * * @return number of bitstreams found * - * @throws IOException + * @throws IOException if IO error * if io error occurs + * @throws SQLException if database error */ @Override public int getNotToBeProcessedReport(Context context, Date startDate, Date endDate, @@ -239,13 +247,15 @@ public class SimpleReporterServiceImpl implements SimpleReporterService /** * Get any bitstreams that are not checked by the checksum checker. * + * @param context context * @param osw * the OutputStreamWriter to write to * * @return the number of unchecked bitstreams * - * @throws IOException + * @throws IOException if IO error * if io error occurs + * @throws SQLException if database error */ @Override public int getUncheckedBitstreamsReport(Context context, OutputStreamWriter osw) @@ -282,7 +292,7 @@ public class SimpleReporterServiceImpl implements SimpleReporterService * @param osw * the output stream writer to write to. * - * @throws IOException + * @throws IOException if IO error * if io error occurs */ protected void printHistoryRecords(List mostRecentChecksums, OutputStreamWriter osw) @@ -313,13 +323,15 @@ public class SimpleReporterServiceImpl implements SimpleReporterService /** * Create a list of the found history records. * + * @param context context * @param bitstreams * the list of history records to be iterated over. * @param osw * the output stream to write to. * - * @throws IOException + * @throws IOException if IO error * if io error occurs + * @throws SQLException if database error */ protected void printDSpaceInfoRecords(Context context, List bitstreams, OutputStreamWriter osw) throws IOException, SQLException { diff --git a/dspace-api/src/main/java/org/dspace/checker/dao/ChecksumHistoryDAO.java b/dspace-api/src/main/java/org/dspace/checker/dao/ChecksumHistoryDAO.java index b513cd45ca..0aea30166e 100644 --- a/dspace-api/src/main/java/org/dspace/checker/dao/ChecksumHistoryDAO.java +++ b/dspace-api/src/main/java/org/dspace/checker/dao/ChecksumHistoryDAO.java @@ -19,7 +19,7 @@ import java.util.Date; /** * Database Access Object interface class for the ChecksumHistory object. * The implementation of this class is responsible for all database calls for the ChecksumHistory object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ @@ -33,7 +33,7 @@ public interface ChecksumHistoryDAO extends GenericDAO { * @param retentionDate row must be older than this to be deleted. * @param checksumResultCode row must have this result to be deleted. * @return number of rows deleted. - * @throws SQLException + * @throws SQLException if database error */ public int deleteByDateAndCode(Context context, Date retentionDate, ChecksumResultCode checksumResultCode) throws SQLException; @@ -42,7 +42,7 @@ public interface ChecksumHistoryDAO extends GenericDAO { * * @param context * @param bitstream - * @throws SQLException + * @throws SQLException if database error */ public void deleteByBitstream(Context context, Bitstream bitstream) throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/checker/dao/ChecksumResultDAO.java b/dspace-api/src/main/java/org/dspace/checker/dao/ChecksumResultDAO.java index 0cb5795ec8..6f688ec10b 100644 --- a/dspace-api/src/main/java/org/dspace/checker/dao/ChecksumResultDAO.java +++ b/dspace-api/src/main/java/org/dspace/checker/dao/ChecksumResultDAO.java @@ -17,7 +17,7 @@ import java.sql.SQLException; /** * Database Access Object interface class for the ChecksumResult object. * The implementation of this class is responsible for all database calls for the ChecksumResult object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/checker/dao/MostRecentChecksumDAO.java b/dspace-api/src/main/java/org/dspace/checker/dao/MostRecentChecksumDAO.java index bcd78a745c..578abce624 100644 --- a/dspace-api/src/main/java/org/dspace/checker/dao/MostRecentChecksumDAO.java +++ b/dspace-api/src/main/java/org/dspace/checker/dao/MostRecentChecksumDAO.java @@ -20,7 +20,7 @@ import java.util.List; /** * Database Access Object interface class for the MostRecentChecksum object. * The implementation of this class is responsible for all database calls for the MostRecentChecksum object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/checker/service/ChecksumHistoryService.java b/dspace-api/src/main/java/org/dspace/checker/service/ChecksumHistoryService.java index fabfbc884c..578214ac1d 100644 --- a/dspace-api/src/main/java/org/dspace/checker/service/ChecksumHistoryService.java +++ b/dspace-api/src/main/java/org/dspace/checker/service/ChecksumHistoryService.java @@ -35,11 +35,13 @@ public interface ChecksumHistoryService { /** * Prune the history records from the database. * + * @param context context * @param interests * set of results and the duration of time before they are * removed from the database * * @return number of bitstreams deleted + * @throws SQLException if database error */ public int prune(Context context, Map interests) throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/checker/service/SimpleReporterService.java b/dspace-api/src/main/java/org/dspace/checker/service/SimpleReporterService.java index 6f1fb1ab50..b4b159890e 100644 --- a/dspace-api/src/main/java/org/dspace/checker/service/SimpleReporterService.java +++ b/dspace-api/src/main/java/org/dspace/checker/service/SimpleReporterService.java @@ -29,6 +29,7 @@ public interface SimpleReporterService * Returns the bitstreams set found to be deleted for the specified date * range. * + * @param context context * @param startDate * the start date range * @param endDate @@ -38,8 +39,9 @@ public interface SimpleReporterService * * @return number of bitstreams found * - * @throws IOException + * @throws IOException if IO error * if io error occurs + * @throws SQLException if database error */ public int getDeletedBitstreamReport(Context context, Date startDate, Date endDate, OutputStreamWriter osw) throws IOException, SQLException; @@ -48,6 +50,7 @@ public interface SimpleReporterService * The a report of bitstreams found where the checksum has been changed * since the last check for the specified date range. * + * @param context context * @param startDate * the start date range. * @param endDate @@ -57,8 +60,9 @@ public interface SimpleReporterService * * @return number of bitstreams found * - * @throws IOException + * @throws IOException if IO error * if io error occurs + * @throws SQLException if database error */ public int getChangedChecksumReport(Context context, Date startDate, Date endDate, OutputStreamWriter osw) throws IOException, SQLException; @@ -67,6 +71,7 @@ public interface SimpleReporterService * The report of bitstreams for the specified date range where it was * determined the bitstreams can no longer be found. * + * @param context context * @param startDate * the start date range. * @param endDate @@ -76,8 +81,9 @@ public interface SimpleReporterService * * @return number of bitstreams found * - * @throws IOException + * @throws IOException if IO error * if io error occurs + * @throws SQLException if database error */ public int getBitstreamNotFoundReport(Context context, Date startDate, Date endDate, OutputStreamWriter osw) throws IOException, SQLException; @@ -86,15 +92,18 @@ public interface SimpleReporterService * The bitstreams that were set to not be processed report for the specified * date range. * + * @param context context * @param startDate * the start date range. * @param endDate * the end date range. * @param osw * the output stream writer to write to + * @return number of bitstreams found * - * @throws IOException + * @throws IOException if IO error * if io error occurs + * @throws SQLException if database error * */ public int getNotToBeProcessedReport(Context context, Date startDate, Date endDate, @@ -104,13 +113,15 @@ public interface SimpleReporterService * The bitstreams that are not known to the checksum checker. This means * they are in the bitstream table but not in the most recent checksum table * + * @param context context * @param osw * the output stream writer to write to * * @return number of bitstreams found * - * @throws IOException + * @throws IOException if IO error * if io error occurs + * @throws SQLException if database error * */ public int getUncheckedBitstreamsReport(Context context, OutputStreamWriter osw) diff --git a/dspace-api/src/main/java/org/dspace/content/Bitstream.java b/dspace-api/src/main/java/org/dspace/content/Bitstream.java index 56ea77ea4d..8632cd23c3 100644 --- a/dspace-api/src/main/java/org/dspace/content/Bitstream.java +++ b/dspace-api/src/main/java/org/dspace/content/Bitstream.java @@ -127,8 +127,10 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport /** * Set the name of the bitstream * + * @param context context * @param n * the new name of the bitstream + * @throws SQLException if database error */ public void setName(Context context, String n) throws SQLException { getBitstreamService().setMetadataSingleValue(context, this, MetadataSchema.DC_SCHEMA, "title", null, null, n); @@ -149,8 +151,10 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport /** * Set the source of the bitstream * + * @param context context * @param n * the new source of the bitstream + * @throws SQLException if database error */ public void setSource(Context context, String n) throws SQLException { getBitstreamService().setMetadataSingleValue(context, this, MetadataSchema.DC_SCHEMA, "source", null, null, n); @@ -170,8 +174,10 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport /** * Set the description of the bitstream * + * @param context context * @param n * the new description of the bitstream + * @throws SQLException if database error */ public void setDescription(Context context, String n) throws SQLException { getBitstreamService().setMetadataSingleValue(context, this, MetadataSchema.DC_SCHEMA, "description", null, null, n); @@ -238,7 +244,9 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport /** * Get the format of the bitstream * + * @param context context * @return the format of this bitstream + * @throws SQLException if database error */ public BitstreamFormat getFormat(Context context) throws SQLException { @@ -255,6 +263,7 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport * This method allows us to verify is the bitstream is still valid * * @return true if the bitstream has been deleted + * @throws SQLException if database error */ public boolean isDeleted() throws SQLException { @@ -269,7 +278,7 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport * Get the bundles this bitstream appears in * * @return array of Bundle s this bitstream appears in - * @throws SQLException + * @throws SQLException if database error */ public List getBundles() throws SQLException { @@ -312,7 +321,7 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport /** * Set the asset store number where this bitstream is stored * - * @return the asset store number of the bitstream + * @param storeNumber asset store number of the bitstream */ public void setStoreNumber(int storeNumber) { this.storeNumber = storeNumber; @@ -335,9 +344,10 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport * Set the user's format description. This implies that the format of the * bitstream is uncertain, and the format is set to "unknown." * + * @param context * @param desc * the user's description of the format - * @throws SQLException + * @throws SQLException if database error */ public void setUserFormatDescription(Context context, String desc) throws SQLException { @@ -348,7 +358,9 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport * Get the description of the format - either the user's or the description * of the format defined by the system. * + * @param context context * @return a description of the format. + * @throws SQLException if database error */ public String getFormatDescription(Context context) throws SQLException { @@ -360,10 +372,11 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport * description, it is cleared. Passing in null sets the type * of this bitstream to "unknown". * + * @param context context * @param f * the format of this bitstream, or null for * unknown - * @throws SQLException + * @throws SQLException if database error */ public void setFormat(Context context, BitstreamFormat f) throws SQLException { diff --git a/dspace-api/src/main/java/org/dspace/content/BitstreamFormat.java b/dspace-api/src/main/java/org/dspace/content/BitstreamFormat.java index 4561b037ca..7ed93abeaa 100644 --- a/dspace-api/src/main/java/org/dspace/content/BitstreamFormat.java +++ b/dspace-api/src/main/java/org/dspace/content/BitstreamFormat.java @@ -9,17 +9,22 @@ package org.dspace.content; import java.io.Serializable; import java.sql.SQLException; +import java.util.LinkedList; import java.util.List; import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.service.BitstreamFormatService; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.hibernate.annotations.Cascade; import org.hibernate.annotations.CollectionId; import org.hibernate.annotations.Type; import org.hibernate.proxy.HibernateProxyHelper; import javax.persistence.*; +import java.io.Serializable; +import java.sql.SQLException; +import java.util.List; /** * Class representing a particular bitstream format. @@ -32,14 +37,14 @@ import javax.persistence.*; */ @Entity @Table(name="bitstreamformatregistry") -public class BitstreamFormat implements Serializable +public class BitstreamFormat implements Serializable, ReloadableEntity { @Id @Column(name="bitstream_format_id", nullable = false, unique = true) @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="bitstreamformatregistry_seq") @SequenceGenerator(name="bitstreamformatregistry_seq", sequenceName="bitstreamformatregistry_seq", allocationSize = 1, initialValue = 1) - private int id; + private Integer id; @Column(name="short_description", length = 128, unique = true) private String shortDescription; @@ -102,7 +107,7 @@ public class BitstreamFormat implements Serializable */ protected BitstreamFormat() { - + fileExtensions = new LinkedList<>(); } /** @@ -110,7 +115,7 @@ public class BitstreamFormat implements Serializable * * @return the internal identifier */ - public final int getID() + public final Integer getID() { return id; } diff --git a/dspace-api/src/main/java/org/dspace/content/BitstreamFormatServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/BitstreamFormatServiceImpl.java index 1adc5054c4..1c300f7ab2 100644 --- a/dspace-api/src/main/java/org/dspace/content/BitstreamFormatServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/BitstreamFormatServiceImpl.java @@ -18,6 +18,7 @@ import org.dspace.core.LogManager; import org.springframework.beans.factory.annotation.Autowired; import java.sql.SQLException; +import java.util.Collections; import java.util.List; /** @@ -59,7 +60,7 @@ public class BitstreamFormatServiceImpl implements BitstreamFormatService { * ID of the bitstream format * * @return the bitstream format, or null if the ID is invalid. - * @throws SQLException + * @throws SQLException if database error */ @Override public BitstreamFormat find(Context context, int id) @@ -181,17 +182,25 @@ public class BitstreamFormatServiceImpl implements BitstreamFormatService { @Override public void update(Context context, BitstreamFormat bitstreamFormat) throws SQLException, AuthorizeException { - // Check authorisation - only administrators can change formats - if (!authorizeService.isAdmin(context)) - { - throw new AuthorizeException( - "Only administrators can modify bitstream formats"); + update(context, Collections.singletonList(bitstreamFormat)); + } + + @Override + public void update(Context context, List bitstreamFormats) throws SQLException, AuthorizeException { + if(CollectionUtils.isNotEmpty(bitstreamFormats)) { + // Check authorisation - only administrators can change formats + if (!authorizeService.isAdmin(context)) { + throw new AuthorizeException( + "Only administrators can modify bitstream formats"); + } + + for (BitstreamFormat bitstreamFormat : bitstreamFormats) { + log.info(LogManager.getHeader(context, "update_bitstream_format", + "bitstream_format_id=" + bitstreamFormat.getID())); + + bitstreamFormatDAO.save(context, bitstreamFormat); + } } - - log.info(LogManager.getHeader(context, "update_bitstream_format", - "bitstream_format_id=" + bitstreamFormat.getID())); - - bitstreamFormatDAO.save(context, bitstreamFormat); } @Override diff --git a/dspace-api/src/main/java/org/dspace/content/BitstreamServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/BitstreamServiceImpl.java index 5689530579..5dff3287ac 100644 --- a/dspace-api/src/main/java/org/dspace/content/BitstreamServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/BitstreamServiceImpl.java @@ -144,8 +144,9 @@ public class BitstreamServiceImpl extends DSpaceObjectServiceImpl imp * @param assetstore corresponds to an assetstore in dspace.cfg * @param bitstreamPath the path and filename relative to the assetstore * @return the newly registered bitstream - * @throws IOException - * @throws SQLException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public Bitstream register(Context context, @@ -255,7 +256,9 @@ public class BitstreamServiceImpl extends DSpaceObjectServiceImpl imp //Remove all bundles from the bitstream object, clearing the connection in 2 ways bundles.clear(); - deleteMetadata(context, bitstream); + + // Remove policies + authorizeService.removeAllPolicies(context, bitstream); // Remove bitstream itself bitstream.setDeleted(true); diff --git a/dspace-api/src/main/java/org/dspace/content/Bundle.java b/dspace-api/src/main/java/org/dspace/content/Bundle.java index 9bf2111ad4..ef2f7173ce 100644 --- a/dspace-api/src/main/java/org/dspace/content/Bundle.java +++ b/dspace-api/src/main/java/org/dspace/content/Bundle.java @@ -88,9 +88,11 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport /** * Set the name of the bundle * + * @param context context * @param name * string name of the bundle (ORIGINAL, TEXT, THUMBNAIL) are the * values currently used + * @throws SQLException if database error */ public void setName(Context context, String name) throws SQLException { @@ -197,6 +199,7 @@ public class Bundle extends DSpaceObject implements DSpaceObjectLegacySupport /** * return type found in Constants + * @return bundle type */ @Override public int getType() diff --git a/dspace-api/src/main/java/org/dspace/content/BundleServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/BundleServiceImpl.java index 4402c9d6b2..73043d6451 100644 --- a/dspace-api/src/main/java/org/dspace/content/BundleServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/BundleServiceImpl.java @@ -416,8 +416,6 @@ public class BundleServiceImpl extends DSpaceObjectServiceImpl implement // remove our authorization policies authorizeService.removeAllPolicies(context, bundle); - deleteMetadata(context, bundle); - // Remove ourself bundleDAO.delete(context, bundle); } 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 9bc9058bff..43a145842c 100644 --- a/dspace-api/src/main/java/org/dspace/content/Collection.java +++ b/dspace-api/src/main/java/org/dspace/content/Collection.java @@ -228,8 +228,9 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor * Set the license for this collection. Passing in null means * that the site-wide default will be used. * - * @param license - * the license, or null + * @param context context + * @param license the license, or null + * @throws SQLException if database error */ public void setLicense(Context context, String license) throws SQLException { getCollectionService().setMetadata(context, this, "license", license); @@ -242,6 +243,7 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor * for a submission. * * @return the item template, or null + * @throws SQLException if database error */ public Item getTemplateItem() throws SQLException { @@ -257,7 +259,7 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor * Get the communities this collection appears in * * @return array of Community objects - * @throws SQLException + * @throws SQLException if database error */ public List getCommunities() throws SQLException { diff --git a/dspace-api/src/main/java/org/dspace/content/CollectionServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/CollectionServiceImpl.java index 5b46309e4b..28e35b0531 100644 --- a/dspace-api/src/main/java/org/dspace/content/CollectionServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/CollectionServiceImpl.java @@ -23,6 +23,8 @@ import org.dspace.eperson.Group; import org.dspace.eperson.service.GroupService; import org.dspace.eperson.service.SubscribeService; import org.dspace.event.Event; +import org.dspace.harvest.HarvestedCollection; +import org.dspace.harvest.service.HarvestedCollectionService; import org.dspace.workflow.factory.WorkflowServiceFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -63,6 +65,8 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl i protected SubscribeService subscribeService; @Autowired(required = true) protected WorkspaceItemService workspaceItemService; + @Autowired(required=true) + protected HarvestedCollectionService harvestedCollectionService; protected CollectionServiceImpl() @@ -635,6 +639,13 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl i log.info(LogManager.getHeader(context, "delete_collection", "collection_id=" + collection.getID())); + // remove harvested collections. + HarvestedCollection hc = harvestedCollectionService.find(context,collection); + if(hc!=null) + { + harvestedCollectionService.delete(context, hc); + } + context.addEvent(new Event(Event.DELETE, Constants.COLLECTION, collection.getID(), collection.getHandle(), getIdentifiers(context, collection))); @@ -725,8 +736,6 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl i groupService.delete(context, g); } - - deleteMetadata(context, collection); Iterator owningCommunities = collection.getCommunities().iterator(); while (owningCommunities.hasNext()) { diff --git a/dspace-api/src/main/java/org/dspace/content/Community.java b/dspace-api/src/main/java/org/dspace/content/Community.java index e998db44e4..8e0897208e 100644 --- a/dspace-api/src/main/java/org/dspace/content/Community.java +++ b/dspace-api/src/main/java/org/dspace/content/Community.java @@ -224,6 +224,7 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport /** * return type found in Constants + * @return Community type */ @Override public int getType() diff --git a/dspace-api/src/main/java/org/dspace/content/CommunityServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/CommunityServiceImpl.java index d56d91ee89..baefeaab3e 100644 --- a/dspace-api/src/main/java/org/dspace/content/CommunityServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/CommunityServiceImpl.java @@ -328,6 +328,9 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl imp /** * Internal method to process subcommunities recursively + * @param community community + * @param collectionList list of collections + * @throws SQLException if database error */ protected void addCollectionList(Community community, List collectionList) throws SQLException { @@ -489,9 +492,11 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl imp * Internal method to remove the community and all its children from the * database, and perform any pre/post-cleanup * - * @throws SQLException - * @throws AuthorizeException - * @throws IOException + * @param context context + * @param community community + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ protected void rawDelete(Context context, Community community) throws SQLException, AuthorizeException, IOException { @@ -528,9 +533,6 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl imp // Remove any Handle handleService.unbindHandle(context, community); - deleteMetadata(context, community); - - Group g = community.getAdministrators(); // Delete community row diff --git a/dspace-api/src/main/java/org/dspace/content/DCSeriesNumber.java b/dspace-api/src/main/java/org/dspace/content/DCSeriesNumber.java index 93e79b138e..9820687d49 100644 --- a/dspace-api/src/main/java/org/dspace/content/DCSeriesNumber.java +++ b/dspace-api/src/main/java/org/dspace/content/DCSeriesNumber.java @@ -93,6 +93,7 @@ public class DCSeriesNumber /** * Get the series name - guaranteed non-null + * @return name */ public String getSeries() { @@ -101,6 +102,7 @@ public class DCSeriesNumber /** * Get the number - guaranteed non-null + * @return number */ public String getNumber() { diff --git a/dspace-api/src/main/java/org/dspace/content/DSpaceObject.java b/dspace-api/src/main/java/org/dspace/content/DSpaceObject.java index 61013746bc..280e10e274 100644 --- a/dspace-api/src/main/java/org/dspace/content/DSpaceObject.java +++ b/dspace-api/src/main/java/org/dspace/content/DSpaceObject.java @@ -8,7 +8,10 @@ package org.dspace.content; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; import org.dspace.authorize.ResourcePolicy; +import org.dspace.core.ReloadableEntity; import org.dspace.handle.Handle; import org.hibernate.annotations.GenericGenerator; @@ -23,7 +26,7 @@ import javax.persistence.*; @Entity @Inheritance(strategy= InheritanceType.JOINED) @Table(name = "dspaceobject") -public abstract class DSpaceObject implements Serializable +public abstract class DSpaceObject implements Serializable, ReloadableEntity { @Id @GeneratedValue(generator = "system-uuid") @@ -36,18 +39,18 @@ public abstract class DSpaceObject implements Serializable @Transient private StringBuffer eventDetails = null; - @OneToMany(fetch = FetchType.LAZY, mappedBy = "dSpaceObject", cascade={CascadeType.PERSIST}, orphanRemoval = true) + @OneToMany(fetch = FetchType.LAZY, mappedBy = "dSpaceObject", cascade = CascadeType.ALL, orphanRemoval = true) @OrderBy("metadataField, place") private List metadata = new ArrayList<>(); @OneToMany(fetch = FetchType.LAZY, mappedBy = "dso") // Order by is here to ensure that the oldest handle is retrieved first, // multiple handles are assigned to the latest version of an item the original handle will have the lowest identifier - // This handle is the prefered handle. - @OrderBy("handle_id ASC") + // This handle is the preferred handle. + @OrderBy("id ASC") private List handles = new ArrayList<>(); - @OneToMany(fetch = FetchType.LAZY, mappedBy = "dSpaceObject", cascade={CascadeType.PERSIST}, orphanRemoval = false) + @OneToMany(fetch = FetchType.LAZY, mappedBy = "dSpaceObject", cascade = CascadeType.ALL) private List resourcePolicies = new ArrayList<>(); /** @@ -192,4 +195,5 @@ public abstract class DSpaceObject implements Serializable protected void setModified() { this.modified = true; } + } \ No newline at end of file diff --git a/dspace-api/src/main/java/org/dspace/content/DSpaceObjectServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/DSpaceObjectServiceImpl.java index 14c3dd9114..91f1b7a833 100644 --- a/dspace-api/src/main/java/org/dspace/content/DSpaceObjectServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/DSpaceObjectServiceImpl.java @@ -34,6 +34,7 @@ import java.util.*; * are required to have. * * @author kevinvandevelde at atmire.com + * @param class type */ public abstract class DSpaceObjectServiceImpl implements DSpaceObjectService { @@ -204,31 +205,16 @@ public abstract class DSpaceObjectServiceImpl implements @Override public void addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, List values) throws SQLException { - String fieldKey = metadataAuthorityService.makeFieldKey(schema, element, qualifier); - if (metadataAuthorityService.isAuthorityControlled(fieldKey)) - { - List authorities = new ArrayList(); - List confidences = new ArrayList(); - for (int i = 0; i < values.size(); ++i) - { - if(dso instanceof Item) - { - getAuthoritiesAndConfidences(fieldKey, ((Item) dso).getOwningCollection(), values, authorities, confidences, i); - }else{ - getAuthoritiesAndConfidences(fieldKey, null, values, authorities, confidences, i); - } - } - addMetadata(context, dso, schema, element, qualifier, lang, values, authorities, confidences); - } - else - { - addMetadata(context, dso, schema, element, qualifier, lang, values, null, null); + MetadataField metadataField = metadataFieldService.findByElement(context, schema, element, qualifier); + if (metadataField == null) { + throw new SQLException("bad_dublin_core schema=" + schema + "." + element + "." + qualifier); } + + addMetadata(context, dso, metadataField, lang, values); } @Override public void addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, List values, List authorities, List confidences) throws SQLException { - // We will not verify that they are valid entries in the registry // until update() is called. MetadataField metadataField = metadataFieldService.findByElement(context, schema, element, qualifier); @@ -315,8 +301,28 @@ public abstract class DSpaceObjectServiceImpl implements @Override public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value) throws SQLException { - addMetadata(context, dso, metadataField, language, Arrays.asList(value), null, null); + addMetadata(context, dso, metadataField, language, Arrays.asList(value)); + } + @Override + public void addMetadata(Context context, T dso, MetadataField metadataField, String language, List values) throws SQLException { + if(metadataField != null) { + String fieldKey = metadataAuthorityService.makeFieldKey(metadataField.getMetadataSchema().getName(), metadataField.getElement(), metadataField.getQualifier()); + if (metadataAuthorityService.isAuthorityControlled(fieldKey)) { + List authorities = new ArrayList(); + List confidences = new ArrayList(); + for (int i = 0; i < values.size(); ++i) { + if (dso instanceof Item) { + getAuthoritiesAndConfidences(fieldKey, ((Item) dso).getOwningCollection(), values, authorities, confidences, i); + } else { + getAuthoritiesAndConfidences(fieldKey, null, values, authorities, confidences, i); + } + } + addMetadata(context, dso, metadataField, language, values, authorities, confidences); + } else { + addMetadata(context, dso, metadataField, language, values, null, null); + } + } } @Override @@ -357,6 +363,12 @@ public abstract class DSpaceObjectServiceImpl implements /** * Retrieve first metadata field value + * @param dso + * @param language + * @param element + * @param schema + * @param qualifier + * @return */ @Override public String getMetadataFirstValue(T dso, String schema, String element, String qualifier, String language){ @@ -369,6 +381,7 @@ public abstract class DSpaceObjectServiceImpl implements /** * Set first metadata field value + * @throws SQLException if database error */ @Override public void setMetadataSingleValue(Context context, T dso, String schema, String element, String qualifier, String language, String value) throws SQLException { @@ -380,21 +393,6 @@ public abstract class DSpaceObjectServiceImpl implements } } - /** - * Protected method that deletes all metadata values from the database, should only be called when deleting the item. - * @param context the dspaceObject - * @param dso the dspaceObject who's metadata we are to delete - */ - protected void deleteMetadata(Context context, T dso) throws SQLException { - - Iterator metadataValueIterator = dso.getMetadata().iterator(); - while (metadataValueIterator.hasNext()) { - MetadataValue metadataValue = metadataValueIterator.next(); - metadataValueIterator.remove(); - metadataValueService.delete(context, metadataValue); - } - } - /** * Utility method for pattern-matching metadata elements. This * method will return true if the given schema, @@ -487,10 +485,12 @@ public abstract class DSpaceObjectServiceImpl implements /** * Splits "schema.element.qualifier.language" into an array. - *

- * The returned array will always have length >= 4 - *

+ *

+ * The returned array will always have length greater than or equal to 4 + *

* Values in the returned array can be empty or null. + * @param fieldName field name + * @return array */ protected String[] getElements(String fieldName) { String[] tokens = StringUtils.split(fieldName, "."); @@ -505,10 +505,12 @@ public abstract class DSpaceObjectServiceImpl implements /** * Splits "schema.element.qualifier.language" into an array. - *

- * The returned array will always have length >= 4 - *

+ *

+ * The returned array will always have length greater than or equal to 4 + *

* When @param fill is true, elements that would be empty or null are replaced by Item.ANY + * @param fieldName field name + * @return array */ protected String[] getElementsFilled(String fieldName) { String[] elements = getElements(fieldName); diff --git a/dspace-api/src/main/java/org/dspace/content/InProgressSubmission.java b/dspace-api/src/main/java/org/dspace/content/InProgressSubmission.java index 7979034982..7af3b1d108 100644 --- a/dspace-api/src/main/java/org/dspace/content/InProgressSubmission.java +++ b/dspace-api/src/main/java/org/dspace/content/InProgressSubmission.java @@ -7,10 +7,10 @@ */ package org.dspace.content; -import java.sql.SQLException; - import org.dspace.eperson.EPerson; +import java.sql.SQLException; + /** * Interface for manipulating in-progress submissions, without having to know at * which stage of submission they are (in workspace or workflow system) @@ -25,7 +25,7 @@ public interface InProgressSubmission * * @return the internal identifier */ - int getID(); + Integer getID(); /** * Get the incomplete item object @@ -45,6 +45,7 @@ public interface InProgressSubmission * Get the submitter * * @return the submitting e-person + * @throws SQLException if database error */ EPerson getSubmitter() throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/content/Item.java b/dspace-api/src/main/java/org/dspace/content/Item.java index a9046b27bf..3322ac5627 100644 --- a/dspace-api/src/main/java/org/dspace/content/Item.java +++ b/dspace-api/src/main/java/org/dspace/content/Item.java @@ -15,7 +15,6 @@ import org.dspace.eperson.EPerson; import org.hibernate.proxy.HibernateProxyHelper; import javax.persistence.*; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -193,7 +192,6 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport * Get the owning Collection for the item * * @return Collection that is the owner of the item - * @throws SQLException */ public Collection getOwningCollection() { @@ -229,7 +227,6 @@ public class Item extends DSpaceObject implements DSpaceObjectLegacySupport * Get the collections this item is in. The order is indeterminate. * * @return the collections this item is in, if any. - * @throws SQLException */ public List getCollections() { diff --git a/dspace-api/src/main/java/org/dspace/content/ItemComparator.java b/dspace-api/src/main/java/org/dspace/content/ItemComparator.java index 401fd5d8fa..f7d3900445 100644 --- a/dspace-api/src/main/java/org/dspace/content/ItemComparator.java +++ b/dspace-api/src/main/java/org/dspace/content/ItemComparator.java @@ -71,8 +71,8 @@ public class ItemComparator implements Comparator, Serializable * language. * *

- * Return >= 1 if the first is lexicographically greater than the second; <= - * -1 if the second is lexicographically greater than the first, and 0 + * Return greater than or equal to 1 if the first is lexicographically greater than the second; + * less than or equal to -1 if the second is lexicographically greater than the first, and 0 * otherwise. *

* @@ -82,8 +82,8 @@ public class ItemComparator implements Comparator, Serializable * @param second * The second object to compare. Must be an object of type * org.dspace.content.Item. - * @return >= 1 if the first is lexicographically greater than the second; <= - * -1 if the second is lexicographically greater than the first, and + * @return greater than or equal 1 if the first is lexicographically greater than the second; + * less than or equal -1 if the second is lexicographically greater than the first, and * 0 otherwise. */ @Override diff --git a/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java index ac12adb60f..0d19c8bd2b 100644 --- a/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java @@ -25,6 +25,8 @@ import org.dspace.core.LogManager; import org.dspace.eperson.EPerson; import org.dspace.eperson.Group; import org.dspace.event.Event; +import org.dspace.harvest.HarvestedItem; +import org.dspace.harvest.service.HarvestedItemService; import org.dspace.identifier.IdentifierException; import org.dspace.identifier.service.IdentifierService; import org.dspace.versioning.service.VersioningService; @@ -74,6 +76,8 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl implements It protected IdentifierService identifierService; @Autowired(required = true) protected VersioningService versioningService; + @Autowired(required=true) + protected HarvestedItemService harvestedItemService; protected ItemServiceImpl() { @@ -596,14 +600,20 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl implements It log.info(LogManager.getHeader(context, "delete_item", "item_id=" + item.getID())); - deleteMetadata(context, item); - // Remove bundles removeAllBundles(context, item); // remove version attached to the item removeVersion(context, item); + // Also delete the item if it appears in a harvested collection. + HarvestedItem hi = harvestedItemService.find(context, item); + + if(hi!=null) + { + harvestedItemService.delete(context, hi); + } + //Only clear collections after we have removed everything else from the item item.getCollections().clear(); item.setOwningCollection(null); @@ -917,7 +927,9 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl implements It * @param qualifier metadata field qualifier * @param value field value or Item.ANY to match any value * @return an iterator over the items matching that authority value - * @throws SQLException, AuthorizeException, IOException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error * */ @Override diff --git a/dspace-api/src/main/java/org/dspace/content/LicenseUtils.java b/dspace-api/src/main/java/org/dspace/content/LicenseUtils.java index 90f2639f76..9effd3cab9 100644 --- a/dspace-api/src/main/java/org/dspace/content/LicenseUtils.java +++ b/dspace-api/src/main/java/org/dspace/content/LicenseUtils.java @@ -56,7 +56,6 @@ public class LicenseUtils * {x} any addition argument supplied wrapped in the * LicenseArgumentFormatter based on his type (map key) * - * @see license.LicenseArgumentFormatter * @param locale * @param collection * @param item @@ -125,9 +124,9 @@ public class LicenseUtils * the item object of the license * @param licenseText * the license the user granted - * @throws SQLException - * @throws IOException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error */ public static void grantLicense(Context context, Item item, String licenseText) throws SQLException, IOException, diff --git a/dspace-api/src/main/java/org/dspace/content/MetadataField.java b/dspace-api/src/main/java/org/dspace/content/MetadataField.java index 267c1fa2c5..329537f31e 100644 --- a/dspace-api/src/main/java/org/dspace/content/MetadataField.java +++ b/dspace-api/src/main/java/org/dspace/content/MetadataField.java @@ -8,10 +8,14 @@ package org.dspace.content; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; +import org.hibernate.annotations.Cache; +import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.proxy.HibernateProxyHelper; import javax.persistence.*; + /** * DSpace object that represents a metadata field, which is * defined by a combination of schema, element, and qualifier. Every @@ -23,16 +27,18 @@ import javax.persistence.*; * @see org.dspace.content.MetadataSchema */ @Entity +@Cacheable +@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) @Table(name="metadatafieldregistry") -public class MetadataField { +public class MetadataField implements ReloadableEntity { @Id @Column(name="metadata_field_id", nullable = false, unique = true) @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="metadatafieldregistry_seq") @SequenceGenerator(name="metadatafieldregistry_seq", sequenceName="metadatafieldregistry_seq", allocationSize = 1, initialValue = 1) - private int id; + private Integer id; - @ManyToOne(fetch = FetchType.LAZY) + @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "metadata_schema_id",nullable = false) private MetadataSchema metadataSchema; @@ -62,7 +68,7 @@ public class MetadataField { * * @return metadata field id */ - public int getFieldID() + public Integer getID() { return id; } @@ -170,7 +176,7 @@ public class MetadataField { return false; } final MetadataField other = (MetadataField) obj; - if (this.getFieldID() != other.getFieldID()) + if (this.getID() != other.getID()) { return false; } @@ -185,8 +191,8 @@ public class MetadataField { public int hashCode() { int hash = 7; - hash = 47 * hash + getFieldID(); - hash = 47 * hash + getMetadataSchema().getSchemaID(); + hash = 47 * hash + getID(); + hash = 47 * hash + getMetadataSchema().getID(); return hash; } diff --git a/dspace-api/src/main/java/org/dspace/content/MetadataFieldServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/MetadataFieldServiceImpl.java index acf0449317..805a5a8c70 100644 --- a/dspace-api/src/main/java/org/dspace/content/MetadataFieldServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/MetadataFieldServiceImpl.java @@ -58,7 +58,7 @@ public class MetadataFieldServiceImpl implements MetadataFieldService { if (hasElement(context, -1, metadataSchema, element, qualifier)) { throw new NonUniqueMetadataException("Please make " + element + "." - + qualifier + " unique within schema #" + metadataSchema.getSchemaID()); + + qualifier + " unique within schema #" + metadataSchema.getID()); } // Create a table row and update it with the values @@ -71,7 +71,7 @@ public class MetadataFieldServiceImpl implements MetadataFieldService { metadataFieldDAO.save(context, metadataField); log.info(LogManager.getHeader(context, "create_metadata_field", - "metadata_field_id=" + metadataField.getFieldID())); + "metadata_field_id=" + metadataField.getID())); return metadataField; } @@ -118,7 +118,7 @@ public class MetadataFieldServiceImpl implements MetadataFieldService { } // Ensure the element and qualifier are unique within a given schema. - if (hasElement(context, metadataField.getFieldID(), metadataField.getMetadataSchema(), metadataField.getElement(), metadataField.getQualifier())) + if (hasElement(context, metadataField.getID(), metadataField.getMetadataSchema(), metadataField.getElement(), metadataField.getQualifier())) { throw new NonUniqueMetadataException("Please make " + metadataField.getMetadataSchema().getName() + "." + metadataField.getElement() + "." + metadataField.getQualifier()); @@ -127,7 +127,7 @@ public class MetadataFieldServiceImpl implements MetadataFieldService { metadataFieldDAO.save(context, metadataField); log.info(LogManager.getHeader(context, "update_metadatafieldregistry", - "metadata_field_id=" + metadataField.getFieldID() + "element=" + metadataField.getElement() + "metadata_field_id=" + metadataField.getID() + "element=" + metadataField.getElement() + "qualifier=" + metadataField.getQualifier())); } @@ -141,7 +141,7 @@ public class MetadataFieldServiceImpl implements MetadataFieldService { } log.info(LogManager.getHeader(context, "delete_metadata_field", - "metadata_field_id=" + metadataField.getFieldID())); + "metadata_field_id=" + metadataField.getID())); metadataValueService.deleteByMetadataField(context, metadataField); metadataFieldDAO.delete(context, metadataField); @@ -153,11 +153,12 @@ public class MetadataFieldServiceImpl implements MetadataFieldService { * database constraint. * * @param context dspace context + * @param fieldId field id * @param metadataSchema metadataSchema - * @param element - * @param qualifier + * @param element element + * @param qualifier qualifier * @return true if unique - * @throws SQLException + * @throws SQLException if database error */ protected boolean hasElement(Context context, int fieldId, MetadataSchema metadataSchema, String element, String qualifier) throws SQLException { diff --git a/dspace-api/src/main/java/org/dspace/content/MetadataSchema.java b/dspace-api/src/main/java/org/dspace/content/MetadataSchema.java index 4558cd7013..e877261c15 100644 --- a/dspace-api/src/main/java/org/dspace/content/MetadataSchema.java +++ b/dspace-api/src/main/java/org/dspace/content/MetadataSchema.java @@ -8,6 +8,8 @@ package org.dspace.content; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; +import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.proxy.HibernateProxyHelper; import javax.persistence.*; @@ -26,8 +28,10 @@ import javax.persistence.*; * @see org.dspace.content.MetadataField */ @Entity +@Cacheable +@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) @Table(name="metadataschemaregistry") -public class MetadataSchema +public class MetadataSchema implements ReloadableEntity { /** Short Name of built-in Dublin Core schema. */ public static final String DC_SCHEMA = "dc"; @@ -36,7 +40,7 @@ public class MetadataSchema @Column(name="metadata_schema_id") @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="metadataschemaregistry_seq") @SequenceGenerator(name="metadataschemaregistry_seq", sequenceName="metadataschemaregistry_seq", allocationSize = 1) - private int id; + private Integer id; @Column(name = "namespace", unique = true, length = 256) private String namespace; @@ -132,7 +136,7 @@ public class MetadataSchema * * @return schema record key */ - public int getSchemaID() + public Integer getID() { return id; } diff --git a/dspace-api/src/main/java/org/dspace/content/MetadataSchemaServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/MetadataSchemaServiceImpl.java index c56b2dfeb3..601a90a976 100644 --- a/dspace-api/src/main/java/org/dspace/content/MetadataSchemaServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/MetadataSchemaServiceImpl.java @@ -73,7 +73,7 @@ public class MetadataSchemaServiceImpl implements MetadataSchemaService { metadataSchemaDAO.save(context, metadataSchema); log.info(LogManager.getHeader(context, "create_metadata_schema", "metadata_schema_id=" - + metadataSchema.getSchemaID())); + + metadataSchema.getID())); return metadataSchema; } @@ -92,21 +92,21 @@ public class MetadataSchemaServiceImpl implements MetadataSchemaService { } // Ensure the schema name is unique - if (!uniqueShortName(context, metadataSchema.getSchemaID(), metadataSchema.getName())) + if (!uniqueShortName(context, metadataSchema.getID(), metadataSchema.getName())) { throw new NonUniqueMetadataException("Please make the name " + metadataSchema.getName() + " unique"); } // Ensure the schema namespace is unique - if (!uniqueNamespace(context, metadataSchema.getSchemaID(), metadataSchema.getNamespace())) + if (!uniqueNamespace(context, metadataSchema.getID(), metadataSchema.getNamespace())) { throw new NonUniqueMetadataException("Please make the namespace " + metadataSchema.getNamespace() + " unique"); } metadataSchemaDAO.save(context, metadataSchema); log.info(LogManager.getHeader(context, "update_metadata_schema", - "metadata_schema_id=" + metadataSchema.getSchemaID() + "namespace=" + "metadata_schema_id=" + metadataSchema.getID() + "namespace=" + metadataSchema.getNamespace() + "name=" + metadataSchema.getName())); } @@ -120,7 +120,7 @@ public class MetadataSchemaServiceImpl implements MetadataSchemaService { } log.info(LogManager.getHeader(context, "delete_metadata_schema", - "metadata_schema_id=" + metadataSchema.getSchemaID())); + "metadata_schema_id=" + metadataSchema.getID())); metadataSchemaDAO.delete(context, metadataSchema); } @@ -151,9 +151,10 @@ public class MetadataSchemaServiceImpl implements MetadataSchemaService { * number of times in the current schema. * * @param context DSpace context + * @param metadataSchemaId metadata schema id * @param namespace namespace URI to match * @return true of false - * @throws SQLException + * @throws SQLException if database error */ protected boolean uniqueNamespace(Context context, int metadataSchemaId, String namespace) throws SQLException @@ -165,9 +166,10 @@ public class MetadataSchemaServiceImpl implements MetadataSchemaService { * Return true if and only if the passed name is unique. * * @param context DSpace context + * @param metadataSchemaId metadata schema id * @param name short name of schema * @return true of false - * @throws SQLException + * @throws SQLException if database error */ protected boolean uniqueShortName(Context context, int metadataSchemaId, String name) throws SQLException diff --git a/dspace-api/src/main/java/org/dspace/content/MetadataValue.java b/dspace-api/src/main/java/org/dspace/content/MetadataValue.java index 97214bd5fb..8a0344e01b 100644 --- a/dspace-api/src/main/java/org/dspace/content/MetadataValue.java +++ b/dspace-api/src/main/java/org/dspace/content/MetadataValue.java @@ -8,6 +8,7 @@ package org.dspace.content; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.hibernate.annotations.Type; import org.hibernate.proxy.HibernateProxyHelper; @@ -26,17 +27,17 @@ import javax.persistence.*; */ @Entity @Table(name="metadatavalue") -public class MetadataValue +public class MetadataValue implements ReloadableEntity { /** The reference to the metadata field */ @Id @Column(name="metadata_value_id") @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="metadatavalue_seq") @SequenceGenerator(name="metadatavalue_seq", sequenceName="metadatavalue_seq", allocationSize = 1) - private int valueId; + private Integer id; /** The primary key for the metadata value */ - @ManyToOne + @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "metadata_field_id") private MetadataField metadataField = null; @@ -62,7 +63,7 @@ public class MetadataValue @Column(name = "confidence") private int confidence = -1; - @ManyToOne(fetch = FetchType.EAGER, cascade={CascadeType.PERSIST}) + @ManyToOne(fetch = FetchType.LAZY, cascade={CascadeType.PERSIST}) @JoinColumn(name="dspace_object_id") protected DSpaceObject dSpaceObject; @@ -73,7 +74,7 @@ public class MetadataValue */ protected MetadataValue() { - + id = 0; } /** @@ -81,9 +82,9 @@ public class MetadataValue * * @return metadata value ID */ - public int getValueId() + public Integer getID() { - return valueId; + return id; } /** @@ -238,11 +239,11 @@ public class MetadataValue return false; } final MetadataValue other = (MetadataValue) obj; - if (this.valueId != other.valueId) + if (this.id != other.id) { return false; } - if (this.getValueId() != other.getValueId()) + if (this.getID() != other.getID()) { return false; } @@ -257,8 +258,8 @@ public class MetadataValue public int hashCode() { int hash = 7; - hash = 47 * hash + this.valueId; - hash = 47 * hash + this.getValueId(); + hash = 47 * hash + this.id; + hash = 47 * hash + this.getID(); hash = 47 * hash + this.getDSpaceObject().getID().hashCode(); return hash; } diff --git a/dspace-api/src/main/java/org/dspace/content/MetadataValueServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/MetadataValueServiceImpl.java index 297e0b9cce..53ba317298 100644 --- a/dspace-api/src/main/java/org/dspace/content/MetadataValueServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/MetadataValueServiceImpl.java @@ -72,7 +72,7 @@ public class MetadataValueServiceImpl implements MetadataValueService { public void update(Context context, MetadataValue metadataValue) throws SQLException { metadataValueDAO.save(context, metadataValue); log.info(LogManager.getHeader(context, "update_metadatavalue", - "metadata_value_id=" + metadataValue.getValueId())); + "metadata_value_id=" + metadataValue.getID())); } @@ -89,7 +89,7 @@ public class MetadataValueServiceImpl implements MetadataValueService { @Override public void delete(Context context, MetadataValue metadataValue) throws SQLException { log.info(LogManager.getHeader(context, "delete_metadata_value", - " metadata_value_id=" + metadataValue.getValueId())); + " metadata_value_id=" + metadataValue.getID())); metadataValueDAO.delete(context, metadataValue); } diff --git a/dspace-api/src/main/java/org/dspace/content/WorkspaceItem.java b/dspace-api/src/main/java/org/dspace/content/WorkspaceItem.java index a902bb5096..367d99e9ca 100644 --- a/dspace-api/src/main/java/org/dspace/content/WorkspaceItem.java +++ b/dspace-api/src/main/java/org/dspace/content/WorkspaceItem.java @@ -7,19 +7,19 @@ */ package org.dspace.content; -import java.io.Serializable; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - import org.apache.commons.lang.builder.HashCodeBuilder; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.dspace.eperson.EPerson; import org.dspace.eperson.Group; import org.dspace.workflow.WorkflowItem; import org.hibernate.proxy.HibernateProxyHelper; import javax.persistence.*; +import java.io.Serializable; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; /** * Class representing an item in the process of being submitted by a user @@ -29,14 +29,14 @@ import javax.persistence.*; */ @Entity @Table(name = "workspaceitem") -public class WorkspaceItem implements InProgressSubmission, Serializable +public class WorkspaceItem implements InProgressSubmission, Serializable, ReloadableEntity { @Id @Column(name = "workspace_item_id", unique = true, nullable = false) @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="workspaceitem_seq") @SequenceGenerator(name="workspaceitem_seq", sequenceName="workspaceitem_seq", allocationSize = 1) - private int workspaceItemId; + private Integer workspaceItemId; /** The item this workspace object pertains to */ @OneToOne(fetch = FetchType.LAZY) @@ -90,7 +90,7 @@ public class WorkspaceItem implements InProgressSubmission, Serializable * @return the internal identifier */ @Override - public int getID() + public Integer getID() { return workspaceItemId; } diff --git a/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthorityServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthorityServiceImpl.java index 6f98bc9349..0484c0a768 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthorityServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/ChoiceAuthorityServiceImpl.java @@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired; * * Configuration keys, per metadata field (e.g. "dc.contributer.author") * + * {@code * # names the ChoiceAuthority plugin called for this field * choices.plugin. = name-of-plugin * @@ -36,7 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired; * * # is value "closed" to the set of these choices or are non-authority values permitted? * choices.closed. = true | false - * + * } * @author Larry Stone * @see ChoiceAuthority */ @@ -62,7 +63,7 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService private final String CHOICES_PRESENTATION_PREFIX = "choices.presentation."; private final String CHOICES_CLOSED_PREFIX = "choices.closed."; - private ChoiceAuthorityServiceImpl() { + protected ChoiceAuthorityServiceImpl() { } // translate tail of configuration key (supposed to be schema.element.qual) diff --git a/dspace-api/src/main/java/org/dspace/content/authority/Choices.java b/dspace-api/src/main/java/org/dspace/content/authority/Choices.java index fba7012f4f..5780f6c1b1 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/Choices.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/Choices.java @@ -97,6 +97,11 @@ public class Choices /** * Constructor for general purpose + * @param values values array + * @param start start number + * @param total total results + * @param confidence confidence level + * @param more whether more values */ public Choices(Choice values[], int start, int total, int confidence, boolean more) { @@ -110,6 +115,12 @@ public class Choices /** * Constructor for general purpose + * @param values values array + * @param start start number + * @param total total results + * @param confidence confidence level + * @param more whether more values + * @param defaultSelected default selected value */ public Choices(Choice values[], int start, int total, int confidence, boolean more, int defaultSelected) { @@ -124,6 +135,7 @@ public class Choices /** * Constructor for error results + * @param confidence confidence level */ public Choices(int confidence) { @@ -133,6 +145,7 @@ public class Choices /** * Constructor for simple empty or error results + * @param isError whether error */ public Choices(boolean isError) { diff --git a/dspace-api/src/main/java/org/dspace/content/authority/DCInputAuthority.java b/dspace-api/src/main/java/org/dspace/content/authority/DCInputAuthority.java index 0efeed2fc4..42da4664db 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/DCInputAuthority.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/DCInputAuthority.java @@ -26,13 +26,15 @@ import org.dspace.core.SelfNamedPlugin; * * Configuration: * This MUST be configured aas a self-named plugin, e.g.: + * {@code * plugin.selfnamed.org.dspace.content.authority.ChoiceAuthority = \ * org.dspace.content.authority.DCInputAuthority + * } * - * It AUTOMATICALLY configures a plugin instance for each - * element (within ) of the input-forms.xml. The name + * It AUTOMATICALLY configures a plugin instance for each {@code } + * element (within {@code }) of the input-forms.xml. The name * of the instance is the "value-pairs-name" attribute, e.g. - * the element: + * the element: {@code } * defines a plugin instance "common_types". * * IMPORTANT NOTE: Since these value-pairs do NOT include authority keys, diff --git a/dspace-api/src/main/java/org/dspace/content/authority/DSpaceControlledVocabulary.java b/dspace-api/src/main/java/org/dspace/content/authority/DSpaceControlledVocabulary.java index 36b839cad4..91e0a53fdd 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/DSpaceControlledVocabulary.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/DSpaceControlledVocabulary.java @@ -31,24 +31,27 @@ import org.dspace.services.ConfigurationService; /** * ChoiceAuthority source that reads the JSPUI-style hierarchical vocabularies - * from ${dspace.dir}/config/controlled-vocabularies/*.xml and turns them into + * from {@code ${dspace.dir}/config/controlled-vocabularies/*.xml} and turns them into * autocompleting authorities. * * Configuration: * This MUST be configured as a self-named plugin, e.g.: + * {@code * plugin.selfnamed.org.dspace.content.authority.ChoiceAuthority = \ * org.dspace.content.authority.DSpaceControlledVocabulary + * } * * It AUTOMATICALLY configures a plugin instance for each XML file in the * controlled vocabularies directory. The name of the plugin is the basename - * of the file; e.g., "${dspace.dir}/config/controlled-vocabularies/nsi.xml" + * of the file; e.g., {@code ${dspace.dir}/config/controlled-vocabularies/nsi.xml} * would generate a plugin called "nsi". * * Each configured plugin comes with three configuration options: + * {@code * vocabulary.plugin._plugin_.hierarchy.store = # Store entire hierarchy along with selected value. Default: TRUE * vocabulary.plugin._plugin_.hierarchy.suggest = # Display entire hierarchy in the suggestion list. Default: TRUE * vocabulary.plugin._plugin_.delimiter = "" # Delimiter to use when building hierarchy strings. Default: "::" - * + * } * * @author Michael B. Klein * diff --git a/dspace-api/src/main/java/org/dspace/content/authority/MetadataAuthorityServiceImpl.java b/dspace-api/src/main/java/org/dspace/content/authority/MetadataAuthorityServiceImpl.java index 400b9e5ab7..21ec172d2d 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/MetadataAuthorityServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/MetadataAuthorityServiceImpl.java @@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; * * Configuration keys, per metadata field (e.g. "dc.contributer.author") * + * {@code * # is field authority controlled (i.e. store authority, confidence values)? * authority.controlled. = true * @@ -44,7 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired; * authority.minconfidence.SCHEMA.ELEMENT.QUALIFIER = SYMBOL * e.g. * authority.minconfidence.dc.contributor.author = accepted - * + * } * NOTE: There is *expected* to be a "choices" (see ChoiceAuthorityManager) * configuration for each authority-controlled field. * @@ -215,6 +216,7 @@ public class MetadataAuthorityServiceImpl implements MetadataAuthorityService /** * Give the minimal level of confidence required to consider valid an authority value * for the given metadata. + * @param metadataField metadata field * @return the minimal valid level of confidence for the given metadata */ @Override diff --git a/dspace-api/src/main/java/org/dspace/content/authority/service/ChoiceAuthorityService.java b/dspace-api/src/main/java/org/dspace/content/authority/service/ChoiceAuthorityService.java index 418faa8438..0b2381b944 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/service/ChoiceAuthorityService.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/service/ChoiceAuthorityService.java @@ -19,7 +19,7 @@ import java.util.List; * about the choice aspect of authority control for a metadata field. * * Configuration keys, per metadata field (e.g. "dc.contributer.author") - * + * {@code * # names the ChoiceAuthority plugin called for this field * choices.plugin. = name-of-plugin * @@ -29,7 +29,7 @@ import java.util.List; * * # is value "closed" to the set of these choices or are non-authority values permitted? * choices.closed. = true | false - * + * } * @author Larry Stone * @see ChoiceAuthority */ @@ -40,7 +40,7 @@ public interface ChoiceAuthorityService * Wrapper that calls getMatches method of the plugin corresponding to * the metadata field defined by schema,element,qualifier. * - * @see org.dspace.content.authority.ChoiceAuthority#getMatches(String, String, int, int, int, String) + * @see org.dspace.content.authority.ChoiceAuthority#getMatches(java.lang.String, java.lang.String, org.dspace.content.Collection, int, int, java.lang.String) * @param schema schema of metadata field * @param element element of metadata field * @param qualifier qualifier of metadata field @@ -57,7 +57,7 @@ public interface ChoiceAuthorityService * Wrapper calls getMatches method of the plugin corresponding to * the metadata field defined by single field key. * - * @see org.dspace.content.authority.ChoiceAuthority#getMatches(String, String, int, int, int, String) + * @see org.dspace.content.authority.ChoiceAuthority#getMatches(java.lang.String, java.lang.String, org.dspace.content.Collection, int, int, java.lang.String) * @param fieldKey single string identifying metadata field * @param query user's value to match * @param collection database ID of Collection for context (owner of Item) @@ -75,7 +75,7 @@ public interface ChoiceAuthorityService * Wrapper that calls getBestMatch method of the plugin corresponding to * the metadata field defined by single field key. * - * @see org.dspace.content.authority.ChoiceAuthority#getBestMatch(String, String, int, String) + * @see org.dspace.content.authority.ChoiceAuthority#getBestMatch(java.lang.String, java.lang.String, org.dspace.content.Collection, java.lang.String) * @param fieldKey single string identifying metadata field * @param query user's value to match * @param collection database ID of Collection for context (owner of Item) @@ -88,18 +88,26 @@ public interface ChoiceAuthorityService /** * Wrapper that calls getLabel method of the plugin corresponding to * the metadata field defined by schema,element,qualifier. + * @param metadataValue metadata value + * @param locale explicit localization key if available + * @return label */ public String getLabel(MetadataValue metadataValue, String locale); /** * Wrapper that calls getLabel method of the plugin corresponding to * the metadata field defined by single field key. + * @param fieldKey single string identifying metadata field + * @param locale explicit localization key if available + * @param authKey authority key + * @return label */ public String getLabel(String fieldKey, String authKey, String locale); /** * Predicate, is there a Choices configuration of any kind for the * given metadata field? + * @param fieldKey single string identifying metadata field * @return true if choices are configured for this field. */ public boolean isChoicesConfigured(String fieldKey); @@ -108,6 +116,7 @@ public interface ChoiceAuthorityService * Get the presentation keyword (should be "lookup", "select" or "suggest", but this * is an informal convention so it can be easily extended) for this field. * + * @param fieldKey field key * @return configured presentation type for this field, or null if none found */ public String getPresentation(String fieldKey); @@ -115,12 +124,15 @@ public interface ChoiceAuthorityService /** * Get the configured "closed" value for this field. * + * @param fieldKey single string identifying metadata field * @return true if choices are closed for this field. */ public boolean isClosed(String fieldKey); /** * Wrapper to call plugin's getVariants(). + * @param metadataValue metadata value + * @return List of variants */ public List getVariants(MetadataValue metadataValue); } \ No newline at end of file diff --git a/dspace-api/src/main/java/org/dspace/content/authority/service/MetadataAuthorityService.java b/dspace-api/src/main/java/org/dspace/content/authority/service/MetadataAuthorityService.java index bc485bc49f..66436be6de 100644 --- a/dspace-api/src/main/java/org/dspace/content/authority/service/MetadataAuthorityService.java +++ b/dspace-api/src/main/java/org/dspace/content/authority/service/MetadataAuthorityService.java @@ -8,8 +8,6 @@ package org.dspace.content.authority.service; import org.dspace.content.MetadataField; -import org.dspace.content.authority.ChoiceAuthorityServiceImpl; -import org.dspace.content.authority.Choices; import java.util.List; @@ -19,40 +17,56 @@ import java.util.List; * Configuration keys, per metadata field (e.g. "dc.contributer.author") * * # is field authority controlled (i.e. store authority, confidence values)? - * authority.controlled. = true + * {@code authority.controlled. = true} * * # is field required to have an authority value, or may it be empty? * # default is false. - * authority.required. = true | false + * {@code authority.required. = true | false} * * # default value of minimum confidence level for ALL fields - must be * # symbolic confidence level, see org.dspace.content.authority.Choices - * authority.minconfidence = uncertain + * {@code authority.minconfidence = uncertain} * * # minimum confidence level for this field - * authority.minconfidence.SCHEMA.ELEMENT.QUALIFIER = SYMBOL + * {@code authority.minconfidence.SCHEMA.ELEMENT.QUALIFIER = SYMBOL} * e.g. - * authority.minconfidence.dc.contributor.author = accepted + * {@code authority.minconfidence.dc.contributor.author = accepted} * * NOTE: There is *expected* to be a "choices" (see ChoiceAuthorityManager) * configuration for each authority-controlled field. * - * @see ChoiceAuthorityServiceImpl - * @see Choices + * @see org.dspace.content.authority.ChoiceAuthorityServiceImpl + * @see org.dspace.content.authority.Choices * @author Larry Stone */ public interface MetadataAuthorityService { - /** Predicate - is field authority-controlled? */ + /** + * Predicate - is field authority-controlled? + * @param metadataField metadata field + * @return true/false + */ public boolean isAuthorityControlled(MetadataField metadataField); - /** Predicate - is field authority-controlled? */ + /** + * Predicate - is field authority-controlled? + * @param fieldKey field key + * @return true/false + */ public boolean isAuthorityControlled(String fieldKey); - /** Predicate - is authority value required for field? */ + /** + * Predicate - is authority value required for field? + * @param metadataField metadata field + * @return true/false + */ public boolean isAuthorityRequired(MetadataField metadataField); - /** Predicate - is authority value required for field? */ + /** + * Predicate - is authority value required for field? + * @param fieldKey field key + * @return true/false + */ public boolean isAuthorityRequired(String fieldKey); @@ -60,6 +74,8 @@ public interface MetadataAuthorityService { * Construct a single key from the tuple of schema/element/qualifier * that describes a metadata field. Punt to the function we use for * submission UI input forms, for now. + * @param metadataField metadata field + * @return field key */ public String makeFieldKey(MetadataField metadataField); @@ -67,12 +83,17 @@ public interface MetadataAuthorityService { * Construct a single key from the tuple of schema/element/qualifier * that describes a metadata field. Punt to the function we use for * submission UI input forms, for now. + * @param schema schema + * @param element element + * @param qualifier qualifier + * @return field key */ public String makeFieldKey(String schema, String element, String qualifier); /** * Give the minimal level of confidence required to consider valid an authority value * for the given metadata. + * @param metadataField metadata field * @return the minimal valid level of confidence for the given metadata */ public int getMinConfidence(MetadataField metadataField); diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/AIPDIMCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/AIPDIMCrosswalk.java index b551527ca5..a5d29247d7 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/AIPDIMCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/AIPDIMCrosswalk.java @@ -115,6 +115,7 @@ public class AIPDIMCrosswalk * When there are no results, an * empty list is returned, but never null. * + * @param context context * @param dso the DSpace Object whose metadata to export. * @return results of crosswalk as list of XML elements. * @@ -139,6 +140,7 @@ public class AIPDIMCrosswalk * This is typically the root element of a document. *

* + * @param context context * @param dso the DSpace Object whose metadata to export. * @return root Element of the target metadata, never null * @@ -160,6 +162,11 @@ public class AIPDIMCrosswalk * Ingest a whole document. Build Document object around root element, * and feed that to the transformation, since it may get handled * differently than a List of metadata elements. + * @param createMissingMetadataFields whether to create missing fields + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void ingest(Context context, DSpaceObject dso, Element root, boolean createMissingMetadataFields) @@ -171,6 +178,12 @@ public class AIPDIMCrosswalk /** * Fields correspond directly to Item.addMetadata() calls so * they are simply executed. + * @param createMissingMetadataFields whether to create missing fields + * @param dimList List of elements + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void ingest(Context context, DSpaceObject dso, List dimList, boolean createMissingMetadataFields) diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/AIPTechMDCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/AIPTechMDCrosswalk.java index 3a56fbf9e9..1856615edd 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/AIPTechMDCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/AIPTechMDCrosswalk.java @@ -157,6 +157,7 @@ public class AIPTechMDCrosswalk implements IngestionCrosswalk, DisseminationCros * When there are no results, an * empty list is returned, but never null. * + * @param context context * @param dso the DSpace Object whose metadata to export. * @return results of crosswalk as list of XML elements. * @@ -181,6 +182,7 @@ public class AIPTechMDCrosswalk implements IngestionCrosswalk, DisseminationCros * This is typically the root element of a document. *

* + * @param context context * @param dso the DSpace Object whose metadata to export. * @return root Element of the target metadata, never null * @@ -323,6 +325,11 @@ public class AIPTechMDCrosswalk implements IngestionCrosswalk, DisseminationCros * Ingest a whole document. Build Document object around root element, * and feed that to the transformation, since it may get handled * differently than a List of metadata elements. + * @param createMissingMetadataFields whether to create missing fields + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void ingest(Context context, DSpaceObject dso, Element root, boolean createMissingMetadataFields) @@ -336,6 +343,12 @@ public class AIPTechMDCrosswalk implements IngestionCrosswalk, DisseminationCros * Translation produces a list of DIM "field" elements; * these correspond directly to Item.addMetadata() calls so * they are simply executed. + * @param createMissingMetadataFields whether to create missing fields + * @param dimList List of elements + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void ingest(Context context, DSpaceObject dso, List dimList, boolean createMissingMetadataFields) diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/CrosswalkMetadataValidator.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/CrosswalkMetadataValidator.java new file mode 100644 index 0000000000..0c704b9580 --- /dev/null +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/CrosswalkMetadataValidator.java @@ -0,0 +1,115 @@ +/** + * The contents of this file are subject to the license and copyright + * detailed in the LICENSE and NOTICE files at the root of the source + * tree and available online at + * + * http://www.dspace.org/license/ + */ +package org.dspace.content.crosswalk; + +import org.apache.commons.lang3.tuple.ImmutableTriple; +import org.apache.commons.lang3.tuple.Triple; +import org.dspace.authorize.AuthorizeException; +import org.dspace.content.MetadataField; +import org.dspace.content.MetadataSchema; +import org.dspace.content.NonUniqueMetadataException; +import org.dspace.content.factory.ContentServiceFactory; +import org.dspace.content.service.MetadataFieldService; +import org.dspace.content.service.MetadataSchemaService; +import org.dspace.core.ConfigurationManager; +import org.dspace.core.Context; + +import java.sql.SQLException; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +public class CrosswalkMetadataValidator { + + protected MetadataSchemaService metadataSchemaService; + protected MetadataFieldService metadataFieldService; + + private String schemaChoice; + private String fieldChoice; + + private Map, MetadataField> validatedMetadataFields; + + public CrosswalkMetadataValidator() { + metadataSchemaService = ContentServiceFactory.getInstance().getMetadataSchemaService(); + metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService(); + + validatedMetadataFields = new HashMap<>(); + + // The two options, with three possibilities each: add, ignore, fail + schemaChoice = ConfigurationManager.getProperty("oai", "harvester.unknownSchema"); + if (schemaChoice == null) + { + schemaChoice = "fail"; + } + + fieldChoice = ConfigurationManager.getProperty("oai", "harvester.unknownField"); + if (fieldChoice == null) + { + fieldChoice = "fail"; + } + } + + /** + * Scans metadata for elements not defined in this DSpace instance. It then takes action based + * on a configurable parameter (fail, ignore, add). + */ + public MetadataField checkMetadata(Context context, String schema, String element, String qualifier, boolean forceCreate) throws SQLException, AuthorizeException, CrosswalkException { + if(!validatedBefore(schema, element, qualifier)) { + // Verify that the schema exists + MetadataSchema mdSchema = metadataSchemaService.find(context, schema); + MetadataField mdField = null; + + if (mdSchema == null) { + // add a new schema, giving it a namespace of "unknown". Possibly a very bad idea. + if (forceCreate && schemaChoice.equals("add")) { + try { + mdSchema = metadataSchemaService.create(context, schema, String.valueOf(new Date().getTime())); + mdSchema.setNamespace("unknown" + mdSchema.getID()); + metadataSchemaService.update(context, mdSchema); + } catch (NonUniqueMetadataException e) { + // This case should not be possible + e.printStackTrace(); + } + } + // ignore the offending schema, quietly dropping all of its metadata elements before they clog our gears + else if (!schemaChoice.equals("ignore")) { + throw new CrosswalkException("The '" + schema + "' schema has not been defined in this DSpace instance. "); + } + } + + if (mdSchema != null) { + // Verify that the element exists; this part is reachable only if the metadata schema is valid + mdField = metadataFieldService.findByElement(context, mdSchema, element, qualifier); + if (mdField == null) { + if (forceCreate && fieldChoice.equals("add")) { + try { + metadataFieldService.create(context, mdSchema, element, qualifier, null); + } catch (NonUniqueMetadataException e) { + // This case should also not be possible + e.printStackTrace(); + } + } else if (!fieldChoice.equals("ignore")) { + throw new CrosswalkException("The '" + element + "." + qualifier + "' element has not been defined in this DSpace instance. "); + } + } + } + + validatedMetadataFields.put(createKey(schema, element, qualifier), mdField); + } + + return validatedMetadataFields.get(createKey(schema, element, qualifier)); + } + + private boolean validatedBefore(String schema, String element, String qualifier) { + return validatedMetadataFields.containsKey(createKey(schema, element, qualifier)); + } + + private ImmutableTriple createKey(final String schema, final String element, final String qualifier) { + return new ImmutableTriple(schema, element, qualifier); + } +} diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/CrosswalkUtils.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/CrosswalkUtils.java deleted file mode 100644 index 9c8725018c..0000000000 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/CrosswalkUtils.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.content.crosswalk; - -import org.dspace.authorize.AuthorizeException; -import org.dspace.content.MetadataField; -import org.dspace.content.MetadataSchema; -import org.dspace.content.NonUniqueMetadataException; -import org.dspace.content.factory.ContentServiceFactory; -import org.dspace.content.service.MetadataFieldService; -import org.dspace.content.service.MetadataSchemaService; -import org.dspace.core.ConfigurationManager; -import org.dspace.core.Context; - -import java.sql.SQLException; -import java.util.Date; - -public class CrosswalkUtils { - - protected static final MetadataSchemaService metadataSchemaService = ContentServiceFactory.getInstance().getMetadataSchemaService(); - protected static final MetadataFieldService metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService(); - - /** - * Scans metadata for elements not defined in this DSpace instance. It then takes action based - * on a configurable parameter (fail, ignore, add). - */ - public static void checkMetadata(Context context, String schema, String element, String qualifier, boolean forceCreate) throws SQLException, AuthorizeException, CrosswalkException { - // The two options, with three possibilities each: add, ignore, fail - String schemaChoice = ConfigurationManager.getProperty("oai", "harvester.unknownSchema"); - if (schemaChoice == null) - { - schemaChoice = "fail"; - } - - String fieldChoice = ConfigurationManager.getProperty("oai", "harvester.unknownField"); - if (fieldChoice == null) - { - fieldChoice = "fail"; - } - - // Verify that the schema exists - MetadataSchema mdSchema = metadataSchemaService.find(context, schema); - if (mdSchema == null) { - // add a new schema, giving it a namespace of "unknown". Possibly a very bad idea. - if (forceCreate && schemaChoice.equals("add")) - { - try { - mdSchema = metadataSchemaService.create(context, schema, String.valueOf(new Date().getTime())); - mdSchema.setNamespace("unknown"+mdSchema.getSchemaID()); - metadataSchemaService.update(context, mdSchema); - } catch (NonUniqueMetadataException e) { - // This case should not be possible - e.printStackTrace(); - } - } - // ignore the offending schema, quietly dropping all of its metadata elements before they clog our gears - else if (!schemaChoice.equals("ignore")) { - throw new CrosswalkException("The '" + schema + "' schema has not been defined in this DSpace instance. "); - } - } - - if (mdSchema != null) { - // Verify that the element exists; this part is reachable only if the metadata schema is valid - MetadataField mdField = metadataFieldService.findByElement(context, mdSchema, element, qualifier); - if (mdField == null) { - if (forceCreate && fieldChoice.equals("add")) { - try { - metadataFieldService.create(context, mdSchema, element, qualifier, null); - } catch (NonUniqueMetadataException e) { - // This case should also not be possible - e.printStackTrace(); - } - } - else if (!fieldChoice.equals("ignore")) { - throw new CrosswalkException("The '" + element + "." + qualifier + "' element has not been defined in this DSpace instance. "); - } - } - } - } -} diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/DIMIngestionCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/DIMIngestionCrosswalk.java index 911b0f58db..b108d90805 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/DIMIngestionCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/DIMIngestionCrosswalk.java @@ -7,13 +7,10 @@ */ package org.dspace.content.crosswalk; -import java.io.IOException; -import java.sql.SQLException; -import java.util.List; - import org.dspace.authorize.AuthorizeException; import org.dspace.content.DSpaceObject; import org.dspace.content.Item; +import org.dspace.content.MetadataField; import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.service.ItemService; import org.dspace.core.Constants; @@ -21,6 +18,10 @@ import org.dspace.core.Context; import org.jdom.Element; import org.jdom.Namespace; +import java.io.IOException; +import java.sql.SQLException; +import java.util.List; + /** * DIM ingestion crosswalk *

@@ -33,7 +34,7 @@ public class DIMIngestionCrosswalk implements IngestionCrosswalk { private static final Namespace DIM_NS = Namespace.getNamespace("http://www.dspace.org/xmlns/dspace/dim"); protected ItemService itemService = ContentServiceFactory.getInstance().getItemService(); - + private CrosswalkMetadataValidator metadataValidator = new CrosswalkMetadataValidator(); @Override public void ingest(Context context, DSpaceObject dso, List metadata, boolean createMissingMetadataFields) throws CrosswalkException, IOException, SQLException, AuthorizeException { @@ -69,8 +70,8 @@ public class DIMIngestionCrosswalk implements IngestionCrosswalk String schema = field.getAttributeValue("mdschema"); String element = field.getAttributeValue("element"); String qualifier = field.getAttributeValue("qualifier"); - CrosswalkUtils.checkMetadata(context, schema, element, qualifier, createMissingMetadataFields); - itemService.addMetadata(context, item, schema, element, qualifier, + MetadataField metadataField = metadataValidator.checkMetadata(context, schema, element, qualifier, createMissingMetadataFields); + itemService.addMetadata(context, item, metadataField, field.getAttributeValue("lang"), field.getText()); } diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/DisseminationCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/DisseminationCrosswalk.java index e272f355a4..bcc73bc80c 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/DisseminationCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/DisseminationCrosswalk.java @@ -91,6 +91,7 @@ public interface DisseminationCrosswalk * When there are no results, an * empty list is returned, but never null. * + * @param context context * @param dso the DSpace Object whose metadata to export. * @return results of crosswalk as list of XML elements. * @@ -110,6 +111,7 @@ public interface DisseminationCrosswalk * This is typically the root element of a document. *

* + * @param context context * @param dso the DSpace Object whose metadata to export. * @return root Element of the target metadata, never null * diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/IngestionCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/IngestionCrosswalk.java index ec6a057c21..3151c2ec67 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/IngestionCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/IngestionCrosswalk.java @@ -63,6 +63,7 @@ public interface IngestionCrosswalk * @param context DSpace context. * @param dso DSpace Object (Item, Bitstream, etc) to which new metadata gets attached. * @param metadata List of XML Elements of metadata + * @param createMissingMetadataFields whether to create missing fields * * @throws CrosswalkInternalException (CrosswalkException) failure of the crosswalk itself. * @throws CrosswalkObjectNotSupported (CrosswalkException) Cannot crosswalk into this kind of DSpace object. @@ -85,6 +86,7 @@ public interface IngestionCrosswalk * @param context DSpace context. * @param dso DSpace Object (usually an Item) to which new metadata gets attached. * @param root root Element of metadata document. + * @param createMissingMetadataFields whether to create missing fields * * @throws CrosswalkInternalException (CrosswalkException) failure of the crosswalk itself. * @throws CrosswalkObjectNotSupported (CrosswalkException) Cannot crosswalk into this kind of DSpace object. diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/METSRightsCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/METSRightsCrosswalk.java index 2a37020f4d..a2bf63ddcd 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/METSRightsCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/METSRightsCrosswalk.java @@ -40,7 +40,7 @@ import org.jdom.Element; import org.jdom.Namespace; /** - * METSRights Ingestion & Dissemination Crosswalk + * METSRights Ingestion and Dissemination Crosswalk *

* Translate between DSpace internal policies (i.e. permissions) and the * METSRights metadata schema @@ -130,12 +130,13 @@ public class METSRightsCrosswalk * policies (permissions) for the provided object, and translates them into * METSRights PermissionTypes. * + * @param context context * @param dso DSpace Object - * @return XML Element corresponding to the new translation - * @throws CrosswalkException - * @throws IOException - * @throws SQLException - * @throws AuthorizeException + * @return XML Element corresponding to the new {@code } translation + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public Element disseminateElement(Context context, DSpaceObject dso) @@ -404,10 +405,11 @@ public class METSRightsCrosswalk * @param context * @param dso * @param root - * @throws CrosswalkException - * @throws IOException - * @throws SQLException - * @throws AuthorizeException + * @param createMissingMetadataFields + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void ingest(Context context, DSpaceObject dso, Element root, boolean createMissingMetadataFields) @@ -432,12 +434,14 @@ public class METSRightsCrosswalk * conjunction with another Crosswalk which can create/restore missing * Groups or EPeople (e.g. RoleCrosswalk). * - * @param context - * @param dso - * @throws CrosswalkException - * @throws IOException - * @throws SQLException - * @throws AuthorizeException + * @param context context + * @param dso Dspace object + * @param ml list of elements + * @param createMissingMetadataFields whether to create missing fields + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error * @see RoleCrosswalk */ @Override diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/MODSDisseminationCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/MODSDisseminationCrosswalk.java index 8ec6ddf628..acfb3f6e29 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/MODSDisseminationCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/MODSDisseminationCrosswalk.java @@ -310,6 +310,11 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin /** * Returns object's metadata in MODS format, as List of XML structure nodes. + * @param context context + * @throws org.dspace.content.crosswalk.CrosswalkException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public List disseminateList(Context context, DSpaceObject dso) @@ -321,6 +326,11 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin /** * Disseminate an Item, Collection, or Community to MODS. + * @param context context + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public Element disseminateElement(Context context, DSpaceObject dso) @@ -439,6 +449,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin * * @param site * The site to derive metadata from + * @return list of metadata */ protected List site2Metadata(Site site) { @@ -473,6 +484,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin * * @param community * The community to derive metadata from + * @return list of metadata */ protected List community2Metadata(Community community) { @@ -522,6 +534,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin * * @param collection * The collection to derive metadata from + * @return list of metadata */ protected List collection2Metadata(Collection collection) { @@ -585,6 +598,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin * * @param item * The item to derive metadata from + * @return list of metadata */ protected List item2Metadata(Item item) { diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/OAIDCIngestionCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/OAIDCIngestionCrosswalk.java index 8ec6cb3640..124e9ce285 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/OAIDCIngestionCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/OAIDCIngestionCrosswalk.java @@ -7,13 +7,10 @@ */ package org.dspace.content.crosswalk; -import java.io.IOException; -import java.sql.SQLException; -import java.util.List; - import org.dspace.authorize.AuthorizeException; import org.dspace.content.DSpaceObject; import org.dspace.content.Item; +import org.dspace.content.MetadataField; import org.dspace.content.MetadataSchema; import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.service.ItemService; @@ -22,6 +19,10 @@ import org.dspace.core.Context; import org.jdom.Element; import org.jdom.Namespace; +import java.io.IOException; +import java.sql.SQLException; +import java.util.List; + /** * DIM ingestion crosswalk *

@@ -34,6 +35,7 @@ public class OAIDCIngestionCrosswalk implements IngestionCrosswalk { protected ItemService itemService = ContentServiceFactory.getInstance().getItemService(); + private CrosswalkMetadataValidator metadataValidator = new CrosswalkMetadataValidator(); @Override public void ingest(Context context, DSpaceObject dso, List metadata, boolean createMissingMetadataFields) throws CrosswalkException, IOException, SQLException, AuthorizeException { @@ -64,8 +66,8 @@ public class OAIDCIngestionCrosswalk if (lang == null) { lang = element.getAttributeValue("lang"); } - CrosswalkUtils.checkMetadata(context, MetadataSchema.DC_SCHEMA, element.getName(), null, createMissingMetadataFields); - itemService.addMetadata(context, item, "dc", element.getName(), null, lang, element.getText()); + MetadataField metadataField = metadataValidator.checkMetadata(context, MetadataSchema.DC_SCHEMA, element.getName(), null, createMissingMetadataFields); + itemService.addMetadata(context, item, metadataField, lang, element.getText()); } } diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/OREDisseminationCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/OREDisseminationCrosswalk.java index 899b2d68d4..be68791368 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/OREDisseminationCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/OREDisseminationCrosswalk.java @@ -80,10 +80,10 @@ public class OREDisseminationCrosswalk * Disseminate an Atom-encoded ORE ReM mapped from a DSpace Item * @param item * @return - * @throws CrosswalkException - * @throws IOException - * @throws SQLException - * @throws AuthorizeException + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ private Element disseminateItem(Context context, Item item) throws CrosswalkException, IOException, SQLException, AuthorizeException { diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/OREIngestionCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/OREIngestionCrosswalk.java index a4913d7ea4..4d7310afbc 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/OREIngestionCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/OREIngestionCrosswalk.java @@ -225,7 +225,7 @@ public class OREIngestionCrosswalk /** - * Helper method to escape all chaacters that are not part of the canon set + * Helper method to escape all characters that are not part of the canon set * @param sourceString source unescaped string */ private String encodeForURL(String sourceString) { diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/QDCCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/QDCCrosswalk.java index f7d929d085..ff4d026d88 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/QDCCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/QDCCrosswalk.java @@ -7,18 +7,6 @@ */ package org.dspace.content.crosswalk; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.StringReader; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - import org.apache.commons.lang.ArrayUtils; import org.apache.log4j.Logger; import org.dspace.authorize.AuthorizeException; @@ -34,6 +22,13 @@ import org.jdom.Element; import org.jdom.Namespace; import org.jdom.input.SAXBuilder; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.StringReader; +import java.sql.SQLException; +import java.util.*; + /** * Configurable QDC Crosswalk *

@@ -122,6 +117,8 @@ public class QDCCrosswalk extends SelfNamedPlugin protected ItemService itemService = ContentServiceFactory.getInstance().getItemService(); + private CrosswalkMetadataValidator metadataValidator = new CrosswalkMetadataValidator(); + /** * Fill in the plugin-name table from DSpace configuration entries * for configuration files for flavors of QDC crosswalk: @@ -336,6 +333,11 @@ public class QDCCrosswalk extends SelfNamedPlugin /** * Returns object's metadata in MODS format, as XML structure node. + * @param context context + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public List disseminateList(Context context, DSpaceObject dso) @@ -463,7 +465,15 @@ public class QDCCrosswalk extends SelfNamedPlugin else if (element2qdc.containsKey(key)) { String qdc[] = (element2qdc.get(key)).split("\\."); - CrosswalkUtils.checkMetadata(context, qdc[0], qdc[1], qdc[2], createMissingMetadataFields); + + MetadataField metadataField; + if (qdc.length == 3) { + metadataField = metadataValidator.checkMetadata(context, qdc[0], qdc[1], qdc[2], createMissingMetadataFields); + } else if (qdc.length == 2) { + metadataField = metadataValidator.checkMetadata(context, qdc[0], qdc[1], null, createMissingMetadataFields); + } else { + throw new CrosswalkInternalException("Unrecognized format in QDC element identifier for key=\"" + key + "\", qdc=\"" + element2qdc.get(key) + "\""); + } // get language - prefer xml:lang, accept lang. String lang = me.getAttributeValue("lang", Namespace.XML_NAMESPACE); @@ -472,18 +482,7 @@ public class QDCCrosswalk extends SelfNamedPlugin lang = me.getAttributeValue("lang"); } - if (qdc.length == 3) - { - itemService.addMetadata(context, item, qdc[0], qdc[1], qdc[2], lang, me.getText()); - } - else if (qdc.length == 2) - { - itemService.addMetadata(context, item, qdc[0], qdc[1], null, lang, me.getText()); - } - else - { - throw new CrosswalkInternalException("Unrecognized format in QDC element identifier for key=\"" + key + "\", qdc=\"" + element2qdc.get(key) + "\""); - } + itemService.addMetadata(context, item, metadataField, lang, me.getText()); } else { diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/RoleCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/RoleCrosswalk.java index 6b880cb3bb..ad56dd1d45 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/RoleCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/RoleCrosswalk.java @@ -35,11 +35,11 @@ import org.jdom.output.XMLOutputter; /** * Role Crosswalk *

- * Translate between DSpace Group & EPeople definitions and a DSpace-specific + * Translate between DSpace Group and EPeople definitions and a DSpace-specific * XML export format (generated by the RoleDisseminator). This is primarily * used for AIPs, but may be used by other Packagers as necessary. *

- * This crosswalk allows you to export DSpace Groups & EPeople to this XML + * This crosswalk allows you to export DSpace Groups and EPeople to this XML * structured format. It also allows you to import an XML file of this format * in order to restore DSpace Groups and EPeople defined within it. *

@@ -135,6 +135,7 @@ public class RoleCrosswalk * When there are no results, an * empty list is returned, but never null. * + * @param context context * @param dso the DSpace Object whose metadata to export. * @return results of crosswalk as list of XML elements. * @@ -159,6 +160,7 @@ public class RoleCrosswalk * This is typically the root element of a document. *

* + * @param context context * @param dso the DSpace Object whose metadata to export. * @return root Element of the target metadata, never null * @@ -241,13 +243,14 @@ public class RoleCrosswalk /** * Ingest a List of XML elements * - * @param context - * @param dso - * @param metadata - * @throws CrosswalkException - * @throws IOException - * @throws SQLException - * @throws AuthorizeException + * @param context context + * @param dso DSpaceObject + * @param metadata list of metadata + * @param createMissingMetadataFields whether to create missing fields + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void ingest(Context context, DSpaceObject dso, List metadata, boolean createMissingMetadataFields) @@ -265,13 +268,14 @@ public class RoleCrosswalk *

* This essentially just wraps a call to the configured Role PackageIngester. * - * @param context - * @param dso - * @param root - * @throws CrosswalkException - * @throws IOException - * @throws SQLException - * @throws AuthorizeException + * @param context context + * @param dso DSpaceObject + * @param root root element + * @param createMissingMetadataFields whether to create missing fields + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void ingest(Context context, DSpaceObject dso, Element root, boolean createMissingMetadataFields) diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/SimpleDCDisseminationCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/SimpleDCDisseminationCrosswalk.java index b60136bdb5..78ad431049 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/SimpleDCDisseminationCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/SimpleDCDisseminationCrosswalk.java @@ -77,6 +77,11 @@ public class SimpleDCDisseminationCrosswalk extends SelfNamedPlugin * Returns object's metadata as XML elements. * Simple-minded copying of elements: convert contributor.author to * "creator" but otherwise just grab element name without qualifier. + * @param context context + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public List disseminateList(Context context, DSpaceObject dso) diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/StreamDisseminationCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/StreamDisseminationCrosswalk.java index 8380dce629..c4582b0302 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/StreamDisseminationCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/StreamDisseminationCrosswalk.java @@ -35,6 +35,7 @@ public interface StreamDisseminationCrosswalk /** * Predicate: Can this disseminator crosswalk the given object. * + * @param context context * @param dso dspace object, e.g. an Item. * @return true when disseminator is capable of producing metadata. */ diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/XHTMLHeadDisseminationCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/XHTMLHeadDisseminationCrosswalk.java index 81486e8d60..80f8e651e3 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/XHTMLHeadDisseminationCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/XHTMLHeadDisseminationCrosswalk.java @@ -146,6 +146,11 @@ public class XHTMLHeadDisseminationCrosswalk extends SelfNamedPlugin implements /** * This generates a <head> element around the metadata; in general * this will probably not be used + * @param context context + * @throws CrosswalkException crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public Element disseminateElement(Context context, DSpaceObject dso) @@ -161,6 +166,11 @@ public class XHTMLHeadDisseminationCrosswalk extends SelfNamedPlugin implements /** * Return <meta> elements that can be put in the <head> element * of an XHTML document. + * @param context context + * @throws CrosswalkException crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public List disseminateList(Context context, DSpaceObject dso) throws CrosswalkException, diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/XSLTDisseminationCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/XSLTDisseminationCrosswalk.java index 17469eee78..687bde5a1f 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/XSLTDisseminationCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/XSLTDisseminationCrosswalk.java @@ -250,6 +250,11 @@ public class XSLTDisseminationCrosswalk /** * Disseminate the DSpace item, collection, or community. * + * @param context context + * @throws CrosswalkException crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error * @see DisseminationCrosswalk */ @Override @@ -321,6 +326,8 @@ public class XSLTDisseminationCrosswalk * Generate an intermediate representation of a DSpace object. * * @param dso The dspace object to build a representation of. + * @param dcvs list of metadata + * @return element */ public static Element createDIM(DSpaceObject dso, List dcvs) { @@ -343,6 +350,7 @@ public class XSLTDisseminationCrosswalk * Generate an intermediate representation of a DSpace object. * * @param dso The dspace object to build a representation of. + * @return element */ public static Element createDIM(DSpaceObject dso) { @@ -515,7 +523,9 @@ public class XSLTDisseminationCrosswalk /** * Simple command-line rig for testing the DIM output of a stylesheet. - * Usage: java XSLTDisseminationCrosswalk [output-file] + * Usage: {@code java XSLTDisseminationCrosswalk [output-file]} + * @param argv arguments + * @throws Exception if error */ public static void main(String[] argv) throws Exception { diff --git a/dspace-api/src/main/java/org/dspace/content/crosswalk/XSLTIngestionCrosswalk.java b/dspace-api/src/main/java/org/dspace/content/crosswalk/XSLTIngestionCrosswalk.java index 08f90d803f..47f5b09bb5 100644 --- a/dspace-api/src/main/java/org/dspace/content/crosswalk/XSLTIngestionCrosswalk.java +++ b/dspace-api/src/main/java/org/dspace/content/crosswalk/XSLTIngestionCrosswalk.java @@ -18,12 +18,7 @@ import javax.xml.transform.TransformerException; import org.apache.commons.lang.ArrayUtils; import org.apache.log4j.Logger; import org.dspace.authorize.AuthorizeException; -import org.dspace.content.DSpaceObject; -import org.dspace.content.Collection; -import org.dspace.content.Community; -import org.dspace.content.Item; -import org.dspace.content.MetadataField; -import org.dspace.content.MetadataSchema; +import org.dspace.content.*; import org.dspace.content.authority.Choices; import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.packager.PackageUtils; @@ -41,6 +36,12 @@ import org.jdom.output.XMLOutputter; import org.jdom.transform.JDOMResult; import org.jdom.transform.JDOMSource; +import java.io.FileInputStream; +import java.io.IOException; +import java.sql.SQLException; +import java.util.Iterator; +import java.util.List; + /** * Configurable XSLT-driven ingestion Crosswalk *

@@ -100,7 +101,8 @@ public class XSLTIngestionCrosswalk String authority = field.getAttributeValue("authority"); String sconf = field.getAttributeValue("confidence"); - CrosswalkUtils.checkMetadata(context, schema, element, qualifier, createMissingMetadataFields); + CrosswalkMetadataValidator metadataValidator = new CrosswalkMetadataValidator(); + MetadataField metadataField = metadataValidator.checkMetadata(context, schema, element, qualifier, createMissingMetadataFields); // sanity check: some XSL puts an empty string in qualifier, // change it to null so we match the unqualified DC field: if (qualifier != null && qualifier.equals("")) @@ -113,11 +115,11 @@ public class XSLTIngestionCrosswalk { int confidence = (sconf != null && sconf.length() > 0) ? Choices.getConfidenceValue(sconf) : Choices.CF_UNSET; - itemService.addMetadata(context, item, schema, element, qualifier, lang, field.getText(), authority, confidence); + itemService.addMetadata(context, item, metadataField, lang, field.getText(), authority, confidence); } else { - itemService.addMetadata(context, item, schema, element, qualifier, lang, field.getText()); + itemService.addMetadata(context, item, metadataField, lang, field.getText()); } } @@ -126,6 +128,11 @@ public class XSLTIngestionCrosswalk * Translation produces a list of DIM "field" elements; * these correspond directly to Item.addMetadata() calls so * they are simply executed. + * @param createMissingMetadataFields whether to create missing fields + * @throws CrosswalkException crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void ingest(Context context, DSpaceObject dso, List metadata, @@ -155,6 +162,11 @@ public class XSLTIngestionCrosswalk * Ingest a whole document. Build Document object around root element, * and feed that to the transformation, since it may get handled * differently than a List of metadata elements. + * @param createMissingMetadataFields whether to create missing fields + * @throws CrosswalkException crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void ingest(Context context, DSpaceObject dso, Element root, boolean createMissingMetadataFields) @@ -207,6 +219,11 @@ public class XSLTIngestionCrosswalk * @param context the context * @param dso object into which to ingest metadata * @param dim root of a DIM expression + * @param createMissingMetadataFields whether to create missing fields + * @throws CrosswalkException crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public static void ingestDIM(Context context, DSpaceObject dso, Element dim, boolean createMissingMetadataFields) @@ -275,7 +292,9 @@ public class XSLTIngestionCrosswalk /** * Simple command-line rig for testing the DIM output of a stylesheet. - * Usage: java XSLTIngestionCrosswalk + * Usage: {@code java XSLTIngestionCrosswalk } + * @param argv arguments + * @throws Exception if error */ public static void main(String[] argv) throws Exception { diff --git a/dspace-api/src/main/java/org/dspace/content/dao/BitstreamDAO.java b/dspace-api/src/main/java/org/dspace/content/dao/BitstreamDAO.java index 6e86801e0b..c568d838e6 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/BitstreamDAO.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/BitstreamDAO.java @@ -20,7 +20,7 @@ import java.util.List; /** * Database Access Object interface class for the Bitstream object. * The implementation of this class is responsible for all database calls for the Bitstream object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/content/dao/BitstreamFormatDAO.java b/dspace-api/src/main/java/org/dspace/content/dao/BitstreamFormatDAO.java index 777fd9b593..3c7c1907ff 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/BitstreamFormatDAO.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/BitstreamFormatDAO.java @@ -17,7 +17,7 @@ import java.util.List; /** * Database Access Object interface class for the BitstreamFormat object. * The implementation of this class is responsible for all database calls for the BitstreamFormat object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/content/dao/BundleDAO.java b/dspace-api/src/main/java/org/dspace/content/dao/BundleDAO.java index 09c0d298e1..0e13711876 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/BundleDAO.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/BundleDAO.java @@ -15,7 +15,7 @@ import java.sql.SQLException; /** * Database Access Object interface class for the Bundle object. * The implementation of this class is responsible for all database calls for the Bundle object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/content/dao/CollectionDAO.java b/dspace-api/src/main/java/org/dspace/content/dao/CollectionDAO.java index a202e875ab..616a3997e8 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/CollectionDAO.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/CollectionDAO.java @@ -21,7 +21,7 @@ import java.util.Map; /** * Database Access Object interface class for the Collection object. * The implementation of this class is responsible for all database calls for the Collection object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/content/dao/CommunityDAO.java b/dspace-api/src/main/java/org/dspace/content/dao/CommunityDAO.java index 4247784c64..99f422b01f 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/CommunityDAO.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/CommunityDAO.java @@ -19,7 +19,7 @@ import java.util.List; /** * Database Access Object interface class for the Community object. * The implementation of this class is responsible for all database calls for the Community object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/content/dao/ItemDAO.java b/dspace-api/src/main/java/org/dspace/content/dao/ItemDAO.java index 1a21b4c645..80f7fa834d 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/ItemDAO.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/ItemDAO.java @@ -22,7 +22,7 @@ import java.util.UUID; /** * Database Access Object interface class for the Item object. * The implementation of this class is responsible for all database calls for the Item object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ @@ -35,9 +35,10 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO /** * Find all Items modified since a Date. * - * @param context + * @param context Context * @param since Earliest interesting last-modified date. - * @return + * @return iterator over items + * @throws SQLException if database error */ public Iterator findByLastModifiedSince(Context context, Date since) throws SQLException; @@ -58,12 +59,12 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO /** * Count number of items in a given collection - * @param context + * @param context context * @param collection the collection * @param includeArchived whether to include archived items in count * @param includeWithdrawn whether to include withdrawn items in count * @return item count - * @throws SQLException + * @throws SQLException if database error */ public int countItems(Context context, Collection collection, boolean includeArchived, boolean includeWithdrawn) throws SQLException; @@ -73,23 +74,24 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO * {@link org.dspace.content.service.CommunityService#getAllCollections(Context,Community)} * to determine the unique number of items in a Community. * - * @param context + * @param context context * @param collections the list of collections * @param includeArchived whether to include archived items in count * @param includeWithdrawn whether to include withdrawn items in count * @return item count - * @throws SQLException + * @throws SQLException if database error */ public int countItems(Context context, List collections, boolean includeArchived, boolean includeWithdrawn) throws SQLException; /** * Get all Items installed or withdrawn, discoverable, and modified since a Date. - * @param context - * @param archived - * @param withdrawn - * @param discoverable + * @param context context + * @param archived whether to find archived + * @param withdrawn whether to find withdrawn + * @param discoverable whether to find discoverable * @param lastModified earliest interesting last-modified date. - * @return + * @return iterator over items + * @throws SQLException if database error */ public Iterator findAll(Context context, boolean archived, boolean withdrawn, boolean discoverable, Date lastModified) @@ -97,19 +99,19 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO /** * Count total number of items (rows in item table) - * @param context + * @param context context * @return total count - * @throws SQLException + * @throws SQLException if database error */ int countRows(Context context) throws SQLException; /** * Count number of items based on specific status flags - * @param context + * @param context context * @param includeArchived whether to include archived items in count * @param includeWithdrawn whether to include withdrawn items in count * @return count of items - * @throws SQLException + * @throws SQLException if database error */ int countItems(Context context, boolean includeArchived, boolean includeWithdrawn) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/content/dao/MetadataFieldDAO.java b/dspace-api/src/main/java/org/dspace/content/dao/MetadataFieldDAO.java index 0338ab630d..47388761f0 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/MetadataFieldDAO.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/MetadataFieldDAO.java @@ -18,7 +18,7 @@ import java.util.List; /** * Database Access Object interface class for the MetadataField object. * The implementation of this class is responsible for all database calls for the MetadataField object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/content/dao/MetadataSchemaDAO.java b/dspace-api/src/main/java/org/dspace/content/dao/MetadataSchemaDAO.java index 5621234712..16cf18de5a 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/MetadataSchemaDAO.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/MetadataSchemaDAO.java @@ -16,7 +16,7 @@ import java.sql.SQLException; /** * Database Access Object interface class for the MetadataSchema object. * The implementation of this class is responsible for all database calls for the MetadataSchema object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/content/dao/MetadataValueDAO.java b/dspace-api/src/main/java/org/dspace/content/dao/MetadataValueDAO.java index 2e5967fa5e..212a7fe666 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/MetadataValueDAO.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/MetadataValueDAO.java @@ -18,7 +18,7 @@ import java.util.List; /** * Database Access Object interface class for the MetadataValue object. * The implementation of this class is responsible for all database calls for the MetadataValue object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ @@ -34,4 +34,5 @@ public interface MetadataValueDAO extends GenericDAO { throws SQLException; int countRows(Context context) throws SQLException; + } diff --git a/dspace-api/src/main/java/org/dspace/content/dao/SiteDAO.java b/dspace-api/src/main/java/org/dspace/content/dao/SiteDAO.java index f2b13db98a..da35c10a49 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/SiteDAO.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/SiteDAO.java @@ -9,14 +9,13 @@ package org.dspace.content.dao; import org.dspace.content.Site; import org.dspace.core.Context; -import org.dspace.core.GenericDAO; import java.sql.SQLException; /** * Database Access Object interface class for the Site object. * The implementation of this class is responsible for all database calls for the Site object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/content/dao/WorkspaceItemDAO.java b/dspace-api/src/main/java/org/dspace/content/dao/WorkspaceItemDAO.java index d03baa4408..4d9f536c04 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/WorkspaceItemDAO.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/WorkspaceItemDAO.java @@ -21,7 +21,7 @@ import java.util.Map; /** * Database Access Object interface class for the WorkspaceItem object. * The implementation of this class is responsible for all database calls for the WorkspaceItem object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/content/dao/impl/BitstreamFormatDAOImpl.java b/dspace-api/src/main/java/org/dspace/content/dao/impl/BitstreamFormatDAOImpl.java index 7768cd8ddd..c25c198785 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/impl/BitstreamFormatDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/impl/BitstreamFormatDAOImpl.java @@ -43,10 +43,11 @@ public class BitstreamFormatDAOImpl extends AbstractHibernateDAOnull if * there's no bitstream format with the given MIMEtype. - * @throws java.sql.SQLException + * @throws SQLException if database error */ @Override public BitstreamFormat findByMIMEType(Context context, String mimeType, boolean includeInternal) throws SQLException @@ -72,7 +73,7 @@ public class BitstreamFormatDAOImpl extends AbstractHibernateDAOnull if * there's no bitstream format with the given short description - * @throws java.sql.SQLException + * @throws SQLException if database error */ @Override public BitstreamFormat findByShortDescription(Context context, diff --git a/dspace-api/src/main/java/org/dspace/content/dao/impl/CollectionDAOImpl.java b/dspace-api/src/main/java/org/dspace/content/dao/impl/CollectionDAOImpl.java index 21d72281db..8426bac072 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/impl/CollectionDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/impl/CollectionDAOImpl.java @@ -47,9 +47,9 @@ public class CollectionDAOImpl extends AbstractHibernateDSODAO imple * * @param context * DSpace context object - * + * @param order order by MetadataField * @return the collections in the system - * @throws java.sql.SQLException + * @throws SQLException if database error */ @Override public List findAll(Context context, MetadataField order) throws SQLException @@ -72,7 +72,7 @@ public class CollectionDAOImpl extends AbstractHibernateDSODAO imple if(limit != null){ hibernateQuery.setMaxResults(limit); } - hibernateQuery.setParameter(order.toString(), order.getFieldID()); + hibernateQuery.setParameter(order.toString(), order.getID()); return list(hibernateQuery); } diff --git a/dspace-api/src/main/java/org/dspace/content/dao/impl/CommunityDAOImpl.java b/dspace-api/src/main/java/org/dspace/content/dao/impl/CommunityDAOImpl.java index 47fd0f9e58..6faf24eba1 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/impl/CommunityDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/impl/CommunityDAOImpl.java @@ -43,10 +43,11 @@ public class CommunityDAOImpl extends AbstractHibernateDSODAO impleme * Get a list of all communities in the system. These are alphabetically * sorted by community name. * - * @param context - * DSpace context object + * @param context DSpace context object + * @param sortField sort field * * @return the communities in the system + * @throws SQLException if database error */ @Override public List findAll(Context context, MetadataField sortField) throws SQLException @@ -69,7 +70,7 @@ public class CommunityDAOImpl extends AbstractHibernateDSODAO impleme if(limit != null){ query.setMaxResults(limit); } - query.setParameter(sortField.toString(), sortField.getFieldID()); + query.setParameter(sortField.toString(), sortField.getID()); return list(query); } @@ -89,7 +90,7 @@ public class CommunityDAOImpl extends AbstractHibernateDSODAO impleme addMetadataSortQuery(queryBuilder, Arrays.asList(sortField), ListUtils.EMPTY_LIST); Query query = createQuery(context, queryBuilder.toString()); - query.setParameter(sortField.toString(), sortField.getFieldID()); + query.setParameter(sortField.toString(), sortField.getID()); return findMany(context, query); } diff --git a/dspace-api/src/main/java/org/dspace/content/dao/impl/ItemDAOImpl.java b/dspace-api/src/main/java/org/dspace/content/dao/impl/ItemDAOImpl.java index 4f8b21487e..8540fd88ad 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/impl/ItemDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/impl/ItemDAOImpl.java @@ -107,7 +107,7 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO implements ItemDA addMetadataSortQuery(query, Collections.singletonList(metadataField), null); Query hibernateQuery = createQuery(context, query.toString()); - hibernateQuery.setParameter(metadataField.toString(), metadataField.getFieldID()); + hibernateQuery.setParameter(metadataField.toString(), metadataField.getID()); hibernateQuery.setParameter("in_archive", true); hibernateQuery.setParameter("submitter", eperson); hibernateQuery.setMaxResults(limit); @@ -244,6 +244,9 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO implements ItemDA @Override public int countItems(Context context, List collections, boolean includeArchived, boolean includeWithdrawn) throws SQLException { + if (collections.size() == 0) { + return 0; + } Query query = createQuery(context, "select count(distinct i) from Item i " + "join i.collections collection " + "WHERE collection IN (:collections) AND i.inArchive=:in_archive AND i.withdrawn=:withdrawn"); diff --git a/dspace-api/src/main/java/org/dspace/content/dao/impl/MetadataFieldDAOImpl.java b/dspace-api/src/main/java/org/dspace/content/dao/impl/MetadataFieldDAOImpl.java index c0de3200a6..8902a89c5c 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/impl/MetadataFieldDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/impl/MetadataFieldDAOImpl.java @@ -10,11 +10,12 @@ package org.dspace.content.dao.impl; import org.dspace.content.MetadataField; import org.dspace.content.MetadataSchema; import org.dspace.content.dao.MetadataFieldDAO; -import org.dspace.core.Context; import org.dspace.core.AbstractHibernateDAO; +import org.dspace.core.Context; import org.hibernate.Criteria; +import org.hibernate.FetchMode; +import org.hibernate.Query; import org.hibernate.criterion.Order; -import org.hibernate.criterion.Restrictions; import java.sql.SQLException; import java.util.List; @@ -36,85 +37,110 @@ public class MetadataFieldDAOImpl extends AbstractHibernateDAO im @Override public MetadataField find(Context context, int metadataFieldId, MetadataSchema metadataSchema, String element, String qualifier) throws SQLException{ - Criteria criteria = createCriteria(context, MetadataField.class); - criteria.add( - Restrictions.and( - Restrictions.not(Restrictions.eq("id", metadataFieldId)), - Restrictions.eq("metadataSchema.id", metadataSchema.getSchemaID()), - Restrictions.eq("element", element), - Restrictions.eqOrIsNull("qualifier", qualifier) - ) - ); - criteria.setCacheable(true); + Query query; - return singleResult(criteria); + if(qualifier != null) { + query = createQuery(context, "SELECT mf " + + "FROM MetadataField mf " + + "JOIN FETCH mf.metadataSchema ms " + + "WHERE mf.id != :id " + + "AND ms.name = :name AND mf.element = :element " + + "AND qualifier = :qualifier"); + } else { + query = createQuery(context, "SELECT mf " + + "FROM MetadataField mf " + + "JOIN FETCH mf.metadataSchema ms " + + "WHERE mf.id != :id " + + "AND ms.name = :name AND mf.element = :element " + + "AND mf.qualifier IS NULL"); + } + + query.setParameter("id", metadataFieldId); + query.setParameter("name", metadataSchema.getName()); + query.setParameter("element", element); + + if(qualifier != null) { + query.setParameter("qualifier", qualifier); + } + + query.setCacheable(true); + return singleResult(query); } @Override public MetadataField findByElement(Context context, MetadataSchema metadataSchema, String element, String qualifier) throws SQLException { - Criteria criteria = createCriteria(context, MetadataField.class); - criteria.add( - Restrictions.and( - Restrictions.eq("metadataSchema.id", metadataSchema.getSchemaID()), - Restrictions.eq("element", element), - Restrictions.eqOrIsNull("qualifier", qualifier) - ) - ); - criteria.setCacheable(true); + return findByElement(context, metadataSchema.getName(), element, qualifier); + } - return singleResult(criteria); + @Override + public MetadataField findByElement(Context context, String metadataSchema, String element, String qualifier) throws SQLException + { + Query query; + + if(qualifier != null) { + query = createQuery(context, "SELECT mf " + + "FROM MetadataField mf " + + "JOIN FETCH mf.metadataSchema ms " + + "WHERE ms.name = :name AND mf.element = :element " + + "AND qualifier = :qualifier"); + } else { + query = createQuery(context, "SELECT mf " + + "FROM MetadataField mf " + + "JOIN FETCH mf.metadataSchema ms " + + "WHERE ms.name = :name AND mf.element = :element " + + "AND mf.qualifier IS NULL"); + } + + query.setParameter("name", metadataSchema); + query.setParameter("element", element); + + if(qualifier != null) { + query.setParameter("qualifier", qualifier); + } + + query.setCacheable(true); + return singleResult(query); } @Override public List findAll(Context context, Class clazz) throws SQLException { Criteria criteria = createCriteria(context, MetadataField.class); criteria.createAlias("metadataSchema", "s").addOrder(Order.asc("s.name")).addOrder(Order.asc("element")).addOrder(Order.asc("qualifier")); + criteria.setFetchMode("metadataSchema", FetchMode.JOIN); criteria.setCacheable(true); return list(criteria); } - @Override - public MetadataField findByElement(Context context, String metadataSchema, String element, String qualifier) throws SQLException - { - Criteria criteria = createCriteria(context, MetadataField.class); - criteria.createAlias("metadataSchema", "s").add( - Restrictions.and( - Restrictions.eq("s.name", metadataSchema), - Restrictions.eq("element", element), - Restrictions.eqOrIsNull("qualifier", qualifier) - ) - ); - criteria.setCacheable(true); - - return singleResult(criteria); - } - @Override public List findFieldsByElementNameUnqualified(Context context, String metadataSchema, String element) throws SQLException { - Criteria criteria = createCriteria(context, MetadataField.class); - criteria.createAlias("metadataSchema", "s").add( - Restrictions.and( - Restrictions.eq("s.name", metadataSchema), - Restrictions.eq("element", element) - ) - ); - criteria.setCacheable(true); + Query query = createQuery(context, "SELECT mf " + + "FROM MetadataField mf " + + "JOIN FETCH mf.metadataSchema ms " + + "WHERE ms.name = :name AND mf.element = :element "); - return list(criteria); + + query.setParameter("name", metadataSchema); + query.setParameter("element", element); + + query.setCacheable(true); + return list(query); } @Override public List findAllInSchema(Context context, MetadataSchema metadataSchema) throws SQLException { - // Get all the metadatafieldregistry rows - Criteria criteria = createCriteria(context, MetadataField.class); - criteria.createAlias("metadataSchema", "s"); - criteria.add(Restrictions.eq("s.id", metadataSchema.getSchemaID())); - criteria.addOrder(Order.asc("s.name")).addOrder(Order.asc("element")).addOrder(Order.asc("qualifier")); - criteria.setCacheable(true); - return list(criteria); + Query query = createQuery(context, "SELECT mf " + + "FROM MetadataField mf " + + "JOIN FETCH mf.metadataSchema ms " + + "WHERE ms.name = :name " + + "ORDER BY mf.element ASC, mf.qualifier ASC "); + + query.setParameter("name", metadataSchema.getName()); + + query.setCacheable(true); + return list(query); } } diff --git a/dspace-api/src/main/java/org/dspace/content/dao/impl/MetadataSchemaDAOImpl.java b/dspace-api/src/main/java/org/dspace/content/dao/impl/MetadataSchemaDAOImpl.java index 5747bbd4dc..2aa71e2631 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/impl/MetadataSchemaDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/impl/MetadataSchemaDAOImpl.java @@ -9,11 +9,11 @@ package org.dspace.content.dao.impl; import org.dspace.content.MetadataSchema; import org.dspace.content.dao.MetadataSchemaDAO; -import org.dspace.core.Context; import org.dspace.core.AbstractHibernateDAO; +import org.dspace.core.Context; import org.hibernate.Criteria; +import org.hibernate.Query; import org.hibernate.criterion.Order; -import org.hibernate.criterion.Restrictions; import java.sql.SQLException; import java.util.List; @@ -38,17 +38,20 @@ public class MetadataSchemaDAOImpl extends AbstractHibernateDAO * @param context DSpace context * @param namespace namespace URI to match * @return metadata schema object or null if none found. - * @throws java.sql.SQLException + * @throws SQLException if database error */ @Override public MetadataSchema findByNamespace(Context context, String namespace) throws SQLException { // Grab rows from DB - Criteria criteria = createCriteria(context, MetadataSchema.class); - criteria.add(Restrictions.eq("namespace", namespace)); - criteria.setCacheable(true); + Query query = createQuery(context, + "SELECT ms FROM MetadataSchema ms " + + "WHERE ms.namespace = :namespace "); - return uniqueResult(criteria); + query.setParameter("namespace", namespace); + + query.setCacheable(true); + return singleResult(query); } @Override @@ -66,42 +69,46 @@ public class MetadataSchemaDAOImpl extends AbstractHibernateDAO * number of times in the current schema. * * @param context DSpace context + * @param metadataSchemaId schema id * @param namespace namespace URI to match * @return true of false - * @throws java.sql.SQLException + * @throws SQLException if database error */ @Override public boolean uniqueNamespace(Context context, int metadataSchemaId, String namespace) throws SQLException { - Criteria criteria = createCriteria(context, MetadataSchema.class); - criteria.add(Restrictions.and( - Restrictions.not(Restrictions.eq("id", metadataSchemaId)), - Restrictions.eq("namespace", namespace) - )); - criteria.setCacheable(true); + Query query = createQuery(context, + "SELECT ms FROM MetadataSchema ms " + + "WHERE ms.namespace = :namespace and ms.id != :id"); - return uniqueResult(criteria) == null; + query.setParameter("namespace", namespace); + query.setParameter("id", metadataSchemaId); + + query.setCacheable(true); + return singleResult(query) == null; } /** * Return true if and only if the passed name is unique. * * @param context DSpace context + * @param metadataSchemaId schema id * @param name short name of schema * @return true of false - * @throws java.sql.SQLException + * @throws SQLException if database error */ @Override public boolean uniqueShortName(Context context, int metadataSchemaId, String name) throws SQLException { - Criteria criteria = createCriteria(context, MetadataSchema.class); - criteria.add(Restrictions.and( - Restrictions.not(Restrictions.eq("id", metadataSchemaId)), - Restrictions.eq("name", name) - )); - criteria.setCacheable(true); + Query query = createQuery(context, + "SELECT ms FROM MetadataSchema ms " + + "WHERE ms.name = :name and ms.id != :id"); - return uniqueResult(criteria) == null; + query.setParameter("name", name); + query.setParameter("id", metadataSchemaId); + + query.setCacheable(true); + return singleResult(query) == null; } /** @@ -112,17 +119,18 @@ public class MetadataSchemaDAOImpl extends AbstractHibernateDAO * @param shortName * the short name for the schema * @return the metadata schema object - * @throws java.sql.SQLException + * @throws SQLException if database error */ @Override public MetadataSchema find(Context context, String shortName) throws SQLException { - Criteria criteria = createCriteria(context, MetadataSchema.class); - criteria.add( - Restrictions.eq("name", shortName) - ); - criteria.setCacheable(true); + Query query = createQuery(context, + "SELECT ms FROM MetadataSchema ms " + + "WHERE ms.name = :name"); - return uniqueResult(criteria); + query.setParameter("name", shortName); + + query.setCacheable(true); + return singleResult(query); } } diff --git a/dspace-api/src/main/java/org/dspace/content/dao/impl/MetadataValueDAOImpl.java b/dspace-api/src/main/java/org/dspace/content/dao/impl/MetadataValueDAOImpl.java index 59a13bcd82..aed022b5b9 100644 --- a/dspace-api/src/main/java/org/dspace/content/dao/impl/MetadataValueDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/content/dao/impl/MetadataValueDAOImpl.java @@ -10,9 +10,10 @@ package org.dspace.content.dao.impl; import org.dspace.content.MetadataField; import org.dspace.content.MetadataValue; import org.dspace.content.dao.MetadataValueDAO; -import org.dspace.core.Context; import org.dspace.core.AbstractHibernateDAO; +import org.dspace.core.Context; import org.hibernate.Criteria; +import org.hibernate.FetchMode; import org.hibernate.Query; import org.hibernate.criterion.Restrictions; @@ -39,8 +40,10 @@ public class MetadataValueDAOImpl extends AbstractHibernateDAO im { Criteria criteria = createCriteria(context, MetadataValue.class); criteria.add( - Restrictions.eq("metadataField", metadataField) + Restrictions.eq("metadataField.id", metadataField.getID()) ); + criteria.setFetchMode("metadataField", FetchMode.JOIN); + return list(criteria); } @@ -50,6 +53,8 @@ public class MetadataValueDAOImpl extends AbstractHibernateDAO im criteria.add( Restrictions.like("value", "%" + value + "%") ); + criteria.setFetchMode("metadataField", FetchMode.JOIN); + return list(criteria); } @@ -65,7 +70,7 @@ public class MetadataValueDAOImpl extends AbstractHibernateDAO im public MetadataValue getMinimum(Context context, int metadataFieldId) throws SQLException { - String queryString = "SELECT m FROM MetadataValue m WHERE metadata_field_id = :metadata_field_id ORDER BY text_value"; + String queryString = "SELECT m FROM MetadataValue m JOIN FETCH m.metadataField WHERE m.metadataField.id = :metadata_field_id ORDER BY text_value"; Query query = createQuery(context, queryString); query.setParameter("metadata_field_id", metadataFieldId); query.setMaxResults(1); @@ -76,4 +81,5 @@ public class MetadataValueDAOImpl extends AbstractHibernateDAO im public int countRows(Context context) throws SQLException { return count(createQuery(context, "SELECT count(*) FROM MetadataValue")); } + } diff --git a/dspace-api/src/main/java/org/dspace/content/packager/AbstractMETSDisseminator.java b/dspace-api/src/main/java/org/dspace/content/packager/AbstractMETSDisseminator.java index a80ba481b3..eb36bafc47 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/AbstractMETSDisseminator.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/AbstractMETSDisseminator.java @@ -86,7 +86,7 @@ import org.jdom.output.XMLOutputter; /** * Base class for disseminator of - * METS (Metadata Encoding & Transmission Standard) Package.
+ * METS (Metadata Encoding and Transmission Standard) Package.
* See http://www.loc.gov/standards/mets/ *

* This is a generic packager framework intended to be subclassed to create @@ -227,6 +227,10 @@ public abstract class AbstractMETSDisseminator * @param pkgFile File where export package should be written * @throws PackageValidationException if package cannot be created or there * is a fatal error in creating it. + * @throws CrosswalkException if crosswalk error + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error */ @Override public void disseminate(Context context, DSpaceObject dso, @@ -305,10 +309,12 @@ public abstract class AbstractMETSDisseminator * @param dso The DSpace Object * @param params Parameters to the Packager script * @param pkg Package output stream - * @throws PackageValidationException - * @throws AuthorizeException - * @throws SQLException - * @throws IOException + * @throws PackageValidationException if package validation error + * @throws CrosswalkException if crosswalk error + * @throws AuthorizeException if authorization error + * @throws MetsException if METS error + * @throws SQLException if database error + * @throws IOException if IO error */ protected void writeZipPackage(Context context, DSpaceObject dso, PackageParameters params, OutputStream pkg) @@ -409,6 +415,10 @@ public abstract class AbstractMETSDisseminator * @param dso The DSpace Object * @param params Parameters to the Packager script * @param zip Zip output + * @throws PackageValidationException if validation error + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error */ protected void addBitstreamsToZip(Context context, DSpaceObject dso, PackageParameters params, ZipOutputStream zip) @@ -552,11 +562,11 @@ public abstract class AbstractMETSDisseminator * * @return mdSec element or null if xwalk returns empty results. * - * @throws SQLException - * @throws PackageValidationException - * @throws CrosswalkException - * @throws IOException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws PackageValidationException if package validation error + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error */ protected MdSec makeMdSec(Context context, DSpaceObject dso, Class mdSecClass, String typeSpec, PackageParameters params, @@ -786,6 +796,17 @@ public abstract class AbstractMETSDisseminator /** * Write out a METS manifest. * Mostly lifted from Rob Tansley's METS exporter. + * @param context context + * @param dso DSpaceObject + * @param params packaging params + * @param extraStreams streams + * @return METS manifest + * @throws MetsException if mets error + * @throws PackageValidationException if validation error + * @throws CrosswalkException if crosswalk error + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error */ protected Mets makeManifest(Context context, DSpaceObject dso, PackageParameters params, @@ -1190,12 +1211,12 @@ public abstract class AbstractMETSDisseminator } /** - * Create a

element with which references a child + * Create a {@code
} element with {@code } which references a child * object via its handle (and via a local file name, when recursively disseminating * all child objects). - * @param type - type attr value for the
+ * @param type - type attr value for the {@code
} * @param dso - object for which to create the div - * @param params + * @param params package params * @return a new {@code Div} with {@code dso} as child. */ protected Div makeChildDiv(String type, DSpaceObject dso, PackageParameters params) @@ -1260,6 +1281,7 @@ public abstract class AbstractMETSDisseminator * the derived bitstream * * @return the corresponding original bitstream (or null) + * @throws SQLException if database error */ protected Bitstream findOriginalBitstream(Item item, Bitstream derived) throws SQLException @@ -1356,12 +1378,12 @@ public abstract class AbstractMETSDisseminator } /** - * Cleanup our license file reference links, as Deposit Licenses & CC Licenses can be + * Cleanup our license file reference links, as Deposit Licenses and CC Licenses can be * added two ways (and we only want to add them to zip package *once*): * (1) Added as a normal Bitstream (assuming LICENSE and CC_LICENSE bundles will be included in pkg) * (2) Added via a 'rightsMD' crosswalk (as they are rights information/metadata on an Item) *

- * So, if they are being added by *both*, then we want to just link the rightsMD entry so + * So, if they are being added by *both*, then we want to just link the rightsMD {@code } entry so * that it points to the Bitstream location. This implementation is a bit 'hackish', but it's * the best we can do, as the Harvard METS API doesn't allow us to go back and crawl an entire * METS file to look for these inconsistencies/duplications. @@ -1369,10 +1391,10 @@ public abstract class AbstractMETSDisseminator * @param context current DSpace Context * @param params current Packager Parameters * @param dso current DSpace Object - * @param mdRef the rightsMD element - * @throws SQLException - * @throws IOException - * @throws AuthorizeException + * @param mdRef the rightsMD {@code } element + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error */ protected void linkLicenseRefsToBitstreams(Context context, PackageParameters params, DSpaceObject dso, MdRef mdRef) @@ -1475,9 +1497,11 @@ public abstract class AbstractMETSDisseminator * For a manifest-only METS, this is a reference to an HTTP URL where * the bitstream should be able to be downloaded from. * + * @param context context * @param bitstream the Bitstream * @param params Packager Parameters * @return String in URL format naming path to bitstream. + * @throws SQLException if database error */ public String makeBitstreamURL(Context context, Bitstream bitstream, PackageParameters params) throws SQLException { // if bare manifest, use external "persistent" URI for bitstreams @@ -1541,6 +1565,11 @@ public abstract class AbstractMETSDisseminator /** * Create metsHdr element - separate so subclasses can override. + * @param context context + * @param dso DSpaceObject + * @param params packaging params + * @return Mets header + * @throws SQLException if database error */ public abstract MetsHdr makeMetsHdr(Context context, DSpaceObject dso, PackageParameters params) throws SQLException; @@ -1568,8 +1597,13 @@ public abstract class AbstractMETSDisseminator * E.g. the type string "DC:qualifiedDublinCore" tells it to * create a METS section with MDTYPE="DC" and use the plugin * named "qualifiedDublinCore" to obtain the data. + * @param context context + * @param dso DSpaceObject * @param params the PackageParameters passed to the disseminator. * @return array of metadata type strings, never null. + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public abstract String [] getDmdTypes(Context context, DSpaceObject dso, PackageParameters params) throws SQLException, IOException, AuthorizeException; @@ -1579,8 +1613,13 @@ public abstract class AbstractMETSDisseminator * object and each Bitstream in an Item. The type string may be a * simple name or colon-separated compound as specified for * getDmdTypes() above. + * @param context context + * @param dso DSpaceObject * @param params the PackageParameters passed to the disseminator. * @return array of metadata type strings, never null. + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public abstract String[] getTechMdTypes(Context context, DSpaceObject dso, PackageParameters params) throws SQLException, IOException, AuthorizeException; @@ -1590,8 +1629,13 @@ public abstract class AbstractMETSDisseminator * object and each Bitstream in an Item. The type string may be a * simple name or colon-separated compound as specified for * getDmdTypes() above. + * @param context context + * @param dso DSpaceObject * @param params the PackageParameters passed to the disseminator. * @return array of metadata type strings, never null. + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public abstract String[] getSourceMdTypes(Context context, DSpaceObject dso, PackageParameters params) throws SQLException, IOException, AuthorizeException; @@ -1602,8 +1646,13 @@ public abstract class AbstractMETSDisseminator * The type string may be a simple name or colon-separated compound * as specified for getDmdTypes() above. * + * @param context context + * @param dso DSpaceObject * @param params the PackageParameters passed to the disseminator. * @return array of metadata type strings, never null. + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public abstract String[] getDigiprovMdTypes(Context context, DSpaceObject dso, PackageParameters params) throws SQLException, IOException, AuthorizeException; @@ -1614,8 +1663,13 @@ public abstract class AbstractMETSDisseminator * The type string may be a simple name or colon-separated compound * as specified for getDmdTypes() above. * + * @param context context + * @param dso DSpaceObject * @param params the PackageParameters passed to the disseminator. * @return array of metadata type strings, never null. + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public abstract String[] getRightsMdTypes(Context context, DSpaceObject dso, PackageParameters params) throws SQLException, IOException, AuthorizeException; @@ -1625,13 +1679,21 @@ public abstract class AbstractMETSDisseminator * METS document, as required by this subclass. A simple default * structure map which fulfills the minimal DSpace METS DIP/SIP * requirements is already present, so this does not need to do anything. + * @param context context + * @param dso DSpaceObject * @param mets the METS document to which to add structMaps + * @param params the PackageParameters passed to the disseminator. + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws MetsException if METS error */ public abstract void addStructMap(Context context, DSpaceObject dso, PackageParameters params, Mets mets) throws SQLException, IOException, AuthorizeException, MetsException; /** + * @param bundle bundle * @return true when this bundle should be included as "content" * in the package.. e.g. DSpace SIP does not include metadata bundles. */ diff --git a/dspace-api/src/main/java/org/dspace/content/packager/AbstractMETSIngester.java b/dspace-api/src/main/java/org/dspace/content/packager/AbstractMETSIngester.java index d81cfa288b..14ed4237ef 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/AbstractMETSIngester.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/AbstractMETSIngester.java @@ -38,7 +38,7 @@ import org.dspace.workflow.factory.WorkflowServiceFactory; import org.jdom.Element; /** - * Base class for package ingester of METS (Metadata Encoding & Transmission + * Base class for package ingester of METS (Metadata Encoding and Transmission * Standard) Packages.
* See * http://www.loc.gov/standards/mets/. @@ -136,6 +136,8 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * @param mdref * the METS mdRef element to locate the input for. * @return the input stream of its content. + * @throws MetadataValidationException if validation error + * @throws IOException if IO error * @see METSManifest */ @Override @@ -178,13 +180,14 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * may be null, which takes default license. * @return DSpaceObject created by ingest. * - * @throws PackageValidationException + * @throws PackageValidationException if package validation error * if package is unacceptable or there is a fatal error turning * it into a DSpaceObject. - * @throws CrosswalkException - * @throws AuthorizeException - * @throws SQLException - * @throws IOException + * @throws CrosswalkException if crosswalk error + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error + * @throws WorkflowException if workflow error */ @Override public DSpaceObject ingest(Context context, DSpaceObject parent, @@ -301,10 +304,10 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * @param params * Ingestion parameters * @return parsed out METSManifest - * @throws IOException - * @throws SQLException - * @throws AuthorizeException - * @throws MetadataValidationException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws MetadataValidationException if metadata validation error */ protected METSManifest parsePackage(Context context, File pkgFile, PackageParameters params) throws IOException, SQLException, @@ -366,12 +369,13 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * @param license * DSpace license agreement * @return completed result as a DSpace object - * @throws IOException - * @throws SQLException - * @throws AuthorizeException - * @throws CrosswalkException - * @throws MetadataValidationException - * @throws PackageValidationException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws CrosswalkException if crosswalk error + * @throws MetadataValidationException if metadata validation error + * @throws WorkflowException if workflow error + * @throws PackageValidationException if package validation error */ protected DSpaceObject ingestObject(Context context, DSpaceObject parent, METSManifest manifest, File pkgFile, PackageParameters params, @@ -581,12 +585,12 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * @param license * DSpace license agreement * @return completed result as a DSpace object - * @throws IOException - * @throws SQLException - * @throws AuthorizeException - * @throws CrosswalkException - * @throws MetadataValidationException - * @throws PackageValidationException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws CrosswalkException if crosswalk error + * @throws MetadataValidationException if metadata validation error + * @throws PackageValidationException if package validation error */ protected DSpaceObject replaceObject(Context context, DSpaceObject dso, METSManifest manifest, File pkgFile, PackageParameters params, @@ -627,7 +631,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester // clear out all metadata values associated with this object PackageUtils.clearAllMetadata(context, dso); - // @TODO -- We are currently NOT clearing out the following during a + // TODO -- We are currently NOT clearing out the following during a // replace. So, even after a replace, the following information may be // retained in the system: // o Rights/Permissions in system or on objects @@ -737,12 +741,12 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * Ingestion Parameters * @param mdRefCallback * MdrefManager storing info about mdRefs in manifest - * @throws SQLException - * @throws IOException - * @throws AuthorizeException - * @throws MetadataValidationException - * @throws CrosswalkException - * @throws PackageValidationException + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error + * @throws MetadataValidationException if metadata validation error + * @throws CrosswalkException if crosswalk error + * @throws PackageValidationException if package validation error */ protected void addBitstreams(Context context, Item item, METSManifest manifest, File pkgFile, PackageParameters params, @@ -910,9 +914,10 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * DSpace Item * @param manifest * The METS Manifest - * @throws SQLException - * @throws AuthorizeException - * @throws PackageValidationException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws PackageValidationException if package validation error */ protected void addManifestBitstream(Context context, Item item, METSManifest manifest) throws IOException, SQLException, @@ -958,11 +963,11 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * zip) * @param params * Ingestion Parameters - * @throws SQLException - * @throws IOException - * @throws AuthorizeException - * @throws MetadataValidationException - * @throws PackageValidationException + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error + * @throws MetadataValidationException if metadata validation error + * @throws PackageValidationException if package validation error */ protected void addContainerLogo(Context context, DSpaceObject dso, METSManifest manifest, File pkgFile, PackageParameters params) @@ -1026,11 +1031,11 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * @param callback * the MdrefManager (manages all external metadata files * referenced by METS mdref elements) - * @throws SQLException - * @throws IOException - * @throws AuthorizeException - * @throws MetadataValidationException - * @throws PackageValidationException + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error + * @throws MetadataValidationException if metadata validation error + * @throws PackageValidationException if package validation error */ protected void addTemplateItem(Context context, DSpaceObject dso, METSManifest manifest, File pkgFile, PackageParameters params, @@ -1110,13 +1115,14 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * @param params * Parameters passed from the packager script * @return DSpaceObject created by ingest. - * @throws PackageValidationException + * @throws PackageValidationException if package validation error * if package is unacceptable or there is a fatal error turning * it into a DSpace Object. - * @throws IOException - * @throws SQLException - * @throws AuthorizeException - * @throws CrosswalkException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws CrosswalkException if crosswalk error + * @throws WorkflowException if workflow error */ @Override public DSpaceObject replace(Context context, DSpaceObject dsoToReplace, @@ -1297,8 +1303,12 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester /** * Remove an existing DSpace Object (called during a replace) * + * @param context context * @param dso * DSpace Object + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ protected void removeObject(Context context, DSpaceObject dso) throws AuthorizeException, SQLException, IOException @@ -1343,10 +1353,10 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * @param manifest * METS manifest * @return a DSpace Object which is the parent (or null, if not found) - * @throws PackageValidationException + * @throws PackageValidationException if package validation error * if parent reference cannot be found in manifest - * @throws MetadataValidationException - * @throws SQLException + * @throws MetadataValidationException if metadata validation error + * @throws SQLException if database error */ public DSpaceObject getParentObject(Context context, METSManifest manifest) throws PackageValidationException, MetadataValidationException, @@ -1394,8 +1404,10 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * @param manifest * METS manifest * @return handle as a string (or null, if not found) - * @throws PackageValidationException + * @throws PackageValidationException if package validation error * if handle cannot be found in manifest + * @throws MetadataValidationException if validation error + * @throws SQLException if database error */ public String getObjectHandle(METSManifest manifest) throws PackageValidationException, MetadataValidationException, @@ -1429,6 +1441,8 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * @param path * the File path (either path in Zip package or a URL) * @return the InputStream for the file + * @throws MetadataValidationException if validation error + * @throws IOException if IO error */ protected static InputStream getFileInputStream(File pkgFile, PackageParameters params, String path) @@ -1510,7 +1524,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * access the METS document through the manifest variable, an * instance of METSManifest. * - * @throws MetadataValidationException + * @throws MetadataValidationException if metadata validation error * if there is a fatal problem with the METS document's * conformance to the expected profile. */ @@ -1531,10 +1545,9 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * Note that item and manifest are available as * protected fields from the superclass. * - * @param context - * the DSpace context - * @param manifest - * the METSManifest + * @param context the DSpace context + * @param dso DSpace Object + * @param manifest the METSManifest * @param callback * the MdrefManager (manages all external metadata files * referenced by METS mdref elements) @@ -1542,6 +1555,11 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * array of Elements, each a METS dmdSec that * applies to the Item as a whole. * @param params + * @throws CrosswalkException if crosswalk error + * @throws PackageValidationException if package validation error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public abstract void crosswalkObjectDmd(Context context, DSpaceObject dso, METSManifest manifest, MdrefManager callback, Element dmds[], @@ -1566,10 +1584,16 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * * @param context * the DSpace context + * @param item Item * @param collection * DSpace Collection to which the item is being submitted. * @param license * optional user-supplied Deposit License text (may be null) + * @param params + * @throws PackageValidationException if package validation error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public abstract void addLicense(Context context, Item item, String license, Collection collection, PackageParameters params) @@ -1588,6 +1612,11 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * the DSpace Object * @param params * the Packager Parameters + * @throws CrosswalkException if crosswalk error + * @throws PackageValidationException if package validation error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public abstract void finishObject(Context context, DSpaceObject dso, PackageParameters params) throws PackageValidationException, @@ -1596,7 +1625,9 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester /** * Determines what type of DSpace object is represented in this METS doc. * + * @param manifest METS manifest * @return one of the object types in Constants. + * @throws PackageValidationException if package validation error */ public abstract int getObjectType(METSManifest manifest) throws PackageValidationException; @@ -1604,6 +1635,15 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester /** * Subclass-dependent final processing on a Bitstream; could include fixing * up the name, bundle, other attributes. + * @param context context + * @param manifest METS manifest + * @param bs bitstream + * @param mfile element + * @param params package params + * @throws MetadataValidationException if validation error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public abstract void finishBitstream(Context context, Bitstream bs, Element mfile, METSManifest manifest, PackageParameters params) @@ -1614,6 +1654,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester * Returns keyword that makes the configuration keys of this subclass * unique, e.g. if it returns NAME, the key would be: * "mets.NAME.ingest.preserveManifest = true" + * @return name */ public abstract String getConfigurationName(); diff --git a/dspace-api/src/main/java/org/dspace/content/packager/AbstractPackageDisseminator.java b/dspace-api/src/main/java/org/dspace/content/packager/AbstractPackageDisseminator.java index 36e0a2de3f..8e06918438 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/AbstractPackageDisseminator.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/AbstractPackageDisseminator.java @@ -40,7 +40,7 @@ import java.util.List; * * @author Tim Donohue * @see PackageDisseminator - * @see PluginService + * @see org.dspace.core.service.PluginService */ public abstract class AbstractPackageDisseminator implements PackageDisseminator @@ -76,6 +76,10 @@ public abstract class AbstractPackageDisseminator * packages will be written to the same directory as this File. * @throws PackageValidationException if package cannot be created or there is * a fatal error in creating it. + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public List disseminateAll(Context context, DSpaceObject dso, diff --git a/dspace-api/src/main/java/org/dspace/content/packager/AbstractPackageIngester.java b/dspace-api/src/main/java/org/dspace/content/packager/AbstractPackageIngester.java index e7857e5741..ead6225f75 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/AbstractPackageIngester.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/AbstractPackageIngester.java @@ -53,7 +53,7 @@ import org.dspace.workflow.WorkflowException; * * @author Tim Donohue * @see PackageIngester - * @see PluginService + * @see org.dspace.core.service.PluginService */ public abstract class AbstractPackageIngester implements PackageIngester @@ -114,6 +114,11 @@ public abstract class AbstractPackageIngester * is unacceptable or there is a fatal error in creating a DSpaceObject * @throws UnsupportedOperationException if this packager does not * implement ingestAll + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws WorkflowException if workflow error */ @Override public List ingestAll(Context context, DSpaceObject parent, File pkgFile, @@ -254,6 +259,11 @@ public abstract class AbstractPackageIngester * is unacceptable or there is a fatal error in creating a DSpaceObject * @throws UnsupportedOperationException if this packager does not * implement replaceAll + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws WorkflowException if workflow error */ @Override public List replaceAll(Context context, DSpaceObject dso, diff --git a/dspace-api/src/main/java/org/dspace/content/packager/DSpaceAIPDisseminator.java b/dspace-api/src/main/java/org/dspace/content/packager/DSpaceAIPDisseminator.java index 05bcdbd071..ca735905c6 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/DSpaceAIPDisseminator.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/DSpaceAIPDisseminator.java @@ -201,9 +201,7 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator * @param dso current DSpace Object * @param params Packager Parameters * @return List of crosswalk names to run - * @throws SQLException - * @throws IOException - * @throws AuthorizeException + * @throws SQLException if error */ @Override public MetsHdr makeMetsHdr(Context context, DSpaceObject dso, @@ -255,9 +253,9 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator * @param dso current DSpace Object * @param params Packager Parameters * @return List of crosswalk names to run - * @throws SQLException - * @throws IOException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error */ @Override public String [] getDmdTypes(Context context, DSpaceObject dso, PackageParameters params) @@ -284,9 +282,9 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator * @param dso current DSpace Object * @param params Packager Parameters * @return List of crosswalk names to run - * @throws SQLException - * @throws IOException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error */ @Override public String[] getTechMdTypes(Context context, DSpaceObject dso, PackageParameters params) @@ -324,9 +322,9 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator * @param dso current DSpace Object * @param params Packager Parameters * @return List of crosswalk names to run - * @throws SQLException - * @throws IOException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error */ @Override public String[] getSourceMdTypes(Context context, DSpaceObject dso, PackageParameters params) @@ -353,9 +351,9 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator * @param dso current DSpace Object * @param params Packager Parameters * @return List of crosswalk names to run - * @throws SQLException - * @throws IOException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error */ @Override public String[] getDigiprovMdTypes(Context context, DSpaceObject dso, PackageParameters params) @@ -383,9 +381,9 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator * @param dso current DSpace Object * @param params Packager Parameters * @return List of crosswalk names to run - * @throws SQLException - * @throws IOException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error */ @Override public String[] getRightsMdTypes(Context context, DSpaceObject dso, PackageParameters params) @@ -452,9 +450,9 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator * @param dso Current DSpace object * @param params Packager Parameters * @param mets METS manifest - * @throws SQLException - * @throws IOException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error * @throws MetsException */ @Override diff --git a/dspace-api/src/main/java/org/dspace/content/packager/DSpaceAIPIngester.java b/dspace-api/src/main/java/org/dspace/content/packager/DSpaceAIPIngester.java index d360b7caae..edf88aacd8 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/DSpaceAIPIngester.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/DSpaceAIPIngester.java @@ -95,6 +95,11 @@ public class DSpaceAIPIngester * 3. If (1) or (2) succeeds, crosswalk it and ignore all other DMDs with * same GROUPID
* 4. Crosswalk remaining DMDs not eliminated already. + * @throws PackageValidationException validation error + * @throws CrosswalkException if crosswalk error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void crosswalkObjectDmd(Context context, DSpaceObject dso, @@ -193,6 +198,10 @@ public class DSpaceAIPIngester * license supplied by explicit argument next, else use collection's * default deposit license. * Normally the rightsMD crosswalks should provide a license. + * @throws PackageValidationException validation error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void addLicense(Context context, Item item, String license, @@ -232,6 +241,11 @@ public class DSpaceAIPIngester * @param context DSpace Context * @param dso DSpace object * @param params Packager Parameters + * @throws org.dspace.content.packager.PackageValidationException + * @throws java.sql.SQLException + * @throws org.dspace.content.crosswalk.CrosswalkException + * @throws java.io.IOException + * @throws org.dspace.authorize.AuthorizeException */ @Override public void finishObject(Context context, DSpaceObject dso, PackageParameters params) @@ -256,6 +270,10 @@ public class DSpaceAIPIngester /** * Nothing extra to do to bitstream after ingestion. + * @throws MetadataValidationException if validation error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void finishBitstream(Context context, @@ -271,6 +289,8 @@ public class DSpaceAIPIngester /** * Return the type of DSpaceObject in this package; it is * in the TYPE attribute of the mets:mets element. + * @return type + * @throws PackageValidationException if package validation error */ @Override public int getObjectType(METSManifest manifest) @@ -296,6 +316,7 @@ public class DSpaceAIPIngester /** * Name used to distinguish DSpace Configuration entries for this subclass. + * @return config name */ @Override public String getConfigurationName() diff --git a/dspace-api/src/main/java/org/dspace/content/packager/DSpaceMETSDisseminator.java b/dspace-api/src/main/java/org/dspace/content/packager/DSpaceMETSDisseminator.java index cc6e7605ed..de96d561aa 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/DSpaceMETSDisseminator.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/DSpaceMETSDisseminator.java @@ -32,7 +32,7 @@ import edu.harvard.hul.ois.mets.helper.PCData; /** * Packager plugin to produce a - * METS (Metadata Encoding & Transmission Standard) package + * METS (Metadata Encoding and Transmission Standard) package * that is accepted as a DSpace METS SIP (Submission Information Package). * See http://www.loc.gov/standards/mets/ * for more information on METS. @@ -104,6 +104,7 @@ public class DSpaceMETSDisseminator /** * Create metsHdr element - separate so subclasses can override. + * @return mets header */ @Override public MetsHdr makeMetsHdr(Context context, DSpaceObject dso, @@ -134,6 +135,10 @@ public class DSpaceMETSDisseminator * params may contain one or more values for "dmd"; each of those is * the name of a crosswalk plugin, optionally followed by colon and * its METS MDTYPE name. + * @return array of DMD types + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public String [] getDmdTypes(Context context, DSpaceObject dso, PackageParameters params) @@ -159,6 +164,10 @@ public class DSpaceMETSDisseminator * Get name of technical metadata crosswalk for Bitstreams. * Default is PREMIS. This is both the name of the crosswalk plugin * and the METS MDTYPE. + * @return array of TechMD types + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public String[] getTechMdTypes(Context context, DSpaceObject dso, PackageParameters params) @@ -193,6 +202,10 @@ public class DSpaceMETSDisseminator /** * Add rights MD (licenses) for DSpace item. These * may include a deposit license, and Creative Commons. + * @return array of RightsMD types + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public String[] getRightsMdTypes(Context context, DSpaceObject dso, PackageParameters params) diff --git a/dspace-api/src/main/java/org/dspace/content/packager/DSpaceMETSIngester.java b/dspace-api/src/main/java/org/dspace/content/packager/DSpaceMETSIngester.java index 3cf2b518df..4ea1f3e349 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/DSpaceMETSIngester.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/DSpaceMETSIngester.java @@ -28,7 +28,7 @@ import org.jdom.Element; /** * Packager plugin to ingest a - * METS (Metadata Encoding & Transmission Standard) package + * METS (Metadata Encoding and Transmission Standard) package * that conforms to the DSpace METS SIP (Submission Information Package) Profile. * See http://www.loc.gov/standards/mets/ * for more information on METS, and @@ -76,6 +76,11 @@ public class DSpaceMETSIngester * 3. If (1) or (2) succeeds, crosswalk it and ignore all other DMDs with * same GROUPID
* 4. Crosswalk remaining DMDs not eliminated already. + * @throws CrosswalkException if crosswalk error + * @throws PackageValidationException if validation error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void crosswalkObjectDmd(Context context, DSpaceObject dso, @@ -167,6 +172,10 @@ public class DSpaceMETSIngester * supplied by explicit argument first, else use collection's * default deposit license. * For Creative Commons, look for a rightsMd containing a CC license. + * @throws PackageValidationException if validation error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void addLicense(Context context, Item item, String license, @@ -220,6 +229,10 @@ public class DSpaceMETSIngester /** * Take a second pass over files to correct names of derived files * (e.g. thumbnails, extracted text) to what DSpace expects: + * @throws MetadataValidationException if validation error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ @Override public void finishBitstream(Context context, diff --git a/dspace-api/src/main/java/org/dspace/content/packager/METSManifest.java b/dspace-api/src/main/java/org/dspace/content/packager/METSManifest.java index bf958ae1d1..160b413b6b 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/METSManifest.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/METSManifest.java @@ -65,7 +65,7 @@ import org.jdom.xpath.XPath; *
eg. mets.xsd.dc = http://purl.org/dc/elements/1.1/ dc.xsd *
Add a separate config entry for each schema. * - *

  • Crosswalk plugin mappings: + *
  • Crosswalk plugin mappings: * These tell it the name of the crosswalk plugin to invoke for metadata sections * with a particular value of MDTYPE (or OTHERMDTYPE) * By default, the crosswalk mechanism will look for a plugin with the @@ -83,8 +83,6 @@ import org.jdom.xpath.XPath; * @author WeiHua Huang * @author Rita Lee * @author Larry Stone - * @see org.dspace.content.packager.MetsSubmission - * @see org.dspace.app.mets.FederatedMETSImport */ public class METSManifest { @@ -109,9 +107,10 @@ public class METSManifest * @param mdRef JDOM element of mdRef in the METS manifest. * @return stream containing the metadata mentioned in mdRef. * @throws MetadataValidationException if the mdRef is unacceptable or missing required information. - * @throws IOException if it is returned by services called by this method. - * @throws SQLException if it is returned by services called by this method. - * @throws AuthorizeException if it is returned by services called by this method. + * @throws PackageValidationException if package validation error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public InputStream getInputStream(Element mdRef) throws MetadataValidationException, PackageValidationException, @@ -154,7 +153,7 @@ public class METSManifest /** all mdRef elements in the manifest */ protected List mdFiles = null; - /** elements in "original" file group (bundle) */ + /** {@code } elements in "original" file group (bundle) */ protected List contentFiles = null; protected List bundleFiles = null; @@ -232,6 +231,7 @@ public class METSManifest * Default constructor, only called internally. * @param builder XML parser (for parsing mdRef'd files and binData) * @param mets parsed METS document + * @param configName config name */ protected METSManifest(SAXBuilder builder, Element mets, String configName) { @@ -247,6 +247,8 @@ public class METSManifest * @param is input stream containing serialized XML * @param validate if true, enable XML validation using schemas * in document. Also validates any sub-documents. + * @param configName config name + * @throws IOException if IO error * @throws MetadataValidationException if there is any error parsing * or validating the METS. * @return new METSManifest object. @@ -320,6 +322,7 @@ public class METSManifest * Gets all file elements which make up * the item's content. * @return a List of Elements. + * @throws MetadataValidationException if validation error */ public List getBundleFiles() throws MetadataValidationException @@ -377,6 +380,7 @@ public class METSManifest * document. Used by ingester to e.g. check that all * required files are present. * @return a List of Elements. + * @throws MetadataValidationException if validation error */ public List getMdFiles() throws MetadataValidationException @@ -465,6 +469,7 @@ public class METSManifest * Get the DSpace bundle name corresponding to the USE * attribute of the file group enclosing this file element. * + * @param file file element * @return DSpace bundle name * @throws MetadataValidationException when there is no USE attribute on the enclosing fileGrp. */ @@ -478,6 +483,8 @@ public class METSManifest * Get the DSpace bundle name corresponding to the USE * attribute of the file group enclosing this file element. * + * @param file file element + * @param getParent parent flag * @return DSpace bundle name * @throws MetadataValidationException when there is no USE attribute on the enclosing fileGrp. */ @@ -502,6 +509,7 @@ public class METSManifest * By "local" we mean the reference to the actual resource containing * the data for this file, e.g. a relative path within a Zip or tar archive * if the METS is serving as a manifest for that sort of package. + * @param file file element * @return "local" file name (i.e. relative to package or content * directory) corresponding to this file or mdRef element. * @throws MetadataValidationException when there is not enough information to find a resource identifier. @@ -553,6 +561,7 @@ public class METSManifest * first {@code structMap} has an {@code fptr}. * * @return file element of Item's primary bitstream, or null if there is none. + * @throws MetadataValidationException if validation error */ public Element getPrimaryOrLogoBitstream() throws MetadataValidationException @@ -578,7 +587,9 @@ public class METSManifest /** * Get the metadata type from within a *mdSec element. + * @param mdSec mdSec element * @return metadata type name. + * @throws MetadataValidationException if validation error */ public String getMdType(Element mdSec) throws MetadataValidationException @@ -606,7 +617,9 @@ public class METSManifest /** * Returns MIME type of metadata content, if available. + * @param mdSec mdSec element * @return MIMEtype word, or null if none is available. + * @throws MetadataValidationException if validation error */ public String getMdContentMimeType(Element mdSec) throws MetadataValidationException @@ -633,8 +646,14 @@ public class METSManifest * Return contents of *md element as List of XML Element objects. * Gets content, dereferencing mdRef if necessary, or decoding and parsing * a binData that contains XML. + * @param mdSec mdSec element + * @param callback mdref callback * @return contents of metadata section, or empty list if no XML content is available. * @throws MetadataValidationException if METS is invalid, or there is an error parsing the XML. + * @throws PackageValidationException if invalid package + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public List getMdContentAsXml(Element mdSec, Mdref callback) throws MetadataValidationException, PackageValidationException, @@ -734,8 +753,14 @@ public class METSManifest * Return contents of *md element as stream. * Gets content, dereferencing mdRef if necessary, or decoding * a binData element if necessary. + * @param mdSec mdSec element + * @param callback mdref callback * @return Stream containing contents of metadata section. Never returns null. * @throws MetadataValidationException if METS format does not contain any metadata. + * @throws PackageValidationException if invalid package + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public InputStream getMdContentAsStream(Element mdSec, Mdref callback) throws MetadataValidationException, PackageValidationException, @@ -788,7 +813,7 @@ public class METSManifest * in the first {@code }. * * @return Element which is the DSpace Object Contents {@code
    } - * @throws MetadataValidationException + * @throws MetadataValidationException if metadata validation error */ public Element getObjStructDiv() throws MetadataValidationException @@ -820,7 +845,7 @@ public class METSManifest * These {@code
    }s reference the location of any child objects METS manifests. * * @return a List of {@code Element}s, each a {@code
    }. May be empty but NOT null. - * @throws MetadataValidationException + * @throws MetadataValidationException if metadata validation error */ public List getChildObjDivs() throws MetadataValidationException @@ -837,7 +862,7 @@ public class METSManifest * These file paths are located in the {@code } where @LOCTYPE=URL * * @return a list of Strings, corresponding to relative file paths of children METS manifests - * @throws MetadataValidationException + * @throws MetadataValidationException if metadata validation error */ public String[] getChildMetsFilePaths() throws MetadataValidationException @@ -889,7 +914,7 @@ public class METSManifest * This parent object is the owner of current object. * * @return Link to the Parent Object (this is the Handle of that Parent) - * @throws MetadataValidationException + * @throws MetadataValidationException if metadata validation error */ public String getParentOwnerLink() throws MetadataValidationException @@ -1078,6 +1103,17 @@ public class METSManifest /** * Invokes appropriate crosswalks on Item-wide descriptive metadata. + * @param context context + * @param callback mdref callback + * @param dso DSpaceObject + * @param params package params + * @param dmdSec dmdSec element + * @throws MetadataValidationException if METS error + * @throws CrosswalkException if crosswalk error + * @throws PackageValidationException if invalid package + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void crosswalkItemDmd(Context context, PackageParameters params, DSpaceObject dso, @@ -1091,7 +1127,15 @@ public class METSManifest /** * Crosswalk all technical and source metadata sections that belong * to the whole object. + * @param context context + * @param callback mdref callback + * @param params package params + * @param dso DSpaceObject * @throws MetadataValidationException if METS is invalid, e.g. referenced amdSec is missing. + * @throws PackageValidationException if invalid package + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void crosswalkObjectOtherAdminMD(Context context, PackageParameters params, DSpaceObject dso, Mdref callback) @@ -1118,7 +1162,17 @@ public class METSManifest /** * Just crosswalk the sourceMD sections; used to set the handle and parent of AIP. + * @param context context + * @param callback mdref callback + * @param params package params + * @param dso DSpaceObject * @return true if any metadata section was actually crosswalked, false otherwise + * @throws MetadataValidationException if METS is invalid, e.g. referenced amdSec is missing. + * @throws PackageValidationException if invalid package + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws CrosswalkException if crosswalk error */ public boolean crosswalkObjectSourceMD(Context context, PackageParameters params, DSpaceObject dso, Mdref callback) @@ -1143,7 +1197,7 @@ public class METSManifest * Get an aray of all AMDID values for this object * * @return - * @throws MetadataValidationException + * @throws MetadataValidationException if metadata validation error */ protected String[] getAmdIDs() throws MetadataValidationException @@ -1279,7 +1333,13 @@ public class METSManifest * @param bitstream bitstream target of the crosswalk * @param fileId value of ID attribute in the file element responsible * for the contents of that bitstream. - * @param callback ??? + * @param callback mdref callback + * @throws MetadataValidationException if METS is invalid, e.g. referenced amdSec is missing. + * @throws PackageValidationException if invalid package + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws CrosswalkException if crosswalk error */ public void crosswalkBitstream(Context context, PackageParameters params, Bitstream bitstream, diff --git a/dspace-api/src/main/java/org/dspace/content/packager/PDFPackager.java b/dspace-api/src/main/java/org/dspace/content/packager/PDFPackager.java index 5d4a5f0e0e..7c4087fa6e 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/PDFPackager.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/PDFPackager.java @@ -106,8 +106,12 @@ public class PDFPackager * @param params package parameters (none recognized) * @param license may be null, which takes default license. * @return workspace item created by ingest. - * @throws PackageException if package is unacceptable or there is - * a fatal error turning it into an Item. + * @throws PackageValidationException if package invalid + * @throws CrosswalkException if crosswalking fails + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error + * @throws WorkflowException if workflow error */ @Override public DSpaceObject ingest(Context context, DSpaceObject parent, @@ -181,6 +185,12 @@ public class PDFPackager /** * IngestAll() cannot be implemented for a PDF ingester, because there's only one PDF to ingest + * @throws UnsupportedOperationException if unsupported operation + * @throws PackageException if package error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws CrosswalkException if crosswalk error */ @Override public List ingestAll(Context context, DSpaceObject parent, File pkgFile, @@ -195,6 +205,12 @@ public class PDFPackager /** * Replace is not implemented. + * @throws UnsupportedOperationException if unsupported operation + * @throws PackageException if package error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws CrosswalkException if crosswalk error */ @Override public DSpaceObject replace(Context context, DSpaceObject dso, @@ -208,6 +224,12 @@ public class PDFPackager /** * ReplaceAll() cannot be implemented for a PDF ingester, because there's only one PDF to ingest + * @throws UnsupportedOperationException if unsupported operation + * @throws PackageException if package error + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws CrosswalkException if crosswalk error */ @Override public List replaceAll(Context context, DSpaceObject dso, @@ -223,6 +245,11 @@ public class PDFPackager * VERY crude dissemination: just look for the first * bitstream with the PDF package type, and toss it out. * Works on packages importer with this packager, and maybe some others. + * @param dso DSpaceObject + * @throws CrosswalkException if crosswalk error + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error */ @Override public void disseminate(Context context, DSpaceObject dso, @@ -273,6 +300,11 @@ public class PDFPackager /** * disseminateAll() cannot be implemented for a PDF disseminator, because there's only one PDF to disseminate + * @throws PackageException if package error + * @throws CrosswalkException if crosswalk error + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error */ @Override public List disseminateAll(Context context, DSpaceObject dso, @@ -287,6 +319,7 @@ public class PDFPackager /** * Identifies the MIME-type of this package, i.e. "application/pdf". * + * @param params package params * @return the MIME type (content-type header) of the package to be returned */ @Override diff --git a/dspace-api/src/main/java/org/dspace/content/packager/PackageDisseminator.java b/dspace-api/src/main/java/org/dspace/content/packager/PackageDisseminator.java index ea3049b5ce..e15aa06316 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/PackageDisseminator.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/PackageDisseminator.java @@ -67,6 +67,10 @@ public interface PackageDisseminator * @param pkgFile File where export package should be written * @throws PackageValidationException if package cannot be created or there is * a fatal error in creating it. + * @throws CrosswalkException if crosswalk error + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error */ void disseminate(Context context, DSpaceObject object, PackageParameters params, File pkgFile) @@ -103,6 +107,10 @@ public interface PackageDisseminator * @return List of all package Files which were successfully disseminated * @throws PackageValidationException if package cannot be created or there is * a fatal error in creating it. + * @throws CrosswalkException if crosswalk error + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error */ List disseminateAll(Context context, DSpaceObject dso, PackageParameters params, File pkgFile) @@ -115,6 +123,7 @@ public interface PackageDisseminator * Required when sending the package via HTTP, to * provide the Content-Type header. * + * @param params Package Parameters * @return the MIME type (content-type header) of the package to be returned */ String getMIMEType(PackageParameters params); diff --git a/dspace-api/src/main/java/org/dspace/content/packager/PackageException.java b/dspace-api/src/main/java/org/dspace/content/packager/PackageException.java index 92442593cd..0257387b7a 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/PackageException.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/PackageException.java @@ -62,6 +62,7 @@ public class PackageException extends Exception /** * Write details of this exception to the indicated logger. * Dump a stack trace to the log to aid in debugging. + * @param log logger */ public void log(Logger log) { diff --git a/dspace-api/src/main/java/org/dspace/content/packager/PackageIngester.java b/dspace-api/src/main/java/org/dspace/content/packager/PackageIngester.java index 9f01dd3896..85733fe200 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/PackageIngester.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/PackageIngester.java @@ -70,6 +70,11 @@ public interface PackageIngester * * @throws PackageValidationException if package is unacceptable or there is * a fatal error turning it into a DSpaceObject. + * @throws CrosswalkException if crosswalk error + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error + * @throws WorkflowException if workflow error */ DSpaceObject ingest(Context context, DSpaceObject parent, File pkgFile, PackageParameters params, String license) @@ -112,6 +117,11 @@ public interface PackageIngester * is unacceptable or there is a fatal error in creating a DSpaceObject * @throws UnsupportedOperationException if this packager does not * implement ingestAll + * @throws CrosswalkException if crosswalk error + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error + * @throws WorkflowException if workflow error */ List ingestAll(Context context, DSpaceObject parent, File pkgFile, PackageParameters params, String license) @@ -139,6 +149,11 @@ public interface PackageIngester * a fatal error turning it into an Item. * @throws UnsupportedOperationException if this packager does not * implement replace. + * @throws CrosswalkException if crosswalk error + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error + * @throws WorkflowException if workflow error */ DSpaceObject replace(Context context, DSpaceObject dso, File pkgFile, PackageParameters params) @@ -179,6 +194,11 @@ public interface PackageIngester * is unacceptable or there is a fatal error in creating a DSpaceObject * @throws UnsupportedOperationException if this packager does not * implement replaceAll + * @throws CrosswalkException if crosswalk error + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error + * @throws WorkflowException if workflow error */ List replaceAll(Context context, DSpaceObject dso, File pkgFile, PackageParameters params) diff --git a/dspace-api/src/main/java/org/dspace/content/packager/PackageUtils.java b/dspace-api/src/main/java/org/dspace/content/packager/PackageUtils.java index f6a9f68b91..402763a6b7 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/PackageUtils.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/PackageUtils.java @@ -14,8 +14,6 @@ import java.io.IOException; import java.io.InputStream; import java.sql.SQLException; import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -130,6 +128,7 @@ public class PackageUtils * Used by all SIP processors as a common sanity test. * * @param item - item to test. + * @throws PackageValidationException if validation error */ public static void checkItemMetadata(Item item) throws PackageValidationException @@ -151,6 +150,9 @@ public class PackageUtils * @param license - license string to add, may be null to invoke default. * @param item - the item. * @param collection - get the default license from here. + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public static void addDepositLicense(Context context, String license, Item item, Collection collection) @@ -194,6 +196,7 @@ public class PackageUtils * @param item Item whose bitstreams to search. * @param name Bitstream's name to match. * @return first bitstream found or null. + * @throws SQLException if database error */ public static Bitstream getBitstreamByName(Item item, String name) throws SQLException @@ -208,6 +211,7 @@ public class PackageUtils * @param bsName - name of bitstream to match. * @param bnName - bundle name to match, or null for all. * @return the format found or null if none found. + * @throws SQLException if database error */ public static Bitstream getBitstreamByName(Item item, String bsName, String bnName) throws SQLException @@ -239,10 +243,12 @@ public class PackageUtils * Find bitstream by its format, looking in a specific bundle. * Used to look for particularly-typed Package Manifest bitstreams. * + * @param context context * @param item - dspace item whose bundles to search. * @param bsf - BitstreamFormat object to match. * @param bnName - bundle name to match, or null for all. * @return the format found or null if none found. + * @throws SQLException if database error */ public static Bitstream getBitstreamByFormat(Context context, Item item, BitstreamFormat bsf, String bnName) @@ -328,6 +334,8 @@ public class PackageUtils * @param MIMEType - MIME content-type * @param desc - long description * @return BitstreamFormat object that was found or created. Never null. + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public static BitstreamFormat findOrCreateBitstreamFormat(Context context, String shortDesc, String MIMEType, String desc) @@ -349,8 +357,11 @@ public class PackageUtils * @param shortDesc - short descriptive name, used to locate existing format. * @param MIMEType - mime content-type * @param desc - long description + * @param supportLevel support level * @param internal value for the 'internal' flag of a new format if created. * @return BitstreamFormat object that was found or created. Never null. + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public static BitstreamFormat findOrCreateBitstreamFormat(Context context, String shortDesc, String MIMEType, String desc, int supportLevel, boolean internal) @@ -380,9 +391,9 @@ public class PackageUtils * @param item * the item * @return the license bitstream or null - * - * @throws IOException - * if the license bitstream can't be read + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if the license bitstream can't be read */ public static Bitstream findDepositLicense(Context context, Item item) throws SQLException, IOException, AuthorizeException @@ -440,9 +451,9 @@ public class PackageUtils * @param handle Handle of new Object (may be null) * @param params Properties-style list of options (interpreted by each packager). * @return newly created DSpace Object (or null) - * @throws AuthorizeException - * @throws SQLException - * @throws IOException + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IOException if IO error */ public static DSpaceObject createDSpaceObject(Context context, DSpaceObject parent, int type, String handle, PackageParameters params) throws AuthorizeException, SQLException, IOException @@ -496,9 +507,10 @@ public class PackageUtils * @param handle Handle to assign to item (may be null) * @param params Properties-style list of options (interpreted by each packager). * @return finished Item - * @throws IOException - * @throws SQLException - * @throws AuthorizeException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws WorkflowException if workflow error */ public static Item finishCreateItem(Context context, WorkspaceItem wsi, String handle, PackageParameters params) throws IOException, SQLException, AuthorizeException, WorkflowException { @@ -538,7 +550,11 @@ public class PackageUtils *

    * This method is necessary as there is no generic 'update()' on a DSpaceObject * + * @param context context * @param dso DSpaceObject to update + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ public static void updateDSpaceObject(Context context, DSpaceObject dso) throws AuthorizeException, SQLException, IOException @@ -616,9 +632,9 @@ public class PackageUtils * Creates the specified file (along with all parent directories) if it doesn't already * exist. If the file already exists, nothing happens. * - * @param file + * @param file file * @return boolean true if succeeded, false otherwise - * @throws IOException + * @throws IOException if IO error */ public static boolean createFile(File file) throws IOException @@ -645,12 +661,16 @@ public class PackageUtils /** * Remove all bitstreams (files) associated with a DSpace object. *

    - * If this object is an Item, it removes all bundles & bitstreams. If this + * If this object is an Item, it removes all bundles and bitstreams. If this * object is a Community or Collection, it removes all logo bitstreams. *

    * This method is useful for replace functionality. * + * @param context context * @param dso The object to remove all bitstreams from + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public static void removeAllBitstreams(Context context, DSpaceObject dso) throws SQLException, IOException, AuthorizeException @@ -689,7 +709,11 @@ public class PackageUtils *

    * This method is useful for replace functionality. * + * @param context context * @param dso The object to remove all metadata from + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public static void clearAllMetadata(Context context, DSpaceObject dso) throws SQLException, IOException, AuthorizeException @@ -763,7 +787,7 @@ public class PackageUtils * (represented by [ID] above) becomes meaningless when content is exported * outside of DSpace. In order to make these Group names meaningful outside * of DSpace, they must be translated into a different format: - *

  • COMMUNITY_[HANDLE]_ADMIN (e.g. COMMUNITY_hdl:123456789/10_ADMIN), etc. + * {@code COMMUNITY_[HANDLE]_ADMIN} (e.g. COMMUNITY_hdl:123456789/10_ADMIN), etc. *

    * This format replaces the internal ID with an external Handle identifier * (which is expected to be more meaningful even when content is exported @@ -786,6 +810,7 @@ public class PackageUtils * @param context current DSpace Context * @param groupName Group's name * @return the group name, with any internal IDs translated to Handles + * @throws PackageException if package error */ public static String translateGroupNameForExport(Context context, String groupName) throws PackageException @@ -871,6 +896,7 @@ public class PackageUtils * @param context current DSpace Context * @param groupName Group's name * @return the group name, with any Handles translated to internal IDs + * @throws PackageException if package error */ public static String translateGroupNameForImport(Context context, String groupName) throws PackageException diff --git a/dspace-api/src/main/java/org/dspace/content/packager/RoleDisseminator.java b/dspace-api/src/main/java/org/dspace/content/packager/RoleDisseminator.java index 695efccd7e..fedc54ac44 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/RoleDisseminator.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/RoleDisseminator.java @@ -121,7 +121,7 @@ public class RoleDisseminator implements PackageDisseminator * * @param emitPasswords true if password hashes should be included. * @return the stream of XML representing users and groups. - * @throws IOException + * @throws IOException if IO error * if a PipedOutputStream or PipedInputStream cannot be created. */ InputStream asStream(Context context, DSpaceObject object, boolean emitPasswords) @@ -191,11 +191,11 @@ public class RoleDisseminator implements PackageDisseminator /** * Serialize users and groups to a stream. * - * @param context + * @param context current Context + * @param object DSpaceObject * @param stream receives the output. Is not closed by this method. * @param emitPasswords true if password hashes should be included. - * @throws XMLStreamException - * @throws SQLException + * @throws PackageException if error */ protected void writeToStream(Context context, DSpaceObject object, OutputStream stream, boolean emitPasswords) @@ -290,12 +290,14 @@ public class RoleDisseminator implements PackageDisseminator * * @param context * the DSpace Context - * @parm relatedObject + * @param relatedObject * the DSpaceObject related to this group (if any) * @param group * the Group to describe * @param writer * the description to this stream + * @throws XMLStreamException if XML error + * @throws PackageException if packaging error */ protected void writeGroup(Context context, DSpaceObject relatedObject, Group group, XMLStreamWriter writer) throws XMLStreamException, PackageException @@ -436,6 +438,7 @@ public class RoleDisseminator implements PackageDisseminator * the description to this stream * @param emitPassword * do not export the password hash unless true + * @throws XMLStreamException if XML error */ protected void writeEPerson(EPerson eperson, XMLStreamWriter writer, boolean emitPassword) throws XMLStreamException @@ -533,13 +536,14 @@ public class RoleDisseminator implements PackageDisseminator * @param context The DSpace context * @param object the DSpace object * @return array of all associated groups + * @throws SQLException if database error */ protected List findAssociatedGroups(Context context, DSpaceObject object) throws SQLException { if(object.getType()==Constants.SITE) { - // @TODO FIXME -- if there was a way to ONLY export Groups which are NOT + // TODO FIXME -- if there was a way to ONLY export Groups which are NOT // associated with a Community or Collection, we should be doing that instead! return groupService.findAll(context, null); } @@ -635,6 +639,7 @@ public class RoleDisseminator implements PackageDisseminator * @param context The DSpace context * @param object the DSpace object * @return array of all associated EPerson objects + * @throws SQLException if database error */ protected List findAssociatedPeople(Context context, DSpaceObject object) throws SQLException diff --git a/dspace-api/src/main/java/org/dspace/content/packager/RoleIngester.java b/dspace-api/src/main/java/org/dspace/content/packager/RoleIngester.java index 4714ebdce4..9e230e0e55 100644 --- a/dspace-api/src/main/java/org/dspace/content/packager/RoleIngester.java +++ b/dspace-api/src/main/java/org/dspace/content/packager/RoleIngester.java @@ -66,9 +66,9 @@ public class RoleIngester implements PackageIngester * the Parent DSpaceObject * @param document * the XML Document - * @throws SQLException - * @throws AuthorizeException - * @throws PackageException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws PackageException if packaging error */ void ingestDocument(Context context, DSpaceObject parent, PackageParameters params, Document document) @@ -427,15 +427,12 @@ public class RoleIngester implements PackageIngester /** * Ingest roles from an InputStream. * - * @param context - * DSpace Context - * @param parent - * the Parent DSpaceObject - * @param stream - * the XML Document InputStream - * @throws PackageException - * @throws SQLException - * @throws AuthorizeException + * @param context DSpace Context + * @param parent the Parent DSpaceObject + * @param params package params + * @throws PackageException if packaging error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void ingestStream(Context context, DSpaceObject parent, PackageParameters params, InputStream stream) diff --git a/dspace-api/src/main/java/org/dspace/content/service/BitstreamFormatService.java b/dspace-api/src/main/java/org/dspace/content/service/BitstreamFormatService.java index e658fa89c0..e5f83243c7 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/BitstreamFormatService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/BitstreamFormatService.java @@ -37,7 +37,7 @@ public interface BitstreamFormatService extends DSpaceCRUDServicenull if * there's no bitstream format with the given MIMEtype. - * @throws java.sql.SQLException + * @throws SQLException if database error */ public BitstreamFormat findByMIMEType(Context context, String mimeType) throws SQLException; @@ -51,7 +51,7 @@ public interface BitstreamFormatService extends DSpaceCRUDServicenull if * there's no bitstream format with the given short description - * @throws SQLException + * @throws SQLException if database error */ public BitstreamFormat findByShortDescription(Context context, String desc) throws SQLException; @@ -62,7 +62,7 @@ public interface BitstreamFormatService extends DSpaceCRUDService findAll(Context context) throws SQLException; @@ -89,15 +89,18 @@ public interface BitstreamFormatService extends DSpaceCRUDService findNonInternal(Context context) throws SQLException; /** * Set the short description of the bitstream format * + * @param context context + * @param bitstreamFormat format * @param shortDescription * the new short description + * @throws SQLException if database error */ public void setShortDescription(Context context, BitstreamFormat bitstreamFormat, String shortDescription) throws SQLException; @@ -105,6 +108,7 @@ public interface BitstreamFormatService extends DSpaceCRUDServiceUNKNOWN,KNOWN or SUPPORTED. * + * @param bitstreamFormat format * @return the support level */ public String getSupportLevelText(BitstreamFormat bitstreamFormat); @@ -113,6 +117,7 @@ public interface BitstreamFormatService extends DSpaceCRUDServiceUNKNOWN,KNOWN or SUPPORTED. * + * @param bitstreamFormat format * @param supportLevel * the new support level */ @@ -134,10 +139,12 @@ public interface BitstreamFormatService extends DSpaceCRUDService, DSpace * the bits to put in the bitstream * * @return the newly created bitstream - * @throws java.io.IOException - * @throws SQLException + * @throws IOException if IO error + * @throws SQLException if database error */ public Bitstream create(Context context, InputStream is) throws IOException, SQLException; @@ -57,8 +57,9 @@ public interface BitstreamService extends DSpaceObjectService, DSpace * the bits to put in the bitstream * * @return the newly created bitstream - * @throws java.io.IOException - * @throws SQLException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Bitstream create(Context context, Bundle bundle, InputStream is) throws IOException, SQLException, AuthorizeException; @@ -68,11 +69,13 @@ public interface BitstreamService extends DSpaceObjectService, DSpace * format. * * @param context DSpace context object + * @param bundle The bundle in which our bitstream should be added. * @param assetstore corresponds to an assetstore in dspace.cfg * @param bitstreamPath the path and filename relative to the assetstore * @return the newly registered bitstream - * @throws IOException - * @throws SQLException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Bitstream register(Context context, Bundle bundle, int assetstore, String bitstreamPath) throws IOException, SQLException, AuthorizeException; @@ -86,8 +89,9 @@ public interface BitstreamService extends DSpaceObjectService, DSpace * @param assetstore corresponds to an assetstore in dspace.cfg * @param bitstreamPath the path and filename relative to the assetstore * @return the newly registered bitstream - * @throws IOException - * @throws SQLException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Bitstream register(Context context, int assetstore, String bitstreamPath) throws IOException, SQLException, AuthorizeException; @@ -96,17 +100,22 @@ public interface BitstreamService extends DSpaceObjectService, DSpace * Set the user's format description. This implies that the format of the * bitstream is uncertain, and the format is set to "unknown." * + * @param context DSpace context object + * @param bitstream DSpace bitstream * @param desc * the user's description of the format - * @throws SQLException + * @throws SQLException if database error */ public void setUserFormatDescription(Context context, Bitstream bitstream, String desc) throws SQLException; /** * Get the description of the format - either the user's or the description * of the format defined by the system. - * + * + * @param context DSpace context object + * @param bitstream DSpace bitstream * @return a description of the format. + * @throws SQLException if database error */ public String getFormatDescription(Context context, Bitstream bitstream) throws SQLException; @@ -115,20 +124,24 @@ public interface BitstreamService extends DSpaceObjectService, DSpace * description, it is cleared. Passing in null sets the type * of this bitstream to "unknown". * + * @param context DSpace context object + * @param bitstream DSpace bitstream * @param bitstreamFormat * the format of this bitstream, or null for * unknown - * @throws SQLException + * @throws SQLException if database error */ public void setFormat(Context context, Bitstream bitstream, BitstreamFormat bitstreamFormat) throws SQLException; /** * Retrieve the contents of the bitstream * + * @param context DSpace context object + * @param bitstream DSpace bitstream * @return a stream from which the bitstream can be read. - * @throws IOException - * @throws SQLException - * @throws AuthorizeException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public InputStream retrieve(Context context, Bitstream bitstream) throws IOException, SQLException, AuthorizeException; @@ -137,6 +150,7 @@ public interface BitstreamService extends DSpaceObjectService, DSpace * filesystem than in assetstore). More about registered items: * https://wiki.duraspace.org/display/DSDOC3x/Registering+(not+Importing)+Bitstreams+via+Simple+Archive+Format * + * @param bitstream DSpace bitstream * @return true if the bitstream is registered, false otherwise */ public boolean isRegisteredBitstream(Bitstream bitstream); @@ -145,7 +159,7 @@ public interface BitstreamService extends DSpaceObjectService, DSpace * Retrieve all bitstreams with the deleted flag set to true * @param context the dspace context * @return a list of all bitstreams that have been "deleted" - * @throws SQLException ... + * @throws SQLException if database error */ public List findDeletedBitstreams(Context context) throws SQLException; @@ -154,8 +168,8 @@ public interface BitstreamService extends DSpaceObjectService, DSpace * Remove a bitstream that has been set to "deleted" from the database * @param context the dspace context * @param bitstream the bitstream to deleted from the database - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void expunge(Context context, Bitstream bitstream) throws SQLException, AuthorizeException; @@ -179,7 +193,7 @@ public interface BitstreamService extends DSpaceObjectService, DSpace public Long countByStoreNumber(Context context, Integer storeNumber) throws SQLException; - int countTotal(Context context) throws SQLException ; + int countTotal(Context context) throws SQLException; int countDeletedBitstreams(Context context) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/content/service/BundleService.java b/dspace-api/src/main/java/org/dspace/content/service/BundleService.java index dcaef66c14..7d99aafe5f 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/BundleService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/BundleService.java @@ -34,8 +34,11 @@ public interface BundleService extends DSpaceObjectService, DSpaceObject * * @param context * DSpace context object - * + * @param item DSpace item + * @param name bundle name * @return the newly created bundle + * @throws AuthorizeException if authorization error + * @throws SQLException if database error */ public Bundle create(Context context, Item item, String name) throws SQLException, AuthorizeException; @@ -44,8 +47,12 @@ public interface BundleService extends DSpaceObjectService, DSpaceObject /** * Add an existing bitstream to this bundle * + * @param context DSpace Context + * @param bundle the bitstream bundle * @param bitstream * the bitstream to add + * @throws AuthorizeException if authorization error + * @throws SQLException if database error */ public void addBitstream(Context context, Bundle bundle, Bitstream bitstream) throws SQLException, AuthorizeException; @@ -60,8 +67,13 @@ public interface BundleService extends DSpaceObjectService, DSpaceObject * bitstream from the foreign key constraint so that the * cleanup process can run normally. * + * @param context DSpace Context + * @param bundle the bitstream bundle * @param bitstream * the bitstream to remove + * @throws IOException if IO error + * @throws AuthorizeException if authorization error + * @throws SQLException if database error */ public void removeBitstream(Context context, Bundle bundle, Bitstream bitstream) throws AuthorizeException, SQLException, IOException; @@ -71,12 +83,14 @@ public interface BundleService extends DSpaceObjectService, DSpaceObject * remove all policies on the bundle and its contents, and replace them with * the DEFAULT_BITSTREAM_READ policies belonging to the collection. * + * @param context DSpace Context + * @param bundle the bitstream bundle * @param collection * Collection - * @throws java.sql.SQLException + * @throws SQLException * if an SQL error or if no default policies found. It's a bit * draconian, but default policies must be enforced. - * @throws AuthorizeException + * @throws AuthorizeException if authorization error */ public void inheritCollectionDefaultPolicies(Context context, Bundle bundle, Collection collection) throws java.sql.SQLException, AuthorizeException; @@ -85,11 +99,13 @@ public interface BundleService extends DSpaceObjectService, DSpaceObject * remove all of the policies for the bundle and bitstream contents and replace * them with a new list of policies * + * @param context DSpace Context + * @param bundle the bitstream bundle * @param newpolicies - * this will be all of the new policies for the bundle and * bitstream contents - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void replaceAllBitstreamPolicies(Context context, Bundle bundle, List newpolicies) throws SQLException, AuthorizeException; @@ -100,6 +116,8 @@ public interface BundleService extends DSpaceObjectService, DSpaceObject /** * Changes bitstream order according to the array + * @param context DSpace Context + * @param bundle the bitstream bundle * @param bitstreamIds the identifiers in the order they are to be set * @throws SQLException when an SQL error has occurred (querying DSpace) * @throws AuthorizeException If the user can't make the changes diff --git a/dspace-api/src/main/java/org/dspace/content/service/CollectionService.java b/dspace-api/src/main/java/org/dspace/content/service/CollectionService.java index e81cc49d30..5ba99ae434 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/CollectionService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/CollectionService.java @@ -36,10 +36,11 @@ public interface CollectionService extends DSpaceObjectService, DSpa * * @param context * DSpace context object + * @param community DSpace Community (parent) * * @return the newly created collection - * @throws java.sql.SQLException - * @throws org.dspace.authorize.AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Collection create(Context context, Community community) throws SQLException, AuthorizeException; @@ -51,11 +52,12 @@ public interface CollectionService extends DSpaceObjectService, DSpa * * @param context * DSpace context object + * @param community DSpace Community (parent) * * @param handle the pre-determined Handle to assign to the new community * @return the newly created collection - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Collection create(Context context, Community community, String handle) throws SQLException, AuthorizeException; @@ -68,7 +70,7 @@ public interface CollectionService extends DSpaceObjectService, DSpa * DSpace context object * * @return the collections in the system - * @throws SQLException + * @throws SQLException if database error */ public List findAll(Context context) throws SQLException; @@ -77,8 +79,8 @@ public interface CollectionService extends DSpaceObjectService, DSpa * @param context * @param limit * @param offset - * @return - * @throws SQLException + * @return List of Collections + * @throws SQLException if database error */ public List findAll(Context context, Integer limit, Integer offset) throws SQLException; @@ -95,14 +97,15 @@ public interface CollectionService extends DSpaceObjectService, DSpa /** * Set a metadata value * + * @param context DSpace Context + * @param collection Collection * @param field * the name of the metadata field to get * @param value * value to set the field to * - * @exception IllegalArgumentException - * if the requested metadata field doesn't exist - * @exception java.util.MissingResourceException + * @throws MissingResourceException if resource missing + * @throws SQLException if database error */ @Deprecated public void setMetadata(Context context, Collection collection, String field, String value) throws MissingResourceException, SQLException; @@ -115,13 +118,15 @@ public interface CollectionService extends DSpaceObjectService, DSpa * effect. Setting a logo and not calling update later may * result in a previous logo lying around as an "orphaned" bitstream. * + * @param context DSpace Context + * @param collection Collection * @param is the stream to use as the new logo * * @return the new logo bitstream, or null if there is no * logo (null was passed in) - * @throws AuthorizeException - * @throws IOException - * @throws SQLException + * @throws AuthorizeException if authorization error + * @throws IOException if IO error + * @throws SQLException if database error */ public Bitstream setLogo(Context context, Collection collection, InputStream is) throws AuthorizeException, IOException, SQLException; @@ -133,12 +138,14 @@ public interface CollectionService extends DSpaceObjectService, DSpa * between the group and the collection is not written until * update is called. * + * @param context DSpace Context + * @param collection Collection * @param step * the step (1-3) of the workflow to create or get the group for * * @return the workflow group associated with this collection - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Group createWorkflowGroup(Context context, Collection collection, int step) throws SQLException, AuthorizeException; @@ -148,6 +155,7 @@ public interface CollectionService extends DSpaceObjectService, DSpa * null can be passed in if there should be no associated * group for that workflow step; any existing group is NOT deleted. * + * @param collection Collection * @param step * the workflow step (1-3) * @param group @@ -160,6 +168,7 @@ public interface CollectionService extends DSpaceObjectService, DSpa * This returns null if there is no group associated with * this collection for the given step. * + * @param collection Collection * @param step * the workflow step (1-3) * @@ -173,9 +182,11 @@ public interface CollectionService extends DSpaceObjectService, DSpa * other groups may also be allowed to submit to this collection by the * authorization system. * + * @param context DSpace Context + * @param collection Collection * @return the default group of submitters associated with this collection - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Group createSubmitters(Context context, Collection collection) throws SQLException, AuthorizeException; @@ -184,6 +195,10 @@ public interface CollectionService extends DSpaceObjectService, DSpa * then return without error. This will merely dereference the current * submitters group from the collection so that it may be deleted * without violating database constraints. + * @param context DSpace Context + * @param collection Collection + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void removeSubmitters(Context context, Collection collection) throws SQLException, AuthorizeException; @@ -193,9 +208,11 @@ public interface CollectionService extends DSpaceObjectService, DSpa * Returns either the newly created group or the previously existing one. * Note that other groups may also be administrators. * + * @param context DSpace Context + * @param collection Collection * @return the default group of editors associated with this collection - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Group createAdministrators(Context context, Collection collection) throws SQLException, AuthorizeException; @@ -204,6 +221,10 @@ public interface CollectionService extends DSpaceObjectService, DSpa * then return without error. This will merely dereference the current * administrators group from the collection so that it may be deleted * without violating database constraints. + * @param context DSpace Context + * @param collection Collection + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void removeAdministrators(Context context, Collection collection) throws SQLException, AuthorizeException; @@ -212,6 +233,7 @@ public interface CollectionService extends DSpaceObjectService, DSpa * collection. If the collection does not have a specific license, the * site-wide default is returned. * + * @param collection Collection * @return the license for this collection */ public String getLicense(Collection collection); @@ -219,6 +241,7 @@ public interface CollectionService extends DSpaceObjectService, DSpa /** * Find out if the collection has a custom license * + * @param collection Collection * @return true if the collection has a custom license */ public boolean hasCustomLicense(Collection collection); @@ -229,8 +252,10 @@ public interface CollectionService extends DSpaceObjectService, DSpa * the collection after doing this, or the item will have been created but * the collection record will not refer to it. * - * @throws SQLException - * @throws AuthorizeException + * @param context DSpace Context + * @param collection Collection + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void createTemplateItem(Context context, Collection collection) throws SQLException, AuthorizeException; @@ -241,9 +266,11 @@ public interface CollectionService extends DSpaceObjectService, DSpa * any other changes made; in other words, this method does an * update. * - * @throws SQLException - * @throws AuthorizeException - * @throws IOException + * @param context DSpace Context + * @param collection Collection + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ public void removeTemplateItem(Context context, Collection collection) throws SQLException, AuthorizeException, IOException; @@ -253,21 +280,25 @@ public interface CollectionService extends DSpaceObjectService, DSpa * remove a personal workspace item etc. This has instant effect; * update need not be called. * + * @param context DSpace Context + * @param collection Collection * @param item * item to add - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void addItem(Context context, Collection collection, Item item) throws SQLException, AuthorizeException; /** * Remove an item. If the item is then orphaned, it is deleted. * + * @param context DSpace Context + * @param collection Collection * @param item * item to remove - * @throws SQLException - * @throws AuthorizeException - * @throws IOException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ public void removeItem(Context context, Collection collection, Item item) throws SQLException, AuthorizeException, IOException; @@ -285,14 +316,14 @@ public interface CollectionService extends DSpaceObjectService, DSpa * (useful for trimming 'select to collection' list) or figuring out which * collections a person is an editor for. * - * @param context + * @param context DSpace Context * @param community * (optional) restrict search to a community, else null * @param actionID * of the action * * @return Collection [] of collections with matching permissions - * @throws SQLException + * @throws SQLException if database error */ public List findAuthorized(Context context, Community community, int actionID) throws java.sql.SQLException; @@ -304,9 +335,9 @@ public interface CollectionService extends DSpaceObjectService, DSpa /** * The map entry returned contains a collection as a key and sum of bitstream sizes in bytes as a value - * @param context - * @return - * @throws SQLException + * @param context DSpace Context + * @return List of Collections and bitstream sizes map + * @throws SQLException if database error */ List> getCollectionsWithBitstreamSizesTotal(Context context) throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/content/service/CommunityService.java b/dspace-api/src/main/java/org/dspace/content/service/CommunityService.java index 3c56062714..ab45f0d637 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/CommunityService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/CommunityService.java @@ -33,10 +33,13 @@ public interface CommunityService extends DSpaceObjectService, DSpace /** * Create a new top-level community, with a new ID. * + * @param parent parent community * @param context * DSpace context object * * @return the newly created community + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Community create(Community parent, Context context) throws SQLException, AuthorizeException; @@ -44,11 +47,14 @@ public interface CommunityService extends DSpaceObjectService, DSpace /** * Create a new top-level community, with a new ID. * + * @param parent parent community * @param context * DSpace context object * @param handle the pre-determined Handle to assign to the new community * * @return the newly created community + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Community create(Community parent, Context context, String handle) throws SQLException, AuthorizeException; @@ -62,16 +68,17 @@ public interface CommunityService extends DSpaceObjectService, DSpace * DSpace context object * * @return the communities in the system + * @throws SQLException if database error */ public List findAll(Context context) throws SQLException; /** * Get all communities in the system. Adds support for limit and offset. - * @param context - * @param limit - * @param offset - * @return - * @throws SQLException + * @param context context + * @param limit limit + * @param offset offset + * @return list of communities + * @throws SQLException if database error */ public List findAll(Context context, Integer limit, Integer offset) throws SQLException; @@ -84,12 +91,14 @@ public interface CommunityService extends DSpaceObjectService, DSpace * DSpace context object * * @return the top-level communities in the system + * @throws SQLException if database error */ public List findAllTop(Context context) throws SQLException; /** * Get the value of a metadata field * + * @param community community * @param field * the name of the metadata field to get * @@ -97,6 +106,7 @@ public interface CommunityService extends DSpaceObjectService, DSpace * * @exception IllegalArgumentException * if the requested metadata field doesn't exist + * @deprecated */ @Override @Deprecated @@ -106,6 +116,8 @@ public interface CommunityService extends DSpaceObjectService, DSpace /** * Set a metadata value * + * @param context context + * @param community community * @param field * the name of the metadata field to get * @param value @@ -114,6 +126,8 @@ public interface CommunityService extends DSpaceObjectService, DSpace * @exception IllegalArgumentException * if the requested metadata field doesn't exist * @exception java.util.MissingResourceException + * @throws SQLException if database error + * @deprecated */ @Deprecated public void setMetadata(Context context, Community community, String field, String value) throws MissingResourceException, SQLException; @@ -122,14 +136,19 @@ public interface CommunityService extends DSpaceObjectService, DSpace * Give the community a logo. Passing in null removes any * existing logo. You will need to set the format of the new logo bitstream * before it will work, for example to "JPEG". Note that - * update(/code> will need to be called for the change to take + * update will need to be called for the change to take * effect. Setting a logo and not calling update later may * result in a previous logo lying around as an "orphaned" bitstream. * + * @param context context + * @param community community * @param is the stream to use as the new logo * * @return the new logo bitstream, or null if there is no * logo (null was passed in) + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Bitstream setLogo(Context context, Community community, InputStream is) throws AuthorizeException, IOException, SQLException; @@ -139,9 +158,11 @@ public interface CommunityService extends DSpaceObjectService, DSpace * Returns either the newly created group or the previously existing one. * Note that other groups may also be administrators. * + * @param context context + * @param community community * @return the default group of editors associated with this community - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Group createAdministrators(Context context, Community community) throws SQLException, AuthorizeException; @@ -150,6 +171,10 @@ public interface CommunityService extends DSpaceObjectService, DSpace * then return without error. This will merely dereference the current * administrators group from the community so that it may be deleted * without violating database constraints. + * @param context context + * @param community community + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void removeAdministrators(Context context, Community community) throws SQLException, AuthorizeException; @@ -157,14 +182,20 @@ public interface CommunityService extends DSpaceObjectService, DSpace * Return an array of parent communities of this community, in ascending * order. If community is top-level, return an empty array. * + * @param context context + * @param community community * @return an array of parent communities, empty if top-level + * @throws SQLException if database error */ public List getAllParents(Context context, Community community) throws SQLException; /** * Return an array of collections of this community and its subcommunities * + * @param context context + * @param community community * @return an array of collections + * @throws SQLException if database error */ public List getAllCollections(Context context, Community community) throws SQLException; @@ -173,8 +204,12 @@ public interface CommunityService extends DSpaceObjectService, DSpace /** * Add an exisiting collection to the community * + * @param context context + * @param community community * @param collection * collection to add + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void addCollection(Context context, Community community, Collection collection) throws SQLException, AuthorizeException; @@ -182,26 +217,37 @@ public interface CommunityService extends DSpaceObjectService, DSpace /** * Create a new sub-community within this community. * + * @param context context + * @param parentCommunity parent community * @return the new community + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Community createSubcommunity(Context context, Community parentCommunity) throws SQLException, AuthorizeException; /** * Create a new sub-community within this community. * + * @param context context * @param handle the pre-determined Handle to assign to the new community + * @param parentCommunity parent community * @return the new community + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Community createSubcommunity(Context context, Community parentCommunity, String handle) throws SQLException, AuthorizeException; /** - * Add an exisiting community as a subcommunity to the community + * Add an existing community as a subcommunity to the community * + * @param context context * @param parentCommunity * parent community to add our subcommunity to * @param childCommunity * subcommunity to add + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void addSubcommunity(Context context, Community parentCommunity, Community childCommunity) throws SQLException, AuthorizeException; @@ -211,11 +257,12 @@ public interface CommunityService extends DSpaceObjectService, DSpace * then it is permanently deleted. If it has more than one parent community, * it is simply unmapped from the current community. * - * @param c - * collection to remove - * @throws SQLException - * @throws AuthorizeException - * @throws IOException + * @param context context + * @param c collection to remove + * @param community community + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ public void removeCollection(Context context, Community community, Collection c) throws SQLException, AuthorizeException, IOException; @@ -225,11 +272,13 @@ public interface CommunityService extends DSpaceObjectService, DSpace * then it is permanently deleted. If it has more than one parent community, * it is simply unmapped from the current community. * + * @param context context * @param childCommunity * subcommunity to remove - * @throws SQLException - * @throws AuthorizeException - * @throws IOException + * @param parentCommunity parent community + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ public void removeSubcommunity(Context context, Community parentCommunity, Community childCommunity) throws SQLException, AuthorizeException, IOException; @@ -237,7 +286,10 @@ public interface CommunityService extends DSpaceObjectService, DSpace /** * return TRUE if context's user can edit community, false otherwise * + * @param context context + * @param community community * @return boolean true = current user can edit community + * @throws SQLException if database error */ public boolean canEditBoolean(Context context, Community community) throws java.sql.SQLException; diff --git a/dspace-api/src/main/java/org/dspace/content/service/DSpaceObjectLegacySupportService.java b/dspace-api/src/main/java/org/dspace/content/service/DSpaceObjectLegacySupportService.java index 1420a57266..b5023f4afa 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/DSpaceObjectLegacySupportService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/DSpaceObjectLegacySupportService.java @@ -17,6 +17,7 @@ import java.sql.SQLException; * to identify DSpaceObjects prior to DSpace 6.0 * * @author kevinvandevelde at atmire.com + * @param class type */ public interface DSpaceObjectLegacySupportService { diff --git a/dspace-api/src/main/java/org/dspace/content/service/DSpaceObjectService.java b/dspace-api/src/main/java/org/dspace/content/service/DSpaceObjectService.java index 1f82f71ed5..4997de29ad 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/DSpaceObjectService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/DSpaceObjectService.java @@ -25,6 +25,7 @@ import java.util.UUID; * are required to have. * * @author kevinvandevelde at atmire.com + * @param class type */ public interface DSpaceObjectService { @@ -46,6 +47,7 @@ public interface DSpaceObjectService { * Get a proper name for the object. This may return null. * Name should be suitable for display in a user interface. * + * @param dso DSpaceObject * @return Name for the object, or null if it doesn't have * one */ @@ -54,6 +56,8 @@ public interface DSpaceObjectService { /** * Tries to lookup all Identifiers of this DSpaceObject. + * @param context DSpace context + * @param dso DSpaceObject * @return An array containing all found identifiers or an array with a length of 0. */ public ArrayList getIdentifiers(Context context, T dso); @@ -66,9 +70,11 @@ public interface DSpaceObjectService { * current one, where allowed ADMIN actions imply allowed ADMIN actions on * the object self. * + * @param context DSpace context + * @param dso DSpaceObject * @return the dspace object that "own" the current object in * the hierarchy - * @throws SQLException + * @throws SQLException if database error */ public DSpaceObject getParentObject(Context context, T dso) throws SQLException; @@ -80,6 +86,8 @@ public interface DSpaceObjectService { * action on the object itself. Subclass should override this method as * needed. * + * @param context DSpace context + * @param dso DSpaceObject * @param action * ID of action being attempted, from * org.dspace.core.Constants. The ADMIN action is @@ -87,7 +95,7 @@ public interface DSpaceObjectService { * IllegalArgumentException should be thrown * @return the dspace object, if any, where an ADMIN action is sufficient to * grant the original action - * @throws SQLException + * @throws SQLException if database error * @throws IllegalArgumentException * if the ADMIN action is supplied as parameter of the method * call @@ -96,6 +104,7 @@ public interface DSpaceObjectService { /** * Provide the text name of the type of this DSpaceObject. It is most likely all uppercase. + * @param dso DSpaceObject * @return Object type as text */ public String getTypeText(T dso); @@ -127,7 +136,7 @@ public interface DSpaceObjectService { * combination is significant. When retrieving with wildcards, values of a * particular element/qualifier/language combinations will be adjacent, but * the overall ordering of the combinations is indeterminate. - * + * @param dSpaceObject DSpaceObject * @param schema * the schema for the metadata field. Must match * the name of an existing metadata schema. @@ -145,17 +154,20 @@ public interface DSpaceObjectService { * values with no language are returned, and * DSpaceObject.ANY means values with any country code or * no country code are returned. + * * @return metadata fields that match the parameters */ public List getMetadata(T dSpaceObject, String schema, String element, String qualifier, String lang); /** * Retrieve metadata field values from a given metadata string - * of the form .[.|.*] + * of the form {@code .[.|.*]} * + * @param dSpaceObject DSpaceObject * @param mdString * The metadata string of the form - * .[.|.*] + * {@code .[.|.*]} + * @return metadata fields that match the parameters */ public List getMetadataByMetadataString(T dSpaceObject, String mdString); @@ -163,6 +175,7 @@ public interface DSpaceObjectService { /** * Get the value of a metadata field * + * @param dSpaceObject DSpaceObject * @param value * the name of the metadata field to get * @@ -186,6 +199,9 @@ public interface DSpaceObjectService { * If metadata authority control is available, try to get authority * values. The authority confidence depends on whether authority is * required or not. + * + * @param context DSpace context + * @param dso DSpaceObject * @param schema * the schema for the metadata field. Must match * the name of an existing metadata schema. @@ -200,6 +216,7 @@ public interface DSpaceObjectService { * value has no language (for example, a date). * @param values * the values to add. + * @throws SQLException if database error */ public void addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, List values) throws SQLException; @@ -207,6 +224,9 @@ public interface DSpaceObjectService { * Add metadata fields. These are appended to existing values. * Use clearDC to remove values. The ordering of values * passed in is maintained. + * + * @param context DSpace context + * @param dso DSpaceObject * @param schema * the schema for the metadata field. Must match * the name of an existing metadata schema. @@ -225,6 +245,7 @@ public interface DSpaceObjectService { * the external authority key for this value (or null) * @param confidences * the authority confidence (default 0) + * @throws SQLException if database error */ public void addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, List values, List authorities, List confidences) throws SQLException; @@ -232,6 +253,9 @@ public interface DSpaceObjectService { * Add metadata fields. These are appended to existing values. * Use clearDC to remove values. The ordering of values * passed in is maintained. + * + * @param context DSpace context + * @param dso DSpaceObject * @param metadataField * the metadata field to which the value is to be set * @param lang @@ -244,6 +268,7 @@ public interface DSpaceObjectService { * the external authority key for this value (or null) * @param confidences * the authority confidence (default 0) + * @throws SQLException if database error */ public void addMetadata(Context context, T dso, MetadataField metadataField, String lang, List values, List authorities, List confidences) throws SQLException; @@ -251,11 +276,14 @@ public interface DSpaceObjectService { public void addMetadata(Context context, T dso, MetadataField metadataField, String language, String value) throws SQLException; + public void addMetadata(Context context, T dso, MetadataField metadataField, String language, List values) throws SQLException; /** * Add a single metadata field. This is appended to existing * values. Use clearDC to remove values. * + * @param context DSpace context + * @param dso DSpaceObject * @param schema * the schema for the metadata field. Must match * the name of an existing metadata schema. @@ -270,6 +298,7 @@ public interface DSpaceObjectService { * value has no language (for example, a date). * @param value * the value to add. + * @throws SQLException if database error */ public void addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value) throws SQLException; @@ -277,6 +306,8 @@ public interface DSpaceObjectService { * Add a single metadata field. This is appended to existing * values. Use clearDC to remove values. * + * @param context DSpace context + * @param dso DSpaceObject * @param schema * the schema for the metadata field. Must match * the name of an existing metadata schema. @@ -295,6 +326,7 @@ public interface DSpaceObjectService { * the external authority key for this value (or null) * @param confidence * the authority confidence (default 0) + * @throws SQLException if database error */ public void addMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value, String authority, int confidence) throws SQLException; @@ -306,6 +338,8 @@ public interface DSpaceObjectService { * Thus, dspaceobject.clearDC(Item.ANY, Item.ANY, Item.ANY) will * remove all Dublin Core metadata associated with an DSpaceObject. * + * @param context DSpace context + * @param dso DSpaceObject * @param schema * the schema for the metadata field. Must match * the name of an existing metadata schema. @@ -321,6 +355,7 @@ public interface DSpaceObjectService { * values with no language are removed, and Item.ANY * means values with any country code or no country code are * removed. + * @throws SQLException if database error */ public void clearMetadata(Context context, T dso, String schema, String element, String qualifier, String lang) throws SQLException; @@ -329,6 +364,25 @@ public interface DSpaceObjectService { public String getMetadataFirstValue(T dso, String schema, String element, String qualifier, String language); /** * Set first metadata field value + * @param context DSpace context + * @param dso DSpaceObject + * @param schema + * the schema for the metadata field. Must match + * the name of an existing metadata schema. + * @param element + * the Dublin Core element to remove, or Item.ANY + * @param qualifier + * the qualifier. null means unqualified, and + * Item.ANY means any qualifier (including + * unqualified.) + * @param language + * the ISO639 language code, optionally followed by an underscore + * and the ISO3166 country code. null means only + * values with no language are removed, and Item.ANY + * means values with any country code or no country code are + * removed. + * @param value metadata value + * @throws SQLException if database error */ public void setMetadataSingleValue(Context context, T dso, String schema, String element, String qualifier, String language, String value) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/content/service/InProgressSubmissionService.java b/dspace-api/src/main/java/org/dspace/content/service/InProgressSubmissionService.java index fa878b0940..c08935bda7 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/InProgressSubmissionService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/InProgressSubmissionService.java @@ -19,16 +19,25 @@ import java.sql.SQLException; * are required to have. * * @author kevinvandevelde at atmire.com + * @param class type */ public interface InProgressSubmissionService { /** * Deletes submission wrapper, doesn't delete item contents + * @param context context + * @param inProgressSubmission submission + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void deleteWrapper(Context context, T inProgressSubmission) throws SQLException, AuthorizeException; /** * Update the submission, including the unarchived item. + * @param context context + * @param inProgressSubmission submission + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void update(Context context, T inProgressSubmission) throws SQLException, AuthorizeException; } diff --git a/dspace-api/src/main/java/org/dspace/content/service/InstallItemService.java b/dspace-api/src/main/java/org/dspace/content/service/InstallItemService.java index 273c0e80df..3fe6e1e4f0 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/InstallItemService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/InstallItemService.java @@ -33,6 +33,8 @@ public interface InstallItemService { * submission to install * * @return the fully archived Item + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Item installItem(Context context, InProgressSubmission is) throws SQLException, AuthorizeException; @@ -47,6 +49,9 @@ public interface InstallItemService { * the existing Handle to give to the installed item * * @return the fully archived Item + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Item installItem(Context c, InProgressSubmission is, String suppliedHandle) throws SQLException, @@ -68,6 +73,9 @@ public interface InstallItemService { * to create a new one. * * @return the fully archived Item + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Item restoreItem(Context c, InProgressSubmission is, String suppliedHandle) throws SQLException, IOException, AuthorizeException; @@ -76,9 +84,11 @@ public interface InstallItemService { * Generate provenance-worthy description of the bitstreams contained in an * item. * + * @param context context * @param myitem the item to generate description for * * @return provenance description + * @throws SQLException if database error */ public String getBitstreamProvenanceMessage(Context context, Item myitem) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/content/service/ItemService.java b/dspace-api/src/main/java/org/dspace/content/service/ItemService.java index aad6852f44..5f639bc9ed 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/ItemService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/ItemService.java @@ -37,11 +37,11 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * since items need to be created as workspace items. Authorisation is the * responsibility of the caller. * - * @param context - * DSpace context object + * @param context DSpace context object + * @param workspaceItem in progress workspace item * @return the newly created item - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Item create(Context context, WorkspaceItem workspaceItem) throws SQLException, AuthorizeException; @@ -51,8 +51,11 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * the collection after doing this, or the item will have been created but * the collection record will not refer to it. * - * @throws SQLException - * @throws AuthorizeException + * @param context DSpace context object + * @param collection Collection (parent) + * @return Item + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Item createTemplateItem(Context context, Collection collection) throws SQLException, AuthorizeException; @@ -60,10 +63,9 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * Get all the items in the archive. Only items with the "in archive" flag * set are included. The order of the list is indeterminate. * - * @param context - * DSpace context object + * @param context DSpace context object * @return an iterator over the items in the archive. - * @throws SQLException + * @throws SQLException if database error */ public Iterator findAll(Context context) throws SQLException; @@ -74,7 +76,7 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * @param context * DSpace context object * @return an iterator over the items in the archive. - * @throws SQLException + * @throws SQLException if database error */ public Iterator findAllUnfiltered(Context context) throws SQLException; @@ -87,42 +89,49 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * @param eperson * the submitter * @return an iterator over the items submitted by eperson - * @throws SQLException + * @throws SQLException if database error */ public Iterator findBySubmitter(Context context, EPerson eperson) throws SQLException; /** * Retrieve the list of Items submitted by eperson, ordered by recently submitted, optionally limitable - * @param context - * @param eperson + * @param context context + * @param eperson eperson * @param limit a positive integer to limit, -1 or null for unlimited * @return - * @throws SQLException + * @throws SQLException if database error */ public Iterator findBySubmitterDateSorted(Context context, EPerson eperson, Integer limit) throws SQLException; /** * Get all the items in this collection. The order is indeterminate. * + * @param context DSpace context object + * @param collection Collection (parent) * @return an iterator over the items in the collection. - * @throws SQLException + * @throws SQLException if database error */ public Iterator findByCollection(Context context, Collection collection) throws SQLException; /** * Get all the items in this collection. The order is indeterminate. * + * @param context DSpace context object + * @param collection Collection (parent) + * @param limit limited number of items + * @param offset offset value * @return an iterator over the items in the collection. - * @throws SQLException + * @throws SQLException if database error */ public Iterator findByCollection(Context context, Collection collection, Integer limit, Integer offset) throws SQLException; /** * Get all Items installed or withdrawn, discoverable, and modified since a Date. - * @param context + * @param context context * @param since earliest interesting last-modified date, or null for no date test. - * @return + * @return an iterator over the items in the collection. + * @throws SQLException if database error */ public Iterator findInArchiveOrWithdrawnDiscoverableModifiedSince(Context context, Date since) throws SQLException; @@ -130,16 +139,19 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega /** * Get all the items in this collection. The order is indeterminate. * + * @param context DSpace context object + * @param collection Collection (parent) * @return an iterator over the items in the collection. - * @throws SQLException + * @throws SQLException if database error */ public Iterator findAllByCollection(Context context, Collection collection) throws SQLException; /** * See whether this Item is contained by a given Collection. - * @param collection + * @param item Item + * @param collection Collection (parent * @return true if {@code collection} contains this Item. - * @throws SQLException + * @throws SQLException if database error */ public boolean isIn(Item item, Collection collection) throws SQLException; @@ -148,8 +160,10 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * communities that house the collections this item is in, including parent * communities of the owning collections. * + * @param context DSpace context object + * @param item Item * @return the communities this item is in. - * @throws SQLException + * @throws SQLException if database error */ public List getCommunities(Context context, Item item) throws SQLException; @@ -157,8 +171,10 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega /** * Get the bundles matching a bundle name (name corresponds roughly to type) * + * @param item Item * @param name * name of bundle (ORIGINAL/TEXT/THUMBNAIL) + * @throws SQLException if database error * * @return the bundles in an unordered array */ @@ -167,10 +183,12 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega /** * Add an existing bundle to this item. This has immediate effect. * + * @param context DSpace context object + * @param item Item * @param bundle * the bundle to add - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void addBundle(Context context, Item item, Bundle bundle) throws SQLException, AuthorizeException; @@ -178,11 +196,13 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * Remove a bundle. This may result in the bundle being deleted, if the * bundle is orphaned. * + * @param context DSpace context object + * @param item Item * @param bundle * the bundle to remove - * @throws SQLException - * @throws AuthorizeException - * @throws java.io.IOException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ public void removeBundle(Context context, Item item, Bundle bundle) throws SQLException, AuthorizeException, IOException; @@ -190,12 +210,12 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega /** * Remove all bundles linked to this item. This may result in the bundle being deleted, if the * bundle is orphaned. - * + * @param context DSpace context object * @param item * the item from which to remove our bundles - * @throws SQLException - * @throws AuthorizeException - * @throws java.io.IOException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ public void removeAllBundles(Context context, Item item) throws AuthorizeException, SQLException, IOException; @@ -203,14 +223,16 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * Create a single bitstream in a new bundle. Provided as a convenience * method for the most common use. * + * @param context DSpace context object + * @param item Item * @param is * the stream to create the new bitstream from * @param name * is the name of the bundle (ORIGINAL, TEXT, THUMBNAIL) * @return Bitstream that is created - * @throws AuthorizeException - * @throws IOException - * @throws SQLException + * @throws AuthorizeException if authorization error + * @throws IOException if IO error + * @throws SQLException if database error */ public Bitstream createSingleBitstream(Context context, InputStream is, Item item, String name) throws AuthorizeException, IOException, SQLException; @@ -218,12 +240,14 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega /** * Convenience method, calls createSingleBitstream() with name "ORIGINAL" * + * @param context DSpace context object + * @param item Item * @param is * InputStream * @return created bitstream - * @throws AuthorizeException - * @throws IOException - * @throws SQLException + * @throws AuthorizeException if authorization error + * @throws IOException if IO error + * @throws SQLException if database error */ public Bitstream createSingleBitstream(Context context, InputStream is, Item item) throws AuthorizeException, IOException, SQLException; @@ -232,8 +256,10 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * Get all non-internal bitstreams in the item. This is mainly used for * auditing for provenance messages and adding format.* DC values. The order * is indeterminate. - * + * @param context DSpace context object + * @param item Item * @return non-internal bitstreams. + * @throws SQLException if database error */ public List getNonInternalBitstreams(Context context, Item item) throws SQLException; @@ -244,9 +270,11 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega *

    * This method is used by the org.dspace.submit.step.LicenseStep class * - * @throws SQLException - * @throws AuthorizeException - * @throws IOException + * @param context DSpace context object + * @param item Item + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ public void removeDSpaceLicense(Context context, Item item) throws SQLException, AuthorizeException, IOException; @@ -254,9 +282,11 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega /** * Remove all licenses from an item - it was rejected * - * @throws SQLException - * @throws AuthorizeException - * @throws IOException + * @param context DSpace context object + * @param item Item + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ public void removeLicenses(Context context, Item item) throws SQLException, AuthorizeException, IOException; @@ -264,8 +294,10 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * Withdraw the item from the archive. It is kept in place, and the content * and metadata are not deleted, but it is not publicly accessible. * - * @throws SQLException - * @throws AuthorizeException + * @param context DSpace context object + * @param item Item + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void withdraw(Context context, Item item) throws SQLException, AuthorizeException; @@ -273,14 +305,17 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega /** * Reinstate a withdrawn item * - * @throws SQLException - * @throws AuthorizeException + * @param context DSpace context object + * @param item Item + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void reinstate(Context context, Item item) throws SQLException, AuthorizeException; /** * Return true if this Collection 'owns' this item * + * @param item Item * @param collection * Collection * @return true if this Collection owns this item @@ -291,11 +326,13 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * remove all of the policies for item and replace them with a new list of * policies * + * @param context DSpace context object + * @param item Item * @param newpolicies - * this will be all of the new policies for the item and its * contents - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void replaceAllItemPolicies(Context context, Item item, List newpolicies) throws SQLException, AuthorizeException; @@ -304,11 +341,13 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * remove all of the policies for item's bitstreams and bundles and replace * them with a new list of policies * + * @param context DSpace context object + * @param item Item * @param newpolicies - * this will be all of the new policies for the bundle and * bitstream contents - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void replaceAllBitstreamPolicies(Context context, Item item, List newpolicies) throws SQLException, AuthorizeException; @@ -318,9 +357,12 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * remove all of the policies for item's bitstreams and bundles that belong * to a given Group * + * @param context DSpace context object + * @param item Item * @param group * Group referenced by policies that needs to be removed - * @throws SQLException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void removeGroupPolicies(Context context, Item item, Group group) throws SQLException, AuthorizeException; @@ -329,12 +371,14 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * the DEFAULT_ITEM_READ and DEFAULT_BITSTREAM_READ policies belonging to * the collection. * + * @param context DSpace context object + * @param item Item * @param collection * Collection - * @throws java.sql.SQLException + * @throws SQLException if database error * if an SQL error or if no default policies found. It's a bit * draconian, but default policies must be enforced. - * @throws AuthorizeException + * @throws AuthorizeException if authorization error */ public void inheritCollectionDefaultPolicies(Context context, Item item, Collection collection) throws java.sql.SQLException, AuthorizeException; @@ -347,43 +391,57 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega /** * Moves the item from one collection to another one * - * @throws SQLException - * @throws AuthorizeException - * @throws IOException + * @param context DSpace context object + * @param item Item + * @param from Collection to move from + * @param to Collection to move to + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ public void move(Context context, Item item, Collection from, Collection to) throws SQLException, AuthorizeException, IOException; /** * Moves the item from one collection to another one * - * @throws SQLException - * @throws AuthorizeException - * @throws IOException + * @param context DSpace context object + * @param item Item + * @param from Collection to move from + * @param to Collection to move to + * @param inheritDefaultPolicies whether to inherit policies from new collection + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ public void move (Context context, Item item, Collection from, Collection to, boolean inheritDefaultPolicies) throws SQLException, AuthorizeException, IOException; /** * Check the bundle ORIGINAL to see if there are any uploaded files * + * @param item Item * @return true if there is a bundle named ORIGINAL with one or more * bitstreams inside - * @throws SQLException + * @throws SQLException if database error */ public boolean hasUploadedFiles(Item item) throws SQLException; /** * Get the collections this item is not in. * + * @param context DSpace context object + * @param item Item * @return the collections this item is not in, if any. - * @throws SQLException + * @throws SQLException if database error */ public List getCollectionsNotLinked(Context context, Item item) throws SQLException; /** * return TRUE if context's user can edit item, false otherwise * + * @param context DSpace context object + * @param item Item * @return boolean true = current user can edit item - * @throws SQLException + * @throws SQLException if database error */ public boolean canEdit(Context context, Item item) throws java.sql.SQLException; @@ -397,7 +455,9 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * @param qualifier metadata field qualifier * @param value field value or Item.ANY to match any value * @return an iterator over the items matching that authority value - * @throws SQLException, AuthorizeException, IOException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error * */ public Iterator findByMetadataField(Context context, @@ -417,7 +477,9 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * @param qualifier metadata field qualifier * @param value the value of authority key to look for * @return an iterator over the items matching that authority value - * @throws SQLException, AuthorizeException, IOException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ public Iterator findByAuthorityValue(Context context, String schema, String element, String qualifier, String value) @@ -430,25 +492,29 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega * Service method for knowing if this Item should be visible in the item list. * Items only show up in the "item list" if the user has READ permission * and if the Item isn't flagged as unlisted. - * @param context - * @param item - * @return + * @param context context + * @param item item + * @return true or false */ public boolean isItemListedForUser(Context context, Item item); /** * counts items in the given collection * - * @return total items + * @param context DSpace context object + * @param collection Collection + * @return total items + * @throws SQLException if database error */ public int countItems(Context context, Collection collection) throws SQLException; /** * Find all Items modified since a Date. * - * @param context + * @param context context * @param last Earliest interesting last-modified date. - * @return + * @return iterator over items + * @throws SQLException if database error */ public Iterator findByLastModifiedSince(Context context, Date last) throws SQLException; @@ -456,13 +522,37 @@ public interface ItemService extends DSpaceObjectService, DSpaceObjectLega /** * counts items in the given community * + * @param context DSpace context object + * @param community Community * @return total items + * @throws SQLException if database error */ public int countItems(Context context, Community community) throws SQLException; + /** + * counts all items + * + * @param context DSpace context object + * @return total items + * @throws SQLException if database error + */ int countTotal(Context context) throws SQLException; + /** + * counts all items not in archive + * + * @param context DSpace context object + * @return total items + * @throws SQLException if database error + */ int countNotArchivedItems(Context context) throws SQLException; + /** + * counts all withdrawn items + * + * @param context DSpace context object + * @return total items + * @throws SQLException if database error + */ int countWithdrawnItems(Context context) throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/content/service/MetadataFieldService.java b/dspace-api/src/main/java/org/dspace/content/service/MetadataFieldService.java index ee1240f808..4199498010 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/MetadataFieldService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/MetadataFieldService.java @@ -30,9 +30,13 @@ public interface MetadataFieldService { * * @param context * DSpace context object - * @throws IOException - * @throws AuthorizeException - * @throws SQLException + * @param metadataSchema schema + * @param scopeNote scope note + * @param element element + * @param qualifier qualifier + * @return new MetadataField + * @throws AuthorizeException if authorization error + * @throws SQLException if database error * @throws NonUniqueMetadataException */ public MetadataField create(Context context, MetadataSchema metadataSchema, String element, String qualifier, String scopeNote) @@ -47,7 +51,7 @@ public interface MetadataFieldService { * @param id * the metadata field ID * @return the metadata field object - * @throws SQLException + * @throws SQLException if database error */ public MetadataField find(Context context, int id) throws SQLException; @@ -59,7 +63,7 @@ public interface MetadataFieldService { * @param element element name * @param qualifier qualifier (may be ANY or null) * @return recalled metadata field - * @throws SQLException + * @throws SQLException if database error */ public MetadataField findByElement(Context context, MetadataSchema metadataSchema, String element, String qualifier) throws SQLException; @@ -75,7 +79,7 @@ public interface MetadataFieldService { * * @param context dspace context * @return an array of all the Dublin Core types - * @throws SQLException + * @throws SQLException if database error */ public List findAll(Context context) throws SQLException; @@ -85,7 +89,7 @@ public interface MetadataFieldService { * @param context dspace context * @param metadataSchema the metadata schema for which we want all our metadata fields * @return array of metadata fields - * @throws SQLException + * @throws SQLException if database error */ public List findAllInSchema(Context context, MetadataSchema metadataSchema) throws SQLException; @@ -95,10 +99,11 @@ public interface MetadataFieldService { * Update the metadata field in the database. * * @param context dspace context - * @throws SQLException - * @throws AuthorizeException + * @param metadataField metadata field + * @throws SQLException if database error + * @throws AuthorizeException if authorization error * @throws NonUniqueMetadataException - * @throws IOException + * @throws IOException if IO error */ public void update(Context context, MetadataField metadataField) throws SQLException, AuthorizeException, NonUniqueMetadataException, IOException; @@ -107,8 +112,9 @@ public interface MetadataFieldService { * Delete the metadata field. * * @param context dspace context - * @throws SQLException - * @throws AuthorizeException + * @param metadataField metadata field + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void delete(Context context, MetadataField metadataField) throws SQLException, AuthorizeException; } diff --git a/dspace-api/src/main/java/org/dspace/content/service/MetadataSchemaService.java b/dspace-api/src/main/java/org/dspace/content/service/MetadataSchemaService.java index f44ee0d6fa..b2a2e45662 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/MetadataSchemaService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/MetadataSchemaService.java @@ -24,12 +24,15 @@ import java.util.List; public interface MetadataSchemaService { /** - * Creates a new metadata schema in the database, using the name & namspace. + * Creates a new metadata schema in the database, using the name and namespace. * * @param context * DSpace context object - * @throws SQLException - * @throws AuthorizeException + * @param name name + * @param namespace namespace + * @return new MetadataSchema + * @throws SQLException if database error + * @throws AuthorizeException if authorization error * @throws NonUniqueMetadataException */ public MetadataSchema create(Context context, String name, String namespace) throws SQLException, AuthorizeException, NonUniqueMetadataException; @@ -40,7 +43,7 @@ public interface MetadataSchemaService { * @param context DSpace context * @param namespace namespace URI to match * @return metadata schema object or null if none found. - * @throws SQLException + * @throws SQLException if database error */ public MetadataSchema findByNamespace(Context context, String namespace) throws SQLException; @@ -48,8 +51,9 @@ public interface MetadataSchemaService { * Update the metadata schema in the database. * * @param context DSpace context - * @throws SQLException - * @throws AuthorizeException + * @param metadataSchema metadata schema + * @throws SQLException if database error + * @throws AuthorizeException if authorization error * @throws NonUniqueMetadataException */ public void update(Context context, MetadataSchema metadataSchema) throws SQLException, AuthorizeException, NonUniqueMetadataException; @@ -58,8 +62,9 @@ public interface MetadataSchemaService { * Delete the metadata schema. * * @param context DSpace context - * @throws SQLException - * @throws AuthorizeException + * @param metadataSchema metadata schema + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public void delete(Context context, MetadataSchema metadataSchema) throws SQLException, AuthorizeException; @@ -68,7 +73,7 @@ public interface MetadataSchemaService { * * @param context DSpace context * @return array of metadata schemas - * @throws SQLException + * @throws SQLException if database error */ public List findAll(Context context) throws SQLException; @@ -81,7 +86,7 @@ public interface MetadataSchemaService { * @param id * the schema ID * @return the metadata schema object - * @throws SQLException + * @throws SQLException if database error */ public MetadataSchema find(Context context, int id) throws SQLException; @@ -93,7 +98,7 @@ public interface MetadataSchemaService { * @param shortName * the short name for the schema * @return the metadata schema object - * @throws SQLException + * @throws SQLException if database error */ public MetadataSchema find(Context context, String shortName) throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/content/service/MetadataValueService.java b/dspace-api/src/main/java/org/dspace/content/service/MetadataValueService.java index 3f67de7eab..71356f0292 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/MetadataValueService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/MetadataValueService.java @@ -30,7 +30,10 @@ public interface MetadataValueService { * * @param context * DSpace context object - * @throws java.sql.SQLException + * @param dso DSpaceObject + * @param metadataField metadata field + * @return new MetadataValue + * @throws SQLException if database error */ public MetadataValue create(Context context, DSpaceObject dso, MetadataField metadataField) throws SQLException; @@ -41,7 +44,7 @@ public interface MetadataValueService { * @param valueId database key id of value * @return recalled metadata value * @throws java.io.IOException - * @throws SQLException + * @throws SQLException if database error */ public MetadataValue find(Context context, int valueId) throws IOException, SQLException; @@ -53,8 +56,8 @@ public interface MetadataValueService { * @param context dspace context * @param metadataField metadata field whose values to look for * @return a collection of metadata values - * @throws IOException - * @throws SQLException + * @throws IOException if IO error + * @throws SQLException if database error */ public List findByField(Context context, MetadataField metadataField) throws IOException, SQLException; @@ -63,7 +66,8 @@ public interface MetadataValueService { * Update the metadata value in the database. * * @param context dspace context - * @throws SQLException + * @param metadataValue metadata value + * @throws SQLException if database error */ public void update(Context context, MetadataValue metadataValue) throws SQLException; @@ -73,7 +77,8 @@ public interface MetadataValueService { * Delete the metadata field. * * @param context dspace context - * @throws SQLException + * @param metadataValue metadata value + * @throws SQLException if database error */ public void delete(Context context, MetadataValue metadataValue) throws SQLException; @@ -87,7 +92,7 @@ public interface MetadataValueService { * @param context * @param metadataFieldId unique identifier of the interesting field. * @return - * @throws SQLException + * @throws SQLException if database error */ public MetadataValue getMinimum(Context context, int metadataFieldId) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/content/service/SupervisedItemService.java b/dspace-api/src/main/java/org/dspace/content/service/SupervisedItemService.java index 19735ca28b..e1a48596df 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/SupervisedItemService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/SupervisedItemService.java @@ -28,6 +28,7 @@ public interface SupervisedItemService * @param context the context this object exists in * * @return array of SupervisedItems + * @throws SQLException if database error */ public List getAll(Context context) throws SQLException; @@ -39,6 +40,7 @@ public interface SupervisedItemService * @param context the dspace context * * @return the items eperson is supervising in an array + * @throws SQLException if database error */ public List findbyEPerson(Context context, EPerson ep) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/content/service/WorkspaceItemService.java b/dspace-api/src/main/java/org/dspace/content/service/WorkspaceItemService.java index 98e3a95328..061dd0dd24 100644 --- a/dspace-api/src/main/java/org/dspace/content/service/WorkspaceItemService.java +++ b/dspace-api/src/main/java/org/dspace/content/service/WorkspaceItemService.java @@ -38,6 +38,7 @@ public interface WorkspaceItemService extends InProgressSubmissionService findByEPerson(Context context, EPerson ep) throws SQLException; @@ -86,6 +90,7 @@ public interface WorkspaceItemService extends InProgressSubmissionService findByCollection(Context context, Collection collection) throws SQLException; @@ -101,6 +106,7 @@ public interface WorkspaceItemService extends InProgressSubmissionService findAll(Context context) throws SQLException; @@ -123,6 +130,11 @@ public interface WorkspaceItemService extends InProgressSubmissionService> getStageReachedCounts(Context context) throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/core/AbstractHibernateDAO.java b/dspace-api/src/main/java/org/dspace/core/AbstractHibernateDAO.java index 9c7517e845..3d83109e3d 100644 --- a/dspace-api/src/main/java/org/dspace/core/AbstractHibernateDAO.java +++ b/dspace-api/src/main/java/org/dspace/core/AbstractHibernateDAO.java @@ -8,7 +8,9 @@ package org.dspace.core; import org.apache.commons.collections.CollectionUtils; -import org.hibernate.*; +import org.hibernate.Criteria; +import org.hibernate.Query; +import org.hibernate.Session; import org.hibernate.criterion.Projections; import java.sql.SQLException; @@ -22,6 +24,7 @@ import java.util.UUID; * Each DAO should extend this class to prevent code duplication. * * @author kevinvandevelde at atmire.com + * @param class type */ public abstract class AbstractHibernateDAO implements GenericDAO { @@ -93,7 +96,7 @@ public abstract class AbstractHibernateDAO implements GenericDAO { * @param context * @param query * @return - * @throws SQLException + * @throws SQLException if database error */ public List findMany(Context context, Query query) throws SQLException { @SuppressWarnings("unchecked") @@ -149,6 +152,7 @@ public abstract class AbstractHibernateDAO implements GenericDAO { */ public T singleResult(Criteria criteria) { + criteria.setMaxResults(1); List list = list(criteria); if(CollectionUtils.isNotEmpty(list)) { @@ -159,6 +163,17 @@ public abstract class AbstractHibernateDAO implements GenericDAO { } + public T singleResult(final Query query) { + query.setMaxResults(1); + List list = list(query); + if(CollectionUtils.isNotEmpty(list)) + { + return list.get(0); + }else{ + return null; + } + } + public T uniqueResult(Query query) { @SuppressWarnings("unchecked") diff --git a/dspace-api/src/main/java/org/dspace/core/AbstractHibernateDSODAO.java b/dspace-api/src/main/java/org/dspace/core/AbstractHibernateDSODAO.java index 1b6a78517b..db91b7a0fc 100644 --- a/dspace-api/src/main/java/org/dspace/core/AbstractHibernateDSODAO.java +++ b/dspace-api/src/main/java/org/dspace/core/AbstractHibernateDSODAO.java @@ -23,6 +23,7 @@ import java.util.List; * Each DSO Database Access Objects should extend this class to prevent code duplication. * * @author kevinvandevelde at atmire.com + * @param class type */ public abstract class AbstractHibernateDSODAO extends AbstractHibernateDAO { diff --git a/dspace-api/src/main/java/org/dspace/core/Constants.java b/dspace-api/src/main/java/org/dspace/core/Constants.java index e70e5abe2f..88ebbbbadc 100644 --- a/dspace-api/src/main/java/org/dspace/core/Constants.java +++ b/dspace-api/src/main/java/org/dspace/core/Constants.java @@ -143,7 +143,7 @@ public class Constants /** * generating constants for the relevance array dynamically is simple: just - * 1 << TYPE + * {@code 1 << TYPE} */ public static final int RBITSTREAM = 1 << BITSTREAM; diff --git a/dspace-api/src/main/java/org/dspace/core/Context.java b/dspace-api/src/main/java/org/dspace/core/Context.java index 9382c40e25..56512ce986 100644 --- a/dspace-api/src/main/java/org/dspace/core/Context.java +++ b/dspace-api/src/main/java/org/dspace/core/Context.java @@ -7,9 +7,6 @@ */ package org.dspace.core; -import java.sql.SQLException; -import java.util.*; - import org.apache.log4j.Logger; import org.dspace.eperson.EPerson; import org.dspace.eperson.Group; @@ -22,6 +19,9 @@ import org.dspace.storage.rdbms.DatabaseConfigVO; import org.dspace.utils.DSpace; import org.springframework.util.CollectionUtils; +import java.sql.SQLException; +import java.util.*; + /** * Class representing the context of a particular DSpace operation. This stores * information such as the current authenticated user and the database @@ -89,10 +89,11 @@ public class Context init(); } + /** * Construct a new context object with default options. A database connection is opened. * No user is authenticated. - * + * * @exception SQLException * if there was an error obtaining a database connection */ @@ -106,8 +107,6 @@ public class Context * No user is authenticated. * * @param options context operation flags - * @exception SQLException - * if there was an error obtaining a database connection */ public Context(short options) { @@ -159,7 +158,6 @@ public class Context return dbConnection; } - public DatabaseConfigVO getDBConfig() throws SQLException { return dbConnection.getDatabaseConfig(); @@ -351,8 +349,41 @@ public class Context if(!isValid()) log.info("complete() was called on a closed Context object. No changes to commit."); - // FIXME: Might be good not to do a commit() if nothing has actually - // been written using this connection + try + { + // As long as we have a valid, writeable database connection, + // commit any changes made as part of the transaction + commit(); + } + finally + { + if(dbConnection != null) + { + // Free the DB connection + dbConnection.closeDBConnection(); + dbConnection = null; + } + } + } + + /** + * Commit the current transaction with the database, persisting any pending changes. + * The database connection is not closed and can be reused afterwards. + * + * WARNING: After calling this method all previously fetched entities are "detached" (pending + * changes are not tracked anymore). You have to reload all entities you still want to work with + * manually after this method call (see {@link Context#reloadEntity(ReloadableEntity)}). + * + * @throws SQLException When committing the transaction in the database fails. + */ + public void commit() throws SQLException + { + // If Context is no longer open/valid, just note that it has already been closed + if(!isValid()) { + log.info("commit() was called on a closed Context object. No changes to commit."); + } + + // Our DB Connection (Hibernate) will decide if an actual commit is required or not try { // As long as we have a valid, writeable database connection, @@ -361,16 +392,17 @@ public class Context { dispatchEvents(); } - } - finally - { + + } finally { + if(log.isDebugEnabled()) { + log.debug("Cache size on commit is " + getCacheSize()); + } + if(dbConnection != null) { //Commit our changes dbConnection.commit(); - // Free the DB connection - dbConnection.closeDBConnection(); - dbConnection = null; + reloadContextBoundEntities(); } } } @@ -402,6 +434,7 @@ public class Context /** * Select an event dispatcher, null selects the default * + * @param dispatcher dispatcher */ public void setDispatcher(String dispatcher) { @@ -453,7 +486,7 @@ public class Context } /** - * Retrieves the first element in the events list & removes it from the list of events once retrieved + * Retrieves the first element in the events list and removes it from the list of events once retrieved * @return The first event of the list or null if the list is empty */ public Event pollEvent() @@ -564,7 +597,8 @@ public class Context /** * Get an array of all of the special groups that current user is a member * of. - * @throws SQLException + * @return list of groups + * @throws SQLException if database error */ public List getSpecialGroups() throws SQLException { @@ -584,7 +618,7 @@ public class Context * If a context is garbage-collected, we roll back and free up the * database connection if there is one. */ - if (dbConnection.isTransActionAlive()) + if (dbConnection != null && dbConnection.isTransActionAlive()) { abort(); } @@ -596,7 +630,82 @@ public class Context dbConnection.shutdown(); } + /** + * Clear the cache of all object that have been read from the database so far. This will also free up + * (heap space) memory. You should use this method when processing a large number of records. + * + * WARNING: After calling this method all previously fetched entities are "detached" (pending + * changes are not tracked anymore). You have to reload all entities you still want to work with + * manually after this method call (see {@link Context#reloadEntity(ReloadableEntity)}). + * + * This method will take care of reloading the current user. + * + * @throws SQLException When clearing the entity cache fails + */ public void clearCache() throws SQLException { + if(log.isDebugEnabled()) { + log.debug("Cache size before clear cache is " + getCacheSize()); + } + this.getDBConnection().clearCache(); - } + + reloadContextBoundEntities(); + } + + /** + * Returns the size of the cache of all object that have been read from the database so far. A larger number + * means that more memory is consumed by the cache. This also has a negative impact on the query performance. In + * that case you should consider clearing the cache (see {@link Context#clearCache() clearCache}). + * + * @throws SQLException When connecting to the active cache fails. + */ + public long getCacheSize() throws SQLException { + return this.getDBConnection().getCacheSize(); + } + + /** + * Enable or disable "batch processing mode" for this context. + * + * Enabling batch processing mode means that the database connection is configured so that it is optimized to + * process a large number of records. + * + * Disabling batch processing mode restores the normal behaviour that is optimal for querying and updating a + * small number of records. + * + * @param batchModeEnabled When true, batch processing mode will be enabled. If false, it will be disabled. + * @throws SQLException When configuring the database connection fails. + */ + public void enableBatchMode(boolean batchModeEnabled) throws SQLException { + dbConnection.setOptimizedForBatchProcessing(batchModeEnabled); + } + + /** + * Check if "batch processing mode" is enabled for this context. + * @return True if batch processing mode is enabled, false otherwise. + */ + public boolean isBatchModeEnabled() { + return dbConnection.isOptimizedForBatchProcessing(); + } + + /** + * Reload an entity from the database into the cache. This method will return a reference to the "attached" + * entity. This means changes to the entity will be tracked and persisted to the database. + * + * @param entity The entity to reload + * @param The class of the enity. The entity must implement the {@link ReloadableEntity} interface. + * @return A (possibly) NEW reference to the entity that should be used for further processing. + * @throws SQLException When reloading the entity from the database fails. + */ + @SuppressWarnings("unchecked") + public E reloadEntity(E entity) throws SQLException { + return (E) dbConnection.reloadEntity(entity); + } + + /** + * Reload all entities related to this context. + * @throws SQLException When reloading one of the entities fails. + */ + private void reloadContextBoundEntities() throws SQLException { + currentUser = reloadEntity(currentUser); + } } diff --git a/dspace-api/src/main/java/org/dspace/core/DBConnection.java b/dspace-api/src/main/java/org/dspace/core/DBConnection.java index d9f9b80ea4..9450ccc001 100644 --- a/dspace-api/src/main/java/org/dspace/core/DBConnection.java +++ b/dspace-api/src/main/java/org/dspace/core/DBConnection.java @@ -16,6 +16,7 @@ import java.sql.SQLException; * Interface representing a Database connection, this class should only be access by the context object. * * @author kevinvandevelde at atmire.com + * @param class type */ public interface DBConnection { @@ -40,4 +41,16 @@ public interface DBConnection { public DatabaseConfigVO getDatabaseConfig() throws SQLException; public void clearCache() throws SQLException; + + public void setOptimizedForBatchProcessing(boolean batchOptimized) throws SQLException; + + public boolean isOptimizedForBatchProcessing(); + + public long getCacheSize() throws SQLException; + + /** + * Reload a DSpace object from the database. This will make sure the object is valid and stored in the cache. + * @param entity The DSpace object to reload + */ + public E reloadEntity(E entity) throws SQLException; } \ No newline at end of file diff --git a/dspace-api/src/main/java/org/dspace/core/Email.java b/dspace-api/src/main/java/org/dspace/core/Email.java index 7fcdbfdc24..9a5ecb6d90 100644 --- a/dspace-api/src/main/java/org/dspace/core/Email.java +++ b/dspace-api/src/main/java/org/dspace/core/Email.java @@ -232,7 +232,7 @@ public class Email * * @throws MessagingException * if there was a problem sending the mail. - * @throws IOException + * @throws IOException if IO error */ public void send() throws MessagingException, IOException { @@ -370,7 +370,7 @@ public class Email * @return the email object, with the content and subject filled out from * the template * - * @throws IOException + * @throws IOException if IO error * if the template couldn't be found, or there was some other * error reading the template */ diff --git a/dspace-api/src/main/java/org/dspace/core/GenericDAO.java b/dspace-api/src/main/java/org/dspace/core/GenericDAO.java index 5139526b43..6e13e9e73a 100644 --- a/dspace-api/src/main/java/org/dspace/core/GenericDAO.java +++ b/dspace-api/src/main/java/org/dspace/core/GenericDAO.java @@ -7,6 +7,8 @@ */ package org.dspace.core; +import org.dspace.content.DSpaceObject; + import java.sql.SQLException; import java.util.List; import java.util.UUID; @@ -17,6 +19,7 @@ import java.util.UUID; * The default hibernate implementation offers up a class that implements all these methods. * * @author kevinvandevelde at atmire.com + * @param class type */ public interface GenericDAO { @@ -32,7 +35,7 @@ public interface GenericDAO * @param context * @param clazz the desired type. * @return - * @throws SQLException + * @throws SQLException if database error */ public List findAll(Context context, Class clazz) throws SQLException; @@ -42,7 +45,7 @@ public interface GenericDAO * @param context * @param query * @return - * @throws SQLException + * @throws SQLException if database error */ public T findUnique(Context context, String query) throws SQLException; @@ -56,7 +59,7 @@ public interface GenericDAO * @param context * @param query * @return - * @throws SQLException + * @throws SQLException if database error */ public List findMany(Context context, String query) throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/core/HibernateDBConnection.java b/dspace-api/src/main/java/org/dspace/core/HibernateDBConnection.java index 7803b87e1d..e6f529f63e 100644 --- a/dspace-api/src/main/java/org/dspace/core/HibernateDBConnection.java +++ b/dspace-api/src/main/java/org/dspace/core/HibernateDBConnection.java @@ -7,16 +7,20 @@ */ package org.dspace.core; +import org.dspace.content.DSpaceObject; import org.dspace.storage.rdbms.DatabaseConfigVO; +import org.hibernate.FlushMode; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.proxy.HibernateProxyHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.orm.hibernate4.SessionFactoryUtils; import javax.sql.DataSource; +import java.io.Serializable; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.SQLException; @@ -32,10 +36,13 @@ public class HibernateDBConnection implements DBConnection { @Qualifier("sessionFactory") private SessionFactory sessionFactory; + private boolean batchModeEnabled = false; + @Override public Session getSession() throws SQLException { if(!isTransActionAlive()){ sessionFactory.getCurrentSession().beginTransaction(); + configureBatchMode(); } return sessionFactory.getCurrentSession(); } @@ -74,6 +81,7 @@ public class HibernateDBConnection implements DBConnection { public void commit() throws SQLException { if(isTransActionAlive() && !getTransaction().wasRolledBack()) { + getSession().flush(); getTransaction().commit(); } } @@ -110,6 +118,43 @@ public class HibernateDBConnection implements DBConnection { @Override public void clearCache() throws SQLException { - this.getSession().clear(); + getSession().flush(); + getSession().clear(); } + + @Override + public long getCacheSize() throws SQLException { + return getSession().getStatistics().getEntityCount(); + } + + @Override + @SuppressWarnings("unchecked") + public E reloadEntity(final E entity) throws SQLException { + if(entity == null) { + return null; + } else if(getSession().contains(entity)) { + return entity; + } else { + return (E) getSession().get(HibernateProxyHelper.getClassWithoutInitializingProxy(entity), entity.getID()); + } + } + + @Override + public void setOptimizedForBatchProcessing(final boolean batchOptimized) throws SQLException { + this.batchModeEnabled = batchOptimized; + configureBatchMode(); + } + + @Override + public boolean isOptimizedForBatchProcessing() { + return batchModeEnabled; + } + + private void configureBatchMode() throws SQLException { + if(batchModeEnabled) { + getSession().setFlushMode(FlushMode.ALWAYS); + } else { + getSession().setFlushMode(FlushMode.AUTO); + } + } } \ No newline at end of file diff --git a/dspace-api/src/main/java/org/dspace/core/I18nUtil.java b/dspace-api/src/main/java/org/dspace/core/I18nUtil.java index 2fa03be9b0..aba0bff4e3 100644 --- a/dspace-api/src/main/java/org/dspace/core/I18nUtil.java +++ b/dspace-api/src/main/java/org/dspace/core/I18nUtil.java @@ -97,7 +97,8 @@ public class I18nUtil * Get the Locale for a specified EPerson. If the language is missing, * return the default Locale for the repository. * - * @param ep + * @param ep Eperson + * @return Locale */ public static Locale getEPersonLocale(EPerson ep) { diff --git a/dspace-api/src/main/java/org/dspace/core/LegacyPluginServiceImpl.java b/dspace-api/src/main/java/org/dspace/core/LegacyPluginServiceImpl.java index cbdc0959f9..35b9f1b0fb 100644 --- a/dspace-api/src/main/java/org/dspace/core/LegacyPluginServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/core/LegacyPluginServiceImpl.java @@ -24,8 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired; /** * The Legacy Plugin Service is a very simple component container (based on the - * legacy PluginManager class from <=5.x). It reads defined "plugins" (interfaces) - * from config file(s) and makes them available to the API. (@TODO: Someday, this + * legacy PluginManager class from 5.x or below). It reads defined "plugins" (interfaces) + * from config file(s) and makes them available to the API. (TODO: Someday, this * entire "plugin" framework needs to be replaced by Spring Beans.) *

    * It creates and organizes components (plugins), and helps select a plugin in @@ -90,7 +90,7 @@ public class LegacyPluginServiceImpl implements PluginService @Autowired(required = true) protected ConfigurationService configurationService; - private LegacyPluginServiceImpl() { + protected LegacyPluginServiceImpl() { } /** @@ -548,6 +548,7 @@ public class LegacyPluginServiceImpl implements PluginService *

  • Implementations of named plugin have no name collisions. *
  • Named plugin entries lacking names. * + * @throws IOException if IO error */ public void checkConfiguration() throws IOException @@ -712,6 +713,8 @@ public class LegacyPluginServiceImpl implements PluginService * Invoking this class from the command line just runs * checkConfiguration and shows the results. * There are no command-line options. + * @param argv arguments + * @throws Exception if error */ public void main(String[] argv) throws Exception { diff --git a/dspace-api/src/main/java/org/dspace/core/PluginConfigurationError.java b/dspace-api/src/main/java/org/dspace/core/PluginConfigurationError.java index a2dac6b502..7e02c05f85 100644 --- a/dspace-api/src/main/java/org/dspace/core/PluginConfigurationError.java +++ b/dspace-api/src/main/java/org/dspace/core/PluginConfigurationError.java @@ -16,7 +16,7 @@ package org.dspace.core; * * @author Larry Stone * @version $Revision$ - * @see PluginService + * @see org.dspace.core.service.PluginService */ public class PluginConfigurationError extends Error diff --git a/dspace-api/src/main/java/org/dspace/core/PluginInstantiationException.java b/dspace-api/src/main/java/org/dspace/core/PluginInstantiationException.java index 24d4fd005e..2d498cd7be 100644 --- a/dspace-api/src/main/java/org/dspace/core/PluginInstantiationException.java +++ b/dspace-api/src/main/java/org/dspace/core/PluginInstantiationException.java @@ -19,7 +19,7 @@ package org.dspace.core; * * @author Larry Stone * @version $Revision$ - * @see PluginService + * @see org.dspace.core.service.PluginService */ public class PluginInstantiationException extends RuntimeException diff --git a/dspace-api/src/main/java/org/dspace/core/ReloadableEntity.java b/dspace-api/src/main/java/org/dspace/core/ReloadableEntity.java new file mode 100644 index 0000000000..87ee88bf5f --- /dev/null +++ b/dspace-api/src/main/java/org/dspace/core/ReloadableEntity.java @@ -0,0 +1,20 @@ +/** + * The contents of this file are subject to the license and copyright + * detailed in the LICENSE and NOTICE files at the root of the source + * tree and available online at + * + * http://www.dspace.org/license/ + */ +package org.dspace.core; + +import java.io.Serializable; + +/** + * Interface that has to be implemented by all entities that can be reloaded by the Context + * (see {@link org.dspace.core.Context#reloadEntity(ReloadableEntity)} ])} + */ +public interface ReloadableEntity { + + T getID(); + +} diff --git a/dspace-api/src/main/java/org/dspace/core/SelfNamedPlugin.java b/dspace-api/src/main/java/org/dspace/core/SelfNamedPlugin.java index 2cc9e6777b..e9a1002f8e 100644 --- a/dspace-api/src/main/java/org/dspace/core/SelfNamedPlugin.java +++ b/dspace-api/src/main/java/org/dspace/core/SelfNamedPlugin.java @@ -26,7 +26,7 @@ package org.dspace.core; * * @author Larry Stone * @version $Revision$ - * @see PluginService + * @see org.dspace.core.service.PluginService */ public abstract class SelfNamedPlugin { diff --git a/dspace-api/src/main/java/org/dspace/core/Utils.java b/dspace-api/src/main/java/org/dspace/core/Utils.java index 0f23801b3f..cdb297cbf4 100644 --- a/dspace-api/src/main/java/org/dspace/core/Utils.java +++ b/dspace-api/src/main/java/org/dspace/core/Utils.java @@ -217,6 +217,7 @@ public final class Utils * The InputStream to obtain data from. * @param output * The OutputStream to copy data to. + * @throws IOException if IO error */ public static void copy(final InputStream input, final OutputStream output) throws IOException @@ -253,6 +254,7 @@ public final class Utils * The InputStream to obtain data from. * @param destination * The OutputStream to copy data to. + * @throws IOException if IO error */ public static void bufferedCopy(final InputStream source, final OutputStream destination) throws IOException @@ -267,8 +269,8 @@ public final class Utils /** * Replace characters that could be interpreted as HTML codes with symbolic * references (entities). This function should be called before displaying - * any metadata fields that could contain the characters " <", ">", "&", - * "'", and double quotation marks. This will effectively disable HTML links + * any metadata fields that could contain the characters {@code "<", ">", "&", "'"}, + * and double quotation marks. This will effectively disable HTML links * in metadata. * * @param value @@ -283,7 +285,7 @@ public final class Utils } /** - * Utility method to parse durations defined as \d+[smhdwy] (seconds, + * Utility method to parse durations defined as {@code \d+[smhdwy]} (seconds, * minutes, hours, days, weeks, years) * * @param duration diff --git a/dspace-api/src/main/java/org/dspace/core/service/LicenseService.java b/dspace-api/src/main/java/org/dspace/core/service/LicenseService.java index d0f36bed61..732fe93b53 100644 --- a/dspace-api/src/main/java/org/dspace/core/service/LicenseService.java +++ b/dspace-api/src/main/java/org/dspace/core/service/LicenseService.java @@ -20,6 +20,7 @@ public interface LicenseService { * @param licenseFile * name for the file into which license will be written, * relative to the current directory. + * @param newLicense new license */ public void writeLicenseFile(String licenseFile, String newLicense); diff --git a/dspace-api/src/main/java/org/dspace/core/service/NewsService.java b/dspace-api/src/main/java/org/dspace/core/service/NewsService.java index c342ae0305..7612614f25 100644 --- a/dspace-api/src/main/java/org/dspace/core/service/NewsService.java +++ b/dspace-api/src/main/java/org/dspace/core/service/NewsService.java @@ -19,6 +19,7 @@ public interface NewsService { * * @param newsFile * name of the news file to read in, relative to the news file path. + * @return contents */ public String readNewsFile(String newsFile); @@ -29,12 +30,14 @@ public interface NewsService { * name of the news file to read in, relative to the news file path. * @param news * the text to be written to the file. + * @return string */ public String writeNewsFile(String newsFile, String news); /** * Get the path for the news files. * + * @return path */ public String getNewsFilePath(); diff --git a/dspace-api/src/main/java/org/dspace/core/service/PluginService.java b/dspace-api/src/main/java/org/dspace/core/service/PluginService.java index 14f1a7a301..ef8cd3393c 100644 --- a/dspace-api/src/main/java/org/dspace/core/service/PluginService.java +++ b/dspace-api/src/main/java/org/dspace/core/service/PluginService.java @@ -9,7 +9,7 @@ package org.dspace.core.service; /** * A service to manage "plugins". At this point, it's based off of the structure - * of the legacy PluginManager (<=5.x), until a better plugin definition is created. + * of the legacy PluginManager (5.x or below), until a better plugin definition is created. *

    * In DSpace, a "plugin" corresponds simply to a Java interface. Plugin implementations * are simply classes which implement that interface (and often they are given unique diff --git a/dspace-api/src/main/java/org/dspace/ctask/general/ClamScan.java b/dspace-api/src/main/java/org/dspace/ctask/general/ClamScan.java index c40459cc19..eecdd89a25 100644 --- a/dspace-api/src/main/java/org/dspace/ctask/general/ClamScan.java +++ b/dspace-api/src/main/java/org/dspace/ctask/general/ClamScan.java @@ -240,7 +240,7 @@ public class ClamScan extends AbstractCurationTask * @param the InputStream to read * @param the item handle for reporting results * @return a ScanResult representing the server response - * @throws IOException + * @throws IOException if IO error */ final byte[] buffer = new byte[DEFAULT_CHUNK_SIZE];; protected int scan(Bitstream bitstream, InputStream inputstream, String itemHandle) diff --git a/dspace-api/src/main/java/org/dspace/ctask/general/MetadataWebService.java b/dspace-api/src/main/java/org/dspace/ctask/general/MetadataWebService.java index bfcf8bd6ff..c71c24c730 100644 --- a/dspace-api/src/main/java/org/dspace/ctask/general/MetadataWebService.java +++ b/dspace-api/src/main/java/org/dspace/ctask/general/MetadataWebService.java @@ -24,7 +24,6 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.namespace.NamespaceContext; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import javax.xml.XMLConstants; @@ -65,7 +64,7 @@ import org.dspace.curate.Suspendable; * Intended use: cataloging tool in workflow and general curation. * The task uses a URL 'template' to compose the service call, e.g. * - * http://www.sherpa.ac.uk/romeo/api29.php?issn={dc.identifier.issn} + * {@code http://www.sherpa.ac.uk/romeo/api29.php?issn=\{dc.identifier.issn\}} * * Task will substitute the value of the passed item's metadata field * in the {parameter} position. If multiple values are present in the @@ -74,19 +73,19 @@ import org.dspace.curate.Suspendable; * The task uses another property (the datamap) to determine what data * to extract from the service response and how to use it, e.g. * - * //publisher/name=>dc.publisher,//romeocolour + * {@code //publisher/name=>dc.publisher,//romeocolour} * * Task will evaluate the left-hand side (or entire token) of each * comma-separated token in the property as an XPath 1.0 expression into - * the response document, and if there is a mapping symbol (e.g.'=>') and + * the response document, and if there is a mapping symbol (e.g. {@code '=>'}) and * value, it will assign the response document value(s) to the named * metadata field in the passed item. If the response document contains * multiple values, they will all be assigned to the item field. The * mapping symbol governs the nature of metadata field assignment: * - * '->' mapping will add to any existing values in the item field - * '=>' mapping will replace any existing values in the item field - * '~>' mapping will add *only* if item field has no existing values + * {@code '->'} mapping will add to any existing values in the item field + * {@code '=>'} mapping will replace any existing values in the item field + * {@code '~>'} mapping will add *only* if item field has no existing values * * Unmapped data (without a mapping symbol) will simply be added to the task * result string, prepended by the XPath expression (a little prettified). @@ -95,21 +94,21 @@ import org.dspace.curate.Suspendable; * * A very rudimentary facility for transformation of data is supported, e.g. * - * http://www.crossref.org/openurl/?id={doi:dc.relation.isversionof}&format=unixref + * {@code http://www.crossref.org/openurl/?id=\{doi:dc.relation.isversionof\}&format=unixref} * * The 'doi:' prefix will cause the task to look for a 'transform' with that * name, which is applied to the metadata value before parameter substitution * occurs. Transforms are defined in a task property such as the following: * - * transform.doi = match 10. trunc 60 + * {@code transform.doi = match 10. trunc 60} * * This means exclude the value string up to the occurrence of '10.', then * truncate after 60 characters. The only transform functions currently defined: * - * 'cut' = remove number leading characters - * 'trunc' = remove trailing characters after number length - * 'match' = start match at pattern - * 'text' = append literal characters (enclose in ' ' when whitespace needed) + * {@code 'cut' } = remove number leading characters + * {@code 'trunc' } = remove trailing characters after number length + * {@code 'match' } = start match at pattern + * {@code 'text' } = append literal characters (enclose in ' ' when whitespace needed) * * If the transform results in an invalid state (e.g. cutting more characters * than are in the value), the condition will be logged and the @@ -117,7 +116,7 @@ import org.dspace.curate.Suspendable; * * Transforms may also be used in datamaps, e.g. * - * //publisher/name=>shorten:dc.publisher,//romeocolour + * {@code //publisher/name=>shorten:dc.publisher,//romeocolour} * * which would apply the 'shorten' transform to the service response value(s) * prior to metadata field assignment. @@ -125,7 +124,7 @@ import org.dspace.curate.Suspendable; * An optional property 'headers' may be defined to stipulate any HTTP headers * required in the service call. The property syntax is double-pipe separated headers: * - * Accept: text/xml||Cache-Control: no-cache + * {@code Accept: text/xml||Cache-Control: no-cache} * * @author richardrodgers */ @@ -214,7 +213,7 @@ public class MetadataWebService extends AbstractCurationTask implements Namespac * Perform the curation task upon passed DSO * * @param dso the DSpace object - * @throws IOException + * @throws IOException if IO error */ @Override public int perform(DSpaceObject dso) throws IOException { diff --git a/dspace-api/src/main/java/org/dspace/ctask/general/ProfileFormats.java b/dspace-api/src/main/java/org/dspace/ctask/general/ProfileFormats.java index c72821d40b..1bcda07851 100644 --- a/dspace-api/src/main/java/org/dspace/ctask/general/ProfileFormats.java +++ b/dspace-api/src/main/java/org/dspace/ctask/general/ProfileFormats.java @@ -36,7 +36,7 @@ public class ProfileFormats extends AbstractCurationTask * Perform the curation task upon passed DSO * * @param dso the DSpace object - * @throws IOException + * @throws IOException if IO error */ @Override public int perform(DSpaceObject dso) throws IOException diff --git a/dspace-api/src/main/java/org/dspace/ctask/general/RequiredMetadata.java b/dspace-api/src/main/java/org/dspace/ctask/general/RequiredMetadata.java index 670d7861d3..1168b7156f 100644 --- a/dspace-api/src/main/java/org/dspace/ctask/general/RequiredMetadata.java +++ b/dspace-api/src/main/java/org/dspace/ctask/general/RequiredMetadata.java @@ -59,7 +59,7 @@ public class RequiredMetadata extends AbstractCurationTask * Perform the curation task upon passed DSO * * @param dso the DSpace object - * @throws IOException + * @throws IOException if IO error */ @Override public int perform(DSpaceObject dso) throws IOException diff --git a/dspace-api/src/main/java/org/dspace/curate/AbstractCurationTask.java b/dspace-api/src/main/java/org/dspace/curate/AbstractCurationTask.java index 9529e6cc1c..986332c4f6 100644 --- a/dspace-api/src/main/java/org/dspace/curate/AbstractCurationTask.java +++ b/dspace-api/src/main/java/org/dspace/curate/AbstractCurationTask.java @@ -77,7 +77,7 @@ public abstract class AbstractCurationTask implements CurationTask * DSOs or just all Items, respectively. * * @param dso current DSpaceObject - * @throws IOException + * @throws IOException if IO error */ protected void distribute(DSpaceObject dso) throws IOException { @@ -137,8 +137,8 @@ public abstract class AbstractCurationTask implements CurationTask * distribute method is used. * * @param dso the DSpaceObject - * @throws SQLException - * @throws IOException + * @throws SQLException if database error + * @throws IOException if IO error */ protected void performObject(DSpaceObject dso) throws SQLException, IOException { @@ -163,8 +163,8 @@ public abstract class AbstractCurationTask implements CurationTask * distribute method is used. * * @param item the DSpace Item - * @throws SQLException - * @throws IOException + * @throws SQLException if database error + * @throws IOException if IO error */ protected void performItem(Item item) throws SQLException, IOException { @@ -187,7 +187,7 @@ public abstract class AbstractCurationTask implements CurationTask * canonical id of object * @return dso * DSpace object, or null if no object with id exists - * @throws IOException + * @throws IOException if IO error */ protected DSpaceObject dereference(Context ctx, String id) throws IOException { diff --git a/dspace-api/src/main/java/org/dspace/curate/CitationPage.java b/dspace-api/src/main/java/org/dspace/curate/CitationPage.java index 570bd96afe..6c5ae56d34 100644 --- a/dspace-api/src/main/java/org/dspace/curate/CitationPage.java +++ b/dspace-api/src/main/java/org/dspace/curate/CitationPage.java @@ -196,9 +196,9 @@ public class CitationPage extends AbstractCurationTask { * bundle. * @param item The item containing the bundles being used. * @param bitstream The original source bitstream. - * @throws SQLException - * @throws AuthorizeException - * @throws IOException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ protected void addCitedPageToItem(File citedTemp, Bundle bundle, Bundle pBundle, Bundle dBundle, Map displayMap, Item item, diff --git a/dspace-api/src/main/java/org/dspace/curate/CurationTask.java b/dspace-api/src/main/java/org/dspace/curate/CurationTask.java index c94b2e0656..77ab483cbf 100644 --- a/dspace-api/src/main/java/org/dspace/curate/CurationTask.java +++ b/dspace-api/src/main/java/org/dspace/curate/CurationTask.java @@ -27,7 +27,7 @@ public interface CurationTask * * @param curator the Curator controlling this task * @param taskId identifier task should use in invoking services - * @throws IOException + * @throws IOException if error */ void init(Curator curator, String taskId) throws IOException; @@ -36,7 +36,7 @@ public interface CurationTask * * @param dso the DSpace object * @return status code - * @throws IOException + * @throws IOException if error */ int perform(DSpaceObject dso) throws IOException; @@ -46,7 +46,7 @@ public interface CurationTask * @param ctx DSpace context object * @param id persistent ID for DSpace object * @return status code - * @throws Exception + * @throws IOException if error */ int perform(Context ctx, String id) throws IOException; } diff --git a/dspace-api/src/main/java/org/dspace/curate/Curator.java b/dspace-api/src/main/java/org/dspace/curate/Curator.java index e5964dd7d9..d52cba77e9 100644 --- a/dspace-api/src/main/java/org/dspace/curate/Curator.java +++ b/dspace-api/src/main/java/org/dspace/curate/Curator.java @@ -180,7 +180,7 @@ public class Curator * * @param c a Dpace context * @param id an object identifier - * @throws IOException + * @throws IOException if IO error */ public void curate(Context c, String id) throws IOException { @@ -234,7 +234,7 @@ public class Curator * authenticated Context object. * * @param dso the DSpace object - * @throws IOException + * @throws IOException if IO error */ public void curate(DSpaceObject dso) throws IOException { @@ -274,7 +274,7 @@ public class Curator * @param id an object Id * @param queueId name of a queue. If queue does not exist, it will * be created automatically. - * @throws IOException + * @throws IOException if IO error */ public void queue(Context c, String id, String queueId) throws IOException { @@ -391,11 +391,11 @@ public class Curator } /** - * Run task for entire Site (including all Communities, Collections & Items) + * Run task for entire Site (including all Communities, Collections and Items) * @param tr TaskRunner * @param site DSpace Site object * @return true if successful, false otherwise - * @throws IOException + * @throws IOException if IO error */ protected boolean doSite(TaskRunner tr, Site site) throws IOException { @@ -443,7 +443,7 @@ public class Curator * @param tr TaskRunner * @param comm Community * @return true if successful, false otherwise - * @throws IOException + * @throws IOException if IO error */ protected boolean doCommunity(TaskRunner tr, Community comm) throws IOException { @@ -473,7 +473,7 @@ public class Curator * @param tr TaskRunner * @param coll Collection * @return true if successful, false otherwise - * @throws IOException + * @throws IOException if IO error */ protected boolean doCollection(TaskRunner tr, Collection coll) throws IOException { diff --git a/dspace-api/src/main/java/org/dspace/curate/ResolvedTask.java b/dspace-api/src/main/java/org/dspace/curate/ResolvedTask.java index 7dfdc42023..7c3051cd09 100644 --- a/dspace-api/src/main/java/org/dspace/curate/ResolvedTask.java +++ b/dspace-api/src/main/java/org/dspace/curate/ResolvedTask.java @@ -62,7 +62,7 @@ public class ResolvedTask * curation DI. * * @param curator the Curator controlling this task - * @throws IOException + * @throws IOException if IO error */ public void init(Curator curator) throws IOException { @@ -81,7 +81,7 @@ public class ResolvedTask * * @param dso the DSpace object * @return status code - * @throws IOException + * @throws IOException if error */ public int perform(DSpaceObject dso) throws IOException { @@ -94,7 +94,7 @@ public class ResolvedTask * @param ctx DSpace context object * @param id persistent ID for DSpace object * @return status code - * @throws Exception + * @throws IOException if error */ public int perform(Context ctx, String id) throws IOException { diff --git a/dspace-api/src/main/java/org/dspace/curate/ScriptedTask.java b/dspace-api/src/main/java/org/dspace/curate/ScriptedTask.java index c5d5f319f5..0e1d3ba8f9 100644 --- a/dspace-api/src/main/java/org/dspace/curate/ScriptedTask.java +++ b/dspace-api/src/main/java/org/dspace/curate/ScriptedTask.java @@ -30,7 +30,7 @@ public interface ScriptedTask * * @param curator the Curator controlling this task * @param taskId identifier task should use in invoking services - * @throws IOException + * @throws IOException if IO error */ public void init(Curator curator, String taskId) throws IOException; @@ -39,7 +39,7 @@ public interface ScriptedTask * * @param dso the DSpace object * @return status code - * @throws IOException + * @throws IOException if IO error */ public int performDso(DSpaceObject dso) throws IOException; @@ -49,7 +49,7 @@ public interface ScriptedTask * @param ctx DSpace context object * @param id persistent ID for DSpace object * @return status code - * @throws IOException + * @throws IOException if IO error */ public int performId(Context ctx, String id) throws IOException; } diff --git a/dspace-api/src/main/java/org/dspace/curate/TaskQueue.java b/dspace-api/src/main/java/org/dspace/curate/TaskQueue.java index 1ed2f3d320..e383aa6947 100644 --- a/dspace-api/src/main/java/org/dspace/curate/TaskQueue.java +++ b/dspace-api/src/main/java/org/dspace/curate/TaskQueue.java @@ -37,7 +37,7 @@ public interface TaskQueue { * the name of the queue on which to write * @param entry * the task entry - * @throws IOException + * @throws IOException if IO error */ void enqueue(String queueName, TaskQueueEntry entry) throws IOException; @@ -48,7 +48,7 @@ public interface TaskQueue { * the name of the queue on which to write * @param entrySet * the set of task entries - * @throws IOException + * @throws IOException if IO error */ void enqueue(String queueName, Set entrySet) throws IOException; @@ -64,7 +64,7 @@ public interface TaskQueue { * a token which must be presented to release the queue * @return set * the current set of queued task entries - * @throws IOException + * @throws IOException if IO error */ Set dequeue(String queueName, long ticket) throws IOException; diff --git a/dspace-api/src/main/java/org/dspace/curate/TaskResolver.java b/dspace-api/src/main/java/org/dspace/curate/TaskResolver.java index 5c12e577e0..516395d99b 100644 --- a/dspace-api/src/main/java/org/dspace/curate/TaskResolver.java +++ b/dspace-api/src/main/java/org/dspace/curate/TaskResolver.java @@ -41,24 +41,24 @@ import org.dspace.services.factory.DSpaceServicesFactory; * dspace/config/modules/curate.cfg property "script.dir". A catalog of * scripted tasks named 'task.catalog" is kept in this directory. * Each task has a 'descriptor' property with value syntax: - * || + * {@code ||} * An example property: * - * linkchecker = ruby|rubytask.rb|LinkChecker.new + * {@code linkchecker = ruby|rubytask.rb|LinkChecker.new} * * This descriptor means that a 'ruby' script engine will be created, - * a script file named 'rubytask.rb' in the directory will be + * a script file named 'rubytask.rb' in the directory {@code } will be * loaded and the resolver will expect an evaluation of 'LinkChecker.new' will * provide a correct implementation object. * * Script files may embed their descriptors to facilitate deployment. * To accomplish this, a script must include the descriptor string with syntax: - * $td= somewhere on a comment line. for example: + * {@code $td=} somewhere on a comment line. for example: * - * # My descriptor $td=ruby|rubytask.rb|LinkChecker.new + * {@code My descriptor $td=ruby|rubytask.rb|LinkChecker.new} * - * For portability, the component may be omitted in this context. - * Thus, $td=ruby||LinkChecker.new will be expanded to a descriptor + * For portability, the {@code } component may be omitted in this context. + * Thus, {@code$td=ruby||LinkChecker.new} will be expanded to a descriptor * with the name of the embedding file. * * @author richardrodgers diff --git a/dspace-api/src/main/java/org/dspace/curate/Utils.java b/dspace-api/src/main/java/org/dspace/curate/Utils.java index c1b69d5257..20cb6c4b48 100644 --- a/dspace-api/src/main/java/org/dspace/curate/Utils.java +++ b/dspace-api/src/main/java/org/dspace/curate/Utils.java @@ -39,7 +39,7 @@ public class Utils * @return checksum * string of the calculated checksum * - * @throws IOException + * @throws IOException if IO error */ public static String checksum(File file, String algorithm) throws IOException { @@ -71,7 +71,7 @@ public class Utils * @return checksum * string of the calculated checksum * - * @throws IOException + * @throws IOException if IO error */ public static String checksum(InputStream in, String algorithm) throws IOException { @@ -122,7 +122,7 @@ public class Utils * * @param inFile * @param outFile - * @throws IOException + * @throws IOException if IO error */ public static void copy(File inFile, File outFile) throws IOException { @@ -156,7 +156,7 @@ public class Utils * input stream * @param out * output stream - * @throws IOException + * @throws IOException if IO error */ public static void copy(InputStream in, OutputStream out) throws IOException { diff --git a/dspace-api/src/main/java/org/dspace/curate/service/WorkflowCuratorService.java b/dspace-api/src/main/java/org/dspace/curate/service/WorkflowCuratorService.java index 453a17fbcc..36cdb60cb5 100644 --- a/dspace-api/src/main/java/org/dspace/curate/service/WorkflowCuratorService.java +++ b/dspace-api/src/main/java/org/dspace/curate/service/WorkflowCuratorService.java @@ -35,9 +35,9 @@ public interface WorkflowCuratorService { * @return true if curation was completed or not required, * false if tasks were queued for later completion, * or item was rejected - * @throws AuthorizeException - * @throws IOException - * @throws SQLException + * @throws AuthorizeException if authorization error + * @throws IOException if IO error + * @throws SQLException if database error */ public boolean doCuration(Context c, BasicWorkflowItem wfi) throws AuthorizeException, IOException, SQLException; @@ -48,9 +48,9 @@ public interface WorkflowCuratorService { * * @param c the user context * @param wfId the workflow id - * @throws AuthorizeException - * @throws IOException - * @throws SQLException + * @throws AuthorizeException if authorization error + * @throws IOException if IO error + * @throws SQLException if database error */ public boolean curate(Curator curator, Context c, String wfId) throws AuthorizeException, IOException, SQLException; diff --git a/dspace-api/src/main/java/org/dspace/discovery/IndexClient.java b/dspace-api/src/main/java/org/dspace/discovery/IndexClient.java index ce4b0a5900..9d72900a0d 100644 --- a/dspace-api/src/main/java/org/dspace/discovery/IndexClient.java +++ b/dspace-api/src/main/java/org/dspace/discovery/IndexClient.java @@ -33,7 +33,7 @@ public class IndexClient { * * @param args the command-line arguments, none used * @throws java.io.IOException - * @throws java.sql.SQLException + * @throws SQLException if database error * */ public static void main(String[] args) throws SQLException, IOException, SearchServiceException { diff --git a/dspace-api/src/main/java/org/dspace/discovery/SearchService.java b/dspace-api/src/main/java/org/dspace/discovery/SearchService.java index 0f84961e6e..b5ba441c0d 100644 --- a/dspace-api/src/main/java/org/dspace/discovery/SearchService.java +++ b/dspace-api/src/main/java/org/dspace/discovery/SearchService.java @@ -34,7 +34,7 @@ public interface SearchService { * DSpace Context object. * @param query * the discovery query object. - * @throws SearchServiceException + * @throws SearchServiceException if search error */ DiscoverResult search(Context context, DiscoverQuery query) throws SearchServiceException; @@ -50,7 +50,7 @@ public interface SearchService { * within this object) * @param query * the discovery query object - * @throws SearchServiceException + * @throws SearchServiceException if search error */ DiscoverResult search(Context context, DSpaceObject dso, DiscoverQuery query) throws SearchServiceException; @@ -64,7 +64,7 @@ public interface SearchService { * @param includeWithdrawn * use true to include in the results also withdrawn * items that match the query. - * @throws SearchServiceException + * @throws SearchServiceException if search error */ DiscoverResult search(Context context, DiscoverQuery query, boolean includeWithdrawn) throws SearchServiceException; @@ -82,7 +82,7 @@ public interface SearchService { * use true to include in the results also withdrawn * items that match the query * - * @throws SearchServiceException + * @throws SearchServiceException if search error */ DiscoverResult search(Context context, DSpaceObject dso, DiscoverQuery query, boolean includeWithdrawn) throws SearchServiceException; @@ -101,7 +101,7 @@ public interface SearchService { * @param field the field of the filter query * @param value the filter query value * @return a filter query - * @throws SQLException ... + * @throws SQLException if database error */ DiscoverFilterQuery toFilterQuery(Context context, String field, String operator, String value) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/discovery/SolrServiceContentInOriginalBundleFilterPlugin.java b/dspace-api/src/main/java/org/dspace/discovery/SolrServiceContentInOriginalBundleFilterPlugin.java index 5ed5c73c52..85f2d671bd 100644 --- a/dspace-api/src/main/java/org/dspace/discovery/SolrServiceContentInOriginalBundleFilterPlugin.java +++ b/dspace-api/src/main/java/org/dspace/discovery/SolrServiceContentInOriginalBundleFilterPlugin.java @@ -25,7 +25,7 @@ import org.dspace.core.Context; * and add it to the expected place) just with an empty list of used metadata * fields because there are none. * - * @author Christian Scheible + * @author Christian Scheible christian.scheible@uni-konstanz.de * */ public class SolrServiceContentInOriginalBundleFilterPlugin implements SolrServiceIndexPlugin diff --git a/dspace-api/src/main/java/org/dspace/discovery/SolrServiceImpl.java b/dspace-api/src/main/java/org/dspace/discovery/SolrServiceImpl.java index 02bd46d83f..63fc69ea97 100644 --- a/dspace-api/src/main/java/org/dspace/discovery/SolrServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/discovery/SolrServiceImpl.java @@ -69,7 +69,7 @@ import java.util.*; * collections, communities, etc. It is meant to either be invoked from the * command line (see dspace/bin/index-all) or via the indexContent() methods * within DSpace. - *

    + *

    * The Administrator can choose to run SolrIndexer in a cron that repeats * regularly, a failed attempt to index from the UI will be "caught" up on in * that cron. @@ -173,8 +173,7 @@ public class SolrServiceImpl implements SearchService, IndexingService { * * @param context Users Context * @param dso DSpace Object (Item, Collection or Community - * @throws SQLException - * @throws IOException + * @throws SQLException if error */ @Override public void indexContent(Context context, DSpaceObject dso) @@ -190,8 +189,7 @@ public class SolrServiceImpl implements SearchService, IndexingService { * @param context Users Context * @param dso DSpace Object (Item, Collection or Community * @param force Force update even if not stale. - * @throws SQLException - * @throws IOException + * @throws SQLException if error */ @Override public void indexContent(Context context, DSpaceObject dso, @@ -256,8 +254,8 @@ public class SolrServiceImpl implements SearchService, IndexingService { * * @param context * @param dso DSpace Object, can be Community, Item, or Collection - * @throws SQLException - * @throws IOException + * @throws SQLException if database error + * @throws IOException if IO error */ @Override public void unIndexContent(Context context, DSpaceObject dso) @@ -271,8 +269,8 @@ public class SolrServiceImpl implements SearchService, IndexingService { * @param context * @param dso DSpace Object, can be Community, Item, or Collection * @param commit if true force an immediate commit on SOLR - * @throws SQLException - * @throws IOException + * @throws SQLException if database error + * @throws IOException if IO error */ @Override public void unIndexContent(Context context, DSpaceObject dso, boolean commit) @@ -298,8 +296,8 @@ public class SolrServiceImpl implements SearchService, IndexingService { * Unindex a Document in the Lucene index. * @param context the dspace context * @param handle the handle of the object to be deleted - * @throws IOException - * @throws SQLException + * @throws IOException if IO error + * @throws SQLException if database error */ @Override public void unIndexContent(Context context, String handle) throws IOException, SQLException { @@ -310,8 +308,8 @@ public class SolrServiceImpl implements SearchService, IndexingService { * Unindex a Document in the Lucene Index. * @param context the dspace context * @param handle the handle of the object to be deleted - * @throws SQLException - * @throws IOException + * @throws SQLException if database error + * @throws IOException if IO error */ @Override public void unIndexContent(Context context, String handle, boolean commit) @@ -380,7 +378,7 @@ public class SolrServiceImpl implements SearchService, IndexingService { * Iterates over all Items, Collections and Communities. And updates them in * the index. Uses decaching to control memory footprint. Uses indexContent * and isStale to check state of item in index. - *

    + *

    * At first it may appear counterintuitive to have an IndexWriter/Reader * opened and closed on each DSO. But this allows the UI processes to step * in and attain a lock and write to the index even if other processes/jvms @@ -648,8 +646,9 @@ public class SolrServiceImpl implements SearchService, IndexingService { /** + * @param context DSpace context * @param myitem the item for which our locations are to be retrieved - * @return a list containing the identifiers of the communities & collections + * @return a list containing the identifiers of the communities and collections * @throws SQLException sql exception */ protected List getItemLocations(Context context, Item myitem) @@ -746,8 +745,8 @@ public class SolrServiceImpl implements SearchService, IndexingService { * Build a solr document for a DSpace Community. * * @param community Community to be indexed - * @throws SQLException - * @throws IOException + * @throws SQLException if database error + * @throws IOException if IO error */ protected void buildDocument(Context context, Community community) throws SQLException, IOException { @@ -874,8 +873,8 @@ public class SolrServiceImpl implements SearchService, IndexingService { * * @param context Users Context * @param item The DSpace Item to be indexed - * @throws SQLException - * @throws IOException + * @throws SQLException if database error + * @throws IOException if IO error */ protected void buildDocument(Context context, Item item) throws SQLException, IOException { diff --git a/dspace-api/src/main/java/org/dspace/discovery/configuration/TagCloudConfiguration.java b/dspace-api/src/main/java/org/dspace/discovery/configuration/TagCloudConfiguration.java index d130cf8d47..61d8b244a6 100644 --- a/dspace-api/src/main/java/org/dspace/discovery/configuration/TagCloudConfiguration.java +++ b/dspace-api/src/main/java/org/dspace/discovery/configuration/TagCloudConfiguration.java @@ -203,7 +203,7 @@ public class TagCloudConfiguration { } /** - * @param ordering the locale to set + * @param locale the locale to set */ public void setLocale(String locale) { this.locale = locale; diff --git a/dspace-api/src/main/java/org/dspace/disseminate/CitationDocumentServiceImpl.java b/dspace-api/src/main/java/org/dspace/disseminate/CitationDocumentServiceImpl.java index 9ceee6ed38..d0ea59c934 100644 --- a/dspace-api/src/main/java/org/dspace/disseminate/CitationDocumentServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/disseminate/CitationDocumentServiceImpl.java @@ -253,7 +253,7 @@ public class CitationDocumentServiceImpl implements CitationDocumentService, Ini /** * Should the citation page be the first page of the document, or the last page? - * default => true. true => first page, false => last page + * default = true. true = first page, false = last page * citation_as_first_page=true */ protected Boolean citationAsFirstPage = null; diff --git a/dspace-api/src/main/java/org/dspace/disseminate/service/CitationDocumentService.java b/dspace-api/src/main/java/org/dspace/disseminate/service/CitationDocumentService.java index db3ca3f26d..9743579c0b 100644 --- a/dspace-api/src/main/java/org/dspace/disseminate/service/CitationDocumentService.java +++ b/dspace-api/src/main/java/org/dspace/disseminate/service/CitationDocumentService.java @@ -44,12 +44,20 @@ public interface CitationDocumentService { * This object is citation-able (presently, just PDF) * * The module must be enabled, before the permission level checks happen. - * @param bitstream - * @return + * @param bitstream DSpace bitstream + * @param context DSpace context + * @throws SQLException if error + * @return true or false */ public Boolean isCitationEnabledForBitstream(Bitstream bitstream, Context context) throws SQLException; - + /** + * + * @param context DSpace Context + * @param bitstream DSpace Bitstream + * @return true or false + * @throws SQLException if error + */ public boolean canGenerateCitationVersion(Context context, Bitstream bitstream) throws SQLException; /** @@ -64,33 +72,67 @@ public interface CitationDocumentService { *

  • Create cover page and add content to it.
  • *
  • Concatenate the coverpage and the source * document.
  • - *

    + * * + * @param context DSpace context * @param bitstream The source bitstream being cited. This must be a PDF. * @return The temporary File that is the finished, cited document. - * @throws java.io.FileNotFoundException - * @throws SQLException - * @throws org.dspace.authorize.AuthorizeException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public File makeCitedDocument(Context context, Bitstream bitstream) throws IOException, SQLException, AuthorizeException; + /** + * + * @param page page + * @param contentStream content stream + * @param text text to draw + * @param startX x-coordinate of word + * @param startY y-coordinate of word + * @param pdfFont font + * @param fontSize size of font + * @return integer + * @throws IOException if IO error + */ public int drawStringWordWrap(PDPage page, PDPageContentStream contentStream, String text, int startX, int startY, PDFont pdfFont, float fontSize) throws IOException; + /** + * Get name of owning community + * @param context DSpace context + * @param item DSpace Item + * @return name + */ public String getOwningCommunity(Context context, Item item); + /** + * Get name of owning collection + * @param item DSpace Item + * @return owning collection name + */ public String getOwningCollection(Item item); + /** + * Get metadata separated by value separator (semicolon) + * @param item DSpace Item + * @param metadataKey metadata string + * @see org.dspace.content.service.DSpaceObjectService#getMetadataByMetadataString(org.dspace.content.DSpaceObject, java.lang.String) + * @return string + */ public String getAllMetadataSeparated(Item item, String metadataKey); /** - * @param page - * @param contentStream + * @param page page + * @param contentStream content stream * @param y the y-coordinate of the first row * @param margin the padding on left and right of table * @param content a 2d array containing the table data - * @throws IOException + * @param font PDFont + * @param fontSize size of font (int) + * @param cellBorders whether to include cellBorders + * @throws IOException if error */ public void drawTable(PDPage page, PDPageContentStream contentStream, float y, float margin, diff --git a/dspace-api/src/main/java/org/dspace/embargo/DayTableEmbargoSetter.java b/dspace-api/src/main/java/org/dspace/embargo/DayTableEmbargoSetter.java index 6353ad97d5..b1a2a054ac 100644 --- a/dspace-api/src/main/java/org/dspace/embargo/DayTableEmbargoSetter.java +++ b/dspace-api/src/main/java/org/dspace/embargo/DayTableEmbargoSetter.java @@ -23,11 +23,11 @@ import org.dspace.services.factory.DSpaceServicesFactory; * to a fixed number of days. Table constructed from a dspace.cfg property * with syntax: * - * embargo.terms.days = 90 days:90,1 year:365,2 years:730 + * {@code embargo.terms.days = 90 days:90,1 year:365,2 years:730} * - * That is, an arbitrary, comma separated, list of : where - * can be any string and must be a positive integer. - * All the fields should be defined in a 'value-pairs' element, + * That is, an arbitrary, comma separated, list of {@code :} where {@code } + * can be any string and {@code } must be a positive integer. + * All the {@code } fields should be defined in a 'value-pairs' element, * and the field configured as the embargo terms should employ a drop-down using * that element in input_forms.xml, if user submission is desired. * diff --git a/dspace-api/src/main/java/org/dspace/embargo/EmbargoServiceImpl.java b/dspace-api/src/main/java/org/dspace/embargo/EmbargoServiceImpl.java index ffa2f9cf66..bde9843f7d 100644 --- a/dspace-api/src/main/java/org/dspace/embargo/EmbargoServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/embargo/EmbargoServiceImpl.java @@ -27,17 +27,18 @@ import org.springframework.beans.factory.annotation.Autowired; * Public interface to the embargo subsystem. *

    * Configuration properties: (with examples) - *
    # DC metadata field to hold the user-supplied embargo terms - *
    embargo.field.terms = dc.embargo.terms - *
    # DC metadata field to hold computed "lift date" of embargo - *
    embargo.field.lift = dc.date.available - *
    # String to indicate indefinite (forever) embargo in terms - *
    embargo.terms.open = Indefinite - *
    # implementation of embargo setter plugin - *
    plugin.single.org.dspace.embargo.EmbargoSetter = edu.my.Setter - *
    # implementation of embargo lifter plugin - *
    plugin.single.org.dspace.embargo.EmbargoLifter = edu.my.Lifter - * + * {@code + * # DC metadata field to hold the user-supplied embargo terms + * embargo.field.terms = dc.embargo.terms + * # DC metadata field to hold computed "lift date" of embargo + * embargo.field.lift = dc.date.available + * # String to indicate indefinite (forever) embargo in terms + * embargo.terms.open = Indefinite + * # implementation of embargo setter plugin + * plugin.single.org.dspace.embargo.EmbargoSetter = edu.my.Setter + * # implementation of embargo lifter plugin + * plugin.single.org.dspace.embargo.EmbargoLifter = edu.my.Lifter + * } * @author Larry Stone * @author Richard Rodgers */ diff --git a/dspace-api/src/main/java/org/dspace/embargo/service/EmbargoService.java b/dspace-api/src/main/java/org/dspace/embargo/service/EmbargoService.java index 36209e6e12..44c81a152a 100644 --- a/dspace-api/src/main/java/org/dspace/embargo/service/EmbargoService.java +++ b/dspace-api/src/main/java/org/dspace/embargo/service/EmbargoService.java @@ -22,17 +22,18 @@ import java.util.List; * Public interface to the embargo subsystem. *

    * Configuration properties: (with examples) - *
    # DC metadata field to hold the user-supplied embargo terms - *
    embargo.field.terms = dc.embargo.terms - *
    # DC metadata field to hold computed "lift date" of embargo - *
    embargo.field.lift = dc.date.available - *
    # String to indicate indefinite (forever) embargo in terms - *
    embargo.terms.open = Indefinite - *
    # implementation of embargo setter plugin - *
    plugin.single.org.dspace.embargo.EmbargoSetter = edu.my.Setter - *
    # implementation of embargo lifter plugin - *
    plugin.single.org.dspace.embargo.EmbargoLifter = edu.my.Lifter - * + * {@code + * # DC metadata field to hold the user-supplied embargo terms + * embargo.field.terms = dc.embargo.terms + * # DC metadata field to hold computed "lift date" of embargo + * embargo.field.lift = dc.date.available + * # String to indicate indefinite (forever) embargo in terms + * embargo.terms.open = Indefinite + * # implementation of embargo setter plugin + * plugin.single.org.dspace.embargo.EmbargoSetter = edu.my.Setter + * # implementation of embargo lifter plugin + * plugin.single.org.dspace.embargo.EmbargoLifter = edu.my.Lifter + * } * @author Larry Stone * @author Richard Rodgers */ diff --git a/dspace-api/src/main/java/org/dspace/eperson/AccountServiceImpl.java b/dspace-api/src/main/java/org/dspace/eperson/AccountServiceImpl.java index 4cfb02b81d..b6f306487f 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/AccountServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/eperson/AccountServiceImpl.java @@ -7,24 +7,19 @@ */ package org.dspace.eperson; -import java.io.IOException; -import java.sql.SQLException; -import java.util.Locale; - -import javax.mail.MessagingException; - import org.apache.log4j.Logger; import org.dspace.authorize.AuthorizeException; -import org.dspace.core.ConfigurationManager; -import org.dspace.core.Context; -import org.dspace.core.Email; -import org.dspace.core.I18nUtil; -import org.dspace.core.Utils; +import org.dspace.core.*; import org.dspace.eperson.service.AccountService; import org.dspace.eperson.service.EPersonService; import org.dspace.eperson.service.RegistrationDataService; import org.springframework.beans.factory.annotation.Autowired; +import javax.mail.MessagingException; +import java.io.IOException; +import java.sql.SQLException; +import java.util.Locale; + /** * * Methods for handling registration by email and forgotten passwords. When @@ -219,7 +214,7 @@ public class AccountServiceImpl implements AccountService if (log.isDebugEnabled()) { log.debug("Created callback " - + rd.getId() + + rd.getID() + " with token " + rd.getToken() + " with email \"" + email + "\""); } diff --git a/dspace-api/src/main/java/org/dspace/eperson/EPersonConsumer.java b/dspace-api/src/main/java/org/dspace/eperson/EPersonConsumer.java index a2356ba5ef..f5c6cced62 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/EPersonConsumer.java +++ b/dspace-api/src/main/java/org/dspace/eperson/EPersonConsumer.java @@ -37,7 +37,7 @@ public class EPersonConsumer implements Consumer /** * Initalise the consumer * - * @throws Exception + * @throws Exception if error */ @Override public void initialize() @@ -51,7 +51,7 @@ public class EPersonConsumer implements Consumer * * @param context * @param event - * @throws Exception + * @throws Exception if error */ @Override public void consume(Context context, Event event) @@ -116,7 +116,7 @@ public class EPersonConsumer implements Consumer * Handle the end of the event * * @param ctx - * @throws Exception + * @throws Exception if error */ @Override public void end(Context ctx) diff --git a/dspace-api/src/main/java/org/dspace/eperson/EPersonServiceImpl.java b/dspace-api/src/main/java/org/dspace/eperson/EPersonServiceImpl.java index 0ac5742857..af8b13a05e 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/EPersonServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/eperson/EPersonServiceImpl.java @@ -209,9 +209,6 @@ public class EPersonServiceImpl extends DSpaceObjectServiceImpl impleme throw new AuthorizeException(new EPersonDeletionException(constraintList)); } - // Delete the Dublin Core - deleteMetadata(context, ePerson); - context.addEvent(new Event(Event.DELETE, Constants.EPERSON, ePerson.getID(), ePerson.getEmail(), getIdentifiers(context, ePerson))); // XXX FIXME: This sidesteps the object model code so it won't diff --git a/dspace-api/src/main/java/org/dspace/eperson/Groomer.java b/dspace-api/src/main/java/org/dspace/eperson/Groomer.java index 651b1b93d4..a573ecc027 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/Groomer.java +++ b/dspace-api/src/main/java/org/dspace/eperson/Groomer.java @@ -162,7 +162,7 @@ public class Groomer /** * List accounts having no password salt. * - * @throws SQLException + * @throws SQLException if database error */ private static void findUnsalted() throws SQLException diff --git a/dspace-api/src/main/java/org/dspace/eperson/GroupServiceImpl.java b/dspace-api/src/main/java/org/dspace/eperson/GroupServiceImpl.java index 2513ef63f3..aeebd5e0e5 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/GroupServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/eperson/GroupServiceImpl.java @@ -171,22 +171,19 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl implements EPerson currentUser = context.getCurrentUser(); //First check the special groups - boolean found = false; List specialGroups = context.getSpecialGroups(); if(CollectionUtils.isNotEmpty(specialGroups)) { - Iterator it = specialGroups.iterator(); - while (it.hasNext() && !found) { - Group next = it.next(); - found = StringUtils.equals(next.getName(), groupName); + for (Group specialGroup : specialGroups) + { + //Check if the current special group is the one we are looking for OR retrieve all groups & make a check here. + if(StringUtils.equals(specialGroup.getName(), groupName) || allMemberGroups(context, currentUser).contains(findByName(context, groupName))) + { + return true; + } } } - - if(found) { - return true; - } else { - //lookup eperson in normal groups and subgroups - return epersonInGroup(context, groupName, currentUser); - } + //lookup eperson in normal groups and subgroups + return epersonInGroup(context, groupName, currentUser); } else { return false; } @@ -271,7 +268,7 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl implements return groupDAO.findByName(context, name); } - /** DEPRECATED: Please use findAll(Context context, List metadataSortFields) instead */ + /** DEPRECATED: Please use {@code findAll(Context context, List metadataSortFields)} instead */ @Override @Deprecated public List findAll(Context context, int sortField) throws SQLException { @@ -364,8 +361,6 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl implements ePerson.getGroups().remove(group); } - deleteMetadata(context, group); - // empty out group2groupcache table (if we do it after we delete our object we get an issue with references) group2GroupCacheDAO.deleteAll(context); // Remove ourself @@ -470,7 +465,7 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl implements protected boolean epersonInGroup(Context context, String groupName, EPerson ePerson) throws SQLException { - return groupDAO.findByNameAndEPerson(context, groupName, ePerson) != null; + return groupDAO.findByNameAndMembership(context, groupName, ePerson) != null; } diff --git a/dspace-api/src/main/java/org/dspace/eperson/RegistrationData.java b/dspace-api/src/main/java/org/dspace/eperson/RegistrationData.java index 9da5e3c0b8..b0c575eb1a 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/RegistrationData.java +++ b/dspace-api/src/main/java/org/dspace/eperson/RegistrationData.java @@ -8,6 +8,7 @@ package org.dspace.eperson; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import javax.persistence.*; import java.util.Date; @@ -19,13 +20,13 @@ import java.util.Date; */ @Entity @Table(name="registrationdata") -public class RegistrationData { +public class RegistrationData implements ReloadableEntity { @Id @Column(name="registrationdata_id") @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="registrationdata_seq") @SequenceGenerator(name="registrationdata_seq", sequenceName="registrationdata_seq", allocationSize = 1) - private int id; + private Integer id; @Column(name = "email", unique = true, length = 64) private String email; @@ -47,7 +48,7 @@ public class RegistrationData { } - public int getId() { + public Integer getID() { return id; } diff --git a/dspace-api/src/main/java/org/dspace/eperson/RegistrationDataServiceImpl.java b/dspace-api/src/main/java/org/dspace/eperson/RegistrationDataServiceImpl.java index b2c27df252..3a5d3ab097 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/RegistrationDataServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/eperson/RegistrationDataServiceImpl.java @@ -7,6 +7,7 @@ */ package org.dspace.eperson; +import org.apache.commons.collections.CollectionUtils; import org.dspace.authorize.AuthorizeException; import org.dspace.core.Context; import org.dspace.eperson.dao.RegistrationDataDAO; @@ -14,6 +15,8 @@ import org.dspace.eperson.service.RegistrationDataService; import org.springframework.beans.factory.annotation.Autowired; import java.sql.SQLException; +import java.util.Collections; +import java.util.List; /** * Service implementation for the RegistrationData object. @@ -61,8 +64,16 @@ public class RegistrationDataServiceImpl implements RegistrationDataService @Override public void update(Context context, RegistrationData registrationData) throws SQLException, AuthorizeException { - registrationDataDAO.save(context, registrationData); + update(context, Collections.singletonList(registrationData)); + } + @Override + public void update(Context context, List registrationDataRecords) throws SQLException, AuthorizeException { + if(CollectionUtils.isNotEmpty(registrationDataRecords)) { + for (RegistrationData registrationData : registrationDataRecords) { + registrationDataDAO.save(context, registrationData); + } + } } @Override diff --git a/dspace-api/src/main/java/org/dspace/eperson/SubscribeCLITool.java b/dspace-api/src/main/java/org/dspace/eperson/SubscribeCLITool.java index 92ea35f5d3..28bf66e707 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/SubscribeCLITool.java +++ b/dspace-api/src/main/java/org/dspace/eperson/SubscribeCLITool.java @@ -48,12 +48,12 @@ public class SubscribeCLITool { * Process subscriptions. This must be invoked only once a day. Messages are * only sent out when a collection has actually received new items, so that * people's mailboxes are not clogged with many "no new items" mails. - *

    + *

    * Yesterday's newly available items are included. If this is run at for * example midday, any items that have been made available during the * current day will not be included, but will be included in the next day's * run. - *

    + *

    * For example, if today's date is 2002-10-10 (in UTC) items made available * during 2002-10-09 (UTC) will be included. * diff --git a/dspace-api/src/main/java/org/dspace/eperson/Subscription.java b/dspace-api/src/main/java/org/dspace/eperson/Subscription.java index 2bce2407db..b0438db872 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/Subscription.java +++ b/dspace-api/src/main/java/org/dspace/eperson/Subscription.java @@ -9,6 +9,7 @@ package org.dspace.eperson; import org.dspace.content.Collection; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import javax.persistence.*; @@ -19,13 +20,13 @@ import javax.persistence.*; */ @Entity @Table(name = "subscription") -public class Subscription { +public class Subscription implements ReloadableEntity { @Id @Column(name = "subscription_id", unique = true, nullable = false) @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="subscription_seq") @SequenceGenerator(name="subscription_seq", sequenceName="subscription_seq", allocationSize = 1) - private int id; + private Integer id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "collection_id") @@ -45,7 +46,7 @@ public class Subscription { } - public int getId() { + public Integer getID() { return id; } diff --git a/dspace-api/src/main/java/org/dspace/eperson/dao/EPersonDAO.java b/dspace-api/src/main/java/org/dspace/eperson/dao/EPersonDAO.java index 926e1ff540..e01f08017a 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/dao/EPersonDAO.java +++ b/dspace-api/src/main/java/org/dspace/eperson/dao/EPersonDAO.java @@ -22,7 +22,7 @@ import java.util.Set; /** * Database Access Object interface class for the EPerson object. * The implementation of this class is responsible for all database calls for the EPerson object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/eperson/dao/Group2GroupCacheDAO.java b/dspace-api/src/main/java/org/dspace/eperson/dao/Group2GroupCacheDAO.java index d10bd2ea1c..9fc0422dca 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/dao/Group2GroupCacheDAO.java +++ b/dspace-api/src/main/java/org/dspace/eperson/dao/Group2GroupCacheDAO.java @@ -19,7 +19,7 @@ import java.util.Set; /** * Database Access Object interface class for the Group2GroupCache object. * The implementation of this class is responsible for all database calls for the Group2GroupCache object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/eperson/dao/GroupDAO.java b/dspace-api/src/main/java/org/dspace/eperson/dao/GroupDAO.java index f2af343482..ac50863ecc 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/dao/GroupDAO.java +++ b/dspace-api/src/main/java/org/dspace/eperson/dao/GroupDAO.java @@ -22,7 +22,7 @@ import java.util.UUID; /** * Database Access Object interface class for the Group object. * The implementation of this class is responsible for all database calls for the Group object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ @@ -34,7 +34,7 @@ public interface GroupDAO extends DSpaceObjectDAO, DSpaceObjectLegacySupp * @param searchValue The value to match * @param metadataField The metadata field to search in * @return The groups that have a matching value for specified metadata field - * @throws SQLException + * @throws SQLException if database error */ List findByMetadataField(Context context, String searchValue, MetadataField metadataField) throws SQLException; @@ -43,7 +43,7 @@ public interface GroupDAO extends DSpaceObjectDAO, DSpaceObjectLegacySupp * @param context The DSpace context * @param sortMetadataFields The metadata fields to sort on * @return A list of all groups, ordered by metadata fields - * @throws SQLException + * @throws SQLException if database error */ List findAll(Context context, List sortMetadataFields) throws SQLException; @@ -51,7 +51,7 @@ public interface GroupDAO extends DSpaceObjectDAO, DSpaceObjectLegacySupp * Find all groups ordered by name ascending * @param context The DSpace context * @return A list of all groups, ordered by name - * @throws SQLException + * @throws SQLException if database error */ List findAll(Context context) throws SQLException; @@ -60,7 +60,7 @@ public interface GroupDAO extends DSpaceObjectDAO, DSpaceObjectLegacySupp * @param context The DSpace context * @param ePerson The EPerson to match * @return A list of all groups to which the given EPerson belongs - * @throws SQLException + * @throws SQLException if database error */ List findByEPerson(Context context, EPerson ePerson) throws SQLException; @@ -69,7 +69,7 @@ public interface GroupDAO extends DSpaceObjectDAO, DSpaceObjectLegacySupp * @param context The DSpace context * @param flushQueries Flush all pending queries * @return A list of pairs indicating parent - child - * @throws SQLException + * @throws SQLException if database error */ List> getGroup2GroupResults(Context context, boolean flushQueries) throws SQLException; @@ -77,7 +77,7 @@ public interface GroupDAO extends DSpaceObjectDAO, DSpaceObjectLegacySupp * Return all empty groups * @param context The DSpace context * @return All empty groups - * @throws SQLException + * @throws SQLException if database error */ List getEmptyGroups(Context context) throws SQLException; @@ -85,7 +85,7 @@ public interface GroupDAO extends DSpaceObjectDAO, DSpaceObjectLegacySupp * Count the number of groups in DSpace * @param context The DSpace context * @return The number of groups - * @throws SQLException + * @throws SQLException if database error */ int countRows(Context context) throws SQLException; @@ -94,7 +94,7 @@ public interface GroupDAO extends DSpaceObjectDAO, DSpaceObjectLegacySupp * @param context The DSpace context * @param name The name of the group to look for * @return The group with the specified name - * @throws SQLException + * @throws SQLException if database error */ Group findByName(Context context, String name) throws SQLException; @@ -105,7 +105,7 @@ public interface GroupDAO extends DSpaceObjectDAO, DSpaceObjectLegacySupp * @param offset Offset to use for pagination (-1 to disable) * @param limit The maximum number of results to return (-1 to disable) * @return Groups matching the query - * @throws SQLException + * @throws SQLException if database error */ List findByNameLike(Context context, String groupName, int offset, int limit) throws SQLException; @@ -114,7 +114,7 @@ public interface GroupDAO extends DSpaceObjectDAO, DSpaceObjectLegacySupp * @param context The DSpace context * @param groupName Part of the group's name to search for * @return The number of matching groups - * @throws SQLException + * @throws SQLException if database error */ int countByNameLike(Context context, String groupName) throws SQLException; @@ -124,8 +124,8 @@ public interface GroupDAO extends DSpaceObjectDAO, DSpaceObjectLegacySupp * @param groupName The name of the group to look for * @param ePerson The EPerson which has to be a member * @return The group with the specified name - * @throws SQLException + * @throws SQLException if database error */ - Group findByNameAndEPerson(Context context, String groupName, EPerson ePerson) throws SQLException; + Group findByNameAndMembership(Context context, String groupName, EPerson ePerson) throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/eperson/dao/RegistrationDataDAO.java b/dspace-api/src/main/java/org/dspace/eperson/dao/RegistrationDataDAO.java index 23c8e8b6a3..d25f234408 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/dao/RegistrationDataDAO.java +++ b/dspace-api/src/main/java/org/dspace/eperson/dao/RegistrationDataDAO.java @@ -16,7 +16,7 @@ import java.sql.SQLException; /** * Database Access Object interface class for the RegistrationData object. * The implementation of this class is responsible for all database calls for the RegistrationData object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/eperson/dao/SubscriptionDAO.java b/dspace-api/src/main/java/org/dspace/eperson/dao/SubscriptionDAO.java index 4e409b631d..6f8f92a836 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/dao/SubscriptionDAO.java +++ b/dspace-api/src/main/java/org/dspace/eperson/dao/SubscriptionDAO.java @@ -19,7 +19,7 @@ import java.util.List; /** * Database Access Object interface class for the Subscription object. * The implementation of this class is responsible for all database calls for the Subscription object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/eperson/dao/impl/EPersonDAOImpl.java b/dspace-api/src/main/java/org/dspace/eperson/dao/impl/EPersonDAOImpl.java index 1c6aa2bbe1..f03d128168 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/dao/impl/EPersonDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/eperson/dao/impl/EPersonDAOImpl.java @@ -11,14 +11,13 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.ListUtils; import org.apache.commons.lang3.StringUtils; import org.dspace.content.MetadataField; -import org.dspace.core.Context; import org.dspace.core.AbstractHibernateDSODAO; +import org.dspace.core.Context; import org.dspace.eperson.EPerson; import org.dspace.eperson.Group; import org.dspace.eperson.dao.EPersonDAO; import org.hibernate.Criteria; import org.hibernate.Query; -import org.hibernate.criterion.Disjunction; import org.hibernate.criterion.Restrictions; import java.sql.SQLException; @@ -100,17 +99,20 @@ public class EPersonDAOImpl extends AbstractHibernateDSODAO implements @Override public List findByGroups(Context context, Set groups) throws SQLException { - Criteria criteria = createCriteria(context, EPerson.class); - criteria.createAlias("groups", "g"); - Disjunction orRestriction = Restrictions.or(); - for(Group group : groups) - { - orRestriction.add(Restrictions.eq("g.id", group.getID())); - } - criteria.add(orRestriction); - return list(criteria); - } + Query query = createQuery(context, + "SELECT DISTINCT e FROM EPerson e " + + "JOIN e.groups g " + + "WHERE g.id IN (:idList) "); + List idList = new ArrayList<>(groups.size()); + for (Group group : groups) { + idList.add(group.getID()); + } + + query.setParameterList("idList", idList); + + return list(query); + } @Override public List findWithPasswordWithoutDigestAlgorithm(Context context) throws SQLException { @@ -152,7 +154,7 @@ public class EPersonDAOImpl extends AbstractHibernateDSODAO implements query.setParameter("queryParam", "%"+queryParam.toLowerCase()+"%"); } for (MetadataField metadataField : metadataFieldsToJoin) { - query.setParameter(metadataField.toString(), metadataField.getFieldID()); + query.setParameter(metadataField.toString(), metadataField.getID()); } return query; diff --git a/dspace-api/src/main/java/org/dspace/eperson/dao/impl/GroupDAOImpl.java b/dspace-api/src/main/java/org/dspace/eperson/dao/impl/GroupDAOImpl.java index 7337f6611e..c239661bdd 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/dao/impl/GroupDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/eperson/dao/impl/GroupDAOImpl.java @@ -47,7 +47,7 @@ public class GroupDAOImpl extends AbstractHibernateDSODAO implements Grou addMetadataValueWhereQuery(queryBuilder, Collections.singletonList(metadataField), "=", null); Query query = createQuery(context, queryBuilder.toString()); - query.setParameter(metadataField.toString(), metadataField.getFieldID()); + query.setParameter(metadataField.toString(), metadataField.getID()); query.setParameter("queryParam", searchValue); return list(query); @@ -65,7 +65,7 @@ public class GroupDAOImpl extends AbstractHibernateDSODAO implements Grou Query query = createQuery(context, queryBuilder.toString()); for (MetadataField sortField : sortMetadataFields) { - query.setParameter(sortField.toString(), sortField.getFieldID()); + query.setParameter(sortField.toString(), sortField.getID()); } return list(query); } @@ -97,11 +97,11 @@ public class GroupDAOImpl extends AbstractHibernateDSODAO implements Grou query.setParameter("name", name); query.setCacheable(true); - return uniqueResult(query); + return singleResult(query); } @Override - public Group findByNameAndEPerson(Context context, String groupName, EPerson ePerson) throws SQLException { + public Group findByNameAndMembership(Context context, String groupName, EPerson ePerson) throws SQLException { if(groupName == null || ePerson == null) { return null; } else { @@ -123,7 +123,7 @@ public class GroupDAOImpl extends AbstractHibernateDSODAO implements Grou query.setParameter("eperson_id", ePerson.getID()); query.setCacheable(true); - return uniqueResult(query); + return singleResult(query); } } diff --git a/dspace-api/src/main/java/org/dspace/eperson/service/GroupService.java b/dspace-api/src/main/java/org/dspace/eperson/service/GroupService.java index ae0dacce4d..892bd8be32 100644 --- a/dspace-api/src/main/java/org/dspace/eperson/service/GroupService.java +++ b/dspace-api/src/main/java/org/dspace/eperson/service/GroupService.java @@ -34,20 +34,28 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * * @param context * DSpace context object + * @return group + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public Group create(Context context) throws SQLException, AuthorizeException; /** * set name of group * + * @param group DSpace group * @param name * new group name + * @throws SQLException if database error */ public void setName(Group group, String name) throws SQLException; /** * add an eperson member * + * @param context + * DSpace context object + * @param group DSpace group * @param e * eperson */ @@ -56,13 +64,20 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe /** * add group to this group * - * @param groupParent + * @param context + * DSpace context object + * @param groupParent parent group + * @param groupChild child group + * @throws SQLException if database error */ public void addMember(Context context, Group groupParent, Group groupChild) throws SQLException; /** * remove an eperson from a group * + * @param context + * DSpace context object + * @param group DSpace group * @param ePerson * eperson */ @@ -72,7 +87,11 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe /** * remove group from this group * - * @param g + * @param context + * DSpace context object + * @param groupParent parent group + * @param childGroup child group + * @throws SQLException if database error */ public void removeMember(Context context, Group groupParent, Group childGroup) throws SQLException; @@ -80,17 +99,20 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * check to see if an eperson is a direct member. * If the eperson is a member via a subgroup will be returned false * - * @param e + * @param group DSpace group + * @param ePerson * eperson to check membership + * @return true or false */ public boolean isDirectMember(Group group, EPerson ePerson); /** - * Check to see if g is a direct group member. - * If g is a subgroup via another group will be returned false + * Check to see if childGroup is a direct group member of owningGroup. + * If childGroup is a subgroup via another group will be returned false * - * @param g - * group to check + * @param owningGroup parent group + * @param childGroup child group + * @return true or false */ public boolean isMember(Group owningGroup, Group childGroup); @@ -103,6 +125,8 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * context * @param group * group to check + * @return true or false + * @throws SQLException if database error */ public boolean isMember(Context context, Group group) throws SQLException; @@ -115,15 +139,18 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * context * @param groupName * the name of the group to check + * @return true or false + * @throws SQLException if database error */ public boolean isMember(Context context, String groupName) throws SQLException; /** * Get all of the groups that an eperson is a member of. * - * @param context - * @param ePerson - * @throws SQLException + * @param context DSpace contenxt + * @param ePerson ePerson object + * @return list of Group objects + * @throws SQLException if database error */ public List allMemberGroups(Context context, EPerson ePerson) throws SQLException; @@ -136,8 +163,8 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * DSpace context * @param group * Group object - * @return Array of EPerson objects - * @throws SQLException + * @return List of EPerson objects + * @throws SQLException if error */ public List allMembers(Context context, Group group) throws SQLException; @@ -148,6 +175,7 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * @param name * * @return the named Group, or null if not found + * @throws SQLException if error */ public Group findByName(Context context, String name) throws SQLException; @@ -159,11 +187,20 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * @param metadataSortFields * metadata fields to sort by, leave empty to sort by Name * - * @return array of all groups in the site + * @return List of all groups in the site + * @throws SQLException if error */ public List findAll(Context context, List metadataSortFields) throws SQLException; - /** DEPRECATED: Please use findAll(Context context, List metadataFieldsSort) instead */ + + /** + * DEPRECATED: Please use {@code findAll(Context context, List metadataFieldsSort)} instead + * @param context DSpace context + * @param sortField sort field index + * @return List of all groups in the site + * @throws SQLException if error + * @deprecated + */ @Deprecated public List findAll(Context context, int sortField) throws SQLException; @@ -176,6 +213,7 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * The group name or group ID * * @return array of Group objects + * @throws SQLException if error */ public List search(Context context, String groupIdentifier) throws SQLException; @@ -192,6 +230,7 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * Maximum number of matches returned * * @return array of Group objects + * @throws SQLException if error */ public List search(Context context, String groupIdentifier, int offset, int limit) throws SQLException; @@ -205,11 +244,14 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * The search string * * @return the number of groups matching the query + * @throws SQLException if error */ public int searchResultCount(Context context, String query) throws SQLException; /** * Return true if group has no direct or indirect members + * @param group DSpace group + * @return true or false */ public boolean isEmpty(Group group); @@ -219,7 +261,7 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * * @param context the DSpace context * @throws SQLException database exception - * @throws AuthorizeException + * @throws AuthorizeException authorization error */ public void initDefaultGroupNames(Context context) throws SQLException, AuthorizeException; @@ -227,7 +269,7 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * Find all empty groups in DSpace * @param context The DSpace context * @return All empty groups - * @throws SQLException + * @throws SQLException database exception */ List getEmptyGroups(Context context) throws SQLException; @@ -235,7 +277,7 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * Count the total number of groups in DSpace * @param context The DSpace context * @return The total number of groups - * @throws SQLException + * @throws SQLException database exception */ int countTotal(Context context) throws SQLException; @@ -245,7 +287,7 @@ public interface GroupService extends DSpaceObjectService, DSpaceObjectLe * @param searchValue The value to match * @param metadataField The metadata field to search in * @return The groups that have a matching value for specified metadata field - * @throws SQLException + * @throws SQLException database exception */ List findByMetadataField(Context context, String searchValue, MetadataField metadataField) throws SQLException; } diff --git a/dspace-api/src/main/java/org/dspace/handle/Handle.java b/dspace-api/src/main/java/org/dspace/handle/Handle.java index 4297d39892..0c17894293 100644 --- a/dspace-api/src/main/java/org/dspace/handle/Handle.java +++ b/dspace-api/src/main/java/org/dspace/handle/Handle.java @@ -7,8 +7,11 @@ */ package org.dspace.handle; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; import org.dspace.content.DSpaceObject; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import javax.persistence.*; @@ -19,7 +22,7 @@ import javax.persistence.*; */ @Entity @Table(name="handle") -public class Handle { +public class Handle implements ReloadableEntity { @Id @Column(name="handle_id") @@ -51,7 +54,7 @@ public class Handle { } - public Integer getId() { + public Integer getID() { return id; } @@ -78,4 +81,26 @@ public class Handle { public Integer getResourceTypeId() { return resourceTypeId; } + + public boolean equals(final Object o) { + if (this == o) return true; + + if (o == null || getClass() != o.getClass()) return false; + + Handle handle1 = (Handle) o; + + return new EqualsBuilder() + .append(id, handle1.id) + .append(handle, handle1.handle) + .append(resourceTypeId, handle1.resourceTypeId) + .isEquals(); + } + + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(id) + .append(handle) + .append(resourceTypeId) + .toHashCode(); + } } diff --git a/dspace-api/src/main/java/org/dspace/handle/HandleServiceImpl.java b/dspace-api/src/main/java/org/dspace/handle/HandleServiceImpl.java index c90284c024..3cab15ebd2 100644 --- a/dspace-api/src/main/java/org/dspace/handle/HandleServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/handle/HandleServiceImpl.java @@ -7,10 +7,6 @@ */ package org.dspace.handle; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - import org.apache.commons.collections.CollectionUtils; import org.apache.log4j.Logger; import org.dspace.content.DSpaceObject; @@ -22,6 +18,10 @@ import org.dspace.handle.dao.HandleDAO; import org.dspace.handle.service.HandleService; import org.springframework.beans.factory.annotation.Autowired; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + /** * Interface to the CNRI Handle * System . @@ -133,7 +133,7 @@ public class HandleServiceImpl implements HandleService throws SQLException { Handle handle = handleDAO.create(context, new Handle()); - String handleId = createId(handle.getId()); + String handleId = createId(handle.getID()); handle.setHandle(handleId); handle.setDSpaceObject(dso); diff --git a/dspace-api/src/main/java/org/dspace/handle/dao/HandleDAO.java b/dspace-api/src/main/java/org/dspace/handle/dao/HandleDAO.java index c38dd9fd1f..fcc465c873 100644 --- a/dspace-api/src/main/java/org/dspace/handle/dao/HandleDAO.java +++ b/dspace-api/src/main/java/org/dspace/handle/dao/HandleDAO.java @@ -18,7 +18,7 @@ import java.util.List; /** * Database Access Object interface class for the Handle object. * The implementation of this class is responsible for all database calls for the Handle object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/handle/dao/impl/HandleDAOImpl.java b/dspace-api/src/main/java/org/dspace/handle/dao/impl/HandleDAOImpl.java index 7f5ddc646e..a378f5a384 100644 --- a/dspace-api/src/main/java/org/dspace/handle/dao/impl/HandleDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/handle/dao/impl/HandleDAOImpl.java @@ -17,6 +17,7 @@ import org.hibernate.Query; import org.hibernate.criterion.Restrictions; import java.sql.SQLException; +import java.util.Collections; import java.util.List; /** @@ -35,18 +36,34 @@ public class HandleDAOImpl extends AbstractHibernateDAO implements Handl @Override public List getHandlesByDSpaceObject(Context context, DSpaceObject dso) throws SQLException { - Criteria criteria = createCriteria(context, Handle.class); - criteria.add(Restrictions.and( - Restrictions.eq("dso", dso) - )); - return list(criteria); + if(dso == null) { + return Collections.emptyList(); + } else { + Query query = createQuery(context, + "SELECT h " + + "FROM Handle h " + + "LEFT JOIN FETCH h.dso " + + "WHERE h.dso.id = :id "); + + query.setParameter("id", dso.getID()); + + query.setCacheable(true); + return list(query); + } } @Override public Handle findByHandle(Context context, String handle) throws SQLException { - Criteria criteria = createCriteria(context, Handle.class); - criteria.add(Restrictions.eq("handle", handle)); - return uniqueResult(criteria); + Query query = createQuery(context, + "SELECT h " + + "FROM Handle h " + + "LEFT JOIN FETCH h.dso " + + "WHERE h.handle = :handle "); + + query.setParameter("handle", handle); + + query.setCacheable(true); + return uniqueResult(query); } @Override diff --git a/dspace-api/src/main/java/org/dspace/harvest/HarvestConsumer.java b/dspace-api/src/main/java/org/dspace/harvest/HarvestConsumer.java index b12366821a..0585d4cac0 100644 --- a/dspace-api/src/main/java/org/dspace/harvest/HarvestConsumer.java +++ b/dspace-api/src/main/java/org/dspace/harvest/HarvestConsumer.java @@ -39,7 +39,7 @@ public class HarvestConsumer implements Consumer /** * Initialise the consumer * - * @throws Exception + * @throws Exception if error */ @Override public void initialize() @@ -53,7 +53,7 @@ public class HarvestConsumer implements Consumer * * @param context * @param event - * @throws Exception + * @throws Exception if error */ @Override public void consume(Context context, Event event) @@ -101,7 +101,7 @@ public class HarvestConsumer implements Consumer * Handle the end of the event * * @param ctx - * @throws Exception + * @throws Exception if error */ @Override public void end(Context ctx) diff --git a/dspace-api/src/main/java/org/dspace/harvest/HarvestScheduler.java b/dspace-api/src/main/java/org/dspace/harvest/HarvestScheduler.java index a9647fbaf4..2a692f253e 100644 --- a/dspace-api/src/main/java/org/dspace/harvest/HarvestScheduler.java +++ b/dspace-api/src/main/java/org/dspace/harvest/HarvestScheduler.java @@ -146,6 +146,8 @@ public class HarvestScheduler implements Runnable { try { + mainContext = new Context(); + synchronized (HarvestScheduler.class) { switch (interrupt) { case HARVESTER_INTERRUPT_NONE: @@ -179,7 +181,6 @@ public class HarvestScheduler implements Runnable status = HARVESTER_STATUS_RUNNING; // Stage #1: if something is ready for harvest, push it onto the ready stack, mark it as "queued" - mainContext = new Context(); List cids = harvestedCollectionService.findReady(mainContext); log.info("Collections ready for immediate harvest: " + cids.toString()); diff --git a/dspace-api/src/main/java/org/dspace/harvest/HarvestedCollection.java b/dspace-api/src/main/java/org/dspace/harvest/HarvestedCollection.java index fdc15290db..8a75b1cb3d 100644 --- a/dspace-api/src/main/java/org/dspace/harvest/HarvestedCollection.java +++ b/dspace-api/src/main/java/org/dspace/harvest/HarvestedCollection.java @@ -9,6 +9,7 @@ package org.dspace.harvest; import org.dspace.content.Collection; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import javax.persistence.*; import java.util.Date; @@ -19,7 +20,7 @@ import java.util.Date; @Entity @Table(name="harvested_collection") -public class HarvestedCollection +public class HarvestedCollection implements ReloadableEntity { @Id @Column(name="id") @@ -86,6 +87,10 @@ public class HarvestedCollection { } + public Integer getID() { + return id; + } + /** * A function to set all harvesting-related parameters at once */ diff --git a/dspace-api/src/main/java/org/dspace/harvest/HarvestedItem.java b/dspace-api/src/main/java/org/dspace/harvest/HarvestedItem.java index a32494adb5..4393fb0094 100644 --- a/dspace-api/src/main/java/org/dspace/harvest/HarvestedItem.java +++ b/dspace-api/src/main/java/org/dspace/harvest/HarvestedItem.java @@ -11,6 +11,7 @@ import java.util.Date; import org.dspace.content.Item; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import javax.persistence.*; @@ -19,13 +20,13 @@ import javax.persistence.*; */ @Entity @Table(name="harvested_item") -public class HarvestedItem +public class HarvestedItem implements ReloadableEntity { @Id @Column(name="id") @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="harvested_item_seq") @SequenceGenerator(name="harvested_item_seq", sequenceName="harvested_item_seq", allocationSize = 1) - private int id; + private Integer id; @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name="item_id", unique = true) @@ -48,7 +49,7 @@ public class HarvestedItem { } - public int getId() { + public Integer getID() { return id; } diff --git a/dspace-api/src/main/java/org/dspace/harvest/OAIHarvester.java b/dspace-api/src/main/java/org/dspace/harvest/OAIHarvester.java index 72398bff32..0fc86d845c 100644 --- a/dspace-api/src/main/java/org/dspace/harvest/OAIHarvester.java +++ b/dspace-api/src/main/java/org/dspace/harvest/OAIHarvester.java @@ -7,40 +7,17 @@ */ package org.dspace.harvest; -import java.io.ByteArrayInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.net.ConnectException; -import java.sql.SQLException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Locale; -import java.util.Set; -import java.util.TimeZone; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.TransformerException; - import ORG.oclc.oai.harvester2.verb.*; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.dspace.authorize.AuthorizeException; import org.dspace.content.*; +import org.dspace.content.Collection; import org.dspace.content.crosswalk.CrosswalkException; import org.dspace.content.crosswalk.IngestionCrosswalk; import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.service.*; -import org.dspace.core.Constants; -import org.dspace.core.Context; -import org.dspace.core.Email; -import org.dspace.core.I18nUtil; -import org.dspace.core.Utils; +import org.dspace.core.*; import org.dspace.core.factory.CoreServiceFactory; import org.dspace.core.service.PluginService; import org.dspace.handle.factory.HandleServiceFactory; @@ -57,6 +34,14 @@ import org.jdom.input.DOMBuilder; import org.jdom.output.XMLOutputter; import org.xml.sax.SAXException; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; +import java.io.*; +import java.net.ConnectException; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.*; + /** * This class handles OAI harvesting of externally located records into this repository. @@ -92,6 +77,7 @@ public class OAIHarvester { protected PluginService pluginService; protected ConfigurationService configurationService; + // The collection this harvester instance is dealing with Collection targetCollection; HarvestedCollection harvestRow; @@ -111,7 +97,6 @@ public class OAIHarvester { // DOMbuilder class for the DOM -> JDOM conversions private static DOMBuilder db = new DOMBuilder(); - // The point at which this thread should terminate itself /* Initialize the harvester with a collection object */ @@ -130,6 +115,9 @@ public class OAIHarvester { workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService(); pluginService = CoreServiceFactory.getInstance().getPluginService(); + configurationService = DSpaceServicesFactory.getInstance().getConfigurationService(); + + if (dso.getType() != Constants.COLLECTION) { throw new HarvestingException("OAIHarvester can only harvest collections"); @@ -227,6 +215,9 @@ public class OAIHarvester { */ public void runHarvest() throws SQLException, IOException, AuthorizeException { + boolean originalMode = ourContext.isBatchModeEnabled(); + ourContext.enableBatchMode(true); + // figure out the relevant parameters String oaiSource = harvestRow.getOaiSource(); String oaiSetId = harvestRow.getOaiSetId(); @@ -243,6 +234,8 @@ public class OAIHarvester { fromDate = processDate(harvestRow.getHarvestDate()); } + long totalListSize = 0; + long currentRecord = 0; Date startTime = new Date(); String toDate = processDate(startTime,0); @@ -287,9 +280,10 @@ public class OAIHarvester { // set the status indicating the collection is currently being processed harvestRow.setHarvestStatus(HarvestedCollection.STATUS_BUSY); - harvestRow.setHarvestMessage("Collection is currently being harvested"); + harvestRow.setHarvestMessage("Collection harvesting is initializing..."); harvestRow.setHarvestStartTime(startTime); harvestedCollection.update(ourContext, harvestRow); + intermediateCommit(); // expiration timer starts int expirationInterval = configurationService.getIntProperty("oai.harvester.threadTimeout"); @@ -313,6 +307,7 @@ public class OAIHarvester { { log.info("HTTP Request: " + listRecords.getRequestURL()); } + while (listRecords != null) { records = new ArrayList(); @@ -341,6 +336,14 @@ public class OAIHarvester { { root = oaiResponse.getRootElement(); records.addAll(root.getChild("ListRecords", OAI_NS).getChildren("record", OAI_NS)); + + Element resumptionElement = root.getChild("ListRecords", OAI_NS).getChild("resumptionToken", OAI_NS); + if(resumptionElement != null && resumptionElement.getAttribute("completeListSize") != null) { + String value = resumptionElement.getAttribute("completeListSize").getValue(); + if(StringUtils.isNotBlank(value)) { + totalListSize = Long.parseLong(value); + } + } } // Process the obtained records @@ -359,8 +362,12 @@ public class OAIHarvester { throw new HarvestingException("runHarvest method timed out for collection " + targetCollection.getID()); } - processRecord(record,OREPrefix); + currentRecord++; + + processRecord(record, OREPrefix, currentRecord, totalListSize); ourContext.dispatchEvents(); + + intermediateCommit(); } } @@ -375,15 +382,20 @@ public class OAIHarvester { ourContext.turnOffAuthorisationSystem(); try { collectionService.update(ourContext, targetCollection); + + harvestRow.setHarvestMessage(String.format("Collection is currently being harvested (item %d of %d)", currentRecord, totalListSize)); + harvestedCollection.update(ourContext, harvestRow); } finally { //In case of an exception, make sure to restore our authentication state to the previous state ourContext.restoreAuthSystemState(); } + ourContext.dispatchEvents(); + intermediateCommit(); } } catch (HarvestingException hex) { - log.error("Harvesting error occurred while processing an OAI record: " + hex.getMessage()); + log.error("Harvesting error occurred while processing an OAI record: " + hex.getMessage(), hex); harvestRow.setHarvestMessage("Error occurred while processing an OAI record"); // if the last status is also an error, alert the admin @@ -391,14 +403,17 @@ public class OAIHarvester { alertAdmin(HarvestedCollection.STATUS_OAI_ERROR, hex); } harvestRow.setHarvestStatus(HarvestedCollection.STATUS_OAI_ERROR); + harvestedCollection.update(ourContext, harvestRow); + ourContext.complete(); return; } catch (Exception ex) { harvestRow.setHarvestMessage("Unknown error occurred while generating an OAI response"); harvestRow.setHarvestStatus(HarvestedCollection.STATUS_UNKNOWN_ERROR); + harvestedCollection.update(ourContext, harvestRow); alertAdmin(HarvestedCollection.STATUS_UNKNOWN_ERROR, ex); - log.error("Error occurred while generating an OAI response: " + ex.getMessage() + " " + ex.getCause()); - ex.printStackTrace(); + log.error("Error occurred while generating an OAI response: " + ex.getMessage() + " " + ex.getCause(), ex); + ourContext.complete(); return; } finally { @@ -414,16 +429,31 @@ public class OAIHarvester { harvestRow.setHarvestStartTime(startTime); harvestRow.setHarvestMessage("Harvest from " + oaiSource + " successful"); harvestRow.setHarvestStatus(HarvestedCollection.STATUS_READY); - log.info("Harvest from " + oaiSource + " successful. The process took " + timeTaken + " milliseconds."); + log.info("Harvest from " + oaiSource + " successful. The process took " + timeTaken + " milliseconds. Harvested " + currentRecord + " items."); harvestedCollection.update(ourContext, harvestRow); + + ourContext.enableBatchMode(originalMode); } - /** + private void intermediateCommit() throws SQLException { + ourContext.commit(); + reloadRequiredEntities(); + } + + private void reloadRequiredEntities() throws SQLException { + //Reload our objects in our cache + targetCollection = ourContext.reloadEntity(targetCollection); + harvestRow = ourContext.reloadEntity(harvestRow); + } + + /** * Process an individual PMH record, making (or updating) a corresponding DSpace Item. - * @param record a JDOM Element containing the actual PMH record with descriptive metadata. + * @param record a JDOM Element containing the actual PMH record with descriptive metadata. * @param OREPrefix the metadataprefix value used by the remote PMH server to disseminate ORE. Only used for collections set up to harvest content. - */ - protected void processRecord(Element record, String OREPrefix) throws SQLException, AuthorizeException, IOException, CrosswalkException, HarvestingException, ParserConfigurationException, SAXException, TransformerException + * @param currentRecord + * @param totalListSize The total number of records that this Harvest contains + */ + protected void processRecord(Element record, String OREPrefix, final long currentRecord, long totalListSize) throws SQLException, AuthorizeException, IOException, CrosswalkException, HarvestingException, ParserConfigurationException, SAXException, TransformerException { WorkspaceItem wi = null; Date timeStart = new Date(); @@ -476,7 +506,7 @@ public class OAIHarvester { Date OAIDatestamp = Utils.parseISO8601Date(header.getChildText("datestamp", OAI_NS)); Date itemLastHarvest = hi.getHarvestDate(); if (itemLastHarvest != null && OAIDatestamp.before(itemLastHarvest)) { - log.info("Item " + item.getHandle() + " was harvested more recently than the last update time reporetd by the OAI server; skipping."); + log.info("Item " + item.getHandle() + " was harvested more recently than the last update time reported by the OAI server; skipping."); return; } @@ -592,7 +622,8 @@ public class OAIHarvester { itemService.update(ourContext, item); harvestedItemService.update(ourContext, hi); long timeTaken = new Date().getTime() - timeStart.getTime(); - log.info("Item " + item.getHandle() + "(" + item.getID() + ")" + " has been ingested. The whole process took: " + timeTaken + " ms. "); + log.info(String.format("Item %s (%s) has been ingested (item %d of %d). The whole process took: %d ms.", + item.getHandle(), item.getID(), currentRecord, totalListSize, timeTaken)); // Stop ignoring authorization ourContext.restoreAuthSystemState(); @@ -695,7 +726,7 @@ public class OAIHarvester { * @throws TransformerException * @throws SAXException * @throws ParserConfigurationException - * @throws IOException + * @throws IOException if IO error */ private String oaiGetDateGranularity(String oaiSource) throws IOException, ParserConfigurationException, SAXException, TransformerException { diff --git a/dspace-api/src/main/java/org/dspace/harvest/dao/HarvestedCollectionDAO.java b/dspace-api/src/main/java/org/dspace/harvest/dao/HarvestedCollectionDAO.java index 96002fe235..d888d99ac9 100644 --- a/dspace-api/src/main/java/org/dspace/harvest/dao/HarvestedCollectionDAO.java +++ b/dspace-api/src/main/java/org/dspace/harvest/dao/HarvestedCollectionDAO.java @@ -19,7 +19,7 @@ import java.util.List; /** * Database Access Object interface class for the HarvestedCollection object. * The implementation of this class is responsible for all database calls for the HarvestedCollection object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/harvest/dao/HarvestedItemDAO.java b/dspace-api/src/main/java/org/dspace/harvest/dao/HarvestedItemDAO.java index 6e2aadb04f..ae58b608aa 100644 --- a/dspace-api/src/main/java/org/dspace/harvest/dao/HarvestedItemDAO.java +++ b/dspace-api/src/main/java/org/dspace/harvest/dao/HarvestedItemDAO.java @@ -18,7 +18,7 @@ import java.sql.SQLException; /** * Database Access Object interface class for the HarvestedItem object. * The implementation of this class is responsible for all database calls for the HarvestedItem object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/harvest/service/HarvestedCollectionService.java b/dspace-api/src/main/java/org/dspace/harvest/service/HarvestedCollectionService.java index 2578b76194..a02d723faf 100644 --- a/dspace-api/src/main/java/org/dspace/harvest/service/HarvestedCollectionService.java +++ b/dspace-api/src/main/java/org/dspace/harvest/service/HarvestedCollectionService.java @@ -57,14 +57,14 @@ public interface HarvestedCollectionService { /** Find all collections that are set up for harvesting * * return: list of collection id's - * @throws SQLException + * @throws SQLException if database error */ public List findAll(Context context) throws SQLException; /** Find all collections that are ready for harvesting * * return: list of collection id's - * @throws SQLException + * @throws SQLException if database error */ public List findReady(Context context) throws SQLException; @@ -72,18 +72,18 @@ public interface HarvestedCollectionService { * Find all collections with the specified status flag. * @param context * @param status see HarvestInstance.STATUS_... - * @throws SQLException + * @throws SQLException if database error */ public List findByStatus(Context context, int status) throws SQLException; /** Find the collection that was harvested the longest time ago. - * @throws SQLException + * @throws SQLException if database error */ public HarvestedCollection findOldestHarvest (Context context) throws SQLException; /** Find the collection that was harvested most recently. - * @throws SQLException + * @throws SQLException if database error */ public HarvestedCollection findNewestHarvest (Context context) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/health/InfoCheck.java b/dspace-api/src/main/java/org/dspace/health/InfoCheck.java index 50bab74c1a..7a76cb8224 100644 --- a/dspace-api/src/main/java/org/dspace/health/InfoCheck.java +++ b/dspace-api/src/main/java/org/dspace/health/InfoCheck.java @@ -7,16 +7,14 @@ */ package org.dspace.health; -import java.text.SimpleDateFormat; import org.apache.commons.io.FileUtils; import org.dspace.core.ConfigurationManager; -import org.dspace.storage.bitstore.BitstreamStorageServiceImpl; +import org.dspace.services.ConfigurationService; import org.dspace.storage.bitstore.DSBitStoreService; -import org.dspace.storage.bitstore.factory.StorageServiceFactory; -import org.dspace.storage.bitstore.service.BitstreamStorageService; import org.dspace.utils.DSpace; import java.io.File; +import java.text.SimpleDateFormat; import java.util.Date; /** @@ -27,7 +25,8 @@ public class InfoCheck extends Check { @Override public String run( ReportInfo ri ) { StringBuilder sb = new StringBuilder(); - + ConfigurationService configurationService + = new DSpace().getConfigurationService(); sb.append("Generated: ").append( new Date().toString() ).append("\n"); @@ -50,10 +49,10 @@ public class InfoCheck extends Check { localStore.getBaseDir().toString(), "Assetstore size", }, new String[] { - ConfigurationManager.getProperty("search.dir"), + configurationService.getProperty("search.dir"), "Search dir size", }, new String[] { - ConfigurationManager.getProperty("log.dir"), + configurationService.getProperty("log.report.dir"), "Log dir size", }, }) { try { diff --git a/dspace-api/src/main/java/org/dspace/identifier/DOI.java b/dspace-api/src/main/java/org/dspace/identifier/DOI.java index 48acc1532c..7ee083de73 100644 --- a/dspace-api/src/main/java/org/dspace/identifier/DOI.java +++ b/dspace-api/src/main/java/org/dspace/identifier/DOI.java @@ -10,6 +10,7 @@ package org.dspace.identifier; import org.dspace.content.DSpaceObject; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import javax.persistence.*; @@ -21,7 +22,7 @@ import javax.persistence.*; @Entity @Table(name = "Doi" ) public class DOI - implements Identifier + implements Identifier, ReloadableEntity { public static final String SCHEME = "doi:"; @@ -55,7 +56,7 @@ public class DOI { } - public Integer getId() { + public Integer getID() { return id; } 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 d24e6c6622..3369dc2a98 100644 --- a/dspace-api/src/main/java/org/dspace/identifier/DOIIdentifierProvider.java +++ b/dspace-api/src/main/java/org/dspace/identifier/DOIIdentifierProvider.java @@ -698,7 +698,7 @@ public class DOIIdentifierProvider * @param identifier The DOI in a format that is accepted by * {@link formatIdentifier(String)}. * @return Null if the DOI couldn't be found or the associated DSpaceObject. - * @throws SQLException + * @throws SQLException if database error * @throws IdentifierException If {@code identifier} is null or an empty string. * @throws IllegalArgumentException If the identifier couldn't be recognized as DOI. */ @@ -731,7 +731,7 @@ public class DOIIdentifierProvider * @param dso DSpaceObject to find doi for. DOIs with status TO_BE_DELETED will be * ignored. * @return The DOI as String or null if DOI was not found. - * @throws SQLException + * @throws SQLException if database error */ public String getDOIByObject(Context context, DSpaceObject dso) throws SQLException @@ -841,7 +841,7 @@ public class DOIIdentifierProvider // We need to generate a new DOI. doi = doiService.create(context); doiIdentifier = this.getPrefix() + "/" + this.getNamespaceSeparator() + - doi.getId(); + doi.getID(); } // prepare new doiRow @@ -888,8 +888,8 @@ public class DOIIdentifierProvider * @param context * @param dso DSpaceObject the DOI should be added to. * @param doi The DOI that should be added as metadata. - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ protected void saveDOIToObject(Context context, DSpaceObject dso, String doi) throws SQLException, AuthorizeException, IdentifierException @@ -919,8 +919,8 @@ public class DOIIdentifierProvider * @param context * @param dso The DSpaceObject the DOI should be removed from. * @param doi The DOI to remove out of the metadata. - * @throws AuthorizeException - * @throws SQLException + * @throws AuthorizeException if authorization error + * @throws SQLException if database error */ protected void removeDOIFromObject(Context context, DSpaceObject dso, String doi) throws AuthorizeException, SQLException, IdentifierException diff --git a/dspace-api/src/main/java/org/dspace/identifier/DataCiteXMLCreator.java b/dspace-api/src/main/java/org/dspace/identifier/DataCiteXMLCreator.java index 0455bc0d83..46e76ef7fd 100644 --- a/dspace-api/src/main/java/org/dspace/identifier/DataCiteXMLCreator.java +++ b/dspace-api/src/main/java/org/dspace/identifier/DataCiteXMLCreator.java @@ -140,7 +140,7 @@ public class DataCiteXMLCreator * Test the operation of this class. * * @param argv
    [0]: handle of an object for which to prepare XML metadata. - * @throws Exception + * @throws Exception if error */ public static void main(String[] argv) throws Exception diff --git a/dspace-api/src/main/java/org/dspace/identifier/EZIDIdentifierProvider.java b/dspace-api/src/main/java/org/dspace/identifier/EZIDIdentifierProvider.java index cc96e275eb..c1aad0244b 100644 --- a/dspace-api/src/main/java/org/dspace/identifier/EZIDIdentifierProvider.java +++ b/dspace-api/src/main/java/org/dspace/identifier/EZIDIdentifierProvider.java @@ -505,7 +505,7 @@ public class EZIDIdentifierProvider /** * Get configured value of EZID username. - * @throws IdentifierException + * @throws IdentifierException if identifier error */ private String loadUser() throws IdentifierException @@ -523,7 +523,7 @@ public class EZIDIdentifierProvider /** * Get configured value of EZID password. - * @throws IdentifierException + * @throws IdentifierException if identifier error */ private String loadPassword() throws IdentifierException @@ -541,7 +541,7 @@ public class EZIDIdentifierProvider /** * Get configured value of EZID "shoulder". - * @throws IdentifierException + * @throws IdentifierException if identifier error */ private String loadAuthority() throws IdentifierException diff --git a/dspace-api/src/main/java/org/dspace/identifier/IdentifierProvider.java b/dspace-api/src/main/java/org/dspace/identifier/IdentifierProvider.java index 775e4cc05f..9771e4f0f1 100644 --- a/dspace-api/src/main/java/org/dspace/identifier/IdentifierProvider.java +++ b/dspace-api/src/main/java/org/dspace/identifier/IdentifierProvider.java @@ -62,7 +62,7 @@ public abstract class IdentifierProvider { * @param context * @param item object to be named. * @return existing identifier of {@code item} if it has one, else a new identifier. - * @throws IdentifierException + * @throws IdentifierException if identifier error */ public abstract String register(Context context, DSpaceObject item) throws IdentifierException; @@ -72,7 +72,7 @@ public abstract class IdentifierProvider { * @param context * @param dso object to be named. * @return existing identifier of {@code dso} if it has one, else a new identifier. - * @throws IdentifierException + * @throws IdentifierException if identifier error */ public abstract String mint(Context context, DSpaceObject dso) throws IdentifierException; @@ -83,8 +83,8 @@ public abstract class IdentifierProvider { * @param identifier to be resolved. * @param attributes additional information for resolving {@code identifier}. * @return the named object. - * @throws IdentifierNotFoundException - * @throws IdentifierNotResolvableException + * @throws IdentifierNotFoundException if identifier not found + * @throws IdentifierNotResolvableException if identifier not resolvable */ public abstract DSpaceObject resolve(Context context, String identifier, String... attributes) throws IdentifierNotFoundException, IdentifierNotResolvableException;; @@ -94,8 +94,8 @@ public abstract class IdentifierProvider { * @param context * @param object The object to be looked up. * @return identifier for {@code object}. - * @throws IdentifierNotFoundException - * @throws IdentifierNotResolvableException + * @throws IdentifierNotFoundException if identifier not found + * @throws IdentifierNotResolvableException if identifier not resolvable */ public abstract String lookup(Context context, DSpaceObject object) throws IdentifierNotFoundException, IdentifierNotResolvableException;; @@ -104,7 +104,7 @@ public abstract class IdentifierProvider { * * @param context * @param dso object to lose its identity. - * @throws IdentifierException + * @throws IdentifierException if identifier error */ public abstract void delete(Context context, DSpaceObject dso) throws IdentifierException; @@ -114,7 +114,7 @@ public abstract class IdentifierProvider { * @param context * @param dso object to be de-identified. * @param identifier to be removed. - * @throws IdentifierException + * @throws IdentifierException if identifier error */ public abstract void delete(Context context, DSpaceObject dso, String identifier) throws IdentifierException; @@ -124,7 +124,7 @@ public abstract class IdentifierProvider { * @param context * @param dso object to be identified. * @param identifier to be set on the object. - * @throws IdentifierException + * @throws IdentifierException if identifier error */ public abstract void reserve(Context context, DSpaceObject dso, String identifier) throws IdentifierException; @@ -134,6 +134,7 @@ public abstract class IdentifierProvider { * @param context * @param object to be identified. * @param identifier to be created. + * @throws IdentifierException if identifier error */ public abstract void register(Context context, DSpaceObject object, String identifier) throws IdentifierException; diff --git a/dspace-api/src/main/java/org/dspace/identifier/VersionedDOIIdentifierProvider.java b/dspace-api/src/main/java/org/dspace/identifier/VersionedDOIIdentifierProvider.java index 1893423464..c8292b5d67 100644 --- a/dspace-api/src/main/java/org/dspace/identifier/VersionedDOIIdentifierProvider.java +++ b/dspace-api/src/main/java/org/dspace/identifier/VersionedDOIIdentifierProvider.java @@ -7,9 +7,6 @@ */ package org.dspace.identifier; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.dspace.authorize.AuthorizeException; @@ -27,6 +24,10 @@ import org.dspace.versioning.service.VersioningService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Required; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + /** * * @author Marsa Haoua @@ -269,7 +270,7 @@ public class VersionedDOIIdentifierProvider extends DOIIdentifierProvider // as we reuse the DOI ID, we do not have to check whether the DOI exists already. String identifier = this.getPrefix() + "/" + this.getNamespaceSeparator() + - doi.getId().toString(); + doi.getID().toString(); if (version.getVersionNumber() > 1) { diff --git a/dspace-api/src/main/java/org/dspace/identifier/VersionedHandleIdentifierProviderWithCanonicalHandles.java b/dspace-api/src/main/java/org/dspace/identifier/VersionedHandleIdentifierProviderWithCanonicalHandles.java index 484de0ebae..e455825bf5 100644 --- a/dspace-api/src/main/java/org/dspace/identifier/VersionedHandleIdentifierProviderWithCanonicalHandles.java +++ b/dspace-api/src/main/java/org/dspace/identifier/VersionedHandleIdentifierProviderWithCanonicalHandles.java @@ -501,8 +501,8 @@ public class VersionedHandleIdentifierProviderWithCanonicalHandles extends Ident * @param context * @param item * @param handle - * @throws SQLException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ protected void modifyHandleMetadata(Context context, Item item, String handle) throws SQLException, AuthorizeException diff --git a/dspace-api/src/main/java/org/dspace/identifier/dao/DOIDAO.java b/dspace-api/src/main/java/org/dspace/identifier/dao/DOIDAO.java index 6e447aaca8..5ade8a4b84 100644 --- a/dspace-api/src/main/java/org/dspace/identifier/dao/DOIDAO.java +++ b/dspace-api/src/main/java/org/dspace/identifier/dao/DOIDAO.java @@ -18,7 +18,7 @@ import java.util.List; /** * Database Access Object interface class for the DOI object. * The implementation of this class is responsible for all database calls for the DOI object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ 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 ec942ccaf5..f02fcb7477 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 @@ -40,8 +40,7 @@ public interface DOIConnector { * * @param context * @param doi - * @return - * @throws DOIIdentifierException + * @throws DOIIdentifierException if DOI error */ public void deleteDOI(Context context, String doi) throws DOIIdentifierException; @@ -57,8 +56,7 @@ public interface DOIConnector { * @param context * @param dso * @param doi - * @return - * @throws DOIIdentifierException + * @throws DOIIdentifierException if DOI error */ public void reserveDOI(Context context, DSpaceObject dso, String doi) throws DOIIdentifierException; @@ -74,8 +72,7 @@ public interface DOIConnector { * @param context * @param dso * @param doi - * @return - * @throws DOIIdentifierException + * @throws DOIIdentifierException if DOI error */ public void registerDOI(Context context, DSpaceObject dso, String doi) throws DOIIdentifierException; @@ -89,8 +86,7 @@ public interface DOIConnector { * @param context * @param dso * @param doi - * @return - * @throws IdentifierException + * @throws DOIIdentifierException if DOI error */ public void updateMetadata(Context context, DSpaceObject dso, String doi) throws DOIIdentifierException; diff --git a/dspace-api/src/main/java/org/dspace/identifier/doi/DOIOrganiser.java b/dspace-api/src/main/java/org/dspace/identifier/doi/DOIOrganiser.java index d5e4130e75..47b97e3cc1 100644 --- a/dspace-api/src/main/java/org/dspace/identifier/doi/DOIOrganiser.java +++ b/dspace-api/src/main/java/org/dspace/identifier/doi/DOIOrganiser.java @@ -723,7 +723,7 @@ public class DOIOrganiser { * contains digits only we treat it as ItemID, if not we try to find a * matching doi or a handle (in this order). * @return The TableRow or null if the Object does not have a DOI. - * @throws SQLException + * @throws SQLException if database error * @throws IllegalArgumentException If the identifier is null, an empty * String or specifies an DSpaceObject that is not an item. We currently * support DOIs for items only, but this may change once... 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 ac900a1bf5..588cab7cbe 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 @@ -749,7 +749,7 @@ implements DOIConnector * @param req * @param doi * @return - * @throws DOIIdentifierException + * @throws DOIIdentifierException if DOI error */ protected DataCiteResponse sendHttpRequest(HttpUriRequest req, String doi) throws DOIIdentifierException diff --git a/dspace-api/src/main/java/org/dspace/identifier/service/DOIService.java b/dspace-api/src/main/java/org/dspace/identifier/service/DOIService.java index f8ce56d2fb..4e87c7a246 100644 --- a/dspace-api/src/main/java/org/dspace/identifier/service/DOIService.java +++ b/dspace-api/src/main/java/org/dspace/identifier/service/DOIService.java @@ -76,7 +76,7 @@ public interface DOIService { * @param statuses The statuses the DOI should not be in, @{link DOIIdentifierProvider.DELETED}. * @param dsoIsNotNull Boolean whether all DOIs should be excluded where the DSpaceObject is NULL. * @return null or a list of DOIs - * @throws SQLException + * @throws SQLException if database error */ public List getSimilarDOIsNotInState(Context context, String doiPattern, List statuses, boolean dsoIsNotNull) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/identifier/service/IdentifierService.java b/dspace-api/src/main/java/org/dspace/identifier/service/IdentifierService.java index 800c171173..2e858882bd 100644 --- a/dspace-api/src/main/java/org/dspace/identifier/service/IdentifierService.java +++ b/dspace-api/src/main/java/org/dspace/identifier/service/IdentifierService.java @@ -61,8 +61,8 @@ public interface IdentifierService { * * @param context * @param identifier - * @throws org.dspace.identifier.IdentifierNotFoundException - * @throws org.dspace.identifier.IdentifierNotResolvableException + * @throws IdentifierNotFoundException if identifier not found + * @throws IdentifierNotResolvableException if identifier not resolvable */ DSpaceObject resolve(Context context, String identifier) throws IdentifierNotFoundException, IdentifierNotResolvableException; @@ -72,9 +72,9 @@ public interface IdentifierService { * * @param context * @param dso - * @throws org.dspace.authorize.AuthorizeException - * @throws java.sql.SQLException - * @throws org.dspace.identifier.IdentifierException + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IdentifierException if identifier error */ void reserve(Context context, DSpaceObject dso) throws AuthorizeException, SQLException, IdentifierException; @@ -87,9 +87,9 @@ public interface IdentifierService { * @param context * @param dso * @param identifier - * @throws org.dspace.authorize.AuthorizeException - * @throws java.sql.SQLException - * @throws IdentifierException + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IdentifierException if identifier error */ void reserve(Context context, DSpaceObject dso, String identifier) throws AuthorizeException, SQLException, IdentifierException; @@ -97,9 +97,9 @@ public interface IdentifierService { * * @param context * @param dso - * @throws org.dspace.authorize.AuthorizeException - * @throws java.sql.SQLException - * @throws IdentifierException + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IdentifierException if identifier error */ void register(Context context, DSpaceObject dso) throws AuthorizeException, SQLException, IdentifierException; @@ -113,9 +113,9 @@ public interface IdentifierService { * @param context * @param dso * @param identifier - * @throws org.dspace.authorize.AuthorizeException - * @throws java.sql.SQLException - * @throws IdentifierException + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IdentifierException if identifier error */ void register(Context context, DSpaceObject dso, String identifier) throws AuthorizeException, SQLException, IdentifierException; @@ -125,9 +125,9 @@ public interface IdentifierService { * * @param context * @param dso - * @throws org.dspace.authorize.AuthorizeException - * @throws java.sql.SQLException - * @throws IdentifierException + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IdentifierException if identifier error */ void delete(Context context, DSpaceObject dso) throws AuthorizeException, SQLException, IdentifierException; @@ -139,9 +139,9 @@ public interface IdentifierService { * @param context * @param dso * @param identifier - * @throws org.dspace.authorize.AuthorizeException - * @throws java.sql.SQLException - * @throws IdentifierException + * @throws AuthorizeException if authorization error + * @throws SQLException if database error + * @throws IdentifierException if identifier error */ void delete(Context context, DSpaceObject dso, String identifier) throws AuthorizeException, SQLException, IdentifierException; diff --git a/dspace-api/src/main/java/org/dspace/importer/external/service/other/MetadataSource.java b/dspace-api/src/main/java/org/dspace/importer/external/service/other/MetadataSource.java index 7de892c3e8..cbf0512737 100644 --- a/dspace-api/src/main/java/org/dspace/importer/external/service/other/MetadataSource.java +++ b/dspace-api/src/main/java/org/dspace/importer/external/service/other/MetadataSource.java @@ -179,7 +179,7 @@ public abstract class MetadataSource { /** * Attempts to init a session * - * @throws Exception + * @throws Exception if error */ public abstract void init() throws Exception; diff --git a/dspace-api/src/main/java/org/dspace/license/CCLookup.java b/dspace-api/src/main/java/org/dspace/license/CCLookup.java index eb4ea641f9..55e58f5717 100644 --- a/dspace-api/src/main/java/org/dspace/license/CCLookup.java +++ b/dspace-api/src/main/java/org/dspace/license/CCLookup.java @@ -252,7 +252,7 @@ public class CCLookup { * containing the user-supplied answer. * @param lang The language to request localized elements in. * - * @throws IOException + * @throws IOException if IO error * * @see CCLicense * @see Map @@ -321,7 +321,7 @@ public class CCLookup { * * Note: does not support localization in 1.5 -- not yet * - * @throws IOException + * @throws IOException if IO error * * @see CCLicense * @see Map diff --git a/dspace-api/src/main/java/org/dspace/license/LicenseCleanup.java b/dspace-api/src/main/java/org/dspace/license/LicenseCleanup.java index fda7977c38..4302321805 100644 --- a/dspace-api/src/main/java/org/dspace/license/LicenseCleanup.java +++ b/dspace-api/src/main/java/org/dspace/license/LicenseCleanup.java @@ -72,9 +72,9 @@ public class LicenseCleanup /** * @param args - * @throws SQLException - * @throws IOException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error */ public static void main(String[] args) throws SQLException, AuthorizeException, IOException @@ -132,9 +132,9 @@ public class LicenseCleanup /** * Process Item, correcting CC-License if encountered. * @param item - * @throws SQLException - * @throws AuthorizeException - * @throws IOException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ protected static void handleItem(Context context, Item item) throws SQLException, AuthorizeException, IOException @@ -198,9 +198,9 @@ public class LicenseCleanup * * @param b the Bitstream to be copied. * @return copy of the content of {@code b}. - * @throws IOException - * @throws SQLException - * @throws AuthorizeException + * @throws IOException if IO error + * @throws SQLException if database error + * @throws AuthorizeException if authorization error */ public static byte[] copy(Context context, Bitstream b) throws IOException, SQLException, AuthorizeException diff --git a/dspace-api/src/main/java/org/dspace/license/service/CreativeCommonsService.java b/dspace-api/src/main/java/org/dspace/license/service/CreativeCommonsService.java index 5a98b96f66..e7d7058c88 100644 --- a/dspace-api/src/main/java/org/dspace/license/service/CreativeCommonsService.java +++ b/dspace-api/src/main/java/org/dspace/license/service/CreativeCommonsService.java @@ -53,9 +53,9 @@ public interface CreativeCommonsService { * @param item * @param licenseStm * @param mimeType - * @throws SQLException - * @throws IOException - * @throws AuthorizeException + * @throws SQLException if database error + * @throws IOException if IO error + * @throws AuthorizeException if authorization error * * * // PATCHED 12/01 FROM JIRA re: mimetypes for CCLicense and License RDF wjb */ diff --git a/dspace-api/src/main/java/org/dspace/rdf/RDFConfiguration.java b/dspace-api/src/main/java/org/dspace/rdf/RDFConfiguration.java deleted file mode 100644 index 1864f25f11..0000000000 --- a/dspace-api/src/main/java/org/dspace/rdf/RDFConfiguration.java +++ /dev/null @@ -1,297 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ - -package org.dspace.rdf; - -import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; -import org.dspace.core.Constants; -import org.dspace.rdf.conversion.RDFConverter; -import org.dspace.rdf.storage.RDFStorage; -import org.dspace.rdf.storage.URIGenerator; -import org.dspace.services.ConfigurationService; -import org.dspace.services.factory.DSpaceServicesFactory; - -/** - * - * @author Pascal-Nicolas Becker (dspace -at- pascal -hyphen- becker -dot- de) - */ -public class RDFConfiguration { - private static final Logger log = Logger.getLogger(RDFConfiguration.class); - - /** - * Property key to load the public address of the SPARQL endpoint. - */ - public static final String SPARQL_ENDPOINT_KEY = "rdf.public.sparql.endpoint"; - - /** - * Property key to load the class to use as URIGenerator. - */ - public static final String URIGENERATOR_KEY = "rdf.URIGenerator"; - /** - * Property key to load the class to use as RDFConverter. - */ - public static final String RDFCONVERTER_KEY = "rdf.converter"; - /** - * Property key to load the list of plugins for the RDFConverter. - */ - public static final String CONVERTER_PLUGINS_KEY = "rdf.converter.plugins"; - /** - * Key of the Property to load the types of DSpaceObjects that should get - * converted. - */ - public static final String CONVERTER_DSOTYPES_KEY = "rdf.converter.DSOtypes"; - /** - * Property key to load the class to use as RDFStorage. - */ - public static final String RDFSTORAGE_KEY = "rdf.storage"; - /** - * Property key to load the address of the SPARQL 1.1 GRAPH STORE HTTP - * PROTOCOL endpoint. - */ - public static final String STORAGE_GRAPHSTORE_ENDPOINT_KEY = - "rdf.storage.graphstore.endpoint"; - /** - * Property key to load whether HTTP authentication for the - * graph store endpoint is required. - */ - public static final String STORAGE_GRAPHSTORE_AUTHENTICATION_KEY = - "rdf.storage.graphstore.authentication"; - /** - * Property key to load the username if authentication for the graph store - * endpoint is required. - */ - public static final String STORAGE_GRAPHSTORE_LOGIN_KEY = "rdf.storage.graphstore.login"; - /** - * Property key to load the password if authentication for the graph store - * endpoint is required. - */ - public static final String STORAGE_GRAPHSTORE_PASSWORD_KEY = "rdf.storage.graphstore.password"; - - /** - * Property key to load the address of the SPARQL endpoint to use within - * DSpace. If the property is empty or does not exist, the public SPARQL - * endpoint will be used. - */ - public static final String STORAGE_SPARQL_ENDPOINT_KEY = "rdf.storage.sparql.endpoint"; - /** - * Property key to load whether HTTP authentication for the internal SPARQL - * endpoint is required. - */ - public static final String STORAGE_SPARQL_AUTHENTICATION_KEY = "rdf.storage.sparql.authentication"; - /** - * Property key to load the username if authentication for the internal - * SPARQL endpoint is required. - */ - public static final String STORAGE_SPARQL_LOGIN_KEY = "rdf.storage.sparql.login"; - /** - * Property key to load the password if authentication for the internal - * SPARQL endpoint is required. - */ - public static final String STORAGE_SPARQL_PASSWORD_KEY = "rdf.storage.sparql.password"; - - /** - * Property key to load the URL of the dspace-rdf module. This is necessary - * to create links from the jspui or xmlui to RDF representation of - * DSpaceObjects. - */ - public static final String CONTEXT_PATH_KEY = "rdf.contextPath"; - - public static final String CONTENT_NEGOTIATION_KEY = "rdf.contentNegotiation.enable"; - - private static URIGenerator generator; - private static RDFStorage storage; - private static RDFConverter converter; - - public static String[] getConverterPlugins() - { - return RDFConfiguration.loadConfigurationArray(CONVERTER_PLUGINS_KEY); - } - - public static String[] getDSOTypesToConvert() - { - String[] dsoTypes = DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty(CONVERTER_DSOTYPES_KEY); - if (dsoTypes == null) - { - log.warn("Property rdf." + CONVERTER_DSOTYPES_KEY + " was not found " - + "or is empty. Will convert all type of DSpace Objects."); - return Constants.typeText; - } - return dsoTypes; - } - - public static boolean isConvertType(int type) - { - for (String typeName : getDSOTypesToConvert()) - { - if (Constants.getTypeID(typeName) == type) return true; - } - return false; - } - - public static boolean isConvertType(String type) - { - for (String typeName : getDSOTypesToConvert()) - { - if (typeName.equalsIgnoreCase(type)) return true; - } - return false; - } - - public static boolean isContentNegotiationEnabled() - { - ConfigurationService configurationService = - DSpaceServicesFactory.getInstance().getConfigurationService(); - return configurationService.getPropertyAsType(CONTENT_NEGOTIATION_KEY, - false); - } - - public static String getPublicSparqlEndpointAddress() - { - ConfigurationService configurationService = - DSpaceServicesFactory.getInstance().getConfigurationService(); - return configurationService.getProperty(SPARQL_ENDPOINT_KEY); - } - - public static String getInternalSparqlEndpointAddress() - { - ConfigurationService configurationService = - DSpaceServicesFactory.getInstance().getConfigurationService(); - String internalSparqlEndpoint = - configurationService.getProperty(STORAGE_SPARQL_ENDPOINT_KEY); - String externalSparqlEndpoint = - configurationService.getProperty(SPARQL_ENDPOINT_KEY); - return StringUtils.isEmpty(internalSparqlEndpoint) ? - externalSparqlEndpoint : internalSparqlEndpoint; - - } - - public static String getDSpaceRDFModuleURI() - { - ConfigurationService configurationService = - DSpaceServicesFactory.getInstance().getConfigurationService(); - return configurationService.getProperty(CONTEXT_PATH_KEY); - } - - protected static RDFConverter getRDFConverter() - { - if (converter == null) - { - ConfigurationService configurationService = - DSpaceServicesFactory.getInstance().getConfigurationService(); - converter = (RDFConverter) initializeClass(configurationService, - RDFCONVERTER_KEY, "RDFConverter"); - } - return converter; - } - - /* - * Initialize the URIGenerator configured in dsapce config (see - * {@link #URIGENERATOR_KEY URIGENERATOR_KEY}). - * The URIGenerator should be configurable, using the DSpace configuration - * and not using spring to avoid xml configuration. This method loads and - * initialize the configured URIGenerator. It is static so that the - * RDFizer must not be initialized to generate the identifier for a DSO. - */ - protected static URIGenerator getURIGenerator() - { - if (generator == null) - { - ConfigurationService configurationService = - DSpaceServicesFactory.getInstance().getConfigurationService(); - generator = (URIGenerator) initializeClass(configurationService, - URIGENERATOR_KEY, "URIGenerator"); - } - return generator; - } - - /* - * Initialize the RDFStorage configured in dsapce config (see - * {@link #RDFSTORAGE_KEY RDFSTORAGE_KEY}). - * The storage class should be configurable, using the DSpace configuration - * and not using spring to avoid xml configuration. This method loads and - * initialize the configured RDFStorage class. It is static so that the - * RDFizer must not be initialized to load RDF data. - */ - protected static RDFStorage getRDFStorage() - { - if (storage == null) - { - ConfigurationService configurationService = - DSpaceServicesFactory.getInstance().getConfigurationService(); - storage = (RDFStorage) initializeClass(configurationService, - RDFSTORAGE_KEY, "RDFStorage"); - } - return storage; - } - - /** - * Load a comma separated value out of the configuration an split it into a - * string array. - * @param key Key of the configuration value. - * @return Null if the configuration value was not found or empty. A String - * array representing the configuration value splitted on commas. - */ - public static String[] loadConfigurationArray(String key) - { - ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService(); - if(config.hasProperty(key)) - return config.getArrayProperty(key); - else - return null; - } - - - /* - * This method must by static, so we can use it from - * RDFizer.generateIdentifier and RDFizer.generateGraphName. Cause this - * method is static we cannot use the configurationService initilised in - * the class constructor. - * This method loads from DSpace configuration which class to use and - * initalizes it. - */ - private static Object initializeClass(ConfigurationService configurationService, - String propertyName, - String objectName) - { - String className = configurationService.getProperty(propertyName); - if (StringUtils.isEmpty(className)) - { - log.error("Cannot load " + objectName + "! Property " + propertyName - + " not found or empty!"); - throw new RuntimeException("Cannot load " + objectName - + ", property not found or not configured!"); - } - - Object instantiatedObject = null; - try - { - Class objectClass = Class.forName(className); - instantiatedObject = objectClass.newInstance(); - } catch (ClassNotFoundException ex) { - log.error("Cannot find class '" + className + "' for " + objectName - + ". " + "Please check your configuration.", ex); - throw new RuntimeException("Cannot find class for " + objectName - + " (" + className + ").", ex); - } catch (InstantiationException ex) { - log.error("Cannot instantiate " + objectName + " (class " - + className + ").", ex); - throw new RuntimeException("Cannot instantiate " + objectName - + " (class " + className + ").", ex); - } catch (IllegalAccessException ex) { - log.error("IllegalAccessException thrown while instantiating the " - + objectName + " (class " + className + ").", ex); - throw new RuntimeException("IllegalAccessException thrown while " - + "instantiating the " + objectName + " (class " - + className + ").", ex); - } - - return instantiatedObject; - } - -} diff --git a/dspace-api/src/main/java/org/dspace/rdf/RDFUtil.java b/dspace-api/src/main/java/org/dspace/rdf/RDFUtil.java index 303e96abf5..5b79856fa3 100644 --- a/dspace-api/src/main/java/org/dspace/rdf/RDFUtil.java +++ b/dspace-api/src/main/java/org/dspace/rdf/RDFUtil.java @@ -24,6 +24,8 @@ import org.dspace.content.Site; import org.dspace.content.factory.ContentServiceFactory; import org.dspace.core.Constants; import org.dspace.core.Context; +import org.dspace.rdf.factory.RDFFactory; +import org.dspace.services.factory.DSpaceServicesFactory; /** * @@ -32,6 +34,54 @@ import org.dspace.core.Context; public class RDFUtil { private static final Logger log = Logger.getLogger(RDFUtil.class); private static final AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService(); + + public static final String CONTENT_NEGOTIATION_KEY = "rdf.contentNegotiation.enable"; + /** + * Key of the Property to load the types of DSpaceObjects that should get + * converted. + */ + public static final String CONVERTER_DSOTYPES_KEY = "rdf.converter.DSOtypes"; + /** + * Property key to load the password if authentication for the graph store + * endpoint is required. + */ + public static final String STORAGE_GRAPHSTORE_PASSWORD_KEY = "rdf.storage.graphstore.password"; + /** + * Property key to load the URL of the dspace-rdf module. This is necessary + * to create links from the jspui or xmlui to RDF representation of + * DSpaceObjects. + */ + public static final String CONTEXT_PATH_KEY = "rdf.contextPath"; + /** + * Property key to load the public address of the SPARQL endpoint. + */ + public static final String SPARQL_ENDPOINT_KEY = "rdf.public.sparql.endpoint"; + /** + * Property key to load the username if authentication for the internal + * SPARQL endpoint is required. + */ + public static final String STORAGE_SPARQL_LOGIN_KEY = "rdf.storage.sparql.login"; + /** + * Property key to load the password if authentication for the internal + * SPARQL endpoint is required. + */ + public static final String STORAGE_SPARQL_PASSWORD_KEY = "rdf.storage.sparql.password"; + /** + * Property key to load the address of the SPARQL 1.1 GRAPH STORE HTTP + * PROTOCOL endpoint. + */ + public static final String STORAGE_GRAPHSTORE_ENDPOINT_KEY = "rdf.storage.graphstore.endpoint"; + /** + * Property key to load the address of the SPARQL endpoint to use within + * DSpace. If the property is empty or does not exist, the public SPARQL + * endpoint will be used. + */ + public static final String STORAGE_SPARQL_ENDPOINT_KEY = "rdf.storage.sparql.endpoint"; + /** + * Property key to load the username if authentication for the graph store + * endpoint is required. + */ + public static final String STORAGE_GRAPHSTORE_LOGIN_KEY = "rdf.storage.graphstore.login"; /** * Loads converted data of a DSpaceObject identified by the URI provided @@ -45,7 +95,7 @@ public class RDFUtil { */ public static Model loadModel(String identifier) { - return RDFConfiguration.getRDFStorage().load(identifier); + return RDFFactory.getInstance().getRDFStorage().load(identifier); } /** @@ -65,7 +115,7 @@ public class RDFUtil { public static String generateIdentifier(Context context, DSpaceObject dso) throws SQLException { - return RDFConfiguration.getURIGenerator().generateIdentifier(context, dso); + return RDFFactory.getInstance().getURIGenerator().generateIdentifier(context, dso); } /** @@ -89,7 +139,7 @@ public class RDFUtil { String handle, List identifier) throws SQLException { - return RDFConfiguration.getURIGenerator().generateIdentifier(context, + return RDFFactory.getInstance().getURIGenerator().generateIdentifier(context, type, id, handle, identifier); } /** @@ -107,7 +157,7 @@ public class RDFUtil { * @return The converted data or null if the conversion result is empty. * Remember to close the model as soon as you don't need it anymore. * @throws RDFMissingIdentifierException If no identifier could be generated. - * @throws java.sql.SQLException + * @throws SQLException if database error * @throws ItemNotArchivedException If you want to convert an Item that is * not archived. * @throws ItemWithdrawnException If you want to convert an Item that is @@ -124,22 +174,33 @@ public class RDFUtil { ItemWithdrawnException, ItemNotDiscoverableException, AuthorizeException, IllegalArgumentException { - if (dso.getType() != Constants.SITE - && dso.getType() != Constants.COMMUNITY - && dso.getType() != Constants.COLLECTION - && dso.getType() != Constants.ITEM) + String[] dsoTypes = DSpaceServicesFactory.getInstance() + .getConfigurationService() + .getArrayProperty(CONVERTER_DSOTYPES_KEY); + if (dsoTypes == null || dsoTypes.length == 0) { - throw new IllegalArgumentException(ContentServiceFactory.getInstance().getDSpaceObjectService(dso).getTypeText(dso) - + " is currently not supported as independent entity."); + log.warn("Property rdf." + CONVERTER_DSOTYPES_KEY + " was not found " + + "or is empty. Will convert all type of DSpace Objects."); + } else { + boolean found = false; + for (String type : dsoTypes) + { + if (StringUtils.equalsIgnoreCase(Constants.typeText[dso.getType()], type.trim())) + { + found = true; + break; + } + } + if (!found) + { + log.warn("Configuration of DSpaceObjects of type " + + Constants.typeText[dso.getType()] + + " prohibitted by configuration."); + return null; + } } - - if (!RDFConfiguration.isConvertType(ContentServiceFactory.getInstance().getDSpaceObjectService(dso).getTypeText(dso))) - { - return null; - } - isPublic(context, dso); - return RDFConfiguration.getRDFConverter().convert(context, dso); + return RDFFactory.getInstance().getRDFConverter().convert(context, dso); } /** @@ -158,7 +219,7 @@ public class RDFUtil { * @return The converted data or null if the conversion result is empty. * Remember to close the model as soon as you don't need it anymore. * @throws RDFMissingIdentifierException If no identifier could be generated. - * @throws java.sql.SQLException + * @throws SQLException if database error * @throws ItemNotArchivedException If you want to convert an Item that is * not archived. * @throws ItemWithdrawnException If you want to convert an Item that is @@ -190,11 +251,11 @@ public class RDFUtil { { // if data about this dso is stored in the triplestore already, we // should remove it as a conversion currently result in no data - RDFConfiguration.getRDFStorage().delete(identifier); + RDFFactory.getInstance().getRDFStorage().delete(identifier); return null; } - RDFConfiguration.getRDFStorage().store(identifier, convertedData); + RDFFactory.getInstance().getRDFStorage().store(identifier, convertedData); return convertedData; } @@ -210,7 +271,7 @@ public class RDFUtil { * anonymous user here, as the triple store probably provides * a public SPARQL endpoint. * @param dso The DSpaceObjet to check. - * @throws SQLException + * @throws SQLException if database error * @throws ItemNotArchivedException If {@code dso} is an Item and is not * archived. * @throws ItemWithdrawnException If {@code dso} is an Item and is withdrawn. @@ -254,7 +315,7 @@ public class RDFUtil { * @return true if {@link #isPublic(Context, DSpaceObject) * isPublic(Context, DSpaceObject)} doesn't throw an exception, false if it * did. - * @throws SQLException + * @throws SQLException if database error */ public static boolean isPublicBoolean(Context context, DSpaceObject dso) throws SQLException @@ -274,7 +335,7 @@ public class RDFUtil { */ public static void delete(String uri) { - RDFConfiguration.getRDFStorage().delete(uri); + RDFFactory.getInstance().getRDFStorage().delete(uri); } /** @@ -284,17 +345,17 @@ public class RDFUtil { * @param type DSpaceObject type (e.g. {@link Constants#ITEM Constants.ITEM}). * @param id Id of the DspaceObject. * @param handle Handle of the DSpaceObject. - * @throws SQLException + * @throws SQLException if database error * @throws RDFMissingIdentifierException In case that no Identifier could be generated. */ public static void delete(Context ctx, int type, UUID id, String handle, List identifiers) throws SQLException, RDFMissingIdentifierException { - String uri = RDFConfiguration.getURIGenerator().generateIdentifier(ctx, - type, id, handle, identifiers); + String uri = RDFFactory.getInstance().getURIGenerator() + .generateIdentifier(ctx, type, id, handle, identifiers); if (uri != null) { - RDFConfiguration.getRDFStorage().delete(uri); + RDFFactory.getInstance().getRDFStorage().delete(uri); } else { throw new RDFMissingIdentifierException(type, id); } diff --git a/dspace-api/src/main/java/org/dspace/rdf/RDFizer.java b/dspace-api/src/main/java/org/dspace/rdf/RDFizer.java index 61954f2845..6e5d8f55ac 100644 --- a/dspace-api/src/main/java/org/dspace/rdf/RDFizer.java +++ b/dspace-api/src/main/java/org/dspace/rdf/RDFizer.java @@ -39,6 +39,8 @@ import org.dspace.core.Constants; import org.dspace.core.Context; import org.dspace.handle.factory.HandleServiceFactory; import org.dspace.handle.service.HandleService; +import org.dspace.rdf.factory.RDFFactory; +import org.dspace.rdf.storage.RDFStorage; import org.dspace.services.ConfigurationService; import org.dspace.services.factory.DSpaceServicesFactory; @@ -53,17 +55,19 @@ public class RDFizer { private static final Logger log = Logger.getLogger(RDFizer.class); - protected ConfigurationService configurationService; - protected boolean stdout; protected boolean verbose; protected boolean dryrun; protected String lang; protected Context context; + + protected final ConfigurationService configurationService; protected final ContentServiceFactory contentServiceFactory; protected final CommunityService communityService; protected final ItemService itemService; protected final HandleService handleService; + protected final RDFStorage storage; + /** * Set to remember with DSpaceObject were converted or deleted from the @@ -75,17 +79,19 @@ public class RDFizer { public RDFizer() { - this.configurationService = DSpaceServicesFactory.getInstance().getConfigurationService(); this.stdout = false; this.verbose = false; this.dryrun = false; this.lang = "TURTLE"; this.processed = new CopyOnWriteArraySet(); this.context = new Context(Context.READ_ONLY); + + this.configurationService = DSpaceServicesFactory.getInstance().getConfigurationService(); this.contentServiceFactory = ContentServiceFactory.getInstance(); this.communityService = contentServiceFactory.getCommunityService(); this.itemService = contentServiceFactory.getItemService(); this.handleService = HandleServiceFactory.getInstance().getHandleService(); + this.storage = RDFFactory.getInstance().getRDFStorage(); } /** @@ -170,7 +176,7 @@ public class RDFizer { public void deleteAll() { report("Sending delete command to the triple store."); - if (!this.dryrun) RDFConfiguration.getRDFStorage().deleteAll(); + if (!this.dryrun) storage.deleteAll(); report("Deleted all data from the triplestore."); } @@ -218,7 +224,7 @@ public class RDFizer { report("Deleting Named Graph" + identifier); if (!dryrun) { - RDFConfiguration.getRDFStorage().delete(identifier); + storage.delete(identifier); } } }; @@ -412,9 +418,11 @@ public class RDFizer { } // Currently Bundles and Bitsreams aren't supported as independent entities. -// The should be converted as part of an item. So we do not need to make +// They should be converted as part of an item. So we do not need to make // the recursive call for them. An item itself will be converted as part // of the callback call below. +// The following code is left here for the day, we decide to also convert +// bundles and/or bitstreams. // // if (dso instanceof Item) // { @@ -563,7 +571,7 @@ public class RDFizer { { if (!this.dryrun) { - RDFConfiguration.getRDFStorage().delete(identifier); + storage.delete(identifier); } if (this.verbose) { diff --git a/dspace-api/src/main/java/org/dspace/rdf/conversion/MetadataConverterPlugin.java b/dspace-api/src/main/java/org/dspace/rdf/conversion/MetadataConverterPlugin.java index bcba1b1162..d1fc834ec3 100644 --- a/dspace-api/src/main/java/org/dspace/rdf/conversion/MetadataConverterPlugin.java +++ b/dspace-api/src/main/java/org/dspace/rdf/conversion/MetadataConverterPlugin.java @@ -35,6 +35,7 @@ import org.dspace.core.Constants; import org.dspace.core.Context; import org.dspace.rdf.RDFUtil; import org.dspace.services.ConfigurationService; +import org.springframework.beans.factory.annotation.Autowired; /** * @@ -47,6 +48,7 @@ public class MetadataConverterPlugin implements ConverterPlugin public final static String METADATA_PREFIXES_KEY = "rdf.metadata.prefixes"; private final static Logger log = Logger.getLogger(MetadataConverterPlugin.class); + @Autowired(required=true) protected ConfigurationService configurationService; @Override diff --git a/dspace-api/src/main/java/org/dspace/rdf/conversion/RDFConverterImpl.java b/dspace-api/src/main/java/org/dspace/rdf/conversion/RDFConverterImpl.java index ecb66d7683..7750c6c538 100644 --- a/dspace-api/src/main/java/org/dspace/rdf/conversion/RDFConverterImpl.java +++ b/dspace-api/src/main/java/org/dspace/rdf/conversion/RDFConverterImpl.java @@ -12,14 +12,12 @@ import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import java.sql.SQLException; import java.util.List; -import java.util.ArrayList; import org.apache.log4j.Logger; import org.dspace.authorize.AuthorizeException; import org.dspace.content.DSpaceObject; import org.dspace.core.Context; -import org.dspace.rdf.RDFConfiguration; import org.dspace.services.ConfigurationService; -import org.dspace.services.factory.DSpaceServicesFactory; +import org.springframework.beans.factory.annotation.Autowired; /** * @@ -27,56 +25,33 @@ import org.dspace.services.factory.DSpaceServicesFactory; */ public class RDFConverterImpl implements RDFConverter { - protected ConfigurationService configurationService; - protected List plugins; private static final Logger log = Logger.getLogger(RDFConverterImpl.class); - protected RDFConverterImpl() + protected ConfigurationService configurationService; + protected List plugins; + + @Autowired(required=true) + public void setConfigurationService(ConfigurationService configurationService) { - this.configurationService = DSpaceServicesFactory.getInstance().getConfigurationService(); - this.plugins = new ArrayList(); - - String pluginNames[] = RDFConfiguration.getConverterPlugins(); - - if (pluginNames == null || pluginNames.length == 0) + this.configurationService = configurationService; + } + + @Autowired(required=true) + public void setPlugins(List plugins) + { + this.plugins = plugins; + if (log.isDebugEnabled()) { - log.error("Cannot load RDF converter plugins!"); - throw new RuntimeException("Cannot load rdf converter plugins!"); - } - - for (String plugin : pluginNames) - { - try + StringBuilder pluginNames = new StringBuilder(); + for (ConverterPlugin plugin : plugins) { - Class pluginClass = Class.forName(plugin); - ConverterPlugin pluginInstance = - (ConverterPlugin) pluginClass.newInstance(); - pluginInstance.setConfigurationService(this.configurationService); - this.plugins.add(pluginInstance); + if (pluginNames.length() > 0) + { + pluginNames.append(", "); + } + pluginNames.append(plugin.getClass().getCanonicalName()); } - catch (ClassNotFoundException ex) - { - log.warn("Cannot load plugin '" + plugin - + "': class not found!", ex); - // if we would ignore a plugin, we would generate incomplete RDF data. - throw new RuntimeException(ex.getMessage(), ex); - } - catch (IllegalAccessException ex) - { - log.warn("Cannot load plugin '" + plugin - + "': illegal access!", ex); - // if we would ignore a plugin, we would generate incomplete RDF data. - throw new RuntimeException(ex.getMessage(), ex); - } - catch (InstantiationException ex) - { - log.warn("Cannot load plugin '" + plugin - + "': cannot instantiate the module!", ex); - // if we would ignore a plugin, we would generate incomplete RDF data. - throw new RuntimeException(ex.getMessage(), ex); - } - log.debug("Successfully loaded RDFConverterPlugin " - + plugin + "."); + log.debug("Loaded the following plugins: " + pluginNames.toString()); } } diff --git a/dspace-api/src/main/java/org/dspace/rdf/conversion/SimpleDSORelationsConverterPlugin.java b/dspace-api/src/main/java/org/dspace/rdf/conversion/SimpleDSORelationsConverterPlugin.java index c6ce56d21f..a75121ef71 100644 --- a/dspace-api/src/main/java/org/dspace/rdf/conversion/SimpleDSORelationsConverterPlugin.java +++ b/dspace-api/src/main/java/org/dspace/rdf/conversion/SimpleDSORelationsConverterPlugin.java @@ -22,16 +22,15 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.dspace.app.util.Util; import org.dspace.content.*; -import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.service.BitstreamService; import org.dspace.content.service.CommunityService; import org.dspace.content.service.ItemService; import org.dspace.content.service.SiteService; import org.dspace.core.Constants; import org.dspace.core.Context; -import org.dspace.rdf.RDFConfiguration; import org.dspace.rdf.RDFUtil; import org.dspace.services.ConfigurationService; +import org.springframework.beans.factory.annotation.Autowired; /** * @@ -53,90 +52,17 @@ implements ConverterPlugin private static final Logger log = Logger.getLogger(SimpleDSORelationsConverterPlugin.class); - protected ConfigurationService configurationService; - protected String[] site2community; - protected String[] community2site; - protected String[] community2subcommunity; - protected String[] subcommunity2community; - protected String[] community2collection; - protected String[] collection2community; - protected String[] collection2item; - protected String[] item2collection; - protected String[] item2bitstream; - - protected BitstreamService bitstreamService = ContentServiceFactory.getInstance().getBitstreamService(); - protected ItemService itemService = ContentServiceFactory.getInstance().getItemService(); - protected CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService(); - protected SiteService siteService = ContentServiceFactory.getInstance().getSiteService(); - - public SimpleDSORelationsConverterPlugin() - { - site2community = RDFConfiguration.loadConfigurationArray(SIMPLE_RELATIONS_SITE2COMMUNITY_KEY); - community2site = RDFConfiguration.loadConfigurationArray(SIMPLE_RELATIONS_COMMUNITY2SITE_KEY); - community2subcommunity = RDFConfiguration.loadConfigurationArray(SIMPLE_RELATIONS_COMMUNITY2SUBCOMMUNITY_KEY); - subcommunity2community = RDFConfiguration.loadConfigurationArray(SIMPLE_RELATIONS_SUBCOMMUNITY2COMMUNITY_KEY); - community2collection = RDFConfiguration.loadConfigurationArray(SIMPLE_RELATIONS_COMMUNITY2COLLECTION_KEY); - collection2community = RDFConfiguration.loadConfigurationArray(SIMPLE_RELATIONS_COLLECTION2COMMUNITY_KEY); - collection2item = RDFConfiguration.loadConfigurationArray(SIMPLE_RELATIONS_COLLECTION2ITEM_KEY); - item2collection = RDFConfiguration.loadConfigurationArray(SIMPLE_RELATIONS_ITEM2COLLECTION_KEY); - item2bitstream = RDFConfiguration.loadConfigurationArray(SIMPLE_RELATIONS_ITEM2BITSTREAM_KEY); - - if (site2community == null) - { - log.warn("SimpleDSORelationsConverterPlugin was unable to load " - + "configuration to convert relation between the repository " - + "the repository (SITE) and the top communities."); - } - if (community2site == null) - { - log.warn("SimpleDSORelationsConverterPlugin was unable to load " - + "configuration to convert relation between " - + "the top communities and the repository (SITE)."); - } - if (community2subcommunity == null) - { - log.warn("SimpleDSORelationsConverterPlugin was unable to load " - + "configuration to convert relation between " - + "communities and subcommunities."); - } - if (subcommunity2community == null) - { - log.warn("SimpleDSORelationsConverterPlugin was unable to load " - + "configuration to convert relation between " - + "subcommunities and communities."); - } - if (community2collection == null) - { - log.warn("SimpleDSORelationsConverterPlugin was unable to load " - + "configuration to convert relation between " - + "communities and collections."); - } - if (collection2community == null) - { - log.warn("SimpleDSORelationsConverterPlugin was unable to load " - + "configuration to convert relation between " - + "collections and communities."); - } - if (collection2item == null) - { - log.warn("SimpleDSORelationsConverterPlugin was unable to load " - + "configuration to convert relation between " - + "collections and items"); - } - if (item2collection == null) - { - log.warn("SimpleDSORelationsConverterPlugin was unable to load " - + "configuration to convert relation between " - + "items and collections"); - } - if (item2bitstream == null) - { - log.warn("SimpleDSORelationsConverterPlugin was unable to load " - + "configuration to convert relation between " - + "items and bitstreams."); - } - } + @Autowired(required=true) + protected BitstreamService bitstreamService; + @Autowired(required=true) + protected ItemService itemService; + @Autowired(required=true) + protected CommunityService communityService; + @Autowired(required=true) + protected SiteService siteService; + @Autowired(required=true) + protected ConfigurationService configurationService; /** * Loads the prefixes that should be used by the @@ -210,7 +136,8 @@ implements ConverterPlugin public Model convertSite(Context context, Site site) throws SQLException { - if (site2community == null) + String[] site2community = configurationService.getArrayProperty(SIMPLE_RELATIONS_SITE2COMMUNITY_KEY); + if (site2community == null || site2community.length == 0) { log.info("Either there was a problem loading the configuration or " + "linking from the repository (SITE) to the top level " @@ -262,33 +189,52 @@ implements ConverterPlugin public Model convertCommunity(Context context, Community community) throws SQLException { - if (community2site == null) + String[] community2site = configurationService.getArrayProperty(SIMPLE_RELATIONS_COMMUNITY2SITE_KEY); + if (community2site == null || community2site.length == 0) { log.info("Either there was a problem loading the configuration or " + "linking from the top level communities to the repository " + "(SITE) is disabled. Won't link from the top level " + "communities to the repository (SITE)."); + // don't return here, as we might have to add other links. + // ensure community2site is not null + community2site = new String[] {}; } - if (community2subcommunity == null) + + String[] community2subcommunity = configurationService.getArrayProperty(SIMPLE_RELATIONS_COMMUNITY2SUBCOMMUNITY_KEY); + if (community2subcommunity == null || community2subcommunity.length == 0) { log.info("Either there was a problem loading the configuration or " + "linking from communities to subcommunities was disabled. " + "Won't link from communities to subcommunities."); + // don't return here, as we might have to add other links. + // ensure community2subcommunity is not null + community2subcommunity = new String[] {}; } - if (subcommunity2community == null) + + String[] subcommunity2community = configurationService.getArrayProperty(SIMPLE_RELATIONS_SUBCOMMUNITY2COMMUNITY_KEY); + if (subcommunity2community == null || subcommunity2community.length == 0) { log.info("Either there was a problem loading the configuration or " + "linking from subcommunities to communities was disabled. " + "Won't link from subcommunities to communities."); + // don't return here, as we might have to add other links. + // ensure subcommunity2community is not null + subcommunity2community = new String[] {}; } - if (community2collection == null) + + String[] community2collection = configurationService.getArrayProperty(SIMPLE_RELATIONS_COMMUNITY2COLLECTION_KEY); + if (community2collection == null || community2collection.length == 0) { log.info("Either there was a problem loading the configuration or " + "linking from communities to collections was disabled. " + "Won't link from collections to subcommunities."); + // don't return here, as we might have to add other links. + // ensure community2collection is not null + community2collection = new String[] {}; } - if (community2site == null && community2subcommunity == null - && subcommunity2community == null && community2collection == null) + if (community2site.length == 0 && community2subcommunity.length == 0 + && subcommunity2community.length == 0 && community2collection.length == 0) { return null; } @@ -393,19 +339,28 @@ implements ConverterPlugin public Model convertCollection(Context context, Collection collection) throws SQLException { - if (collection2community == null) + String[] collection2community = configurationService.getArrayProperty(SIMPLE_RELATIONS_COLLECTION2COMMUNITY_KEY); + if (collection2community == null || collection2community.length == 0) { log.info("Either there was a problem loading the configuration or " + "linking from collections to communities was disabled. " + "Won't link from collections to communities."); + // don't return here, as we might have to link to items. + // ensure collection2community is not null + collection2community = new String[] {}; } - if (collection2item == null) + + String[] collection2item = configurationService.getArrayProperty(SIMPLE_RELATIONS_COLLECTION2ITEM_KEY); + if (collection2item == null || collection2item.length == 0) { log.info("Either there was a problem loading the configuration or " + "linking from collections to items was disabled. " + "Won't link from collections to items."); + // don't return here, as we might have to link to communities. + // ensure collection2item is not null + collection2item = new String[] {}; } - if (collection2community == null && collection2item == null) + if (collection2community.length == 0 && collection2item.length == 0) { return null; } @@ -468,19 +423,29 @@ implements ConverterPlugin public Model convertItem(Context context, Item item) throws SQLException { - if (item2collection == null) + String[] item2collection = configurationService.getArrayProperty(SIMPLE_RELATIONS_ITEM2COLLECTION_KEY); + if (item2collection == null || item2collection.length == 0) { log.info("Either there was a problem loading the configuration or " + "linking from items to collections was disabled. " + "Won't link from items to collections."); + // don't return here, as we might have to link to bitstreams. + // ensure item2collection is not null + item2collection = new String[] {}; } - if (item2bitstream == null) + + String[] item2bitstream = configurationService.getArrayProperty(SIMPLE_RELATIONS_ITEM2BITSTREAM_KEY); + if (item2bitstream == null || item2bitstream.length == 0) { log.info("Either there was a problem loading the configuration or " + "linking from items to bitstreams was disabled. " + "Won't link from items to bitstreams."); + // don't return here, as we might have to link to collections. + // ensure item2bitstream is not null + item2bitstream = new String[] {}; } - if (item2collection == null && item2bitstream == null) + + if (item2collection.length == 0 && item2bitstream.length == 0) { return null; } @@ -560,7 +525,7 @@ implements ConverterPlugin * @param bitstream Bitstream for which a URL should be generated. * @return The link to the URL or null if the Bistream is is a Community or * Collection logo. - * @throws SQLException + * @throws SQLException if database error */ public String bitstreamURI(Context context, Bitstream bitstream) throws SQLException diff --git a/dspace-api/src/main/java/org/dspace/rdf/conversion/StaticDSOConverterPlugin.java b/dspace-api/src/main/java/org/dspace/rdf/conversion/StaticDSOConverterPlugin.java index fade467057..23d37821f1 100644 --- a/dspace-api/src/main/java/org/dspace/rdf/conversion/StaticDSOConverterPlugin.java +++ b/dspace-api/src/main/java/org/dspace/rdf/conversion/StaticDSOConverterPlugin.java @@ -22,6 +22,7 @@ import org.dspace.core.Constants; import org.dspace.core.Context; import org.dspace.rdf.RDFUtil; import org.dspace.services.ConfigurationService; +import org.springframework.beans.factory.annotation.Autowired; /** * @@ -35,12 +36,14 @@ implements ConverterPlugin public static final String CONSTANT_DATA_FILENAME_KEY_PREFIX = "rdf.constant.data."; public static final String CONSTANT_DATA_GENERAL_KEY_SUFFIX = "GENERAL"; + @Autowired(required=true) protected ConfigurationService configurationService; @Override public void setConfigurationService(ConfigurationService configurationService) { this.configurationService = configurationService; } + @Override public Model convert(Context context, DSpaceObject dso) throws SQLException diff --git a/dspace-api/src/main/java/org/dspace/rdf/factory/RDFFactory.java b/dspace-api/src/main/java/org/dspace/rdf/factory/RDFFactory.java new file mode 100644 index 0000000000..37a936e75c --- /dev/null +++ b/dspace-api/src/main/java/org/dspace/rdf/factory/RDFFactory.java @@ -0,0 +1,32 @@ +/** + * The contents of this file are subject to the license and copyright + * detailed in the LICENSE and NOTICE files at the root of the source + * tree and available online at + * + * http://www.dspace.org/license/ + */ + +package org.dspace.rdf.factory; + +import org.dspace.rdf.conversion.RDFConverter; +import org.dspace.rdf.storage.RDFStorage; +import org.dspace.rdf.storage.URIGenerator; +import org.dspace.utils.DSpace; + +/** + * Abstract factory to get services for the rdf package, use RDFFactory.getInstance() to retrieve an implementation. + * @author Pascal-Nicolas Becker (p dot becker at tu hyphen berlin dot de) + */ +public abstract class RDFFactory +{ + public abstract RDFStorage getRDFStorage(); + + public abstract URIGenerator getURIGenerator(); + + public abstract RDFConverter getRDFConverter(); + + public static RDFFactory getInstance() + { + return new DSpace().getServiceManager().getServiceByName("rdfFactory", RDFFactory.class); + } +} \ No newline at end of file diff --git a/dspace-api/src/main/java/org/dspace/rdf/factory/RDFFactoryImpl.java b/dspace-api/src/main/java/org/dspace/rdf/factory/RDFFactoryImpl.java new file mode 100644 index 0000000000..48e2372a5c --- /dev/null +++ b/dspace-api/src/main/java/org/dspace/rdf/factory/RDFFactoryImpl.java @@ -0,0 +1,69 @@ +/** + * The contents of this file are subject to the license and copyright + * detailed in the LICENSE and NOTICE files at the root of the source + * tree and available online at + * + * http://www.dspace.org/license/ + */ + +package org.dspace.rdf.factory; + +import org.apache.log4j.Logger; +import org.dspace.rdf.conversion.RDFConverter; +import org.dspace.rdf.storage.RDFStorage; +import org.dspace.rdf.storage.URIGenerator; +import org.springframework.beans.factory.annotation.Required; + +/** + * + * @author Pascal-Nicolas Becker (p dot becker at tu hyphen berlin dot de) + */ +public class RDFFactoryImpl extends RDFFactory +{ + // we have several URIGenerators that use each other as fallback + // following we have to instantiate all of them and cannot use autowiring + // by type here. So we use setters and properties in spring configuration + // instead. + + private static final Logger log = Logger.getLogger(RDFFactoryImpl.class); + + private RDFStorage storage; + private URIGenerator generator; + private RDFConverter converter; + + @Required + public void setStorage(RDFStorage storage) { + this.storage = storage; + } + + @Required + public void setGenerator(URIGenerator generator) { + if (log.isDebugEnabled()) + { + log.debug("Using '" + generator.getClass().getCanonicalName() + + "' as URIGenerator."); + } + this.generator = generator; + } + + @Required + public void setConverter(RDFConverter converter) { + this.converter = converter; + } + + @Override + public RDFStorage getRDFStorage() { + return storage; + } + + @Override + public URIGenerator getURIGenerator() { + return generator; + } + + @Override + public RDFConverter getRDFConverter() { + return converter; + } + +} diff --git a/dspace-api/src/main/java/org/dspace/rdf/negotiation/NegotiationFilter.java b/dspace-api/src/main/java/org/dspace/rdf/negotiation/NegotiationFilter.java index b883e15f45..c30f76c2de 100644 --- a/dspace-api/src/main/java/org/dspace/rdf/negotiation/NegotiationFilter.java +++ b/dspace-api/src/main/java/org/dspace/rdf/negotiation/NegotiationFilter.java @@ -21,7 +21,8 @@ import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; -import org.dspace.rdf.RDFConfiguration; +import org.dspace.rdf.RDFUtil; +import org.dspace.services.factory.DSpaceServicesFactory; /** * @@ -45,7 +46,8 @@ public class NegotiationFilter implements Filter { try { - if (!RDFConfiguration.isContentNegotiationEnabled()) + if (!DSpaceServicesFactory.getInstance().getConfigurationService() + .getBooleanProperty(RDFUtil.CONTENT_NEGOTIATION_KEY, false)) { chain.doFilter(request, response); return; diff --git a/dspace-api/src/main/java/org/dspace/rdf/negotiation/Negotiator.java b/dspace-api/src/main/java/org/dspace/rdf/negotiation/Negotiator.java index 957517b6ed..fd8d28b69d 100644 --- a/dspace-api/src/main/java/org/dspace/rdf/negotiation/Negotiator.java +++ b/dspace-api/src/main/java/org/dspace/rdf/negotiation/Negotiator.java @@ -15,8 +15,8 @@ import java.util.Iterator; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.dspace.core.ConfigurationManager; -import org.dspace.rdf.RDFConfiguration; +import org.dspace.rdf.RDFUtil; +import org.dspace.services.factory.DSpaceServicesFactory; /** * @@ -244,7 +244,8 @@ public class Negotiator { if (StringUtils.isEmpty(handle)) { log.warn("Handle is empty, set it to Site Handle."); - handle = ConfigurationManager.getProperty("handle.prefix") + "/0"; + handle = DSpaceServicesFactory.getInstance().getConfigurationService() + .getProperty("handle.prefix") + "/0"; } // don't redirect if HTML is requested and content negotiation is done @@ -262,8 +263,10 @@ public class Negotiator { // if html is requested we have to forward to the repositories webui. if ("html".equals(lang)) { - urlBuilder.append(ConfigurationManager.getProperty("dspace.url")); - if (!handle.equals(ConfigurationManager.getProperty("handle.prefix") + "/0")) + urlBuilder.append(DSpaceServicesFactory.getInstance() + .getConfigurationService().getProperty("dspace.url")); + if (!handle.equals(DSpaceServicesFactory.getInstance() + .getConfigurationService().getProperty("handle.prefix") + "/0")) { urlBuilder.append("/handle/"); urlBuilder.append(handle).append("/").append(extraPathInfo); @@ -287,7 +290,9 @@ public class Negotiator { } // load the URI of the dspace-rdf module. - urlBuilder.append(RDFConfiguration.getDSpaceRDFModuleURI()); + urlBuilder.append(DSpaceServicesFactory.getInstance() + .getConfigurationService() + .getProperty(RDFUtil.CONTEXT_PATH_KEY)); if (urlBuilder.length() == 0) { log.error("Cannot load URL of dspace-rdf module. " diff --git a/dspace-api/src/main/java/org/dspace/rdf/storage/DOIHandleURIGenerator.java b/dspace-api/src/main/java/org/dspace/rdf/storage/DOIHandleURIGenerator.java index cd013d9584..8158345674 100644 --- a/dspace-api/src/main/java/org/dspace/rdf/storage/DOIHandleURIGenerator.java +++ b/dspace-api/src/main/java/org/dspace/rdf/storage/DOIHandleURIGenerator.java @@ -8,6 +8,10 @@ package org.dspace.rdf.storage; +import org.dspace.identifier.service.DOIService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Required; + /** * Extends the DOIURIGenerator but uses handles as fallback to DOIs. * @author pbecker @@ -16,7 +20,16 @@ public class DOIHandleURIGenerator extends DOIURIGenerator implements URIGenerator { + protected static URIGenerator fallback; - protected final static URIGenerator fallback = new HandleURIGenerator(); + @Required + public static void setFallback(URIGenerator fallback) { + DOIURIGenerator.fallback = fallback; + } + + @Autowired(required=true) + public void setDoiService(DOIService doiService) { + this.doiService = doiService; + } } diff --git a/dspace-api/src/main/java/org/dspace/rdf/storage/DOIURIGenerator.java b/dspace-api/src/main/java/org/dspace/rdf/storage/DOIURIGenerator.java index cf45c8b28e..e584b49dd3 100644 --- a/dspace-api/src/main/java/org/dspace/rdf/storage/DOIURIGenerator.java +++ b/dspace-api/src/main/java/org/dspace/rdf/storage/DOIURIGenerator.java @@ -20,6 +20,8 @@ import org.dspace.identifier.service.DOIService; import java.sql.SQLException; import java.util.List; import java.util.UUID; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Required; /** * @@ -30,12 +32,15 @@ implements URIGenerator { private static final Logger log = Logger.getLogger(DOIURIGenerator.class); - /* - * Currently (DSpace 5) DSpace supports DOIs for items only. This fallback - * will be used to generate an URI, whenever no DOI was found. - */ - protected final static URIGenerator fallback = new LocalURIGenerator(); - protected final DOIService doiService = IdentifierServiceFactory.getInstance().getDOIService(); + protected static URIGenerator fallback; + + @Required + public static void setFallback(URIGenerator fallback) { + DOIURIGenerator.fallback = fallback; + } + + @Autowired(required=true) + protected DOIService doiService; @Override public String generateIdentifier(Context context, int type, UUID id, String handle, List identifiers) throws SQLException { diff --git a/dspace-api/src/main/java/org/dspace/rdf/storage/HandleURIGenerator.java b/dspace-api/src/main/java/org/dspace/rdf/storage/HandleURIGenerator.java index 24c4f95d2d..c5d5646439 100644 --- a/dspace-api/src/main/java/org/dspace/rdf/storage/HandleURIGenerator.java +++ b/dspace-api/src/main/java/org/dspace/rdf/storage/HandleURIGenerator.java @@ -23,6 +23,7 @@ import org.dspace.handle.service.HandleService; import java.sql.SQLException; import java.util.List; import java.util.UUID; +import org.springframework.beans.factory.annotation.Autowired; /** * @@ -31,8 +32,10 @@ import java.util.UUID; public class HandleURIGenerator implements URIGenerator { private static final Logger log = Logger.getLogger(HandleURIGenerator.class); - protected final SiteService siteService = ContentServiceFactory.getInstance().getSiteService(); - protected final HandleService handleService = HandleServiceFactory.getInstance().getHandleService(); + @Autowired(required=true) + protected SiteService siteService; + @Autowired(required=true) + protected HandleService handleService; @Override diff --git a/dspace-api/src/main/java/org/dspace/rdf/storage/LocalURIGenerator.java b/dspace-api/src/main/java/org/dspace/rdf/storage/LocalURIGenerator.java index 4e5b27da5b..3f8dd8ab3b 100644 --- a/dspace-api/src/main/java/org/dspace/rdf/storage/LocalURIGenerator.java +++ b/dspace-api/src/main/java/org/dspace/rdf/storage/LocalURIGenerator.java @@ -15,12 +15,13 @@ import java.util.UUID; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.dspace.content.DSpaceObject; -import org.dspace.content.Site; import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.service.SiteService; import org.dspace.core.Constants; import org.dspace.core.Context; -import org.dspace.rdf.RDFConfiguration; +import org.dspace.rdf.RDFUtil; +import org.dspace.services.factory.DSpaceServicesFactory; +import org.springframework.beans.factory.annotation.Autowired; /** * @@ -29,14 +30,16 @@ import org.dspace.rdf.RDFConfiguration; public class LocalURIGenerator implements URIGenerator { private static final Logger log = Logger.getLogger(LocalURIGenerator.class); - protected final SiteService siteService = ContentServiceFactory.getInstance().getSiteService(); + @Autowired(required=true) + protected SiteService siteService; @Override public String generateIdentifier(Context context, int type, UUID id, String handle, List identifiers) throws SQLException { - String urlPrefix = RDFConfiguration.getDSpaceRDFModuleURI() + "/resource/"; + String urlPrefix = DSpaceServicesFactory.getInstance().getConfigurationService() + .getProperty(RDFUtil.CONTEXT_PATH_KEY) + "/resource/"; if (type == Constants.SITE) { diff --git a/dspace-api/src/main/java/org/dspace/rdf/storage/RDFStorageImpl.java b/dspace-api/src/main/java/org/dspace/rdf/storage/RDFStorageImpl.java index f773705fd8..6ee2e91a6d 100644 --- a/dspace-api/src/main/java/org/dspace/rdf/storage/RDFStorageImpl.java +++ b/dspace-api/src/main/java/org/dspace/rdf/storage/RDFStorageImpl.java @@ -30,9 +30,9 @@ import org.apache.jena.atlas.web.auth.SimpleAuthenticator; import org.apache.jena.web.DatasetGraphAccessor; import org.apache.jena.web.DatasetGraphAccessorHTTP; import org.apache.log4j.Logger; -import org.dspace.rdf.RDFConfiguration; +import org.dspace.rdf.RDFUtil; import org.dspace.services.ConfigurationService; -import org.dspace.services.factory.DSpaceServicesFactory; +import org.springframework.beans.factory.annotation.Autowired; /** * @@ -42,86 +42,9 @@ public class RDFStorageImpl implements RDFStorage { private static final Logger log = Logger.getLogger(RDFStorageImpl.class); - - private final String GRAPHSTORE_ENDPOINT; - private final String GRAPHSTORE_LOGIN; - private final String GRAPHSTORE_PASSWORD; - private final String SPARQL_ENDPOINT; - private final String SPARQL_LOGIN; - private final String SPARQL_PASSWORD; - - private ConfigurationService configurationService; - - public RDFStorageImpl() - { - this.configurationService = DSpaceServicesFactory.getInstance().getConfigurationService(); - - this.GRAPHSTORE_ENDPOINT = this.configurationService - .getProperty(RDFConfiguration.STORAGE_GRAPHSTORE_ENDPOINT_KEY); - if (StringUtils.isEmpty(this.GRAPHSTORE_ENDPOINT)) - { - log.warn("Cannot load Graph Store HTTP Protocol endpoint! Property " - + RDFConfiguration.STORAGE_GRAPHSTORE_ENDPOINT_KEY + " does not " - + "exist or is empty."); - throw new RuntimeException("Cannot load Graph Store HTTP Protocol " - + "endpoint! Property " - + RDFConfiguration.STORAGE_GRAPHSTORE_ENDPOINT_KEY + " does not " - + "exist or is empty."); - } - - boolean graphstore_use_auth = this.configurationService.getPropertyAsType( - RDFConfiguration.STORAGE_GRAPHSTORE_AUTHENTICATION_KEY, false); - String graphstore_login = this.configurationService.getProperty( - RDFConfiguration.STORAGE_GRAPHSTORE_LOGIN_KEY); - String graphstore_password = this.configurationService.getProperty( - RDFConfiguration.STORAGE_GRAPHSTORE_PASSWORD_KEY); - if (!graphstore_use_auth - || (graphstore_use_auth && StringUtils.isEmpty(graphstore_login)) - || (graphstore_use_auth && StringUtils.isEmpty(graphstore_password))) - { - this.GRAPHSTORE_LOGIN = null; - this.GRAPHSTORE_PASSWORD = null; - if (graphstore_use_auth) - { - log.warn("The rdf storage is configured to use authentication " - + "to connect to the Graph Store HTTP Protocol endpoint, " - + "but no credentials are configured."); - } - } else { - this.GRAPHSTORE_LOGIN = graphstore_login; - this.GRAPHSTORE_PASSWORD = graphstore_password; - } - - this.SPARQL_ENDPOINT = RDFConfiguration.getInternalSparqlEndpointAddress(); - if (StringUtils.isEmpty(this.SPARQL_ENDPOINT)) - { - log.warn("Cannot load internal or public SPARQL endpoint!"); - throw new RuntimeException("Cannot load internal or public SPARQL " - + "endpoint!"); - } - boolean sparql_use_auth = this.configurationService.getPropertyAsType( - RDFConfiguration.STORAGE_SPARQL_AUTHENTICATION_KEY, false); - String sparql_login = this.configurationService.getProperty( - RDFConfiguration.STORAGE_SPARQL_LOGIN_KEY); - String sparql_password = this.configurationService.getProperty( - RDFConfiguration.STORAGE_SPARQL_PASSWORD_KEY); - if (!sparql_use_auth - || (sparql_use_auth && StringUtils.isEmpty(sparql_login)) - || (sparql_use_auth && StringUtils.isEmpty(sparql_password))) - { - this.SPARQL_LOGIN = null; - this.SPARQL_PASSWORD = null; - if (sparql_use_auth) - { - log.warn("The rdf storage is configured to use authentication " - + "for sparql quries, but no credentials are configured."); - } - } else { - this.SPARQL_LOGIN = sparql_login; - this.SPARQL_PASSWORD = sparql_password; - } - } + @Autowired(required=true) + protected ConfigurationService configurationService; @Override public void store(String uri, Model model) @@ -153,14 +76,18 @@ implements RDFStorage protected DatasetGraphAccessor getAccessor() { DatasetGraphAccessor accessor; - if (this.GRAPHSTORE_LOGIN != null) + if (configurationService.hasProperty(RDFUtil.STORAGE_GRAPHSTORE_LOGIN_KEY) + && configurationService.hasProperty(RDFUtil.STORAGE_GRAPHSTORE_PASSWORD_KEY)) { HttpAuthenticator httpAuthenticator = new SimpleAuthenticator( - GRAPHSTORE_LOGIN, GRAPHSTORE_PASSWORD.toCharArray()); - accessor = new DatasetGraphAccessorHTTP(GRAPHSTORE_ENDPOINT, + configurationService.getProperty(RDFUtil.STORAGE_GRAPHSTORE_LOGIN_KEY), + configurationService.getProperty(RDFUtil.STORAGE_GRAPHSTORE_PASSWORD_KEY).toCharArray()); + accessor = new DatasetGraphAccessorHTTP(getGraphStoreEndpoint(), httpAuthenticator); } else { - accessor = new DatasetGraphAccessorHTTP(GRAPHSTORE_ENDPOINT); + log.debug("Did not found credential to use for our connection to the " + + "Graph Store HTTP endpoint, trying to connect unauthenticated."); + accessor = new DatasetGraphAccessorHTTP(getGraphStoreEndpoint()); } return accessor; } @@ -184,14 +111,16 @@ implements RDFStorage public List getAllStoredGraphs() { String queryString = "SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o } }"; QueryExecution qexec; - if (this.SPARQL_LOGIN != null) + if (configurationService.hasProperty(RDFUtil.STORAGE_SPARQL_LOGIN_KEY) + && configurationService.hasProperty(RDFUtil.STORAGE_SPARQL_PASSWORD_KEY)) { HttpAuthenticator httpAuthenticator = new SimpleAuthenticator( - SPARQL_LOGIN, SPARQL_PASSWORD.toCharArray()); - qexec = QueryExecutionFactory.sparqlService(SPARQL_ENDPOINT, + configurationService.getProperty(RDFUtil.STORAGE_SPARQL_LOGIN_KEY), + configurationService.getProperty(RDFUtil.STORAGE_GRAPHSTORE_PASSWORD_KEY).toCharArray()); + qexec = QueryExecutionFactory.sparqlService(getSparqlEndpoint(), queryString, httpAuthenticator); } else { - qexec = QueryExecutionFactory.sparqlService(SPARQL_ENDPOINT, + qexec = QueryExecutionFactory.sparqlService(getSparqlEndpoint(), queryString); } @@ -207,22 +136,40 @@ implements RDFStorage } qexec.close(); return graphs; - /* - } catch (QueryExceptionHTTP ex) + } + + protected String getGraphStoreEndpoint() + { + String endpoint = configurationService.getProperty(RDFUtil.STORAGE_GRAPHSTORE_ENDPOINT_KEY); + if (StringUtils.isEmpty(endpoint)) { - System.err.println("== QUERYEXCEPTIONHTTP =="); - System.err.println(ex.getMessage()); - System.err.println(ex.getResponseCode() + ": " + ex.getResponseMessage()); - Throwable cause = ex.getCause(); - int i = 1; - while (cause != null) - { - System.err.println("Cause " + i + " '" + cause.getClass().getName() + "': " + cause.getMessage()); - cause = cause.getCause(); - i++; - } - ex.printStackTrace(System.err); - throw new RuntimeException(ex); - }*/ + log.warn("Cannot load Graph Store HTTP Protocol endpoint! Property " + + RDFUtil.STORAGE_GRAPHSTORE_ENDPOINT_KEY + " does not " + + "exist or is empty."); + throw new RuntimeException("Cannot load Graph Store HTTP Protocol " + + "endpoint! Property " + + RDFUtil.STORAGE_GRAPHSTORE_ENDPOINT_KEY + " does not " + + "exist or is empty."); + } + return endpoint; + } + + protected String getSparqlEndpoint() + { + // Lets see if a SPARQL endpoint is defined to be used by RDFStorageImpl + String endpoint = configurationService.getProperty(RDFUtil.STORAGE_SPARQL_ENDPOINT_KEY); + if (StringUtils.isEmpty(endpoint)) + { + // try to load the public sparql endpoint + endpoint = configurationService.getProperty(RDFUtil.SPARQL_ENDPOINT_KEY); + } + // check if we found an endpoint + if (StringUtils.isEmpty(endpoint)) + { + log.warn("Cannot load internal or public SPARQL endpoint!"); + throw new RuntimeException("Cannot load internal or public SPARQL " + + "endpoint!"); + } + return endpoint; } } diff --git a/dspace-api/src/main/java/org/dspace/search/Harvest.java b/dspace-api/src/main/java/org/dspace/search/Harvest.java index ae12e974cc..cce88bfc90 100644 --- a/dspace-api/src/main/java/org/dspace/search/Harvest.java +++ b/dspace-api/src/main/java/org/dspace/search/Harvest.java @@ -84,7 +84,7 @@ public class Harvest * @param nonAnon * If items without anonymous access should be included or not * @return List of HarvestedItemInfo objects - * @throws java.sql.SQLException + * @throws SQLException if database error * @throws java.text.ParseException If the date is not in a supported format */ public static List harvest(Context context, DSpaceObject scope, @@ -203,7 +203,7 @@ public class Harvest * * @return HarvestedItemInfo object for the single item, or * null - * @throws java.sql.SQLException + * @throws SQLException if database error */ public static HarvestedItemInfo getSingle(Context context, String handle, boolean collections) throws SQLException @@ -242,7 +242,7 @@ public class Harvest * DSpace context * @param itemInfo * HarvestedItemInfo object to fill out - * @throws java.sql.SQLException + * @throws SQLException if database error */ private static void fillCollections(Context context, HarvestedItemInfo itemInfo) throws SQLException diff --git a/dspace-api/src/main/java/org/dspace/service/DSpaceCRUDService.java b/dspace-api/src/main/java/org/dspace/service/DSpaceCRUDService.java index 48910557a3..8dcf7ecc15 100644 --- a/dspace-api/src/main/java/org/dspace/service/DSpaceCRUDService.java +++ b/dspace-api/src/main/java/org/dspace/service/DSpaceCRUDService.java @@ -11,6 +11,7 @@ import org.dspace.authorize.AuthorizeException; import org.dspace.core.Context; import java.sql.SQLException; +import java.util.List; /** * Interface containing the simple CRUD methods so we don't have to add them over and again to every service which @@ -26,5 +27,7 @@ public interface DSpaceCRUDService { public void update(Context context, T t) throws SQLException, AuthorizeException; + public void update(Context context, List t) throws SQLException, AuthorizeException; + public void delete(Context context, T t) throws SQLException, AuthorizeException; } diff --git a/dspace-api/src/main/java/org/dspace/sort/SortOption.java b/dspace-api/src/main/java/org/dspace/sort/SortOption.java index 99951047aa..f61c8afefc 100644 --- a/dspace-api/src/main/java/org/dspace/sort/SortOption.java +++ b/dspace-api/src/main/java/org/dspace/sort/SortOption.java @@ -82,7 +82,7 @@ public class SortOption * @param name * @param md * @param type - * @throws SortException + * @throws SortException if sort error */ public SortOption(int number, String name, String md, String type) throws SortException @@ -100,7 +100,7 @@ public class SortOption * * @param number * @param definition - * @throws SortException + * @throws SortException if sort error */ public SortOption(int number, String definition) throws SortException @@ -219,7 +219,7 @@ public class SortOption /** * Tell the class to generate the metadata bits * - * @throws SortException + * @throws SortException if sort error */ private void generateMdBits() throws SortException @@ -293,7 +293,7 @@ public class SortOption /** * Return all the configured sort options. - * @throws SortException + * @throws SortException if sort error */ public static Set getSortOptions() throws SortException { @@ -308,7 +308,7 @@ public class SortOption /** * Get the defined sort option by number (.1, .2, etc). * @param number - * @throws SortException + * @throws SortException if sort error */ public static SortOption getSortOption(int number) throws SortException { @@ -325,7 +325,7 @@ public class SortOption /** * Get the default sort option - initially, just the first one defined. - * @throws SortException + * @throws SortException if sort error */ public static SortOption getDefaultSortOption() throws SortException { diff --git a/dspace-api/src/main/java/org/dspace/statistics/service/SolrLoggerService.java b/dspace-api/src/main/java/org/dspace/statistics/service/SolrLoggerService.java index 6a6c3bf33b..57e36e8319 100644 --- a/dspace-api/src/main/java/org/dspace/statistics/service/SolrLoggerService.java +++ b/dspace-api/src/main/java/org/dspace/statistics/service/SolrLoggerService.java @@ -75,7 +75,7 @@ public interface SolrLoggerService { * the current SolrInputDocument * @param dso * the current dspace object we want to log - * @throws java.sql.SQLException + * @throws SQLException if database error * ignore it */ public void storeParents(SolrInputDocument doc1, DSpaceObject dso) @@ -200,7 +200,7 @@ public interface SolrLoggerService { * Export all SOLR usage statistics for viewing/downloading content to a flat text file. * The file goes to a series * - * @throws Exception + * @throws Exception if error */ public void exportHits() throws Exception; diff --git a/dspace-api/src/main/java/org/dspace/statistics/util/ApacheLogRobotsProcessor.java b/dspace-api/src/main/java/org/dspace/statistics/util/ApacheLogRobotsProcessor.java index 243bf7378c..33c678be65 100644 --- a/dspace-api/src/main/java/org/dspace/statistics/util/ApacheLogRobotsProcessor.java +++ b/dspace-api/src/main/java/org/dspace/statistics/util/ApacheLogRobotsProcessor.java @@ -32,7 +32,7 @@ public class ApacheLogRobotsProcessor { * by analyzing users of the robots.txt file * * @param args - * @throws Exception + * @throws Exception if error */ public static void main(String[] args) throws Exception { diff --git a/dspace-api/src/main/java/org/dspace/storage/bitstore/BitStoreMigrate.java b/dspace-api/src/main/java/org/dspace/storage/bitstore/BitStoreMigrate.java index 9ebddab399..0d0754eccb 100644 --- a/dspace-api/src/main/java/org/dspace/storage/bitstore/BitStoreMigrate.java +++ b/dspace-api/src/main/java/org/dspace/storage/bitstore/BitStoreMigrate.java @@ -90,7 +90,7 @@ public class BitStoreMigrate { Integer sourceAssetstore = Integer.valueOf(line.getOptionValue('a')); Integer destinationAssetstore = Integer.valueOf(line.getOptionValue('b')); - //Safe default, commit every time. @TODO Performance Profile + //Safe default, commit every time. TODO Performance Profile Integer batchCommitSize = 1; if(line.hasOption('s')) { batchCommitSize = Integer.parseInt(line.getOptionValue('s')); diff --git a/dspace-api/src/main/java/org/dspace/storage/bitstore/BitstreamStorageServiceImpl.java b/dspace-api/src/main/java/org/dspace/storage/bitstore/BitstreamStorageServiceImpl.java index e3440e950c..f7bae8da27 100644 --- a/dspace-api/src/main/java/org/dspace/storage/bitstore/BitstreamStorageServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/storage/bitstore/BitstreamStorageServiceImpl.java @@ -143,7 +143,7 @@ public class BitstreamStorageServiceImpl implements BitstreamStorageService, Ini * @return The ID of the registered bitstream * @exception SQLException * If a problem occurs accessing the RDBMS - * @throws IOException + * @throws IOException if IO error */ @Override public UUID register(Context context, Bitstream bitstream, int assetstore, @@ -339,7 +339,7 @@ public class BitstreamStorageServiceImpl implements BitstreamStorageService, Ini * @param context * @param bitstream the bitstream to be cloned * @return id of the clone bitstream. - * @throws SQLException + * @throws SQLException if database error */ @Override public Bitstream clone(Context context, Bitstream bitstream) throws SQLException, IOException, AuthorizeException { diff --git a/dspace-api/src/main/java/org/dspace/storage/bitstore/service/BitstreamStorageService.java b/dspace-api/src/main/java/org/dspace/storage/bitstore/service/BitstreamStorageService.java index fbbe44eee4..cc9709cf27 100644 --- a/dspace-api/src/main/java/org/dspace/storage/bitstore/service/BitstreamStorageService.java +++ b/dspace-api/src/main/java/org/dspace/storage/bitstore/service/BitstreamStorageService.java @@ -99,7 +99,7 @@ public interface BitstreamStorageService { * @return The ID of the registered bitstream * @exception SQLException * If a problem occurs accessing the RDBMS - * @throws IOException + * @throws IOException if IO error */ public UUID register(Context context, Bitstream bitstream, int assetstore, String bitstreamPath) throws SQLException, IOException, AuthorizeException; @@ -152,7 +152,7 @@ public interface BitstreamStorageService { /** * Print out (log/out) a listing of the assetstores configured, and how many assets they contain * @param context - * @throws SQLException + * @throws SQLException if database error */ public void printStores(Context context) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseUtils.java b/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseUtils.java index 8da9b10d38..4c279b1765 100644 --- a/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseUtils.java +++ b/dspace-api/src/main/java/org/dspace/storage/rdbms/DatabaseUtils.java @@ -439,7 +439,7 @@ public class DatabaseUtils * If a Flyway DB migration fails it will be rolled back to the last * successful migration, and any errors will be logged. * - * @throws SQLException + * @throws SQLException if database error * If database cannot be upgraded. */ public static synchronized void updateDatabase() @@ -468,7 +468,7 @@ public class DatabaseUtils * DataSource object (retrieved from DatabaseManager()) * @param connection * Database connection - * @throws SQLException + * @throws SQLException if database error * If database cannot be upgraded. */ protected static synchronized void updateDatabase(DataSource datasource, Connection connection) @@ -497,7 +497,7 @@ public class DatabaseUtils * @param outOfOrder * If true, Flyway will run any lower version migrations that were previously "ignored". * If false, Flyway will only run new migrations with a higher version number. - * @throws SQLException + * @throws SQLException if database error * If database cannot be upgraded. */ protected static synchronized void updateDatabase(DataSource datasource, Connection connection, String targetVersion, boolean outOfOrder) @@ -580,7 +580,7 @@ public class DatabaseUtils * Initialized Flyway object * @param dataSource * Initialized DataSource - * @throws SQLException + * @throws SQLException if database error * If database cannot be cleaned. */ private static synchronized void cleanDatabase(Flyway flyway, DataSource dataSource) @@ -977,7 +977,7 @@ public class DatabaseUtils * Current Database Connection * @param sqlToExecute * The actual SQL to execute as a String - * @throws SQLException + * @throws SQLException if database error * If a database error occurs */ public static void executeSql(Connection connection, String sqlToExecute) throws SQLException @@ -1249,7 +1249,7 @@ public class DatabaseUtils * * @param connection current DB Connection * @return a DB keyword/type (see DatabaseUtils.DBMS_* constants) - * @throws SQLException + * @throws SQLException if database error */ public static String getDbType(Connection connection) throws SQLException diff --git a/dspace-api/src/main/java/org/dspace/submit/step/CCLicenseStep.java b/dspace-api/src/main/java/org/dspace/submit/step/CCLicenseStep.java index 076cfe1577..714de1a9f1 100644 --- a/dspace-api/src/main/java/org/dspace/submit/step/CCLicenseStep.java +++ b/dspace-api/src/main/java/org/dspace/submit/step/CCLicenseStep.java @@ -10,7 +10,7 @@ package org.dspace.submit.step; import java.util.Enumeration; import java.util.Map; import java.util.HashMap; - +import org.apache.commons.lang3.*; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; @@ -272,7 +272,7 @@ public class CCLicenseStep extends AbstractProcessingStep } return STATUS_COMPLETE; } - else if (licenseclass.equals("xmlui.Submission.submit.CCLicenseStep.select_change")) + else if (StringUtils.isBlank(licenseclass) || licenseclass.equals("xmlui.Submission.submit.CCLicenseStep.select_change")) { removeRequiredAttributes(session); return STATUS_COMPLETE; diff --git a/dspace-api/src/main/java/org/dspace/submit/step/DescribeStep.java b/dspace-api/src/main/java/org/dspace/submit/step/DescribeStep.java index 4445f71c9e..348acbd94a 100644 --- a/dspace-api/src/main/java/org/dspace/submit/step/DescribeStep.java +++ b/dspace-api/src/main/java/org/dspace/submit/step/DescribeStep.java @@ -821,7 +821,7 @@ public class DescribeStep extends AbstractProcessingStep * the metadata element * @param qualifier * the metadata qualifier, or null if unqualified - * @throws SQLException + * @throws SQLException if database error */ protected void readDate(Context context, HttpServletRequest request, Item item, String schema, String element, String qualifier) throws SQLException diff --git a/dspace-api/src/main/java/org/dspace/usage/TabFileUsageEventListener.java b/dspace-api/src/main/java/org/dspace/usage/TabFileUsageEventListener.java index 8c4e3e67fe..64daea6017 100644 --- a/dspace-api/src/main/java/org/dspace/usage/TabFileUsageEventListener.java +++ b/dspace-api/src/main/java/org/dspace/usage/TabFileUsageEventListener.java @@ -65,7 +65,7 @@ public class TabFileUsageEventListener String logDir = null; if (!new File(logPath).isAbsolute()) { - logDir = configurationService.getProperty("log.dir"); + logDir = configurationService.getProperty("log.report.dir"); } File logFile = new File(logDir, logPath); diff --git a/dspace-api/src/main/java/org/dspace/versioning/Version.java b/dspace-api/src/main/java/org/dspace/versioning/Version.java index 182b4382b4..d79b33e9cd 100644 --- a/dspace-api/src/main/java/org/dspace/versioning/Version.java +++ b/dspace-api/src/main/java/org/dspace/versioning/Version.java @@ -9,6 +9,7 @@ package org.dspace.versioning; import org.dspace.content.Item; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.dspace.eperson.EPerson; import org.hibernate.proxy.HibernateProxyHelper; @@ -24,13 +25,13 @@ import java.util.Date; */ @Entity @Table(name="versionitem") -public class Version { +public class Version implements ReloadableEntity { @Id @Column(name="versionitem_id") @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="versionitem_seq") @SequenceGenerator(name="versionitem_seq", sequenceName="versionitem_seq", allocationSize = 1) - private int id; + private Integer id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "item_id") @@ -68,7 +69,7 @@ public class Version { } - public int getId() { + public Integer getID() { return id; } @@ -133,7 +134,7 @@ public class Version { } final Version that = (Version)o; - if (this.getId() != that.getId()) + if (this.getID() != that.getID()) { return false; } @@ -144,7 +145,7 @@ public class Version { @Override public int hashCode() { int hash=7; - hash=79*hash+ this.getId(); + hash=79*hash+ this.getID(); return hash; } } diff --git a/dspace-api/src/main/java/org/dspace/versioning/VersionHistory.java b/dspace-api/src/main/java/org/dspace/versioning/VersionHistory.java index aee31cfe77..ca231cbc98 100644 --- a/dspace-api/src/main/java/org/dspace/versioning/VersionHistory.java +++ b/dspace-api/src/main/java/org/dspace/versioning/VersionHistory.java @@ -8,6 +8,7 @@ package org.dspace.versioning; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.hibernate.proxy.HibernateProxyHelper; import javax.persistence.*; @@ -25,7 +26,7 @@ import org.apache.log4j.Logger; */ @Entity @Table(name="versionhistory") -public class VersionHistory { +public class VersionHistory implements ReloadableEntity { private static final Logger log = Logger.getLogger(VersionHistory.class); @@ -33,7 +34,7 @@ public class VersionHistory { @Column(name="versionhistory_id") @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="versionhistory_seq") @SequenceGenerator(name="versionhistory_seq", sequenceName="versionhistory_seq", allocationSize = 1) - private int id; + private Integer id; //We use fetchtype eager for versions since we always require our versions when loading the history @OneToMany(fetch = FetchType.EAGER, mappedBy = "versionHistory") @@ -50,7 +51,7 @@ public class VersionHistory { } - public int getId() { + public Integer getID() { return id; } @@ -92,7 +93,7 @@ public class VersionHistory { } final VersionHistory that = (VersionHistory)o; - if (this.getId() != that.getId()) + if (this.getID() != that.getID()) { return false; } @@ -104,7 +105,7 @@ public class VersionHistory { public int hashCode() { int hash=7; - hash=79*hash+ this.getId(); + hash=79*hash+ this.getID(); return hash; } diff --git a/dspace-api/src/main/java/org/dspace/versioning/VersionHistoryServiceImpl.java b/dspace-api/src/main/java/org/dspace/versioning/VersionHistoryServiceImpl.java index 07d199ff65..96f9e7d682 100644 --- a/dspace-api/src/main/java/org/dspace/versioning/VersionHistoryServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/versioning/VersionHistoryServiceImpl.java @@ -7,17 +7,19 @@ */ package org.dspace.versioning; +import org.apache.commons.collections.CollectionUtils; import org.dspace.authorize.AuthorizeException; import org.dspace.content.Item; import org.dspace.core.Context; import org.dspace.versioning.dao.VersionHistoryDAO; import org.dspace.versioning.service.VersionHistoryService; +import org.dspace.versioning.service.VersioningService; import org.springframework.beans.factory.annotation.Autowired; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; -import org.dspace.versioning.service.VersioningService; /** * @@ -52,7 +54,16 @@ public class VersionHistoryServiceImpl implements VersionHistoryService @Override public void update(Context context, VersionHistory versionHistory) throws SQLException, AuthorizeException { - versionHistoryDAO.save(context, versionHistory); + update(context, Collections.singletonList(versionHistory)); + } + + @Override + public void update(Context context, List versionHistories) throws SQLException, AuthorizeException { + if(CollectionUtils.isNotEmpty(versionHistories)) { + for (VersionHistory versionHistory : versionHistories) { + versionHistoryDAO.save(context, versionHistory); + } + } } @Override diff --git a/dspace-api/src/main/java/org/dspace/versioning/dao/VersionDAO.java b/dspace-api/src/main/java/org/dspace/versioning/dao/VersionDAO.java index ca7e631c49..c8dfbfc2f0 100644 --- a/dspace-api/src/main/java/org/dspace/versioning/dao/VersionDAO.java +++ b/dspace-api/src/main/java/org/dspace/versioning/dao/VersionDAO.java @@ -19,7 +19,7 @@ import org.dspace.versioning.VersionHistory; /** * Database Access Object interface class for the Version object. * The implementation of this class is responsible for all database calls for the Version object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/versioning/dao/VersionHistoryDAO.java b/dspace-api/src/main/java/org/dspace/versioning/dao/VersionHistoryDAO.java index 076001d054..26e981062d 100644 --- a/dspace-api/src/main/java/org/dspace/versioning/dao/VersionHistoryDAO.java +++ b/dspace-api/src/main/java/org/dspace/versioning/dao/VersionHistoryDAO.java @@ -19,7 +19,7 @@ import org.dspace.versioning.Version; /** * Database Access Object interface class for the VersionHistory object. * The implementation of this class is responsible for all database calls for the VersionHistory object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/versioning/dao/impl/VersionDAOImpl.java b/dspace-api/src/main/java/org/dspace/versioning/dao/impl/VersionDAOImpl.java index 927ab35032..7804cc7d95 100644 --- a/dspace-api/src/main/java/org/dspace/versioning/dao/impl/VersionDAOImpl.java +++ b/dspace-api/src/main/java/org/dspace/versioning/dao/impl/VersionDAOImpl.java @@ -8,18 +8,18 @@ package org.dspace.versioning.dao.impl; import org.dspace.content.Item; -import org.dspace.core.Context; import org.dspace.core.AbstractHibernateDAO; +import org.dspace.core.Context; import org.dspace.versioning.Version; +import org.dspace.versioning.VersionHistory; import org.dspace.versioning.dao.VersionDAO; import org.hibernate.Criteria; +import org.hibernate.Query; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import java.sql.SQLException; import java.util.List; -import org.dspace.versioning.VersionHistory; -import org.hibernate.Query; -import org.hibernate.criterion.Order; /** * Hibernate implementation of the Database Access Object interface class for the Version object. @@ -51,7 +51,7 @@ public class VersionDAOImpl extends AbstractHibernateDAO implements Ver Query q = this.createQuery(c, "SELECT (COALESCE(MAX(versionNumber), 0) + 1) " + "FROM Version WHERE versionHistory.id = :historyId"); - q.setParameter("historyId", vh.getId()); + q.setParameter("historyId", vh.getID()); int next = (Integer) q.uniqueResult(); return next; diff --git a/dspace-api/src/main/java/org/dspace/workflowbasic/BasicWorkflowItem.java b/dspace-api/src/main/java/org/dspace/workflowbasic/BasicWorkflowItem.java index a68fe417b5..f4ae0c9f43 100644 --- a/dspace-api/src/main/java/org/dspace/workflowbasic/BasicWorkflowItem.java +++ b/dspace-api/src/main/java/org/dspace/workflowbasic/BasicWorkflowItem.java @@ -7,15 +7,15 @@ */ package org.dspace.workflowbasic; -import java.sql.SQLException; - import org.dspace.content.Collection; import org.dspace.content.Item; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.dspace.eperson.EPerson; import org.dspace.workflow.WorkflowItem; import javax.persistence.*; +import java.sql.SQLException; /** * Class representing an item going through the workflow process in DSpace @@ -25,14 +25,14 @@ import javax.persistence.*; */ @Entity @Table(name = "workflowitem") -public class BasicWorkflowItem implements WorkflowItem +public class BasicWorkflowItem implements WorkflowItem, ReloadableEntity { @Id @Column(name = "workflow_id", unique = true, nullable = false) @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="workflowitem_seq") @SequenceGenerator(name="workflowitem_seq", sequenceName="workflowitem_seq", allocationSize = 1) - private int workflowitemId; + private Integer workflowitemId; /** The item this workflow object pertains to */ @@ -78,7 +78,7 @@ public class BasicWorkflowItem implements WorkflowItem * @return the internal identifier */ @Override - public int getID() + public Integer getID() { return workflowitemId; } diff --git a/dspace-api/src/main/java/org/dspace/workflowbasic/TaskListItem.java b/dspace-api/src/main/java/org/dspace/workflowbasic/TaskListItem.java index 7a4175c758..3a70f6edf0 100644 --- a/dspace-api/src/main/java/org/dspace/workflowbasic/TaskListItem.java +++ b/dspace-api/src/main/java/org/dspace/workflowbasic/TaskListItem.java @@ -8,6 +8,7 @@ package org.dspace.workflowbasic; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.dspace.eperson.EPerson; import javax.persistence.*; @@ -19,7 +20,7 @@ import javax.persistence.*; */ @Entity @Table(name = "tasklistitem") -public class TaskListItem { +public class TaskListItem implements ReloadableEntity { @Id @Column(name = "tasklist_id", unique = true, nullable = false) @@ -64,4 +65,8 @@ public class TaskListItem { void setWorkflowItem(BasicWorkflowItem workflowItem) { this.workflowItem = workflowItem; } + + public Integer getID() { + return taskListItemId; + } } diff --git a/dspace-api/src/main/java/org/dspace/workflowbasic/dao/BasicWorkflowItemDAO.java b/dspace-api/src/main/java/org/dspace/workflowbasic/dao/BasicWorkflowItemDAO.java index 9248c92e2a..8a29b61199 100644 --- a/dspace-api/src/main/java/org/dspace/workflowbasic/dao/BasicWorkflowItemDAO.java +++ b/dspace-api/src/main/java/org/dspace/workflowbasic/dao/BasicWorkflowItemDAO.java @@ -20,7 +20,7 @@ import java.util.List; /** * Database Access Object interface class for the BasicWorkflowItem object. * The implementation of this class is responsible for all database calls for the BasicWorkflowItem object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/workflowbasic/dao/TaskListItemDAO.java b/dspace-api/src/main/java/org/dspace/workflowbasic/dao/TaskListItemDAO.java index af111607f9..10e0663ceb 100644 --- a/dspace-api/src/main/java/org/dspace/workflowbasic/dao/TaskListItemDAO.java +++ b/dspace-api/src/main/java/org/dspace/workflowbasic/dao/TaskListItemDAO.java @@ -19,7 +19,7 @@ import java.util.List; /** * Database Access Object interface class for the TaskListItem object. * The implementation of this class is responsible for all database calls for the TaskListItem object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/workflowbasic/service/BasicWorkflowItemService.java b/dspace-api/src/main/java/org/dspace/workflowbasic/service/BasicWorkflowItemService.java index 8e53420b52..26520e8c39 100644 --- a/dspace-api/src/main/java/org/dspace/workflowbasic/service/BasicWorkflowItemService.java +++ b/dspace-api/src/main/java/org/dspace/workflowbasic/service/BasicWorkflowItemService.java @@ -26,6 +26,13 @@ public interface BasicWorkflowItemService extends WorkflowItemService findPooledTasks(Context context, EPerson ePerson) throws SQLException; + /** + * Retrieve the list of BasicWorkflowItems that the given EPerson is owner of (owner == claimed for review) + * @param context the dspace context + * @param ePerson a DSpace EPerson + * @return a list of BasicWorkflowItem objects + * @throws SQLException + */ public List findByOwner(Context context, EPerson ePerson) throws SQLException; int countTotal(Context context) throws SQLException; diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/ClaimedTask.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/ClaimedTask.java index a842122fda..b57779c959 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/ClaimedTask.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/ClaimedTask.java @@ -8,6 +8,7 @@ package org.dspace.xmlworkflow.storedcomponents; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.dspace.eperson.EPerson; import javax.persistence.*; @@ -22,14 +23,14 @@ import javax.persistence.*; */ @Entity @Table(name="cwf_claimtask") -public class ClaimedTask { +public class ClaimedTask implements ReloadableEntity { @Id @Column(name="claimtask_id") @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="cwf_claimtask_seq") @SequenceGenerator(name="cwf_claimtask_seq", sequenceName="cwf_claimtask_seq", allocationSize = 1) - private int id; + private Integer id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "workflowitem_id") @@ -64,7 +65,7 @@ public class ClaimedTask { } - public int getId() { + public Integer getID() { return id; } diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/ClaimedTaskServiceImpl.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/ClaimedTaskServiceImpl.java index dc02ef5bbd..127a2eafdc 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/ClaimedTaskServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/ClaimedTaskServiceImpl.java @@ -7,6 +7,7 @@ */ package org.dspace.xmlworkflow.storedcomponents; +import org.apache.commons.collections.CollectionUtils; import org.dspace.authorize.AuthorizeException; import org.dspace.core.Context; import org.dspace.eperson.EPerson; @@ -15,6 +16,8 @@ import org.dspace.xmlworkflow.storedcomponents.service.ClaimedTaskService; import org.springframework.beans.factory.annotation.Autowired; import java.sql.SQLException; +import java.util.Arrays; +import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -48,7 +51,16 @@ public class ClaimedTaskServiceImpl implements ClaimedTaskService @Override public void update(Context context, ClaimedTask claimedTask) throws SQLException, AuthorizeException { - claimedTaskDAO.save(context, claimedTask); + update(context, Collections.singletonList(claimedTask)); + } + + @Override + public void update(Context context, List claimedTasks) throws SQLException, AuthorizeException { + if(CollectionUtils.isNotEmpty(claimedTasks)) { + for (ClaimedTask claimedTask : claimedTasks) { + claimedTaskDAO.save(context, claimedTask); + } + } } @Override diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/CollectionRole.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/CollectionRole.java index 55296e3eed..030cbfa783 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/CollectionRole.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/CollectionRole.java @@ -9,6 +9,7 @@ package org.dspace.xmlworkflow.storedcomponents; import org.dspace.content.Collection; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.dspace.eperson.Group; import javax.persistence.*; @@ -28,13 +29,13 @@ import java.sql.SQLException; */ @Entity @Table(name="cwf_collectionrole") -public class CollectionRole { +public class CollectionRole implements ReloadableEntity { @Id @Column(name="collectionrole_id") @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="cwf_collectionrole_seq") @SequenceGenerator(name="cwf_collectionrole_seq", sequenceName="cwf_collectionrole_seq", allocationSize = 1) - private int id; + private Integer id; // @Column(name = "role_id") // @Lob @@ -83,4 +84,7 @@ public class CollectionRole { return group; } + public Integer getID() { + return id; + } } diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/InProgressUser.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/InProgressUser.java index c3a92941ba..9479f51664 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/InProgressUser.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/InProgressUser.java @@ -8,6 +8,7 @@ package org.dspace.xmlworkflow.storedcomponents; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.dspace.eperson.EPerson; import javax.persistence.*; @@ -22,13 +23,13 @@ import javax.persistence.*; */ @Entity @Table(name="cwf_in_progress_user") -public class InProgressUser { +public class InProgressUser implements ReloadableEntity { @Id @Column(name="in_progress_user_id") @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="cwf_in_progress_user_seq") @SequenceGenerator(name="cwf_in_progress_user_seq", sequenceName="cwf_in_progress_user_seq", allocationSize = 1) - private int id; + private Integer id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name="user_id") @@ -51,7 +52,7 @@ public class InProgressUser { } - public int getId() { + public Integer getID() { return id; } diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/InProgressUserServiceImpl.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/InProgressUserServiceImpl.java index e7d82293e0..7df5381a1c 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/InProgressUserServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/InProgressUserServiceImpl.java @@ -7,6 +7,7 @@ */ package org.dspace.xmlworkflow.storedcomponents; +import org.apache.commons.collections.CollectionUtils; import org.dspace.authorize.AuthorizeException; import org.dspace.core.Context; import org.dspace.eperson.EPerson; @@ -15,6 +16,7 @@ import org.dspace.xmlworkflow.storedcomponents.service.InProgressUserService; import org.springframework.beans.factory.annotation.Autowired; import java.sql.SQLException; +import java.util.Collections; import java.util.List; /** @@ -71,7 +73,16 @@ public class InProgressUserServiceImpl implements InProgressUserService { @Override public void update(Context context, InProgressUser inProgressUser) throws SQLException, AuthorizeException { - inProgressUserDAO.save(context, inProgressUser); + update(context, Collections.singletonList(inProgressUser)); + } + + @Override + public void update(Context context, List inProgressUsers) throws SQLException, AuthorizeException { + if(CollectionUtils.isNotEmpty(inProgressUsers)) { + for (InProgressUser inProgressUser : inProgressUsers) { + inProgressUserDAO.save(context, inProgressUser); + } + } } @Override diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/PoolTask.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/PoolTask.java index 6a7a53848f..c20253faa9 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/PoolTask.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/PoolTask.java @@ -8,6 +8,7 @@ package org.dspace.xmlworkflow.storedcomponents; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.dspace.eperson.EPerson; import org.dspace.eperson.Group; @@ -24,13 +25,13 @@ import java.sql.SQLException; */ @Entity @Table(name="cwf_pooltask") -public class PoolTask { +public class PoolTask implements ReloadableEntity { @Id @Column(name="pooltask_id") @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="cwf_pooltask_seq") @SequenceGenerator(name="cwf_pooltask_seq", sequenceName="cwf_pooltask_seq", allocationSize = 1) - private int id; + private Integer id; @OneToOne @JoinColumn(name = "workflowitem_id") @@ -70,6 +71,10 @@ public class PoolTask { } + public Integer getID() { + return id; + } + public void setEperson(EPerson eperson){ this.ePerson = eperson; } @@ -117,5 +122,4 @@ public class PoolTask { public String getActionID(){ return this.actionId; } - } diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/PoolTaskServiceImpl.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/PoolTaskServiceImpl.java index 80b9bb8525..3ede946a65 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/PoolTaskServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/PoolTaskServiceImpl.java @@ -7,6 +7,7 @@ */ package org.dspace.xmlworkflow.storedcomponents; +import org.apache.commons.collections.CollectionUtils; import org.dspace.authorize.AuthorizeException; import org.dspace.core.Context; import org.dspace.eperson.EPerson; @@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -133,7 +135,16 @@ public class PoolTaskServiceImpl implements PoolTaskService { @Override public void update(Context context, PoolTask poolTask) throws SQLException, AuthorizeException { - poolTaskDAO.save(context, poolTask); + update(context, Collections.singletonList(poolTask)); + } + + @Override + public void update(Context context, List poolTasks) throws SQLException, AuthorizeException { + if(CollectionUtils.isNotEmpty(poolTasks)) { + for (PoolTask poolTask : poolTasks) { + poolTaskDAO.save(context, poolTask); + } + } } @Override diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/WorkflowItemRole.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/WorkflowItemRole.java index f33129393a..13c33fa3a8 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/WorkflowItemRole.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/WorkflowItemRole.java @@ -8,6 +8,7 @@ package org.dspace.xmlworkflow.storedcomponents; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.dspace.eperson.EPerson; import org.dspace.eperson.Group; @@ -26,13 +27,13 @@ import java.sql.SQLException; */ @Entity @Table(name="cwf_workflowitemrole") -public class WorkflowItemRole { +public class WorkflowItemRole implements ReloadableEntity { @Id @Column(name="workflowitemrole_id") @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="cwf_workflowitemrole_seq") @SequenceGenerator(name="cwf_workflowitemrole_seq", sequenceName="cwf_workflowitemrole_seq", allocationSize = 1) - private int id; + private Integer id; // @Column(name = "role_id") // @Lob @@ -62,6 +63,10 @@ public class WorkflowItemRole { } + public Integer getID() { + return id; + } + public void setRoleId(String id){ this.roleId = id; } @@ -93,5 +98,4 @@ public class WorkflowItemRole { public Group getGroup() throws SQLException { return group; } - } diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/WorkflowItemRoleServiceImpl.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/WorkflowItemRoleServiceImpl.java index 58d0b4056e..a23ffd61e4 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/WorkflowItemRoleServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/WorkflowItemRoleServiceImpl.java @@ -7,6 +7,7 @@ */ package org.dspace.xmlworkflow.storedcomponents; +import org.apache.commons.collections.CollectionUtils; import org.dspace.authorize.AuthorizeException; import org.dspace.core.Context; import org.dspace.eperson.EPerson; @@ -15,6 +16,7 @@ import org.dspace.xmlworkflow.storedcomponents.service.WorkflowItemRoleService; import org.springframework.beans.factory.annotation.Autowired; import java.sql.SQLException; +import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -72,7 +74,16 @@ public class WorkflowItemRoleServiceImpl implements WorkflowItemRoleService { @Override public void update(Context context, WorkflowItemRole workflowItemRole) throws SQLException, AuthorizeException { - workflowItemRoleDAO.save(context, workflowItemRole); + update(context, Collections.singletonList(workflowItemRole)); + } + + @Override + public void update(Context context, List workflowItemRoles) throws SQLException, AuthorizeException { + if(CollectionUtils.isNotEmpty(workflowItemRoles)) { + for (WorkflowItemRole workflowItemRole : workflowItemRoles) { + workflowItemRoleDAO.save(context, workflowItemRole); + } + } } @Override diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/XmlWorkflowItem.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/XmlWorkflowItem.java index 7842c17230..587198cbdc 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/XmlWorkflowItem.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/XmlWorkflowItem.java @@ -10,6 +10,7 @@ package org.dspace.xmlworkflow.storedcomponents; import org.dspace.content.Collection; import org.dspace.content.Item; import org.dspace.core.Context; +import org.dspace.core.ReloadableEntity; import org.dspace.eperson.EPerson; import org.dspace.workflow.WorkflowItem; @@ -26,13 +27,13 @@ import java.sql.SQLException; */ @Entity @Table(name="cwf_workflowitem") -public class XmlWorkflowItem implements WorkflowItem { +public class XmlWorkflowItem implements WorkflowItem, ReloadableEntity { @Id @Column(name="workflowitem_id") @GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="cwf_workflowitem_seq") @SequenceGenerator(name="cwf_workflowitem_seq", sequenceName="cwf_workflowitem_seq", allocationSize = 1) - private int id; + private Integer id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "collection_id") @@ -67,7 +68,7 @@ public class XmlWorkflowItem implements WorkflowItem { * @return the internal identifier */ @Override - public int getID() + public Integer getID() { return id; } diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/ClaimedTaskDAO.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/ClaimedTaskDAO.java index 8f3870012c..c8224ac682 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/ClaimedTaskDAO.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/ClaimedTaskDAO.java @@ -19,7 +19,7 @@ import java.util.List; /** * Database Access Object interface class for the ClaimedTask object. * The implementation of this class is responsible for all database calls for the ClaimedTask object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/CollectionRoleDAO.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/CollectionRoleDAO.java index fc1865c050..c2cdf70fac 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/CollectionRoleDAO.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/CollectionRoleDAO.java @@ -18,7 +18,7 @@ import java.util.List; /** * Database Access Object interface class for the CollectionRole object. * The implementation of this class is responsible for all database calls for the CollectionRole object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/InProgressUserDAO.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/InProgressUserDAO.java index 644fe11fe7..89277758dd 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/InProgressUserDAO.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/InProgressUserDAO.java @@ -19,7 +19,7 @@ import java.util.List; /** * Database Access Object interface class for the InProgressUser object. * The implementation of this class is responsible for all database calls for the InProgressUser object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/PoolTaskDAO.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/PoolTaskDAO.java index e6e6a84427..6e5a925ef4 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/PoolTaskDAO.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/PoolTaskDAO.java @@ -20,7 +20,7 @@ import java.util.List; /** * Database Access Object interface class for the PoolTask object. * The implementation of this class is responsible for all database calls for the PoolTask object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/WorkflowItemRoleDAO.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/WorkflowItemRoleDAO.java index 479285620a..435d967b58 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/WorkflowItemRoleDAO.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/WorkflowItemRoleDAO.java @@ -19,7 +19,7 @@ import java.util.List; /** * Database Access Object interface class for the WorkflowItemRole object. * The implementation of this class is responsible for all database calls for the WorkflowItemRole object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/XmlWorkflowItemDAO.java b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/XmlWorkflowItemDAO.java index 90adff8a72..559a920575 100644 --- a/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/XmlWorkflowItemDAO.java +++ b/dspace-api/src/main/java/org/dspace/xmlworkflow/storedcomponents/dao/XmlWorkflowItemDAO.java @@ -20,7 +20,7 @@ import java.util.List; /** * Database Access Object interface class for the XmlWorkflowItem object. * The implementation of this class is responsible for all database calls for the XmlWorkflowItem object and is autowired by spring - * This class should only be accessed from a single service & should never be exposed outside of the API + * This class should only be accessed from a single service and should never be exposed outside of the API * * @author kevinvandevelde at atmire.com */ diff --git a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V6.0_2016.04.04__DS-3086-OAI-Performance-fix.sql b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V6.0_2016.04.04__DS-3086-OAI-Performance-fix.sql new file mode 100644 index 0000000000..9d9579b375 --- /dev/null +++ b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V6.0_2016.04.04__DS-3086-OAI-Performance-fix.sql @@ -0,0 +1,28 @@ +-- +-- The contents of this file are subject to the license and copyright +-- detailed in the LICENSE and NOTICE files at the root of the source +-- tree and available online at +-- +-- http://www.dspace.org/license/ +-- + +--------------------------------------------------------------- +-- DS-3086 OAI Harvesting performance +--------------------------------------------------------------- +-- This script will create indexes on the key fields of the +-- metadataschemaregistry and metadatafieldregistry tables to +-- increase the performance of the queries. It will also add +-- "ON DELETE CASCADE" to improve the performance of Item deletion. +--------------------------------------------------------------- + +CREATE UNIQUE INDEX metadataschemaregistry_unique_idx_short_id on metadataschemaregistry(short_id); + +CREATE INDEX metadatafieldregistry_idx_element_qualifier on metadatafieldregistry(element, qualifier); + +CREATE INDEX resourcepolicy_idx_rptype on resourcepolicy(rptype); + +ALTER TABLE resourcepolicy DROP CONSTRAINT ResourcePolicy_dspace_object_fk; +ALTER TABLE ResourcePolicy ADD CONSTRAINT ResourcePolicy_dspace_object_fk FOREIGN KEY (dspace_object) REFERENCES dspaceobject ON DELETE CASCADE; + +ALTER TABLE metadatavalue DROP CONSTRAINT metadatavalue_dspace_object_id_fk; +ALTER TABLE metadatavalue ADD CONSTRAINT metadatavalue_dspace_object_id_fk FOREIGN KEY (dspace_object_id) REFERENCES dspaceobject ON DELETE CASCADE; diff --git a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V6.0_2016.05.10__DS-3168-fix-requestitem_item_id_column.sql b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V6.0_2016.05.10__DS-3168-fix-requestitem_item_id_column.sql new file mode 100644 index 0000000000..ccde6ab222 --- /dev/null +++ b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V6.0_2016.05.10__DS-3168-fix-requestitem_item_id_column.sql @@ -0,0 +1,24 @@ +-- +-- The contents of this file are subject to the license and copyright +-- detailed in the LICENSE and NOTICE files at the root of the source +-- tree and available online at +-- +-- http://www.dspace.org/license/ +-- + +--------------------------------------------------------------- +-- DS-3168 Embargo request Unknown Entity RequestItem +--------------------------------------------------------------- +-- convert the item_id and bitstream_id columns from integer to UUID +--------------------------------------------------------------- +ALTER TABLE requestitem ALTER COLUMN item_id rename to item_legacy_id; +ALTER TABLE requestitem ADD COLUMN item_id UUID; +ALTER TABLE requestitem ADD CONSTRAINT requestitem_item_id_fk FOREIGN KEY (item_id) REFERENCES Item; +UPDATE requestitem SET item_id = (SELECT item.uuid FROM item WHERE requestitem.item_legacy_id = item.item_id); +ALTER TABLE requestitem DROP COLUMN item_legacy_id; + +ALTER TABLE requestitem ALTER COLUMN bitstream_id rename to bitstream_legacy_id; +ALTER TABLE requestitem ADD COLUMN bitstream_id UUID; +ALTER TABLE requestitem ADD CONSTRAINT requestitem_id_fk FOREIGN KEY (bitstream_id) REFERENCES Bitstream; +UPDATE requestitem SET bitstream_id = (SELECT Bitstream.uuid FROM Bitstream WHERE requestitem.bitstream_legacy_id = Bitstream.bitstream_id); +ALTER TABLE requestitem DROP COLUMN bitstream_legacy_id; \ No newline at end of file diff --git a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/oracle/V6.0_2016.04.04__DS-3086-OAI-Performance-fix.sql b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/oracle/V6.0_2016.04.04__DS-3086-OAI-Performance-fix.sql new file mode 100644 index 0000000000..7b13d10b6d --- /dev/null +++ b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/oracle/V6.0_2016.04.04__DS-3086-OAI-Performance-fix.sql @@ -0,0 +1,46 @@ +-- +-- The contents of this file are subject to the license and copyright +-- detailed in the LICENSE and NOTICE files at the root of the source +-- tree and available online at +-- +-- http://www.dspace.org/license/ +-- + +--------------------------------------------------------------- +-- DS-3086 OAI Harvesting performance +--------------------------------------------------------------- +-- This script will create indexes on the key fields of the +-- metadataschemaregistry and metadatafieldregistry tables to +-- increase the performance of the queries. It will also add +-- "ON DELETE CASCADE" to improve the performance of Item deletion. +--------------------------------------------------------------- + +CREATE UNIQUE INDEX metadataschema_idx_short_id on metadataschemaregistry(short_id); + +CREATE INDEX metadatafield_idx_elem_qual on metadatafieldregistry(element, qualifier); + +CREATE INDEX resourcepolicy_idx_rptype on resourcepolicy(rptype); + +-- Add "ON DELETE CASCADE" to foreign key constraint to Item +ALTER TABLE RESOURCEPOLICY ADD DSPACE_OBJECT_NEW RAW(16); +UPDATE RESOURCEPOLICY SET DSPACE_OBJECT_NEW = DSPACE_OBJECT; +ALTER TABLE RESOURCEPOLICY DROP COLUMN DSPACE_OBJECT; +ALTER TABLE RESOURCEPOLICY RENAME COLUMN DSPACE_OBJECT_NEW to DSPACE_OBJECT; + +ALTER TABLE RESOURCEPOLICY +ADD CONSTRAINT RESOURCEPOLICY_DSPACE_OBJ_FK +FOREIGN KEY (DSPACE_OBJECT) +REFERENCES dspaceobject(uuid) +ON DELETE CASCADE; + +-- Add "ON DELETE CASCADE" to foreign key constraint to Item +ALTER TABLE METADATAVALUE ADD DSPACE_OBJECT_NEW RAW(16); +UPDATE METADATAVALUE SET DSPACE_OBJECT_NEW = DSPACE_OBJECT_ID; +ALTER TABLE METADATAVALUE DROP COLUMN DSPACE_OBJECT_ID; +ALTER TABLE METADATAVALUE RENAME COLUMN DSPACE_OBJECT_NEW to DSPACE_OBJECT_ID; + +ALTER TABLE METADATAVALUE +ADD CONSTRAINT METADATAVALUE_DSPACE_OBJECT_FK +FOREIGN KEY (DSPACE_OBJECT_ID) +REFERENCES DSPACEOBJECT(UUID) +ON DELETE CASCADE; \ No newline at end of file diff --git a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/oracle/V6.0_2016.05.10__DS-3168-fix-requestitem_item_id_column.sql b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/oracle/V6.0_2016.05.10__DS-3168-fix-requestitem_item_id_column.sql new file mode 100644 index 0000000000..2ba3517e19 --- /dev/null +++ b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/oracle/V6.0_2016.05.10__DS-3168-fix-requestitem_item_id_column.sql @@ -0,0 +1,24 @@ +-- +-- The contents of this file are subject to the license and copyright +-- detailed in the LICENSE and NOTICE files at the root of the source +-- tree and available online at +-- +-- http://www.dspace.org/license/ +-- + +--------------------------------------------------------------- +-- DS-3168 Embargo request Unknown Entity RequestItem +--------------------------------------------------------------- +-- convert the item_id and bitstream_id columns from integer to UUID +--------------------------------------------------------------- +ALTER TABLE requestitem RENAME COLUMN item_id to item_legacy_id; +ALTER TABLE requestitem ADD item_id RAW(16) REFERENCES Item(uuid); +CREATE INDEX requestitem_item on requestitem(item_id); +UPDATE requestitem SET item_id = (SELECT item.uuid FROM item WHERE requestitem.item_legacy_id = item.item_id); +ALTER TABLE requestitem DROP COLUMN item_legacy_id; + +ALTER TABLE requestitem RENAME COLUMN bitstream_id to bitstream_legacy_id; +ALTER TABLE requestitem ADD bitstream_id RAW(16) REFERENCES Bitstream(uuid); +CREATE INDEX requestitem_bitstream on requestitem(bitstream_id); +UPDATE requestitem SET bitstream_id = (SELECT Bitstream.uuid FROM Bitstream WHERE requestitem.bitstream_legacy_id = Bitstream.bitstream_id); +ALTER TABLE requestitem DROP COLUMN bitstream_legacy_id; \ No newline at end of file diff --git a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V6.0_2016.04.04__DS-3086-OAI-Performance-fix.sql b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V6.0_2016.04.04__DS-3086-OAI-Performance-fix.sql new file mode 100644 index 0000000000..0603c39396 --- /dev/null +++ b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V6.0_2016.04.04__DS-3086-OAI-Performance-fix.sql @@ -0,0 +1,42 @@ +-- +-- The contents of this file are subject to the license and copyright +-- detailed in the LICENSE and NOTICE files at the root of the source +-- tree and available online at +-- +-- http://www.dspace.org/license/ +-- + +--------------------------------------------------------------- +-- DS-3086 OAI Harvesting performance +--------------------------------------------------------------- +-- This script will create indexes on the key fields of the +-- metadataschemaregistry and metadatafieldregistry tables to +-- increase the performance of the queries. It will also add +-- "ON DELETE CASCADE" to improve the performance of Item deletion. +--------------------------------------------------------------- + +CREATE UNIQUE INDEX metadataschemaregistry_unique_idx_short_id on metadataschemaregistry(short_id); + +CREATE INDEX metadatafieldregistry_idx_element_qualifier on metadatafieldregistry(element, qualifier); + +CREATE INDEX resourcepolicy_idx_rptype on resourcepolicy(rptype); + +ALTER TABLE resourcepolicy +DROP CONSTRAINT resourcepolicy_dspace_object_fkey, +ADD CONSTRAINT resourcepolicy_dspace_object_fkey +FOREIGN KEY (dspace_object) +REFERENCES dspaceobject(uuid) +ON DELETE CASCADE; + +ALTER TABLE metadatavalue +DROP CONSTRAINT metadatavalue_dspace_object_id_fkey, +ADD CONSTRAINT metadatavalue_dspace_object_id_fkey +FOREIGN KEY (dspace_object_id) +REFERENCES dspaceobject(uuid) +ON DELETE CASCADE; + +-- Clean up + +-- Duplicate of INDEX metadatavalue_field_object (a composite index can also serve as a 'single field' index) +-- and metadatavalue_field_fk_idx. This index also does not exist for H2 or Oracle. +DROP INDEX metadatavalue_field; \ No newline at end of file diff --git a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V6.0_2016.05.10__DS-3168-fix-requestitem_item_id_column.sql b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V6.0_2016.05.10__DS-3168-fix-requestitem_item_id_column.sql new file mode 100644 index 0000000000..afa7c5e68a --- /dev/null +++ b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V6.0_2016.05.10__DS-3168-fix-requestitem_item_id_column.sql @@ -0,0 +1,24 @@ +-- +-- The contents of this file are subject to the license and copyright +-- detailed in the LICENSE and NOTICE files at the root of the source +-- tree and available online at +-- +-- http://www.dspace.org/license/ +-- + +--------------------------------------------------------------- +-- DS-3168 Embargo request Unknown Entity RequestItem +--------------------------------------------------------------- +-- convert the item_id and bitstream_id columns from integer to UUID +--------------------------------------------------------------- +ALTER TABLE requestitem RENAME COLUMN item_id to item_legacy_id; +ALTER TABLE requestitem ADD COLUMN item_id UUID REFERENCES Item(uuid); +UPDATE requestitem SET item_id = (SELECT item.uuid FROM item WHERE requestitem.item_legacy_id = item.item_id); +ALTER TABLE requestitem DROP COLUMN item_legacy_id; +CREATE INDEX requestitem_item on requestitem(item_id); + +ALTER TABLE requestitem RENAME COLUMN bitstream_id to bitstream_legacy_id; +ALTER TABLE requestitem ADD COLUMN bitstream_id UUID REFERENCES Bitstream(uuid); +UPDATE requestitem SET bitstream_id = (SELECT Bitstream.uuid FROM Bitstream WHERE requestitem.bitstream_legacy_id = Bitstream.bitstream_id); +ALTER TABLE requestitem DROP COLUMN bitstream_legacy_id; +CREATE INDEX requestitem_bitstream on requestitem(bitstream_id); \ No newline at end of file diff --git a/dspace-api/src/test/java/org/dspace/AbstractUnitTest.java b/dspace-api/src/test/java/org/dspace/AbstractUnitTest.java index 069130000d..43e8c7574f 100644 --- a/dspace-api/src/test/java/org/dspace/AbstractUnitTest.java +++ b/dspace-api/src/test/java/org/dspace/AbstractUnitTest.java @@ -7,10 +7,6 @@ */ package org.dspace; -import static org.junit.Assert.fail; - -import java.sql.SQLException; - import org.apache.log4j.Logger; import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.factory.AuthorizeServiceFactory; @@ -26,6 +22,10 @@ import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; +import java.sql.SQLException; + +import static org.junit.Assert.fail; + /** @@ -85,7 +85,8 @@ public class AbstractUnitTest extends AbstractDSpaceTest catch(SQLException se) { log.error("Error initializing database", se); - fail("Error initializing database: " + se.getMessage()); + fail("Error initializing database: " + se.getMessage() + + (se.getCause() == null ? "" : ": " + se.getCause().getMessage())); } // Initialize mock indexer (which does nothing, since Solr isn't running) diff --git a/dspace-api/src/test/java/org/dspace/checker/dao/impl/ChecksumHistoryDAOImplTest.java b/dspace-api/src/test/java/org/dspace/checker/dao/impl/ChecksumHistoryDAOImplTest.java index 489870d2ab..63187fb3a8 100644 --- a/dspace-api/src/test/java/org/dspace/checker/dao/impl/ChecksumHistoryDAOImplTest.java +++ b/dspace-api/src/test/java/org/dspace/checker/dao/impl/ChecksumHistoryDAOImplTest.java @@ -91,7 +91,7 @@ public class ChecksumHistoryDAOImplTest bss.update(context, bs); context.restoreAuthSystemState(); - cal.roll(Calendar.DATE, -1); + cal.add(Calendar.DATE, -1); Date matchDate = cal.getTime(); checkId++; qry.setInteger("id", checkId); @@ -101,7 +101,7 @@ public class ChecksumHistoryDAOImplTest qry.executeUpdate(); // Row with nonmatching result code - cal.roll(Calendar.DATE, -1); + cal.add(Calendar.DATE, -1); Date noMatchDate = cal.getTime(); checkId++; qry.setInteger("id", checkId); @@ -111,7 +111,7 @@ public class ChecksumHistoryDAOImplTest qry.executeUpdate(); // Create one newer row - cal.roll(Calendar.DATE, +3); + cal.add(Calendar.DATE, +3); Date futureDate = cal.getTime(); checkId++; qry.setInteger("id", checkId); diff --git a/dspace-api/src/test/java/org/dspace/content/InstallItemTest.java b/dspace-api/src/test/java/org/dspace/content/InstallItemTest.java index f4628119bc..7cae76fcc9 100644 --- a/dspace-api/src/test/java/org/dspace/content/InstallItemTest.java +++ b/dspace-api/src/test/java/org/dspace/content/InstallItemTest.java @@ -7,26 +7,28 @@ */ package org.dspace.content; -import mockit.*; - +import mockit.NonStrictExpectations; +import org.apache.log4j.Logger; +import org.dspace.AbstractUnitTest; import org.dspace.authorize.AuthorizeException; import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.service.*; import org.dspace.core.Constants; import org.dspace.core.Context; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; -import java.io.FileInputStream; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.sql.SQLException; import java.util.List; -import org.dspace.AbstractUnitTest; -import org.apache.log4j.Logger; -import org.junit.*; -import static org.junit.Assert.* ; -import static org.hamcrest.CoreMatchers.*; -import org.junit.rules.ExpectedException; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.*; /** diff --git a/dspace-api/src/test/java/org/dspace/content/MetadataFieldTest.java b/dspace-api/src/test/java/org/dspace/content/MetadataFieldTest.java index 4a38943b92..687ba14ffa 100644 --- a/dspace-api/src/test/java/org/dspace/content/MetadataFieldTest.java +++ b/dspace-api/src/test/java/org/dspace/content/MetadataFieldTest.java @@ -8,18 +8,21 @@ package org.dspace.content; import mockit.NonStrictExpectations; -import java.sql.SQLException; -import java.util.List; - -import org.dspace.AbstractUnitTest; import org.apache.log4j.Logger; +import org.dspace.AbstractUnitTest; import org.dspace.authorize.AuthorizeException; import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.service.MetadataFieldService; import org.dspace.content.service.MetadataSchemaService; -import org.junit.*; -import static org.junit.Assert.* ; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.sql.SQLException; +import java.util.List; + import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.*; /** * Unit Tests for class MetadataFieldTest @@ -136,7 +139,7 @@ public class MetadataFieldTest extends AbstractUnitTest @Test public void testGetFieldID() { - assertTrue("testGetFieldID 0",mf.getFieldID() >= 0); + assertTrue("testGetFieldID 0",mf.getID() >= 0); } /** @@ -221,7 +224,7 @@ public class MetadataFieldTest extends AbstractUnitTest MetadataField m = metadataFieldService.create(context, dcSchema, elem, qual, null); MetadataField found = metadataFieldService.findByElement(context, dcSchema, elem, qual); - assertThat("testCreateAuth 0",found.getFieldID(), equalTo(m.getFieldID())); + assertThat("testCreateAuth 0",found.getID(), equalTo(m.getID())); } /** @@ -268,7 +271,7 @@ public class MetadataFieldTest extends AbstractUnitTest { MetadataField found = metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, element, qualifier); assertThat("testFindByElement 0",found, notNullValue()); - assertThat("testFindByElement 1",found.getFieldID(), equalTo(mf.getFieldID())); + assertThat("testFindByElement 1",found.getID(), equalTo(mf.getID())); assertThat("testFindByElement 2",found.getElement(), equalTo(mf.getElement())); assertThat("testFindByElement 3",found.getQualifier(), equalTo(mf.getQualifier())); } @@ -334,7 +337,7 @@ public class MetadataFieldTest extends AbstractUnitTest metadataFieldService.update(context, m); MetadataField found = metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, elem, qual); - assertThat("testUpdateAuth 0",found.getFieldID(), equalTo(m.getFieldID())); + assertThat("testUpdateAuth 0",found.getID(), equalTo(m.getID())); } /** @@ -426,11 +429,11 @@ public class MetadataFieldTest extends AbstractUnitTest @Test public void testFind() throws Exception { - int id = mf.getFieldID(); + int id = mf.getID(); MetadataField found = metadataFieldService.find(context, id); assertThat("testFind 0",found, notNullValue()); - assertThat("testFind 1",found.getFieldID(), equalTo(mf.getFieldID())); + assertThat("testFind 1",found.getID(), equalTo(mf.getID())); } } diff --git a/dspace-api/src/test/java/org/dspace/content/MetadataSchemaTest.java b/dspace-api/src/test/java/org/dspace/content/MetadataSchemaTest.java index 2601ae757d..e93d406183 100644 --- a/dspace-api/src/test/java/org/dspace/content/MetadataSchemaTest.java +++ b/dspace-api/src/test/java/org/dspace/content/MetadataSchemaTest.java @@ -7,18 +7,20 @@ */ package org.dspace.content; -import org.dspace.authorize.AuthorizeException; import mockit.NonStrictExpectations; +import org.apache.log4j.Logger; +import org.dspace.AbstractUnitTest; +import org.dspace.authorize.AuthorizeException; +import org.dspace.content.factory.ContentServiceFactory; +import org.dspace.content.service.MetadataSchemaService; +import org.junit.Before; +import org.junit.Test; + import java.sql.SQLException; import java.util.List; -import org.dspace.AbstractUnitTest; -import org.apache.log4j.Logger; -import org.dspace.content.factory.ContentServiceFactory; -import org.dspace.content.service.MetadataSchemaService; -import org.junit.*; -import static org.junit.Assert.* ; import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.*; /** * Unit Tests for class MetadataSchema @@ -120,7 +122,7 @@ public class MetadataSchemaTest extends AbstractUnitTest @Test public void testGetSchemaID() throws SQLException { - assertThat("testGetSchemaID 0",ms.getSchemaID(), equalTo(metadataSchemaService.find(context, MetadataSchema.DC_SCHEMA).getSchemaID())); + assertThat("testGetSchemaID 0",ms.getID(), equalTo(metadataSchemaService.find(context, MetadataSchema.DC_SCHEMA).getID())); } /** @@ -188,7 +190,7 @@ public class MetadataSchemaTest extends AbstractUnitTest log.info(">>"+ms.getNamespace()+" "+ms.getName()); MetadataSchema found = metadataSchemaService.findByNamespace(context, ms.getNamespace()); assertThat("testFindByNamespace 0",found, notNullValue()); - assertThat("testFindByNamespace 1",found.getSchemaID(), equalTo(ms.getSchemaID())); + assertThat("testFindByNamespace 1",found.getID(), equalTo(ms.getID())); } /** @@ -210,7 +212,7 @@ public class MetadataSchemaTest extends AbstractUnitTest metadataSchemaService.update(context, metadataSchema); MetadataSchema found = metadataSchemaService.findByNamespace(context, namespace); - assertThat("testUpdateAuth 0",found.getSchemaID(), equalTo(metadataSchema.getSchemaID())); + assertThat("testUpdateAuth 0",found.getID(), equalTo(metadataSchema.getID())); } /** @@ -321,9 +323,9 @@ public class MetadataSchemaTest extends AbstractUnitTest @Test public void testFind_Context_int() throws Exception { - MetadataSchema found = metadataSchemaService.find(context, ms.getSchemaID()); + MetadataSchema found = metadataSchemaService.find(context, ms.getID()); assertThat("testFind_Context_int 0",found, notNullValue()); - assertThat("testFind_Context_int 1",found.getSchemaID(), equalTo(ms.getSchemaID())); + assertThat("testFind_Context_int 1",found.getID(), equalTo(ms.getID())); assertThat("testFind_Context_int 2",found.getName(), equalTo(ms.getName())); assertThat("testFind_Context_int 3",found.getNamespace(), equalTo(ms.getNamespace())); } @@ -337,7 +339,7 @@ public class MetadataSchemaTest extends AbstractUnitTest String shortName = ms.getName(); MetadataSchema found = metadataSchemaService.find(context, shortName); assertThat("testFind_Context_String 0",found, notNullValue()); - assertThat("testFind_Context_String 1",found.getSchemaID(), equalTo(ms.getSchemaID())); + assertThat("testFind_Context_String 1",found.getID(), equalTo(ms.getID())); assertThat("testFind_Context_String 2",found.getName(), equalTo(ms.getName())); assertThat("testFind_Context_String 3",found.getNamespace(), equalTo(ms.getNamespace())); diff --git a/dspace-api/src/test/java/org/dspace/content/MetadataValueTest.java b/dspace-api/src/test/java/org/dspace/content/MetadataValueTest.java index bc92efefe2..6bade66746 100644 --- a/dspace-api/src/test/java/org/dspace/content/MetadataValueTest.java +++ b/dspace-api/src/test/java/org/dspace/content/MetadataValueTest.java @@ -7,18 +7,21 @@ */ package org.dspace.content; +import org.apache.log4j.Logger; +import org.dspace.AbstractUnitTest; +import org.dspace.authorize.AuthorizeException; +import org.dspace.content.factory.ContentServiceFactory; +import org.dspace.content.service.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + import java.io.IOException; import java.sql.SQLException; import java.util.List; -import org.dspace.AbstractUnitTest; -import org.apache.log4j.Logger; -import org.dspace.authorize.AuthorizeException; -import org.dspace.content.factory.ContentServiceFactory; -import org.dspace.content.service.*; -import org.junit.*; -import static org.junit.Assert.* ; import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.*; /** * Unit Tests for class MetadataValue @@ -132,9 +135,9 @@ public class MetadataValueTest extends AbstractUnitTest public void testGetFieldId() { MetadataValue instance = new MetadataValue(); - assertThat("testGetFieldId 0", instance.getValueId(), equalTo(0)); + assertThat("testGetFieldId 0", instance.getID(), equalTo(0)); - assertThat("testGetFieldId 1", mv.getMetadataField().getFieldID(), equalTo(mf.getFieldID())); + assertThat("testGetFieldId 1", mv.getMetadataField().getID(), equalTo(mf.getID())); } /** @@ -192,7 +195,7 @@ public class MetadataValueTest extends AbstractUnitTest @Test public void testGetValueId() { - assertThat("testGetValueId 0",mv.getValueId(), notNullValue()); + assertThat("testGetValueId 0",mv.getID(), notNullValue()); } /** @@ -271,10 +274,10 @@ public class MetadataValueTest extends AbstractUnitTest public void testFind() throws Exception { metadataValueService.create(context, it, mf); - int id = mv.getValueId(); + int id = mv.getID(); MetadataValue found = metadataValueService.find(context, id); assertThat("testFind 0",found, notNullValue()); - assertThat("testFind 1",found.getValueId(), equalTo(id)); + assertThat("testFind 1",found.getID(), equalTo(id)); } /** diff --git a/dspace-api/src/test/java/org/dspace/content/packager/ITDSpaceAIP.java b/dspace-api/src/test/java/org/dspace/content/packager/ITDSpaceAIP.java index 3a3b3b803c..b8439cbb15 100644 --- a/dspace-api/src/test/java/org/dspace/content/packager/ITDSpaceAIP.java +++ b/dspace-api/src/test/java/org/dspace/content/packager/ITDSpaceAIP.java @@ -900,7 +900,7 @@ public class ITDSpaceAIP extends AbstractUnitTest * In HashMap, Key is the object handle, and Value is "[type-text]::[title]". * @param dso DSpaceObject * @param infoMap HashMap - * @throws SQLException + * @throws SQLException if database error */ private void saveObjectInfo(DSpaceObject dso, HashMap infoMap) throws SQLException @@ -957,7 +957,7 @@ public class ITDSpaceAIP extends AbstractUnitTest *

    * In HashMap, Key is the object handle, and Value is "[type-text]::[title]". * @param infoMap HashMap of objects to check for - * @throws SQLException + * @throws SQLException if database error */ private void assertObjectsExist(HashMap infoMap) throws SQLException @@ -988,7 +988,7 @@ public class ITDSpaceAIP extends AbstractUnitTest /** * Assert the objects listed in a HashMap do NOT exist in DSpace. * @param infoMap HashMap of objects to check for - * @throws SQLException + * @throws SQLException if database error */ public void assertObjectsNotExist(HashMap infoMap) throws SQLException diff --git a/dspace-api/src/test/java/org/dspace/core/PathsClassLoaderTest.java b/dspace-api/src/test/java/org/dspace/core/PathsClassLoaderTest.java index 733c803ee2..2f662ab876 100644 --- a/dspace-api/src/test/java/org/dspace/core/PathsClassLoaderTest.java +++ b/dspace-api/src/test/java/org/dspace/core/PathsClassLoaderTest.java @@ -120,7 +120,7 @@ public class PathsClassLoaderTest /** * Test of findClass method, of class PathsClassLoader. - * @throws java.lang.Exception + * @throws Exception if error */ @Test public void testFindClass() diff --git a/dspace-api/src/test/java/org/dspace/identifier/DOIIdentifierProviderTest.java b/dspace-api/src/test/java/org/dspace/identifier/DOIIdentifierProviderTest.java index 9ddab8290f..0837db32c0 100644 --- a/dspace-api/src/test/java/org/dspace/identifier/DOIIdentifierProviderTest.java +++ b/dspace-api/src/test/java/org/dspace/identifier/DOIIdentifierProviderTest.java @@ -140,9 +140,9 @@ public class DOIIdentifierProviderTest /** * Create a fresh Item, installed in the repository. * - * @throws SQLException - * @throws AuthorizeException - * @throws IOException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ private Item newItem() throws SQLException, AuthorizeException, IOException, IllegalAccessException, IdentifierException, WorkflowException @@ -209,7 +209,7 @@ public class DOIIdentifierProviderTest * @param metadata Whether the DOI should be included in the metadata of the item. * @param doi The doi or null if we should generate one. * @return the DOI - * @throws SQLException + * @throws SQLException if database error */ public String createDOI(Item item, Integer status, boolean metadata, String doi) throws SQLException, IdentifierException, AuthorizeException diff --git a/dspace-api/src/test/java/org/dspace/identifier/EZIDIdentifierProviderTest.java b/dspace-api/src/test/java/org/dspace/identifier/EZIDIdentifierProviderTest.java index 47be52e957..5bf5dfcca1 100644 --- a/dspace-api/src/test/java/org/dspace/identifier/EZIDIdentifierProviderTest.java +++ b/dspace-api/src/test/java/org/dspace/identifier/EZIDIdentifierProviderTest.java @@ -93,9 +93,9 @@ public class EZIDIdentifierProviderTest /** * Create a fresh Item, installed in the repository. * - * @throws SQLException - * @throws AuthorizeException - * @throws IOException + * @throws SQLException if database error + * @throws AuthorizeException if authorization error + * @throws IOException if IO error */ private Item newItem(Context ctx) throws SQLException, AuthorizeException, IOException, WorkflowException { @@ -403,7 +403,7 @@ public class EZIDIdentifierProviderTest /** * Test of crosswalkMetadata method, of class EZIDIdentifierProvider. - * @throws Exception + * @throws Exception if error */ @Test public void testCrosswalkMetadata() diff --git a/dspace-api/src/test/resources/log4j.properties b/dspace-api/src/test/resources/log4j.properties index b1631e421c..db62b5dc01 100644 --- a/dspace-api/src/test/resources/log4j.properties +++ b/dspace-api/src/test/resources/log4j.properties @@ -58,4 +58,5 @@ log4j.logger.org.hibernate=INFO # For detailed Hibernate logging in Unit Tests, you can enable the following # setting which logs all JDBC bind parameter runtime arguments. # This will drastically increase the size of Unit Test logs though. -#log4j.logger.org.hibernate.type=TRACE +#log4j.logger.org.hibernate.SQL=DEBUG, A1 +#log4j.logger.org.hibernate.type=TRACE, A1 diff --git a/dspace-jspui/pom.xml b/dspace-jspui/pom.xml index 4f306febdd..af1684c997 100644 --- a/dspace-jspui/pom.xml +++ b/dspace-jspui/pom.xml @@ -13,7 +13,7 @@ org.dspace dspace-parent - 6.0-rc2-SNAPSHOT + 6.0-rc3-SNAPSHOT .. diff --git a/dspace-jspui/src/main/java/org/dspace/app/webui/discovery/DiscoverySearchRequestProcessor.java b/dspace-jspui/src/main/java/org/dspace/app/webui/discovery/DiscoverySearchRequestProcessor.java index 7ae8785d50..9ebb6afbd1 100644 --- a/dspace-jspui/src/main/java/org/dspace/app/webui/discovery/DiscoverySearchRequestProcessor.java +++ b/dspace-jspui/src/main/java/org/dspace/app/webui/discovery/DiscoverySearchRequestProcessor.java @@ -182,9 +182,7 @@ public class DiscoverySearchRequestProcessor implements SearchRequestProcessor // format and return results Map labelMap = getLabels(request); - DSpaceObject[] dsoResults = new DSpaceObject[qResults - .getDspaceObjects().size()]; - qResults.getDspaceObjects().toArray(dsoResults); + List dsoResults = qResults.getDspaceObjects(); Document resultsDoc = openSearchService.getResultsDoc(context, format, query, (int) qResults.getTotalSearchResults(), qResults.getStart(), qResults.getMaxResults(), container, dsoResults, labelMap); diff --git a/dspace-jspui/src/main/java/org/dspace/app/webui/jsptag/ItemTag.java b/dspace-jspui/src/main/java/org/dspace/app/webui/jsptag/ItemTag.java index eca8d03f0f..fcecb776bc 100644 --- a/dspace-jspui/src/main/java/org/dspace/app/webui/jsptag/ItemTag.java +++ b/dspace-jspui/src/main/java/org/dspace/app/webui/jsptag/ItemTag.java @@ -926,7 +926,7 @@ public class ItemTag extends TagSupport handle = "db-id/" + item.getID(); } - out.print(""); + out.print(""); out.print(""); + out.print(""); String desc = primaryBitstream.getDescription(); out.print((desc != null) ? desc : ""); @@ -1016,7 +1016,7 @@ public class ItemTag extends TagSupport Constants.DEFAULT_ENCODING) + "\">"; out - .print(""); + .print(""); out.print(""); + .print(""); String desc = b.getDescription(); out.print((desc != null) ? desc : ""); diff --git a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/FeedServlet.java b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/FeedServlet.java index 153871118c..78f5bedddc 100644 --- a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/FeedServlet.java +++ b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/FeedServlet.java @@ -288,7 +288,7 @@ public class FeedServlet extends DSpaceServlet } // returns recently changed items, checking for accessibility - private Item[] getItems(Context context, DSpaceObject dso) + private List getItems(Context context, DSpaceObject dso) throws IOException, SQLException { try @@ -326,12 +326,9 @@ public class FeedServlet extends DSpaceServlet BrowseEngine be = new BrowseEngine(context); BrowseInfo bi = be.browseMini(scope); List results = bi.getResults(); - Item[] resultsArray; if (includeAll) { - resultsArray = new Item[results.size()]; - resultsArray = results.toArray(resultsArray); - return resultsArray; + return results; } else { @@ -351,9 +348,7 @@ public class FeedServlet extends DSpaceServlet } } } - resultsArray = new Item[items.size()]; - resultsArray = items.toArray(resultsArray); - return resultsArray; + return items; } } catch (SortException se) diff --git a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/MyDSpaceServlet.java b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/MyDSpaceServlet.java index 403870d0ef..c8a5564f29 100644 --- a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/MyDSpaceServlet.java +++ b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/MyDSpaceServlet.java @@ -844,7 +844,7 @@ public class MyDSpaceServlet extends DSpaceServlet List pooledList = workflowService.getPooledTasks(context, currentUser); // User's WorkflowItems - List workflowItems = workflowItemService.findByOwner(context, currentUser); + List workflowItems = workflowItemService.findBySubmitter(context, currentUser); // User's PersonalWorkspace List workspaceItems = workspaceItemService.findByEPerson(context, currentUser); diff --git a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/RequestItemServlet.java b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/RequestItemServlet.java index 4c0d4e1162..30184fb70e 100644 --- a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/RequestItemServlet.java +++ b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/RequestItemServlet.java @@ -220,6 +220,8 @@ public class RequestItemServlet extends DSpaceServlet String token = requestItemService.createRequest(context, bitstream_id != null? bitstreamService.find(context, bitstream_id):null, item, allfiles, requesterEmail, reqname, coment); + String linkedToken = getLinkTokenEmail(context, token); + // All data is there, send the email Email email = Email.getEmail(I18nUtil.getEmailFilename( context.getCurrentLocale(), "request_item.author")); @@ -243,7 +245,7 @@ public class RequestItemServlet extends DSpaceServlet .getHandle())); email.addArgument(title); // request item title email.addArgument(coment); // message - email.addArgument(token); + email.addArgument(linkedToken); email.addArgument(authorName); // corresponding author name email.addArgument(authorEmail); // corresponding author email @@ -532,14 +534,17 @@ public class RequestItemServlet extends DSpaceServlet } } - /** + /** * Get the link to the author in RequestLink email. * - * @param email - * The email address to mail to - * - * @exception SQLExeption - * + * @param context + * the context object + * @param token + * the token + * + * @return link based on the token + * + * @throws java.sql.SQLException */ public static String getLinkTokenEmail(Context context, String token) throws SQLException diff --git a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/VersionHistoryServlet.java b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/VersionHistoryServlet.java index 4c31515bd4..84376600ea 100644 --- a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/VersionHistoryServlet.java +++ b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/VersionHistoryServlet.java @@ -7,15 +7,6 @@ */ package org.dspace.app.webui.servlet; -import com.hp.hpl.jena.sparql.vocabulary.DOAP; -import java.io.IOException; -import java.sql.SQLException; -import java.util.UUID; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.apache.log4j.Logger; import org.dspace.app.webui.util.JSPManager; import org.dspace.app.webui.util.UIUtil; @@ -33,6 +24,13 @@ import org.dspace.versioning.factory.VersionServiceFactory; import org.dspace.versioning.service.VersionHistoryService; import org.dspace.versioning.service.VersioningService; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.sql.SQLException; +import java.util.UUID; + /** * Servlet for handling the operations in the version history page * @@ -98,7 +96,7 @@ public class VersionHistoryServlet extends DSpaceServlet Version version = versionHistoryService.getVersion(context, history, item); if (version != null) { - versionID = String.valueOf(version.getId()); + versionID = String.valueOf(version.getID()); } } String submit = UIUtil.getSubmitButton(request, "submit"); diff --git a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/admin/EditItemServlet.java b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/admin/EditItemServlet.java index f0b972379e..d7b5607e1c 100644 --- a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/admin/EditItemServlet.java +++ b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/admin/EditItemServlet.java @@ -7,27 +7,6 @@ */ package org.dspace.app.webui.servlet.admin; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.UUID; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.apache.commons.fileupload.FileUploadBase.FileSizeLimitExceededException; import org.apache.log4j.Logger; import org.dspace.app.util.AuthorizeUtil; @@ -37,23 +16,11 @@ import org.dspace.app.webui.util.FileUploadRequest; import org.dspace.app.webui.util.JSPManager; import org.dspace.app.webui.util.UIUtil; import org.dspace.authorize.AuthorizeException; -import org.dspace.content.Bitstream; -import org.dspace.content.BitstreamFormat; -import org.dspace.content.Bundle; +import org.dspace.content.*; import org.dspace.content.Collection; -import org.dspace.content.DSpaceObject; -import org.dspace.content.Item; -import org.dspace.content.MetadataField; -import org.dspace.content.MetadataSchema; import org.dspace.content.authority.Choices; import org.dspace.content.factory.ContentServiceFactory; -import org.dspace.content.service.BitstreamFormatService; -import org.dspace.content.service.BitstreamService; -import org.dspace.content.service.BundleService; -import org.dspace.content.service.CollectionService; -import org.dspace.content.service.ItemService; -import org.dspace.content.service.MetadataFieldService; -import org.dspace.content.service.MetadataSchemaService; +import org.dspace.content.service.*; import org.dspace.core.Constants; import org.dspace.core.Context; import org.dspace.core.LogManager; @@ -62,6 +29,13 @@ import org.dspace.handle.service.HandleService; import org.dspace.license.factory.LicenseServiceFactory; import org.dspace.license.service.CreativeCommonsService; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.sql.SQLException; +import java.util.*; + /** * Servlet for editing and deleting (expunging) items * @@ -479,7 +453,7 @@ public class EditItemServlet extends DSpaceServlet { String displayName = ""; displayName = schemaName + "." + f.getElement() + (f.getQualifier() == null ? "" : "." + f.getQualifier()); - metadataFields.put(f.getFieldID(), displayName); + metadataFields.put(f.getID(), displayName); } } diff --git a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/admin/MetadataFieldRegistryServlet.java b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/admin/MetadataFieldRegistryServlet.java index 82d93d4874..e09556534c 100644 --- a/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/admin/MetadataFieldRegistryServlet.java +++ b/dspace-jspui/src/main/java/org/dspace/app/webui/servlet/admin/MetadataFieldRegistryServlet.java @@ -84,12 +84,12 @@ public class MetadataFieldRegistryServlet extends DSpaceServlet String element = request.getParameter("element"); String scope = request.getParameter("scope_note"); String qual = request.getParameter("qualifier"); - if (qual.equals("")) + if ("".equals(qual)) { qual = null; } - if (button.equals("submit_update")) + if ("submit_update".equals(button)) { // The sanity check will update the request error string if needed if (!sanityCheck(request, labels)) @@ -118,7 +118,7 @@ public class MetadataFieldRegistryServlet extends DSpaceServlet log.error(e); } } - else if (button.equals("submit_add")) + else if ("submit_add".equals(button)) { // The sanity check will update the request error string if needed @@ -151,7 +151,7 @@ public class MetadataFieldRegistryServlet extends DSpaceServlet context.abort(); } } - else if (button.equals("submit_delete")) + else if ("submit_delete".equals(button)) { // Start delete process - go through verification step MetadataField dc = fieldService.find(context, UIUtil @@ -160,7 +160,7 @@ public class MetadataFieldRegistryServlet extends DSpaceServlet JSPManager.showJSP(request, response, "/dspace-admin/confirm-delete-mdfield.jsp"); } - else if (button.equals("submit_confirm_delete")) + else if ("submit_confirm_delete".equals(button)) { // User confirms deletion of type MetadataField dc = fieldService.find(context, UIUtil @@ -179,7 +179,7 @@ public class MetadataFieldRegistryServlet extends DSpaceServlet } context.complete(); } - else if (button.equals("submit_move")) + else if ("submit_move".equals(button)) { // User requests that one or more metadata elements be moved to a // new metadata schema. Note that we change the default schema ID to diff --git a/dspace-jspui/src/main/webapp/community-home.jsp b/dspace-jspui/src/main/webapp/community-home.jsp index d1204e0307..ee87b34ee8 100644 --- a/dspace-jspui/src/main/webapp/community-home.jsp +++ b/dspace-jspui/src/main/webapp/community-home.jsp @@ -204,9 +204,6 @@ <% } %> -

    <%-- Browse --%> @@ -231,15 +228,6 @@
    -
    - - <% - int discovery_panel_cols = 12; - int discovery_facet_cols = 4; - %> - <%@ include file="discovery/static-sidebar-facet.jsp" %> -
    -
    <%@ include file="discovery/static-tagcloud-facet.jsp" %>
    @@ -359,9 +347,9 @@ } %>
    + <% if(editor_button || add_button) // edit button(s) { %> -
    @@ -410,6 +398,12 @@ <% } %>
    + <% } %> + <%= sidebar %> + <% + int discovery_panel_cols = 12; + int discovery_facet_cols = 12; + %> + <%@ include file="discovery/static-sidebar-facet.jsp" %>
    - <% } %> diff --git a/dspace-jspui/src/main/webapp/display-item.jsp b/dspace-jspui/src/main/webapp/display-item.jsp index fec1393dd8..c119894b00 100644 --- a/dspace-jspui/src/main/webapp/display-item.jsp +++ b/dspace-jspui/src/main/webapp/display-item.jsp @@ -188,7 +188,7 @@ <% if(hasVersionHistory) { %>
    - + " />
    <% } %> diff --git a/dspace-jspui/src/main/webapp/dspace-admin/confirm-delete-mdfield.jsp b/dspace-jspui/src/main/webapp/dspace-admin/confirm-delete-mdfield.jsp index bda5d8d41f..27fba62a08 100644 --- a/dspace-jspui/src/main/webapp/dspace-admin/confirm-delete-mdfield.jsp +++ b/dspace-jspui/src/main/webapp/dspace-admin/confirm-delete-mdfield.jsp @@ -58,7 +58,7 @@ <%--

    This will result in an error if any items have values for this metadata field.

    --%>

    - +
    <%-- --%> " /> diff --git a/dspace-jspui/src/main/webapp/dspace-admin/confirm-delete-mdschema.jsp b/dspace-jspui/src/main/webapp/dspace-admin/confirm-delete-mdschema.jsp index 622f85e6f6..50474fe8b1 100644 --- a/dspace-jspui/src/main/webapp/dspace-admin/confirm-delete-mdschema.jsp +++ b/dspace-jspui/src/main/webapp/dspace-admin/confirm-delete-mdschema.jsp @@ -48,7 +48,7 @@

    - +
    <%-- --%> "> diff --git a/dspace-jspui/src/main/webapp/dspace-admin/list-formats.jsp b/dspace-jspui/src/main/webapp/dspace-admin/list-formats.jsp index f5f76a8a8d..6ba1693bb4 100644 --- a/dspace-jspui/src/main/webapp/dspace-admin/list-formats.jsp +++ b/dspace-jspui/src/main/webapp/dspace-admin/list-formats.jsp @@ -21,7 +21,6 @@ <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> - <%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %> <%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %> @@ -30,14 +29,16 @@ <%@ page import="org.dspace.core.Context"%> <%@ page import="org.dspace.app.webui.util.UIUtil"%> <%@ page import="java.util.List" %> +<%@ page import="java.lang.StringBuilder" %> <%@ page import="org.dspace.content.service.BitstreamFormatService" %> <%@ page import="org.dspace.content.factory.ContentServiceFactory" %> <% - BitstreamFormatService bitstreamFormatService = ContentServiceFactory.getInstance().getBitstreamFormatService(); - List formats = - (List) request.getAttribute("formats"); + BitstreamFormatService bitstreamFormatService + = ContentServiceFactory.getInstance().getBitstreamFormatService(); + List formats + = (List) request.getAttribute("formats"); %> -

    - "> +

    + + + +

    @@ -58,90 +62,144 @@ %> - - -
    + + + - + + <% String row = "even"; - for (int i = 0; i < formats.size(); i++) + for (BitstreamFormat format : formats) { - List extensions = formats.get(i).getExtensions(); - String extValue = ""; - - for (int j = 0 ; j < extensions.size(); j++) + List extensions = format.getExtensions(); + StringBuilder extValueBuilder = new StringBuilder(256); + if (null != extensions) { - if (j > 0) + for (String extension : extensions) { - extValue = extValue + ", "; + if (extValueBuilder.length() > 0) + { + extValueBuilder.append(", "); + } + extValueBuilder.append(extension); } - extValue = extValue + extensions.get(j); } + String extValue = extValueBuilder.toString(); %> - - + @@ -150,11 +208,14 @@ } %> -
    - - / - / - / - / - / - / + + / + / + / + / + / + / -
    - - - <%= formats.get(i).getID() %> +
    + + + <%= format.getID() %>
    - - " size="14" placeholder=""/> + +
    - + <% - if (bitstreamFormatService.findUnknown(context).getID() == formats.get(i).getID()) { + if (bitstreamFormatService.findUnknown(context).getID() == format.getID()) { %> - <%= formats.get(i).getShortDescription() %> - <% } else { %> - " size="10" placeholder=""/> + <%= format.getShortDescription() %> + <% } else { %> + <% } %> -
    +
    - - " size="20" placeholder=""/> + +
    -
    - +
    +
    -
    - /> -
    -
    - - "/> -
    -
    - - "/> - +
    + /> +
    +
    + + +
    +
    + + + <% - if (bitstreamFormatService.findUnknown(context).getID() != formats.get(i).getID()) { + if (bitstreamFormatService.findUnknown(context).getID() != format.getID()) { %> - " /> - <% - } + + <% + } %>
    - - +
    +
    -
    - - " /> - -
    +
    + + + +
    diff --git a/dspace-jspui/src/main/webapp/dspace-admin/list-metadata-fields.jsp b/dspace-jspui/src/main/webapp/dspace-admin/list-metadata-fields.jsp index 64b60e909a..e6fc4e016e 100644 --- a/dspace-jspui/src/main/webapp/dspace-admin/list-metadata-fields.jsp +++ b/dspace-jspui/src/main/webapp/dspace-admin/list-metadata-fields.jsp @@ -92,7 +92,7 @@ if (error!=null) {
    - <%= types.get(i).getFieldID() %> + <%= types.get(i).getID() %>
    @@ -109,7 +109,7 @@ if (error!=null) {
    - + "/> "/> @@ -125,7 +125,7 @@ if (error!=null) { - +

    @@ -157,7 +157,7 @@ if (error!=null) { for (int i = 0; i < types.size(); i++) { String qualifier = (types.get(i).getQualifier() == null ? "" : "."+types.get(i).getQualifier()); -%> +%> <% } %> @@ -166,9 +166,9 @@ if (error!=null) { <% for (int i = 0; i < schemas.size(); i++) { - if (schemas.get(i).getSchemaID() != schema.getSchemaID()) + if (schemas.get(i).getID() != schema.getID()) { -%> +%> <% } } %> diff --git a/dspace-jspui/src/main/webapp/dspace-admin/list-metadata-schemas.jsp b/dspace-jspui/src/main/webapp/dspace-admin/list-metadata-schemas.jsp index a17282ef8a..33d7047bae 100644 --- a/dspace-jspui/src/main/webapp/dspace-admin/list-metadata-schemas.jsp +++ b/dspace-jspui/src/main/webapp/dspace-admin/list-metadata-schemas.jsp @@ -70,18 +70,18 @@ if (error!=null) { { %> - <%= schemas.get(i).getSchemaID() %> + <%= schemas.get(i).getID() %> -
    <%= schemas.get(i).getNamespace() %> + <%= schemas.get(i).getNamespace() %> <%= schemas.get(i).getName() %> - <% if ( schemas.get(i).getSchemaID() != 1 ) { %> + <% if ( schemas.get(i).getID() != 1 ) { %> - - " onclick="javascript:document.schema.namespace.value='<%= schemas.get(i).getNamespace() %>';document.schema.short_name.value='<%= schemas.get(i).getName() %>';document.schema.dc_schema_id.value='<%= schemas.get(i).getSchemaID() %>';return null;"/> + + " onclick="javascript:document.schema.namespace.value='<%= schemas.get(i).getNamespace() %>';document.schema.short_name.value='<%= schemas.get(i).getName() %>';document.schema.dc_schema_id.value='<%= schemas.get(i).getID() %>';return null;"/> "/> <% } %> diff --git a/dspace-jspui/src/main/webapp/dspace-admin/wizard-default-item.jsp b/dspace-jspui/src/main/webapp/dspace-admin/wizard-default-item.jsp index 0312f6a0f8..46ad4e0e7e 100644 --- a/dspace-jspui/src/main/webapp/dspace-admin/wizard-default-item.jsp +++ b/dspace-jspui/src/main/webapp/dspace-admin/wizard-default-item.jsp @@ -83,7 +83,7 @@ <% for (int dc = 0; dc < dcTypes.size(); dc++) { %> - <% } %> diff --git a/dspace-jspui/src/main/webapp/home.jsp b/dspace-jspui/src/main/webapp/home.jsp index 61e238b997..67bbea4c3c 100644 --- a/dspace-jspui/src/main/webapp/home.jsp +++ b/dspace-jspui/src/main/webapp/home.jsp @@ -30,6 +30,7 @@ <%@ page import="java.io.File" %> <%@ page import="java.util.Enumeration"%> <%@ page import="java.util.Locale"%> +<%@ page import="java.util.List"%> <%@ page import="javax.servlet.jsp.jstl.core.*" %> <%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %> <%@ page import="org.apache.commons.lang.StringUtils" %> diff --git a/dspace-jspui/src/main/webapp/layout/navbar-default.jsp b/dspace-jspui/src/main/webapp/layout/navbar-default.jsp index 878996317c..891c4f62a9 100644 --- a/dspace-jspui/src/main/webapp/layout/navbar-default.jsp +++ b/dspace-jspui/src/main/webapp/layout/navbar-default.jsp @@ -129,7 +129,7 @@ %>
  • + document.repost.submit();" href="<%= currentPage %>?locale=<%=supportedLocales[i].toString()%>"> <%= supportedLocales[i].getDisplayLanguage(supportedLocales[i])%>
  • diff --git a/dspace-jspui/src/main/webapp/mydspace/subscriptions.jsp b/dspace-jspui/src/main/webapp/mydspace/subscriptions.jsp index cdc5b9191f..1cf02aced7 100644 --- a/dspace-jspui/src/main/webapp/mydspace/subscriptions.jsp +++ b/dspace-jspui/src/main/webapp/mydspace/subscriptions.jsp @@ -11,15 +11,15 @@ - Show a user's subscriptions and allow them to be modified - - Attributes: - - subscriptions - Collection[] - collections user is subscribed to - - updated - Boolean - if true, subscriptions have just been updated + - avail - List - collections available to this user for subscription. + - subscriptions - List - collections user is subscribed to. + - updated - Boolean - if true, subscriptions have just been updated. --%> <%@ page contentType="text/html;charset=UTF-8" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" - prefix="fmt" %> - + prefix="fmt" %> <%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %> @@ -28,13 +28,14 @@ <%@ page import="org.dspace.content.Community" %> <%@ page import="org.dspace.content.Collection" %> <%@ page import="org.dspace.app.util.CollectionDropDown" %> +<%@ page import="org.dspace.eperson.Subscription" %> <%@ page import="java.util.List" %> <% List availableSubscriptions = (List) request.getAttribute("availableSubscriptions"); - List subscriptions = - (List) request.getAttribute("subscriptions"); + List subscriptions = + (List) request.getAttribute("subscriptions"); boolean updated = ((Boolean) request.getAttribute("updated")).booleanValue(); %> @@ -44,10 +45,13 @@ parenttitlekey="jsp.mydspace" titlekey="jsp.mydspace.subscriptions.title"> - <%--

    Your Subscriptions

    --%> -

    - "> -

    + <%--

    Your Subscriptions

    --%> +

    + + + + +

    <% if (updated) { @@ -57,24 +61,34 @@ <% } %> -
    -
    + +
    -
    - " /> - " /> +
    + " /> + " />
    - + <% if (subscriptions.size() > 0) { @@ -95,12 +109,17 @@ --%> - <%= CollectionDropDown.collectionPath(subscriptions.get(i),0) %> + + <%= CollectionDropDown.collectionPath(subscriptions.get(i).getCollection(),0) %> +
    - - " /> + + " />
    @@ -121,6 +140,10 @@ <% } %> -

    +

    + + + +

    diff --git a/dspace-jspui/src/main/webapp/requestItem/request-form.jsp b/dspace-jspui/src/main/webapp/requestItem/request-form.jsp index c7b81ce96d..5748c767ba 100644 --- a/dspace-jspui/src/main/webapp/requestItem/request-form.jsp +++ b/dspace-jspui/src/main/webapp/requestItem/request-form.jsp @@ -21,8 +21,8 @@ <%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> -<%@ page import="org.dspace.app.webui.servlet.RequestItemServlet"%> -<%@ page import="javax.servlet.jsp.jstl.fmt.LocaleSupport" %> +<%@ page import="java.util.*"%> +<%@ page import="org.dspace.app.webui.servlet.*" %> <% request.setCharacterEncoding("UTF-8"); @@ -48,8 +48,8 @@ String coment = (String) request.getAttribute("coment"); if (coment == null) coment = ""; - - String bitstream_id = (String) request.getAttribute("bitstream-id"); + + UUID bitstream_id = (UUID) request.getAttribute("bitstream-id"); boolean allfiles = (request.getAttribute("allfiles") != null); %> diff --git a/dspace-jspui/src/main/webapp/static/css/bootstrap/dspace-theme.css b/dspace-jspui/src/main/webapp/static/css/bootstrap/dspace-theme.css index d0aebd504c..05b2dd45c3 100644 --- a/dspace-jspui/src/main/webapp/static/css/bootstrap/dspace-theme.css +++ b/dspace-jspui/src/main/webapp/static/css/bootstrap/dspace-theme.css @@ -105,4 +105,10 @@ span.batchimport-error-tab { span.batchimport-error-caused { font-weight:bold; +} + +.break-all{ + -ms-word-break: break-all; + word-break: break-all; + word-wrap: break-word; } \ No newline at end of file diff --git a/dspace-jspui/src/main/webapp/submit/creative-commons.jsp b/dspace-jspui/src/main/webapp/submit/creative-commons.jsp index 2095b81df4..430bcbd35f 100644 --- a/dspace-jspui/src/main/webapp/submit/creative-commons.jsp +++ b/dspace-jspui/src/main/webapp/submit/creative-commons.jsp @@ -48,7 +48,7 @@ Boolean lExists = (Boolean)request.getAttribute("cclicense.exists"); boolean licenseExists = (lExists == null ? false : lExists.booleanValue()); - String jurisdiction = ConfigurationManager.getProperty("webui.submit.cc-jurisdiction"); + String jurisdiction = ConfigurationManager.getProperty("cc.license.jurisdiction"); if ((jurisdiction != null) && (!"".equals(jurisdiction))) { jurisdiction = "&jurisdiction=" + jurisdiction.trim(); diff --git a/dspace-jspui/src/main/webapp/submit/review-upload.jsp b/dspace-jspui/src/main/webapp/submit/review-upload.jsp index 3feb553690..25e91c71c2 100644 --- a/dspace-jspui/src/main/webapp/submit/review-upload.jsp +++ b/dspace-jspui/src/main/webapp/submit/review-upload.jsp @@ -68,7 +68,7 @@
    <%= (subInfo.getSubmissionItem().hasMultipleFiles() ? LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.review.upload1") : LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.review.upload2")) %> - + <% List bitstreams = ContentServiceFactory.getInstance().getItemService().getNonInternalBitstreams(context, item); diff --git a/dspace-jspui/src/main/webapp/submit/upload-file-list.jsp b/dspace-jspui/src/main/webapp/submit/upload-file-list.jsp index 9f3c4275c9..300419b62e 100644 --- a/dspace-jspui/src/main/webapp/submit/upload-file-list.jsp +++ b/dspace-jspui/src/main/webapp/submit/upload-file-list.jsp @@ -176,7 +176,7 @@ <% } } %> /> - + <%= bitstreams.get(i).getName() %> <% // Don't display "remove" button in workflow mode if (allowFileEditing) @@ -189,7 +189,7 @@ } %> <%= bitstreams.get(i).getSize() %> bytes - + <%= (bitstreams.get(i).getDescription() == null || bitstreams.get(i).getDescription().equals("") ? LocaleSupport.getLocalizedMessage(pageContext, "jsp.submit.upload-file-list.empty1") : bitstreams.get(i).getDescription()) %> diff --git a/dspace-jspui/src/main/webapp/tools/edit-collection.jsp b/dspace-jspui/src/main/webapp/tools/edit-collection.jsp index 6513c4a434..f17305d2e7 100644 --- a/dspace-jspui/src/main/webapp/tools/edit-collection.jsp +++ b/dspace-jspui/src/main/webapp/tools/edit-collection.jsp @@ -411,7 +411,7 @@ <% for (int i = 0; i < dcTypes.size(); i++) { - Integer fieldID = new Integer(dcTypes.get(i).getFieldID()); + Integer fieldID = new Integer(dcTypes.get(i).getID()); String displayName = (String)metadataFields.get(fieldID); %> diff --git a/dspace-jspui/src/main/webapp/tools/itemmap-info.jsp b/dspace-jspui/src/main/webapp/tools/itemmap-info.jsp index 0975041abf..48e1d7ba93 100644 --- a/dspace-jspui/src/main/webapp/tools/itemmap-info.jsp +++ b/dspace-jspui/src/main/webapp/tools/itemmap-info.jsp @@ -12,8 +12,9 @@ - - Attributes to pass in: - - - collection - Collection we're managing - - message - String to output + - collection - Collection we're managing + - message - String to output + - processedItems - List of UUID of items to be mapped. --%> <%@ page contentType="text/html;charset=UTF-8" %> @@ -21,13 +22,9 @@ <%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> -<%@ page import="java.net.URLEncoder" %> -<%@ page import="java.util.Iterator" %> -<%@ page import="java.util.Map" %> <%@ page import="java.util.LinkedList" %> +<%@ page import="java.util.UUID" %> <%@ page import="org.dspace.content.Collection" %> -<%@ page import="org.dspace.content.Item" %> -<%@ page import="org.dspace.core.ConfigurationManager" %> <% Collection collection = (Collection)request.getAttribute("collection"); @@ -35,7 +32,7 @@ // supported values: "none-selected", "none-removed", "added", "remove" String message = (String)request.getAttribute("message"); - LinkedList processedItems = (LinkedList)request.getAttribute("processedItems"); + LinkedList processedItems = (LinkedList)request.getAttribute("processedItems"); %> @@ -48,19 +45,19 @@ <% } else if (message.equals("none-removed")) { %> <% } else if (message.equals("added")) { %> - <%-- Iterate through processed items --%> - <% for (int i=0; i - - <%= (String)processedItems.get(i) %> -
    - <% } %> + <%-- Iterate through processed items --%> + <% for (int i=0; i + + <%= (String)processedItems.get(i).toString() %> +
    + <% } %> <% } else if (message.equals("remove")) { %> - <%-- Iterate through processed items --%> - <% for (int i=0; i - - <%= (String)processedItems.get(i) %> -
    - <% } %> + <%-- Iterate through processed items --%> + <% for (int i=0; i + + <%= (String)processedItems.get(i).toString() %> +
    + <% } %> <% } %>
    diff --git a/dspace-jspui/src/main/webapp/tools/version-history.jsp b/dspace-jspui/src/main/webapp/tools/version-history.jsp index 43d8061d49..d1b21a0d32 100644 --- a/dspace-jspui/src/main/webapp/tools/version-history.jsp +++ b/dspace-jspui/src/main/webapp/tools/version-history.jsp @@ -113,14 +113,14 @@ var j = jQuery.noConflict(); %> - + <%= versRow.getVersionNumber() %> <%= identifier %><%= item.getID()==versRow.getItem().getID()?"":""%> <% if (show_submitter) { %> <%=versRowPerson.getFullName() %> <% } %> <%= versRow.getVersionDate() %> - <%= versRow.getSummary() %>  + <%= versRow.getSummary() %>  <% } %> diff --git a/dspace-oai/pom.xml b/dspace-oai/pom.xml index a53ce0bcba..3a0cf21c0d 100644 --- a/dspace-oai/pom.xml +++ b/dspace-oai/pom.xml @@ -8,7 +8,7 @@ dspace-parent org.dspace - 6.0-rc2-SNAPSHOT + 6.0-rc3-SNAPSHOT .. diff --git a/dspace-oai/src/main/java/org/dspace/xoai/data/DSpaceSolrItem.java b/dspace-oai/src/main/java/org/dspace/xoai/data/DSpaceSolrItem.java index f28517ddff..c095ffbbec 100644 --- a/dspace-oai/src/main/java/org/dspace/xoai/data/DSpaceSolrItem.java +++ b/dspace-oai/src/main/java/org/dspace/xoai/data/DSpaceSolrItem.java @@ -17,6 +17,7 @@ import org.apache.solr.common.SolrDocument; import com.lyncode.xoai.dataprovider.core.ItemMetadata; import com.lyncode.xoai.dataprovider.core.ReferenceSet; +import java.util.Collection; /** * @@ -24,26 +25,35 @@ import com.lyncode.xoai.dataprovider.core.ReferenceSet; */ public class DSpaceSolrItem extends DSpaceItem { - private static Logger log = LogManager + private static final Logger log = LogManager .getLogger(DSpaceSolrItem.class); - private String unparsedMD; + private final String unparsedMD; private ItemMetadata metadata; - private String handle; - private Date lastMod; - private List sets; - private boolean deleted; - + private final String handle; + private final Date lastMod; + private final List sets; + private final boolean deleted; + public DSpaceSolrItem (SolrDocument doc) { log.debug("Creating OAI Item from Solr source"); unparsedMD = (String) doc.getFieldValue("item.compile"); handle = (String) doc.getFieldValue("item.handle"); lastMod = (Date) doc.getFieldValue("item.lastmodified"); - sets = new ArrayList(); - for (Object obj : doc.getFieldValues("item.communities")) - sets.add(new ReferenceSet((String) obj)); - for (Object obj : doc.getFieldValues("item.collections")) - sets.add(new ReferenceSet((String) obj)); + sets = new ArrayList<>(); + + Collection fieldValues; + + fieldValues = doc.getFieldValues("item.communities"); + if (null != fieldValues) + for (Object obj : fieldValues) + sets.add(new ReferenceSet((String) obj)); + + fieldValues = doc.getFieldValues("item.collections"); + if (null != fieldValues) + for (Object obj : fieldValues) + sets.add(new ReferenceSet((String) obj)); + deleted = (Boolean) doc.getFieldValue("item.deleted"); } diff --git a/dspace-oai/src/main/java/org/dspace/xoai/services/impl/DSpaceFieldResolver.java b/dspace-oai/src/main/java/org/dspace/xoai/services/impl/DSpaceFieldResolver.java index 35547c7acc..995638e17a 100644 --- a/dspace-oai/src/main/java/org/dspace/xoai/services/impl/DSpaceFieldResolver.java +++ b/dspace-oai/src/main/java/org/dspace/xoai/services/impl/DSpaceFieldResolver.java @@ -7,15 +7,15 @@ */ package org.dspace.xoai.services.impl; +import org.dspace.content.MetadataField; +import org.dspace.content.factory.ContentServiceFactory; +import org.dspace.content.service.MetadataFieldService; import org.dspace.core.Context; import org.dspace.xoai.exceptions.InvalidMetadataFieldException; import org.dspace.xoai.services.api.FieldResolver; import java.sql.SQLException; import java.util.regex.Pattern; -import org.dspace.content.MetadataField; -import org.dspace.content.factory.ContentServiceFactory; -import org.dspace.content.service.MetadataFieldService; public class DSpaceFieldResolver implements FieldResolver { private MetadataFieldCache metadataFieldCache = null; @@ -41,7 +41,7 @@ public class DSpaceFieldResolver implements FieldResolver { MetadataField metadataField = metadataFieldService.findByElement(context, schema, element, qualifier); if (null != metadataField) { - metadataFieldCache.add(field, metadataField.getFieldID()); + metadataFieldCache.add(field, metadataField.getID()); } else throw new InvalidMetadataFieldException(); diff --git a/dspace-rdf/pom.xml b/dspace-rdf/pom.xml index a9172ad046..4d2fcf515b 100644 --- a/dspace-rdf/pom.xml +++ b/dspace-rdf/pom.xml @@ -9,7 +9,7 @@ org.dspace dspace-parent - 6.0-rc2-SNAPSHOT + 6.0-rc3-SNAPSHOT .. diff --git a/dspace-rest/pom.xml b/dspace-rest/pom.xml index 1a08fb2a6b..15e564051e 100644 --- a/dspace-rest/pom.xml +++ b/dspace-rest/pom.xml @@ -3,7 +3,7 @@ org.dspace dspace-rest war - 6.0-rc2-SNAPSHOT + 6.0-rc3-SNAPSHOT DSpace REST :: API and Implementation DSpace RESTful Web Services API http://demo.dspace.org @@ -11,7 +11,7 @@ org.dspace dspace-parent - 6.0-rc2-SNAPSHOT + 6.0-rc3-SNAPSHOT .. diff --git a/dspace-rest/src/main/java/org/dspace/rest/common/MetadataField.java b/dspace-rest/src/main/java/org/dspace/rest/common/MetadataField.java index 8ad22459c8..2b204ccb63 100644 --- a/dspace-rest/src/main/java/org/dspace/rest/common/MetadataField.java +++ b/dspace-rest/src/main/java/org/dspace/rest/common/MetadataField.java @@ -55,7 +55,7 @@ public class MetadataField { } this.setName(sb.toString()); - this.setFieldId(field.getFieldID()); + this.setFieldId(field.getID()); this.setElement(field.getElement()); this.setQualifier(field.getQualifier()); this.setDescription(field.getScopeNote()); diff --git a/dspace-rest/src/main/java/org/dspace/rest/common/MetadataSchema.java b/dspace-rest/src/main/java/org/dspace/rest/common/MetadataSchema.java index c1480fce54..7557bb87d1 100644 --- a/dspace-rest/src/main/java/org/dspace/rest/common/MetadataSchema.java +++ b/dspace-rest/src/main/java/org/dspace/rest/common/MetadataSchema.java @@ -48,7 +48,7 @@ public class MetadataSchema { if(expand != null) { expandFields = Arrays.asList(expand.split(",")); } - this.setSchemaID(schema.getSchemaID()); + this.setSchemaID(schema.getID()); this.setPrefix(schema.getName()); this.setNamespace(schema.getNamespace()); if (expandFields.contains("fields") || expandFields.contains("all")) { diff --git a/dspace-rest/src/main/webapp/static/reports/authenticate.html b/dspace-rest/src/main/webapp/static/reports/authenticate.html new file mode 100644 index 0000000000..046ced425c --- /dev/null +++ b/dspace-rest/src/main/webapp/static/reports/authenticate.html @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + Authenticate for the REST Report Tools + + +

    Login for an Authenticated Report View

    +
    This is intended for sites with Password Authentication Enabled
    + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + \ No newline at end of file diff --git a/dspace-rest/src/main/webapp/static/reports/index.html b/dspace-rest/src/main/webapp/static/reports/index.html index 3aa56ac160..d6634187e9 100644 --- a/dspace-rest/src/main/webapp/static/reports/index.html +++ b/dspace-rest/src/main/webapp/static/reports/index.html @@ -25,6 +25,7 @@ Query Tool +

    DSpace REST QC Client

    diff --git a/dspace-rest/src/main/webapp/static/reports/query.html b/dspace-rest/src/main/webapp/static/reports/query.html index 67ebb50a88..3f24956402 100644 --- a/dspace-rest/src/main/webapp/static/reports/query.html +++ b/dspace-rest/src/main/webapp/static/reports/query.html @@ -24,6 +24,7 @@ Collection Filter +

    DSpace REST Query Client

    diff --git a/dspace-rest/src/main/webapp/static/reports/restCollReport.js b/dspace-rest/src/main/webapp/static/reports/restCollReport.js index 76a9547f8b..27fb644361 100644 --- a/dspace-rest/src/main/webapp/static/reports/restCollReport.js +++ b/dspace-rest/src/main/webapp/static/reports/restCollReport.js @@ -6,361 +6,360 @@ * http://www.dspace.org/license/ */ var CollReport = function() { - Report.call(this); - //If sortable.js is included, uncomment the following - //this.hasSorttable = function(){return true;} - - this.COLL_LIMIT = 20; - this.TOOBIG = 10000; - this.loadId = 0; - this.THREADS =11; - this.THREADSP = 11; - this.ACCIDX_COLL = 1; - this.ACCIDX_ITEM = 2; - this.getDefaultParameters = function(){ - return { - "show_fields[]" : [], - filters : "", - limit : this.COUNT_LIMIT, - offset : 0, - icollection : "", - ifilter : "", - }; - } - this.getCurrentParameters = function(){ - return { - "show_fields[]" : this.myMetadataFields.getShowFields(), - filters : this.myFilters.getFilterList(), - limit : this.myReportParameters.getLimit(), - offset : this.myReportParameters.getOffset(), - icollection : $("#icollection").val(), - ifilter : $("#ifilter").val(), - }; - } - var self = this; + Report.call(this); + //If sortable.js is included, uncomment the following + //this.hasSorttable = function(){return true;} + + this.COLL_LIMIT = 20; + this.TOOBIG = 10000; + this.loadId = 0; + this.THREADS =11; + this.THREADSP = 11; + this.ACCIDX_COLL = 1; + this.ACCIDX_ITEM = 2; + this.getDefaultParameters = function(){ + return { + "show_fields[]" : [], + filters : "", + limit : this.COUNT_LIMIT, + offset : 0, + icollection : "", + ifilter : "", + }; + } + this.getCurrentParameters = function(){ + return { + "show_fields[]" : this.myMetadataFields.getShowFields(), + filters : this.myFilters.getFilterList(), + limit : this.myReportParameters.getLimit(), + offset : this.myReportParameters.getOffset(), + icollection : $("#icollection").val(), + ifilter : $("#ifilter").val(), + }; + } + var self = this; - this.init = function() { - this.baseInit(); - $("#icollection").val(self.myReportParameters.params.icollection); - $("#ifilter").val(self.myReportParameters.params.ifilter); - $("#itemResults").accordion({ - heightStyle: "content", - collapsible: true, - active: 1 - }); - } - - this.myAuth.callback = function(data) { - self.createCollectionTable(); - $(".showCollections").bind("click", function(){ - self.loadData(); - }); - $("#refresh-fields").bind("click", function(){ - self.drawItemTable($("#icollection").val(), $("#ifilter").val(), 0); - }); - } + this.init = function() { + this.baseInit(); + $("#icollection").val(self.myReportParameters.params.icollection); + $("#ifilter").val(self.myReportParameters.params.ifilter); + $("#itemResults").accordion({ + heightStyle: "content", + collapsible: true, + active: 1 + }); + } + + this.myAuth.callback = function(data) { + self.createCollectionTable(); + $("#table tbody tr").remove(); + $(".showCollections").bind("click", function(){ + self.loadData(); + }); + $("#refresh-fields").bind("click", function(){ + self.drawItemTable($("#icollection").val(), $("#ifilter").val(), 0); + }); + } - this.createCollectionTable = function() { - var self = this; - var tbl = $(""); - tbl.attr("id","table"); - $("#report").replaceWith(tbl); + this.createCollectionTable = function() { + var self = this; + var tbl = $("
    "); + tbl.attr("id","table"); + $("#report").replaceWith(tbl); - var thead = $(""); - tbl.append(thead); - var tbody = $(""); - tbl.append(tbody); - var tr = self.myHtmlUtil.addTr(thead).addClass("header"); - self.myHtmlUtil.addTh(tr, "Num").addClass("num").addClass("sorttable_numeric"); - self.myHtmlUtil.addTh(tr, "Community").addClass("title"); - self.myHtmlUtil.addTh(tr, "Collection").addClass("title"); - var thn = self.myHtmlUtil.addTh(tr, "Num Items").addClass("sorttable_numeric"); - self.myHtmlUtil.makeTotalCol(thn); - thn = self.myHtmlUtil.addTh(tr, "Num Filtered").addClass("sorttable_numeric"); - self.myHtmlUtil.makeTotalCol(thn); - - self.addCollections(); - } + var thead = $(""); + tbl.append(thead); + var tbody = $(""); + tbl.append(tbody); + var tr = self.myHtmlUtil.addTr(thead).addClass("header"); + self.myHtmlUtil.addTh(tr, "Num").addClass("num").addClass("sorttable_numeric"); + self.myHtmlUtil.addTh(tr, "Community").addClass("title"); + self.myHtmlUtil.addTh(tr, "Collection").addClass("title"); + var thn = self.myHtmlUtil.addTh(tr, "Num Items").addClass("sorttable_numeric"); + self.myHtmlUtil.makeTotalCol(thn); + thn = self.myHtmlUtil.addTh(tr, "Num Filtered").addClass("sorttable_numeric"); + self.myHtmlUtil.makeTotalCol(thn); + + self.addCollections(); + } - this.addCollections = function() { - var self = this; - - $.ajax({ - url: "/rest/hierarchy", - dataType: "json", - headers: self.myAuth.getHeaders(), - success: function(data){ - if (data.community != null) { - $.each(data.community, function(index, comm){ - self.addCommunity(comm, comm); - }); - } - self.setCollectionCounts(0); - }, - error: function(xhr, status, errorThrown) { - alert("Error in /rest/hierarchy "+ status+ " " + errorThrown); - } - }); - }; + this.addCollections = function() { + var self = this; + + $.ajax({ + url: "/rest/hierarchy", + dataType: "json", + headers: self.myAuth.getHeaders(), + success: function(data){ + if (data.community != null) { + $.each(data.community, function(index, comm){ + self.addCommunity(comm, comm); + }); + } + self.setCollectionCounts(0); + }, + error: function(xhr, status, errorThrown) { + alert("Error in /rest/hierarchy "+ status+ " " + errorThrown); + } + }); + }; - this.addCommunity = function(top, comm) { - var self = this; + this.addCommunity = function(top, comm) { + var self = this; - if (comm.collection != null) { - $.each(comm.collection, function(index, coll){ - self.addCollection(top, coll); - }); - } - if (comm.community != null) { - $.each(comm.community, function(index, scomm){ - self.addCommunity(top, scomm); - }); - } - }; + if (comm.collection != null) { + $.each(comm.collection, function(index, coll){ + self.addCollection(top, coll); + }); + } + if (comm.community != null) { + $.each(comm.community, function(index, scomm){ + self.addCommunity(top, scomm); + }); + } + }; - this.addCollection = function(top, coll) { - var self = this; + this.addCollection = function(top, coll) { + var self = this; - var tbody = $("#table tbody"); - var index = tbody.find("tr").length; + var tbody = $("#table tbody"); + var index = tbody.find("tr").length; - var tr = self.myHtmlUtil.addTr(tbody); - tr.attr("cid", coll.id).attr("index",index).addClass(index % 2 == 0 ? "odd data" : "even data"); - self.myHtmlUtil.addTd(tr, index + 1).addClass("num"); - var parval = self.myHtmlUtil.getAnchor(top.name, self.ROOTPATH + top.handle); - - self.myHtmlUtil.addTd(tr, parval).addClass("title comm"); - self.myHtmlUtil.addTdAnchor(tr, coll.name, self.ROOTPATH + coll.handle).addClass("title"); - var td = self.myHtmlUtil.addTd(tr, "").addClass("num").addClass("link").addClass("numCount"); - td = self.myHtmlUtil.addTd(tr, "").addClass("num").addClass("numFiltered"); - }; - - - this.setCollectionCounts = function(offset) { - var self = this; + var tr = self.myHtmlUtil.addTr(tbody); + tr.attr("cid", coll.id).attr("index",index).addClass(index % 2 == 0 ? "odd data" : "even data"); + self.myHtmlUtil.addTd(tr, index + 1).addClass("num"); + var parval = self.myHtmlUtil.getAnchor(top.name, self.ROOTPATH + top.handle); + + self.myHtmlUtil.addTd(tr, parval).addClass("title comm"); + self.myHtmlUtil.addTdAnchor(tr, coll.name, self.ROOTPATH + coll.handle).addClass("title"); + var td = self.myHtmlUtil.addTd(tr, "").addClass("num").addClass("link").addClass("numCount"); + td = self.myHtmlUtil.addTd(tr, "").addClass("num").addClass("numFiltered"); + }; + + + this.setCollectionCounts = function(offset) { + var self = this; - $.ajax({ - url: "/rest/filtered-collections", - data: { - limit : self.COLL_LIMIT, - offset : offset - }, - dataType: "json", - headers: self.myAuth.getHeaders(), - success: function(data){ - $.each(data, function(index, coll){ - var id = self.getId(coll); - var tr = $("#table tbody").find("tr[cid="+id+"]"); - var td = tr.find("td.numCount"); - td.text(coll.numberItems); - td.on("click", function(){ - self.drawItemTable(self.getId(coll),'',0); - $("#icollection").val(self.getId(coll)); - $("#ifilter").val(""); - }); - }); - - //cannot assume data returned is full amount in case some items are restricted - //if (data.length == self.COLL_LIMIT) { - if (data.length > 0) { - self.setCollectionCounts(offset + self.COLL_LIMIT); - return; - } - self.myHtmlUtil.totalCol(3); - $("#table").addClass("sortable"); - - if (self.myFilters.getFilterList() != "") { - self.loadData(); - if ($("#icollection").val() != "") { - self.drawItemTable($("#icollection").val(), $("#ifilter").val(), 0); - } - } - }, - error: function(xhr, status, errorThrown) { - alert("Error in /rest/collections "+ status+ " " + errorThrown); - }, - complete: function(xhr, status) { - self.spinner.stop(); - $(".showCollections").attr("disabled", false); - } - }); - } - - this.loadData = function() { - self.spinner.spin($("h1")[0]); - $(".showCollections").attr("disabled", true); - $("#metadatadiv").accordion("option", "active", self.ACCIDX_COLL); - self.loadId++; - $("td.datacol,th.datacol").remove(); - $("#table tr.data").addClass("processing"); - self.myFilters.filterString = self.myFilters.getFilterList(); - self.doRow(0, self.THREADS, self.loadId); - } - - this.doRow = function(row, threads, curLoadId) { - if (self.loadId != curLoadId) return; - var tr = $("tr[index="+row+"]"); - if (!tr.is("*")){ - return; - } - - var cid = tr.attr("cid"); - $.ajax({ - url: "/rest/filtered-collections/"+cid, - data: { - limit : self.COUNT_LIMIT, - filters : self.myFilters.filterString, - }, - dataType: "json", - headers: self.myAuth.getHeaders(), - success: function(data) { - var numItems = data.numberItems; - var numItemsProcessed = data.numberItemsProcessed; - $.each(data.itemFilters, function(index, itemFilter){ - if (self.loadId != curLoadId) { - return; - } - var trh = $("#table tr.header"); - var filterName = itemFilter["filter-name"]; - var filterTitle = itemFilter.title == null ? filterName : itemFilter.title; - if (!trh.find("th."+filterName).is("*")) { - var th = self.myHtmlUtil.addTh(trh, filterTitle); - th.addClass(filterName).addClass("datacol").addClass("sorttable_numeric"); - self.myHtmlUtil.makeTotalCol(th); - - if (itemFilter.description != null) { - th.attr("title", itemFilter.description); - } - - $("tr.data").each(function(){ - var td = self.myHtmlUtil.addTd($(this), ""); - td.addClass(filterName).addClass("num").addClass("datacol"); - }); - } - - self.setCellCount(tr, cid, 0, (numItems != numItemsProcessed), itemFilter); - self.setFilteredCount(tr, cid, 0, numItems, numItemsProcessed); - }); - - tr.removeClass("processing"); - if (!$("#table tr.processing").is("*")) { - self.updateSortable(); - self.totalFilters(); - self.spinner.stop(); - $(".showCollections").attr("disabled", false); - return; + $.ajax({ + url: "/rest/filtered-collections", + data: { + limit : self.COLL_LIMIT, + offset : offset + }, + dataType: "json", + headers: self.myAuth.getHeaders(), + success: function(data){ + $.each(data, function(index, coll){ + var id = self.getId(coll); + var tr = $("#table tbody").find("tr[cid="+id+"]"); + var td = tr.find("td.numCount"); + td.text(coll.numberItems); + td.on("click", function(){ + self.drawItemTable(self.getId(coll),'',0); + $("#icollection").val(self.getId(coll)); + $("#ifilter").val(""); + }); + }); + + //cannot assume data returned is full amount in case some items are restricted + //if (data.length == self.COLL_LIMIT) { + if (data.length > 0) { + self.setCollectionCounts(offset + self.COLL_LIMIT); + return; + } + self.myHtmlUtil.totalCol(3); + $("#table").addClass("sortable"); + + if (self.myFilters.getFilterList() != "") { + self.loadData(); + if ($("#icollection").val() != "") { + self.drawItemTable($("#icollection").val(), $("#ifilter").val(), 0); + } + } + }, + error: function(xhr, status, errorThrown) { + alert("Error in /rest/collections "+ status+ " " + errorThrown); + }, + complete: function(xhr, status) { + self.spinner.stop(); + $(".showCollections").attr("disabled", false); + } + }); + } + + this.loadData = function() { + self.spinner.spin($("h1")[0]); + $(".showCollections").attr("disabled", true); + $("#metadatadiv").accordion("option", "active", self.ACCIDX_COLL); + self.loadId++; + $("td.datacol,th.datacol").remove(); + $("#table tr.data").addClass("processing"); + self.myFilters.filterString = self.myFilters.getFilterList(); + self.doRow(0, self.THREADS, self.loadId); + } + + this.doRow = function(row, threads, curLoadId) { + if (self.loadId != curLoadId) return; + var tr = $("tr[index="+row+"]"); + if (!tr.is("*")){ + return; + } + + var cid = tr.attr("cid"); + $.ajax({ + url: "/rest/filtered-collections/"+cid, + data: { + limit : self.COUNT_LIMIT, + filters : self.myFilters.filterString, + }, + dataType: "json", + headers: self.myAuth.getHeaders(), + success: function(data) { + var numItems = data.numberItems; + var numItemsProcessed = data.numberItemsProcessed; + $.each(data.itemFilters, function(index, itemFilter){ + if (self.loadId != curLoadId) { + return; } - if (row % threads == 0 || threads == 1) { - for(var i=1; i<=threads; i++) { - self.doRow(row+i, threads, curLoadId); - } - } - }, - error: function(xhr, status, errorThrown) { - alert("Error in /rest/filtered-collections "+ status+ " " + errorThrown); - }, - complete: function(xhr, status) { - self.spinner.stop(); - $(".showCollections").attr("disabled", false); - } - - - }); - }; - - this.updateSortable = function() { - if (self.hasSorttable()) { - $("#table").removeClass("sortable"); - $("#table").addClass("sortable"); - sorttable.makeSortable($("#table")[0]); - } - } - - this.totalFilters = function() { - var colcount = $("#table tr th").length; - for(var i=4; i= self.TOOBIG) { td.addClass("toobig"); title+= "\nIt will take significant time to apply this filter to the entire collection." - } + } td.attr("title", title); return false; } else { - self.totalFilters(); + self.totalFilters(); } return true; } - - this.setCellCount = function(tr, cid, offset, isPartial, itemFilter) { - var filterName = itemFilter["filter-name"]; - var icount = itemFilter["item-count"]; + + this.setCellCount = function(tr, cid, offset, isPartial, itemFilter) { + var filterName = itemFilter["filter-name"]; + var icount = itemFilter["item-count"]; - var td = tr.find("td."+filterName); + var td = tr.find("td."+filterName); if (icount == null) { - icount = 0; + icount = 0; } var cur = parseInt(td.text()); if (!isNaN(cur)) { - icount += cur; + icount += cur; } td.removeClass("partial"); @@ -368,113 +367,113 @@ var CollReport = function() { td.removeAttr("title"); td.off(); td.text(icount); - if (icount != 0) { - td.addClass("link"); - if (isPartial) { - td.addClass("partial"); - td.attr("title", "Collection partially processed, item counts are incomplete"); - } - td.on("click", function(){ - self.drawItemTable(cid,filterName,0); - $("#icollection").val(cid); - $("#ifilter").val(filterName); - }); - } - } - - - this.drawItemTable = function(cid, filter, offset) { - self = this; - self.spinner.spin($("h1")[0]); - $("#itemtable").replaceWith($('
    ')); - var itbl = $("#itemtable"); - //itbl.find("tr").remove("*"); - var tr = self.myHtmlUtil.addTr(itbl).addClass("header"); - self.myHtmlUtil.addTh(tr, "Num").addClass("num").addClass("sorttable_numeric"); - self.myHtmlUtil.addTh(tr, "id"); - self.myHtmlUtil.addTh(tr, "Handle"); - self.myHtmlUtil.addTh(tr, "dc.title" + self.getLangSuffix()).addClass("title"); - var fields = $("#show-fields select").val(); - if (fields != null) { - $.each(fields, function(index, field){ - self.myHtmlUtil.addTh(tr, field + self.getLangSuffix()); - }); - } + if (icount != 0) { + td.addClass("link"); + if (isPartial) { + td.addClass("partial"); + td.attr("title", "Collection partially processed, item counts are incomplete"); + } + td.on("click", function(){ + self.drawItemTable(cid,filterName,0); + $("#icollection").val(cid); + $("#ifilter").val(filterName); + }); + } + } + + + this.drawItemTable = function(cid, filter, offset) { + self = this; + self.spinner.spin($("h1")[0]); + $("#itemtable").replaceWith($('
    ')); + var itbl = $("#itemtable"); + //itbl.find("tr").remove("*"); + var tr = self.myHtmlUtil.addTr(itbl).addClass("header"); + self.myHtmlUtil.addTh(tr, "Num").addClass("num").addClass("sorttable_numeric"); + self.myHtmlUtil.addTh(tr, "id"); + self.myHtmlUtil.addTh(tr, "Handle"); + self.myHtmlUtil.addTh(tr, "dc.title" + self.getLangSuffix()).addClass("title"); + var fields = $("#show-fields select").val(); + if (fields != null) { + $.each(fields, function(index, field){ + self.myHtmlUtil.addTh(tr, field + self.getLangSuffix()); + }); + } - var params = { - expand: fields == null ? "items" : "items,metadata", - limit: self.ITEM_LIMIT, - filters: filter, - offset: offset, - "show_fields[]" : fields, - } - - $.ajax({ - url: "/rest/filtered-collections/"+cid, - data: params, - dataType: "json", - headers: self.myAuth.getHeaders(), - success: function(data){ - var source = filter == "" ? data.items : data.itemFilters[0].items; - - $.each(source, function(index, item){ - var tr = self.myHtmlUtil.addTr(itbl); - tr.addClass(index % 2 == 0 ? "odd data" : "even data"); - self.myHtmlUtil.addTd(tr, offset+index+1).addClass("num"); - self.myHtmlUtil.addTd(tr, self.getId(item)); - self.myHtmlUtil.addTdAnchor(tr, item.handle, self.ROOTPATH + item.handle); - self.myHtmlUtil.addTd(tr, item.name).addClass("ititle"); - if (fields != null) { - $.each(fields, function(index, field){ - var text = ""; - $.each(item.metadata, function(mindex,mv){ - if (mv.key == field) { - if (text != "") { - text += "
    "; - } - text += mv.value; - } - }); - self.myHtmlUtil.addTd(tr, text); - }); - } - }); - self.displayItems(filter + " Items in " + data.name, - offset, - self.ITEM_LIMIT, - data.numberItems, - function(){self.drawItemTable(cid, filter, (offset - self.ITEM_LIMIT < 0) ? 0 : offset - self.ITEM_LIMIT);}, - function(){self.drawItemTable(cid, filter, offset + self.ITEM_LIMIT);} - ); - - if (self.hasSorttable()){ - sorttable.makeSortable(itbl[0]); - } - $("#metadatadiv").accordion("option", "active", self.ACCIDX_ITEM); - }, - error: function(xhr, status, errorThrown) { - alert("Error in /rest/filtered-collections "+ status+ " " + errorThrown); - }, - complete: function(xhr, status) { - self.spinner.stop(); - $(".showCollections").attr("disabled", false); - } - }); - } + var params = { + expand: fields == null ? "items" : "items,metadata", + limit: self.ITEM_LIMIT, + filters: filter, + offset: offset, + "show_fields[]" : fields, + } + + $.ajax({ + url: "/rest/filtered-collections/"+cid, + data: params, + dataType: "json", + headers: self.myAuth.getHeaders(), + success: function(data){ + var source = filter == "" ? data.items : data.itemFilters[0].items; + + $.each(source, function(index, item){ + var tr = self.myHtmlUtil.addTr(itbl); + tr.addClass(index % 2 == 0 ? "odd data" : "even data"); + self.myHtmlUtil.addTd(tr, offset+index+1).addClass("num"); + self.myHtmlUtil.addTd(tr, self.getId(item)); + self.myHtmlUtil.addTdAnchor(tr, item.handle, self.ROOTPATH + item.handle); + self.myHtmlUtil.addTd(tr, item.name).addClass("ititle"); + if (fields != null) { + $.each(fields, function(index, field){ + var text = ""; + $.each(item.metadata, function(mindex,mv){ + if (mv.key == field) { + if (text != "") { + text += "
    "; + } + text += mv.value; + } + }); + self.myHtmlUtil.addTd(tr, text); + }); + } + }); + self.displayItems(filter + " Items in " + data.name, + offset, + self.ITEM_LIMIT, + data.numberItems, + function(){self.drawItemTable(cid, filter, (offset - self.ITEM_LIMIT < 0) ? 0 : offset - self.ITEM_LIMIT);}, + function(){self.drawItemTable(cid, filter, offset + self.ITEM_LIMIT);} + ); + + if (self.hasSorttable()){ + sorttable.makeSortable(itbl[0]); + } + $("#metadatadiv").accordion("option", "active", self.ACCIDX_ITEM); + }, + error: function(xhr, status, errorThrown) { + alert("Error in /rest/filtered-collections "+ status+ " " + errorThrown); + }, + complete: function(xhr, status) { + self.spinner.stop(); + $(".showCollections").attr("disabled", false); + } + }); + } - //Ignore the first column containing a row number and the item handle - this.exportCol = function(colnum, col) { - var data = ""; - if (colnum == 0) return ""; - if (colnum == 2) return ""; - data += (colnum == 1) ? "" : ","; - data += self.exportCell(col); - return data; - } + //Ignore the first column containing a row number and the item handle + this.exportCol = function(colnum, col) { + var data = ""; + if (colnum == 0) return ""; + if (colnum == 2) return ""; + data += (colnum == 1) ? "" : ","; + data += self.exportCell(col); + return data; + } } CollReport.prototype = Object.create(Report.prototype); $(document).ready(function(){ - var myReport=new CollReport(); - myReport.init(); + var myReport=new CollReport(); + myReport.init(); }); diff --git a/dspace-rest/src/main/webapp/static/reports/restQueryReport.js b/dspace-rest/src/main/webapp/static/reports/restQueryReport.js index d045614ea8..a237125149 100644 --- a/dspace-rest/src/main/webapp/static/reports/restQueryReport.js +++ b/dspace-rest/src/main/webapp/static/reports/restQueryReport.js @@ -6,318 +6,318 @@ * http://www.dspace.org/license/ */ var QueryReport = function() { - Report.call(this); - - //If sortable.js is included, uncomment the following - //this.hasSorttable = function(){return true;} - - this.getDefaultParameters = function(){ - return { - "collSel[]" : [], - "query_field[]" : [], - "query_op[]" : [], - "query_val[]" : [], - "show_fields[]" : [], - "filters" : "", - "limit" : this.ITEM_LIMIT, - "offset" : 0, - }; - } - this.getCurrentParameters = function(){ - var params = { - "query_field[]" : [], - "query_op[]" : [], - "query_val[]" : [], - "collSel[]" : ($("#collSel").val() == null) ? [""] : $("#collSel").val(), - limit : this.myReportParameters.getLimit(), - offset : this.myReportParameters.getOffset(), - "expand" : "parentCollection,metadata", - filters : this.myFilters.getFilterList(), - "show_fields[]" : this.myMetadataFields.getShowFields(), - }; - $("select.query-tool,input.query-tool").each(function() { - var paramArr = params[$(this).attr("name")]; - paramArr[paramArr.length] = $(this).val(); - }); - return params; - } - var self = this; + Report.call(this); + + //If sortable.js is included, uncomment the following + //this.hasSorttable = function(){return true;} + + this.getDefaultParameters = function(){ + return { + "collSel[]" : [], + "query_field[]" : [], + "query_op[]" : [], + "query_val[]" : [], + "show_fields[]" : [], + "filters" : "", + "limit" : this.ITEM_LIMIT, + "offset" : 0, + }; + } + this.getCurrentParameters = function(){ + var params = { + "query_field[]" : [], + "query_op[]" : [], + "query_val[]" : [], + "collSel[]" : ($("#collSel").val() == null) ? [""] : $("#collSel").val(), + limit : this.myReportParameters.getLimit(), + offset : this.myReportParameters.getOffset(), + "expand" : "parentCollection,metadata", + filters : this.myFilters.getFilterList(), + "show_fields[]" : this.myMetadataFields.getShowFields(), + }; + $("select.query-tool,input.query-tool").each(function() { + var paramArr = params[$(this).attr("name")]; + paramArr[paramArr.length] = $(this).val(); + }); + return params; + } + var self = this; - this.init = function() { - this.baseInit(); - var communitySelector = new CommunitySelector(this, $("#collSelector"), this.myReportParameters.params["collSel[]"]); - } - - this.initMetadataFields = function() { - this.myMetadataFields = new QueryableMetadataFields(self); - this.myMetadataFields.load(); - } - this.myAuth.callback = function(data) { - $(".query-button").click(function(){self.runQuery();}) - } + this.init = function() { + this.baseInit(); + } + + this.initMetadataFields = function() { + this.myMetadataFields = new QueryableMetadataFields(self); + this.myMetadataFields.load(); + } + this.myAuth.callback = function(data) { + var communitySelector = new CommunitySelector(self, $("#collSelector"), self.myReportParameters.params["collSel[]"]); + $(".query-button").click(function(){self.runQuery();}) + } - this.runQuery = function() { - this.spinner.spin($("body")[0]); - $("button").attr("disabled", true); - $.ajax({ - url: "/rest/filtered-items", - data: this.getCurrentParameters(), - dataType: "json", - headers: self.myAuth.getHeaders(), - success: function(data){ - data.metadata = $("#show-fields select").val(); - self.drawItemFilterTable(data); - self.spinner.stop(); - $("button").not("#next,#prev").attr("disabled", false); - }, - error: function(xhr, status, errorThrown) { - alert("Error in /rest/filtered-items "+ status+ " " + errorThrown); - }, - complete: function(xhr, status, errorThrown) { - self.spinner.stop(); - $("button").not("#next,#prev").attr("disabled", false); - } - }); - } - - this.drawItemFilterTable = function(data) { - $("#itemtable").replaceWith($('
    ')); - var itbl = $("#itemtable"); - var tr = self.myHtmlUtil.addTr(itbl).addClass("header"); - self.myHtmlUtil.addTh(tr, "Num").addClass("num").addClass("sorttable_numeric"); - self.myHtmlUtil.addTh(tr, "id"); - self.myHtmlUtil.addTh(tr, "collection"); - self.myHtmlUtil.addTh(tr, "Item Handle"); - self.myHtmlUtil.addTh(tr, "dc.title" + self.getLangSuffix()); - - var mdCols = []; - if (data.metadata) { - $.each(data.metadata, function(index, field) { - if (field != "") { - self.myHtmlUtil.addTh(tr,field + self.getLangSuffix()).addClass("returnFields"); - mdCols[mdCols.length] = field; - } - }); - } - - $.each(data.items, function(index, item){ - var tr = self.myHtmlUtil.addTr(itbl); - tr.addClass(index % 2 == 0 ? "odd data" : "even data"); - self.myHtmlUtil.addTd(tr, self.myReportParameters.getOffset()+index+1).addClass("num"); - self.myHtmlUtil.addTd(tr, self.getId(item)); - if (item.parentCollection == null) { - self.myHtmlUtil.addTd(tr, "--"); - } else { - self.myHtmlUtil.addTdAnchor(tr, item.parentCollection.name, self.ROOTPATH + item.parentCollection.handle); - } - self.myHtmlUtil.addTdAnchor(tr, item.handle, self.ROOTPATH + item.handle); - self.myHtmlUtil.addTd(tr, item.name); - - for(var i=0; i"+metadata.value+"
    "); - td.append(div); - } - } - }); - } - }); - - this.displayItems(data["query-annotation"], - this.myReportParameters.getOffset(), - this.myReportParameters.getLimit(), - data["unfiltered-item-count"], - function(){ - self.myReportParameters.updateOffset(false); - self.runQuery(); - }, - function(){ - self.myReportParameters.updateOffset(true); - self.runQuery(); - } - ); - - if (this.hasSorttable()) { - sorttable.makeSortable(itbl[0]); - } - $("#metadatadiv").accordion("option", "active", $("#metadatadiv > h3").length - 1); - } - - //Ignore the first column containing a row number and the item handle, get handle for the collection - this.exportCol = function(colnum, col) { - var data = ""; - if (colnum == 0) return ""; - if (colnum == 3) return ""; - data += (colnum == 1) ? "" : ","; - - if (colnum == 2) { - var anchor = $(col).find("a"); - var href = anchor.is("a") ? anchor.attr("href").replace(self.ROOTPATH,"") : $(col).text(); - data += "\"" + href + "\""; - } else { - data += self.exportCell(col); } - return data; - } + this.runQuery = function() { + this.spinner.spin($("body")[0]); + $("button").attr("disabled", true); + $.ajax({ + url: "/rest/filtered-items", + data: this.getCurrentParameters(), + dataType: "json", + headers: self.myAuth.getHeaders(), + success: function(data){ + data.metadata = $("#show-fields select").val(); + self.drawItemFilterTable(data); + self.spinner.stop(); + $("button").not("#next,#prev").attr("disabled", false); + }, + error: function(xhr, status, errorThrown) { + alert("Error in /rest/filtered-items "+ status+ " " + errorThrown); + }, + complete: function(xhr, status, errorThrown) { + self.spinner.stop(); + $("button").not("#next,#prev").attr("disabled", false); + } + }); + } + + this.drawItemFilterTable = function(data) { + $("#itemtable").replaceWith($('
    ')); + var itbl = $("#itemtable"); + var tr = self.myHtmlUtil.addTr(itbl).addClass("header"); + self.myHtmlUtil.addTh(tr, "Num").addClass("num").addClass("sorttable_numeric"); + self.myHtmlUtil.addTh(tr, "id"); + self.myHtmlUtil.addTh(tr, "collection"); + self.myHtmlUtil.addTh(tr, "Item Handle"); + self.myHtmlUtil.addTh(tr, "dc.title" + self.getLangSuffix()); + + var mdCols = []; + if (data.metadata) { + $.each(data.metadata, function(index, field) { + if (field != "") { + self.myHtmlUtil.addTh(tr,field + self.getLangSuffix()).addClass("returnFields"); + mdCols[mdCols.length] = field; + } + }); + } + + $.each(data.items, function(index, item){ + var tr = self.myHtmlUtil.addTr(itbl); + tr.addClass(index % 2 == 0 ? "odd data" : "even data"); + self.myHtmlUtil.addTd(tr, self.myReportParameters.getOffset()+index+1).addClass("num"); + self.myHtmlUtil.addTd(tr, self.getId(item)); + if (item.parentCollection == null) { + self.myHtmlUtil.addTd(tr, "--"); + } else { + self.myHtmlUtil.addTdAnchor(tr, item.parentCollection.name, self.ROOTPATH + item.parentCollection.handle); + } + self.myHtmlUtil.addTdAnchor(tr, item.handle, self.ROOTPATH + item.handle); + self.myHtmlUtil.addTd(tr, item.name); + + for(var i=0; i"+metadata.value+"
    "); + td.append(div); + } + } + }); + } + }); + + this.displayItems(data["query-annotation"], + this.myReportParameters.getOffset(), + this.myReportParameters.getLimit(), + data["unfiltered-item-count"], + function(){ + self.myReportParameters.updateOffset(false); + self.runQuery(); + }, + function(){ + self.myReportParameters.updateOffset(true); + self.runQuery(); + } + ); + + if (this.hasSorttable()) { + sorttable.makeSortable(itbl[0]); + } + $("#metadatadiv").accordion("option", "active", $("#metadatadiv > h3").length - 1); + } + + //Ignore the first column containing a row number and the item handle, get handle for the collection + this.exportCol = function(colnum, col) { + var data = ""; + if (colnum == 0) return ""; + if (colnum == 3) return ""; + data += (colnum == 1) ? "" : ","; + + if (colnum == 2) { + var anchor = $(col).find("a"); + var href = anchor.is("a") ? anchor.attr("href").replace(self.ROOTPATH,"") : $(col).text(); + data += "\"" + href + "\""; + } else { + data += self.exportCell(col); } + return data; + } } QueryReport.prototype = Object.create(Report.prototype); $(document).ready(function(){ - var myReport=new QueryReport(); - myReport.init(); + var myReport=new QueryReport(); + myReport.init(); }); var QueryableMetadataFields = function(report) { - MetadataFields.call(this, report); + MetadataFields.call(this, report); var self = this; - - this.initFields = function(data, report) { - self.metadataSchemas = data; - var params = report.myReportParameters.params; - var fields = params["query_field[]"]; - var ops = params["query_op[]"]; - var vals = params["query_val[]"]; - if (fields && ops && vals) { - if (fields.length == 0) { - self.drawFilterQuery("*","exists",""); - } else { - for(var i=0; i i ? ops[i] : ""; - var val = vals.length > i ? vals[i] : ""; - self.drawFilterQuery(fields[i],op,val); - } - } - } - self.drawShowFields(params["show_fields[]"]); - self.initQueries(); - report.spinner.stop(); - $(".query-button").attr("disabled", false); - } - - this.initQueries = function() { - $("#predefselect") - .append($("")) - .append($("")) - .append($("")) - .append($("")) - .append($("")) - .append($("")) - .append($("")) - .append($("")) - .append($("")) - .append($("")) - .append($("")) - .append($("")) - .append($("")) - .on("change",function(){ - $("div.metadata").remove(); - var val = $("#predefselect").val(); - if (val == 'new') { - self.drawFilterQuery("","",""); - } else if (val == 'q1') { - self.drawFilterQuery("dc.title","doesnt_exist",""); - } else if (val == 'q2') { - self.drawFilterQuery("dc.identifier.uri","doesnt_exist",""); - } else if (val == 'q3') { - self.drawFilterQuery("dc.subject.*","like","%;%"); - } else if (val == 'q4') { - self.drawFilterQuery("dc.contributor.author","like","% and %"); - } else if (val == 'q5') { - self.drawFilterQuery("dc.creator","like","% and %"); - } else if (val == 'q6') { - self.drawFilterQuery("dc.description","matches","^.*(http://|https://|mailto:).*$"); - } else if (val == 'q7') { - self.drawFilterQuery("dc.description.provenance","matches","^.*No\\. of bitstreams(.|\\r|\\n|\\r\\n)*\\.(PDF|pdf|DOC|doc|PPT|ppt|DOCX|docx|PPTX|pptx).*$"); - } else if (val == 'q8') { - self.drawFilterQuery("dc.description.provenance","doesnt_match","^.*No\\. of bitstreams(.|\\r|\\n|\\r\\n)*\\.(PDF|pdf|DOC|doc|PPT|ppt|DOCX|docx|PPTX|pptx).*$"); - } else if (val == 'q9') { - self.drawFilterQuery("*","matches","^\\s*$"); - } else if (val == 'q10') { - self.drawFilterQuery("dc.description.*","matches","^.*[^\\s]{50,}.*$"); - } else if (val == 'q12') { - self.drawFilterQuery("*","matches","^.*&#.*$"); - } else if (val == 'q13') { - self.drawFilterQuery("*","matches","^.*[^[:ascii:]].*$"); - } - }); - } + + this.initFields = function(data, report) { + self.metadataSchemas = data; + var params = report.myReportParameters.params; + var fields = params["query_field[]"]; + var ops = params["query_op[]"]; + var vals = params["query_val[]"]; + if (fields && ops && vals) { + if (fields.length == 0) { + self.drawFilterQuery("*","exists",""); + } else { + for(var i=0; i i ? ops[i] : ""; + var val = vals.length > i ? vals[i] : ""; + self.drawFilterQuery(fields[i],op,val); + } + } + } + self.drawShowFields(params["show_fields[]"]); + self.initQueries(); + report.spinner.stop(); + $(".query-button").attr("disabled", false); + } + + this.initQueries = function() { + $("#predefselect") + .append($("")) + .append($("")) + .append($("")) + .append($("")) + .append($("")) + .append($("")) + .append($("")) + .append($("")) + .append($("")) + .append($("")) + .append($("")) + .append($("")) + .append($("")) + .on("change",function(){ + $("div.metadata").remove(); + var val = $("#predefselect").val(); + if (val == 'new') { + self.drawFilterQuery("","",""); + } else if (val == 'q1') { + self.drawFilterQuery("dc.title","doesnt_exist",""); + } else if (val == 'q2') { + self.drawFilterQuery("dc.identifier.uri","doesnt_exist",""); + } else if (val == 'q3') { + self.drawFilterQuery("dc.subject.*","like","%;%"); + } else if (val == 'q4') { + self.drawFilterQuery("dc.contributor.author","like","% and %"); + } else if (val == 'q5') { + self.drawFilterQuery("dc.creator","like","% and %"); + } else if (val == 'q6') { + self.drawFilterQuery("dc.description","matches","^.*(http://|https://|mailto:).*$"); + } else if (val == 'q7') { + self.drawFilterQuery("dc.description.provenance","matches","^.*No\\. of bitstreams(.|\\r|\\n|\\r\\n)*\\.(PDF|pdf|DOC|doc|PPT|ppt|DOCX|docx|PPTX|pptx).*$"); + } else if (val == 'q8') { + self.drawFilterQuery("dc.description.provenance","doesnt_match","^.*No\\. of bitstreams(.|\\r|\\n|\\r\\n)*\\.(PDF|pdf|DOC|doc|PPT|ppt|DOCX|docx|PPTX|pptx).*$"); + } else if (val == 'q9') { + self.drawFilterQuery("*","matches","^\\s*$"); + } else if (val == 'q10') { + self.drawFilterQuery("dc.description.*","matches","^.*[^\\s]{50,}.*$"); + } else if (val == 'q12') { + self.drawFilterQuery("*","matches","^.*&#.*$"); + } else if (val == 'q13') { + self.drawFilterQuery("*","matches","^.*[^[:ascii:]].*$"); + } + }); + } - this.drawFilterQuery = function(pField, pOp, pVal) { - var div = $("