mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 15:03:18 +00:00
Implement community feedbacks
This commit is contained in:
@@ -11,11 +11,15 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.versioning.dao.VersionHistoryDAO;
|
||||
import org.dspace.versioning.service.VersionHistoryService;
|
||||
import org.dspace.versioning.service.VersioningService;
|
||||
@@ -34,6 +38,12 @@ public class VersionHistoryServiceImpl implements VersionHistoryService {
|
||||
@Autowired(required = true)
|
||||
private VersioningService versioningService;
|
||||
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
|
||||
@Autowired
|
||||
private ConfigurationService configurationService;
|
||||
|
||||
protected VersionHistoryServiceImpl() {
|
||||
|
||||
}
|
||||
@@ -210,4 +220,20 @@ public class VersionHistoryServiceImpl implements VersionHistoryService {
|
||||
return versionHistoryDAO.findByItem(context, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSeeDraftVersion(Context context, VersionHistory versionHistory) throws SQLException {
|
||||
Version version = this.getLatestVersion(context, versionHistory);
|
||||
if (Objects.nonNull(version)) {
|
||||
EPerson submitter = version.getItem().getSubmitter();
|
||||
boolean isAdmin = authorizeService.isAdmin(context);
|
||||
boolean canCreateVersion = configurationService
|
||||
.getBooleanProperty("versioning.submitterCanCreateNewVersion");
|
||||
if (!isAdmin && !(canCreateVersion && Objects.equals(submitter, context.getCurrentUser()))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -67,4 +67,6 @@ public interface VersionHistoryService extends DSpaceCRUDService<VersionHistory>
|
||||
|
||||
public void remove(VersionHistory versionHistory, Version version);
|
||||
|
||||
public boolean canSeeDraftVersion(Context context, VersionHistory versionHistory) throws SQLException;
|
||||
|
||||
}
|
||||
|
@@ -55,9 +55,7 @@ public class CanCreateVersionFeature implements AuthorizationFeature {
|
||||
}
|
||||
Item item = itemService.find(context, UUID.fromString(((ItemRest) object).getUuid()));
|
||||
if (Objects.nonNull(item)) {
|
||||
String stringBlockEntity = configurationService.getProperty("versioning.block.entity");
|
||||
boolean isBlockEntity = StringUtils.isNotBlank(stringBlockEntity) ?
|
||||
Boolean.valueOf(stringBlockEntity) : true;
|
||||
boolean isBlockEntity = configurationService.getBooleanProperty("versioning.block.entity", true);
|
||||
boolean hasEntityType = StringUtils.isNotBlank(itemService.
|
||||
getMetadataFirstValue(item, "dspace", "entity", "type", Item.ANY));
|
||||
if (isBlockEntity && hasEntityType) {
|
||||
|
@@ -54,9 +54,7 @@ public class CanDeleteVersionFeature extends DeleteFeature {
|
||||
Version version = versioningService.getVersion(context, ((VersionRest)object).getId());
|
||||
if (Objects.nonNull(version) && Objects.nonNull(version.getItem())) {
|
||||
ItemRest itemRest = itemConverter.convert(version.getItem(), DefaultProjection.DEFAULT);
|
||||
String stringBlockEntity = configurationService.getProperty("versioning.block.entity");
|
||||
boolean isBlockEntity = StringUtils.isNotBlank(stringBlockEntity) ?
|
||||
Boolean.valueOf(stringBlockEntity) : true;
|
||||
boolean isBlockEntity = configurationService.getBooleanProperty("versioning.block.entity", true);
|
||||
boolean hasEntityType = StringUtils.isNotBlank(
|
||||
itemService.getMetadataFirstValue(version.getItem(), "dspace", "entity", "type", Item.ANY));
|
||||
if (isBlockEntity && hasEntityType) {
|
||||
|
@@ -57,9 +57,7 @@ public class CanEditVersionFeature implements AuthorizationFeature {
|
||||
}
|
||||
Version version = versioningService.getVersion(context, (((VersionRest) object).getId()));
|
||||
if (Objects.nonNull(version) && Objects.nonNull(version.getItem())) {
|
||||
String stringBlockEntity = configurationService.getProperty("versioning.block.entity");
|
||||
boolean isBlockEntity = StringUtils.isNotBlank(stringBlockEntity) ?
|
||||
Boolean.valueOf(stringBlockEntity) : true;
|
||||
boolean isBlockEntity = configurationService.getBooleanProperty("versioning.block.entity", true);
|
||||
boolean hasEntityType = StringUtils.isNotBlank(
|
||||
itemService.getMetadataFirstValue(version.getItem(), "dspace", "entity", "type", Item.ANY));
|
||||
if (isBlockEntity && hasEntityType) {
|
||||
|
@@ -53,9 +53,7 @@ public class CanManageVersionsFeature implements AuthorizationFeature {
|
||||
}
|
||||
Item item = itemService.find(context, UUID.fromString(((ItemRest) object).getUuid()));
|
||||
if (Objects.nonNull(item)) {
|
||||
String stringBlockEntity = configurationService.getProperty("versioning.block.entity");
|
||||
boolean isBlockEntity = StringUtils.isNotBlank(stringBlockEntity) ?
|
||||
Boolean.valueOf(stringBlockEntity) : true;
|
||||
boolean isBlockEntity = configurationService.getBooleanProperty("versioning.block.entity", true);
|
||||
boolean hasEntityType = StringUtils.isNotBlank(itemService.
|
||||
getMetadataFirstValue(item, "dspace", "entity", "type", Item.ANY));
|
||||
if (isBlockEntity && hasEntityType) {
|
||||
|
@@ -15,13 +15,9 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.model.VersionHistoryRest;
|
||||
import org.dspace.app.rest.projection.Projection;
|
||||
import org.dspace.app.rest.utils.ContextUtil;
|
||||
import org.dspace.authorize.service.AuthorizeService;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.RequestService;
|
||||
import org.dspace.services.model.Request;
|
||||
import org.dspace.versioning.Version;
|
||||
import org.dspace.versioning.VersionHistory;
|
||||
import org.dspace.versioning.service.VersionHistoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -38,12 +34,6 @@ public class VersionHistoryConverter implements DSpaceConverter<VersionHistory,
|
||||
@Autowired
|
||||
private RequestService requestService;
|
||||
|
||||
@Autowired
|
||||
private AuthorizeService authorizeService;
|
||||
|
||||
@Autowired
|
||||
private ConfigurationService configurationService;
|
||||
|
||||
@Autowired
|
||||
private VersionHistoryService versionHistoryService;
|
||||
|
||||
@@ -51,11 +41,15 @@ public class VersionHistoryConverter implements DSpaceConverter<VersionHistory,
|
||||
public VersionHistoryRest convert(VersionHistory modelObject, Projection projection) {
|
||||
Context context = getContext();
|
||||
VersionHistoryRest versionHistoryRest = new VersionHistoryRest();
|
||||
versionHistoryRest.setId(modelObject.getID());
|
||||
if (Objects.nonNull(context.getCurrentUser())) {
|
||||
if (canSeeDraftVersion(context, modelObject)) {
|
||||
versionHistoryRest.setDraftVersion(modelObject.hasDraftVersion());
|
||||
try {
|
||||
versionHistoryRest.setId(modelObject.getID());
|
||||
if (Objects.nonNull(context.getCurrentUser())) {
|
||||
if (versionHistoryService.canSeeDraftVersion(context, modelObject)) {
|
||||
versionHistoryRest.setDraftVersion(modelObject.hasDraftVersion());
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return versionHistoryRest;
|
||||
}
|
||||
@@ -65,25 +59,6 @@ public class VersionHistoryConverter implements DSpaceConverter<VersionHistory,
|
||||
return VersionHistory.class;
|
||||
}
|
||||
|
||||
private boolean canSeeDraftVersion(Context context, VersionHistory versionHistory) {
|
||||
try {
|
||||
Version version = versionHistoryService.getLatestVersion(context, versionHistory);
|
||||
if (Objects.nonNull(version)) {
|
||||
EPerson submitter = version.getItem().getSubmitter();
|
||||
boolean isAdmin = authorizeService.isAdmin(context);
|
||||
boolean canCreateVersion = configurationService
|
||||
.getBooleanProperty("versioning.submitterCanCreateNewVersion");
|
||||
if (!isAdmin && !(canCreateVersion && Objects.equals(submitter, context.getCurrentUser()))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the context from the request
|
||||
* If not request is found, will return null
|
||||
|
@@ -1,28 +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.exception;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
/**
|
||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.it)
|
||||
*/
|
||||
@ResponseStatus(value = HttpStatus.FORBIDDEN, reason = "Forbidden request")
|
||||
public class DSpaceForbiddenException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 8869331967657914409L;
|
||||
|
||||
public DSpaceForbiddenException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public DSpaceForbiddenException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
@@ -57,11 +57,11 @@ public class VersionHistoryDraftVersionLinkRepository extends AbstractDSpaceRest
|
||||
Projection projection) throws SQLException {
|
||||
Context context = obtainContext();
|
||||
if (Objects.isNull(versionHistoryId) || versionHistoryId < 0) {
|
||||
throw new DSpaceBadRequestException("Provied id is not correct!");
|
||||
throw new DSpaceBadRequestException("Provided id is not correct!");
|
||||
}
|
||||
VersionHistory versionHistory = versionHistoryService.find(context, versionHistoryId);
|
||||
if (Objects.isNull(versionHistory)) {
|
||||
throw new ResourceNotFoundException("No such versio found");
|
||||
throw new ResourceNotFoundException("No such version found");
|
||||
}
|
||||
Version oldestVersion = versionHistoryService.getLatestVersion(context, versionHistory);
|
||||
|
||||
|
@@ -15,7 +15,6 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.converter.ConverterService;
|
||||
import org.dspace.app.rest.exception.DSpaceBadRequestException;
|
||||
import org.dspace.app.rest.exception.DSpaceForbiddenException;
|
||||
import org.dspace.app.rest.exception.RepositoryMethodNotImplementedException;
|
||||
import org.dspace.app.rest.exception.UnprocessableEntityException;
|
||||
import org.dspace.app.rest.model.VersionRest;
|
||||
@@ -112,17 +111,16 @@ public class VersionRestRepository extends DSpaceRestRepository<VersionRest, Int
|
||||
}
|
||||
|
||||
boolean hasEntityType = StringUtils.isNotBlank(itemService.
|
||||
getMetadataFirstValue(item, "dspace", "entity", "type", Item.ANY));
|
||||
String stringBlockEntity = configurationService.getProperty("versioning.block.entity");
|
||||
getMetadataFirstValue(item, "dspace", "entity", "type", Item.ANY));
|
||||
boolean isBlockEntity = configurationService.getBooleanProperty("versioning.block.entity", true);
|
||||
|
||||
EPerson submitter = item.getSubmitter();
|
||||
boolean isAdmin = authorizeService.isAdmin(context);
|
||||
boolean canCreateVersion = configurationService.getBooleanProperty("versioning.submitterCanCreateNewVersion");
|
||||
boolean isBlockEntity = StringUtils.isNotBlank(stringBlockEntity) ? Boolean.valueOf(stringBlockEntity) : true;
|
||||
|
||||
if (!isAdmin && !(canCreateVersion && Objects.equals(submitter, context.getCurrentUser())) ||
|
||||
(hasEntityType && isBlockEntity)) {
|
||||
throw new DSpaceForbiddenException("");
|
||||
throw new AuthorizeException();
|
||||
}
|
||||
|
||||
WorkflowItem workflowItem = null;
|
||||
@@ -140,7 +138,8 @@ public class VersionRestRepository extends DSpaceRestRepository<VersionRest, Int
|
||||
}
|
||||
|
||||
if (Objects.nonNull(workflowItem) || Objects.nonNull(workspaceItem)) {
|
||||
throw new UnprocessableEntityException("");
|
||||
throw new UnprocessableEntityException("It is not possible to create a new version"
|
||||
+ " if the latest one in submisssion!");
|
||||
}
|
||||
|
||||
Version version = StringUtils.isNotBlank(summary) ?
|
||||
@@ -168,8 +167,8 @@ public class VersionRestRepository extends DSpaceRestRepository<VersionRest, Int
|
||||
break;
|
||||
case "add":
|
||||
if (StringUtils.isNotBlank(version.getSummary())) {
|
||||
throw new DSpaceBadRequestException("The 'summary' property is setted with value:"
|
||||
+ version.getSummary() + ", it is not possible to add new value");
|
||||
throw new DSpaceBadRequestException("The 'summary' already contains the value: "
|
||||
+ version.getSummary() + ", it is not possible to add a new value.");
|
||||
}
|
||||
version.setSummary(operation.getValue().toString());
|
||||
break;
|
||||
|
@@ -33,6 +33,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Methods of this class are used on PreAuthorize annotations
|
||||
* to convert input parameters.
|
||||
*
|
||||
* @author Mykhaylo Boychuk (mykhaylo.boychuk at 4science.it)
|
||||
*/
|
||||
@Component(value = "extractorOf")
|
||||
|
@@ -22,6 +22,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.dspace.app.rest.matcher.VersionHistoryMatcher;
|
||||
import org.dspace.app.rest.matcher.VersionMatcher;
|
||||
import org.dspace.app.rest.matcher.WorkflowItemMatcher;
|
||||
import org.dspace.app.rest.matcher.WorkspaceItemMatcher;
|
||||
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
@@ -29,6 +30,7 @@ import org.dspace.builder.CollectionBuilder;
|
||||
import org.dspace.builder.CommunityBuilder;
|
||||
import org.dspace.builder.ItemBuilder;
|
||||
import org.dspace.builder.VersionBuilder;
|
||||
import org.dspace.builder.WorkflowItemBuilder;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.Community;
|
||||
import org.dspace.content.Item;
|
||||
@@ -39,6 +41,7 @@ import org.dspace.versioning.Version;
|
||||
import org.dspace.versioning.VersionHistory;
|
||||
import org.dspace.versioning.service.VersionHistoryService;
|
||||
import org.dspace.versioning.service.VersioningService;
|
||||
import org.dspace.xmlworkflow.storedcomponents.XmlWorkflowItem;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -380,6 +383,119 @@ public class VersionHistoryRestRepositoryIT extends AbstractControllerIntegratio
|
||||
.andExpect(status().isUnauthorized());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findDraftOfVersionNotFoundTest() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
.build();
|
||||
|
||||
Collection col = CollectionBuilder.createCollection(context, parentCommunity)
|
||||
.withName("Collection test")
|
||||
.build();
|
||||
|
||||
Item item = ItemBuilder.createItem(context, col)
|
||||
.withTitle("Public test item")
|
||||
.withIssueDate("2021-04-27")
|
||||
.withAuthor("Doe, John")
|
||||
.withSubject("ExtraEntry")
|
||||
.build();
|
||||
|
||||
VersionBuilder.createVersion(context, item, "test").build();
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
String tokenAdmin = getAuthToken(admin.getEmail(), password);
|
||||
getClient(tokenAdmin).perform(get("/api/versioning/versionhistories/" + Integer.MAX_VALUE + "/draftVersion"))
|
||||
.andExpect(status().isNotFound());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findDraftOfVersionNoContentTest() throws Exception {
|
||||
//disable file upload mandatory
|
||||
configurationService.setProperty("webui.submit.upload.required", false);
|
||||
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
.build();
|
||||
|
||||
Collection col = CollectionBuilder.createCollection(context, parentCommunity)
|
||||
.withName("Collection test")
|
||||
.withSubmitterGroup(admin)
|
||||
.build();
|
||||
|
||||
Item item = ItemBuilder.createItem(context, col)
|
||||
.withTitle("Public test item")
|
||||
.withIssueDate("2021-04-27")
|
||||
.withAuthor("Doe, John")
|
||||
.withSubject("ExtraEntry")
|
||||
.build();
|
||||
|
||||
Version version = VersionBuilder.createVersion(context, item, "test").build();
|
||||
VersionHistory vh = versionHistoryService.findByItem(context, version.getItem());
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
AtomicReference<Integer> idRef = new AtomicReference<Integer>();
|
||||
String tokenAdmin = getAuthToken(admin.getEmail(), password);
|
||||
|
||||
// retrieve the workspace item
|
||||
getClient(tokenAdmin).perform(get("/api/submission/workspaceitems/search/item")
|
||||
.param("uuid", String.valueOf(version.getItem().getID())))
|
||||
.andExpect(status().isOk())
|
||||
.andDo(result -> idRef.set(read(result.getResponse().getContentAsString(), "$.id")));
|
||||
|
||||
// submit the workspaceitem to complete the deposit
|
||||
getClient(tokenAdmin).perform(post(BASE_REST_SERVER_URL + "/api/workflow/workflowitems")
|
||||
.content("/api/submission/workspaceitems/" + idRef.get())
|
||||
.contentType(textUriContentType))
|
||||
.andExpect(status().isCreated());
|
||||
|
||||
getClient(tokenAdmin).perform(get("/api/versioning/versionhistories/" + vh.getID() + "/draftVersion"))
|
||||
.andExpect(status().isNoContent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findWorkflowItemOfDraftVersionAdminTest() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
.build();
|
||||
|
||||
Collection col = CollectionBuilder.createCollection(context, parentCommunity)
|
||||
.withName("Collection 1")
|
||||
.withWorkflowGroup(1, admin)
|
||||
.build();
|
||||
|
||||
Item item = ItemBuilder.createItem(context, col)
|
||||
.withTitle("Public test item")
|
||||
.withIssueDate("2021-04-27")
|
||||
.withAuthor("Doe, John")
|
||||
.withSubject("ExtraEntry")
|
||||
.build();
|
||||
|
||||
XmlWorkflowItem witem = WorkflowItemBuilder.createWorkflowItem(context, col)
|
||||
.withTitle("Workflow Item 1")
|
||||
.withIssueDate("2017-10-17")
|
||||
.withAuthor("Doe, John")
|
||||
.withSubject("ExtraEntry")
|
||||
.build();
|
||||
|
||||
Version version = VersionBuilder.createVersion(context, item, "test").build();
|
||||
version.setItem(witem.getItem());
|
||||
VersionHistory vh = versionHistoryService.findByItem(context, version.getItem());
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
String tokenAdmin = getAuthToken(admin.getEmail(), password);
|
||||
|
||||
getClient(tokenAdmin).perform(get("/api/versioning/versionhistories/" + vh.getID() + "/draftVersion"))
|
||||
.andExpect(jsonPath("$", Matchers.is(
|
||||
WorkflowItemMatcher.matchItemWithTitleAndDateIssuedAndSubject(witem,
|
||||
"Workflow Item 1", "2017-10-17", "ExtraEntry"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findWorkspaceItemOfDraftVersionLoggedUserTest() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
@@ -412,7 +528,7 @@ public class VersionHistoryRestRepositoryIT extends AbstractControllerIntegratio
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findVersionsOfVersionHistoryCheckPaginationAfterDelitingOfVersionTest() throws Exception {
|
||||
public void findVersionsOfVersionHistoryCheckPaginationAfterDeletingOfVersionTest() throws Exception {
|
||||
//disable file upload mandatory
|
||||
configurationService.setProperty("webui.submit.upload.required", false);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
@@ -8,6 +8,7 @@
|
||||
package org.dspace.app.rest;
|
||||
import static com.jayway.jsonpath.JsonPath.read;
|
||||
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
||||
import static org.hamcrest.Matchers.emptyOrNullString;
|
||||
import static org.hamcrest.Matchers.emptyString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
|
||||
@@ -293,6 +294,46 @@ public class VersionRestRepositoryIT extends AbstractControllerIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createFirstVersionWithoutSummaryTest() throws Exception {
|
||||
context.turnOffAuthorisationSystem();
|
||||
parentCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
.build();
|
||||
|
||||
Collection col = CollectionBuilder.createCollection(context, parentCommunity)
|
||||
.withName("Collection test")
|
||||
.build();
|
||||
|
||||
Item item = ItemBuilder.createItem(context, col)
|
||||
.withTitle("Public test item")
|
||||
.withIssueDate("2021-04-27")
|
||||
.withAuthor("Doe, John")
|
||||
.withSubject("ExtraEntry")
|
||||
.build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
AtomicReference<Integer> idRef = new AtomicReference<Integer>();
|
||||
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||
|
||||
try {
|
||||
getClient(adminToken).perform(post("/api/versioning/versions")
|
||||
.contentType(MediaType.parseMediaType(RestMediaTypes.TEXT_URI_LIST_VALUE))
|
||||
.content("/api/core/items/" + item.getID()))
|
||||
.andExpect(status().isCreated())
|
||||
.andExpect(jsonPath("$", Matchers.allOf(
|
||||
hasJsonPath("$.version", is(2)),
|
||||
hasJsonPath("$.summary", emptyOrNullString()),
|
||||
hasJsonPath("$.submitterName", is("first (admin) last (admin)")),
|
||||
hasJsonPath("$.type", is("version"))
|
||||
)))
|
||||
.andDo(result -> idRef.set(read(result.getResponse().getContentAsString(), "$.id")));
|
||||
} finally {
|
||||
VersionBuilder.delete(idRef.get());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createFirstVersionItemBadRequestTest() throws Exception {
|
||||
String adminToken = getAuthToken(admin.getEmail(), password);
|
||||
|
@@ -409,7 +409,7 @@ public class CanCreateVersionFeatureIT extends AbstractControllerIntegrationTest
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
configurationService.setProperty("versioning.submitterCanCreateNewVersion", true);
|
||||
configurationService.setProperty("versioning.block.entity", "");
|
||||
configurationService.setProperty("versioning.block.entity", null);
|
||||
|
||||
Community rootCommunity = CommunityBuilder.createCommunity(context)
|
||||
.withName("Parent Community")
|
||||
@@ -417,7 +417,6 @@ public class CanCreateVersionFeatureIT extends AbstractControllerIntegrationTest
|
||||
|
||||
Collection col = CollectionBuilder.createCollection(context, rootCommunity)
|
||||
.withName("Collection 1")
|
||||
.withAdminGroup(eperson)
|
||||
.withSubmitterGroup(eperson)
|
||||
.build();
|
||||
|
||||
|
Reference in New Issue
Block a user