CST-12822 add offerType to NotifyRequestStatus object, adjust IT test and fix json response

This commit is contained in:
frabacche
2023-11-29 15:54:43 +01:00
parent 87c512f3ee
commit 7f99236e85
7 changed files with 35 additions and 38 deletions

View File

@@ -16,6 +16,7 @@ public class RequestStatus {
private String serviceName;
private String serviceUrl;
private String offerType;
private NotifyRequestStatusEnum status;
public String getServiceName() {
@@ -36,5 +37,11 @@ public class RequestStatus {
public void setStatus(NotifyRequestStatusEnum status) {
this.status = status;
}
public String getOfferType() {
return offerType;
}
public void setOfferType(String offerType) {
this.offerType = offerType;
}
}

View File

@@ -33,6 +33,7 @@ import org.dspace.app.ldn.model.RequestStatus;
import org.dspace.app.ldn.model.Service;
import org.dspace.app.ldn.processor.LDNProcessor;
import org.dspace.app.ldn.service.LDNMessageService;
import org.dspace.app.ldn.utility.LDNUtils;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.dspace.content.service.ItemService;
@@ -41,6 +42,7 @@ import org.dspace.handle.service.HandleService;
import org.dspace.services.ConfigurationService;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Implementation of {@link LDNMessageService}
*
@@ -292,6 +294,7 @@ public class LDNMessageServiceImpl implements LDNMessageService {
RequestStatus offer = new RequestStatus();
offer.setServiceName(msg.getTarget() == null ? "Unknown Service" : msg.getTarget().getName());
offer.setServiceUrl(msg.getTarget() == null ? "" : msg.getTarget().getUrl());
offer.setOfferType(LDNUtils.getNotifyType(msg.getCoarNotifyType()));
List<LDNMessageEntity> acks = ldnMessageDao.findAllRelatedMessagesByItem(
context, msg, item, "Accept", "TentativeReject", "TentativeAccept", "Announce");
if (acks == null || acks.isEmpty()) {

View File

@@ -80,4 +80,17 @@ public class LDNUtils {
return resolverId;
}
/**
* Clear the coarNotifyType from the source code.
*
* @param coarNotifyType coar Notify Type to sanitize
* @return String just the notify type
*/
public static String getNotifyType(String coarNotifyType) {
String justNotifyType = coarNotifyType;
justNotifyType = justNotifyType.substring(justNotifyType.lastIndexOf(":") + 1);
justNotifyType = justNotifyType.replace("Action", "");
return justNotifyType;
}
}