Merge branch 'main' into enhancement/xoai-access-status-plugin

This commit is contained in:
Paulo Graça
2023-06-02 09:47:12 +01:00
committed by GitHub
23 changed files with 560 additions and 125 deletions

View File

@@ -22,7 +22,9 @@ public class ImageMagickPdfThumbnailFilter extends ImageMagickThumbnailFilter {
File f2 = null; File f2 = null;
File f3 = null; File f3 = null;
try { try {
f2 = getImageFile(f, 0, verbose); // Step 1: get an image from our PDF file, with PDF-specific processing options
f2 = getImageFile(f, verbose);
// Step 2: use the image above to create the final resized and rotated thumbnail
f3 = getThumbnailFile(f2, verbose); f3 = getThumbnailFile(f2, verbose);
byte[] bytes = Files.readAllBytes(f3.toPath()); byte[] bytes = Files.readAllBytes(f3.toPath());
return new ByteArrayInputStream(bytes); return new ByteArrayInputStream(bytes);

View File

@@ -116,9 +116,17 @@ public abstract class ImageMagickThumbnailFilter extends MediaFilter {
return f2; return f2;
} }
public File getImageFile(File f, int page, boolean verbose) /**
* Return an image from a bitstream with specific processing options for
* PDFs. This is only used by ImageMagickPdfThumbnailFilter in order to
* generate an intermediate image file for use with getThumbnailFile.
*/
public File getImageFile(File f, boolean verbose)
throws IOException, InterruptedException, IM4JavaException { throws IOException, InterruptedException, IM4JavaException {
File f2 = new File(f.getParentFile(), f.getName() + ".jpg"); // Writing an intermediate file to disk is inefficient, but since we're
// doing it anyway, we should use a lossless format. IM's internal MIFF
// is lossless like PNG and TIFF, but much faster.
File f2 = new File(f.getParentFile(), f.getName() + ".miff");
f2.deleteOnExit(); f2.deleteOnExit();
ConvertCmd cmd = new ConvertCmd(); ConvertCmd cmd = new ConvertCmd();
IMOperation op = new IMOperation(); IMOperation op = new IMOperation();
@@ -155,7 +163,7 @@ public abstract class ImageMagickThumbnailFilter extends MediaFilter {
op.define("pdf:use-cropbox=true"); op.define("pdf:use-cropbox=true");
} }
String s = "[" + page + "]"; String s = "[0]";
op.addImage(f.getAbsolutePath() + s); op.addImage(f.getAbsolutePath() + s);
if (configurationService.getBooleanProperty(PRE + ".flatten", true)) { if (configurationService.getBooleanProperty(PRE + ".flatten", true)) {
op.flatten(); op.flatten();
@@ -208,20 +216,20 @@ public abstract class ImageMagickThumbnailFilter extends MediaFilter {
if (description != null) { if (description != null) {
if (replaceRegex.matcher(description).matches()) { if (replaceRegex.matcher(description).matches()) {
if (verbose) { if (verbose) {
System.out.format("%s %s matches pattern and is replacable.%n", System.out.format("%s %s matches pattern and is replaceable.%n",
description, nsrc); description, n);
} }
continue; continue;
} }
if (description.equals(getDescription())) { if (description.equals(getDescription())) {
if (verbose) { if (verbose) {
System.out.format("%s %s is replaceable.%n", System.out.format("%s %s is replaceable.%n",
getDescription(), nsrc); getDescription(), n);
} }
continue; continue;
} }
} }
System.out.format("Custom Thumbnail exists for %s for item %s. Thumbnail will not be generated.%n", System.out.format("Custom thumbnail exists for %s for item %s. Thumbnail will not be generated.%n",
nsrc, item.getHandle()); nsrc, item.getHandle());
return false; return false;
} }

View File

@@ -11,6 +11,9 @@ import java.io.Serializable;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.dspace.content.InProgressSubmission;
import org.dspace.content.WorkspaceItem;
import org.hibernate.proxy.HibernateProxyHelper;
/** /**
* Class representing configuration for a single step within an Item Submission * Class representing configuration for a single step within an Item Submission
@@ -173,6 +176,38 @@ public class SubmissionStepConfig implements Serializable {
return visibilityOutside; return visibilityOutside;
} }
/**
* Check if given submission section object is hidden for the current submission scope
*
* @param obj the InProgressSubmission to check
* @return true if the submission section is hidden, false otherwise
*/
public boolean isHiddenForInProgressSubmission(InProgressSubmission obj) {
String scopeToCheck = getScope(obj);
if (scope == null || scopeToCheck == null) {
return false;
}
String visibility = getVisibility();
String visibilityOutside = getVisibilityOutside();
if (scope.equalsIgnoreCase(scopeToCheck)) {
return "hidden".equalsIgnoreCase(visibility);
} else {
return visibilityOutside == null || "hidden".equalsIgnoreCase(visibilityOutside);
}
}
private String getScope(InProgressSubmission obj) {
if (HibernateProxyHelper.getClassWithoutInitializingProxy(obj).equals(WorkspaceItem.class)) {
return "submission";
}
return "workflow";
}
/** /**
* Get the number of this step in the current Submission process config. * Get the number of this step in the current Submission process config.
* Step numbers start with #0 (although step #0 is ALWAYS the special * Step numbers start with #0 (although step #0 is ALWAYS the special

View File

@@ -27,13 +27,14 @@ import org.dspace.versioning.Version;
import org.dspace.versioning.VersionHistory; import org.dspace.versioning.VersionHistory;
import org.dspace.versioning.service.VersionHistoryService; import org.dspace.versioning.service.VersionHistoryService;
import org.dspace.versioning.service.VersioningService; import org.dspace.versioning.service.VersioningService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
/** /**
* @author Marsa Haoua * @author Marsa Haoua
* @author Pascal-Nicolas Becker (dspace at pascal dash becker dot de) * @author Pascal-Nicolas Becker (dspace at pascal dash becker dot de)
*/ */
public class VersionedDOIIdentifierProvider extends DOIIdentifierProvider { public class VersionedDOIIdentifierProvider extends DOIIdentifierProvider implements InitializingBean {
/** /**
* log4j category * log4j category
*/ */
@@ -49,6 +50,19 @@ public class VersionedDOIIdentifierProvider extends DOIIdentifierProvider {
@Autowired(required = true) @Autowired(required = true)
protected VersionHistoryService versionHistoryService; protected VersionHistoryService versionHistoryService;
/**
* After all the properties are set check that the versioning is enabled
*
* @throws Exception throws an exception if this isn't the case
*/
@Override
public void afterPropertiesSet() throws Exception {
if (!configurationService.getBooleanProperty("versioning.enabled", true)) {
throw new RuntimeException("the " + VersionedDOIIdentifierProvider.class.getName() +
" is enabled, but the versioning is disabled.");
}
}
@Override @Override
public String mint(Context context, DSpaceObject dso) throws IdentifierException { public String mint(Context context, DSpaceObject dso) throws IdentifierException {
return mint(context, dso, this.filter); return mint(context, dso, this.filter);

View File

@@ -35,6 +35,7 @@ import org.dspace.versioning.Version;
import org.dspace.versioning.VersionHistory; import org.dspace.versioning.VersionHistory;
import org.dspace.versioning.service.VersionHistoryService; import org.dspace.versioning.service.VersionHistoryService;
import org.dspace.versioning.service.VersioningService; import org.dspace.versioning.service.VersioningService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -45,7 +46,7 @@ import org.springframework.stereotype.Component;
* @author Pascal-Nicolas Becker (dspace at pascal dash becker dot de) * @author Pascal-Nicolas Becker (dspace at pascal dash becker dot de)
*/ */
@Component @Component
public class VersionedHandleIdentifierProvider extends IdentifierProvider { public class VersionedHandleIdentifierProvider extends IdentifierProvider implements InitializingBean {
/** /**
* log4j category * log4j category
*/ */
@@ -71,6 +72,19 @@ public class VersionedHandleIdentifierProvider extends IdentifierProvider {
@Autowired(required = true) @Autowired(required = true)
protected ContentServiceFactory contentServiceFactory; protected ContentServiceFactory contentServiceFactory;
/**
* After all the properties are set check that the versioning is enabled
*
* @throws Exception throws an exception if this isn't the case
*/
@Override
public void afterPropertiesSet() throws Exception {
if (!configurationService.getBooleanProperty("versioning.enabled", true)) {
throw new RuntimeException("the " + VersionedHandleIdentifierProvider.class.getName() +
" is enabled, but the versioning is disabled.");
}
}
@Override @Override
public boolean supports(Class<? extends Identifier> identifier) { public boolean supports(Class<? extends Identifier> identifier) {
return Handle.class.isAssignableFrom(identifier); return Handle.class.isAssignableFrom(identifier);

View File

@@ -30,6 +30,7 @@ import org.dspace.versioning.Version;
import org.dspace.versioning.VersionHistory; import org.dspace.versioning.VersionHistory;
import org.dspace.versioning.service.VersionHistoryService; import org.dspace.versioning.service.VersionHistoryService;
import org.dspace.versioning.service.VersioningService; import org.dspace.versioning.service.VersioningService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -39,7 +40,8 @@ import org.springframework.stereotype.Component;
* @author Ben Bosman (ben at atmire dot com) * @author Ben Bosman (ben at atmire dot com)
*/ */
@Component @Component
public class VersionedHandleIdentifierProviderWithCanonicalHandles extends IdentifierProvider { public class VersionedHandleIdentifierProviderWithCanonicalHandles extends IdentifierProvider
implements InitializingBean {
/** /**
* log4j category * log4j category
*/ */
@@ -65,6 +67,19 @@ public class VersionedHandleIdentifierProviderWithCanonicalHandles extends Ident
@Autowired(required = true) @Autowired(required = true)
private ItemService itemService; private ItemService itemService;
/**
* After all the properties are set check that the versioning is enabled
*
* @throws Exception throws an exception if this isn't the case
*/
@Override
public void afterPropertiesSet() throws Exception {
if (!configurationService.getBooleanProperty("versioning.enabled", true)) {
throw new RuntimeException("the " + VersionedHandleIdentifierProviderWithCanonicalHandles.class.getName() +
" is enabled, but the versioning is disabled.");
}
}
@Override @Override
public boolean supports(Class<? extends Identifier> identifier) { public boolean supports(Class<? extends Identifier> identifier) {
return Handle.class.isAssignableFrom(identifier); return Handle.class.isAssignableFrom(identifier);

View File

@@ -11,6 +11,8 @@ import java.text.ParseException;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.ResourcePolicy; import org.dspace.authorize.ResourcePolicy;
import org.dspace.authorize.service.AuthorizeService; import org.dspace.authorize.service.AuthorizeService;
@@ -21,6 +23,7 @@ import org.dspace.core.Context;
import org.dspace.eperson.Group; import org.dspace.eperson.Group;
import org.dspace.eperson.service.GroupService; import org.dspace.eperson.service.GroupService;
import org.dspace.util.DateMathParser; import org.dspace.util.DateMathParser;
import org.dspace.util.TimeHelpers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
/** /**
@@ -28,8 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
* set permission on a file. An option is defined by a name such as "open * set permission on a file. An option is defined by a name such as "open
* access", "embargo", "restricted access", etc. and some optional attributes to * access", "embargo", "restricted access", etc. and some optional attributes to
* better clarify the constraints and input available to the user. For instance * better clarify the constraints and input available to the user. For instance
* an embargo option could allow to set a start date not longer than 3 years, * an embargo option could allow to set a start date not longer than 3 years.
* etc
* *
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it) * @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
*/ */
@@ -44,9 +46,9 @@ public class AccessConditionOption {
@Autowired @Autowired
private ResourcePolicyService resourcePolicyService; private ResourcePolicyService resourcePolicyService;
DateMathParser dateMathParser = new DateMathParser(); private static final Logger LOG = LogManager.getLogger();
/** An unique name identifying the access contion option **/ /** A unique name identifying the access condition option. **/
private String name; private String name;
/** /**
@@ -147,6 +149,9 @@ public class AccessConditionOption {
* startDate should be null. Otherwise startDate may not be null. * startDate should be null. Otherwise startDate may not be null.
* @param endDate end date of the resource policy. If {@link #getHasEndDate()} returns false, * @param endDate end date of the resource policy. If {@link #getHasEndDate()} returns false,
* endDate should be null. Otherwise endDate may not be null. * endDate should be null. Otherwise endDate may not be null.
* @throws SQLException passed through.
* @throws AuthorizeException passed through.
* @throws ParseException passed through (indicates problem with a date).
*/ */
public void createResourcePolicy(Context context, DSpaceObject obj, String name, String description, public void createResourcePolicy(Context context, DSpaceObject obj, String name, String description,
Date startDate, Date endDate) Date startDate, Date endDate)
@@ -175,17 +180,25 @@ public class AccessConditionOption {
} }
/** /**
* Validate the policy properties, throws exceptions if any is not valid * Validate the policy properties, throws exceptions if any is not valid.
* *
* @param context DSpace context * @param context DSpace context.
* @param name Name of the resource policy * @param name Name of the resource policy.
* @param startDate Start date of the resource policy. If {@link #getHasStartDate()} * @param startDate Start date of the resource policy. If
* returns false, startDate should be null. Otherwise startDate may not be null. * {@link #getHasStartDate()} returns false, startDate
* @param endDate End date of the resource policy. If {@link #getHasEndDate()} * should be null. Otherwise startDate may not be null.
* returns false, endDate should be null. Otherwise endDate may not be null. * @param endDate End date of the resource policy. If
* {@link #getHasEndDate()} returns false, endDate should
* be null. Otherwise endDate may not be null.
* @throws IllegalStateException if a date is required and absent,
* a date is not required and present, or a date exceeds its
* configured maximum.
* @throws ParseException passed through.
*/ */
private void validateResourcePolicy(Context context, String name, Date startDate, Date endDate) private void validateResourcePolicy(Context context, String name, Date startDate, Date endDate)
throws SQLException, AuthorizeException, ParseException { throws IllegalStateException, ParseException {
LOG.debug("Validate policy dates: name '{}', startDate {}, endDate {}",
name, startDate, endDate);
if (getHasStartDate() && Objects.isNull(startDate)) { if (getHasStartDate() && Objects.isNull(startDate)) {
throw new IllegalStateException("The access condition " + getName() + " requires a start date."); throw new IllegalStateException("The access condition " + getName() + " requires a start date.");
} }
@@ -199,29 +212,33 @@ public class AccessConditionOption {
throw new IllegalStateException("The access condition " + getName() + " cannot contain an end date."); throw new IllegalStateException("The access condition " + getName() + " cannot contain an end date.");
} }
DateMathParser dateMathParser = new DateMathParser();
Date latestStartDate = null; Date latestStartDate = null;
if (Objects.nonNull(getStartDateLimit())) { if (Objects.nonNull(getStartDateLimit())) {
latestStartDate = dateMathParser.parseMath(getStartDateLimit()); latestStartDate = TimeHelpers.toMidnightUTC(dateMathParser.parseMath(getStartDateLimit()));
} }
Date latestEndDate = null; Date latestEndDate = null;
if (Objects.nonNull(getEndDateLimit())) { if (Objects.nonNull(getEndDateLimit())) {
latestEndDate = dateMathParser.parseMath(getEndDateLimit()); latestEndDate = TimeHelpers.toMidnightUTC(dateMathParser.parseMath(getEndDateLimit()));
} }
LOG.debug(" latestStartDate {}, latestEndDate {}",
latestStartDate, latestEndDate);
// throw if startDate after latestStartDate // throw if startDate after latestStartDate
if (Objects.nonNull(startDate) && Objects.nonNull(latestStartDate) && startDate.after(latestStartDate)) { if (Objects.nonNull(startDate) && Objects.nonNull(latestStartDate) && startDate.after(latestStartDate)) {
throw new IllegalStateException(String.format( throw new IllegalStateException(String.format(
"The start date of access condition %s should be earlier than %s from now.", "The start date of access condition %s should be earlier than %s from now (%s).",
getName(), getStartDateLimit() getName(), getStartDateLimit(), dateMathParser.getNow()
)); ));
} }
// throw if endDate after latestEndDate // throw if endDate after latestEndDate
if (Objects.nonNull(endDate) && Objects.nonNull(latestEndDate) && endDate.after(latestEndDate)) { if (Objects.nonNull(endDate) && Objects.nonNull(latestEndDate) && endDate.after(latestEndDate)) {
throw new IllegalStateException(String.format( throw new IllegalStateException(String.format(
"The end date of access condition %s should be earlier than %s from now.", "The end date of access condition %s should be earlier than %s from now (%s).",
getName(), getEndDateLimit() getName(), getEndDateLimit(), dateMathParser.getNow()
)); ));
} }
} }

View File

@@ -26,12 +26,15 @@ import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/** /**
* This class (Apache license) is copied from Apache Solr and add some tweaks to resolve unneeded dependency: * This class (Apache license) is copied from Apache Solr, adding some tweaks to
* https://raw.githubusercontent.com/apache/lucene-solr/releases/lucene-solr/7.1.0/solr/core/src/java/org/apache/solr * resolve an unneeded dependency. See
* /util/DateMathParser.java * <a href='https://raw.githubusercontent.com/apache/lucene-solr/releases/lucene-solr/7.1.0/solr/core/src/java/org/apache/solr/util/DateMathParser.java'>the original</a>.
* *
* <p>
* A Simple Utility class for parsing "math" like strings relating to Dates. * A Simple Utility class for parsing "math" like strings relating to Dates.
* *
* <p> * <p>
@@ -78,7 +81,7 @@ import java.util.regex.Pattern;
* "<code>setNow</code>" in the interim). The default value of 'now' is * "<code>setNow</code>" in the interim). The default value of 'now' is
* the time at the moment the <code>DateMathParser</code> instance is * the time at the moment the <code>DateMathParser</code> instance is
* constructed, unless overridden by the {@link CommonParams#NOW NOW} * constructed, unless overridden by the {@link CommonParams#NOW NOW}
* request param. * request parameter.
* </p> * </p>
* *
* <p> * <p>
@@ -88,7 +91,7 @@ import java.util.regex.Pattern;
* cascades to rounding of HOUR, MIN, MONTH, YEAR as well. The default * cascades to rounding of HOUR, MIN, MONTH, YEAR as well. The default
* <code>TimeZone</code> used is <code>UTC</code> unless overridden by the * <code>TimeZone</code> used is <code>UTC</code> unless overridden by the
* {@link CommonParams#TZ TZ} * {@link CommonParams#TZ TZ}
* request param. * request parameter.
* </p> * </p>
* *
* <p> * <p>
@@ -102,6 +105,8 @@ import java.util.regex.Pattern;
*/ */
public class DateMathParser { public class DateMathParser {
private static final Logger LOG = LogManager.getLogger();
public static final TimeZone UTC = TimeZone.getTimeZone("UTC"); public static final TimeZone UTC = TimeZone.getTimeZone("UTC");
/** /**
@@ -119,12 +124,12 @@ public class DateMathParser {
/** /**
* A mapping from (uppercased) String labels identifying time units, * A mapping from (uppercased) String labels identifying time units,
* to the corresponding {@link ChronoUnit} enum (e.g. "YEARS") used to * to the corresponding {@link ChronoUnit} value (e.g. "YEARS") used to
* set/add/roll that unit of measurement. * set/add/roll that unit of measurement.
* *
* <p> * <p>
* A single logical unit of time might be represented by multiple labels * A single logical unit of time might be represented by multiple labels
* for convenience (ie: <code>DATE==DAYS</code>, * for convenience (i.e. <code>DATE==DAYS</code>,
* <code>MILLI==MILLIS</code>) * <code>MILLI==MILLIS</code>)
* </p> * </p>
* *
@@ -220,6 +225,7 @@ public class DateMathParser {
* *
* @param now an optional fixed date to use as "NOW" * @param now an optional fixed date to use as "NOW"
* @param val the string to parse * @param val the string to parse
* @return result of applying the parsed expression to "NOW".
* @throws Exception * @throws Exception
*/ */
public static Date parseMath(Date now, String val) throws Exception { public static Date parseMath(Date now, String val) throws Exception {
@@ -308,6 +314,7 @@ public class DateMathParser {
/** /**
* Defines this instance's concept of "now". * Defines this instance's concept of "now".
* *
* @param n new value of "now".
* @see #getNow * @see #getNow
*/ */
public void setNow(Date n) { public void setNow(Date n) {
@@ -316,12 +323,12 @@ public class DateMathParser {
/** /**
* Returns a clone of this instance's concept of "now" (never null). * Returns a clone of this instance's concept of "now" (never null).
*
* If setNow was never called (or if null was specified) then this method * If setNow was never called (or if null was specified) then this method
* first defines 'now' as the value dictated by the SolrRequestInfo if it * first defines 'now' as the value dictated by the SolrRequestInfo if it
* exists -- otherwise it uses a new Date instance at the moment getNow() * exists -- otherwise it uses a new Date instance at the moment getNow()
* is first called. * is first called.
* *
* @return "now".
* @see #setNow * @see #setNow
* @see SolrRequestInfo#getNOW * @see SolrRequestInfo#getNOW
*/ */
@@ -334,9 +341,12 @@ public class DateMathParser {
} }
/** /**
* Parses a string of commands relative "now" are returns the resulting Date. * Parses a date expression relative to "now".
* *
* @throws ParseException positions in ParseExceptions are token positions, not character positions. * @param math a date expression such as "+24MONTHS".
* @return the result of applying the expression to the current time.
* @throws ParseException positions in ParseExceptions are token positions,
* not character positions.
*/ */
public Date parseMath(String math) throws ParseException { public Date parseMath(String math) throws ParseException {
/* check for No-Op */ /* check for No-Op */
@@ -344,6 +354,8 @@ public class DateMathParser {
return getNow(); return getNow();
} }
LOG.debug("parsing {}", math);
ZoneId zoneId = zone.toZoneId(); ZoneId zoneId = zone.toZoneId();
// localDateTime is a date and time local to the timezone specified // localDateTime is a date and time local to the timezone specified
LocalDateTime localDateTime = ZonedDateTime.ofInstant(getNow().toInstant(), zoneId).toLocalDateTime(); LocalDateTime localDateTime = ZonedDateTime.ofInstant(getNow().toInstant(), zoneId).toLocalDateTime();
@@ -394,11 +406,44 @@ public class DateMathParser {
} }
} }
LOG.debug("returning {}", localDateTime);
return Date.from(ZonedDateTime.of(localDateTime, zoneId).toInstant()); return Date.from(ZonedDateTime.of(localDateTime, zoneId).toInstant());
} }
private static Pattern splitter = Pattern.compile("\\b|(?<=\\d)(?=\\D)"); private static Pattern splitter = Pattern.compile("\\b|(?<=\\d)(?=\\D)");
/**
* For manual testing. With one argument, test one-argument parseMath.
* With two (or more) arguments, test two-argument parseMath.
*
* @param argv date math expressions.
* @throws java.lang.Exception passed through.
*/
public static void main(String[] argv)
throws Exception {
DateMathParser parser = new DateMathParser();
try {
Date parsed;
if (argv.length <= 0) {
System.err.println("Date math expression(s) expected.");
}
if (argv.length > 0) {
parsed = parser.parseMath(argv[0]);
System.out.format("Applied %s to implicit current time: %s%n",
argv[0], parsed.toString());
}
if (argv.length > 1) {
parsed = DateMathParser.parseMath(new Date(), argv[1]);
System.out.format("Applied %s to explicit current time: %s%n",
argv[1], parsed.toString());
}
} catch (ParseException ex) {
System.err.format("Oops: %s%n", ex.getMessage());
}
}
} }

View File

@@ -0,0 +1,42 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.util;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
/**
* Various manipulations of dates and times.
*
* @author mwood
*/
public class TimeHelpers {
private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
/**
* Never instantiate this class.
*/
private TimeHelpers() {}
/**
* Set a Date's time to midnight UTC.
*
* @param from some date-time.
* @return midnight UTC of the supplied date-time.
*/
public static Date toMidnightUTC(Date from) {
GregorianCalendar calendar = new GregorianCalendar(UTC);
calendar.setTime(from);
calendar.set(GregorianCalendar.HOUR_OF_DAY, 0);
calendar.set(GregorianCalendar.MINUTE, 0);
calendar.set(GregorianCalendar.SECOND, 0);
calendar.set(GregorianCalendar.MILLISECOND, 0);
return calendar.getTime();
}
}

View File

@@ -23,6 +23,7 @@
<name-map collection-handle="123456789/qualdrop-test" submission-name="qualdroptest"/> <name-map collection-handle="123456789/qualdrop-test" submission-name="qualdroptest"/>
<name-map collection-handle="123456789/typebind-test" submission-name="typebindtest"/> <name-map collection-handle="123456789/typebind-test" submission-name="typebindtest"/>
<name-map collection-handle="123456789/accessCondition-not-discoverable" submission-name="accessConditionNotDiscoverable"/> <name-map collection-handle="123456789/accessCondition-not-discoverable" submission-name="accessConditionNotDiscoverable"/>
<name-map collection-handle="123456789/test-hidden" submission-name="test-hidden"/>
</submission-map> </submission-map>
@@ -54,7 +55,6 @@
<heading></heading> <heading></heading>
<processing-class>org.dspace.app.rest.submit.step.CollectionStep</processing-class> <processing-class>org.dspace.app.rest.submit.step.CollectionStep</processing-class>
<type>collection</type> <type>collection</type>
<scope visibility="hidden" visibilityOutside="hidden">submission</scope>
</step-definition> </step-definition>
<step-definition id="traditionalpageone" mandatory="true"> <step-definition id="traditionalpageone" mandatory="true">
<heading>submit.progressbar.describe.stepone</heading> <heading>submit.progressbar.describe.stepone</heading>
@@ -149,6 +149,34 @@
<processing-class>org.dspace.app.rest.submit.step.ShowIdentifiersStep</processing-class> <processing-class>org.dspace.app.rest.submit.step.ShowIdentifiersStep</processing-class>
<type>identifiers</type> <type>identifiers</type>
</step-definition> </step-definition>
<step-definition id="test-outside-workflow-hidden" mandatory="true">
<heading>submit.progressbar.describe.stepone</heading>
<processing-class>org.dspace.app.rest.submit.step.DescribeStep</processing-class>
<type>submission-form</type>
<scope visibilityOutside="hidden">workflow</scope>
</step-definition>
<step-definition id="test-outside-submission-hidden" mandatory="true">
<heading>submit.progressbar.describe.stepone</heading>
<processing-class>org.dspace.app.rest.submit.step.DescribeStep</processing-class>
<type>submission-form</type>
<scope visibilityOutside="hidden">submission</scope>
</step-definition>
<step-definition id="test-never-hidden" mandatory="true">
<heading></heading>
<processing-class>org.dspace.app.rest.submit.step.CollectionStep</processing-class>
<type>collection</type>
</step-definition>
<step-definition id="test-always-hidden" mandatory="true">
<heading></heading>
<processing-class>org.dspace.app.rest.submit.step.CollectionStep</processing-class>
<type>collection</type>
<scope visibility="hidden" visibilityOutside="hidden">submission</scope>
</step-definition>
</step-definitions> </step-definitions>
<!-- The submission-definitions map lays out the detailed definition of --> <!-- The submission-definitions map lays out the detailed definition of -->
@@ -222,6 +250,13 @@
<step id="notDiscoverable"/> <step id="notDiscoverable"/>
</submission-process> </submission-process>
<submission-process name="test-hidden">
<step id="test-outside-workflow-hidden"/>
<step id="test-outside-submission-hidden"/>
<step id="test-never-hidden"/>
<step id="test-always-hidden"/>
</submission-process>
</submission-definitions> </submission-definitions>
</item-submission> </item-submission>

View File

@@ -436,6 +436,35 @@ it, please enter the types and the actual numbers or codes.</hint>
</field> </field>
</row> </row>
</form> </form>
<form name="test-outside-workflow-hidden">
<row>
<field>
<dc-schema>dc</dc-schema>
<dc-element>title</dc-element>
<dc-qualifier></dc-qualifier>
<repeatable>false</repeatable>
<label>Title</label>
<input-type>onebox</input-type>
<required>Field required</required>
</field>
</row>
</form>
<form name="test-outside-submission-hidden">
<row>
<field>
<dc-schema>dc</dc-schema>
<dc-element>type</dc-element>
<dc-qualifier></dc-qualifier>
<repeatable>false</repeatable>
<label>Type</label>
<input-type>onebox</input-type>
<required>Field required</required>
</field>
</row>
</form>
</form-definitions> </form-definitions>

View File

@@ -189,6 +189,10 @@ public class WorkspaceItemBuilder extends AbstractBuilder<WorkspaceItem, Workspa
return addMetadataValue(MetadataSchemaEnum.DC.getName(),"description", "abstract", subject); return addMetadataValue(MetadataSchemaEnum.DC.getName(),"description", "abstract", subject);
} }
public WorkspaceItemBuilder withType(final String type) {
return addMetadataValue(MetadataSchemaEnum.DC.getName(),"type", null, type);
}
public WorkspaceItemBuilder grantLicense() { public WorkspaceItemBuilder grantLicense() {
Item item = workspaceItem.getItem(); Item item = workspaceItem.getItem();
String license; String license;

View File

@@ -0,0 +1,34 @@
/**
* 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.util;
import static org.junit.Assert.assertEquals;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.Date;
import org.junit.Test;
/**
* Test {@link TimeHelpers}.
* @author Mark H. Wood <mwood@iupui.edu>
*/
public class TimeHelpersTest {
/**
* Test of toMidnightUTC method, of class TimeHelpers.
*/
@Test
public void testToMidnightUTC() {
System.out.println("toMidnightUTC");
Date from = Date.from(ZonedDateTime.of(1957, 01, 27, 04, 05, 06, 007, ZoneOffset.UTC).toInstant());
Date expResult = Date.from(ZonedDateTime.of(1957, 01, 27, 00, 00, 00, 000, ZoneOffset.UTC).toInstant());
Date result = TimeHelpers.toMidnightUTC(from);
assertEquals(expResult, result);
}
}

View File

@@ -86,6 +86,10 @@ public abstract class AInprogressItemConverter<T extends InProgressSubmission,
for (SubmissionSectionRest sections : def.getPanels()) { for (SubmissionSectionRest sections : def.getPanels()) {
SubmissionStepConfig stepConfig = submissionSectionConverter.toModel(sections); SubmissionStepConfig stepConfig = submissionSectionConverter.toModel(sections);
if (stepConfig.isHiddenForInProgressSubmission(obj)) {
continue;
}
/* /*
* First, load the step processing class (using the current * First, load the step processing class (using the current
* class loader) * class loader)

View File

@@ -6,7 +6,9 @@
* http://www.dspace.org/license/ * http://www.dspace.org/license/
*/ */
package org.dspace.app.rest.converter; package org.dspace.app.rest.converter;
import java.text.ParseException; import java.text.ParseException;
import java.util.Date;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.dspace.app.rest.model.AccessConditionOptionRest; import org.dspace.app.rest.model.AccessConditionOptionRest;
@@ -15,6 +17,7 @@ import org.dspace.app.rest.projection.Projection;
import org.dspace.submit.model.AccessConditionConfiguration; import org.dspace.submit.model.AccessConditionConfiguration;
import org.dspace.submit.model.AccessConditionOption; import org.dspace.submit.model.AccessConditionOption;
import org.dspace.util.DateMathParser; import org.dspace.util.DateMathParser;
import org.dspace.util.TimeHelpers;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
@@ -27,21 +30,21 @@ import org.springframework.stereotype.Component;
public class SubmissionAccessOptionConverter public class SubmissionAccessOptionConverter
implements DSpaceConverter<AccessConditionConfiguration, SubmissionAccessOptionRest> { implements DSpaceConverter<AccessConditionConfiguration, SubmissionAccessOptionRest> {
DateMathParser dateMathParser = new DateMathParser();
@Override @Override
public SubmissionAccessOptionRest convert(AccessConditionConfiguration config, Projection projection) { public SubmissionAccessOptionRest convert(AccessConditionConfiguration config, Projection projection) {
SubmissionAccessOptionRest model = new SubmissionAccessOptionRest(); SubmissionAccessOptionRest model = new SubmissionAccessOptionRest();
model.setId(config.getName()); model.setId(config.getName());
model.setCanChangeDiscoverable(config.getCanChangeDiscoverable()); model.setCanChangeDiscoverable(config.getCanChangeDiscoverable());
model.setProjection(projection); model.setProjection(projection);
DateMathParser dateMathParser = new DateMathParser();
for (AccessConditionOption option : config.getOptions()) { for (AccessConditionOption option : config.getOptions()) {
AccessConditionOptionRest optionRest = new AccessConditionOptionRest(); AccessConditionOptionRest optionRest = new AccessConditionOptionRest();
optionRest.setHasStartDate(option.getHasStartDate()); optionRest.setHasStartDate(option.getHasStartDate());
optionRest.setHasEndDate(option.getHasEndDate()); optionRest.setHasEndDate(option.getHasEndDate());
if (StringUtils.isNotBlank(option.getStartDateLimit())) { if (StringUtils.isNotBlank(option.getStartDateLimit())) {
try { try {
optionRest.setMaxStartDate(dateMathParser.parseMath(option.getStartDateLimit())); Date requested = dateMathParser.parseMath(option.getStartDateLimit());
optionRest.setMaxStartDate(TimeHelpers.toMidnightUTC(requested));
} catch (ParseException e) { } catch (ParseException e) {
throw new IllegalStateException("Wrong start date limit configuration for the access condition " throw new IllegalStateException("Wrong start date limit configuration for the access condition "
+ "option named " + option.getName()); + "option named " + option.getName());
@@ -49,7 +52,8 @@ public class SubmissionAccessOptionConverter
} }
if (StringUtils.isNotBlank(option.getEndDateLimit())) { if (StringUtils.isNotBlank(option.getEndDateLimit())) {
try { try {
optionRest.setMaxEndDate(dateMathParser.parseMath(option.getEndDateLimit())); Date requested = dateMathParser.parseMath(option.getEndDateLimit());
optionRest.setMaxEndDate(TimeHelpers.toMidnightUTC(requested));
} catch (ParseException e) { } catch (ParseException e) {
throw new IllegalStateException("Wrong end date limit configuration for the access condition " throw new IllegalStateException("Wrong end date limit configuration for the access condition "
+ "option named " + option.getName()); + "option named " + option.getName());

View File

@@ -10,6 +10,7 @@ package org.dspace.app.rest.repository;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -18,11 +19,11 @@ import org.dspace.app.rest.model.AccessConditionOptionRest;
import org.dspace.app.rest.model.SubmissionUploadRest; import org.dspace.app.rest.model.SubmissionUploadRest;
import org.dspace.app.rest.projection.Projection; import org.dspace.app.rest.projection.Projection;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.eperson.service.GroupService;
import org.dspace.submit.model.AccessConditionOption; import org.dspace.submit.model.AccessConditionOption;
import org.dspace.submit.model.UploadConfiguration; import org.dspace.submit.model.UploadConfiguration;
import org.dspace.submit.model.UploadConfigurationService; import org.dspace.submit.model.UploadConfigurationService;
import org.dspace.util.DateMathParser; import org.dspace.util.DateMathParser;
import org.dspace.util.TimeHelpers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@@ -47,11 +48,6 @@ public class SubmissionUploadRestRepository extends DSpaceRestRepository<Submiss
@Autowired @Autowired
private UploadConfigurationService uploadConfigurationService; private UploadConfigurationService uploadConfigurationService;
@Autowired
GroupService groupService;
DateMathParser dateMathParser = new DateMathParser();
@PreAuthorize("hasAuthority('AUTHENTICATED')") @PreAuthorize("hasAuthority('AUTHENTICATED')")
@Override @Override
public SubmissionUploadRest findOne(Context context, String submitName) { public SubmissionUploadRest findOne(Context context, String submitName) {
@@ -70,7 +66,7 @@ public class SubmissionUploadRestRepository extends DSpaceRestRepository<Submiss
Collection<UploadConfiguration> uploadConfigs = uploadConfigurationService.getMap().values(); Collection<UploadConfiguration> uploadConfigs = uploadConfigurationService.getMap().values();
Projection projection = utils.obtainProjection(); Projection projection = utils.obtainProjection();
List<SubmissionUploadRest> results = new ArrayList<>(); List<SubmissionUploadRest> results = new ArrayList<>();
List<String> configNames = new ArrayList<String>(); List<String> configNames = new ArrayList<>();
for (UploadConfiguration uploadConfig : uploadConfigs) { for (UploadConfiguration uploadConfig : uploadConfigs) {
if (!configNames.contains(uploadConfig.getName())) { if (!configNames.contains(uploadConfig.getName())) {
configNames.add(uploadConfig.getName()); configNames.add(uploadConfig.getName());
@@ -92,13 +88,15 @@ public class SubmissionUploadRestRepository extends DSpaceRestRepository<Submiss
private SubmissionUploadRest convert(Context context, UploadConfiguration config, Projection projection) { private SubmissionUploadRest convert(Context context, UploadConfiguration config, Projection projection) {
SubmissionUploadRest result = new SubmissionUploadRest(); SubmissionUploadRest result = new SubmissionUploadRest();
result.setProjection(projection); result.setProjection(projection);
DateMathParser dateMathParser = new DateMathParser();
for (AccessConditionOption option : config.getOptions()) { for (AccessConditionOption option : config.getOptions()) {
AccessConditionOptionRest optionRest = new AccessConditionOptionRest(); AccessConditionOptionRest optionRest = new AccessConditionOptionRest();
optionRest.setHasStartDate(option.getHasStartDate()); optionRest.setHasStartDate(option.getHasStartDate());
optionRest.setHasEndDate(option.getHasEndDate()); optionRest.setHasEndDate(option.getHasEndDate());
if (StringUtils.isNotBlank(option.getStartDateLimit())) { if (StringUtils.isNotBlank(option.getStartDateLimit())) {
try { try {
optionRest.setMaxStartDate(dateMathParser.parseMath(option.getStartDateLimit())); Date requested = dateMathParser.parseMath(option.getStartDateLimit());
optionRest.setMaxStartDate(TimeHelpers.toMidnightUTC(requested));
} catch (ParseException e) { } catch (ParseException e) {
throw new IllegalStateException("Wrong start date limit configuration for the access condition " throw new IllegalStateException("Wrong start date limit configuration for the access condition "
+ "option named " + option.getName()); + "option named " + option.getName());
@@ -106,7 +104,8 @@ public class SubmissionUploadRestRepository extends DSpaceRestRepository<Submiss
} }
if (StringUtils.isNotBlank(option.getEndDateLimit())) { if (StringUtils.isNotBlank(option.getEndDateLimit())) {
try { try {
optionRest.setMaxEndDate(dateMathParser.parseMath(option.getEndDateLimit())); Date requested = dateMathParser.parseMath(option.getEndDateLimit());
optionRest.setMaxEndDate(TimeHelpers.toMidnightUTC(requested));
} catch (ParseException e) { } catch (ParseException e) {
throw new IllegalStateException("Wrong end date limit configuration for the access condition " throw new IllegalStateException("Wrong end date limit configuration for the access condition "
+ "option named " + option.getName()); + "option named " + option.getName());

View File

@@ -6,9 +6,11 @@
* http://www.dspace.org/license/ * http://www.dspace.org/license/
*/ */
package org.dspace.app.rest.submit.factory.impl; package org.dspace.app.rest.submit.factory.impl;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@@ -23,6 +25,7 @@ import org.dspace.content.Item;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.submit.model.AccessConditionConfiguration; import org.dspace.submit.model.AccessConditionConfiguration;
import org.dspace.submit.model.AccessConditionConfigurationService; import org.dspace.submit.model.AccessConditionConfigurationService;
import org.dspace.util.TimeHelpers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
/** /**
@@ -52,6 +55,18 @@ public class AccessConditionAddPatchOperation extends AddPatchOperation<AccessCo
String[] absolutePath = getAbsolutePath(path).split("/"); String[] absolutePath = getAbsolutePath(path).split("/");
List<AccessConditionDTO> accessConditions = parseAccessConditions(path, value, absolutePath); List<AccessConditionDTO> accessConditions = parseAccessConditions(path, value, absolutePath);
// Clamp access condition dates to midnight UTC
for (AccessConditionDTO condition : accessConditions) {
Date date = condition.getStartDate();
if (null != date) {
condition.setStartDate(TimeHelpers.toMidnightUTC(date));
}
date = condition.getEndDate();
if (null != date) {
condition.setEndDate(TimeHelpers.toMidnightUTC(date));
}
}
verifyAccessConditions(context, configuration, accessConditions); verifyAccessConditions(context, configuration, accessConditions);
if (absolutePath.length == 1) { if (absolutePath.length == 1) {
@@ -65,7 +80,7 @@ public class AccessConditionAddPatchOperation extends AddPatchOperation<AccessCo
} }
private List<AccessConditionDTO> parseAccessConditions(String path, Object value, String[] split) { private List<AccessConditionDTO> parseAccessConditions(String path, Object value, String[] split) {
List<AccessConditionDTO> accessConditions = new ArrayList<AccessConditionDTO>(); List<AccessConditionDTO> accessConditions = new ArrayList<>();
if (split.length == 1) { if (split.length == 1) {
accessConditions = evaluateArrayObject((LateObjectEvaluator) value); accessConditions = evaluateArrayObject((LateObjectEvaluator) value);
} else if (split.length == 2) { } else if (split.length == 2) {

View File

@@ -6,6 +6,7 @@
* http://www.dspace.org/license/ * http://www.dspace.org/license/
*/ */
package org.dspace.app.rest.submit.factory.impl; package org.dspace.app.rest.submit.factory.impl;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@@ -29,6 +30,7 @@ import org.dspace.core.Context;
import org.dspace.submit.model.AccessConditionConfiguration; import org.dspace.submit.model.AccessConditionConfiguration;
import org.dspace.submit.model.AccessConditionConfigurationService; import org.dspace.submit.model.AccessConditionConfigurationService;
import org.dspace.submit.model.AccessConditionOption; import org.dspace.submit.model.AccessConditionOption;
import org.dspace.util.TimeHelpers;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -106,7 +108,7 @@ public class AccessConditionReplacePatchOperation extends ReplacePatchOperation<
return null; return null;
} }
private AccessConditionDTO createDTO(ResourcePolicy rpToReplace, String attributeReplace, String valueToReplare) private AccessConditionDTO createDTO(ResourcePolicy rpToReplace, String attributeReplace, String valueToReplace)
throws ParseException { throws ParseException {
AccessConditionDTO accessCondition = new AccessConditionDTO(); AccessConditionDTO accessCondition = new AccessConditionDTO();
accessCondition.setName(rpToReplace.getRpName()); accessCondition.setName(rpToReplace.getRpName());
@@ -114,13 +116,13 @@ public class AccessConditionReplacePatchOperation extends ReplacePatchOperation<
accessCondition.setEndDate(rpToReplace.getEndDate()); accessCondition.setEndDate(rpToReplace.getEndDate());
switch (attributeReplace) { switch (attributeReplace) {
case "name": case "name":
accessCondition.setName(valueToReplare); accessCondition.setName(valueToReplace);
return accessCondition; return accessCondition;
case "startDate": case "startDate":
accessCondition.setStartDate(parseDate(valueToReplare)); accessCondition.setStartDate(TimeHelpers.toMidnightUTC(parseDate(valueToReplace)));
return accessCondition; return accessCondition;
case "endDate": case "endDate":
accessCondition.setEndDate(parseDate(valueToReplare)); accessCondition.setEndDate(TimeHelpers.toMidnightUTC(parseDate(valueToReplace)));
return accessCondition; return accessCondition;
default: default:
throw new UnprocessableEntityException("The provided attribute: " throw new UnprocessableEntityException("The provided attribute: "
@@ -128,17 +130,17 @@ public class AccessConditionReplacePatchOperation extends ReplacePatchOperation<
} }
} }
private void updatePolicy(Context context, String valueToReplare, String attributeReplace, private void updatePolicy(Context context, String valueToReplace, String attributeReplace,
ResourcePolicy rpToReplace) throws SQLException, AuthorizeException { ResourcePolicy rpToReplace) throws SQLException, AuthorizeException {
switch (attributeReplace) { switch (attributeReplace) {
case "name": case "name":
rpToReplace.setRpName(valueToReplare); rpToReplace.setRpName(valueToReplace);
break; break;
case "startDate": case "startDate":
rpToReplace.setStartDate(parseDate(valueToReplare)); rpToReplace.setStartDate(TimeHelpers.toMidnightUTC(parseDate(valueToReplace)));
break; break;
case "endDate": case "endDate":
rpToReplace.setEndDate(parseDate(valueToReplare)); rpToReplace.setEndDate(TimeHelpers.toMidnightUTC(parseDate(valueToReplace)));
break; break;
default: default:
throw new IllegalArgumentException("Attribute to replace is not valid:" + attributeReplace); throw new IllegalArgumentException("Attribute to replace is not valid:" + attributeReplace);

View File

@@ -257,10 +257,10 @@ public class SubmissionDefinitionsControllerIT extends AbstractControllerIntegra
Matchers.containsString("page=1"), Matchers.containsString("size=1")))) Matchers.containsString("page=1"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.last.href", Matchers.allOf( .andExpect(jsonPath("$._links.last.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=5"), Matchers.containsString("size=1")))) Matchers.containsString("page=6"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$.page.size", is(1))) .andExpect(jsonPath("$.page.size", is(1)))
.andExpect(jsonPath("$.page.totalElements", is(6))) .andExpect(jsonPath("$.page.totalElements", is(7)))
.andExpect(jsonPath("$.page.totalPages", is(6))) .andExpect(jsonPath("$.page.totalPages", is(7)))
.andExpect(jsonPath("$.page.number", is(0))); .andExpect(jsonPath("$.page.number", is(0)));
getClient(tokenAdmin).perform(get("/api/config/submissiondefinitions") getClient(tokenAdmin).perform(get("/api/config/submissiondefinitions")
@@ -268,7 +268,7 @@ public class SubmissionDefinitionsControllerIT extends AbstractControllerIntegra
.param("page", "1")) .param("page", "1"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(contentType)) .andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.submissiondefinitions[0].id", is("accessConditionNotDiscoverable"))) .andExpect(jsonPath("$._embedded.submissiondefinitions[0].id", is("test-hidden")))
.andExpect(jsonPath("$._links.first.href", Matchers.allOf( .andExpect(jsonPath("$._links.first.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=0"), Matchers.containsString("size=1")))) Matchers.containsString("page=0"), Matchers.containsString("size=1"))))
@@ -285,8 +285,8 @@ public class SubmissionDefinitionsControllerIT extends AbstractControllerIntegra
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page="), Matchers.containsString("size=1")))) Matchers.containsString("page="), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$.page.size", is(1))) .andExpect(jsonPath("$.page.size", is(1)))
.andExpect(jsonPath("$.page.totalElements", is(6))) .andExpect(jsonPath("$.page.totalElements", is(7)))
.andExpect(jsonPath("$.page.totalPages", is(6))) .andExpect(jsonPath("$.page.totalPages", is(7)))
.andExpect(jsonPath("$.page.number", is(1))); .andExpect(jsonPath("$.page.number", is(1)));
getClient(tokenAdmin).perform(get("/api/config/submissiondefinitions") getClient(tokenAdmin).perform(get("/api/config/submissiondefinitions")
@@ -294,30 +294,56 @@ public class SubmissionDefinitionsControllerIT extends AbstractControllerIntegra
.param("page", "2")) .param("page", "2"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(contentType)) .andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.submissiondefinitions[0].id", is("languagetestprocess"))) .andExpect(jsonPath("$._embedded.submissiondefinitions[0].id", is("accessConditionNotDiscoverable")))
.andExpect(jsonPath("$._links.first.href", Matchers.allOf( .andExpect(jsonPath("$._links.first.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=0"), Matchers.containsString("size=1")))) Matchers.containsString("page=0"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.prev.href", Matchers.allOf( .andExpect(jsonPath("$._links.prev.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=1"), Matchers.containsString("size=1")))) Matchers.containsString("page=1"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.next.href", Matchers.allOf( .andExpect(jsonPath("$._links.next.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=3"), Matchers.containsString("size=1")))) Matchers.containsString("page=3"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.self.href", Matchers.allOf( .andExpect(jsonPath("$._links.self.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=2"), Matchers.containsString("size=1")))) Matchers.containsString("page=2"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.last.href", Matchers.allOf( .andExpect(jsonPath("$._links.last.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=5"), Matchers.containsString("size=1")))) Matchers.containsString("page=6"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$.page.size", is(1))) .andExpect(jsonPath("$.page.size", is(1)))
.andExpect(jsonPath("$.page.totalElements", is(6))) .andExpect(jsonPath("$.page.totalElements", is(7)))
.andExpect(jsonPath("$.page.totalPages", is(6))) .andExpect(jsonPath("$.page.totalPages", is(7)))
.andExpect(jsonPath("$.page.number", is(2))); .andExpect(jsonPath("$.page.number", is(2)));
getClient(tokenAdmin).perform(get("/api/config/submissiondefinitions")
.param("size", "1")
.param("page", "3"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.submissiondefinitions[0].id", is("languagetestprocess")))
.andExpect(jsonPath("$._links.first.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=0"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.prev.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=2"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.next.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=4"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.self.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=3"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.last.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=6"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$.page.size", is(1)))
.andExpect(jsonPath("$.page.totalElements", is(7)))
.andExpect(jsonPath("$.page.totalPages", is(7)))
.andExpect(jsonPath("$.page.number", is(3)));
getClient(tokenAdmin).perform(get("/api/config/submissiondefinitions") getClient(tokenAdmin).perform(get("/api/config/submissiondefinitions")
.param("size", "1") .param("size", "1")
.param("page", "3")) .param("page", "4"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(contentType)) .andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.submissiondefinitions[0].id", is("qualdroptest"))) .andExpect(jsonPath("$._embedded.submissiondefinitions[0].id", is("qualdroptest")))
@@ -326,24 +352,24 @@ public class SubmissionDefinitionsControllerIT extends AbstractControllerIntegra
Matchers.containsString("page=0"), Matchers.containsString("size=1")))) Matchers.containsString("page=0"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.prev.href", Matchers.allOf( .andExpect(jsonPath("$._links.prev.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=2"), Matchers.containsString("size=1")))) Matchers.containsString("page=3"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.next.href", Matchers.allOf( .andExpect(jsonPath("$._links.next.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=4"), Matchers.containsString("size=1")))) Matchers.containsString("page=5"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.self.href", Matchers.allOf( .andExpect(jsonPath("$._links.self.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=3"), Matchers.containsString("size=1")))) Matchers.containsString("page=4"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.last.href", Matchers.allOf( .andExpect(jsonPath("$._links.last.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=5"), Matchers.containsString("size=1")))) Matchers.containsString("page=6"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$.page.size", is(1))) .andExpect(jsonPath("$.page.size", is(1)))
.andExpect(jsonPath("$.page.totalElements", is(6))) .andExpect(jsonPath("$.page.totalElements", is(7)))
.andExpect(jsonPath("$.page.totalPages", is(6))) .andExpect(jsonPath("$.page.totalPages", is(7)))
.andExpect(jsonPath("$.page.number", is(3))); .andExpect(jsonPath("$.page.number", is(4)));
getClient(tokenAdmin).perform(get("/api/config/submissiondefinitions") getClient(tokenAdmin).perform(get("/api/config/submissiondefinitions")
.param("size", "1") .param("size", "1")
.param("page", "4")) .param("page", "5"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(contentType)) .andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.submissiondefinitions[0].id", is("extractiontestprocess"))) .andExpect(jsonPath("$._embedded.submissiondefinitions[0].id", is("extractiontestprocess")))
@@ -352,20 +378,20 @@ public class SubmissionDefinitionsControllerIT extends AbstractControllerIntegra
Matchers.containsString("page=0"), Matchers.containsString("size=1")))) Matchers.containsString("page=0"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.prev.href", Matchers.allOf( .andExpect(jsonPath("$._links.prev.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=3"), Matchers.containsString("size=1")))) Matchers.containsString("page=4"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.next.href", Matchers.allOf( .andExpect(jsonPath("$._links.next.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=5"), Matchers.containsString("size=1")))) Matchers.containsString("page=6"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.self.href", Matchers.allOf( .andExpect(jsonPath("$._links.self.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=4"), Matchers.containsString("size=1")))) Matchers.containsString("page=5"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$._links.last.href", Matchers.allOf( .andExpect(jsonPath("$._links.last.href", Matchers.allOf(
Matchers.containsString("/api/config/submissiondefinitions?"), Matchers.containsString("/api/config/submissiondefinitions?"),
Matchers.containsString("page=5"), Matchers.containsString("size=1")))) Matchers.containsString("page=6"), Matchers.containsString("size=1"))))
.andExpect(jsonPath("$.page.size", is(1))) .andExpect(jsonPath("$.page.size", is(1)))
.andExpect(jsonPath("$.page.totalElements", is(6))) .andExpect(jsonPath("$.page.totalElements", is(7)))
.andExpect(jsonPath("$.page.totalPages", is(6))) .andExpect(jsonPath("$.page.totalPages", is(7)))
.andExpect(jsonPath("$.page.number", is(4))); .andExpect(jsonPath("$.page.number", is(5)));
} }
} }

View File

@@ -67,13 +67,13 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
.andExpect(content().contentType(contentType)) .andExpect(content().contentType(contentType))
//The configuration file for the test env includes 6 forms //The configuration file for the test env includes 6 forms
.andExpect(jsonPath("$.page.size", is(20))) .andExpect(jsonPath("$.page.size", is(20)))
.andExpect(jsonPath("$.page.totalElements", equalTo(8))) .andExpect(jsonPath("$.page.totalElements", equalTo(10)))
.andExpect(jsonPath("$.page.totalPages", equalTo(1))) .andExpect(jsonPath("$.page.totalPages", equalTo(1)))
.andExpect(jsonPath("$.page.number", is(0))) .andExpect(jsonPath("$.page.number", is(0)))
.andExpect( .andExpect(
jsonPath("$._links.self.href", Matchers.startsWith(REST_SERVER_URL + "config/submissionforms"))) jsonPath("$._links.self.href", Matchers.startsWith(REST_SERVER_URL + "config/submissionforms")))
//The array of submissionforms should have a size of 8 //The array of submissionforms should have a size of 8
.andExpect(jsonPath("$._embedded.submissionforms", hasSize(equalTo(8)))) .andExpect(jsonPath("$._embedded.submissionforms", hasSize(equalTo(10))))
; ;
} }
@@ -84,12 +84,12 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(contentType)) .andExpect(content().contentType(contentType))
.andExpect(jsonPath("$.page.size", is(20))) .andExpect(jsonPath("$.page.size", is(20)))
.andExpect(jsonPath("$.page.totalElements", equalTo(8))) .andExpect(jsonPath("$.page.totalElements", equalTo(10)))
.andExpect(jsonPath("$.page.totalPages", equalTo(1))) .andExpect(jsonPath("$.page.totalPages", equalTo(1)))
.andExpect(jsonPath("$.page.number", is(0))) .andExpect(jsonPath("$.page.number", is(0)))
.andExpect(jsonPath("$._links.self.href", Matchers.startsWith(REST_SERVER_URL .andExpect(jsonPath("$._links.self.href", Matchers.startsWith(REST_SERVER_URL
+ "config/submissionforms"))) + "config/submissionforms")))
.andExpect(jsonPath("$._embedded.submissionforms", hasSize(equalTo(8)))); .andExpect(jsonPath("$._embedded.submissionforms", hasSize(equalTo(10))));
} }
@Test @Test
@@ -696,10 +696,10 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
Matchers.containsString("page=1"), Matchers.containsString("size=2")))) Matchers.containsString("page=1"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.last.href", Matchers.allOf( .andExpect(jsonPath("$._links.last.href", Matchers.allOf(
Matchers.containsString("/api/config/submissionforms?"), Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=3"), Matchers.containsString("size=2")))) Matchers.containsString("page=4"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$.page.size", is(2))) .andExpect(jsonPath("$.page.size", is(2)))
.andExpect(jsonPath("$.page.totalElements", equalTo(8))) .andExpect(jsonPath("$.page.totalElements", equalTo(10)))
.andExpect(jsonPath("$.page.totalPages", equalTo(4))) .andExpect(jsonPath("$.page.totalPages", equalTo(5)))
.andExpect(jsonPath("$.page.number", is(0))); .andExpect(jsonPath("$.page.number", is(0)));
getClient(tokenAdmin).perform(get("/api/config/submissionforms") getClient(tokenAdmin).perform(get("/api/config/submissionforms")
@@ -707,8 +707,8 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
.param("page", "1")) .param("page", "1"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(contentType)) .andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.submissionforms[0].id", is("languagetest"))) .andExpect(jsonPath("$._embedded.submissionforms[0].id", is("test-outside-workflow-hidden")))
.andExpect(jsonPath("$._embedded.submissionforms[1].id", is("qualdroptest"))) .andExpect(jsonPath("$._embedded.submissionforms[1].id", is("languagetest")))
.andExpect(jsonPath("$._links.first.href", Matchers.allOf( .andExpect(jsonPath("$._links.first.href", Matchers.allOf(
Matchers.containsString("/api/config/submissionforms?"), Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=0"), Matchers.containsString("size=2")))) Matchers.containsString("page=0"), Matchers.containsString("size=2"))))
@@ -723,10 +723,10 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
Matchers.containsString("page=2"), Matchers.containsString("size=2")))) Matchers.containsString("page=2"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.last.href", Matchers.allOf( .andExpect(jsonPath("$._links.last.href", Matchers.allOf(
Matchers.containsString("/api/config/submissionforms?"), Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=3"), Matchers.containsString("size=2")))) Matchers.containsString("page=4"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$.page.size", is(2))) .andExpect(jsonPath("$.page.size", is(2)))
.andExpect(jsonPath("$.page.totalElements", equalTo(8))) .andExpect(jsonPath("$.page.totalElements", equalTo(10)))
.andExpect(jsonPath("$.page.totalPages", equalTo(4))) .andExpect(jsonPath("$.page.totalPages", equalTo(5)))
.andExpect(jsonPath("$.page.number", is(1))); .andExpect(jsonPath("$.page.number", is(1)));
getClient(tokenAdmin).perform(get("/api/config/submissionforms") getClient(tokenAdmin).perform(get("/api/config/submissionforms")
@@ -734,8 +734,8 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
.param("page", "2")) .param("page", "2"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(contentType)) .andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.submissionforms[0].id", is("traditionalpagetwo"))) .andExpect(jsonPath("$._embedded.submissionforms[0].id", is("test-outside-submission-hidden")))
.andExpect(jsonPath("$._embedded.submissionforms[1].id", is("sampleauthority"))) .andExpect(jsonPath("$._embedded.submissionforms[1].id", is("qualdroptest")))
.andExpect(jsonPath("$._links.first.href", Matchers.allOf( .andExpect(jsonPath("$._links.first.href", Matchers.allOf(
Matchers.containsString("/api/config/submissionforms?"), Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=0"), Matchers.containsString("size=2")))) Matchers.containsString("page=0"), Matchers.containsString("size=2"))))
@@ -747,10 +747,10 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
Matchers.containsString("page=2"), Matchers.containsString("size=2")))) Matchers.containsString("page=2"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.last.href", Matchers.allOf( .andExpect(jsonPath("$._links.last.href", Matchers.allOf(
Matchers.containsString("/api/config/submissionforms?"), Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=3"), Matchers.containsString("size=2")))) Matchers.containsString("page=4"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$.page.size", is(2))) .andExpect(jsonPath("$.page.size", is(2)))
.andExpect(jsonPath("$.page.totalElements", equalTo(8))) .andExpect(jsonPath("$.page.totalElements", equalTo(10)))
.andExpect(jsonPath("$.page.totalPages", equalTo(4))) .andExpect(jsonPath("$.page.totalPages", equalTo(5)))
.andExpect(jsonPath("$.page.number", is(2))); .andExpect(jsonPath("$.page.number", is(2)));
getClient(tokenAdmin).perform(get("/api/config/submissionforms") getClient(tokenAdmin).perform(get("/api/config/submissionforms")
@@ -758,7 +758,8 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
.param("page", "3")) .param("page", "3"))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(contentType)) .andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.submissionforms[0].id", is("traditionalpageone"))) .andExpect(jsonPath("$._embedded.submissionforms[0].id", is("traditionalpagetwo")))
.andExpect(jsonPath("$._embedded.submissionforms[1].id", is("sampleauthority")))
.andExpect(jsonPath("$._links.first.href", Matchers.allOf( .andExpect(jsonPath("$._links.first.href", Matchers.allOf(
Matchers.containsString("/api/config/submissionforms?"), Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=0"), Matchers.containsString("size=2")))) Matchers.containsString("page=0"), Matchers.containsString("size=2"))))
@@ -770,10 +771,33 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
Matchers.containsString("page=3"), Matchers.containsString("size=2")))) Matchers.containsString("page=3"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.last.href", Matchers.allOf( .andExpect(jsonPath("$._links.last.href", Matchers.allOf(
Matchers.containsString("/api/config/submissionforms?"), Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=3"), Matchers.containsString("size=2")))) Matchers.containsString("page=4"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$.page.size", is(2))) .andExpect(jsonPath("$.page.size", is(2)))
.andExpect(jsonPath("$.page.totalElements", equalTo(8))) .andExpect(jsonPath("$.page.totalElements", equalTo(10)))
.andExpect(jsonPath("$.page.totalPages", equalTo(4))) .andExpect(jsonPath("$.page.totalPages", equalTo(5)))
.andExpect(jsonPath("$.page.number", is(3))); .andExpect(jsonPath("$.page.number", is(3)));
getClient(tokenAdmin).perform(get("/api/config/submissionforms")
.param("size", "2")
.param("page", "4"))
.andExpect(status().isOk())
.andExpect(content().contentType(contentType))
.andExpect(jsonPath("$._embedded.submissionforms[0].id", is("traditionalpageone")))
.andExpect(jsonPath("$._links.first.href", Matchers.allOf(
Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=0"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.prev.href", Matchers.allOf(
Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=3"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.self.href", Matchers.allOf(
Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=4"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$._links.last.href", Matchers.allOf(
Matchers.containsString("/api/config/submissionforms?"),
Matchers.containsString("page=4"), Matchers.containsString("size=2"))))
.andExpect(jsonPath("$.page.size", is(2)))
.andExpect(jsonPath("$.page.totalElements", equalTo(10)))
.andExpect(jsonPath("$.page.totalPages", equalTo(5)))
.andExpect(jsonPath("$.page.number", is(4)));
} }
} }

View File

@@ -2122,4 +2122,35 @@ public class WorkflowItemRestRepositoryIT extends AbstractControllerIntegrationT
WorkflowItemBuilder.deleteWorkflowItem(idRef.get()); WorkflowItemBuilder.deleteWorkflowItem(idRef.get());
} }
} }
@Test
public void testWorkflowWithHiddenSections() throws Exception {
context.turnOffAuthorisationSystem();
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
Collection collection = CollectionBuilder.createCollection(context, parentCommunity, "123456789/test-hidden")
.withName("Collection 1")
.withWorkflowGroup(1, eperson)
.build();
XmlWorkflowItem workflowItem = WorkflowItemBuilder.createWorkflowItem(context, collection)
.withTitle("Workflow Item")
.build();
context.restoreAuthSystemState();
getClient(getAuthToken(admin.getEmail(), password))
.perform(get("/api/workflow/workflowitems/" + workflowItem.getID()))
.andExpect(status().isOk())
.andExpect(jsonPath("$.sections.test-outside-workflow-hidden").exists())
.andExpect(jsonPath("$.sections.test-outside-submission-hidden").doesNotExist())
.andExpect(jsonPath("$.sections.test-never-hidden").exists())
.andExpect(jsonPath("$.sections.test-always-hidden").doesNotExist());
}
} }

View File

@@ -8566,4 +8566,41 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
))); )));
} }
@Test
public void testSubmissionWithHiddenSections() throws Exception {
context.turnOffAuthorisationSystem();
parentCommunity = CommunityBuilder.createCommunity(context)
.withName("Parent Community")
.build();
Collection collection = CollectionBuilder.createCollection(context, parentCommunity, "123456789/test-hidden")
.withName("Collection 1")
.build();
WorkspaceItem workspaceItem = WorkspaceItemBuilder.createWorkspaceItem(context, collection)
.withTitle("Workspace Item")
.withIssueDate("2023-01-01")
.withType("book")
.build();
context.restoreAuthSystemState();
String adminToken = getAuthToken(admin.getEmail(), password);
getClient(adminToken)
.perform(get("/api/submission/workspaceitems/" + workspaceItem.getID()))
.andExpect(status().isOk())
.andExpect(jsonPath("$.sections.test-outside-workflow-hidden").doesNotExist())
.andExpect(jsonPath("$.sections.test-outside-submission-hidden").exists())
.andExpect(jsonPath("$.sections.test-never-hidden").exists())
.andExpect(jsonPath("$.sections.test-always-hidden").doesNotExist());
// Deposit the item
getClient(adminToken).perform(post("/api/workflow/workflowitems")
.content("/api/submission/workspaceitems/" + workspaceItem.getID())
.contentType(textUriContentType))
.andExpect(status().isCreated());
}
} }

View File

@@ -79,7 +79,6 @@
<heading></heading> <heading></heading>
<processing-class>org.dspace.app.rest.submit.step.CollectionStep</processing-class> <processing-class>org.dspace.app.rest.submit.step.CollectionStep</processing-class>
<type>collection</type> <type>collection</type>
<scope visibility="hidden" visibilityOutside="hidden">submission</scope>
</step-definition> </step-definition>
<!-- The following set of DescribeStep <step-definition>s all point to forms (of the same name) which are <!-- The following set of DescribeStep <step-definition>s all point to forms (of the same name) which are