Package org.dspace.app.mediafilter
Class MediaFilterServiceImpl
- java.lang.Object
-
- org.dspace.app.mediafilter.MediaFilterServiceImpl
-
- All Implemented Interfaces:
MediaFilterService,org.springframework.beans.factory.InitializingBean
public class MediaFilterServiceImpl extends Object implements MediaFilterService, org.springframework.beans.factory.InitializingBean
MediaFilterManager is the class that invokes the media/format filters over the repository's content. A few command line flags affect the operation of the MFM: -v verbose outputs all extracted text to STDOUT; -f force forces all bitstreams to be processed, even if they have been before; -n noindex does not recreate index after processing bitstreams; -i [identifier] limits processing scope to a community, collection or item; and -m [max] limits processing to a maximum number of items.
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthorizeServiceauthorizeServiceprotected BitstreamFormatServicebitstreamFormatServiceprotected BitstreamServicebitstreamServiceprotected BundleServicebundleServiceprotected CollectionServicecollectionServiceprotected CommunityServicecommunityServiceprotected ConfigurationServiceconfigurationServiceprotected ItemcurrentItemprotected List<FormatFilter>filterClassesprotected Map<String,List<String>>filterFormatsprotected GroupServicegroupServiceprotected booleanisForceprotected booleanisQuietprotected booleanisVerboseprotected ItemServiceitemServiceprotected intmax2Processprotected intprocessedprotected List<String>publicFiltersClassesprotected List<String>skipList-
Fields inherited from interface org.dspace.app.mediafilter.service.MediaFilterService
FILTER_PLUGIN_SEPARATOR
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMediaFilterServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()voidapplyFiltersAllItems(Context context)voidapplyFiltersCollection(Context context, Collection collection)voidapplyFiltersCommunity(Context context, Community community)voidapplyFiltersItem(Context c, Item item)booleanfilterBitstream(Context context, Item myItem, Bitstream myBitstream)Attempt to filter a bitstream.booleanfilterItem(Context context, Item myItem)Iterate through the item's bitstreams in the ORIGINAL bundle, applying filters if possible.ItemgetCurrentItem()Return the item that is currently being processed/filtered by the MediaFilterManager.booleaninSkipList(String identifier)Check whether or not to skip processing the given identifier.booleanprocessBitstream(Context context, Item item, Bitstream source, FormatFilter formatFilter)A utility class that calls the virtual methods from the current MediaFilter class.voidsetFilterClasses(List<FormatFilter> filterClasses)voidsetFilterFormats(Map<String,List<String>> filterFormats)voidsetForce(boolean isForce)voidsetMax2Process(int max2Process)voidsetQuiet(boolean isQuiet)voidsetSkipList(List<String> skipList)voidsetVerbose(boolean isVerbose)
-
-
-
Field Detail
-
authorizeService
@Autowired(required=true) protected AuthorizeService authorizeService
-
bitstreamFormatService
@Autowired(required=true) protected BitstreamFormatService bitstreamFormatService
-
bitstreamService
@Autowired(required=true) protected BitstreamService bitstreamService
-
bundleService
@Autowired(required=true) protected BundleService bundleService
-
collectionService
@Autowired(required=true) protected CollectionService collectionService
-
communityService
@Autowired(required=true) protected CommunityService communityService
-
groupService
@Autowired(required=true) protected GroupService groupService
-
itemService
@Autowired(required=true) protected ItemService itemService
-
configurationService
@Autowired(required=true) protected ConfigurationService configurationService
-
max2Process
protected int max2Process
-
processed
protected int processed
-
currentItem
protected Item currentItem
-
filterClasses
protected List<FormatFilter> filterClasses
-
isVerbose
protected boolean isVerbose
-
isQuiet
protected boolean isQuiet
-
isForce
protected boolean isForce
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
applyFiltersAllItems
public void applyFiltersAllItems(Context context) throws Exception
- Specified by:
applyFiltersAllItemsin interfaceMediaFilterService- Throws:
Exception
-
applyFiltersCommunity
public void applyFiltersCommunity(Context context, Community community) throws Exception
- Specified by:
applyFiltersCommunityin interfaceMediaFilterService- Throws:
Exception
-
applyFiltersCollection
public void applyFiltersCollection(Context context, Collection collection) throws Exception
- Specified by:
applyFiltersCollectionin interfaceMediaFilterService- Throws:
Exception
-
applyFiltersItem
public void applyFiltersItem(Context c, Item item) throws Exception
- Specified by:
applyFiltersItemin interfaceMediaFilterService- Throws:
Exception
-
filterItem
public boolean filterItem(Context context, Item myItem) throws Exception
Description copied from interface:MediaFilterServiceIterate through the item's bitstreams in the ORIGINAL bundle, applying filters if possible.- Specified by:
filterItemin interfaceMediaFilterService- Parameters:
context- contextmyItem- item- Returns:
- true if any bitstreams processed, false if none
- Throws:
Exception- if error
-
filterBitstream
public boolean filterBitstream(Context context, Item myItem, Bitstream myBitstream) throws Exception
Description copied from interface:MediaFilterServiceAttempt to filter a bitstream. An exception will be thrown if the media filter class cannot be instantiated. Exceptions from filtering will be logged to STDOUT and swallowed.- Specified by:
filterBitstreamin interfaceMediaFilterService- Parameters:
context- contextmyItem- itemmyBitstream- bitstream- Returns:
- true if bitstream processed, false if no applicable filter or already processed
- Throws:
Exception- if error
-
processBitstream
public boolean processBitstream(Context context, Item item, Bitstream source, FormatFilter formatFilter) throws Exception
Description copied from interface:MediaFilterServiceA utility class that calls the virtual methods from the current MediaFilter class. It scans the bitstreams in an item, and decides if a bitstream has already been filtered, and if not or if overWrite is set, invokes the filter.- Specified by:
processBitstreamin interfaceMediaFilterService- Parameters:
context- contextitem- item containing bitstream to processsource- source bitstream to processformatFilter- FormatFilter to perform filtering- Returns:
- true if new rendition is created, false if rendition already exists and overWrite is not set
- Throws:
Exception- if error occurs
-
getCurrentItem
public Item getCurrentItem()
Description copied from interface:MediaFilterServiceReturn the item that is currently being processed/filtered by the MediaFilterManager.This allows FormatFilters to retrieve the Item object in case they need access to item-level information for their format transformations/conversions.
- Specified by:
getCurrentItemin interfaceMediaFilterService- Returns:
- current Item being processed by MediaFilterManager
-
inSkipList
public boolean inSkipList(String identifier)
Description copied from interface:MediaFilterServiceCheck whether or not to skip processing the given identifier.- Specified by:
inSkipListin interfaceMediaFilterService- Parameters:
identifier- identifier (handle) of a community, collection or item- Returns:
- true if this community, collection or item should be skipped during processing. Otherwise, return false.
-
setVerbose
public void setVerbose(boolean isVerbose)
- Specified by:
setVerbosein interfaceMediaFilterService
-
setQuiet
public void setQuiet(boolean isQuiet)
- Specified by:
setQuietin interfaceMediaFilterService
-
setForce
public void setForce(boolean isForce)
- Specified by:
setForcein interfaceMediaFilterService
-
setMax2Process
public void setMax2Process(int max2Process)
- Specified by:
setMax2Processin interfaceMediaFilterService
-
setFilterClasses
public void setFilterClasses(List<FormatFilter> filterClasses)
- Specified by:
setFilterClassesin interfaceMediaFilterService
-
setSkipList
public void setSkipList(List<String> skipList)
- Specified by:
setSkipListin interfaceMediaFilterService
-
setFilterFormats
public void setFilterFormats(Map<String,List<String>> filterFormats)
- Specified by:
setFilterFormatsin interfaceMediaFilterService
-
-