mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-19 16:03:07 +00:00
[CST-12108] refactoring
This commit is contained in:
@@ -13,7 +13,7 @@ import java.security.NoSuchAlgorithmException;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||||
import org.dspace.qaevent.service.dto.EmptyMessageDTO;
|
import org.dspace.qaevent.service.dto.CorrectionTypeMessageDTO;
|
||||||
import org.dspace.qaevent.service.dto.OpenaireMessageDTO;
|
import org.dspace.qaevent.service.dto.OpenaireMessageDTO;
|
||||||
import org.dspace.qaevent.service.dto.QAMessageDTO;
|
import org.dspace.qaevent.service.dto.QAMessageDTO;
|
||||||
import org.dspace.util.RawJsonDeserializer;
|
import org.dspace.util.RawJsonDeserializer;
|
||||||
@@ -198,7 +198,7 @@ public class QAEvent {
|
|||||||
case OPENAIRE_SOURCE:
|
case OPENAIRE_SOURCE:
|
||||||
return OpenaireMessageDTO.class;
|
return OpenaireMessageDTO.class;
|
||||||
case INTERNAL_ITEM_SOURCE:
|
case INTERNAL_ITEM_SOURCE:
|
||||||
return EmptyMessageDTO.class;
|
return CorrectionTypeMessageDTO.class;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unknown event's source: " + getSource());
|
throw new IllegalArgumentException("Unknown event's source: " + getSource());
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,7 @@ import org.dspace.authorize.AuthorizeException;
|
|||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.QAEvent;
|
import org.dspace.content.QAEvent;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.qaevent.service.dto.QAMessageDTO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface class that model the CorrectionType.
|
* Interface class that model the CorrectionType.
|
||||||
@@ -27,16 +28,14 @@ public interface CorrectionType {
|
|||||||
|
|
||||||
public String getCreationForm();
|
public String getCreationForm();
|
||||||
|
|
||||||
public String getDiscoveryConfiguration();
|
|
||||||
|
|
||||||
public boolean isRequiredRelatedItem();
|
public boolean isRequiredRelatedItem();
|
||||||
|
|
||||||
public boolean isAllowed(Context context, Item targetItem) throws AuthorizeException, SQLException;
|
public boolean isAllowed(Context context, Item targetItem) throws AuthorizeException, SQLException;
|
||||||
|
|
||||||
public boolean isAllowed(Context context, Item targetItem, Item relatedItem) throws AuthorizeException,SQLException;
|
public boolean isAllowed(Context context, Item targetItem, Item relatedItem) throws AuthorizeException,SQLException;
|
||||||
|
|
||||||
public QAEvent createCorrection(Context context, Item targetItem);
|
public QAEvent createCorrection(Context context, Item targetItem, QAMessageDTO reason);
|
||||||
|
|
||||||
public QAEvent createCorrection(Context context, Item targetItem, Item relatedItem);
|
public QAEvent createCorrection(Context context, Item targetItem, Item relatedItem, QAMessageDTO reason);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.correctiontype;
|
package org.dspace.correctiontype;
|
||||||
|
|
||||||
import static org.apache.commons.lang.StringUtils.EMPTY;
|
|
||||||
import static org.dspace.content.QAEvent.INTERNAL_ITEM_SOURCE;
|
import static org.dspace.content.QAEvent.INTERNAL_ITEM_SOURCE;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -21,6 +20,8 @@ import org.dspace.content.QAEvent;
|
|||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.qaevent.service.QAEventService;
|
import org.dspace.qaevent.service.QAEventService;
|
||||||
|
import org.dspace.qaevent.service.dto.CorrectionTypeMessageDTO;
|
||||||
|
import org.dspace.qaevent.service.dto.QAMessageDTO;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ public class ReinstateCorrectionType implements CorrectionType, InitializingBean
|
|||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String topic;
|
private String topic;
|
||||||
|
private String creationForm;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private QAEventService qaEventService;
|
private QAEventService qaEventService;
|
||||||
@@ -53,14 +55,15 @@ public class ReinstateCorrectionType implements CorrectionType, InitializingBean
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QAEvent createCorrection(Context context, Item targetItem) {
|
public QAEvent createCorrection(Context context, Item targetItem, QAMessageDTO reason) {
|
||||||
|
CorrectionTypeMessageDTO mesasge = (CorrectionTypeMessageDTO) reason;
|
||||||
QAEvent qaEvent = new QAEvent(INTERNAL_ITEM_SOURCE,
|
QAEvent qaEvent = new QAEvent(INTERNAL_ITEM_SOURCE,
|
||||||
"handle:" + targetItem.getHandle(),
|
"handle:" + targetItem.getHandle(),
|
||||||
targetItem.getID().toString(),
|
targetItem.getID().toString(),
|
||||||
targetItem.getName(),
|
targetItem.getName(),
|
||||||
this.getTopic(),
|
this.getTopic(),
|
||||||
1.0,
|
1.0,
|
||||||
new Gson().toJson(new Object()),
|
new Gson().toJson(mesasge),
|
||||||
new Date()
|
new Date()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -69,8 +72,8 @@ public class ReinstateCorrectionType implements CorrectionType, InitializingBean
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QAEvent createCorrection(Context context, Item targetItem, Item relatedItem) {
|
public QAEvent createCorrection(Context context, Item targetItem, Item relatedItem, QAMessageDTO reason) {
|
||||||
return this.createCorrection(context, targetItem);
|
return this.createCorrection(context, targetItem, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -101,12 +104,11 @@ public class ReinstateCorrectionType implements CorrectionType, InitializingBean
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCreationForm() {
|
public String getCreationForm() {
|
||||||
return EMPTY;
|
return this.creationForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setCreationForm(String creationForm) {
|
||||||
public String getDiscoveryConfiguration() {
|
this.creationForm = creationForm;
|
||||||
return EMPTY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.correctiontype;
|
package org.dspace.correctiontype;
|
||||||
|
|
||||||
import static org.apache.commons.lang.StringUtils.EMPTY;
|
|
||||||
import static org.dspace.content.QAEvent.INTERNAL_ITEM_SOURCE;
|
import static org.dspace.content.QAEvent.INTERNAL_ITEM_SOURCE;
|
||||||
import static org.dspace.core.Constants.READ;
|
import static org.dspace.core.Constants.READ;
|
||||||
|
|
||||||
@@ -21,6 +20,8 @@ import org.dspace.content.Item;
|
|||||||
import org.dspace.content.QAEvent;
|
import org.dspace.content.QAEvent;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.qaevent.service.QAEventService;
|
import org.dspace.qaevent.service.QAEventService;
|
||||||
|
import org.dspace.qaevent.service.dto.CorrectionTypeMessageDTO;
|
||||||
|
import org.dspace.qaevent.service.dto.QAMessageDTO;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ public class WithdrawnCorrectionType implements CorrectionType, InitializingBean
|
|||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String topic;
|
private String topic;
|
||||||
|
private String creationForm;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private QAEventService qaEventService;
|
private QAEventService qaEventService;
|
||||||
@@ -47,13 +49,14 @@ public class WithdrawnCorrectionType implements CorrectionType, InitializingBean
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QAEvent createCorrection(Context context, Item targetItem) {
|
public QAEvent createCorrection(Context context, Item targetItem, QAMessageDTO reason) {
|
||||||
|
CorrectionTypeMessageDTO mesasge = (CorrectionTypeMessageDTO) reason;
|
||||||
QAEvent qaEvent = new QAEvent(INTERNAL_ITEM_SOURCE,
|
QAEvent qaEvent = new QAEvent(INTERNAL_ITEM_SOURCE,
|
||||||
"handle:" + targetItem.getHandle(),
|
"handle:" + targetItem.getHandle(),
|
||||||
targetItem.getID().toString(),
|
targetItem.getID().toString(),
|
||||||
targetItem.getName(),
|
targetItem.getName(),
|
||||||
this.getTopic(), 1.0,
|
this.getTopic(), 1.0,
|
||||||
new Gson().toJson(new Object()),
|
new Gson().toJson(mesasge),
|
||||||
new Date()
|
new Date()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -68,8 +71,8 @@ public class WithdrawnCorrectionType implements CorrectionType, InitializingBean
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QAEvent createCorrection(Context context, Item targetItem, Item relatedItem) {
|
public QAEvent createCorrection(Context context, Item targetItem, Item relatedItem, QAMessageDTO reason) {
|
||||||
return createCorrection(context, targetItem);
|
return createCorrection(context, targetItem, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -100,12 +103,11 @@ public class WithdrawnCorrectionType implements CorrectionType, InitializingBean
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCreationForm() {
|
public String getCreationForm() {
|
||||||
return EMPTY;
|
return this.creationForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setCreationForm(String creationForm) {
|
||||||
public String getDiscoveryConfiguration() {
|
this.creationForm = creationForm;
|
||||||
return EMPTY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* 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.qaevent.service.dto;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of {@link QAMessageDTO} that model empty message.
|
||||||
|
*
|
||||||
|
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.it)
|
||||||
|
*/
|
||||||
|
public class CorrectionTypeMessageDTO implements QAMessageDTO, Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 2718151302291303796L;
|
||||||
|
|
||||||
|
private String reason;
|
||||||
|
|
||||||
|
public CorrectionTypeMessageDTO() {}
|
||||||
|
|
||||||
|
public CorrectionTypeMessageDTO(String reason) {
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReason(String reason) {
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,10 +0,0 @@
|
|||||||
package org.dspace.qaevent.service.dto;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implementation of {@link QAMessageDTO} that model empty message.
|
|
||||||
*
|
|
||||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.it)
|
|
||||||
*/
|
|
||||||
public class EmptyMessageDTO implements QAMessageDTO {
|
|
||||||
|
|
||||||
}
|
|
@@ -17,5 +17,4 @@ import org.dspace.content.QAEvent;
|
|||||||
*/
|
*/
|
||||||
public interface QAMessageDTO {
|
public interface QAMessageDTO {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -292,7 +292,7 @@ public class QAEventServiceImpl implements QAEventService {
|
|||||||
solrQuery.setRows(pageSize);
|
solrQuery.setRows(pageSize);
|
||||||
}
|
}
|
||||||
solrQuery.setSort(orderField, ascending ? ORDER.asc : ORDER.desc);
|
solrQuery.setSort(orderField, ascending ? ORDER.asc : ORDER.desc);
|
||||||
solrQuery.setQuery(TOPIC + ":" + topic.replaceAll("!", "/"));
|
solrQuery.setQuery(TOPIC + ":" + topic.replaceAll("!", "\\\\/"));
|
||||||
|
|
||||||
QueryResponse response;
|
QueryResponse response;
|
||||||
try {
|
try {
|
||||||
|
@@ -27,7 +27,6 @@ public class CorrectionTypeConverter implements DSpaceConverter<CorrectionType,
|
|||||||
targetRest.setProjection(projection);
|
targetRest.setProjection(projection);
|
||||||
targetRest.setId(target.getId());
|
targetRest.setId(target.getId());
|
||||||
targetRest.setTopic(target.getTopic());
|
targetRest.setTopic(target.getTopic());
|
||||||
targetRest.setDiscoveryConfiguration(target.getDiscoveryConfiguration());
|
|
||||||
targetRest.setCreationForm(target.getCreationForm());
|
targetRest.setCreationForm(target.getCreationForm());
|
||||||
return targetRest;
|
return targetRest;
|
||||||
}
|
}
|
||||||
|
@@ -14,13 +14,13 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||||
import org.dspace.app.rest.model.EmptyQAEventMessageRest;
|
import org.dspace.app.rest.model.CorrectionTypeQAEventMessageRest;
|
||||||
import org.dspace.app.rest.model.OpenaireQAEventMessageRest;
|
import org.dspace.app.rest.model.OpenaireQAEventMessageRest;
|
||||||
import org.dspace.app.rest.model.QAEventMessageRest;
|
import org.dspace.app.rest.model.QAEventMessageRest;
|
||||||
import org.dspace.app.rest.model.QAEventRest;
|
import org.dspace.app.rest.model.QAEventRest;
|
||||||
import org.dspace.app.rest.projection.Projection;
|
import org.dspace.app.rest.projection.Projection;
|
||||||
import org.dspace.content.QAEvent;
|
import org.dspace.content.QAEvent;
|
||||||
import org.dspace.qaevent.service.dto.EmptyMessageDTO;
|
import org.dspace.qaevent.service.dto.CorrectionTypeMessageDTO;
|
||||||
import org.dspace.qaevent.service.dto.OpenaireMessageDTO;
|
import org.dspace.qaevent.service.dto.OpenaireMessageDTO;
|
||||||
import org.dspace.qaevent.service.dto.QAMessageDTO;
|
import org.dspace.qaevent.service.dto.QAMessageDTO;
|
||||||
import org.dspace.services.ConfigurationService;
|
import org.dspace.services.ConfigurationService;
|
||||||
@@ -56,9 +56,9 @@ public class QAEventConverter implements DSpaceConverter<QAEvent, QAEventRest> {
|
|||||||
rest.setId(modelObject.getEventId());
|
rest.setId(modelObject.getEventId());
|
||||||
try {
|
try {
|
||||||
rest.setMessage(convertMessage(jsonMapper.readValue(modelObject.getMessage(),
|
rest.setMessage(convertMessage(jsonMapper.readValue(modelObject.getMessage(),
|
||||||
modelObject.getMessageDtoClass())));
|
modelObject.getMessageDtoClass())));
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
rest.setSource(modelObject.getSource());
|
rest.setSource(modelObject.getSource());
|
||||||
rest.setOriginalId(modelObject.getOriginalId());
|
rest.setOriginalId(modelObject.getOriginalId());
|
||||||
@@ -76,12 +76,19 @@ public class QAEventConverter implements DSpaceConverter<QAEvent, QAEventRest> {
|
|||||||
if (dto instanceof OpenaireMessageDTO) {
|
if (dto instanceof OpenaireMessageDTO) {
|
||||||
return convertOpenaireMessage(dto);
|
return convertOpenaireMessage(dto);
|
||||||
}
|
}
|
||||||
if (dto instanceof EmptyMessageDTO) {
|
if (dto instanceof CorrectionTypeMessageDTO) {
|
||||||
return new EmptyQAEventMessageRest();
|
return convertCorrectionTypeMessage(dto);
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Unknown message type: " + dto.getClass());
|
throw new IllegalArgumentException("Unknown message type: " + dto.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private QAEventMessageRest convertCorrectionTypeMessage(QAMessageDTO dto) {
|
||||||
|
CorrectionTypeMessageDTO correctionTypeDto = (CorrectionTypeMessageDTO) dto;
|
||||||
|
CorrectionTypeQAEventMessageRest message = new CorrectionTypeQAEventMessageRest();
|
||||||
|
message.setReason(correctionTypeDto.getReason());
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
private QAEventMessageRest convertOpenaireMessage(QAMessageDTO dto) {
|
private QAEventMessageRest convertOpenaireMessage(QAMessageDTO dto) {
|
||||||
OpenaireMessageDTO openaireDto = (OpenaireMessageDTO) dto;
|
OpenaireMessageDTO openaireDto = (OpenaireMessageDTO) dto;
|
||||||
OpenaireQAEventMessageRest message = new OpenaireQAEventMessageRest();
|
OpenaireQAEventMessageRest message = new OpenaireQAEventMessageRest();
|
||||||
|
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* 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.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mykhaylo Boychuk (mykhaylo.boychuk@4science.com)
|
||||||
|
*/
|
||||||
|
public class CorrectionTypeQAEventMessageRest implements QAEventMessageRest {
|
||||||
|
|
||||||
|
private String reason;
|
||||||
|
|
||||||
|
public String getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReason(String reason) {
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.model;
|
package org.dspace.app.rest.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.dspace.app.rest.RestResourceController;
|
import org.dspace.app.rest.RestResourceController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +24,6 @@ public class CorrectionTypeRest extends BaseObjectRest<String> {
|
|||||||
|
|
||||||
private String topic;
|
private String topic;
|
||||||
private String creationForm;
|
private String creationForm;
|
||||||
private String discoveryConfiguration;
|
|
||||||
|
|
||||||
public String getTopic() {
|
public String getTopic() {
|
||||||
return topic;
|
return topic;
|
||||||
@@ -33,14 +33,6 @@ public class CorrectionTypeRest extends BaseObjectRest<String> {
|
|||||||
this.topic = topic;
|
this.topic = topic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDiscoveryConfiguration() {
|
|
||||||
return discoveryConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDiscoveryConfiguration(String discoveryConfiguration) {
|
|
||||||
this.discoveryConfiguration = discoveryConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCreationForm() {
|
public String getCreationForm() {
|
||||||
return creationForm;
|
return creationForm;
|
||||||
}
|
}
|
||||||
@@ -55,6 +47,7 @@ public class CorrectionTypeRest extends BaseObjectRest<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return NAME;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +0,0 @@
|
|||||||
/**
|
|
||||||
* The contents of this file are subject to the license and copyright
|
|
||||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
|
||||||
* tree and available online at
|
|
||||||
*
|
|
||||||
* http://www.dspace.org/license/
|
|
||||||
*/
|
|
||||||
package org.dspace.app.rest.model;
|
|
||||||
|
|
||||||
public class EmptyQAEventMessageRest implements QAEventMessageRest {
|
|
||||||
|
|
||||||
}
|
|
@@ -7,31 +7,34 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.app.rest.repository;
|
package org.dspace.app.rest.repository;
|
||||||
|
|
||||||
import static org.dspace.core.Constants.ITEM;
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.dspace.app.rest.Parameter;
|
import org.dspace.app.rest.Parameter;
|
||||||
import org.dspace.app.rest.SearchRestMethod;
|
import org.dspace.app.rest.SearchRestMethod;
|
||||||
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
|
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
|
||||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||||
import org.dspace.app.rest.model.QAEventRest;
|
import org.dspace.app.rest.model.QAEventRest;
|
||||||
import org.dspace.app.rest.model.patch.Patch;
|
import org.dspace.app.rest.model.patch.Patch;
|
||||||
import org.dspace.app.rest.repository.handler.service.UriListHandlerService;
|
|
||||||
import org.dspace.app.rest.repository.patch.ResourcePatch;
|
import org.dspace.app.rest.repository.patch.ResourcePatch;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.content.DSpaceObject;
|
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.QAEvent;
|
import org.dspace.content.QAEvent;
|
||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.correctiontype.CorrectionType;
|
import org.dspace.correctiontype.CorrectionType;
|
||||||
|
import org.dspace.correctiontype.service.CorrectionTypeService;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
import org.dspace.qaevent.dao.QAEventsDao;
|
import org.dspace.qaevent.dao.QAEventsDao;
|
||||||
import org.dspace.qaevent.service.QAEventService;
|
import org.dspace.qaevent.service.QAEventService;
|
||||||
|
import org.dspace.qaevent.service.dto.CorrectionTypeMessageDTO;
|
||||||
import org.dspace.util.UUIDUtils;
|
import org.dspace.util.UUIDUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -64,7 +67,7 @@ public class QAEventRestRepository extends DSpaceRestRepository<QAEventRest, Str
|
|||||||
private ResourcePatch<QAEvent> resourcePatch;
|
private ResourcePatch<QAEvent> resourcePatch;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UriListHandlerService uriListHandlerService;
|
private CorrectionTypeService correctionTypeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PreAuthorize("hasAuthority('ADMIN')")
|
@PreAuthorize("hasAuthority('ADMIN')")
|
||||||
@@ -137,47 +140,58 @@ public class QAEventRestRepository extends DSpaceRestRepository<QAEventRest, Str
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@PreAuthorize("hasAuthority('AUTHENTICATED')")
|
@PreAuthorize("hasAuthority('AUTHENTICATED')")
|
||||||
protected QAEventRest createAndReturn(Context context, List<String> stringList)
|
protected QAEventRest createAndReturn(Context context) throws SQLException, AuthorizeException {
|
||||||
throws SQLException, AuthorizeException {
|
ServletRequest request = getRequestService().getCurrentRequest().getServletRequest();
|
||||||
|
|
||||||
if (stringList.size() < 2) {
|
String itemUUID = request.getParameter("target");
|
||||||
throw new IllegalArgumentException("the request must include at least uris for target item, " +
|
String relatedItemUUID = request.getParameter("related");
|
||||||
"and correction type");
|
String correctionTypeStr = request.getParameter("correctionType");
|
||||||
|
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(correctionTypeStr) || StringUtils.isBlank(itemUUID)) {
|
||||||
|
throw new UnprocessableEntityException("The target item and correctionType must be provided!");
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpServletRequest request = getRequestService().getCurrentRequest().getHttpServletRequest();
|
Item targetItem = null;
|
||||||
CorrectionType correctionType = uriListHandlerService.handle(context, request, List.of(stringList.get(0)),
|
Item relatedItem = null;
|
||||||
CorrectionType.class);
|
try {
|
||||||
|
targetItem = itemService.find(context, UUID.fromString(itemUUID));
|
||||||
|
relatedItem = StringUtils.isNotBlank(relatedItemUUID) ?
|
||||||
|
itemService.find(context, UUID.fromString(relatedItemUUID)) : null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new UnprocessableEntityException(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Objects.isNull(targetItem)) {
|
||||||
|
throw new UnprocessableEntityException("The target item UUID is not valid!");
|
||||||
|
}
|
||||||
|
|
||||||
|
CorrectionType correctionType = correctionTypeService.findOne(correctionTypeStr);
|
||||||
if (Objects.isNull(correctionType)) {
|
if (Objects.isNull(correctionType)) {
|
||||||
throw new UnprocessableEntityException("The given correction type in the request is not valid!");
|
throw new UnprocessableEntityException("The given correction type in the request is not valid!");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DSpaceObject> list = utils.constructDSpaceObjectList(context, stringList);
|
if (correctionType.isRequiredRelatedItem() && Objects.isNull(relatedItem)) {
|
||||||
|
throw new UnprocessableEntityException("The given correction type in the request is not valid!");
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
CorrectionTypeMessageDTO reason = null;
|
||||||
|
try {
|
||||||
|
reason = mapper.readValue(request.getInputStream(), CorrectionTypeMessageDTO.class);
|
||||||
|
} catch (IOException exIO) {
|
||||||
|
throw new UnprocessableEntityException("error parsing the body " + exIO.getMessage(), exIO);
|
||||||
|
}
|
||||||
|
|
||||||
QAEvent qaEvent;
|
QAEvent qaEvent;
|
||||||
List<Item> items = getItems(list, correctionType);
|
|
||||||
if (correctionType.isRequiredRelatedItem()) {
|
if (correctionType.isRequiredRelatedItem()) {
|
||||||
qaEvent = correctionType.createCorrection(context, items.get(0), items.get(1));
|
qaEvent = correctionType.createCorrection(context, targetItem, relatedItem, reason);
|
||||||
} else {
|
} else {
|
||||||
qaEvent = correctionType.createCorrection(context, items.get(0));
|
qaEvent = correctionType.createCorrection(context, targetItem, reason);
|
||||||
}
|
}
|
||||||
return converter.toRest(qaEvent, utils.obtainProjection());
|
return converter.toRest(qaEvent, utils.obtainProjection());
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Item> getItems(List<DSpaceObject> list, CorrectionType correctionType) {
|
|
||||||
if (correctionType.isRequiredRelatedItem()) {
|
|
||||||
if (list.size() == 2 && list.get(0).getType() == ITEM && list.get(1).getType() == ITEM) {
|
|
||||||
return List.of((Item) list.get(0), (Item) list.get(1));
|
|
||||||
} else {
|
|
||||||
throw new UnprocessableEntityException("The given items in the request were not valid!");
|
|
||||||
}
|
|
||||||
} else if (list.size() != 1) {
|
|
||||||
throw new UnprocessableEntityException("The given item in the request were not valid!");
|
|
||||||
} else {
|
|
||||||
return List.of((Item) list.get(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<QAEventRest> getDomainClass() {
|
public Class<QAEventRest> getDomainClass() {
|
||||||
return QAEventRest.class;
|
return QAEventRest.class;
|
||||||
|
@@ -50,12 +50,15 @@ public class CorrectionTypeRestRepositoryIT extends AbstractControllerIntegratio
|
|||||||
.andExpect(jsonPath("$.page.totalElements", greaterThanOrEqualTo(2)))
|
.andExpect(jsonPath("$.page.totalElements", greaterThanOrEqualTo(2)))
|
||||||
.andExpect(jsonPath("$._embedded.correctiontypes", containsInAnyOrder(
|
.andExpect(jsonPath("$._embedded.correctiontypes", containsInAnyOrder(
|
||||||
allOf(
|
allOf(
|
||||||
hasJsonPath("$.id", equalTo("withdrawnRequest")),
|
hasJsonPath("$.id", equalTo("request-withdrawn")),
|
||||||
hasJsonPath("$.topic", equalTo("REQUEST/WITHDRAWN"))
|
hasJsonPath("$.topic", equalTo("REQUEST/WITHDRAWN")),
|
||||||
|
hasJsonPath("$.creationForm", equalTo("provideReason")),
|
||||||
|
hasJsonPath("$.type", equalTo("correctiontype"))
|
||||||
),
|
),
|
||||||
allOf(
|
allOf(
|
||||||
hasJsonPath("$.id", equalTo("reinstateRequest")),
|
hasJsonPath("$.id", equalTo("request-reinstate")),
|
||||||
hasJsonPath("$.topic", equalTo("REQUEST/REINSTATE"))
|
hasJsonPath("$.topic", equalTo("REQUEST/REINSTATE")),
|
||||||
|
hasJsonPath("$.type", equalTo("correctiontype"))
|
||||||
)
|
)
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -63,10 +66,12 @@ public class CorrectionTypeRestRepositoryIT extends AbstractControllerIntegratio
|
|||||||
@Test
|
@Test
|
||||||
public void findOneTest() throws Exception {
|
public void findOneTest() throws Exception {
|
||||||
String adminToken = getAuthToken(admin.getEmail(), password);
|
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(adminToken).perform(get("/api/config/correctiontypes/withdrawnRequest"))
|
getClient(adminToken).perform(get("/api/config/correctiontypes/request-withdrawn"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.id", equalTo("withdrawnRequest")))
|
.andExpect(jsonPath("$.id", equalTo("request-withdrawn")))
|
||||||
.andExpect(jsonPath("$.topic", equalTo("REQUEST/WITHDRAWN")));
|
.andExpect(jsonPath("$.topic", equalTo("REQUEST/WITHDRAWN")))
|
||||||
|
.andExpect(jsonPath("$.creationForm", equalTo("provideReason")))
|
||||||
|
.andExpect(jsonPath("$.type", equalTo("correctiontype")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -79,14 +84,14 @@ public class CorrectionTypeRestRepositoryIT extends AbstractControllerIntegratio
|
|||||||
@Test
|
@Test
|
||||||
public void findByItemWithoutUUIDParameterTest() throws Exception {
|
public void findByItemWithoutUUIDParameterTest() throws Exception {
|
||||||
String adminToken = getAuthToken(admin.getEmail(), password);
|
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByItem/"))
|
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByItem"))
|
||||||
.andExpect(status().isBadRequest());
|
.andExpect(status().isBadRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findByItemNotFoundTest() throws Exception {
|
public void findByItemNotFoundTest() throws Exception {
|
||||||
String adminToken = getAuthToken(admin.getEmail(), password);
|
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByItem/")
|
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByItem")
|
||||||
.param("uuid", UUID.randomUUID().toString()))
|
.param("uuid", UUID.randomUUID().toString()))
|
||||||
.andExpect(status().isUnprocessableEntity());
|
.andExpect(status().isUnprocessableEntity());
|
||||||
}
|
}
|
||||||
@@ -100,7 +105,7 @@ public class CorrectionTypeRestRepositoryIT extends AbstractControllerIntegratio
|
|||||||
authorizeService.removeAllPolicies(context, privateItem);
|
authorizeService.removeAllPolicies(context, privateItem);
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
getClient().perform(get("/api/config/correctiontypes/search/findByItem/")
|
getClient().perform(get("/api/config/correctiontypes/search/findByItem")
|
||||||
.param("uuid", privateItem.getID().toString()))
|
.param("uuid", privateItem.getID().toString()))
|
||||||
.andExpect(status().isUnauthorized());
|
.andExpect(status().isUnauthorized());
|
||||||
}
|
}
|
||||||
@@ -116,7 +121,7 @@ public class CorrectionTypeRestRepositoryIT extends AbstractControllerIntegratio
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String adminToken = getAuthToken(admin.getEmail(), password);
|
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByItem/")
|
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByItem")
|
||||||
.param("uuid", item.getID().toString()))
|
.param("uuid", item.getID().toString()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.page.totalElements", is(0)));
|
.andExpect(jsonPath("$.page.totalElements", is(0)));
|
||||||
@@ -135,12 +140,12 @@ public class CorrectionTypeRestRepositoryIT extends AbstractControllerIntegratio
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String tokenAdmin = getAuthToken(admin.getEmail(), password);
|
String tokenAdmin = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(tokenAdmin).perform(get("/api/config/correctiontypes/search/findByItem/")
|
getClient(tokenAdmin).perform(get("/api/config/correctiontypes/search/findByItem")
|
||||||
.param("uuid", item.getID().toString()))
|
.param("uuid", item.getID().toString()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.page.totalElements", is(1)))
|
.andExpect(jsonPath("$.page.totalElements", is(1)))
|
||||||
.andExpect(jsonPath("$._embedded.correctiontypes", containsInAnyOrder(allOf(
|
.andExpect(jsonPath("$._embedded.correctiontypes", containsInAnyOrder(allOf(
|
||||||
hasJsonPath("$.id", equalTo("reinstateRequest")),
|
hasJsonPath("$.id", equalTo("request-reinstate")),
|
||||||
hasJsonPath("$.topic", equalTo("REQUEST/REINSTATE"))
|
hasJsonPath("$.topic", equalTo("REQUEST/REINSTATE"))
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
@@ -156,14 +161,16 @@ public class CorrectionTypeRestRepositoryIT extends AbstractControllerIntegratio
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String adminToken = getAuthToken(admin.getEmail(), password);
|
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByItem/")
|
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByItem")
|
||||||
.param("uuid", item.getID().toString()))
|
.param("uuid", item.getID().toString()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.page.totalElements", is(1)))
|
.andExpect(jsonPath("$.page.totalElements", is(1)))
|
||||||
.andExpect(jsonPath("$._embedded.correctiontypes", containsInAnyOrder(
|
.andExpect(jsonPath("$._embedded.correctiontypes", containsInAnyOrder(
|
||||||
allOf(
|
allOf(
|
||||||
hasJsonPath("$.id", equalTo("withdrawnRequest")),
|
hasJsonPath("$.id", equalTo("request-withdrawn")),
|
||||||
hasJsonPath("$.topic", equalTo("REQUEST/WITHDRAWN"))
|
hasJsonPath("$.topic", equalTo("REQUEST/WITHDRAWN")),
|
||||||
|
hasJsonPath("$.creationForm", equalTo("provideReason")),
|
||||||
|
hasJsonPath("$.type", equalTo("correctiontype"))
|
||||||
)
|
)
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -179,14 +186,16 @@ public class CorrectionTypeRestRepositoryIT extends AbstractControllerIntegratio
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String adminToken = getAuthToken(admin.getEmail(), password);
|
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByItem/")
|
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByItem")
|
||||||
.param("uuid", itemOne.getID().toString()))
|
.param("uuid", itemOne.getID().toString()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.page.totalElements", is(1)))
|
.andExpect(jsonPath("$.page.totalElements", is(1)))
|
||||||
.andExpect(jsonPath("$._embedded.correctiontypes", containsInAnyOrder(
|
.andExpect(jsonPath("$._embedded.correctiontypes", containsInAnyOrder(
|
||||||
allOf(
|
allOf(
|
||||||
hasJsonPath("$.id", equalTo("withdrawnRequest")),
|
hasJsonPath("$.id", equalTo("request-withdrawn")),
|
||||||
hasJsonPath("$.topic", equalTo("REQUEST/WITHDRAWN"))
|
hasJsonPath("$.topic", equalTo("REQUEST/WITHDRAWN")),
|
||||||
|
hasJsonPath("$.creationForm", equalTo("provideReason")),
|
||||||
|
hasJsonPath("$.type", equalTo("correctiontype"))
|
||||||
)
|
)
|
||||||
)));
|
)));
|
||||||
|
|
||||||
@@ -201,14 +210,16 @@ public class CorrectionTypeRestRepositoryIT extends AbstractControllerIntegratio
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String adminToken = getAuthToken(admin.getEmail(), password);
|
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByItem/")
|
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByItem")
|
||||||
.param("uuid", item.getID().toString()))
|
.param("uuid", item.getID().toString()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.page.totalElements", is(1)))
|
.andExpect(jsonPath("$.page.totalElements", is(1)))
|
||||||
.andExpect(jsonPath("$._embedded.correctiontypes", containsInAnyOrder(
|
.andExpect(jsonPath("$._embedded.correctiontypes", containsInAnyOrder(
|
||||||
allOf(
|
allOf(
|
||||||
hasJsonPath("$.id", equalTo("withdrawnRequest")),
|
hasJsonPath("$.id", equalTo("request-withdrawn")),
|
||||||
hasJsonPath("$.topic", equalTo("REQUEST/WITHDRAWN"))
|
hasJsonPath("$.topic", equalTo("REQUEST/WITHDRAWN")),
|
||||||
|
hasJsonPath("$.creationForm", equalTo("provideReason")),
|
||||||
|
hasJsonPath("$.type", equalTo("correctiontype"))
|
||||||
)
|
)
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
@@ -216,14 +227,14 @@ public class CorrectionTypeRestRepositoryIT extends AbstractControllerIntegratio
|
|||||||
@Test
|
@Test
|
||||||
public void findByTopicWithoutTopicParameterTest() throws Exception {
|
public void findByTopicWithoutTopicParameterTest() throws Exception {
|
||||||
String adminToken = getAuthToken(admin.getEmail(), password);
|
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByTopic/"))
|
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByTopic"))
|
||||||
.andExpect(status().isBadRequest());
|
.andExpect(status().isBadRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findByWrongTopicTest() throws Exception {
|
public void findByWrongTopicTest() throws Exception {
|
||||||
String adminToken = getAuthToken(admin.getEmail(), password);
|
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByTopic/")
|
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByTopic")
|
||||||
.param("topic", "wrongValue"))
|
.param("topic", "wrongValue"))
|
||||||
.andExpect(status().isNoContent());
|
.andExpect(status().isNoContent());
|
||||||
}
|
}
|
||||||
@@ -231,11 +242,13 @@ public class CorrectionTypeRestRepositoryIT extends AbstractControllerIntegratio
|
|||||||
@Test
|
@Test
|
||||||
public void findByTopicTest() throws Exception {
|
public void findByTopicTest() throws Exception {
|
||||||
String adminToken = getAuthToken(admin.getEmail(), password);
|
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||||
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByTopic/")
|
getClient(adminToken).perform(get("/api/config/correctiontypes/search/findByTopic")
|
||||||
.param("topic", "REQUEST/WITHDRAWN"))
|
.param("topic", "REQUEST/WITHDRAWN"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.id", equalTo("withdrawnRequest")))
|
.andExpect(jsonPath("$.id", equalTo("request-withdrawn")))
|
||||||
.andExpect(jsonPath("$.topic", equalTo("REQUEST/WITHDRAWN")));
|
.andExpect(jsonPath("$.topic", equalTo("REQUEST/WITHDRAWN")))
|
||||||
|
.andExpect(jsonPath("$.creationForm", equalTo("provideReason")))
|
||||||
|
.andExpect(jsonPath("$.type", equalTo("correctiontype")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,7 @@ import java.util.UUID;
|
|||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.dspace.app.rest.matcher.ItemMatcher;
|
import org.dspace.app.rest.matcher.ItemMatcher;
|
||||||
import org.dspace.app.rest.matcher.QAEventMatcher;
|
import org.dspace.app.rest.matcher.QAEventMatcher;
|
||||||
import org.dspace.app.rest.model.patch.Operation;
|
import org.dspace.app.rest.model.patch.Operation;
|
||||||
@@ -48,6 +49,7 @@ import org.dspace.content.Item;
|
|||||||
import org.dspace.content.QAEvent;
|
import org.dspace.content.QAEvent;
|
||||||
import org.dspace.content.QAEventProcessed;
|
import org.dspace.content.QAEventProcessed;
|
||||||
import org.dspace.qaevent.dao.QAEventsDao;
|
import org.dspace.qaevent.dao.QAEventsDao;
|
||||||
|
import org.dspace.qaevent.service.dto.CorrectionTypeMessageDTO;
|
||||||
import org.hamcrest.Matchers;
|
import org.hamcrest.Matchers;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -890,6 +892,7 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String adminToken = getAuthToken(admin.getEmail(), password);
|
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||||
|
String ePersonToken = getAuthToken(eperson.getEmail(), password);
|
||||||
getClient(adminToken).perform(get("/api/core/items/" + publication.getID()))
|
getClient(adminToken).perform(get("/api/core/items/" + publication.getID()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.inArchive", is(false)))
|
.andExpect(jsonPath("$.inArchive", is(false)))
|
||||||
@@ -897,13 +900,16 @@ public class QAEventRestRepositoryIT extends AbstractControllerIntegrationTest {
|
|||||||
|
|
||||||
AtomicReference<String> idRef = new AtomicReference<String>();
|
AtomicReference<String> idRef = new AtomicReference<String>();
|
||||||
|
|
||||||
getClient(adminToken).perform(post("/api/integration/qualityassuranceevents")
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
.contentType(RestMediaTypes.TEXT_URI_LIST)
|
CorrectionTypeMessageDTO dto = new CorrectionTypeMessageDTO("provided reason!");
|
||||||
.content("https://localhost:8080/server/api/config/correctiontypes/reinstateRequest\n" +
|
|
||||||
"https://localhost:8080/server/api/core/items/" + publication.getID()
|
getClient(ePersonToken).perform(post("/api/integration/qualityassuranceevents")
|
||||||
))
|
.param("correctionType", "request-withdrawn")
|
||||||
.andExpect(status().isCreated())
|
.param("target", publication.getID().toString())
|
||||||
.andDo(result -> idRef.set(read(result.getResponse().getContentAsString(), "$.id")));
|
.contentType(contentType)
|
||||||
|
.content(mapper.writeValueAsBytes(dto)))
|
||||||
|
.andExpect(status().isCreated())
|
||||||
|
.andDo(result -> idRef.set(read(result.getResponse().getContentAsString(), "$.id")));
|
||||||
|
|
||||||
getClient(adminToken).perform(get("/api/integration/qualityassuranceevents/" + idRef.get()))
|
getClient(adminToken).perform(get("/api/integration/qualityassuranceevents/" + idRef.get()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
|
@@ -5,12 +5,13 @@
|
|||||||
default-lazy-init="true">
|
default-lazy-init="true">
|
||||||
|
|
||||||
<bean id="withdrawnRequest" class="org.dspace.correctiontype.WithdrawnCorrectionType" >
|
<bean id="withdrawnRequest" class="org.dspace.correctiontype.WithdrawnCorrectionType" >
|
||||||
<property name="id" value="withdrawnRequest"/>
|
<property name="id" value="request-withdrawn"/>
|
||||||
<property name="topic" value="REQUEST/WITHDRAWN"/>
|
<property name="topic" value="REQUEST/WITHDRAWN"/>
|
||||||
|
<property name="creationForm" value="provideReason"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="reinstateRequest" class="org.dspace.correctiontype.ReinstateCorrectionType" >
|
<bean id="reinstateRequest" class="org.dspace.correctiontype.ReinstateCorrectionType" >
|
||||||
<property name="id" value="reinstateRequest"/>
|
<property name="id" value="request-reinstate"/>
|
||||||
<property name="topic" value="REQUEST/REINSTATE"/>
|
<property name="topic" value="REQUEST/REINSTATE"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user