mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 10:04:21 +00:00
Merge pull request #7973 from abollini/performance-improvements
Performance improvements
This commit is contained in:
@@ -250,13 +250,8 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
||||
if (e != null) {
|
||||
userToCheck = e;
|
||||
|
||||
// perform isAdmin check to see
|
||||
// if user is an Admin on this object
|
||||
DSpaceObject adminObject = useInheritance ? serviceFactory.getDSpaceObjectService(o)
|
||||
.getAdminObject(c, o, action) : null;
|
||||
|
||||
if (isAdmin(c, e, adminObject)) {
|
||||
c.cacheAuthorizedAction(o, action, e, true, null);
|
||||
// perform immediately isAdmin check as this is cheap
|
||||
if (isAdmin(c, e)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -280,13 +275,15 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
||||
ignoreCustomPolicies = !isAnyItemInstalled(c, Arrays.asList(((Bundle) o)));
|
||||
}
|
||||
if (o instanceof Item) {
|
||||
if (workspaceItemService.findByItem(c, (Item) o) != null ||
|
||||
workflowItemService.findByItem(c, (Item) o) != null) {
|
||||
// the isArchived check is fast and would exclude the possibility that the item
|
||||
// is a workspace or workflow without further queries
|
||||
if (!((Item) o).isArchived() &&
|
||||
(workspaceItemService.findByItem(c, (Item) o) != null ||
|
||||
workflowItemService.findByItem(c, (Item) o) != null)) {
|
||||
ignoreCustomPolicies = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (ResourcePolicy rp : getPoliciesActionFilter(c, o, action)) {
|
||||
|
||||
if (ignoreCustomPolicies
|
||||
@@ -322,6 +319,16 @@ public class AuthorizeServiceImpl implements AuthorizeService {
|
||||
}
|
||||
}
|
||||
|
||||
if (e != null) {
|
||||
// if user is an Admin on this object
|
||||
DSpaceObject adminObject = useInheritance ? serviceFactory.getDSpaceObjectService(o)
|
||||
.getAdminObject(c, o, action) : null;
|
||||
|
||||
if (isAdmin(c, e, adminObject)) {
|
||||
c.cacheAuthorizedAction(o, action, e, true, null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// default authorization is denial
|
||||
c.cacheAuthorizedAction(o, action, e, false, null);
|
||||
return false;
|
||||
|
@@ -53,8 +53,7 @@ public class AdminRestPermissionEvaluatorPlugin extends RestObjectPermissionEval
|
||||
EPerson ePerson = null;
|
||||
|
||||
try {
|
||||
ePerson = ePersonService.findByEmail(context, (String) authentication.getPrincipal());
|
||||
|
||||
ePerson = context.getCurrentUser();
|
||||
if (ePerson != null) {
|
||||
|
||||
//Check if user is a repository admin
|
||||
|
@@ -76,7 +76,7 @@ public class AuthorizeServicePermissionEvaluatorPlugin extends RestObjectPermiss
|
||||
return false;
|
||||
}
|
||||
|
||||
ePerson = ePersonService.findByEmail(context, (String) authentication.getPrincipal());
|
||||
ePerson = context.getCurrentUser();
|
||||
|
||||
if (dSpaceObjectService != null && dsoId != null) {
|
||||
DSpaceObject dSpaceObject = dSpaceObjectService.find(context, dsoId);
|
||||
|
Reference in New Issue
Block a user