mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Merge remote-tracking branch 'community/main' into w2p-71502_deleting-items-with-min-relationship
This commit is contained in:
14
.codecov.yml
14
.codecov.yml
@@ -4,6 +4,13 @@
|
||||
# Can be validated via instructions at:
|
||||
# https://docs.codecov.io/docs/codecov-yaml#validate-your-repository-yaml
|
||||
|
||||
# Tell Codecov not to send a coverage notification until (at least) 2 builds are completed
|
||||
# Since we run Unit & Integration tests in parallel, this lets Codecov know that coverage
|
||||
# needs to be merged across those builds
|
||||
codecov:
|
||||
notify:
|
||||
after_n_builds: 2
|
||||
|
||||
# Settings related to code coverage analysis
|
||||
coverage:
|
||||
status:
|
||||
@@ -17,10 +24,9 @@ coverage:
|
||||
# Configuration for patch-level checks. This checks the relative coverage of the new PR code ONLY.
|
||||
patch:
|
||||
default:
|
||||
# For each PR, make sure the coverage of the new code is within 1% of current overall coverage.
|
||||
# We let 'patch' be more lenient as we only require *project* coverage to not drop significantly.
|
||||
target: auto
|
||||
threshold: 1%
|
||||
# Enable informational mode, which just provides info to reviewers & always passes
|
||||
# https://docs.codecov.io/docs/commit-status#section-informational
|
||||
informational: true
|
||||
|
||||
# Turn PR comments "off". This feature adds the code coverage summary as a
|
||||
# comment on each PR. See https://docs.codecov.io/docs/pull-request-comments
|
||||
|
4
.github/pull_request_template.md
vendored
4
.github/pull_request_template.md
vendored
@@ -1,7 +1,7 @@
|
||||
## References
|
||||
_Add references/links to any related issues or PRs. These may include:_
|
||||
* Related to [REST Contract](https://github.com/DSpace/Rest7Contract) or an open REST Contract PR, if any
|
||||
* Fixes [GitHub issue](https://github.com/DSpace/DSpace/issues), if any
|
||||
* Fixes #[issue-number]
|
||||
* Related to [REST Contract](https://github.com/DSpace/Rest7Contract)
|
||||
|
||||
## Description
|
||||
Short summary of changes (1-2 sentences).
|
||||
|
65
.github/workflows/build.yml
vendored
Normal file
65
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
# DSpace Continuous Integration/Build via GitHub Actions
|
||||
# Concepts borrowed from
|
||||
# https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-java-with-maven
|
||||
name: Build
|
||||
|
||||
# Run this Build for all pushes / PRs to current branch
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
# Give Maven 1GB of memory to work with
|
||||
# Suppress all Maven "downloading" messages in Travis logs (see https://stackoverflow.com/a/35653426)
|
||||
# This also slightly speeds builds, as there is less logging
|
||||
MAVEN_OPTS: "-Xmx1024M -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
|
||||
strategy:
|
||||
# Create a matrix of two separate configurations for Unit vs Integration Tests
|
||||
# This will ensure those tasks are run in parallel
|
||||
matrix:
|
||||
include:
|
||||
# NOTE: Unit Tests include deprecated REST API v6 (as it has unit tests)
|
||||
- type: "Unit Tests"
|
||||
mvnflags: "-DskipUnitTests=false -Pdspace-rest"
|
||||
# NOTE: ITs skip all code validation checks, as they are already done by Unit Test job.
|
||||
# - enforcer.skip => Skip maven-enforcer-plugin rules
|
||||
# - checkstyle.skip => Skip all checkstyle checks by maven-checkstyle-plugin
|
||||
# - license.skip => Skip all license header checks by license-maven-plugin
|
||||
# - xml.skip => Skip all XML/XSLT validation by xml-maven-plugin
|
||||
- type: "Integration Tests"
|
||||
mvnflags: "-DskipIntegrationTests=false -Denforcer.skip=true -Dcheckstyle.skip=true -Dlicense.skip=true -Dxml.skip=true"
|
||||
# Do NOT exit immediately if one matrix job fails
|
||||
# This ensures ITs continue running even if Unit Tests fail, or visa versa
|
||||
fail-fast: false
|
||||
# These are the actual CI steps to perform per job
|
||||
steps:
|
||||
# https://github.com/actions/checkout
|
||||
- name: Checkout codebase
|
||||
uses: actions/checkout@v1
|
||||
|
||||
# https://github.com/actions/setup-java
|
||||
- name: Install JDK 11
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
|
||||
# https://github.com/actions/cache
|
||||
- name: Cache Maven dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
# Cache entire ~/.m2/repository
|
||||
path: ~/.m2/repository
|
||||
# Cache key is hash of all pom.xml files. Therefore any changes to POMs will invalidate cache
|
||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: ${{ runner.os }}-maven-
|
||||
|
||||
# Run parallel Maven builds based on the above 'strategy.matrix'
|
||||
- name: Run Maven ${{ matrix.type }}
|
||||
env:
|
||||
TEST_FLAGS: ${{ matrix.mvnflags }}
|
||||
run: mvn install -B -V -P-assembly -Pcoverage-report $TEST_FLAGS
|
||||
|
||||
# https://github.com/codecov/codecov-action
|
||||
- name: Upload coverage to Codecov.io
|
||||
uses: codecov/codecov-action@v1
|
55
.travis.yml
55
.travis.yml
@@ -1,55 +0,0 @@
|
||||
# DSpace's Travis CI Configuration
|
||||
# Builds: https://travis-ci.com/github/DSpace/DSpace
|
||||
# Travis configuration guide/validation: https://config.travis-ci.com/explore
|
||||
language: java
|
||||
# TODO: Upgrade to Bionic
|
||||
dist: trusty
|
||||
os: linux
|
||||
|
||||
jdk:
|
||||
# DS-3384 Oracle JDK has DocLint enabled by default.
|
||||
# Let's use this to catch any newly introduced DocLint issues.
|
||||
- oraclejdk11
|
||||
|
||||
# Define global environment variables (shared across all jobs)
|
||||
env:
|
||||
global:
|
||||
# Suppress all Maven "downloading" messages in Travis logs (see https://stackoverflow.com/a/35653426)
|
||||
# This also slightly speeds builds in Travis, as there is less logging
|
||||
- HIDE_MAVEN_DOWNLOADS="-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
|
||||
# Give Maven 1GB of memory to work with
|
||||
- MAVEN_OPTS="-Xmx1024M $HIDE_MAVEN_DOWNLOADS"
|
||||
# Maven options which will skip ALL code validation checks. Includes skipping:
|
||||
# - enforcer.skip => Skip maven-enforcer-plugin rules
|
||||
# - checkstyle.skip => Skip all checkstyle checks by maven-checkstyle-plugin
|
||||
# - license.skip => Skip all license header checks by license-maven-plugin
|
||||
# - xml.skip => Skip all XML/XSLT validation by xml-maven-plugin
|
||||
# (Useful for builds which don't need to repeat code checks)
|
||||
- SKIP_CODE_CHECKS="-Denforcer.skip=true -Dcheckstyle.skip=true -Dlicense.skip=true -Dxml.skip=true"
|
||||
|
||||
# Create two jobs to run Unit & Integration tests in parallel.
|
||||
# These jobs only differ in the TEST_FLAGS defined below,
|
||||
# and otherwise share all the other configs in this file
|
||||
jobs:
|
||||
include:
|
||||
- name: "Run Unit Tests & Check Code"
|
||||
# NOTE: unit tests include deprecated REST API v6 (as it has unit tests)
|
||||
env: TEST_FLAGS="-DskipUnitTests=false -Pdspace-rest"
|
||||
- name: "Run Integration Tests"
|
||||
# NOTE: skips code checks, as they are already done by Unit Test job
|
||||
env: TEST_FLAGS="-DskipIntegrationTests=false $SKIP_CODE_CHECKS"
|
||||
|
||||
# Skip 'install' process to save time. We build/install/test all at once in "script" below.
|
||||
install: skip
|
||||
|
||||
# Build DSpace and run configured tests (see 'jobs' above)
|
||||
# Notes on flags used:
|
||||
# -B => Maven batch/non-interactive mode (recommended for CI)
|
||||
# -V => Display Maven version info before build
|
||||
# -P-assembly => Disable build of dspace-installer in [src]/dspace/, as it can be memory intensive
|
||||
# -Pcoverage-report => Enable aggregate code coverage report (across all modules) via JaCoCo
|
||||
script: mvn install -B -V -P-assembly -Pcoverage-report $TEST_FLAGS
|
||||
|
||||
# After a successful build and test (see 'script'), send aggregate code coverage reports
|
||||
# (generated by -Pcoverage-report above) to CodeCov.io
|
||||
after_success: bash <(curl -s https://codecov.io/bash)
|
@@ -51,7 +51,12 @@ RUN ant init_installation update_configs update_code update_webapps
|
||||
# Create a new tomcat image that does not retain the the build directory contents
|
||||
FROM tomcat:8-jdk11
|
||||
ENV DSPACE_INSTALL=/dspace
|
||||
ENV TOMCAT_INSTALL=/usr/local/tomcat
|
||||
COPY --from=ant_build /dspace $DSPACE_INSTALL
|
||||
# Enable the AJP connector in Tomcat's server.xml
|
||||
# NOTE: secretRequired="false" should only be used when AJP is NOT accessible from an external network. But, secretRequired="true" isn't supported by mod_proxy_ajp until Apache 2.5
|
||||
RUN sed -i '/Service name="Catalina".*/a \\n <Connector protocol="AJP/1.3" port="8009" address="0.0.0.0" redirectPort="8443" URIEncoding="UTF-8" secretRequired="false" />' $TOMCAT_INSTALL/conf/server.xml
|
||||
# Expose Tomcat port and AJP port
|
||||
EXPOSE 8080 8009
|
||||
|
||||
ENV JAVA_OPTS=-Xmx2000m
|
||||
|
@@ -1,7 +1,7 @@
|
||||
|
||||
# DSpace
|
||||
|
||||
[](https://travis-ci.com/DSpace/DSpace)
|
||||
[](https://github.com/DSpace/DSpace/actions?query=workflow%3ABuild)
|
||||
|
||||
[DSpace Documentation](https://wiki.lyrasis.org/display/DSDOC/) |
|
||||
[DSpace Releases](https://github.com/DSpace/DSpace/releases) |
|
||||
@@ -86,7 +86,7 @@ DSpace uses GitHub to track issues:
|
||||
### Running Tests
|
||||
|
||||
By default, in DSpace, Unit Tests and Integration Tests are disabled. However, they are
|
||||
run automatically by [Travis CI](https://travis-ci.com/DSpace/DSpace/) for all Pull Requests and code commits.
|
||||
run automatically by [GitHub Actions](https://github.com/DSpace/DSpace/actions?query=workflow%3ABuild) for all Pull Requests and code commits.
|
||||
|
||||
* How to run both Unit Tests (via `maven-surefire-plugin`) and Integration Tests (via `maven-failsafe-plugin`):
|
||||
```
|
||||
|
@@ -15,6 +15,8 @@ services:
|
||||
ports:
|
||||
- published: 8080
|
||||
target: 8080
|
||||
- published: 8009
|
||||
target: 8009
|
||||
stdin_open: true
|
||||
tty: true
|
||||
volumes:
|
||||
|
@@ -315,6 +315,13 @@
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-ehcache</artifactId>
|
||||
<exclusions>
|
||||
<!-- Newer version pulled in via Jersey below -->
|
||||
<exclusion>
|
||||
<groupId>org.javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
@@ -325,16 +332,16 @@
|
||||
<artifactId>hibernate-validator-cdi</artifactId>
|
||||
<version>${hibernate-validator.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.javax.persistence</groupId>
|
||||
<artifactId>hibernate-jpa-2.1-api</artifactId>
|
||||
<version>1.0.0.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-orm</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>javax.el</artifactId>
|
||||
<version>3.0.1-b10</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.handle</groupId>
|
||||
@@ -356,10 +363,6 @@
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>jargon</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>mets</artifactId>
|
||||
@@ -369,14 +372,6 @@
|
||||
<artifactId>apache-jena-libs</artifactId>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<!-- Required to support PubMed API call in "PubmedImportMetadataSourceServiceImpl.GetRecord" -->
|
||||
<!-- Makes runtime operations in Jersey Dependency Injection -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.inject</groupId>
|
||||
<artifactId>jersey-hk2</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
@@ -437,10 +432,6 @@
|
||||
<groupId>org.jdom</groupId>
|
||||
<artifactId>jdom</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>oro</groupId>
|
||||
<artifactId>oro</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox</artifactId>
|
||||
@@ -453,14 +444,6 @@
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>rome</groupId>
|
||||
<artifactId>rome</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>rome</groupId>
|
||||
<artifactId>opensearch</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xalan</groupId>
|
||||
<artifactId>xalan</artifactId>
|
||||
@@ -469,14 +452,6 @@
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xml-apis</groupId>
|
||||
<artifactId>xml-apis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ibm.icu</groupId>
|
||||
<artifactId>icu4j</artifactId>
|
||||
@@ -496,7 +471,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<artifactId>hamcrest-all</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -514,6 +489,7 @@
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- Used for RSS / ATOM syndication feeds -->
|
||||
<dependency>
|
||||
<groupId>org.rometools</groupId>
|
||||
<artifactId>rome-modules</artifactId>
|
||||
@@ -729,7 +705,6 @@
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
@@ -820,6 +795,11 @@
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
<!-- Exclude Woodstox, as later version provided by Solr dependencies -->
|
||||
<exclusion>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -833,14 +813,28 @@
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
<!-- Exclude Woodstox, as later version provided by Solr dependencies -->
|
||||
<exclusion>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
<artifactId>woodstox-core-asl</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Jersey / JAX-RS client (javax.ws.rs.*) dependencies needed to integrate with external sources/services -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
<!-- Required because Jersey no longer includes a dependency injection provider by default.
|
||||
Needed to support PubMed API call in "PubmedImportMetadataSourceServiceImpl.GetRecord" -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.inject</groupId>
|
||||
<artifactId>jersey-hk2</artifactId>
|
||||
<version>${jersey.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- S3 -->
|
||||
<dependency>
|
||||
<groupId>com.amazonaws</groupId>
|
||||
@@ -848,12 +842,30 @@
|
||||
<version>1.10.50</version>
|
||||
</dependency>
|
||||
|
||||
<!-- For ORCID v2 integration -->
|
||||
<dependency>
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>orcid-jaxb-api</artifactId>
|
||||
<version>2.1.0</version>
|
||||
<groupId>org.orcid</groupId>
|
||||
<artifactId>orcid-model</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
@@ -864,7 +876,7 @@
|
||||
<dependency>
|
||||
<groupId>com.opencsv</groupId>
|
||||
<artifactId>opencsv</artifactId>
|
||||
<version>4.5</version>
|
||||
<version>5.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Email templating -->
|
||||
@@ -882,13 +894,7 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hibernate.javax.persistence</groupId>
|
||||
<artifactId>hibernate-jpa-2.1-api</artifactId>
|
||||
<version>1.0.0.Final</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.bcel</groupId>
|
||||
<artifactId>bcel</artifactId>
|
||||
<version>6.4.0</version>
|
||||
|
@@ -14,9 +14,9 @@ import java.util.UUID;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Community;
|
||||
@@ -51,7 +51,7 @@ public class CommunityFiliator {
|
||||
*/
|
||||
public static void main(String[] argv) throws Exception {
|
||||
// create an options object and populate it
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
|
||||
Options options = new Options();
|
||||
|
||||
|
@@ -13,10 +13,9 @@ import java.util.Locale;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.I18nUtil;
|
||||
import org.dspace.eperson.EPerson;
|
||||
@@ -24,6 +23,8 @@ import org.dspace.eperson.Group;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.eperson.service.GroupService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* A command-line tool for creating an initial administrator for setting up a
|
||||
@@ -61,7 +62,7 @@ public final class CreateAdministrator {
|
||||
*/
|
||||
public static void main(String[] argv)
|
||||
throws Exception {
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
Options options = new Options();
|
||||
|
||||
CreateAdministrator ca = new CreateAdministrator();
|
||||
@@ -147,9 +148,10 @@ public final class CreateAdministrator {
|
||||
lastName = lastName.trim();
|
||||
}
|
||||
|
||||
if (ConfigurationManager.getProperty("webui.supported.locales") != null) {
|
||||
System.out.println("Select one of the following languages: " + ConfigurationManager
|
||||
.getProperty("webui.supported.locales"));
|
||||
ConfigurationService cfg = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
if (cfg.hasProperty("webui.supported.locales")) {
|
||||
System.out.println("Select one of the following languages: "
|
||||
+ cfg.getProperty("webui.supported.locales"));
|
||||
System.out.print("Language: ");
|
||||
System.out.flush();
|
||||
|
||||
|
@@ -10,6 +10,7 @@ package org.dspace.administer;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -17,25 +18,28 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.xml.serialize.Method;
|
||||
import org.apache.xml.serialize.OutputFormat;
|
||||
import org.apache.xml.serialize.XMLSerializer;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
import org.dspace.content.service.MetadataSchemaService;
|
||||
import org.dspace.core.Context;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.w3c.dom.DOMConfiguration;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.bootstrap.DOMImplementationRegistry;
|
||||
import org.w3c.dom.ls.DOMImplementationLS;
|
||||
import org.w3c.dom.ls.LSOutput;
|
||||
import org.w3c.dom.ls.LSSerializer;
|
||||
|
||||
|
||||
/**
|
||||
* @author Graham Triggs
|
||||
*
|
||||
* This class creates an xml document as passed in the arguments and
|
||||
* This class creates an XML document as passed in the arguments and
|
||||
* from the metadata schemas for the repository.
|
||||
*
|
||||
* The form of the XML is as follows
|
||||
@@ -61,17 +65,20 @@ public class MetadataExporter {
|
||||
private MetadataExporter() { }
|
||||
|
||||
/**
|
||||
* @param args commandline arguments
|
||||
* @param args command line arguments
|
||||
* @throws ParseException if parser error
|
||||
* @throws SAXException if XML parse error
|
||||
* @throws IOException if IO error
|
||||
* @throws SQLException if database error
|
||||
* @throws RegistryExportException if export error
|
||||
* @throws ClassNotFoundException if no suitable DOM implementation
|
||||
* @throws InstantiationException if no suitable DOM implementation
|
||||
* @throws IllegalAccessException if no suitable DOM implementation
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
throws ParseException, SQLException, IOException, SAXException, RegistryExportException {
|
||||
throws ParseException, SQLException, IOException, RegistryExportException,
|
||||
ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||
// create an options object and populate it
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
Options options = new Options();
|
||||
options.addOption("f", "file", true, "output xml file for registry");
|
||||
options.addOption("s", "schema", true, "the name of the schema to export");
|
||||
@@ -95,32 +102,31 @@ public class MetadataExporter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a registry to a filepath
|
||||
* Save a registry to a file path
|
||||
*
|
||||
* @param file filepath
|
||||
* @param file file path
|
||||
* @param schema schema definition to save
|
||||
* @throws SQLException if database error
|
||||
* @throws IOException if IO error
|
||||
* @throws SAXException if XML error
|
||||
* @throws RegistryExportException if export error
|
||||
* @throws ClassNotFoundException if no suitable DOM implementation
|
||||
* @throws InstantiationException if no suitable DOM implementation
|
||||
* @throws IllegalAccessException if no suitable DOM implementation
|
||||
*/
|
||||
public static void saveRegistry(String file, String schema)
|
||||
throws SQLException, IOException, SAXException, RegistryExportException {
|
||||
throws SQLException, IOException, RegistryExportException,
|
||||
ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||
// create a context
|
||||
Context context = new Context();
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
OutputFormat xmlFormat = new OutputFormat(Method.XML, "UTF-8", true);
|
||||
xmlFormat.setLineWidth(120);
|
||||
xmlFormat.setIndent(4);
|
||||
|
||||
XMLSerializer xmlSerializer = new XMLSerializer(new BufferedWriter(new FileWriter(file)), xmlFormat);
|
||||
// XMLSerializer xmlSerializer = new XMLSerializer(System.out, xmlFormat);
|
||||
xmlSerializer.startDocument();
|
||||
xmlSerializer.startElement("dspace-dc-types", null);
|
||||
// Initialize an XML document.
|
||||
Document document = DOMImplementationRegistry.newInstance()
|
||||
.getDOMImplementation("XML 3.0")
|
||||
.createDocument(null, "dspace-dc-types", null);
|
||||
|
||||
// Save the schema definition(s)
|
||||
saveSchema(context, xmlSerializer, schema);
|
||||
saveSchema(context, document, schema);
|
||||
|
||||
List<MetadataField> mdFields = null;
|
||||
|
||||
@@ -139,55 +145,64 @@ public class MetadataExporter {
|
||||
mdFields = metadataFieldService.findAll(context);
|
||||
}
|
||||
|
||||
// Output the metadata fields
|
||||
// Compose the metadata fields
|
||||
for (MetadataField mdField : mdFields) {
|
||||
saveType(context, xmlSerializer, mdField);
|
||||
saveType(context, document, mdField);
|
||||
}
|
||||
|
||||
xmlSerializer.endElement("dspace-dc-types");
|
||||
xmlSerializer.endDocument();
|
||||
// Serialize the completed document to the output file.
|
||||
try (Writer writer = new BufferedWriter(new FileWriter(file))) {
|
||||
DOMImplementationLS lsImplementation
|
||||
= (DOMImplementationLS) DOMImplementationRegistry.newInstance()
|
||||
.getDOMImplementation("LS");
|
||||
LSSerializer serializer = lsImplementation.createLSSerializer();
|
||||
DOMConfiguration configuration = serializer.getDomConfig();
|
||||
configuration.setParameter("format-pretty-print", true);
|
||||
LSOutput lsOutput = lsImplementation.createLSOutput();
|
||||
lsOutput.setEncoding("UTF-8");
|
||||
lsOutput.setCharacterStream(writer);
|
||||
serializer.write(document, lsOutput);
|
||||
}
|
||||
|
||||
// abort the context, as we shouldn't have changed it!!
|
||||
context.abort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the schema registry. If the parameter 'schema' is null or empty, save all schemas
|
||||
* Compose the schema registry. If the parameter 'schema' is null or empty, save all schemas.
|
||||
*
|
||||
* @param context DSpace Context
|
||||
* @param xmlSerializer XML serializer
|
||||
* @param document the document being built
|
||||
* @param schema schema (may be null to save all)
|
||||
* @throws SQLException if database error
|
||||
* @throws SAXException if XML error
|
||||
* @throws RegistryExportException if export error
|
||||
*/
|
||||
public static void saveSchema(Context context, XMLSerializer xmlSerializer, String schema)
|
||||
throws SQLException, SAXException, RegistryExportException {
|
||||
public static void saveSchema(Context context, Document document, String schema)
|
||||
throws SQLException, RegistryExportException {
|
||||
if (schema != null && !"".equals(schema)) {
|
||||
// Find a single named schema
|
||||
MetadataSchema mdSchema = metadataSchemaService.find(context, schema);
|
||||
|
||||
saveSchema(xmlSerializer, mdSchema);
|
||||
saveSchema(document, mdSchema);
|
||||
} else {
|
||||
// Find all schemas
|
||||
List<MetadataSchema> mdSchemas = metadataSchemaService.findAll(context);
|
||||
|
||||
for (MetadataSchema mdSchema : mdSchemas) {
|
||||
saveSchema(xmlSerializer, mdSchema);
|
||||
saveSchema(document, mdSchema);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a single schema (namespace) registry entry
|
||||
* Compose a single schema (namespace) registry entry
|
||||
*
|
||||
* @param xmlSerializer XML serializer
|
||||
* @param mdSchema DSpace metadata schema
|
||||
* @throws SAXException if XML error
|
||||
* @param document the output document being built.
|
||||
* @param mdSchema DSpace metadata schema
|
||||
* @throws RegistryExportException if export error
|
||||
*/
|
||||
private static void saveSchema(XMLSerializer xmlSerializer, MetadataSchema mdSchema)
|
||||
throws SAXException, RegistryExportException {
|
||||
private static void saveSchema(Document document, MetadataSchema mdSchema)
|
||||
throws RegistryExportException {
|
||||
// If we haven't got a schema, it's an error
|
||||
if (mdSchema == null) {
|
||||
throw new RegistryExportException("no schema to export");
|
||||
@@ -206,35 +221,34 @@ public class MetadataExporter {
|
||||
return;
|
||||
}
|
||||
|
||||
// Output the parent tag
|
||||
xmlSerializer.startElement("dc-schema", null);
|
||||
Element document_element = document.getDocumentElement();
|
||||
|
||||
// Output the schema name
|
||||
xmlSerializer.startElement("name", null);
|
||||
xmlSerializer.characters(name.toCharArray(), 0, name.length());
|
||||
xmlSerializer.endElement("name");
|
||||
// Compose the parent tag
|
||||
Element schema_element = document.createElement("dc-schema");
|
||||
document_element.appendChild(schema_element);
|
||||
|
||||
// Output the schema namespace
|
||||
xmlSerializer.startElement("namespace", null);
|
||||
xmlSerializer.characters(namespace.toCharArray(), 0, namespace.length());
|
||||
xmlSerializer.endElement("namespace");
|
||||
// Compose the schema name
|
||||
Element name_element = document.createElement("name");
|
||||
schema_element.appendChild(name_element);
|
||||
name_element.setTextContent(name);
|
||||
|
||||
xmlSerializer.endElement("dc-schema");
|
||||
// Compose the schema namespace
|
||||
Element namespace_element = document.createElement("namespace");
|
||||
schema_element.appendChild(namespace_element);
|
||||
namespace_element.setTextContent(namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a single metadata field registry entry to xml
|
||||
* Compose a single metadata field registry entry to XML.
|
||||
*
|
||||
* @param context DSpace context
|
||||
* @param xmlSerializer xml serializer
|
||||
* @param document the output document being built.
|
||||
* @param mdField DSpace metadata field
|
||||
* @throws SAXException if XML error
|
||||
* @throws RegistryExportException if export error
|
||||
* @throws SQLException if database error
|
||||
* @throws IOException if IO error
|
||||
*/
|
||||
private static void saveType(Context context, XMLSerializer xmlSerializer, MetadataField mdField)
|
||||
throws SAXException, RegistryExportException, SQLException, IOException {
|
||||
private static void saveType(Context context, Document document, MetadataField mdField)
|
||||
throws RegistryExportException, SQLException {
|
||||
// If we haven't been given a field, it's an error
|
||||
if (mdField == null) {
|
||||
throw new RegistryExportException("no field to export");
|
||||
@@ -251,38 +265,39 @@ public class MetadataExporter {
|
||||
throw new RegistryExportException("incomplete field information");
|
||||
}
|
||||
|
||||
// Output the parent tag
|
||||
xmlSerializer.startElement("dc-type", null);
|
||||
Element document_element = document.getDocumentElement();
|
||||
|
||||
// Output the schema name
|
||||
xmlSerializer.startElement("schema", null);
|
||||
xmlSerializer.characters(schemaName.toCharArray(), 0, schemaName.length());
|
||||
xmlSerializer.endElement("schema");
|
||||
// Compose the parent tag
|
||||
Element dc_type = document.createElement("dc-type");
|
||||
document_element.appendChild(dc_type);
|
||||
|
||||
// Output the element
|
||||
xmlSerializer.startElement("element", null);
|
||||
xmlSerializer.characters(element.toCharArray(), 0, element.length());
|
||||
xmlSerializer.endElement("element");
|
||||
// Compose the schema name
|
||||
Element schema_element = document.createElement("schema");
|
||||
dc_type.appendChild(schema_element);
|
||||
schema_element.setTextContent(schemaName);
|
||||
|
||||
// Output the qualifier, if present
|
||||
// Compose the element
|
||||
Element element_element = document.createElement("element");
|
||||
dc_type.appendChild(element_element);
|
||||
element_element.setTextContent(element);
|
||||
|
||||
// Compose the qualifier, if present
|
||||
if (qualifier != null) {
|
||||
xmlSerializer.startElement("qualifier", null);
|
||||
xmlSerializer.characters(qualifier.toCharArray(), 0, qualifier.length());
|
||||
xmlSerializer.endElement("qualifier");
|
||||
Element qualifier_element = document.createElement("qualifier");
|
||||
dc_type.appendChild(qualifier_element);
|
||||
qualifier_element.setTextContent(qualifier);
|
||||
} else {
|
||||
xmlSerializer.comment("unqualified");
|
||||
dc_type.appendChild(document.createComment("unqualified"));
|
||||
}
|
||||
|
||||
// Output the scope note, if present
|
||||
// Compose the scope note, if present
|
||||
if (scopeNote != null) {
|
||||
xmlSerializer.startElement("scope_note", null);
|
||||
xmlSerializer.characters(scopeNote.toCharArray(), 0, scopeNote.length());
|
||||
xmlSerializer.endElement("scope_note");
|
||||
Element scope_element = document.createElement("scope_note");
|
||||
dc_type.appendChild(scope_element);
|
||||
scope_element.setTextContent(scopeNote);
|
||||
} else {
|
||||
xmlSerializer.comment("no scope note");
|
||||
dc_type.appendChild(document.createComment("no scope note"));
|
||||
}
|
||||
|
||||
xmlSerializer.endElement("dc-type");
|
||||
}
|
||||
|
||||
static Map<Integer, String> schemaMap = new HashMap<Integer, String>();
|
||||
@@ -317,7 +332,7 @@ public class MetadataExporter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the usage message to stdout
|
||||
* Print the usage message to standard output
|
||||
*/
|
||||
public static void usage() {
|
||||
String usage = "Use this class with the following options:\n" +
|
||||
|
@@ -14,9 +14,9 @@ import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.MetadataField;
|
||||
@@ -94,7 +94,7 @@ public class MetadataImporter {
|
||||
boolean forceUpdate = false;
|
||||
|
||||
// create an options object and populate it
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
Options options = new Options();
|
||||
options.addOption("f", "file", true, "source xml file for DC fields");
|
||||
options.addOption("u", "update", false, "update an existing schema");
|
||||
|
@@ -7,6 +7,14 @@
|
||||
*/
|
||||
package org.dspace.administer;
|
||||
|
||||
import static org.dspace.content.service.DSpaceObjectService.MD_COPYRIGHT_TEXT;
|
||||
import static org.dspace.content.service.DSpaceObjectService.MD_INTRODUCTORY_TEXT;
|
||||
import static org.dspace.content.service.DSpaceObjectService.MD_LICENSE;
|
||||
import static org.dspace.content.service.DSpaceObjectService.MD_NAME;
|
||||
import static org.dspace.content.service.DSpaceObjectService.MD_PROVENANCE_DESCRIPTION;
|
||||
import static org.dspace.content.service.DSpaceObjectService.MD_SHORT_DESCRIPTION;
|
||||
import static org.dspace.content.service.DSpaceObjectService.MD_SIDEBAR_TEXT;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
@@ -35,6 +43,7 @@ import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataFieldName;
|
||||
import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
@@ -88,12 +97,12 @@ public class StructBuilder {
|
||||
/**
|
||||
* A table to hold metadata for the collection being worked on.
|
||||
*/
|
||||
private static final Map<String, String> collectionMap = new HashMap<>();
|
||||
private static final Map<String, MetadataFieldName> collectionMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* A table to hold metadata for the community being worked on.
|
||||
*/
|
||||
private static final Map<String, String> communityMap = new HashMap<>();
|
||||
private static final Map<String, MetadataFieldName> communityMap = new HashMap<>();
|
||||
|
||||
protected static CommunityService communityService
|
||||
= ContentServiceFactory.getInstance().getCommunityService();
|
||||
@@ -261,19 +270,19 @@ public class StructBuilder {
|
||||
}
|
||||
|
||||
// load the mappings into the member variable hashmaps
|
||||
communityMap.put("name", "name");
|
||||
communityMap.put("description", "short_description");
|
||||
communityMap.put("intro", "introductory_text");
|
||||
communityMap.put("copyright", "copyright_text");
|
||||
communityMap.put("sidebar", "side_bar_text");
|
||||
communityMap.put("name", MD_NAME);
|
||||
communityMap.put("description", MD_SHORT_DESCRIPTION);
|
||||
communityMap.put("intro", MD_INTRODUCTORY_TEXT);
|
||||
communityMap.put("copyright", MD_COPYRIGHT_TEXT);
|
||||
communityMap.put("sidebar", MD_SIDEBAR_TEXT);
|
||||
|
||||
collectionMap.put("name", "name");
|
||||
collectionMap.put("description", "short_description");
|
||||
collectionMap.put("intro", "introductory_text");
|
||||
collectionMap.put("copyright", "copyright_text");
|
||||
collectionMap.put("sidebar", "side_bar_text");
|
||||
collectionMap.put("license", "license");
|
||||
collectionMap.put("provenance", "provenance_description");
|
||||
collectionMap.put("name", MD_NAME);
|
||||
collectionMap.put("description", MD_SHORT_DESCRIPTION);
|
||||
collectionMap.put("intro", MD_INTRODUCTORY_TEXT);
|
||||
collectionMap.put("copyright", MD_COPYRIGHT_TEXT);
|
||||
collectionMap.put("sidebar", MD_SIDEBAR_TEXT);
|
||||
collectionMap.put("license", MD_LICENSE);
|
||||
collectionMap.put("provenance", MD_PROVENANCE_DESCRIPTION);
|
||||
|
||||
Element[] elements = new Element[]{};
|
||||
try {
|
||||
@@ -619,14 +628,16 @@ public class StructBuilder {
|
||||
}
|
||||
|
||||
// default the short description to be an empty string
|
||||
communityService.setMetadata(context, community, "short_description", " ");
|
||||
communityService.setMetadataSingleValue(context, community,
|
||||
MD_SHORT_DESCRIPTION, null, " ");
|
||||
|
||||
// now update the metadata
|
||||
Node tn = communities.item(i);
|
||||
for (Map.Entry<String, String> entry : communityMap.entrySet()) {
|
||||
for (Map.Entry<String, MetadataFieldName> entry : communityMap.entrySet()) {
|
||||
NodeList nl = XPathAPI.selectNodeList(tn, entry.getKey());
|
||||
if (nl.getLength() == 1) {
|
||||
communityService.setMetadata(context, community, entry.getValue(), getStringValue(nl.item(0)));
|
||||
communityService.setMetadataSingleValue(context, community,
|
||||
entry.getValue(), null, getStringValue(nl.item(0)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,30 +661,41 @@ public class StructBuilder {
|
||||
element.setAttribute("identifier", community.getHandle());
|
||||
|
||||
Element nameElement = new Element("name");
|
||||
nameElement.setText(communityService.getMetadata(community, "name"));
|
||||
nameElement.setText(communityService.getMetadataFirstValue(
|
||||
community, CommunityService.MD_NAME, Item.ANY));
|
||||
element.addContent(nameElement);
|
||||
|
||||
if (communityService.getMetadata(community, "short_description") != null) {
|
||||
String fieldValue;
|
||||
|
||||
fieldValue = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element descriptionElement = new Element("description");
|
||||
descriptionElement.setText(communityService.getMetadata(community, "short_description"));
|
||||
descriptionElement.setText(fieldValue);
|
||||
element.addContent(descriptionElement);
|
||||
}
|
||||
|
||||
if (communityService.getMetadata(community, "introductory_text") != null) {
|
||||
fieldValue = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element introElement = new Element("intro");
|
||||
introElement.setText(communityService.getMetadata(community, "introductory_text"));
|
||||
introElement.setText(fieldValue);
|
||||
element.addContent(introElement);
|
||||
}
|
||||
|
||||
if (communityService.getMetadata(community, "copyright_text") != null) {
|
||||
fieldValue = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element copyrightElement = new Element("copyright");
|
||||
copyrightElement.setText(communityService.getMetadata(community, "copyright_text"));
|
||||
copyrightElement.setText(fieldValue);
|
||||
element.addContent(copyrightElement);
|
||||
}
|
||||
|
||||
if (communityService.getMetadata(community, "side_bar_text") != null) {
|
||||
fieldValue = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element sidebarElement = new Element("sidebar");
|
||||
sidebarElement.setText(communityService.getMetadata(community, "side_bar_text"));
|
||||
sidebarElement.setText(fieldValue);
|
||||
element.addContent(sidebarElement);
|
||||
}
|
||||
|
||||
@@ -717,14 +739,16 @@ public class StructBuilder {
|
||||
Collection collection = collectionService.create(context, parent);
|
||||
|
||||
// default the short description to the empty string
|
||||
collectionService.setMetadata(context, collection, "short_description", " ");
|
||||
collectionService.setMetadataSingleValue(context, collection,
|
||||
MD_SHORT_DESCRIPTION, Item.ANY, " ");
|
||||
|
||||
// import the rest of the metadata
|
||||
Node tn = collections.item(i);
|
||||
for (Map.Entry<String, String> entry : collectionMap.entrySet()) {
|
||||
for (Map.Entry<String, MetadataFieldName> entry : collectionMap.entrySet()) {
|
||||
NodeList nl = XPathAPI.selectNodeList(tn, entry.getKey());
|
||||
if (nl.getLength() == 1) {
|
||||
collectionService.setMetadata(context, collection, entry.getValue(), getStringValue(nl.item(0)));
|
||||
collectionService.setMetadataSingleValue(context, collection,
|
||||
entry.getValue(), null, getStringValue(nl.item(0)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -733,42 +757,57 @@ public class StructBuilder {
|
||||
element.setAttribute("identifier", collection.getHandle());
|
||||
|
||||
Element nameElement = new Element("name");
|
||||
nameElement.setText(collectionService.getMetadata(collection, "name"));
|
||||
nameElement.setText(collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_NAME, Item.ANY));
|
||||
element.addContent(nameElement);
|
||||
|
||||
if (collectionService.getMetadata(collection, "short_description") != null) {
|
||||
String fieldValue;
|
||||
|
||||
fieldValue = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element descriptionElement = new Element("description");
|
||||
descriptionElement.setText(collectionService.getMetadata(collection, "short_description"));
|
||||
descriptionElement.setText(fieldValue);
|
||||
element.addContent(descriptionElement);
|
||||
}
|
||||
|
||||
if (collectionService.getMetadata(collection, "introductory_text") != null) {
|
||||
fieldValue = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element introElement = new Element("intro");
|
||||
introElement.setText(collectionService.getMetadata(collection, "introductory_text"));
|
||||
introElement.setText(fieldValue);
|
||||
element.addContent(introElement);
|
||||
}
|
||||
|
||||
if (collectionService.getMetadata(collection, "copyright_text") != null) {
|
||||
fieldValue = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element copyrightElement = new Element("copyright");
|
||||
copyrightElement.setText(collectionService.getMetadata(collection, "copyright_text"));
|
||||
copyrightElement.setText(fieldValue);
|
||||
element.addContent(copyrightElement);
|
||||
}
|
||||
|
||||
if (collectionService.getMetadata(collection, "side_bar_text") != null) {
|
||||
fieldValue = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element sidebarElement = new Element("sidebar");
|
||||
sidebarElement.setText(collectionService.getMetadata(collection, "side_bar_text"));
|
||||
sidebarElement.setText(fieldValue);
|
||||
element.addContent(sidebarElement);
|
||||
}
|
||||
|
||||
if (collectionService.getMetadata(collection, "license") != null) {
|
||||
fieldValue = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_LICENSE, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element sidebarElement = new Element("license");
|
||||
sidebarElement.setText(collectionService.getMetadata(collection, "license"));
|
||||
sidebarElement.setText(fieldValue);
|
||||
element.addContent(sidebarElement);
|
||||
}
|
||||
|
||||
if (collectionService.getMetadata(collection, "provenance_description") != null) {
|
||||
fieldValue = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_PROVENANCE_DESCRIPTION, Item.ANY);
|
||||
if (fieldValue != null) {
|
||||
Element sidebarElement = new Element("provenance");
|
||||
sidebarElement.setText(collectionService.getMetadata(collection, "provenance_description"));
|
||||
sidebarElement.setText(fieldValue);
|
||||
element.addContent(sidebarElement);
|
||||
}
|
||||
|
||||
@@ -777,5 +816,4 @@ public class StructBuilder {
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -175,11 +175,14 @@ public class DSpaceCSV implements Serializable {
|
||||
headings.add(element);
|
||||
} else if (!"id".equals(element)) {
|
||||
String authorityPrefix = "";
|
||||
AuthorityValue authorityValueType = authorityValueService.getAuthorityValueType(element);
|
||||
if (authorityValueType != null) {
|
||||
String authorityType = authorityValueType.getAuthorityType();
|
||||
authorityPrefix = element.substring(0, authorityType.length() + 1);
|
||||
element = element.substring(authorityPrefix.length());
|
||||
if (StringUtils.startsWith(element, "[authority]")) {
|
||||
element = StringUtils.substringAfter(element, "[authority]");
|
||||
AuthorityValue authorityValueType = authorityValueService.getAuthorityValueType(element);
|
||||
if (authorityValueType != null) {
|
||||
String authorityType = authorityValueType.getAuthorityType();
|
||||
authorityPrefix = element.substring(0, authorityType.length() + 1);
|
||||
element = element.substring(authorityPrefix.length());
|
||||
}
|
||||
}
|
||||
|
||||
// Verify that the heading is valid in the metadata registry
|
||||
@@ -303,7 +306,7 @@ public class DSpaceCSV implements Serializable {
|
||||
// Specify default values
|
||||
String[] defaultValues =
|
||||
new String[] {
|
||||
"dc.date.accessioned, dc.date.available, dc.date.updated, dc.description.provenance"
|
||||
"dc.date.accessioned", "dc.date.available", "dc.date.updated", "dc.description.provenance"
|
||||
};
|
||||
String[] toIgnoreArray =
|
||||
DSpaceServicesFactory.getInstance()
|
||||
|
@@ -51,7 +51,6 @@ import org.dspace.content.service.MetadataValueService;
|
||||
import org.dspace.content.service.RelationshipService;
|
||||
import org.dspace.content.service.RelationshipTypeService;
|
||||
import org.dspace.content.service.WorkspaceItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
@@ -61,6 +60,8 @@ import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.scripts.DSpaceRunnable;
|
||||
import org.dspace.scripts.handler.DSpaceRunnableHandler;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.utils.DSpace;
|
||||
import org.dspace.workflow.WorkflowException;
|
||||
import org.dspace.workflow.WorkflowItem;
|
||||
@@ -113,14 +114,14 @@ public class MetadataImport extends DSpaceRunnable<MetadataImportScriptConfigura
|
||||
*
|
||||
* @see #populateRefAndRowMap(DSpaceCSVLine, UUID)
|
||||
*/
|
||||
protected static HashMap<UUID, String> entityTypeMap = new HashMap<>();
|
||||
protected HashMap<UUID, String> entityTypeMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Map of UUIDs to their relations that are referenced within any import with their referers.
|
||||
* Map of UUIDs to their relations that are referenced within any import with their referrers.
|
||||
*
|
||||
* @see #populateEntityRelationMap(String, String, String)
|
||||
*/
|
||||
protected static HashMap<String, HashMap<String, ArrayList<String>>> entityRelationMap = new HashMap<>();
|
||||
protected HashMap<String, HashMap<String, ArrayList<String>>> entityRelationMap = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
@@ -129,7 +130,7 @@ public class MetadataImport extends DSpaceRunnable<MetadataImportScriptConfigura
|
||||
protected ArrayList<String> relationValidationErrors = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Counter of rows proccssed in a CSV.
|
||||
* Counter of rows processed in a CSV.
|
||||
*/
|
||||
protected Integer rowCount = 1;
|
||||
|
||||
@@ -158,6 +159,8 @@ public class MetadataImport extends DSpaceRunnable<MetadataImportScriptConfigura
|
||||
protected EntityService entityService = ContentServiceFactory.getInstance().getEntityService();
|
||||
protected AuthorityValueService authorityValueService = AuthorityServiceFactory.getInstance()
|
||||
.getAuthorityValueService();
|
||||
protected ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
/**
|
||||
* Create an instance of the metadata importer. Requires a context and an array of CSV lines
|
||||
@@ -419,7 +422,7 @@ public class MetadataImport extends DSpaceRunnable<MetadataImportScriptConfigura
|
||||
// Do nothing
|
||||
} else if ("expunge".equals(action)) {
|
||||
// Does the configuration allow deletes?
|
||||
if (!ConfigurationManager.getBooleanProperty("bulkedit", "allowexpunge", false)) {
|
||||
if (!configurationService.getBooleanProperty("bulkedit.allowexpunge", false)) {
|
||||
throw new MetadataImportException("'expunge' action denied by configuration");
|
||||
}
|
||||
|
||||
@@ -1368,12 +1371,12 @@ public class MetadataImport extends DSpaceRunnable<MetadataImportScriptConfigura
|
||||
* Set authority controlled fields
|
||||
*/
|
||||
private void setAuthorizedMetadataFields() {
|
||||
authorityControlled = new HashSet<String>();
|
||||
Enumeration propertyNames = ConfigurationManager.getProperties().propertyNames();
|
||||
authorityControlled = new HashSet<>();
|
||||
Enumeration propertyNames = configurationService.getProperties().propertyNames();
|
||||
while (propertyNames.hasMoreElements()) {
|
||||
String key = ((String) propertyNames.nextElement()).trim();
|
||||
if (key.startsWith(AC_PREFIX)
|
||||
&& ConfigurationManager.getBooleanProperty(key, false)) {
|
||||
&& configurationService.getBooleanProperty(key, false)) {
|
||||
authorityControlled.add(key.substring(AC_PREFIX.length()));
|
||||
}
|
||||
}
|
||||
@@ -1403,16 +1406,16 @@ public class MetadataImport extends DSpaceRunnable<MetadataImportScriptConfigura
|
||||
//Populate the EntityRelationMap
|
||||
populateEntityRelationMap(uuid, key, originId.toString());
|
||||
}
|
||||
} else {
|
||||
newLine.add(key, null);
|
||||
}
|
||||
} else {
|
||||
if (line.get(key).size() > 1) {
|
||||
if (line.get(key).size() > 0) {
|
||||
for (String value : line.get(key)) {
|
||||
newLine.add(key, value);
|
||||
}
|
||||
} else {
|
||||
if (line.get(key).size() > 0) {
|
||||
newLine.add(key, line.get(key).get(0));
|
||||
}
|
||||
newLine.add(key, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1517,6 +1520,9 @@ public class MetadataImport extends DSpaceRunnable<MetadataImportScriptConfigura
|
||||
throw new MetadataImportException("Error in CSV row " + rowCount + ":\n" +
|
||||
"Not a UUID or indirect entity reference: '" + reference + "'");
|
||||
}
|
||||
}
|
||||
if (reference.contains("::virtual::")) {
|
||||
return UUID.fromString(StringUtils.substringBefore(reference, "::virtual::"));
|
||||
} else if (!reference.startsWith("rowName:")) { // Not a rowName ref; so it's a metadata value reference
|
||||
MetadataValueService metadataValueService = ContentServiceFactory.getInstance().getMetadataValueService();
|
||||
MetadataFieldService metadataFieldService =
|
||||
@@ -1688,19 +1694,39 @@ public class MetadataImport extends DSpaceRunnable<MetadataImportScriptConfigura
|
||||
// Add to errors if Realtionship.type cannot be derived.
|
||||
Item originItem = null;
|
||||
if (itemService.find(c, UUID.fromString(targetUUID)) != null) {
|
||||
originItem = itemService.find(c, UUID.fromString(originRefererUUID));
|
||||
List<MetadataValue> relTypes = itemService.
|
||||
getMetadata(originItem, "relationship",
|
||||
"type", null, Item.ANY);
|
||||
String relTypeValue = null;
|
||||
if (relTypes.size() > 0) {
|
||||
relTypeValue = relTypes.get(0).getValue();
|
||||
DSpaceCSVLine dSpaceCSVLine = this.csv.getCSVLines()
|
||||
.get(Integer.valueOf(originRow) - 1);
|
||||
List<String> relTypes = dSpaceCSVLine.get("relationship.type");
|
||||
if (relTypes == null || relTypes.isEmpty()) {
|
||||
dSpaceCSVLine.get("relationship.type[]");
|
||||
}
|
||||
|
||||
if (relTypes != null && relTypes.size() > 0) {
|
||||
String relTypeValue = relTypes.get(0);
|
||||
relTypeValue = StringUtils.remove(relTypeValue, "\"").trim();
|
||||
originType = entityTypeService.findByEntityType(c, relTypeValue).getLabel();
|
||||
validateTypesByTypeByTypeName(c, targetType, originType, typeName, originRow);
|
||||
} else {
|
||||
relationValidationErrors.add("Error on CSV row " + originRow + ":" + "\n" +
|
||||
"Cannot resolve Entity type for reference: "
|
||||
+ originRefererUUID);
|
||||
originItem = itemService.find(c, UUID.fromString(originRefererUUID));
|
||||
if (originItem != null) {
|
||||
List<MetadataValue> mdv = itemService.getMetadata(originItem,
|
||||
"relationship",
|
||||
"type", null,
|
||||
Item.ANY);
|
||||
if (!mdv.isEmpty()) {
|
||||
String relTypeValue = mdv.get(0).getValue();
|
||||
originType = entityTypeService.findByEntityType(c, relTypeValue).getLabel();
|
||||
validateTypesByTypeByTypeName(c, targetType, originType, typeName,
|
||||
originRow);
|
||||
} else {
|
||||
relationValidationErrors.add("Error on CSV row " + originRow + ":" + "\n" +
|
||||
"Cannot resolve Entity type for reference: " + originRefererUUID);
|
||||
}
|
||||
} else {
|
||||
relationValidationErrors.add("Error on CSV row " + originRow + ":" + "\n" +
|
||||
"Cannot resolve Entity type for reference: "
|
||||
+ originRefererUUID);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -1727,11 +1753,11 @@ public class MetadataImport extends DSpaceRunnable<MetadataImportScriptConfigura
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a list of potenital Relationship Types given a typeName and attempts to match the given
|
||||
* Generates a list of potential Relationship Types given a typeName and attempts to match the given
|
||||
* targetType and originType to a Relationship Type in the list.
|
||||
*
|
||||
* @param targetType entity type of target.
|
||||
* @param originType entity type of origin referer.
|
||||
* @param originType entity type of origin referrer.
|
||||
* @param typeName left or right typeName of the respective Relationship.
|
||||
* @return the UUID of the item.
|
||||
*/
|
||||
|
@@ -17,12 +17,11 @@ import java.util.UUID;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.OptionBuilder;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.checker.BitstreamDispatcher;
|
||||
@@ -87,7 +86,7 @@ public final class ChecksumChecker {
|
||||
*/
|
||||
public static void main(String[] args) throws SQLException {
|
||||
// set up command line parser
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
CommandLine line = null;
|
||||
|
||||
// create an options object and populate it
|
||||
@@ -102,19 +101,21 @@ public final class ChecksumChecker {
|
||||
options.addOption("a", "handle", true, "Specify a handle to check");
|
||||
options.addOption("v", "verbose", false, "Report all processing");
|
||||
|
||||
OptionBuilder.withArgName("bitstream-ids").hasArgs().withDescription(
|
||||
"Space separated list of bitstream ids");
|
||||
Option useBitstreamIds = OptionBuilder.create('b');
|
||||
Option option;
|
||||
|
||||
options.addOption(useBitstreamIds);
|
||||
option = Option.builder("b")
|
||||
.longOpt("bitstream-ids")
|
||||
.hasArgs()
|
||||
.desc("Space separated list of bitstream ids")
|
||||
.build();
|
||||
options.addOption(option);
|
||||
|
||||
options.addOption("p", "prune", false, "Prune configuration file");
|
||||
options.addOption(OptionBuilder
|
||||
.withArgName("prune")
|
||||
.hasOptionalArgs(1)
|
||||
.withDescription(
|
||||
"Prune old results (optionally using specified properties file for configuration)")
|
||||
.create('p'));
|
||||
option = Option.builder("p")
|
||||
.longOpt("prune")
|
||||
.optionalArg(true)
|
||||
.desc("Prune old results (optionally using specified properties file for configuration)")
|
||||
.build();
|
||||
options.addOption(option);
|
||||
|
||||
try {
|
||||
line = parser.parse(options, args);
|
||||
|
@@ -15,9 +15,9 @@ import java.util.UUID;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
@@ -53,7 +53,7 @@ public class Harvest {
|
||||
|
||||
public static void main(String[] argv) throws Exception {
|
||||
// create an options object and populate it
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
|
||||
Options options = new Options();
|
||||
|
||||
@@ -402,11 +402,7 @@ public class Harvest {
|
||||
context.setCurrentUser(eperson);
|
||||
harvester.runHarvest();
|
||||
context.complete();
|
||||
} catch (SQLException e) {
|
||||
throw new IllegalStateException("Failed to run harvester", e);
|
||||
} catch (AuthorizeException e) {
|
||||
throw new IllegalStateException("Failed to run harvester", e);
|
||||
} catch (IOException e) {
|
||||
} catch (SQLException | AuthorizeException | IOException e) {
|
||||
throw new IllegalStateException("Failed to run harvester", e);
|
||||
}
|
||||
|
||||
|
@@ -15,9 +15,9 @@ import java.util.UUID;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.dspace.app.itemexport.factory.ItemExportServiceFactory;
|
||||
import org.dspace.app.itemexport.service.ItemExportService;
|
||||
import org.dspace.content.Collection;
|
||||
@@ -69,7 +69,7 @@ public class ItemExportCLITool {
|
||||
*/
|
||||
public static void main(String[] argv) throws Exception {
|
||||
// create an options object and populate it
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
|
||||
Options options = new Options();
|
||||
|
||||
|
@@ -47,7 +47,6 @@ import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.Email;
|
||||
@@ -57,6 +56,7 @@ import org.dspace.core.Utils;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -93,12 +93,14 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
protected ItemService itemService;
|
||||
@Autowired(required = true)
|
||||
protected HandleService handleService;
|
||||
@Autowired(required = true)
|
||||
protected ConfigurationService configurationService;
|
||||
|
||||
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private Logger log = org.apache.logging.log4j.LogManager.getLogger(ItemExportServiceImpl.class);
|
||||
private final Logger log = org.apache.logging.log4j.LogManager.getLogger(ItemExportServiceImpl.class);
|
||||
|
||||
protected ItemExportServiceImpl() {
|
||||
|
||||
@@ -605,7 +607,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
|
||||
// check the size of all the bitstreams against the configuration file
|
||||
// entry if it exists
|
||||
String megaBytes = ConfigurationManager
|
||||
String megaBytes = configurationService
|
||||
.getProperty("org.dspace.app.itemexport.max.size");
|
||||
if (megaBytes != null) {
|
||||
float maxSize = 0;
|
||||
@@ -730,7 +732,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
@Override
|
||||
public String getExportDownloadDirectory(EPerson ePerson)
|
||||
throws Exception {
|
||||
String downloadDir = ConfigurationManager
|
||||
String downloadDir = configurationService
|
||||
.getProperty("org.dspace.app.itemexport.download.dir");
|
||||
if (downloadDir == null) {
|
||||
throw new Exception(
|
||||
@@ -747,7 +749,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
|
||||
@Override
|
||||
public String getExportWorkDirectory() throws Exception {
|
||||
String exportDir = ConfigurationManager
|
||||
String exportDir = configurationService
|
||||
.getProperty("org.dspace.app.itemexport.work.dir");
|
||||
if (exportDir == null) {
|
||||
throw new Exception(
|
||||
@@ -853,7 +855,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<String> fileNames = new ArrayList<String>();
|
||||
List<String> fileNames = new ArrayList<>();
|
||||
|
||||
for (String fileName : downloadDir.list()) {
|
||||
if (fileName.contains("export") && fileName.endsWith(".zip")) {
|
||||
@@ -870,7 +872,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
|
||||
@Override
|
||||
public void deleteOldExportArchives(EPerson eperson) throws Exception {
|
||||
int hours = ConfigurationManager
|
||||
int hours = configurationService
|
||||
.getIntProperty("org.dspace.app.itemexport.life.span.hours");
|
||||
Calendar now = Calendar.getInstance();
|
||||
now.setTime(new Date());
|
||||
@@ -891,11 +893,11 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
|
||||
@Override
|
||||
public void deleteOldExportArchives() throws Exception {
|
||||
int hours = ConfigurationManager.getIntProperty("org.dspace.app.itemexport.life.span.hours");
|
||||
int hours = configurationService.getIntProperty("org.dspace.app.itemexport.life.span.hours");
|
||||
Calendar now = Calendar.getInstance();
|
||||
now.setTime(new Date());
|
||||
now.add(Calendar.HOUR, (-hours));
|
||||
File downloadDir = new File(ConfigurationManager.getProperty("org.dspace.app.itemexport.download.dir"));
|
||||
File downloadDir = new File(configurationService.getProperty("org.dspace.app.itemexport.download.dir"));
|
||||
if (downloadDir.exists()) {
|
||||
// Get a list of all the sub-directories, potentially one for each ePerson.
|
||||
File[] dirs = downloadDir.listFiles();
|
||||
@@ -929,8 +931,8 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
Locale supportedLocale = I18nUtil.getEPersonLocale(eperson);
|
||||
Email email = Email.getEmail(I18nUtil.getEmailFilename(supportedLocale, "export_success"));
|
||||
email.addRecipient(eperson.getEmail());
|
||||
email.addArgument(ConfigurationManager.getProperty("dspace.ui.url") + "/exportdownload/" + fileName);
|
||||
email.addArgument(ConfigurationManager.getProperty("org.dspace.app.itemexport.life.span.hours"));
|
||||
email.addArgument(configurationService.getProperty("dspace.ui.url") + "/exportdownload/" + fileName);
|
||||
email.addArgument(configurationService.getProperty("org.dspace.app.itemexport.life.span.hours"));
|
||||
|
||||
email.send();
|
||||
} catch (Exception e) {
|
||||
@@ -947,7 +949,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
Email email = Email.getEmail(I18nUtil.getEmailFilename(supportedLocale, "export_error"));
|
||||
email.addRecipient(eperson.getEmail());
|
||||
email.addArgument(error);
|
||||
email.addArgument(ConfigurationManager.getProperty("dspace.ui.url") + "/feedback");
|
||||
email.addArgument(configurationService.getProperty("dspace.ui.url") + "/feedback");
|
||||
|
||||
email.send();
|
||||
} catch (Exception e) {
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.app.itemimport;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -15,9 +16,9 @@ import java.util.UUID;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.dspace.app.itemimport.factory.ItemImportServiceFactory;
|
||||
import org.dspace.app.itemimport.service.ItemImportService;
|
||||
import org.dspace.content.Collection;
|
||||
@@ -67,7 +68,7 @@ public class ItemImportCLITool {
|
||||
|
||||
try {
|
||||
// create an options object and populate it
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
|
||||
Options options = new Options();
|
||||
|
||||
@@ -408,7 +409,7 @@ public class ItemImportCLITool {
|
||||
"Deleting temporary zip directory: " + myloader.getTempWorkDirFile().getAbsolutePath());
|
||||
myloader.cleanupZipTemp();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
} catch (IOException ex) {
|
||||
System.out.println("Unable to delete temporary zip archive location: " + myloader.getTempWorkDirFile()
|
||||
.getAbsolutePath());
|
||||
}
|
||||
|
@@ -85,7 +85,6 @@ import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
import org.dspace.content.service.MetadataSchemaService;
|
||||
import org.dspace.content.service.WorkspaceItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.Email;
|
||||
@@ -96,6 +95,7 @@ import org.dspace.eperson.Group;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.eperson.service.GroupService;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.utils.DSpace;
|
||||
import org.dspace.workflow.WorkflowItem;
|
||||
import org.dspace.workflow.WorkflowService;
|
||||
@@ -157,8 +157,11 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
protected WorkspaceItemService workspaceItemService;
|
||||
@Autowired(required = true)
|
||||
protected WorkflowService workflowService;
|
||||
@Autowired(required = true)
|
||||
protected ConfigurationService configurationService;
|
||||
|
||||
protected final String tempWorkDir = ConfigurationManager.getProperty("org.dspace.app.batchitemimport.work.dir");
|
||||
protected final String tempWorkDir
|
||||
= configurationService.getProperty("org.dspace.app.batchitemimport.work.dir");
|
||||
|
||||
protected boolean isTest = false;
|
||||
protected boolean isResume = false;
|
||||
@@ -217,7 +220,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
//Determine the folder where BTE will output the results
|
||||
String outputFolder = null;
|
||||
if (workingDir == null) { //This indicates a command line import, create a random path
|
||||
File importDir = new File(ConfigurationManager.getProperty("org.dspace.app.batchitemimport.work.dir"));
|
||||
File importDir = new File(configurationService.getProperty("org.dspace.app.batchitemimport.work.dir"));
|
||||
if (!importDir.exists()) {
|
||||
boolean success = importDir.mkdir();
|
||||
if (!success) {
|
||||
@@ -1481,7 +1484,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
|
||||
File tempdir = new File(destinationDir);
|
||||
if (!tempdir.isDirectory()) {
|
||||
log.error("'" + ConfigurationManager.getProperty("org.dspace.app.itemexport.work.dir") +
|
||||
log.error("'" + configurationService.getProperty("org.dspace.app.itemexport.work.dir") +
|
||||
"' as defined by the key 'org.dspace.app.itemexport.work.dir' in dspace.cfg " +
|
||||
"is not a valid directory");
|
||||
}
|
||||
@@ -1506,60 +1509,54 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
log.error("Unable to create contents directory: " + zipDir + entry.getName());
|
||||
}
|
||||
} else {
|
||||
System.out.println("Extracting file: " + entry.getName());
|
||||
log.info("Extracting file: " + entry.getName());
|
||||
|
||||
int index = entry.getName().lastIndexOf('/');
|
||||
if (index == -1) {
|
||||
// Was it created on Windows instead?
|
||||
index = entry.getName().lastIndexOf('\\');
|
||||
}
|
||||
if (index > 0) {
|
||||
File dir = new File(zipDir + entry.getName().substring(0, index));
|
||||
if (!dir.exists() && !dir.mkdirs()) {
|
||||
log.error("Unable to create directory: " + dir.getAbsolutePath());
|
||||
}
|
||||
// Verify that the directory the entry is using is a subpath of zipDir (and not somewhere else!)
|
||||
if (!dir.toPath().normalize().startsWith(zipDir)) {
|
||||
throw new IOException("Bad zip entry: '" + entry.getName()
|
||||
+ "' in file '" + zipfile.getAbsolutePath() + "'!"
|
||||
+ " Cannot process this file.");
|
||||
}
|
||||
|
||||
//Entries could have too many directories, and we need to adjust the sourcedir
|
||||
// file1.zip (SimpleArchiveFormat / item1 / contents|dublin_core|...
|
||||
// SimpleArchiveFormat / item2 / contents|dublin_core|...
|
||||
// or
|
||||
// file2.zip (item1 / contents|dublin_core|...
|
||||
// item2 / contents|dublin_core|...
|
||||
|
||||
//regex supports either windows or *nix file paths
|
||||
String[] entryChunks = entry.getName().split("/|\\\\");
|
||||
if (entryChunks.length > 2) {
|
||||
if (StringUtils.equals(sourceDirForZip, sourcedir)) {
|
||||
sourceDirForZip = sourcedir + "/" + entryChunks[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
File outFile = new File(zipDir + entry.getName());
|
||||
// Verify that this file will be created in our zipDir (and not somewhere else!)
|
||||
String entryName = entry.getName();
|
||||
File outFile = new File(zipDir + entryName);
|
||||
// Verify that this file will be extracted into our zipDir (and not somewhere else!)
|
||||
if (!outFile.toPath().normalize().startsWith(zipDir)) {
|
||||
throw new IOException("Bad zip entry: '" + entry.getName()
|
||||
throw new IOException("Bad zip entry: '" + entryName
|
||||
+ "' in file '" + zipfile.getAbsolutePath() + "'!"
|
||||
+ " Cannot process this file.");
|
||||
} else {
|
||||
System.out.println("Extracting file: " + entryName);
|
||||
log.info("Extracting file: " + entryName);
|
||||
|
||||
int index = entryName.lastIndexOf('/');
|
||||
if (index == -1) {
|
||||
// Was it created on Windows instead?
|
||||
index = entryName.lastIndexOf('\\');
|
||||
}
|
||||
if (index > 0) {
|
||||
File dir = new File(zipDir + entryName.substring(0, index));
|
||||
if (!dir.exists() && !dir.mkdirs()) {
|
||||
log.error("Unable to create directory: " + dir.getAbsolutePath());
|
||||
}
|
||||
|
||||
//Entries could have too many directories, and we need to adjust the sourcedir
|
||||
// file1.zip (SimpleArchiveFormat / item1 / contents|dublin_core|...
|
||||
// SimpleArchiveFormat / item2 / contents|dublin_core|...
|
||||
// or
|
||||
// file2.zip (item1 / contents|dublin_core|...
|
||||
// item2 / contents|dublin_core|...
|
||||
|
||||
//regex supports either windows or *nix file paths
|
||||
String[] entryChunks = entryName.split("/|\\\\");
|
||||
if (entryChunks.length > 2) {
|
||||
if (StringUtils.equals(sourceDirForZip, sourcedir)) {
|
||||
sourceDirForZip = sourcedir + "/" + entryChunks[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
InputStream in = zf.getInputStream(entry);
|
||||
BufferedOutputStream out = new BufferedOutputStream(
|
||||
new FileOutputStream(outFile));
|
||||
while ((len = in.read(buffer)) >= 0) {
|
||||
out.write(buffer, 0, len);
|
||||
}
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
InputStream in = zf.getInputStream(entry);
|
||||
BufferedOutputStream out = new BufferedOutputStream(
|
||||
new FileOutputStream(outFile));
|
||||
while ((len = in.read(buffer)) >= 0) {
|
||||
out.write(buffer, 0, len);
|
||||
}
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1652,7 +1649,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
}
|
||||
}
|
||||
|
||||
importDir = ConfigurationManager.getProperty(
|
||||
importDir = configurationService.getProperty(
|
||||
"org.dspace.app.batchitemimport.work.dir") + File.separator + "batchuploads" + File.separator
|
||||
+ context
|
||||
.getCurrentUser()
|
||||
@@ -1810,7 +1807,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
Email email = Email.getEmail(I18nUtil.getEmailFilename(supportedLocale, "bte_batch_import_error"));
|
||||
email.addRecipient(eperson.getEmail());
|
||||
email.addArgument(error);
|
||||
email.addArgument(ConfigurationManager.getProperty("dspace.ui.url") + "/feedback");
|
||||
email.addArgument(configurationService.getProperty("dspace.ui.url") + "/feedback");
|
||||
|
||||
email.send();
|
||||
} catch (Exception e) {
|
||||
@@ -1848,7 +1845,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
@Override
|
||||
public String getImportUploadableDirectory(EPerson ePerson)
|
||||
throws Exception {
|
||||
String uploadDir = ConfigurationManager.getProperty("org.dspace.app.batchitemimport.work.dir");
|
||||
String uploadDir = configurationService.getProperty("org.dspace.app.batchitemimport.work.dir");
|
||||
if (uploadDir == null) {
|
||||
throw new Exception(
|
||||
"A dspace.cfg entry for 'org.dspace.app.batchitemimport.work.dir' does not exist.");
|
||||
|
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.dspace.app.itemupdate;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
@@ -20,22 +21,25 @@ import java.util.Map;
|
||||
public class ActionManager implements Iterable<UpdateAction> {
|
||||
|
||||
protected Map<Class<? extends UpdateAction>, UpdateAction> registry
|
||||
= new LinkedHashMap<Class<? extends UpdateAction>, UpdateAction>();
|
||||
= new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* Get update action
|
||||
* Get update action.
|
||||
*
|
||||
* @param actionClass UpdateAction class
|
||||
* @return instantiation of UpdateAction class
|
||||
* @throws InstantiationException if instantiation error
|
||||
* @throws IllegalAccessException if illegal access error
|
||||
* @throws NoSuchMethodException passed through.
|
||||
* @throws InvocationTargetException passed through.
|
||||
*/
|
||||
public UpdateAction getUpdateAction(Class<? extends UpdateAction> actionClass)
|
||||
throws InstantiationException, IllegalAccessException {
|
||||
throws InstantiationException, IllegalAccessException,
|
||||
NoSuchMethodException, IllegalArgumentException, InvocationTargetException {
|
||||
UpdateAction action = registry.get(actionClass);
|
||||
|
||||
if (action == null) {
|
||||
action = actionClass.newInstance();
|
||||
action = actionClass.getDeclaredConstructor().newInstance();
|
||||
registry.put(actionClass, action);
|
||||
}
|
||||
|
||||
@@ -58,7 +62,8 @@ public class ActionManager implements Iterable<UpdateAction> {
|
||||
@Override
|
||||
public Iterator<UpdateAction> iterator() {
|
||||
return new Iterator<UpdateAction>() {
|
||||
private Iterator<Class<? extends UpdateAction>> itr = registry.keySet().iterator();
|
||||
private final Iterator<Class<? extends UpdateAction>> itr
|
||||
= registry.keySet().iterator();
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
|
@@ -24,10 +24,10 @@ import java.util.UUID;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
@@ -109,7 +109,7 @@ public class ItemUpdate {
|
||||
|
||||
// instance variables
|
||||
protected ActionManager actionMgr = new ActionManager();
|
||||
protected List<String> undoActionList = new ArrayList<String>();
|
||||
protected List<String> undoActionList = new ArrayList<>();
|
||||
protected String eperson;
|
||||
|
||||
/**
|
||||
@@ -117,7 +117,7 @@ public class ItemUpdate {
|
||||
*/
|
||||
public static void main(String[] argv) {
|
||||
// create an options object and populate it
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
|
||||
Options options = new Options();
|
||||
|
||||
@@ -275,7 +275,8 @@ public class ItemUpdate {
|
||||
Class<?> cfilter = Class.forName(filterClassname);
|
||||
pr("BitstreamFilter class to instantiate: " + cfilter.toString());
|
||||
|
||||
filter = (BitstreamFilter) cfilter.newInstance(); //unfortunate cast, an erasure consequence
|
||||
filter = (BitstreamFilter) cfilter.getDeclaredConstructor()
|
||||
.newInstance(); //unfortunate cast, an erasure consequence
|
||||
} catch (Exception e) {
|
||||
pr("Error: Failure instantiating bitstream filter class: " + filterClassname);
|
||||
System.exit(1);
|
||||
|
@@ -38,8 +38,8 @@ import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
@@ -226,7 +226,9 @@ public class MetadataUtilities {
|
||||
if (language == null) {
|
||||
language = "en";
|
||||
} else if ("".equals(language)) {
|
||||
language = ConfigurationManager.getProperty("default.language");
|
||||
language = DSpaceServicesFactory.getInstance()
|
||||
.getConfigurationService()
|
||||
.getProperty("default.language");
|
||||
}
|
||||
|
||||
DtoMetadata dtom = DtoMetadata.create(schema, element, qualifier, language, value);
|
||||
|
@@ -12,7 +12,8 @@ import java.io.InputStream;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* Filter image bitstreams, scaling the image to be within the bounds of
|
||||
@@ -66,17 +67,19 @@ public class BrandedPreviewJPEGFilter extends MediaFilter {
|
||||
BufferedImage buf = ImageIO.read(source);
|
||||
|
||||
// get config params
|
||||
float xmax = (float) ConfigurationManager
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
float xmax = (float) configurationService
|
||||
.getIntProperty("webui.preview.maxwidth");
|
||||
float ymax = (float) ConfigurationManager
|
||||
float ymax = (float) configurationService
|
||||
.getIntProperty("webui.preview.maxheight");
|
||||
boolean blurring = (boolean) ConfigurationManager
|
||||
boolean blurring = (boolean) configurationService
|
||||
.getBooleanProperty("webui.preview.blurring");
|
||||
boolean hqscaling = (boolean) ConfigurationManager
|
||||
boolean hqscaling = (boolean) configurationService
|
||||
.getBooleanProperty("webui.preview.hqscaling");
|
||||
int brandHeight = ConfigurationManager.getIntProperty("webui.preview.brand.height");
|
||||
String brandFont = ConfigurationManager.getProperty("webui.preview.brand.font");
|
||||
int brandFontPoint = ConfigurationManager.getIntProperty("webui.preview.brand.fontpoint");
|
||||
int brandHeight = configurationService.getIntProperty("webui.preview.brand.height");
|
||||
String brandFont = configurationService.getProperty("webui.preview.brand.font");
|
||||
int brandFontPoint = configurationService.getIntProperty("webui.preview.brand.fontpoint");
|
||||
|
||||
JPEGFilter jpegFilter = new JPEGFilter();
|
||||
return jpegFilter
|
||||
|
@@ -19,8 +19,9 @@ import org.dspace.content.Bundle;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.im4java.core.ConvertCmd;
|
||||
import org.im4java.core.IM4JavaException;
|
||||
import org.im4java.core.IMOperation;
|
||||
@@ -33,36 +34,18 @@ import org.im4java.process.ProcessStarter;
|
||||
* no bigger than. Creates only JPEGs.
|
||||
*/
|
||||
public abstract class ImageMagickThumbnailFilter extends MediaFilter {
|
||||
protected static int width = 180;
|
||||
protected static int height = 120;
|
||||
private static boolean flatten = true;
|
||||
static String bitstreamDescription = "IM Thumbnail";
|
||||
static final String defaultPattern = "Generated Thumbnail";
|
||||
static Pattern replaceRegex = Pattern.compile(defaultPattern);
|
||||
private static final int DEFAULT_WIDTH = 180;
|
||||
private static final int DEFAULT_HEIGHT = 120;
|
||||
static final String DEFAULT_PATTERN = "Generated Thumbnail";
|
||||
protected final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
protected static final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
static String cmyk_profile;
|
||||
static String srgb_profile;
|
||||
protected static final String PRE = ImageMagickThumbnailFilter.class.getName();
|
||||
|
||||
static {
|
||||
String pre = ImageMagickThumbnailFilter.class.getName();
|
||||
String s = ConfigurationManager.getProperty(pre + ".ProcessStarter");
|
||||
String s = configurationService.getProperty(PRE + ".ProcessStarter");
|
||||
ProcessStarter.setGlobalSearchPath(s);
|
||||
width = ConfigurationManager.getIntProperty("thumbnail.maxwidth", width);
|
||||
height = ConfigurationManager.getIntProperty("thumbnail.maxheight", height);
|
||||
flatten = ConfigurationManager.getBooleanProperty(pre + ".flatten", flatten);
|
||||
String description = ConfigurationManager.getProperty(pre + ".bitstreamDescription");
|
||||
cmyk_profile = ConfigurationManager.getProperty(pre + ".cmyk_profile");
|
||||
srgb_profile = ConfigurationManager.getProperty(pre + ".srgb_profile");
|
||||
if (description != null) {
|
||||
bitstreamDescription = description;
|
||||
}
|
||||
try {
|
||||
String patt = ConfigurationManager.getProperty(pre + ".replaceRegex");
|
||||
replaceRegex = Pattern.compile(patt == null ? defaultPattern : patt);
|
||||
} catch (PatternSyntaxException e) {
|
||||
System.err.println("Invalid thumbnail replacement pattern: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public ImageMagickThumbnailFilter() {
|
||||
@@ -94,7 +77,7 @@ public abstract class ImageMagickThumbnailFilter extends MediaFilter {
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return bitstreamDescription;
|
||||
return configurationService.getProperty(PRE + ".bitstreamDescription", "IM Thumbnail");
|
||||
}
|
||||
|
||||
public File inputStreamToTempFile(InputStream source, String prefix, String suffix) throws IOException {
|
||||
@@ -120,7 +103,8 @@ public abstract class ImageMagickThumbnailFilter extends MediaFilter {
|
||||
IMOperation op = new IMOperation();
|
||||
op.autoOrient();
|
||||
op.addImage(f.getAbsolutePath());
|
||||
op.thumbnail(width, height);
|
||||
op.thumbnail(configurationService.getIntProperty("thumbnail.maxwidth", DEFAULT_WIDTH),
|
||||
configurationService.getIntProperty("thumbnail.maxheight", DEFAULT_HEIGHT));
|
||||
op.addImage(f2.getAbsolutePath());
|
||||
if (verbose) {
|
||||
System.out.println("IM Thumbnail Param: " + op);
|
||||
@@ -137,11 +121,14 @@ public abstract class ImageMagickThumbnailFilter extends MediaFilter {
|
||||
IMOperation op = new IMOperation();
|
||||
String s = "[" + page + "]";
|
||||
op.addImage(f.getAbsolutePath() + s);
|
||||
if (flatten) {
|
||||
if (configurationService.getBooleanProperty(PRE + ".flatten", true)) {
|
||||
op.flatten();
|
||||
}
|
||||
|
||||
// PDFs using the CMYK color system can be handled specially if
|
||||
// profiles are defined
|
||||
String cmyk_profile = configurationService.getProperty(PRE + ".cmyk_profile");
|
||||
String srgb_profile = configurationService.getProperty(PRE + ".srgb_profile");
|
||||
if (cmyk_profile != null && srgb_profile != null) {
|
||||
Info imageInfo = new Info(f.getAbsolutePath() + s, true);
|
||||
String imageClass = imageInfo.getImageClass();
|
||||
@@ -174,24 +161,32 @@ public abstract class ImageMagickThumbnailFilter extends MediaFilter {
|
||||
String description = bit.getDescription();
|
||||
// If anything other than a generated thumbnail
|
||||
// is found, halt processing
|
||||
Pattern replaceRegex;
|
||||
try {
|
||||
String patt = configurationService.getProperty(PRE + ".replaceRegex", DEFAULT_PATTERN);
|
||||
replaceRegex = Pattern.compile(patt == null ? DEFAULT_PATTERN : patt);
|
||||
} catch (PatternSyntaxException e) {
|
||||
System.err.println("Invalid thumbnail replacement pattern: " + e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
if (description != null) {
|
||||
if (replaceRegex.matcher(description).matches()) {
|
||||
if (verbose) {
|
||||
System.out.println(description + " " + nsrc
|
||||
+ " matches pattern and is replacable.");
|
||||
System.out.format("%s %s matches pattern and is replacable.%n",
|
||||
description, nsrc);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (description.equals(bitstreamDescription)) {
|
||||
if (description.equals(getDescription())) {
|
||||
if (verbose) {
|
||||
System.out.println(bitstreamDescription + " " + nsrc
|
||||
+ " is replacable.");
|
||||
System.out.format("%s %s is replaceable.%n",
|
||||
getDescription(), nsrc);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
System.out.println("Custom Thumbnail exists for " + nsrc + " for item "
|
||||
+ item.getHandle() + ". Thumbnail will not be generated. ");
|
||||
System.out.format("Custom Thumbnail exists for %s for item %s. Thumbnail will not be generated.%n",
|
||||
nsrc, item.getHandle());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,8 @@ import java.io.InputStream;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* Filter image bitstreams, scaling the image to be within the bounds of
|
||||
@@ -80,13 +81,15 @@ public class JPEGFilter extends MediaFilter implements SelfRegisterInputFormats
|
||||
public InputStream getThumb(Item currentItem, BufferedImage buf, boolean verbose)
|
||||
throws Exception {
|
||||
// get config params
|
||||
float xmax = (float) ConfigurationManager
|
||||
final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
float xmax = (float) configurationService
|
||||
.getIntProperty("thumbnail.maxwidth");
|
||||
float ymax = (float) ConfigurationManager
|
||||
float ymax = (float) configurationService
|
||||
.getIntProperty("thumbnail.maxheight");
|
||||
boolean blurring = (boolean) ConfigurationManager
|
||||
boolean blurring = (boolean) configurationService
|
||||
.getBooleanProperty("thumbnail.blurring");
|
||||
boolean hqscaling = (boolean) ConfigurationManager
|
||||
boolean hqscaling = (boolean) configurationService
|
||||
.getBooleanProperty("thumbnail.hqscaling");
|
||||
|
||||
return getThumbDim(currentItem, buf, verbose, xmax, ymax, blurring, hqscaling, 0, 0, null);
|
||||
@@ -169,9 +172,11 @@ public class JPEGFilter extends MediaFilter implements SelfRegisterInputFormats
|
||||
g2d.drawImage(buf, 0, 0, (int) xsize, (int) ysize, null);
|
||||
|
||||
if (brandHeight != 0) {
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
Brand brand = new Brand((int) xsize, brandHeight, new Font(brandFont, Font.PLAIN, brandFontPoint), 5);
|
||||
BufferedImage brandImage = brand.create(ConfigurationManager.getProperty("webui.preview.brand"),
|
||||
ConfigurationManager.getProperty("webui.preview.brand.abbrev"),
|
||||
BufferedImage brandImage = brand.create(configurationService.getProperty("webui.preview.brand"),
|
||||
configurationService.getProperty("webui.preview.brand.abbrev"),
|
||||
currentItem == null ? "" : "hdl:" + currentItem.getHandle());
|
||||
|
||||
g2d.drawImage(brandImage, (int) 0, (int) ysize, (int) xsize, (int) 20, null);
|
||||
|
@@ -16,12 +16,11 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.MissingArgumentException;
|
||||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.OptionBuilder;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.dspace.app.mediafilter.factory.MediaFilterServiceFactory;
|
||||
import org.dspace.app.mediafilter.service.MediaFilterService;
|
||||
@@ -66,7 +65,7 @@ public class MediaFilterCLITool {
|
||||
System.setProperty("java.awt.headless", "true");
|
||||
|
||||
// create an options object and populate it
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
|
||||
int status = 0;
|
||||
|
||||
@@ -85,26 +84,30 @@ public class MediaFilterCLITool {
|
||||
options.addOption("h", "help", false, "help");
|
||||
|
||||
//create a "plugin" option (to specify specific MediaFilter plugins to run)
|
||||
OptionBuilder.withLongOpt("plugins");
|
||||
OptionBuilder.withValueSeparator(',');
|
||||
OptionBuilder.withDescription(
|
||||
"ONLY run the specified Media Filter plugin(s)\n" +
|
||||
"listed from '" + MEDIA_FILTER_PLUGINS_KEY + "' in dspace.cfg.\n" +
|
||||
"Separate multiple with a comma (,)\n" +
|
||||
"(e.g. MediaFilterManager -p \n\"Word Text Extractor\",\"PDF Text Extractor\")");
|
||||
Option pluginOption = OptionBuilder.create('p');
|
||||
pluginOption.setArgs(Option.UNLIMITED_VALUES); //unlimited number of args
|
||||
Option pluginOption = Option.builder("p")
|
||||
.longOpt("plugins")
|
||||
.hasArg()
|
||||
.hasArgs()
|
||||
.valueSeparator(',')
|
||||
.desc(
|
||||
"ONLY run the specified Media Filter plugin(s)\n" +
|
||||
"listed from '" + MEDIA_FILTER_PLUGINS_KEY + "' in dspace.cfg.\n" +
|
||||
"Separate multiple with a comma (,)\n" +
|
||||
"(e.g. MediaFilterManager -p \n\"Word Text Extractor\",\"PDF Text Extractor\")")
|
||||
.build();
|
||||
options.addOption(pluginOption);
|
||||
|
||||
//create a "skip" option (to specify communities/collections/items to skip)
|
||||
OptionBuilder.withLongOpt("skip");
|
||||
OptionBuilder.withValueSeparator(',');
|
||||
OptionBuilder.withDescription(
|
||||
"SKIP the bitstreams belonging to identifier\n" +
|
||||
"Separate multiple identifiers with a comma (,)\n" +
|
||||
"(e.g. MediaFilterManager -s \n 123456789/34,123456789/323)");
|
||||
Option skipOption = OptionBuilder.create('s');
|
||||
skipOption.setArgs(Option.UNLIMITED_VALUES); //unlimited number of args
|
||||
Option skipOption = Option.builder("s")
|
||||
.longOpt("skip")
|
||||
.hasArg()
|
||||
.hasArgs()
|
||||
.valueSeparator(',')
|
||||
.desc(
|
||||
"SKIP the bitstreams belonging to identifier\n" +
|
||||
"Separate multiple identifiers with a comma (,)\n" +
|
||||
"(e.g. MediaFilterManager -s \n 123456789/34,123456789/323)")
|
||||
.build();
|
||||
options.addOption(skipOption);
|
||||
|
||||
boolean isVerbose = false;
|
||||
@@ -179,7 +182,7 @@ public class MediaFilterCLITool {
|
||||
mediaFilterService.setMax2Process(max2Process);
|
||||
|
||||
//initialize an array of our enabled filters
|
||||
List<FormatFilter> filterList = new ArrayList<FormatFilter>();
|
||||
List<FormatFilter> filterList = new ArrayList<>();
|
||||
|
||||
//set up each filter
|
||||
for (int i = 0; i < filterNames.length; i++) {
|
||||
|
@@ -21,7 +21,8 @@ import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
|
||||
import org.apache.pdfbox.text.PDFTextStripper;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/*
|
||||
*
|
||||
@@ -72,8 +73,10 @@ public class PDFFilter extends MediaFilter {
|
||||
@Override
|
||||
public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose)
|
||||
throws Exception {
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
try {
|
||||
boolean useTemporaryFile = ConfigurationManager.getBooleanProperty("pdffilter.largepdfs", false);
|
||||
boolean useTemporaryFile = configurationService.getBooleanProperty("pdffilter.largepdfs", false);
|
||||
|
||||
// get input stream from bitstream
|
||||
// pass to filter, get string back
|
||||
@@ -124,7 +127,7 @@ public class PDFFilter extends MediaFilter {
|
||||
}
|
||||
} catch (OutOfMemoryError oome) {
|
||||
log.error("Error parsing PDF document " + oome.getMessage(), oome);
|
||||
if (!ConfigurationManager.getBooleanProperty("pdffilter.skiponmemoryexception", false)) {
|
||||
if (!configurationService.getBooleanProperty("pdffilter.skiponmemoryexception", false)) {
|
||||
throw oome;
|
||||
}
|
||||
}
|
||||
|
@@ -17,9 +17,9 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.crosswalk.CrosswalkException;
|
||||
@@ -175,7 +175,7 @@ public class Packager {
|
||||
"flag can be used if you want to save (pipe) a report of all changes to a file, and " +
|
||||
"therefore need to bypass all user interaction.");
|
||||
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
CommandLine line = parser.parse(options, argv);
|
||||
|
||||
String sourceFile = null;
|
||||
|
@@ -10,13 +10,13 @@ package org.dspace.app.requestitem;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.I18nUtil;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -30,9 +30,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* @author Peter Dietz
|
||||
*/
|
||||
public class RequestItemHelpdeskStrategy extends RequestItemSubmitterStrategy {
|
||||
|
||||
private Logger log = org.apache.logging.log4j.LogManager.getLogger(RequestItemHelpdeskStrategy.class);
|
||||
|
||||
@Autowired(required = true)
|
||||
protected EPersonService ePersonService;
|
||||
|
||||
@@ -41,9 +38,11 @@ public class RequestItemHelpdeskStrategy extends RequestItemSubmitterStrategy {
|
||||
|
||||
@Override
|
||||
public RequestItemAuthor getRequestItemAuthor(Context context, Item item) throws SQLException {
|
||||
boolean helpdeskOverridesSubmitter = ConfigurationManager
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
boolean helpdeskOverridesSubmitter = configurationService
|
||||
.getBooleanProperty("request.item.helpdesk.override", false);
|
||||
String helpDeskEmail = ConfigurationManager.getProperty("mail.helpdesk");
|
||||
String helpDeskEmail = configurationService.getProperty("mail.helpdesk");
|
||||
|
||||
if (helpdeskOverridesSubmitter && StringUtils.isNotBlank(helpDeskEmail)) {
|
||||
return getHelpDeskPerson(context, helpDeskEmail);
|
||||
@@ -64,10 +63,8 @@ public class RequestItemHelpdeskStrategy extends RequestItemSubmitterStrategy {
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
public RequestItemAuthor getHelpDeskPerson(Context context, String helpDeskEmail) throws SQLException {
|
||||
EPerson helpdeskEPerson = null;
|
||||
|
||||
context.turnOffAuthorisationSystem();
|
||||
helpdeskEPerson = ePersonService.findByEmail(context, helpDeskEmail);
|
||||
EPerson helpdeskEPerson = ePersonService.findByEmail(context, helpDeskEmail);
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
if (helpdeskEPerson != null) {
|
||||
|
@@ -16,8 +16,10 @@ import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
public class SHERPAService {
|
||||
private CloseableHttpClient client = null;
|
||||
@@ -29,7 +31,7 @@ public class SHERPAService {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(SHERPAService.class);
|
||||
private static final Logger log = LogManager.getLogger(SHERPAService.class);
|
||||
|
||||
public SHERPAService() {
|
||||
HttpClientBuilder builder = HttpClientBuilder.create();
|
||||
@@ -43,8 +45,10 @@ public class SHERPAService {
|
||||
|
||||
|
||||
public SHERPAResponse searchByJournalISSN(String query) {
|
||||
String endpoint = ConfigurationManager.getProperty("sherpa.romeo.url");
|
||||
String apiKey = ConfigurationManager.getProperty("sherpa.romeo.apikey");
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String endpoint = configurationService.getProperty("sherpa.romeo.url");
|
||||
String apiKey = configurationService.getProperty("sherpa.romeo.apikey");
|
||||
|
||||
HttpGet method = null;
|
||||
SHERPAResponse sherpaResponse = null;
|
||||
|
@@ -23,10 +23,10 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -53,7 +53,7 @@ public class GenerateSitemaps {
|
||||
/**
|
||||
* Logger
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(GenerateSitemaps.class);
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(GenerateSitemaps.class);
|
||||
|
||||
private static final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
||||
private static final CollectionService collectionService =
|
||||
@@ -70,7 +70,7 @@ public class GenerateSitemaps {
|
||||
public static void main(String[] args) throws Exception {
|
||||
final String usage = GenerateSitemaps.class.getCanonicalName();
|
||||
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
HelpFormatter hf = new HelpFormatter();
|
||||
|
||||
Options options = new Options();
|
||||
|
@@ -16,10 +16,11 @@ import java.util.Properties;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* This class allows the running of the DSpace statistic tools
|
||||
@@ -56,7 +57,7 @@ public class CreateStatReport {
|
||||
/**
|
||||
* File suffix for log files
|
||||
*/
|
||||
private static String outputSuffix = ".dat";
|
||||
private static final String outputSuffix = ".dat";
|
||||
|
||||
/**
|
||||
* User context
|
||||
@@ -66,9 +67,6 @@ public class CreateStatReport {
|
||||
/**
|
||||
* the config file from which to configure the analyser
|
||||
*/
|
||||
private static String configFile = ConfigurationManager.getProperty("dspace.dir") +
|
||||
File.separator + "config" + File.separator +
|
||||
"dstat.cfg";
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -81,8 +79,12 @@ public class CreateStatReport {
|
||||
* Usage: java CreateStatReport -r <statistic to run>
|
||||
*/
|
||||
public static void main(String[] argv) throws Exception {
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
// Open the statistics config file
|
||||
final String configFile = configurationService.getProperty("dspace.dir")
|
||||
+ File.separator + "config" + File.separator + "dstat.cfg";
|
||||
FileInputStream fis = new java.io.FileInputStream(new File(configFile));
|
||||
Properties config = new Properties();
|
||||
config.load(fis);
|
||||
@@ -108,11 +110,11 @@ public class CreateStatReport {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//get paths to directories
|
||||
outputLogDirectory = ConfigurationManager.getProperty("log.report.dir") + File.separator;
|
||||
outputReportDirectory = ConfigurationManager.getProperty("report.dir") + File.separator;
|
||||
outputLogDirectory = configurationService.getProperty("log.report.dir") + File.separator;
|
||||
outputReportDirectory = configurationService.getProperty("report.dir") + File.separator;
|
||||
|
||||
//read in command line variable to determine which statistic to run
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
Options options = new Options();
|
||||
options.addOption("r", "report", true, "report");
|
||||
CommandLine line = parser.parse(options, argv);
|
||||
@@ -405,6 +407,5 @@ public class CreateStatReport {
|
||||
System.out.println(
|
||||
"Available: <stat-initial> <stat-general> <stat-monthly> <stat-report-initial> <stat-report-general> " +
|
||||
"<stat-report-monthly>");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,8 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* This class provides HTML reports for the ReportGenerator class
|
||||
@@ -34,7 +35,7 @@ public class HTMLReport implements Report {
|
||||
/**
|
||||
* a list of the statistic blocks being managed by this class
|
||||
*/
|
||||
private List<Statistics> blocks = new ArrayList<Statistics>();
|
||||
private final List<Statistics> blocks = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* the title for the page
|
||||
@@ -59,16 +60,23 @@ public class HTMLReport implements Report {
|
||||
/**
|
||||
* the output file to which to write aggregation data
|
||||
*/
|
||||
private String output = ConfigurationManager.getProperty("dspace.dir") +
|
||||
File.separator + "log" + File.separator + "report";
|
||||
private String output;
|
||||
|
||||
/**
|
||||
* constructor for HTML reporting
|
||||
* Output file path is set to {@code ${dspace.dir}/log/report}.
|
||||
*/
|
||||
public HTMLReport() {
|
||||
// empty constructor
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
output = configurationService.getProperty("dspace.dir")
|
||||
+ File.separator + "log" + File.separator + "report";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a non-default output file path.
|
||||
*
|
||||
* @param newOutput new path to the report.
|
||||
*/
|
||||
public void setOutput(String newOutput) {
|
||||
if (newOutput != null) {
|
||||
output = newOutput;
|
||||
@@ -82,7 +90,7 @@ public class HTMLReport implements Report {
|
||||
*/
|
||||
@Override
|
||||
public String render() {
|
||||
StringBuffer frag = new StringBuffer();
|
||||
StringBuilder frag = new StringBuilder();
|
||||
|
||||
// get the page headings
|
||||
frag.append(header(pageTitle));
|
||||
@@ -140,7 +148,7 @@ public class HTMLReport implements Report {
|
||||
* @return an HTML string providing internal page navigation
|
||||
*/
|
||||
public String navigation() {
|
||||
StringBuffer frag = new StringBuffer();
|
||||
StringBuilder frag = new StringBuilder();
|
||||
|
||||
frag.append("<div class=\"reportNavigation\">");
|
||||
frag.append("<a href=\"#general_overview\">General Overview</a>");
|
||||
@@ -173,7 +181,6 @@ public class HTMLReport implements Report {
|
||||
@Override
|
||||
public void addBlock(Statistics stat) {
|
||||
blocks.add(stat);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +214,7 @@ public class HTMLReport implements Report {
|
||||
*/
|
||||
@Override
|
||||
public String dateRange() {
|
||||
StringBuffer frag = new StringBuffer();
|
||||
StringBuilder frag = new StringBuilder();
|
||||
DateFormat df = DateFormat.getDateInstance();
|
||||
|
||||
frag.append("<div class=\"reportDate\">");
|
||||
@@ -255,7 +262,6 @@ public class HTMLReport implements Report {
|
||||
if (pageTitle == null) {
|
||||
pageTitle = mainTitle;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +286,7 @@ public class HTMLReport implements Report {
|
||||
// FIXME: this need to be figured out to integrate nicely into the
|
||||
// whole JSTL thing, but for the moment it's just going to deliver
|
||||
// some styles
|
||||
StringBuffer frag = new StringBuffer();
|
||||
StringBuilder frag = new StringBuilder();
|
||||
|
||||
frag.append("<style type=\"text/css\">\n");
|
||||
frag.append("body { font-family: Arial, Helvetica, sans-serif }");
|
||||
@@ -334,7 +340,7 @@ public class HTMLReport implements Report {
|
||||
*/
|
||||
@Override
|
||||
public String statBlock(Statistics content) {
|
||||
StringBuffer frag = new StringBuffer();
|
||||
StringBuilder frag = new StringBuilder();
|
||||
Stat[] stats = content.getStats();
|
||||
|
||||
// start the table
|
||||
@@ -345,14 +351,14 @@ public class HTMLReport implements Report {
|
||||
frag.append("\t<tr>\n");
|
||||
frag.append("\t\t<th>\n");
|
||||
if (content.getStatName() != null) {
|
||||
frag.append("\t\t\t" + content.getStatName() + "\n");
|
||||
frag.append("\t\t\t").append(content.getStatName()).append("\n");
|
||||
} else {
|
||||
frag.append("\t\t\t \n");
|
||||
}
|
||||
frag.append("\t\t</th>\n");
|
||||
frag.append("\t\t<th>\n");
|
||||
if (content.getResultName() != null) {
|
||||
frag.append("\t\t\t" + content.getResultName() + "\n");
|
||||
frag.append("\t\t\t").append(content.getResultName()).append("\n");
|
||||
} else {
|
||||
frag.append("\t\t\t \n");
|
||||
}
|
||||
@@ -370,10 +376,10 @@ public class HTMLReport implements Report {
|
||||
style = "reportEvenRow";
|
||||
}
|
||||
|
||||
frag.append("\t<tr class=\"" + style + "\">\n\t\t<td>\n");
|
||||
frag.append("\t<tr class=\"").append(style).append("\">\n\t\t<td>\n");
|
||||
frag.append("\t\t\t");
|
||||
if (stats[i].getReference() != null) {
|
||||
frag.append("<a href=\"" + stats[i].getReference() + "\" ");
|
||||
frag.append("<a href=\"").append(stats[i].getReference()).append("\" ");
|
||||
frag.append("target=\"_blank\">");
|
||||
}
|
||||
frag.append(this.clean(stats[i].getKey()));
|
||||
@@ -405,9 +411,9 @@ public class HTMLReport implements Report {
|
||||
@Override
|
||||
public String floorInfo(int floor) {
|
||||
if (floor > 0) {
|
||||
StringBuffer frag = new StringBuffer();
|
||||
StringBuilder frag = new StringBuilder();
|
||||
frag.append("<div class=\"reportFloor\">");
|
||||
frag.append("(more than " + ReportTools.numberFormat(floor) + " times)");
|
||||
frag.append("(more than ").append(ReportTools.numberFormat(floor)).append(" times)");
|
||||
frag.append("</div>\n");
|
||||
return frag.toString();
|
||||
} else {
|
||||
@@ -419,12 +425,12 @@ public class HTMLReport implements Report {
|
||||
* output the explanation of the report block in HTML format
|
||||
*
|
||||
* @param explanation some text explaining the coming report block
|
||||
* @return a string containing an explanaton HTML formatted
|
||||
* @return a string containing an explanation HTML formatted
|
||||
*/
|
||||
@Override
|
||||
public String blockExplanation(String explanation) {
|
||||
if (explanation != null) {
|
||||
StringBuffer frag = new StringBuffer();
|
||||
StringBuilder frag = new StringBuilder();
|
||||
frag.append("<div class=\"reportExplanation\">");
|
||||
frag.append(explanation);
|
||||
frag.append("</div>\n\n");
|
||||
|
@@ -30,13 +30,14 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.core.Utils;
|
||||
import org.dspace.discovery.DiscoverQuery;
|
||||
import org.dspace.discovery.SearchServiceException;
|
||||
import org.dspace.discovery.SearchUtils;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* This class performs all the actual analysis of a given set of DSpace log
|
||||
@@ -268,7 +269,7 @@ public class LogAnalyser {
|
||||
/**
|
||||
* the log directory to be analysed
|
||||
*/
|
||||
private static String logDir = ConfigurationManager.getProperty("log.report.dir");
|
||||
private static String logDir;
|
||||
|
||||
/**
|
||||
* the regex to describe the file name format
|
||||
@@ -276,16 +277,14 @@ public class LogAnalyser {
|
||||
private static String fileTemplate = "dspace\\.log.*";
|
||||
|
||||
/**
|
||||
* the config file from which to configure the analyser
|
||||
* the configuration file from which to configure the analyser
|
||||
*/
|
||||
private static String configFile = ConfigurationManager.getProperty("dspace.dir") +
|
||||
File.separator + "config" + File.separator +
|
||||
"dstat.cfg";
|
||||
private static String configFile;
|
||||
|
||||
/**
|
||||
* the output file to which to write aggregation data
|
||||
*/
|
||||
private static String outFile = ConfigurationManager.getProperty("log.report.dir") + File.separator + "dstat.dat";
|
||||
private static String outFile;
|
||||
|
||||
/**
|
||||
* the starting date of the report
|
||||
@@ -582,9 +581,11 @@ public class LogAnalyser {
|
||||
}
|
||||
|
||||
// now do the host name and url lookup
|
||||
hostName = Utils.getHostName(ConfigurationManager.getProperty("dspace.ui.url"));
|
||||
name = ConfigurationManager.getProperty("dspace.name").trim();
|
||||
url = ConfigurationManager.getProperty("dspace.ui.url").trim();
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
hostName = Utils.getHostName(configurationService.getProperty("dspace.ui.url"));
|
||||
name = configurationService.getProperty("dspace.name").trim();
|
||||
url = configurationService.getProperty("dspace.ui.url").trim();
|
||||
if ((url != null) && (!url.endsWith("/"))) {
|
||||
url = url + "/";
|
||||
}
|
||||
@@ -622,8 +623,13 @@ public class LogAnalyser {
|
||||
String myConfigFile, String myOutFile,
|
||||
Date myStartDate, Date myEndDate,
|
||||
boolean myLookUp) {
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
if (myLogDir != null) {
|
||||
logDir = myLogDir;
|
||||
} else {
|
||||
logDir = configurationService.getProperty("log.report.dir");
|
||||
}
|
||||
|
||||
if (myFileTemplate != null) {
|
||||
@@ -632,6 +638,9 @@ public class LogAnalyser {
|
||||
|
||||
if (myConfigFile != null) {
|
||||
configFile = myConfigFile;
|
||||
} else {
|
||||
configFile = configurationService.getProperty("dspace.dir")
|
||||
+ File.separator + "config" + File.separator + "dstat.cfg";
|
||||
}
|
||||
|
||||
if (myStartDate != null) {
|
||||
@@ -644,9 +653,9 @@ public class LogAnalyser {
|
||||
|
||||
if (myOutFile != null) {
|
||||
outFile = myOutFile;
|
||||
} else {
|
||||
outFile = configurationService.getProperty("log.report.dir") + File.separator + "dstat.dat";
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -657,7 +666,7 @@ public class LogAnalyser {
|
||||
*/
|
||||
public static String createOutput() {
|
||||
// start a string buffer to hold the final output
|
||||
StringBuffer summary = new StringBuffer();
|
||||
StringBuilder summary = new StringBuilder();
|
||||
|
||||
// define an iterator that will be used to go over the hashmap keys
|
||||
Iterator<String> keys = null;
|
||||
@@ -820,7 +829,7 @@ public class LogAnalyser {
|
||||
*/
|
||||
public static void setRegex(String fileTemplate) {
|
||||
// build the exclude characters regular expression
|
||||
StringBuffer charRegEx = new StringBuffer();
|
||||
StringBuilder charRegEx = new StringBuilder();
|
||||
charRegEx.append("[");
|
||||
for (int i = 0; i < excludeChars.size(); i++) {
|
||||
charRegEx.append("\\").append(excludeChars.get(i));
|
||||
@@ -864,7 +873,7 @@ public class LogAnalyser {
|
||||
logRegex = Pattern.compile(fileTemplate);
|
||||
|
||||
// set up the pattern for matching any of the query types
|
||||
StringBuffer typeRXString = new StringBuffer();
|
||||
StringBuilder typeRXString = new StringBuilder();
|
||||
typeRXString.append("(");
|
||||
for (int i = 0; i < excludeTypes.size(); i++) {
|
||||
if (i > 0) {
|
||||
@@ -876,7 +885,7 @@ public class LogAnalyser {
|
||||
typeRX = Pattern.compile(typeRXString.toString());
|
||||
|
||||
// set up the pattern for matching any of the words to exclude
|
||||
StringBuffer wordRXString = new StringBuffer();
|
||||
StringBuilder wordRXString = new StringBuilder();
|
||||
wordRXString.append("(");
|
||||
for (int i = 0; i < excludeWords.size(); i++) {
|
||||
if (i > 0) {
|
||||
@@ -890,8 +899,6 @@ public class LogAnalyser {
|
||||
}
|
||||
wordRXString.append(")");
|
||||
wordRX = Pattern.compile(wordRXString.toString());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -920,18 +927,18 @@ public class LogAnalyser {
|
||||
*/
|
||||
public static void readConfig(String configFile) throws IOException {
|
||||
//instantiate aggregators
|
||||
actionAggregator = new HashMap<String, Integer>();
|
||||
searchAggregator = new HashMap<String, Integer>();
|
||||
userAggregator = new HashMap<String, Integer>();
|
||||
itemAggregator = new HashMap<String, Integer>();
|
||||
archiveStats = new HashMap<String, Integer>();
|
||||
actionAggregator = new HashMap<>();
|
||||
searchAggregator = new HashMap<>();
|
||||
userAggregator = new HashMap<>();
|
||||
itemAggregator = new HashMap<>();
|
||||
archiveStats = new HashMap<>();
|
||||
|
||||
//instantiate lists
|
||||
generalSummary = new ArrayList<String>();
|
||||
excludeWords = new ArrayList<String>();
|
||||
excludeTypes = new ArrayList<String>();
|
||||
excludeChars = new ArrayList<String>();
|
||||
itemTypes = new ArrayList<String>();
|
||||
generalSummary = new ArrayList<>();
|
||||
excludeWords = new ArrayList<>();
|
||||
excludeTypes = new ArrayList<>();
|
||||
excludeChars = new ArrayList<>();
|
||||
itemTypes = new ArrayList<>();
|
||||
|
||||
// prepare our standard file readers and buffered readers
|
||||
FileReader fr = null;
|
||||
@@ -1002,8 +1009,6 @@ public class LogAnalyser {
|
||||
// close the inputs
|
||||
br.close();
|
||||
fr.close();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -32,10 +32,11 @@ import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* This class performs the action of coordinating a usage report being
|
||||
@@ -161,7 +162,7 @@ public class ReportGenerator {
|
||||
/**
|
||||
* pattern that matches an unqualified aggregator property
|
||||
*/
|
||||
private static Pattern real = Pattern.compile("^(.+)=(.+)");
|
||||
private static final Pattern real = Pattern.compile("^(.+)=(.+)");
|
||||
|
||||
//////////////////////////
|
||||
// Miscellaneous variables
|
||||
@@ -189,11 +190,12 @@ public class ReportGenerator {
|
||||
/**
|
||||
* the log file action to human readable action map
|
||||
*/
|
||||
private static String map = ConfigurationManager.getProperty("dspace.dir") +
|
||||
File.separator + "config" + File.separator + "dstat.map";
|
||||
private static String map;
|
||||
|
||||
private static final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
private static final HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||
private static final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -268,6 +270,9 @@ public class ReportGenerator {
|
||||
throws Exception, SQLException {
|
||||
if (myMap != null) {
|
||||
map = myMap;
|
||||
} else {
|
||||
map = configurationService.getProperty("dspace.dir")
|
||||
+ File.separator + "config" + File.separator + "dstat.map";
|
||||
}
|
||||
|
||||
// create the relevant report type
|
||||
@@ -302,15 +307,15 @@ public class ReportGenerator {
|
||||
startTime = new GregorianCalendar();
|
||||
|
||||
/** instantiate aggregators */
|
||||
actionAggregator = new HashMap<String, String>();
|
||||
searchAggregator = new HashMap<String, String>();
|
||||
userAggregator = new HashMap<String, String>();
|
||||
itemAggregator = new HashMap<String, String>();
|
||||
archiveStats = new HashMap<String, String>();
|
||||
actionMap = new HashMap<String, String>();
|
||||
actionAggregator = new HashMap<>();
|
||||
searchAggregator = new HashMap<>();
|
||||
userAggregator = new HashMap<>();
|
||||
itemAggregator = new HashMap<>();
|
||||
archiveStats = new HashMap<>();
|
||||
actionMap = new HashMap<>();
|
||||
|
||||
/** instantite lists */
|
||||
generalSummary = new ArrayList<String>();
|
||||
/** instantiate lists */
|
||||
generalSummary = new ArrayList<>();
|
||||
|
||||
// set the parameters for this analysis
|
||||
setParameters(myInput);
|
||||
@@ -486,8 +491,6 @@ public class ReportGenerator {
|
||||
report.addBlock(process);
|
||||
|
||||
report.render();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -612,8 +615,6 @@ public class ReportGenerator {
|
||||
if (myInput != null) {
|
||||
input = myInput;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -768,9 +769,9 @@ public class ReportGenerator {
|
||||
List<MetadataValue> author = itemService
|
||||
.getMetadata(item, MetadataSchemaEnum.DC.getName(), "contributor", "author", Item.ANY);
|
||||
|
||||
StringBuffer authors = new StringBuffer();
|
||||
StringBuilder authors = new StringBuilder();
|
||||
if (author.size() > 0) {
|
||||
authors.append("(" + author.get(0).getValue());
|
||||
authors.append("(").append(author.get(0).getValue());
|
||||
}
|
||||
if (author.size() > 1) {
|
||||
authors.append(" et al");
|
||||
|
@@ -22,7 +22,8 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* Helper class for loading the analysis / report files from the reports directory
|
||||
@@ -219,8 +220,8 @@ public class StatisticsLoader {
|
||||
}
|
||||
|
||||
// Create new maps for the monthly analysis / reports
|
||||
Map<String, StatsFile> newMonthlyAnalysis = new HashMap<String, StatsFile>();
|
||||
Map<String, StatsFile> newMonthlyReports = new HashMap<String, StatsFile>();
|
||||
Map<String, StatsFile> newMonthlyAnalysis = new HashMap<>();
|
||||
Map<String, StatsFile> newMonthlyReports = new HashMap<>();
|
||||
|
||||
StatsFile newGeneralAnalysis = null;
|
||||
StatsFile newGeneralReport = null;
|
||||
@@ -320,7 +321,9 @@ public class StatisticsLoader {
|
||||
* @return array of files
|
||||
*/
|
||||
private static File[] getAnalysisAndReportFileList() {
|
||||
File reportDir = new File(ConfigurationManager.getProperty("log.report.dir"));
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
File reportDir = new File(configurationService.getProperty("log.report.dir"));
|
||||
if (reportDir != null) {
|
||||
return reportDir.listFiles(new AnalysisAndReportFilter());
|
||||
}
|
||||
|
@@ -14,8 +14,9 @@ import java.util.Date;
|
||||
|
||||
import org.dspace.app.util.factory.UtilServiceFactory;
|
||||
import org.dspace.app.util.service.WebAppService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -57,7 +58,9 @@ abstract public class AbstractDSpaceWebapp
|
||||
|
||||
started = new Date();
|
||||
|
||||
url = ConfigurationManager.getProperty("dspace.ui.url");
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
url = configurationService.getProperty("dspace.ui.url");
|
||||
if (null == url) {
|
||||
throw new IllegalStateException("dspace.ui.url is undefined");
|
||||
}
|
||||
|
@@ -16,8 +16,9 @@ import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* Utility class for lists of collections.
|
||||
@@ -55,8 +56,11 @@ public class CollectionDropDown {
|
||||
* @return Full path to the collection (truncated)
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
public static String collectionPath(Context context, Collection col, int maxchars) throws SQLException {
|
||||
String separator = ConfigurationManager.getProperty("subcommunity.separator");
|
||||
public static String collectionPath(Context context, Collection col, int maxchars)
|
||||
throws SQLException {
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String separator = configurationService.getProperty("subcommunity.separator");
|
||||
if (separator == null) {
|
||||
separator = " > ";
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.dspace.app.util;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
@@ -27,13 +28,11 @@ public class DSpaceWebappListener implements ServletContextListener {
|
||||
|
||||
try {
|
||||
Class webappClass = Class.forName("org.dspace.utils.DSpaceWebapp");
|
||||
webApp = (AbstractDSpaceWebapp) webappClass.newInstance();
|
||||
webApp = (AbstractDSpaceWebapp) webappClass.getDeclaredConstructor().newInstance();
|
||||
webApp.register();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
event.getServletContext().log("Can't create webapp MBean: " + ex.getMessage());
|
||||
} catch (InstantiationException ex) {
|
||||
event.getServletContext().log("Can't create webapp MBean: " + ex.getMessage());
|
||||
} catch (IllegalAccessException ex) {
|
||||
} catch (ClassNotFoundException | InstantiationException
|
||||
| IllegalAccessException | IllegalArgumentException
|
||||
| NoSuchMethodException | InvocationTargetException ex) {
|
||||
event.getServletContext().log("Can't create webapp MBean: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
@@ -26,6 +26,7 @@ import java.util.Properties;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||
import org.dspace.content.Bitstream;
|
||||
@@ -36,10 +37,11 @@ import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Element;
|
||||
|
||||
/**
|
||||
@@ -51,7 +53,7 @@ import org.jdom.Element;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class GoogleMetadata {
|
||||
|
||||
private final static Logger log = org.apache.logging.log4j.LogManager.getLogger(GoogleMetadata.class);
|
||||
private final static Logger log = LogManager.getLogger(GoogleMetadata.class);
|
||||
|
||||
protected static final String GOOGLE_PREFIX = "google.";
|
||||
|
||||
@@ -62,7 +64,7 @@ public class GoogleMetadata {
|
||||
protected String itemURL;
|
||||
|
||||
// Configuration keys and fields
|
||||
protected static Map<String, String> googleScholarSettings = new HashMap<String, String>();
|
||||
protected static Map<String, String> googleScholarSettings = new HashMap<>();
|
||||
|
||||
// Google field names (e.g. citation_fieldname) and formatted metadata
|
||||
// values
|
||||
@@ -132,35 +134,39 @@ public class GoogleMetadata {
|
||||
|
||||
private static GoogleBitstreamComparator googleBitstreamComparator = null;
|
||||
|
||||
// Load configured fields from google-metadata.properties
|
||||
static {
|
||||
private final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
File loadedFile = null;
|
||||
URL url = null;
|
||||
InputStream is = null;
|
||||
|
||||
String googleConfigFile = ConfigurationManager
|
||||
/**
|
||||
* Load configured fields from google-metadata.properties.
|
||||
*/
|
||||
private void loadGoogleScholarSettings()
|
||||
throws MalformedURLException, IOException {
|
||||
String googleConfigFile = configurationService
|
||||
.getProperty("google-metadata.config");
|
||||
log.info("Using [" + googleConfigFile
|
||||
+ "] for Google Metadata configuration");
|
||||
log.info("Using [{}] for Google Metadata configuration", googleConfigFile);
|
||||
|
||||
loadedFile = new File(googleConfigFile);
|
||||
File loadedFile = new File(googleConfigFile);
|
||||
URL url;
|
||||
try {
|
||||
url = loadedFile.toURL();
|
||||
url = loadedFile.toURI().toURL();
|
||||
|
||||
} catch (MalformedURLException mux) {
|
||||
log.error("Can't find Google Metadata configuration file: "
|
||||
+ googleConfigFile, mux);
|
||||
log.error("Can't find Google Metadata configuration file: {}",
|
||||
googleConfigFile, mux);
|
||||
throw mux;
|
||||
}
|
||||
|
||||
Properties properties = new Properties();
|
||||
InputStream is;
|
||||
try {
|
||||
is = url.openStream();
|
||||
properties.load(is);
|
||||
|
||||
} catch (IOException iox) {
|
||||
log.error("Could not read Google Metadata configuration file: "
|
||||
+ googleConfigFile, iox);
|
||||
log.error("Could not read Google Metadata configuration file: {}",
|
||||
googleConfigFile, iox);
|
||||
throw iox;
|
||||
}
|
||||
|
||||
Enumeration propertyNames = properties.propertyNames();
|
||||
@@ -180,19 +186,21 @@ public class GoogleMetadata {
|
||||
}
|
||||
}
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
logConfiguration();
|
||||
}
|
||||
logConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump Metadata field mapping to log
|
||||
*/
|
||||
public static void logConfiguration() {
|
||||
if (!log.isDebugEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.debug("Google Metadata Configuration Mapping:");
|
||||
|
||||
for (String name : googleScholarSettings.keySet()) {
|
||||
log.debug(" " + name + " => " + googleScholarSettings.get(name));
|
||||
log.debug(" {} => {}", name, googleScholarSettings.get(name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,9 +210,14 @@ public class GoogleMetadata {
|
||||
*
|
||||
* @param context context
|
||||
* @param item The item being viewed to extract metadata from
|
||||
* @throws SQLException if database error
|
||||
* @throws SQLException if database error.
|
||||
* @throws java.io.IOException passed through.
|
||||
*/
|
||||
public GoogleMetadata(Context context, Item item) throws SQLException {
|
||||
public GoogleMetadata(Context context, Item item)
|
||||
throws SQLException, IOException {
|
||||
if (googleScholarSettings.isEmpty()) {
|
||||
loadGoogleScholarSettings();
|
||||
}
|
||||
|
||||
// Hold onto the item in case we need to refresh a stale parse
|
||||
this.item = item;
|
||||
@@ -336,7 +349,7 @@ public class GoogleMetadata {
|
||||
int optionMatches = 0;
|
||||
String[] components;
|
||||
List<MetadataValue> values;
|
||||
ArrayList<MetadataValue> resolvedFields = new ArrayList<MetadataValue>();
|
||||
ArrayList<MetadataValue> resolvedFields = new ArrayList<>();
|
||||
|
||||
for (String field : optionFields) {
|
||||
|
||||
@@ -399,8 +412,8 @@ public class GoogleMetadata {
|
||||
*/
|
||||
protected ArrayList<ArrayList<String>> parseOptions(String configFilter) {
|
||||
|
||||
ArrayList<String> options = new ArrayList<String>();
|
||||
ArrayList<ArrayList<String>> parsedOptions = new ArrayList<ArrayList<String>>();
|
||||
ArrayList<String> options = new ArrayList<>();
|
||||
ArrayList<ArrayList<String>> parsedOptions = new ArrayList<>();
|
||||
|
||||
if (null == configFilter || configFilter.equals("")) {
|
||||
return null;
|
||||
@@ -414,7 +427,7 @@ public class GoogleMetadata {
|
||||
options.add(option.trim());
|
||||
}
|
||||
} else {
|
||||
options = new ArrayList<String>();
|
||||
options = new ArrayList<>();
|
||||
options.add(configFilter);
|
||||
}
|
||||
|
||||
@@ -426,12 +439,12 @@ public class GoogleMetadata {
|
||||
for (String option : options) {
|
||||
|
||||
ArrayList<String> fields;
|
||||
parsedFields = new ArrayList<String>();
|
||||
parsedFields = new ArrayList<>();
|
||||
|
||||
if (option.contains(",")) {
|
||||
fields = parseFields(option);
|
||||
} else {
|
||||
fields = new ArrayList<String>();
|
||||
fields = new ArrayList<>();
|
||||
fields.add(option);
|
||||
}
|
||||
|
||||
@@ -472,7 +485,7 @@ public class GoogleMetadata {
|
||||
*/
|
||||
protected ArrayList<String> parseFields(String configString) {
|
||||
|
||||
ArrayList<String> fields = new ArrayList<String>();
|
||||
ArrayList<String> fields = new ArrayList<>();
|
||||
|
||||
for (String field : configString.split("\\,")) {
|
||||
fields.add(field.trim());
|
||||
@@ -523,7 +536,7 @@ public class GoogleMetadata {
|
||||
List<MetadataValue> allMD = itemService.getMetadata(item, components[0], components[1],
|
||||
components[2], Item.ANY);
|
||||
|
||||
ArrayList<String> expandedDC = new ArrayList<String>();
|
||||
ArrayList<String> expandedDC = new ArrayList<>();
|
||||
for (MetadataValue v : allMD) {
|
||||
|
||||
// De-dup multiple occurrences of field names in item
|
||||
@@ -558,7 +571,7 @@ public class GoogleMetadata {
|
||||
MetadataSchema metadataSchema = v.getMetadataField().getMetadataSchema();
|
||||
name.append(metadataSchema.getName()).append(".").append(metadataField.getElement());
|
||||
if (null != metadataField.getQualifier()) {
|
||||
name.append("." + metadataField.getQualifier());
|
||||
name.append(".").append(metadataField.getQualifier());
|
||||
}
|
||||
|
||||
return name.toString();
|
||||
@@ -687,7 +700,7 @@ public class GoogleMetadata {
|
||||
* @return List of elements
|
||||
*/
|
||||
public List<Element> disseminateList() {
|
||||
List<Element> metas = new ArrayList<Element>();
|
||||
List<Element> metas = new ArrayList<>();
|
||||
|
||||
for (Entry<String, String> m : getMappings()) {
|
||||
Element e = new Element("meta");
|
||||
@@ -889,7 +902,7 @@ public class GoogleMetadata {
|
||||
Bitstream bitstream = findLinkableFulltext(item);
|
||||
if (bitstream != null) {
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(ConfigurationManager.getProperty("dspace.ui.url"));
|
||||
path.append(configurationService.getProperty("dspace.ui.url"));
|
||||
|
||||
if (item.getHandle() != null) {
|
||||
path.append("/bitstream/");
|
||||
@@ -1075,7 +1088,7 @@ public class GoogleMetadata {
|
||||
// FIXME: Shouldn't have to parse identifiers for every identification.
|
||||
|
||||
ArrayList<ArrayList<String>> options = parseOptions(dConfig);
|
||||
HashMap<String, ArrayList<String>> mdPairs = new HashMap<String, ArrayList<String>>();
|
||||
HashMap<String, ArrayList<String>> mdPairs = new HashMap<>();
|
||||
|
||||
// Parse field/value pairs from field identifier string
|
||||
for (ArrayList<String> option : options) {
|
||||
@@ -1092,7 +1105,7 @@ public class GoogleMetadata {
|
||||
}
|
||||
} else {
|
||||
// Otherwise, add it as the first occurrence of this field
|
||||
ArrayList<String> newField = new ArrayList<String>();
|
||||
ArrayList<String> newField = new ArrayList<>();
|
||||
newField.add(parsedPair[1].trim());
|
||||
mdPairs.put(parsedPair[0].trim(), newField);
|
||||
|
||||
@@ -1113,7 +1126,7 @@ public class GoogleMetadata {
|
||||
|
||||
// Check resolved/present metadata fields against configured values
|
||||
ArrayList<MetadataValue> presentMD = resolveMetadataFields(sb.toString());
|
||||
if (null != presentMD && presentMD.size() != 0) {
|
||||
if (null != presentMD && !presentMD.isEmpty()) {
|
||||
for (MetadataValue v : presentMD) {
|
||||
String fieldName = buildFieldName(v);
|
||||
if (mdPairs.containsKey(fieldName)) {
|
||||
|
@@ -18,10 +18,10 @@ import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -48,9 +48,9 @@ public class InitializeEntities {
|
||||
|
||||
private final static Logger log = LogManager.getLogger();
|
||||
|
||||
private RelationshipTypeService relationshipTypeService;
|
||||
private RelationshipService relationshipService;
|
||||
private EntityTypeService entityTypeService;
|
||||
private final RelationshipTypeService relationshipTypeService;
|
||||
private final RelationshipService relationshipService;
|
||||
private final EntityTypeService entityTypeService;
|
||||
|
||||
|
||||
private InitializeEntities() {
|
||||
@@ -62,14 +62,14 @@ public class InitializeEntities {
|
||||
/**
|
||||
* The main method for this script
|
||||
*
|
||||
* @param argv The commandline arguments given with this command
|
||||
* @param argv The command line arguments given with this command
|
||||
* @throws SQLException If something goes wrong with the database
|
||||
* @throws AuthorizeException If something goes wrong with permissions
|
||||
* @throws ParseException If something goes wrong with the parsing
|
||||
*/
|
||||
public static void main(String[] argv) throws SQLException, AuthorizeException, ParseException {
|
||||
InitializeEntities initializeEntities = new InitializeEntities();
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
Options options = createCommandLineOptions();
|
||||
CommandLine line = parser.parse(options,argv);
|
||||
String fileLocation = getFileLocationFromCommandLine(line);
|
||||
|
@@ -377,7 +377,7 @@ public class SubmissionConfigReader {
|
||||
for (int i = 0; i < len; i++) {
|
||||
Node nd = nl.item(i);
|
||||
// process each step definition
|
||||
if (nd.getNodeName().equals("step")) {
|
||||
if (StringUtils.equalsIgnoreCase(nd.getNodeName(), "step-definition")) {
|
||||
String stepID = getAttribute(nd, "id");
|
||||
if (stepID == null) {
|
||||
throw new SAXException(
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.app.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -49,7 +50,6 @@ import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.discovery.IndexableObject;
|
||||
import org.dspace.discovery.indexobject.IndexableCollection;
|
||||
@@ -102,7 +102,7 @@ public class SyndicationFeed {
|
||||
};
|
||||
protected String defaultExternalMedia = "dc.source.uri";
|
||||
|
||||
private final ConfigurationService configurationService =
|
||||
private static final ConfigurationService configurationService =
|
||||
DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
// metadata field for Item title in entry:
|
||||
@@ -196,18 +196,19 @@ public class SyndicationFeed {
|
||||
|
||||
// dso is null for the whole site, or a search without scope
|
||||
if (dso == null) {
|
||||
defaultTitle = ConfigurationManager.getProperty("dspace.name");
|
||||
defaultTitle = configurationService.getProperty("dspace.name");
|
||||
feed.setDescription(localize(labels, MSG_FEED_DESCRIPTION));
|
||||
objectURL = resolveURL(request, null);
|
||||
logoURL = ConfigurationManager.getProperty("webui.feed.logo.url");
|
||||
logoURL = configurationService.getProperty("webui.feed.logo.url");
|
||||
} else {
|
||||
Bitstream logo = null;
|
||||
if (dso instanceof IndexableCollection) {
|
||||
Collection col = ((IndexableCollection) dso).getIndexedObject();
|
||||
defaultTitle = col.getName();
|
||||
feed.setDescription(collectionService.getMetadata(col, "short_description"));
|
||||
feed.setDescription(collectionService.getMetadataFirstValue(col,
|
||||
CollectionService.MD_SHORT_DESCRIPTION, Item.ANY));
|
||||
logo = col.getLogo();
|
||||
String cols = ConfigurationManager.getProperty("webui.feed.podcast.collections");
|
||||
String cols = configurationService.getProperty("webui.feed.podcast.collections");
|
||||
if (cols != null && cols.length() > 1 && cols.contains(col.getHandle())) {
|
||||
podcastFeed = true;
|
||||
}
|
||||
@@ -215,9 +216,10 @@ public class SyndicationFeed {
|
||||
} else if (dso instanceof IndexableCommunity) {
|
||||
Community comm = ((IndexableCommunity) dso).getIndexedObject();
|
||||
defaultTitle = comm.getName();
|
||||
feed.setDescription(communityService.getMetadata(comm, "short_description"));
|
||||
feed.setDescription(communityService.getMetadataFirstValue(comm,
|
||||
CommunityService.MD_SHORT_DESCRIPTION, Item.ANY));
|
||||
logo = comm.getLogo();
|
||||
String comms = ConfigurationManager.getProperty("webui.feed.podcast.communities");
|
||||
String comms = configurationService.getProperty("webui.feed.podcast.communities");
|
||||
if (comms != null && comms.length() > 1 && comms.contains(comm.getHandle())) {
|
||||
podcastFeed = true;
|
||||
}
|
||||
@@ -251,7 +253,7 @@ public class SyndicationFeed {
|
||||
|
||||
// add entries for items
|
||||
if (items != null) {
|
||||
List<SyndEntry> entries = new ArrayList<SyndEntry>();
|
||||
List<SyndEntry> entries = new ArrayList<>();
|
||||
for (IndexableObject idxObj : items) {
|
||||
if (!(idxObj instanceof IndexableItem)) {
|
||||
continue;
|
||||
@@ -277,7 +279,7 @@ public class SyndicationFeed {
|
||||
// date of last change to Item
|
||||
entry.setUpdatedDate(item.getLastModified());
|
||||
|
||||
StringBuffer db = new StringBuffer();
|
||||
StringBuilder db = new StringBuilder();
|
||||
for (String df : descriptionFields) {
|
||||
// Special Case: "(date)" in field name means render as date
|
||||
boolean isDate = df.indexOf("(date)") > 0;
|
||||
@@ -313,7 +315,7 @@ public class SyndicationFeed {
|
||||
// This gets the authors into an ATOM feed
|
||||
List<MetadataValue> authors = itemService.getMetadataByMetadataString(item, authorField);
|
||||
if (authors.size() > 0) {
|
||||
List<SyndPerson> creators = new ArrayList<SyndPerson>();
|
||||
List<SyndPerson> creators = new ArrayList<>();
|
||||
for (MetadataValue author : authors) {
|
||||
SyndPerson sp = new SyndPersonImpl();
|
||||
sp.setName(author.getValue());
|
||||
@@ -329,7 +331,7 @@ public class SyndicationFeed {
|
||||
if (dcCreatorField != null) {
|
||||
List<MetadataValue> dcAuthors = itemService.getMetadataByMetadataString(item, dcCreatorField);
|
||||
if (dcAuthors.size() > 0) {
|
||||
List<String> creators = new ArrayList<String>();
|
||||
List<String> creators = new ArrayList<>();
|
||||
for (MetadataValue author : dcAuthors) {
|
||||
creators.add(author.getValue());
|
||||
}
|
||||
@@ -345,7 +347,7 @@ public class SyndicationFeed {
|
||||
if (dcDescriptionField != null) {
|
||||
List<MetadataValue> v = itemService.getMetadataByMetadataString(item, dcDescriptionField);
|
||||
if (v.size() > 0) {
|
||||
StringBuffer descs = new StringBuffer();
|
||||
StringBuilder descs = new StringBuilder();
|
||||
for (MetadataValue d : v) {
|
||||
if (descs.length() > 0) {
|
||||
descs.append("\n\n");
|
||||
@@ -374,8 +376,6 @@ public class SyndicationFeed {
|
||||
enc.setLength(bit.getSizeBytes());
|
||||
enc.setUrl(urlOfBitstream(request, bit));
|
||||
enclosures.add(enc);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -395,7 +395,7 @@ public class SyndicationFeed {
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (SQLException e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
entry.setEnclosures(enclosures);
|
||||
@@ -501,7 +501,7 @@ public class SyndicationFeed {
|
||||
|
||||
// utility to get config property with default value when not set.
|
||||
protected static String getDefaultedConfiguration(String key, String dfl) {
|
||||
String result = ConfigurationManager.getProperty(key);
|
||||
String result = configurationService.getProperty(key);
|
||||
return (result == null) ? dfl : result;
|
||||
}
|
||||
|
||||
@@ -531,14 +531,14 @@ public class SyndicationFeed {
|
||||
if (dso == null) {
|
||||
if (baseURL == null) {
|
||||
if (request == null) {
|
||||
baseURL = ConfigurationManager.getProperty("dspace.ui.url");
|
||||
baseURL = configurationService.getProperty("dspace.ui.url");
|
||||
} else {
|
||||
baseURL = ConfigurationManager.getProperty("dspace.ui.url");
|
||||
baseURL = configurationService.getProperty("dspace.ui.url");
|
||||
baseURL += request.getContextPath();
|
||||
}
|
||||
}
|
||||
return baseURL;
|
||||
} else if (ConfigurationManager.getBooleanProperty("webui.feed.localresolve")) {
|
||||
} else if (configurationService.getBooleanProperty("webui.feed.localresolve")) {
|
||||
// return a link to handle in repository
|
||||
return resolveURL(request, null) + "/handle/" + dso.getHandle();
|
||||
} else {
|
||||
|
@@ -15,9 +15,9 @@ import java.util.List;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpHead;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.util.dao.WebAppDAO;
|
||||
import org.dspace.app.util.service.WebAppService;
|
||||
@@ -76,13 +76,13 @@ public class WebAppServiceImpl implements WebAppService {
|
||||
|
||||
for (WebApp app : webApps) {
|
||||
method = new HttpHead(app.getUrl());
|
||||
HttpClient client = new DefaultHttpClient();
|
||||
HttpResponse response = client.execute(method);
|
||||
int status = response.getStatusLine().getStatusCode();
|
||||
int status;
|
||||
try (CloseableHttpClient client = HttpClientBuilder.create().build()) {
|
||||
HttpResponse response = client.execute(method);
|
||||
status = response.getStatusLine().getStatusCode();
|
||||
}
|
||||
if (status != HttpStatus.SC_OK) {
|
||||
delete(context, app
|
||||
|
||||
);
|
||||
delete(context, app);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
package org.dspace.authenticate;
|
||||
|
||||
import static org.dspace.eperson.service.EPersonService.MD_PHONE;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
@@ -33,7 +35,6 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authenticate.factory.AuthenticateServiceFactory;
|
||||
import org.dspace.authenticate.service.AuthenticationService;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.eperson.EPerson;
|
||||
@@ -41,19 +42,28 @@ import org.dspace.eperson.Group;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.eperson.service.GroupService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* This combined LDAP authentication method supersedes both the 'LDAPAuthentication'
|
||||
* and the 'LDAPHierarchicalAuthentication' methods. It's capable of both:
|
||||
* - authenticaton against a flat LDAP tree where all users are in the same unit
|
||||
* (if search.user or search.password is not set)
|
||||
* - authentication against structured hierarchical LDAP trees of users.
|
||||
* <ul>
|
||||
* <li>authentication against a flat LDAP tree where all users are in the same unit
|
||||
* (if {@code search.user} or {@code search.password} is not set)</li>
|
||||
* <li>authentication against structured hierarchical LDAP trees of users.</li>
|
||||
* </ul>
|
||||
* An initial bind is required using a user name and password in order to
|
||||
* search the tree and find the DN of the user. A second bind is then required to
|
||||
* check the credentials of the user by binding directly to their DN.
|
||||
*
|
||||
* @author Stuart Lewis, Chris Yates, Alex Barbieri, Flavio Botelho, Reuben Pasquini, Samuel Ottenhoff, Ivan Masár
|
||||
* @version $Revision$
|
||||
* @author Stuart Lewis
|
||||
* @author Chris Yates
|
||||
* @author Alex Barbieri
|
||||
* @author Flavio Botelho
|
||||
* @author Reuben Pasquini
|
||||
* @author Samuel Ottenhoff
|
||||
* @author Ivan Masár
|
||||
*/
|
||||
public class LDAPAuthentication
|
||||
implements AuthenticationMethod {
|
||||
@@ -61,13 +71,17 @@ public class LDAPAuthentication
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(LDAPAuthentication.class);
|
||||
|
||||
protected AuthenticationService authenticationService = AuthenticateServiceFactory.getInstance()
|
||||
.getAuthenticationService();
|
||||
protected EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||
protected GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();
|
||||
private static final Logger log
|
||||
= org.apache.logging.log4j.LogManager.getLogger(LDAPAuthentication.class);
|
||||
|
||||
protected AuthenticationService authenticationService
|
||||
= AuthenticateServiceFactory.getInstance().getAuthenticationService();
|
||||
protected EPersonService ePersonService
|
||||
= EPersonServiceFactory.getInstance().getEPersonService();
|
||||
protected GroupService groupService
|
||||
= EPersonServiceFactory.getInstance().getGroupService();
|
||||
protected ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
/**
|
||||
* Let a real auth method return true if it wants.
|
||||
@@ -80,7 +94,7 @@ public class LDAPAuthentication
|
||||
String username)
|
||||
throws SQLException {
|
||||
// Looks to see if autoregister is set or not
|
||||
return ConfigurationManager.getBooleanProperty("authentication-ldap", "autoregister");
|
||||
return configurationService.getBooleanProperty("authentication-ldap.autoregister");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +142,7 @@ public class LDAPAuthentication
|
||||
// ensures they are LDAP users
|
||||
try {
|
||||
if (!context.getCurrentUser().getNetid().equals("")) {
|
||||
String groupName = ConfigurationManager.getProperty("authentication-ldap", "login.specialgroup");
|
||||
String groupName = configurationService.getProperty("authentication-ldap.login.specialgroup");
|
||||
if ((groupName != null) && (!groupName.trim().equals(""))) {
|
||||
Group ldapGroup = groupService.findByName(context, groupName);
|
||||
if (ldapGroup == null) {
|
||||
@@ -142,7 +156,7 @@ public class LDAPAuthentication
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception npe) {
|
||||
} catch (SQLException ex) {
|
||||
// The user is not an LDAP user, so we don't need to worry about them
|
||||
}
|
||||
return Collections.EMPTY_LIST;
|
||||
@@ -205,11 +219,11 @@ public class LDAPAuthentication
|
||||
SpeakerToLDAP ldap = new SpeakerToLDAP(log);
|
||||
|
||||
// Get the DN of the user
|
||||
boolean anonymousSearch = ConfigurationManager.getBooleanProperty("authentication-ldap", "search.anonymous");
|
||||
String adminUser = ConfigurationManager.getProperty("authentication-ldap", "search.user");
|
||||
String adminPassword = ConfigurationManager.getProperty("authentication-ldap", "search.password");
|
||||
String objectContext = ConfigurationManager.getProperty("authentication-ldap", "object_context");
|
||||
String idField = ConfigurationManager.getProperty("authentication-ldap", "id_field");
|
||||
boolean anonymousSearch = configurationService.getBooleanProperty("authentication-ldap.search.anonymous");
|
||||
String adminUser = configurationService.getProperty("authentication-ldap.search.user");
|
||||
String adminPassword = configurationService.getProperty("authentication-ldap.search.password");
|
||||
String objectContext = configurationService.getProperty("authentication-ldap.object_context");
|
||||
String idField = configurationService.getProperty("authentication-ldap.id_field");
|
||||
String dn = "";
|
||||
|
||||
// If adminUser is blank and anonymous search is not allowed, then we can't search so construct the DN
|
||||
@@ -263,9 +277,8 @@ public class LDAPAuthentication
|
||||
if (StringUtils.isEmpty(email)) {
|
||||
// If no email, check if we have a "netid_email_domain". If so, append it to the netid to create
|
||||
// email
|
||||
if (StringUtils
|
||||
.isNotEmpty(ConfigurationManager.getProperty("authentication-ldap", "netid_email_domain"))) {
|
||||
email = netid + ConfigurationManager.getProperty("authentication-ldap", "netid_email_domain");
|
||||
if (configurationService.hasProperty("authentication-ldap.netid_email_domain")) {
|
||||
email = netid + configurationService.getProperty("authentication-ldap.netid_email_domain");
|
||||
} else {
|
||||
// We don't have a valid email address. We'll default it to 'netid' but log a warning
|
||||
log.warn(LogManager.getHeader(context, "autoregister",
|
||||
@@ -310,7 +323,8 @@ public class LDAPAuthentication
|
||||
eperson.setLastName(context, ldap.ldapSurname);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(ldap.ldapPhone)) {
|
||||
ePersonService.setMetadata(context, eperson, "phone", ldap.ldapPhone);
|
||||
ePersonService.setMetadataSingleValue(context, eperson,
|
||||
MD_PHONE, ldap.ldapPhone, null);
|
||||
}
|
||||
eperson.setNetid(netid.toLowerCase());
|
||||
eperson.setCanLogIn(true);
|
||||
@@ -365,21 +379,34 @@ public class LDAPAuthentication
|
||||
/**
|
||||
* LDAP settings
|
||||
*/
|
||||
String ldap_provider_url = ConfigurationManager.getProperty("authentication-ldap", "provider_url");
|
||||
String ldap_id_field = ConfigurationManager.getProperty("authentication-ldap", "id_field");
|
||||
String ldap_search_context = ConfigurationManager.getProperty("authentication-ldap", "search_context");
|
||||
String ldap_search_scope = ConfigurationManager.getProperty("authentication-ldap", "search_scope");
|
||||
final String ldap_provider_url;
|
||||
final String ldap_id_field;
|
||||
final String ldap_search_context;
|
||||
final String ldap_search_scope;
|
||||
|
||||
String ldap_email_field = ConfigurationManager.getProperty("authentication-ldap", "email_field");
|
||||
String ldap_givenname_field = ConfigurationManager.getProperty("authentication-ldap", "givenname_field");
|
||||
String ldap_surname_field = ConfigurationManager.getProperty("authentication-ldap", "surname_field");
|
||||
String ldap_phone_field = ConfigurationManager.getProperty("authentication-ldap", "phone_field");
|
||||
String ldap_group_field = ConfigurationManager.getProperty("authentication-ldap", "login.groupmap.attribute");
|
||||
final String ldap_email_field;
|
||||
final String ldap_givenname_field;
|
||||
final String ldap_surname_field;
|
||||
final String ldap_phone_field;
|
||||
final String ldap_group_field;
|
||||
|
||||
boolean useTLS = ConfigurationManager.getBooleanProperty("authentication-ldap", "starttls", false);
|
||||
final boolean useTLS;
|
||||
|
||||
SpeakerToLDAP(Logger thelog) {
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
log = thelog;
|
||||
|
||||
ldap_provider_url = configurationService.getProperty("authentication-ldap.provider_url");
|
||||
ldap_id_field = configurationService.getProperty("authentication-ldap.id_field");
|
||||
ldap_search_context = configurationService.getProperty("authentication-ldap.search_context");
|
||||
ldap_search_scope = configurationService.getProperty("authentication-ldap.search_scope");
|
||||
ldap_email_field = configurationService.getProperty("authentication-ldap.email_field");
|
||||
ldap_givenname_field = configurationService.getProperty("authentication-ldap.givenname_field");
|
||||
ldap_surname_field = configurationService.getProperty("authentication-ldap.surname_field");
|
||||
ldap_phone_field = configurationService.getProperty("authentication-ldap.phone_field");
|
||||
ldap_group_field = configurationService.getProperty("authentication-ldap.login.groupmap.attribute");
|
||||
useTLS = configurationService.getBooleanProperty("authentication-ldap.starttls", false);
|
||||
}
|
||||
|
||||
protected String getDNOfUser(String adminUser, String adminPassword, Context context, String netid) {
|
||||
@@ -399,7 +426,8 @@ public class LDAPAuthentication
|
||||
}
|
||||
|
||||
// Set up environment for creating initial context
|
||||
Hashtable<String, String> env = new Hashtable<String, String>();
|
||||
@SuppressWarnings("UseOfObsoleteCollectionType")
|
||||
Hashtable<String, String> env = new Hashtable<>();
|
||||
env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
|
||||
env.put(javax.naming.Context.PROVIDER_URL, ldap_provider_url);
|
||||
|
||||
@@ -447,7 +475,7 @@ public class LDAPAuthentication
|
||||
SearchControls ctrls = new SearchControls();
|
||||
ctrls.setSearchScope(ldap_search_scope_value);
|
||||
|
||||
String searchName = "";
|
||||
String searchName;
|
||||
if (useTLS) {
|
||||
searchName = ldap_search_context;
|
||||
} else {
|
||||
@@ -555,7 +583,8 @@ public class LDAPAuthentication
|
||||
|
||||
|
||||
// Set up environment for creating initial context
|
||||
Hashtable<String, String> env = new Hashtable<String, String>();
|
||||
@SuppressWarnings("UseOfObsoleteCollectionType")
|
||||
Hashtable<String, String> env = new Hashtable<>();
|
||||
env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
|
||||
"com.sun.jndi.ldap.LdapCtxFactory");
|
||||
env.put(javax.naming.Context.PROVIDER_URL, ldap_provider_url);
|
||||
@@ -652,7 +681,7 @@ public class LDAPAuthentication
|
||||
if (StringUtils.isNotBlank(dn)) {
|
||||
System.out.println("dn:" + dn);
|
||||
int i = 1;
|
||||
String groupMap = ConfigurationManager.getProperty("authentication-ldap", "login.groupmap." + i);
|
||||
String groupMap = configurationService.getProperty("authentication-ldap", "login.groupmap." + i);
|
||||
|
||||
boolean cmp;
|
||||
|
||||
@@ -692,7 +721,7 @@ public class LDAPAuthentication
|
||||
}
|
||||
}
|
||||
|
||||
groupMap = ConfigurationManager.getProperty("authentication-ldap", "login.groupmap." + ++i);
|
||||
groupMap = configurationService.getProperty("authentication-ldap", "login.groupmap." + ++i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,11 +24,14 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authenticate.factory.AuthenticateServiceFactory;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataFieldName;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.NonUniqueMetadataException;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
@@ -65,13 +68,12 @@ import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
* @author <a href="mailto:bliong@melcoe.mq.edu.au">Bruc Liong, MELCOE</a>
|
||||
* @author <a href="mailto:kli@melcoe.mq.edu.au">Xiang Kevin Li, MELCOE</a>
|
||||
* @author <a href="http://www.scottphillips.com">Scott Phillips</a>
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class ShibAuthentication implements AuthenticationMethod {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(ShibAuthentication.class);
|
||||
private static final Logger log = LogManager.getLogger(ShibAuthentication.class);
|
||||
|
||||
/**
|
||||
* Additional metadata mappings
|
||||
@@ -843,25 +845,24 @@ public class ShibAuthentication implements AuthenticationMethod {
|
||||
|
||||
// Truncate values
|
||||
if (value == null) {
|
||||
log.warn(
|
||||
"Unable to update the eperson's '" + field + "' metadata because the header '" + header + "' does" +
|
||||
" not exist.");
|
||||
log.warn("Unable to update the eperson's '{}' metadata"
|
||||
+ " because the header '{}' does not exist.", field, header);
|
||||
continue;
|
||||
} else if ("phone".equals(field) && value.length() > PHONE_MAX_SIZE) {
|
||||
log.warn(
|
||||
"Truncating eperson phone metadata because it is longer than " + PHONE_MAX_SIZE + ": '" + value +
|
||||
"'");
|
||||
log.warn("Truncating eperson phone metadata because it is longer than {}: '{}'",
|
||||
PHONE_MAX_SIZE, value);
|
||||
value = value.substring(0, PHONE_MAX_SIZE);
|
||||
} else if (value.length() > METADATA_MAX_SIZE) {
|
||||
log.warn(
|
||||
"Truncating eperson " + field + " metadata because it is longer than " + METADATA_MAX_SIZE + ": " +
|
||||
"'" + value + "'");
|
||||
log.warn("Truncating eperson {} metadata because it is longer than {}: '{}'",
|
||||
field, METADATA_MAX_SIZE, value);
|
||||
value = value.substring(0, METADATA_MAX_SIZE);
|
||||
}
|
||||
|
||||
ePersonService.setMetadata(context, eperson, field, value);
|
||||
log.debug(
|
||||
"Updated the eperson's '" + field + "' metadata using header: '" + header + "' = '" + value + "'.");
|
||||
String[] nameParts = MetadataFieldName.parse(field);
|
||||
ePersonService.setMetadataSingleValue(context, eperson,
|
||||
nameParts[0], nameParts[1], nameParts[2], value, null);
|
||||
log.debug("Updated the eperson's '{}' metadata using header: '{}' = '{}'.",
|
||||
field, header, value);
|
||||
}
|
||||
ePersonService.update(context, eperson);
|
||||
context.dispatchEvents();
|
||||
@@ -889,10 +890,8 @@ public class ShibAuthentication implements AuthenticationMethod {
|
||||
protected int swordCompatibility(Context context, String username, String password, HttpServletRequest request)
|
||||
throws SQLException {
|
||||
|
||||
EPerson eperson = null;
|
||||
|
||||
log.debug("Shibboleth Sword compatibility activated.");
|
||||
eperson = ePersonService.findByEmail(context, username.toLowerCase());
|
||||
EPerson eperson = ePersonService.findByEmail(context, username.toLowerCase());
|
||||
|
||||
if (eperson == null) {
|
||||
// lookup failed.
|
||||
@@ -951,7 +950,7 @@ public class ShibAuthentication implements AuthenticationMethod {
|
||||
}
|
||||
|
||||
|
||||
HashMap<String, String> map = new HashMap<String, String>();
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
|
||||
String[] mappingString = configurationService.getArrayProperty("authentication-shibboleth.eperson.metadata");
|
||||
boolean autoCreate = configurationService
|
||||
@@ -990,19 +989,19 @@ public class ShibAuthentication implements AuthenticationMethod {
|
||||
|
||||
if (valid) {
|
||||
// The eperson field is fine, we can use it.
|
||||
log.debug("Loading additional eperson metadata mapping for: '" + header + "' = '" + name + "'");
|
||||
log.debug("Loading additional eperson metadata mapping for: '{}' = '{}'",
|
||||
header, name);
|
||||
map.put(header, name);
|
||||
} else {
|
||||
// The field doesn't exist, and we can't use it.
|
||||
log.error(
|
||||
"Skipping the additional eperson metadata mapping for: '" + header + "' = '" + name + "' because " +
|
||||
"the field is not supported by the current configuration.");
|
||||
log.error("Skipping the additional eperson metadata mapping for: '{}' = '{}'"
|
||||
+ " because the field is not supported by the current configuration.",
|
||||
header, name);
|
||||
}
|
||||
} // foreach metadataStringList
|
||||
|
||||
|
||||
metadataHeaderMap = map;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1020,12 +1019,8 @@ public class ShibAuthentication implements AuthenticationMethod {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The phone is a predefined field
|
||||
if ("phone".equals(metadataName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
MetadataField metadataField = metadataFieldService.findByElement(context, "eperson", metadataName, null);
|
||||
MetadataField metadataField = metadataFieldService.findByElement(context,
|
||||
MetadataSchemaEnum.EPERSON.getName(), metadataName, null);
|
||||
return metadataField != null;
|
||||
}
|
||||
|
||||
@@ -1063,10 +1058,7 @@ public class ShibAuthentication implements AuthenticationMethod {
|
||||
try {
|
||||
context.turnOffAuthorisationSystem();
|
||||
metadataField = metadataFieldService.create(context, epersonSchema, metadataName, null, null);
|
||||
} catch (AuthorizeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return false;
|
||||
} catch (NonUniqueMetadataException e) {
|
||||
} catch (AuthorizeException | NonUniqueMetadataException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return false;
|
||||
} finally {
|
||||
@@ -1211,7 +1203,7 @@ public class ShibAuthentication implements AuthenticationMethod {
|
||||
// Shibboleth attributes are separated by semicolons (and semicolons are
|
||||
// escaped with a backslash). So here we will scan through the string and
|
||||
// split on any unescaped semicolons.
|
||||
List<String> valueList = new ArrayList<String>();
|
||||
List<String> valueList = new ArrayList<>();
|
||||
int idx = 0;
|
||||
do {
|
||||
idx = values.indexOf(';', idx);
|
||||
|
@@ -12,6 +12,7 @@ import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
@@ -21,7 +22,8 @@ import org.apache.solr.client.solrj.response.FacetField;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.dspace.authority.indexer.AuthorityIndexingService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
@@ -31,7 +33,7 @@ import org.dspace.core.ConfigurationManager;
|
||||
*/
|
||||
public class AuthoritySolrServiceImpl implements AuthorityIndexingService, AuthoritySearchService {
|
||||
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(AuthoritySolrServiceImpl.class);
|
||||
private static final Logger log = LogManager.getLogger(AuthoritySolrServiceImpl.class);
|
||||
|
||||
protected AuthoritySolrServiceImpl() {
|
||||
|
||||
@@ -46,7 +48,9 @@ public class AuthoritySolrServiceImpl implements AuthorityIndexingService, Autho
|
||||
throws MalformedURLException, SolrServerException, IOException {
|
||||
if (solr == null) {
|
||||
|
||||
String solrService = ConfigurationManager.getProperty("solr.authority.server");
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String solrService = configurationService.getProperty("solr.authority.server");
|
||||
|
||||
log.debug("Solr authority URL: " + solrService);
|
||||
|
||||
@@ -153,7 +157,7 @@ public class AuthoritySolrServiceImpl implements AuthorityIndexingService, Autho
|
||||
|
||||
QueryResponse response = getSolr().query(solrQuery);
|
||||
|
||||
List<String> results = new ArrayList<String>();
|
||||
List<String> results = new ArrayList<>();
|
||||
FacetField facetField = response.getFacetField("field");
|
||||
if (facetField != null) {
|
||||
List<FacetField.Count> values = facetField.getValues();
|
||||
|
@@ -7,20 +7,22 @@
|
||||
*/
|
||||
package org.dspace.authority;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
* This class contains a list of active authority types.
|
||||
* It can be used to created a new instance of a specific type.
|
||||
* However if you need to make a new instance to store it in solr, you need to use AuthorityValueGenerator.
|
||||
* To create an instance from a solr record, use AuthorityValue#fromSolr(SolrDocument).
|
||||
* However if you need to make a new instance to store it in Solr, you need to use {@link AuthorityValueGenerator}.
|
||||
* To create an instance from a Solr record, use {@link AuthorityValue#fromSolr(SolrDocument)}.
|
||||
*
|
||||
* This class is instantiated in spring and accessed by a static method in AuthorityValue.
|
||||
* This class is instantiated in Spring and accessed by a static method in AuthorityValue.
|
||||
*
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||
@@ -32,11 +34,11 @@ public class AuthorityTypes {
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(AuthorityTypes.class);
|
||||
private static final Logger log = LogManager.getLogger(AuthorityTypes.class);
|
||||
|
||||
protected List<AuthorityValue> types = new ArrayList<AuthorityValue>();
|
||||
protected List<AuthorityValue> types = new ArrayList<>();
|
||||
|
||||
protected Map<String, AuthorityValue> fieldDefaults = new HashMap<String, AuthorityValue>();
|
||||
protected Map<String, AuthorityValue> fieldDefaults = new HashMap<>();
|
||||
|
||||
|
||||
public List<AuthorityValue> getTypes() {
|
||||
@@ -60,10 +62,10 @@ public class AuthorityTypes {
|
||||
for (AuthorityValue authorityValue : types) {
|
||||
if (authorityValue.getAuthorityType().equals(type)) {
|
||||
try {
|
||||
result = authorityValue.getClass().newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
log.error("Error", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
result = authorityValue.getClass().getDeclaredConstructor().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException
|
||||
| NoSuchMethodException | SecurityException
|
||||
| IllegalArgumentException | InvocationTargetException e) {
|
||||
log.error("Error", e);
|
||||
}
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.authority;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
@@ -15,19 +16,22 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authority.factory.AuthorityServiceFactory;
|
||||
import org.dspace.authority.service.AuthorityValueService;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* @author Antoine Snyers (antoine at atmire.com)
|
||||
@@ -40,21 +44,23 @@ public class UpdateAuthorities {
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(UpdateAuthorities.class);
|
||||
private static final Logger log = LogManager.getLogger(UpdateAuthorities.class);
|
||||
|
||||
protected PrintWriter print = null;
|
||||
|
||||
private Context context;
|
||||
private final Context context;
|
||||
private List<String> selectedIDs;
|
||||
|
||||
protected final ItemService itemService;
|
||||
protected final AuthorityValueService authorityValueService;
|
||||
protected final ConfigurationService configurationService;
|
||||
|
||||
public UpdateAuthorities(Context context) {
|
||||
print = new PrintWriter(System.out);
|
||||
this.context = context;
|
||||
this.authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService();
|
||||
this.itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
this.configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ParseException {
|
||||
@@ -78,7 +84,7 @@ public class UpdateAuthorities {
|
||||
}
|
||||
|
||||
protected static int processArgs(String[] args, UpdateAuthorities UpdateAuthorities) throws ParseException {
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
Options options = createCommandLineOptions();
|
||||
CommandLine line = parser.parse(options, args);
|
||||
|
||||
@@ -102,7 +108,7 @@ public class UpdateAuthorities {
|
||||
}
|
||||
|
||||
private void setSelectedIDs(String b) {
|
||||
this.selectedIDs = new ArrayList<String>();
|
||||
this.selectedIDs = new ArrayList<>();
|
||||
String[] orcids = b.split(",");
|
||||
for (String orcid : orcids) {
|
||||
this.selectedIDs.add(orcid.trim());
|
||||
@@ -125,7 +131,7 @@ public class UpdateAuthorities {
|
||||
List<AuthorityValue> authorities;
|
||||
|
||||
if (selectedIDs != null && !selectedIDs.isEmpty()) {
|
||||
authorities = new ArrayList<AuthorityValue>();
|
||||
authorities = new ArrayList<>();
|
||||
for (String selectedID : selectedIDs) {
|
||||
AuthorityValue byUID = authorityValueService.findByUID(context, selectedID);
|
||||
authorities.add(byUID);
|
||||
@@ -149,7 +155,7 @@ public class UpdateAuthorities {
|
||||
protected void followUp(AuthorityValue authority) {
|
||||
print.println("Updated: " + authority.getValue() + " - " + authority.getId());
|
||||
|
||||
boolean updateItems = ConfigurationManager.getBooleanProperty("solrauthority", "auto-update-items");
|
||||
boolean updateItems = configurationService.getBooleanProperty("solrauthority.auto-update-items");
|
||||
if (updateItems) {
|
||||
updateItems(authority);
|
||||
}
|
||||
@@ -169,7 +175,7 @@ public class UpdateAuthorities {
|
||||
print.println("Updated item with handle " + next.getHandle());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (SQLException | AuthorizeException e) {
|
||||
log.error("Error updating item", e);
|
||||
print.println("Error updating item. " + Arrays.toString(e.getStackTrace()));
|
||||
}
|
||||
|
@@ -460,7 +460,7 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
||||
groupService.allMemberGroups(c, e),
|
||||
Constants.ADMIN, Constants.COLLECTION);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(policies)) {
|
||||
if (CollectionUtils.isNotEmpty(policies) || isCommunityAdmin(c, e)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -7,8 +7,11 @@
|
||||
*/
|
||||
package org.dspace.browse;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* Factory class to generate DAOs based on the configuration
|
||||
@@ -33,16 +36,21 @@ public class BrowseDAOFactory {
|
||||
*/
|
||||
public static BrowseDAO getInstance(Context context)
|
||||
throws BrowseException {
|
||||
String className = ConfigurationManager.getProperty("browseDAO.class");
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String className = configurationService.getProperty("browseDAO.class");
|
||||
if (className == null) {
|
||||
// SOLR implementation is the default since DSpace 4.0
|
||||
return new SolrBrowseDAO(context);
|
||||
}
|
||||
try {
|
||||
return (BrowseDAO) Class
|
||||
.forName(ConfigurationManager.getProperty("browseDAO.class"))
|
||||
.forName(configurationService.getProperty("browseDAO.class"))
|
||||
.getConstructor(Context.class).newInstance(context);
|
||||
} catch (Exception e) {
|
||||
} catch (ClassNotFoundException | IllegalAccessException
|
||||
| IllegalArgumentException | InstantiationException
|
||||
| NoSuchMethodException | SecurityException |
|
||||
InvocationTargetException e) {
|
||||
throw new BrowseException("The configuration for browseDAO is invalid: " + className, e);
|
||||
}
|
||||
}
|
||||
|
@@ -13,7 +13,8 @@ import java.util.StringTokenizer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.sort.SortException;
|
||||
import org.dspace.sort.SortOption;
|
||||
|
||||
@@ -414,6 +415,7 @@ public final class BrowseIndex {
|
||||
* @return the name of the table
|
||||
* @deprecated 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
public static String getTableName(int number, boolean isCommunity, boolean isCollection, boolean isDistinct,
|
||||
boolean isMap) {
|
||||
return BrowseIndex.getTableName(makeTableBaseName(number), isCommunity, isCollection, isDistinct, isMap);
|
||||
@@ -462,6 +464,7 @@ public final class BrowseIndex {
|
||||
* @return the name of the table
|
||||
* @deprecated 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
public String getTableName(boolean isCommunity, boolean isCollection, boolean isDistinct, boolean isMap) {
|
||||
if (isDistinct || isMap) {
|
||||
return BrowseIndex.getTableName(number, isCommunity, isCollection, isDistinct, isMap);
|
||||
@@ -482,6 +485,7 @@ public final class BrowseIndex {
|
||||
* @return the name of the table
|
||||
* @deprecated 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
public String getTableName(boolean isCommunity, boolean isCollection) {
|
||||
return getTableName(isCommunity, isCollection, false, false);
|
||||
}
|
||||
@@ -514,6 +518,7 @@ public final class BrowseIndex {
|
||||
* @return table name
|
||||
* @deprecated 1.5
|
||||
*/
|
||||
@Deprecated
|
||||
public String getTableName(boolean isDistinct, boolean isCommunity, boolean isCollection) {
|
||||
return getTableName(isCommunity, isCollection, isDistinct, false);
|
||||
}
|
||||
@@ -649,6 +654,7 @@ public final class BrowseIndex {
|
||||
* @throws BrowseException if browse error
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public static String[] tables()
|
||||
throws BrowseException {
|
||||
BrowseIndex[] bis = getBrowseIndices();
|
||||
@@ -670,13 +676,14 @@ public final class BrowseIndex {
|
||||
throws BrowseException {
|
||||
int idx = 1;
|
||||
String definition;
|
||||
ArrayList<BrowseIndex> browseIndices = new ArrayList<BrowseIndex>();
|
||||
ArrayList<BrowseIndex> browseIndices = new ArrayList<>();
|
||||
|
||||
while (((definition = ConfigurationManager.getProperty("webui.browse.index." + idx))) != null) {
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
while (((definition = configurationService.getProperty("webui.browse.index." + idx))) != null) {
|
||||
BrowseIndex bi = new BrowseIndex(definition, idx);
|
||||
bi.displayFrequencies = Boolean.valueOf(ConfigurationManager
|
||||
.getBooleanProperty("webui.browse.metadata.show-freq."
|
||||
+ idx, true));
|
||||
bi.displayFrequencies = configurationService
|
||||
.getBooleanProperty("webui.browse.metadata.show-freq." + idx, true);
|
||||
|
||||
browseIndices.add(bi);
|
||||
idx++;
|
||||
@@ -804,8 +811,8 @@ public final class BrowseIndex {
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean isTagCloudEnabled() {
|
||||
|
||||
return ConfigurationManager.getBooleanProperty("webui.browse.index.tagcloud." + number);
|
||||
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
return configurationService.getBooleanProperty("webui.browse.index.tagcloud." + number);
|
||||
}
|
||||
}
|
||||
|
@@ -475,6 +475,7 @@ public class BrowseInfo {
|
||||
* @return an empty array of Item.
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public Item[] getItemResults() {
|
||||
return new Item[0];
|
||||
}
|
||||
|
@@ -10,7 +10,8 @@ package org.dspace.browse;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* Class to represent the configuration of the cross-linking between browse
|
||||
@@ -23,7 +24,7 @@ public class CrossLinks {
|
||||
/**
|
||||
* a map of the desired links
|
||||
*/
|
||||
private Map<String, String> links = new HashMap<String, String>();
|
||||
private Map<String, String> links = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Construct a new object which will obtain the configuration for itself.
|
||||
@@ -35,7 +36,9 @@ public class CrossLinks {
|
||||
int i = 1;
|
||||
while (true) {
|
||||
String field = "webui.browse.link." + i;
|
||||
String config = ConfigurationManager.getProperty(field);
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String config = configurationService.getProperty(field);
|
||||
if (config == null) {
|
||||
break;
|
||||
}
|
||||
|
@@ -7,8 +7,11 @@
|
||||
*/
|
||||
package org.dspace.browse;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* Factory class to allow us to load the correct DAO for registering
|
||||
@@ -38,16 +41,22 @@ public class ItemCountDAOFactory {
|
||||
/** Log4j logger */
|
||||
ItemCountDAO dao = null;
|
||||
|
||||
String className = ConfigurationManager.getProperty("ItemCountDAO.class");
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String className = configurationService.getProperty("ItemCountDAO.class");
|
||||
|
||||
// SOLR implementation is the default since DSpace 4.0
|
||||
if (className == null) {
|
||||
dao = new ItemCountDAOSolr();
|
||||
} else {
|
||||
try {
|
||||
dao = (ItemCountDAO) Class
|
||||
.forName(className.trim()).newInstance();
|
||||
} catch (Exception e) {
|
||||
dao = (ItemCountDAO) Class.forName(className.trim())
|
||||
.getDeclaredConstructor()
|
||||
.newInstance();
|
||||
} catch (ClassNotFoundException | IllegalAccessException
|
||||
| InstantiationException | NoSuchMethodException
|
||||
| SecurityException | IllegalArgumentException
|
||||
| InvocationTargetException e) {
|
||||
throw new ItemCountException("The configuration for ItemCountDAO is invalid: " + className, e);
|
||||
}
|
||||
}
|
||||
|
@@ -12,8 +12,10 @@ import java.util.Locale;
|
||||
import com.ibm.icu.text.CollationElementIterator;
|
||||
import com.ibm.icu.text.Collator;
|
||||
import com.ibm.icu.text.RuleBasedCollator;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.text.filter.TextFilter;
|
||||
|
||||
/**
|
||||
@@ -32,7 +34,7 @@ import org.dspace.text.filter.TextFilter;
|
||||
* @author Graham Triggs
|
||||
*/
|
||||
public class LocaleOrderingFilter implements TextFilter {
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(LocaleOrderingFilter.class);
|
||||
private static final Logger log = LogManager.getLogger(LocaleOrderingFilter.class);
|
||||
|
||||
/**
|
||||
* Uses a Locale dependent Collator to generate a sort string
|
||||
@@ -47,7 +49,7 @@ public class LocaleOrderingFilter implements TextFilter {
|
||||
// Have we got a collator?
|
||||
if (collator != null) {
|
||||
int element;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
// Iterate through the elements of the collator
|
||||
CollationElementIterator iter = collator.getCollationElementIterator(str);
|
||||
@@ -107,7 +109,9 @@ public class LocaleOrderingFilter implements TextFilter {
|
||||
Locale theLocale = null;
|
||||
|
||||
// Get a Locale configuration from the dspace.cfg
|
||||
String locale = ConfigurationManager.getProperty("webui.browse.sort.locale");
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String locale = configurationService.getProperty("webui.browse.sort.locale");
|
||||
|
||||
if (locale != null) {
|
||||
// Attempt to create Locale for the configured value
|
||||
|
@@ -17,17 +17,19 @@ import javax.mail.MessagingException;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.checker.factory.CheckerServiceFactory;
|
||||
import org.dspace.checker.service.SimpleReporterService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.Email;
|
||||
import org.dspace.core.Utils;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -44,7 +46,7 @@ public class DailyReportEmailer {
|
||||
/**
|
||||
* log4j logger.
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(DailyReportEmailer.class);
|
||||
private static final Logger log = LogManager.getLogger(DailyReportEmailer.class);
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
@@ -63,14 +65,16 @@ public class DailyReportEmailer {
|
||||
public void sendReport(File attachment, int numberOfBitstreams)
|
||||
throws IOException, javax.mail.MessagingException {
|
||||
if (numberOfBitstreams > 0) {
|
||||
String hostname = Utils.getHostName(ConfigurationManager.getProperty("dspace.ui.url"));
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String hostname = Utils.getHostName(configurationService.getProperty("dspace.ui.url"));
|
||||
Email email = new Email();
|
||||
email.setSubject(
|
||||
"Checksum checker Report - " + numberOfBitstreams + " Bitstreams found with POSSIBLE issues on " +
|
||||
hostname);
|
||||
email.setSubject(String.format(
|
||||
"Checksum checker Report - %d Bitstreams found with POSSIBLE issues on %s",
|
||||
numberOfBitstreams, hostname));
|
||||
email.setContent("Checker Report", "report is attached ...");
|
||||
email.addAttachment(attachment, "checksum_checker_report.txt");
|
||||
email.addRecipient(ConfigurationManager.getProperty("mail.admin"));
|
||||
email.addRecipient(configurationService.getProperty("mail.admin"));
|
||||
email.send();
|
||||
}
|
||||
}
|
||||
@@ -98,7 +102,7 @@ public class DailyReportEmailer {
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// set up command line parser
|
||||
CommandLineParser parser = new PosixParser();
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
CommandLine line = null;
|
||||
|
||||
// create an options object and populate it
|
||||
@@ -164,7 +168,9 @@ public class DailyReportEmailer {
|
||||
int numBitstreams = 0;
|
||||
|
||||
// create a temporary file in the log directory
|
||||
String dirLocation = ConfigurationManager.getProperty("log.report.dir");
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String dirLocation = configurationService.getProperty("log.report.dir");
|
||||
File directory = new File(dirLocation);
|
||||
|
||||
if (directory.exists() && directory.isDirectory()) {
|
||||
@@ -247,7 +253,7 @@ public class DailyReportEmailer {
|
||||
if (writer != null) {
|
||||
try {
|
||||
writer.close();
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
log.fatal("Could not close writer", e);
|
||||
}
|
||||
}
|
||||
|
@@ -19,12 +19,14 @@ import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.checker.factory.CheckerServiceFactory;
|
||||
import org.dspace.checker.service.ChecksumHistoryService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.Utils;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* Manages the deletion of results from the checksum history. It uses the
|
||||
@@ -40,7 +42,7 @@ public final class ResultsPruner {
|
||||
/**
|
||||
* Default logger.
|
||||
*/
|
||||
private static final Logger LOG = org.apache.logging.log4j.LogManager.getLogger(ResultsPruner.class);
|
||||
private static final Logger LOG = LogManager.getLogger(ResultsPruner.class);
|
||||
|
||||
/**
|
||||
* Factory method for the default results pruner configuration using
|
||||
@@ -51,12 +53,13 @@ public final class ResultsPruner {
|
||||
*/
|
||||
public static ResultsPruner getDefaultPruner(Context context) {
|
||||
try {
|
||||
return getPruner(context, ConfigurationManager.getProperties());
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
return getPruner(context, configurationService.getProperties());
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new IllegalStateException(
|
||||
"VeryExceptionalException - config file not there! ", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -7,11 +7,14 @@
|
||||
*/
|
||||
package org.dspace.content;
|
||||
|
||||
import static org.dspace.content.service.DSpaceObjectService.MD_LICENSE;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
@@ -46,7 +49,6 @@ import org.hibernate.proxy.HibernateProxyHelper;
|
||||
* effect.
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "collection")
|
||||
@@ -87,23 +89,11 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
|
||||
joinColumns = {@JoinColumn(name = "collection_id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "community_id")}
|
||||
)
|
||||
private Set<Community> communities = new HashSet<>();
|
||||
private final Set<Community> communities = new HashSet<>();
|
||||
|
||||
@Transient
|
||||
private transient CollectionService collectionService;
|
||||
|
||||
// Keys for accessing Collection metadata
|
||||
@Transient
|
||||
public static final String COPYRIGHT_TEXT = "copyright_text";
|
||||
@Transient
|
||||
public static final String INTRODUCTORY_TEXT = "introductory_text";
|
||||
@Transient
|
||||
public static final String SHORT_DESCRIPTION = "short_description";
|
||||
@Transient
|
||||
public static final String SIDEBAR_TEXT = "side_bar_text";
|
||||
@Transient
|
||||
public static final String PROVENANCE_TEXT = "provenance_description";
|
||||
|
||||
/**
|
||||
* Protected constructor, create object using:
|
||||
* {@link org.dspace.content.service.CollectionService#create(Context, Community)}
|
||||
@@ -207,10 +197,17 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
|
||||
* Get the license that users must grant before submitting to this
|
||||
* collection.
|
||||
*
|
||||
* @return the license for this collection
|
||||
* @return the license for this collection. Never null.
|
||||
*/
|
||||
@Nonnull
|
||||
public String getLicenseCollection() {
|
||||
return getCollectionService().getMetadata(this, "license");
|
||||
String license = getCollectionService()
|
||||
.getMetadataFirstValue(this, CollectionService.MD_LICENSE, Item.ANY);
|
||||
if (null == license) {
|
||||
return "";
|
||||
} else {
|
||||
return license;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,7 +219,7 @@ public class Collection extends DSpaceObject implements DSpaceObjectLegacySuppor
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
public void setLicense(Context context, String license) throws SQLException {
|
||||
getCollectionService().setMetadata(context, this, "license", license);
|
||||
getCollectionService().setMetadataSingleValue(context, this, MD_LICENSE, Item.ANY, license);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -36,7 +36,6 @@ import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.WorkspaceItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.I18nUtil;
|
||||
@@ -55,6 +54,9 @@ import org.dspace.eperson.service.SubscribeService;
|
||||
import org.dspace.event.Event;
|
||||
import org.dspace.harvest.HarvestedCollection;
|
||||
import org.dspace.harvest.service.HarvestedCollectionService;
|
||||
import org.dspace.identifier.IdentifierException;
|
||||
import org.dspace.identifier.service.IdentifierService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||
import org.dspace.xmlworkflow.WorkflowConfigurationException;
|
||||
import org.dspace.xmlworkflow.factory.XmlWorkflowFactory;
|
||||
@@ -92,6 +94,8 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
protected CommunityService communityService;
|
||||
@Autowired(required = true)
|
||||
protected GroupService groupService;
|
||||
@Autowired(required = true)
|
||||
protected IdentifierService identifierService;
|
||||
|
||||
@Autowired(required = true)
|
||||
protected LicenseService licenseService;
|
||||
@@ -111,6 +115,9 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
@Autowired(required = true)
|
||||
protected SearchService searchService;
|
||||
|
||||
@Autowired(required = true)
|
||||
protected ConfigurationService configurationService;
|
||||
|
||||
protected CollectionServiceImpl() {
|
||||
super();
|
||||
}
|
||||
@@ -131,13 +138,6 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
//Add our newly created collection to our community, authorization checks occur in THIS method
|
||||
communityService.addCollection(context, community, newCollection);
|
||||
|
||||
//Update our community so we have a collection identifier
|
||||
if (handle == null) {
|
||||
handleService.createHandle(context, newCollection);
|
||||
} else {
|
||||
handleService.createHandle(context, newCollection, handle);
|
||||
}
|
||||
|
||||
// create the default authorization policy for collections
|
||||
// of 'anonymous' READ
|
||||
Group anonymousGroup = groupService.findByName(context, Group.ANONYMOUS);
|
||||
@@ -150,6 +150,18 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
authorizeService
|
||||
.createResourcePolicy(context, newCollection, anonymousGroup, null, Constants.DEFAULT_BITSTREAM_READ, null);
|
||||
|
||||
collectionDAO.save(context, newCollection);
|
||||
|
||||
//Update our collection so we have a collection identifier
|
||||
try {
|
||||
if (handle == null) {
|
||||
identifierService.register(context, newCollection);
|
||||
} else {
|
||||
identifierService.register(context, newCollection, handle);
|
||||
}
|
||||
} catch (IllegalStateException | IdentifierException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
|
||||
context.addEvent(new Event(Event.CREATE, Constants.COLLECTION,
|
||||
newCollection.getID(), newCollection.getHandle(),
|
||||
@@ -159,7 +171,6 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
"collection_id=" + newCollection.getID())
|
||||
+ ",handle=" + newCollection.getHandle());
|
||||
|
||||
collectionDAO.save(context, newCollection);
|
||||
return newCollection;
|
||||
}
|
||||
|
||||
@@ -189,7 +200,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
|
||||
@Override
|
||||
public List<Collection> findAuthorizedOptimized(Context context, int actionID) throws SQLException {
|
||||
if (!ConfigurationManager
|
||||
if (!configurationService
|
||||
.getBooleanProperty("org.dspace.content.Collection.findAuthorizedPerformanceOptimize", false)) {
|
||||
// Fallback to legacy query if config says so. The rationale could be that a site found a bug.
|
||||
return findAuthorized(context, null, actionID);
|
||||
@@ -290,9 +301,10 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(Context context, Collection collection, String field, String value)
|
||||
throws MissingResourceException, SQLException {
|
||||
if ((field.trim()).equals("name") && (value == null || value.trim().equals(""))) {
|
||||
public void setMetadataSingleValue(Context context, Collection collection,
|
||||
MetadataFieldName field, String language, String value)
|
||||
throws MissingResourceException, SQLException {
|
||||
if (field.equals(MD_NAME) && (value == null || value.trim().equals(""))) {
|
||||
try {
|
||||
value = I18nUtil.getMessage("org.dspace.workflow.WorkflowManager.untitled");
|
||||
} catch (MissingResourceException e) {
|
||||
@@ -300,21 +312,19 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
}
|
||||
}
|
||||
|
||||
String[] MDValue = getMDValueByLegacyField(field);
|
||||
|
||||
/*
|
||||
* Set metadata field to null if null
|
||||
* and trim strings to eliminate excess
|
||||
* whitespace.
|
||||
*/
|
||||
if (value == null) {
|
||||
clearMetadata(context, collection, MDValue[0], MDValue[1], MDValue[2], Item.ANY);
|
||||
clearMetadata(context, collection, field.SCHEMA, field.ELEMENT, field.QUALIFIER, Item.ANY);
|
||||
collection.setMetadataModified();
|
||||
} else {
|
||||
setMetadataSingleValue(context, collection, MDValue[0], MDValue[1], MDValue[2], null, value);
|
||||
super.setMetadataSingleValue(context, collection, field, null, value);
|
||||
}
|
||||
|
||||
collection.addDetails(field);
|
||||
collection.addDetails(field.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -454,22 +464,6 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of a metadata field
|
||||
*
|
||||
* @param collection which collection to operate on
|
||||
* @param field the name of the metadata field to get
|
||||
* @return the value of the metadata field
|
||||
* @throws IllegalArgumentException if the requested metadata field doesn't exist
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMetadata(Collection collection, String field) {
|
||||
String[] MDValue = getMDValueByLegacyField(field);
|
||||
String value = getMetadataFirstValue(collection, MDValue[0], MDValue[1], MDValue[2], Item.ANY);
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Group createSubmitters(Context context, Collection collection) throws SQLException, AuthorizeException {
|
||||
// Check authorisation - Must be an Admin to create Submitters Group
|
||||
@@ -550,7 +544,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
|
||||
@Override
|
||||
public String getLicense(Collection collection) {
|
||||
String license = getMetadata(collection, "license");
|
||||
String license = getMetadataFirstValue(collection, CollectionService.MD_LICENSE, Item.ANY);
|
||||
|
||||
if (license == null || license.trim().equals("")) {
|
||||
// Fallback to site-wide default
|
||||
@@ -922,7 +916,7 @@ public class CollectionServiceImpl extends DSpaceObjectServiceImpl<Collection> i
|
||||
public List<Collection> findCollectionsWithSubmit(String q, Context context, Community community,
|
||||
int offset, int limit) throws SQLException, SearchServiceException {
|
||||
|
||||
List<Collection> collections = new ArrayList<Collection>();
|
||||
List<Collection> collections = new ArrayList<>();
|
||||
DiscoverQuery discoverQuery = new DiscoverQuery();
|
||||
discoverQuery.setDSpaceObjectFilter(IndexableCollection.TYPE);
|
||||
discoverQuery.setStart(offset);
|
||||
|
@@ -63,13 +63,13 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
joinColumns = {@JoinColumn(name = "parent_comm_id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "child_comm_id")}
|
||||
)
|
||||
private Set<Community> subCommunities = new HashSet<>();
|
||||
private final Set<Community> subCommunities = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "subCommunities")
|
||||
private Set<Community> parentCommunities = new HashSet<>();
|
||||
private final Set<Community> parentCommunities = new HashSet<>();
|
||||
|
||||
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "communities", cascade = {CascadeType.PERSIST})
|
||||
private Set<Collection> collections = new HashSet<>();
|
||||
private final Set<Collection> collections = new HashSet<>();
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "admin")
|
||||
@@ -83,12 +83,6 @@ public class Community extends DSpaceObject implements DSpaceObjectLegacySupport
|
||||
@JoinColumn(name = "logo_bitstream_id")
|
||||
private Bitstream logo = null;
|
||||
|
||||
// Keys for accessing Community metadata
|
||||
public static final String COPYRIGHT_TEXT = "copyright_text";
|
||||
public static final String INTRODUCTORY_TEXT = "introductory_text";
|
||||
public static final String SHORT_DESCRIPTION = "short_description";
|
||||
public static final String SIDEBAR_TEXT = "side_bar_text";
|
||||
|
||||
@Transient
|
||||
protected transient CommunityService communityService;
|
||||
|
||||
|
@@ -37,6 +37,8 @@ import org.dspace.core.LogManager;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.dspace.eperson.service.GroupService;
|
||||
import org.dspace.event.Event;
|
||||
import org.dspace.identifier.IdentifierException;
|
||||
import org.dspace.identifier.service.IdentifierService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -51,7 +53,7 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(CommunityServiceImpl.class);
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(CommunityServiceImpl.class);
|
||||
|
||||
@Autowired(required = true)
|
||||
protected CommunityDAO communityDAO;
|
||||
@@ -69,6 +71,8 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
protected BitstreamService bitstreamService;
|
||||
@Autowired(required = true)
|
||||
protected SiteService siteService;
|
||||
@Autowired(required = true)
|
||||
protected IdentifierService identifierService;
|
||||
|
||||
protected CommunityServiceImpl() {
|
||||
super();
|
||||
@@ -90,17 +94,6 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
|
||||
Community newCommunity = communityDAO.create(context, new Community());
|
||||
|
||||
try {
|
||||
if (handle == null) {
|
||||
handleService.createHandle(context, newCommunity);
|
||||
} else {
|
||||
handleService.createHandle(context, newCommunity, handle);
|
||||
}
|
||||
} catch (IllegalStateException ie) {
|
||||
//If an IllegalStateException is thrown, then an existing object is already using this handle
|
||||
throw ie;
|
||||
}
|
||||
|
||||
if (parent != null) {
|
||||
parent.addSubCommunity(newCommunity);
|
||||
newCommunity.addParentCommunity(parent);
|
||||
@@ -115,14 +108,24 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
|
||||
communityDAO.save(context, newCommunity);
|
||||
|
||||
try {
|
||||
if (handle == null) {
|
||||
identifierService.register(context, newCommunity);
|
||||
} else {
|
||||
identifierService.register(context, newCommunity, handle);
|
||||
}
|
||||
} catch (IllegalStateException | IdentifierException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
|
||||
context.addEvent(new Event(Event.CREATE, Constants.COMMUNITY, newCommunity.getID(), newCommunity.getHandle(),
|
||||
getIdentifiers(context, newCommunity)));
|
||||
getIdentifiers(context, newCommunity)));
|
||||
|
||||
// if creating a top-level Community, simulate an ADD event at the Site.
|
||||
if (parent == null) {
|
||||
context.addEvent(new Event(Event.ADD, Constants.SITE, siteService.findSite(context).getID(),
|
||||
Constants.COMMUNITY, newCommunity.getID(), newCommunity.getHandle(),
|
||||
getIdentifiers(context, newCommunity)));
|
||||
Constants.COMMUNITY, newCommunity.getID(), newCommunity.getHandle(),
|
||||
getIdentifiers(context, newCommunity)));
|
||||
}
|
||||
|
||||
log.info(LogManager.getHeader(context, "create_community",
|
||||
@@ -175,17 +178,10 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMetadata(Community community, String field) {
|
||||
String[] MDValue = getMDValueByLegacyField(field);
|
||||
String value = getMetadataFirstValue(community, MDValue[0], MDValue[1], MDValue[2], Item.ANY);
|
||||
return value == null ? "" : value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(Context context, Community community, String field, String value)
|
||||
throws MissingResourceException, SQLException {
|
||||
if ((field.trim()).equals("name")
|
||||
&& (value == null || value.trim().equals(""))) {
|
||||
public void setMetadataSingleValue(Context context, Community community,
|
||||
MetadataFieldName field, String language, String value)
|
||||
throws MissingResourceException, SQLException {
|
||||
if (field.equals(MD_NAME) && (value == null || value.trim().equals(""))) {
|
||||
try {
|
||||
value = I18nUtil.getMessage("org.dspace.workflow.WorkflowManager.untitled");
|
||||
} catch (MissingResourceException e) {
|
||||
@@ -193,19 +189,19 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
}
|
||||
}
|
||||
|
||||
String[] MDValue = getMDValueByLegacyField(field);
|
||||
|
||||
/*
|
||||
* Set metadata field to null if null
|
||||
* and trim strings to eliminate excess
|
||||
* whitespace.
|
||||
*/
|
||||
if (value == null) {
|
||||
clearMetadata(context, community, MDValue[0], MDValue[1], MDValue[2], Item.ANY);
|
||||
clearMetadata(context, community, field.SCHEMA, field.ELEMENT, field.QUALIFIER, Item.ANY);
|
||||
community.setMetadataModified();
|
||||
} else {
|
||||
setMetadataSingleValue(context, community, MDValue[0], MDValue[1], MDValue[2], null, value);
|
||||
super.setMetadataSingleValue(context, community, field, null, value);
|
||||
}
|
||||
community.addDetails(field);
|
||||
|
||||
community.addDetails(field.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -310,7 +306,7 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
|
||||
@Override
|
||||
public List<Community> getAllParents(Context context, Community community) throws SQLException {
|
||||
List<Community> parentList = new ArrayList<Community>();
|
||||
List<Community> parentList = new ArrayList<>();
|
||||
Community parent = (Community) getParentObject(context, community);
|
||||
while (parent != null) {
|
||||
parentList.add(parent);
|
||||
@@ -332,7 +328,7 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
|
||||
|
||||
@Override
|
||||
public List<Collection> getAllCollections(Context context, Community community) throws SQLException {
|
||||
List<Collection> collectionList = new ArrayList<Collection>();
|
||||
List<Collection> collectionList = new ArrayList<>();
|
||||
List<Community> subCommunities = community.getSubcommunities();
|
||||
for (Community subCommunity : subCommunities) {
|
||||
addCollectionList(subCommunity, collectionList);
|
||||
|
@@ -131,7 +131,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(T dso, String schema, String element, String qualifier, String lang) {
|
||||
// Build up list of matching values
|
||||
List<MetadataValue> values = new ArrayList<MetadataValue>();
|
||||
List<MetadataValue> values = new ArrayList<>();
|
||||
for (MetadataValue dcv : dso.getMetadata()) {
|
||||
if (match(schema, element, qualifier, lang, dcv)) {
|
||||
values.add(dcv);
|
||||
@@ -298,7 +298,6 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
}
|
||||
}
|
||||
metadataValue.setValue(String.valueOf(dcvalue));
|
||||
;
|
||||
} else {
|
||||
metadataValue.setValue(null);
|
||||
}
|
||||
@@ -337,8 +336,8 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
.makeFieldKey(metadataField.getMetadataSchema().getName(), metadataField.getElement(),
|
||||
metadataField.getQualifier());
|
||||
if (metadataAuthorityService.isAuthorityControlled(fieldKey)) {
|
||||
List<String> authorities = new ArrayList<String>();
|
||||
List<Integer> confidences = new ArrayList<Integer>();
|
||||
List<String> authorities = new ArrayList<>();
|
||||
List<Integer> confidences = new ArrayList<>();
|
||||
for (int i = 0; i < values.size(); ++i) {
|
||||
if (dso instanceof Item) {
|
||||
getAuthoritiesAndConfidences(fieldKey, ((Item) dso).getOwningCollection(), values, authorities,
|
||||
@@ -410,6 +409,24 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve first metadata field value
|
||||
*
|
||||
* @param dso The DSpaceObject which we ask for metadata.
|
||||
* @param field {schema, element, qualifier} for the desired field.
|
||||
* @param language the language to match, or <code>Item.ANY</code>
|
||||
* @return the first metadata field value
|
||||
*/
|
||||
@Override
|
||||
public String getMetadataFirstValue(T dso, MetadataFieldName field, String language) {
|
||||
List<MetadataValue> metadataValues
|
||||
= getMetadata(dso, field.SCHEMA, field.ELEMENT, field.QUALIFIER, language);
|
||||
if (CollectionUtils.isNotEmpty(metadataValues)) {
|
||||
return metadataValues.get(0).getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set first metadata field value
|
||||
*
|
||||
@@ -425,6 +442,21 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadataSingleValue(Context context, T dso, MetadataFieldName field,
|
||||
String language, String value)
|
||||
throws SQLException {
|
||||
if (value != null) {
|
||||
clearMetadata(context, dso, field.SCHEMA, field.ELEMENT, field.QUALIFIER,
|
||||
language);
|
||||
|
||||
String newValueLanguage = (Item.ANY.equals(language)) ? null : language;
|
||||
addMetadata(context, dso, field.SCHEMA, field.ELEMENT, field.QUALIFIER,
|
||||
newValueLanguage, value);
|
||||
dso.setMetadataModified();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method for pattern-matching metadata elements. This
|
||||
* method will return <code>true</code> if the given schema,
|
||||
@@ -574,6 +606,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
//RelationshipMetadataValue instance.
|
||||
//This is done to ensure that the order is correct.
|
||||
metadataValues.sort(new Comparator<MetadataValue>() {
|
||||
@Override
|
||||
public int compare(MetadataValue o1, MetadataValue o2) {
|
||||
int compare = o1.getPlace() - o2.getPlace();
|
||||
if (compare == 0) {
|
||||
@@ -744,7 +777,12 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
}
|
||||
|
||||
/**
|
||||
* Supports moving metadata by updating the place of the metadata value
|
||||
* Supports moving metadata by updating the place of the metadata value.
|
||||
*
|
||||
* @param context current DSpace session.
|
||||
* @param dso unused.
|
||||
* @param place ordinal position of the value in the list of that field's values.
|
||||
* @param rr the value to be placed.
|
||||
*/
|
||||
protected void moveSingleMetadataValue(Context context, T dso, int place, MetadataValue rr) {
|
||||
//just move the metadata
|
||||
|
@@ -1333,7 +1333,7 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
if (StringUtils.equals(schema, MetadataSchemaEnum.RELATION.getName()) && !StringUtils.equals(element, "type")) {
|
||||
|
||||
List<RelationshipMetadataValue> relationMetadata = relationshipMetadataService
|
||||
.getRelationshipMetadata(item, false);
|
||||
.getRelationshipMetadata(item, enableVirtualMetadata);
|
||||
List<MetadataValue> listToReturn = new LinkedList<>();
|
||||
for (MetadataValue metadataValue : relationMetadata) {
|
||||
if (StringUtils.equals(metadataValue.getMetadataField().getElement(), element)) {
|
||||
|
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.content;
|
||||
|
||||
import java.util.Arrays;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* Simple immutable holder for the name of a metadata field.
|
||||
*
|
||||
* @author mwood
|
||||
*/
|
||||
public class MetadataFieldName {
|
||||
/** Name of the metadata schema which defines this field. Never null. */
|
||||
public final String SCHEMA;
|
||||
|
||||
/** Element name of this field. Never null. */
|
||||
public final String ELEMENT;
|
||||
|
||||
/** Qualifier name of this field. May be {@code null}. */
|
||||
public final String QUALIFIER;
|
||||
|
||||
/**
|
||||
* Initialize a tuple of (schema, element, qualifier) to name a metadata field.
|
||||
* @param schema name (not URI) of the schema. Cannot be null.
|
||||
* @param element element name of the field. Cannot be null.
|
||||
* @param qualifier qualifier name of the field.
|
||||
*/
|
||||
public MetadataFieldName(@Nonnull String schema, @Nonnull String element, String qualifier) {
|
||||
if (null == schema) {
|
||||
throw new NullPointerException("Schema must not be null.");
|
||||
}
|
||||
|
||||
if (null == element) {
|
||||
throw new NullPointerException("Element must not be null.");
|
||||
}
|
||||
|
||||
SCHEMA = schema;
|
||||
ELEMENT = element;
|
||||
QUALIFIER = qualifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a tuple of (schema, element, qualifier=null) to name a metadata field.
|
||||
* @param schema name (not URI) of the schema. Cannot be null.
|
||||
* @param element element name of the field. Cannot be null.
|
||||
*/
|
||||
public MetadataFieldName(@Nonnull String schema, @Nonnull String element) {
|
||||
if (null == schema) {
|
||||
throw new NullPointerException("Schema must not be null.");
|
||||
}
|
||||
|
||||
if (null == element) {
|
||||
throw new NullPointerException("Element must not be null.");
|
||||
}
|
||||
|
||||
SCHEMA = schema;
|
||||
ELEMENT = element;
|
||||
QUALIFIER = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a tuple of (schema, element, qualifier) to name a metadata field.
|
||||
* @param schema name (not URI) of the schema. Cannot be null.
|
||||
* @param element element name of the field. Cannot be null.
|
||||
* @param qualifier qualifier name of the field.
|
||||
*/
|
||||
public MetadataFieldName(@Nonnull MetadataSchemaEnum schema, @Nonnull String element, String qualifier) {
|
||||
if (null == schema) {
|
||||
throw new IllegalArgumentException("Schema must not be null.");
|
||||
}
|
||||
|
||||
if (null == element) {
|
||||
throw new IllegalArgumentException("Element must not be null.");
|
||||
}
|
||||
|
||||
SCHEMA = schema.getName();
|
||||
ELEMENT = element;
|
||||
QUALIFIER = qualifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a tuple of (schema, element, qualifier=null) to name a metadata field.
|
||||
* @param schema name (not URI) of the schema. Cannot be null.
|
||||
* @param element element name of the field. Cannot be null.
|
||||
*/
|
||||
public MetadataFieldName(@Nonnull MetadataSchemaEnum schema, @Nonnull String element) {
|
||||
if (null == schema) {
|
||||
throw new IllegalArgumentException("Schema must not be null.");
|
||||
}
|
||||
|
||||
if (null == element) {
|
||||
throw new IllegalArgumentException("Element must not be null.");
|
||||
}
|
||||
|
||||
SCHEMA = schema.getName();
|
||||
ELEMENT = element;
|
||||
QUALIFIER = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a tuple of (schema, element, qualifier) to name a metadata field.
|
||||
* @param name a dotted-triple {@code schema.element[.qualifier]}. If the
|
||||
* optional qualifier is omitted, it will be stored as {@code null}.
|
||||
*/
|
||||
public MetadataFieldName(@Nonnull String name) {
|
||||
String[] elements = parse(name);
|
||||
SCHEMA = elements[0];
|
||||
ELEMENT = elements[1];
|
||||
QUALIFIER = elements[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a dotted-triple field name {@code schema.element[.qualifier]} into
|
||||
* its components.
|
||||
* @param name the dotted-triple field name.
|
||||
* @return the components. Always of size 3. If the qualifier is omitted,
|
||||
* the third element is {@code null}.
|
||||
* @throws IllegalArgumentException if there are not at least two components.
|
||||
* @throws NullPointerException if {@code name} is null.
|
||||
*/
|
||||
public static String[] parse(@Nonnull String name) {
|
||||
if (null == name) {
|
||||
throw new NullPointerException("Name is null");
|
||||
}
|
||||
|
||||
String[] elements = name.split("\\.", 3);
|
||||
if (elements.length < 2) {
|
||||
throw new IllegalArgumentException("Not enough elements: " + name);
|
||||
}
|
||||
return Arrays.copyOf(elements, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a dotted-atoms representation of this field name.
|
||||
* @return SCHEMA.ELEMENT.QUALIFIER
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buffer = new StringBuilder(32);
|
||||
buffer.append(SCHEMA)
|
||||
.append('.')
|
||||
.append(ELEMENT);
|
||||
if (null != QUALIFIER) {
|
||||
buffer.append('.')
|
||||
.append(QUALIFIER);
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
@@ -8,21 +8,23 @@
|
||||
package org.dspace.content;
|
||||
|
||||
/**
|
||||
* This is an enum that holds track of a few special MetadataSchema types.
|
||||
* This is an enumeration that holds track of a few special MetadataSchema types.
|
||||
* It is important to note that this list is not exhaustive for the MetadataSchema
|
||||
* types and different MetadataSchema can easily be made.
|
||||
* These MetadataSchema objects are simply required.
|
||||
*/
|
||||
public enum MetadataSchemaEnum {
|
||||
DC("dc"), RELATION("relation");
|
||||
DC("dc"),
|
||||
EPERSON("eperson"),
|
||||
RELATION("relation");
|
||||
|
||||
/**
|
||||
* The String representation of the MetadataSchemaEnum
|
||||
*/
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Default constructor with the name parameter
|
||||
* Default constructor with the name parameter.
|
||||
* @param name The name parameter
|
||||
*/
|
||||
MetadataSchemaEnum(String name) {
|
||||
@@ -30,8 +32,8 @@ public enum MetadataSchemaEnum {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic getter for the String representation of the enum object
|
||||
* @return The name of the enum object
|
||||
* Generic getter for the String representation of the enumerated object.
|
||||
* @return The name of the enumerated object
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
|
@@ -85,14 +85,16 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
||||
Item otherItem;
|
||||
int place = 0;
|
||||
boolean isLeftwards;
|
||||
if (StringUtils.equals(relationshipType.getLeftType().getLabel(), entityType)) {
|
||||
if (StringUtils.equals(relationshipType.getLeftType().getLabel(), entityType) &&
|
||||
item.getID().equals(relationship.getLeftItem().getID())) {
|
||||
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getLeftwardType());
|
||||
otherItem = relationship.getRightItem();
|
||||
relationName = relationship.getRelationshipType().getLeftwardType();
|
||||
place = relationship.getLeftPlace();
|
||||
isLeftwards = false; //if the current item is stored on the left,
|
||||
// the name variant is retrieved from the rightwards label
|
||||
} else if (StringUtils.equals(relationshipType.getRightType().getLabel(), entityType)) {
|
||||
} else if (StringUtils.equals(relationshipType.getRightType().getLabel(), entityType) &&
|
||||
item.getID().equals(relationship.getRightItem().getID())) {
|
||||
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getRightwardType());
|
||||
otherItem = relationship.getLeftItem();
|
||||
relationName = relationship.getRelationshipType().getRightwardType();
|
||||
|
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.dspace.content;
|
||||
|
||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||
import org.dspace.core.Constants;
|
||||
|
||||
/**
|
||||
@@ -60,6 +61,11 @@ public class RelationshipMetadataValue extends MetadataValue {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return new HashCodeBuilder().append(getID()).append(isUseForPlace()).toHashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the Relationship ID from which the current RelationshipMetadataValue is derived
|
||||
*
|
||||
|
@@ -202,14 +202,14 @@ public class RelationshipServiceImpl implements RelationshipService {
|
||||
return false;
|
||||
}
|
||||
if (!verifyMaxCardinality(context, relationship.getLeftItem(),
|
||||
relationshipType.getLeftMaxCardinality(), relationshipType)) {
|
||||
relationshipType.getLeftMaxCardinality(), relationshipType, true)) {
|
||||
log.warn("The relationship has been deemed invalid since the left item has more" +
|
||||
" relationships than the left max cardinality allows after we'd store this relationship");
|
||||
logRelationshipTypeDetailsForError(relationshipType);
|
||||
return false;
|
||||
}
|
||||
if (!verifyMaxCardinality(context, relationship.getRightItem(),
|
||||
relationshipType.getRightMaxCardinality(), relationshipType)) {
|
||||
relationshipType.getRightMaxCardinality(), relationshipType, false)) {
|
||||
log.warn("The relationship has been deemed invalid since the right item has more" +
|
||||
" relationships than the right max cardinality allows after we'd store this relationship");
|
||||
logRelationshipTypeDetailsForError(relationshipType);
|
||||
@@ -232,9 +232,10 @@ public class RelationshipServiceImpl implements RelationshipService {
|
||||
|
||||
private boolean verifyMaxCardinality(Context context, Item itemToProcess,
|
||||
Integer maxCardinality,
|
||||
RelationshipType relationshipType) throws SQLException {
|
||||
RelationshipType relationshipType,
|
||||
boolean isLeft) throws SQLException {
|
||||
List<Relationship> rightRelationships = findByItemAndRelationshipType(context, itemToProcess, relationshipType,
|
||||
false);
|
||||
isLeft);
|
||||
if (maxCardinality != null && rightRelationships.size() >= maxCardinality) {
|
||||
return false;
|
||||
}
|
||||
@@ -559,9 +560,9 @@ public class RelationshipServiceImpl implements RelationshipService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType)
|
||||
throws SQLException {
|
||||
return relationshipDAO.countByItemAndRelationshipType(context, item, relationshipType);
|
||||
public int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType,
|
||||
boolean isLeft) throws SQLException {
|
||||
return relationshipDAO.countByItemAndRelationshipType(context, item, relationshipType, isLeft);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -14,9 +14,10 @@ import javax.persistence.Transient;
|
||||
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.SiteService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
|
||||
/**
|
||||
@@ -56,7 +57,9 @@ public class Site extends DSpaceObject {
|
||||
}
|
||||
|
||||
public String getURL() {
|
||||
return ConfigurationManager.getProperty("dspace.ui.url");
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
return configurationService.getProperty("dspace.ui.url");
|
||||
}
|
||||
|
||||
private SiteService getSiteService() {
|
||||
|
@@ -15,7 +15,6 @@ import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.content.dao.SiteDAO;
|
||||
import org.dspace.content.service.SiteService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.event.Event;
|
||||
@@ -94,7 +93,7 @@ public class SiteServiceImpl extends DSpaceObjectServiceImpl<Site> implements Si
|
||||
|
||||
@Override
|
||||
public String getName(Site dso) {
|
||||
return ConfigurationManager.getProperty("dspace.name");
|
||||
return configurationService.getProperty("dspace.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -9,23 +9,23 @@ package org.dspace.content.authority;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.authority.service.MetadataAuthorityService;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* Broker for metadata authority settings configured for each metadata field.
|
||||
*
|
||||
* Configuration keys, per metadata field (e.g. "dc.contributer.author")
|
||||
* Configuration keys, per metadata field (e.g. "dc.contributor.author")
|
||||
*
|
||||
* {@code
|
||||
* # is field authority controlled (i.e. store authority, confidence values)?
|
||||
@@ -52,13 +52,18 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* @see Choices
|
||||
*/
|
||||
public class MetadataAuthorityServiceImpl implements MetadataAuthorityService {
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(MetadataAuthorityServiceImpl.class);
|
||||
private static final Logger log = LogManager.getLogger(MetadataAuthorityServiceImpl.class);
|
||||
|
||||
private static final String AUTH_PREFIX = "authority.controlled";
|
||||
|
||||
@Autowired(required = true)
|
||||
protected MetadataFieldService metadataFieldService;
|
||||
|
||||
@Autowired(required = true)
|
||||
protected ConfigurationService configurationService;
|
||||
|
||||
// map of field key to authority plugin
|
||||
protected Map<String, Boolean> controlled = new HashMap<String, Boolean>();
|
||||
protected Map<String, Boolean> controlled = new HashMap<>();
|
||||
|
||||
// map of field key to answer of whether field is required to be controlled
|
||||
protected Map<String, Boolean> isAuthorityRequired = null;
|
||||
@@ -67,7 +72,7 @@ public class MetadataAuthorityServiceImpl implements MetadataAuthorityService {
|
||||
* map of field key to answer of which is the min acceptable confidence
|
||||
* value for a field with authority
|
||||
*/
|
||||
protected Map<String, Integer> minConfidence = new HashMap<String, Integer>();
|
||||
protected Map<String, Integer> minConfidence = new HashMap<>();
|
||||
|
||||
/**
|
||||
* fallback default value unless authority.minconfidence = X is configured.
|
||||
@@ -81,54 +86,50 @@ public class MetadataAuthorityServiceImpl implements MetadataAuthorityService {
|
||||
public void init() {
|
||||
|
||||
if (isAuthorityRequired == null) {
|
||||
isAuthorityRequired = new HashMap<String, Boolean>();
|
||||
Enumeration pn = ConfigurationManager.propertyNames();
|
||||
final String authPrefix = "authority.controlled.";
|
||||
isAuthorityRequired = new HashMap<>();
|
||||
List<String> keys = configurationService.getPropertyKeys(AUTH_PREFIX);
|
||||
Context context = new Context();
|
||||
try {
|
||||
while (pn.hasMoreElements()) {
|
||||
String key = (String) pn.nextElement();
|
||||
if (key.startsWith(authPrefix)) {
|
||||
// field is expected to be "schema.element.qualifier"
|
||||
String field = key.substring(authPrefix.length());
|
||||
int dot = field.indexOf('.');
|
||||
if (dot < 0) {
|
||||
log.warn(
|
||||
"Skipping invalid MetadataAuthority configuration property: " + key + ": does not " +
|
||||
"have schema.element.qualifier");
|
||||
continue;
|
||||
}
|
||||
String schema = field.substring(0, dot);
|
||||
String element = field.substring(dot + 1);
|
||||
String qualifier = null;
|
||||
dot = element.indexOf('.');
|
||||
if (dot >= 0) {
|
||||
qualifier = element.substring(dot + 1);
|
||||
element = element.substring(0, dot);
|
||||
}
|
||||
|
||||
|
||||
MetadataField metadataField = metadataFieldService
|
||||
.findByElement(context, schema, element, qualifier);
|
||||
if (metadataField == null) {
|
||||
throw new IllegalStateException(
|
||||
"Error while configuring authority control, metadata field: " + field + " could not " +
|
||||
"be found");
|
||||
}
|
||||
boolean ctl = ConfigurationManager.getBooleanProperty(key, true);
|
||||
boolean req = ConfigurationManager.getBooleanProperty("authority.required." + field, false);
|
||||
controlled.put(metadataField.toString(), ctl);
|
||||
isAuthorityRequired.put(metadataField.toString(), req);
|
||||
|
||||
// get minConfidence level for this field if any
|
||||
int mci = readConfidence("authority.minconfidence." + field);
|
||||
if (mci >= Choices.CF_UNSET) {
|
||||
minConfidence.put(metadataField.toString(), mci);
|
||||
}
|
||||
log.debug(
|
||||
"Authority Control: For schema=" + schema + ", elt=" + element + ", qual=" + qualifier +
|
||||
", controlled=" + ctl + ", required=" + req);
|
||||
for (String key : keys) {
|
||||
// field is expected to be "schema.element.qualifier"
|
||||
String field = key.substring(AUTH_PREFIX.length() + 1);
|
||||
int dot = field.indexOf('.');
|
||||
if (dot < 0) {
|
||||
log.warn(
|
||||
"Skipping invalid MetadataAuthority configuration property: {}:"
|
||||
+ " does not have schema.element.qualifier", key);
|
||||
continue;
|
||||
}
|
||||
String schema = field.substring(0, dot);
|
||||
String element = field.substring(dot + 1);
|
||||
String qualifier = null;
|
||||
dot = element.indexOf('.');
|
||||
if (dot >= 0) {
|
||||
qualifier = element.substring(dot + 1);
|
||||
element = element.substring(0, dot);
|
||||
}
|
||||
|
||||
|
||||
MetadataField metadataField = metadataFieldService
|
||||
.findByElement(context, schema, element, qualifier);
|
||||
if (metadataField == null) {
|
||||
throw new IllegalStateException(
|
||||
"Error while configuring authority control, metadata field: " + field + " could not " +
|
||||
"be found");
|
||||
}
|
||||
boolean ctl = configurationService.getBooleanProperty(key, true);
|
||||
boolean req = configurationService.getBooleanProperty("authority.required." + field, false);
|
||||
controlled.put(metadataField.toString(), ctl);
|
||||
isAuthorityRequired.put(metadataField.toString(), req);
|
||||
|
||||
// get minConfidence level for this field if any
|
||||
int mci = readConfidence("authority.minconfidence." + field);
|
||||
if (mci >= Choices.CF_UNSET) {
|
||||
minConfidence.put(metadataField.toString(), mci);
|
||||
}
|
||||
log.debug(
|
||||
"Authority Control: For schema=" + schema + ", elt=" + element + ", qual=" + qualifier +
|
||||
", controlled=" + ctl + ", required=" + req);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Error reading authority config", e);
|
||||
@@ -143,7 +144,7 @@ public class MetadataAuthorityServiceImpl implements MetadataAuthorityService {
|
||||
}
|
||||
|
||||
private int readConfidence(String key) {
|
||||
String mc = ConfigurationManager.getProperty(key);
|
||||
String mc = configurationService.getProperty(key);
|
||||
if (mc != null) {
|
||||
int mci = Choices.getConfidenceValue(mc.trim(), Choices.CF_UNSET - 1);
|
||||
if (mci == Choices.CF_UNSET - 1) {
|
||||
|
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.dspace.content.authority;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -14,8 +15,10 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
@@ -25,7 +28,6 @@ import org.dspace.authority.AuthorityValue;
|
||||
import org.dspace.authority.SolrAuthorityInterface;
|
||||
import org.dspace.authority.factory.AuthorityServiceFactory;
|
||||
import org.dspace.authority.service.AuthorityValueService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.NameAwarePlugin;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
@@ -49,13 +51,16 @@ public class SolrAuthority implements ChoiceAuthority {
|
||||
DSpaceServicesFactory.getInstance().getServiceManager()
|
||||
.getServiceByName("AuthoritySource", SolrAuthorityInterface.class);
|
||||
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(SolrAuthority.class);
|
||||
private static final Logger log = LogManager.getLogger(SolrAuthority.class);
|
||||
|
||||
protected boolean externalResults = false;
|
||||
protected final AuthorityValueService authorityValueService = AuthorityServiceFactory.getInstance()
|
||||
.getAuthorityValueService();
|
||||
protected final ConfigurationService configurationService = DSpaceServicesFactory.getInstance()
|
||||
.getConfigurationService();
|
||||
|
||||
protected final AuthorityValueService authorityValueService
|
||||
= AuthorityServiceFactory.getInstance().getAuthorityValueService();
|
||||
|
||||
protected final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
public Choices getMatches(String text, int start, int limit, String locale,
|
||||
boolean bestMatch) {
|
||||
if (limit == 0) {
|
||||
@@ -91,7 +96,7 @@ public class SolrAuthority implements ChoiceAuthority {
|
||||
//We add one to our facet limit so that we know if there are more matches
|
||||
int maxNumberOfSolrResults = limit + 1;
|
||||
if (externalResults) {
|
||||
maxNumberOfSolrResults = ConfigurationManager.getIntProperty("xmlui.lookup.select.size", 12);
|
||||
maxNumberOfSolrResults = configurationService.getIntProperty("xmlui.lookup.select.size", 12);
|
||||
}
|
||||
queryArgs.set(CommonParams.ROWS, maxNumberOfSolrResults);
|
||||
|
||||
@@ -144,7 +149,7 @@ public class SolrAuthority implements ChoiceAuthority {
|
||||
|
||||
|
||||
int confidence;
|
||||
if (choices.size() == 0) {
|
||||
if (choices.isEmpty()) {
|
||||
confidence = Choices.CF_NOTFOUND;
|
||||
} else if (choices.size() == 1) {
|
||||
confidence = Choices.CF_UNCERTAIN;
|
||||
@@ -154,7 +159,7 @@ public class SolrAuthority implements ChoiceAuthority {
|
||||
|
||||
result = new Choices(choices.toArray(new Choice[choices.size()]), start,
|
||||
hasMore ? max : choices.size() + start, confidence, hasMore);
|
||||
} catch (Exception e) {
|
||||
} catch (IOException | SolrServerException e) {
|
||||
log.error("Error while retrieving authority values {field: " + field + ", prefix:" + text + "}", e);
|
||||
result = new Choices(true);
|
||||
}
|
||||
@@ -269,7 +274,7 @@ public class SolrAuthority implements ChoiceAuthority {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (IOException | SolrServerException e) {
|
||||
log.error("error occurred while trying to get label for key " + key, e);
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,6 @@ import org.dspace.content.service.BitstreamFormatService;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.SiteService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
@@ -39,6 +38,8 @@ import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
|
||||
@@ -51,29 +52,34 @@ import org.jdom.Namespace;
|
||||
* a complete and accurate image of all of the attributes an object
|
||||
* has in the RDBMS.
|
||||
*
|
||||
* <p>
|
||||
* It encodes the following common properties of all archival objects:
|
||||
* <dl>
|
||||
* <dt>identifier.uri</dt> <dd>persistent identifier of object in URI form (e.g. Handle URN)</dd>
|
||||
* <dt>relation.isPartOf</dt> <dd>persistent identifier of object's parent in URI form (e.g. Handle URN)</dd>
|
||||
* <dt>relation.isReferencedBy</dt> <dd>if relevant, persistent identifier of
|
||||
* other objects that map this one as a child. May repeat.</dd>
|
||||
* </dl>
|
||||
*
|
||||
* identifier.uri -- persistent identifier of object in URI form (e.g. Handle URN)
|
||||
* relation.isPartOf -- persistent identifier of object's parent in URI form (e.g. Handle URN)
|
||||
* relation.isReferencedBy -- if relevant, persistent identifier of other objects that map this one as a child. May
|
||||
* repeat.
|
||||
*
|
||||
* <p>
|
||||
* There may also be other fields, depending on the type of object,
|
||||
* which encode attributes that are not part of the descriptive metadata and
|
||||
* are not adequately covered by other technical MD formats (i.e. PREMIS).
|
||||
*
|
||||
* <p>
|
||||
* Configuration entries:
|
||||
* aip.ingest.createEperson -- boolean, create EPerson for Submitter
|
||||
* automatically, on ingest, if it doesn't exist.
|
||||
* <dl>
|
||||
* <dt>aip.ingest.createEperson</dt> <dd>boolean, create EPerson for Submitter
|
||||
* automatically, on ingest, if it doesn't exist.</dd>
|
||||
* </dl>
|
||||
*
|
||||
* @author Larry Stone
|
||||
* @version $Revision: 1.2 $
|
||||
*/
|
||||
public class AIPTechMDCrosswalk implements IngestionCrosswalk, DisseminationCrosswalk {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(AIPTechMDCrosswalk.class);
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(AIPTechMDCrosswalk.class);
|
||||
protected final BitstreamFormatService bitstreamFormatService = ContentServiceFactory.getInstance()
|
||||
.getBitstreamFormatService();
|
||||
protected final SiteService siteService = ContentServiceFactory.getInstance().getSiteService();
|
||||
@@ -81,6 +87,8 @@ public class AIPTechMDCrosswalk implements IngestionCrosswalk, DisseminationCros
|
||||
protected final EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||
protected final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
protected final HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||
protected final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
/**
|
||||
* Get XML namespaces of the elements this crosswalk may return.
|
||||
@@ -391,7 +399,7 @@ public class AIPTechMDCrosswalk implements IngestionCrosswalk, DisseminationCros
|
||||
String configName = new DSpaceAIPIngester().getConfigurationName();
|
||||
|
||||
//Create the EPerson if specified and person doesn't already exit
|
||||
if (ConfigurationManager.getBooleanProperty(
|
||||
if (configurationService.getBooleanProperty(
|
||||
METSManifest.CONFIG_METS_PREFIX + configName + ".ingest.createSubmitter")) {
|
||||
sub = ePersonService.create(context);
|
||||
sub.setEmail(value);
|
||||
|
@@ -11,6 +11,7 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Bitstream;
|
||||
@@ -28,10 +29,11 @@ import org.dspace.license.service.CreativeCommonsService;
|
||||
* Export the object's Creative Commons license, text form.
|
||||
*
|
||||
* @author Larry Stone
|
||||
* @version $Revision: 1.0 $
|
||||
* @deprecated to make uniform JSPUI and XMLUI approach the bitstream with the license in the textual format it is no
|
||||
* @deprecated to make uniform JSPUI and XMLUI approach the bitstream with the
|
||||
* license in the textual format it is no
|
||||
* longer stored (see https://jira.duraspace.org/browse/DS-2604)
|
||||
*/
|
||||
@Deprecated
|
||||
public class CreativeCommonsTextStreamDisseminationCrosswalk
|
||||
implements StreamDisseminationCrosswalk {
|
||||
|
||||
@@ -42,8 +44,8 @@ public class CreativeCommonsTextStreamDisseminationCrosswalk
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log =
|
||||
org.apache.logging.log4j.LogManager.getLogger(CreativeCommonsTextStreamDisseminationCrosswalk.class);
|
||||
private static final Logger log =
|
||||
LogManager.getLogger(CreativeCommonsTextStreamDisseminationCrosswalk.class);
|
||||
|
||||
@Override
|
||||
public boolean canDisseminate(Context context, DSpaceObject dso) {
|
||||
|
@@ -21,8 +21,9 @@ import org.dspace.content.NonUniqueMetadataException;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.MetadataFieldService;
|
||||
import org.dspace.content.service.MetadataSchemaService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
public class CrosswalkMetadataValidator {
|
||||
|
||||
@@ -32,21 +33,23 @@ public class CrosswalkMetadataValidator {
|
||||
private String schemaChoice;
|
||||
private String fieldChoice;
|
||||
|
||||
private Map<Triple<String, String, String>, MetadataField> validatedMetadataFields;
|
||||
private final Map<Triple<String, String, String>, MetadataField> validatedMetadataFields;
|
||||
|
||||
public CrosswalkMetadataValidator() {
|
||||
metadataSchemaService = ContentServiceFactory.getInstance().getMetadataSchemaService();
|
||||
metadataFieldService = ContentServiceFactory.getInstance().getMetadataFieldService();
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
validatedMetadataFields = new HashMap<>();
|
||||
|
||||
// The two options, with three possibilities each: add, ignore, fail
|
||||
schemaChoice = ConfigurationManager.getProperty("oai", "harvester.unknownSchema");
|
||||
schemaChoice = configurationService.getProperty("oai.harvester.unknownSchema");
|
||||
if (schemaChoice == null) {
|
||||
schemaChoice = "fail";
|
||||
}
|
||||
|
||||
fieldChoice = ConfigurationManager.getProperty("oai", "harvester.unknownField");
|
||||
fieldChoice = configurationService.getProperty("oai.harvester.unknownField");
|
||||
if (fieldChoice == null) {
|
||||
fieldChoice = "fail";
|
||||
}
|
||||
@@ -123,6 +126,6 @@ public class CrosswalkMetadataValidator {
|
||||
|
||||
private ImmutableTriple<String, String, String> createKey(final String schema, final String element,
|
||||
final String qualifier) {
|
||||
return new ImmutableTriple<String, String, String>(schema, element, qualifier);
|
||||
return new ImmutableTriple<>(schema, element, qualifier);
|
||||
}
|
||||
}
|
||||
|
@@ -19,10 +19,11 @@ import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.packager.PackageDisseminator;
|
||||
import org.dspace.content.packager.PackageException;
|
||||
import org.dspace.content.packager.PackageParameters;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
@@ -85,7 +86,7 @@ public class METSDisseminationCrosswalk
|
||||
public List<Element> disseminateList(Context context, DSpaceObject dso)
|
||||
throws CrosswalkException,
|
||||
IOException, SQLException, AuthorizeException {
|
||||
List<Element> result = new ArrayList<Element>(1);
|
||||
List<Element> result = new ArrayList<>(1);
|
||||
result.add(disseminateElement(context, dso));
|
||||
return result;
|
||||
}
|
||||
@@ -114,8 +115,11 @@ public class METSDisseminationCrosswalk
|
||||
pparams.put("manifestOnly", "true");
|
||||
|
||||
// Create a temporary file to disseminate into
|
||||
String tempDirectory = (ConfigurationManager.getProperty("upload.temp.dir") != null)
|
||||
? ConfigurationManager.getProperty("upload.temp.dir") : System.getProperty("java.io.tmpdir");
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String tempDirectory = (configurationService.hasProperty("upload.temp.dir"))
|
||||
? configurationService.getProperty("upload.temp.dir")
|
||||
: System.getProperty("java.io.tmpdir");
|
||||
|
||||
File tempFile = File.createTempFile("METSDissemination" + dso.hashCode(), null, new File(tempDirectory));
|
||||
tempFile.deleteOnExit();
|
||||
|
@@ -21,6 +21,7 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Collection;
|
||||
@@ -34,12 +35,13 @@ import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.SelfNamedPlugin;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
@@ -84,14 +86,13 @@ import org.jdom.xpath.XPath;
|
||||
*
|
||||
* @author Larry Stone
|
||||
* @author Scott Phillips
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
implements DisseminationCrosswalk {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(MODSDisseminationCrosswalk.class);
|
||||
private static final Logger log = LogManager.getLogger(MODSDisseminationCrosswalk.class);
|
||||
|
||||
private static final String CONFIG_PREFIX = "crosswalk.mods.properties.";
|
||||
|
||||
@@ -99,6 +100,8 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
protected final CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
|
||||
protected final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
protected final HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||
protected static final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
/**
|
||||
* Fill in the plugin alias table from DSpace configuration entries
|
||||
@@ -107,13 +110,10 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
private static String aliases[] = null;
|
||||
|
||||
static {
|
||||
List<String> aliasList = new ArrayList<String>();
|
||||
Enumeration<String> pe = (Enumeration<String>) ConfigurationManager.propertyNames();
|
||||
while (pe.hasMoreElements()) {
|
||||
String key = pe.nextElement();
|
||||
if (key.startsWith(CONFIG_PREFIX)) {
|
||||
aliasList.add(key.substring(CONFIG_PREFIX.length()));
|
||||
}
|
||||
List<String> aliasList = new ArrayList<>();
|
||||
List<String> keys = configurationService.getPropertyKeys(CONFIG_PREFIX);
|
||||
for (String key : keys) {
|
||||
aliasList.add(key.substring(CONFIG_PREFIX.length()));
|
||||
}
|
||||
aliases = (String[]) aliasList.toArray(new String[aliasList.size()]);
|
||||
}
|
||||
@@ -142,8 +142,8 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
private static final String schemaLocation =
|
||||
MODS_NS.getURI() + " " + MODS_XSD;
|
||||
|
||||
private static XMLOutputter outputUgly = new XMLOutputter();
|
||||
private static SAXBuilder builder = new SAXBuilder();
|
||||
private static final XMLOutputter outputUgly = new XMLOutputter();
|
||||
private static final SAXBuilder builder = new SAXBuilder();
|
||||
|
||||
private Map<String, modsTriple> modsMap = null;
|
||||
|
||||
@@ -176,11 +176,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
result.xpath.addNamespace(XLINK_NS);
|
||||
Document d = builder.build(new StringReader(prolog + xml + postlog));
|
||||
result.xml = (Element) d.getRootElement().getContent(0);
|
||||
} catch (JDOMException je) {
|
||||
log.error("Error initializing modsTriple(\"" + qdc + "\",\"" + xml + "\",\"" + xpath + "\"): got " + je
|
||||
.toString());
|
||||
return null;
|
||||
} catch (IOException je) {
|
||||
} catch (JDOMException | IOException je) {
|
||||
log.error("Error initializing modsTriple(\"" + qdc + "\",\"" + xml + "\",\"" + xpath + "\"): got " + je
|
||||
.toString());
|
||||
return null;
|
||||
@@ -226,14 +222,14 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
return;
|
||||
}
|
||||
String cmPropName = CONFIG_PREFIX + myAlias;
|
||||
String propsFilename = ConfigurationManager.getProperty(cmPropName);
|
||||
String propsFilename = configurationService.getProperty(cmPropName);
|
||||
if (propsFilename == null) {
|
||||
String msg = "MODS crosswalk missing " +
|
||||
"configuration file for crosswalk named \"" + myAlias + "\"";
|
||||
log.error(msg);
|
||||
throw new CrosswalkInternalException(msg);
|
||||
} else {
|
||||
String parent = ConfigurationManager.getProperty("dspace.dir") +
|
||||
String parent = configurationService.getProperty("dspace.dir") +
|
||||
File.separator + "config" + File.separator;
|
||||
File propsFile = new File(parent, propsFilename);
|
||||
Properties modsConfig = new Properties();
|
||||
@@ -256,7 +252,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
}
|
||||
}
|
||||
|
||||
modsMap = new HashMap<String, modsTriple>();
|
||||
modsMap = new HashMap<>();
|
||||
Enumeration<String> pe = (Enumeration<String>) modsConfig.propertyNames();
|
||||
while (pe.hasMoreElements()) {
|
||||
String qdc = pe.nextElement();
|
||||
@@ -343,7 +339,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
}
|
||||
initMap();
|
||||
|
||||
List<Element> result = new ArrayList<Element>(dcvs.size());
|
||||
List<Element> result = new ArrayList<>(dcvs.size());
|
||||
|
||||
for (MetadataValueDTO dcv : dcvs) {
|
||||
String qdc = dcv.getSchema() + "." + dcv.getElement();
|
||||
@@ -453,13 +449,18 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
protected List<MetadataValueDTO> community2Metadata(Community community) {
|
||||
List<MetadataValueDTO> metadata = new ArrayList<>();
|
||||
|
||||
String description = communityService.getMetadata(community, "introductory_text");
|
||||
String description_abstract = communityService.getMetadata(community, "short_description");
|
||||
String description_table = communityService.getMetadata(community, "side_bar_text");
|
||||
String description = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
String description_abstract = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
String description_table = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
String identifier_uri = handleService.getCanonicalPrefix()
|
||||
+ community.getHandle();
|
||||
String rights = communityService.getMetadata(community, "copyright_text");
|
||||
String title = communityService.getMetadata(community, "name");
|
||||
String rights = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
String title = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_NAME, Item.ANY);
|
||||
|
||||
metadata.add(createDCValue("description", null, description));
|
||||
|
||||
@@ -496,15 +497,22 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
protected List<MetadataValueDTO> collection2Metadata(Collection collection) {
|
||||
List<MetadataValueDTO> metadata = new ArrayList<>();
|
||||
|
||||
String description = collectionService.getMetadata(collection, "introductory_text");
|
||||
String description_abstract = collectionService.getMetadata(collection, "short_description");
|
||||
String description_table = collectionService.getMetadata(collection, "side_bar_text");
|
||||
String description = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
String description_abstract = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
String description_table = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
String identifier_uri = handleService.getCanonicalPrefix()
|
||||
+ collection.getHandle();
|
||||
String provenance = collectionService.getMetadata(collection, "provenance_description");
|
||||
String rights = collectionService.getMetadata(collection, "copyright_text");
|
||||
String rights_license = collectionService.getMetadata(collection, "license");
|
||||
String title = collectionService.getMetadata(collection, "name");
|
||||
String provenance = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_PROVENANCE_DESCRIPTION, Item.ANY);
|
||||
String rights = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
String rights_license = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_LICENSE, Item.ANY);
|
||||
String title = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_NAME, Item.ANY);
|
||||
|
||||
if (description != null) {
|
||||
metadata.add(createDCValue("description", null, description));
|
||||
@@ -579,7 +587,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Filtering out non-XML characters in string, reason=" + reason);
|
||||
}
|
||||
StringBuffer result = new StringBuffer(value.length());
|
||||
StringBuilder result = new StringBuilder(value.length());
|
||||
for (int i = 0; i < value.length(); ++i) {
|
||||
char c = value.charAt(i);
|
||||
if (Verifier.isXMLCharacter((int) c)) {
|
||||
|
@@ -15,6 +15,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Bitstream;
|
||||
@@ -25,9 +26,10 @@ import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.BitstreamFormatService;
|
||||
import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
|
||||
@@ -41,27 +43,29 @@ import org.jdom.Namespace;
|
||||
* specification for both ingest and dissemination.
|
||||
*
|
||||
* @author Larry Stone
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class PREMISCrosswalk
|
||||
implements IngestionCrosswalk, DisseminationCrosswalk {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(PREMISCrosswalk.class);
|
||||
private static final Logger log = LogManager.getLogger(PREMISCrosswalk.class);
|
||||
|
||||
private static final Namespace PREMIS_NS =
|
||||
Namespace.getNamespace("premis", "http://www.loc.gov/standards/premis");
|
||||
|
||||
// XML schemaLocation fragment for this crosswalk, from config.
|
||||
private String schemaLocation =
|
||||
private final String schemaLocation =
|
||||
PREMIS_NS.getURI() + " http://www.loc.gov/standards/premis/PREMIS-v1-0.xsd";
|
||||
|
||||
private static final Namespace namespaces[] = {PREMIS_NS};
|
||||
|
||||
protected BitstreamService bitstreamService = ContentServiceFactory.getInstance().getBitstreamService();
|
||||
protected BitstreamFormatService bitstreamFormatService = ContentServiceFactory.getInstance()
|
||||
.getBitstreamFormatService();
|
||||
protected BitstreamService bitstreamService
|
||||
= ContentServiceFactory.getInstance().getBitstreamService();
|
||||
protected BitstreamFormatService bitstreamFormatService
|
||||
= ContentServiceFactory.getInstance().getBitstreamFormatService();
|
||||
protected ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
/*----------- Submission functions -------------------*/
|
||||
|
||||
@@ -219,7 +223,7 @@ public class PREMISCrosswalk
|
||||
// b. name of bitstream, if any
|
||||
// c. made-up name based on sequence ID and extension.
|
||||
String sid = String.valueOf(bitstream.getSequenceID());
|
||||
String baseUrl = ConfigurationManager.getProperty("dspace.ui.url");
|
||||
String baseUrl = configurationService.getProperty("dspace.ui.url");
|
||||
String handle = null;
|
||||
// get handle of parent Item of this bitstream, if there is one:
|
||||
List<Bundle> bn = bitstream.getBundles();
|
||||
@@ -308,7 +312,7 @@ public class PREMISCrosswalk
|
||||
public List<Element> disseminateList(Context context, DSpaceObject dso)
|
||||
throws CrosswalkException,
|
||||
IOException, SQLException, AuthorizeException {
|
||||
List<Element> result = new ArrayList<Element>(1);
|
||||
List<Element> result = new ArrayList<>(1);
|
||||
result.add(disseminateElement(context, dso));
|
||||
return result;
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
@@ -30,10 +31,11 @@ import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.SelfNamedPlugin;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
@@ -44,7 +46,7 @@ import org.jdom.input.SAXBuilder;
|
||||
* <p>
|
||||
* This class supports multiple dissemination crosswalks from DSpace
|
||||
* internal data to the Qualified Dublin Core XML format
|
||||
* (see <a href="http://dublincore.org/">http://dublincore.org/</a>
|
||||
* (see <a href="http://dublincore.org/">http://dublincore.org/</a>).
|
||||
* <p>
|
||||
* It registers multiple Plugin names, which it reads from
|
||||
* the DSpace configuration as follows:
|
||||
@@ -91,20 +93,19 @@ import org.jdom.input.SAXBuilder;
|
||||
* http://dublincore.org/schemas/xmls/qdc/2003/04/02/qualifieddc.xsd</pre>
|
||||
*
|
||||
* @author Larry Stone
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class QDCCrosswalk extends SelfNamedPlugin
|
||||
implements DisseminationCrosswalk, IngestionCrosswalk {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(QDCCrosswalk.class);
|
||||
private static final Logger log = LogManager.getLogger(QDCCrosswalk.class);
|
||||
|
||||
// map of qdc to JDOM Element
|
||||
private Map<String, Element> qdc2element = new HashMap<String, Element>();
|
||||
private final Map<String, Element> qdc2element = new HashMap<>();
|
||||
|
||||
// map of JDOM Element to qdc Metadatum
|
||||
private Map<String, String> element2qdc = new HashMap<String, String>();
|
||||
private final Map<String, String> element2qdc = new HashMap<>();
|
||||
|
||||
// the XML namespaces from config file for this name.
|
||||
private Namespace namespaces[] = null;
|
||||
@@ -124,11 +125,14 @@ public class QDCCrosswalk extends SelfNamedPlugin
|
||||
// XML schemaLocation fragment for this crosswalk, from config.
|
||||
private String schemaLocation = null;
|
||||
|
||||
private static SAXBuilder builder = new SAXBuilder();
|
||||
private static final SAXBuilder builder = new SAXBuilder();
|
||||
|
||||
protected ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
|
||||
private CrosswalkMetadataValidator metadataValidator = new CrosswalkMetadataValidator();
|
||||
protected static final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
private final CrosswalkMetadataValidator metadataValidator = new CrosswalkMetadataValidator();
|
||||
|
||||
/**
|
||||
* Fill in the plugin-name table from DSpace configuration entries
|
||||
@@ -137,14 +141,11 @@ public class QDCCrosswalk extends SelfNamedPlugin
|
||||
private static String aliases[] = null;
|
||||
|
||||
static {
|
||||
List<String> aliasList = new ArrayList<String>();
|
||||
Enumeration<String> pe = (Enumeration<String>) ConfigurationManager.propertyNames();
|
||||
List<String> aliasList = new ArrayList<>();
|
||||
String propname = CONFIG_PREFIX + ".properties.";
|
||||
while (pe.hasMoreElements()) {
|
||||
String key = pe.nextElement();
|
||||
if (key.startsWith(propname)) {
|
||||
aliasList.add(key.substring(propname.length()));
|
||||
}
|
||||
List<String> configKeys = configurationService.getPropertyKeys(propname);
|
||||
for (String key : configKeys) {
|
||||
aliasList.add(key.substring(propname.length()));
|
||||
}
|
||||
aliases = (String[]) aliasList.toArray(new String[aliasList.size()]);
|
||||
}
|
||||
@@ -212,38 +213,35 @@ public class QDCCrosswalk extends SelfNamedPlugin
|
||||
|
||||
myName = getPluginInstanceName();
|
||||
if (myName == null) {
|
||||
throw new CrosswalkInternalException("Cannot determine plugin name, " +
|
||||
throw new CrosswalkInternalException("Cannot determine plugin name. " +
|
||||
"You must use PluginService to instantiate QDCCrosswalk so the " +
|
||||
"instance knows its name.");
|
||||
}
|
||||
|
||||
// grovel DSpace configuration for namespaces
|
||||
List<Namespace> nsList = new ArrayList<Namespace>();
|
||||
Enumeration<String> pe = (Enumeration<String>) ConfigurationManager.propertyNames();
|
||||
List<Namespace> nsList = new ArrayList<>();
|
||||
String propname = CONFIG_PREFIX + ".namespace." + myName + ".";
|
||||
while (pe.hasMoreElements()) {
|
||||
String key = pe.nextElement();
|
||||
if (key.startsWith(propname)) {
|
||||
nsList.add(Namespace.getNamespace(key.substring(propname.length()),
|
||||
ConfigurationManager.getProperty(key)));
|
||||
}
|
||||
List<String> configKeys = configurationService.getPropertyKeys(propname);
|
||||
for (String key : configKeys) {
|
||||
nsList.add(Namespace.getNamespace(key.substring(propname.length()),
|
||||
configurationService.getProperty(key)));
|
||||
}
|
||||
nsList.add(Namespace.XML_NAMESPACE);
|
||||
namespaces = (Namespace[]) nsList.toArray(new Namespace[nsList.size()]);
|
||||
|
||||
// get XML schemaLocation fragment from config
|
||||
schemaLocation = ConfigurationManager.getProperty(CONFIG_PREFIX + ".schemaLocation." + myName);
|
||||
schemaLocation = configurationService.getProperty(CONFIG_PREFIX + ".schemaLocation." + myName);
|
||||
|
||||
// read properties
|
||||
String cmPropName = CONFIG_PREFIX + ".properties." + myName;
|
||||
String propsFilename = ConfigurationManager.getProperty(cmPropName);
|
||||
String propsFilename = configurationService.getProperty(cmPropName);
|
||||
if (propsFilename == null) {
|
||||
throw new CrosswalkInternalException("Configuration error: " +
|
||||
"No properties file configured for QDC crosswalk named \"" +
|
||||
myName + "\"");
|
||||
}
|
||||
|
||||
String parent = ConfigurationManager.getProperty("dspace.dir") +
|
||||
String parent = configurationService.getProperty("dspace.dir") +
|
||||
File.separator + "config" + File.separator;
|
||||
File propsFile = new File(parent, propsFilename);
|
||||
Properties qdcProps = new Properties();
|
||||
@@ -264,7 +262,7 @@ public class QDCCrosswalk extends SelfNamedPlugin
|
||||
// grovel properties to initialize qdc->element and element->qdc maps.
|
||||
// evaluate the XML fragment with a wrapper including namespaces.
|
||||
String postlog = "</wrapper>";
|
||||
StringBuffer prologb = new StringBuffer("<wrapper");
|
||||
StringBuilder prologb = new StringBuilder("<wrapper");
|
||||
for (int i = 0; i < namespaces.length; ++i) {
|
||||
prologb.append(" xmlns:");
|
||||
prologb.append(namespaces[i].getPrefix());
|
||||
@@ -274,9 +272,9 @@ public class QDCCrosswalk extends SelfNamedPlugin
|
||||
}
|
||||
prologb.append(">");
|
||||
String prolog = prologb.toString();
|
||||
pe = (Enumeration<String>) qdcProps.propertyNames();
|
||||
while (pe.hasMoreElements()) {
|
||||
String qdc = pe.nextElement();
|
||||
Enumeration<String> qdcKeys = (Enumeration<String>) qdcProps.propertyNames();
|
||||
while (qdcKeys.hasMoreElements()) {
|
||||
String qdc = qdcKeys.nextElement();
|
||||
String val = qdcProps.getProperty(qdc);
|
||||
try {
|
||||
Document d = builder.build(new StringReader(prolog + val + postlog));
|
||||
@@ -296,7 +294,7 @@ public class QDCCrosswalk extends SelfNamedPlugin
|
||||
public Namespace[] getNamespaces() {
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
} catch (IOException | CrosswalkException e) {
|
||||
// ignore
|
||||
}
|
||||
return (Namespace[]) ArrayUtils.clone(namespaces);
|
||||
@@ -306,7 +304,7 @@ public class QDCCrosswalk extends SelfNamedPlugin
|
||||
public String getSchemaLocation() {
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
} catch (IOException | CrosswalkException e) {
|
||||
// ignore
|
||||
}
|
||||
return schemaLocation;
|
||||
@@ -338,7 +336,7 @@ public class QDCCrosswalk extends SelfNamedPlugin
|
||||
init();
|
||||
|
||||
List<MetadataValue> dc = itemService.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
|
||||
List<Element> result = new ArrayList<Element>(dc.size());
|
||||
List<Element> result = new ArrayList<>(dc.size());
|
||||
for (int i = 0; i < dc.size(); i++) {
|
||||
MetadataValue metadataValue = dc.get(i);
|
||||
MetadataField metadataField = metadataValue.getMetadataField();
|
||||
|
@@ -20,10 +20,11 @@ import org.dspace.content.packager.PackageException;
|
||||
import org.dspace.content.packager.PackageIngester;
|
||||
import org.dspace.content.packager.PackageParameters;
|
||||
import org.dspace.content.packager.RoleDisseminator;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.workflow.WorkflowException;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
@@ -179,8 +180,11 @@ public class RoleCrosswalk
|
||||
}
|
||||
|
||||
// Create a temporary file to disseminate into
|
||||
String tempDirectory = (ConfigurationManager.getProperty("upload.temp.dir") != null)
|
||||
? ConfigurationManager.getProperty("upload.temp.dir") : System.getProperty("java.io.tmpdir");
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String tempDirectory = (configurationService.hasProperty("upload.temp.dir"))
|
||||
? configurationService.getProperty("upload.temp.dir")
|
||||
: System.getProperty("java.io.tmpdir");
|
||||
File tempFile = File
|
||||
.createTempFile("RoleCrosswalkDisseminate" + dso.hashCode(), null, new File(tempDirectory));
|
||||
tempFile.deleteOnExit();
|
||||
@@ -292,8 +296,11 @@ public class RoleCrosswalk
|
||||
}
|
||||
|
||||
// Create a temporary file to ingest from
|
||||
String tempDirectory = (ConfigurationManager.getProperty("upload.temp.dir") != null)
|
||||
? ConfigurationManager.getProperty("upload.temp.dir") : System.getProperty("java.io.tmpdir");
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String tempDirectory = (configurationService.hasProperty("upload.temp.dir"))
|
||||
? configurationService.getProperty("upload.temp.dir")
|
||||
: System.getProperty("java.io.tmpdir");
|
||||
File tempFile = File.createTempFile("RoleCrosswalkIngest" + dso.hashCode(), null, new File(tempDirectory));
|
||||
tempFile.deleteOnExit();
|
||||
FileOutputStream fileOutStream = null;
|
||||
|
@@ -29,10 +29,11 @@ import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.SelfNamedPlugin;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.Verifier;
|
||||
@@ -59,29 +60,32 @@ import org.jdom.Verifier;
|
||||
* collections.
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class XHTMLHeadDisseminationCrosswalk extends SelfNamedPlugin implements
|
||||
DisseminationCrosswalk {
|
||||
public class XHTMLHeadDisseminationCrosswalk
|
||||
extends SelfNamedPlugin
|
||||
implements DisseminationCrosswalk {
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log = LogManager.getLogger(XHTMLHeadDisseminationCrosswalk.class);
|
||||
private static final Logger log = LogManager.getLogger(XHTMLHeadDisseminationCrosswalk.class);
|
||||
|
||||
private static final String XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
||||
|
||||
protected final ItemService itemService
|
||||
= ContentServiceFactory.getInstance().getItemService();
|
||||
protected final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
/**
|
||||
* Location of config file
|
||||
* Location of configuration file
|
||||
*/
|
||||
private final String config = ConfigurationManager
|
||||
.getProperty("dspace.dir")
|
||||
private final String config = configurationService.getProperty("dspace.dir")
|
||||
+ File.separator
|
||||
+ "config"
|
||||
+ File.separator
|
||||
+ "crosswalks"
|
||||
+ File.separator + "xhtml-head-item.properties";
|
||||
|
||||
private static final String XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
||||
protected final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
|
||||
/**
|
||||
* Maps DSpace metadata field to name to use in XHTML head element, e.g.
|
||||
* dc.creator or dc.description.abstract
|
||||
@@ -99,9 +103,9 @@ public class XHTMLHeadDisseminationCrosswalk extends SelfNamedPlugin implements
|
||||
private Map<String, String> schemaURLs;
|
||||
|
||||
public XHTMLHeadDisseminationCrosswalk() throws IOException {
|
||||
names = new HashMap<String, String>();
|
||||
schemes = new HashMap<String, String>();
|
||||
schemaURLs = new HashMap<String, String>();
|
||||
names = new HashMap<>();
|
||||
schemes = new HashMap<>();
|
||||
schemaURLs = new HashMap<>();
|
||||
|
||||
// Read in configuration
|
||||
Properties crosswalkProps = new Properties();
|
||||
@@ -189,7 +193,7 @@ public class XHTMLHeadDisseminationCrosswalk extends SelfNamedPlugin implements
|
||||
|
||||
Item item = (Item) dso;
|
||||
String handle = item.getHandle();
|
||||
List<Element> metas = new ArrayList<Element>();
|
||||
List<Element> metas = new ArrayList<>();
|
||||
List<MetadataValue> values = itemService.getMetadata(item, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
|
||||
|
||||
// Add in schema URLs e.g. <link rel="schema.DC" href="...." />
|
||||
|
@@ -11,7 +11,6 @@ import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
@@ -19,8 +18,9 @@ import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.SelfNamedPlugin;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Namespace;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -83,7 +83,6 @@ import org.slf4j.LoggerFactory;
|
||||
* does this automatically.
|
||||
*
|
||||
* @author Larry Stone
|
||||
* @version $Revision$
|
||||
*/
|
||||
public abstract class XSLTCrosswalk extends SelfNamedPlugin {
|
||||
/**
|
||||
@@ -98,7 +97,7 @@ public abstract class XSLTCrosswalk extends SelfNamedPlugin {
|
||||
Namespace.getNamespace("dim", "http://www.dspace.org/xmlns/dspace/dim");
|
||||
|
||||
/**
|
||||
* Prefix for all lines in the config file for XSLT plugins.
|
||||
* Prefix for all lines in the configuration file for XSLT plugins.
|
||||
*/
|
||||
protected static final String CONFIG_PREFIX = "crosswalk.";
|
||||
|
||||
@@ -117,12 +116,13 @@ public abstract class XSLTCrosswalk extends SelfNamedPlugin {
|
||||
String suffix = CONFIG_STYLESHEET;
|
||||
|
||||
List<String> aliasList = new ArrayList<>();
|
||||
Enumeration<String> pe = (Enumeration<String>) ConfigurationManager.propertyNames();
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
List<String> configKeys = configurationService.getPropertyKeys(prefix);
|
||||
|
||||
LOG.debug("XSLTCrosswalk: Looking for config prefix = {}", prefix);
|
||||
while (pe.hasMoreElements()) {
|
||||
String key = pe.nextElement();
|
||||
if (key.startsWith(prefix) && key.endsWith(suffix)) {
|
||||
for (String key : configKeys) {
|
||||
if (key.endsWith(suffix)) {
|
||||
LOG.debug("Getting XSLT plugin name from config line: {}", key);
|
||||
aliasList.add(key.substring(prefix.length(), key.length() - suffix.length()));
|
||||
}
|
||||
@@ -155,13 +155,15 @@ public abstract class XSLTCrosswalk extends SelfNamedPlugin {
|
||||
return null;
|
||||
}
|
||||
String cmPropName = CONFIG_PREFIX + direction + "." + myAlias + CONFIG_STYLESHEET;
|
||||
String fname = ConfigurationManager.getProperty(cmPropName);
|
||||
ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
String fname = configurationService.getProperty(cmPropName);
|
||||
if (fname == null) {
|
||||
LOG.error("Missing configuration filename for XSLT-based crosswalk: no " +
|
||||
"value for property = {}", cmPropName);
|
||||
return null;
|
||||
} else {
|
||||
String parent = ConfigurationManager.getProperty("dspace.dir") +
|
||||
String parent = configurationService.getProperty("dspace.dir") +
|
||||
File.separator + "config" + File.separator;
|
||||
transformFile = new File(parent, fname);
|
||||
}
|
||||
|
@@ -15,7 +15,6 @@ import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -36,11 +35,12 @@ import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
@@ -95,11 +95,14 @@ public class XSLTDisseminationCrosswalk
|
||||
|
||||
private static final String DIRECTION = "dissemination";
|
||||
|
||||
protected static final CommunityService communityService = ContentServiceFactory.getInstance()
|
||||
.getCommunityService();
|
||||
protected static final CollectionService collectionService = ContentServiceFactory.getInstance()
|
||||
.getCollectionService();
|
||||
protected static final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
protected static final CommunityService communityService
|
||||
= ContentServiceFactory.getInstance().getCommunityService();
|
||||
protected static final CollectionService collectionService
|
||||
= ContentServiceFactory.getInstance().getCollectionService();
|
||||
protected static final ItemService itemService
|
||||
= ContentServiceFactory.getInstance().getItemService();
|
||||
protected static final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
private static final String aliases[] = makeAliases(DIRECTION);
|
||||
|
||||
@@ -133,7 +136,7 @@ public class XSLTDisseminationCrosswalk
|
||||
|
||||
// get the schema location string, should already be in the
|
||||
// right format for value of "schemaLocation" attribute.
|
||||
schemaLocation = ConfigurationManager.getProperty(prefix + "schemaLocation");
|
||||
schemaLocation = configurationService.getProperty(prefix + "schemaLocation");
|
||||
if (schemaLocation == null) {
|
||||
LOG.warn("No schemaLocation for crosswalk=" + myAlias + ", key=" + prefix + "schemaLocation");
|
||||
} else if (schemaLocation.length() > 0 && schemaLocation.indexOf(' ') < 0) {
|
||||
@@ -146,18 +149,15 @@ public class XSLTDisseminationCrosswalk
|
||||
// grovel for namespaces of the form:
|
||||
// crosswalk.diss.{PLUGIN_NAME}.namespace.{PREFIX} = {URI}
|
||||
String nsPrefix = prefix + "namespace.";
|
||||
Enumeration<String> pe = (Enumeration<String>) ConfigurationManager.propertyNames();
|
||||
List<String> configKeys = configurationService.getPropertyKeys(nsPrefix);
|
||||
List<Namespace> nsList = new ArrayList<>();
|
||||
while (pe.hasMoreElements()) {
|
||||
String key = pe.nextElement();
|
||||
if (key.startsWith(nsPrefix)) {
|
||||
nsList.add(Namespace.getNamespace(key.substring(nsPrefix.length()),
|
||||
ConfigurationManager.getProperty(key)));
|
||||
}
|
||||
for (String key : configKeys) {
|
||||
nsList.add(Namespace.getNamespace(key.substring(nsPrefix.length()),
|
||||
configurationService.getProperty(key)));
|
||||
}
|
||||
namespaces = nsList.toArray(new Namespace[nsList.size()]);
|
||||
|
||||
preferList = ConfigurationManager.getBooleanProperty(prefix + "preferList", false);
|
||||
preferList = configurationService.getBooleanProperty(prefix + "preferList", false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,14 +341,21 @@ public class XSLTDisseminationCrosswalk
|
||||
if (dso.getType() == Constants.COLLECTION) {
|
||||
Collection collection = (Collection) dso;
|
||||
|
||||
String description = collectionService.getMetadata(collection, "introductory_text");
|
||||
String description_abstract = collectionService.getMetadata(collection, "short_description");
|
||||
String description_table = collectionService.getMetadata(collection, "side_bar_text");
|
||||
String description = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
String description_abstract = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
String description_table = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
String identifier_uri = "hdl:" + collection.getHandle();
|
||||
String provenance = collectionService.getMetadata(collection, "provenance_description");
|
||||
String rights = collectionService.getMetadata(collection, "copyright_text");
|
||||
String rights_license = collectionService.getMetadata(collection, "license");
|
||||
String title = collectionService.getMetadata(collection, "name");
|
||||
String provenance = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_PROVENANCE_DESCRIPTION, Item.ANY);
|
||||
String rights = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
String rights_license = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_LICENSE, Item.ANY);
|
||||
String title = collectionService.getMetadataFirstValue(collection,
|
||||
CollectionService.MD_NAME, Item.ANY);
|
||||
|
||||
dim.addContent(createField("dc", "description", null, null, description));
|
||||
dim.addContent(createField("dc", "description", "abstract", null, description_abstract));
|
||||
@@ -361,12 +368,17 @@ public class XSLTDisseminationCrosswalk
|
||||
} else if (dso.getType() == Constants.COMMUNITY) {
|
||||
Community community = (Community) dso;
|
||||
|
||||
String description = communityService.getMetadata(community, "introductory_text");
|
||||
String description_abstract = communityService.getMetadata(community, "short_description");
|
||||
String description_table = communityService.getMetadata(community, "side_bar_text");
|
||||
String description = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_INTRODUCTORY_TEXT, Item.ANY);
|
||||
String description_abstract = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SHORT_DESCRIPTION, Item.ANY);
|
||||
String description_table = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_SIDEBAR_TEXT, Item.ANY);
|
||||
String identifier_uri = "hdl:" + community.getHandle();
|
||||
String rights = communityService.getMetadata(community, "copyright_text");
|
||||
String title = communityService.getMetadata(community, "name");
|
||||
String rights = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_COPYRIGHT_TEXT, Item.ANY);
|
||||
String title = communityService.getMetadataFirstValue(community,
|
||||
CommunityService.MD_NAME, Item.ANY);
|
||||
|
||||
dim.addContent(createField("dc", "description", null, null, description));
|
||||
dim.addContent(createField("dc", "description", "abstract", null, description_abstract));
|
||||
@@ -463,7 +475,7 @@ public class XSLTDisseminationCrosswalk
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Filtering out non-XML characters in string, reason=" + reason);
|
||||
}
|
||||
StringBuffer result = new StringBuffer(value.length());
|
||||
StringBuilder result = new StringBuilder(value.length());
|
||||
for (int i = 0; i < value.length(); ++i) {
|
||||
char c = value.charAt(i);
|
||||
if (Verifier.isXMLCharacter((int) c)) {
|
||||
@@ -558,7 +570,7 @@ public class XSLTDisseminationCrosswalk
|
||||
try {
|
||||
XMLOutputter xmlout = new XMLOutputter(Format.getPrettyFormat());
|
||||
xmlout.output(new Document(root), out);
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
// as this script is for testing dissemination crosswalks, we want
|
||||
// verbose information in case of an exception.
|
||||
System.err.println("An error occurred after processing the dissemination crosswalk.");
|
||||
|
@@ -23,10 +23,11 @@ import org.dspace.content.Community;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataFieldName;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.authority.Choices;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.packager.PackageUtils;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
@@ -180,15 +181,11 @@ public class XSLTIngestionCrosswalk
|
||||
}
|
||||
|
||||
// return coll/comm "metadata" label corresponding to a DIM field.
|
||||
private static String getMetadataForDIM(Element field) {
|
||||
private static MetadataFieldName getMetadataForDIM(Element field) {
|
||||
// make up fieldname, then look for it in xwalk
|
||||
String element = field.getAttributeValue("element");
|
||||
String qualifier = field.getAttributeValue("qualifier");
|
||||
String fname = "dc." + element;
|
||||
if (qualifier != null) {
|
||||
fname += "." + qualifier;
|
||||
}
|
||||
return PackageUtils.dcToContainerMetadata(fname);
|
||||
return new MetadataFieldName(MetadataSchemaEnum.DC.getName(), element, qualifier);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,16 +231,18 @@ public class XSLTIngestionCrosswalk
|
||||
} else if ("field".equals(field.getName()) &&
|
||||
DIM_NS.equals(field.getNamespace()) &&
|
||||
schema != null && "dc".equals(schema)) {
|
||||
String md = getMetadataForDIM(field);
|
||||
MetadataFieldName md = getMetadataForDIM(field);
|
||||
if (md == null) {
|
||||
log.warn("Cannot map to Coll/Comm metadata field, DIM element=" +
|
||||
field.getAttributeValue("element") + ", qualifier=" + field
|
||||
.getAttributeValue("qualifier"));
|
||||
} else {
|
||||
if (type == Constants.COLLECTION) {
|
||||
collectionService.setMetadata(context, (Collection) dso, md, field.getText());
|
||||
collectionService.setMetadataSingleValue(context,
|
||||
(Collection) dso, md, null, field.getText());
|
||||
} else {
|
||||
communityService.setMetadata(context, (Community) dso, md, field.getText());
|
||||
communityService.setMetadataSingleValue(context,
|
||||
(Community) dso, md, null, field.getText());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@@ -189,15 +189,17 @@ public interface RelationshipDAO extends GenericDAO<Relationship> {
|
||||
int countByItem(Context context, Item item) throws SQLException;
|
||||
|
||||
/**
|
||||
* Count total number of relationships (rows in relationship table) by an item and a relationship type
|
||||
* Count total number of relationships (rows in relationship table) by an item and a relationship type and a boolean
|
||||
* indicating whether the item should be the leftItem or the rightItem
|
||||
*
|
||||
* @param context context
|
||||
* @param relationshipType relationship type to filter by
|
||||
* @param item item to filter by
|
||||
* @param isLeft Indicating whether the counted Relationships should have the given Item on the left side or not
|
||||
* @return total count
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType)
|
||||
int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType, boolean isLeft)
|
||||
throws SQLException;
|
||||
|
||||
/**
|
||||
|
@@ -201,18 +201,24 @@ public class RelationshipDAOImpl extends AbstractHibernateDAO<Relationship> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType)
|
||||
throws SQLException {
|
||||
public int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType,
|
||||
boolean isLeft) throws SQLException {
|
||||
|
||||
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Relationship.class);
|
||||
Root<Relationship> relationshipRoot = criteriaQuery.from(Relationship.class);
|
||||
criteriaQuery.select(relationshipRoot);
|
||||
criteriaQuery
|
||||
if (isLeft) {
|
||||
criteriaQuery
|
||||
.where(criteriaBuilder.equal(relationshipRoot.get(Relationship_.relationshipType),
|
||||
relationshipType), criteriaBuilder.or
|
||||
(criteriaBuilder.equal(relationshipRoot.get(Relationship_.leftItem), item),
|
||||
criteriaBuilder.equal(relationshipRoot.get(Relationship_.rightItem), item)));
|
||||
relationshipType),
|
||||
criteriaBuilder.equal(relationshipRoot.get(Relationship_.leftItem), item));
|
||||
} else {
|
||||
criteriaQuery
|
||||
.where(criteriaBuilder.equal(relationshipRoot.get(Relationship_.relationshipType),
|
||||
relationshipType),
|
||||
criteriaBuilder.equal(relationshipRoot.get(Relationship_.rightItem), item));
|
||||
}
|
||||
return count(context, criteriaQuery, criteriaBuilder, relationshipRoot);
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URLEncoder;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
@@ -53,6 +54,7 @@ import edu.harvard.hul.ois.mets.helper.MetsException;
|
||||
import edu.harvard.hul.ois.mets.helper.MetsValidator;
|
||||
import edu.harvard.hul.ois.mets.helper.MetsWriter;
|
||||
import edu.harvard.hul.ois.mets.helper.PreformedXML;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.util.Util;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||
@@ -116,14 +118,13 @@ import org.jdom.output.XMLOutputter;
|
||||
* @author Larry Stone
|
||||
* @author Robert Tansley
|
||||
* @author Tim Donohue
|
||||
* @version $Revision$
|
||||
*/
|
||||
public abstract class AbstractMETSDisseminator
|
||||
extends AbstractPackageDisseminator {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static org.apache.logging.log4j.Logger log =
|
||||
private static final Logger log =
|
||||
org.apache.logging.log4j.LogManager.getLogger(AbstractMETSDisseminator.class);
|
||||
|
||||
// JDOM xml output writer - indented format for readability.
|
||||
@@ -163,7 +164,7 @@ public abstract class AbstractMETSDisseminator
|
||||
* element to e.g. a rightsMD segment.
|
||||
*/
|
||||
protected static class MdStreamCache {
|
||||
protected Map<MdRef, InputStream> extraFiles = new HashMap<MdRef, InputStream>();
|
||||
protected Map<MdRef, InputStream> extraFiles = new HashMap<>();
|
||||
|
||||
public void addStream(MdRef key, InputStream md) {
|
||||
extraFiles.put(key, md);
|
||||
@@ -270,7 +271,9 @@ public abstract class AbstractMETSDisseminator
|
||||
+ Constants.typeText[dso.getType()] + ", handle="
|
||||
+ dso.getHandle() + ", dbID="
|
||||
+ String.valueOf(dso.getID())));
|
||||
} catch (MetsException e) {
|
||||
} catch (MetsException
|
||||
| NoSuchMethodException | InstantiationException
|
||||
| IllegalAccessException | InvocationTargetException e) {
|
||||
String errorMsg = "Error exporting METS for DSpace Object, type="
|
||||
+ Constants.typeText[dso.getType()] + ", handle="
|
||||
+ dso.getHandle() + ", dbID="
|
||||
@@ -302,11 +305,17 @@ public abstract class AbstractMETSDisseminator
|
||||
* @throws MetsException if METS error
|
||||
* @throws SQLException if database error
|
||||
* @throws IOException if IO error
|
||||
* @throws NoSuchMethodException passed through.
|
||||
* @throws InstantiationException passed through.
|
||||
* @throws IllegalAccessException passed through.
|
||||
* @throws InvocationTargetException passed through.
|
||||
*/
|
||||
protected void writeZipPackage(Context context, DSpaceObject dso,
|
||||
PackageParameters params, OutputStream pkg)
|
||||
throws PackageValidationException, CrosswalkException, MetsException,
|
||||
AuthorizeException, SQLException, IOException {
|
||||
AuthorizeException, SQLException, IOException, NoSuchMethodException,
|
||||
InstantiationException, IllegalAccessException,
|
||||
IllegalArgumentException, InvocationTargetException {
|
||||
long lmTime = 0;
|
||||
if (dso.getType() == Constants.ITEM) {
|
||||
lmTime = ((Item) dso).getLastModified().getTime();
|
||||
@@ -523,7 +532,7 @@ public abstract class AbstractMETSDisseminator
|
||||
|
||||
/**
|
||||
* Create an element wrapped around a metadata reference (either mdWrap
|
||||
* or mdRef); i.e. dmdSec, techMd, sourceMd, etc. Checks for
|
||||
* or mdRef); i.e.dmdSec, techMd, sourceMd, etc. Checks for
|
||||
* XML-DOM oriented crosswalk first, then if not found looks for
|
||||
* stream crosswalk of the same name.
|
||||
*
|
||||
@@ -533,21 +542,27 @@ public abstract class AbstractMETSDisseminator
|
||||
* @param typeSpec Type of metadata going into this mdSec (e.g. MODS, DC, PREMIS, etc)
|
||||
* @param params the PackageParameters
|
||||
* @param extraStreams list of extra files which need to be added to final dissemination package
|
||||
* @return mdSec element or null if xwalk returns empty results.
|
||||
* @return mdSec element or null if crosswalk returns empty results.
|
||||
* @throws SQLException if database error
|
||||
* @throws PackageValidationException if package validation error
|
||||
* @throws CrosswalkException if crosswalk error
|
||||
* @throws IOException if IO error
|
||||
* @throws AuthorizeException if authorization error
|
||||
* @throws NoSuchMethodException if mdSecClass cannot be instantiated.
|
||||
* @throws InstantiationException if mdSecClass cannot be instantiated.
|
||||
* @throws IllegalAccessException if mdSecClass cannot be instantiated.
|
||||
* @throws InvocationTargetException if mdSecClass cannot be instantiated.
|
||||
*/
|
||||
protected MdSec makeMdSec(Context context, DSpaceObject dso, Class mdSecClass,
|
||||
String typeSpec, PackageParameters params,
|
||||
MdStreamCache extraStreams)
|
||||
throws SQLException, PackageValidationException, CrosswalkException,
|
||||
IOException, AuthorizeException {
|
||||
IOException, AuthorizeException, NoSuchMethodException,
|
||||
InstantiationException, IllegalAccessException, IllegalArgumentException,
|
||||
InvocationTargetException {
|
||||
try {
|
||||
//create our metadata element (dmdSec, techMd, sourceMd, rightsMD etc.)
|
||||
MdSec mdSec = (MdSec) mdSecClass.newInstance();
|
||||
MdSec mdSec = (MdSec) mdSecClass.getDeclaredConstructor().newInstance();
|
||||
mdSec.setID(gensym(mdSec.getLocalName()));
|
||||
String parts[] = typeSpec.split(":", 2);
|
||||
String xwalkName;
|
||||
@@ -665,9 +680,7 @@ public abstract class AbstractMETSDisseminator
|
||||
"StreamDisseminationCrosswalk");
|
||||
}
|
||||
}
|
||||
} catch (InstantiationException e) {
|
||||
throw new PackageValidationException("Error instantiating Mdsec object: " + e.toString(), e);
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
throw new PackageValidationException("Error instantiating Mdsec object: " + e.toString(), e);
|
||||
}
|
||||
}
|
||||
@@ -680,7 +693,9 @@ public abstract class AbstractMETSDisseminator
|
||||
PackageParameters params,
|
||||
MdStreamCache extraStreams)
|
||||
throws SQLException, PackageValidationException, CrosswalkException,
|
||||
IOException, AuthorizeException {
|
||||
IOException, AuthorizeException,
|
||||
NoSuchMethodException, InstantiationException, IllegalAccessException,
|
||||
IllegalArgumentException, InvocationTargetException {
|
||||
for (int i = 0; i < mdTypes.length; ++i) {
|
||||
MdSec md = makeMdSec(context, dso, mdSecClass, mdTypes[i], params, extraStreams);
|
||||
if (md != null) {
|
||||
@@ -693,7 +708,9 @@ public abstract class AbstractMETSDisseminator
|
||||
protected String addAmdSec(Context context, DSpaceObject dso, PackageParameters params,
|
||||
Mets mets, MdStreamCache extraStreams)
|
||||
throws SQLException, PackageValidationException, CrosswalkException,
|
||||
IOException, AuthorizeException {
|
||||
IOException, AuthorizeException, NoSuchMethodException,
|
||||
InstantiationException, IllegalAccessException, IllegalArgumentException,
|
||||
IllegalArgumentException, InvocationTargetException {
|
||||
String techMdTypes[] = getTechMdTypes(context, dso, params);
|
||||
String rightsMdTypes[] = getRightsMdTypes(context, dso, params);
|
||||
String sourceMdTypes[] = getSourceMdTypes(context, dso, params);
|
||||
@@ -731,12 +748,11 @@ public abstract class AbstractMETSDisseminator
|
||||
}
|
||||
|
||||
/**
|
||||
* Write out a METS manifest.
|
||||
* Mostly lifted from Rob Tansley's METS exporter.
|
||||
* Write out a METS manifest. Mostly lifted from Rob Tansley's METS exporter.
|
||||
*
|
||||
* @param context context
|
||||
* @param dso DSpaceObject
|
||||
* @param params packaging params
|
||||
* @param params packaging parameters
|
||||
* @param extraStreams streams
|
||||
* @return METS manifest
|
||||
* @throws MetsException if mets error
|
||||
@@ -745,12 +761,17 @@ public abstract class AbstractMETSDisseminator
|
||||
* @throws AuthorizeException if authorization error
|
||||
* @throws SQLException if database error
|
||||
* @throws IOException if IO error
|
||||
* @throws NoSuchMethodException if DmdSec cannot be instantiated.
|
||||
* @throws InstantiationException if DmdSec cannot be instantiated.
|
||||
* @throws IllegalAccessException if DmdSec cannot be instantiated.
|
||||
* @throws InvocationTargetException if DmdSec cannot be instantiated.
|
||||
*/
|
||||
protected Mets makeManifest(Context context, DSpaceObject dso,
|
||||
PackageParameters params,
|
||||
MdStreamCache extraStreams)
|
||||
throws MetsException, PackageValidationException, CrosswalkException, AuthorizeException, SQLException,
|
||||
IOException {
|
||||
IOException, NoSuchMethodException, InstantiationException,
|
||||
IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||
|
||||
// Create the METS manifest in memory
|
||||
Mets mets = new Mets();
|
||||
|
@@ -41,12 +41,13 @@ import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.WorkspaceItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.workflow.WorkflowException;
|
||||
import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||
import org.jdom.Element;
|
||||
@@ -100,7 +101,6 @@ import org.jdom.Element;
|
||||
*
|
||||
* @author Larry Stone
|
||||
* @author Tim Donohue
|
||||
* @version $Revision$
|
||||
* @see org.dspace.content.packager.METSManifest
|
||||
* @see AbstractPackageIngester
|
||||
* @see PackageIngester
|
||||
@@ -109,7 +109,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(AbstractMETSIngester.class);
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(AbstractMETSIngester.class);
|
||||
|
||||
protected final BitstreamService bitstreamService = ContentServiceFactory.getInstance().getBitstreamService();
|
||||
protected final BitstreamFormatService bitstreamFormatService = ContentServiceFactory.getInstance()
|
||||
@@ -121,6 +121,8 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester {
|
||||
protected final HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||
protected final WorkspaceItemService workspaceItemService = ContentServiceFactory.getInstance()
|
||||
.getWorkspaceItemService();
|
||||
protected final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -135,7 +137,7 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester {
|
||||
protected static final class MdrefManager implements METSManifest.Mdref {
|
||||
private File packageFile = null;
|
||||
|
||||
private PackageParameters params;
|
||||
private final PackageParameters params;
|
||||
|
||||
// constructor initializes from package file
|
||||
private MdrefManager(File packageFile, PackageParameters params) {
|
||||
@@ -1133,22 +1135,22 @@ public abstract class AbstractMETSIngester extends AbstractPackageIngester {
|
||||
|
||||
// whether or not to save manifest as a bitstream in METADATA bundle.
|
||||
protected boolean preserveManifest() {
|
||||
return ConfigurationManager.getBooleanProperty("mets."
|
||||
+ getConfigurationName() + ".ingest.preserveManifest",
|
||||
false);
|
||||
return configurationService.getBooleanProperty(
|
||||
"mets." + getConfigurationName() + ".ingest.preserveManifest",
|
||||
false);
|
||||
}
|
||||
|
||||
// return short name of manifest bitstream format
|
||||
protected String getManifestBitstreamFormat() {
|
||||
return ConfigurationManager.getProperty("mets."
|
||||
+ getConfigurationName() + ".ingest.manifestBitstreamFormat");
|
||||
return configurationService.getProperty(
|
||||
"mets." + getConfigurationName() + ".ingest.manifestBitstreamFormat");
|
||||
}
|
||||
|
||||
// whether or not to use Collection Templates when creating a new item
|
||||
protected boolean useCollectionTemplate() {
|
||||
return ConfigurationManager.getBooleanProperty("mets."
|
||||
+ getConfigurationName() + ".ingest.useCollectionTemplate",
|
||||
false);
|
||||
return configurationService.getBooleanProperty(
|
||||
"mets." + getConfigurationName() + ".ingest.useCollectionTemplate",
|
||||
false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -25,7 +25,6 @@ import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
|
||||
@@ -45,7 +44,6 @@ import org.dspace.core.Context;
|
||||
* plugin, and a way to create packages acceptable to the METS SIP importer.
|
||||
*
|
||||
* @author Larry Stone
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class DSpaceMETSDisseminator
|
||||
extends AbstractMETSDisseminator {
|
||||
@@ -115,8 +113,7 @@ public class DSpaceMETSDisseminator
|
||||
agent.setTYPE(Type.ORGANIZATION);
|
||||
Name name = new Name();
|
||||
name.getContent()
|
||||
.add(new PCData(ConfigurationManager
|
||||
.getProperty("dspace.name")));
|
||||
.add(new PCData(configurationService.getProperty("dspace.name")));
|
||||
agent.getContent().add(name);
|
||||
metsHdr.getContent().add(agent);
|
||||
return metsHdr;
|
||||
@@ -198,7 +195,7 @@ public class DSpaceMETSDisseminator
|
||||
@Override
|
||||
public String[] getRightsMdTypes(Context context, DSpaceObject dso, PackageParameters params)
|
||||
throws SQLException, IOException, AuthorizeException {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (dso.getType() == Constants.ITEM) {
|
||||
Item item = (Item) dso;
|
||||
|
@@ -13,11 +13,11 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Bitstream;
|
||||
@@ -29,10 +29,11 @@ import org.dspace.content.crosswalk.CrosswalkObjectNotSupported;
|
||||
import org.dspace.content.crosswalk.IngestionCrosswalk;
|
||||
import org.dspace.content.crosswalk.MetadataValidationException;
|
||||
import org.dspace.content.crosswalk.StreamIngestionCrosswalk;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Content;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
@@ -62,8 +63,8 @@ import org.jdom.xpath.XPath;
|
||||
* <UL>
|
||||
* <LI>Local XML schema (XSD) declarations, in the general format:
|
||||
* <br><code>mets.xsd.<em>identifier</em> = <em>namespace</em> <em>xsd-URL</em></code>
|
||||
* <br> eg. <code>mets.xsd.dc = http://purl.org/dc/elements/1.1/ dc.xsd</code>
|
||||
* <br>Add a separate config entry for each schema.
|
||||
* <br> e.g. <code>mets.xsd.dc = http://purl.org/dc/elements/1.1/ dc.xsd</code>
|
||||
* <br>Add a separate configuration entry for each schema.
|
||||
* </LI>
|
||||
* <LI>Crosswalk plugin mappings:
|
||||
* These tell it the name of the crosswalk plugin to invoke for metadata sections
|
||||
@@ -117,8 +118,10 @@ public class METSManifest {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(METSManifest.class);
|
||||
private static final Logger log = LogManager.getLogger(METSManifest.class);
|
||||
|
||||
private static final ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
/**
|
||||
* Canonical filename of METS manifest within a package or as a bitstream.
|
||||
*/
|
||||
@@ -131,7 +134,7 @@ public class METSManifest {
|
||||
public static final String CONFIG_METS_PREFIX = "mets.";
|
||||
|
||||
/**
|
||||
* prefix of config lines identifying local XML Schema (XSD) files
|
||||
* prefix of configuration lines identifying local XML Schema (XSD) files
|
||||
*/
|
||||
protected static final String CONFIG_XSD_PREFIX = CONFIG_METS_PREFIX + "xsd.";
|
||||
|
||||
@@ -190,49 +193,43 @@ public class METSManifest {
|
||||
protected static String localSchemas;
|
||||
|
||||
static {
|
||||
String dspace_dir = ConfigurationManager.getProperty("dspace.dir");
|
||||
String dspace_dir = configurationService.getProperty("dspace.dir");
|
||||
File xsdPath1 = new File(dspace_dir + "/config/schemas/");
|
||||
File xsdPath2 = new File(dspace_dir + "/config/");
|
||||
|
||||
Enumeration<String> pe = (Enumeration<String>) ConfigurationManager.propertyNames();
|
||||
StringBuffer result = new StringBuffer();
|
||||
while (pe.hasMoreElements()) {
|
||||
List<String> configKeys = configurationService.getPropertyKeys(CONFIG_XSD_PREFIX);
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (String key : configKeys) {
|
||||
// config lines have the format:
|
||||
// mets.xsd.{identifier} = {namespace} {xsd-URL}
|
||||
// e.g.
|
||||
// mets.xsd.dc = http://purl.org/dc/elements/1.1/ dc.xsd
|
||||
// (filename is relative to {dspace_dir}/config/schemas/)
|
||||
String key = pe.nextElement();
|
||||
if (key.startsWith(CONFIG_XSD_PREFIX)) {
|
||||
String spec = ConfigurationManager.getProperty(key);
|
||||
String val[] = spec.trim().split("\\s+");
|
||||
if (val.length == 2) {
|
||||
File xsd = new File(xsdPath1, val[1]);
|
||||
if (!xsd.exists()) {
|
||||
xsd = new File(xsdPath2, val[1]);
|
||||
}
|
||||
if (!xsd.exists()) {
|
||||
log.warn("Schema file not found for config entry=\"" + spec + "\"");
|
||||
} else {
|
||||
try {
|
||||
String u = xsd.toURL().toString();
|
||||
if (result.length() > 0) {
|
||||
result.append(" ");
|
||||
}
|
||||
result.append(val[0]).append(" ").append(u);
|
||||
} catch (java.net.MalformedURLException e) {
|
||||
log.warn("Skipping badly formed XSD URL: " + e.toString());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("Schema config entry has wrong format, entry=\"" + spec + "\"");
|
||||
String spec = configurationService.getProperty(key);
|
||||
String val[] = spec.trim().split("\\s+");
|
||||
if (val.length == 2) {
|
||||
File xsd = new File(xsdPath1, val[1]);
|
||||
if (!xsd.exists()) {
|
||||
xsd = new File(xsdPath2, val[1]);
|
||||
}
|
||||
if (!xsd.exists()) {
|
||||
log.warn("Schema file not found for config entry=\"{}\"", spec);
|
||||
} else {
|
||||
try {
|
||||
String u = xsd.toURI().toURL().toString();
|
||||
if (result.length() > 0) {
|
||||
result.append(" ");
|
||||
}
|
||||
result.append(val[0]).append(" ").append(u);
|
||||
} catch (java.net.MalformedURLException e) {
|
||||
log.warn("Skipping badly formed XSD URL: {}", () -> e.toString());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.warn("Schema config entry has wrong format, entry=\"{}\"", spec);
|
||||
}
|
||||
}
|
||||
localSchemas = result.toString();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Got local schemas = \"" + localSchemas + "\"");
|
||||
}
|
||||
log.debug("Got local schemas = \"{}\"", () -> result.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,12 +237,12 @@ public class METSManifest {
|
||||
*
|
||||
* @param builder XML parser (for parsing mdRef'd files and binData)
|
||||
* @param mets parsed METS document
|
||||
* @param configName config name
|
||||
* @param configName configuration name
|
||||
*/
|
||||
protected METSManifest(SAXBuilder builder, Element mets, String configName) {
|
||||
super();
|
||||
this.mets = mets;
|
||||
parser = builder;
|
||||
this.parser = builder;
|
||||
this.configName = configName;
|
||||
}
|
||||
|
||||
@@ -337,7 +334,7 @@ public class METSManifest {
|
||||
return bundleFiles;
|
||||
}
|
||||
|
||||
bundleFiles = new ArrayList<Element>();
|
||||
bundleFiles = new ArrayList<>();
|
||||
Element fileSec = mets.getChild("fileSec", metsNS);
|
||||
|
||||
if (fileSec != null) {
|
||||
@@ -356,7 +353,7 @@ public class METSManifest {
|
||||
return contentFiles;
|
||||
}
|
||||
|
||||
contentFiles = new ArrayList<Element>();
|
||||
contentFiles = new ArrayList<>();
|
||||
Element fileSec = mets.getChild("fileSec", metsNS);
|
||||
|
||||
if (fileSec != null) {
|
||||
@@ -623,7 +620,7 @@ public class METSManifest {
|
||||
* @throws SQLException if database error
|
||||
* @throws AuthorizeException if authorization error
|
||||
*/
|
||||
public List<Element> getMdContentAsXml(Element mdSec, Mdref callback)
|
||||
private List<Element> getMdContentAsXml(Element mdSec, Mdref callback)
|
||||
throws MetadataValidationException, PackageValidationException,
|
||||
IOException, SQLException, AuthorizeException {
|
||||
try {
|
||||
@@ -637,7 +634,7 @@ public class METSManifest {
|
||||
// XML parser stupidly includes newlines in prettyprinting
|
||||
// as text content objects..
|
||||
String id = mdSec.getAttributeValue("ID");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Iterator mi = mdc.iterator(); mi.hasNext(); ) {
|
||||
sb.append(", ").append(((Content) mi.next()).toString());
|
||||
}
|
||||
@@ -661,12 +658,12 @@ public class METSManifest {
|
||||
if (mimeType != null && mimeType.equalsIgnoreCase("text/xml")) {
|
||||
byte value[] = Base64.decodeBase64(bin.getText().getBytes());
|
||||
Document mdd = parser.build(new ByteArrayInputStream(value));
|
||||
List<Element> result = new ArrayList<Element>(1);
|
||||
List<Element> result = new ArrayList<>(1);
|
||||
result.add(mdd.getRootElement());
|
||||
return result;
|
||||
} else {
|
||||
log.warn("Ignoring binData section because MIMETYPE is not XML, but: " + mimeType);
|
||||
return new ArrayList<Element>(0);
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -677,13 +674,15 @@ public class METSManifest {
|
||||
if (mdRef != null) {
|
||||
String mimeType = mdRef.getAttributeValue("MIMETYPE");
|
||||
if (mimeType != null && mimeType.equalsIgnoreCase("text/xml")) {
|
||||
Document mdd = parser.build(callback.getInputStream(mdRef));
|
||||
List<Element> result = new ArrayList<Element>(1);
|
||||
// This next line triggers a false-positive XXE warning from LGTM, even though we disallow DTD
|
||||
// parsing during initialization of parser in create()
|
||||
Document mdd = parser.build(callback.getInputStream(mdRef)); // lgtm [java/xxe]
|
||||
List<Element> result = new ArrayList<>(1);
|
||||
result.add(mdd.getRootElement());
|
||||
return result;
|
||||
} else {
|
||||
log.warn("Ignoring mdRef section because MIMETYPE is not XML, but: " + mimeType);
|
||||
return new ArrayList<Element>(0);
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -803,7 +802,7 @@ public class METSManifest {
|
||||
//get our child object <div>s
|
||||
List childObjDivs = getChildObjDivs();
|
||||
|
||||
List<String> childPathList = new ArrayList<String>();
|
||||
List<String> childPathList = new ArrayList<>();
|
||||
|
||||
if (childObjDivs != null && !childObjDivs.isEmpty()) {
|
||||
Iterator childIterator = childObjDivs.iterator();
|
||||
@@ -915,10 +914,10 @@ public class METSManifest {
|
||||
* then try
|
||||
* mets.default.ingest.crosswalk.MDNAME = XWALKNAME
|
||||
*/
|
||||
String xwalkName = ConfigurationManager.getProperty(
|
||||
String xwalkName = configurationService.getProperty(
|
||||
CONFIG_METS_PREFIX + configName + ".ingest.crosswalk." + type);
|
||||
if (xwalkName == null) {
|
||||
xwalkName = ConfigurationManager.getProperty(
|
||||
xwalkName = configurationService.getProperty(
|
||||
CONFIG_METS_PREFIX + "default.ingest.crosswalk." + type);
|
||||
if (xwalkName == null) {
|
||||
xwalkName = type;
|
||||
@@ -991,7 +990,7 @@ public class METSManifest {
|
||||
return new Element[0];
|
||||
}
|
||||
String amdID[] = amds.split("\\s+");
|
||||
List<Element> resultList = new ArrayList<Element>();
|
||||
List<Element> resultList = new ArrayList<>();
|
||||
for (int i = 0; i < amdID.length; ++i) {
|
||||
List rmds = getElementByXPath("mets:amdSec[@ID=\"" + amdID[i] + "\"]", false).
|
||||
getChildren("rightsMD",
|
||||
|
@@ -21,6 +21,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Bitstream;
|
||||
@@ -30,6 +31,7 @@ import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataFieldName;
|
||||
import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
@@ -57,7 +59,6 @@ import org.dspace.workflow.factory.WorkflowServiceFactory;
|
||||
* Container class for code that is useful to many packagers.
|
||||
*
|
||||
* @author Larry Stone
|
||||
* @version $Revision$
|
||||
*/
|
||||
|
||||
public class PackageUtils {
|
||||
@@ -65,7 +66,7 @@ public class PackageUtils {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(PackageUtils.class);
|
||||
private static final Logger log = LogManager.getLogger(PackageUtils.class);
|
||||
|
||||
// Map of metadata elements for Communities and Collections
|
||||
// Format is alternating key/value in a straight array; use this
|
||||
@@ -159,7 +160,7 @@ public class PackageUtils {
|
||||
public static void checkItemMetadata(Item item)
|
||||
throws PackageValidationException {
|
||||
List<MetadataValue> t = itemService.getMetadata(item, MetadataSchemaEnum.DC.getName(), "title", null, Item.ANY);
|
||||
if (t == null || t.size() == 0) {
|
||||
if (t == null || t.isEmpty()) {
|
||||
throw new PackageValidationException("Item cannot be created without the required \"title\" DC metadata.");
|
||||
}
|
||||
}
|
||||
@@ -704,7 +705,9 @@ public class PackageUtils {
|
||||
// to clear out all the Collection database fields.
|
||||
for (String dbField : ccMetadataToDC.keySet()) {
|
||||
try {
|
||||
collectionService.setMetadata(context, collection, dbField, null);
|
||||
String[] elements = MetadataFieldName.parse(dbField);
|
||||
collectionService.clearMetadata(context, collection,
|
||||
elements[0], elements[1], elements[2], Item.ANY);
|
||||
} catch (IllegalArgumentException ie) {
|
||||
// ignore the error -- just means the field doesn't exist in DB
|
||||
// Communities & Collections don't include the exact same metadata fields
|
||||
@@ -718,7 +721,9 @@ public class PackageUtils {
|
||||
// to clear out all the Community database fields.
|
||||
for (String dbField : ccMetadataToDC.keySet()) {
|
||||
try {
|
||||
communityService.setMetadata(context, community, dbField, null);
|
||||
String[] elements = MetadataFieldName.parse(dbField);
|
||||
communityService.clearMetadata(context, community,
|
||||
elements[0], elements[1], elements[2], Item.ANY);
|
||||
} catch (IllegalArgumentException ie) {
|
||||
// ignore the error -- just means the field doesn't exist in DB
|
||||
// Communities & Collections don't include the exact same metadata fields
|
||||
|
@@ -12,7 +12,6 @@ import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Bitstream;
|
||||
@@ -23,11 +22,10 @@ import org.dspace.core.Context;
|
||||
import org.dspace.discovery.SearchServiceException;
|
||||
import org.dspace.eperson.Group;
|
||||
|
||||
|
||||
/**
|
||||
* Service interface class for the Collection object.
|
||||
* The implementation of this class is responsible for all business logic calls for the Collection object and is
|
||||
* autowired by spring
|
||||
* The implementation of this class is responsible for all business logic calls
|
||||
* for the Collection object and is autowired by Spring.
|
||||
*
|
||||
* @author kevinvandevelde at atmire.com
|
||||
*/
|
||||
@@ -93,20 +91,6 @@ public interface CollectionService
|
||||
|
||||
public List<Collection> findGroupMapped(Context context, int actionID) throws java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Set a metadata value
|
||||
*
|
||||
* @param context DSpace Context
|
||||
* @param collection Collection
|
||||
* @param field the name of the metadata field to get
|
||||
* @param value value to set the field to
|
||||
* @throws MissingResourceException if resource missing
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMetadata(Context context, Collection collection, String field, String value)
|
||||
throws MissingResourceException, SQLException;
|
||||
|
||||
/**
|
||||
* Give the collection a logo. Passing in <code>null</code> removes any
|
||||
* existing logo. You will need to set the format of the new logo bitstream
|
||||
@@ -149,9 +133,12 @@ public interface CollectionService
|
||||
* <code>null</code> can be passed in if there should be no associated
|
||||
* group for that workflow step; any existing group is NOT deleted.
|
||||
*
|
||||
* @param context current DSpace session.
|
||||
* @param collection Collection
|
||||
* @param step the workflow step (1-3)
|
||||
* @param group the new workflow group, or <code>null</code>
|
||||
* @throws SQLException passed through.
|
||||
* @throws AuthorizeException passed through.
|
||||
*/
|
||||
public void setWorkflowGroup(Context context, Collection collection, int step, Group group)
|
||||
throws SQLException, AuthorizeException;
|
||||
|
@@ -11,7 +11,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Bitstream;
|
||||
@@ -29,7 +28,6 @@ import org.dspace.eperson.Group;
|
||||
*/
|
||||
public interface CommunityService extends DSpaceObjectService<Community>, DSpaceObjectLegacySupportService<Community> {
|
||||
|
||||
|
||||
/**
|
||||
* Create a new top-level community, with a new ID.
|
||||
*
|
||||
@@ -88,36 +86,6 @@ public interface CommunityService extends DSpaceObjectService<Community>, DSpace
|
||||
*/
|
||||
public List<Community> findAllTop(Context context) throws SQLException;
|
||||
|
||||
/**
|
||||
* Get the value of a metadata field
|
||||
*
|
||||
* @param community community
|
||||
* @param field the name of the metadata field to get
|
||||
* @return the value of the metadata field
|
||||
* @throws IllegalArgumentException if the requested metadata field doesn't exist
|
||||
* @deprecated
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getMetadata(Community community, String field);
|
||||
|
||||
|
||||
/**
|
||||
* Set a metadata value
|
||||
*
|
||||
* @param context context
|
||||
* @param community community
|
||||
* @param field the name of the metadata field to get
|
||||
* @param value value to set the field to
|
||||
* @throws IllegalArgumentException if the requested metadata field doesn't exist
|
||||
* @throws MissingResourceException if resource missing
|
||||
* @throws SQLException if database error
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMetadata(Context context, Community community, String field, String value)
|
||||
throws MissingResourceException, SQLException;
|
||||
|
||||
/**
|
||||
* Give the community a logo. Passing in <code>null</code> removes any
|
||||
* existing logo. You will need to set the format of the new logo bitstream
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
package org.dspace.content.service;
|
||||
|
||||
import static org.dspace.content.MetadataSchemaEnum.DC;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@@ -16,25 +18,46 @@ import java.util.UUID;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataFieldName;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.core.Context;
|
||||
|
||||
/**
|
||||
* Service interface class for the DSpaceObject.
|
||||
* All DSpaceObject service classes should implement this class since it offers some basic methods which all
|
||||
* DSpaceObjects
|
||||
* are required to have.
|
||||
* All DSpaceObject service classes should implement this class since it offers
|
||||
* some basic methods which all {@code DSpaceObject}s are required to have.
|
||||
*
|
||||
* @param <T> class type
|
||||
* @author kevinvandevelde at atmire.com
|
||||
*/
|
||||
public interface DSpaceObjectService<T extends DSpaceObject> {
|
||||
|
||||
// Some common metadata fields which must be defined.
|
||||
|
||||
public static final MetadataFieldName MD_INTRODUCTORY_TEXT
|
||||
= new MetadataFieldName(DC, "description");
|
||||
public static final MetadataFieldName MD_SHORT_DESCRIPTION
|
||||
= new MetadataFieldName(DC, "description", "abstract");
|
||||
public static final MetadataFieldName MD_SIDEBAR_TEXT
|
||||
= new MetadataFieldName(DC, "description", "tableofcontents");
|
||||
public static final MetadataFieldName MD_COPYRIGHT_TEXT
|
||||
= new MetadataFieldName(DC, "rights");
|
||||
public static final MetadataFieldName MD_NAME
|
||||
= new MetadataFieldName(DC, "title");
|
||||
public static final MetadataFieldName MD_PROVENANCE_DESCRIPTION
|
||||
= new MetadataFieldName(DC, "provenance");
|
||||
public static final MetadataFieldName MD_LICENSE
|
||||
= new MetadataFieldName(DC, "rights", "license");
|
||||
public static final MetadataFieldName MD_USER_FORMAT_DESCRIPTION
|
||||
= new MetadataFieldName(DC, "format");
|
||||
public static final MetadataFieldName MD_SOURCE
|
||||
= new MetadataFieldName(DC, "source");
|
||||
|
||||
/**
|
||||
* Generic find for when the precise type of an Entity is not known
|
||||
*
|
||||
* @param context - the context
|
||||
* @param uuid - uuid within table of type'd dspace objects
|
||||
* @param uuid - uuid within table of typed dspace objects
|
||||
* @return the dspace object found, or null if it does not exist.
|
||||
* @throws SQLException only upon failure accessing the database.
|
||||
*/
|
||||
@@ -175,10 +198,29 @@ public interface DSpaceObjectService<T extends DSpaceObject> {
|
||||
public String getMetadata(T dSpaceObject, String value);
|
||||
|
||||
|
||||
/**
|
||||
* Get the value(s) of a metadata field.
|
||||
* @param dSpaceObject the object whose metadata are sought.
|
||||
* @param mdString the name of the field: {@code schema.element.qualifier}.
|
||||
* @param authority name of the authority which controls these values, or null.
|
||||
* @return all matching metadata values, or null if none.
|
||||
*/
|
||||
public List<MetadataValue> getMetadata(T dSpaceObject, String mdString, String authority);
|
||||
|
||||
public List<MetadataValue> getMetadata(T dSpaceObject, String schema, String element, String qualifier, String lang,
|
||||
String authority);
|
||||
/**
|
||||
* Get the value(s) of a metadata field.
|
||||
* @param dSpaceObject the object whose metadata are sought.
|
||||
* @param schema name of the schema which defines the field.
|
||||
* @param element the field's element name.
|
||||
* @param qualifier the field's qualifier name, or null.
|
||||
* @param lang the language of the requested field value(s),
|
||||
* null if explicitly no language,
|
||||
* or {@link org.dspace.content.Item.ANY} to match all languages.
|
||||
* @param authority name of the authority which controls these values, or null.
|
||||
* @return value(s) of the indicated field for the given DSO, or null.
|
||||
*/
|
||||
public List<MetadataValue> getMetadata(T dSpaceObject, String schema,
|
||||
String element, String qualifier, String lang, String authority);
|
||||
|
||||
/**
|
||||
* Add metadata fields. These are appended to existing values.
|
||||
@@ -376,8 +418,26 @@ public interface DSpaceObjectService<T extends DSpaceObject> {
|
||||
|
||||
public void removeMetadataValues(Context context, T dso, List<MetadataValue> values) throws SQLException;
|
||||
|
||||
/**
|
||||
* Get the first value of a metadata field.
|
||||
* @param dso the object whose metadata are sought.
|
||||
* @param schema name of the schema which defines the field.
|
||||
* @param element element name of the field.
|
||||
* @param qualifier qualifier name of the field, or null.
|
||||
* @param language select only values in this language.
|
||||
* @return first value of the field, or null if none.
|
||||
*/
|
||||
public String getMetadataFirstValue(T dso, String schema, String element, String qualifier, String language);
|
||||
|
||||
/**
|
||||
* Get the first value of a metadata field.
|
||||
* @param dso the object whose metadata are sought.
|
||||
* @param field {schema, element, qualifier} for the desired field.
|
||||
* @param language select only values in this language.
|
||||
* @return first value of the field, or null if none.
|
||||
*/
|
||||
public String getMetadataFirstValue(T dso, MetadataFieldName field, String language);
|
||||
|
||||
/**
|
||||
* Set first metadata field value
|
||||
*
|
||||
@@ -400,6 +460,24 @@ public interface DSpaceObjectService<T extends DSpaceObject> {
|
||||
public void setMetadataSingleValue(Context context, T dso, String schema, String element, String qualifier,
|
||||
String language, String value) throws SQLException;
|
||||
|
||||
/**
|
||||
* Set first metadata field value
|
||||
*
|
||||
* @param context DSpace context
|
||||
* @param dso DSpaceObject
|
||||
* @param field {schema, element, qualifier} for the desired field.
|
||||
* @param language the ISO639 language code, optionally followed by an underscore
|
||||
* and the ISO3166 country code. <code>null</code> means only
|
||||
* values with no language are removed, and <code>Item.ANY</code>
|
||||
* means values with any country code or no country code are
|
||||
* removed.
|
||||
* @param value metadata value
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
public void setMetadataSingleValue(Context context, T dso,
|
||||
MetadataFieldName field, String language, String value)
|
||||
throws SQLException;
|
||||
|
||||
public void updateLastModified(Context context, T dso) throws SQLException, AuthorizeException;
|
||||
|
||||
public void update(Context context, T dso) throws SQLException, AuthorizeException;
|
||||
|
@@ -283,14 +283,16 @@ public interface RelationshipService extends DSpaceCRUDService<Relationship> {
|
||||
int countByItem(Context context, Item item) throws SQLException;
|
||||
|
||||
/**
|
||||
* Count total number of relationships (rows in relationship table) by a relationship type
|
||||
* Count total number of relationships (rows in relationship table) by a relationship type and a boolean indicating
|
||||
* whether the relationship should contain the item on the left side or not
|
||||
*
|
||||
* @param context context
|
||||
* @param relationshipType relationship type to filter by
|
||||
* @return total count
|
||||
* @param isLeft Indicating whether the counted Relationships should have the given Item on the left side or not
|
||||
* @return total count with the given parameters
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType)
|
||||
int countByItemAndRelationshipType(Context context, Item item, RelationshipType relationshipType, boolean isLeft)
|
||||
throws SQLException;
|
||||
|
||||
/**
|
||||
|
@@ -147,8 +147,8 @@ public class Related implements VirtualMetadataConfiguration {
|
||||
* and pass this along to the next VirtualBean that's stored in this class.
|
||||
* @param context The relevant DSpace context
|
||||
* @param item The item that will be used to find the related item through its relationships
|
||||
* @return The String value of the metadata fields concatened with a seperator as defined
|
||||
* in the deepest Concatened bean in the chain
|
||||
* @return The String value of the metadata fields concatenated with a separator as defined
|
||||
* in the deepest Concatenated bean in the chain
|
||||
* Will return an empty list if no relationships are found
|
||||
* @throws SQLException If something goes wrong
|
||||
*/
|
||||
@@ -173,12 +173,12 @@ public class Related implements VirtualMetadataConfiguration {
|
||||
|
||||
for (Relationship relationship : relationships) {
|
||||
if (relationship.getRelationshipType().getLeftType() == entityType) {
|
||||
if (relationship.getLeftPlace() == place) {
|
||||
if (place == null || relationship.getLeftPlace() == place) {
|
||||
Item otherItem = relationship.getRightItem();
|
||||
return virtualMetadataConfiguration.getValues(context, otherItem);
|
||||
}
|
||||
} else if (relationship.getRelationshipType().getRightType() == entityType) {
|
||||
if (relationship.getRightPlace() == place) {
|
||||
if (place == null || relationship.getRightPlace() == place) {
|
||||
Item otherItem = relationship.getLeftItem();
|
||||
return virtualMetadataConfiguration.getValues(context, otherItem);
|
||||
}
|
||||
|
@@ -1,340 +0,0 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.core;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.configuration2.Configuration;
|
||||
import org.apache.commons.configuration2.ConfigurationConverter;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* Class for reading the DSpace system configuration. The main configuration is
|
||||
* read in as properties from a standard properties file.
|
||||
* <P>
|
||||
* To specify a different configuration, the system property
|
||||
* <code>dspace.dir</code> should be set to the DSpace installation directory.
|
||||
* <P>
|
||||
* Other configuration files are read from the <code>config</code> directory
|
||||
* of the DSpace installation directory.
|
||||
*
|
||||
* @author Robert Tansley
|
||||
* @author Larry Stone - Interpolated values.
|
||||
* @author Mark Diggory - General Improvements to detection, logging and loading.
|
||||
* @author Tim Donohue - Refactored to wrap ConfigurationService
|
||||
* @version $Revision$
|
||||
* @deprecated Please use org.dspace.services.ConfigurationService. See examples below.
|
||||
*/
|
||||
public class ConfigurationManager {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(ConfigurationManager.class);
|
||||
|
||||
protected ConfigurationManager() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify if DSpace is properly configured
|
||||
*
|
||||
* @return boolean true if configured, false otherwise
|
||||
*/
|
||||
public static boolean isConfigured() {
|
||||
return DSpaceServicesFactory.getInstance().getConfigurationService() != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all properties in main configuration
|
||||
*
|
||||
* @return properties - all non-modular properties
|
||||
*/
|
||||
public static Properties getProperties() {
|
||||
return DSpaceServicesFactory.getInstance().getConfigurationService().getProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all properties for a given module
|
||||
*
|
||||
* @param module the name of the module
|
||||
* @return properties - all module's properties
|
||||
*/
|
||||
public static Properties getProperties(String module) {
|
||||
// Find subset of Configurations which have been prefixed with the module name
|
||||
Configuration subset = DSpaceServicesFactory.getInstance().getConfigurationService().getConfiguration()
|
||||
.subset(module);
|
||||
|
||||
// Convert to a Properties object and return it
|
||||
return ConfigurationConverter.getProperties(subset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration property
|
||||
*
|
||||
* @param property the name of the property
|
||||
* @return the value of the property, or <code>null</code> if the property
|
||||
* does not exist.
|
||||
*/
|
||||
public static String getProperty(String property) {
|
||||
return DSpaceServicesFactory.getInstance().getConfigurationService().getProperty(property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a module configuration property value.
|
||||
*
|
||||
* @param module the name of the module, or <code>null</code> for regular configuration
|
||||
* property
|
||||
* @param property the name (key) of the property
|
||||
* @return the value of the property, or <code>null</code> if the
|
||||
* property does not exist
|
||||
*/
|
||||
public static String getProperty(String module, String property) {
|
||||
if (module == null) {
|
||||
return getProperty(property);
|
||||
}
|
||||
|
||||
// Assume "module" properties are always prefixed with the module name
|
||||
return getProperty(module + "." + property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration property as an integer
|
||||
*
|
||||
* @param property the name of the property
|
||||
* @return the value of the property. <code>0</code> is returned if the
|
||||
* property does not exist. To differentiate between this case and
|
||||
* when the property actually is zero, use <code>getProperty</code>.
|
||||
*/
|
||||
public static int getIntProperty(String property) {
|
||||
return DSpaceServicesFactory.getInstance().getConfigurationService().getIntProperty(property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a module configuration property as an integer
|
||||
*
|
||||
* @param module the name of the module
|
||||
* @param property the name of the property
|
||||
* @return the value of the property. <code>0</code> is returned if the
|
||||
* property does not exist. To differentiate between this case and
|
||||
* when the property actually is zero, use <code>getProperty</code>.
|
||||
*/
|
||||
public static int getIntProperty(String module, String property) {
|
||||
if (module == null) {
|
||||
return getIntProperty(property);
|
||||
}
|
||||
|
||||
// Assume "module" properties are always prefixed with the module name
|
||||
return getIntProperty(module + "." + property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration property as an integer, with default
|
||||
*
|
||||
* @param property the name of the property
|
||||
* @param defaultValue value to return if property is not found or is not an Integer.
|
||||
* @return the value of the property. <code>default</code> is returned if
|
||||
* the property does not exist or is not an Integer. To differentiate between this case
|
||||
* and when the property actually is false, use
|
||||
* <code>getProperty</code>.
|
||||
*/
|
||||
public static int getIntProperty(String property, int defaultValue) {
|
||||
return DSpaceServicesFactory.getInstance().getConfigurationService().getIntProperty(property, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a module configuration property as an integer, with default
|
||||
*
|
||||
* @param module the name of the module
|
||||
* @param property the name of the property
|
||||
* @param defaultValue value to return if property is not found or is not an Integer.
|
||||
* @return the value of the property. <code>default</code> is returned if
|
||||
* the property does not exist or is not an Integer. To differentiate between this case
|
||||
* and when the property actually is false, use
|
||||
* <code>getProperty</code>.
|
||||
*/
|
||||
public static int getIntProperty(String module, String property, int defaultValue) {
|
||||
if (module == null) {
|
||||
return getIntProperty(property, defaultValue);
|
||||
}
|
||||
|
||||
// Assume "module" properties are always prefixed with the module name
|
||||
return getIntProperty(module + "." + property, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration property as a long
|
||||
*
|
||||
* @param property the name of the property
|
||||
* @return the value of the property. <code>0</code> is returned if the
|
||||
* property does not exist. To differentiate between this case and
|
||||
* when the property actually is zero, use <code>getProperty</code>.
|
||||
*/
|
||||
public static long getLongProperty(String property) {
|
||||
return DSpaceServicesFactory.getInstance().getConfigurationService().getLongProperty(property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a module configuration property as a long
|
||||
*
|
||||
* @param module the name of the module
|
||||
* @param property the name of the property
|
||||
* @return the value of the property. <code>0</code> is returned if the
|
||||
* property does not exist. To differentiate between this case and
|
||||
* when the property actually is zero, use <code>getProperty</code>.
|
||||
*/
|
||||
public static long getLongProperty(String module, String property) {
|
||||
if (module == null) {
|
||||
return getLongProperty(property);
|
||||
}
|
||||
|
||||
// Assume "module" properties are always prefixed with the module name
|
||||
return getLongProperty(module + "." + property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration property as an long, with default
|
||||
*
|
||||
* @param property the name of the property
|
||||
* @param defaultValue value to return if property is not found or is not a Long.
|
||||
* @return the value of the property. <code>default</code> is returned if
|
||||
* the property does not exist or is not an Integer. To differentiate between this case
|
||||
* and when the property actually is false, use
|
||||
* <code>getProperty</code>.
|
||||
*/
|
||||
public static long getLongProperty(String property, int defaultValue) {
|
||||
return DSpaceServicesFactory.getInstance().getConfigurationService().getLongProperty(property, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration property as an long, with default
|
||||
*
|
||||
* @param module the module, or <code>null</code> for regular property
|
||||
* @param property the name of the property
|
||||
* @param defaultValue value to return if property is not found or is not a Long.
|
||||
* @return the value of the property. <code>default</code> is returned if
|
||||
* the property does not exist or is not an Integer. To differentiate between this case
|
||||
* and when the property actually is false, use
|
||||
* <code>getProperty</code>.
|
||||
*/
|
||||
public static long getLongProperty(String module, String property, int defaultValue) {
|
||||
if (module == null) {
|
||||
return getLongProperty(property, defaultValue);
|
||||
}
|
||||
|
||||
// Assume "module" properties are always prefixed with the module name
|
||||
return getLongProperty(module + "." + property, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration property as a boolean. True is indicated if the value
|
||||
* of the property is <code>TRUE</code> or <code>YES</code> (case
|
||||
* insensitive.)
|
||||
*
|
||||
* @param property the name of the property
|
||||
* @return the value of the property. <code>false</code> is returned if
|
||||
* the property does not exist. To differentiate between this case
|
||||
* and when the property actually is false, use
|
||||
* <code>getProperty</code>.
|
||||
*/
|
||||
public static boolean getBooleanProperty(String property) {
|
||||
return DSpaceServicesFactory.getInstance().getConfigurationService().getBooleanProperty(property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a module configuration property as a boolean. True is indicated if
|
||||
* the value of the property is <code>TRUE</code> or <code>YES</code> (case
|
||||
* insensitive.)
|
||||
*
|
||||
* @param module the module, or <code>null</code> for regular property
|
||||
* @param property the name of the property
|
||||
* @return the value of the property. <code>false</code> is returned if
|
||||
* the property does not exist. To differentiate between this case
|
||||
* and when the property actually is false, use
|
||||
* <code>getProperty</code>.
|
||||
*/
|
||||
public static boolean getBooleanProperty(String module, String property) {
|
||||
if (module == null) {
|
||||
return getBooleanProperty(property);
|
||||
}
|
||||
|
||||
// Assume "module" properties are always prefixed with the module name
|
||||
return getBooleanProperty(module + "." + property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a configuration property as a boolean, with default.
|
||||
* True is indicated if the value
|
||||
* of the property is <code>TRUE</code> or <code>YES</code> (case
|
||||
* insensitive.)
|
||||
*
|
||||
* @param property the name of the property
|
||||
* @param defaultValue value to return if property is not found.
|
||||
* @return the value of the property. <code>default</code> is returned if
|
||||
* the property does not exist. To differentiate between this case
|
||||
* and when the property actually is false, use
|
||||
* <code>getProperty</code>.
|
||||
*/
|
||||
public static boolean getBooleanProperty(String property, boolean defaultValue) {
|
||||
return DSpaceServicesFactory.getInstance().getConfigurationService().getBooleanProperty(property, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a module configuration property as a boolean, with default.
|
||||
* True is indicated if the value
|
||||
* of the property is <code>TRUE</code> or <code>YES</code> (case
|
||||
* insensitive.)
|
||||
*
|
||||
* @param module module, or <code>null</code> for regular property
|
||||
* @param property the name of the property
|
||||
* @param defaultValue value to return if property is not found.
|
||||
* @return the value of the property. <code>default</code> is returned if
|
||||
* the property does not exist. To differentiate between this case
|
||||
* and when the property actually is false, use
|
||||
* <code>getProperty</code>.
|
||||
*/
|
||||
public static boolean getBooleanProperty(String module, String property, boolean defaultValue) {
|
||||
if (module == null) {
|
||||
return getBooleanProperty(property, defaultValue);
|
||||
}
|
||||
|
||||
// Assume "module" properties are always prefixed with the module name
|
||||
return getBooleanProperty(module + "." + property, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an enumeration of all the keys in the DSpace configuration
|
||||
* <P>
|
||||
* As ConfigurationManager is now deprecated, older code using this method
|
||||
* should consider using ConfigurationService.getPropertyKeys() directly.
|
||||
*
|
||||
* @return an enumeration of all the keys in the DSpace configuration
|
||||
*/
|
||||
public static Enumeration<?> propertyNames() {
|
||||
// Get a list of all property keys, and convert into an Enumeration
|
||||
return java.util.Collections
|
||||
.enumeration(DSpaceServicesFactory.getInstance().getConfigurationService().getPropertyKeys());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an enumeration of all the keys in a module configuration
|
||||
* <P>
|
||||
* As ConfigurationManager is now deprecated, older code using this method
|
||||
* should consider using ConfigurationService.getPropertyKeys(String prefix) directly.
|
||||
*
|
||||
* @param module module, or <code>null</code> for regular property
|
||||
* @return an enumeration of all the keys in the module configuration,
|
||||
* or <code>null</code> if the module does not exist.
|
||||
*/
|
||||
public static Enumeration<?> propertyNames(String module) {
|
||||
// Get property keys beginning with this prefix, and convert into an Enumeration
|
||||
return java.util.Collections
|
||||
.enumeration(DSpaceServicesFactory.getInstance().getConfigurationService().getPropertyKeys(module));
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user