Javadoc cleanup, force projection in test that need it

This commit is contained in:
Andrea Bollini
2020-03-08 16:42:01 +01:00
parent 8e975bc228
commit d63493905b
7 changed files with 18 additions and 20 deletions

View File

@@ -8,14 +8,14 @@
package org.dspace.app.rest.authorization;
import org.dspace.app.rest.model.BaseObjectRest;
import org.dspace.app.rest.model.RestAddressableModel;
import org.dspace.content.Site;
import org.dspace.discovery.IndexableObject;
import org.dspace.eperson.EPerson;
/**
* An authorization is the right for a specific {@link EPerson}, eventually null to indicate unauthenticated users, to
* use a specific {@link AuthorizationFeature} on a defined object. The target object must implement the
* {@link IndexableObject} interface so to have an unique ID and type
* {@link RestAddressableModel} interface so to be directly addressable
*
* @author Andrea Bollini (andrea.bollini at 4science.it)
*/

View File

@@ -10,7 +10,7 @@ package org.dspace.app.rest.authorization;
import java.sql.SQLException;
import org.dspace.app.rest.model.BaseObjectRest;
import org.dspace.app.rest.model.RestModel;
import org.dspace.app.rest.model.RestAddressableModel;
import org.dspace.app.rest.model.SiteRest;
import org.dspace.core.Context;
import org.springframework.core.annotation.AnnotationUtils;
@@ -64,7 +64,7 @@ public interface AuthorizationFeature {
}
/**
* Return the supported object type according to the {@link RestModel#getType()}
* Return the supported object type according to the {@link RestAddressableModel#getUniqueType()}
*
* @return the supported object type, required to be not null
*/

View File

@@ -46,6 +46,13 @@ public abstract class RestAddressableModel implements RestModel {
}
@JsonIgnore
/**
*
* @return an unique string useful to unambiguously identify the type of rest
* object. It is in the form of category.model where model is in its
* singular form. Examples include core.item, core.community,
* submission.workspaceitem, etc.
*/
public String getUniqueType() {
return getCategory() + "." + getType();
}

View File

@@ -125,16 +125,11 @@ public class AuthorizationRestRepository extends DSpaceRestRepository<Authorizat
/**
* It returns the list of matching available authorizations granted to the specified eperson or to the anonymous
* user. Only administrators and the user identified by the epersonUuid parameter can access this method
*
*
* @param context
* the DSpace Context
* @param uri
* the uri of the object to check the authorization against
* @param epersonUuid
* the eperson uuid to use in the authorization evaluation
* @param featureName
* limit the authorization check to only the feature identified via its name
* @param pageable
* the pagination options
* @return the list of matching authorization available for the requested user and object, filtered by feature if
@@ -175,9 +170,6 @@ public class AuthorizationRestRepository extends DSpaceRestRepository<Authorizat
* It returns the authorization related to the requested feature if granted to the specified eperson or to the
* anonymous user. Only administrators and the user identified by the epersonUuid parameter can access this method
*
*
* @param context
* the DSpace Context
* @param uri
* the uri of the object to check the authorization against
* @param epersonUuid

View File

@@ -20,7 +20,7 @@ import org.dspace.core.ReloadableEntity;
*
* @author Andrea Bollini (andrea.bollini at 4science.it)
*
* @param <F> the ReloadableEntity type
* @param <T> the ReloadableEntity type
* @param <PK> the primary key type
*/
public interface ReloadableEntityObjectRepository<T extends ReloadableEntity<PK>,

View File

@@ -17,7 +17,6 @@ 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.eperson.service.EPersonService;
import org.dspace.services.RequestService;
import org.dspace.services.model.Request;
import org.slf4j.Logger;
@@ -42,9 +41,6 @@ public class ReadAuthorizationPermissionEvaluatorPlugin extends RestObjectPermis
@Autowired
private RequestService requestService;
@Autowired
private EPersonService ePersonService;
@Autowired
private AuthorizationRestUtil authorizationRestUtil;
@@ -67,9 +63,7 @@ public class ReadAuthorizationPermissionEvaluatorPlugin extends RestObjectPermis
return true;
}
EPerson ePerson = authorizationRestUtil.getEperson(context, targetId.toString());
EPerson currUser = null;
currUser = ePersonService.findByEmail(context, (String) authentication.getPrincipal());
EPerson currUser = context.getCurrentUser();
if (ePerson == null) {
// everyone can check authorization for the anonymous user

View File

@@ -363,6 +363,7 @@ public class AuthorizationRestRepositoryIT extends AbstractControllerIntegration
// verify that it works for administrators
String adminToken = getAuthToken(admin.getEmail(), password);
getClient(adminToken).perform(get("/api/authz/authorizations/search/object")
.param("projection", "full")
.param("uri", siteUri)
.param("eperson", admin.getID().toString()))
.andExpect(status().isOk())
@@ -395,6 +396,7 @@ public class AuthorizationRestRepositoryIT extends AbstractControllerIntegration
// verify that it works for normal loggedin users
String epersonToken = getAuthToken(eperson.getEmail(), password);
getClient(epersonToken).perform(get("/api/authz/authorizations/search/object")
.param("projection", "full")
.param("uri", siteUri)
.param("eperson", eperson.getID().toString()))
.andExpect(status().isOk())
@@ -427,6 +429,7 @@ public class AuthorizationRestRepositoryIT extends AbstractControllerIntegration
// verify that it works for administators inspecting other users
getClient(adminToken).perform(get("/api/authz/authorizations/search/object")
.param("projection", "full")
.param("uri", siteUri)
.param("eperson", eperson.getID().toString()))
.andExpect(status().isOk())
@@ -463,6 +466,7 @@ public class AuthorizationRestRepositoryIT extends AbstractControllerIntegration
// verify that it works for anonymous users
getClient().perform(get("/api/authz/authorizations/search/object")
.param("projection", "full")
.param("uri", siteUri))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.authorizations", Matchers.hasSize(greaterThanOrEqualTo(1))))
@@ -493,6 +497,7 @@ public class AuthorizationRestRepositoryIT extends AbstractControllerIntegration
// verify that it works for administrators inspecting anonymous users
getClient(adminToken).perform(get("/api/authz/authorizations/search/object")
.param("projection", "full")
.param("uri", siteUri))
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.authorizations", Matchers.hasSize(greaterThanOrEqualTo(1))))