Skip to content

Commit

Permalink
Work in progress: update RTS For DSpace 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nwoodward committed Jul 26, 2024
1 parent ec570e1 commit a079e64
Show file tree
Hide file tree
Showing 22 changed files with 137 additions and 92 deletions.
73 changes: 45 additions & 28 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
</organization>

<properties>
<!-- DSpace Version Information (supported version of DSpace is 7.2 or above) -->
<dspace.version>[7.2,7.20)</dspace.version>
<!-- DSpace Version Information (supported version of DSpace is 8.0 or above) -->
<dspace.version>[8.0,8.20)</dspace.version>
<!-- DuraCloud Version Information (supported version of DuraCloud) -->
<duracloud.version>7.0.0</duracloud.version>
<duracloud.version>8.1.0</duracloud.version>
<!-- DuraSpace BagIt Support Library -->
<bagit-support.version>1.1.0</bagit-support.version>
<jaxb.version>2.3.1</jaxb.version>
<!-- Replication Task Suite requires Java 11 because DSpace 7 requires it -->
<java.version>11</java.version>
<jaxb-api.version>4.0.2</jaxb-api.version>
<jaxb-runtime.version>4.0.5</jaxb-runtime.version>
<!-- Replication Task Suite requires Java 17 because DSpace 8 requires it -->
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
</properties>
Expand All @@ -36,7 +37,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.1.0</version>
<version>3.4.1</version>
<executions>
<execution>
<id>enforce-java</id>
Expand Down Expand Up @@ -87,7 +88,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.13.0</version>
<configuration>
<release>${java.version}</release>
</configuration>
Expand All @@ -96,7 +97,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
Expand All @@ -109,29 +110,29 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
<version>3.6.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<version>3.3.1</version>
</plugin>
<!-- Used to generate a new release via Sonatype (see release profile). -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<version>1.6.13</version>
</plugin>
<!-- Used to generate JavaDocs for new releases (see release profile). -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<version>3.6.3</version>
<configuration>
<!-- Never fail a build based on Javadoc errors -->
<failOnError>false</failOnError>
Expand All @@ -141,21 +142,21 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<version>3.3.0</version>
</plugin>
<!-- Used to sign new releases via GPG (see release profile). -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<version>3.2.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<version>3.0.0</version>
<configuration>
<!-- During release:perform, enable the "release" profile (see below) -->
<releaseProfiles>release</releaseProfiles>
Expand Down Expand Up @@ -266,24 +267,32 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.11.1</version>
<version>3.26.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.8.0</version>
<version>3.12.4</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand All @@ -310,27 +319,27 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.20.0</version>
<version>2.23.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.20.0</version>
<version>2.23.1</version>
<scope>test</scope>
</dependency>

