try to handle rights exception

This commit is contained in:
Luigi Andrea Pascarelli
2017-12-06 16:33:58 +01:00
parent 787d8e4a6f
commit cb4121539a
5 changed files with 14 additions and 9 deletions

View File

@@ -547,7 +547,7 @@ public class Util {
return toReturn;
}
public static List<String> diff(Collection fromCollection, Collection toCollection) throws Exception {
public static List<String> diff(Collection fromCollection, Collection toCollection) throws DCInputsReaderException {
DCInputsReader reader = new DCInputsReader();
List<DCInputSet> from = reader.getInputsByCollectionHandle(fromCollection.getHandle());
List<DCInputSet> to = reader.getInputsByCollectionHandle(toCollection.getHandle());

View File

@@ -16,6 +16,7 @@ import java.util.Set;
import org.apache.log4j.Logger;
import org.dspace.app.util.DCInput;
import org.dspace.app.util.DCInputsReaderException;
import org.dspace.app.util.Util;
import org.dspace.authorize.AuthorizeException;
import org.dspace.authorize.ResourcePolicy;
@@ -261,7 +262,7 @@ public class WorkspaceItemServiceImpl implements WorkspaceItemService {
}
@Override
public void move(Context context, WorkspaceItem source, Collection fromCollection, Collection toCollection) throws Exception {
public void move(Context context, WorkspaceItem source, Collection fromCollection, Collection toCollection) throws DCInputsReaderException {
source.setCollection(toCollection);
List<MetadataValue> remove = new ArrayList<>();

View File

@@ -7,14 +7,14 @@
*/
package org.dspace.content.service;
import java.sql.SQLException;
import org.dspace.app.util.DCInputsReaderException;
import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Collection;
import org.dspace.content.InProgressSubmission;
import org.dspace.content.Item;
import org.dspace.core.Context;
import java.sql.SQLException;
/**
* Service interface class for the InProgressSubmission.
* All InProgressSubmission service classes should implement this class since it offers some basic methods which all InProgressSubmissions
@@ -43,5 +43,5 @@ public interface InProgressSubmissionService<T extends InProgressSubmission> {
*/
public void update(Context context, T inProgressSubmission) throws SQLException, AuthorizeException;
public void move(Context context, T inProgressSubmission, Collection fromCollection, Collection toCollection) throws Exception;
public void move(Context context, T inProgressSubmission, Collection fromCollection, Collection toCollection) throws DCInputsReaderException;
}

View File

@@ -18,6 +18,7 @@ import org.dspace.app.rest.exception.PatchUnprocessableEntityException;
import org.dspace.app.rest.model.DirectlyAddressableRestModel;
import org.dspace.app.rest.model.hateoas.DSpaceResource;
import org.dspace.app.rest.model.step.UploadStatusResponse;
import org.dspace.app.util.DCInputsReaderException;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.Context;
import org.springframework.data.domain.Page;
@@ -160,13 +161,13 @@ extends AbstractDSpaceRestRepository
try {
patch(context, request, apiCategory, model, id, patch);
context.commit();
} catch (SQLException | AuthorizeException e) {
} catch (SQLException | AuthorizeException | DCInputsReaderException e) {
throw new PatchUnprocessableEntityException(e.getMessage());
}
return findOne(id);
}
protected void patch(Context context, HttpServletRequest request, String apiCategory, String model, ID id, Patch patch) throws HttpRequestMethodNotSupportedException, SQLException, AuthorizeException {
protected void patch(Context context, HttpServletRequest request, String apiCategory, String model, ID id, Patch patch) throws HttpRequestMethodNotSupportedException, SQLException, AuthorizeException, DCInputsReaderException {
throw new HttpRequestMethodNotSupportedException("No implementation found; Method not allowed!");
}

View File

@@ -7,6 +7,9 @@
*/
package org.dspace.app.rest.submit.factory.impl;
import java.sql.SQLException;
import org.dspace.app.util.DCInputsReaderException;
import org.dspace.content.Collection;
import org.dspace.content.Item;
import org.dspace.content.WorkspaceItem;
@@ -35,7 +38,7 @@ public class CollectionReplacePatchOperation extends ReplacePatchOperation<Strin
@Override
void replace(Context context, Request currentRequest, WorkspaceItem source, String path, Object value)
throws Exception {
throws SQLException, DCInputsReaderException {
String uuid = (String) value;
Collection fromCollection = source.getCollection();