mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 23:13:10 +00:00
Merge branch 'master' into DS-3363-csv-import-error-messages
This commit is contained in:
14
.travis.yml
14
.travis.yml
@@ -5,6 +5,20 @@ env:
|
|||||||
# Give Maven 1GB of memory to work with
|
# Give Maven 1GB of memory to work with
|
||||||
- MAVEN_OPTS=-Xmx1024M
|
- MAVEN_OPTS=-Xmx1024M
|
||||||
|
|
||||||
|
jdk:
|
||||||
|
# DS-3384 Oracle JDK 8 has DocLint enabled by default.
|
||||||
|
# Let's use this to catch any newly introduced DocLint issues.
|
||||||
|
- oraclejdk8
|
||||||
|
- oraclejdk7
|
||||||
|
|
||||||
|
## Should we run into any problems with oraclejdk8 on Travis, we may try the following workaround.
|
||||||
|
## https://docs.travis-ci.com/user/languages/java#Testing-Against-Multiple-JDKs
|
||||||
|
## https://github.com/travis-ci/travis-ci/issues/3259#issuecomment-130860338
|
||||||
|
#addons:
|
||||||
|
# apt:
|
||||||
|
# packages:
|
||||||
|
# - oracle-java8-installer
|
||||||
|
|
||||||
# Install prerequisites for building Mirage2 more rapidly
|
# Install prerequisites for building Mirage2 more rapidly
|
||||||
before_install:
|
before_install:
|
||||||
# Install Node.js 6.5.0 & print version info
|
# Install Node.js 6.5.0 & print version info
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.dspace</groupId>
|
<groupId>org.dspace</groupId>
|
||||||
<artifactId>dspace-parent</artifactId>
|
<artifactId>dspace-parent</artifactId>
|
||||||
<version>6.0-rc5-SNAPSHOT</version>
|
<version>7.0-SNAPSHOT</version>
|
||||||
<relativePath>..</relativePath>
|
<relativePath>..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@@ -71,11 +71,11 @@ public interface ExtractingParams {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Restrict the extracted parts of a document to be indexed
|
* Restrict the extracted parts of a document to be indexed
|
||||||
* by passing in an XPath expression. All content that satisfies the XPath expr.
|
* by passing in an XPath expression. All content that satisfies the XPath expr.
|
||||||
* will be passed to the {@link SolrContentHandler}.
|
* will be passed to the {@link org.apache.solr.handler.extraction.SolrContentHandler}.
|
||||||
* <p>
|
* <p>
|
||||||
* See Tika's docs for what the extracted document looks like.
|
* See Tika's docs for what the extracted document looks like.
|
||||||
* <p>
|
*
|
||||||
* @see #CAPTURE_ELEMENTS
|
* @see #CAPTURE_ELEMENTS
|
||||||
*/
|
*/
|
||||||
public static final String XPATH_EXPRESSION = "xpath";
|
public static final String XPATH_EXPRESSION = "xpath";
|
||||||
@@ -105,7 +105,7 @@ 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
|
* 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.
|
* then the case of passing in an XPath expression.
|
||||||
* <p>
|
* <p>
|
||||||
* The Capture field is based on the localName returned to the {@link SolrContentHandler}
|
* The Capture field is based on the localName returned to the {@link org.apache.solr.handler.extraction.SolrContentHandler}
|
||||||
* by Tika, not to be confused by the mapped field. The field name can then
|
* by Tika, not to be confused by the mapped field. The field name can then
|
||||||
* be mapped into the index schema.
|
* be mapped into the index schema.
|
||||||
* <p>
|
* <p>
|
||||||
|
@@ -48,7 +48,7 @@ public class CommunityFiliator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param argv arguments
|
* @param argv the command line arguments given
|
||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
public static void main(String[] argv) throws Exception
|
public static void main(String[] argv) throws Exception
|
||||||
|
@@ -47,8 +47,8 @@ import org.dspace.eperson.service.GroupService;
|
|||||||
*/
|
*/
|
||||||
public final class CreateAdministrator
|
public final class CreateAdministrator
|
||||||
{
|
{
|
||||||
/** DSpace Context object */
|
/** DSpace Context object */
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
protected EPersonService ePersonService;
|
protected EPersonService ePersonService;
|
||||||
protected GroupService groupService;
|
protected GroupService groupService;
|
||||||
@@ -57,37 +57,36 @@ public final class CreateAdministrator
|
|||||||
* For invoking via the command line. If called with no command line arguments,
|
* For invoking via the command line. If called with no command line arguments,
|
||||||
* it will negotiate with the user for the administrator details
|
* it will negotiate with the user for the administrator details
|
||||||
*
|
*
|
||||||
* @param argv
|
* @param argv the command line arguments given
|
||||||
* command-line arguments
|
|
||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
public static void main(String[] argv)
|
public static void main(String[] argv)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
CommandLineParser parser = new PosixParser();
|
CommandLineParser parser = new PosixParser();
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
CreateAdministrator ca = new CreateAdministrator();
|
CreateAdministrator ca = new CreateAdministrator();
|
||||||
|
|
||||||
options.addOption("e", "email", true, "administrator email address");
|
options.addOption("e", "email", true, "administrator email address");
|
||||||
options.addOption("f", "first", true, "administrator first name");
|
options.addOption("f", "first", true, "administrator first name");
|
||||||
options.addOption("l", "last", true, "administrator last name");
|
options.addOption("l", "last", true, "administrator last name");
|
||||||
options.addOption("c", "language", true, "administrator language");
|
options.addOption("c", "language", true, "administrator language");
|
||||||
options.addOption("p", "password", true, "administrator password");
|
options.addOption("p", "password", true, "administrator password");
|
||||||
|
|
||||||
CommandLine line = parser.parse(options, argv);
|
CommandLine line = parser.parse(options, argv);
|
||||||
|
|
||||||
if (line.hasOption("e") && line.hasOption("f") && line.hasOption("l") &&
|
if (line.hasOption("e") && line.hasOption("f") && line.hasOption("l") &&
|
||||||
line.hasOption("c") && line.hasOption("p"))
|
line.hasOption("c") && line.hasOption("p"))
|
||||||
{
|
{
|
||||||
ca.createAdministrator(line.getOptionValue("e"),
|
ca.createAdministrator(line.getOptionValue("e"),
|
||||||
line.getOptionValue("f"), line.getOptionValue("l"),
|
line.getOptionValue("f"), line.getOptionValue("l"),
|
||||||
line.getOptionValue("c"), line.getOptionValue("p"));
|
line.getOptionValue("c"), line.getOptionValue("p"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ca.negotiateAdministratorDetails();
|
ca.negotiateAdministratorDetails();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,9 +95,9 @@ public final class CreateAdministrator
|
|||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
protected CreateAdministrator()
|
protected CreateAdministrator()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
context = new Context();
|
context = new Context();
|
||||||
groupService = EPersonServiceFactory.getInstance().getGroupService();
|
groupService = EPersonServiceFactory.getInstance().getGroupService();
|
||||||
ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||||
}
|
}
|
||||||
@@ -110,27 +109,27 @@ public final class CreateAdministrator
|
|||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
protected void negotiateAdministratorDetails()
|
protected void negotiateAdministratorDetails()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
Console console = System.console();
|
Console console = System.console();
|
||||||
|
|
||||||
System.out.println("Creating an initial administrator account");
|
System.out.println("Creating an initial administrator account");
|
||||||
|
|
||||||
boolean dataOK = false;
|
boolean dataOK = false;
|
||||||
|
|
||||||
String email = null;
|
String email = null;
|
||||||
String firstName = null;
|
String firstName = null;
|
||||||
String lastName = null;
|
String lastName = null;
|
||||||
char[] password1 = null;
|
char[] password1 = null;
|
||||||
char[] password2 = null;
|
char[] password2 = null;
|
||||||
String language = I18nUtil.DEFAULTLOCALE.getLanguage();
|
String language = I18nUtil.DEFAULTLOCALE.getLanguage();
|
||||||
|
|
||||||
while (!dataOK)
|
while (!dataOK)
|
||||||
{
|
{
|
||||||
System.out.print("E-mail address: ");
|
System.out.print("E-mail address: ");
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
|
|
||||||
email = console.readLine();
|
email = console.readLine();
|
||||||
if (!StringUtils.isBlank(email))
|
if (!StringUtils.isBlank(email))
|
||||||
{
|
{
|
||||||
email = email.trim();
|
email = email.trim();
|
||||||
@@ -140,34 +139,34 @@ public final class CreateAdministrator
|
|||||||
System.out.println("Please provide an email address.");
|
System.out.println("Please provide an email address.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.print("First name: ");
|
System.out.print("First name: ");
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
|
|
||||||
firstName = console.readLine();
|
firstName = console.readLine();
|
||||||
|
|
||||||
if (firstName != null)
|
if (firstName != null)
|
||||||
{
|
{
|
||||||
firstName = firstName.trim();
|
firstName = firstName.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.print("Last name: ");
|
System.out.print("Last name: ");
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
|
|
||||||
lastName = console.readLine();
|
lastName = console.readLine();
|
||||||
|
|
||||||
if (lastName != null)
|
if (lastName != null)
|
||||||
{
|
{
|
||||||
lastName = lastName.trim();
|
lastName = lastName.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigurationManager.getProperty("webui.supported.locales") != null)
|
if (ConfigurationManager.getProperty("webui.supported.locales") != null)
|
||||||
{
|
{
|
||||||
System.out.println("Select one of the following languages: " + ConfigurationManager.getProperty("webui.supported.locales"));
|
System.out.println("Select one of the following languages: " + ConfigurationManager.getProperty("webui.supported.locales"));
|
||||||
System.out.print("Language: ");
|
System.out.print("Language: ");
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
|
|
||||||
language = console.readLine();
|
language = console.readLine();
|
||||||
|
|
||||||
if (language != null)
|
if (language != null)
|
||||||
{
|
{
|
||||||
@@ -176,25 +175,25 @@ public final class CreateAdministrator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Password will not display on screen.");
|
System.out.println("Password will not display on screen.");
|
||||||
System.out.print("Password: ");
|
System.out.print("Password: ");
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
|
|
||||||
password1 = console.readPassword();
|
password1 = console.readPassword();
|
||||||
|
|
||||||
System.out.print("Again to confirm: ");
|
System.out.print("Again to confirm: ");
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
|
|
||||||
password2 = console.readPassword();
|
password2 = console.readPassword();
|
||||||
|
|
||||||
//TODO real password validation
|
//TODO real password validation
|
||||||
if (password1.length > 1 && Arrays.equals(password1, password2))
|
if (password1.length > 1 && Arrays.equals(password1, password2))
|
||||||
{
|
{
|
||||||
// password OK
|
// password OK
|
||||||
System.out.print("Is the above data correct? (y or n): ");
|
System.out.print("Is the above data correct? (y or n): ");
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
|
|
||||||
String s = console.readLine();
|
String s = console.readLine();
|
||||||
|
|
||||||
if (s != null)
|
if (s != null)
|
||||||
{
|
{
|
||||||
@@ -204,15 +203,15 @@ public final class CreateAdministrator
|
|||||||
dataOK = true;
|
dataOK = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
System.out.println("Passwords don't match");
|
System.out.println("Passwords don't match");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we make it to here, we are ready to create an administrator
|
// if we make it to here, we are ready to create an administrator
|
||||||
createAdministrator(email, firstName, lastName, language, String.valueOf(password1));
|
createAdministrator(email, firstName, lastName, language, String.valueOf(password1));
|
||||||
|
|
||||||
//Cleaning arrays that held password
|
//Cleaning arrays that held password
|
||||||
Arrays.fill(password1, ' ');
|
Arrays.fill(password1, ' ');
|
||||||
@@ -223,31 +222,31 @@ public final class CreateAdministrator
|
|||||||
* Create the administrator with the given details. If the user
|
* Create the administrator with the given details. If the user
|
||||||
* already exists then they are simply upped to administrator status
|
* already exists then they are simply upped to administrator status
|
||||||
*
|
*
|
||||||
* @param email the email for the user
|
* @param email the email for the user
|
||||||
* @param first user's first name
|
* @param first user's first name
|
||||||
* @param last user's last name
|
* @param last user's last name
|
||||||
* @param language preferred language
|
* @param language preferred language
|
||||||
* @param pw desired password
|
* @param pw desired password
|
||||||
*
|
*
|
||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
protected void createAdministrator(String email, String first, String last,
|
protected void createAdministrator(String email, String first, String last,
|
||||||
String language, String pw)
|
String language, String pw)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
// Of course we aren't an administrator yet so we need to
|
// Of course we aren't an administrator yet so we need to
|
||||||
// circumvent authorisation
|
// circumvent authorisation
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
// Find administrator group
|
// Find administrator group
|
||||||
Group admins = groupService.findByName(context, Group.ADMIN);
|
Group admins = groupService.findByName(context, Group.ADMIN);
|
||||||
|
|
||||||
if (admins == null)
|
if (admins == null)
|
||||||
{
|
{
|
||||||
throw new IllegalStateException("Error, no admin group (group 1) found");
|
throw new IllegalStateException("Error, no admin group (group 1) found");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the administrator e-person
|
// Create the administrator e-person
|
||||||
EPerson eperson = ePersonService.findByEmail(context,email);
|
EPerson eperson = ePersonService.findByEmail(context,email);
|
||||||
|
|
||||||
// check if the email belongs to a registered user,
|
// check if the email belongs to a registered user,
|
||||||
@@ -260,18 +259,18 @@ public final class CreateAdministrator
|
|||||||
eperson.setRequireCertificate(false);
|
eperson.setRequireCertificate(false);
|
||||||
eperson.setSelfRegistered(false);
|
eperson.setSelfRegistered(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
eperson.setLastName(context, last);
|
eperson.setLastName(context, last);
|
||||||
eperson.setFirstName(context, first);
|
eperson.setFirstName(context, first);
|
||||||
eperson.setLanguage(context, language);
|
eperson.setLanguage(context, language);
|
||||||
ePersonService.setPassword(eperson, pw);
|
ePersonService.setPassword(eperson, pw);
|
||||||
ePersonService.update(context, eperson);
|
ePersonService.update(context, eperson);
|
||||||
|
|
||||||
groupService.addMember(context, admins, eperson);
|
groupService.addMember(context, admins, eperson);
|
||||||
groupService.update(context, admins);
|
groupService.update(context, admins);
|
||||||
|
|
||||||
context.complete();
|
context.complete();
|
||||||
|
|
||||||
System.out.println("Administrator account created");
|
System.out.println("Administrator account created");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -71,7 +71,8 @@ public class MetadataImporter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* main method for reading user input from the command line
|
* main method for reading user input from the command line
|
||||||
* @param args arguments
|
*
|
||||||
|
* @param args the command line arguments given
|
||||||
* @throws ParseException if parse error
|
* @throws ParseException if parse error
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
@@ -83,9 +84,9 @@ public class MetadataImporter
|
|||||||
* @throws RegistryImportException if import fails
|
* @throws RegistryImportException if import fails
|
||||||
**/
|
**/
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
throws ParseException, SQLException, IOException, TransformerException,
|
throws ParseException, SQLException, IOException, TransformerException,
|
||||||
ParserConfigurationException, AuthorizeException, SAXException,
|
ParserConfigurationException, AuthorizeException, SAXException,
|
||||||
NonUniqueMetadataException, RegistryImportException
|
NonUniqueMetadataException, RegistryImportException
|
||||||
{
|
{
|
||||||
boolean forceUpdate = false;
|
boolean forceUpdate = false;
|
||||||
|
|
||||||
@@ -114,7 +115,7 @@ public class MetadataImporter
|
|||||||
/**
|
/**
|
||||||
* Load the data from the specified file path into the database
|
* Load the data from the specified file path into the database
|
||||||
*
|
*
|
||||||
* @param file the file path containing the source data
|
* @param file the file path containing the source data
|
||||||
* @param forceUpdate whether to force update
|
* @param forceUpdate whether to force update
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
@@ -126,8 +127,8 @@ public class MetadataImporter
|
|||||||
* @throws RegistryImportException if import fails
|
* @throws RegistryImportException if import fails
|
||||||
*/
|
*/
|
||||||
public static void loadRegistry(String file, boolean forceUpdate)
|
public static void loadRegistry(String file, boolean forceUpdate)
|
||||||
throws SQLException, IOException, TransformerException, ParserConfigurationException,
|
throws SQLException, IOException, TransformerException, ParserConfigurationException,
|
||||||
AuthorizeException, SAXException, NonUniqueMetadataException, RegistryImportException
|
AuthorizeException, SAXException, NonUniqueMetadataException, RegistryImportException
|
||||||
{
|
{
|
||||||
Context context = null;
|
Context context = null;
|
||||||
|
|
||||||
@@ -301,8 +302,8 @@ public class MetadataImporter
|
|||||||
public static void usage()
|
public static void usage()
|
||||||
{
|
{
|
||||||
String usage = "Use this class with the following option:\n" +
|
String usage = "Use this class with the following option:\n" +
|
||||||
" -f <xml source file> : specify which xml source file " +
|
" -f <xml source file> : specify which xml source file " +
|
||||||
"contains the DC fields to import.\n";
|
"contains the DC fields to import.\n";
|
||||||
System.out.println(usage);
|
System.out.println(usage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -54,8 +54,7 @@ public class RegistryLoader
|
|||||||
/**
|
/**
|
||||||
* For invoking via the command line
|
* For invoking via the command line
|
||||||
*
|
*
|
||||||
* @param argv
|
* @param argv the command line arguments given
|
||||||
* command-line arguments
|
|
||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
public static void main(String[] argv) throws Exception
|
public static void main(String[] argv) throws Exception
|
||||||
|
@@ -92,47 +92,48 @@ public class StructBuilder
|
|||||||
*
|
*
|
||||||
* The output file will contain exactly the same as the source xml document, but
|
* 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.
|
* with the handle for each imported item added as an attribute.
|
||||||
* @param argv commandline arguments
|
*
|
||||||
|
* @param argv the command line arguments given
|
||||||
* @throws Exception if an error occurs
|
* @throws Exception if an error occurs
|
||||||
*/
|
*/
|
||||||
public static void main(String[] argv)
|
public static void main(String[] argv)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
CommandLineParser parser = new PosixParser();
|
CommandLineParser parser = new PosixParser();
|
||||||
|
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
options.addOption( "f", "file", true, "file");
|
options.addOption( "f", "file", true, "file");
|
||||||
options.addOption( "e", "eperson", true, "eperson");
|
options.addOption( "e", "eperson", true, "eperson");
|
||||||
options.addOption("o", "output", true, "output");
|
options.addOption("o", "output", true, "output");
|
||||||
|
|
||||||
CommandLine line = parser.parse( options, argv );
|
CommandLine line = parser.parse( options, argv );
|
||||||
|
|
||||||
String file = null;
|
String file = null;
|
||||||
String eperson = null;
|
String eperson = null;
|
||||||
String output = null;
|
String output = null;
|
||||||
|
|
||||||
if (line.hasOption('f'))
|
if (line.hasOption('f'))
|
||||||
{
|
{
|
||||||
file = line.getOptionValue('f');
|
file = line.getOptionValue('f');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.hasOption('e'))
|
if (line.hasOption('e'))
|
||||||
{
|
{
|
||||||
eperson = line.getOptionValue('e');
|
eperson = line.getOptionValue('e');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.hasOption('o'))
|
if (line.hasOption('o'))
|
||||||
{
|
{
|
||||||
output = line.getOptionValue('o');
|
output = line.getOptionValue('o');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output == null || eperson == null || file == null)
|
if (output == null || eperson == null || file == null)
|
||||||
{
|
{
|
||||||
usage();
|
usage();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a context
|
// create a context
|
||||||
Context context = new Context();
|
Context context = new Context();
|
||||||
|
|
||||||
@@ -204,12 +205,12 @@ public class StructBuilder
|
|||||||
* Validate the XML document. This method does not return, but if validation
|
* Validate the XML document. This method does not return, but if validation
|
||||||
* fails it generates an error and ceases execution
|
* fails it generates an error and ceases execution
|
||||||
*
|
*
|
||||||
* @param document the XML document object
|
* @param document the XML document object
|
||||||
* @throws TransformerException if transformer error
|
* @throws TransformerException if transformer error
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static void validate(org.w3c.dom.Document document)
|
private static void validate(org.w3c.dom.Document document)
|
||||||
throws TransformerException
|
throws TransformerException
|
||||||
{
|
{
|
||||||
StringBuffer err = new StringBuffer();
|
StringBuffer err = new StringBuffer();
|
||||||
boolean trip = false;
|
boolean trip = false;
|
||||||
@@ -245,13 +246,13 @@ public class StructBuilder
|
|||||||
*
|
*
|
||||||
* @param communities the NodeList of communities to validate
|
* @param communities the NodeList of communities to validate
|
||||||
* @param level the level in the XML document that we are at, for the purposes
|
* @param level the level in the XML document that we are at, for the purposes
|
||||||
* of error reporting
|
* of error reporting
|
||||||
*
|
*
|
||||||
* @return the errors that need to be generated by the calling method, or null if
|
* @return the errors that need to be generated by the calling method, or null if
|
||||||
* no errors.
|
* no errors.
|
||||||
*/
|
*/
|
||||||
private static String validateCommunities(NodeList communities, int level)
|
private static String validateCommunities(NodeList communities, int level)
|
||||||
throws TransformerException
|
throws TransformerException
|
||||||
{
|
{
|
||||||
StringBuffer err = new StringBuffer();
|
StringBuffer err = new StringBuffer();
|
||||||
boolean trip = false;
|
boolean trip = false;
|
||||||
@@ -260,32 +261,32 @@ public class StructBuilder
|
|||||||
for (int i = 0; i < communities.getLength(); i++)
|
for (int i = 0; i < communities.getLength(); i++)
|
||||||
{
|
{
|
||||||
Node n = communities.item(i);
|
Node n = communities.item(i);
|
||||||
NodeList name = XPathAPI.selectNodeList(n, "name");
|
NodeList name = XPathAPI.selectNodeList(n, "name");
|
||||||
if (name.getLength() != 1)
|
if (name.getLength() != 1)
|
||||||
{
|
{
|
||||||
String pos = Integer.toString(i + 1);
|
String pos = Integer.toString(i + 1);
|
||||||
err.append("-The level " + level + " community in position " + pos);
|
err.append("-The level " + level + " community in position " + pos);
|
||||||
err.append(" does not contain exactly one name field\n");
|
err.append(" does not contain exactly one name field\n");
|
||||||
trip = true;
|
trip = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate sub communities
|
// validate sub communities
|
||||||
NodeList subCommunities = XPathAPI.selectNodeList(n, "community");
|
NodeList subCommunities = XPathAPI.selectNodeList(n, "community");
|
||||||
String comErrs = validateCommunities(subCommunities, level + 1);
|
String comErrs = validateCommunities(subCommunities, level + 1);
|
||||||
if (comErrs != null)
|
if (comErrs != null)
|
||||||
{
|
{
|
||||||
err.append(comErrs);
|
err.append(comErrs);
|
||||||
trip = true;
|
trip = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate collections
|
// validate collections
|
||||||
NodeList collections = XPathAPI.selectNodeList(n, "collection");
|
NodeList collections = XPathAPI.selectNodeList(n, "collection");
|
||||||
String colErrs = validateCollections(collections, level + 1);
|
String colErrs = validateCollections(collections, level + 1);
|
||||||
if (colErrs != null)
|
if (colErrs != null)
|
||||||
{
|
{
|
||||||
err.append(colErrs);
|
err.append(colErrs);
|
||||||
trip = true;
|
trip = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trip)
|
if (trip)
|
||||||
@@ -306,7 +307,7 @@ public class StructBuilder
|
|||||||
* @return the errors to be generated by the calling method, or null if none
|
* @return the errors to be generated by the calling method, or null if none
|
||||||
*/
|
*/
|
||||||
private static String validateCollections(NodeList collections, int level)
|
private static String validateCollections(NodeList collections, int level)
|
||||||
throws TransformerException
|
throws TransformerException
|
||||||
{
|
{
|
||||||
StringBuffer err = new StringBuffer();
|
StringBuffer err = new StringBuffer();
|
||||||
boolean trip = false;
|
boolean trip = false;
|
||||||
@@ -315,14 +316,14 @@ public class StructBuilder
|
|||||||
for (int i = 0; i < collections.getLength(); i++)
|
for (int i = 0; i < collections.getLength(); i++)
|
||||||
{
|
{
|
||||||
Node n = collections.item(i);
|
Node n = collections.item(i);
|
||||||
NodeList name = XPathAPI.selectNodeList(n, "name");
|
NodeList name = XPathAPI.selectNodeList(n, "name");
|
||||||
if (name.getLength() != 1)
|
if (name.getLength() != 1)
|
||||||
{
|
{
|
||||||
String pos = Integer.toString(i + 1);
|
String pos = Integer.toString(i + 1);
|
||||||
err.append("-The level " + level + " collection in position " + pos);
|
err.append("-The level " + level + " collection in position " + pos);
|
||||||
err.append(" does not contain exactly one name field\n");
|
err.append(" does not contain exactly one name field\n");
|
||||||
trip = true;
|
trip = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trip)
|
if (trip)
|
||||||
@@ -342,7 +343,7 @@ public class StructBuilder
|
|||||||
* @return the DOM representation of the XML file
|
* @return the DOM representation of the XML file
|
||||||
*/
|
*/
|
||||||
private static org.w3c.dom.Document loadXML(String filename)
|
private static org.w3c.dom.Document loadXML(String filename)
|
||||||
throws IOException, ParserConfigurationException, SAXException
|
throws IOException, ParserConfigurationException, SAXException
|
||||||
{
|
{
|
||||||
DocumentBuilder builder = DocumentBuilderFactory.newInstance()
|
DocumentBuilder builder = DocumentBuilderFactory.newInstance()
|
||||||
.newDocumentBuilder();
|
.newDocumentBuilder();
|
||||||
@@ -385,10 +386,10 @@ public class StructBuilder
|
|||||||
* @param parent the parent community of the nodelist of communities to create
|
* @param parent the parent community of the nodelist of communities to create
|
||||||
*
|
*
|
||||||
* @return an element array containing additional information regarding the
|
* @return an element array containing additional information regarding the
|
||||||
* created communities (e.g. the handles they have been assigned)
|
* created communities (e.g. the handles they have been assigned)
|
||||||
*/
|
*/
|
||||||
private static Element[] handleCommunities(Context context, NodeList communities, Community parent)
|
private static Element[] handleCommunities(Context context, NodeList communities, Community parent)
|
||||||
throws TransformerException, SQLException, Exception
|
throws TransformerException, SQLException, Exception
|
||||||
{
|
{
|
||||||
Element[] elements = new Element[communities.getLength()];
|
Element[] elements = new Element[communities.getLength()];
|
||||||
|
|
||||||
@@ -506,10 +507,10 @@ public class StructBuilder
|
|||||||
* @param parent the parent community to whom the collections belong
|
* @param parent the parent community to whom the collections belong
|
||||||
*
|
*
|
||||||
* @return an Element array containing additional information about the
|
* @return an Element array containing additional information about the
|
||||||
* created collections (e.g. the handle)
|
* created collections (e.g. the handle)
|
||||||
*/
|
*/
|
||||||
private static Element[] handleCollections(Context context, NodeList collections, Community parent)
|
private static Element[] handleCollections(Context context, NodeList collections, Community parent)
|
||||||
throws TransformerException, SQLException, AuthorizeException, IOException, Exception
|
throws TransformerException, SQLException, AuthorizeException, IOException, Exception
|
||||||
{
|
{
|
||||||
Element[] elements = new Element[collections.getLength()];
|
Element[] elements = new Element[collections.getLength()];
|
||||||
|
|
||||||
|
@@ -53,25 +53,25 @@ public final class ChecksumChecker
|
|||||||
/**
|
/**
|
||||||
* Command line access to the checksum package.
|
* Command line access to the checksum package.
|
||||||
*
|
*
|
||||||
* @param args
|
* <dl>
|
||||||
* <dl>
|
* <dt>-h</dt>
|
||||||
* <dt>-h</dt>
|
* <dd>Print help on command line options</dd>
|
||||||
* <dd>Print help on command line options</dd>
|
* <dt>-l</dt>
|
||||||
* <dt>-l</dt>
|
* <dd>loop through bitstreams once</dd>
|
||||||
* <dd>loop through bitstreams once</dd>
|
* <dt>-L</dt>
|
||||||
* <dt>-L</dt>
|
* <dd>loop continuously through bitstreams</dd>
|
||||||
* <dd>loop continuously through bitstreams</dd>
|
* <dt>-d</dt>
|
||||||
* <dt>-d</dt>
|
* <dd>specify duration of process run</dd>
|
||||||
* <dd>specify duration of process run</dd>
|
* <dt>-b</dt>
|
||||||
* <dt>-b</dt>
|
* <dd>specify bitstream IDs</dd>
|
||||||
* <dd>specify bitstream IDs</dd>
|
* <dt>-a [handle_id]</dt>
|
||||||
* <dt>-a [handle_id]</dt>
|
* <dd>check anything by handle</dd>
|
||||||
* <dd>check anything by handle</dd>
|
* <dt>-e</dt>
|
||||||
* <dt>-e</dt>
|
* <dd>Report only errors in the logs</dd>
|
||||||
* <dd>Report only errors in the logs</dd>
|
* <dt>-p</dt>
|
||||||
* <dt>-p</dt>
|
* <dd>Don't prune results before running checker</dd>
|
||||||
* <dd>Don't prune results before running checker</dd>
|
* </dl>
|
||||||
* </dl>
|
* @param args the command line arguments given
|
||||||
* @throws SQLException if error
|
* @throws SQLException if error
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws SQLException {
|
public static void main(String[] args) throws SQLException {
|
||||||
@@ -84,7 +84,7 @@ public final class ChecksumChecker
|
|||||||
|
|
||||||
options.addOption("l", "looping", false, "Loop once through bitstreams");
|
options.addOption("l", "looping", false, "Loop once through bitstreams");
|
||||||
options.addOption("L", "continuous", false,
|
options.addOption("L", "continuous", false,
|
||||||
"Loop continuously through bitstreams");
|
"Loop continuously through bitstreams");
|
||||||
options.addOption("h", "help", false, "Help");
|
options.addOption("h", "help", false, "Help");
|
||||||
options.addOption("d", "duration", true, "Checking duration");
|
options.addOption("d", "duration", true, "Checking duration");
|
||||||
options.addOption("c", "count", true, "Check count");
|
options.addOption("c", "count", true, "Check count");
|
||||||
@@ -92,19 +92,18 @@ public final class ChecksumChecker
|
|||||||
options.addOption("v", "verbose", false, "Report all processing");
|
options.addOption("v", "verbose", false, "Report all processing");
|
||||||
|
|
||||||
OptionBuilder.withArgName("bitstream-ids").hasArgs().withDescription(
|
OptionBuilder.withArgName("bitstream-ids").hasArgs().withDescription(
|
||||||
"Space separated list of bitstream ids");
|
"Space separated list of bitstream ids");
|
||||||
Option useBitstreamIds = OptionBuilder.create('b');
|
Option useBitstreamIds = OptionBuilder.create('b');
|
||||||
|
|
||||||
options.addOption(useBitstreamIds);
|
options.addOption(useBitstreamIds);
|
||||||
|
|
||||||
options.addOption("p", "prune", false, "Prune configuration file");
|
options.addOption("p", "prune", false, "Prune configuration file");
|
||||||
options
|
options.addOption(OptionBuilder
|
||||||
.addOption(OptionBuilder
|
.withArgName("prune")
|
||||||
.withArgName("prune")
|
.hasOptionalArgs(1)
|
||||||
.hasOptionalArgs(1)
|
.withDescription(
|
||||||
.withDescription(
|
"Prune old results (optionally using specified properties file for configuration)")
|
||||||
"Prune old results (optionally using specified properties file for configuration)")
|
.create('p'));
|
||||||
.create('p'));
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -233,7 +232,7 @@ public final class ChecksumChecker
|
|||||||
context.complete();
|
context.complete();
|
||||||
context = null;
|
context = null;
|
||||||
} finally {
|
} finally {
|
||||||
if(context != null){
|
if (context != null) {
|
||||||
context.abort();
|
context.abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,19 +248,15 @@ public final class ChecksumChecker
|
|||||||
HelpFormatter myhelp = new HelpFormatter();
|
HelpFormatter myhelp = new HelpFormatter();
|
||||||
|
|
||||||
myhelp.printHelp("Checksum Checker\n", options);
|
myhelp.printHelp("Checksum Checker\n", options);
|
||||||
System.out
|
System.out.println("\nSpecify a duration for checker process, using s(seconds),"
|
||||||
.println("\nSpecify a duration for checker process, using s(seconds),"
|
+ "m(minutes), or h(hours): ChecksumChecker -d 30s"
|
||||||
+ "m(minutes), or h(hours): ChecksumChecker -d 30s"
|
+ " OR ChecksumChecker -d 30m"
|
||||||
+ " OR ChecksumChecker -d 30m"
|
+ " OR ChecksumChecker -d 2h");
|
||||||
+ " OR ChecksumChecker -d 2h");
|
System.out.println("\nSpecify bitstream IDs: ChecksumChecker -b 13 15 17 20");
|
||||||
System.out
|
|
||||||
.println("\nSpecify bitstream IDs: ChecksumChecker -b 13 15 17 20");
|
|
||||||
System.out.println("\nLoop once through all bitstreams: "
|
System.out.println("\nLoop once through all bitstreams: "
|
||||||
+ "ChecksumChecker -l");
|
+ "ChecksumChecker -l");
|
||||||
System.out
|
System.out.println("\nLoop continuously through all bitstreams: ChecksumChecker -L");
|
||||||
.println("\nLoop continuously through all bitstreams: ChecksumChecker -L");
|
System.out.println("\nCheck a defined number of bitstreams: ChecksumChecker -c 10");
|
||||||
System.out
|
|
||||||
.println("\nCheck a defined number of bitstreams: ChecksumChecker -c 10");
|
|
||||||
System.out.println("\nReport all processing (verbose)(default reports only errors): ChecksumChecker -v");
|
System.out.println("\nReport all processing (verbose)(default reports only errors): ChecksumChecker -v");
|
||||||
System.out.println("\nDefault (no arguments) is equivalent to '-c 1'");
|
System.out.println("\nDefault (no arguments) is equivalent to '-c 1'");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
|
@@ -67,12 +67,18 @@ public class Harvest
|
|||||||
options.addOption("P", "purge", false, "purge all harvestable collections");
|
options.addOption("P", "purge", false, "purge all harvestable collections");
|
||||||
|
|
||||||
|
|
||||||
options.addOption("e", "eperson", true, "eperson");
|
options.addOption("e", "eperson", true,
|
||||||
options.addOption("c", "collection", true, "harvesting collection (handle or id)");
|
"eperson");
|
||||||
options.addOption("t", "type", true, "type of harvesting (0 for none)");
|
options.addOption("c", "collection", true,
|
||||||
options.addOption("a", "address", true, "address of the OAI-PMH server");
|
"harvesting collection (handle or id)");
|
||||||
options.addOption("i", "oai_set_id", true, "id of the PMH set representing the harvested collection");
|
options.addOption("t", "type", true,
|
||||||
options.addOption("m", "metadata_format", true, "the name of the desired metadata format for harvesting, resolved to namespace and crosswalk in dspace.cfg");
|
"type of harvesting (0 for none)");
|
||||||
|
options.addOption("a", "address", true,
|
||||||
|
"address of the OAI-PMH server");
|
||||||
|
options.addOption("i", "oai_set_id", true,
|
||||||
|
"id of the PMH set representing the harvested collection");
|
||||||
|
options.addOption("m", "metadata_format", true,
|
||||||
|
"the name of the desired metadata format for harvesting, resolved to namespace and crosswalk in dspace.cfg");
|
||||||
|
|
||||||
options.addOption("h", "help", false, "help");
|
options.addOption("h", "help", false, "help");
|
||||||
|
|
||||||
@@ -90,22 +96,14 @@ public class Harvest
|
|||||||
{
|
{
|
||||||
HelpFormatter myhelp = new HelpFormatter();
|
HelpFormatter myhelp = new HelpFormatter();
|
||||||
myhelp.printHelp("Harvest\n", options);
|
myhelp.printHelp("Harvest\n", options);
|
||||||
System.out
|
System.out.println("\nPING OAI server: Harvest -g -s oai_source -i oai_set_id");
|
||||||
.println("\nPING OAI server: Harvest -g -s oai_source -i oai_set_id");
|
System.out.println("RUNONCE harvest with arbitrary options: Harvest -o -e eperson -c collection -t harvest_type -a oai_source -i oai_set_id -m metadata_format");
|
||||||
System.out
|
System.out.println("SETUP a collection for harvesting: Harvest -s -c collection -t harvest_type -a oai_source -i oai_set_id -m metadata_format");
|
||||||
.println("RUNONCE harvest with arbitrary options: Harvest -o -e eperson -c collection -t harvest_type -a oai_source -i oai_set_id -m metadata_format");
|
System.out.println("RUN harvest once: Harvest -r -e eperson -c collection");
|
||||||
System.out
|
System.out.println("START harvest scheduler: Harvest -S");
|
||||||
.println("SETUP a collection for harvesting: Harvest -s -c collection -t harvest_type -a oai_source -i oai_set_id -m metadata_format");
|
System.out.println("RESET all harvest status: Harvest -R");
|
||||||
System.out
|
System.out.println("PURGE a collection of items and settings: Harvest -p -e eperson -c collection");
|
||||||
.println("RUN harvest once: Harvest -r -e eperson -c collection");
|
System.out.println("PURGE all harvestable collections: Harvest -P -e eperson");
|
||||||
System.out
|
|
||||||
.println("START harvest scheduler: Harvest -S");
|
|
||||||
System.out
|
|
||||||
.println("RESET all harvest status: Harvest -R");
|
|
||||||
System.out
|
|
||||||
.println("PURGE a collection of items and settings: Harvest -p -e eperson -c collection");
|
|
||||||
System.out
|
|
||||||
.println("PURGE all harvestable collections: Harvest -P -e eperson");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -147,7 +145,7 @@ public class Harvest
|
|||||||
if (line.hasOption('t')) {
|
if (line.hasOption('t')) {
|
||||||
harvestType = Integer.parseInt(line.getOptionValue('t'));
|
harvestType = Integer.parseInt(line.getOptionValue('t'));
|
||||||
} else {
|
} else {
|
||||||
harvestType = 0;
|
harvestType = 0;
|
||||||
}
|
}
|
||||||
if (line.hasOption('a')) {
|
if (line.hasOption('a')) {
|
||||||
oaiSource = line.getOptionValue('a');
|
oaiSource = line.getOptionValue('a');
|
||||||
@@ -188,31 +186,31 @@ public class Harvest
|
|||||||
// start the harvest loop
|
// start the harvest loop
|
||||||
else if ("start".equals(command))
|
else if ("start".equals(command))
|
||||||
{
|
{
|
||||||
startHarvester();
|
startHarvester();
|
||||||
}
|
}
|
||||||
// reset harvesting status
|
// reset harvesting status
|
||||||
else if ("reset".equals(command))
|
else if ("reset".equals(command))
|
||||||
{
|
{
|
||||||
resetHarvesting();
|
resetHarvesting();
|
||||||
}
|
}
|
||||||
// purge all collections that are set up for harvesting (obviously for testing purposes only)
|
// purge all collections that are set up for harvesting (obviously for testing purposes only)
|
||||||
else if ("purgeAll".equals(command))
|
else if ("purgeAll".equals(command))
|
||||||
{
|
{
|
||||||
if (eperson == null)
|
if (eperson == null)
|
||||||
{
|
{
|
||||||
System.out
|
System.out
|
||||||
.println("Error - an eperson must be provided");
|
.println("Error - an eperson must be provided");
|
||||||
System.out.println(" (run with -h flag for details)");
|
System.out.println(" (run with -h flag for details)");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<HarvestedCollection> harvestedCollections = harvestedCollectionService.findAll(context);
|
List<HarvestedCollection> harvestedCollections = harvestedCollectionService.findAll(context);
|
||||||
for (HarvestedCollection harvestedCollection : harvestedCollections)
|
for (HarvestedCollection harvestedCollection : harvestedCollections)
|
||||||
{
|
{
|
||||||
System.out.println("Purging the following collections (deleting items and resetting harvest status): " + harvestedCollection.getCollection().getID().toString());
|
System.out.println("Purging the following collections (deleting items and resetting harvest status): " + harvestedCollection.getCollection().getID().toString());
|
||||||
harvester.purgeCollection(harvestedCollection.getCollection().getID().toString(), eperson);
|
harvester.purgeCollection(harvestedCollection.getCollection().getID().toString(), eperson);
|
||||||
}
|
}
|
||||||
context.complete();
|
context.complete();
|
||||||
}
|
}
|
||||||
// Delete all items in a collection. Useful for testing fresh harvests.
|
// Delete all items in a collection. Useful for testing fresh harvests.
|
||||||
else if ("purge".equals(command))
|
else if ("purge".equals(command))
|
||||||
@@ -247,9 +245,9 @@ public class Harvest
|
|||||||
}
|
}
|
||||||
if (metadataKey == null)
|
if (metadataKey == null)
|
||||||
{
|
{
|
||||||
System.out.println("Error - a metadata key (commonly the prefix) must be specified for this collection");
|
System.out.println("Error - a metadata key (commonly the prefix) must be specified for this collection");
|
||||||
System.out.println(" (run with -h flag for details)");
|
System.out.println(" (run with -h flag for details)");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
harvester.configureCollection(collection, harvestType, oaiSource, oaiSetID, metadataKey);
|
harvester.configureCollection(collection, harvestType, oaiSource, oaiSetID, metadataKey);
|
||||||
@@ -272,13 +270,13 @@ public class Harvest
|
|||||||
* the collection, if not, bail out.
|
* the collection, if not, bail out.
|
||||||
*/
|
*/
|
||||||
private Collection resolveCollection(String collectionID) {
|
private Collection resolveCollection(String collectionID) {
|
||||||
|
|
||||||
DSpaceObject dso;
|
DSpaceObject dso;
|
||||||
Collection targetCollection = null;
|
Collection targetCollection = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// is the ID a handle?
|
// is the ID a handle?
|
||||||
if (collectionID != null)
|
if (collectionID != null)
|
||||||
{
|
{
|
||||||
if (collectionID.indexOf('/') != -1)
|
if (collectionID.indexOf('/') != -1)
|
||||||
{
|
{
|
||||||
@@ -309,45 +307,45 @@ public class Harvest
|
|||||||
System.out.println("Cannot resolve " + collectionID + " to collection");
|
System.out.println("Cannot resolve " + collectionID + " to collection");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException se) {
|
catch (SQLException se) {
|
||||||
se.printStackTrace();
|
se.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return targetCollection;
|
return targetCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void configureCollection(String collectionID, int type, String oaiSource, String oaiSetId, String mdConfigId) {
|
private void configureCollection(String collectionID, int type, String oaiSource, String oaiSetId, String mdConfigId) {
|
||||||
System.out.println("Running: configure collection");
|
System.out.println("Running: configure collection");
|
||||||
|
|
||||||
Collection collection = resolveCollection(collectionID);
|
Collection collection = resolveCollection(collectionID);
|
||||||
System.out.println(collection.getID());
|
System.out.println(collection.getID());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
HarvestedCollection hc = harvestedCollectionService.find(context, collection);
|
HarvestedCollection hc = harvestedCollectionService.find(context, collection);
|
||||||
if (hc == null) {
|
if (hc == null) {
|
||||||
hc = harvestedCollectionService.create(context, collection);
|
hc = harvestedCollectionService.create(context, collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
hc.setHarvestParams(type, oaiSource, oaiSetId, mdConfigId);
|
hc.setHarvestParams(type, oaiSource, oaiSetId, mdConfigId);
|
||||||
hc.setHarvestStatus(HarvestedCollection.STATUS_READY);
|
hc.setHarvestStatus(HarvestedCollection.STATUS_READY);
|
||||||
harvestedCollectionService.update(context, hc);
|
harvestedCollectionService.update(context, hc);
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
context.complete();
|
context.complete();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
System.out.println("Changes could not be committed");
|
System.out.println("Changes could not be committed");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (context != null)
|
if (context != null)
|
||||||
{
|
{
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -358,49 +356,49 @@ public class Harvest
|
|||||||
* @param email
|
* @param email
|
||||||
*/
|
*/
|
||||||
private void purgeCollection(String collectionID, String email) {
|
private void purgeCollection(String collectionID, String email) {
|
||||||
System.out.println("Purging collection of all items and resetting last_harvested and harvest_message: " + collectionID);
|
System.out.println("Purging collection of all items and resetting last_harvested and harvest_message: " + collectionID);
|
||||||
Collection collection = resolveCollection(collectionID);
|
Collection collection = resolveCollection(collectionID);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
EPerson eperson = ePersonService.findByEmail(context, email);
|
EPerson eperson = ePersonService.findByEmail(context, email);
|
||||||
context.setCurrentUser(eperson);
|
context.setCurrentUser(eperson);
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||||
Iterator<Item> it = itemService.findByCollection(context, collection);
|
Iterator<Item> it = itemService.findByCollection(context, collection);
|
||||||
int i=0;
|
int i=0;
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
i++;
|
i++;
|
||||||
Item item = it.next();
|
Item item = it.next();
|
||||||
System.out.println("Deleting: " + item.getHandle());
|
System.out.println("Deleting: " + item.getHandle());
|
||||||
collectionService.removeItem(context, collection, item);
|
collectionService.removeItem(context, collection, item);
|
||||||
// Dispatch events every 50 items
|
// Dispatch events every 50 items
|
||||||
if (i%50 == 0) {
|
if (i%50 == 0) {
|
||||||
context.dispatchEvents();
|
context.dispatchEvents();
|
||||||
i=0;
|
i=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HarvestedCollection hc = harvestedCollectionService.find(context, collection);
|
HarvestedCollection hc = harvestedCollectionService.find(context, collection);
|
||||||
if (hc != null) {
|
if (hc != null) {
|
||||||
hc.setLastHarvested(null);
|
hc.setLastHarvested(null);
|
||||||
hc.setHarvestMessage("");
|
hc.setHarvestMessage("");
|
||||||
hc.setHarvestStatus(HarvestedCollection.STATUS_READY);
|
hc.setHarvestStatus(HarvestedCollection.STATUS_READY);
|
||||||
hc.setHarvestStartTime(null);
|
hc.setHarvestStartTime(null);
|
||||||
harvestedCollectionService.update(context, hc);
|
harvestedCollectionService.update(context, hc);
|
||||||
}
|
}
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
context.dispatchEvents();
|
context.dispatchEvents();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
System.out.println("Changes could not be committed");
|
System.out.println("Changes could not be committed");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -408,34 +406,34 @@ public class Harvest
|
|||||||
* Run a single harvest cycle on the specified collection under the authorization of the supplied EPerson
|
* Run a single harvest cycle on the specified collection under the authorization of the supplied EPerson
|
||||||
*/
|
*/
|
||||||
private void runHarvest(String collectionID, String email) {
|
private void runHarvest(String collectionID, String email) {
|
||||||
System.out.println("Running: a harvest cycle on " + collectionID);
|
System.out.println("Running: a harvest cycle on " + collectionID);
|
||||||
|
|
||||||
System.out.print("Initializing the harvester... ");
|
System.out.print("Initializing the harvester... ");
|
||||||
OAIHarvester harvester = null;
|
OAIHarvester harvester = null;
|
||||||
try {
|
try {
|
||||||
Collection collection = resolveCollection(collectionID);
|
Collection collection = resolveCollection(collectionID);
|
||||||
HarvestedCollection hc = harvestedCollectionService.find(context, collection);
|
HarvestedCollection hc = harvestedCollectionService.find(context, collection);
|
||||||
harvester = new OAIHarvester(context, collection, hc);
|
harvester = new OAIHarvester(context, collection, hc);
|
||||||
System.out.println("success. ");
|
System.out.println("success. ");
|
||||||
}
|
}
|
||||||
catch (HarvestingException hex) {
|
catch (HarvestingException hex) {
|
||||||
System.out.print("failed. ");
|
System.out.print("failed. ");
|
||||||
System.out.println(hex.getMessage());
|
System.out.println(hex.getMessage());
|
||||||
throw new IllegalStateException("Unable to harvest", hex);
|
throw new IllegalStateException("Unable to harvest", hex);
|
||||||
} catch (SQLException se) {
|
} catch (SQLException se) {
|
||||||
System.out.print("failed. ");
|
System.out.print("failed. ");
|
||||||
System.out.println(se.getMessage());
|
System.out.println(se.getMessage());
|
||||||
throw new IllegalStateException("Unable to access database", se);
|
throw new IllegalStateException("Unable to access database", se);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Harvest will not work for an anonymous user
|
// Harvest will not work for an anonymous user
|
||||||
EPerson eperson = ePersonService.findByEmail(context, email);
|
EPerson eperson = ePersonService.findByEmail(context, email);
|
||||||
System.out.println("Harvest started... ");
|
System.out.println("Harvest started... ");
|
||||||
context.setCurrentUser(eperson);
|
context.setCurrentUser(eperson);
|
||||||
harvester.runHarvest();
|
harvester.runHarvest();
|
||||||
context.complete();
|
context.complete();
|
||||||
}
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
throw new IllegalStateException("Failed to run harvester", e);
|
throw new IllegalStateException("Failed to run harvester", e);
|
||||||
}
|
}
|
||||||
@@ -453,10 +451,10 @@ public class Harvest
|
|||||||
* Resets harvest_status and harvest_start_time flags for all collections that have a row in the harvested_collections table
|
* Resets harvest_status and harvest_start_time flags for all collections that have a row in the harvested_collections table
|
||||||
*/
|
*/
|
||||||
private static void resetHarvesting() {
|
private static void resetHarvesting() {
|
||||||
System.out.print("Resetting harvest status flag on all collections... ");
|
System.out.print("Resetting harvest status flag on all collections... ");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<HarvestedCollection> harvestedCollections = harvestedCollectionService.findAll(context);
|
List<HarvestedCollection> harvestedCollections = harvestedCollectionService.findAll(context);
|
||||||
for (HarvestedCollection harvestedCollection : harvestedCollections)
|
for (HarvestedCollection harvestedCollection : harvestedCollections)
|
||||||
{
|
{
|
||||||
@@ -466,11 +464,11 @@ public class Harvest
|
|||||||
harvestedCollectionService.update(context, harvestedCollection);
|
harvestedCollectionService.update(context, harvestedCollection);
|
||||||
}
|
}
|
||||||
System.out.println("success. ");
|
System.out.println("success. ");
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
System.out.println("failed. ");
|
System.out.println("failed. ");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -483,10 +481,10 @@ public class Harvest
|
|||||||
System.out.print("Starting harvest loop... ");
|
System.out.print("Starting harvest loop... ");
|
||||||
HarvestServiceFactory.getInstance().getHarvestSchedulingService().startNewScheduler();
|
HarvestServiceFactory.getInstance().getHarvestSchedulingService().startNewScheduler();
|
||||||
System.out.println("running. ");
|
System.out.println("running. ");
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -16,38 +16,38 @@ import org.dspace.content.Bitstream;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class BitstreamFilterByFilename extends BitstreamFilter {
|
public class BitstreamFilterByFilename extends BitstreamFilter {
|
||||||
|
|
||||||
protected Pattern pattern;
|
protected Pattern pattern;
|
||||||
protected String filenameRegex;
|
protected String filenameRegex;
|
||||||
|
|
||||||
public BitstreamFilterByFilename()
|
public BitstreamFilterByFilename()
|
||||||
{
|
{
|
||||||
//empty
|
//empty
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests bitstream by matching the regular expression in the
|
* Tests bitstream by matching the regular expression in the
|
||||||
* properties against the bitstream name
|
* properties against the bitstream name
|
||||||
*
|
*
|
||||||
* @param bitstream Bitstream
|
* @param bitstream Bitstream
|
||||||
* @return whether bitstream name matches the regular expression
|
* @return whether bitstream name matches the regular expression
|
||||||
* @exception BitstreamFilterException if filter error
|
* @throws BitstreamFilterException if filter error
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(Bitstream bitstream) throws BitstreamFilterException
|
public boolean accept(Bitstream bitstream) throws BitstreamFilterException
|
||||||
{
|
{
|
||||||
if (filenameRegex == null)
|
if (filenameRegex == null)
|
||||||
{
|
{
|
||||||
filenameRegex = props.getProperty("filename");
|
filenameRegex = props.getProperty("filename");
|
||||||
if (filenameRegex == null)
|
if (filenameRegex == null)
|
||||||
{
|
{
|
||||||
throw new BitstreamFilterException("BitstreamFilter property 'filename' not found.");
|
throw new BitstreamFilterException("BitstreamFilter property 'filename' not found.");
|
||||||
}
|
}
|
||||||
pattern = Pattern.compile(filenameRegex);
|
pattern = Pattern.compile(filenameRegex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Matcher m = pattern.matcher(bitstream.getName());
|
Matcher m = pattern.matcher(bitstream.getName());
|
||||||
return m.matches();
|
return m.matches();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,7 @@ import org.dspace.eperson.service.EPersonService;
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Provides some batch editing capabilities for items in DSpace:
|
* Provides some batch editing capabilities for items in DSpace:
|
||||||
* Metadata fields - Add, Delete
|
* Metadata fields - Add, Delete
|
||||||
* Bitstreams - Add, Delete
|
* Bitstreams - Add, Delete
|
||||||
*
|
*
|
||||||
* The design has been for compatibility with ItemImporter
|
* The design has been for compatibility with ItemImporter
|
||||||
@@ -62,33 +62,33 @@ import org.dspace.eperson.service.EPersonService;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ItemUpdate {
|
public class ItemUpdate {
|
||||||
|
|
||||||
public static final String SUPPRESS_UNDO_FILENAME = "suppress_undo";
|
public static final String SUPPRESS_UNDO_FILENAME = "suppress_undo";
|
||||||
|
|
||||||
public static final String CONTENTS_FILE = "contents";
|
public static final String CONTENTS_FILE = "contents";
|
||||||
public static final String DELETE_CONTENTS_FILE = "delete_contents";
|
public static final String DELETE_CONTENTS_FILE = "delete_contents";
|
||||||
|
|
||||||
public static String HANDLE_PREFIX = null;
|
public static String HANDLE_PREFIX = null;
|
||||||
public static final Map<String, String> filterAliases = new HashMap<String, String>();
|
public static final Map<String, String> filterAliases = new HashMap<String, String>();
|
||||||
|
|
||||||
public static boolean verbose = false;
|
public static boolean verbose = false;
|
||||||
|
|
||||||
protected static final EPersonService epersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
protected static final EPersonService epersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||||
protected static final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
protected static final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
filterAliases.put("ORIGINAL", "org.dspace.app.itemupdate.OriginalBitstreamFilter");
|
filterAliases.put("ORIGINAL", "org.dspace.app.itemupdate.OriginalBitstreamFilter");
|
||||||
filterAliases.put("ORIGINAL_AND_DERIVATIVES", "org.dspace.app.itemupdate.OriginalWithDerivativesBitstreamFilter");
|
filterAliases.put("ORIGINAL_AND_DERIVATIVES", "org.dspace.app.itemupdate.OriginalWithDerivativesBitstreamFilter");
|
||||||
filterAliases.put("TEXT", "org.dspace.app.itemupdate.DerivativeTextBitstreamFilter");
|
filterAliases.put("TEXT", "org.dspace.app.itemupdate.DerivativeTextBitstreamFilter");
|
||||||
filterAliases.put("THUMBNAIL", "org.dspace.app.itemupdate.ThumbnailBitstreamFilter");
|
filterAliases.put("THUMBNAIL", "org.dspace.app.itemupdate.ThumbnailBitstreamFilter");
|
||||||
}
|
}
|
||||||
|
|
||||||
// File listing filter to check for folders
|
// File listing filter to check for folders
|
||||||
static FilenameFilter directoryFilter = new FilenameFilter()
|
static FilenameFilter directoryFilter = new FilenameFilter()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File dir, String n)
|
public boolean accept(File dir, String n)
|
||||||
{
|
{
|
||||||
File f = new File(dir.getAbsolutePath() + File.separatorChar + n);
|
File f = new File(dir.getAbsolutePath() + File.separatorChar + n);
|
||||||
return f.isDirectory();
|
return f.isDirectory();
|
||||||
@@ -99,7 +99,7 @@ public class ItemUpdate {
|
|||||||
static FilenameFilter fileFilter = new FilenameFilter()
|
static FilenameFilter fileFilter = new FilenameFilter()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(File dir, String n)
|
public boolean accept(File dir, String n)
|
||||||
{
|
{
|
||||||
File f = new File(dir.getAbsolutePath() + File.separatorChar + n);
|
File f = new File(dir.getAbsolutePath() + File.separatorChar + n);
|
||||||
return (f.isFile());
|
return (f.isFile());
|
||||||
@@ -113,7 +113,7 @@ public class ItemUpdate {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param argv commandline args
|
* @param argv the command line arguments given
|
||||||
*/
|
*/
|
||||||
public static void main(String[] argv)
|
public static void main(String[] argv)
|
||||||
{
|
{
|
||||||
@@ -122,11 +122,11 @@ public class ItemUpdate {
|
|||||||
|
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
//processing basis for determining items
|
//processing basis for determining items
|
||||||
//item-specific changes with metadata in source directory with dublin_core.xml files
|
//item-specific changes with metadata in source directory with dublin_core.xml files
|
||||||
options.addOption("s", "source", true, "root directory of source dspace archive ");
|
options.addOption("s", "source", true, "root directory of source dspace archive ");
|
||||||
|
|
||||||
//actions on items
|
//actions on items
|
||||||
options.addOption("a", "addmetadata", true, "add metadata specified for each item; multiples separated by semicolon ';'");
|
options.addOption("a", "addmetadata", true, "add metadata specified for each item; multiples separated by semicolon ';'");
|
||||||
options.addOption("d", "deletemetadata", true, "delete metadata specified for each item");
|
options.addOption("d", "deletemetadata", true, "delete metadata specified for each item");
|
||||||
|
|
||||||
@@ -138,13 +138,13 @@ public class ItemUpdate {
|
|||||||
delBitstreamOption.setArgName("BitstreamFilter");
|
delBitstreamOption.setArgName("BitstreamFilter");
|
||||||
options.addOption(delBitstreamOption);
|
options.addOption(delBitstreamOption);
|
||||||
|
|
||||||
//other params
|
//other params
|
||||||
options.addOption("e", "eperson", true, "email of eperson doing the update");
|
options.addOption("e", "eperson", true, "email of eperson doing the update");
|
||||||
options.addOption("i", "itemfield", true, "optional metadata field that containing item identifier; default is dc.identifier.uri");
|
options.addOption("i", "itemfield", true, "optional metadata field that containing item identifier; default is dc.identifier.uri");
|
||||||
options.addOption("F", "filter-properties", true, "filter class name; only for deleting bitstream");
|
options.addOption("F", "filter-properties", true, "filter class name; only for deleting bitstream");
|
||||||
options.addOption("v", "verbose", false, "verbose logging");
|
options.addOption("v", "verbose", false, "verbose logging");
|
||||||
|
|
||||||
//special run states
|
//special run states
|
||||||
options.addOption("t", "test", false, "test run - do not actually import items");
|
options.addOption("t", "test", false, "test run - do not actually import items");
|
||||||
options.addOption("P", "provenance", false, "suppress altering provenance field for bitstream changes");
|
options.addOption("P", "provenance", false, "suppress altering provenance field for bitstream changes");
|
||||||
options.addOption("h", "help", false, "help");
|
options.addOption("h", "help", false, "help");
|
||||||
@@ -156,216 +156,216 @@ public class ItemUpdate {
|
|||||||
String metadataIndexName = null;
|
String metadataIndexName = null;
|
||||||
|
|
||||||
Context context = null;
|
Context context = null;
|
||||||
ItemUpdate iu = new ItemUpdate();
|
ItemUpdate iu = new ItemUpdate();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CommandLine line = parser.parse(options, argv);
|
CommandLine line = parser.parse(options, argv);
|
||||||
|
|
||||||
if (line.hasOption('h'))
|
if (line.hasOption('h'))
|
||||||
{
|
{
|
||||||
HelpFormatter myhelp = new HelpFormatter();
|
HelpFormatter myhelp = new HelpFormatter();
|
||||||
myhelp.printHelp("ItemUpdate", options);
|
myhelp.printHelp("ItemUpdate", options);
|
||||||
pr("");
|
pr("");
|
||||||
pr("Examples:");
|
pr("Examples:");
|
||||||
pr(" adding metadata: ItemUpdate -e jsmith@mit.edu -s sourcedir -a dc.contributor -a dc.subject ");
|
pr(" adding metadata: ItemUpdate -e jsmith@mit.edu -s sourcedir -a dc.contributor -a dc.subject ");
|
||||||
pr(" deleting metadata: ItemUpdate -e jsmith@mit.edu -s sourcedir -d dc.description.other");
|
pr(" deleting metadata: ItemUpdate -e jsmith@mit.edu -s sourcedir -d dc.description.other");
|
||||||
pr(" adding bitstreams: ItemUpdate -e jsmith@mit.edu -s sourcedir -A -i dc.identifier");
|
pr(" adding bitstreams: ItemUpdate -e jsmith@mit.edu -s sourcedir -A -i dc.identifier");
|
||||||
pr(" deleting bitstreams: ItemUpdate -e jsmith@mit.edu -s sourcedir -D ORIGINAL ");
|
pr(" deleting bitstreams: ItemUpdate -e jsmith@mit.edu -s sourcedir -D ORIGINAL ");
|
||||||
pr("");
|
pr("");
|
||||||
|
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.hasOption('v'))
|
if (line.hasOption('v'))
|
||||||
{
|
{
|
||||||
verbose = true;
|
verbose = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (line.hasOption('P'))
|
if (line.hasOption('P'))
|
||||||
{
|
{
|
||||||
alterProvenance = false;
|
alterProvenance = false;
|
||||||
pr("Suppressing changes to Provenance field option");
|
pr("Suppressing changes to Provenance field option");
|
||||||
}
|
}
|
||||||
|
|
||||||
iu.eperson = line.getOptionValue('e'); // db ID or email
|
iu.eperson = line.getOptionValue('e'); // db ID or email
|
||||||
|
|
||||||
if (!line.hasOption('s')) // item specific changes from archive dir
|
if (!line.hasOption('s')) // item specific changes from archive dir
|
||||||
{
|
{
|
||||||
pr("Missing source archive option");
|
pr("Missing source archive option");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
String sourcedir = line.getOptionValue('s');
|
String sourcedir = line.getOptionValue('s');
|
||||||
|
|
||||||
if (line.hasOption('t')) //test
|
if (line.hasOption('t')) //test
|
||||||
{
|
{
|
||||||
isTest = true;
|
isTest = true;
|
||||||
pr("**Test Run** - not actually updating items.");
|
pr("**Test Run** - not actually updating items.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.hasOption('i'))
|
if (line.hasOption('i'))
|
||||||
{
|
{
|
||||||
itemField = line.getOptionValue('i');
|
itemField = line.getOptionValue('i');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.hasOption('d'))
|
if (line.hasOption('d'))
|
||||||
{
|
{
|
||||||
String[] targetFields = line.getOptionValues('d');
|
String[] targetFields = line.getOptionValues('d');
|
||||||
|
|
||||||
DeleteMetadataAction delMetadataAction = (DeleteMetadataAction) iu.actionMgr.getUpdateAction(DeleteMetadataAction.class);
|
DeleteMetadataAction delMetadataAction = (DeleteMetadataAction) iu.actionMgr.getUpdateAction(DeleteMetadataAction.class);
|
||||||
delMetadataAction.addTargetFields(targetFields);
|
delMetadataAction.addTargetFields(targetFields);
|
||||||
|
|
||||||
//undo is an add
|
//undo is an add
|
||||||
for (String field : targetFields)
|
for (String field : targetFields)
|
||||||
{
|
{
|
||||||
iu.undoActionList.add(" -a " + field + " ");
|
iu.undoActionList.add(" -a " + field + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
pr("Delete metadata for fields: ");
|
pr("Delete metadata for fields: ");
|
||||||
for (String s : targetFields)
|
for (String s : targetFields)
|
||||||
{
|
{
|
||||||
pr(" " + s);
|
pr(" " + s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.hasOption('a'))
|
if (line.hasOption('a'))
|
||||||
{
|
{
|
||||||
String[] targetFields = line.getOptionValues('a');
|
String[] targetFields = line.getOptionValues('a');
|
||||||
|
|
||||||
AddMetadataAction addMetadataAction = (AddMetadataAction) iu.actionMgr.getUpdateAction(AddMetadataAction.class);
|
AddMetadataAction addMetadataAction = (AddMetadataAction) iu.actionMgr.getUpdateAction(AddMetadataAction.class);
|
||||||
addMetadataAction.addTargetFields(targetFields);
|
addMetadataAction.addTargetFields(targetFields);
|
||||||
|
|
||||||
//undo is a delete followed by an add of a replace record for target fields
|
//undo is a delete followed by an add of a replace record for target fields
|
||||||
for (String field : targetFields)
|
for (String field : targetFields)
|
||||||
{
|
{
|
||||||
iu.undoActionList.add(" -d " + field + " ");
|
iu.undoActionList.add(" -d " + field + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String field : targetFields)
|
for (String field : targetFields)
|
||||||
{
|
{
|
||||||
iu.undoActionList.add(" -a " + field + " ");
|
iu.undoActionList.add(" -a " + field + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
pr("Add metadata for fields: ");
|
pr("Add metadata for fields: ");
|
||||||
for (String s : targetFields)
|
for (String s : targetFields)
|
||||||
{
|
{
|
||||||
pr(" " + s);
|
pr(" " + s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.hasOption('D')) // undo not supported
|
if (line.hasOption('D')) // undo not supported
|
||||||
{
|
{
|
||||||
pr("Delete bitstreams ");
|
pr("Delete bitstreams ");
|
||||||
|
|
||||||
String[] filterNames = line.getOptionValues('D');
|
String[] filterNames = line.getOptionValues('D');
|
||||||
if ((filterNames != null) && (filterNames.length > 1))
|
if ((filterNames != null) && (filterNames.length > 1))
|
||||||
{
|
{
|
||||||
pr("Error: Only one filter can be a used at a time.");
|
pr("Error: Only one filter can be a used at a time.");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String filterName = line.getOptionValue('D');
|
String filterName = line.getOptionValue('D');
|
||||||
pr("Filter argument: " + filterName);
|
pr("Filter argument: " + filterName);
|
||||||
|
|
||||||
if (filterName == null) // indicates using delete_contents files
|
if (filterName == null) // indicates using delete_contents files
|
||||||
{
|
{
|
||||||
DeleteBitstreamsAction delAction = (DeleteBitstreamsAction) iu.actionMgr.getUpdateAction(DeleteBitstreamsAction.class);
|
DeleteBitstreamsAction delAction = (DeleteBitstreamsAction) iu.actionMgr.getUpdateAction(DeleteBitstreamsAction.class);
|
||||||
delAction.setAlterProvenance(alterProvenance);
|
delAction.setAlterProvenance(alterProvenance);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// check if param is on ALIAS list
|
// check if param is on ALIAS list
|
||||||
String filterClassname = filterAliases.get(filterName);
|
String filterClassname = filterAliases.get(filterName);
|
||||||
|
|
||||||
if (filterClassname == null)
|
if (filterClassname == null)
|
||||||
{
|
{
|
||||||
filterClassname = filterName;
|
filterClassname = filterName;
|
||||||
}
|
}
|
||||||
|
|
||||||
BitstreamFilter filter = null;
|
BitstreamFilter filter = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Class<?> cfilter = Class.forName(filterClassname);
|
Class<?> cfilter = Class.forName(filterClassname);
|
||||||
pr("BitstreamFilter class to instantiate: " + cfilter.toString());
|
pr("BitstreamFilter class to instantiate: " + cfilter.toString());
|
||||||
|
|
||||||
filter = (BitstreamFilter) cfilter.newInstance(); //unfortunate cast, an erasure consequence
|
filter = (BitstreamFilter) cfilter.newInstance(); //unfortunate cast, an erasure consequence
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
pr("Error: Failure instantiating bitstream filter class: " + filterClassname);
|
pr("Error: Failure instantiating bitstream filter class: " + filterClassname);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String filterPropertiesName = line.getOptionValue('F');
|
String filterPropertiesName = line.getOptionValue('F');
|
||||||
if (filterPropertiesName != null) //not always required
|
if (filterPropertiesName != null) //not always required
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// TODO try multiple relative locations, e.g. source dir
|
// TODO try multiple relative locations, e.g. source dir
|
||||||
if (!filterPropertiesName.startsWith("/"))
|
if (!filterPropertiesName.startsWith("/"))
|
||||||
{
|
{
|
||||||
filterPropertiesName = sourcedir + File.separator + filterPropertiesName;
|
filterPropertiesName = sourcedir + File.separator + filterPropertiesName;
|
||||||
}
|
}
|
||||||
|
|
||||||
filter.initProperties(filterPropertiesName);
|
filter.initProperties(filterPropertiesName);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
pr("Error: Failure finding properties file for bitstream filter class: " + filterPropertiesName);
|
pr("Error: Failure finding properties file for bitstream filter class: " + filterPropertiesName);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DeleteBitstreamsByFilterAction delAction =
|
DeleteBitstreamsByFilterAction delAction =
|
||||||
(DeleteBitstreamsByFilterAction) iu.actionMgr.getUpdateAction(DeleteBitstreamsByFilterAction.class);
|
(DeleteBitstreamsByFilterAction) iu.actionMgr.getUpdateAction(DeleteBitstreamsByFilterAction.class);
|
||||||
delAction.setAlterProvenance(alterProvenance);
|
delAction.setAlterProvenance(alterProvenance);
|
||||||
delAction.setBitstreamFilter(filter);
|
delAction.setBitstreamFilter(filter);
|
||||||
//undo not supported
|
//undo not supported
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.hasOption('A'))
|
if (line.hasOption('A'))
|
||||||
{
|
{
|
||||||
pr("Add bitstreams ");
|
pr("Add bitstreams ");
|
||||||
AddBitstreamsAction addAction = (AddBitstreamsAction) iu.actionMgr.getUpdateAction(AddBitstreamsAction.class);
|
AddBitstreamsAction addAction = (AddBitstreamsAction) iu.actionMgr.getUpdateAction(AddBitstreamsAction.class);
|
||||||
addAction.setAlterProvenance(alterProvenance);
|
addAction.setAlterProvenance(alterProvenance);
|
||||||
|
|
||||||
iu.undoActionList.add(" -D "); // delete_contents file will be written, no arg required
|
iu.undoActionList.add(" -D "); // delete_contents file will be written, no arg required
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!iu.actionMgr.hasActions())
|
if (!iu.actionMgr.hasActions())
|
||||||
{
|
{
|
||||||
pr("Error - an action must be specified");
|
pr("Error - an action must be specified");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pr("Actions to be performed: ");
|
pr("Actions to be performed: ");
|
||||||
|
|
||||||
for (UpdateAction ua : iu.actionMgr)
|
for (UpdateAction ua : iu.actionMgr)
|
||||||
{
|
{
|
||||||
pr(" " + ua.getClass().getName());
|
pr(" " + ua.getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pr("ItemUpdate - initializing run on " + (new Date()).toString());
|
pr("ItemUpdate - initializing run on " + (new Date()).toString());
|
||||||
|
|
||||||
context = new Context();
|
context = new Context();
|
||||||
iu.setEPerson(context, iu.eperson);
|
iu.setEPerson(context, iu.eperson);
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
HANDLE_PREFIX = ConfigurationManager.getProperty("handle.canonical.prefix");
|
HANDLE_PREFIX = ConfigurationManager.getProperty("handle.canonical.prefix");
|
||||||
if (HANDLE_PREFIX == null || HANDLE_PREFIX.length() == 0)
|
if (HANDLE_PREFIX == null || HANDLE_PREFIX.length() == 0)
|
||||||
{
|
{
|
||||||
HANDLE_PREFIX = "http://hdl.handle.net/";
|
HANDLE_PREFIX = "http://hdl.handle.net/";
|
||||||
}
|
}
|
||||||
|
|
||||||
iu.processArchive(context, sourcedir, itemField, metadataIndexName, alterProvenance, isTest);
|
iu.processArchive(context, sourcedir, itemField, metadataIndexName, alterProvenance, isTest);
|
||||||
|
|
||||||
context.complete(); // complete all transactions
|
context.complete(); // complete all transactions
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -378,7 +378,7 @@ public class ItemUpdate {
|
|||||||
status = 1;
|
status = 1;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isTest)
|
if (isTest)
|
||||||
@@ -387,14 +387,15 @@ public class ItemUpdate {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pr("End.");
|
pr("End.");
|
||||||
|
|
||||||
}
|
}
|
||||||
System.exit(status);
|
System.exit(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* process an archive
|
* process an archive
|
||||||
|
*
|
||||||
* @param context DSpace Context
|
* @param context DSpace Context
|
||||||
* @param sourceDirPath source path
|
* @param sourceDirPath source path
|
||||||
* @param itemField item field
|
* @param itemField item field
|
||||||
@@ -404,7 +405,7 @@ public class ItemUpdate {
|
|||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
protected void processArchive(Context context, String sourceDirPath, String itemField,
|
protected void processArchive(Context context, String sourceDirPath, String itemField,
|
||||||
String metadataIndexName, boolean alterProvenance, boolean isTest)
|
String metadataIndexName, boolean alterProvenance, boolean isTest)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
// open and process the source directory
|
// open and process the source directory
|
||||||
@@ -424,89 +425,89 @@ public class ItemUpdate {
|
|||||||
File fSuppressUndo = new File(sourceDir, SUPPRESS_UNDO_FILENAME);
|
File fSuppressUndo = new File(sourceDir, SUPPRESS_UNDO_FILENAME);
|
||||||
if (fSuppressUndo.exists())
|
if (fSuppressUndo.exists())
|
||||||
{
|
{
|
||||||
suppressUndo = true;
|
suppressUndo = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
File undoDir = null; //sibling directory of source archive
|
File undoDir = null; //sibling directory of source archive
|
||||||
|
|
||||||
if (!suppressUndo && !isTest)
|
if (!suppressUndo && !isTest)
|
||||||
{
|
{
|
||||||
undoDir = initUndoArchive(sourceDir);
|
undoDir = initUndoArchive(sourceDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int itemCount = 0;
|
||||||
|
int successItemCount = 0;
|
||||||
|
|
||||||
int itemCount = 0;
|
|
||||||
int successItemCount = 0;
|
|
||||||
|
|
||||||
for (String dirname : dircontents)
|
for (String dirname : dircontents)
|
||||||
{
|
{
|
||||||
itemCount++;
|
itemCount++;
|
||||||
pr("");
|
pr("");
|
||||||
pr("processing item " + dirname);
|
pr("processing item " + dirname);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ItemArchive itarch = ItemArchive.create(context, new File(sourceDir, dirname), itemField);
|
ItemArchive itarch = ItemArchive.create(context, new File(sourceDir, dirname), itemField);
|
||||||
|
|
||||||
for (UpdateAction action : actionMgr)
|
for (UpdateAction action : actionMgr)
|
||||||
{
|
{
|
||||||
pr("action: " + action.getClass().getName());
|
pr("action: " + action.getClass().getName());
|
||||||
action.execute(context, itarch, isTest, suppressUndo);
|
action.execute(context, itarch, isTest, suppressUndo);
|
||||||
if (!isTest && !suppressUndo)
|
if (!isTest && !suppressUndo)
|
||||||
{
|
{
|
||||||
itarch.writeUndo(undoDir);
|
itarch.writeUndo(undoDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isTest)
|
if (!isTest)
|
||||||
{
|
{
|
||||||
Item item = itarch.getItem();
|
Item item = itarch.getItem();
|
||||||
itemService.update(context, item); //need to update before commit
|
itemService.update(context, item); //need to update before commit
|
||||||
}
|
}
|
||||||
ItemUpdate.pr("Item " + dirname + " completed");
|
ItemUpdate.pr("Item " + dirname + " completed");
|
||||||
successItemCount++;
|
successItemCount++;
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
pr("Exception processing item " + dirname + ": " + e.toString());
|
pr("Exception processing item " + dirname + ": " + e.toString());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!suppressUndo && !isTest)
|
if (!suppressUndo && !isTest)
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder("dsrun org.dspace.app.itemupdate.ItemUpdate ");
|
StringBuilder sb = new StringBuilder("dsrun org.dspace.app.itemupdate.ItemUpdate ");
|
||||||
sb.append(" -e ").append(this.eperson);
|
sb.append(" -e ").append(this.eperson);
|
||||||
sb.append(" -s ").append(undoDir);
|
sb.append(" -s ").append(undoDir);
|
||||||
|
|
||||||
if (itemField != null)
|
if (itemField != null)
|
||||||
{
|
{
|
||||||
sb.append(" -i ").append(itemField);
|
sb.append(" -i ").append(itemField);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!alterProvenance)
|
if (!alterProvenance)
|
||||||
{
|
{
|
||||||
sb.append(" -P ");
|
sb.append(" -P ");
|
||||||
}
|
}
|
||||||
if (isTest)
|
if (isTest)
|
||||||
{
|
{
|
||||||
sb.append(" -t ");
|
sb.append(" -t ");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String actionOption : undoActionList)
|
for (String actionOption : undoActionList)
|
||||||
{
|
{
|
||||||
sb.append(actionOption);
|
sb.append(actionOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintWriter pw = null;
|
PrintWriter pw = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File cmdFile = new File (undoDir.getParent(), undoDir.getName() + "_command.sh");
|
File cmdFile = new File (undoDir.getParent(), undoDir.getName() + "_command.sh");
|
||||||
pw = new PrintWriter(new BufferedWriter(new FileWriter(cmdFile)));
|
pw = new PrintWriter(new BufferedWriter(new FileWriter(cmdFile)));
|
||||||
pw.println(sb.toString());
|
pw.println(sb.toString());
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
pw.close();
|
pw.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pr("");
|
pr("");
|
||||||
@@ -516,7 +517,6 @@ public class ItemUpdate {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* to avoid overwriting the undo source tree on repeated processing
|
* to avoid overwriting the undo source tree on repeated processing
|
||||||
* sequence numbers are added and checked
|
* sequence numbers are added and checked
|
||||||
*
|
*
|
||||||
@@ -526,45 +526,45 @@ public class ItemUpdate {
|
|||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
*/
|
*/
|
||||||
protected File initUndoArchive(File sourceDir)
|
protected File initUndoArchive(File sourceDir)
|
||||||
throws FileNotFoundException, IOException
|
throws FileNotFoundException, IOException
|
||||||
{
|
{
|
||||||
File parentDir = sourceDir.getCanonicalFile().getParentFile();
|
File parentDir = sourceDir.getCanonicalFile().getParentFile();
|
||||||
if (parentDir == null)
|
if (parentDir == null)
|
||||||
{
|
{
|
||||||
throw new FileNotFoundException("Parent directory of archive directory not found; unable to write UndoArchive; no processing performed");
|
throw new FileNotFoundException("Parent directory of archive directory not found; unable to write UndoArchive; no processing performed");
|
||||||
}
|
}
|
||||||
|
|
||||||
String sourceDirName = sourceDir.getName();
|
String sourceDirName = sourceDir.getName();
|
||||||
int seqNo = 1;
|
int seqNo = 1;
|
||||||
|
|
||||||
File undoDir = new File(parentDir, "undo_" + sourceDirName + "_" + seqNo);
|
File undoDir = new File(parentDir, "undo_" + sourceDirName + "_" + seqNo);
|
||||||
while (undoDir.exists())
|
while (undoDir.exists())
|
||||||
{
|
{
|
||||||
undoDir = new File(parentDir, "undo_" + sourceDirName+ "_" + ++seqNo); //increment
|
undoDir = new File(parentDir, "undo_" + sourceDirName+ "_" + ++seqNo); //increment
|
||||||
}
|
}
|
||||||
|
|
||||||
// create root directory
|
// create root directory
|
||||||
if (!undoDir.mkdir())
|
if (!undoDir.mkdir())
|
||||||
{
|
{
|
||||||
pr("ERROR creating Undo Archive directory " + undoDir.getCanonicalPath());
|
pr("ERROR creating Undo Archive directory " + undoDir.getCanonicalPath());
|
||||||
throw new IOException("ERROR creating Undo Archive directory " + undoDir.getCanonicalPath());
|
throw new IOException("ERROR creating Undo Archive directory " + undoDir.getCanonicalPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Undo is suppressed to prevent undo of undo
|
//Undo is suppressed to prevent undo of undo
|
||||||
File fSuppressUndo = new File(undoDir, ItemUpdate.SUPPRESS_UNDO_FILENAME);
|
File fSuppressUndo = new File(undoDir, ItemUpdate.SUPPRESS_UNDO_FILENAME);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fSuppressUndo.createNewFile();
|
fSuppressUndo.createNewFile();
|
||||||
}
|
}
|
||||||
catch(IOException e)
|
catch(IOException e)
|
||||||
{
|
{
|
||||||
pr("ERROR creating Suppress Undo File " + e.toString());
|
pr("ERROR creating Suppress Undo File " + e.toString());
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
return undoDir;
|
return undoDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
//private void write
|
//private void write
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set EPerson doing import
|
* Set EPerson doing import
|
||||||
@@ -603,14 +603,15 @@ public class ItemUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* poor man's logging
|
* poor man's logging
|
||||||
* As with ItemImport, API logging goes through log4j to the DSpace.log files
|
* 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.
|
* whereas the batch logging goes to the console to be captured there.
|
||||||
|
*
|
||||||
* @param s String
|
* @param s String
|
||||||
*/
|
*/
|
||||||
static void pr(String s)
|
static void pr(String s)
|
||||||
{
|
{
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -619,10 +620,10 @@ public class ItemUpdate {
|
|||||||
*/
|
*/
|
||||||
static void prv(String s)
|
static void prv(String s)
|
||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} //end of class
|
} //end of class
|
||||||
|
@@ -25,7 +25,7 @@ public class CommandRunner
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param args commandline args
|
* @param args the command line arguments given
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
* @throws FileNotFoundException if file doesn't exist
|
* @throws FileNotFoundException if file doesn't exist
|
||||||
*/
|
*/
|
||||||
|
@@ -92,8 +92,9 @@ public class ScriptLauncher
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Recognize and execute a single command.
|
* Recognize and execute a single command.
|
||||||
|
*
|
||||||
* @param doc Document
|
* @param doc Document
|
||||||
* @param args arguments
|
* @param args the command line arguments given
|
||||||
*/
|
*/
|
||||||
static int runOneCommand(Document commandConfigs, String[] args)
|
static int runOneCommand(Document commandConfigs, String[] args)
|
||||||
{
|
{
|
||||||
|
@@ -61,7 +61,7 @@ public abstract class MediaFilter implements FormatFilter
|
|||||||
* @param generatedBitstream
|
* @param generatedBitstream
|
||||||
* the bitstream which was generated by
|
* the bitstream which was generated by
|
||||||
* this filter.
|
* this filter.
|
||||||
* @throws java.lang.Exception
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void postProcessBitstream(Context c, Item item, Bitstream generatedBitstream)
|
public void postProcessBitstream(Context c, Item item, Bitstream generatedBitstream)
|
||||||
|
@@ -24,13 +24,20 @@ public interface RequestItemService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a request item representing the request and put it into the DB
|
* Generate a request item representing the request and put it into the DB
|
||||||
* @param context context
|
* @param context
|
||||||
* @param bitstream bitstream
|
* The relevant DSpace Context.
|
||||||
* @param item item
|
* @param bitstream
|
||||||
* @param reqMessage message
|
* The requested bitstream
|
||||||
* @param allFiles all files flag
|
* @param item
|
||||||
|
* The requested item
|
||||||
|
* @param reqMessage
|
||||||
|
* Request message text
|
||||||
|
* @param allFiles
|
||||||
|
* true indicates that all bitstreams of this item are requested
|
||||||
* @param reqEmail email
|
* @param reqEmail email
|
||||||
* @param reqName name
|
* Requester email
|
||||||
|
* @param reqName
|
||||||
|
* Requester name
|
||||||
* @return the token of the request item
|
* @return the token of the request item
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
@@ -41,8 +48,11 @@ public interface RequestItemService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Save updates to the record. Only accept_request, and decision_date are set-able.
|
* Save updates to the record. Only accept_request, and decision_date are set-able.
|
||||||
|
*
|
||||||
* @param context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param requestItem
|
* @param requestItem
|
||||||
|
* requested item
|
||||||
*/
|
*/
|
||||||
public void update(Context context, RequestItem requestItem);
|
public void update(Context context, RequestItem requestItem);
|
||||||
|
|
||||||
|
@@ -212,7 +212,7 @@ public class LogAnalyser
|
|||||||
/**
|
/**
|
||||||
* main method to be run from command line. See usage information for
|
* main method to be run from command line. See usage information for
|
||||||
* details as to how to use the command line flags (-help)
|
* details as to how to use the command line flags (-help)
|
||||||
* @param argv arguments
|
* @param argv the command line arguments given
|
||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
@@ -1051,7 +1051,7 @@ public class LogAnalyser
|
|||||||
{
|
{
|
||||||
// Use SimpleDateFormat
|
// Use SimpleDateFormat
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'MM'-'dd'T'hh:mm:ss'Z'");
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'MM'-'dd'T'hh:mm:ss'Z'");
|
||||||
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
return sdf.format(date);
|
return sdf.format(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1187,13 +1187,13 @@ public class LogAnalyser
|
|||||||
// that
|
// that
|
||||||
|
|
||||||
DiscoverQuery discoverQuery = new DiscoverQuery();
|
DiscoverQuery discoverQuery = new DiscoverQuery();
|
||||||
if(StringUtils.isNotBlank(type))
|
if (StringUtils.isNotBlank(type))
|
||||||
{
|
{
|
||||||
discoverQuery.addFilterQueries("dc.type=" + type +"*");
|
discoverQuery.addFilterQueries("dc.type=" + type +"*");
|
||||||
}
|
}
|
||||||
StringBuilder accessionedQuery = new StringBuilder();
|
StringBuilder accessionedQuery = new StringBuilder();
|
||||||
accessionedQuery.append("dc.date.accessioned_dt:[");
|
accessionedQuery.append("dc.date.accessioned_dt:[");
|
||||||
if(startDate != null)
|
if (startDate != null)
|
||||||
{
|
{
|
||||||
accessionedQuery.append(unParseDate(startDate));
|
accessionedQuery.append(unParseDate(startDate));
|
||||||
}
|
}
|
||||||
@@ -1202,7 +1202,7 @@ public class LogAnalyser
|
|||||||
accessionedQuery.append("*");
|
accessionedQuery.append("*");
|
||||||
}
|
}
|
||||||
accessionedQuery.append(" TO ");
|
accessionedQuery.append(" TO ");
|
||||||
if(endDate != null)
|
if (endDate != null)
|
||||||
{
|
{
|
||||||
accessionedQuery.append(unParseDate(endDate));
|
accessionedQuery.append(unParseDate(endDate));
|
||||||
}
|
}
|
||||||
@@ -1242,44 +1242,44 @@ public class LogAnalyser
|
|||||||
public static void usage()
|
public static void usage()
|
||||||
{
|
{
|
||||||
String usage = "Usage Information:\n" +
|
String usage = "Usage Information:\n" +
|
||||||
"LogAnalyser [options [parameters]]\n" +
|
"LogAnalyser [options [parameters]]\n" +
|
||||||
"-log [log directory]\n" +
|
"-log [log directory]\n" +
|
||||||
"\tOptional\n" +
|
"\tOptional\n" +
|
||||||
"\tSpecify a directory containing log files\n" +
|
"\tSpecify a directory containing log files\n" +
|
||||||
"\tDefault uses [dspace.dir]/log from dspace.cfg\n" +
|
"\tDefault uses [dspace.dir]/log from dspace.cfg\n" +
|
||||||
"-file [file name regex]\n" +
|
"-file [file name regex]\n" +
|
||||||
"\tOptional\n" +
|
"\tOptional\n" +
|
||||||
"\tSpecify a regular expression as the file name template.\n" +
|
"\tSpecify a regular expression as the file name template.\n" +
|
||||||
"\tCurrently this needs to be correctly escaped for Java string handling (FIXME)\n" +
|
"\tCurrently this needs to be correctly escaped for Java string handling (FIXME)\n" +
|
||||||
"\tDefault uses dspace.log*\n" +
|
"\tDefault uses dspace.log*\n" +
|
||||||
"-cfg [config file path]\n" +
|
"-cfg [config file path]\n" +
|
||||||
"\tOptional\n" +
|
"\tOptional\n" +
|
||||||
"\tSpecify a config file to be used\n" +
|
"\tSpecify a config file to be used\n" +
|
||||||
"\tDefault uses dstat.cfg in dspace config directory\n" +
|
"\tDefault uses dstat.cfg in dspace config directory\n" +
|
||||||
"-out [output file path]\n" +
|
"-out [output file path]\n" +
|
||||||
"\tOptional\n" +
|
"\tOptional\n" +
|
||||||
"\tSpecify an output file to write results into\n" +
|
"\tSpecify an output file to write results into\n" +
|
||||||
"\tDefault uses dstat.dat in dspace log directory\n" +
|
"\tDefault uses dstat.dat in dspace log directory\n" +
|
||||||
"-start [YYYY-MM-DD]\n" +
|
"-start [YYYY-MM-DD]\n" +
|
||||||
"\tOptional\n" +
|
"\tOptional\n" +
|
||||||
"\tSpecify the start date of the analysis\n" +
|
"\tSpecify the start date of the analysis\n" +
|
||||||
"\tIf a start date is specified then no attempt to gather \n" +
|
"\tIf a start date is specified then no attempt to gather \n" +
|
||||||
"\tcurrent database statistics will be made unless -lookup is\n" +
|
"\tcurrent database statistics will be made unless -lookup is\n" +
|
||||||
"\talso passed\n" +
|
"\talso passed\n" +
|
||||||
"\tDefault is to start from the earliest date records exist for\n" +
|
"\tDefault is to start from the earliest date records exist for\n" +
|
||||||
"-end [YYYY-MM-DD]\n" +
|
"-end [YYYY-MM-DD]\n" +
|
||||||
"\tOptional\n" +
|
"\tOptional\n" +
|
||||||
"\tSpecify the end date of the analysis\n" +
|
"\tSpecify the end date of the analysis\n" +
|
||||||
"\tIf an end date is specified then no attempt to gather \n" +
|
"\tIf an end date is specified then no attempt to gather \n" +
|
||||||
"\tcurrent database statistics will be made unless -lookup is\n" +
|
"\tcurrent database statistics will be made unless -lookup is\n" +
|
||||||
"\talso passed\n" +
|
"\talso passed\n" +
|
||||||
"\tDefault is to work up to the last date records exist for\n" +
|
"\tDefault is to work up to the last date records exist for\n" +
|
||||||
"-lookup\n" +
|
"-lookup\n" +
|
||||||
"\tOptional\n" +
|
"\tOptional\n" +
|
||||||
"\tForce a lookup of the current database statistics\n" +
|
"\tForce a lookup of the current database statistics\n" +
|
||||||
"\tOnly needs to be used if date constraints are also in place\n" +
|
"\tOnly needs to be used if date constraints are also in place\n" +
|
||||||
"-help\n" +
|
"-help\n" +
|
||||||
"\tdisplay this usage information\n";
|
"\tdisplay this usage information\n";
|
||||||
|
|
||||||
System.out.println(usage);
|
System.out.println(usage);
|
||||||
}
|
}
|
||||||
|
@@ -125,14 +125,14 @@ public class ReportGenerator
|
|||||||
private static Pattern real = Pattern.compile("^(.+)=(.+)");
|
private static Pattern real = Pattern.compile("^(.+)=(.+)");
|
||||||
|
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
// Miscellaneous variables
|
// Miscellaneous variables
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
|
||||||
/** process timing clock */
|
/** process timing clock */
|
||||||
private static Calendar startTime = null;
|
private static Calendar startTime = null;
|
||||||
|
|
||||||
/** a map from log file action to human readable action */
|
/** a map from log file action to human readable action */
|
||||||
private static Map<String, String> actionMap = null;
|
private static Map<String, String> actionMap = null;
|
||||||
|
|
||||||
/////////////////
|
/////////////////
|
||||||
// report generator config data
|
// report generator config data
|
||||||
@@ -141,9 +141,9 @@ public class ReportGenerator
|
|||||||
/** the input file to build the report from */
|
/** the input file to build the report from */
|
||||||
private static String input = null;
|
private static String input = null;
|
||||||
|
|
||||||
/** the log file action to human readable action map */
|
/** the log file action to human readable action map */
|
||||||
private static String map = ConfigurationManager.getProperty("dspace.dir") +
|
private static String map = ConfigurationManager.getProperty("dspace.dir") +
|
||||||
File.separator + "config" + File.separator + "dstat.map";
|
File.separator + "config" + File.separator + "dstat.map";
|
||||||
|
|
||||||
private static final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
private static final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||||
private static final HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
|
private static final HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||||
@@ -152,9 +152,10 @@ public class ReportGenerator
|
|||||||
/**
|
/**
|
||||||
* main method to be run from command line. See usage information for
|
* main method to be run from command line. See usage information for
|
||||||
* details as to how to use the command line flags
|
* details as to how to use the command line flags
|
||||||
* @param argv
|
* @param argv the command line arguments given
|
||||||
* @throws java.lang.Exception
|
* @throws Exception on generic exception
|
||||||
* @throws java.sql.SQLException
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public static void main(String [] argv)
|
public static void main(String [] argv)
|
||||||
throws Exception, SQLException
|
throws Exception, SQLException
|
||||||
|
@@ -24,14 +24,16 @@ import org.dspace.core.Context;
|
|||||||
public class CollectionDropDown {
|
public class CollectionDropDown {
|
||||||
|
|
||||||
|
|
||||||
private static final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
private static final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get full path starting from a top-level community via subcommunities down to a collection.
|
* Get full path starting from a top-level community via subcommunities down to a collection.
|
||||||
* The full path will not be truncated.
|
* The full path will not be truncated.
|
||||||
*
|
*
|
||||||
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param col
|
* @param col
|
||||||
* Get full path for this collection
|
* Get full path for this collection
|
||||||
* @return Full path to the collection
|
* @return Full path to the collection
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
@@ -44,10 +46,12 @@ public class CollectionDropDown {
|
|||||||
* Get full path starting from a top-level community via subcommunities down to a collection.
|
* Get full path starting from a top-level community via subcommunities down to a collection.
|
||||||
* The full cat will be truncated to the specified number of characters and prepended with an ellipsis.
|
* The full cat will be truncated to the specified number of characters and prepended with an ellipsis.
|
||||||
*
|
*
|
||||||
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param col
|
* @param col
|
||||||
* Get full path for this collection
|
* Get full path for this collection
|
||||||
* @param maxchars
|
* @param maxchars
|
||||||
* Truncate the full path to maxchar characters. 0 means do not truncate.
|
* Truncate the full path to maxchar characters. 0 means do not truncate.
|
||||||
* @return Full path to the collection (truncated)
|
* @return Full path to the collection (truncated)
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
@@ -82,62 +86,64 @@ public class CollectionDropDown {
|
|||||||
return name.toString();
|
return name.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotates an array of collections with their respective full paths (@see #collectionPath() method in this class).
|
* Annotates an array of collections with their respective full paths (@see #collectionPath() method in this class).
|
||||||
* @param collections An array of collections to annotate with their hierarchical paths.
|
* @param context
|
||||||
* The array and all its entries must be non-null.
|
* The relevant DSpace Context.
|
||||||
* @return A sorted array of collection path entries (essentially collection/path pairs).
|
* @param collections An array of collections to annotate with their hierarchical paths.
|
||||||
* @throws SQLException In case there are problems annotating a collection with its path.
|
* The array and all its entries must be non-null.
|
||||||
*/
|
* @return A sorted array of collection path entries (essentially collection/path pairs).
|
||||||
public static CollectionPathEntry[] annotateWithPaths(Context context, List<Collection> collections) throws SQLException
|
* @throws SQLException In case there are problems annotating a collection with its path.
|
||||||
{
|
*/
|
||||||
CollectionPathEntry[] result = new CollectionPathEntry[collections.size()];
|
public static CollectionPathEntry[] annotateWithPaths(Context context, List<Collection> collections) throws SQLException
|
||||||
for (int i = 0; i < collections.size(); i++)
|
{
|
||||||
{
|
CollectionPathEntry[] result = new CollectionPathEntry[collections.size()];
|
||||||
Collection collection = collections.get(i);
|
for (int i = 0; i < collections.size(); i++)
|
||||||
CollectionPathEntry entry = new CollectionPathEntry(collection, collectionPath(context, collection));
|
{
|
||||||
result[i] = entry;
|
Collection collection = collections.get(i);
|
||||||
}
|
CollectionPathEntry entry = new CollectionPathEntry(collection, collectionPath(context, collection));
|
||||||
Arrays.sort(result);
|
result[i] = entry;
|
||||||
return result;
|
}
|
||||||
}
|
Arrays.sort(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper class to hold (collection, full path) pairs. Instances of the helper class are sortable:
|
* A helper class to hold (collection, full path) pairs. Instances of the helper class are sortable:
|
||||||
* two instances will be compared first on their full path and if those are equal,
|
* two instances will be compared first on their full path and if those are equal,
|
||||||
* the comparison will fall back to comparing collection IDs.
|
* the comparison will fall back to comparing collection IDs.
|
||||||
*/
|
*/
|
||||||
public static class CollectionPathEntry implements Comparable<CollectionPathEntry>
|
public static class CollectionPathEntry implements Comparable<CollectionPathEntry>
|
||||||
{
|
{
|
||||||
public Collection collection;
|
public Collection collection;
|
||||||
public String path;
|
public String path;
|
||||||
|
|
||||||
public CollectionPathEntry(Collection collection, String path)
|
public CollectionPathEntry(Collection collection, String path)
|
||||||
{
|
{
|
||||||
this.collection = collection;
|
this.collection = collection;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(CollectionPathEntry other)
|
public int compareTo(CollectionPathEntry other)
|
||||||
{
|
{
|
||||||
if (!this.path.equals(other.path))
|
if (!this.path.equals(other.path))
|
||||||
{
|
{
|
||||||
return this.path.compareTo(other.path);
|
return this.path.compareTo(other.path);
|
||||||
}
|
}
|
||||||
return this.collection.getID().compareTo(other.collection.getID());
|
return this.collection.getID().compareTo(other.collection.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o)
|
public boolean equals(Object o)
|
||||||
{
|
{
|
||||||
return o != null && o instanceof CollectionPathEntry && this.compareTo((CollectionPathEntry) o) == 0;
|
return o != null && o instanceof CollectionPathEntry && this.compareTo((CollectionPathEntry) o) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
return Objects.hash(path, collection.getID());
|
return Objects.hash(path, collection.getID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -36,8 +36,7 @@ public class Configuration
|
|||||||
* </ul>
|
* </ul>
|
||||||
* If the property does not exist, nothing is written.
|
* If the property does not exist, nothing is written.
|
||||||
*
|
*
|
||||||
* @param argv
|
* @param argv the command line arguments given
|
||||||
* command-line arguments
|
|
||||||
*/
|
*/
|
||||||
public static void main(String[] argv)
|
public static void main(String[] argv)
|
||||||
{
|
{
|
||||||
|
@@ -94,8 +94,10 @@ public class DCInput
|
|||||||
* a HashMap
|
* a HashMap
|
||||||
*
|
*
|
||||||
* @param fieldMap
|
* @param fieldMap
|
||||||
* ???
|
* named field values.
|
||||||
|
*
|
||||||
* @param listMap
|
* @param listMap
|
||||||
|
* value-pairs map, computed from the forms definition XML file
|
||||||
*/
|
*/
|
||||||
public DCInput(Map<String, String> fieldMap, Map<String, List<String>> listMap)
|
public DCInput(Map<String, String> fieldMap, Map<String, List<String>> listMap)
|
||||||
{
|
{
|
||||||
|
@@ -20,80 +20,80 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class DCInputSet
|
public class DCInputSet
|
||||||
{
|
{
|
||||||
/** name of the input set */
|
/** name of the input set */
|
||||||
private String formName = null;
|
private String formName = null;
|
||||||
/** the inputs ordered by page and row position */
|
/** the inputs ordered by page and row position */
|
||||||
private DCInput[][] inputPages = null;
|
private DCInput[][] inputPages = null;
|
||||||
|
|
||||||
/** constructor
|
/** constructor
|
||||||
* @param formName form name
|
* @param formName form name
|
||||||
* @param pages pages
|
* @param pages pages
|
||||||
* @param listMap map
|
* @param listMap map
|
||||||
*/
|
*/
|
||||||
public DCInputSet(String formName, List<List<Map<String, String>>> pages, Map<String, List<String>> listMap)
|
public DCInputSet(String formName, List<List<Map<String, String>>> pages, Map<String, List<String>> listMap)
|
||||||
{
|
{
|
||||||
this.formName = formName;
|
this.formName = formName;
|
||||||
inputPages = new DCInput[pages.size()][];
|
inputPages = new DCInput[pages.size()][];
|
||||||
for ( int i = 0; i < inputPages.length; i++ )
|
for ( int i = 0; i < inputPages.length; i++ )
|
||||||
{
|
{
|
||||||
List<Map<String, String>> page = pages.get(i);
|
List<Map<String, String>> page = pages.get(i);
|
||||||
inputPages[i] = new DCInput[page.size()];
|
inputPages[i] = new DCInput[page.size()];
|
||||||
for ( int j = 0; j < inputPages[i].length; j++ )
|
for ( int j = 0; j < inputPages[i].length; j++ )
|
||||||
{
|
{
|
||||||
inputPages[i][j] = new DCInput(page.get(j), listMap);
|
inputPages[i][j] = new DCInput(page.get(j), listMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the name of the form that defines this input set
|
* Return the name of the form that defines this input set
|
||||||
* @return formName the name of the form
|
* @return formName the name of the form
|
||||||
*/
|
*/
|
||||||
public String getFormName()
|
public String getFormName()
|
||||||
{
|
{
|
||||||
return formName;
|
return formName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the number of pages in this input set
|
* Return the number of pages in this input set
|
||||||
* @return number of pages
|
* @return number of pages
|
||||||
*/
|
*/
|
||||||
public int getNumberPages()
|
public int getNumberPages()
|
||||||
{
|
{
|
||||||
return inputPages.length;
|
return inputPages.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all the rows for a page from the form definition
|
* Get all the rows for a page from the form definition
|
||||||
*
|
*
|
||||||
* @param pageNum desired page within set
|
* @param pageNum desired page within set
|
||||||
* @param addTitleAlternative flag to add the additional title row
|
* @param addTitleAlternative flag to add the additional title row
|
||||||
* @param addPublishedBefore flag to add the additional published info
|
* @param addPublishedBefore flag to add the additional published info
|
||||||
*
|
*
|
||||||
* @return an array containing the page's displayable rows
|
* @return an array containing the page's displayable rows
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public DCInput[] getPageRows(int pageNum, boolean addTitleAlternative,
|
public DCInput[] getPageRows(int pageNum, boolean addTitleAlternative,
|
||||||
boolean addPublishedBefore)
|
boolean addPublishedBefore)
|
||||||
{
|
{
|
||||||
List<DCInput> filteredInputs = new ArrayList<DCInput>();
|
List<DCInput> filteredInputs = new ArrayList<DCInput>();
|
||||||
if ( pageNum < inputPages.length )
|
if ( pageNum < inputPages.length )
|
||||||
{
|
{
|
||||||
for (int i = 0; i < inputPages[pageNum].length; i++ )
|
for (int i = 0; i < inputPages[pageNum].length; i++ )
|
||||||
{
|
{
|
||||||
DCInput input = inputPages[pageNum][i];
|
DCInput input = inputPages[pageNum][i];
|
||||||
if (doField(input, addTitleAlternative, addPublishedBefore))
|
if (doField(input, addTitleAlternative, addPublishedBefore))
|
||||||
{
|
{
|
||||||
filteredInputs.add(input);
|
filteredInputs.add(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert list into an array
|
// Convert list into an array
|
||||||
DCInput[] inputArray = new DCInput[filteredInputs.size()];
|
DCInput[] inputArray = new DCInput[filteredInputs.size()];
|
||||||
return filteredInputs.toArray(inputArray);
|
return filteredInputs.toArray(inputArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does this set of inputs include an alternate title field?
|
* Does this set of inputs include an alternate title field?
|
||||||
*
|
*
|
||||||
@@ -101,7 +101,7 @@ public class DCInputSet
|
|||||||
*/
|
*/
|
||||||
public boolean isDefinedMultTitles()
|
public boolean isDefinedMultTitles()
|
||||||
{
|
{
|
||||||
return isFieldPresent("title.alternative");
|
return isFieldPresent("title.alternative");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,36 +111,36 @@ public class DCInputSet
|
|||||||
*/
|
*/
|
||||||
public boolean isDefinedPubBefore()
|
public boolean isDefinedPubBefore()
|
||||||
{
|
{
|
||||||
return ( isFieldPresent("date.issued") &&
|
return ( isFieldPresent("date.issued") &&
|
||||||
isFieldPresent("identifier.citation") &&
|
isFieldPresent("identifier.citation") &&
|
||||||
isFieldPresent("publisher.null") );
|
isFieldPresent("publisher.null") );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does the current input set define the named field?
|
* Does the current input set define the named field?
|
||||||
* Scan through every field in every page of the input set
|
* Scan through every field in every page of the input set
|
||||||
*
|
*
|
||||||
* @param fieldName
|
* @param fieldName selects the field.
|
||||||
* @return true if the current set has the named field
|
* @return true if the current set has the named field
|
||||||
*/
|
*/
|
||||||
public boolean isFieldPresent(String fieldName)
|
public boolean isFieldPresent(String fieldName)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < inputPages.length; i++)
|
for (int i = 0; i < inputPages.length; i++)
|
||||||
{
|
{
|
||||||
DCInput[] pageInputs = inputPages[i];
|
DCInput[] pageInputs = inputPages[i];
|
||||||
for (int row = 0; row < pageInputs.length; row++)
|
for (int row = 0; row < pageInputs.length; row++)
|
||||||
{
|
{
|
||||||
String fullName = pageInputs[row].getElement() + "." +
|
String fullName = pageInputs[row].getElement() + "." +
|
||||||
pageInputs[row].getQualifier();
|
pageInputs[row].getQualifier();
|
||||||
if (fullName.equals(fieldName))
|
if (fullName.equals(fieldName))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does the current input set define the named field?
|
* Does the current input set define the named field?
|
||||||
* and is valid for the specified document type
|
* and is valid for the specified document type
|
||||||
@@ -152,48 +152,48 @@ public class DCInputSet
|
|||||||
*/
|
*/
|
||||||
public boolean isFieldPresent(String fieldName, String documentType)
|
public boolean isFieldPresent(String fieldName, String documentType)
|
||||||
{
|
{
|
||||||
if(documentType == null){
|
if (documentType == null) {
|
||||||
documentType = "";
|
documentType = "";
|
||||||
}
|
}
|
||||||
for (int i = 0; i < inputPages.length; i++)
|
for (int i = 0; i < inputPages.length; i++)
|
||||||
{
|
{
|
||||||
DCInput[] pageInputs = inputPages[i];
|
DCInput[] pageInputs = inputPages[i];
|
||||||
for (int row = 0; row < pageInputs.length; row++)
|
for (int row = 0; row < pageInputs.length; row++)
|
||||||
{
|
{
|
||||||
String fullName = pageInputs[row].getElement() + "." +
|
String fullName = pageInputs[row].getElement() + "." +
|
||||||
pageInputs[row].getQualifier();
|
pageInputs[row].getQualifier();
|
||||||
if (fullName.equals(fieldName) )
|
if (fullName.equals(fieldName) )
|
||||||
{
|
{
|
||||||
if(pageInputs[row].isAllowedFor(documentType)){
|
if (pageInputs[row].isAllowedFor(documentType)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean doField(DCInput dcf, boolean addTitleAlternative,
|
protected boolean doField(DCInput dcf, boolean addTitleAlternative,
|
||||||
boolean addPublishedBefore)
|
boolean addPublishedBefore)
|
||||||
{
|
{
|
||||||
String rowName = dcf.getElement() + "." + dcf.getQualifier();
|
String rowName = dcf.getElement() + "." + dcf.getQualifier();
|
||||||
if ( rowName.equals("title.alternative") && ! addTitleAlternative )
|
if ( rowName.equals("title.alternative") && ! addTitleAlternative )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (rowName.equals("date.issued") && ! addPublishedBefore )
|
if (rowName.equals("date.issued") && ! addPublishedBefore )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (rowName.equals("publisher.null") && ! addPublishedBefore )
|
if (rowName.equals("publisher.null") && ! addPublishedBefore )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (rowName.equals("identifier.citation") && ! addPublishedBefore )
|
if (rowName.equals("identifier.citation") && ! addPublishedBefore )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -82,6 +82,7 @@ public class DCInputsReader
|
|||||||
* level structures: a map between collections and forms, the definition for
|
* level structures: a map between collections and forms, the definition for
|
||||||
* each page of each form, and lists of pairs of values that populate
|
* each page of each form, and lists of pairs of values that populate
|
||||||
* selection boxes.
|
* selection boxes.
|
||||||
|
*
|
||||||
* @throws DCInputsReaderException if input reader error
|
* @throws DCInputsReaderException if input reader error
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@ public class DCInputsReader
|
|||||||
{
|
{
|
||||||
// Load from default file
|
// Load from default file
|
||||||
String defsFile = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
|
String defsFile = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
|
||||||
+ File.separator + "config" + File.separator + FORM_DEF_FILE;
|
+ File.separator + "config" + File.separator + FORM_DEF_FILE;
|
||||||
|
|
||||||
buildInputs(defsFile);
|
buildInputs(defsFile);
|
||||||
}
|
}
|
||||||
@@ -114,23 +115,23 @@ public class DCInputsReader
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
factory.setValidating(false);
|
factory.setValidating(false);
|
||||||
factory.setIgnoringComments(true);
|
factory.setIgnoringComments(true);
|
||||||
factory.setIgnoringElementContentWhitespace(true);
|
factory.setIgnoringElementContentWhitespace(true);
|
||||||
|
|
||||||
DocumentBuilder db = factory.newDocumentBuilder();
|
DocumentBuilder db = factory.newDocumentBuilder();
|
||||||
Document doc = db.parse(uri);
|
Document doc = db.parse(uri);
|
||||||
doNodes(doc);
|
doNodes(doc);
|
||||||
checkValues();
|
checkValues();
|
||||||
}
|
}
|
||||||
catch (FactoryConfigurationError fe)
|
catch (FactoryConfigurationError fe)
|
||||||
{
|
{
|
||||||
throw new DCInputsReaderException("Cannot create Submission form parser",fe);
|
throw new DCInputsReaderException("Cannot create Submission form parser",fe);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new DCInputsReaderException("Error creating submission forms: "+e);
|
throw new DCInputsReaderException("Error creating submission forms: "+e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,27 +156,27 @@ public class DCInputsReader
|
|||||||
* if no default set defined
|
* if no default set defined
|
||||||
*/
|
*/
|
||||||
public DCInputSet getInputs(String collectionHandle)
|
public DCInputSet getInputs(String collectionHandle)
|
||||||
throws DCInputsReaderException
|
throws DCInputsReaderException
|
||||||
{
|
{
|
||||||
String formName = whichForms.get(collectionHandle);
|
String formName = whichForms.get(collectionHandle);
|
||||||
if (formName == null)
|
if (formName == null)
|
||||||
{
|
{
|
||||||
formName = whichForms.get(DEFAULT_COLLECTION);
|
formName = whichForms.get(DEFAULT_COLLECTION);
|
||||||
}
|
}
|
||||||
if (formName == null)
|
if (formName == null)
|
||||||
{
|
{
|
||||||
throw new DCInputsReaderException("No form designated as default");
|
throw new DCInputsReaderException("No form designated as default");
|
||||||
}
|
}
|
||||||
// check mini-cache, and return if match
|
// check mini-cache, and return if match
|
||||||
if ( lastInputSet != null && lastInputSet.getFormName().equals( formName ) )
|
if ( lastInputSet != null && lastInputSet.getFormName().equals( formName ) )
|
||||||
{
|
{
|
||||||
return lastInputSet;
|
return lastInputSet;
|
||||||
}
|
}
|
||||||
// cache miss - construct new DCInputSet
|
// cache miss - construct new DCInputSet
|
||||||
List<List<Map<String, String>>> pages = formDefns.get(formName);
|
List<List<Map<String, String>>> pages = formDefns.get(formName);
|
||||||
if ( pages == null )
|
if ( pages == null )
|
||||||
{
|
{
|
||||||
throw new DCInputsReaderException("Missing the " + formName + " form");
|
throw new DCInputsReaderException("Missing the " + formName + " form");
|
||||||
}
|
}
|
||||||
lastInputSet = new DCInputSet(formName, pages, valuePairs);
|
lastInputSet = new DCInputSet(formName, pages, valuePairs);
|
||||||
return lastInputSet;
|
return lastInputSet;
|
||||||
@@ -197,13 +198,16 @@ public class DCInputsReader
|
|||||||
* Process the top level child nodes in the passed top-level node. These
|
* Process the top level child nodes in the passed top-level node. These
|
||||||
* should correspond to the collection-form maps, the form definitions, and
|
* should correspond to the collection-form maps, the form definitions, and
|
||||||
* the display/storage word pairs.
|
* the display/storage word pairs.
|
||||||
|
*
|
||||||
|
* @param n
|
||||||
|
* top-level DOM node
|
||||||
*/
|
*/
|
||||||
private void doNodes(Node n)
|
private void doNodes(Node n)
|
||||||
throws SAXException, DCInputsReaderException
|
throws SAXException, DCInputsReaderException
|
||||||
{
|
{
|
||||||
if (n == null)
|
if (n == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Node e = getElement(n);
|
Node e = getElement(n);
|
||||||
NodeList nl = e.getChildNodes();
|
NodeList nl = e.getChildNodes();
|
||||||
@@ -212,35 +216,35 @@ public class DCInputsReader
|
|||||||
boolean foundDefs = false;
|
boolean foundDefs = false;
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
Node nd = nl.item(i);
|
Node nd = nl.item(i);
|
||||||
if ((nd == null) || isEmptyTextNode(nd))
|
if ((nd == null) || isEmptyTextNode(nd))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String tagName = nd.getNodeName();
|
String tagName = nd.getNodeName();
|
||||||
if (tagName.equals("form-map"))
|
if (tagName.equals("form-map"))
|
||||||
{
|
{
|
||||||
processMap(nd);
|
processMap(nd);
|
||||||
foundMap = true;
|
foundMap = true;
|
||||||
}
|
}
|
||||||
else if (tagName.equals("form-definitions"))
|
else if (tagName.equals("form-definitions"))
|
||||||
{
|
{
|
||||||
processDefinition(nd);
|
processDefinition(nd);
|
||||||
foundDefs = true;
|
foundDefs = true;
|
||||||
}
|
}
|
||||||
else if (tagName.equals("form-value-pairs"))
|
else if (tagName.equals("form-value-pairs"))
|
||||||
{
|
{
|
||||||
processValuePairs(nd);
|
processValuePairs(nd);
|
||||||
}
|
}
|
||||||
// Ignore unknown nodes
|
// Ignore unknown nodes
|
||||||
}
|
}
|
||||||
if (!foundMap)
|
if (!foundMap)
|
||||||
{
|
{
|
||||||
throw new DCInputsReaderException("No collection to form map found");
|
throw new DCInputsReaderException("No collection to form map found");
|
||||||
}
|
}
|
||||||
if (!foundDefs)
|
if (!foundDefs)
|
||||||
{
|
{
|
||||||
throw new DCInputsReaderException("No form definition found");
|
throw new DCInputsReaderException("No form definition found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,26 +262,26 @@ public class DCInputsReader
|
|||||||
int len = nl.getLength();
|
int len = nl.getLength();
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
Node nd = nl.item(i);
|
Node nd = nl.item(i);
|
||||||
if (nd.getNodeName().equals("name-map"))
|
if (nd.getNodeName().equals("name-map"))
|
||||||
|
{
|
||||||
|
String id = getAttribute(nd, "collection-handle");
|
||||||
|
String value = getAttribute(nd, "form-name");
|
||||||
|
String content = getValue(nd);
|
||||||
|
if (id == null)
|
||||||
{
|
{
|
||||||
String id = getAttribute(nd, "collection-handle");
|
throw new SAXException("name-map element is missing collection-handle attribute");
|
||||||
String value = getAttribute(nd, "form-name");
|
}
|
||||||
String content = getValue(nd);
|
if (value == null)
|
||||||
if (id == null)
|
{
|
||||||
{
|
throw new SAXException("name-map element is missing form-name attribute");
|
||||||
throw new SAXException("name-map element is missing collection-handle attribute");
|
}
|
||||||
}
|
if (content != null && content.length() > 0)
|
||||||
if (value == null)
|
{
|
||||||
{
|
throw new SAXException("name-map element has content, it should be empty.");
|
||||||
throw new SAXException("name-map element is missing form-name attribute");
|
}
|
||||||
}
|
whichForms.put(id, value);
|
||||||
if (content != null && content.length() > 0)
|
} // ignore any child node that isn't a "name-map"
|
||||||
{
|
|
||||||
throw new SAXException("name-map element has content, it should be empty.");
|
|
||||||
}
|
|
||||||
whichForms.put(id, value);
|
|
||||||
} // ignore any child node that isn't a "name-map"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,62 +300,61 @@ public class DCInputsReader
|
|||||||
int len = nl.getLength();
|
int len = nl.getLength();
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
Node nd = nl.item(i);
|
Node nd = nl.item(i);
|
||||||
// process each form definition
|
// process each form definition
|
||||||
if (nd.getNodeName().equals("form"))
|
if (nd.getNodeName().equals("form"))
|
||||||
|
{
|
||||||
|
numForms++;
|
||||||
|
String formName = getAttribute(nd, "name");
|
||||||
|
if (formName == null)
|
||||||
{
|
{
|
||||||
numForms++;
|
throw new SAXException("form element has no name attribute");
|
||||||
String formName = getAttribute(nd, "name");
|
|
||||||
if (formName == null)
|
|
||||||
{
|
|
||||||
throw new SAXException("form element has no name attribute");
|
|
||||||
}
|
|
||||||
List<List<Map<String, String>>> pages = new ArrayList<List<Map<String, String>>>(); // the form contains pages
|
|
||||||
formDefns.put(formName, pages);
|
|
||||||
NodeList pl = nd.getChildNodes();
|
|
||||||
int lenpg = pl.getLength();
|
|
||||||
for (int j = 0; j < lenpg; j++)
|
|
||||||
{
|
|
||||||
Node npg = pl.item(j);
|
|
||||||
// process each page definition
|
|
||||||
if (npg.getNodeName().equals("page"))
|
|
||||||
{
|
|
||||||
String pgNum = getAttribute(npg, "number");
|
|
||||||
if (pgNum == null)
|
|
||||||
{
|
|
||||||
throw new SAXException("Form " + formName + " has no identified pages");
|
|
||||||
}
|
|
||||||
List<Map<String, String>> page = new ArrayList<Map<String, String>>();
|
|
||||||
pages.add(page);
|
|
||||||
NodeList flds = npg.getChildNodes();
|
|
||||||
int lenflds = flds.getLength();
|
|
||||||
for (int k = 0; k < lenflds; k++)
|
|
||||||
{
|
|
||||||
Node nfld = flds.item(k);
|
|
||||||
if ( nfld.getNodeName().equals("field") )
|
|
||||||
{
|
|
||||||
// process each field definition
|
|
||||||
Map<String, String> field = new HashMap<String, String>();
|
|
||||||
page.add(field);
|
|
||||||
processPageParts(formName, pgNum, nfld, field);
|
|
||||||
|
|
||||||
// we omit the duplicate validation, allowing multiple fields definition for
|
|
||||||
// the same metadata and different visibility/type-bind
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // ignore any child that is not a 'page'
|
|
||||||
}
|
|
||||||
// sanity check number of pages
|
|
||||||
if (pages.size() < 1)
|
|
||||||
{
|
|
||||||
throw new DCInputsReaderException("Form " + formName + " has no pages");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
List<List<Map<String, String>>> pages = new ArrayList<List<Map<String, String>>>(); // the form contains pages
|
||||||
|
formDefns.put(formName, pages);
|
||||||
|
NodeList pl = nd.getChildNodes();
|
||||||
|
int lenpg = pl.getLength();
|
||||||
|
for (int j = 0; j < lenpg; j++)
|
||||||
|
{
|
||||||
|
Node npg = pl.item(j);
|
||||||
|
// process each page definition
|
||||||
|
if (npg.getNodeName().equals("page"))
|
||||||
|
{
|
||||||
|
String pgNum = getAttribute(npg, "number");
|
||||||
|
if (pgNum == null)
|
||||||
|
{
|
||||||
|
throw new SAXException("Form " + formName + " has no identified pages");
|
||||||
|
}
|
||||||
|
List<Map<String, String>> page = new ArrayList<Map<String, String>>();
|
||||||
|
pages.add(page);
|
||||||
|
NodeList flds = npg.getChildNodes();
|
||||||
|
int lenflds = flds.getLength();
|
||||||
|
for (int k = 0; k < lenflds; k++)
|
||||||
|
{
|
||||||
|
Node nfld = flds.item(k);
|
||||||
|
if ( nfld.getNodeName().equals("field") )
|
||||||
|
{
|
||||||
|
// process each field definition
|
||||||
|
Map<String, String> field = new HashMap<String, String>();
|
||||||
|
page.add(field);
|
||||||
|
processPageParts(formName, pgNum, nfld, field);
|
||||||
|
|
||||||
|
// we omit the duplicate validation, allowing multiple fields definition for
|
||||||
|
// the same metadata and different visibility/type-bind
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // ignore any child that is not a 'page'
|
||||||
|
}
|
||||||
|
// sanity check number of pages
|
||||||
|
if (pages.size() < 1)
|
||||||
|
{
|
||||||
|
throw new DCInputsReaderException("Form " + formName + " has no pages");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (numForms == 0)
|
if (numForms == 0)
|
||||||
{
|
{
|
||||||
throw new DCInputsReaderException("No form definition found");
|
throw new DCInputsReaderException("No form definition found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,86 +371,86 @@ public class DCInputsReader
|
|||||||
int len = nl.getLength();
|
int len = nl.getLength();
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
Node nd = nl.item(i);
|
Node nd = nl.item(i);
|
||||||
if ( ! isEmptyTextNode(nd) )
|
if ( ! isEmptyTextNode(nd) )
|
||||||
|
{
|
||||||
|
String tagName = nd.getNodeName();
|
||||||
|
String value = getValue(nd);
|
||||||
|
field.put(tagName, value);
|
||||||
|
if (tagName.equals("input-type"))
|
||||||
{
|
{
|
||||||
String tagName = nd.getNodeName();
|
if (value.equals("dropdown")
|
||||||
String value = getValue(nd);
|
|| value.equals("qualdrop_value")
|
||||||
field.put(tagName, value);
|
|| value.equals("list"))
|
||||||
if (tagName.equals("input-type"))
|
{
|
||||||
|
String pairTypeName = getAttribute(nd, PAIR_TYPE_NAME);
|
||||||
|
if (pairTypeName == null)
|
||||||
{
|
{
|
||||||
if (value.equals("dropdown")
|
throw new SAXException("Form " + formName + ", field " +
|
||||||
|| value.equals("qualdrop_value")
|
field.get("dc-element") +
|
||||||
|| value.equals("list"))
|
"." + field.get("dc-qualifier") +
|
||||||
{
|
" has no name attribute");
|
||||||
String pairTypeName = getAttribute(nd, PAIR_TYPE_NAME);
|
|
||||||
if (pairTypeName == null)
|
|
||||||
{
|
|
||||||
throw new SAXException("Form " + formName + ", field " +
|
|
||||||
field.get("dc-element") +
|
|
||||||
"." + field.get("dc-qualifier") +
|
|
||||||
" has no name attribute");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
field.put(PAIR_TYPE_NAME, pairTypeName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (tagName.equals("vocabulary"))
|
else
|
||||||
{
|
{
|
||||||
String closedVocabularyString = getAttribute(nd, "closed");
|
field.put(PAIR_TYPE_NAME, pairTypeName);
|
||||||
field.put("closedVocabulary", closedVocabularyString);
|
|
||||||
}
|
|
||||||
else if (tagName.equals("language"))
|
|
||||||
{
|
|
||||||
if (Boolean.valueOf(value))
|
|
||||||
{
|
|
||||||
String pairTypeName = getAttribute(nd, PAIR_TYPE_NAME);
|
|
||||||
if (pairTypeName == null)
|
|
||||||
{
|
|
||||||
throw new SAXException("Form " + formName + ", field " +
|
|
||||||
field.get("dc-element") +
|
|
||||||
"." + field.get("dc-qualifier") +
|
|
||||||
" has no language attribute");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
field.put(PAIR_TYPE_NAME, pairTypeName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if (tagName.equals("vocabulary"))
|
||||||
|
{
|
||||||
|
String closedVocabularyString = getAttribute(nd, "closed");
|
||||||
|
field.put("closedVocabulary", closedVocabularyString);
|
||||||
|
}
|
||||||
|
else if (tagName.equals("language"))
|
||||||
|
{
|
||||||
|
if (Boolean.valueOf(value))
|
||||||
|
{
|
||||||
|
String pairTypeName = getAttribute(nd, PAIR_TYPE_NAME);
|
||||||
|
if (pairTypeName == null)
|
||||||
|
{
|
||||||
|
throw new SAXException("Form " + formName + ", field " +
|
||||||
|
field.get("dc-element") +
|
||||||
|
"." + field.get("dc-qualifier") +
|
||||||
|
" has no language attribute");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
field.put(PAIR_TYPE_NAME, pairTypeName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String missing = null;
|
String missing = null;
|
||||||
if (field.get("dc-element") == null)
|
if (field.get("dc-element") == null)
|
||||||
{
|
{
|
||||||
missing = "dc-element";
|
missing = "dc-element";
|
||||||
}
|
}
|
||||||
if (field.get("label") == null)
|
if (field.get("label") == null)
|
||||||
{
|
{
|
||||||
missing = "label";
|
missing = "label";
|
||||||
}
|
}
|
||||||
if (field.get("input-type") == null)
|
if (field.get("input-type") == null)
|
||||||
{
|
{
|
||||||
missing = "input-type";
|
missing = "input-type";
|
||||||
}
|
}
|
||||||
if ( missing != null )
|
if ( missing != null )
|
||||||
{
|
{
|
||||||
String msg = "Required field " + missing + " missing on page " + page + " of form " + formName;
|
String msg = "Required field " + missing + " missing on page " + page + " of form " + formName;
|
||||||
throw new SAXException(msg);
|
throw new SAXException(msg);
|
||||||
}
|
}
|
||||||
String type = field.get("input-type");
|
String type = field.get("input-type");
|
||||||
if (type.equals("twobox") || type.equals("qualdrop_value"))
|
if (type.equals("twobox") || type.equals("qualdrop_value"))
|
||||||
{
|
{
|
||||||
String rpt = field.get("repeatable");
|
String rpt = field.get("repeatable");
|
||||||
if ((rpt == null) ||
|
if ((rpt == null) ||
|
||||||
((!rpt.equalsIgnoreCase("yes")) &&
|
((!rpt.equalsIgnoreCase("yes")) &&
|
||||||
(!rpt.equalsIgnoreCase("true"))))
|
(!rpt.equalsIgnoreCase("true"))))
|
||||||
{
|
{
|
||||||
String msg = "The field \'"+field.get("label")+"\' must be repeatable";
|
String msg = "The field \'"+field.get("label")+"\' must be repeatable";
|
||||||
throw new SAXException(msg);
|
throw new SAXException(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,63 +529,62 @@ public class DCInputsReader
|
|||||||
* in the passed in hashmap.
|
* in the passed in hashmap.
|
||||||
*/
|
*/
|
||||||
private void processValuePairs(Node e)
|
private void processValuePairs(Node e)
|
||||||
throws SAXException
|
throws SAXException
|
||||||
{
|
{
|
||||||
NodeList nl = e.getChildNodes();
|
NodeList nl = e.getChildNodes();
|
||||||
int len = nl.getLength();
|
int len = nl.getLength();
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
Node nd = nl.item(i);
|
Node nd = nl.item(i);
|
||||||
String tagName = nd.getNodeName();
|
String tagName = nd.getNodeName();
|
||||||
|
|
||||||
// process each value-pairs set
|
// process each value-pairs set
|
||||||
if (tagName.equals("value-pairs"))
|
if (tagName.equals("value-pairs"))
|
||||||
|
{
|
||||||
|
String pairsName = getAttribute(nd, PAIR_TYPE_NAME);
|
||||||
|
String dcTerm = getAttribute(nd, "dc-term");
|
||||||
|
if (pairsName == null)
|
||||||
|
{
|
||||||
|
String errString =
|
||||||
|
"Missing name attribute for value-pairs for DC term " + dcTerm;
|
||||||
|
throw new SAXException(errString);
|
||||||
|
}
|
||||||
|
List<String> pairs = new ArrayList<String>();
|
||||||
|
valuePairs.put(pairsName, pairs);
|
||||||
|
NodeList cl = nd.getChildNodes();
|
||||||
|
int lench = cl.getLength();
|
||||||
|
for (int j = 0; j < lench; j++)
|
||||||
|
{
|
||||||
|
Node nch = cl.item(j);
|
||||||
|
String display = null;
|
||||||
|
String storage = null;
|
||||||
|
|
||||||
|
if (nch.getNodeName().equals("pair"))
|
||||||
{
|
{
|
||||||
String pairsName = getAttribute(nd, PAIR_TYPE_NAME);
|
NodeList pl = nch.getChildNodes();
|
||||||
String dcTerm = getAttribute(nd, "dc-term");
|
int plen = pl.getLength();
|
||||||
if (pairsName == null)
|
for (int k = 0; k < plen; k++)
|
||||||
{
|
{
|
||||||
String errString =
|
Node vn= pl.item(k);
|
||||||
"Missing name attribute for value-pairs for DC term " + dcTerm;
|
String vName = vn.getNodeName();
|
||||||
throw new SAXException(errString);
|
if (vName.equals("displayed-value"))
|
||||||
|
{
|
||||||
}
|
display = getValue(vn);
|
||||||
List<String> pairs = new ArrayList<String>();
|
}
|
||||||
valuePairs.put(pairsName, pairs);
|
else if (vName.equals("stored-value"))
|
||||||
NodeList cl = nd.getChildNodes();
|
{
|
||||||
int lench = cl.getLength();
|
storage = getValue(vn);
|
||||||
for (int j = 0; j < lench; j++)
|
if (storage == null)
|
||||||
{
|
|
||||||
Node nch = cl.item(j);
|
|
||||||
String display = null;
|
|
||||||
String storage = null;
|
|
||||||
|
|
||||||
if (nch.getNodeName().equals("pair"))
|
|
||||||
{
|
{
|
||||||
NodeList pl = nch.getChildNodes();
|
storage = "";
|
||||||
int plen = pl.getLength();
|
}
|
||||||
for (int k = 0; k < plen; k++)
|
} // ignore any children that aren't 'display' or 'storage'
|
||||||
{
|
|
||||||
Node vn= pl.item(k);
|
|
||||||
String vName = vn.getNodeName();
|
|
||||||
if (vName.equals("displayed-value"))
|
|
||||||
{
|
|
||||||
display = getValue(vn);
|
|
||||||
}
|
|
||||||
else if (vName.equals("stored-value"))
|
|
||||||
{
|
|
||||||
storage = getValue(vn);
|
|
||||||
if (storage == null)
|
|
||||||
{
|
|
||||||
storage = "";
|
|
||||||
}
|
|
||||||
} // ignore any children that aren't 'display' or 'storage'
|
|
||||||
}
|
|
||||||
pairs.add(display);
|
|
||||||
pairs.add(storage);
|
|
||||||
} // ignore any children that aren't a 'pair'
|
|
||||||
}
|
}
|
||||||
} // ignore any children that aren't a 'value-pair'
|
pairs.add(display);
|
||||||
|
pairs.add(storage);
|
||||||
|
} // ignore any children that aren't a 'pair'
|
||||||
|
}
|
||||||
|
} // ignore any children that aren't a 'value-pair'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -595,40 +597,39 @@ public class DCInputsReader
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
private void checkValues()
|
private void checkValues()
|
||||||
throws DCInputsReaderException
|
throws DCInputsReaderException
|
||||||
{
|
{
|
||||||
// Step through every field of every page of every form
|
// Step through every field of every page of every form
|
||||||
Iterator<String> ki = formDefns.keySet().iterator();
|
Iterator<String> ki = formDefns.keySet().iterator();
|
||||||
while (ki.hasNext())
|
while (ki.hasNext())
|
||||||
{
|
{
|
||||||
String idName = ki.next();
|
String idName = ki.next();
|
||||||
List<List<Map<String, String>>> pages = formDefns.get(idName);
|
List<List<Map<String, String>>> pages = formDefns.get(idName);
|
||||||
for (int i = 0; i < pages.size(); i++)
|
for (int i = 0; i < pages.size(); i++)
|
||||||
|
{
|
||||||
|
List<Map<String, String>> page = pages.get(i);
|
||||||
|
for (int j = 0; j < page.size(); j++)
|
||||||
{
|
{
|
||||||
List<Map<String, String>> page = pages.get(i);
|
Map<String, String> fld = page.get(j);
|
||||||
for (int j = 0; j < page.size(); j++)
|
// verify reference in certain input types
|
||||||
{
|
String type = fld.get("input-type");
|
||||||
Map<String, String> fld = page.get(j);
|
|
||||||
// verify reference in certain input types
|
|
||||||
String type = fld.get("input-type");
|
|
||||||
if (type.equals("dropdown")
|
if (type.equals("dropdown")
|
||||||
|| type.equals("qualdrop_value")
|
|| type.equals("qualdrop_value")
|
||||||
|| type.equals("list"))
|
|| type.equals("list"))
|
||||||
{
|
{
|
||||||
String pairsName = fld.get(PAIR_TYPE_NAME);
|
String pairsName = fld.get(PAIR_TYPE_NAME);
|
||||||
List<String> v = valuePairs.get(pairsName);
|
List<String> v = valuePairs.get(pairsName);
|
||||||
if (v == null)
|
if (v == null)
|
||||||
{
|
{
|
||||||
String errString = "Cannot find value pairs for " + pairsName;
|
String errString = "Cannot find value pairs for " + pairsName;
|
||||||
throw new DCInputsReaderException(errString);
|
throw new DCInputsReaderException(errString);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// we omit the "required" and "visibility" validation, provided this must be checked in the processing class
|
|
||||||
// only when it makes sense (if the field isn't visible means that it is not applicable, therefore it can't be required)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// we omit the "required" and "visibility" validation, provided this must be checked in the processing class
|
||||||
|
// only when it makes sense (if the field isn't visible means that it is not applicable, therefore it can't be required)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -652,11 +653,11 @@ public class DCInputsReader
|
|||||||
boolean isEmpty = false;
|
boolean isEmpty = false;
|
||||||
if (nd.getNodeType() == Node.TEXT_NODE)
|
if (nd.getNodeType() == Node.TEXT_NODE)
|
||||||
{
|
{
|
||||||
String text = nd.getNodeValue().trim();
|
String text = nd.getNodeValue().trim();
|
||||||
if (text.length() == 0)
|
if (text.length() == 0)
|
||||||
{
|
{
|
||||||
isEmpty = true;
|
isEmpty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isEmpty;
|
return isEmpty;
|
||||||
}
|
}
|
||||||
@@ -670,15 +671,15 @@ public class DCInputsReader
|
|||||||
int len = attrs.getLength();
|
int len = attrs.getLength();
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
Node attr = attrs.item(i);
|
||||||
|
if (name.equals(attr.getNodeName()))
|
||||||
{
|
{
|
||||||
Node attr = attrs.item(i);
|
return attr.getNodeValue().trim();
|
||||||
if (name.equals(attr.getNodeName()))
|
|
||||||
{
|
|
||||||
return attr.getNodeValue().trim();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//no such attribute
|
//no such attribute
|
||||||
return null;
|
return null;
|
||||||
@@ -694,12 +695,12 @@ public class DCInputsReader
|
|||||||
int len = nl.getLength();
|
int len = nl.getLength();
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
Node n = nl.item(i);
|
Node n = nl.item(i);
|
||||||
short type = n.getNodeType();
|
short type = n.getNodeType();
|
||||||
if (type == Node.TEXT_NODE)
|
if (type == Node.TEXT_NODE)
|
||||||
{
|
{
|
||||||
return n.getNodeValue().trim();
|
return n.getNodeValue().trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Didn't find a text node
|
// Didn't find a text node
|
||||||
return null;
|
return null;
|
||||||
|
@@ -30,6 +30,7 @@ public class DSpaceContextListener implements ServletContextListener
|
|||||||
/**
|
/**
|
||||||
* Initialize any resources required by the application.
|
* Initialize any resources required by the application.
|
||||||
* @param event
|
* @param event
|
||||||
|
* This is the event class for notifications about changes to the servlet context of a web application.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void contextInitialized(ServletContextEvent event)
|
public void contextInitialized(ServletContextEvent event)
|
||||||
@@ -63,6 +64,7 @@ public class DSpaceContextListener implements ServletContextListener
|
|||||||
* Clean up resources used by the application when stopped
|
* Clean up resources used by the application when stopped
|
||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
|
8 Event class for notifications about changes to the servlet context of a web application.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void contextDestroyed(ServletContextEvent event)
|
public void contextDestroyed(ServletContextEvent event)
|
||||||
|
@@ -229,6 +229,7 @@ public class GoogleMetadata
|
|||||||
* first-encountered instance of the field for this Item.
|
* first-encountered instance of the field for this Item.
|
||||||
*
|
*
|
||||||
* @param fieldName
|
* @param fieldName
|
||||||
|
* metadata field name
|
||||||
* @return successful?
|
* @return successful?
|
||||||
*/
|
*/
|
||||||
protected boolean addSingleField(String fieldName)
|
protected boolean addSingleField(String fieldName)
|
||||||
@@ -262,7 +263,7 @@ public class GoogleMetadata
|
|||||||
if (config.equals("$simple-pdf"))
|
if (config.equals("$simple-pdf"))
|
||||||
{
|
{
|
||||||
String pdf_url = getPDFSimpleUrl(item);
|
String pdf_url = getPDFSimpleUrl(item);
|
||||||
if(pdf_url.length() > 0)
|
if (pdf_url.length() > 0)
|
||||||
{
|
{
|
||||||
metadataMappings.put(fieldName, pdf_url);
|
metadataMappings.put(fieldName, pdf_url);
|
||||||
return true;
|
return true;
|
||||||
@@ -291,6 +292,7 @@ public class GoogleMetadata
|
|||||||
* instead of an aggregate.
|
* instead of an aggregate.
|
||||||
*
|
*
|
||||||
* @param configFilter
|
* @param configFilter
|
||||||
|
* list of DC metadata fields separated by "|" characters
|
||||||
* @return The first configured match of metadata field for the item.
|
* @return The first configured match of metadata field for the item.
|
||||||
*/
|
*/
|
||||||
protected MetadataValue resolveMetadataField(String configFilter)
|
protected MetadataValue resolveMetadataField(String configFilter)
|
||||||
@@ -309,6 +311,7 @@ public class GoogleMetadata
|
|||||||
* A plural version of resolveMetadata for aggregate fields.
|
* A plural version of resolveMetadata for aggregate fields.
|
||||||
*
|
*
|
||||||
* @param configFilter
|
* @param configFilter
|
||||||
|
* list of DC metadata fields separated by "|" characters
|
||||||
* @return Aggregate of all matching metadata fields configured in the first
|
* @return Aggregate of all matching metadata fields configured in the first
|
||||||
* option field-set to return any number of filter matches.
|
* option field-set to return any number of filter matches.
|
||||||
*/
|
*/
|
||||||
@@ -328,7 +331,9 @@ public class GoogleMetadata
|
|||||||
* configuration filter.
|
* configuration filter.
|
||||||
*
|
*
|
||||||
* @param configFilter
|
* @param configFilter
|
||||||
|
* list of DC metadata fields separated by "|" characters
|
||||||
* @param returnType
|
* @param returnType
|
||||||
|
* GoogleMetadata.SINGLE / GoogleMetadata.MULTI / GoogleMetadata.ALL_FIELDS_IN_OPTION
|
||||||
* @return Array of configuration to item-field matches
|
* @return Array of configuration to item-field matches
|
||||||
*/
|
*/
|
||||||
protected ArrayList<MetadataValue> resolveMetadata(String configFilter,
|
protected ArrayList<MetadataValue> resolveMetadata(String configFilter,
|
||||||
@@ -350,8 +355,7 @@ public class GoogleMetadata
|
|||||||
|
|
||||||
if (log.isDebugEnabled())
|
if (log.isDebugEnabled())
|
||||||
{
|
{
|
||||||
log
|
log.debug("Resolved Fields For This Item Per Configuration Filter:");
|
||||||
.debug("Resolved Fields For This Item Per Configuration Filter:");
|
|
||||||
for (int i = 0; i < parsedOptions.size(); i++)
|
for (int i = 0; i < parsedOptions.size(); i++)
|
||||||
{
|
{
|
||||||
ArrayList<String> optionFields = parsedOptions.get(i);
|
ArrayList<String> optionFields = parsedOptions.get(i);
|
||||||
@@ -445,6 +449,7 @@ public class GoogleMetadata
|
|||||||
* configuration.
|
* configuration.
|
||||||
*
|
*
|
||||||
* @param configFilter
|
* @param configFilter
|
||||||
|
* list of DC metadata fields separated by "|" characters
|
||||||
* @return array of parsed options or null
|
* @return array of parsed options or null
|
||||||
*/
|
*/
|
||||||
protected ArrayList<ArrayList<String>> parseOptions(String configFilter)
|
protected ArrayList<ArrayList<String>> parseOptions(String configFilter)
|
||||||
@@ -720,7 +725,7 @@ public class GoogleMetadata
|
|||||||
// Dissertations
|
// Dissertations
|
||||||
if (itemIsDissertation())
|
if (itemIsDissertation())
|
||||||
{
|
{
|
||||||
if(log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("ITEM TYPE: DISSERTATION");
|
log.debug("ITEM TYPE: DISSERTATION");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -731,7 +736,7 @@ public class GoogleMetadata
|
|||||||
// Patents
|
// Patents
|
||||||
if (itemIsPatent())
|
if (itemIsPatent())
|
||||||
{
|
{
|
||||||
if(log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("ITEM TYPE: PATENT");
|
log.debug("ITEM TYPE: PATENT");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -750,7 +755,7 @@ public class GoogleMetadata
|
|||||||
// Tech Reports
|
// Tech Reports
|
||||||
if (itemIsTechReport())
|
if (itemIsTechReport())
|
||||||
{
|
{
|
||||||
if(log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("ITEM TYPE: TECH REPORT");
|
log.debug("ITEM TYPE: TECH REPORT");
|
||||||
}
|
}
|
||||||
addSingleField(TECH_REPORT_NUMBER);
|
addSingleField(TECH_REPORT_NUMBER);
|
||||||
@@ -758,7 +763,7 @@ public class GoogleMetadata
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!itemIsDissertation() && !itemIsTechReport()) {
|
if (!itemIsDissertation() && !itemIsTechReport()) {
|
||||||
// PUBLISHER
|
// PUBLISHER
|
||||||
addSingleField(PUBLISHER);
|
addSingleField(PUBLISHER);
|
||||||
}
|
}
|
||||||
@@ -1004,31 +1009,31 @@ public class GoogleMetadata
|
|||||||
* is in the default content bundle, and that the item only has one public bitstream
|
* is in the default content bundle, and that the item only has one public bitstream
|
||||||
* and it is a PDF.
|
* and it is a PDF.
|
||||||
*
|
*
|
||||||
* @param item
|
* @param item item to get PDF URL from
|
||||||
* @return URL that the PDF can be directly downloaded from
|
* @return URL that the PDF can be directly downloaded from
|
||||||
*/
|
*/
|
||||||
protected String getPDFSimpleUrl(Item item)
|
protected String getPDFSimpleUrl(Item item)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Bitstream bitstream = findLinkableFulltext(item);
|
Bitstream bitstream = findLinkableFulltext(item);
|
||||||
if (bitstream != null) {
|
if (bitstream != null) {
|
||||||
StringBuilder path = new StringBuilder();
|
StringBuilder path = new StringBuilder();
|
||||||
path.append(ConfigurationManager.getProperty("dspace.url"));
|
path.append(ConfigurationManager.getProperty("dspace.url"));
|
||||||
|
|
||||||
if (item.getHandle() != null) {
|
if (item.getHandle() != null) {
|
||||||
path.append("/bitstream/");
|
path.append("/bitstream/");
|
||||||
path.append(item.getHandle());
|
path.append(item.getHandle());
|
||||||
path.append("/");
|
path.append("/");
|
||||||
path.append(bitstream.getSequenceID());
|
path.append(bitstream.getSequenceID());
|
||||||
} else {
|
} else {
|
||||||
path.append("/retrieve/");
|
path.append("/retrieve/");
|
||||||
path.append(bitstream.getID());
|
path.append(bitstream.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
path.append("/");
|
path.append("/");
|
||||||
path.append(Util.encodeBitstreamName(bitstream.getName(), Constants.DEFAULT_ENCODING));
|
path.append(Util.encodeBitstreamName(bitstream.getName(), Constants.DEFAULT_ENCODING));
|
||||||
return path.toString();
|
return path.toString();
|
||||||
}
|
}
|
||||||
} catch (UnsupportedEncodingException ex) {
|
} catch (UnsupportedEncodingException ex) {
|
||||||
log.debug(ex.getMessage());
|
log.debug(ex.getMessage());
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
@@ -1038,22 +1043,24 @@ public class GoogleMetadata
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A bitstream is considered linkable fulltext when it is either
|
* A bitstream is considered linkable fulltext when it is either
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>the item's only bitstream (in the ORIGINAL bundle); or</li>
|
* <li>the item's only bitstream (in the ORIGINAL bundle); or</li>
|
||||||
* <li>the primary bitstream</li>
|
* <li>the primary bitstream</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* Additionally, this bitstream must be publicly viewable.
|
* Additionally, this bitstream must be publicly viewable.
|
||||||
* @param item
|
*
|
||||||
* @return a linkable bitstream or null if none found
|
* @param item
|
||||||
* @throws SQLException if database error
|
* bitstream's parent item
|
||||||
*/
|
* @return a linkable bitstream or null if none found
|
||||||
protected Bitstream findLinkableFulltext(Item item) throws SQLException {
|
* @throws SQLException if database error
|
||||||
Bitstream bestSoFar = null;
|
*/
|
||||||
int bitstreamCount = 0;
|
protected Bitstream findLinkableFulltext(Item item) throws SQLException {
|
||||||
List<Bundle> contentBundles = itemService.getBundles(item, "ORIGINAL");
|
Bitstream bestSoFar = null;
|
||||||
for (Bundle bundle : contentBundles) {
|
int bitstreamCount = 0;
|
||||||
|
List<Bundle> contentBundles = itemService.getBundles(item, "ORIGINAL");
|
||||||
|
for (Bundle bundle : contentBundles) {
|
||||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||||
for (Bitstream candidate : bitstreams) {
|
for (Bitstream candidate : bitstreams) {
|
||||||
if (candidate.equals(bundle.getPrimaryBitstream())) { // is primary -> use this one
|
if (candidate.equals(bundle.getPrimaryBitstream())) { // is primary -> use this one
|
||||||
@@ -1068,25 +1075,32 @@ public class GoogleMetadata
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bestSoFar;
|
return bestSoFar;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isPublic(Bitstream bitstream) {
|
/**
|
||||||
if (bitstream == null) {
|
* Find out whether bitstream is readable by the public.
|
||||||
return false;
|
*
|
||||||
}
|
* @param bitstream
|
||||||
boolean result = false;
|
* the target bitstream
|
||||||
Context context = null;
|
* @return whether bitstream is readable by the Anonymous group
|
||||||
try {
|
*/
|
||||||
context = new Context();
|
protected boolean isPublic(Bitstream bitstream) {
|
||||||
result = AuthorizeServiceFactory.getInstance().getAuthorizeService().authorizeActionBoolean(context, bitstream, Constants.READ, true);
|
if (bitstream == null) {
|
||||||
} catch (SQLException e) {
|
return false;
|
||||||
log.error("Cannot determine whether bitstream is public, assuming it isn't. bitstream_id=" + bitstream.getID(), e);
|
}
|
||||||
}
|
boolean result = false;
|
||||||
return result;
|
Context context = null;
|
||||||
}
|
try {
|
||||||
|
context = new Context();
|
||||||
|
result = AuthorizeServiceFactory.getInstance().getAuthorizeService().authorizeActionBoolean(context, bitstream, Constants.READ, true);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
log.error("Cannot determine whether bitstream is public, assuming it isn't. bitstream_id=" + bitstream.getID(), e);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @param field
|
* @param field
|
||||||
@@ -1122,6 +1136,7 @@ public class GoogleMetadata
|
|||||||
/**
|
/**
|
||||||
* If metadata field contains multiple values, then add each value to the map separately
|
* If metadata field contains multiple values, then add each value to the map separately
|
||||||
* @param FIELD
|
* @param FIELD
|
||||||
|
* metadata field
|
||||||
*/
|
*/
|
||||||
protected void addMultipleValues(String FIELD)
|
protected void addMultipleValues(String FIELD)
|
||||||
{
|
{
|
||||||
@@ -1201,6 +1216,7 @@ public class GoogleMetadata
|
|||||||
* metadata practice.
|
* metadata practice.
|
||||||
*
|
*
|
||||||
* @param dConfig
|
* @param dConfig
|
||||||
|
* configured fields (from google-metadata.properties)
|
||||||
* @return item matches configuration
|
* @return item matches configuration
|
||||||
*/
|
*/
|
||||||
protected boolean identifyItemType(String dConfig)
|
protected boolean identifyItemType(String dConfig)
|
||||||
@@ -1223,7 +1239,7 @@ public class GoogleMetadata
|
|||||||
if (mdPairs.containsKey(parsedPair[0].trim()))
|
if (mdPairs.containsKey(parsedPair[0].trim()))
|
||||||
{
|
{
|
||||||
mdPairs.get(parsedPair[0].trim()).add(parsedPair[1]);
|
mdPairs.get(parsedPair[0].trim()).add(parsedPair[1]);
|
||||||
if(log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Registering Type Identifier: " + parsedPair[0] + " => " + parsedPair[1]);
|
log.debug("Registering Type Identifier: " + parsedPair[0] + " => " + parsedPair[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -85,50 +85,50 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
|
|||||||
public void afterPropertiesSet() throws Exception
|
public void afterPropertiesSet() throws Exception
|
||||||
{
|
{
|
||||||
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
|
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||||
enabled = config.getBooleanProperty("websvc.opensearch.enable");
|
enabled = config.getBooleanProperty("websvc.opensearch.enable");
|
||||||
svcUrl = config.getProperty("dspace.url") + "/" +
|
svcUrl = config.getProperty("dspace.url") + "/" +
|
||||||
config.getProperty("websvc.opensearch.svccontext");
|
config.getProperty("websvc.opensearch.svccontext");
|
||||||
uiUrl = config.getProperty("dspace.url") + "/" +
|
uiUrl = config.getProperty("dspace.url") + "/" +
|
||||||
config.getProperty("websvc.opensearch.uicontext");
|
config.getProperty("websvc.opensearch.uicontext");
|
||||||
|
|
||||||
// read rest of config info if enabled
|
// read rest of config info if enabled
|
||||||
formats = new ArrayList<String>();
|
formats = new ArrayList<String>();
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
String[] fmts = config.getArrayProperty("websvc.opensearch.formats");
|
String[] fmts = config.getArrayProperty("websvc.opensearch.formats");
|
||||||
formats = Arrays.asList(fmts);
|
formats = Arrays.asList(fmts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getFormats()
|
public List<String> getFormats()
|
||||||
{
|
{
|
||||||
return formats;
|
return formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getContentType(String format)
|
public String getContentType(String format)
|
||||||
{
|
{
|
||||||
return "html".equals(format) ? "text/html" :
|
return "html".equals(format) ? "text/html" :
|
||||||
"application/" + format + "+xml; charset=UTF-8";
|
"application/" + format + "+xml; charset=UTF-8";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Document getDescriptionDoc(String scope) throws IOException
|
public Document getDescriptionDoc(String scope) throws IOException
|
||||||
{
|
{
|
||||||
return jDomToW3(getServiceDocument(scope));
|
return jDomToW3(getServiceDocument(scope));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDescription(String scope)
|
public String getDescription(String scope)
|
||||||
{
|
{
|
||||||
return new XMLOutputter().outputString(getServiceDocument(scope));
|
return new XMLOutputter().outputString(getServiceDocument(scope));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getResultsString(Context context, String format, String query, int totalResults, int start, int pageSize,
|
public String getResultsString(Context context, String format, String query, int totalResults, int start, int pageSize,
|
||||||
DSpaceObject scope, List<DSpaceObject> results,
|
DSpaceObject scope, List<DSpaceObject> results,
|
||||||
Map<String, String> labels) throws IOException
|
Map<String, String> labels) throws IOException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -137,13 +137,13 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
|
|||||||
catch (FeedException e)
|
catch (FeedException e)
|
||||||
{
|
{
|
||||||
log.error(e.toString(), e);
|
log.error(e.toString(), e);
|
||||||
throw new IOException("Unable to generate feed", e);
|
throw new IOException("Unable to generate feed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start, int pageSize,
|
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start, int pageSize,
|
||||||
DSpaceObject scope, List<DSpaceObject> results, Map<String, String> labels)
|
DSpaceObject scope, List<DSpaceObject> results, Map<String, String> labels)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -169,13 +169,13 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
|
|||||||
{
|
{
|
||||||
format = "atom_1.0";
|
format = "atom_1.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
SyndicationFeed feed = new SyndicationFeed(labels.get(SyndicationFeed.MSG_UITYPE));
|
SyndicationFeed feed = new SyndicationFeed(labels.get(SyndicationFeed.MSG_UITYPE));
|
||||||
feed.populate(null, context, scope, results, labels);
|
feed.populate(null, context, scope, results, labels);
|
||||||
feed.setType(format);
|
feed.setType(format);
|
||||||
feed.addModule(openSearchMarkup(query, totalResults, start, pageSize));
|
feed.addModule(openSearchMarkup(query, totalResults, start, pageSize));
|
||||||
return feed;
|
return feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generates the OpenSearch elements which are added to the RSS or Atom feeds as foreign markup
|
* Generates the OpenSearch elements which are added to the RSS or Atom feeds as foreign markup
|
||||||
@@ -187,17 +187,17 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
|
|||||||
*/
|
*/
|
||||||
protected OpenSearchModule openSearchMarkup(String query, int totalResults, int start, int pageSize)
|
protected OpenSearchModule openSearchMarkup(String query, int totalResults, int start, int pageSize)
|
||||||
{
|
{
|
||||||
OpenSearchModule osMod = new OpenSearchModuleImpl();
|
OpenSearchModule osMod = new OpenSearchModuleImpl();
|
||||||
osMod.setTotalResults(totalResults);
|
osMod.setTotalResults(totalResults);
|
||||||
osMod.setStartIndex(start);
|
osMod.setStartIndex(start);
|
||||||
osMod.setItemsPerPage(pageSize);
|
osMod.setItemsPerPage(pageSize);
|
||||||
OSQuery osq = new OSQuery();
|
OSQuery osq = new OSQuery();
|
||||||
osq.setRole("request");
|
osq.setRole("request");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
osq.setSearchTerms(URLEncoder.encode(query, "UTF-8"));
|
osq.setSearchTerms(URLEncoder.encode(query, "UTF-8"));
|
||||||
}
|
}
|
||||||
catch(UnsupportedEncodingException e)
|
catch (UnsupportedEncodingException e)
|
||||||
{
|
{
|
||||||
log.error(e);
|
log.error(e);
|
||||||
}
|
}
|
||||||
@@ -216,7 +216,7 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
|
|||||||
{
|
{
|
||||||
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
|
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||||
|
|
||||||
Namespace ns = Namespace.getNamespace(osNs);
|
Namespace ns = Namespace.getNamespace(osNs);
|
||||||
Element root = new Element("OpenSearchDescription", ns);
|
Element root = new Element("OpenSearchDescription", ns);
|
||||||
root.addContent(new Element("ShortName", ns).setText(config.getProperty("websvc.opensearch.shortname")));
|
root.addContent(new Element("ShortName", ns).setText(config.getProperty("websvc.opensearch.shortname")));
|
||||||
root.addContent(new Element("LongName", ns).setText(config.getProperty("websvc.opensearch.longname")));
|
root.addContent(new Element("LongName", ns).setText(config.getProperty("websvc.opensearch.longname")));
|
||||||
@@ -227,61 +227,63 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
|
|||||||
String sample = config.getProperty("websvc.opensearch.samplequery");
|
String sample = config.getProperty("websvc.opensearch.samplequery");
|
||||||
if (sample != null && sample.length() > 0)
|
if (sample != null && sample.length() > 0)
|
||||||
{
|
{
|
||||||
Element sq = new Element("Query", ns).setAttribute("role", "example");
|
Element sq = new Element("Query", ns).setAttribute("role", "example");
|
||||||
root.addContent(sq.setAttribute("searchTerms", sample));
|
root.addContent(sq.setAttribute("searchTerms", sample));
|
||||||
}
|
}
|
||||||
String tags = config.getProperty("websvc.opensearch.tags");
|
String tags = config.getProperty("websvc.opensearch.tags");
|
||||||
if (tags != null && tags.length() > 0)
|
if (tags != null && tags.length() > 0)
|
||||||
{
|
{
|
||||||
root.addContent(new Element("Tags", ns).setText(tags));
|
root.addContent(new Element("Tags", ns).setText(tags));
|
||||||
}
|
}
|
||||||
String contact = config.getProperty("mail.admin");
|
String contact = config.getProperty("mail.admin");
|
||||||
if (contact != null && contact.length() > 0)
|
if (contact != null && contact.length() > 0)
|
||||||
{
|
{
|
||||||
root.addContent(new Element("Contact", ns).setText(contact));
|
root.addContent(new Element("Contact", ns).setText(contact));
|
||||||
}
|
}
|
||||||
String faviconUrl = config.getProperty("websvc.opensearch.faviconurl");
|
String faviconUrl = config.getProperty("websvc.opensearch.faviconurl");
|
||||||
if (faviconUrl != null && faviconUrl.length() > 0)
|
if (faviconUrl != null && faviconUrl.length() > 0)
|
||||||
{
|
{
|
||||||
String dim = String.valueOf(16);
|
String dim = String.valueOf(16);
|
||||||
String type = faviconUrl.endsWith("ico") ? "image/vnd.microsoft.icon" : "image/png";
|
String type = faviconUrl.endsWith("ico") ? "image/vnd.microsoft.icon" : "image/png";
|
||||||
Element fav = new Element("Image", ns).setAttribute("height", dim).setAttribute("width", dim).
|
Element fav = new Element("Image", ns).setAttribute("height", dim).setAttribute("width", dim).
|
||||||
setAttribute("type", type).setText(faviconUrl);
|
setAttribute("type", type).setText(faviconUrl);
|
||||||
root.addContent(fav);
|
root.addContent(fav);
|
||||||
}
|
}
|
||||||
// service URLs
|
// service URLs
|
||||||
for (String format : formats)
|
for (String format : formats)
|
||||||
{
|
{
|
||||||
Element url = new Element("Url", ns).setAttribute("type", getContentType(format));
|
Element url = new Element("Url", ns).setAttribute("type", getContentType(format));
|
||||||
StringBuilder template = new StringBuilder();
|
StringBuilder template = new StringBuilder();
|
||||||
if ("html".equals(format))
|
if ("html".equals(format))
|
||||||
{
|
{
|
||||||
template.append(uiUrl);
|
template.append(uiUrl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
template.append(svcUrl);
|
template.append(svcUrl);
|
||||||
}
|
}
|
||||||
template.append("?query={searchTerms}");
|
template.append("?query={searchTerms}");
|
||||||
if(! "html".equals(format))
|
if(! "html".equals(format))
|
||||||
{
|
{
|
||||||
template.append("&start={startIndex?}&rpp={count?}&format=");
|
template.append("&start={startIndex?}&rpp={count?}&format=");
|
||||||
template.append(format);
|
template.append(format);
|
||||||
}
|
}
|
||||||
if (scope != null)
|
if (scope != null)
|
||||||
{
|
{
|
||||||
template.append("&scope=");
|
template.append("&scope=");
|
||||||
template.append(scope);
|
template.append(scope);
|
||||||
}
|
}
|
||||||
url.setAttribute("template", template.toString());
|
url.setAttribute("template", template.toString());
|
||||||
root.addContent(url);
|
root.addContent(url);
|
||||||
}
|
}
|
||||||
return new org.jdom.Document(root);
|
return new org.jdom.Document(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a JDOM document to a W3C one
|
* Converts a JDOM document to a W3C one
|
||||||
|
*
|
||||||
* @param jdomDoc
|
* @param jdomDoc
|
||||||
|
* jDOM document to convert
|
||||||
* @return W3C Document object
|
* @return W3C Document object
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
*/
|
*/
|
||||||
@@ -290,11 +292,11 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
|
|||||||
DOMOutputter domOut = new DOMOutputter();
|
DOMOutputter domOut = new DOMOutputter();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return domOut.output(jdomDoc);
|
return domOut.output(jdomDoc);
|
||||||
}
|
}
|
||||||
catch(JDOMException jde)
|
catch (JDOMException jde)
|
||||||
{
|
{
|
||||||
throw new IOException("JDOM output exception", jde);
|
throw new IOException("JDOM output exception", jde);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -39,7 +39,7 @@ public class SubmissionStepConfig implements Serializable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* the id for this step ('id' only exists if this step is defined in the
|
* the id for this step ('id' only exists if this step is defined in the
|
||||||
* <step-definitions> section)
|
* <step-definitions> section)
|
||||||
*/
|
*/
|
||||||
private String id = null;
|
private String id = null;
|
||||||
|
|
||||||
|
@@ -13,13 +13,15 @@ import java.net.Inet6Address;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* <p>
|
||||||
* Quickly tests whether a given IP address matches an IP range. An
|
* Quickly tests whether a given IP address matches an IP range. An
|
||||||
* {@code IPMatcher} is initialized with a particular IP range specification.
|
* {@code IPMatcher} is initialized with a particular IP range specification.
|
||||||
* Calls to {@link IPMatcher#match(String) match} method will then quickly
|
* Calls to {@link IPMatcher#match(String) match} method will then quickly
|
||||||
* determine whether a given IP falls within that range.
|
* determine whether a given IP falls within that range.
|
||||||
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* Supported range specifications are:
|
* Supported range specifications are:
|
||||||
* <p>
|
* </p>
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Full IPv4 address, e.g. {@code 12.34.56.78}</li>
|
* <li>Full IPv4 address, e.g. {@code 12.34.56.78}</li>
|
||||||
* <li>Full IPv6 address, e.g. {@code 2001:18e8:3:171:218:8bff:fe2a:56a4}</li>
|
* <li>Full IPv6 address, e.g. {@code 2001:18e8:3:171:218:8bff:fe2a:56a4}</li>
|
||||||
@@ -32,7 +34,7 @@ import java.net.UnknownHostException;
|
|||||||
*
|
*
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
* @author Robert Tansley
|
* @author Robert Tansley
|
||||||
* @author Ben Bosman
|
* @author Ben Bosman
|
||||||
* @author Roeland Dillen
|
* @author Roeland Dillen
|
||||||
*/
|
*/
|
||||||
public class IPMatcher
|
public class IPMatcher
|
||||||
|
@@ -242,8 +242,9 @@ public class AuthorityValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a string that will allow this AuthorityType to be recognized and provides information to create a new instance to be created using public AuthorityValue newInstance(String info).
|
* Provides a string that will allow this AuthorityType to be recognized and
|
||||||
* See the implementation of {@link com.atmire.org.dspace.authority.AuthorityValueGenerator#generateRaw(java.lang.String, java.lang.String) AuthorityValueGenerator#generateRaw(java.lang.String, java.lang.String)} for more details.
|
* provides information to create a new instance to be created using {@link #newInstance(String)}.
|
||||||
|
* See the implementation of {@link org.dspace.authority.AuthorityValueServiceImpl#generateRaw(java.lang.String, java.lang.String, java.lang.String)} for more details.
|
||||||
* @return see {@link org.dspace.authority.service.AuthorityValueService#GENERATE AuthorityValueService.GENERATE}
|
* @return see {@link org.dspace.authority.service.AuthorityValueService#GENERATE AuthorityValueService.GENERATE}
|
||||||
*/
|
*/
|
||||||
public String generateString() {
|
public String generateString() {
|
||||||
|
@@ -37,6 +37,7 @@ public class AuthorizeException extends Exception
|
|||||||
* create an exception with only a message
|
* create an exception with only a message
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message
|
||||||
|
* Exception message
|
||||||
*/
|
*/
|
||||||
public AuthorizeException(String message)
|
public AuthorizeException(String message)
|
||||||
{
|
{
|
||||||
|
@@ -92,7 +92,7 @@ public class AuthorizeServiceImpl implements AuthorizeService
|
|||||||
@Override
|
@Override
|
||||||
public void authorizeAction(Context c, DSpaceObject o, int action, boolean useInheritance) throws AuthorizeException, SQLException
|
public void authorizeAction(Context c, DSpaceObject o, int action, boolean useInheritance) throws AuthorizeException, SQLException
|
||||||
{
|
{
|
||||||
authorizeAction(c, c.getCurrentUser(), o, action, useInheritance);
|
authorizeAction(c, c.getCurrentUser(), o, action, useInheritance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -538,12 +538,12 @@ public class AuthorizeServiceImpl implements AuthorizeService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void switchPoliciesAction(Context context, DSpaceObject dso, int fromAction, int toAction) throws SQLException, AuthorizeException {
|
public void switchPoliciesAction(Context context, DSpaceObject dso, int fromAction, int toAction) throws SQLException, AuthorizeException {
|
||||||
List<ResourcePolicy> rps = getPoliciesActionFilter(context, dso, fromAction);
|
List<ResourcePolicy> rps = getPoliciesActionFilter(context, dso, fromAction);
|
||||||
for (ResourcePolicy rp : rps) {
|
for (ResourcePolicy rp : rps) {
|
||||||
rp.setAction(toAction);
|
rp.setAction(toAction);
|
||||||
}
|
}
|
||||||
resourcePolicyService.update(context, rps);
|
resourcePolicyService.update(context, rps);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addPolicies(Context c, List<ResourcePolicy> policies, DSpaceObject dest)
|
public void addPolicies(Context c, List<ResourcePolicy> policies, DSpaceObject dest)
|
||||||
@@ -624,7 +624,7 @@ public class AuthorizeServiceImpl implements AuthorizeService
|
|||||||
|
|
||||||
List<Group> groups = new ArrayList<Group>();
|
List<Group> groups = new ArrayList<Group>();
|
||||||
for (ResourcePolicy resourcePolicy : policies) {
|
for (ResourcePolicy resourcePolicy : policies) {
|
||||||
if(resourcePolicy.getGroup() != null)
|
if (resourcePolicy.getGroup() != null)
|
||||||
{
|
{
|
||||||
groups.add(resourcePolicy.getGroup());
|
groups.add(resourcePolicy.getGroup());
|
||||||
}
|
}
|
||||||
@@ -653,7 +653,7 @@ public class AuthorizeServiceImpl implements AuthorizeService
|
|||||||
if (CollectionUtils.isNotEmpty(policies))
|
if (CollectionUtils.isNotEmpty(policies))
|
||||||
{
|
{
|
||||||
return policies.iterator().next();
|
return policies.iterator().next();
|
||||||
}else{
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -664,16 +664,22 @@ public class AuthorizeServiceImpl implements AuthorizeService
|
|||||||
* have right on the collection. E.g., if the anonymous can access the collection policies are assigned to anonymous.
|
* have right on the collection. E.g., if the anonymous can access the collection policies are assigned to anonymous.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param embargoDate
|
* @param embargoDate
|
||||||
|
* embargo end date
|
||||||
* @param reason
|
* @param reason
|
||||||
|
* embargo reason
|
||||||
* @param dso
|
* @param dso
|
||||||
|
* DSpace object
|
||||||
* @param owningCollection
|
* @param owningCollection
|
||||||
|
* collection to get group policies from
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void generateAutomaticPolicies(Context context, Date embargoDate,
|
public void generateAutomaticPolicies(Context context, Date embargoDate,
|
||||||
String reason, DSpaceObject dso, Collection owningCollection) throws SQLException, AuthorizeException
|
String reason, DSpaceObject dso, Collection owningCollection)
|
||||||
|
throws SQLException, AuthorizeException
|
||||||
{
|
{
|
||||||
|
|
||||||
if (embargoDate != null || (embargoDate == null && dso instanceof Bitstream))
|
if (embargoDate != null || (embargoDate == null && dso instanceof Bitstream))
|
||||||
@@ -714,7 +720,7 @@ public class AuthorizeServiceImpl implements AuthorizeService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourcePolicy createResourcePolicy(Context context, DSpaceObject dso, Group group, EPerson eperson, int type, String rpType) throws SQLException, AuthorizeException {
|
public ResourcePolicy createResourcePolicy(Context context, DSpaceObject dso, Group group, EPerson eperson, int type, String rpType) throws SQLException, AuthorizeException {
|
||||||
if(group == null && eperson == null)
|
if (group == null && eperson == null)
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("We need at least an eperson or a group in order to create a resource policy.");
|
throw new IllegalArgumentException("We need at least an eperson or a group in order to create a resource policy.");
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,8 @@ public class FixDefaultPolicies
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Command line interface to setPolicies - run to see arguments
|
* Command line interface to setPolicies - run to see arguments
|
||||||
* @param argv arguments
|
*
|
||||||
|
* @param argv the command line arguments given
|
||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
public static void main(String[] argv) throws Exception
|
public static void main(String[] argv) throws Exception
|
||||||
|
@@ -43,7 +43,8 @@ public class PolicySet
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Command line interface to setPolicies - run to see arguments
|
* Command line interface to setPolicies - run to see arguments
|
||||||
* @param argv arguments
|
*
|
||||||
|
* @param argv the command line arguments given
|
||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
public static void main(String[] argv) throws Exception
|
public static void main(String[] argv) throws Exception
|
||||||
@@ -130,17 +131,30 @@ public class PolicySet
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param c
|
* @param c
|
||||||
|
* current context
|
||||||
* @param containerType
|
* @param containerType
|
||||||
|
* type, Constants.ITEM or Constants.COLLECTION
|
||||||
* @param containerID
|
* @param containerID
|
||||||
|
* ID of container (DB primary key)
|
||||||
* @param contentType
|
* @param contentType
|
||||||
|
* ID of container (DB primary key)
|
||||||
* @param actionID
|
* @param actionID
|
||||||
|
* action ID (e.g. Constants.READ)
|
||||||
* @param groupID
|
* @param groupID
|
||||||
|
* group ID (database key)
|
||||||
* @param isReplace
|
* @param isReplace
|
||||||
|
* if <code>true</code>, existing policies are removed first,
|
||||||
|
* otherwise add to existing policies
|
||||||
* @param clearOnly
|
* @param clearOnly
|
||||||
|
* if non-null, only process bitstreams whose names contain filter
|
||||||
* @param name
|
* @param name
|
||||||
|
* policy name
|
||||||
* @param description
|
* @param description
|
||||||
|
* policy descrption
|
||||||
* @param startDate
|
* @param startDate
|
||||||
|
* policy start date
|
||||||
* @param endDate
|
* @param endDate
|
||||||
|
* policy end date
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
*/
|
*/
|
||||||
@@ -166,7 +180,7 @@ public class PolicySet
|
|||||||
* @param contentType
|
* @param contentType
|
||||||
* type (BUNDLE, ITEM, or BITSTREAM)
|
* type (BUNDLE, ITEM, or BITSTREAM)
|
||||||
* @param actionID
|
* @param actionID
|
||||||
* action ID
|
* action ID (e.g. Constants.READ)
|
||||||
* @param groupID
|
* @param groupID
|
||||||
* group ID (database key)
|
* group ID (database key)
|
||||||
* @param isReplace
|
* @param isReplace
|
||||||
@@ -214,9 +228,13 @@ public class PolicySet
|
|||||||
* @param filter
|
* @param filter
|
||||||
* if non-null, only process bitstreams whose names contain filter
|
* if non-null, only process bitstreams whose names contain filter
|
||||||
* @param name
|
* @param name
|
||||||
|
* policy name
|
||||||
* @param description
|
* @param description
|
||||||
|
* policy description
|
||||||
* @param startDate
|
* @param startDate
|
||||||
|
* policy start date
|
||||||
* @param endDate
|
* @param endDate
|
||||||
|
* policy end date
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* if database problem
|
* if database problem
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
@@ -250,7 +268,7 @@ public class PolicySet
|
|||||||
{
|
{
|
||||||
|
|
||||||
// before create a new policy check if an identical policy is already in place
|
// before create a new policy check if an identical policy is already in place
|
||||||
if(!authorizeService.isAnIdenticalPolicyAlreadyInPlace(c, myitem, group, actionID, -1)){
|
if (!authorizeService.isAnIdenticalPolicyAlreadyInPlace(c, myitem, group, actionID, -1)) {
|
||||||
// now add the policy
|
// now add the policy
|
||||||
ResourcePolicy rp = resourcePolicyService.create(c);
|
ResourcePolicy rp = resourcePolicyService.create(c);
|
||||||
|
|
||||||
|
@@ -96,6 +96,7 @@ public class ResourcePolicy implements ReloadableEntity<Integer> {
|
|||||||
* Return true if this object equals obj, false otherwise.
|
* Return true if this object equals obj, false otherwise.
|
||||||
*
|
*
|
||||||
* @param obj
|
* @param obj
|
||||||
|
* object to compare (eperson, group, start date, end date, ...)
|
||||||
* @return true if ResourcePolicy objects are equal
|
* @return true if ResourcePolicy objects are equal
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -144,23 +145,22 @@ public class ResourcePolicy implements ReloadableEntity<Integer> {
|
|||||||
{
|
{
|
||||||
int hash = 7;
|
int hash = 7;
|
||||||
hash = 19 * hash + this.getAction();
|
hash = 19 * hash + this.getAction();
|
||||||
if(this.getGroup() != null)
|
if (this.getGroup() != null)
|
||||||
{
|
{
|
||||||
hash = 19 * hash + this.getGroup().hashCode();
|
hash = 19 * hash + this.getGroup().hashCode();
|
||||||
}else{
|
} else {
|
||||||
hash = 19 * hash + -1;
|
hash = 19 * hash + -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.getEPerson() != null)
|
if (this.getEPerson() != null)
|
||||||
{
|
{
|
||||||
hash = 19 * hash + this.getEPerson().hashCode();
|
hash = 19 * hash + this.getEPerson().hashCode();
|
||||||
}else{
|
} else {
|
||||||
hash = 19 * hash + -1;
|
hash = 19 * hash + -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hash = 19 * hash + (this.getStartDate() != null? this.getStartDate().hashCode():0);
|
hash = 19 * hash + (this.getStartDate() != null ? this.getStartDate().hashCode() : 0);
|
||||||
hash = 19 * hash + (this.getEndDate() != null? this.getEndDate().hashCode():0);
|
hash = 19 * hash + (this.getEndDate() != null ? this.getEndDate().hashCode() : 0);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ public class ResourcePolicy implements ReloadableEntity<Integer> {
|
|||||||
/**
|
/**
|
||||||
* set the action this policy authorizes
|
* set the action this policy authorizes
|
||||||
*
|
*
|
||||||
* @param myid action ID from <code>org.dspace.core.Constants</code>
|
* @param myid action ID from {@link org.dspace.core.Constants#Constants Constants}
|
||||||
*/
|
*/
|
||||||
public void setAction(int myid)
|
public void setAction(int myid)
|
||||||
{
|
{
|
||||||
@@ -279,24 +279,24 @@ public class ResourcePolicy implements ReloadableEntity<Integer> {
|
|||||||
this.endDate = d;
|
this.endDate = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRpName(){
|
public String getRpName() {
|
||||||
return rpname;
|
return rpname;
|
||||||
}
|
}
|
||||||
public void setRpName(String name){
|
public void setRpName(String name) {
|
||||||
this.rpname = name;
|
this.rpname = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRpType(){
|
public String getRpType() {
|
||||||
return rptype;
|
return rptype;
|
||||||
}
|
}
|
||||||
public void setRpType(String type){
|
public void setRpType(String type) {
|
||||||
this.rptype = type;
|
this.rptype = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRpDescription(){
|
public String getRpDescription() {
|
||||||
return rpdescription;
|
return rpdescription;
|
||||||
}
|
}
|
||||||
public void setRpDescription(String description){
|
public void setRpDescription(String description) {
|
||||||
this.rpdescription = description;
|
this.rpdescription = description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,10 +44,11 @@ public interface AuthorizeService {
|
|||||||
* @param c context with the current user
|
* @param c context with the current user
|
||||||
* @param o DSpace object user is attempting to perform action on
|
* @param o DSpace object user is attempting to perform action on
|
||||||
* @param actions array of action IDs from
|
* @param actions array of action IDs from
|
||||||
* <code>org.dspace.core.Constants</code>
|
* <code>org.dspace.core.Constants</code>
|
||||||
* @throws AuthorizeException if any one of the specified actions cannot be
|
* @throws AuthorizeException if any one of the specified actions cannot be
|
||||||
* performed by the current user on the given object.
|
* performed by the current user on the given object.
|
||||||
* @throws SQLException if database error
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public void authorizeAnyOf(Context c, DSpaceObject o, int[] actions) throws AuthorizeException, SQLException;
|
public void authorizeAnyOf(Context c, DSpaceObject o, int[] actions) throws AuthorizeException, SQLException;
|
||||||
|
|
||||||
@@ -59,8 +60,11 @@ public interface AuthorizeService {
|
|||||||
* @param c context
|
* @param c context
|
||||||
* @param o a DSpaceObject
|
* @param o a DSpaceObject
|
||||||
* @param action action to perform from <code>org.dspace.core.Constants</code>
|
* @param action action to perform from <code>org.dspace.core.Constants</code>
|
||||||
* @throws AuthorizeException if the user is denied
|
* @throws AuthorizeException
|
||||||
* @throws SQLException if database error
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public void authorizeAction(Context c, DSpaceObject o, int action) throws AuthorizeException, SQLException;
|
public void authorizeAction(Context c, DSpaceObject o, int action) throws AuthorizeException, SQLException;
|
||||||
|
|
||||||
@@ -75,8 +79,11 @@ public interface AuthorizeService {
|
|||||||
* flag to say if ADMIN action on the current object or parent
|
* flag to say if ADMIN action on the current object or parent
|
||||||
* object can be used
|
* object can be used
|
||||||
* @param action action to perform from <code>org.dspace.core.Constants</code>
|
* @param action action to perform from <code>org.dspace.core.Constants</code>
|
||||||
* @throws AuthorizeException if the user is denied
|
* @throws AuthorizeException
|
||||||
* @throws SQLException if database error
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public void authorizeAction(Context c, DSpaceObject o, int action, boolean useInheritance)
|
public void authorizeAction(Context c, DSpaceObject o, int action, boolean useInheritance)
|
||||||
throws AuthorizeException, SQLException;
|
throws AuthorizeException, SQLException;
|
||||||
@@ -93,8 +100,11 @@ public interface AuthorizeService {
|
|||||||
* flag to say if ADMIN action on the current object or parent
|
* flag to say if ADMIN action on the current object or parent
|
||||||
* object can be used
|
* object can be used
|
||||||
* @param action action to perform from <code>org.dspace.core.Constants</code>
|
* @param action action to perform from <code>org.dspace.core.Constants</code>
|
||||||
* @throws AuthorizeException if the user is denied
|
* @throws AuthorizeException
|
||||||
* @throws SQLException if database error
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public void authorizeAction(Context c, EPerson e, DSpaceObject o, int action, boolean useInheritance)
|
public void authorizeAction(Context c, EPerson e, DSpaceObject o, int action, boolean useInheritance)
|
||||||
throws AuthorizeException, SQLException;
|
throws AuthorizeException, SQLException;
|
||||||
@@ -109,7 +119,8 @@ public interface AuthorizeService {
|
|||||||
* <code>org.dspace.core.Constants</code>
|
* <code>org.dspace.core.Constants</code>
|
||||||
* @return {@code true} if the current user in the context is
|
* @return {@code true} if the current user in the context is
|
||||||
* authorized to perform the given action on the given object
|
* authorized to perform the given action on the given object
|
||||||
* @throws SQLException if database error
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public boolean authorizeActionBoolean(Context c, DSpaceObject o, int a) throws SQLException;
|
public boolean authorizeActionBoolean(Context c, DSpaceObject o, int a) throws SQLException;
|
||||||
|
|
||||||
@@ -126,7 +137,8 @@ public interface AuthorizeService {
|
|||||||
* object can be used
|
* object can be used
|
||||||
* @return {@code true} if the current user in the context is
|
* @return {@code true} if the current user in the context is
|
||||||
* authorized to perform the given action on the given object
|
* authorized to perform the given action on the given object
|
||||||
* @throws SQLException if database error
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public boolean authorizeActionBoolean(Context c, DSpaceObject o, int a, boolean useInheritance) throws SQLException;
|
public boolean authorizeActionBoolean(Context c, DSpaceObject o, int a, boolean useInheritance) throws SQLException;
|
||||||
|
|
||||||
@@ -144,7 +156,8 @@ public interface AuthorizeService {
|
|||||||
* object can be used
|
* object can be used
|
||||||
* @return {@code true} if the requested user is
|
* @return {@code true} if the requested user is
|
||||||
* authorized to perform the given action on the given object
|
* authorized to perform the given action on the given object
|
||||||
* @throws SQLException if database error
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public boolean authorizeActionBoolean(Context c, EPerson e, DSpaceObject o, int a, boolean useInheritance) throws SQLException;
|
public boolean authorizeActionBoolean(Context c, EPerson e, DSpaceObject o, int a, boolean useInheritance) throws SQLException;
|
||||||
|
|
||||||
@@ -163,7 +176,8 @@ public interface AuthorizeService {
|
|||||||
* method
|
* method
|
||||||
* @return {@code true} if user has administrative privileges on the
|
* @return {@code true} if user has administrative privileges on the
|
||||||
* given DSpace object
|
* given DSpace object
|
||||||
* @throws SQLException if database error
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public boolean isAdmin(Context c, DSpaceObject o) throws SQLException;
|
public boolean isAdmin(Context c, DSpaceObject o) throws SQLException;
|
||||||
|
|
||||||
@@ -176,7 +190,8 @@ public interface AuthorizeService {
|
|||||||
* @param c current context
|
* @param c current context
|
||||||
* @return {@code true} if user is an admin or ignore authorization
|
* @return {@code true} if user is an admin or ignore authorization
|
||||||
* flag set
|
* flag set
|
||||||
* @throws SQLException if database error
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public boolean isAdmin(Context c) throws SQLException;
|
public boolean isAdmin(Context c) throws SQLException;
|
||||||
|
|
||||||
@@ -432,21 +447,25 @@ public interface AuthorizeService {
|
|||||||
|
|
||||||
public ResourcePolicy createOrModifyPolicy(ResourcePolicy policy, Context context, String name, Group group, EPerson ePerson, Date embargoDate, int action, String reason, DSpaceObject dso) throws AuthorizeException, SQLException;
|
public ResourcePolicy createOrModifyPolicy(ResourcePolicy policy, Context context, String name, Group group, EPerson ePerson, Date embargoDate, int action, String reason, DSpaceObject dso) throws AuthorizeException, SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change all the policies related to the action (fromPolicy) of the
|
* Change all the policies related to the action (fromPolicy) of the
|
||||||
* specified object to the new action (toPolicy)
|
* specified object to the new action (toPolicy)
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* @param dso
|
* The relevant DSpace Context.
|
||||||
* the dspace object
|
* @param dso
|
||||||
* @param fromAction
|
* the dspace object
|
||||||
* the action to change
|
* @param fromAction
|
||||||
* @param toAction
|
* the action to change
|
||||||
* the new action to set
|
* @param toAction
|
||||||
* @throws SQLException
|
* the new action to set
|
||||||
* @throws AuthorizeException
|
* @throws SQLException
|
||||||
*/
|
* An exception that provides information on a database access error or other errors.
|
||||||
void switchPoliciesAction(Context context, DSpaceObject dso, int fromAction, int toAction)
|
* @throws AuthorizeException
|
||||||
throws SQLException, AuthorizeException;
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
|
*/
|
||||||
|
void switchPoliciesAction(Context context, DSpaceObject dso, int fromAction, int toAction)
|
||||||
|
throws SQLException, AuthorizeException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -155,6 +155,7 @@ public interface BrowseDAO
|
|||||||
* to only items or values within items that appear in the given container.
|
* to only items or values within items that appear in the given container.
|
||||||
*
|
*
|
||||||
* @param containerID
|
* @param containerID
|
||||||
|
* community/collection internal ID (UUID)
|
||||||
*/
|
*/
|
||||||
public void setContainerID(UUID containerID);
|
public void setContainerID(UUID containerID);
|
||||||
|
|
||||||
@@ -234,7 +235,7 @@ public interface BrowseDAO
|
|||||||
* normal browse operations can be completed without it. The default is -1, which
|
* normal browse operations can be completed without it. The default is -1, which
|
||||||
* means do not offset.
|
* means do not offset.
|
||||||
*
|
*
|
||||||
* @return the offset
|
* @return paging offset
|
||||||
*/
|
*/
|
||||||
public int getOffset();
|
public int getOffset();
|
||||||
|
|
||||||
@@ -245,6 +246,7 @@ public interface BrowseDAO
|
|||||||
* means do not offset.
|
* means do not offset.
|
||||||
*
|
*
|
||||||
* @param offset
|
* @param offset
|
||||||
|
* paging offset
|
||||||
*/
|
*/
|
||||||
public void setOffset(int offset);
|
public void setOffset(int offset);
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -67,7 +67,7 @@ public class DailyReportEmailer
|
|||||||
public void sendReport(File attachment, int numberOfBitstreams)
|
public void sendReport(File attachment, int numberOfBitstreams)
|
||||||
throws IOException, javax.mail.MessagingException
|
throws IOException, javax.mail.MessagingException
|
||||||
{
|
{
|
||||||
if(numberOfBitstreams > 0)
|
if (numberOfBitstreams > 0)
|
||||||
{
|
{
|
||||||
String hostname = ConfigurationManager.getProperty("dspace.hostname");
|
String hostname = ConfigurationManager.getProperty("dspace.hostname");
|
||||||
Email email = new Email();
|
Email email = new Email();
|
||||||
@@ -83,22 +83,22 @@ public class DailyReportEmailer
|
|||||||
* Allows users to have email sent to them. The default is to send all
|
* Allows users to have email sent to them. The default is to send all
|
||||||
* reports in one email
|
* reports in one email
|
||||||
*
|
*
|
||||||
* @param args
|
* <dl>
|
||||||
* <dl>
|
* <dt>-h</dt>
|
||||||
* <dt>-h</dt>
|
* <dd>help</dd>
|
||||||
* <dd>help</dd>
|
* <dt>-d</dt>
|
||||||
* <dt>-d</dt>
|
* <dd>Select deleted bitstreams</dd>
|
||||||
* <dd>Select deleted bitstreams</dd>
|
* <dt>-m</dt>
|
||||||
* <dt>-m</dt>
|
* <dd>Bitstreams missing from assetstore</dd>
|
||||||
* <dd>Bitstreams missing from assetstore</dd>
|
* <dt>-c</dt>
|
||||||
* <dt>-c</dt>
|
* <dd>Bitstreams whose checksums were changed</dd>
|
||||||
* <dd>Bitstreams whose checksums were changed</dd>
|
* <dt>-n</dt>
|
||||||
* <dt>-n</dt>
|
* <dd>Bitstreams whose checksums were changed</dd>
|
||||||
* <dd>Bitstreams whose checksums were changed</dd>
|
* <dt>-a</dt>
|
||||||
* <dt>-a</dt>
|
* <dd>Send all reports in one email</dd>
|
||||||
* <dd>Send all reports in one email</dd>
|
* </dl>
|
||||||
* </dl>
|
|
||||||
*
|
*
|
||||||
|
* @param args the command line arguments given
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
@@ -110,26 +110,18 @@ public class DailyReportEmailer
|
|||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
|
||||||
options.addOption("h", "help", false, "Help");
|
options.addOption("h", "help", false, "Help");
|
||||||
options
|
options.addOption("d", "Deleted", false,
|
||||||
.addOption("d", "Deleted", false,
|
"Send E-mail report for all bitstreams set as deleted for today");
|
||||||
"Send E-mail report for all bitstreams set as deleted for today");
|
options.addOption("m", "Missing", false,
|
||||||
options
|
"Send E-mail report for all bitstreams not found in assetstore for today");
|
||||||
.addOption("m", "Missing", false,
|
options.addOption("c", "Changed", false,
|
||||||
"Send E-mail report for all bitstreams not found in assetstore for today");
|
"Send E-mail report for all bitstreams where checksum has been changed for today");
|
||||||
options
|
options.addOption("a", "All", false,
|
||||||
.addOption(
|
"Send all E-mail reports");
|
||||||
"c",
|
|
||||||
"Changed",
|
|
||||||
false,
|
|
||||||
"Send E-mail report for all bitstreams where checksum has been changed for today");
|
|
||||||
options.addOption("a", "All", false, "Send all E-mail reports");
|
|
||||||
|
|
||||||
options.addOption("u", "Unchecked", false,
|
options.addOption("u", "Unchecked", false,
|
||||||
"Send the Unchecked bitstream report");
|
"Send the Unchecked bitstream report");
|
||||||
|
options.addOption("n", "Not Processed", false,
|
||||||
options
|
"Send E-mail report for all bitstreams set to longer be processed for today");
|
||||||
.addOption("n", "Not Processed", false,
|
|
||||||
"Send E-mail report for all bitstreams set to longer be processed for today");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -147,19 +139,11 @@ public class DailyReportEmailer
|
|||||||
HelpFormatter myhelp = new HelpFormatter();
|
HelpFormatter myhelp = new HelpFormatter();
|
||||||
|
|
||||||
myhelp.printHelp("Checksum Reporter\n", options);
|
myhelp.printHelp("Checksum Reporter\n", options);
|
||||||
System.out
|
System.out.println("\nSend Deleted bitstream email report: DailyReportEmailer -d");
|
||||||
.println("\nSend Deleted bitstream email report: DailyReportEmailer -d");
|
System.out.println("\nSend Missing bitstreams email report: DailyReportEmailer -m");
|
||||||
System.out
|
System.out.println("\nSend Checksum Changed email report: DailyReportEmailer -c");
|
||||||
.println("\nSend Missing bitstreams email report: DailyReportEmailer -m");
|
System.out.println("\nSend bitstream not to be processed email report: DailyReportEmailer -n");
|
||||||
System.out
|
System.out.println("\nSend Un-checked bitstream report: DailyReportEmailer -u");
|
||||||
.println("\nSend Checksum Changed email report: DailyReportEmailer -c");
|
|
||||||
|
|
||||||
System.out
|
|
||||||
.println("\nSend bitstream not to be processed email report: DailyReportEmailer -n");
|
|
||||||
|
|
||||||
System.out
|
|
||||||
.println("\nSend Un-checked bitstream report: DailyReportEmailer -u");
|
|
||||||
|
|
||||||
System.out.println("\nSend All email reports: DailyReportEmailer");
|
System.out.println("\nSend All email reports: DailyReportEmailer");
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
@@ -201,34 +185,24 @@ public class DailyReportEmailer
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new IllegalStateException("directory :" + dirLocation
|
throw new IllegalStateException("directory :" + dirLocation
|
||||||
+ " does not exist");
|
+ " does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
writer = new FileWriter(report);
|
writer = new FileWriter(report);
|
||||||
|
|
||||||
if ((line.hasOption("a")) || (line.getOptions().length == 0))
|
if ((line.hasOption("a")) || (line.getOptions().length == 0))
|
||||||
{
|
{
|
||||||
writer
|
writer.write("\n--------------------------------- Begin Reporting ------------------------\n\n");
|
||||||
.write("\n--------------------------------- Begin Reporting ------------------------\n\n");
|
numBitstreams += reporter.getDeletedBitstreamReport(context, yesterday, tomorrow, writer);
|
||||||
numBitstreams += reporter.getDeletedBitstreamReport(context, yesterday,
|
writer.write("\n--------------------------------- Report Spacer ---------------------------\n\n");
|
||||||
tomorrow, writer);
|
numBitstreams += reporter.getChangedChecksumReport(context, yesterday, tomorrow, writer);
|
||||||
writer
|
writer.write("\n--------------------------------- Report Spacer ---------------------------\n\n");
|
||||||
.write("\n--------------------------------- Report Spacer ---------------------------\n\n");
|
numBitstreams += reporter.getBitstreamNotFoundReport(context, yesterday, tomorrow, writer);
|
||||||
numBitstreams += reporter.getChangedChecksumReport(context, yesterday,
|
writer.write("\n--------------------------------- Report Spacer ---------------------------\n\n");
|
||||||
tomorrow, writer);
|
numBitstreams += reporter.getNotToBeProcessedReport(context, yesterday, tomorrow, writer);
|
||||||
writer
|
writer.write("\n--------------------------------- Report Spacer ---------------------------\n\n");
|
||||||
.write("\n--------------------------------- Report Spacer ---------------------------\n\n");
|
|
||||||
numBitstreams += reporter.getBitstreamNotFoundReport(context, yesterday,
|
|
||||||
tomorrow, writer);
|
|
||||||
writer
|
|
||||||
.write("\n--------------------------------- Report Spacer ---------------------------\n\n");
|
|
||||||
numBitstreams += reporter.getNotToBeProcessedReport(context, yesterday,
|
|
||||||
tomorrow, writer);
|
|
||||||
writer
|
|
||||||
.write("\n--------------------------------- Report Spacer ---------------------------\n\n");
|
|
||||||
numBitstreams += reporter.getUncheckedBitstreamsReport(context, writer);
|
numBitstreams += reporter.getUncheckedBitstreamsReport(context, writer);
|
||||||
writer
|
writer.write("\n--------------------------------- End Report ---------------------------\n\n");
|
||||||
.write("\n--------------------------------- End Report ---------------------------\n\n");
|
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
emailer.sendReport(report, numBitstreams);
|
emailer.sendReport(report, numBitstreams);
|
||||||
@@ -237,10 +211,9 @@ public class DailyReportEmailer
|
|||||||
{
|
{
|
||||||
if (line.hasOption("d"))
|
if (line.hasOption("d"))
|
||||||
{
|
{
|
||||||
writer
|
writer.write("\n--------------------------------- Begin Reporting ------------------------\n\n");
|
||||||
.write("\n--------------------------------- Begin Reporting ------------------------\n\n");
|
|
||||||
numBitstreams += reporter.getDeletedBitstreamReport(context,
|
numBitstreams += reporter.getDeletedBitstreamReport(context,
|
||||||
yesterday, tomorrow, writer);
|
yesterday, tomorrow, writer);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
emailer.sendReport(report, numBitstreams);
|
emailer.sendReport(report, numBitstreams);
|
||||||
@@ -248,10 +221,9 @@ public class DailyReportEmailer
|
|||||||
|
|
||||||
if (line.hasOption("m"))
|
if (line.hasOption("m"))
|
||||||
{
|
{
|
||||||
writer
|
writer.write("\n--------------------------------- Begin Reporting ------------------------\n\n");
|
||||||
.write("\n--------------------------------- Begin Reporting ------------------------\n\n");
|
|
||||||
numBitstreams += reporter.getBitstreamNotFoundReport(context,
|
numBitstreams += reporter.getBitstreamNotFoundReport(context,
|
||||||
yesterday, tomorrow, writer);
|
yesterday, tomorrow, writer);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
emailer.sendReport(report, numBitstreams);
|
emailer.sendReport(report, numBitstreams);
|
||||||
@@ -259,10 +231,9 @@ public class DailyReportEmailer
|
|||||||
|
|
||||||
if (line.hasOption("c"))
|
if (line.hasOption("c"))
|
||||||
{
|
{
|
||||||
writer
|
writer.write("\n--------------------------------- Begin Reporting ------------------------\n\n");
|
||||||
.write("\n--------------------------------- Begin Reporting ------------------------\n\n");
|
|
||||||
numBitstreams += reporter.getChangedChecksumReport(context,
|
numBitstreams += reporter.getChangedChecksumReport(context,
|
||||||
yesterday, tomorrow, writer);
|
yesterday, tomorrow, writer);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
emailer.sendReport(report, numBitstreams);
|
emailer.sendReport(report, numBitstreams);
|
||||||
@@ -270,10 +241,9 @@ public class DailyReportEmailer
|
|||||||
|
|
||||||
if (line.hasOption("n"))
|
if (line.hasOption("n"))
|
||||||
{
|
{
|
||||||
writer
|
writer.write("\n--------------------------------- Begin Reporting ------------------------\n\n");
|
||||||
.write("\n--------------------------------- Begin Reporting ------------------------\n\n");
|
|
||||||
numBitstreams += reporter.getNotToBeProcessedReport(context,
|
numBitstreams += reporter.getNotToBeProcessedReport(context,
|
||||||
yesterday, tomorrow, writer);
|
yesterday, tomorrow, writer);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
emailer.sendReport(report, numBitstreams);
|
emailer.sendReport(report, numBitstreams);
|
||||||
@@ -281,10 +251,9 @@ public class DailyReportEmailer
|
|||||||
|
|
||||||
if (line.hasOption("u"))
|
if (line.hasOption("u"))
|
||||||
{
|
{
|
||||||
writer
|
writer.write("\n--------------------------------- Begin Reporting ------------------------\n\n");
|
||||||
.write("\n--------------------------------- Begin Reporting ------------------------\n\n");
|
|
||||||
numBitstreams += reporter
|
numBitstreams += reporter
|
||||||
.getUncheckedBitstreamsReport(context, writer);
|
.getUncheckedBitstreamsReport(context, writer);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
emailer.sendReport(report, numBitstreams);
|
emailer.sendReport(report, numBitstreams);
|
||||||
@@ -294,9 +263,10 @@ public class DailyReportEmailer
|
|||||||
catch (MessagingException | SQLException | IOException e)
|
catch (MessagingException | SQLException | IOException e)
|
||||||
{
|
{
|
||||||
log.fatal(e);
|
log.fatal(e);
|
||||||
} finally
|
}
|
||||||
|
finally
|
||||||
{
|
{
|
||||||
if(context != null && context.isValid())
|
if (context != null && context.isValid())
|
||||||
{
|
{
|
||||||
context.abort();
|
context.abort();
|
||||||
}
|
}
|
||||||
|
@@ -30,8 +30,11 @@ public interface ChecksumHistoryDAO extends GenericDAO<ChecksumHistory> {
|
|||||||
* the specified result code.
|
* the specified result code.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* @param retentionDate row must be older than this to be deleted.
|
* The relevant DSpace Context.
|
||||||
* @param checksumResultCode row must have this result to be deleted.
|
* @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.
|
* @return number of rows deleted.
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
@@ -41,7 +44,9 @@ public interface ChecksumHistoryDAO extends GenericDAO<ChecksumHistory> {
|
|||||||
* Delete all ChecksumHistory rows for the given Bitstream.
|
* Delete all ChecksumHistory rows for the given Bitstream.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param bitstream
|
* @param bitstream
|
||||||
|
* which bitstream's checksums to delete
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
public void deleteByBitstream(Context context, Bitstream bitstream) throws SQLException;
|
public void deleteByBitstream(Context context, Bitstream bitstream) throws SQLException;
|
||||||
|
@@ -345,8 +345,9 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
* bitstream is uncertain, and the format is set to "unknown."
|
* bitstream is uncertain, and the format is set to "unknown."
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param desc
|
* @param desc
|
||||||
* the user's description of the format
|
* the user's description of the format
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
public void setUserFormatDescription(Context context, String desc) throws SQLException
|
public void setUserFormatDescription(Context context, String desc) throws SQLException
|
||||||
@@ -436,4 +437,4 @@ public class Bitstream extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -379,12 +379,13 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
|||||||
* Get the value of a metadata field
|
* Get the value of a metadata field
|
||||||
*
|
*
|
||||||
* @param collection
|
* @param collection
|
||||||
|
* which collection to operate on
|
||||||
* @param field
|
* @param field
|
||||||
* the name of the metadata field to get
|
* the name of the metadata field to get
|
||||||
*
|
*
|
||||||
* @return the value of the metadata field
|
* @return the value of the metadata field
|
||||||
*
|
*
|
||||||
* @exception IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if the requested metadata field doesn't exist
|
* if the requested metadata field doesn't exist
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@@ -516,7 +516,7 @@ public class DCDate
|
|||||||
|
|
||||||
public String displayUTCDate(boolean showTime, Locale locale)
|
public String displayUTCDate(boolean showTime, Locale locale)
|
||||||
{
|
{
|
||||||
// forcibly truncate month name to 3 chars -- XXX FIXME?
|
// forcibly truncate month name to 3 chars -- XXX FIXME?
|
||||||
String monthName = getMonthName(getMonthUTC(), locale);
|
String monthName = getMonthName(getMonthUTC(), locale);
|
||||||
if (monthName.length() > 2)
|
if (monthName.length() > 2)
|
||||||
monthName = monthName.substring(0, 3);
|
monthName = monthName.substring(0, 3);
|
||||||
@@ -540,7 +540,7 @@ public class DCDate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if the requested level of granularity is within that of the date.
|
* Test if the requested level of granularity is within that of the date.
|
||||||
*
|
*
|
||||||
* @param dg
|
* @param dg
|
||||||
@@ -594,23 +594,21 @@ public class DCDate
|
|||||||
* Get a date representing the current instant in time.
|
* Get a date representing the current instant in time.
|
||||||
*
|
*
|
||||||
* @return a DSpaceDate object representing the current instant.
|
* @return a DSpaceDate object representing the current instant.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
public static DCDate getCurrent()
|
public static DCDate getCurrent()
|
||||||
{
|
{
|
||||||
return (new DCDate(new Date()));
|
return (new DCDate(new Date()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a month's name for a month between 1 and 12. Any invalid month value
|
* Get a month's name for a month between 1 and 12. Any invalid month value
|
||||||
* (e.g. 0 or -1) will return a value of "Unspecified".
|
* (e.g. 0 or -1) will return a value of "Unspecified".
|
||||||
*
|
*
|
||||||
* @param m
|
* @param m
|
||||||
* the month number
|
* the month number
|
||||||
*
|
|
||||||
* @param locale
|
* @param locale
|
||||||
*
|
* which locale to render the month name in
|
||||||
* @return the month name.
|
* @return the month name.
|
||||||
*/
|
*/
|
||||||
public static String getMonthName(int m, Locale locale)
|
public static String getMonthName(int m, Locale locale)
|
||||||
{
|
{
|
||||||
|
@@ -149,8 +149,8 @@ public class ItemComparator implements Comparator, Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param first
|
* @param first first operand
|
||||||
* @param second
|
* @param second second operand
|
||||||
* @return true if the first string is equal to the second. Either or both
|
* @return true if the first string is equal to the second. Either or both
|
||||||
* may be null.
|
* may be null.
|
||||||
*/
|
*/
|
||||||
@@ -224,7 +224,8 @@ public class ItemComparator implements Comparator, Serializable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalize the title of a Metadatum.
|
* Normalize the title of a Metadatum.
|
||||||
* @param value
|
*
|
||||||
|
* @param value metadata value
|
||||||
* @return normalized title
|
* @return normalized title
|
||||||
*/
|
*/
|
||||||
protected String normalizeTitle(MetadataValue value)
|
protected String normalizeTitle(MetadataValue value)
|
||||||
|
@@ -534,10 +534,10 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
// switch all READ authorization policies to WITHDRAWN_READ
|
// switch all READ authorization policies to WITHDRAWN_READ
|
||||||
authorizeService.switchPoliciesAction(context, item, Constants.READ, Constants.WITHDRAWN_READ);
|
authorizeService.switchPoliciesAction(context, item, Constants.READ, Constants.WITHDRAWN_READ);
|
||||||
for (Bundle bnd : item.getBundles()) {
|
for (Bundle bnd : item.getBundles()) {
|
||||||
authorizeService.switchPoliciesAction(context, bnd, Constants.READ, Constants.WITHDRAWN_READ);
|
authorizeService.switchPoliciesAction(context, bnd, Constants.READ, Constants.WITHDRAWN_READ);
|
||||||
for (Bitstream bs : bnd.getBitstreams()) {
|
for (Bitstream bs : bnd.getBitstreams()) {
|
||||||
authorizeService.switchPoliciesAction(context, bs, Constants.READ, Constants.WITHDRAWN_READ);
|
authorizeService.switchPoliciesAction(context, bs, Constants.READ, Constants.WITHDRAWN_READ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write log
|
// Write log
|
||||||
@@ -586,26 +586,26 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
context.addEvent(new Event(Event.MODIFY, Constants.ITEM, item.getID(),
|
context.addEvent(new Event(Event.MODIFY, Constants.ITEM, item.getID(),
|
||||||
"REINSTATE", getIdentifiers(context, item)));
|
"REINSTATE", getIdentifiers(context, item)));
|
||||||
|
|
||||||
// restore all WITHDRAWN_READ authorization policies back to READ
|
// restore all WITHDRAWN_READ authorization policies back to READ
|
||||||
for (Bundle bnd : item.getBundles()) {
|
for (Bundle bnd : item.getBundles()) {
|
||||||
authorizeService.switchPoliciesAction(context, bnd, Constants.WITHDRAWN_READ, Constants.READ);
|
authorizeService.switchPoliciesAction(context, bnd, Constants.WITHDRAWN_READ, Constants.READ);
|
||||||
for (Bitstream bs : bnd.getBitstreams()) {
|
for (Bitstream bs : bnd.getBitstreams()) {
|
||||||
authorizeService.switchPoliciesAction(context, bs, Constants.WITHDRAWN_READ, Constants.READ);
|
authorizeService.switchPoliciesAction(context, bs, Constants.WITHDRAWN_READ, Constants.READ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the item was withdrawn before the fix DS-3097
|
// check if the item was withdrawn before the fix DS-3097
|
||||||
if (authorizeService.getPoliciesActionFilter(context, item, Constants.WITHDRAWN_READ).size() != 0) {
|
if (authorizeService.getPoliciesActionFilter(context, item, Constants.WITHDRAWN_READ).size() != 0) {
|
||||||
authorizeService.switchPoliciesAction(context, item, Constants.WITHDRAWN_READ, Constants.READ);
|
authorizeService.switchPoliciesAction(context, item, Constants.WITHDRAWN_READ, Constants.READ);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// authorization policies
|
// authorization policies
|
||||||
if (colls.size() > 0)
|
if (colls.size() > 0)
|
||||||
{
|
{
|
||||||
// remove the item's policies and replace them with
|
// remove the item's policies and replace them with
|
||||||
// the defaults from the collection
|
// the defaults from the collection
|
||||||
adjustItemPolicies(context, item, item.getOwningCollection());
|
adjustItemPolicies(context, item, item.getOwningCollection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write log
|
// Write log
|
||||||
@@ -919,12 +919,12 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
// is this collection not yet created, and an item template is created
|
// is this collection not yet created, and an item template is created
|
||||||
if (item.getOwningCollection() == null)
|
if (item.getOwningCollection() == null)
|
||||||
{
|
{
|
||||||
if (!isInProgressSubmission(context, item)) {
|
if (!isInProgressSubmission(context, item)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return collectionService.canEditBoolean(context, item.getOwningCollection(), false);
|
return collectionService.canEditBoolean(context, item.getOwningCollection(), false);
|
||||||
@@ -932,18 +932,21 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the item is an inprogress submission
|
* Check if the item is an inprogress submission
|
||||||
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* @param item
|
* The relevant DSpace Context.
|
||||||
|
* @param item item to check
|
||||||
* @return <code>true</code> if the item is an inprogress submission, i.e. a WorkspaceItem or WorkflowItem
|
* @return <code>true</code> if the item is an inprogress submission, i.e. a WorkspaceItem or WorkflowItem
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public boolean isInProgressSubmission(Context context, Item item) throws SQLException {
|
public boolean isInProgressSubmission(Context context, Item item) throws SQLException {
|
||||||
return workspaceItemService.findByItem(context, item) != null
|
return workspaceItemService.findByItem(context, item) != null
|
||||||
|| workflowItemService.findByItem(context, item) != null;
|
|| workflowItemService.findByItem(context, item) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
With every finished submission a bunch of resource policy entries with have null value for the dspace_object column are generated in the database.
|
With every finished submission a bunch of resource policy entries which have null value for the dspace_object column are generated in the database.
|
||||||
prevent the generation of resource policy entry values with null dspace_object as value
|
prevent the generation of resource policy entry values with null dspace_object as value
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@@ -952,10 +955,16 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
* Add the default policies, which have not been already added to the given DSpace object
|
* Add the default policies, which have not been already added to the given DSpace object
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param dso
|
* @param dso
|
||||||
|
* The DSpace Object to add policies to
|
||||||
* @param defaultCollectionPolicies
|
* @param defaultCollectionPolicies
|
||||||
|
* list of policies
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
* @throws AuthorizeException
|
* @throws AuthorizeException
|
||||||
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
*/
|
*/
|
||||||
protected void addDefaultPoliciesNotInPlace(Context context, DSpaceObject dso, List<ResourcePolicy> defaultCollectionPolicies) throws SQLException, AuthorizeException
|
protected void addDefaultPoliciesNotInPlace(Context context, DSpaceObject dso, List<ResourcePolicy> defaultCollectionPolicies) throws SQLException, AuthorizeException
|
||||||
{
|
{
|
||||||
@@ -983,8 +992,12 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
* @param value field value or Item.ANY to match any value
|
* @param value field value or Item.ANY to match any value
|
||||||
* @return an iterator over the items matching that authority value
|
* @return an iterator over the items matching that authority value
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
|
* A general class of exceptions produced by failed or interrupted I/O operations.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@@ -57,10 +57,15 @@ public class LicenseUtils
|
|||||||
* LicenseArgumentFormatter based on his type (map key)
|
* LicenseArgumentFormatter based on his type (map key)
|
||||||
*
|
*
|
||||||
* @param locale
|
* @param locale
|
||||||
|
* Formatter locale
|
||||||
* @param collection
|
* @param collection
|
||||||
|
* collection to get license from
|
||||||
* @param item
|
* @param item
|
||||||
|
* the item object of the license
|
||||||
* @param eperson
|
* @param eperson
|
||||||
|
* EPerson to get firstname, lastname and email from
|
||||||
* @param additionalInfo
|
* @param additionalInfo
|
||||||
|
* additional template arguments beyond 0-6
|
||||||
* @return the license text obtained substituting the provided argument in
|
* @return the license text obtained substituting the provided argument in
|
||||||
* the license template
|
* the license template
|
||||||
*/
|
*/
|
||||||
@@ -104,9 +109,13 @@ public class LicenseUtils
|
|||||||
* supplying {@code null} for the additionalInfo argument)
|
* supplying {@code null} for the additionalInfo argument)
|
||||||
*
|
*
|
||||||
* @param locale
|
* @param locale
|
||||||
|
* Formatter locale
|
||||||
* @param collection
|
* @param collection
|
||||||
|
* collection to get license from
|
||||||
* @param item
|
* @param item
|
||||||
|
* the item object of the license
|
||||||
* @param eperson
|
* @param eperson
|
||||||
|
* EPerson to get firstname, lastname and email from
|
||||||
* @return the license text, with no custom substitutions.
|
* @return the license text, with no custom substitutions.
|
||||||
*/
|
*/
|
||||||
public static String getLicenseText(Locale locale, Collection collection,
|
public static String getLicenseText(Locale locale, Collection collection,
|
||||||
|
@@ -27,6 +27,7 @@ public class NonUniqueMetadataException extends Exception
|
|||||||
* Create an exception with only a message
|
* Create an exception with only a message
|
||||||
*
|
*
|
||||||
* @param message
|
* @param message
|
||||||
|
* message string
|
||||||
*/
|
*/
|
||||||
public NonUniqueMetadataException(String message)
|
public NonUniqueMetadataException(String message)
|
||||||
{
|
{
|
||||||
|
@@ -57,9 +57,24 @@ public class CrosswalkMetadataValidator {
|
|||||||
/**
|
/**
|
||||||
* Scans metadata for elements not defined in this DSpace instance. It then takes action based
|
* Scans metadata for elements not defined in this DSpace instance. It then takes action based
|
||||||
* on a configurable parameter (fail, ignore, add).
|
* on a configurable parameter (fail, ignore, add).
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
|
* @param schema metadata field schema
|
||||||
|
* @param element metadata field element
|
||||||
|
* @param qualifier metadata field qualifier
|
||||||
|
* @param forceCreate if true, force addinga schema or metadata field
|
||||||
|
* @return metadata field
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
|
* @throws AuthorizeException
|
||||||
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
|
* @throws CrosswalkException
|
||||||
|
* Superclass for more-specific crosswalk exceptions.
|
||||||
*/
|
*/
|
||||||
public MetadataField checkMetadata(Context context, String schema, String element, String qualifier, boolean forceCreate) throws SQLException, AuthorizeException, CrosswalkException {
|
public MetadataField checkMetadata(Context context, String schema, String element, String qualifier, boolean forceCreate) throws SQLException, AuthorizeException, CrosswalkException {
|
||||||
if(!validatedBefore(schema, element, qualifier)) {
|
if (!validatedBefore(schema, element, qualifier)) {
|
||||||
// Verify that the schema exists
|
// Verify that the schema exists
|
||||||
MetadataSchema mdSchema = metadataSchemaService.find(context, schema);
|
MetadataSchema mdSchema = metadataSchemaService.find(context, schema);
|
||||||
MetadataField mdField = null;
|
MetadataField mdField = null;
|
||||||
|
@@ -402,9 +402,13 @@ public class METSRightsCrosswalk
|
|||||||
* Ingest a whole XML document, starting at specified root.
|
* Ingest a whole XML document, starting at specified root.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param dso
|
* @param dso
|
||||||
|
* DSpace object to ingest
|
||||||
* @param root
|
* @param root
|
||||||
|
* root element
|
||||||
* @param createMissingMetadataFields
|
* @param createMissingMetadataFields
|
||||||
|
* whether to create missing fields
|
||||||
* @throws CrosswalkException if crosswalk error
|
* @throws CrosswalkException if crosswalk error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
|
@@ -311,7 +311,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
|||||||
/**
|
/**
|
||||||
* Returns object's metadata in MODS format, as List of XML structure nodes.
|
* Returns object's metadata in MODS format, as List of XML structure nodes.
|
||||||
* @param context context
|
* @param context context
|
||||||
* @throws org.dspace.content.crosswalk.CrosswalkException
|
* @throws CrosswalkException if crosswalk error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
|
@@ -32,6 +32,7 @@ public interface ParameterizedDisseminationCrosswalk
|
|||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param dso the DSpace Object whose metadata to export.
|
* @param dso the DSpace Object whose metadata to export.
|
||||||
* @param parameters
|
* @param parameters
|
||||||
* names and values of parameters to be passed into the transform.
|
* names and values of parameters to be passed into the transform.
|
||||||
|
@@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
* Configurable XSLT-driven dissemination Crosswalk
|
* Configurable XSLT-driven dissemination Crosswalk
|
||||||
* <p>
|
* <p>
|
||||||
* See the XSLTCrosswalk superclass for details on configuration.
|
* See the XSLTCrosswalk superclass for details on configuration.
|
||||||
* <p>
|
* </p>
|
||||||
* <h3>Additional Configuration of Dissemination crosswalk:</h3>
|
* <h3>Additional Configuration of Dissemination crosswalk:</h3>
|
||||||
* The disseminator also needs to be configured with an XML Namespace
|
* The disseminator also needs to be configured with an XML Namespace
|
||||||
* (including prefix and URI) and an XML Schema for output format. This
|
* (including prefix and URI) and an XML Schema for output format. This
|
||||||
@@ -524,7 +524,8 @@ public class XSLTDisseminationCrosswalk
|
|||||||
/**
|
/**
|
||||||
* Simple command-line rig for testing the DIM output of a stylesheet.
|
* Simple command-line rig for testing the DIM output of a stylesheet.
|
||||||
* Usage: {@code java XSLTDisseminationCrosswalk <crosswalk-name> <handle> [output-file]}
|
* Usage: {@code java XSLTDisseminationCrosswalk <crosswalk-name> <handle> [output-file]}
|
||||||
* @param argv arguments
|
*
|
||||||
|
* @param argv the command line arguments given
|
||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
public static void main(String[] argv) throws Exception
|
public static void main(String[] argv) throws Exception
|
||||||
|
@@ -293,7 +293,8 @@ public class XSLTIngestionCrosswalk
|
|||||||
/**
|
/**
|
||||||
* Simple command-line rig for testing the DIM output of a stylesheet.
|
* Simple command-line rig for testing the DIM output of a stylesheet.
|
||||||
* Usage: {@code java XSLTIngestionCrosswalk <crosswalk-name> <input-file>}
|
* Usage: {@code java XSLTIngestionCrosswalk <crosswalk-name> <input-file>}
|
||||||
* @param argv arguments
|
*
|
||||||
|
* @param argv the command line arguments given
|
||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
public static void main(String[] argv) throws Exception
|
public static void main(String[] argv) throws Exception
|
||||||
|
@@ -15,7 +15,7 @@ import org.dspace.core.GenericDAO;
|
|||||||
* All DSpaceObject DAO classes should implement this class since it ensures that the T object is of type DSpaceObject
|
* All DSpaceObject DAO classes should implement this class since it ensures that the T object is of type DSpaceObject
|
||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
* @param <T>
|
* @param <T> some implementation of DSpaceObject
|
||||||
*/
|
*/
|
||||||
public interface DSpaceObjectDAO<T extends DSpaceObject> extends GenericDAO<T> {
|
public interface DSpaceObjectDAO<T extends DSpaceObject> extends GenericDAO<T> {
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@ import java.sql.SQLException;
|
|||||||
* to identify DSpaceObjects prior to DSpace 6.0
|
* to identify DSpaceObjects prior to DSpace 6.0
|
||||||
*
|
*
|
||||||
* @author kevinvandevelde at atmire.com
|
* @author kevinvandevelde at atmire.com
|
||||||
* @param <T>
|
* @param <T> some implementation of DSpaceObject
|
||||||
*/
|
*/
|
||||||
public interface DSpaceObjectLegacySupportDAO<T extends DSpaceObject> extends DSpaceObjectDAO<T> {
|
public interface DSpaceObjectLegacySupportDAO<T extends DSpaceObject> extends DSpaceObjectDAO<T> {
|
||||||
|
|
||||||
|
@@ -106,6 +106,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
protected final WorkspaceItemService workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
|
protected final WorkspaceItemService workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* <p>
|
||||||
* An instance of ZipMdrefManager holds the state needed to retrieve the
|
* An instance of ZipMdrefManager holds the state needed to retrieve the
|
||||||
* contents of an external metadata stream referenced by an
|
* contents of an external metadata stream referenced by an
|
||||||
* <code>mdRef</code> element in a Zipped up METS manifest.
|
* <code>mdRef</code> element in a Zipped up METS manifest.
|
||||||
@@ -244,7 +245,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
license);
|
license);
|
||||||
|
|
||||||
//if ingestion was successful
|
//if ingestion was successful
|
||||||
if(dso!=null)
|
if (dso!=null)
|
||||||
{
|
{
|
||||||
// Log whether we finished an ingest (create new obj) or a restore
|
// Log whether we finished an ingest (create new obj) or a restore
|
||||||
// (restore previously existing obj)
|
// (restore previously existing obj)
|
||||||
@@ -338,7 +339,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
// Retrieve the manifest file entry (named mets.xml)
|
// Retrieve the manifest file entry (named mets.xml)
|
||||||
ZipEntry manifestEntry = zip.getEntry(METSManifest.MANIFEST_FILE);
|
ZipEntry manifestEntry = zip.getEntry(METSManifest.MANIFEST_FILE);
|
||||||
|
|
||||||
if(manifestEntry!=null)
|
if (manifestEntry!=null)
|
||||||
{
|
{
|
||||||
// parse the manifest and sanity-check it.
|
// parse the manifest and sanity-check it.
|
||||||
manifest = METSManifest.create(zip.getInputStream(manifestEntry),
|
manifest = METSManifest.create(zip.getInputStream(manifestEntry),
|
||||||
@@ -404,7 +405,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
catch(UnsupportedOperationException e)
|
catch(UnsupportedOperationException e)
|
||||||
{
|
{
|
||||||
//If user specified to skip item ingest if any "missing parent" error message occur
|
//If user specified to skip item ingest if any "missing parent" error message occur
|
||||||
if(params.getBooleanProperty("skipIfParentMissing", false))
|
if (params.getBooleanProperty("skipIfParentMissing", false))
|
||||||
{
|
{
|
||||||
//log a warning instead of throwing an error
|
//log a warning instead of throwing an error
|
||||||
log.warn(LogManager.getHeader(context, "package_ingest",
|
log.warn(LogManager.getHeader(context, "package_ingest",
|
||||||
@@ -518,7 +519,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
|
|
||||||
// Finally, if item is still in the workspace, then we actually need
|
// Finally, if item is still in the workspace, then we actually need
|
||||||
// to install it into the archive & assign its handle.
|
// to install it into the archive & assign its handle.
|
||||||
if(wsi!=null)
|
if (wsi!=null)
|
||||||
{
|
{
|
||||||
// Finish creating the item. This actually assigns the handle,
|
// Finish creating the item. This actually assigns the handle,
|
||||||
// and will either install item immediately or start a workflow, based on params
|
// and will either install item immediately or start a workflow, based on params
|
||||||
@@ -531,7 +532,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
// Add logo if one is referenced from manifest
|
// Add logo if one is referenced from manifest
|
||||||
addContainerLogo(context, dso, manifest, pkgFile, params);
|
addContainerLogo(context, dso, manifest, pkgFile, params);
|
||||||
|
|
||||||
if(type==Constants.COLLECTION)
|
if (type==Constants.COLLECTION)
|
||||||
{
|
{
|
||||||
//Add template item if one is referenced from manifest (only for Collections)
|
//Add template item if one is referenced from manifest (only for Collections)
|
||||||
addTemplateItem(context, dso, manifest, pkgFile, params, callback);
|
addTemplateItem(context, dso, manifest, pkgFile, params, callback);
|
||||||
@@ -670,11 +671,11 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
|
|
||||||
// have subclass manage license since it may be extra package file.
|
// have subclass manage license since it may be extra package file.
|
||||||
Collection owningCollection = (Collection) ContentServiceFactory.getInstance().getDSpaceObjectService(dso).getParentObject(context, dso);
|
Collection owningCollection = (Collection) ContentServiceFactory.getInstance().getDSpaceObjectService(dso).getParentObject(context, dso);
|
||||||
if(owningCollection == null)
|
if (owningCollection == null)
|
||||||
{
|
{
|
||||||
//We are probably dealing with an item that isn't archived yet
|
//We are probably dealing with an item that isn't archived yet
|
||||||
InProgressSubmission inProgressSubmission = workspaceItemService.findByItem(context, item);
|
InProgressSubmission inProgressSubmission = workspaceItemService.findByItem(context, item);
|
||||||
if(inProgressSubmission == null)
|
if (inProgressSubmission == null)
|
||||||
{
|
{
|
||||||
inProgressSubmission = WorkflowServiceFactory.getInstance().getWorkflowItemService().findByItem(context, item);
|
inProgressSubmission = WorkflowServiceFactory.getInstance().getWorkflowItemService().findByItem(context, item);
|
||||||
}
|
}
|
||||||
@@ -817,7 +818,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
|
|
||||||
// Set bitstream sequence id, if known
|
// Set bitstream sequence id, if known
|
||||||
String seqID = mfile.getAttributeValue("SEQ");
|
String seqID = mfile.getAttributeValue("SEQ");
|
||||||
if(seqID!=null && !seqID.isEmpty())
|
if (seqID!=null && !seqID.isEmpty())
|
||||||
bitstream.setSequenceID(Integer.parseInt(seqID));
|
bitstream.setSequenceID(Integer.parseInt(seqID));
|
||||||
|
|
||||||
// crosswalk this bitstream's administrative metadata located in
|
// crosswalk this bitstream's administrative metadata located in
|
||||||
@@ -878,18 +879,18 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
bundle = bundleService.create(context, item, bundleName);
|
bundle = bundleService.create(context, item, bundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
String mfileGrp = mfile.getAttributeValue("ADMID");
|
String mfileGrp = mfile.getAttributeValue("ADMID");
|
||||||
if (mfileGrp != null)
|
if (mfileGrp != null)
|
||||||
{
|
{
|
||||||
manifest.crosswalkBundle(context, params, bundle, mfileGrp,mdRefCallback);
|
manifest.crosswalkBundle(context, params, bundle, mfileGrp,mdRefCallback);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (log.isDebugEnabled())
|
if (log.isDebugEnabled())
|
||||||
{
|
{
|
||||||
log.debug("Ingesting bundle with no ADMID, not crosswalking bundle metadata");
|
log.debug("Ingesting bundle with no ADMID, not crosswalking bundle metadata");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bundleService.update(context, bundle);
|
bundleService.update(context, bundle);
|
||||||
}// end for each manifest file
|
}// end for each manifest file
|
||||||
@@ -1044,7 +1045,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
CrosswalkException, PackageValidationException
|
CrosswalkException, PackageValidationException
|
||||||
{
|
{
|
||||||
//Template items only valid for collections
|
//Template items only valid for collections
|
||||||
if(dso.getType()!=Constants.COLLECTION)
|
if (dso.getType()!=Constants.COLLECTION)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Collection collection = (Collection) dso;
|
Collection collection = (Collection) dso;
|
||||||
@@ -1052,18 +1053,18 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
//retrieve list of all <div>s representing child objects from manifest
|
//retrieve list of all <div>s representing child objects from manifest
|
||||||
List childObjList = manifest.getChildObjDivs();
|
List childObjList = manifest.getChildObjDivs();
|
||||||
|
|
||||||
if(childObjList!=null && !childObjList.isEmpty())
|
if (childObjList!=null && !childObjList.isEmpty())
|
||||||
{
|
{
|
||||||
Element templateItemDiv = null;
|
Element templateItemDiv = null;
|
||||||
|
|
||||||
Iterator childIterator = childObjList.iterator();
|
Iterator childIterator = childObjList.iterator();
|
||||||
//Search for the child with a type of "DSpace ITEM Template"
|
//Search for the child with a type of "DSpace ITEM Template"
|
||||||
while(childIterator.hasNext())
|
while (childIterator.hasNext())
|
||||||
{
|
{
|
||||||
Element childDiv = (Element) childIterator.next();
|
Element childDiv = (Element) childIterator.next();
|
||||||
String childType = childDiv.getAttributeValue("TYPE");
|
String childType = childDiv.getAttributeValue("TYPE");
|
||||||
//should be the only child of type "ITEM" with "Template" for a suffix
|
//should be the only child of type "ITEM" with "Template" for a suffix
|
||||||
if(childType.contains(Constants.typeText[Constants.ITEM]) &&
|
if (childType.contains(Constants.typeText[Constants.ITEM]) &&
|
||||||
childType.endsWith(AbstractMETSDisseminator.TEMPLATE_TYPE_SUFFIX))
|
childType.endsWith(AbstractMETSDisseminator.TEMPLATE_TYPE_SUFFIX))
|
||||||
{
|
{
|
||||||
templateItemDiv = childDiv;
|
templateItemDiv = childDiv;
|
||||||
@@ -1072,11 +1073,11 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
}
|
}
|
||||||
|
|
||||||
//If an Template Item was found, create it with the specified metadata
|
//If an Template Item was found, create it with the specified metadata
|
||||||
if(templateItemDiv!=null)
|
if (templateItemDiv!=null)
|
||||||
{
|
{
|
||||||
//make sure this templateItemDiv is associated with one or more dmdSecs
|
//make sure this templateItemDiv is associated with one or more dmdSecs
|
||||||
String templateDmdIds = templateItemDiv.getAttributeValue("DMDID");
|
String templateDmdIds = templateItemDiv.getAttributeValue("DMDID");
|
||||||
if(templateDmdIds!=null)
|
if (templateDmdIds!=null)
|
||||||
{
|
{
|
||||||
//create our template item & get a reference to it
|
//create our template item & get a reference to it
|
||||||
itemService.createTemplateItem(context, collection);
|
itemService.createTemplateItem(context, collection);
|
||||||
@@ -1193,7 +1194,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
null);
|
null);
|
||||||
|
|
||||||
//if ingestion was successful
|
//if ingestion was successful
|
||||||
if(dso!=null)
|
if (dso!=null)
|
||||||
{
|
{
|
||||||
// Log that we created an object
|
// Log that we created an object
|
||||||
log.info(LogManager.getHeader(context, "package_replace",
|
log.info(LogManager.getHeader(context, "package_replace",
|
||||||
@@ -1222,7 +1223,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
}
|
}
|
||||||
|
|
||||||
//if ingest/restore/replace successful
|
//if ingest/restore/replace successful
|
||||||
if(dso!=null)
|
if (dso!=null)
|
||||||
{
|
{
|
||||||
// Check if the Packager is currently running recursively.
|
// Check if the Packager is currently running recursively.
|
||||||
// If so, this means the Packager will attempt to recursively
|
// If so, this means the Packager will attempt to recursively
|
||||||
@@ -1547,14 +1548,16 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
*
|
*
|
||||||
* @param context the DSpace context
|
* @param context the DSpace context
|
||||||
* @param dso DSpace Object
|
* @param dso DSpace Object
|
||||||
* @param manifest the METSManifest
|
* @param manifest
|
||||||
|
* the METSManifest
|
||||||
* @param callback
|
* @param callback
|
||||||
* the MdrefManager (manages all external metadata files
|
* the MdrefManager (manages all external metadata files
|
||||||
* referenced by METS <code>mdref</code> elements)
|
* referenced by METS <code>mdref</code> elements)
|
||||||
* @param dmds
|
* @param dmds
|
||||||
* array of Elements, each a METS <code>dmdSec</code> that
|
* array of Elements, each a METS <code>dmdSec</code> that
|
||||||
* applies to the Item as a whole.
|
* applies to the Item as a whole.
|
||||||
* @param params
|
* @param params
|
||||||
|
* Packager Parameters
|
||||||
* @throws CrosswalkException if crosswalk error
|
* @throws CrosswalkException if crosswalk error
|
||||||
* @throws PackageValidationException if package validation error
|
* @throws PackageValidationException if package validation error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
@@ -1586,10 +1589,11 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester
|
|||||||
* the DSpace context
|
* the DSpace context
|
||||||
* @param item Item
|
* @param item Item
|
||||||
* @param collection
|
* @param collection
|
||||||
* DSpace Collection to which the item is being submitted.
|
* DSpace Collection to which the item is being submitted.
|
||||||
* @param license
|
* @param license
|
||||||
* optional user-supplied Deposit License text (may be null)
|
* optional user-supplied Deposit License text (may be null)
|
||||||
* @param params
|
* @param params
|
||||||
|
* Packager Parameters
|
||||||
* @throws PackageValidationException if package validation error
|
* @throws PackageValidationException if package validation error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
|
@@ -454,6 +454,7 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator
|
|||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
* @throws MetsException
|
* @throws MetsException
|
||||||
|
* METS Java toolkit exception class.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addStructMap(Context context, DSpaceObject dso,
|
public void addStructMap(Context context, DSpaceObject dso,
|
||||||
|
@@ -95,6 +95,21 @@ public class DSpaceAIPIngester
|
|||||||
* 3. If (1) or (2) succeeds, crosswalk it and ignore all other DMDs with
|
* 3. If (1) or (2) succeeds, crosswalk it and ignore all other DMDs with
|
||||||
* same GROUPID<br>
|
* same GROUPID<br>
|
||||||
* 4. Crosswalk remaining DMDs not eliminated already.
|
* 4. Crosswalk remaining DMDs not eliminated already.
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
|
* @param dso
|
||||||
|
* DSpace object
|
||||||
|
* @param manifest
|
||||||
|
* the METSManifest
|
||||||
|
* @param callback
|
||||||
|
* the MdrefManager (manages all external metadata files
|
||||||
|
* referenced by METS <code>mdref</code> elements)
|
||||||
|
* @param dmds
|
||||||
|
* array of Elements, each a METS <code>dmdSec</code> that
|
||||||
|
* applies to the Item as a whole.
|
||||||
|
* @param params
|
||||||
|
* Packager Parameters
|
||||||
* @throws PackageValidationException validation error
|
* @throws PackageValidationException validation error
|
||||||
* @throws CrosswalkException if crosswalk error
|
* @throws CrosswalkException if crosswalk error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
@@ -198,6 +213,15 @@ public class DSpaceAIPIngester
|
|||||||
* license supplied by explicit argument next, else use collection's
|
* license supplied by explicit argument next, else use collection's
|
||||||
* default deposit license.
|
* default deposit license.
|
||||||
* Normally the rightsMD crosswalks should provide a license.
|
* Normally the rightsMD crosswalks should provide a license.
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
|
* @param item
|
||||||
|
* item to add license to
|
||||||
|
* @param collection
|
||||||
|
* collection to get the default license from
|
||||||
|
* @param params
|
||||||
|
* Packager Parameters
|
||||||
* @throws PackageValidationException validation error
|
* @throws PackageValidationException validation error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -211,7 +235,7 @@ public class DSpaceAIPIngester
|
|||||||
{
|
{
|
||||||
boolean newLicense = false;
|
boolean newLicense = false;
|
||||||
|
|
||||||
if(!params.restoreModeEnabled())
|
if (!params.restoreModeEnabled())
|
||||||
{
|
{
|
||||||
//AIP is not being restored/replaced, so treat it like a SIP -- every new SIP needs a new license
|
//AIP is not being restored/replaced, so treat it like a SIP -- every new SIP needs a new license
|
||||||
newLicense = true;
|
newLicense = true;
|
||||||
@@ -225,7 +249,7 @@ public class DSpaceAIPIngester
|
|||||||
newLicense = true;
|
newLicense = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newLicense)
|
if (newLicense)
|
||||||
{
|
{
|
||||||
PackageUtils.addDepositLicense(context, license, item, collection);
|
PackageUtils.addDepositLicense(context, license, item, collection);
|
||||||
}
|
}
|
||||||
@@ -233,19 +257,30 @@ public class DSpaceAIPIngester
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Last change to fix up a DSpace Object.
|
* Last change to fix up a DSpace Object.
|
||||||
* <P>
|
* <p>
|
||||||
* For AIPs, if the object is an Item, we may want to make sure all of its
|
* For AIPs, if the object is an Item, we may want to make sure all of its
|
||||||
* metadata fields already exist in the database (otherwise, the database
|
* metadata fields already exist in the database (otherwise, the database
|
||||||
* will throw errors when we attempt to save/update the Item)
|
* will throw errors when we attempt to save/update the Item)
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param context DSpace Context
|
* @param context
|
||||||
* @param dso DSpace object
|
* The relevant DSpace Context.
|
||||||
* @param params Packager Parameters
|
* @param dso
|
||||||
* @throws org.dspace.content.packager.PackageValidationException
|
* DSpace object
|
||||||
* @throws java.sql.SQLException
|
* @param params
|
||||||
* @throws org.dspace.content.crosswalk.CrosswalkException
|
* Packager Parameters
|
||||||
* @throws java.io.IOException
|
* @throws PackageValidationException
|
||||||
* @throws org.dspace.authorize.AuthorizeException
|
* Failure when importing or exporting a package
|
||||||
|
* caused by invalid unacceptable package format or contents
|
||||||
|
* @throws CrosswalkException
|
||||||
|
* Superclass for more-specific crosswalk exceptions.
|
||||||
|
* @throws IOException
|
||||||
|
* A general class of exceptions produced by failed or interrupted I/O operations.
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
|
* @throws AuthorizeException
|
||||||
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void finishObject(Context context, DSpaceObject dso, PackageParameters params)
|
public void finishObject(Context context, DSpaceObject dso, PackageParameters params)
|
||||||
@@ -253,7 +288,7 @@ public class DSpaceAIPIngester
|
|||||||
AuthorizeException, SQLException, IOException
|
AuthorizeException, SQLException, IOException
|
||||||
{
|
{
|
||||||
//Metadata fields are now required before adding, so this logic isn't needed anymore
|
//Metadata fields are now required before adding, so this logic isn't needed anymore
|
||||||
/*if(dso.getType()==Constants.ITEM)
|
/*if (dso.getType()==Constants.ITEM)
|
||||||
{
|
{
|
||||||
// Check if 'createMetadataFields' option is enabled (default=true)
|
// Check if 'createMetadataFields' option is enabled (default=true)
|
||||||
// This defaults to true as by default we should attempt to restore as much metadata as we can.
|
// This defaults to true as by default we should attempt to restore as much metadata as we can.
|
||||||
|
@@ -8,15 +8,18 @@
|
|||||||
package org.dspace.content.packager;
|
package org.dspace.content.packager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* <p>
|
||||||
* This represents a failure when importing or exporting a package
|
* This represents a failure when importing or exporting a package
|
||||||
* caused by invalid unacceptable package format or contents; for
|
* caused by invalid unacceptable package format or contents; for
|
||||||
* example, missing files that were mentioned in the manifest, or
|
* example, missing files that were mentioned in the manifest, or
|
||||||
* extra files not in manifest, or lack of a manifest.
|
* extra files not in manifest, or lack of a manifest.
|
||||||
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* When throwing a PackageValidationException, be sure the message
|
* When throwing a PackageValidationException, be sure the message
|
||||||
* includes enough specific information to let the end user diagnose
|
* includes enough specific information to let the end user diagnose
|
||||||
* the problem, i.e. what files appear to be missing from the manifest
|
* the problem, i.e. what files appear to be missing from the manifest
|
||||||
* or package, or the details of a checksum error on a file.
|
* or package, or the details of a checksum error on a file.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Larry Stone
|
* @author Larry Stone
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
|
@@ -430,6 +430,7 @@ public class RoleIngester implements PackageIngester
|
|||||||
* @param context DSpace Context
|
* @param context DSpace Context
|
||||||
* @param parent the Parent DSpaceObject
|
* @param parent the Parent DSpaceObject
|
||||||
* @param params package params
|
* @param params package params
|
||||||
|
* @param stream input stream with the roles
|
||||||
* @throws PackageException if packaging error
|
* @throws PackageException if packaging error
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
|
@@ -77,8 +77,11 @@ public interface CollectionService extends DSpaceObjectService<Collection>, DSpa
|
|||||||
/**
|
/**
|
||||||
* Get all collections in the system. Adds support for limit and offset.
|
* Get all collections in the system. Adds support for limit and offset.
|
||||||
* @param context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param limit
|
* @param limit
|
||||||
|
* paging limit
|
||||||
* @param offset
|
* @param offset
|
||||||
|
* paging offset
|
||||||
* @return List of Collections
|
* @return List of Collections
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
|
@@ -104,7 +104,7 @@ public interface CommunityService extends DSpaceObjectService<Community>, DSpace
|
|||||||
*
|
*
|
||||||
* @return the value of the metadata field
|
* @return the value of the metadata field
|
||||||
*
|
*
|
||||||
* @exception IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if the requested metadata field doesn't exist
|
* if the requested metadata field doesn't exist
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@@ -123,9 +123,9 @@ public interface CommunityService extends DSpaceObjectService<Community>, DSpace
|
|||||||
* @param value
|
* @param value
|
||||||
* value to set the field to
|
* value to set the field to
|
||||||
*
|
*
|
||||||
* @exception IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if the requested metadata field doesn't exist
|
* if the requested metadata field doesn't exist
|
||||||
* @exception java.util.MissingResourceException
|
* @throws MissingResourceException if resource missing
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@@ -192,7 +192,12 @@ public interface CommunityService extends DSpaceObjectService<Community>, DSpace
|
|||||||
/**
|
/**
|
||||||
* Return an array of parent communities of this collection.
|
* Return an array of parent communities of this collection.
|
||||||
*
|
*
|
||||||
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
|
* @param collection
|
||||||
|
* collection to check
|
||||||
* @return an array of parent communities
|
* @return an array of parent communities
|
||||||
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
public List<Community> getAllParents(Context context, Collection collection) throws SQLException;
|
public List<Community> getAllParents(Context context, Collection collection) throws SQLException;
|
||||||
|
|
||||||
|
@@ -181,7 +181,7 @@ public interface DSpaceObjectService<T extends DSpaceObject> {
|
|||||||
*
|
*
|
||||||
* @return the value of the metadata field (or null if the column is an SQL NULL)
|
* @return the value of the metadata field (or null if the column is an SQL NULL)
|
||||||
*
|
*
|
||||||
* @exception IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if the requested metadata field doesn't exist
|
* if the requested metadata field doesn't exist
|
||||||
*/
|
*/
|
||||||
public String getMetadata(T dSpaceObject, String value);
|
public String getMetadata(T dSpaceObject, String value);
|
||||||
|
@@ -53,7 +53,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param collection Collection (parent)
|
* @param collection Collection (parent)
|
||||||
* @return Item
|
* @return empty template item for this collection
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
*/
|
*/
|
||||||
@@ -96,8 +96,10 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the list of items submitted by eperson, ordered by recently submitted, optionally limitable
|
* Retrieve the list of items submitted by eperson, ordered by recently submitted, optionally limitable
|
||||||
* @param context context
|
*
|
||||||
* @param eperson eperson
|
* @param context DSpace context object
|
||||||
|
* @param eperson
|
||||||
|
* the submitter
|
||||||
* @param limit a positive integer to limit, -1 or null for unlimited
|
* @param limit a positive integer to limit, -1 or null for unlimited
|
||||||
* @return an iterator over the items submitted by eperson
|
* @return an iterator over the items submitted by eperson
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -128,7 +130,8 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all Items installed or withdrawn, discoverable, and modified since a Date.
|
* Get all Items installed or withdrawn, discoverable, and modified since a Date.
|
||||||
* @param context context
|
*
|
||||||
|
* @param context DSpace context object
|
||||||
* @param since earliest interesting last-modified date, or null for no date test.
|
* @param since earliest interesting last-modified date, or null for no date test.
|
||||||
* @return an iterator over the items in the collection.
|
* @return an iterator over the items in the collection.
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -148,7 +151,8 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* See whether this Item is contained by a given Collection.
|
* See whether this Item is contained by a given Collection.
|
||||||
* @param item Item
|
*
|
||||||
|
* @param item item to check
|
||||||
* @param collection Collection (parent
|
* @param collection Collection (parent
|
||||||
* @return true if {@code collection} contains this Item.
|
* @return true if {@code collection} contains this Item.
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -161,7 +165,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* communities of the owning collections.
|
* communities of the owning collections.
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to check
|
||||||
* @return the communities this item is in.
|
* @return the communities this item is in.
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
@@ -171,7 +175,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
/**
|
/**
|
||||||
* Get the bundles matching a bundle name (name corresponds roughly to type)
|
* Get the bundles matching a bundle name (name corresponds roughly to type)
|
||||||
*
|
*
|
||||||
* @param item Item
|
* @param item item to check
|
||||||
* @param name
|
* @param name
|
||||||
* name of bundle (ORIGINAL/TEXT/THUMBNAIL)
|
* name of bundle (ORIGINAL/TEXT/THUMBNAIL)
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -184,7 +188,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* Add an existing bundle to this item. This has immediate effect.
|
* Add an existing bundle to this item. This has immediate effect.
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to add the bundle to
|
||||||
* @param bundle
|
* @param bundle
|
||||||
* the bundle to add
|
* the bundle to add
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -210,9 +214,10 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
/**
|
/**
|
||||||
* Remove all bundles linked to this item. This may result in the bundle being deleted, if the
|
* Remove all bundles linked to this item. This may result in the bundle being deleted, if the
|
||||||
* bundle is orphaned.
|
* bundle is orphaned.
|
||||||
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item
|
* @param item
|
||||||
* the item from which to remove our bundles
|
* the item from which to remove all bundles
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
@@ -224,7 +229,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* method for the most common use.
|
* method for the most common use.
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to create bitstream on
|
||||||
* @param is
|
* @param is
|
||||||
* the stream to create the new bitstream from
|
* the stream to create the new bitstream from
|
||||||
* @param name
|
* @param name
|
||||||
@@ -241,7 +246,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* Convenience method, calls createSingleBitstream() with name "ORIGINAL"
|
* Convenience method, calls createSingleBitstream() with name "ORIGINAL"
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to create bitstream on
|
||||||
* @param is
|
* @param is
|
||||||
* InputStream
|
* InputStream
|
||||||
* @return created bitstream
|
* @return created bitstream
|
||||||
@@ -256,8 +261,9 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* Get all non-internal bitstreams in the item. This is mainly used for
|
* Get all non-internal bitstreams in the item. This is mainly used for
|
||||||
* auditing for provenance messages and adding format.* DC values. The order
|
* auditing for provenance messages and adding format.* DC values. The order
|
||||||
* is indeterminate.
|
* is indeterminate.
|
||||||
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to check
|
||||||
* @return non-internal bitstreams.
|
* @return non-internal bitstreams.
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
@@ -271,7 +277,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* This method is used by the org.dspace.submit.step.LicenseStep class
|
* This method is used by the org.dspace.submit.step.LicenseStep class
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to remove DSpace license from
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
@@ -283,7 +289,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* Remove all licenses from an item - it was rejected
|
* Remove all licenses from an item - it was rejected
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to remove all licenses from
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
@@ -295,7 +301,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* and metadata are not deleted, but it is not publicly accessible.
|
* and metadata are not deleted, but it is not publicly accessible.
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to withdraw
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
*/
|
*/
|
||||||
@@ -306,7 +312,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* Reinstate a withdrawn item
|
* Reinstate a withdrawn item
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item withdrawn item to reinstate
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
*/
|
*/
|
||||||
@@ -315,7 +321,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
/**
|
/**
|
||||||
* Return true if this Collection 'owns' this item
|
* Return true if this Collection 'owns' this item
|
||||||
*
|
*
|
||||||
* @param item Item
|
* @param item item to check
|
||||||
* @param collection
|
* @param collection
|
||||||
* Collection
|
* Collection
|
||||||
* @return true if this Collection owns this item
|
* @return true if this Collection owns this item
|
||||||
@@ -327,7 +333,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* policies
|
* policies
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to replace policies on
|
||||||
* @param newpolicies -
|
* @param newpolicies -
|
||||||
* this will be all of the new policies for the item and its
|
* this will be all of the new policies for the item and its
|
||||||
* contents
|
* contents
|
||||||
@@ -342,7 +348,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* them with a new list of policies
|
* them with a new list of policies
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to replace policies on
|
||||||
* @param newpolicies -
|
* @param newpolicies -
|
||||||
* this will be all of the new policies for the bundle and
|
* this will be all of the new policies for the bundle and
|
||||||
* bitstream contents
|
* bitstream contents
|
||||||
@@ -358,7 +364,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* to a given Group
|
* to a given Group
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to remove group policies from
|
||||||
* @param group
|
* @param group
|
||||||
* Group referenced by policies that needs to be removed
|
* Group referenced by policies that needs to be removed
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -372,7 +378,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* the collection.
|
* the collection.
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to reset policies on
|
||||||
* @param collection
|
* @param collection
|
||||||
* Collection
|
* Collection
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -392,7 +398,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* Moves the item from one collection to another one
|
* Moves the item from one collection to another one
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to move
|
||||||
* @param from Collection to move from
|
* @param from Collection to move from
|
||||||
* @param to Collection to move to
|
* @param to Collection to move to
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -405,7 +411,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* Moves the item from one collection to another one
|
* Moves the item from one collection to another one
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to move
|
||||||
* @param from Collection to move from
|
* @param from Collection to move from
|
||||||
* @param to Collection to move to
|
* @param to Collection to move to
|
||||||
* @param inheritDefaultPolicies whether to inherit policies from new collection
|
* @param inheritDefaultPolicies whether to inherit policies from new collection
|
||||||
@@ -413,12 +419,12 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
*/
|
*/
|
||||||
public void move (Context context, Item item, Collection from, Collection to, boolean inheritDefaultPolicies) throws SQLException, AuthorizeException, IOException;
|
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
|
* Check the bundle ORIGINAL to see if there are any uploaded files
|
||||||
*
|
*
|
||||||
* @param item Item
|
* @param item item to check
|
||||||
* @return true if there is a bundle named ORIGINAL with one or more
|
* @return true if there is a bundle named ORIGINAL with one or more
|
||||||
* bitstreams inside
|
* bitstreams inside
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -429,7 +435,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* Get the collections this item is not in.
|
* Get the collections this item is not in.
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to check
|
||||||
* @return the collections this item is not in, if any.
|
* @return the collections this item is not in, if any.
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
@@ -439,7 +445,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* return TRUE if context's user can edit item, false otherwise
|
* return TRUE if context's user can edit item, false otherwise
|
||||||
*
|
*
|
||||||
* @param context DSpace context object
|
* @param context DSpace context object
|
||||||
* @param item Item
|
* @param item item to check
|
||||||
* @return boolean true = current user can edit item
|
* @return boolean true = current user can edit item
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
@@ -448,8 +454,10 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
/**
|
/**
|
||||||
* return TRUE if context's user can create new version of the item, false
|
* return TRUE if context's user can create new version of the item, false
|
||||||
* otherwise.
|
* otherwise.
|
||||||
|
* @param context DSpace context object
|
||||||
|
* @param item item to check
|
||||||
* @return boolean true = current user can create new version of the item
|
* @return boolean true = current user can create new version of the item
|
||||||
* @throws SQLException
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
public boolean canCreateNewVersion(Context context, Item item) throws SQLException;
|
public boolean canCreateNewVersion(Context context, Item item) throws SQLException;
|
||||||
|
|
||||||
@@ -500,7 +508,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
* Service method for knowing if this Item should be visible in the item list.
|
* 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
|
* Items only show up in the "item list" if the user has READ permission
|
||||||
* and if the Item isn't flagged as unlisted.
|
* and if the Item isn't flagged as unlisted.
|
||||||
* @param context context
|
* @param context DSpace context object
|
||||||
* @param item item
|
* @param item item
|
||||||
* @return true or false
|
* @return true or false
|
||||||
*/
|
*/
|
||||||
@@ -519,7 +527,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
/**
|
/**
|
||||||
* Find all Items modified since a Date.
|
* Find all Items modified since a Date.
|
||||||
*
|
*
|
||||||
* @param context context
|
* @param context DSpace context object
|
||||||
* @param last Earliest interesting last-modified date.
|
* @param last Earliest interesting last-modified date.
|
||||||
* @return iterator over items
|
* @return iterator over items
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -564,11 +572,12 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
|||||||
*/
|
*/
|
||||||
int countWithdrawnItems(Context context) throws SQLException;
|
int countWithdrawnItems(Context context) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the supplied item is an inprogress submission
|
* Check if the supplied item is an inprogress submission
|
||||||
* @param context
|
* @param context DSpace context object
|
||||||
* @param item
|
* @param item item to check
|
||||||
* @return <code>true</code> if the item is linked to a workspaceitem or workflowitem
|
* @return <code>true</code> if the item is linked to a workspaceitem or workflowitem
|
||||||
*/
|
* @throws SQLException if database error
|
||||||
|
*/
|
||||||
boolean isInProgressSubmission(Context context, Item item) throws SQLException;
|
boolean isInProgressSubmission(Context context, Item item) throws SQLException;
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ public interface MetadataFieldService {
|
|||||||
* @return new MetadataField
|
* @return new MetadataField
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws NonUniqueMetadataException
|
* @throws NonUniqueMetadataException if an existing field with an identical element and qualifier is already present
|
||||||
*/
|
*/
|
||||||
public MetadataField create(Context context, MetadataSchema metadataSchema, String element, String qualifier, String scopeNote)
|
public MetadataField create(Context context, MetadataSchema metadataSchema, String element, String qualifier, String scopeNote)
|
||||||
throws AuthorizeException, SQLException, NonUniqueMetadataException;
|
throws AuthorizeException, SQLException, NonUniqueMetadataException;
|
||||||
@@ -102,7 +102,7 @@ public interface MetadataFieldService {
|
|||||||
* @param metadataField metadata field
|
* @param metadataField metadata field
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
* @throws NonUniqueMetadataException
|
* @throws NonUniqueMetadataException if an existing field with an identical element and qualifier is already present
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
*/
|
*/
|
||||||
public void update(Context context, MetadataField metadataField)
|
public void update(Context context, MetadataField metadataField)
|
||||||
|
@@ -33,7 +33,7 @@ public interface MetadataSchemaService {
|
|||||||
* @return new MetadataSchema
|
* @return new MetadataSchema
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
* @throws NonUniqueMetadataException
|
* @throws NonUniqueMetadataException if an existing field with an identical element and qualifier is already present
|
||||||
*/
|
*/
|
||||||
public MetadataSchema create(Context context, String name, String namespace) throws SQLException, AuthorizeException, NonUniqueMetadataException;
|
public MetadataSchema create(Context context, String name, String namespace) throws SQLException, AuthorizeException, NonUniqueMetadataException;
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ public interface MetadataSchemaService {
|
|||||||
* @param metadataSchema metadata schema
|
* @param metadataSchema metadata schema
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
* @throws NonUniqueMetadataException
|
* @throws NonUniqueMetadataException if an existing field with an identical element and qualifier is already present
|
||||||
*/
|
*/
|
||||||
public void update(Context context, MetadataSchema metadataSchema) throws SQLException, AuthorizeException, NonUniqueMetadataException;
|
public void update(Context context, MetadataSchema metadataSchema) throws SQLException, AuthorizeException, NonUniqueMetadataException;
|
||||||
|
|
||||||
|
@@ -43,7 +43,7 @@ public interface MetadataValueService {
|
|||||||
* @param context dspace context
|
* @param context dspace context
|
||||||
* @param valueId database key id of value
|
* @param valueId database key id of value
|
||||||
* @return recalled metadata value
|
* @return recalled metadata value
|
||||||
* @throws java.io.IOException
|
* @throws IOException if IO error
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
public MetadataValue find(Context context, int valueId)
|
public MetadataValue find(Context context, int valueId)
|
||||||
@@ -89,7 +89,7 @@ public interface MetadataValueService {
|
|||||||
/**
|
/**
|
||||||
* Get the minimum value of a given metadata field across all objects.
|
* Get the minimum value of a given metadata field across all objects.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context dspace context
|
||||||
* @param metadataFieldId unique identifier of the interesting field.
|
* @param metadataFieldId unique identifier of the interesting field.
|
||||||
* @return the minimum value of the metadata field
|
* @return the minimum value of the metadata field
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
|
@@ -143,6 +143,7 @@ public interface WorkspaceItemService extends InProgressSubmissionService<Worksp
|
|||||||
/**
|
/**
|
||||||
* The map entry returned contains stage reached as the key and count of items in that stage as a value
|
* The map entry returned contains stage reached as the key and count of items in that stage as a value
|
||||||
* @param context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @return the map
|
* @return the map
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
|
@@ -94,7 +94,9 @@ public abstract class AbstractHibernateDAO<T> implements GenericDAO<T> {
|
|||||||
* Execute a JPA Criteria query and return a collection of results.
|
* Execute a JPA Criteria query and return a collection of results.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* @param query JPQL query string
|
* The relevant DSpace Context.
|
||||||
|
* @param query
|
||||||
|
* JPQL query string
|
||||||
* @return list of DAOs specified by the query string
|
* @return list of DAOs specified by the query string
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
*/
|
*/
|
||||||
@@ -134,7 +136,7 @@ public abstract class AbstractHibernateDAO<T> implements GenericDAO<T> {
|
|||||||
* Retrieve a unique result from the query. If multiple results CAN be
|
* Retrieve a unique result from the query. If multiple results CAN be
|
||||||
* retrieved an exception will be thrown,
|
* retrieved an exception will be thrown,
|
||||||
* so only use when the criteria state uniqueness in the database.
|
* so only use when the criteria state uniqueness in the database.
|
||||||
* @param criteria
|
* @param criteria JPA criteria
|
||||||
* @return a DAO specified by the criteria
|
* @return a DAO specified by the criteria
|
||||||
*/
|
*/
|
||||||
public T uniqueResult(Criteria criteria)
|
public T uniqueResult(Criteria criteria)
|
||||||
@@ -147,7 +149,7 @@ public abstract class AbstractHibernateDAO<T> implements GenericDAO<T> {
|
|||||||
/**
|
/**
|
||||||
* Retrieve a single result from the query. Best used if you expect a
|
* Retrieve a single result from the query. Best used if you expect a
|
||||||
* single result, but this isn't enforced on the database.
|
* single result, but this isn't enforced on the database.
|
||||||
* @param criteria
|
* @param criteria JPA criteria
|
||||||
* @return a DAO specified by the criteria
|
* @return a DAO specified by the criteria
|
||||||
*/
|
*/
|
||||||
public T singleResult(Criteria criteria)
|
public T singleResult(Criteria criteria)
|
||||||
|
@@ -40,8 +40,11 @@ public abstract class AbstractHibernateDSODAO<T extends DSpaceObject> extends Ab
|
|||||||
* The identifier of the join will be the toString() representation of the metadata field.
|
* The identifier of the join will be the toString() representation of the metadata field.
|
||||||
* The joineded metadata fields can then be used to query or sort.
|
* The joineded metadata fields can then be used to query or sort.
|
||||||
* @param query
|
* @param query
|
||||||
|
* partial SQL query (to be appended)
|
||||||
* @param tableIdentifier
|
* @param tableIdentifier
|
||||||
|
* DB table to join with
|
||||||
* @param metadataFields
|
* @param metadataFields
|
||||||
|
* a collection of metadata fields
|
||||||
*/
|
*/
|
||||||
protected void addMetadataLeftJoin(StringBuilder query, String tableIdentifier, Collection<MetadataField> metadataFields)
|
protected void addMetadataLeftJoin(StringBuilder query, String tableIdentifier, Collection<MetadataField> metadataFields)
|
||||||
{
|
{
|
||||||
@@ -63,26 +66,26 @@ public abstract class AbstractHibernateDSODAO<T extends DSpaceObject> extends Ab
|
|||||||
*/
|
*/
|
||||||
protected void addMetadataValueWhereQuery(StringBuilder query, List<MetadataField> metadataFields, String operator, String additionalWhere)
|
protected void addMetadataValueWhereQuery(StringBuilder query, List<MetadataField> metadataFields, String operator, String additionalWhere)
|
||||||
{
|
{
|
||||||
if(CollectionUtils.isNotEmpty(metadataFields) || StringUtils.isNotBlank(additionalWhere)){
|
if (CollectionUtils.isNotEmpty(metadataFields) || StringUtils.isNotBlank(additionalWhere)) {
|
||||||
//Add the where query on metadata
|
//Add the where query on metadata
|
||||||
query.append(" WHERE ");
|
query.append(" WHERE ");
|
||||||
for (int i = 0; i < metadataFields.size(); i++) {
|
for (int i = 0; i < metadataFields.size(); i++) {
|
||||||
MetadataField metadataField = metadataFields.get(i);
|
MetadataField metadataField = metadataFields.get(i);
|
||||||
if(StringUtils.isNotBlank(operator))
|
if (StringUtils.isNotBlank(operator))
|
||||||
{
|
{
|
||||||
query.append(" (");
|
query.append(" (");
|
||||||
query.append("lower(STR(" + metadataField.toString()).append(".value)) ").append(operator).append(" lower(:queryParam)");
|
query.append("lower(STR(" + metadataField.toString()).append(".value)) ").append(operator).append(" lower(:queryParam)");
|
||||||
query.append(")");
|
query.append(")");
|
||||||
if(i < metadataFields.size() - 1)
|
if (i < metadataFields.size() - 1)
|
||||||
{
|
{
|
||||||
query.append(" OR ");
|
query.append(" OR ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StringUtils.isNotBlank(additionalWhere))
|
if (StringUtils.isNotBlank(additionalWhere))
|
||||||
{
|
{
|
||||||
if(CollectionUtils.isNotEmpty(metadataFields))
|
if (CollectionUtils.isNotEmpty(metadataFields))
|
||||||
{
|
{
|
||||||
query.append(" OR ");
|
query.append(" OR ");
|
||||||
}
|
}
|
||||||
@@ -95,23 +98,23 @@ public abstract class AbstractHibernateDSODAO<T extends DSpaceObject> extends Ab
|
|||||||
protected void addMetadataSortQuery(StringBuilder query, List<MetadataField> metadataSortFields, List<String> columnSortFields)
|
protected void addMetadataSortQuery(StringBuilder query, List<MetadataField> metadataSortFields, List<String> columnSortFields)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(CollectionUtils.isNotEmpty(metadataSortFields)){
|
if (CollectionUtils.isNotEmpty(metadataSortFields)) {
|
||||||
query.append(" ORDER BY ");
|
query.append(" ORDER BY ");
|
||||||
for (int i = 0; i < metadataSortFields.size(); i++) {
|
for (int i = 0; i < metadataSortFields.size(); i++) {
|
||||||
MetadataField metadataField = metadataSortFields.get(i);
|
MetadataField metadataField = metadataSortFields.get(i);
|
||||||
query.append("STR(").append(metadataField.toString()).append(".value)");
|
query.append("STR(").append(metadataField.toString()).append(".value)");
|
||||||
if(i != metadataSortFields.size() -1)
|
if (i != metadataSortFields.size() -1)
|
||||||
{
|
{
|
||||||
query.append(",");
|
query.append(",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(CollectionUtils.isNotEmpty(columnSortFields))
|
} else if (CollectionUtils.isNotEmpty(columnSortFields))
|
||||||
{
|
{
|
||||||
query.append(" ORDER BY ");
|
query.append(" ORDER BY ");
|
||||||
for (int i = 0; i < columnSortFields.size(); i++) {
|
for (int i = 0; i < columnSortFields.size(); i++) {
|
||||||
String sortField = columnSortFields.get(i);
|
String sortField = columnSortFields.get(i);
|
||||||
query.append(sortField);
|
query.append(sortField);
|
||||||
if(i != columnSortFields.size() -1)
|
if (i != columnSortFields.size() -1)
|
||||||
{
|
{
|
||||||
query.append(",");
|
query.append(",");
|
||||||
}
|
}
|
||||||
|
@@ -130,7 +130,7 @@ public class Context
|
|||||||
/**
|
/**
|
||||||
* Initializes a new context object.
|
* Initializes a new context object.
|
||||||
*
|
*
|
||||||
* @exception SQLException
|
* @throws SQLException
|
||||||
* if there was an error obtaining a database connection
|
* if there was an error obtaining a database connection
|
||||||
*/
|
*/
|
||||||
private void init()
|
private void init()
|
||||||
@@ -337,7 +337,7 @@ public class Context
|
|||||||
* Calling complete() on a Context which is no longer valid (isValid()==false),
|
* Calling complete() on a Context which is no longer valid (isValid()==false),
|
||||||
* is a no-op.
|
* is a no-op.
|
||||||
*
|
*
|
||||||
* @exception SQLException
|
* @throws SQLException
|
||||||
* if there was an error completing the database transaction
|
* if there was an error completing the database transaction
|
||||||
* or closing the connection
|
* or closing the connection
|
||||||
*/
|
*/
|
||||||
@@ -448,6 +448,7 @@ public class Context
|
|||||||
* Add an event to be dispatched when this context is committed.
|
* Add an event to be dispatched when this context is committed.
|
||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
|
* event to be dispatched
|
||||||
*/
|
*/
|
||||||
public void addEvent(Event event)
|
public void addEvent(Event event)
|
||||||
{
|
{
|
||||||
@@ -630,10 +631,9 @@ public class Context
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the size of the cache of all object that have been read from the database so far. A larger number
|
* Returns the size of the cache of all object that have been read from the database so far.
|
||||||
* 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}).
|
|
||||||
*
|
*
|
||||||
|
* @return connection cache size
|
||||||
* @throws SQLException When connecting to the active cache fails.
|
* @throws SQLException When connecting to the active cache fails.
|
||||||
*/
|
*/
|
||||||
public long getCacheSize() throws SQLException {
|
public long getCacheSize() throws SQLException {
|
||||||
|
@@ -48,13 +48,20 @@ public interface DBConnection<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reload a DSpace object from the database. This will make sure the object is valid and stored in the cache.
|
* Reload a DSpace object from the database. This will make sure the object is valid and stored in the cache.
|
||||||
|
* @param <E> the type of entity.
|
||||||
* @param entity The DSpace object to reload
|
* @param entity The DSpace object to reload
|
||||||
|
* @return the reloaded entity.
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public <E extends ReloadableEntity> E reloadEntity(E entity) throws SQLException;
|
public <E extends ReloadableEntity> E reloadEntity(E entity) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a DSpace object from the cache when batch processing a large number of objects.
|
* Remove a DSpace object from the cache when batch processing a large number of objects.
|
||||||
|
* @param <E> the type of entity.
|
||||||
* @param entity The DSpace object to reload
|
* @param entity The DSpace object to reload
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public <E extends ReloadableEntity> void uncacheEntity(E entity) throws SQLException ;
|
public <E extends ReloadableEntity> void uncacheEntity(E entity) throws SQLException ;
|
||||||
}
|
}
|
||||||
|
@@ -42,25 +42,28 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing an e-mail message, also used to send e-mails.
|
* Class representing an e-mail message, also used to send e-mails.
|
||||||
* <P>
|
* <p>
|
||||||
* Typical use:
|
* Typical use:
|
||||||
* <P>
|
* </p>
|
||||||
|
* <p>
|
||||||
* <code>Email email = new Email();</code><br>
|
* <code>Email email = new Email();</code><br>
|
||||||
* <code>email.addRecipient("foo@bar.com");</code><br>
|
* <code>email.addRecipient("foo@bar.com");</code><br>
|
||||||
* <code>email.addArgument("John");</code><br>
|
* <code>email.addArgument("John");</code><br>
|
||||||
* <code>email.addArgument("On the Testing of DSpace");</code><br>
|
* <code>email.addArgument("On the Testing of DSpace");</code><br>
|
||||||
* <code>email.send();</code><br>
|
* <code>email.send();</code><br>
|
||||||
* <P>
|
* </p>
|
||||||
|
* <p>
|
||||||
* <code>name</code> is the name of an email template in
|
* <code>name</code> is the name of an email template in
|
||||||
* <code>dspace-dir/config/emails/</code> (which also includes the subject.)
|
* <code>dspace-dir/config/emails/</code> (which also includes the subject.)
|
||||||
* <code>arg0</code> and <code>arg1</code> are arguments to fill out the
|
* <code>arg0</code> and <code>arg1</code> are arguments to fill out the
|
||||||
* message with.
|
* message with.
|
||||||
* <P>
|
* </p>
|
||||||
|
* <p>
|
||||||
* Emails are formatted using <code>java.text.MessageFormat.</code>
|
* Emails are formatted using <code>java.text.MessageFormat.</code>
|
||||||
* Additionally, comment lines (starting with '#') are stripped, and if a line
|
* Additionally, comment lines (starting with '#') are stripped, and if a line
|
||||||
* starts with "Subject:" the text on the right of the colon is used for the
|
* starts with "Subject:" the text on the right of the colon is used for the
|
||||||
* subject line. For example:
|
* subject line. For example:
|
||||||
* <P>
|
* </p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
@@ -77,10 +80,10 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
|||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* <P>
|
* <p>
|
||||||
* If the example code above was used to send this mail, the resulting mail
|
* If the example code above was used to send this mail, the resulting mail
|
||||||
* would have the subject <code>Example e-mail</code> and the body would be:
|
* would have the subject <code>Example e-mail</code> and the body would be:
|
||||||
* <P>
|
* </p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
*
|
*
|
||||||
@@ -91,9 +94,10 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
|||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* <P>
|
* <p>
|
||||||
* Note that parameters like <code>{0}</code> cannot be placed in the subject
|
* Note that parameters like <code>{0}</code> cannot be placed in the subject
|
||||||
* of the e-mail; they won't get filled out.
|
* of the e-mail; they won't get filled out.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Robert Tansley
|
* @author Robert Tansley
|
||||||
@@ -295,37 +299,44 @@ public class Email
|
|||||||
message.setText(fullMessage);
|
message.setText(fullMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
Multipart multipart = new MimeMultipart();
|
{
|
||||||
// create the first part of the email
|
Multipart multipart = new MimeMultipart();
|
||||||
BodyPart messageBodyPart = new MimeBodyPart();
|
// create the first part of the email
|
||||||
messageBodyPart.setText(fullMessage);
|
BodyPart messageBodyPart = new MimeBodyPart();
|
||||||
multipart.addBodyPart(messageBodyPart);
|
messageBodyPart.setText(fullMessage);
|
||||||
if(!attachments.isEmpty()){
|
multipart.addBodyPart(messageBodyPart);
|
||||||
for (Iterator<FileAttachment> iter = attachments.iterator(); iter.hasNext();)
|
if (!attachments.isEmpty()) {
|
||||||
{
|
for (Iterator<FileAttachment> iter = attachments.iterator(); iter.hasNext();)
|
||||||
FileAttachment f = iter.next();
|
{
|
||||||
// add the file
|
FileAttachment f = iter.next();
|
||||||
messageBodyPart = new MimeBodyPart();
|
// add the file
|
||||||
messageBodyPart.setDataHandler(new DataHandler(
|
messageBodyPart = new MimeBodyPart();
|
||||||
new FileDataSource(f.file)));
|
messageBodyPart.setDataHandler(new DataHandler(
|
||||||
messageBodyPart.setFileName(f.name);
|
new FileDataSource(f.file)));
|
||||||
multipart.addBodyPart(messageBodyPart);
|
messageBodyPart.setFileName(f.name);
|
||||||
}
|
multipart.addBodyPart(messageBodyPart);
|
||||||
message.setContent(multipart);
|
}
|
||||||
}
|
message.setContent(multipart);
|
||||||
if(!moreAttachments.isEmpty()){
|
}
|
||||||
for (Iterator<InputStreamAttachment> iter = moreAttachments.iterator(); iter.hasNext();)
|
if (!moreAttachments.isEmpty()) {
|
||||||
{
|
for (Iterator<InputStreamAttachment> iter = moreAttachments.iterator(); iter.hasNext();)
|
||||||
InputStreamAttachment isa = iter.next();
|
{
|
||||||
// add the stream
|
InputStreamAttachment isa = iter.next();
|
||||||
messageBodyPart = new MimeBodyPart();
|
// add the stream
|
||||||
messageBodyPart.setDataHandler(new DataHandler(new InputStreamDataSource(isa.name,isa.mimetype,isa.is)));
|
messageBodyPart = new MimeBodyPart();
|
||||||
messageBodyPart.setFileName(isa.name);
|
messageBodyPart.setDataHandler(
|
||||||
multipart.addBodyPart(messageBodyPart);
|
new DataHandler(new InputStreamDataSource(
|
||||||
}
|
isa.name,
|
||||||
message.setContent(multipart);
|
isa.mimetype,
|
||||||
}
|
isa.is)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
messageBodyPart.setFileName(isa.name);
|
||||||
|
multipart.addBodyPart(messageBodyPart);
|
||||||
|
}
|
||||||
|
message.setContent(multipart);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replyTo != null)
|
if (replyTo != null)
|
||||||
@@ -338,7 +349,7 @@ public class Email
|
|||||||
if (disabled)
|
if (disabled)
|
||||||
{
|
{
|
||||||
StringBuffer text = new StringBuffer(
|
StringBuffer text = new StringBuffer(
|
||||||
"Message not sent due to mail.server.disabled:\n");
|
"Message not sent due to mail.server.disabled:\n");
|
||||||
|
|
||||||
Enumeration<String> headers = message.getAllHeaderLines();
|
Enumeration<String> headers = message.getAllHeaderLines();
|
||||||
while (headers.hasMoreElements())
|
while (headers.hasMoreElements())
|
||||||
@@ -375,7 +386,7 @@ public class Email
|
|||||||
* error reading the template
|
* error reading the template
|
||||||
*/
|
*/
|
||||||
public static Email getEmail(String emailFile)
|
public static Email getEmail(String emailFile)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
String charset = null;
|
String charset = null;
|
||||||
String subject = "";
|
String subject = "";
|
||||||
@@ -459,7 +470,7 @@ public class Email
|
|||||||
/**
|
/**
|
||||||
* Test method to send an email to check email server settings
|
* Test method to send an email to check email server settings
|
||||||
*
|
*
|
||||||
* @param args Command line options
|
* @param args the command line arguments given
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
@@ -479,7 +490,7 @@ public class Email
|
|||||||
boolean disabled = config.getBooleanProperty("mail.server.disabled", false);
|
boolean disabled = config.getBooleanProperty("mail.server.disabled", false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( disabled)
|
if (disabled)
|
||||||
{
|
{
|
||||||
System.err.println("\nError sending email:");
|
System.err.println("\nError sending email:");
|
||||||
System.err.println(" - Error: cannot test email because mail.server.disabled is set to true");
|
System.err.println(" - Error: cannot test email because mail.server.disabled is set to true");
|
||||||
@@ -497,8 +508,10 @@ public class Email
|
|||||||
System.err.println("\nPlease see the DSpace documentation for assistance.\n");
|
System.err.println("\nPlease see the DSpace documentation for assistance.\n");
|
||||||
System.err.println("\n");
|
System.err.println("\n");
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}catch (IOException e1) {
|
}
|
||||||
System.err.println("\nError sending email:");
|
catch (IOException e1)
|
||||||
|
{
|
||||||
|
System.err.println("\nError sending email:");
|
||||||
System.err.println(" - Error: " + e1);
|
System.err.println(" - Error: " + e1);
|
||||||
System.err.println("\nPlease see the DSpace documentation for assistance.\n");
|
System.err.println("\nPlease see the DSpace documentation for assistance.\n");
|
||||||
System.err.println("\n");
|
System.err.println("\n");
|
||||||
|
@@ -33,6 +33,7 @@ public interface GenericDAO<T>
|
|||||||
* Fetch all persisted instances of a given object type.
|
* Fetch all persisted instances of a given object type.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param clazz the desired type.
|
* @param clazz the desired type.
|
||||||
* @return list of DAOs of the same type as clazz
|
* @return list of DAOs of the same type as clazz
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -43,6 +44,7 @@ public interface GenericDAO<T>
|
|||||||
* Execute a JPQL query returning a unique result.
|
* Execute a JPQL query returning a unique result.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param query JPQL query string
|
* @param query JPQL query string
|
||||||
* @return a DAO specified by the query string
|
* @return a DAO specified by the query string
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -57,6 +59,7 @@ public interface GenericDAO<T>
|
|||||||
* Execute a JPQL query and return a collection of results.
|
* Execute a JPQL query and return a collection of results.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param query JPQL query string
|
* @param query JPQL query string
|
||||||
* @return list of DAOs specified by the query string
|
* @return list of DAOs specified by the query string
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
|
@@ -23,38 +23,43 @@ import org.dspace.services.ConfigurationService;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* <p>
|
||||||
* The Legacy Plugin Service is a very simple component container (based on the
|
* The Legacy Plugin Service is a very simple component container (based on the
|
||||||
* legacy PluginManager class from 5.x or below). It reads defined "plugins" (interfaces)
|
* 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
|
* from config file(s) and makes them available to the API. (TODO: Someday, this
|
||||||
* entire "plugin" framework needs to be replaced by Spring Beans.)
|
* entire "plugin" framework needs to be replaced by Spring Beans.)
|
||||||
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* It creates and organizes components (plugins), and helps select a plugin in
|
* It creates and organizes components (plugins), and helps select a plugin in
|
||||||
* the cases where there are many possible choices. It also gives some limited
|
* the cases where there are many possible choices. It also gives some limited
|
||||||
* control over the lifecycle of a plugin. It manages three different types
|
* control over the lifecycle of a plugin. It manages three different types
|
||||||
* (usage patterns) of plugins:
|
* (usage patterns) of plugins:
|
||||||
* <p>
|
* </p>
|
||||||
* <ol><li> Singleton Plugin
|
* <ol>
|
||||||
* <br> There is only one implementation class for the plugin. It is indicated
|
* <li>Singleton Plugin<br>
|
||||||
|
* There is only one implementation class for the plugin. It is indicated
|
||||||
* in the configuration. This type of plugin chooses an implementations of
|
* in the configuration. This type of plugin chooses an implementations of
|
||||||
* a service, for the entire system, at configuration time. Your
|
* a service, for the entire system, at configuration time. Your
|
||||||
* application just fetches the plugin for that interface and gets the
|
* application just fetches the plugin for that interface and gets the
|
||||||
* configured-in choice.
|
* configured-in choice.</li>
|
||||||
*
|
*
|
||||||
* <p><li> Sequence Plugins
|
* <li>Sequence Plugins<br>
|
||||||
* <br> You need a sequence or series of plugins, to implement a mechanism like
|
* You need a sequence or series of plugins, to implement a mechanism like
|
||||||
* StackableAuthenticationMethods or a pipeline, where each plugin is
|
* StackableAuthenticationMethods or a pipeline, where each plugin is
|
||||||
* called in order to contribute its implementation of a process to the
|
* called in order to contribute its implementation of a process to the
|
||||||
* whole.
|
* whole.</li>
|
||||||
* <p><li> Named Plugins
|
* <li>Named Plugins<br>
|
||||||
* <br> Use a named plugin when the application has to choose one plugin
|
* Use a named plugin when the application has to choose one plugin
|
||||||
* implementation out of many available ones. Each implementation is bound
|
* implementation out of many available ones. Each implementation is bound
|
||||||
* to one or more names (symbolic identifiers) in the configuration.
|
* to one or more names (symbolic identifiers) in the configuration.</li>
|
||||||
* </ol><p>
|
* </ol>
|
||||||
|
* <p>
|
||||||
* The name is just a <code>String</code> to be associated with the
|
* The name is just a <code>String</code> to be associated with the
|
||||||
* combination of implementation class and interface. It may contain
|
* combination of implementation class and interface. It may contain
|
||||||
* any characters except for comma (,) and equals (=). It may contain
|
* any characters except for comma (,) and equals (=). It may contain
|
||||||
* embedded spaces. Comma is a special character used to separate
|
* embedded spaces. Comma is a special character used to separate
|
||||||
* names in the configuration entry.
|
* names in the configuration entry.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Larry Stone
|
* @author Larry Stone
|
||||||
* @author Tim Donohue (turned old PluginManager into a PluginService)
|
* @author Tim Donohue (turned old PluginManager into a PluginService)
|
||||||
@@ -122,7 +127,7 @@ public class LegacyPluginServiceImpl implements PluginService
|
|||||||
*
|
*
|
||||||
* @param interfaceClass interface Class object
|
* @param interfaceClass interface Class object
|
||||||
* @return instance of plugin
|
* @return instance of plugin
|
||||||
* @throws PluginConfigurationError
|
* @throws PluginConfigurationError if no matching singleton plugin is configured.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Object getSinglePlugin(Class interfaceClass)
|
public Object getSinglePlugin(Class interfaceClass)
|
||||||
@@ -209,7 +214,7 @@ public class LegacyPluginServiceImpl implements PluginService
|
|||||||
catch (ClassNotFoundException e)
|
catch (ClassNotFoundException e)
|
||||||
{
|
{
|
||||||
throw new PluginInstantiationException("Cannot load plugin class: " +
|
throw new PluginInstantiationException("Cannot load plugin class: " +
|
||||||
e.toString(), e);
|
e.toString(), e);
|
||||||
}
|
}
|
||||||
catch (InstantiationException|IllegalAccessException e)
|
catch (InstantiationException|IllegalAccessException e)
|
||||||
{
|
{
|
||||||
@@ -257,7 +262,7 @@ public class LegacyPluginServiceImpl implements PluginService
|
|||||||
// If there's no "=" separator in this value, assume it's
|
// If there's no "=" separator in this value, assume it's
|
||||||
// just a "name" that belongs with previous class.
|
// just a "name" that belongs with previous class.
|
||||||
// (This may occur if there's an unescaped comma between names)
|
// (This may occur if there's an unescaped comma between names)
|
||||||
if(prevClassName!=null && valSplit.length==1)
|
if (prevClassName!=null && valSplit.length==1)
|
||||||
{
|
{
|
||||||
className = prevClassName;
|
className = prevClassName;
|
||||||
name = valSplit[0];
|
name = valSplit[0];
|
||||||
@@ -383,7 +388,7 @@ public class LegacyPluginServiceImpl implements PluginService
|
|||||||
catch (ClassNotFoundException e)
|
catch (ClassNotFoundException e)
|
||||||
{
|
{
|
||||||
throw new PluginInstantiationException("Cannot load plugin class: " +
|
throw new PluginInstantiationException("Cannot load plugin class: " +
|
||||||
e.toString(), e);
|
e.toString(), e);
|
||||||
}
|
}
|
||||||
catch (InstantiationException|IllegalAccessException e)
|
catch (InstantiationException|IllegalAccessException e)
|
||||||
{
|
{
|
||||||
@@ -416,7 +421,7 @@ public class LegacyPluginServiceImpl implements PluginService
|
|||||||
catch (ClassNotFoundException e)
|
catch (ClassNotFoundException e)
|
||||||
{
|
{
|
||||||
throw new PluginInstantiationException("Cannot load plugin class: " +
|
throw new PluginInstantiationException("Cannot load plugin class: " +
|
||||||
e.toString(), e);
|
e.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -713,7 +718,8 @@ public class LegacyPluginServiceImpl implements PluginService
|
|||||||
* Invoking this class from the command line just runs
|
* Invoking this class from the command line just runs
|
||||||
* <code>checkConfiguration</code> and shows the results.
|
* <code>checkConfiguration</code> and shows the results.
|
||||||
* There are no command-line options.
|
* There are no command-line options.
|
||||||
* @param argv arguments
|
*
|
||||||
|
* @param argv the command line arguments given
|
||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
public void main(String[] argv) throws Exception
|
public void main(String[] argv) throws Exception
|
||||||
|
@@ -35,27 +35,27 @@ public class NewsServiceImpl implements NewsService
|
|||||||
{
|
{
|
||||||
private final Logger log = LoggerFactory.getLogger(NewsServiceImpl.class);
|
private final Logger log = LoggerFactory.getLogger(NewsServiceImpl.class);
|
||||||
|
|
||||||
private List<String> acceptableFilenames;
|
private List<String> acceptableFilenames;
|
||||||
|
|
||||||
@Autowired(required = true)
|
@Autowired(required = true)
|
||||||
private ConfigurationService configurationService;
|
private ConfigurationService configurationService;
|
||||||
|
|
||||||
public void setAcceptableFilenames(List<String> acceptableFilenames) {
|
public void setAcceptableFilenames(List<String> acceptableFilenames) {
|
||||||
this.acceptableFilenames = addLocalesToAcceptableFilenames(acceptableFilenames);
|
this.acceptableFilenames = addLocalesToAcceptableFilenames(acceptableFilenames);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<String> addLocalesToAcceptableFilenames(List<String> acceptableFilenames){
|
protected List<String> addLocalesToAcceptableFilenames(List<String> acceptableFilenames) {
|
||||||
String [] locales = configurationService.getArrayProperty("webui.supported.locales");
|
String [] locales = configurationService.getArrayProperty("webui.supported.locales");
|
||||||
List<String> newAcceptableFilenames = new ArrayList<>();
|
List<String> newAcceptableFilenames = new ArrayList<>();
|
||||||
newAcceptableFilenames.addAll(acceptableFilenames);
|
newAcceptableFilenames.addAll(acceptableFilenames);
|
||||||
for(String local : locales){
|
for (String local : locales) {
|
||||||
for(String acceptableFilename : acceptableFilenames){
|
for (String acceptableFilename : acceptableFilenames) {
|
||||||
int lastPoint = acceptableFilename.lastIndexOf(".");
|
int lastPoint = acceptableFilename.lastIndexOf(".");
|
||||||
newAcceptableFilenames.add(
|
newAcceptableFilenames.add(
|
||||||
acceptableFilename.substring(0, lastPoint)
|
acceptableFilename.substring(0, lastPoint)
|
||||||
+ "_"
|
+ "_"
|
||||||
+ local
|
+ local
|
||||||
+ acceptableFilename.substring(lastPoint));
|
+ acceptableFilename.substring(lastPoint));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newAcceptableFilenames;
|
return newAcceptableFilenames;
|
||||||
@@ -68,9 +68,9 @@ public class NewsServiceImpl implements NewsService
|
|||||||
@Override
|
@Override
|
||||||
public String readNewsFile(String newsFile)
|
public String readNewsFile(String newsFile)
|
||||||
{
|
{
|
||||||
if (!validate(newsFile)) {
|
if (!validate(newsFile)) {
|
||||||
throw new IllegalArgumentException("The file "+ newsFile + " is not a valid news file");
|
throw new IllegalArgumentException("The file " + newsFile + " is not a valid news file");
|
||||||
}
|
}
|
||||||
String fileName = getNewsFilePath();
|
String fileName = getNewsFilePath();
|
||||||
|
|
||||||
fileName += newsFile;
|
fileName += newsFile;
|
||||||
@@ -106,9 +106,9 @@ public class NewsServiceImpl implements NewsService
|
|||||||
@Override
|
@Override
|
||||||
public String writeNewsFile(String newsFile, String news)
|
public String writeNewsFile(String newsFile, String news)
|
||||||
{
|
{
|
||||||
if (!validate(newsFile)) {
|
if (!validate(newsFile)) {
|
||||||
throw new IllegalArgumentException("The file "+ newsFile + " is not a valid news file");
|
throw new IllegalArgumentException("The file "+ newsFile + " is not a valid news file");
|
||||||
}
|
}
|
||||||
String fileName = getNewsFilePath();
|
String fileName = getNewsFilePath();
|
||||||
|
|
||||||
fileName += newsFile;
|
fileName += newsFile;
|
||||||
@@ -138,11 +138,11 @@ public class NewsServiceImpl implements NewsService
|
|||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean validate(String newsName) {
|
public boolean validate(String newsName) {
|
||||||
if (acceptableFilenames != null) {
|
if (acceptableFilenames != null) {
|
||||||
return acceptableFilenames.contains(newsName);
|
return acceptableFilenames.contains(newsName);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,11 +42,12 @@ public interface NewsService {
|
|||||||
public String getNewsFilePath();
|
public String getNewsFilePath();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the newsName is a valid one
|
* Check if the newsName is an acceptable file name
|
||||||
*
|
*
|
||||||
* @param newsName
|
* @param newsName
|
||||||
|
* news name
|
||||||
* @return true
|
* @return true
|
||||||
* if the newsName is valid
|
* if the newsName is valid
|
||||||
*/
|
*/
|
||||||
public boolean validate(String newsName);
|
public boolean validate(String newsName);
|
||||||
}
|
}
|
||||||
|
@@ -113,7 +113,10 @@ public class BasicLinkChecker extends AbstractCurationTask
|
|||||||
/**
|
/**
|
||||||
* Check the URL and perform appropriate reporting
|
* Check the URL and perform appropriate reporting
|
||||||
*
|
*
|
||||||
* @param url The URL to check
|
* @param url
|
||||||
|
* The URL to check
|
||||||
|
* @param results
|
||||||
|
* Result string with HTTP status codes
|
||||||
* @return If the URL was OK or not
|
* @return If the URL was OK or not
|
||||||
*/
|
*/
|
||||||
protected boolean checkURL(String url, StringBuilder results)
|
protected boolean checkURL(String url, StringBuilder results)
|
||||||
|
@@ -113,6 +113,8 @@ public class BitstreamsIntoMetadata extends AbstractCurationTask
|
|||||||
* @param item The item
|
* @param item The item
|
||||||
* @param bitstream The bitstream
|
* @param bitstream The bitstream
|
||||||
* @param type The type of bitstream
|
* @param type The type of bitstream
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
protected void addMetadata(Item item, Bitstream bitstream, String type) throws SQLException {
|
protected void addMetadata(Item item, Bitstream bitstream, String type) throws SQLException {
|
||||||
String value = bitstream.getFormat(Curator.curationContext()).getMIMEType() + "##";
|
String value = bitstream.getFormat(Curator.curationContext()).getMIMEType() + "##";
|
||||||
|
@@ -156,6 +156,9 @@ public class ClamScan extends AbstractCurationTask
|
|||||||
/** openSession
|
/** openSession
|
||||||
*
|
*
|
||||||
* This method opens a session.
|
* This method opens a session.
|
||||||
|
*
|
||||||
|
* @throws IOException
|
||||||
|
* A general class of exceptions produced by failed or interrupted I/O operations.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected void openSession() throws IOException
|
protected void openSession() throws IOException
|
||||||
|
@@ -86,7 +86,7 @@ public class Curator
|
|||||||
*/
|
*/
|
||||||
public Curator addTask(String taskName)
|
public Curator addTask(String taskName)
|
||||||
{
|
{
|
||||||
ResolvedTask task = resolver.resolveTask(taskName);
|
ResolvedTask task = resolver.resolveTask(taskName);
|
||||||
if (task != null)
|
if (task != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -149,7 +149,7 @@ public class Curator
|
|||||||
*
|
*
|
||||||
* @param reporter name of reporting stream. The name '-'
|
* @param reporter name of reporting stream. The name '-'
|
||||||
* causes reporting to standard out.
|
* causes reporting to standard out.
|
||||||
* @return the Curator instance
|
* @return return self (Curator instance) with reporter set
|
||||||
*/
|
*/
|
||||||
public Curator setReporter(String reporter)
|
public Curator setReporter(String reporter)
|
||||||
{
|
{
|
||||||
@@ -166,11 +166,14 @@ public class Curator
|
|||||||
* entire performance is complete, and a scope of 'object'
|
* entire performance is complete, and a scope of 'object'
|
||||||
* will commit for each object (e.g. item) encountered in
|
* will commit for each object (e.g. item) encountered in
|
||||||
* a given execution.
|
* a given execution.
|
||||||
|
*
|
||||||
|
* @param scope transactional scope
|
||||||
|
* @return return self (Curator instance) with given scope set
|
||||||
*/
|
*/
|
||||||
public Curator setTransactionScope(TxScope scope)
|
public Curator setTransactionScope(TxScope scope)
|
||||||
{
|
{
|
||||||
txScope = scope;
|
txScope = scope;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -207,11 +210,11 @@ public class Curator
|
|||||||
}
|
}
|
||||||
// if curation scoped, commit transaction
|
// if curation scoped, commit transaction
|
||||||
if (txScope.equals(TxScope.CURATION)) {
|
if (txScope.equals(TxScope.CURATION)) {
|
||||||
Context ctx = curationCtx.get();
|
Context ctx = curationCtx.get();
|
||||||
if (ctx != null)
|
if (ctx != null)
|
||||||
{
|
{
|
||||||
ctx.complete();
|
ctx.complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException sqlE)
|
catch (SQLException sqlE)
|
||||||
@@ -358,18 +361,20 @@ public class Curator
|
|||||||
/**
|
/**
|
||||||
* Returns the context object used in the current curation thread.
|
* Returns the context object used in the current curation thread.
|
||||||
* This is primarily a utility method to allow tasks access to the context when necessary.
|
* This is primarily a utility method to allow tasks access to the context when necessary.
|
||||||
* <P>
|
* <p>
|
||||||
* If the context is null or not set, then this just returns
|
* If the context is null or not set, then this just returns
|
||||||
* a brand new Context object representing an Anonymous User.
|
* a brand new Context object representing an Anonymous User.
|
||||||
*
|
*
|
||||||
* @return curation thread's Context object (or a new, anonymous Context if no curation Context exists)
|
* @return curation thread's Context object (or a new, anonymous Context if no curation Context exists)
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public static Context curationContext() throws SQLException
|
public static Context curationContext() throws SQLException
|
||||||
{
|
{
|
||||||
// Return curation context or new context if undefined/invalid
|
// Return curation context or new context if undefined/invalid
|
||||||
Context curCtx = curationCtx.get();
|
Context curCtx = curationCtx.get();
|
||||||
|
|
||||||
if(curCtx==null || !curCtx.isValid())
|
if (curCtx==null || !curCtx.isValid())
|
||||||
{
|
{
|
||||||
//Create a new context (represents an Anonymous User)
|
//Create a new context (represents an Anonymous User)
|
||||||
curCtx = new Context();
|
curCtx = new Context();
|
||||||
@@ -407,7 +412,7 @@ public class Curator
|
|||||||
|
|
||||||
// Site-wide Tasks really should have an EPerson performer associated with them,
|
// Site-wide Tasks really should have an EPerson performer associated with them,
|
||||||
// otherwise they are run as an "anonymous" user with limited access rights.
|
// otherwise they are run as an "anonymous" user with limited access rights.
|
||||||
if(ctx.getCurrentUser()==null && !ctx.ignoreAuthorization())
|
if (ctx.getCurrentUser()==null && !ctx.ignoreAuthorization())
|
||||||
{
|
{
|
||||||
log.warn("You are running one or more Site-Wide curation tasks in ANONYMOUS USER mode," +
|
log.warn("You are running one or more Site-Wide curation tasks in ANONYMOUS USER mode," +
|
||||||
" as there is no EPerson 'performer' associated with this task. To associate an EPerson 'performer' " +
|
" as there is no EPerson 'performer' associated with this task. To associate an EPerson 'performer' " +
|
||||||
@@ -502,17 +507,20 @@ public class Curator
|
|||||||
/**
|
/**
|
||||||
* Record a 'visit' to a DSpace object and enforce any policies set
|
* Record a 'visit' to a DSpace object and enforce any policies set
|
||||||
* on this curator.
|
* on this curator.
|
||||||
|
* @param dso the DSpace object
|
||||||
|
* @throws IOException
|
||||||
|
* A general class of exceptions produced by failed or interrupted I/O operations.
|
||||||
*/
|
*/
|
||||||
protected void visit(DSpaceObject dso) throws IOException
|
protected void visit(DSpaceObject dso) throws IOException
|
||||||
{
|
{
|
||||||
Context curCtx = curationCtx.get();
|
Context curCtx = curationCtx.get();
|
||||||
if (curCtx != null)
|
if (curCtx != null)
|
||||||
{
|
{
|
||||||
if (txScope.equals(TxScope.OBJECT))
|
if (txScope.equals(TxScope.OBJECT))
|
||||||
{
|
{
|
||||||
curCtx.dispatchEvents();
|
curCtx.dispatchEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class TaskRunner
|
protected class TaskRunner
|
||||||
@@ -540,7 +548,7 @@ public class Curator
|
|||||||
visit(dso);
|
visit(dso);
|
||||||
return ! suspend(statusCode);
|
return ! suspend(statusCode);
|
||||||
}
|
}
|
||||||
catch(IOException ioe)
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
//log error & pass exception upwards
|
//log error & pass exception upwards
|
||||||
log.error("Error executing curation task '" + task.getName() + "'", ioe);
|
log.error("Error executing curation task '" + task.getName() + "'", ioe);
|
||||||
@@ -561,7 +569,7 @@ public class Curator
|
|||||||
visit(null);
|
visit(null);
|
||||||
return ! suspend(statusCode);
|
return ! suspend(statusCode);
|
||||||
}
|
}
|
||||||
catch(IOException ioe)
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
//log error & pass exception upwards
|
//log error & pass exception upwards
|
||||||
log.error("Error executing curation task '" + task.getName() + "'", ioe);
|
log.error("Error executing curation task '" + task.getName() + "'", ioe);
|
||||||
@@ -576,7 +584,7 @@ public class Curator
|
|||||||
|
|
||||||
protected boolean suspend(int code)
|
protected boolean suspend(int code)
|
||||||
{
|
{
|
||||||
Invoked mode = task.getMode();
|
Invoked mode = task.getMode();
|
||||||
if (mode != null && (mode.equals(Invoked.ANY) || mode.equals(iMode)))
|
if (mode != null && (mode.equals(Invoked.ANY) || mode.equals(iMode)))
|
||||||
{
|
{
|
||||||
for (int i : task.getCodes())
|
for (int i : task.getCodes())
|
||||||
|
@@ -114,6 +114,7 @@ public class ResolvedTask
|
|||||||
/**
|
/**
|
||||||
* Returns whether task should be distributed through containers
|
* Returns whether task should be distributed through containers
|
||||||
*
|
*
|
||||||
|
* @return whether task should be distributed through containers
|
||||||
*/
|
*/
|
||||||
public boolean isDistributive()
|
public boolean isDistributive()
|
||||||
{
|
{
|
||||||
@@ -123,6 +124,7 @@ public class ResolvedTask
|
|||||||
/**
|
/**
|
||||||
* Returns whether task alters (mutates) it's target objects
|
* Returns whether task alters (mutates) it's target objects
|
||||||
*
|
*
|
||||||
|
* @return whether task alters (mutates) it's target objects
|
||||||
*/
|
*/
|
||||||
public boolean isMutative()
|
public boolean isMutative()
|
||||||
{
|
{
|
||||||
@@ -139,6 +141,11 @@ public class ResolvedTask
|
|||||||
return codes;
|
return codes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether task is not scripted (curation task)
|
||||||
|
*
|
||||||
|
* @return true if this task is not scripted
|
||||||
|
*/
|
||||||
private boolean unscripted()
|
private boolean unscripted()
|
||||||
{
|
{
|
||||||
return sTask == null;
|
return sTask == null;
|
||||||
|
@@ -27,9 +27,13 @@ public final class TaskQueueEntry
|
|||||||
* TaskQueueEntry constructor with enumerated field values.
|
* TaskQueueEntry constructor with enumerated field values.
|
||||||
*
|
*
|
||||||
* @param epersonId
|
* @param epersonId
|
||||||
|
* task owner
|
||||||
* @param submitTime
|
* @param submitTime
|
||||||
|
* time the task was submitted (System.currentTimeMillis())
|
||||||
* @param taskNames
|
* @param taskNames
|
||||||
|
* list of task names
|
||||||
* @param objId
|
* @param objId
|
||||||
|
* usually a handle or workflow id
|
||||||
*/
|
*/
|
||||||
public TaskQueueEntry(String epersonId, long submitTime,
|
public TaskQueueEntry(String epersonId, long submitTime,
|
||||||
List<String> taskNames, String objId)
|
List<String> taskNames, String objId)
|
||||||
|
@@ -120,8 +120,8 @@ public class Utils
|
|||||||
/**
|
/**
|
||||||
* Performs a buffered copy from one file into another.
|
* Performs a buffered copy from one file into another.
|
||||||
*
|
*
|
||||||
* @param inFile
|
* @param inFile input file
|
||||||
* @param outFile
|
* @param outFile output file
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
*/
|
*/
|
||||||
public static void copy(File inFile, File outFile) throws IOException
|
public static void copy(File inFile, File outFile) throws IOException
|
||||||
|
@@ -54,7 +54,7 @@ import static javax.xml.stream.XMLStreamConstants.*;
|
|||||||
public class WorkflowCuratorServiceImpl implements WorkflowCuratorService
|
public class WorkflowCuratorServiceImpl implements WorkflowCuratorService
|
||||||
{
|
{
|
||||||
|
|
||||||
/** log4j logger */
|
/** log4j logger */
|
||||||
private Logger log = Logger.getLogger(WorkflowCuratorServiceImpl.class);
|
private Logger log = Logger.getLogger(WorkflowCuratorServiceImpl.class);
|
||||||
|
|
||||||
protected Map<String, TaskSet> tsMap = new HashMap<String, TaskSet>();
|
protected Map<String, TaskSet> tsMap = new HashMap<String, TaskSet>();
|
||||||
@@ -79,6 +79,7 @@ public class WorkflowCuratorServiceImpl implements WorkflowCuratorService
|
|||||||
* Ensures the configurationService is injected, so that we can read the
|
* Ensures the configurationService is injected, so that we can read the
|
||||||
* settings from configuration
|
* settings from configuration
|
||||||
* Called by "init-method" in Spring config.
|
* Called by "init-method" in Spring config.
|
||||||
|
* @throws Exception ...
|
||||||
*/
|
*/
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
File cfgFile = new File(configurationService.getProperty("dspace.dir") +
|
File cfgFile = new File(configurationService.getProperty("dspace.dir") +
|
||||||
@@ -87,7 +88,7 @@ public class WorkflowCuratorServiceImpl implements WorkflowCuratorService
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
loadTaskConfig(cfgFile);
|
loadTaskConfig(cfgFile);
|
||||||
if(workflowServiceFactory.getWorkflowService() instanceof BasicWorkflowItemService)
|
if (workflowServiceFactory.getWorkflowService() instanceof BasicWorkflowItemService)
|
||||||
{
|
{
|
||||||
basicWorkflowService = (BasicWorkflowService) workflowServiceFactory.getWorkflowService();
|
basicWorkflowService = (BasicWorkflowService) workflowServiceFactory.getWorkflowService();
|
||||||
basicWorkflowItemService = (BasicWorkflowItemService) workflowServiceFactory.getWorkflowItemService();
|
basicWorkflowItemService = (BasicWorkflowItemService) workflowServiceFactory.getWorkflowItemService();
|
||||||
|
@@ -46,8 +46,12 @@ public interface WorkflowCuratorService {
|
|||||||
/**
|
/**
|
||||||
* Determines and executes curation of a Workflow item.
|
* Determines and executes curation of a Workflow item.
|
||||||
*
|
*
|
||||||
|
* @param curator the Curator object
|
||||||
* @param c the user context
|
* @param c the user context
|
||||||
* @param wfId the workflow id
|
* @param wfId the workflow id
|
||||||
|
* @return true if curation was completed or not required,
|
||||||
|
* false if no workflow item found for id
|
||||||
|
* or item was rejected
|
||||||
* @throws AuthorizeException if authorization error
|
* @throws AuthorizeException if authorization error
|
||||||
* @throws IOException if IO error
|
* @throws IOException if IO error
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
@@ -55,6 +59,18 @@ public interface WorkflowCuratorService {
|
|||||||
public boolean curate(Curator curator, Context c, String wfId)
|
public boolean curate(Curator curator, Context c, String wfId)
|
||||||
throws AuthorizeException, IOException, SQLException;
|
throws AuthorizeException, IOException, SQLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines and executes curation of a Workflow item.
|
||||||
|
*
|
||||||
|
* @param curator the Curator object
|
||||||
|
* @param c the user context
|
||||||
|
* @param wfi the workflow item
|
||||||
|
* @return true if curation was completed or not required,
|
||||||
|
* false if item was rejected
|
||||||
|
* @throws AuthorizeException if authorization error
|
||||||
|
* @throws IOException if IO error
|
||||||
|
* @throws SQLException if database error
|
||||||
|
*/
|
||||||
public boolean curate(Curator curator, Context c, BasicWorkflowItem wfi)
|
public boolean curate(Curator curator, Context c, BasicWorkflowItem wfi)
|
||||||
throws AuthorizeException, IOException, SQLException;
|
throws AuthorizeException, IOException, SQLException;
|
||||||
}
|
}
|
||||||
|
@@ -40,12 +40,17 @@ public class DiscoverHitHighlightingField {
|
|||||||
* field containing a matching hit. e.g. If maxChars = 200
|
* field containing a matching hit. e.g. If maxChars = 200
|
||||||
* and a hit is found in the full-text the 200 chars
|
* and a hit is found in the full-text the 200 chars
|
||||||
* surrounding the hit will be shown
|
* surrounding the hit will be shown
|
||||||
|
*
|
||||||
|
* @return max number of characters shown for a hit
|
||||||
*/
|
*/
|
||||||
public int getMaxChars()
|
public int getMaxChars()
|
||||||
{
|
{
|
||||||
return maxChars;
|
return maxChars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return max number of result snippets
|
||||||
|
*/
|
||||||
public int getMaxSnippets()
|
public int getMaxSnippets()
|
||||||
{
|
{
|
||||||
return maxSnippets;
|
return maxSnippets;
|
||||||
|
@@ -41,12 +41,15 @@ public class IndexClient {
|
|||||||
* from the whole index
|
* from the whole index
|
||||||
*
|
*
|
||||||
* @param args the command-line arguments, none used
|
* @param args the command-line arguments, none used
|
||||||
* @throws java.io.IOException
|
* @throws SQLException
|
||||||
* @throws SQLException if database error
|
* An exception that provides information on a database access error or other errors.
|
||||||
*
|
* @throws IOException
|
||||||
|
* A general class of exceptions produced by failed or interrupted I/O operations.
|
||||||
|
* @throws SearchServiceException if something went wrong with querying the solr server
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) throws SQLException, IOException, SearchServiceException {
|
public static void main(String[] args)
|
||||||
|
throws SQLException, IOException, SearchServiceException
|
||||||
|
{
|
||||||
Context context = new Context();
|
Context context = new Context();
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
@@ -55,46 +58,49 @@ public class IndexClient {
|
|||||||
HelpFormatter formatter = new HelpFormatter();
|
HelpFormatter formatter = new HelpFormatter();
|
||||||
CommandLine line = null;
|
CommandLine line = null;
|
||||||
|
|
||||||
options
|
options.addOption(OptionBuilder
|
||||||
.addOption(OptionBuilder
|
.withArgName("handle to remove")
|
||||||
.withArgName("handle to remove")
|
.hasArg(true)
|
||||||
.hasArg(true)
|
.withDescription(
|
||||||
.withDescription(
|
"remove an Item, Collection or Community from index based on its handle")
|
||||||
"remove an Item, Collection or Community from index based on its handle")
|
.create("r"));
|
||||||
.create("r"));
|
|
||||||
|
|
||||||
options
|
options.addOption(OptionBuilder
|
||||||
.addOption(OptionBuilder
|
.withArgName("handle to add or update")
|
||||||
.withArgName("handle to add or update")
|
.hasArg(true)
|
||||||
.hasArg(true)
|
.withDescription(
|
||||||
.withDescription(
|
"add or update an Item, Collection or Community based on its handle")
|
||||||
"add or update an Item, Collection or Community based on its handle")
|
.create("i"));
|
||||||
.create("i"));
|
|
||||||
|
|
||||||
options
|
options.addOption(OptionBuilder
|
||||||
.addOption(OptionBuilder
|
.isRequired(false)
|
||||||
.isRequired(false)
|
.withDescription(
|
||||||
.withDescription(
|
"clean existing index removing any documents that no longer exist in the db")
|
||||||
"clean existing index removing any documents that no longer exist in the db")
|
.create("c"));
|
||||||
.create("c"));
|
|
||||||
|
|
||||||
options.addOption(OptionBuilder.isRequired(false).withDescription(
|
options.addOption(OptionBuilder
|
||||||
"(re)build index, wiping out current one if it exists").create(
|
.isRequired(false)
|
||||||
"b"));
|
.withDescription(
|
||||||
|
"(re)build index, wiping out current one if it exists")
|
||||||
|
.create("b"));
|
||||||
|
|
||||||
options.addOption(OptionBuilder.isRequired(false).withDescription(
|
options.addOption(OptionBuilder
|
||||||
"Rebuild the spellchecker, can be combined with -b and -f.").create(
|
.isRequired(false)
|
||||||
"s"));
|
.withDescription(
|
||||||
|
"Rebuild the spellchecker, can be combined with -b and -f.")
|
||||||
|
.create("s"));
|
||||||
|
|
||||||
options
|
options.addOption(OptionBuilder
|
||||||
.addOption(OptionBuilder
|
.isRequired(false)
|
||||||
.isRequired(false)
|
.withDescription(
|
||||||
.withDescription(
|
"if updating existing index, force each handle to be reindexed even if uptodate")
|
||||||
"if updating existing index, force each handle to be reindexed even if uptodate")
|
.create("f"));
|
||||||
.create("f"));
|
|
||||||
|
|
||||||
options.addOption(OptionBuilder.isRequired(false).withDescription(
|
options.addOption(OptionBuilder
|
||||||
"print this help message").create("h"));
|
.isRequired(false)
|
||||||
|
.withDescription(
|
||||||
|
"print this help message")
|
||||||
|
.create("h"));
|
||||||
|
|
||||||
options.addOption(OptionBuilder.isRequired(false).withDescription(
|
options.addOption(OptionBuilder.isRequired(false).withDescription(
|
||||||
"optimize search core").create("o"));
|
"optimize search core").create("o"));
|
||||||
@@ -118,7 +124,10 @@ public class IndexClient {
|
|||||||
* new DSpace.getServiceManager().getServiceByName("org.dspace.discovery.SolrIndexer");
|
* new DSpace.getServiceManager().getServiceByName("org.dspace.discovery.SolrIndexer");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
IndexingService indexer = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(IndexingService.class.getName(),IndexingService.class);
|
IndexingService indexer = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(
|
||||||
|
IndexingService.class.getName(),
|
||||||
|
IndexingService.class
|
||||||
|
);
|
||||||
|
|
||||||
if (line.hasOption("r")) {
|
if (line.hasOption("r")) {
|
||||||
log.info("Removing " + line.getOptionValue("r") + " from Index");
|
log.info("Removing " + line.getOptionValue("r") + " from Index");
|
||||||
@@ -133,9 +142,9 @@ public class IndexClient {
|
|||||||
} else if (line.hasOption("o")) {
|
} else if (line.hasOption("o")) {
|
||||||
log.info("Optimizing search core.");
|
log.info("Optimizing search core.");
|
||||||
indexer.optimize();
|
indexer.optimize();
|
||||||
} else if(line.hasOption('s')) {
|
} else if (line.hasOption('s')) {
|
||||||
checkRebuildSpellCheck(line, indexer);
|
checkRebuildSpellCheck(line, indexer);
|
||||||
} else if(line.hasOption('i')) {
|
} else if (line.hasOption('i')) {
|
||||||
final String handle = line.getOptionValue('i');
|
final String handle = line.getOptionValue('i');
|
||||||
final DSpaceObject dso = HandleServiceFactory.getInstance().getHandleService().resolveToObject(context, handle);
|
final DSpaceObject dso = HandleServiceFactory.getInstance().getHandleService().resolveToObject(context, handle);
|
||||||
if (dso == null) {
|
if (dso == null) {
|
||||||
@@ -156,15 +165,31 @@ public class IndexClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info("Done with indexing");
|
log.info("Done with indexing");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indexes the given object and all children, if applicable.
|
* Indexes the given object and all children, if applicable.
|
||||||
|
*
|
||||||
|
* @param indexingService
|
||||||
|
*
|
||||||
|
* @param itemService
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
|
* @param dso
|
||||||
|
* DSpace object to index recursively
|
||||||
|
* @throws IOException
|
||||||
|
* A general class of exceptions produced by failed or interrupted I/O operations.
|
||||||
|
* @throws SearchServiceException in case of a solr exception
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
private static long indexAll(final IndexingService indexingService,
|
private static long indexAll(final IndexingService indexingService,
|
||||||
final ItemService itemService,
|
final ItemService itemService,
|
||||||
final Context context,
|
final Context context,
|
||||||
final DSpaceObject dso) throws IOException, SearchServiceException, SQLException {
|
final DSpaceObject dso)
|
||||||
|
throws IOException, SearchServiceException, SQLException
|
||||||
|
{
|
||||||
long count = 0;
|
long count = 0;
|
||||||
|
|
||||||
indexingService.indexContent(context, dso, true, true);
|
indexingService.indexContent(context, dso, true, true);
|
||||||
@@ -194,11 +219,27 @@ public class IndexClient {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Indexes all items in the given collection.
|
* Indexes all items in the given collection.
|
||||||
|
*
|
||||||
|
* @param indexingService
|
||||||
|
*
|
||||||
|
* @param itemService
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
|
* @param collection
|
||||||
|
* collection to index
|
||||||
|
* @throws IOException
|
||||||
|
* A general class of exceptions produced by failed or interrupted I/O operations.
|
||||||
|
* @throws SearchServiceException in case of a solr exception
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
private static long indexItems(final IndexingService indexingService,
|
private static long indexItems(final IndexingService indexingService,
|
||||||
final ItemService itemService,
|
final ItemService itemService,
|
||||||
final Context context,
|
final Context context,
|
||||||
final Collection collection) throws IOException, SearchServiceException, SQLException {
|
final Collection collection)
|
||||||
|
throws IOException, SearchServiceException, SQLException
|
||||||
|
{
|
||||||
long count = 0;
|
long count = 0;
|
||||||
|
|
||||||
final Iterator<Item> itemIterator = itemService.findByCollection(context, collection);
|
final Iterator<Item> itemIterator = itemService.findByCollection(context, collection);
|
||||||
@@ -220,10 +261,12 @@ public class IndexClient {
|
|||||||
* @param indexer the solr indexer
|
* @param indexer the solr indexer
|
||||||
* @throws SearchServiceException in case of a solr exception
|
* @throws SearchServiceException in case of a solr exception
|
||||||
*/
|
*/
|
||||||
protected static void checkRebuildSpellCheck(CommandLine line, IndexingService indexer) throws SearchServiceException {
|
protected static void checkRebuildSpellCheck(CommandLine line, IndexingService indexer)
|
||||||
|
throws SearchServiceException
|
||||||
|
{
|
||||||
if (line.hasOption("s")) {
|
if (line.hasOption("s")) {
|
||||||
log.info("Rebuilding spell checker.");
|
log.info("Rebuilding spell checker.");
|
||||||
indexer.buildSpellCheck();
|
indexer.buildSpellCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,7 @@ public interface SearchService {
|
|||||||
* DSpace Context object.
|
* DSpace Context object.
|
||||||
* @param query
|
* @param query
|
||||||
* the discovery query object.
|
* the discovery query object.
|
||||||
|
* @return discovery search result object
|
||||||
* @throws SearchServiceException if search error
|
* @throws SearchServiceException if search error
|
||||||
*/
|
*/
|
||||||
DiscoverResult search(Context context, DiscoverQuery query)
|
DiscoverResult search(Context context, DiscoverQuery query)
|
||||||
@@ -50,6 +51,7 @@ public interface SearchService {
|
|||||||
* within this object)
|
* within this object)
|
||||||
* @param query
|
* @param query
|
||||||
* the discovery query object
|
* the discovery query object
|
||||||
|
* @return discovery search result object
|
||||||
* @throws SearchServiceException if search error
|
* @throws SearchServiceException if search error
|
||||||
*/
|
*/
|
||||||
DiscoverResult search(Context context, DSpaceObject dso, DiscoverQuery query)
|
DiscoverResult search(Context context, DSpaceObject dso, DiscoverQuery query)
|
||||||
@@ -64,6 +66,7 @@ public interface SearchService {
|
|||||||
* @param includeWithdrawn
|
* @param includeWithdrawn
|
||||||
* use <code>true</code> to include in the results also withdrawn
|
* use <code>true</code> to include in the results also withdrawn
|
||||||
* items that match the query.
|
* items that match the query.
|
||||||
|
* @return discovery search result object
|
||||||
* @throws SearchServiceException if search error
|
* @throws SearchServiceException if search error
|
||||||
*/
|
*/
|
||||||
DiscoverResult search(Context context, DiscoverQuery query,
|
DiscoverResult search(Context context, DiscoverQuery query,
|
||||||
@@ -81,7 +84,7 @@ public interface SearchService {
|
|||||||
* @param includeWithdrawn
|
* @param includeWithdrawn
|
||||||
* use <code>true</code> to include in the results also withdrawn
|
* use <code>true</code> to include in the results also withdrawn
|
||||||
* items that match the query
|
* items that match the query
|
||||||
*
|
* @return discovery search result object
|
||||||
* @throws SearchServiceException if search error
|
* @throws SearchServiceException if search error
|
||||||
*/
|
*/
|
||||||
DiscoverResult search(Context context, DSpaceObject dso, DiscoverQuery query, boolean includeWithdrawn) throws SearchServiceException;
|
DiscoverResult search(Context context, DSpaceObject dso, DiscoverQuery query, boolean includeWithdrawn) throws SearchServiceException;
|
||||||
@@ -97,11 +100,14 @@ public interface SearchService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms the given string field and value into a filter query
|
* Transforms the given string field and value into a filter query
|
||||||
* @param context the DSpace context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param field the field of the filter query
|
* @param field the field of the filter query
|
||||||
|
* @param operator equals/notequals/notcontains/authority/notauthority
|
||||||
* @param value the filter query value
|
* @param value the filter query value
|
||||||
* @return a filter query
|
* @return a filter query
|
||||||
* @throws SQLException if database error
|
* @throws SQLException if database error
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
DiscoverFilterQuery toFilterQuery(Context context, String field, String operator, String value) throws SQLException;
|
DiscoverFilterQuery toFilterQuery(Context context, String field, String operator, String value) throws SQLException;
|
||||||
|
|
||||||
@@ -118,21 +124,27 @@ public interface SearchService {
|
|||||||
* communities/collections only.
|
* communities/collections only.
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
* @return
|
* The relevant DSpace Context.
|
||||||
|
* @return query string specific to the user's rights
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
String createLocationQueryForAdministrableItems(Context context) throws SQLException;
|
String createLocationQueryForAdministrableItems(Context context) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms the metadata field of the given sort configuration into the indexed field which we can then use in our solr queries
|
* Transforms the metadata field of the given sort configuration into the indexed field which we can then use in our Solr queries.
|
||||||
|
*
|
||||||
* @param metadataField the metadata field
|
* @param metadataField the metadata field
|
||||||
|
* @param type see {@link org.dspace.discovery.configuration.DiscoveryConfigurationParameters}
|
||||||
* @return the indexed field
|
* @return the indexed field
|
||||||
*/
|
*/
|
||||||
String toSortFieldIndex(String metadataField, String type);
|
String toSortFieldIndex(String metadataField, String type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to escape any special characters in a user's query
|
* Utility method to escape any special characters in a user's query
|
||||||
|
*
|
||||||
* @param query
|
* @param query
|
||||||
|
* User's query to escape.
|
||||||
* @return query with any special characters escaped
|
* @return query with any special characters escaped
|
||||||
*/
|
*/
|
||||||
String escapeQueryChars(String query);
|
String escapeQueryChars(String query);
|
||||||
|
@@ -31,28 +31,28 @@ public class SearchUtils {
|
|||||||
|
|
||||||
public static SearchService getSearchService()
|
public static SearchService getSearchService()
|
||||||
{
|
{
|
||||||
if(searchService == null){
|
if (searchService == null) {
|
||||||
org.dspace.kernel.ServiceManager manager = DSpaceServicesFactory.getInstance().getServiceManager();
|
org.dspace.kernel.ServiceManager manager = DSpaceServicesFactory.getInstance().getServiceManager();
|
||||||
searchService = manager.getServiceByName(SearchService.class.getName(),SearchService.class);
|
searchService = manager.getServiceByName(SearchService.class.getName(),SearchService.class);
|
||||||
}
|
}
|
||||||
return searchService;
|
return searchService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DiscoveryConfiguration getDiscoveryConfiguration(){
|
public static DiscoveryConfiguration getDiscoveryConfiguration() {
|
||||||
return getDiscoveryConfiguration(null);
|
return getDiscoveryConfiguration(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DiscoveryConfiguration getDiscoveryConfiguration(DSpaceObject dso){
|
public static DiscoveryConfiguration getDiscoveryConfiguration(DSpaceObject dso) {
|
||||||
DiscoveryConfigurationService configurationService = getConfigurationService();
|
DiscoveryConfigurationService configurationService = getConfigurationService();
|
||||||
|
|
||||||
DiscoveryConfiguration result = null;
|
DiscoveryConfiguration result = null;
|
||||||
if(dso == null){
|
if (dso == null) {
|
||||||
result = configurationService.getMap().get("site");
|
result = configurationService.getMap().get("site");
|
||||||
}else{
|
}else{
|
||||||
result = configurationService.getMap().get(dso.getHandle());
|
result = configurationService.getMap().get(dso.getHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(result == null){
|
if (result == null) {
|
||||||
//No specific configuration, get the default one
|
//No specific configuration, get the default one
|
||||||
result = configurationService.getMap().get("default");
|
result = configurationService.getMap().get("default");
|
||||||
}
|
}
|
||||||
@@ -73,8 +73,11 @@ public class SearchUtils {
|
|||||||
/**
|
/**
|
||||||
* Method that retrieves a list of all the configuration objects from the given item
|
* Method that retrieves a list of all the configuration objects from the given item
|
||||||
* A configuration object can be returned for each parent community/collection
|
* A configuration object can be returned for each parent community/collection
|
||||||
|
*
|
||||||
* @param item the DSpace item
|
* @param item the DSpace item
|
||||||
* @return a list of configuration objects
|
* @return a list of configuration objects
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public static List<DiscoveryConfiguration> getAllDiscoveryConfigurations(Item item) throws SQLException {
|
public static List<DiscoveryConfiguration> getAllDiscoveryConfigurations(Item item) throws SQLException {
|
||||||
Map<String, DiscoveryConfiguration> result = new HashMap<String, DiscoveryConfiguration>();
|
Map<String, DiscoveryConfiguration> result = new HashMap<String, DiscoveryConfiguration>();
|
||||||
@@ -82,14 +85,14 @@ public class SearchUtils {
|
|||||||
List<Collection> collections = item.getCollections();
|
List<Collection> collections = item.getCollections();
|
||||||
for (Collection collection : collections) {
|
for (Collection collection : collections) {
|
||||||
DiscoveryConfiguration configuration = getDiscoveryConfiguration(collection);
|
DiscoveryConfiguration configuration = getDiscoveryConfiguration(collection);
|
||||||
if(!result.containsKey(configuration.getId())){
|
if (!result.containsKey(configuration.getId())) {
|
||||||
result.put(configuration.getId(), configuration);
|
result.put(configuration.getId(), configuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Also add one for the default
|
//Also add one for the default
|
||||||
DiscoveryConfiguration configuration = getDiscoveryConfiguration(null);
|
DiscoveryConfiguration configuration = getDiscoveryConfiguration(null);
|
||||||
if(!result.containsKey(configuration.getId())){
|
if (!result.containsKey(configuration.getId())) {
|
||||||
result.put(configuration.getId(), configuration);
|
result.put(configuration.getId(), configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -55,6 +55,8 @@ public class DiscoveryHitHighlightFieldConfiguration
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the maximum number of highlighted snippets to generate per field
|
* Get the maximum number of highlighted snippets to generate per field
|
||||||
|
*
|
||||||
|
* @return maximum number of highlighted snippets to generate per field
|
||||||
*/
|
*/
|
||||||
public int getSnippets()
|
public int getSnippets()
|
||||||
{
|
{
|
||||||
|
@@ -62,10 +62,11 @@ public class EmbargoCLITool {
|
|||||||
* <dt>-q,--quiet</dt>
|
* <dt>-q,--quiet</dt>
|
||||||
* <dd> No output except upon error.</dd>
|
* <dd> No output except upon error.</dd>
|
||||||
* </dl>
|
* </dl>
|
||||||
|
*
|
||||||
|
* @param argv the command line arguments given
|
||||||
*/
|
*/
|
||||||
public static void main(String argv[])
|
public static void main(String argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
@@ -197,7 +198,7 @@ public class EmbargoCLITool {
|
|||||||
if (line.hasOption('a')){
|
if (line.hasOption('a')){
|
||||||
embargoService.setEmbargo(context, item);
|
embargoService.setEmbargo(context, item);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
log.debug("Testing embargo on item="+item.getHandle()+", date="+liftDate.toString());
|
log.debug("Testing embargo on item="+item.getHandle()+", date="+liftDate.toString());
|
||||||
if (liftDate.toDate().before(now))
|
if (liftDate.toDate().before(now))
|
||||||
{
|
{
|
||||||
@@ -229,8 +230,8 @@ public class EmbargoCLITool {
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
log.error("Failed attempting to lift embargo, item="+item.getHandle()+": ", e);
|
log.error("Failed attempting to lift embargo, item=" + item.getHandle() + ": ", e);
|
||||||
System.err.println("Failed attempting to lift embargo, item="+item.getHandle()+": "+ e);
|
System.err.println("Failed attempting to lift embargo, item=" + item.getHandle() + ": " + e);
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,8 +28,17 @@ public interface EmbargoLifter
|
|||||||
* (access control) by (for example) turning on default read access to all
|
* (access control) by (for example) turning on default read access to all
|
||||||
* Bitstreams.
|
* Bitstreams.
|
||||||
*
|
*
|
||||||
* @param context the DSpace context
|
* @param context
|
||||||
* @param item the Item on which to lift the embargo
|
* The relevant DSpace Context.
|
||||||
|
* @param item
|
||||||
|
* the Item on which to lift the embargo
|
||||||
|
* @throws IOException
|
||||||
|
* A general class of exceptions produced by failed or interrupted I/O operations.
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
|
* @throws AuthorizeException
|
||||||
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
*/
|
*/
|
||||||
public void liftEmbargo(Context context, Item item)
|
public void liftEmbargo(Context context, Item item)
|
||||||
throws SQLException, AuthorizeException, IOException;
|
throws SQLException, AuthorizeException, IOException;
|
||||||
|
@@ -171,6 +171,8 @@ public class EmbargoServiceImpl implements EmbargoService
|
|||||||
* Ensures the configurationService is injected, so that we can
|
* Ensures the configurationService is injected, so that we can
|
||||||
* get plugins and MD field settings from config.
|
* get plugins and MD field settings from config.
|
||||||
* Called by "init-method" in Spring config.
|
* Called by "init-method" in Spring config.
|
||||||
|
*
|
||||||
|
* @throws Exception on generic exception
|
||||||
*/
|
*/
|
||||||
public void init() throws Exception
|
public void init() throws Exception
|
||||||
{
|
{
|
||||||
|
@@ -42,6 +42,11 @@ public interface EmbargoSetter
|
|||||||
* @param item the item to embargo
|
* @param item the item to embargo
|
||||||
* @param terms value of the metadata field configured as embargo terms, if any.
|
* @param terms value of the metadata field configured as embargo terms, if any.
|
||||||
* @return absolute date on which the embargo is to be lifted, or null if none
|
* @return absolute date on which the embargo is to be lifted, or null if none
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
|
* @throws AuthorizeException
|
||||||
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
*/
|
*/
|
||||||
public DCDate parseTerms(Context context, Item item, String terms)
|
public DCDate parseTerms(Context context, Item item, String terms)
|
||||||
throws SQLException, AuthorizeException;
|
throws SQLException, AuthorizeException;
|
||||||
@@ -52,6 +57,11 @@ public interface EmbargoSetter
|
|||||||
*
|
*
|
||||||
* @param context the DSpace context
|
* @param context the DSpace context
|
||||||
* @param item the item to embargo
|
* @param item the item to embargo
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
|
* @throws AuthorizeException
|
||||||
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
*/
|
*/
|
||||||
public void setEmbargo(Context context, Item item)
|
public void setEmbargo(Context context, Item item)
|
||||||
throws SQLException, AuthorizeException;
|
throws SQLException, AuthorizeException;
|
||||||
@@ -68,6 +78,13 @@ public interface EmbargoSetter
|
|||||||
*
|
*
|
||||||
* @param context the DSpace context
|
* @param context the DSpace context
|
||||||
* @param item the item to embargo
|
* @param item the item to embargo
|
||||||
|
* @throws IOException
|
||||||
|
* A general class of exceptions produced by failed or interrupted I/O operations.
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
|
* @throws AuthorizeException
|
||||||
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
*/
|
*/
|
||||||
public void checkEmbargo(Context context, Item item)
|
public void checkEmbargo(Context context, Item item)
|
||||||
throws SQLException, AuthorizeException, IOException;
|
throws SQLException, AuthorizeException, IOException;
|
||||||
|
@@ -51,6 +51,11 @@ public interface EmbargoService {
|
|||||||
*
|
*
|
||||||
* @param context the DSpace context
|
* @param context the DSpace context
|
||||||
* @param item the item to embargo
|
* @param item the item to embargo
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
|
* @throws AuthorizeException
|
||||||
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
*/
|
*/
|
||||||
public void setEmbargo(Context context, Item item)
|
public void setEmbargo(Context context, Item item)
|
||||||
throws SQLException, AuthorizeException;
|
throws SQLException, AuthorizeException;
|
||||||
@@ -69,6 +74,11 @@ public interface EmbargoService {
|
|||||||
* @param context the DSpace context
|
* @param context the DSpace context
|
||||||
* @param item the item to embargo
|
* @param item the item to embargo
|
||||||
* @return lift date on which the embargo is to be lifted, or null if none
|
* @return lift date on which the embargo is to be lifted, or null if none
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
|
* @throws AuthorizeException
|
||||||
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
*/
|
*/
|
||||||
public DCDate getEmbargoTermsAsDate(Context context, Item item)
|
public DCDate getEmbargoTermsAsDate(Context context, Item item)
|
||||||
throws SQLException, AuthorizeException;
|
throws SQLException, AuthorizeException;
|
||||||
@@ -80,6 +90,13 @@ public interface EmbargoService {
|
|||||||
*
|
*
|
||||||
* @param context the DSpace context
|
* @param context the DSpace context
|
||||||
* @param item the item on which to lift the embargo
|
* @param item the item on which to lift the embargo
|
||||||
|
* @throws IOException
|
||||||
|
* A general class of exceptions produced by failed or interrupted I/O operations.
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
|
* @throws AuthorizeException
|
||||||
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
*/
|
*/
|
||||||
public void liftEmbargo(Context context, Item item)
|
public void liftEmbargo(Context context, Item item)
|
||||||
throws SQLException, AuthorizeException, IOException;
|
throws SQLException, AuthorizeException, IOException;
|
||||||
|
@@ -107,7 +107,7 @@ public class AccountServiceImpl implements AccountService
|
|||||||
* @param token
|
* @param token
|
||||||
* Account token
|
* Account token
|
||||||
* @return The EPerson corresponding to token, or null.
|
* @return The EPerson corresponding to token, or null.
|
||||||
* @exception SQLException
|
* @throws SQLException
|
||||||
* If the token or eperson cannot be retrieved from the
|
* If the token or eperson cannot be retrieved from the
|
||||||
* database.
|
* database.
|
||||||
*/
|
*/
|
||||||
@@ -161,7 +161,7 @@ public class AccountServiceImpl implements AccountService
|
|||||||
* DSpace context
|
* DSpace context
|
||||||
* @param token
|
* @param token
|
||||||
* The token to delete
|
* The token to delete
|
||||||
* @exception SQLException
|
* @throws SQLException
|
||||||
* If a database error occurs
|
* If a database error occurs
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -171,7 +171,7 @@ public class AccountServiceImpl implements AccountService
|
|||||||
registrationDataService.deleteByToken(context, token);
|
registrationDataService.deleteByToken(context, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* THIS IS AN INTERNAL METHOD. THE SEND PARAMETER ALLOWS IT TO BE USED FOR
|
* THIS IS AN INTERNAL METHOD. THE SEND PARAMETER ALLOWS IT TO BE USED FOR
|
||||||
* TESTING PURPOSES.
|
* TESTING PURPOSES.
|
||||||
*
|
*
|
||||||
@@ -179,15 +179,18 @@ public class AccountServiceImpl implements AccountService
|
|||||||
* is TRUE, this is registration email; otherwise, it is forgot-password
|
* is TRUE, this is registration email; otherwise, it is forgot-password
|
||||||
* email. If send is TRUE, the email is sent; otherwise it is skipped.
|
* email. If send is TRUE, the email is sent; otherwise it is skipped.
|
||||||
*
|
*
|
||||||
* Potential error conditions: No EPerson with that email (returns null)
|
* Potential error conditions:
|
||||||
* Cannot create registration data in database (throws SQLException) Error
|
* @return null if no EPerson with that email found
|
||||||
* sending email (throws MessagingException) Error reading email template
|
* @throws SQLException Cannot create registration data in database
|
||||||
* (throws IOException) Authorization error (throws AuthorizeException)
|
* @throws MessagingException Error sending email
|
||||||
|
* @throws IOException Error reading email template
|
||||||
|
* @throws AuthorizeException Authorization error
|
||||||
*
|
*
|
||||||
* @param context DSpace context @param email Email address to send the
|
* @param context DSpace context
|
||||||
* forgot-password email to @param isRegister If true, this is for
|
* @param email Email address to send the forgot-password email to
|
||||||
* registration; otherwise, it is for forgot-password @param send If true,
|
* @param isRegister If true, this is for registration; otherwise, it is
|
||||||
* send email; otherwise do not send any email
|
* for forgot-password
|
||||||
|
* @param send If true, send email; otherwise do not send any email
|
||||||
*/
|
*/
|
||||||
protected RegistrationData sendInfo(Context context, String email,
|
protected RegistrationData sendInfo(Context context, String email,
|
||||||
boolean isRegister, boolean send) throws SQLException, IOException,
|
boolean isRegister, boolean send) throws SQLException, IOException,
|
||||||
@@ -234,17 +237,21 @@ public class AccountServiceImpl implements AccountService
|
|||||||
* If isRegister is <code>true</code>, this is registration email;
|
* If isRegister is <code>true</code>, this is registration email;
|
||||||
* otherwise, it is a forgot-password email.
|
* otherwise, it is a forgot-password email.
|
||||||
*
|
*
|
||||||
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param email
|
* @param email
|
||||||
* The email address to mail to
|
* The email address to mail to
|
||||||
* @param isRegister
|
* @param isRegister
|
||||||
* If true, this is registration email; otherwise it is
|
* If true, this is registration email; otherwise it is
|
||||||
* forgot-password email.
|
* forgot-password email.
|
||||||
* @param rd
|
* @param rd
|
||||||
* The RDBMS row representing the registration data.
|
* The RDBMS row representing the registration data.
|
||||||
* @exception MessagingException
|
* @throws MessagingException
|
||||||
* If an error occurs while sending email
|
* If an error occurs while sending email
|
||||||
* @exception IOException
|
* @throws IOException
|
||||||
* If an error occurs while reading the email template.
|
* A general class of exceptions produced by failed or interrupted I/O operations.
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
protected void sendEmail(Context context, String email, boolean isRegister, RegistrationData rd)
|
protected void sendEmail(Context context, String email, boolean isRegister, RegistrationData rd)
|
||||||
throws MessagingException, IOException, SQLException
|
throws MessagingException, IOException, SQLException
|
||||||
@@ -271,4 +278,4 @@ public class AccountServiceImpl implements AccountService
|
|||||||
+ " information to " + email);
|
+ " information to " + email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -104,8 +104,8 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
/**
|
/**
|
||||||
* Return true if this object equals obj, false otherwise.
|
* Return true if this object equals obj, false otherwise.
|
||||||
*
|
*
|
||||||
* @param obj
|
* @param obj another EPerson.
|
||||||
* @return true if ResourcePolicy objects are equal
|
* @return true if EPerson objects are equal in ID, email, and full name
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
@@ -165,8 +165,12 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
* Locale specification of the form {language} or {language}_{territory},
|
* Locale specification of the form {language} or {language}_{territory},
|
||||||
* e.g. "en", "en_US", "pt_BR" (the latter is Brazilian Portugese).
|
* e.g. "en", "en_US", "pt_BR" (the latter is Brazilian Portugese).
|
||||||
*
|
*
|
||||||
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param language
|
* @param language
|
||||||
* language code
|
* language code
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public void setLanguage(Context context, String language) throws SQLException {
|
public void setLanguage(Context context, String language) throws SQLException {
|
||||||
getePersonService().setMetadataSingleValue(context, this, "eperson", "language", null, null, language);
|
getePersonService().setMetadataSingleValue(context, this, "eperson", "language", null, null, language);
|
||||||
@@ -186,7 +190,7 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
* Set the EPerson's email
|
* Set the EPerson's email
|
||||||
*
|
*
|
||||||
* @param s
|
* @param s
|
||||||
* the new email
|
* the new email
|
||||||
*/
|
*/
|
||||||
public void setEmail(String s)
|
public void setEmail(String s)
|
||||||
{
|
{
|
||||||
@@ -208,7 +212,7 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
* Set the EPerson's netid
|
* Set the EPerson's netid
|
||||||
*
|
*
|
||||||
* @param netid
|
* @param netid
|
||||||
* the new netid
|
* the new netid
|
||||||
*/
|
*/
|
||||||
public void setNetid(String netid) {
|
public void setNetid(String netid) {
|
||||||
this.netid = netid;
|
this.netid = netid;
|
||||||
@@ -253,8 +257,12 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
/**
|
/**
|
||||||
* Set the eperson's first name
|
* Set the eperson's first name
|
||||||
*
|
*
|
||||||
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param firstname
|
* @param firstname
|
||||||
* the person's first name
|
* the person's first name
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public void setFirstName(Context context, String firstname) throws SQLException {
|
public void setFirstName(Context context, String firstname) throws SQLException {
|
||||||
getePersonService().setMetadataSingleValue(context, this, "eperson", "firstname", null, null, firstname);
|
getePersonService().setMetadataSingleValue(context, this, "eperson", "firstname", null, null, firstname);
|
||||||
@@ -274,8 +282,12 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
/**
|
/**
|
||||||
* Set the eperson's last name
|
* Set the eperson's last name
|
||||||
*
|
*
|
||||||
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param lastname
|
* @param lastname
|
||||||
* the person's last name
|
* the person's last name
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
*/
|
*/
|
||||||
public void setLastName(Context context, String lastname) throws SQLException {
|
public void setLastName(Context context, String lastname) throws SQLException {
|
||||||
getePersonService().setMetadataSingleValue(context, this, "eperson", "lastname", null, null, lastname);
|
getePersonService().setMetadataSingleValue(context, this, "eperson", "lastname", null, null, lastname);
|
||||||
@@ -286,7 +298,7 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
* Indicate whether the user can log in
|
* Indicate whether the user can log in
|
||||||
*
|
*
|
||||||
* @param login
|
* @param login
|
||||||
* boolean yes/no
|
* boolean yes/no
|
||||||
*/
|
*/
|
||||||
public void setCanLogIn(boolean login)
|
public void setCanLogIn(boolean login)
|
||||||
{
|
{
|
||||||
@@ -308,7 +320,7 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
* Set require cert yes/no
|
* Set require cert yes/no
|
||||||
*
|
*
|
||||||
* @param isrequired
|
* @param isrequired
|
||||||
* boolean yes/no
|
* boolean yes/no
|
||||||
*/
|
*/
|
||||||
public void setRequireCertificate(boolean isrequired)
|
public void setRequireCertificate(boolean isrequired)
|
||||||
{
|
{
|
||||||
@@ -330,7 +342,7 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
* Indicate whether the user self-registered
|
* Indicate whether the user self-registered
|
||||||
*
|
*
|
||||||
* @param sr
|
* @param sr
|
||||||
* boolean yes/no
|
* boolean yes/no
|
||||||
*/
|
*/
|
||||||
public void setSelfRegistered(boolean sr)
|
public void setSelfRegistered(boolean sr)
|
||||||
{
|
{
|
||||||
@@ -369,7 +381,7 @@ public class EPerson extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return type found in Constants
|
* @return type found in Constants, see {@link org.dspace.core.Constants#Constants Constants}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getType()
|
public int getType()
|
||||||
|
@@ -45,6 +45,15 @@ public class EPersonCLITool {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tool for manipulating user accounts.
|
* Tool for manipulating user accounts.
|
||||||
|
*
|
||||||
|
* @param argv the command line arguments given
|
||||||
|
* @throws ParseException
|
||||||
|
* Base for Exceptions thrown during parsing of a command-line.
|
||||||
|
* @throws SQLException
|
||||||
|
* An exception that provides information on a database access error or other errors.
|
||||||
|
* @throws AuthorizeException
|
||||||
|
* Exception indicating the current user of the context does not have permission
|
||||||
|
* to perform a particular action.
|
||||||
*/
|
*/
|
||||||
public static void main(String argv[])
|
public static void main(String argv[])
|
||||||
throws ParseException, SQLException, AuthorizeException {
|
throws ParseException, SQLException, AuthorizeException {
|
||||||
|
@@ -50,7 +50,9 @@ public class EPersonConsumer implements Consumer
|
|||||||
* Consume the event
|
* Consume the event
|
||||||
*
|
*
|
||||||
* @param context
|
* @param context
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @param event
|
* @param event
|
||||||
|
* Which Event to consume
|
||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -116,6 +118,7 @@ public class EPersonConsumer implements Consumer
|
|||||||
* Handle the end of the event
|
* Handle the end of the event
|
||||||
*
|
*
|
||||||
* @param ctx
|
* @param ctx
|
||||||
|
* The relevant DSpace Context.
|
||||||
* @throws Exception if error
|
* @throws Exception if error
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@@ -129,6 +132,7 @@ public class EPersonConsumer implements Consumer
|
|||||||
* Finish the event
|
* Finish the event
|
||||||
*
|
*
|
||||||
* @param ctx
|
* @param ctx
|
||||||
|
* The relevant DSpace Context.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void finish(Context ctx)
|
public void finish(Context ctx)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user