Package org.dspace.app.util
Class MetadataExposureServiceImpl
- java.lang.Object
-
- org.dspace.app.util.MetadataExposureServiceImpl
-
- All Implemented Interfaces:
MetadataExposureService
public class MetadataExposureServiceImpl extends Object implements MetadataExposureService
Static utility class to manage configuration for exposure (hiding) of certain Item metadata fields. This class answers the question, "is the user allowed to see this metadata field?" Any external interface (UI, OAI-PMH, etc) that disseminates metadata should consult it before disseminating the value of a metadata field. Since the MetadataExposure.isHidden() method gets called in a lot of inner loops, it is important to implement it efficiently, in both time and memory utilization. It computes an answer without consuming ANY memory (e.g. it does not build any temporary Strings) and in close to constant time by use of hash tables. Although most sites will only hide a few fields, we can't predict what the usage will be so it's better to make it scalable. Algorithm is as follows: 1. If a Context is provided and it has a user who is Administrator, always grant access (return false). 2. Return true if field is on the hidden list, false otherwise. The internal maps are populated from DSpace Configuration at the first call, in case the properties are not available in the static context. Configuration Properties: ## hide a single metadata field #metadata.hide.SCHEMA.ELEMENT[.QUALIFIER] = true # example: dc.type metadata.hide.dc.type = true # example: dc.description.provenance metadata.hide.dc.description.provenance = true- Version:
- $Revision: 3734 $
- Author:
- Larry Stone
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthorizeServiceauthorizeServiceprotected StringCONFIG_PREFIXprotected ConfigurationServiceconfigurationServiceprotected Map<String,Map<String,Set<String>>>hiddenElementMapsprotected Map<String,Set<String>>hiddenElementSetsprotected org.apache.logging.log4j.Loggerlog
-
Constructor Summary
Constructors Modifier Constructor Description protectedMetadataExposureServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidinit()Loads maps from configuration unless it's already done.booleanisHidden(Context context, String schema, String element, String qualifier)Returns whether the given metadata field should be exposed (visible).protected booleanisInitialized()Returns whether the maps from configuration have already been loaded into the hiddenElementSets property.
-
-
-
Field Detail
-
log
protected org.apache.logging.log4j.Logger log
-
CONFIG_PREFIX
protected final String CONFIG_PREFIX
- See Also:
- Constant Field Values
-
authorizeService
@Autowired(required=true) protected AuthorizeService authorizeService
-
configurationService
@Autowired(required=true) protected ConfigurationService configurationService
-
-
Method Detail
-
isHidden
public boolean isHidden(Context context, String schema, String element, String qualifier) throws SQLException
Description copied from interface:MetadataExposureServiceReturns whether the given metadata field should be exposed (visible). The metadata field is in the DSpace's DC notation: schema.element.qualifier- Specified by:
isHiddenin interfaceMetadataExposureService- Parameters:
context- DSpace contextschema- metadata field schema (namespace), e.g. "dc"element- metadata field elementqualifier- metadata field qualifier- Returns:
- true (hidden) or false (exposed)
- Throws:
SQLException- if database error
-
isInitialized
protected boolean isInitialized()
Returns whether the maps from configuration have already been loaded into the hiddenElementSets property.- Returns:
- true (initialized) or false (not initialized)
-
init
protected void init()
Loads maps from configuration unless it's already done. The configuration properties are a map starting with the "metadata.hide." prefix followed by schema, element and qualifier separated by dots and the value is true (hidden) or false (exposed).
-
-