mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 14:03:17 +00:00
[DS-4287] Refactoring the IndexableObject & SolrServiceImpl: Additional comments, some more narrowing of generics, additional error catching & cleaner way to resolve permissions
This commit is contained in:
@@ -29,6 +29,10 @@ public interface IndexableObject<T extends ReloadableEntity, PK extends Serializ
|
|||||||
*/
|
*/
|
||||||
String getType();
|
String getType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the identifier of this indexableObject, this will be the identifier of the object in the database
|
||||||
|
* @return for a DSpaceObject a uuid will be returned, for a tasks or workflow items an integer will be returned
|
||||||
|
*/
|
||||||
PK getID();
|
PK getID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -21,7 +21,7 @@ import org.dspace.discovery.indexobject.factory.DSpaceObjectIndexFactory;
|
|||||||
* Factory implementation for indexing/retrieving DSpaceObjects in the search core
|
* Factory implementation for indexing/retrieving DSpaceObjects in the search core
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
*/
|
*/
|
||||||
public abstract class DSpaceObjectIndexFactoryImpl<T extends IndexableDSpaceObject, S>
|
public abstract class DSpaceObjectIndexFactoryImpl<T extends IndexableDSpaceObject, S extends DSpaceObject>
|
||||||
extends IndexFactoryImpl<T, S> implements DSpaceObjectIndexFactory<T, S> {
|
extends IndexFactoryImpl<T, S> implements DSpaceObjectIndexFactory<T, S> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -190,7 +190,4 @@ public abstract class IndexFactoryImpl<T extends IndexableObject, S> implements
|
|||||||
public void deleteAll() throws IOException, SolrServerException {
|
public void deleteAll() throws IOException, SolrServerException {
|
||||||
solrSearchCore.getSolr().deleteByQuery(SearchUtils.RESOURCE_TYPE_FIELD + ":" + getType());
|
solrSearchCore.getSolr().deleteByQuery(SearchUtils.RESOURCE_TYPE_FIELD + ":" + getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract List getIndexableObjects(Context context, S object) throws SQLException;
|
|
||||||
}
|
}
|
@@ -26,8 +26,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
* Factory implementation for indexing/retrieving InProgressSubmissions in the search core
|
* Factory implementation for indexing/retrieving InProgressSubmissions in the search core
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
*/
|
*/
|
||||||
public abstract class InprogressSubmissionIndexFactoryImpl<T extends IndexableInProgressSubmission, S>
|
public abstract class InprogressSubmissionIndexFactoryImpl
|
||||||
extends IndexFactoryImpl<T, S> implements InprogressSubmissionIndexFactory<T, S> {
|
<T extends IndexableInProgressSubmission, S extends InProgressSubmission> extends IndexFactoryImpl<T, S>
|
||||||
|
implements InprogressSubmissionIndexFactory<T, S> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected CollectionIndexFactory indexableCollectionService;
|
protected CollectionIndexFactory indexableCollectionService;
|
||||||
|
@@ -41,6 +41,7 @@ import org.dspace.content.authority.service.MetadataAuthorityService;
|
|||||||
import org.dspace.content.service.ItemService;
|
import org.dspace.content.service.ItemService;
|
||||||
import org.dspace.content.service.WorkspaceItemService;
|
import org.dspace.content.service.WorkspaceItemService;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
|
import org.dspace.core.LogManager;
|
||||||
import org.dspace.discovery.FullTextContentStreams;
|
import org.dspace.discovery.FullTextContentStreams;
|
||||||
import org.dspace.discovery.IndexableObject;
|
import org.dspace.discovery.IndexableObject;
|
||||||
import org.dspace.discovery.SearchUtils;
|
import org.dspace.discovery.SearchUtils;
|
||||||
@@ -614,7 +615,8 @@ public class ItemIndexFactoryImpl extends DSpaceObjectIndexFactoryImpl<Indexable
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(LogManager.getHeader(context, "item_metadata_discovery_error",
|
||||||
|
"Item identifier: " + item.getID()), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -636,7 +638,8 @@ public class ItemIndexFactoryImpl extends DSpaceObjectIndexFactoryImpl<Indexable
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(LogManager.getHeader(context, "item_publication_group_discovery_error",
|
||||||
|
"Item identifier: " + item.getID()), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.discovery.indexobject.IndexableDSpaceObject;
|
import org.dspace.discovery.indexobject.IndexableDSpaceObject;
|
||||||
|
|
||||||
@@ -19,7 +20,8 @@ import org.dspace.discovery.indexobject.IndexableDSpaceObject;
|
|||||||
*
|
*
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
*/
|
*/
|
||||||
public interface DSpaceObjectIndexFactory<T extends IndexableDSpaceObject, S> extends IndexFactory<T, S> {
|
public interface DSpaceObjectIndexFactory<T extends IndexableDSpaceObject, S extends DSpaceObject>
|
||||||
|
extends IndexFactory<T, S> {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -91,9 +91,9 @@ public interface IndexFactory<T extends IndexableObject, S> {
|
|||||||
Optional<T> findIndexableObject(Context context, String id) throws SQLException;
|
Optional<T> findIndexableObject(Context context, String id) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine whether the class can handle the object
|
* Determine whether the class can handle the factory implementation
|
||||||
* @param object The object which should be handle
|
* @param object The object which we want to check
|
||||||
* @return True if the class can handle the given object. False if it doesn't.
|
* @return True if the factory implementation can handle the given object. False if it doesn't.
|
||||||
*/
|
*/
|
||||||
boolean supports(Object object);
|
boolean supports(Object object);
|
||||||
|
|
||||||
|
@@ -19,7 +19,8 @@ import org.dspace.discovery.indexobject.IndexableInProgressSubmission;
|
|||||||
*
|
*
|
||||||
* @author Kevin Van de Velde (kevin at atmire dot com)
|
* @author Kevin Van de Velde (kevin at atmire dot com)
|
||||||
*/
|
*/
|
||||||
public interface InprogressSubmissionIndexFactory<T extends IndexableInProgressSubmission, S>
|
public interface InprogressSubmissionIndexFactory<T extends IndexableInProgressSubmission,
|
||||||
|
S extends InProgressSubmission>
|
||||||
extends IndexFactory<T, S> {
|
extends IndexFactory<T, S> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,6 +11,7 @@ import java.io.Serializable;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.dspace.app.rest.model.ClaimedTaskRest;
|
||||||
import org.dspace.app.rest.utils.ContextUtil;
|
import org.dspace.app.rest.utils.ContextUtil;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.eperson.EPerson;
|
import org.dspace.eperson.EPerson;
|
||||||
@@ -49,7 +50,7 @@ public class ClaimedTaskRestPermissionEvaluatorPlugin extends RestObjectPermissi
|
|||||||
public boolean hasDSpacePermission(Authentication authentication, Serializable targetId,
|
public boolean hasDSpacePermission(Authentication authentication, Serializable targetId,
|
||||||
String targetType, DSpaceRestPermission permission) {
|
String targetType, DSpaceRestPermission permission) {
|
||||||
|
|
||||||
if (!StringUtils.equals("CLAIMEDTASK", targetType)) {
|
if (!StringUtils.equalsIgnoreCase(ClaimedTaskRest.NAME, targetType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@ import java.io.Serializable;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.dspace.app.rest.model.PoolTaskRest;
|
||||||
import org.dspace.app.rest.utils.ContextUtil;
|
import org.dspace.app.rest.utils.ContextUtil;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -51,7 +52,7 @@ public class PoolTaskRestPermissionEvaluatorPlugin extends RestObjectPermissionE
|
|||||||
public boolean hasDSpacePermission(Authentication authentication, Serializable targetId,
|
public boolean hasDSpacePermission(Authentication authentication, Serializable targetId,
|
||||||
String targetType, DSpaceRestPermission permission) {
|
String targetType, DSpaceRestPermission permission) {
|
||||||
|
|
||||||
if (!StringUtils.equals("POOLTASK", targetType)) {
|
if (!StringUtils.equalsIgnoreCase(PoolTaskRest.NAME, targetType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@ import java.io.Serializable;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.dspace.app.rest.model.WorkflowItemRest;
|
||||||
import org.dspace.app.rest.utils.ContextUtil;
|
import org.dspace.app.rest.utils.ContextUtil;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
@@ -62,7 +63,7 @@ public class WorkflowRestPermissionEvaluatorPlugin extends RestObjectPermissionE
|
|||||||
//This plugin currently only evaluates READ access
|
//This plugin currently only evaluates READ access
|
||||||
DSpaceRestPermission restPermission = DSpaceRestPermission.convert(permission);
|
DSpaceRestPermission restPermission = DSpaceRestPermission.convert(permission);
|
||||||
if (!DSpaceRestPermission.READ.equals(restPermission)
|
if (!DSpaceRestPermission.READ.equals(restPermission)
|
||||||
|| !StringUtils.equals(targetType, "WORKFLOWITEM")) {
|
|| !StringUtils.equals(WorkflowItemRest.NAME, targetType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user