mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 10:04:21 +00:00
Compare commits
1 Commits
dspace-7.0
...
rest-tutor
Author | SHA1 | Date | |
---|---|---|---|
![]() |
cfc200f2c7 |
29
.codecov.yml
29
.codecov.yml
@@ -1,29 +0,0 @@
|
||||
# DSpace configuration for Codecov.io coverage reports
|
||||
# These override the default YAML settings at
|
||||
# https://docs.codecov.io/docs/codecov-yaml#section-default-yaml
|
||||
# Can be validated via instructions at:
|
||||
# https://docs.codecov.io/docs/codecov-yaml#validate-your-repository-yaml
|
||||
|
||||
# Settings related to code coverage analysis
|
||||
coverage:
|
||||
status:
|
||||
# Configuration for project-level checks. This checks how the PR changes overall coverage.
|
||||
project:
|
||||
default:
|
||||
# For each PR, auto compare coverage to previous commit.
|
||||
# Require that overall (project) coverage does NOT drop more than 0.5%
|
||||
target: auto
|
||||
threshold: 0.5%
|
||||
# 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%
|
||||
|
||||
# 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
|
||||
# However, this same info is available from the Codecov checks in the PR's
|
||||
# "Checks" tab in GitHub. So, the comment is unnecessary.
|
||||
comment: false
|
@@ -1,11 +0,0 @@
|
||||
.git/
|
||||
.idea/
|
||||
.settings/
|
||||
*/target/
|
||||
dspace/modules/*/target/
|
||||
Dockerfile.*
|
||||
dspace/src/main/docker/dspace-postgres-pgcrypto
|
||||
dspace/src/main/docker/dspace-postgres-pgcrypto-curl
|
||||
dspace/src/main/docker/solr
|
||||
dspace/src/main/docker/README.md
|
||||
dspace/src/main/docker-compose/
|
6
.gitattributes
vendored
6
.gitattributes
vendored
@@ -1,12 +1,6 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
# Ensure Unix files always keep Unix line endings
|
||||
*.sh text eol=lf
|
||||
|
||||
# Ensure Windows files always keep Windows line endings
|
||||
*.bat text eol=crlf
|
||||
|
||||
# Standard to msysgit
|
||||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
|
22
.github/ISSUE_TEMPLATE/bug_report.md
vendored
22
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,22 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug, needs triage
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is. Include the version(s) of DSpace where you've seen this problem. Link to examples if they are public.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Do this
|
||||
2. Then this...
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Related work**
|
||||
Link to any related tickets or PRs here.
|
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest a new feature for this project
|
||||
title: ''
|
||||
labels: new feature, needs triage
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives or workarounds you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
@@ -1,26 +0,0 @@
|
||||
# This workflow runs whenever a new pull request is created
|
||||
# TEMPORARILY DISABLED. Unfortunately this doesn't work for PRs created from forked repositories (which is how we tend to create PRs).
|
||||
# There is no known workaround yet. See https://github.community/t/how-to-use-github-token-for-prs-from-forks/16818
|
||||
name: Pull Request opened
|
||||
|
||||
# Only run for newly opened PRs against the "main" branch
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened]
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
automation:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Assign the PR to whomever created it. This is useful for visualizing assignments on project boards
|
||||
# See https://github.com/marketplace/actions/pull-request-assigner
|
||||
- name: Assign PR to creator
|
||||
uses: thomaseizinger/assign-pr-creator-action@v1.0.0
|
||||
# Note, this authentication token is created automatically
|
||||
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# Ignore errors. It is possible the PR was created by someone who cannot be assigned
|
||||
continue-on-error: true
|
26
.github/pull_request_template.md
vendored
26
.github/pull_request_template.md
vendored
@@ -1,26 +0,0 @@
|
||||
## 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
|
||||
|
||||
## Description
|
||||
Short summary of changes (1-2 sentences).
|
||||
|
||||
## Instructions for Reviewers
|
||||
Please add a more detailed description of the changes made by your PR. At a minimum, providing a bulleted list of changes in your PR is helpful to reviewers.
|
||||
|
||||
List of changes in this PR:
|
||||
* First, ...
|
||||
* Second, ...
|
||||
|
||||
**Include guidance for how to test or review your PR.** This may include: steps to reproduce a bug, screenshots or description of a new feature, or reasons behind specific changes.
|
||||
|
||||
## Checklist
|
||||
_This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome). If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!_
|
||||
|
||||
- [ ] My PR is small in size (e.g. less than 1,000 lines of code, not including comments & integration tests). Exceptions may be made if previously agreed upon.
|
||||
- [ ] My PR passes Checkstyle validation based on the [Code Style Guide](https://wiki.lyrasis.org/display/DSPACE/Code+Style+Guide).
|
||||
- [ ] My PR includes Javadoc for _all new (or modified) public methods and classes_. It also includes Javadoc for large or complex private methods.
|
||||
- [ ] My PR passes all tests and includes new/updated Unit or Integration Tests based on the [Code Testing Guide](https://wiki.lyrasis.org/display/DSPACE/Code+Testing+Guide).
|
||||
- [ ] If my PR includes new, third-party dependencies (in any `pom.xml`), I've made sure their licenses align with the [DSpace BSD License](https://github.com/DSpace/DSpace/blob/main/LICENSE) based on the [Licensing of Contributions](https://wiki.lyrasis.org/display/DSPACE/Code+Contribution+Guidelines#CodeContributionGuidelines-LicensingofContributions) documentation.
|
||||
- [ ] If my PR modifies the REST API, I've linked to the REST Contract page (or open PR) related to this change.
|
29
.github/workflows/issue_opened.yml
vendored
29
.github/workflows/issue_opened.yml
vendored
@@ -1,29 +0,0 @@
|
||||
# This workflow runs whenever a new issue is created
|
||||
name: Issue opened
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
|
||||
jobs:
|
||||
automation:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Add the new issue to a project board, if it needs triage
|
||||
# See https://github.com/marketplace/actions/create-project-card-action
|
||||
- name: Add issue to project board
|
||||
# Only add to project board if issue is flagged as "needs triage" or has no labels
|
||||
# NOTE: By default we flag new issues as "needs triage" in our issue template
|
||||
if: (contains(github.event.issue.labels.*.name, 'needs triage') || join(github.event.issue.labels.*.name) == '')
|
||||
uses: technote-space/create-project-card-action@v1
|
||||
# Note, the authentication token below is an ORG level Secret.
|
||||
# It must be created/recreated manually via a personal access token with "public_repo" and "admin:org" permissions
|
||||
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token
|
||||
# This is necessary because the "DSpace Backlog" project is an org level project (i.e. not repo specific)
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.ORG_PROJECT_TOKEN }}
|
||||
PROJECT: DSpace Backlog
|
||||
COLUMN: Triage
|
||||
CHECK_ORG_PROJECT: true
|
||||
# Ignore errors.
|
||||
continue-on-error: true
|
25
.github/workflows/label_merge_conflicts.yml
vendored
25
.github/workflows/label_merge_conflicts.yml
vendored
@@ -1,25 +0,0 @@
|
||||
# This workflow checks open PRs for merge conflicts and labels them when conflicts are found
|
||||
name: Check for merge conflicts
|
||||
|
||||
# Run whenever the "main" branch is updated
|
||||
# NOTE: This means merge conflicts are only checked for when a PR is merged to main.
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
triage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# See: https://github.com/mschilde/auto-label-merge-conflicts/
|
||||
- name: Auto-label PRs with merge conflicts
|
||||
uses: mschilde/auto-label-merge-conflicts@v2.0
|
||||
# Add "merge conflict" label if a merge conflict is detected. Remove it when resolved.
|
||||
# Note, the authentication token is created automatically
|
||||
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
|
||||
with:
|
||||
CONFLICT_LABEL_NAME: 'merge conflict'
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# Ignore errors
|
||||
continue-on-error: true
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -41,4 +41,4 @@ nb-configuration.xml
|
||||
.DS_Store
|
||||
|
||||
##Ignore JRebel project configuration
|
||||
rebel.xml
|
||||
rebel.xml
|
||||
|
@@ -1,9 +0,0 @@
|
||||
# LGTM Settings (https://lgtm.com/)
|
||||
# For reference, see https://lgtm.com/help/lgtm/lgtm.yml-configuration-file
|
||||
# or template at https://lgtm.com/static/downloads/lgtm.template.yml
|
||||
|
||||
extraction:
|
||||
java:
|
||||
index:
|
||||
# Specify the Java version required to build the project
|
||||
java_version: 11
|
83
.travis.yml
83
.travis.yml
@@ -1,55 +1,44 @@
|
||||
# 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
|
||||
sudo: false
|
||||
|
||||
env:
|
||||
# Give Maven 1GB of memory to work with
|
||||
- MAVEN_OPTS=-Xmx1024M
|
||||
|
||||
jdk:
|
||||
# DS-3384 Oracle JDK has DocLint enabled by default.
|
||||
# DS-3384 Oracle JDK 8 has DocLint enabled by default.
|
||||
# Let's use this to catch any newly introduced DocLint issues.
|
||||
- oraclejdk11
|
||||
- oraclejdk8
|
||||
|
||||
# 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"
|
||||
## Should we run into any problems with oraclejdk8 on Travis, we may try the following workaround.
|
||||
## https://docs.travis-ci.com/user/languages/java#Testing-Against-Multiple-JDKs
|
||||
## https://github.com/travis-ci/travis-ci/issues/3259#issuecomment-130860338
|
||||
#addons:
|
||||
# apt:
|
||||
# packages:
|
||||
# - oracle-java8-installer
|
||||
|
||||
# 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"
|
||||
# Install prerequisites for building Mirage2 more rapidly
|
||||
before_install:
|
||||
# Remove outdated settings.xml from Travis builds. Workaround for https://github.com/travis-ci/travis-ci/issues/4629
|
||||
- rm ~/.m2/settings.xml
|
||||
|
||||
# Skip 'install' process to save time. We build/install/test all at once in "script" below.
|
||||
install: skip
|
||||
# Skip install stage, as we'll do it below
|
||||
install: "echo 'Skipping install stage, dependencies will be downloaded during build and test stages.'"
|
||||
|
||||
# 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)
|
||||
# Two stage Build and Test
|
||||
# 1. Install & Unit Test APIs
|
||||
# 2. Assemble DSpace
|
||||
script:
|
||||
# 1. [Install & Unit Test] Check source code licenses and run source code Unit Tests
|
||||
# license:check => Validate all source code license headers
|
||||
# -Dmaven.test.skip=false => Enable DSpace Unit Tests
|
||||
# -DskipITs=false => Enable DSpace Integration Tests
|
||||
# -P !assembly => Skip normal assembly (as it can be memory intensive)
|
||||
# -B => Maven batch/non-interactive mode (recommended for CI)
|
||||
# -V => Display Maven version info before build
|
||||
# -Dsurefire.rerunFailingTestsCount=2 => try again for flakey tests, and keep track of/report on number of retries
|
||||
- "mvn clean install license:check -Dmaven.test.skip=false -DskipITs=false -P !assembly -B -V -Dsurefire.rerunFailingTestsCount=2"
|
||||
# 2. [Assemble DSpace] Ensure overlay & assembly process works (from [src]/dspace/)
|
||||
# -P !assembly => SKIP the actual building of [src]/dspace/dspace-installer (as it can be memory intensive)
|
||||
- "cd dspace && mvn package -P !assembly -B -V -Dsurefire.rerunFailingTestsCount=2"
|
||||
|
63
Dockerfile
63
Dockerfile
@@ -1,63 +0,0 @@
|
||||
# This image will be published as dspace/dspace
|
||||
# See https://github.com/DSpace/DSpace/tree/main/dspace/src/main/docker for usage details
|
||||
#
|
||||
# This version is JDK11 compatible
|
||||
# - tomcat:8-jdk11
|
||||
# - ANT 1.10.7
|
||||
# - maven:3-jdk-11 (see dspace-dependencies)
|
||||
# - note: default tag for branch: dspace/dspace: dspace/dspace:dspace-7_x
|
||||
|
||||
# Step 1 - Run Maven Build
|
||||
FROM dspace/dspace-dependencies:dspace-7_x as build
|
||||
ARG TARGET_DIR=dspace-installer
|
||||
WORKDIR /app
|
||||
|
||||
# The dspace-install directory will be written to /install
|
||||
RUN mkdir /install \
|
||||
&& chown -Rv dspace: /install \
|
||||
&& chown -Rv dspace: /app
|
||||
|
||||
USER dspace
|
||||
|
||||
# Copy the DSpace source code into the workdir (excluding .dockerignore contents)
|
||||
ADD --chown=dspace . /app/
|
||||
COPY dspace/src/main/docker/local.cfg /app/local.cfg
|
||||
|
||||
# Build DSpace (note: this build doesn't include the optional, deprecated "dspace-rest" webapp)
|
||||
# Copy the dspace-install directory to /install. Clean up the build to keep the docker image small
|
||||
RUN mvn package && \
|
||||
mv /app/dspace/target/${TARGET_DIR}/* /install && \
|
||||
mvn clean
|
||||
|
||||
# Step 2 - Run Ant Deploy
|
||||
FROM tomcat:8-jdk11 as ant_build
|
||||
ARG TARGET_DIR=dspace-installer
|
||||
COPY --from=build /install /dspace-src
|
||||
WORKDIR /dspace-src
|
||||
|
||||
# Create the initial install deployment using ANT
|
||||
ENV ANT_VERSION 1.10.7
|
||||
ENV ANT_HOME /tmp/ant-$ANT_VERSION
|
||||
ENV PATH $ANT_HOME/bin:$PATH
|
||||
|
||||
RUN mkdir $ANT_HOME && \
|
||||
wget -qO- "https://archive.apache.org/dist/ant/binaries/apache-ant-$ANT_VERSION-bin.tar.gz" | tar -zx --strip-components=1 -C $ANT_HOME
|
||||
|
||||
RUN ant init_installation update_configs update_code update_webapps
|
||||
|
||||
# Step 3 - Run tomcat
|
||||
# Create a new tomcat image that does not retain the the build directory contents
|
||||
FROM tomcat:8-jdk11
|
||||
ENV DSPACE_INSTALL=/dspace
|
||||
COPY --from=ant_build /dspace $DSPACE_INSTALL
|
||||
EXPOSE 8080 8009
|
||||
|
||||
ENV JAVA_OPTS=-Xmx2000m
|
||||
|
||||
# Run the "server" webapp off the /server path (e.g. http://localhost:8080/server/)
|
||||
RUN ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/server
|
||||
# If you wish to run "server" webapp off the ROOT path, then comment out the above RUN, and uncomment the below RUN.
|
||||
# You also MUST update the URL in dspace/src/main/docker/local.cfg
|
||||
# Please note that server webapp should only run on one path at a time.
|
||||
#RUN mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT.bk && \
|
||||
# ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/ROOT
|
@@ -1,53 +0,0 @@
|
||||
# This image will be published as dspace/dspace-cli
|
||||
# See https://github.com/DSpace/DSpace/tree/main/dspace/src/main/docker for usage details
|
||||
#
|
||||
# This version is JDK11 compatible
|
||||
# - openjdk:11
|
||||
# - ANT 1.10.7
|
||||
# - maven:3-jdk-11 (see dspace-dependencies)
|
||||
# - note: default tag for branch: dspace/dspace-cli: dspace/dspace-cli:dspace-7_x
|
||||
|
||||
# Step 1 - Run Maven Build
|
||||
FROM dspace/dspace-dependencies:dspace-7_x as build
|
||||
ARG TARGET_DIR=dspace-installer
|
||||
WORKDIR /app
|
||||
|
||||
# The dspace-install directory will be written to /install
|
||||
RUN mkdir /install \
|
||||
&& chown -Rv dspace: /install \
|
||||
&& chown -Rv dspace: /app
|
||||
|
||||
USER dspace
|
||||
|
||||
# Copy the DSpace source code into the workdir (excluding .dockerignore contents)
|
||||
ADD --chown=dspace . /app/
|
||||
COPY dspace/src/main/docker/local.cfg /app/local.cfg
|
||||
|
||||
# Build DSpace. Copy the dspace-install directory to /install. Clean up the build to keep the docker image small
|
||||
RUN mvn package && \
|
||||
mv /app/dspace/target/${TARGET_DIR}/* /install && \
|
||||
mvn clean
|
||||
|
||||
# Step 2 - Run Ant Deploy
|
||||
FROM openjdk:11 as ant_build
|
||||
ARG TARGET_DIR=dspace-installer
|
||||
COPY --from=build /install /dspace-src
|
||||
WORKDIR /dspace-src
|
||||
|
||||
# Create the initial install deployment using ANT
|
||||
ENV ANT_VERSION 1.10.7
|
||||
ENV ANT_HOME /tmp/ant-$ANT_VERSION
|
||||
ENV PATH $ANT_HOME/bin:$PATH
|
||||
|
||||
RUN mkdir $ANT_HOME && \
|
||||
wget -qO- "https://archive.apache.org/dist/ant/binaries/apache-ant-$ANT_VERSION-bin.tar.gz" | tar -zx --strip-components=1 -C $ANT_HOME
|
||||
|
||||
RUN ant init_installation update_configs update_code
|
||||
|
||||
# Step 3 - Run jdk
|
||||
# Create a new tomcat image that does not retain the the build directory contents
|
||||
FROM openjdk:11
|
||||
ENV DSPACE_INSTALL=/dspace
|
||||
COPY --from=ant_build /dspace $DSPACE_INSTALL
|
||||
|
||||
ENV JAVA_OPTS=-Xmx1000m
|
@@ -1,27 +0,0 @@
|
||||
# This image will be published as dspace/dspace-dependencies
|
||||
# The purpose of this image is to make the build for dspace/dspace run faster
|
||||
#
|
||||
# This version is JDK11 compatible
|
||||
# - maven:3-jdk-11
|
||||
|
||||
# Step 1 - Run Maven Build
|
||||
FROM maven:3-jdk-11 as build
|
||||
ARG TARGET_DIR=dspace-installer
|
||||
WORKDIR /app
|
||||
|
||||
RUN useradd dspace \
|
||||
&& mkdir /home/dspace \
|
||||
&& chown -Rv dspace: /home/dspace
|
||||
USER dspace
|
||||
|
||||
# Copy the DSpace source code into the workdir (excluding .dockerignore contents)
|
||||
ADD --chown=dspace . /app/
|
||||
COPY dspace/src/main/docker/local.cfg /app/local.cfg
|
||||
|
||||
# Trigger the installation of all maven dependencies
|
||||
RUN mvn package
|
||||
|
||||
# Clear the contents of the /app directory (including all maven builds), so no artifacts remain.
|
||||
# This ensures when dspace:dspace is built, it will just the Maven local cache (.m2) for dependencies
|
||||
USER root
|
||||
RUN rm -rf /app/*
|
@@ -1,72 +0,0 @@
|
||||
# This image will be published as dspace/dspace
|
||||
# See https://github.com/DSpace/DSpace/tree/main/dspace/src/main/docker for usage details
|
||||
#
|
||||
# This version is JDK11 compatible
|
||||
# - tomcat:8-jdk11
|
||||
# - ANT 1.10.7
|
||||
# - maven:3-jdk-11 (see dspace-dependencies)
|
||||
# - note: default tag for branch: dspace/dspace: dspace/dspace:dspace-7_x-test
|
||||
#
|
||||
# This image is meant for TESTING/DEVELOPMENT ONLY as it deploys the old v6 REST API under HTTP (not HTTPS)
|
||||
|
||||
# Step 1 - Run Maven Build
|
||||
FROM dspace/dspace-dependencies:dspace-7_x as build
|
||||
ARG TARGET_DIR=dspace-installer
|
||||
WORKDIR /app
|
||||
|
||||
# The dspace-install directory will be written to /install
|
||||
RUN mkdir /install \
|
||||
&& chown -Rv dspace: /install \
|
||||
&& chown -Rv dspace: /app
|
||||
|
||||
USER dspace
|
||||
|
||||
# Copy the DSpace source code into the workdir (excluding .dockerignore contents)
|
||||
ADD --chown=dspace . /app/
|
||||
COPY dspace/src/main/docker/local.cfg /app/local.cfg
|
||||
|
||||
# Build DSpace (including the optional, deprecated "dspace-rest" webapp)
|
||||
# Copy the dspace-install directory to /install. Clean up the build to keep the docker image small
|
||||
RUN mvn package -Pdspace-rest && \
|
||||
mv /app/dspace/target/${TARGET_DIR}/* /install && \
|
||||
mvn clean
|
||||
|
||||
# Step 2 - Run Ant Deploy
|
||||
FROM tomcat:8-jdk11 as ant_build
|
||||
ARG TARGET_DIR=dspace-installer
|
||||
COPY --from=build /install /dspace-src
|
||||
WORKDIR /dspace-src
|
||||
|
||||
# Create the initial install deployment using ANT
|
||||
ENV ANT_VERSION 1.10.7
|
||||
ENV ANT_HOME /tmp/ant-$ANT_VERSION
|
||||
ENV PATH $ANT_HOME/bin:$PATH
|
||||
|
||||
RUN mkdir $ANT_HOME && \
|
||||
wget -qO- "https://archive.apache.org/dist/ant/binaries/apache-ant-$ANT_VERSION-bin.tar.gz" | tar -zx --strip-components=1 -C $ANT_HOME
|
||||
|
||||
RUN ant init_installation update_configs update_code update_webapps
|
||||
|
||||
# Step 3 - Run tomcat
|
||||
# Create a new tomcat image that does not retain the the build directory contents
|
||||
FROM tomcat:8-jdk11
|
||||
ENV DSPACE_INSTALL=/dspace
|
||||
COPY --from=ant_build /dspace $DSPACE_INSTALL
|
||||
EXPOSE 8080 8009
|
||||
|
||||
ENV JAVA_OPTS=-Xmx2000m
|
||||
|
||||
# Run the "server" webapp off the /server path (e.g. http://localhost:8080/server/)
|
||||
# and the v6.x (deprecated) REST API off the "/rest" path
|
||||
RUN ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/server && \
|
||||
ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest
|
||||
# If you wish to run "server" webapp off the ROOT path, then comment out the above RUN, and uncomment the below RUN.
|
||||
# You also MUST update the URL in dspace/src/main/docker/local.cfg
|
||||
# Please note that server webapp should only run on one path at a time.
|
||||
#RUN mv /usr/local/tomcat/webapps/ROOT /usr/local/tomcat/webapps/ROOT.bk && \
|
||||
# ln -s $DSPACE_INSTALL/webapps/server /usr/local/tomcat/webapps/ROOT && \
|
||||
# ln -s $DSPACE_INSTALL/webapps/rest /usr/local/tomcat/webapps/rest
|
||||
|
||||
# Overwrite the v6.x (deprecated) REST API's web.xml, so that we can run it on HTTP (defaults to requiring HTTPS)
|
||||
COPY dspace/src/main/docker/test/rest_web.xml $DSPACE_INSTALL/webapps/rest/WEB-INF/web.xml
|
||||
RUN sed -i -e "s|\${dspace.dir}|$DSPACE_INSTALL|" $DSPACE_INSTALL/webapps/rest/WEB-INF/web.xml
|
11
LICENSE
11
LICENSE
@@ -1,6 +1,7 @@
|
||||
DSpace source code BSD License:
|
||||
DSpace source code license:
|
||||
|
||||
Copyright (c) 2002-2020, LYRASIS. All rights reserved.
|
||||
|
||||
Copyright (c) 2002-2016, DuraSpace. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
@@ -33,7 +34,7 @@ DAMAGE.
|
||||
|
||||
|
||||
DSpace uses third-party libraries which may be distributed under
|
||||
different licenses to the above. Information about these licenses
|
||||
is detailed in the LICENSES_THIRD_PARTY file at the root of the source
|
||||
tree. You must agree to the terms of these licenses, in addition to
|
||||
different licenses to the above. Information about these licenses
|
||||
is detailed in the LICENSES_THIRD_PARTY file at the root of the source
|
||||
tree. You must agree to the terms of these licenses, in addition to
|
||||
the above DSpace source code license, in order to use this software.
|
||||
|
@@ -366,6 +366,7 @@ https://wiki.duraspace.org/display/DSPACE/Code+Contribution+Guidelines
|
||||
* FindBugs-Annotations (com.google.code.findbugs:annotations:3.0.1u2 - http://findbugs.sourceforge.net/)
|
||||
* MaxMind GeoIP Legacy API (com.maxmind.geoip:geoip-api:1.3.0 - https://github.com/maxmind/geoip-api-java)
|
||||
* JHighlight (com.uwyn:jhighlight:1.0 - https://jhighlight.dev.java.net/)
|
||||
* DSpace TM-Extractors Dependency (org.dspace.dependencies:dspace-tm-extractors:1.0.1 - http://projects.dspace.org/dspace-pom/dspace-tm-extractors)
|
||||
* A Hibernate O/RM Module (org.hibernate:hibernate-core:4.2.21.Final - http://hibernate.org)
|
||||
* A Hibernate O/RM Module (org.hibernate:hibernate-ehcache:4.2.21.Final - http://hibernate.org)
|
||||
* Hibernate Commons Annotations (org.hibernate.common:hibernate-commons-annotations:4.0.2.Final - http://hibernate.org)
|
||||
|
21
NOTICE
21
NOTICE
@@ -1,18 +1,15 @@
|
||||
Licensing Notices
|
||||
=================
|
||||
|
||||
[July 2019] DuraSpace joined with LYRASIS (another 501(c)3 organization) in July 2019.
|
||||
LYRASIS holds the copyrights of DuraSpace.
|
||||
Licensing Notice
|
||||
|
||||
[July 2009] Fedora Commons joined with the DSpace Foundation and began operating under
|
||||
Fedora Commons joined with the DSpace Foundation and began operating under
|
||||
the new name DuraSpace in July 2009. DuraSpace holds the copyrights of
|
||||
the DSpace Foundation, Inc.
|
||||
|
||||
[July 2007] The DSpace Foundation, Inc. is a 501(c)3 corporation established in July 2007
|
||||
with a mission to promote and advance the dspace platform enabling management,
|
||||
access and preservation of digital works. The Foundation was able to transfer
|
||||
the legal copyright from Hewlett-Packard Company (HP) and Massachusetts
|
||||
Institute of Technology (MIT) to the DSpace Foundation in October 2007. Many
|
||||
of the files in the source code may contain a copyright statement stating HP
|
||||
and MIT possess the copyright, in these instances please note that the copy
|
||||
The DSpace Foundation, Inc. is a 501(c)3 corporation established in July 2007
|
||||
with a mission to promote and advance the dspace platform enabling management,
|
||||
access and preservation of digital works. The Foundation was able to transfer
|
||||
the legal copyright from Hewlett-Packard Company (HP) and Massachusetts
|
||||
Institute of Technology (MIT) to the DSpace Foundation in October 2007. Many
|
||||
of the files in the source code may contain a copyright statement stating HP
|
||||
and MIT possess the copyright, in these instances please note that the copy
|
||||
right has transferred to the DSpace foundation, and subsequently to DuraSpace.
|
||||
|
106
README.md
106
README.md
@@ -1,24 +1,27 @@
|
||||
|
||||
# DSpace
|
||||
|
||||
[](https://travis-ci.com/DSpace/DSpace)
|
||||
## NOTE: The rest-tutorial branch has been created to support the [DSpace 7 REST documentation](https://dspace-labs.github.io/DSpace7RestTutorial/walkthrough/intro)
|
||||
- This branch provides stable, referencable line numbers in code
|
||||
|
||||
[DSpace Documentation](https://wiki.lyrasis.org/display/DSDOC/) |
|
||||
[](https://travis-ci.org/DSpace/DSpace)
|
||||
|
||||
[DSpace Documentation](https://wiki.duraspace.org/display/DSDOC/) |
|
||||
[DSpace Releases](https://github.com/DSpace/DSpace/releases) |
|
||||
[DSpace Wiki](https://wiki.lyrasis.org/display/DSPACE/Home) |
|
||||
[Support](https://wiki.lyrasis.org/display/DSPACE/Support)
|
||||
[DSpace Wiki](https://wiki.duraspace.org/display/DSPACE/Home) |
|
||||
[Support](https://wiki.duraspace.org/display/DSPACE/Support)
|
||||
|
||||
DSpace open source software is a turnkey repository application used by more than
|
||||
DSpace open source software is a turnkey repository application used by more than
|
||||
2,000 organizations and institutions worldwide to provide durable access to digital resources.
|
||||
For more information, visit http://www.dspace.org/
|
||||
|
||||
***
|
||||
:warning: **Work on DSpace 7 has begun on our `main` branch.** This means that there is NO user interface on this `main` branch. DSpace 7 will feature a new, unified [Angular](https://angular.io/) user interface, along with an enhanced, rebuilt REST API. The latest status of this work can be found on the [DSpace 7 Working Group](https://wiki.lyrasis.org/display/DSPACE/DSpace+7+Working+Group) page. Additionally, the codebases can be found in the following places:
|
||||
* DSpace 7 REST API work is occurring on the [`main` branch](https://github.com/DSpace/DSpace/tree/main/dspace-server-webapp) of this repository.
|
||||
* The REST Contract is at https://github.com/DSpace/Rest7Contract
|
||||
:warning: **Work on DSpace 7 has begun on our `master` branch.** This means that there is temporarily NO user interface on this `master` branch. DSpace 7 will feature a new, unified [Angular](https://angular.io/) user interface, along with an enhanced, rebuilt REST API. The latest status of this work can be found on the [DSpace 7 UI Working Group](https://wiki.duraspace.org/display/DSPACE/DSpace+7+UI+Working+Group) page. Additionally, the codebases can be found in the following places:
|
||||
* DSpace 7 REST API work is occurring on the [`master` branch](https://github.com/DSpace/DSpace/tree/master/dspace-spring-rest) of this repository.
|
||||
* The REST Contract is being documented at https://github.com/DSpace/Rest7Contract
|
||||
* DSpace 7 Angular UI work is occurring at https://github.com/DSpace/dspace-angular
|
||||
|
||||
**If you would like to get involved in our DSpace 7 development effort, we welcome new contributors.** Just join one of our meetings or get in touch via Slack. See the [DSpace 7 Working Group](https://wiki.lyrasis.org/display/DSPACE/DSpace+7+Working+Group) wiki page for more info.
|
||||
|
||||
**If you would like to get involved in our DSpace 7 development effort, we welcome new contributors.** Just join one of our meetings or get in touch via Slack. See the [DSpace 7 UI Working Group](https://wiki.duraspace.org/display/DSPACE/DSpace+7+UI+Working+Group) wiki page for more info.
|
||||
|
||||
**If you are looking for the ongoing maintenance work for DSpace 6 (or prior releases)**, you can find that work on the corresponding maintenance branch (e.g. [`dspace-6_x`](https://github.com/DSpace/DSpace/tree/dspace-6_x)) in this repository.
|
||||
***
|
||||
@@ -31,32 +34,29 @@ Past releases are all available via GitHub at https://github.com/DSpace/DSpace/r
|
||||
|
||||
## Documentation / Installation
|
||||
|
||||
Documentation for each release may be viewed online or downloaded via our [Documentation Wiki](https://wiki.lyrasis.org/display/DSDOC/).
|
||||
Documentation for each release may be viewed online or downloaded via our [Documentation Wiki](https://wiki.duraspace.org/display/DSDOC/).
|
||||
|
||||
The latest DSpace Installation instructions are available at:
|
||||
https://wiki.lyrasis.org/display/DSDOC6x/Installing+DSpace
|
||||
https://wiki.duraspace.org/display/DSDOC6x/Installing+DSpace
|
||||
|
||||
Please be aware that, as a Java web application, DSpace requires a database (PostgreSQL or Oracle)
|
||||
Please be aware that, as a Java web application, DSpace requires a database (PostgreSQL or Oracle)
|
||||
and a servlet container (usually Tomcat) in order to function.
|
||||
More information about these and all other prerequisites can be found in the Installation instructions above.
|
||||
|
||||
## Running DSpace 7 in Docker
|
||||
See [Running DSpace 7 with Docker Compose](dspace/src/main/docker-compose/README.md)
|
||||
|
||||
## Contributing
|
||||
|
||||
DSpace is a community built and supported project. We do not have a centralized development or support team,
|
||||
DSpace is a community built and supported project. We do not have a centralized development or support team,
|
||||
but have a dedicated group of volunteers who help us improve the software, documentation, resources, etc.
|
||||
|
||||
We welcome contributions of any type. Here's a few basic guides that provide suggestions for contributing to DSpace:
|
||||
* [How to Contribute to DSpace](https://wiki.lyrasis.org/display/DSPACE/How+to+Contribute+to+DSpace): How to contribute in general (via code, documentation, bug reports, expertise, etc)
|
||||
* [Code Contribution Guidelines](https://wiki.lyrasis.org/display/DSPACE/Code+Contribution+Guidelines): How to give back code or contribute features, bug fixes, etc.
|
||||
* [DSpace Community Advisory Team (DCAT)](https://wiki.lyrasis.org/display/cmtygp/DSpace+Community+Advisory+Team): If you are not a developer, we also have an interest group specifically for repository managers. The DCAT group meets virtually, once a month, and sends open invitations to join their meetings via the [DCAT mailing list](https://groups.google.com/d/forum/DSpaceCommunityAdvisoryTeam).
|
||||
* [How to Contribute to DSpace](https://wiki.duraspace.org/display/DSPACE/How+to+Contribute+to+DSpace): How to contribute in general (via code, documentation, bug reports, expertise, etc)
|
||||
* [Code Contribution Guidelines](https://wiki.duraspace.org/display/DSPACE/Code+Contribution+Guidelines): How to give back code or contribute features, bug fixes, etc.
|
||||
* [DSpace Community Advisory Team (DCAT)](https://wiki.duraspace.org/display/cmtygp/DSpace+Community+Advisory+Team): If you are not a developer, we also have an interest group specifically for repository managers. The DCAT group meets virtually, once a month, and sends open invitations to join their meetings via the [DCAT mailing list](https://groups.google.com/d/forum/DSpaceCommunityAdvisoryTeam).
|
||||
|
||||
We also encourage GitHub Pull Requests (PRs) at any time. Please see our [Development with Git](https://wiki.lyrasis.org/display/DSPACE/Development+with+Git) guide for more info.
|
||||
We also encourage GitHub Pull Requests (PRs) at any time. Please see our [Development with Git](https://wiki.duraspace.org/display/DSPACE/Development+with+Git) guide for more info.
|
||||
|
||||
In addition, a listing of all known contributors to DSpace software can be
|
||||
found online at: https://wiki.lyrasis.org/display/DSPACE/DSpaceContributors
|
||||
found online at: https://wiki.duraspace.org/display/DSPACE/DSpaceContributors
|
||||
|
||||
## Getting Help
|
||||
|
||||
@@ -64,72 +64,22 @@ DSpace provides public mailing lists where you can post questions or raise topic
|
||||
We welcome everyone to participate in these lists:
|
||||
|
||||
* [dspace-community@googlegroups.com](https://groups.google.com/d/forum/dspace-community) : General discussion about DSpace platform, announcements, sharing of best practices
|
||||
* [dspace-tech@googlegroups.com](https://groups.google.com/d/forum/dspace-tech) : Technical support mailing list. See also our guide for [How to troubleshoot an error](https://wiki.lyrasis.org/display/DSPACE/Troubleshoot+an+error).
|
||||
* [dspace-tech@googlegroups.com](https://groups.google.com/d/forum/dspace-tech) : Technical support mailing list. See also our guide for [How to troubleshoot an error](https://wiki.duraspace.org/display/DSPACE/Troubleshoot+an+error).
|
||||
* [dspace-devel@googlegroups.com](https://groups.google.com/d/forum/dspace-devel) : Developers / Development mailing list
|
||||
|
||||
Great Q&A is also available under the [DSpace tag on Stackoverflow](http://stackoverflow.com/questions/tagged/dspace)
|
||||
|
||||
Additional support options are at https://wiki.lyrasis.org/display/DSPACE/Support
|
||||
Additional support options are listed at https://wiki.duraspace.org/display/DSPACE/Support
|
||||
|
||||
DSpace also has an active service provider network. If you'd rather hire a service provider to
|
||||
install, upgrade, customize or host DSpace, then we recommend getting in touch with one of our
|
||||
DSpace also has an active service provider network. If you'd rather hire a service provider to
|
||||
install, upgrade, customize or host DSpace, then we recommend getting in touch with one of our
|
||||
[Registered Service Providers](http://www.dspace.org/service-providers).
|
||||
|
||||
## Issue Tracker
|
||||
|
||||
DSpace uses GitHub to track issues:
|
||||
* Backend (REST API) issues: https://github.com/DSpace/DSpace/issues
|
||||
* Frontend (User Interface) issues: https://github.com/DSpace/dspace-angular/issues
|
||||
|
||||
## Testing
|
||||
|
||||
### 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.
|
||||
|
||||
* How to run both Unit Tests (via `maven-surefire-plugin`) and Integration Tests (via `maven-failsafe-plugin`):
|
||||
```
|
||||
mvn install -DskipUnitTests=false -DskipIntegrationTests=false
|
||||
```
|
||||
* How to run _only_ Unit Tests:
|
||||
```
|
||||
mvn test -DskipUnitTests=false
|
||||
```
|
||||
* How to run a *single* Unit Test
|
||||
```
|
||||
# Run all tests in a specific test class
|
||||
# NOTE: failIfNoTests=false is required to skip tests in other modules
|
||||
mvn test -DskipUnitTests=false -Dtest=[full.package.testClassName] -DfailIfNoTests=false
|
||||
|
||||
# Run one test method in a specific test class
|
||||
mvn test -DskipUnitTests=false -Dtest=[full.package.testClassName]#[testMethodName] -DfailIfNoTests=false
|
||||
```
|
||||
* How to run _only_ Integration Tests
|
||||
```
|
||||
mvn install -DskipIntegrationTests=false
|
||||
```
|
||||
* How to run a *single* Integration Test
|
||||
```
|
||||
# Run all integration tests in a specific test class
|
||||
# NOTE: failIfNoTests=false is required to skip tests in other modules
|
||||
mvn install -DskipIntegrationTests=false -Dit.test=[full.package.testClassName] -DfailIfNoTests=false
|
||||
|
||||
# Run one test method in a specific test class
|
||||
mvn install -DskipIntegrationTests=false -Dit.test=[full.package.testClassName]#[testMethodName] -DfailIfNoTests=false
|
||||
```
|
||||
* How to run only tests of a specific DSpace module
|
||||
```
|
||||
# Before you can run only one module's tests, other modules may need installing into your ~/.m2
|
||||
cd [dspace-src]
|
||||
mvn clean install
|
||||
|
||||
# Then, move into a module subdirectory, and run the test command
|
||||
cd [dspace-src]/dspace-server-webapp
|
||||
# Choose your test command from the lists above
|
||||
```
|
||||
The DSpace Issue Tracker can be found at: https://jira.duraspace.org/projects/DS/summary
|
||||
|
||||
## License
|
||||
|
||||
DSpace source code is freely available under a standard [BSD 3-Clause license](https://opensource.org/licenses/BSD-3-Clause).
|
||||
The full license is available in the [LICENSE](LICENSE) file or online at http://www.dspace.org/license/
|
||||
The full license is available at http://www.dspace.org/license/
|
||||
|
@@ -44,16 +44,15 @@ For more information on CheckStyle configurations below, see: http://checkstyle.
|
||||
with @SuppressWarnings. See also SuppressWarningsHolder below -->
|
||||
<module name="SuppressWarningsFilter" />
|
||||
|
||||
<!-- Maximum line length is 120 characters -->
|
||||
<module name="LineLength">
|
||||
<property name="fileExtensions" value="java"/>
|
||||
<property name="max" value="120"/>
|
||||
<!-- Only exceptions for packages, imports, URLs, and JavaDoc {@link} tags -->
|
||||
<property name="ignorePattern" value="^package.*|^import.*|http://|https://|@link"/>
|
||||
</module>
|
||||
|
||||
<!-- Check individual Java source files for specific rules -->
|
||||
<module name="TreeWalker">
|
||||
<!-- Maximum line length is 120 characters -->
|
||||
<module name="LineLength">
|
||||
<property name="max" value="120"/>
|
||||
<!-- Only exceptions for packages, imports, URLs, and JavaDoc {@link} tags -->
|
||||
<property name="ignorePattern" value="^package.*|^import.*|http://|https://|@link"/>
|
||||
</module>
|
||||
|
||||
<!-- Highlight any TODO or FIXME comments in info messages -->
|
||||
<module name="TodoComment">
|
||||
<property name="severity" value="info"/>
|
||||
@@ -95,8 +94,11 @@ For more information on CheckStyle configurations below, see: http://checkstyle.
|
||||
<!-- <property name="scope" value="public"/> -->
|
||||
<!-- TODO: Above rule has been disabled because of large amount of missing public method Javadocs -->
|
||||
<property name="scope" value="nothing"/>
|
||||
<!-- Allow RuntimeExceptions to be undeclared -->
|
||||
<property name="allowUndeclaredRTE" value="true"/>
|
||||
<!-- Allow params, throws and return tags to be optional -->
|
||||
<property name="allowMissingParamTags" value="true"/>
|
||||
<property name="allowMissingThrowsTags" value="true"/>
|
||||
<property name="allowMissingReturnTag" value="true"/>
|
||||
</module>
|
||||
|
||||
|
@@ -1,25 +0,0 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
dspace-cli:
|
||||
image: "${DOCKER_OWNER:-dspace}/dspace-cli:${DSPACE_VER:-dspace-7_x}"
|
||||
container_name: dspace-cli
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.cli
|
||||
#environment:
|
||||
volumes:
|
||||
- ./dspace/src/main/docker-compose/local.cfg:/dspace/config/local.cfg
|
||||
- assetstore:/dspace/assetstore
|
||||
entrypoint: /dspace/bin/dspace
|
||||
command: help
|
||||
networks:
|
||||
- dspacenet
|
||||
tty: true
|
||||
stdin_open: true
|
||||
|
||||
volumes:
|
||||
assetstore:
|
||||
|
||||
networks:
|
||||
dspacenet:
|
@@ -1,69 +0,0 @@
|
||||
version: '3.7'
|
||||
networks:
|
||||
dspacenet:
|
||||
services:
|
||||
dspace:
|
||||
container_name: dspace
|
||||
image: "${DOCKER_OWNER:-dspace}/dspace:${DSPACE_VER:-dspace-7_x-test}"
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.test
|
||||
depends_on:
|
||||
- dspacedb
|
||||
networks:
|
||||
dspacenet:
|
||||
ports:
|
||||
- published: 8080
|
||||
target: 8080
|
||||
stdin_open: true
|
||||
tty: true
|
||||
volumes:
|
||||
- assetstore:/dspace/assetstore
|
||||
- ./dspace/src/main/docker-compose/local.cfg:/dspace/config/local.cfg
|
||||
# Ensure that the database is ready BEFORE starting tomcat
|
||||
# 1. While a TCP connection to dspacedb port 5432 is not available, continue to sleep
|
||||
# 2. Then, run database migration to init database tables
|
||||
# 3. Finally, start Tomcat
|
||||
entrypoint:
|
||||
- /bin/bash
|
||||
- '-c'
|
||||
- |
|
||||
while (!</dev/tcp/dspacedb/5432) > /dev/null 2>&1; do sleep 1; done;
|
||||
/dspace/bin/dspace database migrate
|
||||
catalina.sh run
|
||||
dspacedb:
|
||||
container_name: dspacedb
|
||||
environment:
|
||||
PGDATA: /pgdata
|
||||
image: dspace/dspace-postgres-pgcrypto
|
||||
networks:
|
||||
dspacenet:
|
||||
ports:
|
||||
- published: 5432
|
||||
target: 5432
|
||||
stdin_open: true
|
||||
tty: true
|
||||
volumes:
|
||||
- pgdata:/pgdata
|
||||
dspacesolr:
|
||||
container_name: dspacesolr
|
||||
image: dspace/dspace-solr
|
||||
networks:
|
||||
dspacenet:
|
||||
ports:
|
||||
- published: 8983
|
||||
target: 8983
|
||||
stdin_open: true
|
||||
tty: true
|
||||
volumes:
|
||||
- solr_authority:/opt/solr/server/solr/authority/data
|
||||
- solr_oai:/opt/solr/server/solr/oai/data
|
||||
- solr_search:/opt/solr/server/solr/search/data
|
||||
- solr_statistics:/opt/solr/server/solr/statistics/data
|
||||
volumes:
|
||||
assetstore:
|
||||
pgdata:
|
||||
solr_authority:
|
||||
solr_oai:
|
||||
solr_search:
|
||||
solr_statistics:
|
@@ -1,4 +1,5 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>dspace-api</artifactId>
|
||||
@@ -12,7 +13,7 @@
|
||||
<parent>
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>dspace-parent</artifactId>
|
||||
<version>7.0-beta4</version>
|
||||
<version>7.0-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -50,33 +51,6 @@
|
||||
<configuration>
|
||||
<debug>true</debug>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<annotationProcessorPaths>
|
||||
<!-- Enable Hibernate's Metamodel Generator to generate metadata model classes
|
||||
(ending in _ suffix) for more type-safe Criteria queries -->
|
||||
<path>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
</path>
|
||||
<!-- Enable JAXB -->
|
||||
<path>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>${jaxb-api.version}</version>
|
||||
</path>
|
||||
<!-- Enable Commons Annotations -->
|
||||
<path>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>${javax-annotation.version}</version>
|
||||
</path>
|
||||
<!-- Enable http://errorprone.info -->
|
||||
<path>
|
||||
<groupId>com.google.errorprone</groupId>
|
||||
<artifactId>error_prone_core</artifactId>
|
||||
<version>${errorprone.version}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
@@ -98,11 +72,25 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Verify OS license headers for all source code files -->
|
||||
<plugin>
|
||||
<groupId>com.mycila</groupId>
|
||||
<artifactId>license-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/src/test/resources/**</exclude>
|
||||
<exclude>**/src/test/data/**</exclude>
|
||||
<exclude>**/.gitignore</exclude>
|
||||
<exclude>src/test/data/dspaceFolder/config/spiders/**</exclude>
|
||||
<exclude>src/main/java/org/apache/solr/handler/extraction/ExtractingParams.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>1.9.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>validate</phase>
|
||||
@@ -127,87 +115,50 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- This plugin allows us to run a Groovy script in our Maven POM
|
||||
(see: https://groovy.github.io/gmaven/groovy-maven-plugin/execute.html )
|
||||
We are generating a OS-agnostic version (agnostic.build.dir) of
|
||||
the ${project.build.directory} property (full path of target dir).
|
||||
This is needed by the Surefire & Failsafe plugins (see below)
|
||||
to initialize the Unit Test environment's dspace.cfg file.
|
||||
Otherwise, the Unit Test Framework will not work on Windows OS.
|
||||
This Groovy code was mostly borrowed from:
|
||||
http://stackoverflow.com/questions/3872355/how-to-convert-file-separator-in-maven
|
||||
-->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.gmaven</groupId>
|
||||
<artifactId>groovy-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>setproperty</id>
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<source>
|
||||
project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/');
|
||||
log.info("Initializing Maven property 'agnostic.build.dir' to: {}", project.properties['agnostic.build.dir']);
|
||||
</source>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.mycila</groupId>
|
||||
<artifactId>license-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>src/test/resources/**</exclude>
|
||||
<exclude>src/test/data/**</exclude>
|
||||
<!-- Ignore license header requirements on Flyway upgrade scripts -->
|
||||
<exclude>src/main/resources/org/dspace/storage/rdbms/flywayupgrade/**</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>spotbugs</id>
|
||||
<id>findbugs</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
<!-- property>
|
||||
<name>maven.test.skip</name>
|
||||
<value>false</value>
|
||||
</property -->
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>com.github.spotbugs</groupId>
|
||||
<artifactId>spotbugs-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>findbugs-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<!-- Setup the Unit Test Environment (when -DskipUnitTests=false) -->
|
||||
<!-- If Unit Testing is enabled, then setup the Unit Test Environment.
|
||||
See also the 'skiptests' profile in Parent POM. -->
|
||||
<profile>
|
||||
<id>unit-test-environment</id>
|
||||
<id>test-environment</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
<property>
|
||||
<name>skipUnitTests</name>
|
||||
<name>maven.test.skip</name>
|
||||
<value>false</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Unit Testing setup: This plugin unzips the
|
||||
<!-- Unit/Integration Testing setup: This plugin unzips the
|
||||
'testEnvironment.zip' file (created by dspace-parent POM), into
|
||||
the 'target/testing/' folder, to essentially create a test
|
||||
install of DSpace, against which Tests can be run. -->
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.8</version>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/testing</outputDirectory>
|
||||
<artifactItems>
|
||||
@@ -222,65 +173,12 @@
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>setupUnitTestEnvironment</id>
|
||||
<id>setupTestEnvironment</id>
|
||||
<phase>generate-test-resources</phase>
|
||||
<goals>
|
||||
<goal>unpack</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Run Unit Testing! This plugin just kicks off the tests. -->
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<!-- Specify the dspace.dir to use for test environment -->
|
||||
<!-- ${agnostic.build.dir} is set dynamically by groovy-maven-plugin above -->
|
||||
<!-- This system property is loaded by AbstractDSpaceTest to initialize the test environment -->
|
||||
<dspace.dir>${agnostic.build.dir}/testing/dspace/</dspace.dir>
|
||||
<!-- Turn off any DSpace logging -->
|
||||
<dspace.log.init.disable>true</dspace.log.init.disable>
|
||||
<solr.install.dir>${agnostic.build.dir}/testing/dspace/solr/</solr.install.dir>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<!-- Setup the Integration Test Environment (when -DskipIntegrationTests=false) -->
|
||||
<profile>
|
||||
<id>integration-test-environment</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
<property>
|
||||
<name>skipIntegrationTests</name>
|
||||
<value>false</value>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- Integration Testing setup: This plugin unzips the
|
||||
'testEnvironment.zip' file (created by dspace-parent POM), into
|
||||
the 'target/testing/' folder, to essentially create a test
|
||||
install of DSpace, against which Tests can be run. -->
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/testing</outputDirectory>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>dspace-parent</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>zip</type>
|
||||
<classifier>testEnvironment</classifier>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>setupIntegrationTestEnvironment</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
@@ -291,41 +189,129 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Run Integration Testing! This plugin just kicks off the tests. -->
|
||||
<!-- This plugin allows us to run a Groovy script in our Maven POM
|
||||
(see: http://gmaven.codehaus.org/Executing+Groovy+Code )
|
||||
We are generating a OS-agnostic version (agnostic.build.dir) of
|
||||
the ${project.build.directory} property (full path of target dir).
|
||||
This is needed by the FileWeaver & Surefire plugins (see below)
|
||||
to initialize the Unit Test environment's dspace.cfg file.
|
||||
Otherwise, the Unit Test Framework will not work on Windows OS.
|
||||
This Groovy code was mostly borrowed from:
|
||||
http://stackoverflow.com/questions/3872355/how-to-convert-file-separator-in-maven
|
||||
-->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.gmaven</groupId>
|
||||
<artifactId>groovy-maven-plugin</artifactId>
|
||||
<version>2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>setproperty</id>
|
||||
<phase>generate-test-resources
|
||||
</phase> <!-- XXX I think this should be 'initialize' - MHW -->
|
||||
<goals>
|
||||
<goal>execute</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<source>
|
||||
project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/');
|
||||
println("Initializing Maven property 'agnostic.build.dir' to: " + project.properties['agnostic.build.dir']);
|
||||
</source>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- Run Unit Testing! This plugin just kicks off the tests (when enabled). -->
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<!-- Specify the dspace.dir to use for test environment -->
|
||||
<!-- This system property is loaded by AbstractDSpaceTest to initialize the test environment -->
|
||||
<dspace.dir>${agnostic.build.dir}/testing/dspace/</dspace.dir>
|
||||
<!-- Turn off any DSpace logging -->
|
||||
<dspace.log.init.disable>true</dspace.log.init.disable>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>xml-maven-plugin</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>validate-ALL-xml-and-xsl</id>
|
||||
<phase>process-test-resources</phase>
|
||||
<goals>
|
||||
<goal>validate</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<validationSets>
|
||||
<!-- validate ALL XML and XSL config files in the testing folder -->
|
||||
<validationSet>
|
||||
<dir>${agnostic.build.dir}/testing</dir>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.xsl</include>
|
||||
<include>**/*.xconf</include>
|
||||
</includes>
|
||||
</validationSet>
|
||||
<!-- validate ALL XML and XSL files throughout the project -->
|
||||
<validationSet>
|
||||
<dir>${root.basedir}</dir>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
<include>**/*.xsl</include>
|
||||
<include>**/*.xmap</include>
|
||||
</includes>
|
||||
</validationSet>
|
||||
</validationSets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<!-- Run Integration Testing! This plugin just kicks off the tests (when enabled). -->
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<!-- Specify the dspace.dir to use for test environment -->
|
||||
<!-- ${agnostic.build.dir} is set dynamically by groovy-maven-plugin above -->
|
||||
<dspace.dir>${agnostic.build.dir}/testing/dspace/</dspace.dir>
|
||||
<!-- Turn off any DSpace logging -->
|
||||
<dspace.log.init.disable>true</dspace.log.init.disable>
|
||||
<solr.install.dir>${agnostic.build.dir}/testing/dspace/solr/</solr.install.dir>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.jboss.logging</groupId>
|
||||
<artifactId>jboss-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-ehcache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator-cdi</artifactId>
|
||||
<version>${hibernate-validator.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator-cdi</artifactId>
|
||||
<version>${hibernate-validator.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-orm</artifactId>
|
||||
@@ -337,25 +323,9 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.handle</groupId>
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>handle</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.cnri</groupId>
|
||||
<artifactId>cnri-servlet-container</artifactId>
|
||||
<exclusions>
|
||||
<!-- Newer versions provided in our parent POM -->
|
||||
<exclusion>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-commons</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- Jetty is needed to run Handle Server -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>jargon</artifactId>
|
||||
@@ -364,19 +334,25 @@
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>mets</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dspace.dependencies</groupId>
|
||||
<artifactId>dspace-tm-extractors</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.jena</groupId>
|
||||
<artifactId>apache-jena-libs</artifactId>
|
||||
<type>pom</type>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</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>
|
||||
@@ -385,6 +361,10 @@
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
@@ -403,8 +383,8 @@
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
@@ -420,7 +400,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -437,6 +417,10 @@
|
||||
<groupId>org.jdom</groupId>
|
||||
<artifactId>jdom</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>oro</groupId>
|
||||
<artifactId>oro</artifactId>
|
||||
@@ -449,6 +433,18 @@
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>fontbox</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcmail-jdk15</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
@@ -468,6 +464,12 @@
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>xml-apis</groupId>
|
||||
<artifactId>xml-apis</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xml-apis</groupId>
|
||||
@@ -489,6 +491,11 @@
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>dspace-services</artifactId>
|
||||
</dependency>
|
||||
<dependency> <!-- Keep jmockit before junit -->
|
||||
<groupId>org.jmockit</groupId>
|
||||
<artifactId>jmockit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
@@ -509,193 +516,69 @@
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.rometools</groupId>
|
||||
<artifactId>rome-modules</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gr.ekt.bte</groupId>
|
||||
<artifactId>bte-core</artifactId>
|
||||
<version>0.9.3.5</version>
|
||||
<exclusions>
|
||||
<!-- A more recent version is retrieved from another dependency -->
|
||||
<exclusion>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gr.ekt.bte</groupId>
|
||||
<artifactId>bte-io</artifactId>
|
||||
<version>0.9.3.5</version>
|
||||
<exclusions>
|
||||
<!-- A more recent version is retrieved from another dependency -->
|
||||
<exclusion>
|
||||
<groupId>net.bytebuddy</groupId>
|
||||
<artifactId>byte-buddy</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</exclusion>
|
||||
<!-- A more recent version is retrieved from another dependency -->
|
||||
<exclusion>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.solr</groupId>
|
||||
<artifactId>solr-solrj</artifactId>
|
||||
<version>${solr.client.version}</version>
|
||||
</dependency>
|
||||
<!-- Solr Core is needed for Integration Tests (to run a MockSolrServer) -->
|
||||
<!-- The following Solr / Lucene dependencies also support integration tests -->
|
||||
<dependency>
|
||||
<groupId>org.apache.solr</groupId>
|
||||
<artifactId>solr-core</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>${solr.client.version}</version>
|
||||
<version>${solr.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-continuation</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-deploy</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-http</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-io</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-jmx</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-rewrite</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-security</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlets</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-xml</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.solr</groupId>
|
||||
<artifactId>solr-cell</artifactId>
|
||||
<exclusions>
|
||||
<!-- Newer versions provided in our parent POM -->
|
||||
<exclusion>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-commons</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcpkix-jdk15on</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-xml</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-http</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-deploy</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-continuation</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlets</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-io</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-security</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-core</artifactId>
|
||||
</dependency>
|
||||
<!-- Reminder: Keep icu4j (in Parent POM) synced with version used by lucene-analyzers-icu below,
|
||||
otherwise ICUFoldingFilterFactory may throw errors in tests. -->
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-analyzers-icu</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-analyzers-smartcn</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-analyzers-stempel</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlbeans</groupId>
|
||||
<artifactId>xmlbeans</artifactId>
|
||||
<version>2.6.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-configuration</groupId>
|
||||
<artifactId>commons-configuration</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.maxmind.geoip2</groupId>
|
||||
<artifactId>geoip2</artifactId>
|
||||
@@ -711,6 +594,12 @@
|
||||
<version>2.1.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.lucene</groupId>
|
||||
<artifactId>lucene-core</artifactId>
|
||||
<version>4.10.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.coverity.security</groupId>
|
||||
<artifactId>coverity-escapers</artifactId>
|
||||
@@ -727,6 +616,7 @@
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>19.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
@@ -735,6 +625,11 @@
|
||||
<artifactId>postgresql</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jdbm</groupId>
|
||||
<artifactId>jdbm</artifactId>
|
||||
@@ -752,7 +647,7 @@
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
<version>6.5.5</version>
|
||||
<version>4.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Google Analytics -->
|
||||
@@ -776,7 +671,6 @@
|
||||
<groupId>com.google.oauth-client</groupId>
|
||||
<artifactId>google-oauth-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- FindBugs -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
@@ -786,7 +680,6 @@
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
@@ -798,44 +691,19 @@
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<!-- JAXB API and implementation (no longer bundled as of Java 11) -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache Axiom -->
|
||||
<dependency>
|
||||
<groupId>org.apache.ws.commons.axiom</groupId>
|
||||
<artifactId>axiom-impl</artifactId>
|
||||
<version>${axiom.version}</version>
|
||||
<exclusions>
|
||||
<!-- Exclude Geronimo as it is NOT necessary when using javax.activation (which we use)
|
||||
See: https://ws.apache.org/axiom/userguide/ch04.html#d0e732 -->
|
||||
<exclusion>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<!-- NOTE: SWORDv2 needs 1.2.14, required by Abdera: https://abdera.apache.org/ -->
|
||||
<version>1.2.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.ws.commons.axiom</groupId>
|
||||
<artifactId>axiom-api</artifactId>
|
||||
<version>${axiom.version}</version>
|
||||
<exclusions>
|
||||
<!-- Exclude Geronimo as it is NOT necessary when using javax.activation (which we use)
|
||||
See: https://ws.apache.org/axiom/userguide/ch04.html#d0e732 -->
|
||||
<exclusion>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<!-- NOTE: SWORDv2 needs 1.2.14, required by Abdera: https://abdera.apache.org/ -->
|
||||
<version>1.2.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
@@ -846,54 +714,26 @@
|
||||
<groupId>com.amazonaws</groupId>
|
||||
<artifactId>aws-java-sdk-s3</artifactId>
|
||||
<version>1.10.50</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- For ORCID v2 integration -->
|
||||
<!-- S3 also wanted jackson... -->
|
||||
<dependency>
|
||||
<groupId>org.dspace</groupId>
|
||||
<artifactId>orcid-jaxb-api</artifactId>
|
||||
<version>2.1.0</version>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20180130</version>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Used for Solr core export/import -->
|
||||
<dependency>
|
||||
<groupId>com.opencsv</groupId>
|
||||
<artifactId>opencsv</artifactId>
|
||||
<version>4.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Email templating -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-engine-core</artifactId>
|
||||
<version>2.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.xmlunit</groupId>
|
||||
<artifactId>xmlunit-core</artifactId>
|
||||
<version>2.6.3</version>
|
||||
<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>
|
||||
<groupId>org.apache.bcel</groupId>
|
||||
<artifactId>bcel</artifactId>
|
||||
<version>6.4.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.solr.handler.extraction;
|
||||
|
||||
|
||||
/**
|
||||
* The various Solr Parameters names to use when extracting content.
|
||||
**/
|
||||
public interface ExtractingParams {
|
||||
|
||||
/**
|
||||
* Map all generated attribute names to field names with lowercase and underscores.
|
||||
*/
|
||||
public static final String LOWERNAMES = "lowernames";
|
||||
|
||||
/**
|
||||
* if true, ignore TikaException (give up to extract text but index meta data)
|
||||
*/
|
||||
public static final String IGNORE_TIKA_EXCEPTION = "ignoreTikaException";
|
||||
|
||||
|
||||
/**
|
||||
* The param prefix for mapping Tika metadata to Solr fields.
|
||||
* <p>
|
||||
* To map a field, add a name like:
|
||||
* <pre>fmap.title=solr.title</pre>
|
||||
*
|
||||
* In this example, the tika "title" metadata value will be added to a Solr field named "solr.title"
|
||||
*/
|
||||
public static final String MAP_PREFIX = "fmap.";
|
||||
|
||||
/**
|
||||
* The boost value for the name of the field. The boost can be specified by a name mapping.
|
||||
* <p>
|
||||
* For example
|
||||
* <pre>
|
||||
* map.title=solr.title
|
||||
* boost.solr.title=2.5
|
||||
* </pre>
|
||||
* will boost the solr.title field for this document by 2.5
|
||||
*/
|
||||
public static final String BOOST_PREFIX = "boost.";
|
||||
|
||||
/**
|
||||
* Pass in literal values to be added to the document, as in
|
||||
* <pre>
|
||||
* literal.myField=Foo
|
||||
* </pre>
|
||||
*/
|
||||
public static final String LITERALS_PREFIX = "literal.";
|
||||
|
||||
|
||||
/**
|
||||
* Restrict the extracted parts of a document to be indexed
|
||||
* by passing in an XPath expression. All content that satisfies the XPath expr.
|
||||
* will be passed to the {@link org.apache.solr.handler.extraction.SolrContentHandler}.
|
||||
* <p>
|
||||
* See Tika's docs for what the extracted document looks like.
|
||||
*
|
||||
* @see #CAPTURE_ELEMENTS
|
||||
*/
|
||||
public static final String XPATH_EXPRESSION = "xpath";
|
||||
|
||||
|
||||
/**
|
||||
* Only extract and return the content, do not index it.
|
||||
*/
|
||||
public static final String EXTRACT_ONLY = "extractOnly";
|
||||
|
||||
/**
|
||||
* Content output format if extractOnly is true. Default is "xml", alternative is "text".
|
||||
*/
|
||||
public static final String EXTRACT_FORMAT = "extractFormat";
|
||||
|
||||
/**
|
||||
* Capture attributes separately according to the name of the element, instead of just adding them to the string
|
||||
* buffer
|
||||
*/
|
||||
public static final String CAPTURE_ATTRIBUTES = "captureAttr";
|
||||
|
||||
/**
|
||||
* Literal field values will by default override other values such as metadata and content. Set this to false to
|
||||
* revert to pre-4.0 behaviour
|
||||
*/
|
||||
public static final String LITERALS_OVERRIDE = "literalsOverride";
|
||||
|
||||
/**
|
||||
* Capture the specified fields (and everything included below it that isn't capture by some other capture field)
|
||||
* separately from the default. This is different
|
||||
* then the case of passing in an XPath expression.
|
||||
* <p>
|
||||
* The Capture field is based on the localName returned to the
|
||||
* {@link org.apache.solr.handler.extraction.SolrContentHandler}
|
||||
* by Tika, not to be confused by the mapped field. The field name can then
|
||||
* be mapped into the index schema.
|
||||
* <p>
|
||||
* For instance, a Tika document may look like:
|
||||
* <pre>
|
||||
* <html>
|
||||
* ...
|
||||
* <body>
|
||||
* <p>some text here. <div>more text</div></p>
|
||||
* Some more text
|
||||
* </body>
|
||||
* </pre>
|
||||
* By passing in the p tag, you could capture all P tags separately from the rest of the t
|
||||
* Thus, in the example, the capture of the P tag would be: "some text here. more text"
|
||||
*/
|
||||
public static final String CAPTURE_ELEMENTS = "capture";
|
||||
|
||||
/**
|
||||
* The type of the stream. If not specified, Tika will use mime type detection.
|
||||
*/
|
||||
public static final String STREAM_TYPE = "stream.type";
|
||||
|
||||
|
||||
/**
|
||||
* Optional. The file name. If specified, Tika can take this into account while
|
||||
* guessing the MIME type.
|
||||
*/
|
||||
public static final String RESOURCE_NAME = "resource.name";
|
||||
|
||||
/**
|
||||
* Optional. The password for this resource. Will be used instead of the rule based password lookup mechanisms
|
||||
*/
|
||||
public static final String RESOURCE_PASSWORD = "resource.password";
|
||||
|
||||
/**
|
||||
* Optional. If specified, the prefix will be prepended to all Metadata, such that it would be possible
|
||||
* to setup a dynamic field to automatically capture it
|
||||
*/
|
||||
public static final String UNKNOWN_FIELD_PREFIX = "uprefix";
|
||||
|
||||
/**
|
||||
* Optional. If specified and the name of a potential field cannot be determined, the default Field specified
|
||||
* will be used instead.
|
||||
*/
|
||||
public static final String DEFAULT_FIELD = "defaultField";
|
||||
|
||||
/**
|
||||
* Optional. If specified, loads the file as a source for password lookups for Tika encrypted documents.
|
||||
* <p>
|
||||
* File format is Java properties format with one key=value per line.
|
||||
* The key is evaluated as a regex against the file name, and the value is the password
|
||||
* The rules are evaluated top-bottom, i.e. the first match will be used
|
||||
* If you want a fallback password to be always used, supply a .*=<defaultmypassword> at the end
|
||||
*/
|
||||
public static final String PASSWORD_MAP_FILE = "passwordsFile";
|
||||
}
|
@@ -17,7 +17,7 @@ import org.apache.commons.cli.CommandLineParser;
|
||||
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.apache.commons.collections.CollectionUtils;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
@@ -180,9 +180,13 @@ public class CommunityFiliator {
|
||||
// second test - circularity: parent's parents can't include proposed
|
||||
// child
|
||||
List<Community> parentDads = parent.getParentCommunities();
|
||||
if (parentDads.contains(child)) {
|
||||
System.out.println("Error, circular parentage - child is parent of parent");
|
||||
System.exit(1);
|
||||
|
||||
for (int i = 0; i < parentDads.size(); i++) {
|
||||
if (parentDads.get(i).getID().equals(child.getID())) {
|
||||
System.out
|
||||
.println("Error, circular parentage - child is parent of parent");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// everthing's OK
|
||||
@@ -206,15 +210,26 @@ public class CommunityFiliator {
|
||||
throws SQLException, AuthorizeException, IOException {
|
||||
// verify that child is indeed a child of parent
|
||||
List<Community> parentKids = parent.getSubcommunities();
|
||||
if (!parentKids.contains(child)) {
|
||||
System.out.println("Error, child community not a child of parent community");
|
||||
boolean isChild = false;
|
||||
|
||||
for (int i = 0; i < parentKids.size(); i++) {
|
||||
if (parentKids.get(i).getID().equals(child.getID())) {
|
||||
isChild = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isChild) {
|
||||
System.out
|
||||
.println("Error, child community not a child of parent community");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// OK remove the mappings - but leave the community, which will become
|
||||
// top-level
|
||||
child.removeParentCommunity(parent);
|
||||
parent.removeSubCommunity(child);
|
||||
child.getParentCommunities().remove(parent);
|
||||
parent.getSubcommunities().remove(child);
|
||||
communityService.update(c, child);
|
||||
communityService.update(c, parent);
|
||||
|
||||
|
@@ -15,7 +15,7 @@ import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.I18nUtil;
|
||||
@@ -115,7 +115,7 @@ public final class CreateAdministrator {
|
||||
String lastName = null;
|
||||
char[] password1 = null;
|
||||
char[] password2 = null;
|
||||
String language = I18nUtil.getDefaultLocale().getLanguage();
|
||||
String language = I18nUtil.DEFAULTLOCALE.getLanguage();
|
||||
|
||||
while (!dataOK) {
|
||||
System.out.print("E-mail address: ");
|
||||
|
@@ -21,7 +21,6 @@ import org.apache.xpath.XPathAPI;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.MetadataField;
|
||||
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;
|
||||
@@ -249,7 +248,7 @@ public class MetadataImporter {
|
||||
|
||||
// If the schema is not provided default to DC
|
||||
if (schema == null) {
|
||||
schema = MetadataSchemaEnum.DC.getName();
|
||||
schema = MetadataSchema.DC_SCHEMA;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -17,7 +17,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.BitstreamFormat;
|
||||
@@ -47,7 +47,7 @@ public class RegistryLoader {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(RegistryLoader.class);
|
||||
private static Logger log = Logger.getLogger(RegistryLoader.class);
|
||||
|
||||
protected static BitstreamFormatService bitstreamFormatService = ContentServiceFactory.getInstance()
|
||||
.getBitstreamFormatService();
|
||||
|
@@ -7,16 +7,12 @@
|
||||
*/
|
||||
package org.dspace.administer;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
@@ -25,18 +21,12 @@ 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.HelpFormatter;
|
||||
import org.apache.commons.cli.Option;
|
||||
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.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
@@ -44,7 +34,6 @@ import org.dspace.core.Context;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.output.Format;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
@@ -56,51 +45,44 @@ import org.xml.sax.SAXException;
|
||||
* an XML file.
|
||||
*
|
||||
* The XML file structure needs to be:
|
||||
* <pre>{@code
|
||||
* {@code
|
||||
* <import_structure>
|
||||
* <community>
|
||||
* <name>....</name>
|
||||
* <community>...</community>
|
||||
* <collection>
|
||||
* <name>....</name>
|
||||
* </collection>
|
||||
* </community>
|
||||
* <community>
|
||||
* <name>....</name>
|
||||
* <community>...</community>
|
||||
* <collection>
|
||||
* <name>....</name>
|
||||
* </collection>
|
||||
* </community>
|
||||
* </import_structure>
|
||||
* }</pre>
|
||||
* <p>
|
||||
* It can be arbitrarily deep, and supports all the metadata elements
|
||||
* }
|
||||
* it can be arbitrarily deep, and supports all the metadata elements
|
||||
* that make up the community and collection metadata. See the system
|
||||
* documentation for more details.
|
||||
* documentation for more details
|
||||
*
|
||||
* @author Richard Jones
|
||||
*/
|
||||
|
||||
public class StructBuilder {
|
||||
/** Name of the root element for the document to be imported. */
|
||||
static final String INPUT_ROOT = "import_structure";
|
||||
|
||||
/*
|
||||
* Name of the root element for the document produced by importing.
|
||||
* Community and collection elements are annotated with their identifiers.
|
||||
/**
|
||||
* the output xml document which will contain updated information about the
|
||||
* imported structure
|
||||
*/
|
||||
static final String RESULT_ROOT = "imported_structure";
|
||||
private static org.jdom.Document xmlOutput = new org.jdom.Document(new Element("imported_structure"));
|
||||
|
||||
/**
|
||||
* A table to hold metadata for the collection being worked on.
|
||||
* a hashtable to hold metadata for the collection being worked on
|
||||
*/
|
||||
private static final Map<String, String> collectionMap = new HashMap<>();
|
||||
private static Map<String, String> collectionMap = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* A table to hold metadata for the community being worked on.
|
||||
* a hashtable to hold metadata for the community being worked on
|
||||
*/
|
||||
private static final Map<String, String> communityMap = new HashMap<>();
|
||||
private static Map<String, String> communityMap = new HashMap<String, String>();
|
||||
|
||||
protected static CommunityService communityService
|
||||
= ContentServiceFactory.getInstance().getCommunityService();
|
||||
protected static CollectionService collectionService
|
||||
= ContentServiceFactory.getInstance().getCollectionService();
|
||||
protected static EPersonService ePersonService
|
||||
= EPersonServiceFactory.getInstance().getEPersonService();
|
||||
protected static CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
||||
protected static CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
|
||||
protected static EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -109,156 +91,63 @@ public class StructBuilder {
|
||||
|
||||
/**
|
||||
* Main method to be run from the command line to import a structure into
|
||||
* DSpacee or export existing structure to a file.The command is of the form:
|
||||
* DSpace
|
||||
*
|
||||
* <p>{@code StructBuilder -f [XML source] -e [administrator email] -o [output file]}
|
||||
* This is of the form:
|
||||
*
|
||||
* <p>to import, or
|
||||
* {@code StructBuilder -f [xml source] -e [administrator email] -o [output file]}
|
||||
*
|
||||
* <p>{@code StructBuilder -x -e [administrator email] -o [output file]}</p>
|
||||
* The output file will contain exactly the same as the source xml document, but
|
||||
* with the handle for each imported item added as an attribute.
|
||||
*
|
||||
* <p>to export. The output will contain exactly the same as the source XML
|
||||
* document, but with the Handle for each imported item added as an attribute.
|
||||
*
|
||||
*
|
||||
* @param argv command line arguments.
|
||||
* @throws ParserConfigurationException passed through.
|
||||
* @throws SQLException passed through.
|
||||
* @throws FileNotFoundException if input or output could not be opened.
|
||||
* @throws TransformerException if the input document is invalid.
|
||||
* @param argv the command line arguments given
|
||||
* @throws Exception if an error occurs
|
||||
*/
|
||||
public static void main(String[] argv)
|
||||
throws ParserConfigurationException, SQLException,
|
||||
FileNotFoundException, IOException, TransformerException {
|
||||
// Define command line options.
|
||||
throws Exception {
|
||||
CommandLineParser parser = new PosixParser();
|
||||
|
||||
Options options = new Options();
|
||||
|
||||
options.addOption("h", "help", false, "Print this help message.");
|
||||
options.addOption("?", "help");
|
||||
options.addOption("x", "export", false, "Export the current structure as XML.");
|
||||
options.addOption("f", "file", true, "file");
|
||||
options.addOption("e", "eperson", true, "eperson");
|
||||
options.addOption("o", "output", true, "output");
|
||||
|
||||
options.addOption(Option.builder("e").longOpt("eperson")
|
||||
.desc("User who is manipulating the repository's structure.")
|
||||
.hasArg().argName("eperson").required().build());
|
||||
CommandLine line = parser.parse(options, argv);
|
||||
|
||||
options.addOption(Option.builder("f").longOpt("file")
|
||||
.desc("File of new structure information.")
|
||||
.hasArg().argName("input").build());
|
||||
String file = null;
|
||||
String eperson = null;
|
||||
String output = null;
|
||||
|
||||
options.addOption(Option.builder("o").longOpt("output")
|
||||
.desc("File to receive the structure map ('-' for standard out).")
|
||||
.hasArg().argName("output").required().build());
|
||||
|
||||
// Parse the command line.
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
CommandLine line = null;
|
||||
try {
|
||||
line = parser.parse(options, argv);
|
||||
} catch (ParseException ex) {
|
||||
System.err.println(ex.getMessage());
|
||||
usage(options);
|
||||
System.exit(1);
|
||||
if (line.hasOption('f')) {
|
||||
file = line.getOptionValue('f');
|
||||
}
|
||||
|
||||
// If the user asked for help, give it and exit.
|
||||
if (line.hasOption('h') || line.hasOption('?')) {
|
||||
giveHelp(options);
|
||||
if (line.hasOption('e')) {
|
||||
eperson = line.getOptionValue('e');
|
||||
}
|
||||
|
||||
if (line.hasOption('o')) {
|
||||
output = line.getOptionValue('o');
|
||||
}
|
||||
|
||||
if (output == null || eperson == null || file == null) {
|
||||
usage();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// Otherwise, analyze the command.
|
||||
// Must be import or export.
|
||||
if (!(line.hasOption('f') || line.hasOption('x'))) {
|
||||
giveHelp(options);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// Open the output stream.
|
||||
String output = line.getOptionValue('o');
|
||||
OutputStream outputStream;
|
||||
if ("-".equals(output)) {
|
||||
outputStream = System.out;
|
||||
} else {
|
||||
outputStream = new FileOutputStream(output);
|
||||
}
|
||||
|
||||
// create a context
|
||||
Context context = new Context();
|
||||
|
||||
// set the context.
|
||||
String eperson = line.getOptionValue('e');
|
||||
try {
|
||||
context.setCurrentUser(ePersonService.findByEmail(context, eperson));
|
||||
} catch (SQLException ex) {
|
||||
System.err.format("That user could not be found: %s%n", ex.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// Export? Import?
|
||||
if (line.hasOption('x')) { // export
|
||||
exportStructure(context, outputStream);
|
||||
} else { // Must be import
|
||||
String input = line.getOptionValue('f');
|
||||
if (null == input) {
|
||||
usage(options);
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
InputStream inputStream;
|
||||
if ("-".equals(input)) {
|
||||
inputStream = System.in;
|
||||
} else {
|
||||
inputStream = new FileInputStream(input);
|
||||
}
|
||||
|
||||
importStructure(context, inputStream, outputStream);
|
||||
// save changes from import
|
||||
context.complete();
|
||||
}
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Import new Community/Collection structure.
|
||||
*
|
||||
* @param context
|
||||
* @param input XML which describes the new communities and collections.
|
||||
* @param output input, annotated with the new objects' identifiers.
|
||||
* @throws IOException
|
||||
* @throws ParserConfigurationException
|
||||
* @throws SAXException
|
||||
* @throws TransformerException
|
||||
* @throws SQLException
|
||||
*/
|
||||
static void importStructure(Context context, InputStream input, OutputStream output)
|
||||
throws IOException, ParserConfigurationException, SQLException, TransformerException {
|
||||
// set the context
|
||||
context.setCurrentUser(ePersonService.findByEmail(context, eperson));
|
||||
|
||||
// load the XML
|
||||
Document document = null;
|
||||
try {
|
||||
document = loadXML(input);
|
||||
} catch (IOException ex) {
|
||||
System.err.format("The input document could not be read: %s%n", ex.getMessage());
|
||||
System.exit(1);
|
||||
} catch (SAXException ex) {
|
||||
System.err.format("The input document could not be parsed: %s%n", ex.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
Document document = loadXML(file);
|
||||
|
||||
// run the preliminary validation, to be sure that the the XML document
|
||||
// is properly structured.
|
||||
try {
|
||||
validate(document);
|
||||
} catch (TransformerException ex) {
|
||||
System.err.format("The input document is invalid: %s%n", ex.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// Check for 'identifier' attributes -- possibly output by this class.
|
||||
NodeList identifierNodes = XPathAPI.selectNodeList(document, "//*[@identifier]");
|
||||
if (identifierNodes.getLength() > 0) {
|
||||
System.err.println("The input document has 'identifier' attributes, which will be ignored.");
|
||||
}
|
||||
// is properly structured
|
||||
validate(document);
|
||||
|
||||
// load the mappings into the member variable hashmaps
|
||||
communityMap.put("name", "name");
|
||||
@@ -275,190 +164,62 @@ public class StructBuilder {
|
||||
collectionMap.put("license", "license");
|
||||
collectionMap.put("provenance", "provenance_description");
|
||||
|
||||
Element[] elements = new Element[]{};
|
||||
try {
|
||||
// get the top level community list
|
||||
NodeList first = XPathAPI.selectNodeList(document, "/import_structure/community");
|
||||
// get the top level community list
|
||||
NodeList first = XPathAPI.selectNodeList(document, "/import_structure/community");
|
||||
|
||||
// run the import starting with the top level communities
|
||||
elements = handleCommunities(context, first, null);
|
||||
} catch (TransformerException ex) {
|
||||
System.err.format("Input content not understood: %s%n", ex.getMessage());
|
||||
System.exit(1);
|
||||
} catch (AuthorizeException ex) {
|
||||
System.err.format("Not authorized: %s%n", ex.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
// run the import starting with the top level communities
|
||||
Element[] elements = handleCommunities(context, first, null);
|
||||
|
||||
// generate the output
|
||||
final Element root = new Element(RESULT_ROOT);
|
||||
|
||||
for (Element element : elements) {
|
||||
root.addContent(element);
|
||||
Element root = xmlOutput.getRootElement();
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
root.addContent(elements[i]);
|
||||
}
|
||||
|
||||
// finally write the string into the output file.
|
||||
final org.jdom.Document xmlOutput = new org.jdom.Document(root);
|
||||
// finally write the string into the output file
|
||||
try {
|
||||
new XMLOutputter().output(xmlOutput, output);
|
||||
BufferedWriter out = new BufferedWriter(new FileWriter(output));
|
||||
out.write(new XMLOutputter().outputString(xmlOutput));
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
System.out.printf("Unable to write to output file %s: %s%n",
|
||||
output, e.getMessage());
|
||||
System.exit(1);
|
||||
System.out.println("Unable to write to output file " + output);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
context.complete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a single community, and its children, to the Document.
|
||||
*
|
||||
* @param community
|
||||
* @return a fragment representing this Community.
|
||||
* Output the usage information
|
||||
*/
|
||||
private static Element exportACommunity(Community community) {
|
||||
// Export this Community.
|
||||
Element element = new Element("community");
|
||||
element.setAttribute("identifier", community.getHandle());
|
||||
element.addContent(new Element("name").setText(community.getName()));
|
||||
element.addContent(new Element("description")
|
||||
.setText(communityService.getMetadataFirstValue(community,
|
||||
MetadataSchemaEnum.DC.getName(), "description", "abstract", Item.ANY)));
|
||||
element.addContent(new Element("intro")
|
||||
.setText(communityService.getMetadataFirstValue(community,
|
||||
MetadataSchemaEnum.DC.getName(), "description", null, Item.ANY)));
|
||||
element.addContent(new Element("copyright")
|
||||
.setText(communityService.getMetadataFirstValue(community,
|
||||
MetadataSchemaEnum.DC.getName(), "rights", null, Item.ANY)));
|
||||
element.addContent(new Element("sidebar")
|
||||
.setText(communityService.getMetadataFirstValue(community,
|
||||
MetadataSchemaEnum.DC.getName(), "description", "tableofcontents", Item.ANY)));
|
||||
|
||||
// Export this Community's Community children.
|
||||
for (Community subCommunity : community.getSubcommunities()) {
|
||||
element.addContent(exportACommunity(subCommunity));
|
||||
}
|
||||
|
||||
// Export this Community's Collection children.
|
||||
for (Collection collection : community.getCollections()) {
|
||||
element.addContent(exportACollection(collection));
|
||||
}
|
||||
|
||||
return element;
|
||||
private static void usage() {
|
||||
System.out.println("Usage: java StructBuilder -f <source XML file> -o <output file> -e <eperson email>");
|
||||
System.out.println(
|
||||
"Communities will be created from the top level, and a map of communities to handles will be returned in " +
|
||||
"the output file");
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a single Collection to the Document.
|
||||
*
|
||||
* @param collection
|
||||
* @return a fragment representing this Collection.
|
||||
*/
|
||||
private static Element exportACollection(Collection collection) {
|
||||
// Export this Collection.
|
||||
Element element = new Element("collection");
|
||||
element.setAttribute("identifier", collection.getHandle());
|
||||
element.addContent(new Element("name").setText(collection.getName()));
|
||||
element.addContent(new Element("description")
|
||||
.setText(collectionService.getMetadataFirstValue(collection,
|
||||
MetadataSchemaEnum.DC.getName(), "description", "abstract", Item.ANY)));
|
||||
element.addContent(new Element("intro")
|
||||
.setText(collectionService.getMetadataFirstValue(collection,
|
||||
MetadataSchemaEnum.DC.getName(), "description", null, Item.ANY)));
|
||||
element.addContent(new Element("copyright")
|
||||
.setText(collectionService.getMetadataFirstValue(collection,
|
||||
MetadataSchemaEnum.DC.getName(), "rights", null, Item.ANY)));
|
||||
element.addContent(new Element("sidebar")
|
||||
.setText(collectionService.getMetadataFirstValue(collection,
|
||||
MetadataSchemaEnum.DC.getName(), "description", "tableofcontents", Item.ANY)));
|
||||
element.addContent(new Element("license")
|
||||
.setText(collectionService.getMetadataFirstValue(collection,
|
||||
MetadataSchemaEnum.DC.getName(), "rights", "license", Item.ANY)));
|
||||
// Provenance is special: multivalued
|
||||
for (MetadataValue value : collectionService.getMetadata(collection,
|
||||
MetadataSchemaEnum.DC.getName(), "provenance", null, Item.ANY)) {
|
||||
element.addContent(new Element("provenance")
|
||||
.setText(value.getValue()));
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write out the existing Community/Collection structure.
|
||||
*/
|
||||
static void exportStructure(Context context, OutputStream output) {
|
||||
// Build a document from the Community/Collection hierarchy.
|
||||
Element rootElement = new Element(INPUT_ROOT); // To be read by importStructure, perhaps
|
||||
|
||||
List<Community> communities = null;
|
||||
try {
|
||||
communities = communityService.findAllTop(context);
|
||||
} catch (SQLException ex) {
|
||||
System.out.printf("Unable to get the list of top-level communities: %s%n",
|
||||
ex.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
for (Community community : communities) {
|
||||
rootElement.addContent(exportACommunity(community));
|
||||
}
|
||||
|
||||
// Now write the structure out.
|
||||
org.jdom.Document xmlOutput = new org.jdom.Document(rootElement);
|
||||
try {
|
||||
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
|
||||
outputter.output(xmlOutput, output);
|
||||
} catch (IOException e) {
|
||||
System.out.printf("Unable to write to output file %s: %s%n",
|
||||
output, e.getMessage());
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the usage information.
|
||||
*/
|
||||
private static void usage(Options options) {
|
||||
HelpFormatter helper = new HelpFormatter();
|
||||
try (PrintWriter writer = new PrintWriter(System.out);) {
|
||||
helper.printUsage(writer, 80/* FIXME Magic */,
|
||||
"structure-builder", options);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Help the user more.
|
||||
*/
|
||||
private static void giveHelp(Options options) {
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
formatter.printHelp("struct-builder",
|
||||
"Import or export Community/Collection structure.",
|
||||
options,
|
||||
"When importing (-f), communities will be created from the "
|
||||
+ "top level, and a map of communities to handles will "
|
||||
+ "be returned in the output file. When exporting (-x),"
|
||||
+ "the current structure will be written to the map file.",
|
||||
true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the XML document. This method returns if the document is valid.
|
||||
* If validation fails it generates an error and ceases execution.
|
||||
* Validate the XML document. This method does not return, but if validation
|
||||
* fails it generates an error and ceases execution
|
||||
*
|
||||
* @param document the XML document object
|
||||
* @throws TransformerException if transformer error
|
||||
*/
|
||||
private static void validate(org.w3c.dom.Document document)
|
||||
throws TransformerException {
|
||||
StringBuilder err = new StringBuilder();
|
||||
StringBuffer err = new StringBuffer();
|
||||
boolean trip = false;
|
||||
|
||||
err.append("The following errors were encountered parsing the source XML.\n");
|
||||
err.append("No changes have been made to the DSpace instance.\n\n");
|
||||
err.append("The following errors were encountered parsing the source XML\n");
|
||||
err.append("No changes have been made to the DSpace instance\n\n");
|
||||
|
||||
NodeList first = XPathAPI.selectNodeList(document, "/import_structure/community");
|
||||
if (first.getLength() == 0) {
|
||||
err.append("-There are no top level communities in the source document.");
|
||||
err.append("-There are no top level communities in the source document");
|
||||
System.out.println(err.toString());
|
||||
System.exit(1);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
String errs = validateCommunities(first, 1);
|
||||
@@ -469,13 +230,13 @@ public class StructBuilder {
|
||||
|
||||
if (trip) {
|
||||
System.out.println(err.toString());
|
||||
System.exit(1);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the communities section of the XML document. This returns a string
|
||||
* containing any errors encountered, or null if there were no errors.
|
||||
* containing any errors encountered, or null if there were no errors
|
||||
*
|
||||
* @param communities the NodeList of communities to validate
|
||||
* @param level the level in the XML document that we are at, for the purposes
|
||||
@@ -485,7 +246,7 @@ public class StructBuilder {
|
||||
*/
|
||||
private static String validateCommunities(NodeList communities, int level)
|
||||
throws TransformerException {
|
||||
StringBuilder err = new StringBuilder();
|
||||
StringBuffer err = new StringBuffer();
|
||||
boolean trip = false;
|
||||
String errs = null;
|
||||
|
||||
@@ -494,9 +255,8 @@ public class StructBuilder {
|
||||
NodeList name = XPathAPI.selectNodeList(n, "name");
|
||||
if (name.getLength() != 1) {
|
||||
String pos = Integer.toString(i + 1);
|
||||
err.append("-The level ").append(level)
|
||||
.append(" community in position ").append(pos)
|
||||
.append(" does not contain exactly one name field.\n");
|
||||
err.append("-The level " + level + " community in position " + pos);
|
||||
err.append(" does not contain exactly one name field\n");
|
||||
trip = true;
|
||||
}
|
||||
|
||||
@@ -526,7 +286,7 @@ public class StructBuilder {
|
||||
|
||||
/**
|
||||
* validate the collection section of the XML document. This generates a
|
||||
* string containing any errors encountered, or returns null if no errors.
|
||||
* string containing any errors encountered, or returns null if no errors
|
||||
*
|
||||
* @param collections a NodeList of collections to validate
|
||||
* @param level the level in the XML document for the purposes of error reporting
|
||||
@@ -534,7 +294,7 @@ public class StructBuilder {
|
||||
*/
|
||||
private static String validateCollections(NodeList collections, int level)
|
||||
throws TransformerException {
|
||||
StringBuilder err = new StringBuilder();
|
||||
StringBuffer err = new StringBuffer();
|
||||
boolean trip = false;
|
||||
String errs = null;
|
||||
|
||||
@@ -543,9 +303,8 @@ public class StructBuilder {
|
||||
NodeList name = XPathAPI.selectNodeList(n, "name");
|
||||
if (name.getLength() != 1) {
|
||||
String pos = Integer.toString(i + 1);
|
||||
err.append("-The level ").append(level)
|
||||
.append(" collection in position ").append(pos)
|
||||
.append(" does not contain exactly one name field.\n");
|
||||
err.append("-The level " + level + " collection in position " + pos);
|
||||
err.append(" does not contain exactly one name field\n");
|
||||
trip = true;
|
||||
}
|
||||
}
|
||||
@@ -558,17 +317,17 @@ public class StructBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the XML document from input.
|
||||
* Load in the XML from file.
|
||||
*
|
||||
* @param input the filename to load from.
|
||||
* @return the DOM representation of the XML input.
|
||||
* @param filename the filename to load from
|
||||
* @return the DOM representation of the XML file
|
||||
*/
|
||||
private static org.w3c.dom.Document loadXML(InputStream input)
|
||||
private static org.w3c.dom.Document loadXML(String filename)
|
||||
throws IOException, ParserConfigurationException, SAXException {
|
||||
DocumentBuilder builder = DocumentBuilderFactory.newInstance()
|
||||
.newDocumentBuilder();
|
||||
|
||||
org.w3c.dom.Document document = builder.parse(input);
|
||||
org.w3c.dom.Document document = builder.parse(new File(filename));
|
||||
|
||||
return document;
|
||||
}
|
||||
@@ -579,7 +338,7 @@ public class StructBuilder {
|
||||
* @param node the node from which we want to extract the string value
|
||||
* @return the string value of the node
|
||||
*/
|
||||
private static String getStringValue(Node node) {
|
||||
public static String getStringValue(Node node) {
|
||||
String value = node.getNodeValue();
|
||||
|
||||
if (node.hasChildNodes()) {
|
||||
@@ -604,7 +363,7 @@ public class StructBuilder {
|
||||
* created communities (e.g. the handles they have been assigned)
|
||||
*/
|
||||
private static Element[] handleCommunities(Context context, NodeList communities, Community parent)
|
||||
throws TransformerException, SQLException, AuthorizeException {
|
||||
throws TransformerException, SQLException, Exception {
|
||||
Element[] elements = new Element[communities.getLength()];
|
||||
|
||||
for (int i = 0; i < communities.getLength(); i++) {
|
||||
@@ -631,10 +390,12 @@ public class StructBuilder {
|
||||
}
|
||||
|
||||
// FIXME: at the moment, if the community already exists by name
|
||||
// then this will throw an SQLException on a duplicate key
|
||||
// violation.
|
||||
// Ideally we'd skip this row and continue to create sub communities
|
||||
// and so forth where they don't exist, but it's proving difficult
|
||||
// then this will throw a PSQLException on a duplicate key
|
||||
// violation
|
||||
// Ideally we'd skip this row and continue to create sub
|
||||
// communities
|
||||
// and so forth where they don't exist, but it's proving
|
||||
// difficult
|
||||
// to isolate the community that already exists without hitting
|
||||
// the database directly.
|
||||
communityService.update(context, community);
|
||||
@@ -709,7 +470,7 @@ public class StructBuilder {
|
||||
* created collections (e.g. the handle)
|
||||
*/
|
||||
private static Element[] handleCollections(Context context, NodeList collections, Community parent)
|
||||
throws TransformerException, SQLException, AuthorizeException {
|
||||
throws TransformerException, SQLException, AuthorizeException, IOException, Exception {
|
||||
Element[] elements = new Element[collections.getLength()];
|
||||
|
||||
for (int i = 0; i < collections.getLength(); i++) {
|
||||
|
@@ -19,7 +19,6 @@ import org.dspace.content.Item;
|
||||
* @author Stuart Lewis
|
||||
*/
|
||||
public class BulkEditChange {
|
||||
|
||||
/**
|
||||
* The item these changes relate to
|
||||
*/
|
||||
|
@@ -8,10 +8,14 @@
|
||||
package org.dspace.app.bulkedit;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Serializable;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -23,8 +27,6 @@ import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.authority.AuthorityValue;
|
||||
import org.dspace.authority.factory.AuthorityServiceFactory;
|
||||
import org.dspace.authority.service.AuthorityValueService;
|
||||
@@ -32,7 +34,6 @@ import org.dspace.content.Collection;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.authority.Choices;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
@@ -138,18 +139,18 @@ public class DSpaceCSV implements Serializable {
|
||||
/**
|
||||
* Create a new instance, reading the lines in from file
|
||||
*
|
||||
* @param inputStream the inputstream to read from
|
||||
* @param f The file to read from
|
||||
* @param c The DSpace Context
|
||||
* @throws Exception thrown if there is an error reading or processing the file
|
||||
*/
|
||||
public DSpaceCSV(InputStream inputStream, Context c) throws Exception {
|
||||
public DSpaceCSV(File f, Context c) throws Exception {
|
||||
// Initialise the class
|
||||
init();
|
||||
|
||||
// Open the CSV file
|
||||
BufferedReader input = null;
|
||||
try {
|
||||
input = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
||||
input = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8"));
|
||||
|
||||
// Read the heading line
|
||||
String head = input.readLine();
|
||||
@@ -167,9 +168,6 @@ public class DSpaceCSV implements Serializable {
|
||||
if ("collection".equals(element)) {
|
||||
// Store the heading
|
||||
headings.add(element);
|
||||
} else if ("rowName".equals(element)) {
|
||||
// Store the heading
|
||||
headings.add(element);
|
||||
} else if ("action".equals(element)) { // Store the action
|
||||
// Store the heading
|
||||
headings.add(element);
|
||||
@@ -200,24 +198,20 @@ public class DSpaceCSV implements Serializable {
|
||||
}
|
||||
|
||||
// Check that the scheme exists
|
||||
if (!StringUtils.equals(metadataSchema, MetadataSchemaEnum.RELATION.getName())) {
|
||||
MetadataSchema foundSchema = metadataSchemaService.find(c, metadataSchema);
|
||||
if (foundSchema == null) {
|
||||
throw new MetadataImportInvalidHeadingException(clean[0],
|
||||
MetadataImportInvalidHeadingException
|
||||
.SCHEMA,
|
||||
columnCounter);
|
||||
}
|
||||
MetadataSchema foundSchema = metadataSchemaService.find(c, metadataSchema);
|
||||
if (foundSchema == null) {
|
||||
throw new MetadataImportInvalidHeadingException(clean[0],
|
||||
MetadataImportInvalidHeadingException.SCHEMA,
|
||||
columnCounter);
|
||||
}
|
||||
|
||||
// Check that the metadata element exists in the schema
|
||||
MetadataField foundField = metadataFieldService
|
||||
.findByElement(c, foundSchema, metadataElement, metadataQualifier);
|
||||
if (foundField == null) {
|
||||
throw new MetadataImportInvalidHeadingException(clean[0],
|
||||
MetadataImportInvalidHeadingException
|
||||
.ELEMENT,
|
||||
columnCounter);
|
||||
}
|
||||
// Check that the metadata element exists in the schema
|
||||
MetadataField foundField = metadataFieldService
|
||||
.findByElement(c, foundSchema, metadataElement, metadataQualifier);
|
||||
if (foundField == null) {
|
||||
throw new MetadataImportInvalidHeadingException(clean[0],
|
||||
MetadataImportInvalidHeadingException.ELEMENT,
|
||||
columnCounter);
|
||||
}
|
||||
|
||||
// Store the heading
|
||||
@@ -620,15 +614,21 @@ public class DSpaceCSV implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns an InputStream from the CSV Lines in this DSpaceCSV
|
||||
* @return The InputStream created from the CSVLines in this DSpaceCSV
|
||||
* Save the CSV file to the given filename
|
||||
*
|
||||
* @param filename The filename to save the CSV file to
|
||||
* @throws IOException Thrown if an error occurs when writing the file
|
||||
*/
|
||||
public InputStream getInputStream() {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
public final void save(String filename) throws IOException {
|
||||
// Save the file
|
||||
BufferedWriter out = new BufferedWriter(
|
||||
new OutputStreamWriter(
|
||||
new FileOutputStream(filename), "UTF-8"));
|
||||
for (String csvLine : getCSVLinesAsStringArray()) {
|
||||
stringBuilder.append(csvLine + "\n");
|
||||
out.write(csvLine + "\n");
|
||||
}
|
||||
return IOUtils.toInputStream(stringBuilder.toString(), StandardCharsets.UTF_8);
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -8,107 +8,271 @@
|
||||
package org.dspace.app.bulkedit;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.cli.PosixParser;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.MetadataDSpaceCsvExportService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.scripts.DSpaceRunnable;
|
||||
import org.dspace.utils.DSpace;
|
||||
|
||||
/**
|
||||
* Metadata exporter to allow the batch export of metadata into a file
|
||||
*
|
||||
* @author Stuart Lewis
|
||||
*/
|
||||
public class MetadataExport extends DSpaceRunnable<MetadataExportScriptConfiguration> {
|
||||
public class MetadataExport {
|
||||
/**
|
||||
* The items to export
|
||||
*/
|
||||
protected Iterator<Item> toExport;
|
||||
|
||||
private boolean help = false;
|
||||
private String filename = null;
|
||||
private String handle = null;
|
||||
private boolean exportAllMetadata = false;
|
||||
private boolean exportAllItems = false;
|
||||
protected ItemService itemService;
|
||||
|
||||
private static final String EXPORT_CSV = "exportCSV";
|
||||
protected Context context;
|
||||
|
||||
private MetadataDSpaceCsvExportService metadataDSpaceCsvExportService = new DSpace().getServiceManager()
|
||||
.getServicesByType(MetadataDSpaceCsvExportService.class).get(0);
|
||||
/**
|
||||
* Whether to export all metadata, or just normally edited metadata
|
||||
*/
|
||||
protected boolean exportAll;
|
||||
|
||||
private EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||
protected MetadataExport() {
|
||||
itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void internalRun() throws Exception {
|
||||
/**
|
||||
* Set up a new metadata export
|
||||
*
|
||||
* @param c The Context
|
||||
* @param toExport The ItemIterator of items to export
|
||||
* @param exportAll whether to export all metadata or not (include handle, provenance etc)
|
||||
*/
|
||||
public MetadataExport(Context c, Iterator<Item> toExport, boolean exportAll) {
|
||||
itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
|
||||
// Store the export settings
|
||||
this.toExport = toExport;
|
||||
this.exportAll = exportAll;
|
||||
this.context = c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to export a community (and sub-communities and collections)
|
||||
*
|
||||
* @param c The Context
|
||||
* @param toExport The Community to export
|
||||
* @param exportAll whether to export all metadata or not (include handle, provenance etc)
|
||||
*/
|
||||
public MetadataExport(Context c, Community toExport, boolean exportAll) {
|
||||
itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
|
||||
if (help) {
|
||||
logHelpInfo();
|
||||
printHelp();
|
||||
return;
|
||||
}
|
||||
Context context = new Context();
|
||||
context.turnOffAuthorisationSystem();
|
||||
try {
|
||||
context.setCurrentUser(ePersonService.find(context, this.getEpersonIdentifier()));
|
||||
} catch (SQLException e) {
|
||||
handler.handleException(e);
|
||||
// Try to export the community
|
||||
this.toExport = buildFromCommunity(c, toExport, 0);
|
||||
this.exportAll = exportAll;
|
||||
this.context = c;
|
||||
} catch (SQLException sqle) {
|
||||
// Something went wrong...
|
||||
System.err.println("Error running exporter:");
|
||||
sqle.printStackTrace(System.err);
|
||||
System.exit(1);
|
||||
}
|
||||
DSpaceCSV dSpaceCSV = metadataDSpaceCsvExportService
|
||||
.handleExport(context, exportAllItems, exportAllMetadata, handle,
|
||||
handler);
|
||||
handler.writeFilestream(context, filename, dSpaceCSV.getInputStream(), EXPORT_CSV);
|
||||
context.restoreAuthSystemState();
|
||||
context.complete();
|
||||
}
|
||||
|
||||
protected void logHelpInfo() {
|
||||
handler.logInfo("\nfull export: metadata-export");
|
||||
handler.logInfo("partial export: metadata-export -i handle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataExportScriptConfiguration getScriptConfiguration() {
|
||||
return new DSpace().getServiceManager().getServiceByName("metadata-export",
|
||||
MetadataExportScriptConfiguration.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() throws ParseException {
|
||||
|
||||
if (commandLine.hasOption('h')) {
|
||||
help = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!commandLine.hasOption('i')) {
|
||||
exportAllItems = true;
|
||||
}
|
||||
handle = commandLine.getOptionValue('i');
|
||||
filename = getFileNameForExportFile();
|
||||
|
||||
exportAllMetadata = commandLine.hasOption('a');
|
||||
|
||||
}
|
||||
|
||||
protected String getFileNameForExportFile() throws ParseException {
|
||||
Context context = new Context();
|
||||
try {
|
||||
DSpaceObject dso = null;
|
||||
if (StringUtils.isNotBlank(handle)) {
|
||||
dso = HandleServiceFactory.getInstance().getHandleService().resolveToObject(context, handle);
|
||||
} else {
|
||||
dso = ContentServiceFactory.getInstance().getSiteService().findSite(context);
|
||||
/**
|
||||
* Build an array list of item ids that are in a community (include sub-communities and collections)
|
||||
*
|
||||
* @param context DSpace context
|
||||
* @param community The community to build from
|
||||
* @param indent How many spaces to use when writing out the names of items added
|
||||
* @return The list of item ids
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
protected Iterator<Item> buildFromCommunity(Context context, Community community, int indent)
|
||||
throws SQLException {
|
||||
// Add all the collections
|
||||
List<Collection> collections = community.getCollections();
|
||||
Iterator<Item> result = null;
|
||||
for (Collection collection : collections) {
|
||||
for (int i = 0; i < indent; i++) {
|
||||
System.out.print(" ");
|
||||
}
|
||||
|
||||
Iterator<Item> items = itemService.findByCollection(context, collection);
|
||||
result = addItemsToResult(result, items);
|
||||
|
||||
}
|
||||
// Add all the sub-communities
|
||||
List<Community> communities = community.getSubcommunities();
|
||||
for (Community subCommunity : communities) {
|
||||
for (int i = 0; i < indent; i++) {
|
||||
System.out.print(" ");
|
||||
}
|
||||
Iterator<Item> items = buildFromCommunity(context, subCommunity, indent + 1);
|
||||
result = addItemsToResult(result, items);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private Iterator<Item> addItemsToResult(Iterator<Item> result, Iterator<Item> items) {
|
||||
if (result == null) {
|
||||
result = items;
|
||||
} else {
|
||||
result = Iterators.concat(result, items);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the export
|
||||
*
|
||||
* @return the exported CSV lines
|
||||
*/
|
||||
public DSpaceCSV export() {
|
||||
try {
|
||||
Context.Mode originalMode = context.getCurrentMode();
|
||||
context.setMode(Context.Mode.READ_ONLY);
|
||||
|
||||
// Process each item
|
||||
DSpaceCSV csv = new DSpaceCSV(exportAll);
|
||||
while (toExport.hasNext()) {
|
||||
Item item = toExport.next();
|
||||
csv.addItem(item);
|
||||
context.uncacheEntity(item);
|
||||
}
|
||||
|
||||
context.setMode(originalMode);
|
||||
// Return the results
|
||||
return csv;
|
||||
} catch (Exception e) {
|
||||
// Something went wrong...
|
||||
System.err.println("Error exporting to CSV:");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the help message
|
||||
*
|
||||
* @param options The command line options the user gave
|
||||
* @param exitCode the system exit code to use
|
||||
*/
|
||||
private static void printHelp(Options options, int exitCode) {
|
||||
// print the help message
|
||||
HelpFormatter myhelp = new HelpFormatter();
|
||||
myhelp.printHelp("MetadataExport\n", options);
|
||||
System.out.println("\nfull export: metadataexport -f filename");
|
||||
System.out.println("partial export: metadataexport -i handle -f filename");
|
||||
System.exit(exitCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* main method to run the metadata exporter
|
||||
*
|
||||
* @param argv the command line arguments given
|
||||
* @throws Exception if error occurs
|
||||
*/
|
||||
public static void main(String[] argv) throws Exception {
|
||||
// Create an options object and populate it
|
||||
CommandLineParser parser = new PosixParser();
|
||||
|
||||
Options options = new Options();
|
||||
|
||||
options.addOption("i", "id", true, "ID or handle of thing to export (item, collection, or community)");
|
||||
options.addOption("f", "file", true, "destination where you want file written");
|
||||
options.addOption("a", "all", false,
|
||||
"include all metadata fields that are not normally changed (e.g. provenance)");
|
||||
options.addOption("h", "help", false, "help");
|
||||
|
||||
CommandLine line = null;
|
||||
|
||||
try {
|
||||
line = parser.parse(options, argv);
|
||||
} catch (ParseException pe) {
|
||||
System.err.println("Error with commands.");
|
||||
printHelp(options, 1);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
if (line.hasOption('h')) {
|
||||
printHelp(options, 0);
|
||||
}
|
||||
|
||||
// Check a filename is given
|
||||
if (!line.hasOption('f')) {
|
||||
System.err.println("Required parameter -f missing!");
|
||||
printHelp(options, 1);
|
||||
}
|
||||
String filename = line.getOptionValue('f');
|
||||
|
||||
// Create a context
|
||||
Context c = new Context(Context.Mode.READ_ONLY);
|
||||
c.turnOffAuthorisationSystem();
|
||||
|
||||
// The things we'll export
|
||||
Iterator<Item> toExport = null;
|
||||
MetadataExport exporter = null;
|
||||
|
||||
// Export everything?
|
||||
boolean exportAll = line.hasOption('a');
|
||||
|
||||
ContentServiceFactory contentServiceFactory = ContentServiceFactory.getInstance();
|
||||
// Check we have an item OK
|
||||
ItemService itemService = contentServiceFactory.getItemService();
|
||||
if (!line.hasOption('i')) {
|
||||
System.out.println("Exporting whole repository WARNING: May take some time!");
|
||||
exporter = new MetadataExport(c, itemService.findAll(c), exportAll);
|
||||
} else {
|
||||
String handle = line.getOptionValue('i');
|
||||
DSpaceObject dso = HandleServiceFactory.getInstance().getHandleService().resolveToObject(c, handle);
|
||||
if (dso == null) {
|
||||
throw new ParseException("A handle got given that wasn't able to be parsed to a DSpaceObject");
|
||||
System.err.println("Item '" + handle + "' does not resolve to an item in your repository!");
|
||||
printHelp(options, 1);
|
||||
}
|
||||
|
||||
if (dso.getType() == Constants.ITEM) {
|
||||
System.out.println("Exporting item '" + dso.getName() + "' (" + handle + ")");
|
||||
List<Item> item = new ArrayList<>();
|
||||
item.add((Item) dso);
|
||||
exporter = new MetadataExport(c, item.iterator(), exportAll);
|
||||
} else if (dso.getType() == Constants.COLLECTION) {
|
||||
System.out.println("Exporting collection '" + dso.getName() + "' (" + handle + ")");
|
||||
Collection collection = (Collection) dso;
|
||||
toExport = itemService.findByCollection(c, collection);
|
||||
exporter = new MetadataExport(c, toExport, exportAll);
|
||||
} else if (dso.getType() == Constants.COMMUNITY) {
|
||||
System.out.println("Exporting community '" + dso.getName() + "' (" + handle + ")");
|
||||
exporter = new MetadataExport(c, (Community) dso, exportAll);
|
||||
} else {
|
||||
System.err.println("Error identifying '" + handle + "'");
|
||||
System.exit(1);
|
||||
}
|
||||
return dso.getID().toString() + ".csv";
|
||||
} catch (SQLException e) {
|
||||
handler.handleException("Something went wrong trying to retrieve DSO for handle: " + handle, e);
|
||||
}
|
||||
return null;
|
||||
|
||||
// Perform the export
|
||||
DSpaceCSV csv = exporter.export();
|
||||
|
||||
// Save the files to the file
|
||||
csv.save(filename);
|
||||
|
||||
// Finish off and tidy up
|
||||
c.restoreAuthSystemState();
|
||||
c.complete();
|
||||
}
|
||||
}
|
||||
|
@@ -1,33 +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.app.bulkedit;
|
||||
|
||||
import org.apache.commons.cli.ParseException;
|
||||
|
||||
public class MetadataExportCli extends MetadataExport {
|
||||
|
||||
@Override
|
||||
protected String getFileNameForExportFile() {
|
||||
return commandLine.getOptionValue('f');
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() throws ParseException {
|
||||
super.setup();
|
||||
// Check a filename is given
|
||||
if (!commandLine.hasOption('f')) {
|
||||
throw new ParseException("Required parameter -f missing!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void logHelpInfo() {
|
||||
handler.logInfo("\nfull export: metadata-export -f filename");
|
||||
handler.logInfo("partial export: metadata-export -i handle -f filename");
|
||||
}
|
||||
}
|
@@ -1,26 +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.app.bulkedit;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.apache.commons.cli.Options;
|
||||
|
||||
public class MetadataExportCliScriptConfiguration extends MetadataExportScriptConfiguration<MetadataExportCli> {
|
||||
|
||||
|
||||
@Override
|
||||
public Options getOptions() {
|
||||
Options options = super.getOptions();
|
||||
options.addOption("f", "file", true, "destination where you want file written");
|
||||
options.getOption("f").setType(OutputStream .class);
|
||||
options.getOption("f").setRequired(true);
|
||||
super.options = options;
|
||||
return options;
|
||||
}
|
||||
}
|
@@ -1,70 +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.app.bulkedit;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.scripts.configuration.ScriptConfiguration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* The {@link ScriptConfiguration} for the {@link MetadataExport} script
|
||||
*/
|
||||
public class MetadataExportScriptConfiguration<T extends MetadataExport> extends ScriptConfiguration<T> {
|
||||
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
|
||||
private Class<T> dspaceRunnableClass;
|
||||
|
||||
@Override
|
||||
public Class<T> getDspaceRunnableClass() {
|
||||
return dspaceRunnableClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic setter for the dspaceRunnableClass
|
||||
* @param dspaceRunnableClass The dspaceRunnableClass to be set on this MetadataExportScriptConfiguration
|
||||
*/
|
||||
@Override
|
||||
public void setDspaceRunnableClass(Class<T> dspaceRunnableClass) {
|
||||
this.dspaceRunnableClass = dspaceRunnableClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowedToExecute(Context context) {
|
||||
try {
|
||||
return authorizeService.isAdmin(context);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException("SQLException occurred when checking if the current user is an admin", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Options getOptions() {
|
||||
if (options == null) {
|
||||
Options options = new Options();
|
||||
|
||||
options.addOption("i", "id", true, "ID or handle of thing to export (item, collection, or community)");
|
||||
options.getOption("i").setType(String.class);
|
||||
options.addOption("a", "all", false,
|
||||
"include all metadata fields that are not normally changed (e.g. provenance)");
|
||||
options.getOption("a").setType(boolean.class);
|
||||
options.addOption("h", "help", false, "help");
|
||||
options.getOption("h").setType(boolean.class);
|
||||
|
||||
|
||||
super.options = options;
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,68 +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.app.bulkedit;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.scripts.handler.DSpaceRunnableHandler;
|
||||
|
||||
/**
|
||||
* CLI variant for the {@link MetadataImport} class
|
||||
* This has been made so that we can specify the behaviour of the determineChanges method to be specific for the CLI
|
||||
*/
|
||||
public class MetadataImportCLI extends MetadataImport {
|
||||
|
||||
@Override
|
||||
protected boolean determineChange(DSpaceRunnableHandler handler) throws IOException {
|
||||
handler.logInfo("Do you want to make these changes? [y/n] ");
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in))) {
|
||||
String yn = bufferedReader.readLine();
|
||||
if ("y".equalsIgnoreCase(yn)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void assignCurrentUserInContext(Context context) throws ParseException {
|
||||
try {
|
||||
if (commandLine.hasOption('e')) {
|
||||
EPerson eperson;
|
||||
String e = commandLine.getOptionValue('e');
|
||||
if (e.indexOf('@') != -1) {
|
||||
eperson = EPersonServiceFactory.getInstance().getEPersonService().findByEmail(context, e);
|
||||
} else {
|
||||
eperson = EPersonServiceFactory.getInstance().getEPersonService().find(context, UUID.fromString(e));
|
||||
}
|
||||
|
||||
if (eperson == null) {
|
||||
throw new ParseException("Error, eperson cannot be found: " + e);
|
||||
}
|
||||
context.setCurrentUser(eperson);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ParseException("Unable to find DSpace user: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() throws ParseException {
|
||||
super.setup();
|
||||
if (!commandLine.hasOption('e')) {
|
||||
throw new ParseException("Required parameter -e missing!");
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,27 +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.app.bulkedit;
|
||||
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.dspace.scripts.configuration.ScriptConfiguration;
|
||||
|
||||
/**
|
||||
* The {@link ScriptConfiguration} for the {@link org.dspace.app.bulkedit.MetadataImportCLI} CLI script
|
||||
*/
|
||||
public class MetadataImportCliScriptConfiguration extends MetadataImportScriptConfiguration<MetadataImportCLI> {
|
||||
|
||||
@Override
|
||||
public Options getOptions() {
|
||||
Options options = super.getOptions();
|
||||
options.addOption("e", "email", true, "email address or user id of user (required if adding new items)");
|
||||
options.getOption("e").setType(String.class);
|
||||
options.getOption("e").setRequired(true);
|
||||
super.options = options;
|
||||
return options;
|
||||
}
|
||||
}
|
@@ -1,81 +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.app.bulkedit;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.scripts.configuration.ScriptConfiguration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* The {@link ScriptConfiguration} for the {@link MetadataImport} script
|
||||
*/
|
||||
public class MetadataImportScriptConfiguration<T extends MetadataImport> extends ScriptConfiguration<T> {
|
||||
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
|
||||
private Class<T> dspaceRunnableClass;
|
||||
|
||||
@Override
|
||||
public Class<T> getDspaceRunnableClass() {
|
||||
return dspaceRunnableClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic setter for the dspaceRunnableClass
|
||||
* @param dspaceRunnableClass The dspaceRunnableClass to be set on this MetadataImportScriptConfiguration
|
||||
*/
|
||||
@Override
|
||||
public void setDspaceRunnableClass(Class<T> dspaceRunnableClass) {
|
||||
this.dspaceRunnableClass = dspaceRunnableClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAllowedToExecute(Context context) {
|
||||
try {
|
||||
return authorizeService.isAdmin(context);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException("SQLException occurred when checking if the current user is an admin", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Options getOptions() {
|
||||
if (options == null) {
|
||||
Options options = new Options();
|
||||
|
||||
options.addOption("f", "file", true, "source file");
|
||||
options.getOption("f").setType(InputStream.class);
|
||||
options.getOption("f").setRequired(true);
|
||||
options.addOption("s", "silent", false,
|
||||
"silent operation - doesn't request confirmation of changes USE WITH CAUTION");
|
||||
options.getOption("s").setType(boolean.class);
|
||||
options.addOption("w", "workflow", false, "workflow - when adding new items, use collection workflow");
|
||||
options.getOption("w").setType(boolean.class);
|
||||
options.addOption("n", "notify", false,
|
||||
"notify - when adding new items using a workflow, send notification emails");
|
||||
options.getOption("n").setType(boolean.class);
|
||||
options.addOption("v", "validate-only", false,
|
||||
"validate - just validate the csv, don't run the import");
|
||||
options.getOption("v").setType(boolean.class);
|
||||
options.addOption("t", "template", false,
|
||||
"template - when adding new items, use the collection template (if it exists)");
|
||||
options.getOption("t").setType(boolean.class);
|
||||
options.addOption("h", "help", false, "help");
|
||||
options.getOption("h").setType(boolean.class);
|
||||
|
||||
super.options = options;
|
||||
}
|
||||
return options;
|
||||
}
|
||||
}
|
@@ -23,8 +23,7 @@ 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.apache.log4j.Logger;
|
||||
import org.dspace.checker.BitstreamDispatcher;
|
||||
import org.dspace.checker.CheckerCommand;
|
||||
import org.dspace.checker.HandleDispatcher;
|
||||
@@ -49,7 +48,7 @@ import org.dspace.core.Utils;
|
||||
* @author Nathan Sarr
|
||||
*/
|
||||
public final class ChecksumChecker {
|
||||
private static final Logger LOG = LogManager.getLogger(ChecksumChecker.class);
|
||||
private static final Logger LOG = Logger.getLogger(ChecksumChecker.class);
|
||||
|
||||
private static final BitstreamService bitstreamService = ContentServiceFactory.getInstance().getBitstreamService();
|
||||
|
||||
|
@@ -272,8 +272,9 @@ public class Harvest {
|
||||
targetCollection = (Collection) dso;
|
||||
}
|
||||
} else {
|
||||
// not a handle, try and treat it as an collection database UUID
|
||||
System.out.println("Looking up by UUID: " + collectionID + ", " + "in context: " + context);
|
||||
// not a handle, try and treat it as an integer collection database ID
|
||||
System.out.println("Looking up by id: " + collectionID + ", parsed as '" + Integer
|
||||
.parseInt(collectionID) + "', " + "in context: " + context);
|
||||
targetCollection = collectionService.find(context, UUID.fromString(collectionID));
|
||||
}
|
||||
}
|
||||
@@ -459,7 +460,7 @@ public class Harvest {
|
||||
List<String> errors;
|
||||
|
||||
System.out.print("Testing basic PMH access: ");
|
||||
errors = harvestedCollectionService.verifyOAIharvester(server, set,
|
||||
errors = OAIHarvester.verifyOAIharvester(server, set,
|
||||
(null != metadataFormat) ? metadataFormat : "dc", false);
|
||||
if (errors.isEmpty()) {
|
||||
System.out.println("OK");
|
||||
@@ -470,7 +471,7 @@ public class Harvest {
|
||||
}
|
||||
|
||||
System.out.print("Testing ORE support: ");
|
||||
errors = harvestedCollectionService.verifyOAIharvester(server, set,
|
||||
errors = OAIHarvester.verifyOAIharvester(server, set,
|
||||
(null != metadataFormat) ? metadataFormat : "dc", true);
|
||||
if (errors.isEmpty()) {
|
||||
System.out.println("OK");
|
||||
|
@@ -32,8 +32,8 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import javax.mail.MessagingException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.itemexport.service.ItemExportService;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
@@ -42,7 +42,7 @@ import org.dspace.content.Community;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
@@ -98,7 +98,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private Logger log = org.apache.logging.log4j.LogManager.getLogger(ItemExportServiceImpl.class);
|
||||
private Logger log = Logger.getLogger(ItemExportServiceImpl.class);
|
||||
|
||||
protected ItemExportServiceImpl() {
|
||||
|
||||
@@ -214,7 +214,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
protected void writeMetadata(Context c, String schema, Item i,
|
||||
File destDir, boolean migrate) throws Exception {
|
||||
String filename;
|
||||
if (schema.equals(MetadataSchemaEnum.DC.getName())) {
|
||||
if (schema.equals(MetadataSchema.DC_SCHEMA)) {
|
||||
filename = "dublin_core.xml";
|
||||
} else {
|
||||
filename = "metadata_" + schema + ".xml";
|
||||
@@ -271,8 +271,9 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
("date".equals(metadataField.getElement()) && "accessioned".equals(qualifier)) ||
|
||||
("date".equals(metadataField.getElement()) && "available".equals(qualifier)) ||
|
||||
("identifier".equals(metadataField.getElement()) && "uri".equals(qualifier) &&
|
||||
(dcv.getValue() != null && dcv.getValue().startsWith(
|
||||
handleService.getCanonicalPrefix() + handleService.getPrefix() + "/"))) ||
|
||||
(dcv.getValue() != null && dcv.getValue().startsWith("http://hdl.handle.net/" +
|
||||
handleService
|
||||
.getPrefix() + "/"))) ||
|
||||
("description".equals(metadataField.getElement()) && "provenance".equals(qualifier)) ||
|
||||
("format".equals(metadataField.getElement()) && "extent".equals(qualifier)) ||
|
||||
("format".equals(metadataField.getElement()) && "mimetype".equals(qualifier))))) {
|
||||
@@ -546,7 +547,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||
for (Bitstream bitstream : bitstreams) {
|
||||
// add up the size
|
||||
size += bitstream.getSizeBytes();
|
||||
size += bitstream.getSize();
|
||||
}
|
||||
}
|
||||
items.add(item.getID());
|
||||
@@ -573,7 +574,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||
for (Bitstream bitstream : bitstreams) {
|
||||
// add up the size
|
||||
size += bitstream.getSizeBytes();
|
||||
size += bitstream.getSize();
|
||||
}
|
||||
}
|
||||
items.add(item.getID());
|
||||
@@ -592,7 +593,7 @@ public class ItemExportServiceImpl implements ItemExportService {
|
||||
List<Bitstream> bitstreams = bundle.getBitstreams();
|
||||
for (Bitstream bitstream : bitstreams) {
|
||||
// add up the size
|
||||
size += bitstream.getSizeBytes();
|
||||
size += bitstream.getSize();
|
||||
}
|
||||
}
|
||||
ArrayList<UUID> items = new ArrayList<>();
|
||||
@@ -929,7 +930,7 @@ 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("dspace.url") + "/exportdownload/" + fileName);
|
||||
email.addArgument(ConfigurationManager.getProperty("org.dspace.app.itemexport.life.span.hours"));
|
||||
|
||||
email.send();
|
||||
@@ -947,7 +948,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(ConfigurationManager.getProperty("dspace.url") + "/feedback");
|
||||
|
||||
email.send();
|
||||
} catch (Exception e) {
|
||||
|
@@ -52,13 +52,13 @@ import gr.ekt.bte.core.TransformationSpec;
|
||||
import gr.ekt.bte.dataloader.FileDataLoader;
|
||||
import gr.ekt.bteio.generators.DSpaceOutputGenerator;
|
||||
import gr.ekt.bteio.loaders.OAIPMHDataLoader;
|
||||
import org.apache.commons.collections4.ComparatorUtils;
|
||||
import org.apache.commons.collections.ComparatorUtils;
|
||||
import org.apache.commons.io.FileDeleteStrategy;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.dspace.app.itemimport.service.ItemImportService;
|
||||
import org.dspace.app.util.LocalSchemaFilenameFilter;
|
||||
@@ -74,7 +74,6 @@ import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.content.service.BitstreamFormatService;
|
||||
import org.dspace.content.service.BitstreamService;
|
||||
@@ -125,7 +124,7 @@ import org.xml.sax.SAXException;
|
||||
* allow the registration of files (bitstreams) into DSpace.
|
||||
*/
|
||||
public class ItemImportServiceImpl implements ItemImportService, InitializingBean {
|
||||
private final Logger log = org.apache.logging.log4j.LogManager.getLogger(ItemImportServiceImpl.class);
|
||||
private final Logger log = Logger.getLogger(ItemImportServiceImpl.class);
|
||||
|
||||
@Autowired(required = true)
|
||||
protected AuthorizeService authorizeService;
|
||||
@@ -678,7 +677,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem(
|
||||
"schema");
|
||||
if (schemaAttr == null) {
|
||||
schema = MetadataSchemaEnum.DC.getName();
|
||||
schema = MetadataSchema.DC_SCHEMA;
|
||||
} else {
|
||||
schema = schemaAttr.getNodeValue();
|
||||
}
|
||||
@@ -1519,12 +1518,6 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
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|...
|
||||
@@ -1545,16 +1538,9 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
}
|
||||
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!)
|
||||
if (!outFile.toPath().normalize().startsWith(zipDir)) {
|
||||
throw new IOException("Bad zip entry: '" + entry.getName()
|
||||
+ "' in file '" + zipfile.getAbsolutePath() + "'!"
|
||||
+ " Cannot process this file.");
|
||||
}
|
||||
InputStream in = zf.getInputStream(entry);
|
||||
BufferedOutputStream out = new BufferedOutputStream(
|
||||
new FileOutputStream(outFile));
|
||||
new FileOutputStream(zipDir + entry.getName()));
|
||||
while ((len = in.read(buffer)) >= 0) {
|
||||
out.write(buffer, 0, len);
|
||||
}
|
||||
@@ -1810,7 +1796,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(ConfigurationManager.getProperty("dspace.url") + "/feedback");
|
||||
|
||||
email.send();
|
||||
} catch (Exception e) {
|
||||
|
@@ -30,7 +30,7 @@ import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.util.LocalSchemaFilenameFilter;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
@@ -47,7 +47,7 @@ import org.w3c.dom.Document;
|
||||
* Encapsulates the Item in the context of the DSpace Archive Format
|
||||
*/
|
||||
public class ItemArchive {
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(ItemArchive.class);
|
||||
private static final Logger log = Logger.getLogger(ItemArchive.class);
|
||||
|
||||
public static final String DUBLIN_CORE_XML = "dublin_core.xml";
|
||||
|
||||
|
@@ -31,12 +31,11 @@ import org.apache.commons.cli.PosixParser;
|
||||
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.eperson.EPerson;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.EPersonService;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
|
||||
/**
|
||||
* Provides some batch editing capabilities for items in DSpace:
|
||||
@@ -79,7 +78,6 @@ public class ItemUpdate {
|
||||
|
||||
protected static final EPersonService epersonService = EPersonServiceFactory.getInstance().getEPersonService();
|
||||
protected static final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
protected static final HandleService handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||
|
||||
static {
|
||||
filterAliases.put("ORIGINAL", "org.dspace.app.itemupdate.OriginalBitstreamFilter");
|
||||
@@ -332,7 +330,10 @@ public class ItemUpdate {
|
||||
iu.setEPerson(context, iu.eperson);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
HANDLE_PREFIX = handleService.getCanonicalPrefix();
|
||||
HANDLE_PREFIX = ConfigurationManager.getProperty("handle.canonical.prefix");
|
||||
if (HANDLE_PREFIX == null || HANDLE_PREFIX.length() == 0) {
|
||||
HANDLE_PREFIX = "http://hdl.handle.net/";
|
||||
}
|
||||
|
||||
iu.processArchive(context, sourcedir, itemField, metadataIndexName, alterProvenance, isTest);
|
||||
|
||||
|
@@ -28,13 +28,12 @@ import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.xpath.XPathAPI;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataField;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
@@ -190,7 +189,7 @@ public class MetadataUtilities {
|
||||
NodeList metadata = XPathAPI.selectNodeList(document, "/dublin_core");
|
||||
Node schemaAttr = metadata.item(0).getAttributes().getNamedItem("schema");
|
||||
if (schemaAttr == null) {
|
||||
schema = MetadataSchemaEnum.DC.getName();
|
||||
schema = MetadataSchema.DC_SCHEMA;
|
||||
} else {
|
||||
schema = schemaAttr.getNodeValue();
|
||||
}
|
||||
|
@@ -13,14 +13,6 @@ import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.scripts.DSpaceRunnable;
|
||||
import org.dspace.scripts.configuration.ScriptConfiguration;
|
||||
import org.dspace.scripts.factory.ScriptServiceFactory;
|
||||
import org.dspace.scripts.handler.DSpaceRunnableHandler;
|
||||
import org.dspace.scripts.handler.impl.CommandLineDSpaceRunnableHandler;
|
||||
import org.dspace.scripts.service.ScriptService;
|
||||
import org.dspace.servicemanager.DSpaceKernelImpl;
|
||||
import org.dspace.servicemanager.DSpaceKernelInit;
|
||||
import org.dspace.services.RequestService;
|
||||
@@ -35,9 +27,6 @@ import org.jdom.input.SAXBuilder;
|
||||
* @author Mark Diggory
|
||||
*/
|
||||
public class ScriptLauncher {
|
||||
|
||||
private static final Logger log = Logger.getLogger(ScriptLauncher.class);
|
||||
|
||||
/**
|
||||
* The service manager kernel
|
||||
*/
|
||||
@@ -46,8 +35,7 @@ public class ScriptLauncher {
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
private ScriptLauncher() {
|
||||
}
|
||||
private ScriptLauncher() { }
|
||||
|
||||
/**
|
||||
* Execute the DSpace script launcher
|
||||
@@ -57,7 +45,7 @@ public class ScriptLauncher {
|
||||
* @throws FileNotFoundException if file doesn't exist
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
throws FileNotFoundException, IOException, IllegalAccessException, InstantiationException {
|
||||
throws FileNotFoundException, IOException {
|
||||
// Initialise the service manager kernel
|
||||
try {
|
||||
kernelImpl = DSpaceKernelInit.getKernel(null);
|
||||
@@ -88,9 +76,8 @@ public class ScriptLauncher {
|
||||
}
|
||||
|
||||
// Look up command in the configuration, and execute.
|
||||
|
||||
CommandLineDSpaceRunnableHandler commandLineDSpaceRunnableHandler = new CommandLineDSpaceRunnableHandler();
|
||||
int status = handleScript(args, commandConfigs, commandLineDSpaceRunnableHandler, kernelImpl);
|
||||
int status;
|
||||
status = runOneCommand(commandConfigs, args);
|
||||
|
||||
// Destroy the service kernel if it is still alive
|
||||
if (kernelImpl != null) {
|
||||
@@ -99,55 +86,6 @@ public class ScriptLauncher {
|
||||
}
|
||||
|
||||
System.exit(status);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will take the arguments from a commandline input and it'll find the script that the first argument
|
||||
* refers to and it'll execute this script.
|
||||
* It can return a 1 or a 0 depending on whether the script failed or passed respectively
|
||||
* @param args The arguments for the script and the script as first one in the array
|
||||
* @param commandConfigs The Document
|
||||
* @param dSpaceRunnableHandler The DSpaceRunnableHandler for this execution
|
||||
* @param kernelImpl The relevant DSpaceKernelImpl
|
||||
* @return A 1 or 0 depending on whether the script failed or passed respectively
|
||||
*/
|
||||
public static int handleScript(String[] args, Document commandConfigs,
|
||||
DSpaceRunnableHandler dSpaceRunnableHandler,
|
||||
DSpaceKernelImpl kernelImpl) throws InstantiationException, IllegalAccessException {
|
||||
int status;
|
||||
ScriptService scriptService = ScriptServiceFactory.getInstance().getScriptService();
|
||||
ScriptConfiguration scriptConfiguration = scriptService.getScriptConfiguration(args[0]);
|
||||
DSpaceRunnable script = null;
|
||||
if (scriptConfiguration != null) {
|
||||
script = scriptService.createDSpaceRunnableForScriptConfiguration(scriptConfiguration);
|
||||
}
|
||||
if (script != null) {
|
||||
status = executeScript(args, dSpaceRunnableHandler, script);
|
||||
} else {
|
||||
status = runOneCommand(commandConfigs, args, kernelImpl);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will simply execute the script
|
||||
* @param args The arguments of the script with the script name as first place in the array
|
||||
* @param dSpaceRunnableHandler The relevant DSpaceRunnableHandler
|
||||
* @param script The script to be executed
|
||||
* @return A 1 or 0 depending on whether the script failed or passed respectively
|
||||
*/
|
||||
private static int executeScript(String[] args, DSpaceRunnableHandler dSpaceRunnableHandler,
|
||||
DSpaceRunnable script) {
|
||||
try {
|
||||
script.initialize(args, dSpaceRunnableHandler, null);
|
||||
script.run();
|
||||
return 0;
|
||||
} catch (ParseException e) {
|
||||
script.printHelp();
|
||||
e.printStackTrace();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
protected static int runOneCommand(Document commandConfigs, String[] args) {
|
||||
@@ -160,7 +98,7 @@ public class ScriptLauncher {
|
||||
* @param commandConfigs Document
|
||||
* @param args the command line arguments given
|
||||
*/
|
||||
protected static int runOneCommand(Document commandConfigs, String[] args, DSpaceKernelImpl kernelImpl) {
|
||||
public static int runOneCommand(Document commandConfigs, String[] args, DSpaceKernelImpl kernelImpl) {
|
||||
String request = args[0];
|
||||
Element root = commandConfigs.getRootElement();
|
||||
List<Element> commands = root.getChildren("command");
|
||||
|
@@ -11,7 +11,7 @@ import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.poi.POITextExtractor;
|
||||
import org.apache.poi.extractor.ExtractorFactory;
|
||||
import org.apache.poi.hssf.extractor.ExcelExtractor;
|
||||
@@ -36,7 +36,7 @@ import org.dspace.content.Item;
|
||||
*/
|
||||
public class ExcelFilter extends MediaFilter {
|
||||
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(ExcelFilter.class);
|
||||
private static Logger log = Logger.getLogger(ExcelFilter.class);
|
||||
|
||||
public String getFilteredName(String oldFilename) {
|
||||
return oldFilename + ".txt";
|
||||
|
@@ -143,7 +143,7 @@ public abstract class ImageMagickThumbnailFilter extends MediaFilter {
|
||||
// PDFs using the CMYK color system can be handled specially if
|
||||
// profiles are defined
|
||||
if (cmyk_profile != null && srgb_profile != null) {
|
||||
Info imageInfo = new Info(f.getAbsolutePath() + s, true);
|
||||
Info imageInfo = new Info(f.getAbsolutePath(), true);
|
||||
String imageClass = imageInfo.getImageClass();
|
||||
if (imageClass.contains("CMYK")) {
|
||||
op.profile(cmyk_profile);
|
||||
|
@@ -22,7 +22,7 @@ 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.apache.commons.lang.ArrayUtils;
|
||||
import org.dspace.app.mediafilter.factory.MediaFilterServiceFactory;
|
||||
import org.dspace.app.mediafilter.service.MediaFilterService;
|
||||
import org.dspace.content.Collection;
|
||||
|
@@ -220,7 +220,7 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
||||
} catch (Exception e) {
|
||||
String handle = myItem.getHandle();
|
||||
List<Bundle> bundles = myBitstream.getBundles();
|
||||
long size = myBitstream.getSizeBytes();
|
||||
long size = myBitstream.getSize();
|
||||
String checksum = myBitstream.getChecksum() + " (" + myBitstream.getChecksumAlgorithm() + ")";
|
||||
int assetstore = myBitstream.getStoreNumber();
|
||||
|
||||
@@ -310,11 +310,12 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
||||
// get bitstream filename, calculate destination filename
|
||||
String newName = formatFilter.getFilteredName(source.getName());
|
||||
|
||||
// check if destination bitstream exists
|
||||
Bundle existingBundle = null;
|
||||
Bitstream existingBitstream = null;
|
||||
Bitstream existingBitstream = null; // is there an existing rendition?
|
||||
Bundle targetBundle = null; // bundle we're modifying
|
||||
|
||||
List<Bundle> bundles = itemService.getBundles(item, formatFilter.getBundleName());
|
||||
|
||||
// check if destination bitstream exists
|
||||
if (bundles.size() > 0) {
|
||||
// only finds the last match (FIXME?)
|
||||
for (Bundle bundle : bundles) {
|
||||
@@ -322,7 +323,7 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
||||
|
||||
for (Bitstream bitstream : bitstreams) {
|
||||
if (bitstream.getName().trim().equals(newName.trim())) {
|
||||
existingBundle = bundle;
|
||||
targetBundle = bundle;
|
||||
existingBitstream = bitstream;
|
||||
}
|
||||
}
|
||||
@@ -344,71 +345,63 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
||||
+ " (item: " + item.getHandle() + ")");
|
||||
}
|
||||
|
||||
System.out.println("File: " + newName);
|
||||
|
||||
// start filtering of the bitstream, using try with resource to close all InputStreams properly
|
||||
try (
|
||||
// get the source stream
|
||||
InputStream srcStream = bitstreamService.retrieve(context, source);
|
||||
// filter the source stream to produce the destination stream
|
||||
// this is the hard work, check for OutOfMemoryErrors at the end of the try clause.
|
||||
InputStream destStream = formatFilter.getDestinationStream(item, srcStream, isVerbose);
|
||||
) {
|
||||
InputStream destStream;
|
||||
try {
|
||||
System.out.println("File: " + newName);
|
||||
destStream = formatFilter.getDestinationStream(item, bitstreamService.retrieve(context, source), isVerbose);
|
||||
if (destStream == null) {
|
||||
if (!isQuiet) {
|
||||
System.out.println("SKIPPED: bitstream " + source.getID()
|
||||
+ " (item: " + item.getHandle() + ") because filtering was unsuccessful");
|
||||
+ " (item: " + item.getHandle() + ") because filtering was unsuccessful");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Bundle targetBundle; // bundle we're modifying
|
||||
if (bundles.size() < 1) {
|
||||
// create new bundle if needed
|
||||
targetBundle = bundleService.create(context, item, formatFilter.getBundleName());
|
||||
} else {
|
||||
// take the first match as we already looked out for the correct bundle name
|
||||
targetBundle = bundles.get(0);
|
||||
}
|
||||
|
||||
// create bitstream to store the filter result
|
||||
Bitstream b = bitstreamService.create(context, targetBundle, destStream);
|
||||
// set the name, source and description of the bitstream
|
||||
b.setName(context, newName);
|
||||
b.setSource(context, "Written by FormatFilter " + formatFilter.getClass().getName() +
|
||||
" on " + DCDate.getCurrent() + " (GMT).");
|
||||
b.setDescription(context, formatFilter.getDescription());
|
||||
// Set the format of the bitstream
|
||||
BitstreamFormat bf = bitstreamFormatService.findByShortDescription(context,
|
||||
formatFilter.getFormatString());
|
||||
bitstreamService.setFormat(context, b, bf);
|
||||
bitstreamService.update(context, b);
|
||||
|
||||
//Set permissions on the derivative bitstream
|
||||
//- First remove any existing policies
|
||||
authorizeService.removeAllPolicies(context, b);
|
||||
|
||||
//- Determine if this is a public-derivative format
|
||||
if (publicFiltersClasses.contains(formatFilter.getClass().getSimpleName())) {
|
||||
//- Set derivative bitstream to be publicly accessible
|
||||
Group anonymous = groupService.findByName(context, Group.ANONYMOUS);
|
||||
authorizeService.addPolicy(context, b, Constants.READ, anonymous);
|
||||
} else {
|
||||
//- Inherit policies from the source bitstream
|
||||
authorizeService.inheritPolicies(context, source, b);
|
||||
}
|
||||
|
||||
//do post-processing of the generated bitstream
|
||||
formatFilter.postProcessBitstream(context, item, b);
|
||||
|
||||
} catch (OutOfMemoryError oome) {
|
||||
System.out.println("!!! OutOfMemoryError !!!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// create new bundle if needed
|
||||
if (bundles.size() < 1) {
|
||||
targetBundle = bundleService.create(context, item, formatFilter.getBundleName());
|
||||
} else {
|
||||
// take the first match
|
||||
targetBundle = bundles.get(0);
|
||||
}
|
||||
|
||||
Bitstream b = bitstreamService.create(context, targetBundle, destStream);
|
||||
|
||||
// Now set the format and name of the bitstream
|
||||
b.setName(context, newName);
|
||||
b.setSource(context, "Written by FormatFilter " + formatFilter.getClass().getName() +
|
||||
" on " + DCDate.getCurrent() + " (GMT).");
|
||||
b.setDescription(context, formatFilter.getDescription());
|
||||
|
||||
// Find the proper format
|
||||
BitstreamFormat bf = bitstreamFormatService.findByShortDescription(context,
|
||||
formatFilter.getFormatString());
|
||||
bitstreamService.setFormat(context, b, bf);
|
||||
bitstreamService.update(context, b);
|
||||
|
||||
//Set permissions on the derivative bitstream
|
||||
//- First remove any existing policies
|
||||
authorizeService.removeAllPolicies(context, b);
|
||||
|
||||
//- Determine if this is a public-derivative format
|
||||
if (publicFiltersClasses.contains(formatFilter.getClass().getSimpleName())) {
|
||||
//- Set derivative bitstream to be publicly accessible
|
||||
Group anonymous = groupService.findByName(context, Group.ANONYMOUS);
|
||||
authorizeService.addPolicy(context, b, Constants.READ, anonymous);
|
||||
} else {
|
||||
//- Inherit policies from the source bitstream
|
||||
authorizeService.inheritPolicies(context, source, b);
|
||||
}
|
||||
|
||||
// fixme - set date?
|
||||
// we are overwriting, so remove old bitstream
|
||||
if (existingBitstream != null) {
|
||||
bundleService.removeBitstream(context, existingBundle, existingBitstream);
|
||||
bundleService.removeBitstream(context, targetBundle, existingBitstream);
|
||||
}
|
||||
|
||||
if (!isQuiet) {
|
||||
@@ -416,6 +409,9 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
|
||||
+ " (item: " + item.getHandle() + ") and created '" + newName + "'");
|
||||
}
|
||||
|
||||
//do post-processing of the generated bitstream
|
||||
formatFilter.postProcessBitstream(context, item, b);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -11,9 +11,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.InputStream;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;
|
||||
import org.apache.pdfbox.rendering.PDFRenderer;
|
||||
import org.dspace.content.Item;
|
||||
|
||||
@@ -28,8 +26,6 @@ import org.dspace.content.Item;
|
||||
* @author Jason Sherman jsherman@usao.edu
|
||||
*/
|
||||
public class PDFBoxThumbnail extends MediaFilter implements SelfRegisterInputFormats {
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(PDFBoxThumbnail.class);
|
||||
|
||||
@Override
|
||||
public String getFilteredName(String oldFilename) {
|
||||
return oldFilename + ".jpg";
|
||||
@@ -69,19 +65,12 @@ public class PDFBoxThumbnail extends MediaFilter implements SelfRegisterInputFor
|
||||
@Override
|
||||
public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose)
|
||||
throws Exception {
|
||||
BufferedImage buf;
|
||||
PDDocument doc = PDDocument.load(source);
|
||||
PDFRenderer renderer = new PDFRenderer(doc);
|
||||
BufferedImage buf = renderer.renderImage(0);
|
||||
// ImageIO.write(buf, "PNG", new File("custom-render.png"));
|
||||
doc.close();
|
||||
|
||||
// Render the page image.
|
||||
try ( PDDocument doc = PDDocument.load(source); ) {
|
||||
PDFRenderer renderer = new PDFRenderer(doc);
|
||||
buf = renderer.renderImage(0);
|
||||
} catch (InvalidPasswordException ex) {
|
||||
log.error("PDF is encrypted. Cannot create thumbnail (item: {})",
|
||||
() -> currentItem.getHandle());
|
||||
return null;
|
||||
}
|
||||
|
||||
// Generate thumbnail derivative and return as IO stream.
|
||||
JPEGFilter jpegFilter = new JPEGFilter();
|
||||
return jpegFilter.getThumb(currentItem, buf, verbose);
|
||||
}
|
||||
|
@@ -16,9 +16,8 @@ import java.io.InputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
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;
|
||||
@@ -31,7 +30,7 @@ import org.dspace.core.ConfigurationManager;
|
||||
*/
|
||||
public class PDFFilter extends MediaFilter {
|
||||
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(PDFFilter.class);
|
||||
private static Logger log = Logger.getLogger(PDFFilter.class);
|
||||
|
||||
@Override
|
||||
public String getFilteredName(String oldFilename) {
|
||||
@@ -96,10 +95,6 @@ public class PDFFilter extends MediaFilter {
|
||||
try {
|
||||
pdfDoc = PDDocument.load(source);
|
||||
pts.writeText(pdfDoc, writer);
|
||||
} catch (InvalidPasswordException ex) {
|
||||
log.error("PDF is encrypted. Cannot extract text (item: {})",
|
||||
() -> currentItem.getHandle());
|
||||
return null;
|
||||
} finally {
|
||||
try {
|
||||
if (pdfDoc != null) {
|
||||
|
@@ -10,7 +10,7 @@ package org.dspace.app.mediafilter;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.poi.POITextExtractor;
|
||||
import org.apache.poi.extractor.ExtractorFactory;
|
||||
import org.apache.poi.hslf.extractor.PowerPointExtractor;
|
||||
@@ -23,7 +23,7 @@ import org.dspace.content.Item;
|
||||
*/
|
||||
public class PowerPointFilter extends MediaFilter {
|
||||
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(PowerPointFilter.class);
|
||||
private static Logger log = Logger.getLogger(PowerPointFilter.class);
|
||||
|
||||
@Override
|
||||
public String getFilteredName(String oldFilename) {
|
||||
|
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* 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.app.mediafilter;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.Item;
|
||||
import org.textmining.extraction.TextExtractor;
|
||||
import org.textmining.extraction.word.WordTextExtractorFactory;
|
||||
|
||||
/*
|
||||
*
|
||||
* to do: helpful error messages - can't find mediafilter.cfg - can't
|
||||
* instantiate filter - bitstream format doesn't exist.
|
||||
*
|
||||
*/
|
||||
public class WordFilter extends MediaFilter {
|
||||
|
||||
private static Logger log = Logger.getLogger(WordFilter.class);
|
||||
|
||||
@Override
|
||||
public String getFilteredName(String oldFilename) {
|
||||
return oldFilename + ".txt";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String bundle name
|
||||
*/
|
||||
@Override
|
||||
public String getBundleName() {
|
||||
return "TEXT";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String bitstreamformat
|
||||
*/
|
||||
@Override
|
||||
public String getFormatString() {
|
||||
return "Text";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String description
|
||||
*/
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Extracted text";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param currentItem item
|
||||
* @param source source input stream
|
||||
* @param verbose verbose mode
|
||||
* @return InputStream the resulting input stream
|
||||
* @throws Exception if error
|
||||
*/
|
||||
@Override
|
||||
public InputStream getDestinationStream(Item currentItem, InputStream source, boolean verbose)
|
||||
throws Exception {
|
||||
// get input stream from bitstream
|
||||
// pass to filter, get string back
|
||||
try {
|
||||
WordTextExtractorFactory factory = new WordTextExtractorFactory();
|
||||
TextExtractor e = factory.textExtractor(source);
|
||||
String extractedText = e.getText();
|
||||
|
||||
// if verbose flag is set, print out extracted text
|
||||
// to STDOUT
|
||||
if (verbose) {
|
||||
System.out.println(extractedText);
|
||||
}
|
||||
|
||||
// generate an input stream with the extracted text
|
||||
byte[] textBytes = extractedText.getBytes();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(textBytes);
|
||||
|
||||
return bais; // will this work? or will the byte array be out of scope?
|
||||
} catch (IOException ioe) {
|
||||
System.out.println("Invalid Word Format");
|
||||
log.error("Error detected - Word File format not recognized: "
|
||||
+ ioe.getMessage(), ioe);
|
||||
throw ioe;
|
||||
}
|
||||
}
|
||||
}
|
@@ -78,7 +78,7 @@ public class RequestItem implements ReloadableEntity<Integer> {
|
||||
private Date request_date = null;
|
||||
|
||||
@Column(name = "accept_request")
|
||||
private boolean accept_request;
|
||||
private Boolean accept_request = null;
|
||||
|
||||
/**
|
||||
* Protected constructor, create object using:
|
||||
@@ -88,7 +88,6 @@ public class RequestItem implements ReloadableEntity<Integer> {
|
||||
protected RequestItem() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getID() {
|
||||
return requestitem_id;
|
||||
}
|
||||
|
@@ -19,15 +19,6 @@ import org.dspace.core.Context;
|
||||
* @author Andrea Bollini
|
||||
*/
|
||||
public interface RequestItemAuthorExtractor {
|
||||
|
||||
/**
|
||||
* Retrieve the auhtor to contact for a request copy of the give item.
|
||||
*
|
||||
* @param context DSpace context object
|
||||
* @param item item to request
|
||||
* @return An object containing name an email address to send the request to
|
||||
* or null if no valid email address was found.
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
public RequestItemAuthor getRequestItemAuthor(Context context, Item item) throws SQLException;
|
||||
public RequestItemAuthor getRequestItemAuthor(Context context, Item item)
|
||||
throws SQLException;
|
||||
}
|
||||
|
@@ -9,8 +9,8 @@ package org.dspace.app.requestitem;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
public class RequestItemHelpdeskStrategy extends RequestItemSubmitterStrategy {
|
||||
|
||||
private Logger log = org.apache.logging.log4j.LogManager.getLogger(RequestItemHelpdeskStrategy.class);
|
||||
private Logger log = Logger.getLogger(RequestItemHelpdeskStrategy.class);
|
||||
|
||||
@Autowired(required = true)
|
||||
protected EPersonService ePersonService;
|
||||
@@ -74,8 +74,8 @@ public class RequestItemHelpdeskStrategy extends RequestItemSubmitterStrategy {
|
||||
return new RequestItemAuthor(helpdeskEPerson);
|
||||
} else {
|
||||
String helpdeskName = I18nUtil.getMessage(
|
||||
"org.dspace.app.requestitem.RequestItemHelpdeskStrategy.helpdeskname",
|
||||
context);
|
||||
"org.dspace.app.requestitem.RequestItemHelpdeskStrategy.helpdeskname",
|
||||
context);
|
||||
return new RequestItemAuthor(helpdeskName, helpDeskEmail);
|
||||
}
|
||||
}
|
||||
|
@@ -10,13 +10,12 @@ package org.dspace.app.requestitem;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.I18nUtil;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -39,7 +38,6 @@ public class RequestItemMetadataStrategy extends RequestItemSubmitterStrategy {
|
||||
@Override
|
||||
public RequestItemAuthor getRequestItemAuthor(Context context, Item item)
|
||||
throws SQLException {
|
||||
RequestItemAuthor author = null;
|
||||
if (emailMetadata != null) {
|
||||
List<MetadataValue> vals = itemService.getMetadataByMetadataString(item, emailMetadata);
|
||||
if (vals.size() > 0) {
|
||||
@@ -51,38 +49,19 @@ public class RequestItemMetadataStrategy extends RequestItemSubmitterStrategy {
|
||||
fullname = nameVals.iterator().next().getValue();
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(fullname)) {
|
||||
fullname = I18nUtil
|
||||
.getMessage(
|
||||
"org.dspace.app.requestitem.RequestItemMetadataStrategy.unnamed",
|
||||
context);
|
||||
.getMessage(
|
||||
"org.dspace.app.requestitem.RequestItemMetadataStrategy.unnamed",
|
||||
context);
|
||||
}
|
||||
author = new RequestItemAuthor(fullname, email);
|
||||
RequestItemAuthor author = new RequestItemAuthor(
|
||||
fullname, email);
|
||||
return author;
|
||||
}
|
||||
} else {
|
||||
// Uses the basic strategy to look for the original submitter
|
||||
author = super.getRequestItemAuthor(context, item);
|
||||
// Is the author or his email null, so get the help desk or admin name and email
|
||||
if (null == author || null == author.getEmail()) {
|
||||
String email = null;
|
||||
String name = null;
|
||||
//First get help desk name and email
|
||||
email = DSpaceServicesFactory.getInstance()
|
||||
.getConfigurationService().getProperty("mail.helpdesk");
|
||||
name = DSpaceServicesFactory.getInstance()
|
||||
.getConfigurationService().getProperty("mail.helpdesk.name");
|
||||
// If help desk mail is null get the mail and name of admin
|
||||
if (email == null) {
|
||||
email = DSpaceServicesFactory.getInstance()
|
||||
.getConfigurationService().getProperty("mail.admin");
|
||||
name = DSpaceServicesFactory.getInstance()
|
||||
.getConfigurationService().getProperty("mail.admin.name");
|
||||
}
|
||||
author = new RequestItemAuthor(name, email);
|
||||
}
|
||||
}
|
||||
return author;
|
||||
return super.getRequestItemAuthor(context, item);
|
||||
}
|
||||
|
||||
public void setEmailMetadata(String emailMetadata) {
|
||||
|
@@ -10,7 +10,7 @@ package org.dspace.app.requestitem;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.requestitem.dao.RequestItemDAO;
|
||||
import org.dspace.app.requestitem.service.RequestItemService;
|
||||
import org.dspace.content.Bitstream;
|
||||
@@ -28,7 +28,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
public class RequestItemServiceImpl implements RequestItemService {
|
||||
|
||||
private final Logger log = org.apache.logging.log4j.LogManager.getLogger(RequestItemServiceImpl.class);
|
||||
private final Logger log = Logger.getLogger(RequestItemServiceImpl.class);
|
||||
|
||||
@Autowired(required = true)
|
||||
protected RequestItemDAO requestItemDAO;
|
||||
|
@@ -23,22 +23,13 @@ public class RequestItemSubmitterStrategy implements RequestItemAuthorExtractor
|
||||
public RequestItemSubmitterStrategy() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the submitter of an Item as RequestItemAuthor or null if the
|
||||
* Submitter is deleted.
|
||||
*
|
||||
* @return The submitter of the item or null if the submitter is deleted
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
@Override
|
||||
public RequestItemAuthor getRequestItemAuthor(Context context, Item item)
|
||||
throws SQLException {
|
||||
EPerson submitter = item.getSubmitter();
|
||||
RequestItemAuthor author = null;
|
||||
if (null != submitter) {
|
||||
author = new RequestItemAuthor(
|
||||
submitter.getFullName(), submitter.getEmail());
|
||||
}
|
||||
RequestItemAuthor author = new RequestItemAuthor(
|
||||
submitter.getFullName(), submitter.getEmail());
|
||||
return author;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -8,15 +8,13 @@
|
||||
package org.dspace.app.requestitem.dao.impl;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Root;
|
||||
|
||||
import org.dspace.app.requestitem.RequestItem;
|
||||
import org.dspace.app.requestitem.RequestItem_;
|
||||
import org.dspace.app.requestitem.dao.RequestItemDAO;
|
||||
import org.dspace.core.AbstractHibernateDAO;
|
||||
import org.dspace.core.Context;
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
|
||||
/**
|
||||
* Hibernate implementation of the Database Access Object interface class for the RequestItem object.
|
||||
@@ -32,12 +30,9 @@ public class RequestItemDAOImpl extends AbstractHibernateDAO<RequestItem> implem
|
||||
|
||||
@Override
|
||||
public RequestItem findByToken(Context context, String token) throws SQLException {
|
||||
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RequestItem.class);
|
||||
Root<RequestItem> requestItemRoot = criteriaQuery.from(RequestItem.class);
|
||||
criteriaQuery.select(requestItemRoot);
|
||||
criteriaQuery.where(criteriaBuilder.equal(requestItemRoot.get(RequestItem_.token), token));
|
||||
return uniqueResult(context, criteriaQuery, false, RequestItem.class, -1, -1);
|
||||
Criteria criteria = createCriteria(context, RequestItem.class);
|
||||
criteria.add(Restrictions.eq("token", token));
|
||||
return uniqueResult(criteria);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -15,8 +15,8 @@ import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.sfx.service.SFXFileReaderService;
|
||||
import org.dspace.content.DCPersonName;
|
||||
import org.dspace.content.Item;
|
||||
@@ -58,7 +58,7 @@ public class SFXFileReaderServiceImpl implements SFXFileReaderService {
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private final Logger log = org.apache.logging.log4j.LogManager.getLogger(SFXFileReaderServiceImpl.class);
|
||||
private final Logger log = Logger.getLogger(SFXFileReaderServiceImpl.class);
|
||||
|
||||
protected SFXFileReaderServiceImpl() {
|
||||
}
|
||||
|
@@ -15,9 +15,6 @@ import java.util.List;
|
||||
* @author Andrea Bollini
|
||||
*/
|
||||
public class SHERPAPublisher {
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String alias;
|
||||
@@ -52,7 +49,7 @@ public class SHERPAPublisher {
|
||||
|
||||
private String dateupdated;
|
||||
|
||||
public SHERPAPublisher(String id, String name, String alias, String homeurl,
|
||||
public SHERPAPublisher(String name, String alias, String homeurl,
|
||||
String prearchiving, List<String> prerestriction,
|
||||
String postarchiving, List<String> postrestriction,
|
||||
String pubarchiving, List<String> pubrestriction,
|
||||
@@ -60,8 +57,6 @@ public class SHERPAPublisher {
|
||||
String paidaccessname, String paidaccessnotes,
|
||||
List<String[]> copyright, String romeocolour, String datedded,
|
||||
String dateupdated) {
|
||||
this.id = id;
|
||||
|
||||
this.name = name;
|
||||
|
||||
this.alias = alias;
|
||||
@@ -165,11 +160,4 @@ public class SHERPAPublisher {
|
||||
return dateupdated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic getter for the id
|
||||
* @return the id value of this SHERPAPublisher
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
@@ -13,8 +13,7 @@ import java.util.List;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.app.util.XMLUtils;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
@@ -25,9 +24,7 @@ import org.w3c.dom.Element;
|
||||
* @author Andrea Bollini
|
||||
*/
|
||||
public class SHERPAResponse {
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(SHERPAResponse.class);
|
||||
|
||||
private int numHits;
|
||||
private boolean error;
|
||||
|
||||
private String message;
|
||||
|
||||
@@ -48,9 +45,6 @@ public class SHERPAResponse {
|
||||
factory.setValidating(false);
|
||||
factory.setIgnoringComments(true);
|
||||
factory.setIgnoringElementContentWhitespace(true);
|
||||
// disallow DTD parsing to ensure no XXE attacks can occur.
|
||||
// See https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html
|
||||
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
|
||||
|
||||
DocumentBuilder db = factory.newDocumentBuilder();
|
||||
Document inDoc = db.parse(xmlData);
|
||||
@@ -63,14 +57,13 @@ public class SHERPAResponse {
|
||||
Element publishersElement = XMLUtils.getSingleElement(xmlRoot,
|
||||
"publishers");
|
||||
|
||||
String numhitsString = XMLUtils.getElementValue(headersElement, "numhits");
|
||||
if (StringUtils.isNotBlank(numhitsString)) {
|
||||
numHits = Integer.parseInt(numhitsString);
|
||||
} else {
|
||||
numHits = 0;
|
||||
}
|
||||
message = XMLUtils.getElementValue(headersElement, "message");
|
||||
|
||||
if (StringUtils.isNotBlank(message)) {
|
||||
error = true;
|
||||
return;
|
||||
}
|
||||
|
||||
license = XMLUtils.getElementValue(headersElement, "license");
|
||||
licenseURL = XMLUtils.getElementValue(headersElement, "licenseurl");
|
||||
disclaimer = XMLUtils.getElementValue(headersElement, "disclaimer");
|
||||
@@ -119,8 +112,9 @@ public class SHERPAResponse {
|
||||
|
||||
Element copyrightlinksElement = XMLUtils.getSingleElement(
|
||||
publisherElement, "copyrightlinks");
|
||||
|
||||
publishers
|
||||
.add(new SHERPAPublisher(publisherElement.getAttribute("id"), XMLUtils.getElementValue(
|
||||
.add(new SHERPAPublisher(XMLUtils.getElementValue(
|
||||
publisherElement, "name"),
|
||||
XMLUtils.getElementValue(publisherElement,
|
||||
"alias"), XMLUtils.getElementValue(
|
||||
@@ -168,12 +162,17 @@ public class SHERPAResponse {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error parsing SHERPA API Response", e);
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
|
||||
public SHERPAResponse(String message) {
|
||||
this.message = message;
|
||||
this.error = true;
|
||||
}
|
||||
|
||||
public boolean isError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
@@ -199,8 +198,4 @@ public class SHERPAResponse {
|
||||
public List<SHERPAPublisher> getPublishers() {
|
||||
return publishers;
|
||||
}
|
||||
|
||||
public int getNumHits() {
|
||||
return numHits;
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
package org.dspace.app.sherpa;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpStatus;
|
||||
@@ -16,7 +16,7 @@ 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.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
|
||||
public class SHERPAService {
|
||||
@@ -29,7 +29,7 @@ public class SHERPAService {
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(SHERPAService.class);
|
||||
private static final Logger log = Logger.getLogger(SHERPAService.class);
|
||||
|
||||
public SHERPAService() {
|
||||
HttpClientBuilder builder = HttpClientBuilder.create();
|
||||
|
@@ -11,8 +11,8 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.sherpa.SHERPAResponse;
|
||||
import org.dspace.app.sherpa.SHERPAService;
|
||||
import org.dspace.content.Item;
|
||||
@@ -27,7 +27,7 @@ public class SHERPASubmitService {
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(SHERPASubmitService.class);
|
||||
private static Logger log = Logger.getLogger(SHERPASubmitService.class);
|
||||
|
||||
public void setConfiguration(SHERPASubmitConfigurationService configuration) {
|
||||
this.configuration = configuration;
|
||||
|
@@ -27,10 +27,9 @@ 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;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.Item;
|
||||
@@ -53,7 +52,7 @@ public class GenerateSitemaps {
|
||||
/**
|
||||
* Logger
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(GenerateSitemaps.class);
|
||||
private static Logger log = Logger.getLogger(GenerateSitemaps.class);
|
||||
|
||||
private static final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
|
||||
private static final CollectionService collectionService =
|
||||
@@ -85,9 +84,6 @@ public class GenerateSitemaps {
|
||||
options
|
||||
.addOption("p", "ping", true,
|
||||
"ping specified search engine URL");
|
||||
options
|
||||
.addOption("d", "delete", false,
|
||||
"delete sitemaps dir and its contents");
|
||||
|
||||
CommandLine line = null;
|
||||
|
||||
@@ -109,9 +105,10 @@ public class GenerateSitemaps {
|
||||
}
|
||||
|
||||
/*
|
||||
* Sanity check -- if no sitemap generation or pinging to do, or deletion, print usage
|
||||
* Sanity check -- if no sitemap generation or pinging to do, print
|
||||
* usage
|
||||
*/
|
||||
if (line.getArgs().length != 0 || line.hasOption('d') || line.hasOption('b')
|
||||
if (line.getArgs().length != 0 || line.hasOption('b')
|
||||
&& line.hasOption('s') && !line.hasOption('g')
|
||||
&& !line.hasOption('m') && !line.hasOption('y')
|
||||
&& !line.hasOption('p')) {
|
||||
@@ -126,10 +123,6 @@ public class GenerateSitemaps {
|
||||
generateSitemaps(!line.hasOption('b'), !line.hasOption('s'));
|
||||
}
|
||||
|
||||
if (line.hasOption('d')) {
|
||||
deleteSitemaps();
|
||||
}
|
||||
|
||||
if (line.hasOption('a')) {
|
||||
pingConfiguredSearchEngines();
|
||||
}
|
||||
@@ -147,29 +140,6 @@ public class GenerateSitemaps {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs generate-sitemaps without any params for the scheduler (task-scheduler.xml).
|
||||
*
|
||||
* @throws SQLException if a database error occurs.
|
||||
* @throws IOException if IO error occurs.
|
||||
*/
|
||||
public static void generateSitemapsScheduled() throws IOException, SQLException {
|
||||
generateSitemaps(true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the sitemaps directory and its contents if it exists
|
||||
* @throws IOException if IO error occurs
|
||||
*/
|
||||
public static void deleteSitemaps() throws IOException {
|
||||
File outputDir = new File(configurationService.getProperty("sitemap.dir"));
|
||||
if (!outputDir.exists() && !outputDir.isDirectory()) {
|
||||
log.error("Unable to delete sitemaps directory, doesn't exist or isn't a directort");
|
||||
} else {
|
||||
FileUtils.deleteDirectory(outputDir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate sitemap.org protocol and/or basic HTML sitemaps.
|
||||
*
|
||||
@@ -180,9 +150,14 @@ public class GenerateSitemaps {
|
||||
* @throws IOException if IO error
|
||||
* if IO error occurs.
|
||||
*/
|
||||
public static void generateSitemaps(boolean makeHTMLMap, boolean makeSitemapOrg) throws SQLException, IOException {
|
||||
String uiURLStem = configurationService.getProperty("dspace.ui.url");
|
||||
String sitemapStem = uiURLStem + "/sitemap";
|
||||
public static void generateSitemaps(boolean makeHTMLMap,
|
||||
boolean makeSitemapOrg) throws SQLException, IOException {
|
||||
String sitemapStem = configurationService.getProperty("dspace.url")
|
||||
+ "/sitemap";
|
||||
String htmlMapStem = configurationService.getProperty("dspace.url")
|
||||
+ "/htmlmap";
|
||||
String handleURLStem = configurationService.getProperty("dspace.url")
|
||||
+ "/handle/";
|
||||
|
||||
File outputDir = new File(configurationService.getProperty("sitemap.dir"));
|
||||
if (!outputDir.exists() && !outputDir.mkdir()) {
|
||||
@@ -193,11 +168,13 @@ public class GenerateSitemaps {
|
||||
AbstractGenerator sitemapsOrg = null;
|
||||
|
||||
if (makeHTMLMap) {
|
||||
html = new HTMLSitemapGenerator(outputDir, sitemapStem, ".html");
|
||||
html = new HTMLSitemapGenerator(outputDir, htmlMapStem + "?map=",
|
||||
null);
|
||||
}
|
||||
|
||||
if (makeSitemapOrg) {
|
||||
sitemapsOrg = new SitemapsOrgGenerator(outputDir, sitemapStem, ".xml");
|
||||
sitemapsOrg = new SitemapsOrgGenerator(outputDir, sitemapStem
|
||||
+ "?map=", null);
|
||||
}
|
||||
|
||||
Context c = new Context(Context.Mode.READ_ONLY);
|
||||
@@ -205,7 +182,7 @@ public class GenerateSitemaps {
|
||||
List<Community> comms = communityService.findAll(c);
|
||||
|
||||
for (Community comm : comms) {
|
||||
String url = uiURLStem + "/communities/" + comm.getID();
|
||||
String url = handleURLStem + comm.getHandle();
|
||||
|
||||
if (makeHTMLMap) {
|
||||
html.addURL(url, null);
|
||||
@@ -220,7 +197,7 @@ public class GenerateSitemaps {
|
||||
List<Collection> colls = collectionService.findAll(c);
|
||||
|
||||
for (Collection coll : colls) {
|
||||
String url = uiURLStem + "/collections/" + coll.getID();
|
||||
String url = handleURLStem + coll.getHandle();
|
||||
|
||||
if (makeHTMLMap) {
|
||||
html.addURL(url, null);
|
||||
@@ -237,7 +214,7 @@ public class GenerateSitemaps {
|
||||
|
||||
while (allItems.hasNext()) {
|
||||
Item i = allItems.next();
|
||||
String url = uiURLStem + "/items/" + i.getID();
|
||||
String url = handleURLStem + i.getHandle();
|
||||
Date lastMod = i.getLastModified();
|
||||
|
||||
if (makeHTMLMap) {
|
||||
@@ -316,7 +293,7 @@ public class GenerateSitemaps {
|
||||
.getProperty("http.proxy.port"));
|
||||
}
|
||||
|
||||
String sitemapURL = configurationService.getProperty("dspace.ui.url")
|
||||
String sitemapURL = configurationService.getProperty("dspace.url")
|
||||
+ "/sitemap";
|
||||
|
||||
URL url = new URL(engineURL + URLEncoder.encode(sitemapURL, "UTF-8"));
|
||||
|
@@ -59,7 +59,7 @@ public class SitemapsOrgGenerator extends AbstractGenerator {
|
||||
|
||||
@Override
|
||||
public String getFilename(int number) {
|
||||
return "sitemap" + number + ".xml";
|
||||
return "sitemap" + number + ".xml.gz";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -100,12 +100,12 @@ public class SitemapsOrgGenerator extends AbstractGenerator {
|
||||
|
||||
@Override
|
||||
public boolean useCompression() {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndexFilename() {
|
||||
return "sitemap_index.xml";
|
||||
return "sitemap_index.xml.gz";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -33,7 +33,6 @@ 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;
|
||||
@@ -582,9 +581,9 @@ public class LogAnalyser {
|
||||
}
|
||||
|
||||
// now do the host name and url lookup
|
||||
hostName = Utils.getHostName(ConfigurationManager.getProperty("dspace.ui.url"));
|
||||
hostName = ConfigurationManager.getProperty("dspace.hostname").trim();
|
||||
name = ConfigurationManager.getProperty("dspace.name").trim();
|
||||
url = ConfigurationManager.getProperty("dspace.ui.url").trim();
|
||||
url = ConfigurationManager.getProperty("dspace.url").trim();
|
||||
if ((url != null) && (!url.endsWith("/"))) {
|
||||
url = url + "/";
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.ItemService;
|
||||
@@ -763,10 +763,9 @@ public class ReportGenerator {
|
||||
// build the referece
|
||||
// FIXME: here we have blurred the line between content and presentation
|
||||
// and it should probably be un-blurred
|
||||
List<MetadataValue> title = itemService.getMetadata(item, MetadataSchemaEnum.DC.getName(),
|
||||
"title", null, Item.ANY);
|
||||
List<MetadataValue> title = itemService.getMetadata(item, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY);
|
||||
List<MetadataValue> author = itemService
|
||||
.getMetadata(item, MetadataSchemaEnum.DC.getName(), "contributor", "author", Item.ANY);
|
||||
.getMetadata(item, MetadataSchema.DC_SCHEMA, "contributor", "author", Item.ANY);
|
||||
|
||||
StringBuffer authors = new StringBuffer();
|
||||
if (author.size() > 0) {
|
||||
|
@@ -15,7 +15,7 @@ package org.dspace.app.statistics;
|
||||
*
|
||||
* @author Richard Jones
|
||||
*/
|
||||
public class Stat implements Comparable<Stat> {
|
||||
public class Stat implements Comparable {
|
||||
// FIXME: this class is functional but a bit messy, and should be neatened
|
||||
// up and completed
|
||||
|
||||
@@ -132,17 +132,17 @@ public class Stat implements Comparable<Stat> {
|
||||
|
||||
|
||||
/**
|
||||
* Compare the current Stat to the given Stat returning -1 if o is less
|
||||
* than the current Stat, 0 if they are the same, and +1 if o is greater
|
||||
* than the current Stat.
|
||||
* compare the current object to the given object returning -1 if o is less
|
||||
* than the current object, 0 if they are the same, and +1 if o is greater
|
||||
* than the current object.
|
||||
*
|
||||
* @param stat the Stat object to compare to the current one
|
||||
* @param o the object to compare to the current one
|
||||
* @return +1, 0, -1 if o is less than, equal to, or greater than the
|
||||
* current object value.
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Stat stat) {
|
||||
int objectValue = stat.getValue();
|
||||
public int compareTo(Object o) {
|
||||
int objectValue = ((Stat) o).getValue();
|
||||
|
||||
if (objectValue < this.getValue()) {
|
||||
return -1;
|
||||
|
@@ -21,7 +21,7 @@ import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
|
||||
/**
|
||||
|
@@ -50,16 +50,16 @@ abstract public class AbstractDSpaceWebapp
|
||||
/**
|
||||
* Construct a particular kind of DSpace application.
|
||||
*
|
||||
* @param kind what kind of application is this?
|
||||
* @param kind what kind of application is this? (XMLUI, JSPUI, etc.)
|
||||
*/
|
||||
public AbstractDSpaceWebapp(String kind) {
|
||||
this.kind = kind;
|
||||
|
||||
started = new Date();
|
||||
|
||||
url = ConfigurationManager.getProperty("dspace.ui.url");
|
||||
url = ConfigurationManager.getProperty("dspace.url");
|
||||
if (null == url) {
|
||||
throw new IllegalStateException("dspace.ui.url is undefined");
|
||||
throw new IllegalStateException("dspace.url is undefined");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,10 +9,7 @@ package org.dspace.app.util;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.authenticate.factory.AuthenticateServiceFactory;
|
||||
import org.dspace.authorize.AuthorizeConfiguration;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
@@ -22,22 +19,12 @@ import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.GroupService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.utils.DSpace;
|
||||
import org.dspace.xmlworkflow.factory.XmlWorkflowServiceFactory;
|
||||
import org.dspace.xmlworkflow.storedcomponents.CollectionRole;
|
||||
import org.dspace.xmlworkflow.storedcomponents.service.CollectionRoleService;
|
||||
|
||||
/**
|
||||
* This class is an addition to the AuthorizeManager that perform authorization
|
||||
@@ -47,7 +34,12 @@ import org.dspace.xmlworkflow.storedcomponents.service.CollectionRoleService;
|
||||
*/
|
||||
public class AuthorizeUtil {
|
||||
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(AuthorizeUtil.class);
|
||||
private static final AuthorizeService authorizeService =
|
||||
AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
private static final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
private static final CollectionService collectionService =
|
||||
ContentServiceFactory.getInstance().getCollectionService();
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
@@ -103,9 +95,8 @@ public class AuthorizeUtil {
|
||||
*/
|
||||
public static void authorizeManageItemPolicy(Context context, Item item)
|
||||
throws AuthorizeException, SQLException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
if (AuthorizeConfiguration.canItemAdminManagePolicies()) {
|
||||
AuthorizeServiceFactory.getInstance().getAuthorizeService().authorizeAction(context, item, Constants.ADMIN);
|
||||
authorizeService.authorizeAction(context, item, Constants.ADMIN);
|
||||
} else if (AuthorizeConfiguration.canCollectionAdminManageItemPolicies()) {
|
||||
authorizeService.authorizeAction(context, item
|
||||
.getOwningCollection(), Constants.ADMIN);
|
||||
@@ -133,7 +124,6 @@ public class AuthorizeUtil {
|
||||
*/
|
||||
public static void authorizeManageCollectionPolicy(Context context,
|
||||
Collection collection) throws AuthorizeException, SQLException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
if (AuthorizeConfiguration.canCollectionAdminManagePolicies()) {
|
||||
authorizeService.authorizeAction(context, collection,
|
||||
Constants.ADMIN);
|
||||
@@ -161,7 +151,6 @@ public class AuthorizeUtil {
|
||||
*/
|
||||
public static void authorizeManageCommunityPolicy(Context context,
|
||||
Community community) throws AuthorizeException, SQLException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
if (AuthorizeConfiguration.canCommunityAdminManagePolicies()) {
|
||||
authorizeService.authorizeAction(context, community,
|
||||
Constants.ADMIN);
|
||||
@@ -182,7 +171,6 @@ public class AuthorizeUtil {
|
||||
*/
|
||||
public static void requireAdminRole(Context context)
|
||||
throws AuthorizeException, SQLException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
if (!authorizeService.isAdmin(context)) {
|
||||
throw new AuthorizeException(
|
||||
"Only system admin are allowed to perform this action");
|
||||
@@ -203,12 +191,9 @@ public class AuthorizeUtil {
|
||||
*/
|
||||
public static void authorizeManageCCLicense(Context context, Item item)
|
||||
throws AuthorizeException, SQLException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
|
||||
ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
try {
|
||||
authorizeService.authorizeAction(context, item, Constants.ADD, false);
|
||||
authorizeService.authorizeAction(context, item, Constants.REMOVE, false);
|
||||
authorizeService.authorizeAction(context, item, Constants.ADD);
|
||||
authorizeService.authorizeAction(context, item, Constants.REMOVE);
|
||||
} catch (AuthorizeException authex) {
|
||||
if (AuthorizeConfiguration.canItemAdminManageCCLicense()) {
|
||||
authorizeService
|
||||
@@ -217,10 +202,8 @@ public class AuthorizeUtil {
|
||||
authorizeService.authorizeAction(context, itemService
|
||||
.getParentObject(context, item), Constants.ADMIN);
|
||||
} else if (AuthorizeConfiguration.canCommunityAdminManageCCLicense()) {
|
||||
Collection collection = (Collection) itemService
|
||||
.getParentObject(context, item);
|
||||
authorizeService.authorizeAction(context, collectionService.getParentObject(context, collection),
|
||||
Constants.ADMIN);
|
||||
authorizeService.authorizeAction(context, itemService
|
||||
.getParentObject(context, item), Constants.ADMIN);
|
||||
} else {
|
||||
requireAdminRole(context);
|
||||
}
|
||||
@@ -241,8 +224,6 @@ public class AuthorizeUtil {
|
||||
*/
|
||||
public static void authorizeManageTemplateItem(Context context,
|
||||
Collection collection) throws AuthorizeException, SQLException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
|
||||
boolean isAuthorized = collectionService.canEditBoolean(context, collection, false);
|
||||
|
||||
if (!isAuthorized
|
||||
@@ -277,7 +258,6 @@ public class AuthorizeUtil {
|
||||
*/
|
||||
public static void authorizeManageSubmittersGroup(Context context,
|
||||
Collection collection) throws AuthorizeException, SQLException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
if (AuthorizeConfiguration.canCollectionAdminManageSubmitters()) {
|
||||
authorizeService.authorizeAction(context, collection,
|
||||
Constants.ADMIN);
|
||||
@@ -305,7 +285,6 @@ public class AuthorizeUtil {
|
||||
*/
|
||||
public static void authorizeManageWorkflowsGroup(Context context,
|
||||
Collection collection) throws AuthorizeException, SQLException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
if (AuthorizeConfiguration.canCollectionAdminManageWorkflows()) {
|
||||
authorizeService.authorizeAction(context, collection,
|
||||
Constants.ADMIN);
|
||||
@@ -334,7 +313,6 @@ public class AuthorizeUtil {
|
||||
*/
|
||||
public static void authorizeManageAdminGroup(Context context,
|
||||
Collection collection) throws AuthorizeException, SQLException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
if (AuthorizeConfiguration.canCollectionAdminManageAdminGroup()) {
|
||||
authorizeService.authorizeAction(context, collection,
|
||||
Constants.ADMIN);
|
||||
@@ -363,7 +341,6 @@ public class AuthorizeUtil {
|
||||
*/
|
||||
public static void authorizeRemoveAdminGroup(Context context,
|
||||
Collection collection) throws AuthorizeException, SQLException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
List<Community> parentCommunities = collection.getCommunities();
|
||||
if (AuthorizeConfiguration
|
||||
.canCommunityAdminManageCollectionAdminGroup()
|
||||
@@ -391,7 +368,6 @@ public class AuthorizeUtil {
|
||||
*/
|
||||
public static void authorizeManageAdminGroup(Context context,
|
||||
Community community) throws AuthorizeException, SQLException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
if (AuthorizeConfiguration.canCommunityAdminManageAdminGroup()) {
|
||||
authorizeService.authorizeAction(context, community,
|
||||
Constants.ADMIN);
|
||||
@@ -416,7 +392,6 @@ public class AuthorizeUtil {
|
||||
*/
|
||||
public static void authorizeRemoveAdminGroup(Context context,
|
||||
Community community) throws SQLException, AuthorizeException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
List<Community> parentCommunities = community.getParentCommunities();
|
||||
Community parentCommunity = null;
|
||||
if (0 < parentCommunities.size()) {
|
||||
@@ -483,7 +458,6 @@ public class AuthorizeUtil {
|
||||
public static void authorizeWithdrawItem(Context context, Item item)
|
||||
throws SQLException, AuthorizeException {
|
||||
boolean authorized = false;
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
if (AuthorizeConfiguration.canCollectionAdminPerformItemWithdrawn()) {
|
||||
authorized = authorizeService.authorizeActionBoolean(context, item
|
||||
.getOwningCollection(), Constants.ADMIN);
|
||||
@@ -518,7 +492,6 @@ public class AuthorizeUtil {
|
||||
*/
|
||||
public static void authorizeReinstateItem(Context context, Item item)
|
||||
throws SQLException, AuthorizeException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
List<Collection> colls = item.getCollections();
|
||||
|
||||
for (Collection coll : colls) {
|
||||
@@ -539,154 +512,4 @@ public class AuthorizeUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will check whether the current user is authorized to manage the default read group
|
||||
* @param context The relevant DSpace context
|
||||
* @param collection The collection for which this will be checked
|
||||
* @throws AuthorizeException If something goes wrong
|
||||
* @throws SQLException If something goes wrong
|
||||
*/
|
||||
public static void authorizeManageDefaultReadGroup(Context context,
|
||||
Collection collection) throws AuthorizeException, SQLException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
authorizeService.authorizeAction(context, collection, Constants.ADMIN);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks whether the current user has sufficient rights to modify the group.
|
||||
* Depending on the kind of group and due to delegated administration, separate checks need to be done to verify
|
||||
* whether the user is allowed to modify the group.
|
||||
*
|
||||
* @param context the context of which the user will be checked
|
||||
* @param group the group to be checked
|
||||
* @throws SQLException
|
||||
* @throws AuthorizeException
|
||||
*/
|
||||
public static void authorizeManageGroup(Context context, Group group) throws SQLException, AuthorizeException {
|
||||
AuthorizeService authorizeService = AuthorizeServiceFactory.getInstance().getAuthorizeService();
|
||||
GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();
|
||||
CollectionRoleService collectionRoleService = XmlWorkflowServiceFactory.getInstance()
|
||||
.getCollectionRoleService();
|
||||
if (authorizeService.isAdmin(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
DSpaceObject parentObject = groupService.getParentObject(context, group);
|
||||
if (parentObject == null) {
|
||||
throw new AuthorizeException("not authorized to manage this group");
|
||||
}
|
||||
if (parentObject.getType() == Constants.COLLECTION) {
|
||||
Collection collection = (Collection) parentObject;
|
||||
|
||||
if (group.equals(collection.getSubmitters())) {
|
||||
authorizeManageSubmittersGroup(context, collection);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
List<CollectionRole> collectionRoles = collectionRoleService.findByCollection(context, collection);
|
||||
for (CollectionRole role : collectionRoles) {
|
||||
if (group.equals(role.getGroup())) {
|
||||
authorizeManageWorkflowsGroup(context, collection);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (group.equals(collection.getAdministrators())) {
|
||||
authorizeManageAdminGroup(context, collection);
|
||||
return;
|
||||
}
|
||||
// if we reach this point, it means that the group is related
|
||||
// to a collection but as it is not the submitters, nor the administrators,
|
||||
// nor a workflow groups it must be a default item/bitstream groups
|
||||
authorizeManageDefaultReadGroup(context, collection);
|
||||
return;
|
||||
}
|
||||
if (parentObject.getType() == Constants.COMMUNITY) {
|
||||
Community community = (Community) parentObject;
|
||||
authorizeManageAdminGroup(context, community);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new AuthorizeException("not authorized to manage this group");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return a boolean indicating whether the current user is allowed to register a new
|
||||
* account or not
|
||||
* @param context The relevant DSpace context
|
||||
* @param request The current request
|
||||
* @return A boolean indicating whether the current user can register a new account or not
|
||||
* @throws SQLException If something goes wrong
|
||||
*/
|
||||
public static boolean authorizeNewAccountRegistration(Context context, HttpServletRequest request)
|
||||
throws SQLException {
|
||||
if (DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||
.getBooleanProperty("user.registration", true)) {
|
||||
// This allowSetPassword is currently the only mthod that would return true only when it's
|
||||
// actually expected to be returning true.
|
||||
// For example the LDAP canSelfRegister will return true due to auto-register, while that
|
||||
// does not imply a new user can register explicitly
|
||||
return AuthenticateServiceFactory.getInstance().getAuthenticationService()
|
||||
.allowSetPassword(context, request, null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will return a boolean indicating whether it's allowed to update the password for the EPerson
|
||||
* with the given email and canLogin property
|
||||
* @param context The relevant DSpace context
|
||||
* @param email The email to be checked
|
||||
* @return A boolean indicating if the password can be updated or not
|
||||
*/
|
||||
public static boolean authorizeUpdatePassword(Context context, String email) {
|
||||
try {
|
||||
EPerson eperson = EPersonServiceFactory.getInstance().getEPersonService().findByEmail(context, email);
|
||||
if (eperson != null && eperson.canLogIn()) {
|
||||
HttpServletRequest request = new DSpace().getRequestService().getCurrentRequest()
|
||||
.getHttpServletRequest();
|
||||
return AuthenticateServiceFactory.getInstance().getAuthenticationService()
|
||||
.allowSetPassword(context, request, null);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error("Something went wrong trying to retrieve EPerson for email: " + email, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks if the community Admin can manage accounts
|
||||
*
|
||||
* @return true if is able
|
||||
*/
|
||||
public static boolean canCommunityAdminManageAccounts() {
|
||||
boolean isAble = false;
|
||||
if (AuthorizeConfiguration.canCommunityAdminManagePolicies()
|
||||
|| AuthorizeConfiguration.canCommunityAdminManageAdminGroup()
|
||||
|| AuthorizeConfiguration.canCommunityAdminManageCollectionPolicies()
|
||||
|| AuthorizeConfiguration.canCommunityAdminManageCollectionSubmitters()
|
||||
|| AuthorizeConfiguration.canCommunityAdminManageCollectionWorkflows()
|
||||
|| AuthorizeConfiguration.canCommunityAdminManageCollectionAdminGroup()) {
|
||||
isAble = true;
|
||||
}
|
||||
return isAble;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks if the Collection Admin can manage accounts
|
||||
*
|
||||
* @return true if is able
|
||||
*/
|
||||
public static boolean canCollectionAdminManageAccounts() {
|
||||
boolean isAble = false;
|
||||
if (AuthorizeConfiguration.canCollectionAdminManagePolicies()
|
||||
|| AuthorizeConfiguration.canCollectionAdminManageSubmitters()
|
||||
|| AuthorizeConfiguration.canCollectionAdminManageWorkflows()
|
||||
|| AuthorizeConfiguration.canCollectionAdminManageAdminGroup()) {
|
||||
isAble = true;
|
||||
}
|
||||
return isAble;
|
||||
}
|
||||
}
|
||||
|
@@ -1,58 +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.app.util;
|
||||
|
||||
import net.sf.ehcache.Cache;
|
||||
import net.sf.ehcache.CacheManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.servicemanager.DSpaceKernelImpl;
|
||||
import org.dspace.servicemanager.DSpaceKernelInit;
|
||||
import org.dspace.services.CachingService;
|
||||
|
||||
/**
|
||||
* List all EhCache CacheManager and Cache instances.
|
||||
*
|
||||
* <p>This is a debugging tool, not used in the daily operation of DSpace.
|
||||
* Just run it from the installed instance using
|
||||
* {@code bin/dspace dsrun org.dspace.app.util.CacheSnooper}
|
||||
* to check that the cache configuration is what you expect it to be,
|
||||
* given your configuration.
|
||||
*
|
||||
* <p>This was created to prove a specific cache configuration patch,
|
||||
* but I leave it here in the hope that it may be useful to others.
|
||||
*
|
||||
* @author Mark H. Wood <mwood@iupui.edu>
|
||||
*/
|
||||
public class CacheSnooper {
|
||||
private CacheSnooper() { }
|
||||
|
||||
public static void main(String[] argv) {
|
||||
// Ensure that the DSpace kernel is started.
|
||||
DSpaceKernelImpl kernel = DSpaceKernelInit.getKernel(null);
|
||||
|
||||
// Ensure that the services cache manager is started.
|
||||
CachingService serviceCaches = kernel.getServiceManager()
|
||||
.getServiceByName(null, CachingService.class);
|
||||
|
||||
// Ensure that the database layer is started.
|
||||
Context ctx = new Context();
|
||||
|
||||
// List those caches!
|
||||
for (CacheManager manager : CacheManager.ALL_CACHE_MANAGERS) {
|
||||
System.out.format("CacheManager: %s%n", manager);
|
||||
for (String cacheName : manager.getCacheNames()) {
|
||||
Cache cache = manager.getCache(cacheName);
|
||||
System.out.format(" Cache: '%s'; maxHeap: %d; maxDisk: %d%n",
|
||||
cacheName,
|
||||
cache.getCacheConfiguration().getMaxEntriesLocalHeap(),
|
||||
cache.getCacheConfiguration().getMaxEntriesLocalDisk());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -12,10 +12,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.core.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -64,12 +63,6 @@ public class DCInput {
|
||||
*/
|
||||
private String label = null;
|
||||
|
||||
/**
|
||||
* a style instruction to apply to the input. The exact way to use the style value is UI depending that receive the
|
||||
* value from the REST API as is
|
||||
*/
|
||||
private String style = null;
|
||||
|
||||
/**
|
||||
* the input type
|
||||
*/
|
||||
@@ -90,11 +83,6 @@ public class DCInput {
|
||||
*/
|
||||
private boolean repeatable = false;
|
||||
|
||||
/**
|
||||
* should name-variants be used?
|
||||
*/
|
||||
private boolean nameVariants = false;
|
||||
|
||||
/**
|
||||
* 'hint' text to display
|
||||
*/
|
||||
@@ -140,12 +128,6 @@ public class DCInput {
|
||||
*/
|
||||
private List<String> typeBind = null;
|
||||
|
||||
private boolean isRelationshipField = false;
|
||||
private boolean isMetadataField = false;
|
||||
private String relationshipType = null;
|
||||
private String searchConfiguration = null;
|
||||
private String filter;
|
||||
|
||||
/**
|
||||
* The scope of the input sets, this restricts hidden metadata fields from
|
||||
* view during workflow processing.
|
||||
@@ -172,7 +154,7 @@ public class DCInput {
|
||||
// Default the schema to dublin core
|
||||
dcSchema = fieldMap.get("dc-schema");
|
||||
if (dcSchema == null) {
|
||||
dcSchema = MetadataSchemaEnum.DC.getName();
|
||||
dcSchema = MetadataSchema.DC_SCHEMA;
|
||||
}
|
||||
|
||||
//check if the input have a language tag
|
||||
@@ -189,9 +171,6 @@ public class DCInput {
|
||||
String repStr = fieldMap.get("repeatable");
|
||||
repeatable = "true".equalsIgnoreCase(repStr)
|
||||
|| "yes".equalsIgnoreCase(repStr);
|
||||
String nameVariantsString = fieldMap.get("name-variants");
|
||||
nameVariants = (StringUtils.isNotBlank(nameVariantsString)) ?
|
||||
nameVariantsString.equalsIgnoreCase("true") : false;
|
||||
label = fieldMap.get("label");
|
||||
inputType = fieldMap.get("input-type");
|
||||
// these types are list-controlled
|
||||
@@ -220,12 +199,7 @@ public class DCInput {
|
||||
typeBind.add(type.trim());
|
||||
}
|
||||
}
|
||||
style = fieldMap.get("style");
|
||||
isRelationshipField = fieldMap.containsKey("relationship-type");
|
||||
isMetadataField = fieldMap.containsKey("dc-schema");
|
||||
relationshipType = fieldMap.get("relationship-type");
|
||||
searchConfiguration = fieldMap.get("search-configuration");
|
||||
filter = fieldMap.get("filter");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,26 +252,17 @@ public class DCInput {
|
||||
return isRepeatable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the nameVariants flag for this row
|
||||
*
|
||||
* @return the nameVariants flag
|
||||
*/
|
||||
public boolean areNameVariantsAllowed() {
|
||||
return nameVariants;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the input type for this row
|
||||
*
|
||||
* @return the input type
|
||||
*/
|
||||
public @Nullable String getInputType() {
|
||||
public String getInputType() {
|
||||
return inputType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DC element for this form field.
|
||||
* Get the DC element for this form row.
|
||||
*
|
||||
* @return the DC element
|
||||
*/
|
||||
@@ -306,7 +271,7 @@ public class DCInput {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DC namespace prefix for this form field.
|
||||
* Get the DC namespace prefix for this form row.
|
||||
*
|
||||
* @return the DC namespace prefix
|
||||
*/
|
||||
@@ -325,7 +290,7 @@ public class DCInput {
|
||||
}
|
||||
|
||||
/**
|
||||
* Is there a required string for this form field?
|
||||
* Is there a required string for this form row?
|
||||
*
|
||||
* @return true if a required string is set
|
||||
*/
|
||||
@@ -334,7 +299,7 @@ public class DCInput {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DC qualifier for this form field.
|
||||
* Get the DC qualifier for this form row.
|
||||
*
|
||||
* @return the DC qualifier
|
||||
*/
|
||||
@@ -343,7 +308,7 @@ public class DCInput {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the language for this form field.
|
||||
* Get the language for this form row.
|
||||
*
|
||||
* @return the language state
|
||||
*/
|
||||
@@ -352,7 +317,7 @@ public class DCInput {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hint for this form field
|
||||
* Get the hint for this form row, formatted for an HTML table
|
||||
*
|
||||
* @return the hints
|
||||
*/
|
||||
@@ -361,7 +326,7 @@ public class DCInput {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label for this form field.
|
||||
* Get the label for this form row.
|
||||
*
|
||||
* @return the label
|
||||
*/
|
||||
@@ -369,15 +334,6 @@ public class DCInput {
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the style for this form field
|
||||
*
|
||||
* @return the style
|
||||
*/
|
||||
public String getStyle() {
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the pairs type
|
||||
*
|
||||
@@ -510,18 +466,6 @@ public class DCInput {
|
||||
return Utils.standardize(this.getSchema(), this.getElement(), this.getQualifier(), ".");
|
||||
}
|
||||
|
||||
public String getRelationshipType() {
|
||||
return relationshipType;
|
||||
}
|
||||
|
||||
public String getSearchConfiguration() {
|
||||
return searchConfiguration;
|
||||
}
|
||||
|
||||
public String getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public boolean isQualdropValue() {
|
||||
if ("qualdrop_value".equals(getInputType())) {
|
||||
return true;
|
||||
@@ -546,22 +490,4 @@ public class DCInput {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify whether the current field contains an entity relationship
|
||||
* This also implies a relationship type is defined for this field
|
||||
* The field can contain both an entity relationship and a metadata field simultaneously
|
||||
*/
|
||||
public boolean isRelationshipField() {
|
||||
return isRelationshipField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify whether the current field contains a metadata field
|
||||
* This also implies a field type is defined for this field
|
||||
* The field can contain both an entity relationship and a metadata field simultaneously
|
||||
*/
|
||||
public boolean isMetadataField() {
|
||||
return isMetadataField;
|
||||
}
|
||||
}
|
||||
|
@@ -10,8 +10,6 @@ package org.dspace.app.util;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.core.Utils;
|
||||
/**
|
||||
* Class representing all DC inputs required for a submission, organized into pages
|
||||
*
|
||||
@@ -27,26 +25,25 @@ public class DCInputSet {
|
||||
/**
|
||||
* the inputs ordered by row position
|
||||
*/
|
||||
private DCInput[][] inputs = null;
|
||||
private DCInput[] inputs = null;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
* @param formName form name
|
||||
* @param headings
|
||||
* @param mandatoryFlags
|
||||
* @param rows the rows
|
||||
* @param fields fields
|
||||
* @param listMap map
|
||||
*/
|
||||
public DCInputSet(String formName, List<List<Map<String, String>>> rows, Map<String, List<String>> listMap) {
|
||||
public DCInputSet(String formName,
|
||||
List<Map<String, String>> fields, Map<String, List<String>> listMap) {
|
||||
this.formName = formName;
|
||||
this.inputs = new DCInput[rows.size()][];
|
||||
this.inputs = new DCInput[fields.size()];
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
List<Map<String, String>> fields = rows.get(i);
|
||||
inputs[i] = new DCInput[fields.size()];
|
||||
for (int j = 0; j < inputs[i].length; j++) {
|
||||
Map<String, String> field = rows.get(i).get(j);
|
||||
inputs[i][j] = new DCInput(field, listMap);
|
||||
}
|
||||
Map<String, String> field = fields.get(i);
|
||||
inputs[i] = new DCInput(field, listMap);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +71,7 @@ public class DCInputSet {
|
||||
* @return an array containing the fields
|
||||
*/
|
||||
|
||||
public DCInput[][] getFields() {
|
||||
public DCInput[] getFields() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@@ -107,24 +104,10 @@ public class DCInputSet {
|
||||
*/
|
||||
public boolean isFieldPresent(String fieldName) {
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
for (int j = 0; j < inputs[i].length; j++) {
|
||||
DCInput field = inputs[i][j];
|
||||
// If this is a "qualdrop_value" field, then the full field name is the field + dropdown qualifier
|
||||
if (StringUtils.equals(field.getInputType(), "qualdrop_value")) {
|
||||
List<String> pairs = field.getPairs();
|
||||
for (int k = 0; k < pairs.size(); k += 2) {
|
||||
String qualifier = pairs.get(k + 1);
|
||||
String fullName = Utils.standardize(field.getSchema(), field.getElement(), qualifier, ".");
|
||||
if (fullName.equals(fieldName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String fullName = field.getFieldName();
|
||||
if (fullName.equals(fieldName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
DCInput field = inputs[i];
|
||||
String fullName = field.getFieldName();
|
||||
if (fullName.equals(fieldName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -144,13 +127,11 @@ public class DCInputSet {
|
||||
documentType = "";
|
||||
}
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
for (int j = 0; j < inputs[i].length; j++) {
|
||||
DCInput field = inputs[i][j];
|
||||
String fullName = field.getFieldName();
|
||||
if (fullName.equals(fieldName)) {
|
||||
if (field.isAllowedFor(documentType)) {
|
||||
return true;
|
||||
}
|
||||
DCInput field = inputs[i];
|
||||
String fullName = field.getFieldName();
|
||||
if (fullName.equals(fieldName)) {
|
||||
if (field.isAllowedFor(documentType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ import javax.xml.parsers.FactoryConfigurationError;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.MetadataSchemaEnum;
|
||||
import org.dspace.content.MetadataSchema;
|
||||
import org.dspace.core.Utils;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.w3c.dom.Document;
|
||||
@@ -74,7 +74,7 @@ public class DCInputsReader {
|
||||
* Reference to the forms definitions map, computed from the forms
|
||||
* definition file
|
||||
*/
|
||||
private Map<String, List<List<Map<String, String>>>> formDefns = null;
|
||||
private Map<String, List<Map<String, String>>> formDefns = null;
|
||||
|
||||
/**
|
||||
* Reference to the value-pairs map, computed from the forms definition file
|
||||
@@ -115,7 +115,7 @@ public class DCInputsReader {
|
||||
|
||||
private void buildInputs(String fileName)
|
||||
throws DCInputsReaderException {
|
||||
formDefns = new HashMap<String, List<List<Map<String, String>>>>();
|
||||
formDefns = new HashMap<String, List<Map<String, String>>>();
|
||||
valuePairs = new HashMap<String, List<String>>();
|
||||
|
||||
String uri = "file:" + new File(fileName).getAbsolutePath();
|
||||
@@ -212,7 +212,7 @@ public class DCInputsReader {
|
||||
return lastInputSet;
|
||||
}
|
||||
// cache miss - construct new DCInputSet
|
||||
List<List<Map<String, String>>> pages = formDefns.get(formName);
|
||||
List<Map<String, String>> pages = formDefns.get(formName);
|
||||
if (pages == null) {
|
||||
throw new DCInputsReaderException("Missing the " + formName + " form");
|
||||
}
|
||||
@@ -292,8 +292,8 @@ public class DCInputsReader {
|
||||
|
||||
/**
|
||||
* Process the form-definitions section of the XML file. Each element is
|
||||
* formed thusly: <form name="formname">...row...</form> Each rows
|
||||
* subsection is formed: <row> ...fields... </row> Each field
|
||||
* formed thusly: <form name="formname">...pages...</form> Each pages
|
||||
* subsection is formed: <page number="#"> ...fields... </page> Each field
|
||||
* is formed from: dc-element, dc-qualifier, label, hint, input-type name,
|
||||
* required text, and repeatable flag.
|
||||
*/
|
||||
@@ -311,24 +311,26 @@ public class DCInputsReader {
|
||||
if (formName == null) {
|
||||
throw new SAXException("form element has no name attribute");
|
||||
}
|
||||
List<List<Map<String, String>>> rows = new ArrayList<List<Map<String, String>>>(); // the form
|
||||
// contains rows of fields
|
||||
formDefns.put(formName, rows);
|
||||
List<Map<String, String>> fields = new ArrayList<Map<String, String>>(); // the form contains fields
|
||||
formDefns.put(formName, fields);
|
||||
NodeList pl = nd.getChildNodes();
|
||||
int lenpg = pl.getLength();
|
||||
for (int j = 0; j < lenpg; j++) {
|
||||
Node npg = pl.item(j);
|
||||
if (npg.getNodeName().equals("row")) {
|
||||
List<Map<String, String>> fields = new ArrayList<Map<String, String>>(); // the fields in the
|
||||
// row
|
||||
// process each row definition
|
||||
processRow(formName, j, npg, fields);
|
||||
rows.add(fields);
|
||||
|
||||
if (npg.getNodeName().equals("field")) {
|
||||
// process each field definition
|
||||
Map<String, String> field = new HashMap<String, String>();
|
||||
processField(formName, npg, field);
|
||||
fields.add(field);
|
||||
// we omit the duplicate validation, allowing multiple
|
||||
// fields definition for
|
||||
// the same metadata and different visibility/type-bind
|
||||
}
|
||||
}
|
||||
// sanity check number of fields
|
||||
if (rows.size() < 1) {
|
||||
throw new DCInputsReaderException("Form " + formName + " has no rows");
|
||||
if (fields.size() < 1) {
|
||||
throw new DCInputsReaderException("Form " + formName + " has no fields");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -337,52 +339,6 @@ public class DCInputsReader {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process parts of a row
|
||||
*/
|
||||
private void processRow(String formName, int rowIdx, Node n, List<Map<String, String>> fields)
|
||||
throws SAXException, DCInputsReaderException {
|
||||
|
||||
NodeList pl = n.getChildNodes();
|
||||
int lenpg = pl.getLength();
|
||||
for (int j = 0; j < lenpg; j++) {
|
||||
Node npg = pl.item(j);
|
||||
|
||||
if (npg.getNodeName().equals("field")) {
|
||||
// process each field definition
|
||||
Map<String, String> field = new HashMap<String, String>();
|
||||
processField(formName, npg, field);
|
||||
fields.add(field);
|
||||
String key = field.get(PAIR_TYPE_NAME);
|
||||
if (StringUtils
|
||||
.isNotBlank(key)) {
|
||||
String schema = field.get("dc-schema");
|
||||
String element = field.get("dc-element");
|
||||
String qualifier = field
|
||||
.get("dc-qualifier");
|
||||
String metadataField = schema + "."
|
||||
+ element;
|
||||
if (StringUtils.isNotBlank(qualifier)) {
|
||||
metadataField += "." + qualifier;
|
||||
}
|
||||
}
|
||||
// we omit the duplicate validation, allowing multiple
|
||||
// fields definition for
|
||||
// the same metadata and different visibility/type-bind
|
||||
} else if (StringUtils.equalsIgnoreCase(npg.getNodeName(), "relation-field")) {
|
||||
Map<String, String> relationField = new HashMap<>();
|
||||
processField(formName, npg, relationField);
|
||||
fields.add(relationField);
|
||||
}
|
||||
|
||||
}
|
||||
// sanity check number of fields
|
||||
if (fields.size() < 1) {
|
||||
throw new DCInputsReaderException("Form " + formName + "row " + rowIdx + " has no fields");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process parts of a field
|
||||
* At the end, make sure that input-types 'qualdrop_value' and
|
||||
@@ -400,7 +356,19 @@ public class DCInputsReader {
|
||||
String value = getValue(nd);
|
||||
field.put(tagName, value);
|
||||
if (tagName.equals("input-type")) {
|
||||
handleInputTypeTagName(formName, field, nd, value);
|
||||
if (value.equals("dropdown")
|
||||
|| value.equals("qualdrop_value")
|
||||
|| value.equals("list")) {
|
||||
String pairTypeName = getAttribute(nd, PAIR_TYPE_NAME);
|
||||
if (pairTypeName == null) {
|
||||
throw new SAXException("Form " + formName + ", field " +
|
||||
field.get("dc-element") +
|
||||
"." + field.get("dc-qualifier") +
|
||||
" has no name attribute");
|
||||
} else {
|
||||
field.put(PAIR_TYPE_NAME, pairTypeName);
|
||||
}
|
||||
}
|
||||
} else if (tagName.equals("vocabulary")) {
|
||||
String closedVocabularyString = getAttribute(nd, "closed");
|
||||
field.put("closedVocabulary", closedVocabularyString);
|
||||
@@ -416,30 +384,17 @@ public class DCInputsReader {
|
||||
field.put(PAIR_TYPE_NAME, pairTypeName);
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(tagName, "linked-metadata-field")) {
|
||||
for (int j = 0; j < nd.getChildNodes().getLength(); j ++) {
|
||||
Node nestedNode = nd.getChildNodes().item(j);
|
||||
String nestedTagName = nestedNode.getNodeName();
|
||||
String nestedValue = getValue(nestedNode);
|
||||
field.put(nestedTagName, nestedValue);
|
||||
if (nestedTagName.equals("input-type")) {
|
||||
handleInputTypeTagName(formName, field, nestedNode, nestedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
String missing = null;
|
||||
String nodeName = n.getNodeName();
|
||||
if (field.get("dc-element") == null &&
|
||||
(nodeName.equals("field") || field.containsKey("linked-metadata-field"))) {
|
||||
if (field.get("dc-element") == null) {
|
||||
missing = "dc-element";
|
||||
}
|
||||
if (field.get("label") == null) {
|
||||
missing = "label";
|
||||
}
|
||||
if (field.get("input-type") == null &&
|
||||
(nodeName.equals("field") || field.containsKey("linked-metadata-field"))) {
|
||||
if (field.get("input-type") == null) {
|
||||
missing = "input-type";
|
||||
}
|
||||
if (missing != null) {
|
||||
@@ -447,7 +402,7 @@ public class DCInputsReader {
|
||||
throw new SAXException(msg);
|
||||
}
|
||||
String type = field.get("input-type");
|
||||
if (StringUtils.isNotBlank(type) && (type.equals("twobox") || type.equals("qualdrop_value"))) {
|
||||
if (type.equals("twobox") || type.equals("qualdrop_value")) {
|
||||
String rpt = field.get("repeatable");
|
||||
if ((rpt == null) ||
|
||||
((!rpt.equalsIgnoreCase("yes")) &&
|
||||
@@ -458,23 +413,6 @@ public class DCInputsReader {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleInputTypeTagName(String formName, Map<String, String> field, Node nd, String value)
|
||||
throws SAXException {
|
||||
if (value.equals("dropdown")
|
||||
|| value.equals("qualdrop_value")
|
||||
|| value.equals("list")) {
|
||||
String pairTypeName = getAttribute(nd, PAIR_TYPE_NAME);
|
||||
if (pairTypeName == null) {
|
||||
throw new SAXException("Form " + formName + ", field " +
|
||||
field.get("dc-element") +
|
||||
"." + field.get("dc-qualifier") +
|
||||
" has no name attribute");
|
||||
} else {
|
||||
field.put(PAIR_TYPE_NAME, pairTypeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that this is the only field with the name dc-element.dc-qualifier
|
||||
* If there is a duplicate, return an error message, else return null;
|
||||
@@ -486,7 +424,7 @@ public class DCInputsReader {
|
||||
String elem = field.get("dc-element");
|
||||
String qual = field.get("dc-qualifier");
|
||||
if ((schema == null) || (schema.equals(""))) {
|
||||
schema = MetadataSchemaEnum.DC.getName();
|
||||
schema = MetadataSchema.DC_SCHEMA;
|
||||
}
|
||||
String schemaTest;
|
||||
|
||||
@@ -496,7 +434,7 @@ public class DCInputsReader {
|
||||
Map<String, String> fld = pg.get(j);
|
||||
if ((fld.get("dc-schema") == null) ||
|
||||
((fld.get("dc-schema")).equals(""))) {
|
||||
schemaTest = MetadataSchemaEnum.DC.getName();
|
||||
schemaTest = MetadataSchema.DC_SCHEMA;
|
||||
} else {
|
||||
schemaTest = fld.get("dc-schema");
|
||||
}
|
||||
@@ -599,29 +537,26 @@ public class DCInputsReader {
|
||||
Iterator<String> ki = formDefns.keySet().iterator();
|
||||
while (ki.hasNext()) {
|
||||
String idName = ki.next();
|
||||
List<List<Map<String, String>>> rows = formDefns.get(idName);
|
||||
for (int j = 0; j < rows.size(); j++) {
|
||||
List<Map<String, String>> fields = rows.get(j);
|
||||
for (int i = 0; i < fields.size(); i++) {
|
||||
Map<String, String> fld = fields.get(i);
|
||||
// verify reference in certain input types
|
||||
String type = fld.get("input-type");
|
||||
if (StringUtils.isNotBlank(type) && (type.equals("dropdown")
|
||||
|| type.equals("qualdrop_value")
|
||||
|| type.equals("list"))) {
|
||||
String pairsName = fld.get(PAIR_TYPE_NAME);
|
||||
List<String> v = valuePairs.get(pairsName);
|
||||
if (v == null) {
|
||||
String errString = "Cannot find value pairs for " + pairsName;
|
||||
throw new DCInputsReaderException(errString);
|
||||
}
|
||||
List<Map<String, String>> fields = formDefns.get(idName);
|
||||
for (int i = 0; i < fields.size(); i++) {
|
||||
Map<String, String> fld = fields.get(i);
|
||||
// verify reference in certain input types
|
||||
String type = fld.get("input-type");
|
||||
if (type.equals("dropdown")
|
||||
|| type.equals("qualdrop_value")
|
||||
|| type.equals("list")) {
|
||||
String pairsName = fld.get(PAIR_TYPE_NAME);
|
||||
List<String> v = valuePairs.get(pairsName);
|
||||
if (v == null) {
|
||||
String errString = "Cannot find value pairs for " + pairsName;
|
||||
throw new DCInputsReaderException(errString);
|
||||
}
|
||||
|
||||
// we omit the "required" and "visibility" validation, provided this must be checked in the
|
||||
// processing class
|
||||
// only when it makes sense (if the field isn't visible means that it is not applicable,
|
||||
// therefore it can't be required)
|
||||
}
|
||||
|
||||
// we omit the "required" and "visibility" validation, provided this must be checked in the
|
||||
// processing class
|
||||
// only when it makes sense (if the field isn't visible means that it is not applicable, therefore it
|
||||
// can't be required)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -704,5 +639,4 @@ public class DCInputsReader {
|
||||
}
|
||||
throw new DCInputsReaderException("No field configuration found!");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -16,14 +16,14 @@ import java.util.Enumeration;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Class to initialize / cleanup resources used by DSpace when the web application
|
||||
* is started or stopped.
|
||||
*/
|
||||
public class DSpaceContextListener implements ServletContextListener {
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(DSpaceContextListener.class);
|
||||
private static Logger log = Logger.getLogger(DSpaceContextListener.class);
|
||||
|
||||
/**
|
||||
* Initialize any resources required by the application.
|
||||
|
@@ -0,0 +1,299 @@
|
||||
/**
|
||||
* 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.app.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.apache.log4j.FileAppender;
|
||||
import org.apache.log4j.helpers.LogLog;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
|
||||
/**
|
||||
* Special log appender for log4j. Adds the current date (ie. year-mon) to
|
||||
* the end of the file name, so that rolling on to the next log is simply
|
||||
* a case of starting a new one - no renaming of old logs.
|
||||
*
|
||||
* This is advisable if you are using Windows, and have multiple applications
|
||||
* (ie. dspace, dspace-oai, dspace-sword) that all want to write to the same log file,
|
||||
* as each would otherwise try to rename the old files during rollover.
|
||||
*
|
||||
* An example log4j.properties (one log per month, retains three months of logs)
|
||||
*
|
||||
* log4j.rootCategory=INFO, A1
|
||||
* log4j.appender.A1=org.dspace.app.util.DailyFileAppender
|
||||
* log4j.appender.A1.File=@@log.dir@@/dspace.log
|
||||
* log4j.appender.A1.DatePattern=yyyy-MM
|
||||
* log4j.appender.A1.MaxLogs=3
|
||||
* log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
||||
* log4j.appender.A1.layout.ConversionPattern=%d %-5p %c @ %m%n
|
||||
*/
|
||||
public class DailyFileAppender extends FileAppender {
|
||||
/**
|
||||
* The fixed date pattern to be used if one is not specified.
|
||||
*/
|
||||
private static final String DATE_PATTERN = "yyyy-MM-dd";
|
||||
|
||||
/**
|
||||
* The folder under which daily folders are created. This can be a absolute path
|
||||
* or relative path also.
|
||||
* e.g. JavaLogs/CPRILog or F:/LogFiles/CPRILog
|
||||
*/
|
||||
private String mstrFileName;
|
||||
|
||||
/**
|
||||
* Used internally and contains the name of the date derived from current system date.
|
||||
*/
|
||||
private Date mstrDate = new Date(System.currentTimeMillis());
|
||||
|
||||
/**
|
||||
* Holds the user specified DatePattern,
|
||||
*/
|
||||
private String mstrDatePattern = DATE_PATTERN;
|
||||
|
||||
private boolean mMonthOnly = false;
|
||||
|
||||
/**
|
||||
* The date formatter object used for parsing the user specified DatePattern.
|
||||
*/
|
||||
private SimpleDateFormat mobjSDF;
|
||||
|
||||
private boolean mWithHostName = false;
|
||||
|
||||
private int mMaxLogs = 0;
|
||||
|
||||
/**
|
||||
* Default constructor. This is required as the appender class is dynamically
|
||||
* loaded.
|
||||
*/
|
||||
public DailyFileAppender() {
|
||||
super();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.log4j.FileAppender#activateOptions()
|
||||
*/
|
||||
@Override
|
||||
public void activateOptions() {
|
||||
setFileName();
|
||||
cleanupOldFiles();
|
||||
super.activateOptions();
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Getters
|
||||
*----------------------------------------------------------------------------*/
|
||||
public String getDatePattern() {
|
||||
return this.mstrDatePattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFile() {
|
||||
return this.mstrFileName;
|
||||
}
|
||||
|
||||
public boolean getWithHost() {
|
||||
return mWithHostName;
|
||||
}
|
||||
|
||||
public int getMaxLogs() {
|
||||
return mMaxLogs;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Setters
|
||||
*----------------------------------------------------------------------------*/
|
||||
public void setDatePattern(String pstrPattern) {
|
||||
this.mstrDatePattern = checkPattern(pstrPattern);
|
||||
if (mstrDatePattern.contains("dd") || mstrDatePattern.contains("DD")) {
|
||||
mMonthOnly = false;
|
||||
} else {
|
||||
mMonthOnly = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFile(String file) {
|
||||
// Trim spaces from both ends. The users probably does not want
|
||||
// trailing spaces in file names.
|
||||
String val = file.trim();
|
||||
mstrFileName = val;
|
||||
}
|
||||
|
||||
public void setWithHost(boolean wh) {
|
||||
mWithHostName = wh;
|
||||
}
|
||||
|
||||
public void setMaxLogs(int ml) {
|
||||
mMaxLogs = ml;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Methods
|
||||
*----------------------------------------------------------------------------*/
|
||||
/* (non-Javadoc)
|
||||
* @see org.apache.log4j.WriterAppender#subAppend(org.apache.log4j.spi.LoggingEvent)
|
||||
*/
|
||||
@Override
|
||||
protected void subAppend(LoggingEvent pobjEvent) {
|
||||
Date dtNow = new Date(System.currentTimeMillis());
|
||||
|
||||
boolean rollover = false;
|
||||
|
||||
if (mMonthOnly) {
|
||||
Calendar now = Calendar.getInstance();
|
||||
Calendar cur = Calendar.getInstance();
|
||||
now.setTime(dtNow);
|
||||
cur.setTime(mstrDate);
|
||||
rollover = !(now.get(Calendar.YEAR) == cur.get(Calendar.YEAR) && now.get(Calendar.MONTH) == cur
|
||||
.get(Calendar.MONTH));
|
||||
} else {
|
||||
rollover = !(DateUtils.isSameDay(dtNow, mstrDate));
|
||||
}
|
||||
|
||||
if (rollover) {
|
||||
try {
|
||||
rollOver(dtNow);
|
||||
} catch (IOException IOEx) {
|
||||
LogLog.error("rollOver() failed!", IOEx);
|
||||
}
|
||||
}
|
||||
|
||||
super.subAppend(pobjEvent);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Helpers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* The helper function to validate the DatePattern.
|
||||
*
|
||||
* @param pstrPattern The DatePattern to be validated.
|
||||
* @return The validated date pattern or defautlt DATE_PATTERN
|
||||
*/
|
||||
private String checkPattern(String pstrPattern) {
|
||||
String strRet = null;
|
||||
SimpleDateFormat objFmt = new SimpleDateFormat(DATE_PATTERN);
|
||||
|
||||
try {
|
||||
this.mobjSDF = new SimpleDateFormat(pstrPattern);
|
||||
strRet = pstrPattern;
|
||||
} catch (NullPointerException NPExIgnore) {
|
||||
LogLog.error("Invalid DatePattern " + pstrPattern, NPExIgnore);
|
||||
this.mobjSDF = objFmt;
|
||||
strRet = DATE_PATTERN;
|
||||
} catch (IllegalArgumentException IlArgExIgnore) {
|
||||
LogLog.error("Invalid DatePattern " + pstrPattern, IlArgExIgnore);
|
||||
this.mobjSDF = objFmt;
|
||||
strRet = DATE_PATTERN;
|
||||
} finally {
|
||||
objFmt = null;
|
||||
}
|
||||
return strRet;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is responsible for performing the actual file rollover.
|
||||
*
|
||||
* @param pstrName The name of the new folder based on current system date.
|
||||
* @throws IOException if IO error
|
||||
*/
|
||||
private static boolean deletingFiles = false;
|
||||
|
||||
private void cleanupOldFiles() {
|
||||
// If we need to delete log files
|
||||
if (mMaxLogs > 0 && !deletingFiles) {
|
||||
deletingFiles = true;
|
||||
|
||||
// Determine the final file extension with the hostname
|
||||
String hostFileExt = null;
|
||||
try {
|
||||
hostFileExt = "." + java.net.InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
LogLog.error("Unable to retrieve host name");
|
||||
}
|
||||
|
||||
try {
|
||||
// Array to hold the logs we are going to keep
|
||||
File[] logsToKeep = new File[mMaxLogs];
|
||||
|
||||
// Get a 'master' file handle, and the parent directory from it
|
||||
File logMaster = new File(mstrFileName);
|
||||
File logDir = logMaster.getParentFile();
|
||||
if (logDir.isDirectory()) {
|
||||
// Iterate all the files in that directory
|
||||
File[] logArr = logDir.listFiles();
|
||||
for (File curLog : logArr) {
|
||||
LogLog.debug("Comparing '" + curLog.getAbsolutePath() + "' to '" + mstrFileName + "'");
|
||||
String name = curLog.getAbsolutePath();
|
||||
|
||||
// First, see if we are not using hostname, or the log file ends with this host
|
||||
if (!mWithHostName || (hostFileExt != null && name.endsWith(hostFileExt))) {
|
||||
// Check that the file is indeed one we want (contains the master file name)
|
||||
if (name.contains(mstrFileName)) {
|
||||
// Iterate through the array of logs we are keeping
|
||||
for (int i = 0; curLog != null && i < logsToKeep.length; i++) {
|
||||
// Have we exhausted the 'to keep' array?
|
||||
if (logsToKeep[i] == null) {
|
||||
// Empty space, retain this log file
|
||||
logsToKeep[i] = curLog;
|
||||
curLog = null;
|
||||
} else if (logsToKeep[i].getName().compareTo(curLog.getName()) < 0) {
|
||||
// If the 'kept' file is older than the current one
|
||||
// Replace tested entry with current file
|
||||
File temp = logsToKeep[i];
|
||||
logsToKeep[i] = curLog;
|
||||
curLog = temp;
|
||||
}
|
||||
}
|
||||
|
||||
// If we have a 'current' entry at this point, it's a log we don't want
|
||||
if (curLog != null) {
|
||||
LogLog.debug("Deleting log " + curLog.getName());
|
||||
if (!curLog.delete()) {
|
||||
LogLog.error("Unable to delete log file");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Don't worry about exceptions
|
||||
} finally {
|
||||
deletingFiles = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void rollOver(Date dtNow) throws IOException {
|
||||
mstrDate = dtNow;
|
||||
setFileName();
|
||||
this.setFile(fileName, true, bufferedIO, bufferSize);
|
||||
|
||||
cleanupOldFiles();
|
||||
}
|
||||
|
||||
private void setFileName() {
|
||||
fileName = mstrFileName + "." + mobjSDF.format(mstrDate);
|
||||
|
||||
if (mWithHostName) {
|
||||
try {
|
||||
fileName += "." + java.net.InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
LogLog.error("Unable to retrieve host name");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -12,7 +12,7 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.BitstreamFormat;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
@@ -24,7 +24,7 @@ import org.dspace.core.Context;
|
||||
*/
|
||||
public class GoogleBitstreamComparator implements Comparator<Bitstream> {
|
||||
|
||||
private final static Logger log = org.apache.logging.log4j.LogManager.getLogger(GoogleBitstreamComparator.class);
|
||||
private final static Logger log = Logger.getLogger(GoogleBitstreamComparator.class);
|
||||
|
||||
HashMap<String, Integer> priorityMap = new HashMap<>();
|
||||
|
||||
@@ -86,7 +86,7 @@ public class GoogleBitstreamComparator implements Comparator<Bitstream> {
|
||||
if (priority1 > priority2) {
|
||||
return 1;
|
||||
} else if (priority1 == priority2) {
|
||||
if (b1.getSizeBytes() <= b2.getSizeBytes()) {
|
||||
if (b1.getSize() <= b2.getSize()) {
|
||||
return 1;
|
||||
} else {
|
||||
return -1;
|
||||
|
@@ -26,7 +26,7 @@ import java.util.Properties;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authorize.factory.AuthorizeServiceFactory;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
@@ -51,7 +51,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 = Logger.getLogger(GoogleMetadata.class);
|
||||
|
||||
protected static final String GOOGLE_PREFIX = "google.";
|
||||
|
||||
@@ -889,7 +889,7 @@ public class GoogleMetadata {
|
||||
Bitstream bitstream = findLinkableFulltext(item);
|
||||
if (bitstream != null) {
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(ConfigurationManager.getProperty("dspace.ui.url"));
|
||||
path.append(ConfigurationManager.getProperty("dspace.url"));
|
||||
|
||||
if (item.getHandle() != null) {
|
||||
path.append("/bitstream/");
|
||||
|
@@ -121,24 +121,20 @@ public class IndexVersion {
|
||||
}
|
||||
|
||||
// Open this index directory in Lucene
|
||||
Directory indexDir = FSDirectory.open(dir.toPath());
|
||||
Directory indexDir = FSDirectory.open(dir);
|
||||
|
||||
// Get info on the Lucene segment file(s) in index directory
|
||||
SegmentInfos sis;
|
||||
SegmentInfos sis = new SegmentInfos();
|
||||
try {
|
||||
sis = SegmentInfos.readLatestCommit(indexDir);
|
||||
sis.read(indexDir);
|
||||
} catch (IOException ie) {
|
||||
// Wrap default IOException, providing more info about which directory cannot be read
|
||||
throw new IOException("Could not read Lucene segments files in " + dir.getAbsolutePath(), ie);
|
||||
}
|
||||
|
||||
if (null == sis) {
|
||||
throw new IOException("Could not read Lucene segments files in " + dir.getAbsolutePath());
|
||||
}
|
||||
|
||||
// If we have a valid Solr index dir, but it has no existing segments
|
||||
// then just return an empty string. It's a valid but empty index.
|
||||
if (sis.size() == 0) {
|
||||
if (sis != null && sis.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -250,8 +246,12 @@ public class IndexVersion {
|
||||
} else if (firstMinor > secondMinor) {
|
||||
// If we get here, major versions must be EQUAL. Now, time to check our minor versions
|
||||
return GREATER_THAN;
|
||||
} else {
|
||||
} else if (firstMinor < secondMinor) {
|
||||
return LESS_THAN;
|
||||
} else {
|
||||
// This is an impossible scenario.
|
||||
// This 'else' should never be triggered since we've checked for equality above already
|
||||
return EQUAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,245 +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.app.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
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;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.EntityType;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.EntityTypeService;
|
||||
import org.dspace.content.service.RelationshipService;
|
||||
import org.dspace.content.service.RelationshipTypeService;
|
||||
import org.dspace.core.Context;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* This script is used to initialize the database with a set of relationshiptypes that are written
|
||||
* in an xml file that is given to this script.
|
||||
* This XML file needs to have a proper XML structure and needs to define the variables of the RelationshipType object
|
||||
*/
|
||||
public class InitializeEntities {
|
||||
|
||||
private final static Logger log = LogManager.getLogger();
|
||||
|
||||
private RelationshipTypeService relationshipTypeService;
|
||||
private RelationshipService relationshipService;
|
||||
private EntityTypeService entityTypeService;
|
||||
|
||||
|
||||
private InitializeEntities() {
|
||||
relationshipTypeService = ContentServiceFactory.getInstance().getRelationshipTypeService();
|
||||
relationshipService = ContentServiceFactory.getInstance().getRelationshipService();
|
||||
entityTypeService = ContentServiceFactory.getInstance().getEntityTypeService();
|
||||
}
|
||||
|
||||
/**
|
||||
* The main method for this script
|
||||
*
|
||||
* @param argv The commandline 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();
|
||||
Options options = createCommandLineOptions();
|
||||
CommandLine line = parser.parse(options,argv);
|
||||
String fileLocation = getFileLocationFromCommandLine(line);
|
||||
checkHelpEntered(options, line);
|
||||
initializeEntities.run(fileLocation);
|
||||
}
|
||||
private static void checkHelpEntered(Options options, CommandLine line) {
|
||||
if (line.hasOption("h")) {
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
formatter.printHelp("Intialize Entities", options);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
private static String getFileLocationFromCommandLine(CommandLine line) {
|
||||
String query = line.getOptionValue("f");
|
||||
if (StringUtils.isEmpty(query)) {
|
||||
System.out.println("No file location was entered");
|
||||
log.info("No file location was entered");
|
||||
System.exit(1);
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
protected static Options createCommandLineOptions() {
|
||||
Options options = new Options();
|
||||
options.addOption("f", "file", true, "the location for the file containing the xml data");
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
private void run(String fileLocation) throws SQLException, AuthorizeException {
|
||||
Context context = new Context();
|
||||
context.turnOffAuthorisationSystem();
|
||||
this.parseXMLToRelations(context, fileLocation);
|
||||
context.complete();
|
||||
}
|
||||
|
||||
private void parseXMLToRelations(Context context, String fileLocation) throws AuthorizeException {
|
||||
try {
|
||||
File fXmlFile = new File(fileLocation);
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = null;
|
||||
dBuilder = dbFactory.newDocumentBuilder();
|
||||
Document doc = dBuilder.parse(fXmlFile);
|
||||
|
||||
doc.getDocumentElement().normalize();
|
||||
|
||||
NodeList nList = doc.getElementsByTagName("type");
|
||||
List<RelationshipType> relationshipTypes = new LinkedList<>();
|
||||
for (int i = 0; i < nList.getLength(); i++) {
|
||||
Node nNode = nList.item(i);
|
||||
|
||||
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
|
||||
Element eElement = (Element) nNode;
|
||||
|
||||
String leftType = eElement.getElementsByTagName("leftType").item(0).getTextContent();
|
||||
String rightType = eElement.getElementsByTagName("rightType").item(0).getTextContent();
|
||||
String leftwardType = eElement.getElementsByTagName("leftwardType").item(0).getTextContent();
|
||||
String rightwardType = eElement.getElementsByTagName("rightwardType").item(0).getTextContent();
|
||||
Node copyToLeftNode = eElement.getElementsByTagName("copyToLeft").item(0);
|
||||
Boolean copyToLeft;
|
||||
if (copyToLeftNode == null) {
|
||||
copyToLeft = false;
|
||||
} else {
|
||||
copyToLeft = Boolean.valueOf(copyToLeftNode.getTextContent());
|
||||
|
||||
}
|
||||
Node copyToRightNode = eElement.getElementsByTagName("copyToRight").item(0);
|
||||
Boolean copyToRight;
|
||||
if (copyToRightNode == null) {
|
||||
copyToRight = false;
|
||||
} else {
|
||||
copyToRight = Boolean.valueOf(copyToRightNode.getTextContent());
|
||||
}
|
||||
|
||||
NodeList leftCardinalityList = eElement.getElementsByTagName("leftCardinality");
|
||||
NodeList rightCardinalityList = eElement.getElementsByTagName("rightCardinality");
|
||||
|
||||
String leftCardinalityMin = "";
|
||||
String leftCardinalityMax = "";
|
||||
|
||||
String rightCardinalityMin = "";
|
||||
String rightCardinalityMax = "";
|
||||
|
||||
for (int j = 0; j < leftCardinalityList.getLength(); j++) {
|
||||
Node node = leftCardinalityList.item(j);
|
||||
leftCardinalityMin = getString(leftCardinalityMin,(Element) node, "min");
|
||||
leftCardinalityMax = getString(leftCardinalityMax,(Element) node, "max");
|
||||
|
||||
}
|
||||
|
||||
for (int j = 0; j < rightCardinalityList.getLength(); j++) {
|
||||
Node node = rightCardinalityList.item(j);
|
||||
rightCardinalityMin = getString(rightCardinalityMin,(Element) node, "min");
|
||||
rightCardinalityMax = getString(rightCardinalityMax,(Element) node, "max");
|
||||
|
||||
}
|
||||
populateRelationshipType(context, leftType, rightType, leftwardType, rightwardType,
|
||||
leftCardinalityMin, leftCardinalityMax,
|
||||
rightCardinalityMin, rightCardinalityMax, copyToLeft, copyToRight);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
} catch (ParserConfigurationException | SAXException | IOException | SQLException e) {
|
||||
log.error("An error occurred while parsing the XML file to relations", e);
|
||||
}
|
||||
}
|
||||
|
||||
private String getString(String leftCardinalityMin,Element node, String minOrMax) {
|
||||
if (node.getElementsByTagName(minOrMax).getLength() > 0) {
|
||||
leftCardinalityMin = node.getElementsByTagName(minOrMax).item(0).getTextContent();
|
||||
}
|
||||
return leftCardinalityMin;
|
||||
}
|
||||
|
||||
private void populateRelationshipType(Context context, String leftType, String rightType, String leftwardType,
|
||||
String rightwardType, String leftCardinalityMin, String leftCardinalityMax,
|
||||
String rightCardinalityMin, String rightCardinalityMax,
|
||||
Boolean copyToLeft, Boolean copyToRight)
|
||||
throws SQLException, AuthorizeException {
|
||||
|
||||
EntityType leftEntityType = entityTypeService.findByEntityType(context,leftType);
|
||||
if (leftEntityType == null) {
|
||||
leftEntityType = entityTypeService.create(context, leftType);
|
||||
}
|
||||
EntityType rightEntityType = entityTypeService.findByEntityType(context, rightType);
|
||||
if (rightEntityType == null) {
|
||||
rightEntityType = entityTypeService.create(context, rightType);
|
||||
}
|
||||
Integer leftCardinalityMinInteger;
|
||||
Integer leftCardinalityMaxInteger;
|
||||
Integer rightCardinalityMinInteger;
|
||||
Integer rightCardinalityMaxInteger;
|
||||
if (StringUtils.isNotBlank(leftCardinalityMin)) {
|
||||
leftCardinalityMinInteger = Integer.parseInt(leftCardinalityMin);
|
||||
} else {
|
||||
leftCardinalityMinInteger = null;
|
||||
}
|
||||
if (StringUtils.isNotBlank(leftCardinalityMax)) {
|
||||
leftCardinalityMaxInteger = Integer.parseInt(leftCardinalityMax);
|
||||
} else {
|
||||
leftCardinalityMaxInteger = null;
|
||||
}
|
||||
if (StringUtils.isNotBlank(rightCardinalityMin)) {
|
||||
rightCardinalityMinInteger = Integer.parseInt(rightCardinalityMin);
|
||||
} else {
|
||||
rightCardinalityMinInteger = null;
|
||||
}
|
||||
if (StringUtils.isNotBlank(rightCardinalityMax)) {
|
||||
rightCardinalityMaxInteger = Integer.parseInt(rightCardinalityMax);
|
||||
} else {
|
||||
rightCardinalityMaxInteger = null;
|
||||
}
|
||||
RelationshipType relationshipType = relationshipTypeService
|
||||
.findbyTypesAndTypeName(context, leftEntityType, rightEntityType, leftwardType, rightwardType);
|
||||
if (relationshipType == null) {
|
||||
relationshipTypeService.create(context, leftEntityType, rightEntityType, leftwardType, rightwardType,
|
||||
leftCardinalityMinInteger, leftCardinalityMaxInteger,
|
||||
rightCardinalityMinInteger, rightCardinalityMaxInteger,
|
||||
copyToLeft, copyToRight);
|
||||
} else {
|
||||
relationshipType.setCopyToLeft(copyToLeft);
|
||||
relationshipType.setCopyToRight(copyToRight);
|
||||
relationshipType.setLeftMinCardinality(leftCardinalityMinInteger);
|
||||
relationshipType.setLeftMaxCardinality(leftCardinalityMaxInteger);
|
||||
relationshipType.setRightMinCardinality(rightCardinalityMinInteger);
|
||||
relationshipType.setRightMaxCardinality(rightCardinalityMaxInteger);
|
||||
relationshipTypeService.update(context, relationshipType);
|
||||
}
|
||||
}
|
||||
}
|
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.util.service.MetadataExposureService;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.core.Context;
|
||||
@@ -58,7 +58,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
* @version $Revision: 3734 $
|
||||
*/
|
||||
public class MetadataExposureServiceImpl implements MetadataExposureService {
|
||||
protected Logger log = org.apache.logging.log4j.LogManager.getLogger(MetadataExposureServiceImpl.class);
|
||||
protected Logger log = Logger.getLogger(MetadataExposureServiceImpl.class);
|
||||
|
||||
protected Map<String, Set<String>> hiddenElementSets = null;
|
||||
protected Map<String, Map<String, Set<String>>> hiddenElementMaps = null;
|
||||
|
@@ -20,12 +20,11 @@ import com.sun.syndication.feed.module.opensearch.OpenSearchModule;
|
||||
import com.sun.syndication.feed.module.opensearch.entity.OSQuery;
|
||||
import com.sun.syndication.feed.module.opensearch.impl.OpenSearchModuleImpl;
|
||||
import com.sun.syndication.io.FeedException;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.util.service.OpenSearchService;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.discovery.IndexableObject;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
@@ -34,6 +33,7 @@ import org.jdom.JDOMException;
|
||||
import org.jdom.Namespace;
|
||||
import org.jdom.output.DOMOutputter;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
@@ -53,14 +53,20 @@ import org.w3c.dom.Document;
|
||||
*
|
||||
* @author Richard Rodgers
|
||||
*/
|
||||
public class OpenSearchServiceImpl implements OpenSearchService {
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(OpenSearchServiceImpl.class);
|
||||
public class OpenSearchServiceImpl implements OpenSearchService, InitializingBean {
|
||||
private static final Logger log = Logger.getLogger(OpenSearchServiceImpl.class);
|
||||
|
||||
// are open search queries enabled?
|
||||
protected boolean enabled = false;
|
||||
// supported results formats
|
||||
protected List<String> formats = null;
|
||||
// Namespaces used
|
||||
protected final String osNs = "http://a9.com/-/spec/opensearch/1.1/";
|
||||
|
||||
@Autowired(required = true)
|
||||
protected ConfigurationService configurationService;
|
||||
// base search UI URL
|
||||
protected String uiUrl = null;
|
||||
// base search service URL
|
||||
protected String svcUrl = null;
|
||||
|
||||
@Autowired(required = true)
|
||||
protected HandleService handleService;
|
||||
@@ -69,35 +75,25 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getFormats() {
|
||||
List<String> formats = new ArrayList<>();
|
||||
// read formats only if enabled
|
||||
if (isEnabled()) {
|
||||
String[] fmts = configurationService.getArrayProperty("websvc.opensearch.formats");
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
enabled = config.getBooleanProperty("websvc.opensearch.enable");
|
||||
svcUrl = config.getProperty("dspace.url") + "/" +
|
||||
config.getProperty("websvc.opensearch.svccontext");
|
||||
uiUrl = config.getProperty("dspace.url") + "/" +
|
||||
config.getProperty("websvc.opensearch.uicontext");
|
||||
|
||||
// read rest of config info if enabled
|
||||
formats = new ArrayList<String>();
|
||||
if (enabled) {
|
||||
String[] fmts = config.getArrayProperty("websvc.opensearch.formats");
|
||||
formats = Arrays.asList(fmts);
|
||||
}
|
||||
return formats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return configurationService.getBooleanProperty("websvc.opensearch.enable");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base search service URL (websvc.opensearch.svccontext)
|
||||
*/
|
||||
protected String getBaseSearchServiceURL() {
|
||||
return configurationService.getProperty("dspace.server.url") + "/" +
|
||||
configurationService.getProperty("websvc.opensearch.svccontext");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base search UI URL (websvc.opensearch.uicontext)
|
||||
*/
|
||||
protected String getBaseSearchUIURL() {
|
||||
return configurationService.getProperty("dspace.server.url") + "/" +
|
||||
configurationService.getProperty("websvc.opensearch.uicontext");
|
||||
public List<String> getFormats() {
|
||||
return formats;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,7 +115,7 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
||||
@Override
|
||||
public String getResultsString(Context context, String format, String query, int totalResults, int start,
|
||||
int pageSize,
|
||||
IndexableObject scope, List<IndexableObject> results,
|
||||
DSpaceObject scope, List<DSpaceObject> results,
|
||||
Map<String, String> labels) throws IOException {
|
||||
try {
|
||||
return getResults(context, format, query, totalResults, start, pageSize, scope, results, labels)
|
||||
@@ -133,7 +129,7 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
||||
@Override
|
||||
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start,
|
||||
int pageSize,
|
||||
IndexableObject scope, List<IndexableObject> results, Map<String, String> labels)
|
||||
DSpaceObject scope, List<DSpaceObject> results, Map<String, String> labels)
|
||||
throws IOException {
|
||||
try {
|
||||
return getResults(context, format, query, totalResults, start, pageSize, scope, results, labels)
|
||||
@@ -145,8 +141,8 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
||||
}
|
||||
|
||||
protected SyndicationFeed getResults(Context context, String format, String query, int totalResults, int start,
|
||||
int pageSize, IndexableObject scope,
|
||||
List<IndexableObject> results, Map<String, String> labels) {
|
||||
int pageSize,
|
||||
DSpaceObject scope, List<DSpaceObject> results, Map<String, String> labels) {
|
||||
// Encode results in requested format
|
||||
if ("rss".equals(format)) {
|
||||
format = "rss_2.0";
|
||||
@@ -225,13 +221,13 @@ public class OpenSearchServiceImpl implements OpenSearchService {
|
||||
root.addContent(fav);
|
||||
}
|
||||
// service URLs
|
||||
for (String format : getFormats()) {
|
||||
for (String format : formats) {
|
||||
Element url = new Element("Url", ns).setAttribute("type", getContentType(format));
|
||||
StringBuilder template = new StringBuilder();
|
||||
if ("html".equals(format)) {
|
||||
template.append(getBaseSearchUIURL());
|
||||
template.append(uiUrl);
|
||||
} else {
|
||||
template.append(getBaseSearchServiceURL());
|
||||
template.append(svcUrl);
|
||||
}
|
||||
template.append("?query={searchTerms}");
|
||||
if (!"html".equals(format)) {
|
||||
|
@@ -11,7 +11,7 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CollectionService;
|
||||
@@ -28,7 +28,7 @@ import org.springframework.util.StopWatch;
|
||||
* Invocation: dsrun org.dspace.app.util.OptimizeSelectCollection
|
||||
*/
|
||||
public class OptimizeSelectCollection {
|
||||
private static final Logger log = org.apache.logging.log4j.LogManager.getLogger(OptimizeSelectCollection.class);
|
||||
private static final Logger log = Logger.getLogger(OptimizeSelectCollection.class);
|
||||
private static Context context;
|
||||
|
||||
private static ArrayList<EPerson> brokenPeople;
|
||||
|
@@ -12,7 +12,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Class representing a single Item Submission config definition, organized into
|
||||
@@ -44,7 +44,7 @@ public class SubmissionConfig implements Serializable {
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(SubmissionConfig.class);
|
||||
private static Logger log = Logger.getLogger(SubmissionConfig.class);
|
||||
|
||||
/**
|
||||
* Constructs a new Submission Configuration object, based on the XML
|
||||
|
@@ -19,7 +19,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.FactoryConfigurationError;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Context;
|
||||
@@ -71,7 +71,7 @@ public class SubmissionConfigReader {
|
||||
/**
|
||||
* log4j logger
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(SubmissionConfigReader.class);
|
||||
private static Logger log = Logger.getLogger(SubmissionConfigReader.class);
|
||||
|
||||
/**
|
||||
* The fully qualified pathname of the directory containing the Item Submission Configuration file
|
||||
|
@@ -34,9 +34,9 @@ import com.sun.syndication.feed.synd.SyndPerson;
|
||||
import com.sun.syndication.feed.synd.SyndPersonImpl;
|
||||
import com.sun.syndication.io.FeedException;
|
||||
import com.sun.syndication.io.SyndFeedOutput;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
import org.dspace.content.Collection;
|
||||
@@ -50,11 +50,8 @@ 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.discovery.IndexableObject;
|
||||
import org.dspace.discovery.indexobject.IndexableCollection;
|
||||
import org.dspace.discovery.indexobject.IndexableCommunity;
|
||||
import org.dspace.discovery.indexobject.IndexableItem;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
@@ -72,7 +69,7 @@ import org.w3c.dom.Document;
|
||||
* @author Larry Stone
|
||||
*/
|
||||
public class SyndicationFeed {
|
||||
protected final Logger log = org.apache.logging.log4j.LogManager.getLogger(SyndicationFeed.class);
|
||||
protected final Logger log = Logger.getLogger(SyndicationFeed.class);
|
||||
|
||||
|
||||
/**
|
||||
@@ -182,12 +179,12 @@ public class SyndicationFeed {
|
||||
*
|
||||
* @param request request
|
||||
* @param context context
|
||||
* @param dso the scope
|
||||
* @param dso DSpaceObject
|
||||
* @param items array of objects
|
||||
* @param labels label map
|
||||
*/
|
||||
public void populate(HttpServletRequest request, Context context, IndexableObject dso,
|
||||
List<IndexableObject> items, Map<String, String> labels) {
|
||||
public void populate(HttpServletRequest request, Context context, DSpaceObject dso,
|
||||
List<? extends DSpaceObject> items, Map<String, String> labels) {
|
||||
String logoURL = null;
|
||||
String objectURL = null;
|
||||
String defaultTitle = null;
|
||||
@@ -202,8 +199,8 @@ public class SyndicationFeed {
|
||||
logoURL = ConfigurationManager.getProperty("webui.feed.logo.url");
|
||||
} else {
|
||||
Bitstream logo = null;
|
||||
if (dso instanceof IndexableCollection) {
|
||||
Collection col = ((IndexableCollection) dso).getIndexedObject();
|
||||
if (dso.getType() == Constants.COLLECTION) {
|
||||
Collection col = (Collection) dso;
|
||||
defaultTitle = col.getName();
|
||||
feed.setDescription(collectionService.getMetadata(col, "short_description"));
|
||||
logo = col.getLogo();
|
||||
@@ -211,9 +208,8 @@ public class SyndicationFeed {
|
||||
if (cols != null && cols.length() > 1 && cols.contains(col.getHandle())) {
|
||||
podcastFeed = true;
|
||||
}
|
||||
objectURL = resolveURL(request, col);
|
||||
} else if (dso instanceof IndexableCommunity) {
|
||||
Community comm = ((IndexableCommunity) dso).getIndexedObject();
|
||||
} else if (dso.getType() == Constants.COMMUNITY) {
|
||||
Community comm = (Community) dso;
|
||||
defaultTitle = comm.getName();
|
||||
feed.setDescription(communityService.getMetadata(comm, "short_description"));
|
||||
logo = comm.getLogo();
|
||||
@@ -221,9 +217,8 @@ public class SyndicationFeed {
|
||||
if (comms != null && comms.length() > 1 && comms.contains(comm.getHandle())) {
|
||||
podcastFeed = true;
|
||||
}
|
||||
objectURL = resolveURL(request, comm);
|
||||
}
|
||||
|
||||
objectURL = resolveURL(request, dso);
|
||||
if (logo != null) {
|
||||
logoURL = urlOfBitstream(request, logo);
|
||||
}
|
||||
@@ -252,11 +247,11 @@ public class SyndicationFeed {
|
||||
// add entries for items
|
||||
if (items != null) {
|
||||
List<SyndEntry> entries = new ArrayList<SyndEntry>();
|
||||
for (IndexableObject idxObj : items) {
|
||||
if (!(idxObj instanceof IndexableItem)) {
|
||||
for (DSpaceObject itemDSO : items) {
|
||||
if (itemDSO.getType() != Constants.ITEM) {
|
||||
continue;
|
||||
}
|
||||
Item item = ((IndexableItem) idxObj).getIndexedObject();
|
||||
Item item = (Item) itemDSO;
|
||||
boolean hasDate = false;
|
||||
SyndEntry entry = new SyndEntryImpl();
|
||||
entries.add(entry);
|
||||
@@ -371,7 +366,7 @@ public class SyndicationFeed {
|
||||
if (ArrayUtils.contains(podcastableMIMETypes, mime)) {
|
||||
SyndEnclosure enc = new SyndEnclosureImpl();
|
||||
enc.setType(bit.getFormat(context).getMIMEType());
|
||||
enc.setLength(bit.getSizeBytes());
|
||||
enc.setLength(bit.getSize());
|
||||
enc.setUrl(urlOfBitstream(request, bit));
|
||||
enclosures.add(enc);
|
||||
} else {
|
||||
@@ -531,9 +526,11 @@ public class SyndicationFeed {
|
||||
if (dso == null) {
|
||||
if (baseURL == null) {
|
||||
if (request == null) {
|
||||
baseURL = ConfigurationManager.getProperty("dspace.ui.url");
|
||||
baseURL = ConfigurationManager.getProperty("dspace.url");
|
||||
} else {
|
||||
baseURL = ConfigurationManager.getProperty("dspace.ui.url");
|
||||
baseURL = (request.isSecure()) ? "https://" : "http://";
|
||||
baseURL += ConfigurationManager.getProperty("dspace.hostname");
|
||||
baseURL += ":" + request.getServerPort();
|
||||
baseURL += request.getContextPath();
|
||||
}
|
||||
}
|
||||
|
@@ -22,9 +22,9 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.commons.collections.ListUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataValue;
|
||||
@@ -44,7 +44,7 @@ public class Util {
|
||||
// cache for source version result
|
||||
private static String sourceVersion = null;
|
||||
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(Util.class);
|
||||
private static Logger log = Logger.getLogger(Util.class);
|
||||
|
||||
/**
|
||||
* Default constructor. Must be protected as org.dspace.xmlworkflow.WorkflowUtils extends it
|
||||
@@ -360,13 +360,9 @@ public class Util {
|
||||
InputStream cis = null;
|
||||
try {
|
||||
cis = Util.class.getResourceAsStream("/META-INF/maven/org.dspace/dspace-api/pom.properties");
|
||||
if (cis == null) {
|
||||
// pom.properties will not exist when running tests
|
||||
return "unknown";
|
||||
}
|
||||
constants.load(cis);
|
||||
} catch (Exception e) {
|
||||
log.error("Could not open dspace-api's pom.properties", e);
|
||||
log.error(e.getMessage(), e);
|
||||
} finally {
|
||||
if (cis != null) {
|
||||
try {
|
||||
@@ -422,12 +418,11 @@ public class Util {
|
||||
|
||||
List<DCInputSet> inputSets = inputsReader.getInputsByCollectionHandle(col_handle);
|
||||
|
||||
// Replace the values of Metadatum[] with the correct ones in case
|
||||
// of
|
||||
// controlled vocabularies
|
||||
String currentField = Utils.standardize(schema, element, qualifier, ".");
|
||||
|
||||
for (DCInputSet inputSet : inputSets) {
|
||||
// Replace the values of Metadatum[] with the correct ones in case
|
||||
// of
|
||||
// controlled vocabularies
|
||||
String currentField = Utils.standardize(schema, element, qualifier, ".");
|
||||
|
||||
if (inputSet != null) {
|
||||
|
||||
@@ -435,20 +430,19 @@ public class Util {
|
||||
|
||||
for (int p = 0; p < fieldsNums; p++) {
|
||||
|
||||
DCInput[][] inputs = inputSet.getFields();
|
||||
DCInput[] inputs = inputSet.getFields();
|
||||
|
||||
if (inputs != null) {
|
||||
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
for (int j = 0; j < inputs[i].length; j++) {
|
||||
String inputField = Utils
|
||||
.standardize(inputs[i][j].getSchema(), inputs[i][j].getElement(),
|
||||
inputs[i][j].getQualifier(), ".");
|
||||
if (currentField.equals(inputField)) {
|
||||
myInputs = inputs[i][j];
|
||||
myInputsFound = true;
|
||||
break;
|
||||
}
|
||||
String inputField = Utils.standardize(inputs[i].getSchema(), inputs[i].getElement(),
|
||||
inputs[i].getQualifier(), ".");
|
||||
if (currentField.equals(inputField)) {
|
||||
|
||||
myInputs = inputs[i];
|
||||
myInputsFound = true;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -477,26 +471,6 @@ public class Util {
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split a list in an array of i sub-lists uniformly sized
|
||||
*
|
||||
* @param idsList the list to split
|
||||
* @param i the number of sublists to return
|
||||
*
|
||||
* @return an array of sub-lists of fixed size
|
||||
*/
|
||||
public static <T> List<T>[] splitList(List<T> idsList, int i) {
|
||||
int setmin = idsList.size() / i;
|
||||
List<T>[] result = new List[i];
|
||||
int offset = 0;
|
||||
for (int idx = 0; idx < i - 1; idx++) {
|
||||
result[idx] = idsList.subList(offset, offset + setmin);
|
||||
offset += setmin;
|
||||
}
|
||||
result[i - 1] = idsList.subList(offset, idsList.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<String> differenceInSubmissionFields(Collection fromCollection, Collection toCollection)
|
||||
throws DCInputsReaderException {
|
||||
DCInputsReader reader = new DCInputsReader();
|
||||
@@ -506,17 +480,13 @@ public class Util {
|
||||
Set<String> fromFieldName = new HashSet<>();
|
||||
Set<String> toFieldName = new HashSet<>();
|
||||
for (DCInputSet ff : from) {
|
||||
for (DCInput[] fdcrow : ff.getFields()) {
|
||||
for (DCInput fdc : fdcrow) {
|
||||
fromFieldName.add(fdc.getFieldName());
|
||||
}
|
||||
for (DCInput fdc : ff.getFields()) {
|
||||
fromFieldName.add(fdc.getFieldName());
|
||||
}
|
||||
}
|
||||
for (DCInputSet tt : to) {
|
||||
for (DCInput[] tdcrow : tt.getFields()) {
|
||||
for (DCInput tdc : tdcrow) {
|
||||
toFieldName.add(tdc.getFieldName());
|
||||
}
|
||||
for (DCInput tdc : tt.getFields()) {
|
||||
toFieldName.add(tdc.getFieldName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,7 @@ 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.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.util.dao.WebAppDAO;
|
||||
import org.dspace.app.util.service.WebAppService;
|
||||
import org.dspace.core.Context;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
*/
|
||||
public class WebAppServiceImpl implements WebAppService {
|
||||
|
||||
private final Logger log = org.apache.logging.log4j.LogManager.getLogger(WebAppServiceImpl.class);
|
||||
private final Logger log = Logger.getLogger(WebAppServiceImpl.class);
|
||||
|
||||
@Autowired(required = true)
|
||||
protected WebAppDAO webAppDAO;
|
||||
|
@@ -11,7 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
|
@@ -14,7 +14,6 @@ import java.util.Map;
|
||||
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.discovery.IndexableObject;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
@@ -42,13 +41,6 @@ public interface OpenSearchService {
|
||||
*/
|
||||
public List<String> getFormats();
|
||||
|
||||
/**
|
||||
* Determine if the module is active
|
||||
*
|
||||
* @return boolean indicator if the OpenSearch module is enabled or not
|
||||
*/
|
||||
public boolean isEnabled();
|
||||
|
||||
/**
|
||||
* Returns a mime-type associated with passed format
|
||||
*
|
||||
@@ -84,7 +76,7 @@ public interface OpenSearchService {
|
||||
* @param totalResults - the hit count
|
||||
* @param start - start result index
|
||||
* @param pageSize - page size
|
||||
* @param scope - search scope, null or the community/collection
|
||||
* @param scope - search scope, null or community/collection handle
|
||||
* @param results the retreived DSpace objects satisfying search
|
||||
* @param labels labels to apply - format specific
|
||||
* @return formatted search results
|
||||
@@ -92,7 +84,7 @@ public interface OpenSearchService {
|
||||
*/
|
||||
public String getResultsString(Context context, String format, String query, int totalResults, int start,
|
||||
int pageSize,
|
||||
IndexableObject scope, List<IndexableObject> results,
|
||||
DSpaceObject scope, List<DSpaceObject> results,
|
||||
Map<String, String> labels) throws IOException;
|
||||
|
||||
/**
|
||||
@@ -104,7 +96,7 @@ public interface OpenSearchService {
|
||||
* @param totalResults - the hit count
|
||||
* @param start - start result index
|
||||
* @param pageSize - page size
|
||||
* @param scope - search scope, null or the community/collection
|
||||
* @param scope - search scope, null or community/collection handle
|
||||
* @param results the retreived DSpace objects satisfying search
|
||||
* @param labels labels to apply - format specific
|
||||
* @return formatted search results
|
||||
@@ -112,7 +104,7 @@ public interface OpenSearchService {
|
||||
*/
|
||||
public Document getResultsDoc(Context context, String format, String query, int totalResults, int start,
|
||||
int pageSize,
|
||||
IndexableObject scope, List<IndexableObject> results, Map<String, String> labels)
|
||||
DSpaceObject scope, List<DSpaceObject> results, Map<String, String> labels)
|
||||
throws IOException;
|
||||
|
||||
public DSpaceObject resolveScope(Context context, String scope) throws SQLException;
|
||||
|
@@ -210,10 +210,4 @@ public interface AuthenticationMethod {
|
||||
public String loginPageURL(Context context,
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* Returns a short name that uniquely identifies this authentication method
|
||||
* @return The authentication method name
|
||||
*/
|
||||
public String getName();
|
||||
}
|
||||
|
@@ -9,7 +9,6 @@ package org.dspace.authenticate;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -17,15 +16,15 @@ import java.util.UUID;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.commons.collections.ListUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.LogManager;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.dspace.eperson.factory.EPersonServiceFactory;
|
||||
import org.dspace.eperson.service.GroupService;
|
||||
import org.dspace.service.ClientInfoService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
@@ -50,7 +49,7 @@ public class IPAuthentication implements AuthenticationMethod {
|
||||
/**
|
||||
* Our logger
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(IPAuthentication.class);
|
||||
private static Logger log = Logger.getLogger(IPAuthentication.class);
|
||||
|
||||
/**
|
||||
* Whether to look for x-forwarded headers for logging IP addresses
|
||||
@@ -68,7 +67,6 @@ public class IPAuthentication implements AuthenticationMethod {
|
||||
protected List<IPMatcher> ipNegativeMatchers;
|
||||
|
||||
protected GroupService groupService;
|
||||
protected ClientInfoService clientInfoService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -93,7 +91,6 @@ public class IPAuthentication implements AuthenticationMethod {
|
||||
ipMatcherGroupIDs = new HashMap<>();
|
||||
ipMatcherGroupNames = new HashMap<>();
|
||||
groupService = EPersonServiceFactory.getInstance().getGroupService();
|
||||
clientInfoService = CoreServiceFactory.getInstance().getClientInfoService();
|
||||
|
||||
List<String> propNames = DSpaceServicesFactory.getInstance().getConfigurationService()
|
||||
.getPropertyKeys("authentication-ip");
|
||||
@@ -167,12 +164,23 @@ public class IPAuthentication implements AuthenticationMethod {
|
||||
public List<Group> getSpecialGroups(Context context, HttpServletRequest request)
|
||||
throws SQLException {
|
||||
if (request == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
return ListUtils.EMPTY_LIST;
|
||||
}
|
||||
List<Group> groups = new ArrayList<Group>();
|
||||
|
||||
// Get the user's IP address
|
||||
String addr = clientInfoService.getClientIp(request);
|
||||
String addr = request.getRemoteAddr();
|
||||
if (useProxies == null) {
|
||||
useProxies = ConfigurationManager.getBooleanProperty("useProxies", false);
|
||||
}
|
||||
if (useProxies && request.getHeader("X-Forwarded-For") != null) {
|
||||
/* This header is a comma delimited list */
|
||||
for (String xfip : request.getHeader("X-Forwarded-For").split(",")) {
|
||||
if (!request.getHeader("X-Forwarded-For").contains(addr)) {
|
||||
addr = xfip.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (IPMatcher ipm : ipMatchers) {
|
||||
try {
|
||||
@@ -268,9 +276,4 @@ public class IPAuthentication implements AuthenticationMethod {
|
||||
HttpServletResponse response) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ip";
|
||||
}
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ package org.dspace.authenticate;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -38,7 +38,7 @@ import org.apache.logging.log4j.Logger;
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class IPMatcher {
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(IPMatcher.class);
|
||||
private static Logger log = Logger.getLogger(IPMatcher.class);
|
||||
|
||||
/**
|
||||
* Network to match
|
||||
@@ -87,16 +87,13 @@ public class IPMatcher {
|
||||
+ ipSpec);
|
||||
}
|
||||
|
||||
for (int i = 0; i < netmask.length; i++) {
|
||||
if (maskBits <= 0) {
|
||||
netmask[i] = 0;
|
||||
} else if (maskBits > 8) {
|
||||
netmask[i] = (byte) 0Xff;
|
||||
} else {
|
||||
netmask[i] = (byte) ((byte) 0Xff << 8 - maskBits);
|
||||
}
|
||||
|
||||
maskBits = maskBits - 8;
|
||||
int maskBytes = maskBits / 8;
|
||||
for (int i = 0; i < maskBytes; i++) {
|
||||
netmask[i] = (byte) 0Xff;
|
||||
}
|
||||
netmask[maskBytes] = (byte) ((byte) 0Xff << 8 - (maskBits % 8)); // FIXME test!
|
||||
for (int i = maskBytes + 1; i < (128 / 8); i++) {
|
||||
netmask[i] = 0;
|
||||
}
|
||||
break;
|
||||
case 1: // No explicit mask: fill the mask with 1s
|
||||
|
@@ -10,7 +10,6 @@ package org.dspace.authenticate;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import javax.naming.NamingEnumeration;
|
||||
@@ -28,8 +27,9 @@ import javax.naming.ldap.StartTlsResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.commons.collections.ListUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.authenticate.factory.AuthenticateServiceFactory;
|
||||
import org.dspace.authenticate.service.AuthenticationService;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
@@ -61,7 +61,7 @@ public class LDAPAuthentication
|
||||
/**
|
||||
* log4j category
|
||||
*/
|
||||
private static Logger log = org.apache.logging.log4j.LogManager.getLogger(LDAPAuthentication.class);
|
||||
private static Logger log = Logger.getLogger(LDAPAuthentication.class);
|
||||
|
||||
protected AuthenticationService authenticationService = AuthenticateServiceFactory.getInstance()
|
||||
.getAuthenticationService();
|
||||
@@ -136,7 +136,7 @@ public class LDAPAuthentication
|
||||
log.warn(LogManager.getHeader(context,
|
||||
"ldap_specialgroup",
|
||||
"Group defined in login.specialgroup does not exist"));
|
||||
return Collections.EMPTY_LIST;
|
||||
return ListUtils.EMPTY_LIST;
|
||||
} else {
|
||||
return Arrays.asList(ldapGroup);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class LDAPAuthentication
|
||||
} catch (Exception npe) {
|
||||
// The user is not an LDAP user, so we don't need to worry about them
|
||||
}
|
||||
return Collections.EMPTY_LIST;
|
||||
return ListUtils.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -639,11 +639,6 @@ public class LDAPAuthentication
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ldap";
|
||||
}
|
||||
|
||||
/*
|
||||
* Add authenticated users to the group defined in dspace.cfg by
|
||||
* the authentication-ldap.login.groupmap.* key.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user