mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Small refactor
This commit is contained in:
@@ -115,12 +115,12 @@ public class AuthorizeSolrServiceImpl implements AuthorizeSolrService {
|
||||
* @throws SearchServiceException
|
||||
*/
|
||||
@Override
|
||||
public int countAdminAuthorizedCommunity(Context context, String query)
|
||||
public Long countAdminAuthorizedCommunity(Context context, String query)
|
||||
throws SearchServiceException, SQLException {
|
||||
query = formatCustomQuery(query);
|
||||
DiscoverResult discoverResult = getDiscoverResult(context, query + "search.resourcetype:Community",
|
||||
null, null);
|
||||
return (int)discoverResult.getTotalSearchResults();
|
||||
return discoverResult.getTotalSearchResults();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,12 +160,12 @@ public class AuthorizeSolrServiceImpl implements AuthorizeSolrService {
|
||||
* @throws SearchServiceException
|
||||
*/
|
||||
@Override
|
||||
public int countAdminAuthorizedCollection(Context context, String query)
|
||||
public Long countAdminAuthorizedCollection(Context context, String query)
|
||||
throws SearchServiceException, SQLException {
|
||||
query = formatCustomQuery(query);
|
||||
DiscoverResult discoverResult = getDiscoverResult(context, query + "search.resourcetype:Collection",
|
||||
null, null);
|
||||
return (int)discoverResult.getTotalSearchResults();
|
||||
return discoverResult.getTotalSearchResults();
|
||||
}
|
||||
|
||||
private boolean performCheck(Context context, String query) throws SQLException {
|
||||
|
@@ -70,7 +70,7 @@ public interface AuthorizeSolrService {
|
||||
* @throws SearchServiceException
|
||||
* @throws SQLException
|
||||
*/
|
||||
int countAdminAuthorizedCommunity(Context context, String query)
|
||||
Long countAdminAuthorizedCommunity(Context context, String query)
|
||||
throws SearchServiceException, SQLException;
|
||||
|
||||
/**
|
||||
@@ -96,6 +96,6 @@ public interface AuthorizeSolrService {
|
||||
* @throws SearchServiceException
|
||||
* @throws SQLException
|
||||
*/
|
||||
int countAdminAuthorizedCollection(Context context, String query)
|
||||
Long countAdminAuthorizedCollection(Context context, String query)
|
||||
throws SearchServiceException, SQLException;
|
||||
}
|
||||
|
@@ -9,8 +9,6 @@ package org.dspace.app.rest.authorization.impl;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dspace.app.rest.authorization.AuthorizationFeature;
|
||||
import org.dspace.app.rest.authorization.AuthorizationFeatureDocumentation;
|
||||
import org.dspace.app.rest.model.BaseObjectRest;
|
||||
@@ -32,8 +30,6 @@ import org.springframework.stereotype.Component;
|
||||
description = "It can be used to verify if the current user is admin of any community in the site")
|
||||
public class CommunityAdminFeature implements AuthorizationFeature {
|
||||
|
||||
private static Logger log = LogManager.getLogger(CommunityAdminFeature.class);
|
||||
|
||||
public final static String NAME = "isCommunityAdmin";
|
||||
|
||||
@Autowired
|
||||
|
@@ -212,7 +212,7 @@ public class CollectionRestRepository extends DSpaceObjectRestRepository<Collect
|
||||
List<Collection> collections = authorizeSolrService.findAdminAuthorizedCollection(context, query,
|
||||
Math.toIntExact(pageable.getOffset()),
|
||||
Math.toIntExact(pageable.getPageSize()));
|
||||
int tot = authorizeSolrService.countAdminAuthorizedCollection(context, query);
|
||||
Long tot = authorizeSolrService.countAdminAuthorizedCollection(context, query);
|
||||
return converter.toRestPage(collections, pageable, tot , utils.obtainProjection());
|
||||
} catch (SearchServiceException | SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
|
@@ -216,7 +216,7 @@ public class CommunityRestRepository extends DSpaceObjectRestRepository<Communit
|
||||
List<Community> communities = authorizeSolrService.findAdminAuthorizedCommunity(context, query,
|
||||
Math.toIntExact(pageable.getOffset()),
|
||||
Math.toIntExact(pageable.getPageSize()));
|
||||
int tot = authorizeSolrService.countAdminAuthorizedCommunity(context, query);
|
||||
Long tot = authorizeSolrService.countAdminAuthorizedCommunity(context, query);
|
||||
return converter.toRestPage(communities, pageable, tot , utils.obtainProjection());
|
||||
} catch (SearchServiceException | SQLException e) {
|
||||
throw new RuntimeException(e.getMessage(), e);
|
||||
|
Reference in New Issue
Block a user