mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 06:53:09 +00:00
D4CRIS-416 refactoring to accept "from" attribute from operation; introduce constants to discriminate patch operation implementation; finalize move operation for metadata;
This commit is contained in:
@@ -645,4 +645,52 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
||||
lang, value, authority, confidence);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveMetadata(Context context, T dso, String schema, String element, String qualifier, int from, int to)
|
||||
throws SQLException, IllegalArgumentException {
|
||||
|
||||
if(from==to) {
|
||||
throw new IllegalArgumentException("The \"from\" location MUST be different from \"to\" location");
|
||||
}
|
||||
|
||||
List<MetadataValue> list = getMetadata(dso, schema, element, qualifier, Item.ANY);
|
||||
|
||||
if(from>=list.size()) {
|
||||
throw new IllegalArgumentException("The \"from\" location MUST exist for the operation to be successful. Idx:" + from);
|
||||
}
|
||||
|
||||
clearMetadata(context, dso, schema, element, qualifier, Item.ANY);
|
||||
|
||||
int idx = 0;
|
||||
MetadataValue moved = null;
|
||||
for (MetadataValue md : list) {
|
||||
if (idx == from) {
|
||||
moved = md;
|
||||
break;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
boolean last = true;
|
||||
for (MetadataValue rr : list) {
|
||||
if (idx == to && to<from) {
|
||||
addMetadata(context, dso, schema, element, qualifier, moved.getLanguage(), moved.getValue(), moved.getAuthority(), moved.getConfidence());
|
||||
last = false;
|
||||
}
|
||||
if (idx != from) {
|
||||
addMetadata(context, dso, schema, element, qualifier, rr.getLanguage(), rr.getValue(),
|
||||
rr.getAuthority(), rr.getConfidence());
|
||||
}
|
||||
if (idx == to && to>from) {
|
||||
addMetadata(context, dso, schema, element, qualifier, moved.getLanguage(), moved.getValue(), moved.getAuthority(), moved.getConfidence());
|
||||
last = false;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
if (last) {
|
||||
addMetadata(context, dso, schema, element, qualifier, moved.getLanguage(), moved.getValue(), moved.getAuthority(), moved.getConfidence());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -401,4 +401,6 @@ public interface DSpaceObjectService<T extends DSpaceObject> {
|
||||
public int getSupportsTypeConstant();
|
||||
|
||||
void addAndShiftRightMetadata(Context context, T dso, String schema, String element, String qualifier, String lang, String value, String authority, int confidence, int index) throws SQLException;
|
||||
|
||||
void moveMetadata(Context context, T dso, String schema, String element, String qualifier, int from, int to) throws SQLException;
|
||||
}
|
||||
|
@@ -250,13 +250,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];
|
||||
String absolutePath = "";
|
||||
if(path.length>2) {
|
||||
absolutePath = path[2];
|
||||
}
|
||||
String operation = op.getOp();
|
||||
|
||||
evaluatePatch(context, request, source, wsi, operation, section, absolutePath, op.getValue());
|
||||
evaluatePatch(context, request, source, wsi, section, op);
|
||||
}
|
||||
else {
|
||||
throw new PatchBadRequestException("Patch path operation need to starts with '" + OPERATION_PATH_SECTIONS + "'");
|
||||
@@ -265,8 +259,7 @@ public class WorkspaceItemRestRepository extends DSpaceRestRepository<WorkspaceI
|
||||
wis.update(context, source);
|
||||
}
|
||||
|
||||
private void evaluatePatch(Context context, HttpServletRequest request, WorkspaceItem source, WorkspaceItemRest wsi, String operation, String section, String path,
|
||||
Object value) {
|
||||
private void evaluatePatch(Context context, HttpServletRequest request, WorkspaceItem source, WorkspaceItemRest wsi, String section, Operation op) {
|
||||
SubmissionConfig submissionConfig = submissionConfigReader.getSubmissionConfigByName(wsi.getSubmissionDefinition().getName());
|
||||
for(int stepNum = 0; stepNum<submissionConfig.getNumberOfSteps(); stepNum++) {
|
||||
|
||||
@@ -288,7 +281,7 @@ public class WorkspaceItemRestRepository extends DSpaceRestRepository<WorkspaceI
|
||||
// load the JSPStep interface for this step
|
||||
AbstractRestProcessingStep stepProcessing = (AbstractRestProcessingStep) stepClass
|
||||
.newInstance();
|
||||
stepProcessing.doPatchProcessing(context, getRequestService().getCurrentRequest(), source, operation, path, value);
|
||||
stepProcessing.doPatchProcessing(context, getRequestService().getCurrentRequest(), source, op);
|
||||
} else {
|
||||
throw new PatchBadRequestException("The submission step class specified by '"
|
||||
+ stepConfig.getProcessingClassName()
|
||||
|
@@ -11,8 +11,8 @@ import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.app.rest.model.ErrorRest;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.app.rest.submit.step.validation.Validation;
|
||||
import org.dspace.app.util.SubmissionStepConfig;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
@@ -28,6 +28,13 @@ import org.dspace.services.model.Request;
|
||||
*/
|
||||
public interface AbstractRestProcessingStep {
|
||||
|
||||
public static final String DESCRIBE_STEP_METADATA_OPERATION_ENTRY = "itemmetadata";
|
||||
public static final String COLLECTION_STEP_OPERATION_ENTRY = "collection";
|
||||
public static final String UPLOAD_STEP_METADATA_OPERATION_ENTRY = "bitstreammetadata";
|
||||
public static final String UPLOAD_STEP_REMOVE_OPERATION_ENTRY = "bitstreamremove";
|
||||
public static final String UPLOAD_STEP_ACCESSCONDITIONS_OPERATION_ENTRY = "accessConditions";
|
||||
public static final String LICENSE_STEP_OPERATION_ENTRY = "acceptanceDate";
|
||||
|
||||
public <T extends Serializable> T getData(SubmissionService submissionService, WorkspaceItem obj, SubmissionStepConfig config) throws Exception;
|
||||
|
||||
default public List<ErrorRest> validate(SubmissionService submissionService, WorkspaceItem obj, SubmissionStepConfig config) throws Exception
|
||||
@@ -44,7 +51,6 @@ public interface AbstractRestProcessingStep {
|
||||
return errors;
|
||||
}
|
||||
|
||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, String operation,
|
||||
String path, Object value) throws Exception;
|
||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, Operation op) throws Exception;
|
||||
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
@@ -22,8 +23,8 @@ import org.dspace.services.model.Request;
|
||||
public abstract class AddPatchOperation<T extends Object> extends PatchOperation<T> {
|
||||
|
||||
@Override
|
||||
public void perform(Context context, Request currentRequest, WorkspaceItem source, String string, Object value) throws Exception {
|
||||
add(context, currentRequest, source, string, value);
|
||||
public void perform(Context context, Request currentRequest, WorkspaceItem source, Operation operation) throws Exception {
|
||||
add(context, currentRequest, source, operation.getPath(), operation.getValue());
|
||||
}
|
||||
|
||||
abstract void add(Context context,Request currentRequest,WorkspaceItem source,String string,Object value) throws Exception;
|
||||
|
@@ -42,7 +42,7 @@ public class BitstreamMetadataValueAddPatchOperation extends MetadataValueAddPat
|
||||
|
||||
@Override
|
||||
void add(Context context, Request currentRequest, WorkspaceItem source, String path, Object value) throws Exception {
|
||||
String[] split = path.split("/");
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
Item item = source.getItem();
|
||||
List<Bundle> bundle = itemService.getBundles(item, Constants.CONTENT_BUNDLE_NAME);;
|
||||
for(Bundle bb : bundle) {
|
||||
|
@@ -19,7 +19,6 @@ 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.data.rest.webmvc.json.patch.LateObjectEvaluator;
|
||||
|
||||
/**
|
||||
* Submission "move" PATCH operation.
|
||||
@@ -38,9 +37,9 @@ public class BitstreamMetadataValueMovePatchOperation extends MetadataValueMoveP
|
||||
ItemService itemService;
|
||||
|
||||
@Override
|
||||
void move(Context context, Request currentRequest, WorkspaceItem source, String path, Object from)
|
||||
void move(Context context, Request currentRequest, WorkspaceItem source, String path, String from)
|
||||
throws Exception {
|
||||
String[] splitTo = path.split("/");
|
||||
String[] splitTo = getAbsolutePath(path).split("/");
|
||||
Item item = source.getItem();
|
||||
List<Bundle> bundle = itemService.getBundles(item, Constants.CONTENT_BUNDLE_NAME);
|
||||
for (Bundle bb : bundle) {
|
||||
@@ -48,7 +47,7 @@ public class BitstreamMetadataValueMovePatchOperation extends MetadataValueMoveP
|
||||
for (Bitstream b : bb.getBitstreams()) {
|
||||
if (idx == Integer.parseInt(splitTo[0])) {
|
||||
|
||||
String evalFrom = evaluateString((LateObjectEvaluator) from);
|
||||
String evalFrom = getAbsolutePath(from);
|
||||
String[] splitFrom = evalFrom.split("/");
|
||||
String metadata = splitFrom[0];
|
||||
|
||||
|
@@ -38,7 +38,7 @@ public class BitstreamMetadataValueRemovePatchOperation extends MetadataValueRem
|
||||
|
||||
@Override
|
||||
void remove(Context context, Request currentRequest, WorkspaceItem source, String path, Object value) throws Exception {
|
||||
String[] split = path.split("/");
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
Item item = source.getItem();
|
||||
List<Bundle> bundle = itemService.getBundles(item, Constants.CONTENT_BUNDLE_NAME);;
|
||||
for(Bundle bb : bundle) {
|
||||
|
@@ -47,7 +47,7 @@ public class BitstreamMetadataValueReplacePatchOperation extends MetadataValueRe
|
||||
@Override
|
||||
void replace(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
||||
throws Exception {
|
||||
String[] split = path.split("/");
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
Item item = source.getItem();
|
||||
List<Bundle> bundle = itemService.getBundles(item, Constants.CONTENT_BUNDLE_NAME);
|
||||
for (Bundle bb : bundle) {
|
||||
|
@@ -45,7 +45,7 @@ public class BitstreamRemovePatchOperation extends RemovePatchOperation<String>{
|
||||
external : for(Bundle bb : bbb) {
|
||||
int idx = 0;
|
||||
for(Bitstream b : bb.getBitstreams()) {
|
||||
if(idx==Integer.parseInt(path)) {
|
||||
if(idx==Integer.parseInt(getAbsolutePath(path))) {
|
||||
bitstream = b;
|
||||
break external;
|
||||
}
|
||||
|
@@ -74,7 +74,7 @@ public class ItemMetadataValueAddPatchOperation extends MetadataValueAddPatchOpe
|
||||
@Override
|
||||
void add(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
||||
throws SQLException {
|
||||
String[] split = path.split("/");
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
// if split size is one so we have a call to initialize or replace
|
||||
if (split.length == 1) {
|
||||
List<MetadataValueRest> list = evaluateArrayObject((LateObjectEvaluator) value);
|
||||
|
@@ -13,7 +13,6 @@ 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.data.rest.webmvc.json.patch.LateObjectEvaluator;
|
||||
|
||||
/**
|
||||
* Submission "move" PATCH operation.
|
||||
@@ -37,11 +36,11 @@ public class ItemMetadataValueMovePatchOperation extends MetadataValueMovePatchO
|
||||
ItemService itemService;
|
||||
|
||||
@Override
|
||||
void move(Context context, Request currentRequest, WorkspaceItem source, String path, Object from)
|
||||
void move(Context context, Request currentRequest, WorkspaceItem source, String path, String from)
|
||||
throws Exception {
|
||||
String[] splitTo = path.split("/");
|
||||
String[] splitTo = getAbsolutePath(path).split("/");
|
||||
|
||||
String evalFrom = (String)from;
|
||||
String evalFrom = getAbsolutePath(from);
|
||||
String[] splitFrom = evalFrom.split("/");
|
||||
String metadata = splitFrom[0];
|
||||
|
||||
|
@@ -46,7 +46,7 @@ public class ItemMetadataValueRemovePatchOperation extends MetadataValueRemovePa
|
||||
@Override
|
||||
void remove(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
||||
throws Exception {
|
||||
String[] split = path.split("/");
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
if (split.length == 1) {
|
||||
deleteValue(context, source.getItem(), split[0], -1);
|
||||
} else {
|
||||
|
@@ -57,7 +57,7 @@ public class ItemMetadataValueReplacePatchOperation extends MetadataValueReplace
|
||||
@Override
|
||||
void replace(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
||||
throws Exception {
|
||||
String[] split = path.split("/");
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
|
||||
List<MetadataValue> metadataByMetadataString = itemService.getMetadataByMetadataString(source.getItem(),
|
||||
split[0]);
|
||||
|
@@ -52,7 +52,7 @@ public class LicenseAddPatchOperation extends AddPatchOperation<String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
void add(Context context, Request currentRequest, WorkspaceItem source, String string, Object value)
|
||||
void add(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
||||
throws Exception {
|
||||
Item item = source.getItem();
|
||||
EPerson submitter = context.getCurrentUser();
|
||||
|
@@ -34,7 +34,7 @@ public class LicenseRemovePatchOperation extends RemovePatchOperation<String> {
|
||||
ItemService itemService;
|
||||
|
||||
@Override
|
||||
void remove(Context context, Request currentRequest, WorkspaceItem source, String string, Object value) throws Exception {
|
||||
void remove(Context context, Request currentRequest, WorkspaceItem source, String path, Object value) throws Exception {
|
||||
Item item = source.getItem();
|
||||
itemService.removeDSpaceLicense(context, item);
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ public class LicenseReplacePatchOperation extends ReplacePatchOperation<String>
|
||||
ItemService itemService;
|
||||
|
||||
@Override
|
||||
void replace(Context context, Request currentRequest, WorkspaceItem source, String string, Object value)
|
||||
void replace(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
||||
throws Exception {
|
||||
Item item = source.getItem();
|
||||
List<Bundle> bunds = itemService.getBundles(item, "LICENSE");
|
||||
|
@@ -40,22 +40,8 @@ public abstract class MetadataValueMovePatchOperation<DSO extends DSpaceObject>
|
||||
|
||||
protected void moveValue(Context context, DSO source, String target, int from, int to) throws SQLException {
|
||||
String[] metadata = Utils.tokenize(target);
|
||||
List<MetadataValue> metadataList = getDSpaceObjectService().getMetadataByMetadataString(source, target);
|
||||
|
||||
int idx = 0;
|
||||
MetadataValueRest object = new MetadataValueRest();
|
||||
for (MetadataValue md : metadataList) {
|
||||
if (idx == from) {
|
||||
object.setAuthority(md.getAuthority());
|
||||
object.setConfidence(md.getConfidence());
|
||||
object.setLanguage(md.getLanguage());
|
||||
object.setPlace(md.getPlace());
|
||||
object.setValue(md.getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
getDSpaceObjectService().addAndShiftRightMetadata(context, source, metadata[0], metadata[1], metadata[2],
|
||||
object.getLanguage(), object.getValue(), object.getAuthority(), object.getConfidence(), to);
|
||||
getDSpaceObjectService().moveMetadata(context, source, metadata[0], metadata[1], metadata[2],
|
||||
from, to);
|
||||
}
|
||||
|
||||
protected abstract DSpaceObjectService<DSO> getDSpaceObjectService();
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import org.dspace.app.rest.model.patch.MoveOperation;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
@@ -22,10 +24,10 @@ import org.dspace.services.model.Request;
|
||||
public abstract class MovePatchOperation<T extends Object> extends PatchOperation<T> {
|
||||
|
||||
@Override
|
||||
public void perform(Context context, Request currentRequest, WorkspaceItem source, String path, Object from) throws Exception {
|
||||
move(context, currentRequest, source, path, from);
|
||||
public void perform(Context context, Request currentRequest, WorkspaceItem source, Operation operation) throws Exception {
|
||||
move(context, currentRequest, source, operation.getPath(), ((MoveOperation)operation).getFrom());
|
||||
}
|
||||
|
||||
abstract void move(Context context, Request currentRequest, WorkspaceItem source, String path, Object from) throws Exception;
|
||||
abstract void move(Context context, Request currentRequest, WorkspaceItem source, String path, String from) throws Exception;
|
||||
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ package org.dspace.app.rest.submit.factory.impl;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
@@ -24,8 +25,7 @@ import org.springframework.data.rest.webmvc.json.patch.LateObjectEvaluator;
|
||||
*/
|
||||
public abstract class PatchOperation<T extends Object> {
|
||||
|
||||
public abstract void perform(Context context, Request currentRequest, WorkspaceItem source, String path,
|
||||
Object value) throws Exception;
|
||||
public abstract void perform(Context context, Request currentRequest, WorkspaceItem source, Operation operation) throws Exception;
|
||||
|
||||
public List<T> evaluateArrayObject(LateObjectEvaluator value) {
|
||||
List<T> results = new ArrayList<T>();
|
||||
@@ -59,6 +59,14 @@ public abstract class PatchOperation<T extends Object> {
|
||||
return single;
|
||||
}
|
||||
|
||||
public String getAbsolutePath(String fullpath) {
|
||||
String[] path = fullpath.substring(1).split("/", 3);
|
||||
String absolutePath = "";
|
||||
if (path.length > 2) {
|
||||
absolutePath = path[2];
|
||||
}
|
||||
return absolutePath;
|
||||
}
|
||||
|
||||
protected abstract Class<T[]> getArrayClassForEvaluation();
|
||||
|
||||
|
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
@@ -22,8 +23,8 @@ import org.dspace.services.model.Request;
|
||||
public abstract class RemovePatchOperation<T extends Object> extends PatchOperation<T> {
|
||||
|
||||
@Override
|
||||
public void perform(Context context, Request currentRequest, WorkspaceItem source, String string, Object value) throws Exception{
|
||||
remove(context, currentRequest, source, string, value);
|
||||
public void perform(Context context, Request currentRequest, WorkspaceItem source, Operation operation) throws Exception{
|
||||
remove(context, currentRequest, source, operation.getPath(), operation.getValue());
|
||||
}
|
||||
|
||||
abstract void remove(Context context,Request currentRequest,WorkspaceItem source,String string,Object value) throws Exception;
|
||||
|
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package org.dspace.app.rest.submit.factory.impl;
|
||||
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
@@ -22,9 +23,9 @@ import org.dspace.services.model.Request;
|
||||
public abstract class ReplacePatchOperation<T extends Object> extends PatchOperation<T> {
|
||||
|
||||
@Override
|
||||
public void perform(Context context, Request currentRequest, WorkspaceItem source, String string, Object value)
|
||||
public void perform(Context context, Request currentRequest, WorkspaceItem source, Operation operation)
|
||||
throws Exception {
|
||||
replace(context, currentRequest, source, string, value);
|
||||
replace(context, currentRequest, source, operation.getPath(), operation.getValue());
|
||||
}
|
||||
|
||||
abstract void replace(Context context, Request currentRequest, WorkspaceItem source, String string, Object value)
|
||||
|
@@ -54,7 +54,7 @@ public class ResourcePolicyAddPatchOperation extends AddPatchOperation<ResourceP
|
||||
@Override
|
||||
void add(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
||||
throws Exception {
|
||||
String[] split = path.split("/");
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
Item item = source.getItem();
|
||||
|
||||
List<Bundle> bundle = itemService.getBundles(item, Constants.CONTENT_BUNDLE_NAME);
|
||||
|
@@ -43,7 +43,7 @@ public class ResourcePolicyRemovePatchOperation extends RemovePatchOperation<Res
|
||||
@Override
|
||||
void remove(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
||||
throws Exception {
|
||||
String[] split = path.split("/");
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
String bitstreamIdx = split[0];
|
||||
String rpIdx = split[2];
|
||||
|
||||
|
@@ -54,7 +54,7 @@ public class ResourcePolicyReplacePatchOperation extends ReplacePatchOperation<R
|
||||
@Override
|
||||
void replace(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
|
||||
throws Exception {
|
||||
String[] split = path.split("/");
|
||||
String[] split = getAbsolutePath(path).split("/");
|
||||
Item item = source.getItem();
|
||||
|
||||
List<Bundle> bundle = itemService.getBundles(item, Constants.CONTENT_BUNDLE_NAME);
|
||||
|
@@ -9,7 +9,7 @@ package org.dspace.app.rest.submit.step;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||
import org.dspace.app.rest.submit.SubmissionService;
|
||||
import org.dspace.app.rest.submit.factory.PatchOperationFactory;
|
||||
@@ -20,7 +20,8 @@ import org.dspace.core.Context;
|
||||
import org.dspace.services.model.Request;
|
||||
|
||||
/**
|
||||
* Collection step for DSpace Spring Rest. Expose the collection information of the in progress submission.
|
||||
* Collection step for DSpace Spring Rest. Expose the collection information of
|
||||
* the in progress submission.
|
||||
*
|
||||
* @author Luigi Andrea Pascarelli (luigiandrea.pascarelli at 4science.it)
|
||||
*
|
||||
@@ -36,15 +37,11 @@ public class CollectionStep extends org.dspace.submit.step.SelectCollectionStep
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, String operation,
|
||||
String path, Object value) throws Exception {
|
||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, Operation op)
|
||||
throws Exception {
|
||||
|
||||
if(StringUtils.isBlank(path)) {
|
||||
|
||||
PatchOperation<String> patchOperation = new PatchOperationFactory().instanceOf("collection", operation);
|
||||
patchOperation.perform(context, currentRequest, source, path, value);
|
||||
|
||||
}
|
||||
PatchOperation<String> patchOperation = new PatchOperationFactory().instanceOf(COLLECTION_STEP_OPERATION_ENTRY, op.getOp());
|
||||
patchOperation.perform(context, currentRequest, source, op.getPath(), op.getValue());
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.app.rest.model.MetadataValueRest;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.app.rest.model.step.DataDescribe;
|
||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||
import org.dspace.app.rest.submit.SubmissionService;
|
||||
@@ -99,11 +100,10 @@ public class DescribeStep extends org.dspace.submit.step.DescribeStep implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, String operation,
|
||||
String path, Object value) throws Exception {
|
||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, Operation op) throws Exception {
|
||||
|
||||
PatchOperation<MetadataValueRest> patchOperation = new PatchOperationFactory().instanceOf("metadatavalue", operation);
|
||||
patchOperation.perform(context, currentRequest, source, path, value);
|
||||
PatchOperation<MetadataValueRest> patchOperation = new PatchOperationFactory().instanceOf(DESCRIBE_STEP_METADATA_OPERATION_ENTRY, op.getOp());
|
||||
patchOperation.perform(context, currentRequest, source, op);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,7 @@ package org.dspace.app.rest.submit.step;
|
||||
|
||||
import org.atteo.evo.inflector.English;
|
||||
import org.dspace.app.rest.model.BitstreamRest;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.app.rest.model.step.DataLicense;
|
||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||
import org.dspace.app.rest.submit.SubmissionService;
|
||||
@@ -44,13 +45,12 @@ public class LicenseStep extends org.dspace.submit.step.LicenseStep implements A
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, String operation,
|
||||
String path, Object value) throws Exception {
|
||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, Operation op) throws Exception {
|
||||
|
||||
if("acceptanceDate".equals(path)) {
|
||||
if(op.getPath().endsWith(LICENSE_STEP_OPERATION_ENTRY)) {
|
||||
|
||||
PatchOperation<String> patchOperation = new PatchOperationFactory().instanceOf(path, operation);
|
||||
patchOperation.perform(context, currentRequest, source, path, value);
|
||||
PatchOperation<String> patchOperation = new PatchOperationFactory().instanceOf(LICENSE_STEP_OPERATION_ENTRY, op.getOp());
|
||||
patchOperation.perform(context, currentRequest, source, op.getPath(), op.getValue());
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -9,8 +9,7 @@ package org.dspace.app.rest.submit.step;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.dspace.app.rest.converter.BitstreamFormatConverter;
|
||||
import org.dspace.app.rest.model.patch.Operation;
|
||||
import org.dspace.app.rest.model.step.DataUpload;
|
||||
import org.dspace.app.rest.model.step.UploadBitstreamRest;
|
||||
import org.dspace.app.rest.submit.AbstractRestProcessingStep;
|
||||
@@ -23,9 +22,7 @@ import org.dspace.content.Bundle;
|
||||
import org.dspace.content.WorkspaceItem;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* Upload step for DSpace Spring Rest. Expose information about the bitstream
|
||||
@@ -52,19 +49,22 @@ public class UploadStep extends org.dspace.submit.step.UploadStep implements Abs
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, String operation,
|
||||
String path, Object value) throws Exception {
|
||||
public void doPatchProcessing(Context context, Request currentRequest, WorkspaceItem source, Operation op) throws Exception {
|
||||
|
||||
String[] split = path.split("/");
|
||||
String instance = "";
|
||||
if("remove".equals(operation)) {
|
||||
instance = "bitstreamremove";
|
||||
if("remove".equals(op.getOp())) {
|
||||
instance = UPLOAD_STEP_REMOVE_OPERATION_ENTRY;
|
||||
}
|
||||
else {
|
||||
instance = split[2];
|
||||
if(op.getPath().contains(UPLOAD_STEP_ACCESSCONDITIONS_OPERATION_ENTRY)) {
|
||||
instance = UPLOAD_STEP_ACCESSCONDITIONS_OPERATION_ENTRY;
|
||||
}
|
||||
PatchOperation<?> patchOperation = new PatchOperationFactory().instanceOf(instance, operation);
|
||||
patchOperation.perform(context, currentRequest, source, path, value);
|
||||
else {
|
||||
instance = UPLOAD_STEP_METADATA_OPERATION_ENTRY;
|
||||
}
|
||||
}
|
||||
PatchOperation<?> patchOperation = new PatchOperationFactory().instanceOf(instance, op.getOp());
|
||||
patchOperation.perform(context, currentRequest, source, op.getPath(), op.getValue());
|
||||
|
||||
}
|
||||
|
||||
|
@@ -19,15 +19,27 @@
|
||||
<bean id="patchConfigurationService" class="org.dspace.app.rest.submit.PatchConfigurationService">
|
||||
<property name="map">
|
||||
<map>
|
||||
<entry key="move">
|
||||
<map>
|
||||
<!-- WARNING do not change "key" it match with Java code (TODO dynamic discover from PATCH operation); -->
|
||||
<entry key="itemmetadata">
|
||||
<bean
|
||||
class="org.dspace.app.rest.submit.factory.impl.ItemMetadataValueMovePatchOperation" />
|
||||
</entry>
|
||||
<entry key="bitstreammetadata">
|
||||
<bean
|
||||
class="org.dspace.app.rest.submit.factory.impl.BitstreamMetadataValueMovePatchOperation" />
|
||||
</entry>
|
||||
</map>
|
||||
</entry>
|
||||
<entry key="add">
|
||||
<map>
|
||||
<!-- WARNING do not change "metadatavalue" it is used in the Java logic;
|
||||
the other key are dynamic discover from PATCH path -->
|
||||
<entry key="metadatavalue">
|
||||
<!-- WARNING do not change "key" it match with Java code (TODO dynamic discover from PATCH operation); -->
|
||||
<entry key="itemmetadata">
|
||||
<bean
|
||||
class="org.dspace.app.rest.submit.factory.impl.ItemMetadataValueAddPatchOperation" />
|
||||
</entry>
|
||||
<entry key="metadata">
|
||||
<entry key="bitstreammetadata">
|
||||
<bean
|
||||
class="org.dspace.app.rest.submit.factory.impl.BitstreamMetadataValueAddPatchOperation" />
|
||||
</entry>
|
||||
@@ -39,13 +51,12 @@
|
||||
</entry>
|
||||
<entry key="remove">
|
||||
<map>
|
||||
<!-- WARNING do not change "metadatavalue" it is used in the Java logic;
|
||||
the other key are dynamic discover from PATCH path -->
|
||||
<entry key="metadatavalue">
|
||||
<!-- WARNING do not change "key" it match with Java code (TODO dynamic discover from PATCH operation); -->
|
||||
<entry key="itemmetadata">
|
||||
<bean
|
||||
class="org.dspace.app.rest.submit.factory.impl.ItemMetadataValueRemovePatchOperation" />
|
||||
</entry>
|
||||
<entry key="metadata">
|
||||
<entry key="bitstreammetadata">
|
||||
<bean
|
||||
class="org.dspace.app.rest.submit.factory.impl.BitstreamMetadataValueRemovePatchOperation" />
|
||||
</entry>
|
||||
@@ -53,8 +64,6 @@
|
||||
<bean
|
||||
class="org.dspace.app.rest.submit.factory.impl.LicenseRemovePatchOperation" />
|
||||
</entry>
|
||||
<!-- WARNING do not change "bitstreamremove" it is used in the Java
|
||||
logic -->
|
||||
<entry key="bitstreamremove">
|
||||
<bean
|
||||
class="org.dspace.app.rest.submit.factory.impl.BitstreamRemovePatchOperation" />
|
||||
@@ -67,13 +76,12 @@
|
||||
</entry>
|
||||
<entry key="replace">
|
||||
<map>
|
||||
<!-- WARNING do not change "metadatavalue" it is used in the Java logic;
|
||||
the other key are dynamic discover from PATCH path -->
|
||||
<entry key="metadatavalue">
|
||||
<!-- WARNING do not change "key" it match with Java code (TODO dynamic discover from PATCH operation); -->
|
||||
<entry key="itemmetadata">
|
||||
<bean
|
||||
class="org.dspace.app.rest.submit.factory.impl.ItemMetadataValueReplacePatchOperation" />
|
||||
</entry>
|
||||
<entry key="metadata">
|
||||
<entry key="bitstreammetadata">
|
||||
<bean
|
||||
class="org.dspace.app.rest.submit.factory.impl.BitstreamMetadataValueReplacePatchOperation" />
|
||||
</entry>
|
||||
|
Reference in New Issue
Block a user