mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 10:04:21 +00:00
Cleanup submission code
Moved shared code among workspace and workflow repository to the submission service introduced a base RestProcessingStep interface to be specialized among ListenerStep and AbstractRestProcessingStep (data processing) removed retrieval of the Request from the service passing directly the http request that was available added test to check the special case of steps that should be not exposed as panel (extract step)
This commit is contained in:
@@ -17,6 +17,7 @@ import org.dspace.app.rest.model.SubmissionDefinitionRest;
|
||||
import org.dspace.app.rest.model.SubmissionSectionRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||
import org.dspace.app.rest.submit.RestProcessingStep;
|
||||
import org.dspace.app.rest.submit.SubmissionService;
|
||||
import org.dspace.app.util.SubmissionConfigReader;
|
||||
import org.dspace.app.util.SubmissionConfigReaderException;
|
||||
@@ -100,13 +101,11 @@ public abstract class AInprogressItemConverter<T extends InProgressSubmission,
|
||||
for (ErrorRest error : stepProcessing.validate(submissionService, obj, stepConfig)) {
|
||||
addError(witem.getErrors(), error);
|
||||
}
|
||||
if (stepProcessing.hasDataSection()) {
|
||||
witem.getSections()
|
||||
.put(sections.getId(), stepProcessing.getData(submissionService, obj, stepConfig));
|
||||
}
|
||||
} else {
|
||||
} else if (!(stepInstance instanceof RestProcessingStep)) {
|
||||
log.warn("The submission step class specified by '" + stepConfig.getProcessingClassName() +
|
||||
"' does not extend the class org.dspace.app.rest.submit.AbstractRestProcessingStep!" +
|
||||
"' does not implement the interface org.dspace.app.rest.submit.RestProcessingStep!" +
|
||||
" Therefore it cannot be used by the Configurable Submission as the " +
|
||||
"<processing-class>!");
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ import org.dspace.app.rest.model.CollectionRest;
|
||||
import org.dspace.app.rest.model.SubmissionDefinitionRest;
|
||||
import org.dspace.app.rest.model.SubmissionSectionRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.app.util.SubmissionConfig;
|
||||
import org.dspace.app.util.SubmissionConfigReaderException;
|
||||
@@ -58,9 +59,19 @@ public class SubmissionDefinitionConverter implements DSpaceConverter<Submission
|
||||
List<SubmissionSectionRest> panels = new LinkedList<SubmissionSectionRest>();
|
||||
for (int idx = 0; idx < obj.getNumberOfSteps(); idx++) {
|
||||
SubmissionStepConfig step = obj.getStep(idx);
|
||||
try {
|
||||
// only the step that process data must be included in the panels list
|
||||
if (AbstractRestProcessingStep.class.isAssignableFrom(Class.forName(step.getProcessingClassName()))) {
|
||||
SubmissionSectionRest sp = converter.toRest(step, projection);
|
||||
panels.add(sp);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new IllegalStateException(
|
||||
"The submission configration is invalid the processing class for the step " + step.getId()
|
||||
+ " is not found",
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
HttpServletRequest request = requestService.getCurrentRequest().getHttpServletRequest();
|
||||
Context context = null;
|
||||
|
@@ -11,7 +11,6 @@ import static org.dspace.xmlworkflow.state.actions.processingaction.ProcessingAc
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -26,13 +25,9 @@ import org.dspace.app.rest.model.ErrorRest;
|
||||
import org.dspace.app.rest.model.WorkflowItemRest;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.app.rest.model.patch.Patch;
|
||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||
import org.dspace.app.rest.submit.SubmissionService;
|
||||
import org.dspace.app.rest.submit.UploadableStep;
|
||||
import org.dspace.app.util.SubmissionConfig;
|
||||
import org.dspace.app.util.SubmissionConfigReader;
|
||||
import org.dspace.app.util.SubmissionConfigReaderException;
|
||||
import org.dspace.app.util.SubmissionStepConfig;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.content.Item;
|
||||
@@ -201,39 +196,8 @@ public class WorkflowItemRestRepository extends DSpaceRestRepository<WorkflowIte
|
||||
XmlWorkflowItem source = wis.find(context, id);
|
||||
|
||||
this.checkIfEditMetadataAllowedInCurrentStep(context, source);
|
||||
|
||||
List<ErrorRest> errors = new ArrayList<ErrorRest>();
|
||||
SubmissionConfig submissionConfig =
|
||||
submissionConfigReader.getSubmissionConfigByName(wsi.getSubmissionDefinition().getName());
|
||||
for (int i = 0; i < submissionConfig.getNumberOfSteps(); i++) {
|
||||
SubmissionStepConfig stepConfig = submissionConfig.getStep(i);
|
||||
|
||||
/*
|
||||
* First, load the step processing class (using the current
|
||||
* class loader)
|
||||
*/
|
||||
ClassLoader loader = this.getClass().getClassLoader();
|
||||
Class stepClass;
|
||||
try {
|
||||
stepClass = loader.loadClass(stepConfig.getProcessingClassName());
|
||||
|
||||
Object stepInstance = stepClass.newInstance();
|
||||
if (UploadableStep.class.isAssignableFrom(stepClass)) {
|
||||
UploadableStep uploadableStep = (UploadableStep) stepInstance;
|
||||
uploadableStep.doPreProcessing(context, source);
|
||||
ErrorRest err =
|
||||
uploadableStep.upload(context, submissionService, stepConfig, source, file);
|
||||
uploadableStep.doPostProcessing(context, source);
|
||||
if (err != null) {
|
||||
errors.add(err);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
List<ErrorRest> errors = submissionService.uploadFileToInprogressSubmission(context, request, wsi, source,
|
||||
file);
|
||||
wsi = converter.toRest(source, utils.obtainProjection());
|
||||
|
||||
if (!errors.isEmpty()) {
|
||||
@@ -258,7 +222,7 @@ public class WorkflowItemRestRepository extends DSpaceRestRepository<WorkflowIte
|
||||
String[] path = op.getPath().substring(1).split("/", 3);
|
||||
if (OPERATION_PATH_SECTIONS.equals(path[0])) {
|
||||
String section = path[1];
|
||||
evaluatePatch(context, request, source, wsi, section, op);
|
||||
submissionService.evaluatePatchToInprogressSubmission(context, request, source, wsi, section, op);
|
||||
} else {
|
||||
throw new DSpaceBadRequestException(
|
||||
"Patch path operation need to starts with '" + OPERATION_PATH_SECTIONS + "'");
|
||||
@@ -267,48 +231,6 @@ public class WorkflowItemRestRepository extends DSpaceRestRepository<WorkflowIte
|
||||
wis.update(context, source);
|
||||
}
|
||||
|
||||
private void evaluatePatch(Context context, HttpServletRequest request, XmlWorkflowItem source,
|
||||
WorkflowItemRest wsi, String section, Operation op) {
|
||||
SubmissionConfig submissionConfig =
|
||||
submissionConfigReader.getSubmissionConfigByName(wsi.getSubmissionDefinition().getName());
|
||||
for (int stepNum = 0; stepNum < submissionConfig.getNumberOfSteps(); stepNum++) {
|
||||
|
||||
SubmissionStepConfig stepConfig = submissionConfig.getStep(stepNum);
|
||||
|
||||
if (section.equals(stepConfig.getId())) {
|
||||
/*
|
||||
* First, load the step processing class (using the current
|
||||
* class loader)
|
||||
*/
|
||||
ClassLoader loader = this.getClass().getClassLoader();
|
||||
Class stepClass;
|
||||
try {
|
||||
stepClass = loader.loadClass(stepConfig.getProcessingClassName());
|
||||
|
||||
Object stepInstance = stepClass.newInstance();
|
||||
|
||||
if (stepInstance instanceof AbstractRestProcessingStep) {
|
||||
// load the JSPStep interface for this step
|
||||
AbstractRestProcessingStep stepProcessing =
|
||||
(AbstractRestProcessingStep) stepClass.newInstance();
|
||||
stepProcessing.doPreProcessing(context, source);
|
||||
stepProcessing.doPatchProcessing(context, getRequestService().getCurrentRequest(),
|
||||
source, op, stepConfig);
|
||||
stepProcessing.doPostProcessing(context, source);
|
||||
} else {
|
||||
throw new DSpaceBadRequestException(
|
||||
"The submission step class specified by '" + stepConfig.getProcessingClassName() +
|
||||
"' does not extend the class org.dspace.submit.AbstractProcessingStep!" +
|
||||
" Therefore it cannot be used by the Configurable Submission as the <processing-class>!");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* This method provides support for the administrative abort workflow functionality. The abort functionality will
|
||||
|
@@ -29,7 +29,6 @@ import org.dspace.app.rest.model.WorkspaceItemRest;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.app.rest.model.patch.Patch;
|
||||
import org.dspace.app.rest.repository.handler.service.UriListHandlerService;
|
||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||
import org.dspace.app.rest.submit.SubmissionService;
|
||||
import org.dspace.app.rest.submit.UploadableStep;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
@@ -62,7 +61,6 @@ import org.dspace.submit.AbstractProcessingStep;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.rest.webmvc.json.patch.PatchException;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -227,53 +225,8 @@ public class WorkspaceItemRestRepository extends DSpaceRestRepository<WorkspaceI
|
||||
Context context = obtainContext();
|
||||
WorkspaceItemRest wsi = findOne(context, id);
|
||||
WorkspaceItem source = wis.find(context, id);
|
||||
List<ErrorRest> errors = new ArrayList<ErrorRest>();
|
||||
SubmissionConfig submissionConfig =
|
||||
submissionConfigReader.getSubmissionConfigByName(wsi.getSubmissionDefinition().getName());
|
||||
List<Object[]> stepInstancesAndConfigs = new ArrayList<Object[]>();
|
||||
// we need to run the preProcess of all the appropriate steps and move on to the
|
||||
// upload and postProcess step
|
||||
// We will initialize the step class just one time so that it will be the same
|
||||
// instance over all the phase and we will reduce initialization time as well
|
||||
for (int i = 0; i < submissionConfig.getNumberOfSteps(); i++) {
|
||||
SubmissionStepConfig stepConfig = submissionConfig.getStep(i);
|
||||
/*
|
||||
* First, load the step processing class (using the current
|
||||
* class loader)
|
||||
*/
|
||||
ClassLoader loader = this.getClass().getClassLoader();
|
||||
Class stepClass;
|
||||
try {
|
||||
stepClass = loader.loadClass(stepConfig.getProcessingClassName());
|
||||
if (UploadableStep.class.isAssignableFrom(stepClass)) {
|
||||
Object stepInstance = stepClass.newInstance();
|
||||
stepInstancesAndConfigs.add(new Object[] {stepInstance, stepConfig});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
for (Object[] stepInstanceAndCfg : stepInstancesAndConfigs) {
|
||||
UploadableStep uploadableStep = (UploadableStep) stepInstanceAndCfg[0];
|
||||
uploadableStep.doPreProcessing(context, source);
|
||||
}
|
||||
for (Object[] stepInstanceAndCfg : stepInstancesAndConfigs) {
|
||||
UploadableStep uploadableStep = (UploadableStep) stepInstanceAndCfg[0];
|
||||
ErrorRest err;
|
||||
try {
|
||||
err = uploadableStep.upload(context, submissionService, (SubmissionStepConfig) stepInstanceAndCfg[1],
|
||||
source, file);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (err != null) {
|
||||
errors.add(err);
|
||||
}
|
||||
}
|
||||
for (Object[] stepInstanceAndCfg : stepInstancesAndConfigs) {
|
||||
UploadableStep uploadableStep = (UploadableStep) stepInstanceAndCfg[0];
|
||||
uploadableStep.doPostProcessing(context, source);
|
||||
}
|
||||
List<ErrorRest> errors = submissionService.uploadFileToInprogressSubmission(context, request, wsi, source,
|
||||
file);
|
||||
wsi = converter.toRest(source, utils.obtainProjection());
|
||||
|
||||
if (!errors.isEmpty()) {
|
||||
@@ -296,7 +249,7 @@ public class WorkspaceItemRestRepository extends DSpaceRestRepository<WorkspaceI
|
||||
String[] path = op.getPath().substring(1).split("/", 3);
|
||||
if (OPERATION_PATH_SECTIONS.equals(path[0])) {
|
||||
String section = path[1];
|
||||
evaluatePatch(context, request, source, wsi, section, op);
|
||||
submissionService.evaluatePatchToInprogressSubmission(context, request, source, wsi, section, op);
|
||||
} else {
|
||||
throw new DSpaceBadRequestException(
|
||||
"Patch path operation need to starts with '" + OPERATION_PATH_SECTIONS + "'");
|
||||
@@ -305,74 +258,6 @@ public class WorkspaceItemRestRepository extends DSpaceRestRepository<WorkspaceI
|
||||
wis.update(context, source);
|
||||
}
|
||||
|
||||
private void evaluatePatch(Context context, HttpServletRequest request, WorkspaceItem source, WorkspaceItemRest wsi,
|
||||
String section, Operation op) {
|
||||
boolean sectionExist = false;
|
||||
SubmissionConfig submissionConfig = submissionConfigReader
|
||||
.getSubmissionConfigByName(wsi.getSubmissionDefinition().getName());
|
||||
List<Object[]> stepInstancesAndConfigs = new ArrayList<Object[]>();
|
||||
// we need to run the preProcess of all the appropriate steps and move on to the
|
||||
// doPatchProcessing and postProcess step
|
||||
// We will initialize the step classes just one time so that it will be the same
|
||||
// instance over all the phase and we will reduce initialization time as well
|
||||
for (int i = 0; i < submissionConfig.getNumberOfSteps(); i++) {
|
||||
SubmissionStepConfig stepConfig = submissionConfig.getStep(i);
|
||||
if (section.equals(stepConfig.getId())) {
|
||||
sectionExist = true;
|
||||
}
|
||||
/*
|
||||
* First, load the step processing class (using the current
|
||||
* class loader)
|
||||
*/
|
||||
ClassLoader loader = this.getClass().getClassLoader();
|
||||
Class stepClass;
|
||||
try {
|
||||
stepClass = loader.loadClass(stepConfig.getProcessingClassName());
|
||||
if (AbstractRestProcessingStep.class.isAssignableFrom(stepClass)) {
|
||||
Object stepInstance = stepClass.newInstance();
|
||||
stepInstancesAndConfigs.add(new Object[] {stepInstance, stepConfig});
|
||||
} else {
|
||||
throw new DSpaceBadRequestException(
|
||||
"The submission step class specified by '" + stepConfig.getProcessingClassName() +
|
||||
"' does not extend the class org.dspace.app.rest.submit.AbstractRestProcessingStep!" +
|
||||
" Therefore it cannot be used by the Configurable Submission as the <processing-class>!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new PatchException("Error processing the patch request", e);
|
||||
}
|
||||
}
|
||||
if (!sectionExist) {
|
||||
throw new UnprocessableEntityException("The section with name " + section +
|
||||
" does not exist in this submission!");
|
||||
}
|
||||
for (Object[] stepInstanceAndCfg : stepInstancesAndConfigs) {
|
||||
AbstractRestProcessingStep step = (AbstractRestProcessingStep) stepInstanceAndCfg[0];
|
||||
step.doPreProcessing(context, source);
|
||||
}
|
||||
for (Object[] stepInstanceAndCfg : stepInstancesAndConfigs) {
|
||||
// only the step related to the involved section need to be invoked
|
||||
SubmissionStepConfig stepConfig = (SubmissionStepConfig) stepInstanceAndCfg[1];
|
||||
if (!section.equals(stepConfig.getId())) {
|
||||
continue;
|
||||
}
|
||||
AbstractRestProcessingStep step = (AbstractRestProcessingStep) stepInstanceAndCfg[0];
|
||||
try {
|
||||
step.doPatchProcessing(context, getRequestService().getCurrentRequest(), source, op,
|
||||
stepConfig);
|
||||
} catch (UnprocessableEntityException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new PatchException("Error processing the patch request", e);
|
||||
}
|
||||
}
|
||||
for (Object[] stepInstanceAndCfg : stepInstancesAndConfigs) {
|
||||
AbstractRestProcessingStep step = (AbstractRestProcessingStep) stepInstanceAndCfg[0];
|
||||
step.doPostProcessing(context, source);
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("hasPermission(#id, 'WORKSPACEITEM', 'DELETE')")
|
||||
@Override
|
||||
protected void delete(Context context, Integer id) throws AuthorizeException {
|
||||
|
@@ -10,6 +10,7 @@ package org.dspace.app.rest.submit;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.ErrorRest;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
@@ -18,7 +19,6 @@ import org.dspace.app.util.SubmissionStepConfig;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.services.model.Request;
|
||||
|
||||
/**
|
||||
* Interface for the submission steps to populate sections in the in progress submission and react to patch requests.
|
||||
@@ -26,7 +26,7 @@ import org.dspace.services.model.Request;
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
public interface AbstractRestProcessingStep extends ListenerProcessingStep {
|
||||
public interface AbstractRestProcessingStep {
|
||||
|
||||
public static final String DESCRIBE_STEP_METADATA_OPERATION_ENTRY = "itemmetadata";
|
||||
public static final String COLLECTION_STEP_OPERATION_ENTRY = "collection";
|
||||
@@ -56,19 +56,6 @@ public interface AbstractRestProcessingStep extends ListenerProcessingStep {
|
||||
public <T extends Serializable> T getData(SubmissionService submissionService, InProgressSubmission obj,
|
||||
SubmissionStepConfig config) throws Exception;
|
||||
|
||||
/**
|
||||
* Method to inform the converter that this step has it own section data. This
|
||||
* can be overriden by step that only process/validate data in other section. In
|
||||
* such case the @link
|
||||
* {@link #getData(SubmissionService, InProgressSubmission, SubmissionStepConfig)}
|
||||
* method should return null as it will be ignored
|
||||
*
|
||||
* @return true by default to indicate that the step has it own section data
|
||||
*/
|
||||
default public boolean hasDataSection() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method will expose the list of validation errors identified by the step. The default implementation will
|
||||
* found a {@link Validation} spring bean in the context with the same name that the step id
|
||||
@@ -108,7 +95,7 @@ public interface AbstractRestProcessingStep extends ListenerProcessingStep {
|
||||
* the json patch operation
|
||||
* @throws Exception
|
||||
*/
|
||||
public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op,
|
||||
SubmissionStepConfig stepConf) throws Exception;
|
||||
public void doPatchProcessing(Context context, HttpServletRequest currentRequest, InProgressSubmission source,
|
||||
Operation op, SubmissionStepConfig stepConf) throws Exception;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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.rest.submit;
|
||||
|
||||
/**
|
||||
* This is a placeholder interface to simplify validation of the configuration.
|
||||
* Any processing step MUST inherit such interface usually implementing the
|
||||
* {@link AbstractRestProcessingStep} or {@link ListenerProcessingStep} or both
|
||||
*
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
public interface RestProcessingStep {
|
||||
}
|
@@ -18,18 +18,28 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.atteo.evo.inflector.English;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.exception.DSpaceBadRequestException;
|
||||
import org.dspace.app.rest.exception.RESTAuthorizationException;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
import org.dspace.app.rest.model.AInprogressSubmissionRest;
|
||||
import org.dspace.app.rest.model.BitstreamRest;
|
||||
import org.dspace.app.rest.model.CheckSumRest;
|
||||
import org.dspace.app.rest.model.ErrorRest;
|
||||
import org.dspace.app.rest.model.MetadataValueRest;
|
||||
import org.dspace.app.rest.model.UploadBitstreamAccessConditionDTO;
|
||||
import org.dspace.app.rest.model.WorkspaceItemRest;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.app.rest.model.step.DataCCLicense;
|
||||
import org.dspace.app.rest.model.step.DataUpload;
|
||||
import org.dspace.app.rest.model.step.UploadBitstreamRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
import org.dspace.app.rest.repository.WorkflowItemRestRepository;
|
||||
import org.dspace.app.rest.repository.WorkspaceItemRestRepository;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.app.util.SubmissionConfig;
|
||||
import org.dspace.app.util.SubmissionConfigReader;
|
||||
import org.dspace.app.util.SubmissionConfigReaderException;
|
||||
import org.dspace.app.util.SubmissionStepConfig;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
import org.dspace.content.Bitstream;
|
||||
@@ -53,8 +63,10 @@ import org.dspace.workflow.WorkflowItemService;
|
||||
import org.dspace.workflow.WorkflowService;
|
||||
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.rest.webmvc.json.patch.PatchException;
|
||||
import org.springframework.jdbc.datasource.init.UncategorizedScriptException;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* Service to manipulate in-progress submissions.
|
||||
@@ -86,6 +98,11 @@ public class SubmissionService {
|
||||
private ConverterService converter;
|
||||
@Autowired
|
||||
private org.dspace.app.rest.utils.Utils utils;
|
||||
private SubmissionConfigReader submissionConfigReader;
|
||||
|
||||
public SubmissionService() throws SubmissionConfigReaderException {
|
||||
submissionConfigReader = new SubmissionConfigReader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a workspaceitem using the information in the request
|
||||
@@ -291,4 +308,155 @@ public class SubmissionService {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method used by the {@link WorkspaceItemRestRepository} and
|
||||
* {@link WorkflowItemRestRepository} to deal with the upload in an inprogress
|
||||
* submission
|
||||
*
|
||||
* @param context DSpace Context Object
|
||||
* @param request the http request containing the upload request
|
||||
* @param wsi the inprogress submission current rest representation
|
||||
* @param source the current inprogress submission
|
||||
* @param file the multipartfile of the request
|
||||
* @return the errors present in the resulting inprogress submission
|
||||
*/
|
||||
public List<ErrorRest> uploadFileToInprogressSubmission(Context context, HttpServletRequest request,
|
||||
AInprogressSubmissionRest wsi, InProgressSubmission source, MultipartFile file) {
|
||||
List<ErrorRest> errors = new ArrayList<ErrorRest>();
|
||||
SubmissionConfig submissionConfig =
|
||||
submissionConfigReader.getSubmissionConfigByName(wsi.getSubmissionDefinition().getName());
|
||||
List<Object[]> stepInstancesAndConfigs = new ArrayList<Object[]>();
|
||||
// we need to run the preProcess of all the appropriate steps and move on to the
|
||||
// upload and postProcess step
|
||||
// We will initialize the step class just one time so that it will be the same
|
||||
// instance over all the phase and we will reduce initialization time as well
|
||||
for (int i = 0; i < submissionConfig.getNumberOfSteps(); i++) {
|
||||
SubmissionStepConfig stepConfig = submissionConfig.getStep(i);
|
||||
/*
|
||||
* First, load the step processing class (using the current
|
||||
* class loader)
|
||||
*/
|
||||
ClassLoader loader = this.getClass().getClassLoader();
|
||||
Class stepClass;
|
||||
try {
|
||||
stepClass = loader.loadClass(stepConfig.getProcessingClassName());
|
||||
if (UploadableStep.class.isAssignableFrom(stepClass)) {
|
||||
Object stepInstance = stepClass.newInstance();
|
||||
stepInstancesAndConfigs.add(new Object[] {stepInstance, stepConfig});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
for (Object[] stepInstanceAndCfg : stepInstancesAndConfigs) {
|
||||
UploadableStep uploadableStep = (UploadableStep) stepInstanceAndCfg[0];
|
||||
if (uploadableStep instanceof ListenerProcessingStep) {
|
||||
((ListenerProcessingStep) uploadableStep).doPreProcessing(context, source);
|
||||
}
|
||||
}
|
||||
for (Object[] stepInstanceAndCfg : stepInstancesAndConfigs) {
|
||||
UploadableStep uploadableStep = (UploadableStep) stepInstanceAndCfg[0];
|
||||
ErrorRest err;
|
||||
try {
|
||||
err = uploadableStep.upload(context, this, (SubmissionStepConfig) stepInstanceAndCfg[1],
|
||||
source, file);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (err != null) {
|
||||
errors.add(err);
|
||||
}
|
||||
}
|
||||
for (Object[] stepInstanceAndCfg : stepInstancesAndConfigs) {
|
||||
UploadableStep uploadableStep = (UploadableStep) stepInstanceAndCfg[0];
|
||||
if (uploadableStep instanceof ListenerProcessingStep) {
|
||||
((ListenerProcessingStep) uploadableStep).doPostProcessing(context, source);
|
||||
}
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method used by the {@link WorkspaceItemRestRepository} and
|
||||
* {@link WorkflowItemRestRepository} to deal with the patch of an inprogress
|
||||
* submission
|
||||
*
|
||||
* @param context DSpace Context Object
|
||||
* @param request the http request
|
||||
* @param source the current inprogress submission
|
||||
* @param wsi the inprogress submission current rest representation
|
||||
* @param section the section that is involved in the patch
|
||||
* @param op the patch operation
|
||||
*/
|
||||
public void evaluatePatchToInprogressSubmission(Context context, HttpServletRequest request,
|
||||
InProgressSubmission source, AInprogressSubmissionRest wsi, String section, Operation op) {
|
||||
boolean sectionExist = false;
|
||||
SubmissionConfig submissionConfig = submissionConfigReader
|
||||
.getSubmissionConfigByName(wsi.getSubmissionDefinition().getName());
|
||||
List<Object[]> stepInstancesAndConfigs = new ArrayList<Object[]>();
|
||||
// we need to run the preProcess of all the appropriate steps and move on to the
|
||||
// doPatchProcessing and postProcess step
|
||||
// We will initialize the step classes just one time so that it will be the same
|
||||
// instance over all the phase and we will reduce initialization time as well
|
||||
for (int i = 0; i < submissionConfig.getNumberOfSteps(); i++) {
|
||||
SubmissionStepConfig stepConfig = submissionConfig.getStep(i);
|
||||
if (section.equals(stepConfig.getId())) {
|
||||
sectionExist = true;
|
||||
}
|
||||
/*
|
||||
* First, load the step processing class (using the current class loader)
|
||||
*/
|
||||
ClassLoader loader = this.getClass().getClassLoader();
|
||||
Class stepClass;
|
||||
try {
|
||||
stepClass = loader.loadClass(stepConfig.getProcessingClassName());
|
||||
if (RestProcessingStep.class.isAssignableFrom(stepClass)) {
|
||||
Object stepInstance = stepClass.newInstance();
|
||||
stepInstancesAndConfigs.add(new Object[] { stepInstance, stepConfig });
|
||||
} else {
|
||||
throw new DSpaceBadRequestException("The submission step class specified by '"
|
||||
+ stepConfig.getProcessingClassName()
|
||||
+ "' does not implement the interface org.dspace.app.rest.submit.RestProcessingStep!"
|
||||
+ " Therefore it cannot be used by the Configurable Submission as the <processing-class>!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new PatchException("Error processing the patch request", e);
|
||||
}
|
||||
}
|
||||
if (!sectionExist) {
|
||||
throw new UnprocessableEntityException(
|
||||
"The section with name " + section + " does not exist in this submission!");
|
||||
}
|
||||
for (Object[] stepInstanceAndCfg : stepInstancesAndConfigs) {
|
||||
if (stepInstanceAndCfg[0] instanceof ListenerProcessingStep) {
|
||||
ListenerProcessingStep step = (ListenerProcessingStep) stepInstanceAndCfg[0];
|
||||
step.doPreProcessing(context, source);
|
||||
}
|
||||
}
|
||||
for (Object[] stepInstanceAndCfg : stepInstancesAndConfigs) {
|
||||
// only the step related to the involved section need to be invoked
|
||||
SubmissionStepConfig stepConfig = (SubmissionStepConfig) stepInstanceAndCfg[1];
|
||||
if (!section.equals(stepConfig.getId())) {
|
||||
continue;
|
||||
}
|
||||
AbstractRestProcessingStep step = (AbstractRestProcessingStep) stepInstanceAndCfg[0];
|
||||
try {
|
||||
step.doPatchProcessing(context, request, source, op, stepConfig);
|
||||
} catch (UnprocessableEntityException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new PatchException("Error processing the patch request", e);
|
||||
}
|
||||
}
|
||||
for (Object[] stepInstanceAndCfg : stepInstancesAndConfigs) {
|
||||
if (stepInstanceAndCfg[0] instanceof ListenerProcessingStep) {
|
||||
ListenerProcessingStep step = (ListenerProcessingStep) stepInstanceAndCfg[0];
|
||||
step.doPostProcessing(context, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
public interface UploadableStep extends ListenerProcessingStep {
|
||||
public interface UploadableStep {
|
||||
|
||||
/**
|
||||
* The method to implement to support upload of a file in the submission section (aka panel / step)
|
||||
|
@@ -7,10 +7,11 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
|
||||
/**
|
||||
* Class to manage HTTP PATCH method operation ADD. Please see https://tools.ietf.org/html/rfc6902
|
||||
@@ -21,12 +22,12 @@ import org.dspace.services.model.Request;
|
||||
public abstract class AddPatchOperation<T extends Object> extends PatchOperation<T> {
|
||||
|
||||
@Override
|
||||
public void perform(Context context, Request currentRequest, InProgressSubmission source, Operation operation)
|
||||
throws Exception {
|
||||
public void perform(Context context, HttpServletRequest currentRequest, InProgressSubmission source,
|
||||
Operation operation) throws Exception {
|
||||
add(context, currentRequest, source, operation.getPath(), operation.getValue());
|
||||
}
|
||||
|
||||
abstract void add(Context context, Request currentRequest, InProgressSubmission source, String string, Object value)
|
||||
throws Exception;
|
||||
abstract void add(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String string,
|
||||
Object value) throws Exception;
|
||||
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.MetadataValueRest;
|
||||
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||
@@ -21,7 +22,6 @@ import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class BitstreamMetadataValueAddPatchOperation extends MetadataValueAddPat
|
||||
BitstreamMetadataValuePathUtils bitstreamMetadataValuePathUtils;
|
||||
|
||||
@Override
|
||||
void add(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
void add(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
//"path": "/sections/upload/files/0/metadata/dc.title/2"
|
||||
//"abspath": "/files/0/metadata/dc.title/2"
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.utils.BitstreamMetadataValuePathUtils;
|
||||
import org.dspace.content.Bitstream;
|
||||
@@ -18,7 +19,6 @@ import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,7 @@ public class BitstreamMetadataValueMovePatchOperation extends MetadataValueMoveP
|
||||
BitstreamMetadataValuePathUtils bitstreamMetadataValuePathUtils;
|
||||
|
||||
@Override
|
||||
void move(Context context, Request currentRequest, InProgressSubmission source, String path, String from)
|
||||
void move(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path, String from)
|
||||
throws Exception {
|
||||
//"path": "/sections/upload/files/0/metadata/dc.title/2"
|
||||
//"abspath": "/files/0/metadata/dc.title/2"
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.utils.BitstreamMetadataValuePathUtils;
|
||||
import org.dspace.content.Bitstream;
|
||||
@@ -18,7 +19,6 @@ import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -40,8 +40,8 @@ public class BitstreamMetadataValueRemovePatchOperation extends MetadataValueRem
|
||||
BitstreamMetadataValuePathUtils bitstreamMetadataValuePathUtils;
|
||||
|
||||
@Override
|
||||
void remove(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
void remove(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path,
|
||||
Object value) throws Exception {
|
||||
//"path": "/sections/upload/files/0/metadata/dc.title/2"
|
||||
//"abspath": "/files/0/metadata/dc.title/2"
|
||||
String absolutePath = getAbsolutePath(path);
|
||||
|
@@ -9,6 +9,7 @@ package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.MetadataValueRest;
|
||||
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||
@@ -22,7 +23,6 @@ import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -43,8 +43,8 @@ public class BitstreamMetadataValueReplacePatchOperation extends MetadataValueRe
|
||||
BitstreamMetadataValuePathUtils bitstreamMetadataValuePathUtils;
|
||||
|
||||
@Override
|
||||
void replace(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
void replace(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path,
|
||||
Object value) throws Exception {
|
||||
//"path": "/sections/upload/files/0/metadata/dc.title/2"
|
||||
//"abspath": "/files/0/metadata/dc.title/2"
|
||||
String absolutePath = getAbsolutePath(path);
|
||||
|
@@ -7,11 +7,12 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.content.service.BundleService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -39,7 +40,7 @@ public class BitstreamMovePatchOperation extends MovePatchOperation<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
void move(Context context, Request currentRequest, InProgressSubmission source, String path, String from)
|
||||
void move(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path, String from)
|
||||
throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.Bundle;
|
||||
@@ -17,7 +18,6 @@ import org.dspace.content.service.BundleService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -34,8 +34,8 @@ public class BitstreamRemovePatchOperation extends RemovePatchOperation<String>
|
||||
BundleService bundleService;
|
||||
|
||||
@Override
|
||||
void remove(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
void remove(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path,
|
||||
Object value) throws Exception {
|
||||
|
||||
String absPath = getAbsolutePath(path);
|
||||
String[] split = absPath.split("/");
|
||||
|
@@ -11,6 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.UploadBitstreamAccessConditionDTO;
|
||||
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||
@@ -22,7 +23,6 @@ import org.dspace.content.Item;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.dspace.submit.model.UploadConfiguration;
|
||||
import org.dspace.submit.model.UploadConfigurationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -45,7 +45,7 @@ public class BitstreamResourcePolicyAddPatchOperation extends AddPatchOperation<
|
||||
UploadConfigurationService uploadConfigurationService;
|
||||
|
||||
@Override
|
||||
void add(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
void add(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
//"path": "/sections/upload/files/0/accessConditions"
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.UploadBitstreamAccessConditionDTO;
|
||||
import org.dspace.authorize.ResourcePolicy;
|
||||
@@ -20,7 +21,6 @@ import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -41,8 +41,8 @@ public class BitstreamResourcePolicyRemovePatchOperation
|
||||
BitstreamService bitstreamService;
|
||||
|
||||
@Override
|
||||
void remove(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
void remove(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path,
|
||||
Object value) throws Exception {
|
||||
// "path" : "/sections/upload/files/0/accessConditions/0"
|
||||
// "abspath" : "/files/0/accessConditions/0"
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
|
@@ -11,6 +11,7 @@ import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.ResourcePolicyRest;
|
||||
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||
@@ -24,7 +25,6 @@ import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.dspace.submit.model.UploadConfiguration;
|
||||
import org.dspace.submit.model.UploadConfigurationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -48,8 +48,8 @@ public class BitstreamResourcePolicyReplacePatchOperation extends ReplacePatchOp
|
||||
UploadConfigurationService uploadConfigurationService;
|
||||
|
||||
@Override
|
||||
void replace(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
void replace(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path,
|
||||
Object value) throws Exception {
|
||||
// "path": "/sections/upload/files/0/accessConditions/0"
|
||||
// "abspath": "/files/0/accessConditions/0"
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
|
@@ -7,12 +7,13 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.license.service.CreativeCommonsService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
||||
@@ -44,10 +45,8 @@ public class CCLicenseAddPatchOperation extends AddPatchOperation<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
void add(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
void add(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
|
||||
|
||||
String licenseUri = null;
|
||||
if (value instanceof String) {
|
||||
licenseUri = (String) value;
|
||||
|
@@ -7,12 +7,13 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.license.service.CreativeCommonsService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
|
||||
@@ -42,8 +43,8 @@ public class CCLicenseRemovePatchOperation extends RemovePatchOperation<String>
|
||||
}
|
||||
|
||||
@Override
|
||||
void remove(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
void remove(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path,
|
||||
Object value) throws Exception {
|
||||
Item item = source.getItem();
|
||||
|
||||
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.util.DCInputsReaderException;
|
||||
import org.dspace.content.Collection;
|
||||
@@ -17,7 +18,6 @@ import org.dspace.content.service.CollectionService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.WorkspaceItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.dspace.util.UUIDUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -36,8 +36,8 @@ public class CollectionReplacePatchOperation extends ReplacePatchOperation<Strin
|
||||
WorkspaceItemService workspaceItemService;
|
||||
|
||||
@Override
|
||||
void replace(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws SQLException, DCInputsReaderException {
|
||||
void replace(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path,
|
||||
Object value) throws SQLException, DCInputsReaderException {
|
||||
|
||||
if (!(source instanceof WorkspaceItem)) {
|
||||
throw new IllegalArgumentException("the replace operation is only supported on workspaceitem");
|
||||
|
@@ -9,6 +9,7 @@ package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.MetadataValueRest;
|
||||
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||
@@ -17,7 +18,6 @@ import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ItemMetadataValueAddPatchOperation extends MetadataValueAddPatchOpe
|
||||
ItemService itemService;
|
||||
|
||||
@Override
|
||||
void add(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
void add(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws SQLException {
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
// if split size is one so we have a call to initialize or replace
|
||||
|
@@ -7,11 +7,12 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -35,7 +36,7 @@ public class ItemMetadataValueMovePatchOperation extends MetadataValueMovePatchO
|
||||
ItemService itemService;
|
||||
|
||||
@Override
|
||||
void move(Context context, Request currentRequest, InProgressSubmission source, String path, String from)
|
||||
void move(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path, String from)
|
||||
throws Exception {
|
||||
String[] splitTo = getAbsolutePath(path).split("/");
|
||||
|
||||
|
@@ -7,11 +7,12 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -43,8 +44,8 @@ public class ItemMetadataValueRemovePatchOperation extends MetadataValueRemovePa
|
||||
ItemService itemService;
|
||||
|
||||
@Override
|
||||
void remove(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
void remove(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path,
|
||||
Object value) throws Exception {
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
if (split.length == 1) {
|
||||
deleteValue(context, source.getItem(), split[0], -1);
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.MetadataValueRest;
|
||||
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||
@@ -16,7 +17,6 @@ import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -50,8 +50,8 @@ public class ItemMetadataValueReplacePatchOperation extends MetadataValueReplace
|
||||
ItemService itemService;
|
||||
|
||||
@Override
|
||||
void replace(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
void replace(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path,
|
||||
Object value) throws Exception {
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
|
||||
List<MetadataValue> metadataByMetadataString = itemService.getMetadataByMetadataString(source.getItem(),
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.content.Item;
|
||||
@@ -14,7 +16,6 @@ import org.dspace.content.LicenseUtils;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -49,7 +50,7 @@ public class LicenseAddPatchOperation extends AddPatchOperation<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
void add(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
void add(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
|
||||
Boolean grant = null;
|
||||
|
@@ -7,11 +7,12 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -32,8 +33,8 @@ public class LicenseRemovePatchOperation extends RemovePatchOperation<String> {
|
||||
ItemService itemService;
|
||||
|
||||
@Override
|
||||
void remove(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
void remove(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path,
|
||||
Object value) throws Exception {
|
||||
Item item = source.getItem();
|
||||
itemService.removeDSpaceLicense(context, item);
|
||||
}
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.content.Item;
|
||||
@@ -14,7 +16,6 @@ import org.dspace.content.LicenseUtils;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -30,8 +31,8 @@ public class LicenseReplacePatchOperation extends ReplacePatchOperation<String>
|
||||
ItemService itemService;
|
||||
|
||||
@Override
|
||||
void replace(Context context, Request currentRequest, InProgressSubmission source, String path, Object value)
|
||||
throws Exception {
|
||||
void replace(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path,
|
||||
Object value) throws Exception {
|
||||
|
||||
Boolean grant = null;
|
||||
// we are friendly with the client and accept also a string representation for the boolean
|
||||
|
@@ -7,11 +7,12 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.patch.MoveOperation;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
|
||||
/**
|
||||
* Class to manage HTTP PATCH method operation MOVE
|
||||
@@ -22,12 +23,12 @@ import org.dspace.services.model.Request;
|
||||
public abstract class MovePatchOperation<T extends Object> extends PatchOperation<T> {
|
||||
|
||||
@Override
|
||||
public void perform(Context context, Request currentRequest, InProgressSubmission source, Operation operation)
|
||||
throws Exception {
|
||||
public void perform(Context context, HttpServletRequest currentRequest, InProgressSubmission source,
|
||||
Operation operation) throws Exception {
|
||||
move(context, currentRequest, source, operation.getPath(), ((MoveOperation) operation).getFrom());
|
||||
}
|
||||
|
||||
abstract void move(Context context, Request currentRequest, InProgressSubmission source, String path, String from)
|
||||
throws Exception;
|
||||
abstract void move(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String path,
|
||||
String from) throws Exception;
|
||||
|
||||
}
|
||||
|
@@ -9,12 +9,12 @@ package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.patch.LateObjectEvaluator;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
|
||||
/**
|
||||
* Class to abstract the HTTP PATCH method operation
|
||||
@@ -24,7 +24,7 @@ import org.dspace.services.model.Request;
|
||||
*/
|
||||
public abstract class PatchOperation<T extends Object> {
|
||||
|
||||
public abstract void perform(Context context, Request currentRequest, InProgressSubmission source,
|
||||
public abstract void perform(Context context, HttpServletRequest currentRequest, InProgressSubmission source,
|
||||
Operation operation)
|
||||
throws Exception;
|
||||
|
||||
|
@@ -7,10 +7,11 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
|
||||
/**
|
||||
* Class to manage HTTP PATCH method operation REMOVE
|
||||
@@ -21,12 +22,12 @@ import org.dspace.services.model.Request;
|
||||
public abstract class RemovePatchOperation<T extends Object> extends PatchOperation<T> {
|
||||
|
||||
@Override
|
||||
public void perform(Context context, Request currentRequest, InProgressSubmission source, Operation operation)
|
||||
throws Exception {
|
||||
public void perform(Context context, HttpServletRequest currentRequest, InProgressSubmission source,
|
||||
Operation operation) throws Exception {
|
||||
remove(context, currentRequest, source, operation.getPath(), operation.getValue());
|
||||
}
|
||||
|
||||
abstract void remove(Context context, Request currentRequest, InProgressSubmission source, String string,
|
||||
abstract void remove(Context context, HttpServletRequest currentRequest, InProgressSubmission source, String string,
|
||||
Object value)
|
||||
throws Exception;
|
||||
|
||||
|
@@ -7,10 +7,11 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
|
||||
/**
|
||||
* Class to manage HTTP PATCH method operation REPLACE
|
||||
@@ -21,13 +22,12 @@ import org.dspace.services.model.Request;
|
||||
public abstract class ReplacePatchOperation<T extends Object> extends PatchOperation<T> {
|
||||
|
||||
@Override
|
||||
public void perform(Context context, Request currentRequest, InProgressSubmission source, Operation operation)
|
||||
throws Exception {
|
||||
public void perform(Context context, HttpServletRequest currentRequest, InProgressSubmission source,
|
||||
Operation operation) throws Exception {
|
||||
replace(context, currentRequest, source, operation.getPath(), operation.getValue());
|
||||
}
|
||||
|
||||
abstract void replace(Context context, Request currentRequest, InProgressSubmission source, String string,
|
||||
Object value)
|
||||
throws Exception;
|
||||
abstract void replace(Context context, HttpServletRequest currentRequest, InProgressSubmission source,
|
||||
String string, Object value) throws Exception;
|
||||
|
||||
}
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.step;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.app.rest.model.step.DataCCLicense;
|
||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||
@@ -16,7 +18,6 @@ import org.dspace.app.rest.submit.factory.impl.PatchOperation;
|
||||
import org.dspace.app.util.SubmissionStepConfig;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
|
||||
/**
|
||||
* CC License step for DSpace Spring Rest. Expose the creative commons license information about the in progress
|
||||
@@ -51,8 +52,8 @@ public class CCLicenseStep extends org.dspace.submit.step.CCLicenseStep implemen
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op,
|
||||
SubmissionStepConfig stepConf) throws Exception {
|
||||
public void doPatchProcessing(Context context, HttpServletRequest currentRequest, InProgressSubmission source,
|
||||
Operation op, SubmissionStepConfig stepConf) throws Exception {
|
||||
|
||||
if (op.getPath().endsWith(CCLICENSE_STEP_OPERATION_ENTRY)) {
|
||||
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.app.rest.submit.step;
|
||||
|
||||
import java.util.UUID;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||
@@ -17,7 +18,6 @@ import org.dspace.app.rest.submit.factory.impl.PatchOperation;
|
||||
import org.dspace.app.util.SubmissionStepConfig;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
|
||||
/**
|
||||
* Collection step for DSpace Spring Rest. Expose the collection information of
|
||||
@@ -27,14 +27,6 @@ import org.dspace.services.model.Request;
|
||||
*/
|
||||
public class CollectionStep implements AbstractRestProcessingStep {
|
||||
|
||||
@Override
|
||||
public void doPreProcessing(Context context, InProgressSubmission wsi) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPostProcessing(Context context, InProgressSubmission wsi) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getData(SubmissionService submissionService, InProgressSubmission obj, SubmissionStepConfig config) {
|
||||
if (obj.getCollection() != null) {
|
||||
@@ -44,12 +36,10 @@ public class CollectionStep implements AbstractRestProcessingStep {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op,
|
||||
SubmissionStepConfig stepConf) throws Exception {
|
||||
|
||||
public void doPatchProcessing(Context context, HttpServletRequest currentRequest, InProgressSubmission source,
|
||||
Operation op, SubmissionStepConfig stepConf) throws Exception {
|
||||
PatchOperation<String> patchOperation = new PatchOperationFactory()
|
||||
.instanceOf(COLLECTION_STEP_OPERATION_ENTRY, op.getOp());
|
||||
patchOperation.perform(context, currentRequest, source, op);
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ package org.dspace.app.rest.submit.step;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -30,7 +31,6 @@ import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.Utils;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.dspace.submit.AbstractProcessingStep;
|
||||
|
||||
/**
|
||||
@@ -122,8 +122,8 @@ public class DescribeStep extends AbstractProcessingStep implements AbstractRest
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op,
|
||||
SubmissionStepConfig stepConf) throws Exception {
|
||||
public void doPatchProcessing(Context context, HttpServletRequest currentRequest, InProgressSubmission source,
|
||||
Operation op, SubmissionStepConfig stepConf) throws Exception {
|
||||
|
||||
String[] pathParts = op.getPath().substring(1).split("/");
|
||||
DCInputSet inputConfig = inputReader.getInputsByFormName(stepConf.getId());
|
||||
|
@@ -9,7 +9,6 @@ package org.dspace.app.rest.submit.step;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -23,8 +22,7 @@ import org.apache.commons.collections4.Equator;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.ErrorRest;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||
import org.dspace.app.rest.submit.ListenerProcessingStep;
|
||||
import org.dspace.app.rest.submit.SubmissionService;
|
||||
import org.dspace.app.rest.submit.UploadableStep;
|
||||
import org.dspace.app.rest.utils.Utils;
|
||||
@@ -40,7 +38,6 @@ import org.dspace.external.model.ExternalDataObject;
|
||||
import org.dspace.importer.external.datamodel.ImportRecord;
|
||||
import org.dspace.importer.external.metadatamapping.MetadatumDTO;
|
||||
import org.dspace.importer.external.service.ImportService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.dspace.submit.listener.MetadataListener;
|
||||
import org.dspace.utils.DSpace;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -61,7 +58,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
* @author Andrea Bollini (andrea.bollini at 4science.it)
|
||||
*/
|
||||
public class ExtractMetadataStep implements AbstractRestProcessingStep, UploadableStep {
|
||||
public class ExtractMetadataStep implements ListenerProcessingStep, UploadableStep {
|
||||
|
||||
private ItemService itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
private ImportService importService = new DSpace().getSingletonService(ImportService.class);
|
||||
@@ -197,19 +194,4 @@ public class ExtractMetadataStep implements AbstractRestProcessingStep, Uploadab
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDataSection() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Serializable> T getData(SubmissionService submissionService, InProgressSubmission obj,
|
||||
SubmissionStepConfig config) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op,
|
||||
SubmissionStepConfig stepConf) throws Exception {
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.step;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.atteo.evo.inflector.English;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
import org.dspace.app.rest.model.BitstreamRest;
|
||||
@@ -21,7 +23,6 @@ import org.dspace.content.Bitstream;
|
||||
import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
|
||||
/**
|
||||
* License step for DSpace Spring Rest. Expose the license information about the in progress submission.
|
||||
@@ -51,8 +52,8 @@ public class LicenseStep extends org.dspace.submit.step.LicenseStep implements A
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op,
|
||||
SubmissionStepConfig stepConf) throws Exception {
|
||||
public void doPatchProcessing(Context context, HttpServletRequest currentRequest, InProgressSubmission source,
|
||||
Operation op, SubmissionStepConfig stepConf) throws Exception {
|
||||
|
||||
if (op.getPath().endsWith(LICENSE_STEP_OPERATION_ENTRY)) {
|
||||
|
||||
|
@@ -10,6 +10,7 @@ package org.dspace.app.rest.submit.step;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
@@ -32,7 +33,6 @@ import org.dspace.content.InProgressSubmission;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
@@ -64,8 +64,8 @@ public class UploadStep extends org.dspace.submit.step.UploadStep
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPatchProcessing(Context context, Request currentRequest, InProgressSubmission source, Operation op,
|
||||
SubmissionStepConfig stepConf) throws Exception {
|
||||
public void doPatchProcessing(Context context, HttpServletRequest currentRequest, InProgressSubmission source,
|
||||
Operation op, SubmissionStepConfig stepConf) throws Exception {
|
||||
|
||||
String instance = null;
|
||||
if ("remove".equals(op.getOp())) {
|
||||
|
@@ -221,6 +221,21 @@ public class SubmissionDefinitionsControllerIT extends AbstractControllerIntegra
|
||||
"config/submissionsections/traditionalpageone"))
|
||||
))))
|
||||
;
|
||||
// the extract submission should NOT expose the backend only extract panel
|
||||
getClient(token).perform(get("/api/config/submissiondefinitions/extractiontestprocess/sections")
|
||||
.param("projection", "full"))
|
||||
// The status has to be 200 OK
|
||||
.andExpect(status().isOk())
|
||||
// We expect the content type to be "application/hal+json;charset=UTF-8"
|
||||
.andExpect(content().contentType(contentType))
|
||||
// Match only that a section exists with a submission configuration behind
|
||||
.andExpect(jsonPath("$._embedded.submissionsections", hasSize(6)))
|
||||
.andExpect(jsonPath("$._embedded.submissionsections",
|
||||
Matchers.not(Matchers.hasItem(
|
||||
hasJsonPath("$.id", is("extractionstep"))
|
||||
))))
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user