<!-- JAXB is no longer bundled for java 11
compile only as this will be brought in through dspace-api in 7.x -->
<!-- JAXB is no longer bundled for java 17
compile only as this will be brought in through dspace-api in 8.x -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb.version}</version>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>${jaxb-api.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${jaxb.version}</version>
<version>${jaxb-runtime.version}</version>
<scope>compile</scope>
</dependency>

Expand All @@ -350,6 +359,14 @@
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/dspace/pack/bagit/BagInfoHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static Map<String, Map<String, String>> getTagFiles() {

final List<String> keys = configurationService.getPropertyKeys(TAG_KEY);

// precomplie patterns for when we split strings
// precompile patterns for when we split strings
final Pattern dotSplit = Pattern.compile("\\.");
final Pattern hyphenSplit = Pattern.compile("-");

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/dspace/pack/bagit/BagItAipReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Unmarshaller;

import com.google.common.base.Optional;
import gov.loc.repository.bagit.domain.Bag;
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/dspace/pack/bagit/BagItAipWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;

import com.google.common.io.CountingOutputStream;
import org.apache.commons.io.FileUtils;
Expand All @@ -53,6 +53,8 @@
import org.joda.time.LocalDate;
import org.joda.time.format.ISODateTimeFormat;

import jakarta.xml.bind.JAXBException;

/**
* The BagItAipWriter handles the packaging of DSpaceObjects into their respective bags. It processes the metadata and
* bitstreams given to it by the various {@link org.dspace.pack.Packer}s in order to write the object.properties,
Expand Down
71 changes: 39 additions & 32 deletions src/main/java/org/dspace/pack/bagit/BagItPolicyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,45 @@ public static void registerPolicies(final Context context, final DSpaceObject dS
// then use the authorizationService to add all policies to the dso
final List<ResourcePolicy> resourcePolicies = new ArrayList<>();
for (Policy policy : policies.getPolicies()) {
final ResourcePolicy resourcePolicy = resourcePolicyService.create(context);
EPerson ePerson = null;
Group group = null;

final String groupName = policy.getGroup();
final String ePersonEmail = policy.getEperson();

if (groupName != null) {
final String nameForImport;

if (groupName.equalsIgnoreCase(Group.ADMIN) || groupName.equalsIgnoreCase(Group.ANONYMOUS)) {
nameForImport = groupName;
} else {
nameForImport = PackageUtils.translateGroupNameForImport(context, groupName);
}

group = groupService.findByName(context, nameForImport);
if (group == null) {
logger.warn("Could not find group {}} in the database! If this" +
"is either the ADMIN or ANONYMOUS group check that your database is" +
"initialized correctly.", nameForImport);
}
} else if (ePersonEmail != null) {
ePerson = ePersonService.findByEmail(context, ePersonEmail);
if (ePerson == null) {
logger.warn("Could not find ePerson {} in the database!", ePersonEmail);
}
}

// ResourcePolicy requires either a Group or an EPerson
if (ePerson == null && group == null) {
throw new PackageException("ResourcePolicy requires either a Group or an EPerson. Neither were found.");
}

final ResourcePolicy resourcePolicy = resourcePolicyService.create(context, ePerson, group);
if (resourcePolicy == null) {
throw new PackageException("Unable to create a ResourcePolicy.");
}

// Set remaining ResourcePolicy fields
resourcePolicy.setdSpaceObject(dSpaceObject);

final String rpName = policy.getName();
Expand Down Expand Up @@ -167,37 +205,6 @@ public static void registerPolicies(final Context context, final DSpaceObject dS
}
}

final String groupName = policy.getGroup();
final String epersonEmail = policy.getEperson();
if (groupName != null) {
final String nameForImport;

if (groupName.equalsIgnoreCase(Group.ADMIN) || groupName.equalsIgnoreCase(Group.ANONYMOUS)) {
nameForImport = groupName;
} else {
nameForImport = PackageUtils.translateGroupNameForImport(context, groupName);
}

final Group group = groupService.findByName(context, nameForImport);
if (group == null) {
throw new PackageException("Could not find group " + nameForImport + " in the database! If this" +
"is either the ADMIN or ANONYMOUS group check that your database is" +
"initialized correctly.");
}

resourcePolicy.setGroup(group);
} else if (epersonEmail != null) {
final EPerson ePerson = ePersonService.findByEmail(context, epersonEmail);
if (ePerson == null) {
throw new PackageException("Could not find ePerson " + epersonEmail + " in the database!");
}

resourcePolicy.setEPerson(ePerson);
} else {
// throw an exception as well?
logger.warn("Cannot import policy, no rp-group or rp-eperson attribute found on value!");
}

final Integer action = actionMapper().get(policy.getAction());
// exception if null?
if (action != null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/dspace/pack/bagit/CatalogPacker.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public File pack(File packDir) throws IOException, SQLException, AuthorizeExcept
properties.put(OBJFILE, objectProperties);

// members file
if (members.size() > 0) {
if (!members.isEmpty()) {
properties.put("members", members);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/dspace/pack/bagit/CommunityPacker.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public File pack(File packDir) throws AuthorizeException, SQLException, IOExcept
// collect the policy
final Policies policy = BagItPolicyUtil.getPolicy(context, community);

// and finally get he roles
// and finally get the roles
DSpaceRoles dSpaceRoles = null;
try {
dSpaceRoles = BagItRolesUtil.getDSpaceRoles(context, community);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/dspace/pack/bagit/ItemPacker.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public File pack(final File packDir) throws AuthorizeException, IOException, SQL
linked.append(coll.getHandle()).append(",");
}
}
if (linked.length() > 0) {
if (!linked.isEmpty()) {
objectProperties.add(OTHER_IDS + PROPERTIES_DELIMITER + linked.substring(0, linked.length() - 1));
}
if (item.isWithdrawn()) {
Expand Down Expand Up @@ -304,7 +304,7 @@ public RefFilter(String filter)
{
String[] parts = filter.split(" ");
bundle = parts[0];
size = Long.valueOf(parts[1]);
size = Long.parseLong(parts[1]);
url = parts[2];
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;

/**
* Root tag for metadata.xml. Contains only a list of metadata {@link Value}s.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/dspace/pack/bagit/xml/metadata/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import static org.dspace.eperson.service.EPersonService.MD_LASTNAME;
import static org.dspace.eperson.service.EPersonService.MD_PHONE;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlValue;

import org.dspace.content.MetadataFieldName;
import org.dspace.content.MetadataValue;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/dspace/pack/bagit/xml/policy/Policies.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;

/**
* Root element for policy.xml. Contains only a list of {@link Policy} objects.
Expand Down
Loading

0 comments on commit a079e64

Please sign in to comment.