mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-12 04:23:13 +00:00
Added support for the leftItem and rightItem through the parameters
This commit is contained in:
@@ -561,7 +561,8 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
}
|
}
|
||||||
for (MetadataValue metadataValue : metadataValues) {
|
for (MetadataValue metadataValue : metadataValues) {
|
||||||
//Retrieve & store the place for each metadata value
|
//Retrieve & store the place for each metadata value
|
||||||
if (StringUtils.startsWith(metadataValue.getAuthority(), "virtual::") && ((RelationshipMetadataValue) metadataValue).isUseForPlace()) {
|
if (StringUtils.startsWith(metadataValue.getAuthority(), "virtual::") &&
|
||||||
|
((RelationshipMetadataValue) metadataValue).isUseForPlace()) {
|
||||||
int mvPlace = getMetadataValuePlace(fieldToLastPlace, metadataValue);
|
int mvPlace = getMetadataValuePlace(fieldToLastPlace, metadataValue);
|
||||||
metadataValue.setPlace(mvPlace);
|
metadataValue.setPlace(mvPlace);
|
||||||
String authority = metadataValue.getAuthority();
|
String authority = metadataValue.getAuthority();
|
||||||
|
@@ -1371,10 +1371,7 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<RelationshipMetadataValue> handleRelationshipTypeMetadataMappping(Context context, Item item,
|
private List<RelationshipMetadataValue> handleRelationshipTypeMetadataMappping(Context context, Item item,
|
||||||
HashMap<String, VirtualBean> hashMaps,
|
HashMap<String, VirtualBean> hashMaps, Item otherItem, String relationName, Integer relationshipId)
|
||||||
Item otherItem,
|
|
||||||
String relationName,
|
|
||||||
Integer relationshipId)
|
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
|
List<RelationshipMetadataValue> resultingMetadataValueList = new LinkedList<>();
|
||||||
for (Map.Entry<String, VirtualBean> entry : hashMaps.entrySet()) {
|
for (Map.Entry<String, VirtualBean> entry : hashMaps.entrySet()) {
|
||||||
@@ -1439,7 +1436,8 @@ prevent the generation of resource policy entry values with null dspace_object a
|
|||||||
if (metadataField == null) {
|
if (metadataField == null) {
|
||||||
log.error(
|
log.error(
|
||||||
"A MetadataValue was attempted to construct with MetadataField for paremeters: metadataschema: "
|
"A MetadataValue was attempted to construct with MetadataField for paremeters: metadataschema: "
|
||||||
+ metadataSchema + ", metadataelement:" + metadataElement + ", metadataqualifier: " + metadataQualifier);
|
+ metadataSchema + ", metadataelement:" + metadataElement +
|
||||||
|
", metadataqualifier: " + metadataQualifier);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
metadataValue.setMetadataField(metadataField);
|
metadataValue.setMetadataField(metadataField);
|
||||||
|
@@ -1,3 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* 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.content;
|
package org.dspace.content;
|
||||||
|
|
||||||
import org.hibernate.proxy.HibernateProxyHelper;
|
import org.hibernate.proxy.HibernateProxyHelper;
|
||||||
|
@@ -23,7 +23,6 @@ import org.dspace.content.Collection;
|
|||||||
import org.dspace.content.Community;
|
import org.dspace.content.Community;
|
||||||
import org.dspace.content.Item;
|
import org.dspace.content.Item;
|
||||||
import org.dspace.content.MetadataField;
|
import org.dspace.content.MetadataField;
|
||||||
import org.dspace.content.MetadataValue;
|
|
||||||
import org.dspace.content.RelationshipMetadataValue;
|
import org.dspace.content.RelationshipMetadataValue;
|
||||||
import org.dspace.content.Thumbnail;
|
import org.dspace.content.Thumbnail;
|
||||||
import org.dspace.content.WorkspaceItem;
|
import org.dspace.content.WorkspaceItem;
|
||||||
|
@@ -1,3 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* 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.content.virtual;
|
package org.dspace.content.virtual;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@@ -990,7 +990,10 @@ public class RestResourceController implements InitializingBean {
|
|||||||
return putOneInternal(request, apiCategory, model, id, jsonNode);
|
return putOneInternal(request, apiCategory, model, id, jsonNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <ID extends Serializable> DSpaceResource<RestAddressableModel> putOneInternal(HttpServletRequest request, String apiCategory, String model, ID id, JsonNode jsonNode) {
|
private <ID extends Serializable> DSpaceResource<RestAddressableModel> putOneInternal(HttpServletRequest request,
|
||||||
|
String apiCategory,
|
||||||
|
String model, ID id,
|
||||||
|
JsonNode jsonNode) {
|
||||||
checkModelPluralForm(apiCategory, model);
|
checkModelPluralForm(apiCategory, model);
|
||||||
DSpaceRestRepository<RestAddressableModel, ID> repository = utils.getResourceRepository(apiCategory, model);
|
DSpaceRestRepository<RestAddressableModel, ID> repository = utils.getResourceRepository(apiCategory, model);
|
||||||
RestAddressableModel modelObject = null;
|
RestAddressableModel modelObject = null;
|
||||||
|
@@ -14,7 +14,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.app.rest.converter.RelationshipConverter;
|
import org.dspace.app.rest.converter.RelationshipConverter;
|
||||||
import org.dspace.app.rest.converter.RelationshipTypeConverter;
|
import org.dspace.app.rest.converter.RelationshipTypeConverter;
|
||||||
@@ -33,6 +32,7 @@ import org.dspace.content.service.RelationshipTypeService;
|
|||||||
import org.dspace.core.Constants;
|
import org.dspace.core.Constants;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
|
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;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@@ -107,10 +107,11 @@ public class RelationshipRestRepository extends DSpaceRestRepository<Relationshi
|
|||||||
}
|
}
|
||||||
|
|
||||||
Relationship relationship = new Relationship();
|
Relationship relationship = new Relationship();
|
||||||
Item leftItem = itemService.find(context, relationshipRest.getLeftId());
|
Item leftItem = itemService.find(context, UUIDUtils.fromString(req.getParameter("leftItem")));
|
||||||
Item rightItem = itemService.find(context, relationshipRest.getRightId());
|
Item rightItem = itemService.find(context, UUIDUtils.fromString(req.getParameter("rightItem")));
|
||||||
EPerson ePerson = context.getCurrentUser();
|
EPerson ePerson = context.getCurrentUser();
|
||||||
if (authorizeService.authorizeActionBoolean(context, leftItem, Constants.WRITE) && authorizeService.authorizeActionBoolean(context, rightItem, Constants.WRITE)) {
|
if (authorizeService.authorizeActionBoolean(context, leftItem, Constants.WRITE) &&
|
||||||
|
authorizeService.authorizeActionBoolean(context, rightItem, Constants.WRITE)) {
|
||||||
relationship.setLeftItem(leftItem);
|
relationship.setLeftItem(leftItem);
|
||||||
relationship.setRightItem(rightItem);
|
relationship.setRightItem(rightItem);
|
||||||
relationship
|
relationship
|
||||||
@@ -129,6 +130,7 @@ public class RelationshipRestRepository extends DSpaceRestRepository<Relationshi
|
|||||||
JsonNode jsonNode)
|
JsonNode jsonNode)
|
||||||
throws RepositoryMethodNotImplementedException, SQLException, AuthorizeException {
|
throws RepositoryMethodNotImplementedException, SQLException, AuthorizeException {
|
||||||
|
|
||||||
|
HttpServletRequest req = getRequestService().getCurrentRequest().getHttpServletRequest();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
RelationshipRest relationshipRest = null;
|
RelationshipRest relationshipRest = null;
|
||||||
try {
|
try {
|
||||||
@@ -140,14 +142,16 @@ public class RelationshipRestRepository extends DSpaceRestRepository<Relationshi
|
|||||||
if (relationship == null) {
|
if (relationship == null) {
|
||||||
throw new ResourceNotFoundException(apiCategory + "." + model + " with id: " + id + " not found");
|
throw new ResourceNotFoundException(apiCategory + "." + model + " with id: " + id + " not found");
|
||||||
}
|
}
|
||||||
Item leftItem = itemService.find(context, relationshipRest.getLeftId());
|
Item leftItem = itemService.find(context, UUIDUtils.fromString(req.getParameter("leftItem")));
|
||||||
Item rightItem = itemService.find(context, relationshipRest.getRightId());
|
Item rightItem = itemService.find(context, UUIDUtils.fromString(req.getParameter("rightItem")));
|
||||||
if (authorizeService.authorizeActionBoolean(context, leftItem, Constants.WRITE) && authorizeService.authorizeActionBoolean(context, rightItem, Constants.WRITE)) {
|
if (authorizeService.authorizeActionBoolean(context, leftItem, Constants.WRITE) &&
|
||||||
|
authorizeService.authorizeActionBoolean(context, rightItem, Constants.WRITE)) {
|
||||||
relationship.setId(relationshipRest.getId());
|
relationship.setId(relationshipRest.getId());
|
||||||
relationship.setLeftItem(leftItem);
|
relationship.setLeftItem(leftItem);
|
||||||
relationship.setRightItem(rightItem);
|
relationship.setRightItem(rightItem);
|
||||||
|
|
||||||
relationship.setRelationshipType(relationshipTypeService.find(context, relationshipRest.getRelationshipTypeId()));
|
relationship.setRelationshipType(
|
||||||
|
relationshipTypeService.find(context, relationshipRest.getRelationshipTypeId()));
|
||||||
if (relationshipRest.getLeftPlace() != -1) {
|
if (relationshipRest.getLeftPlace() != -1) {
|
||||||
relationship.setLeftPlace(relationshipRest.getLeftPlace());
|
relationship.setLeftPlace(relationshipRest.getLeftPlace());
|
||||||
}
|
}
|
||||||
@@ -166,12 +170,12 @@ public class RelationshipRestRepository extends DSpaceRestRepository<Relationshi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void delete(Context context, Integer id) throws AuthorizeException {
|
protected void delete(Context context, Integer id) throws AuthorizeException {
|
||||||
|
|
||||||
Relationship relationship = null;
|
Relationship relationship = null;
|
||||||
try {
|
try {
|
||||||
relationship = relationshipService.find(context, id);
|
relationship = relationshipService.find(context, id);
|
||||||
if (relationship != null) {
|
if (relationship != null) {
|
||||||
if (authorizeService.authorizeActionBoolean(context, relationship.getLeftItem(), Constants.WRITE) && authorizeService.authorizeActionBoolean(context, relationship.getRightItem(), Constants.WRITE)) {
|
if (authorizeService.authorizeActionBoolean(context, relationship.getLeftItem(), Constants.WRITE) &&
|
||||||
|
authorizeService.authorizeActionBoolean(context, relationship.getRightItem(), Constants.WRITE)) {
|
||||||
relationshipService.delete(context, relationship);
|
relationshipService.delete(context, relationship);
|
||||||
} else {
|
} else {
|
||||||
throw new AccessDeniedException("You do not have write rights on this relationship's items");
|
throw new AccessDeniedException("You do not have write rights on this relationship's items");
|
||||||
|
Reference in New Issue
Block a user