mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-10 11:33:11 +00:00
Merge pull request #543 from peterdietz/DS-740-public-thumbnails
DS-740 Public derivative thumbnails of restricted original bitstreams
This commit is contained in:
@@ -25,6 +25,7 @@ import org.apache.commons.cli.Options;
|
|||||||
import org.apache.commons.cli.PosixParser;
|
import org.apache.commons.cli.PosixParser;
|
||||||
|
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.authorize.AuthorizeManager;
|
import org.dspace.authorize.AuthorizeManager;
|
||||||
import org.dspace.content.Bitstream;
|
import org.dspace.content.Bitstream;
|
||||||
import org.dspace.content.BitstreamFormat;
|
import org.dspace.content.BitstreamFormat;
|
||||||
@@ -40,6 +41,7 @@ import org.dspace.core.Constants;
|
|||||||
import org.dspace.core.Context;
|
import org.dspace.core.Context;
|
||||||
import org.dspace.core.PluginManager;
|
import org.dspace.core.PluginManager;
|
||||||
import org.dspace.core.SelfNamedPlugin;
|
import org.dspace.core.SelfNamedPlugin;
|
||||||
|
import org.dspace.eperson.Group;
|
||||||
import org.dspace.handle.HandleManager;
|
import org.dspace.handle.HandleManager;
|
||||||
import org.dspace.search.DSIndexer;
|
import org.dspace.search.DSIndexer;
|
||||||
|
|
||||||
@@ -54,6 +56,8 @@ import org.dspace.search.DSIndexer;
|
|||||||
*/
|
*/
|
||||||
public class MediaFilterManager
|
public class MediaFilterManager
|
||||||
{
|
{
|
||||||
|
private static Logger log = Logger.getLogger(MediaFilterManager.class);
|
||||||
|
|
||||||
//key (in dspace.cfg) which lists all enabled filters by name
|
//key (in dspace.cfg) which lists all enabled filters by name
|
||||||
public static final String MEDIA_FILTER_PLUGINS_KEY = "filter.plugins";
|
public static final String MEDIA_FILTER_PLUGINS_KEY = "filter.plugins";
|
||||||
|
|
||||||
@@ -85,10 +89,23 @@ public class MediaFilterManager
|
|||||||
|
|
||||||
private static List<String> skipList = null; //list of identifiers to skip during processing
|
private static List<String> skipList = null; //list of identifiers to skip during processing
|
||||||
|
|
||||||
|
private static List<String> publicFiltersClasses = null;
|
||||||
|
|
||||||
//separator in filterFormats Map between a filter class name and a plugin name,
|
//separator in filterFormats Map between a filter class name and a plugin name,
|
||||||
//for MediaFilters which extend SelfNamedPlugin (\034 is "file separator" char)
|
//for MediaFilters which extend SelfNamedPlugin (\034 is "file separator" char)
|
||||||
public static final String FILTER_PLUGIN_SEPARATOR = "\034";
|
public static final String FILTER_PLUGIN_SEPARATOR = "\034";
|
||||||
|
|
||||||
|
static {
|
||||||
|
String publicPermissionFilters = ConfigurationManager.getProperty("filter.org.dspace.app.mediafilter.publicPermission");
|
||||||
|
if(publicPermissionFilters != null) {
|
||||||
|
String[] publicPermisionFiltersArray = publicPermissionFilters.split(",");
|
||||||
|
publicFiltersClasses = new ArrayList<String>();
|
||||||
|
for(String filter : publicPermisionFiltersArray) {
|
||||||
|
publicFiltersClasses.add(filter.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] argv) throws Exception
|
public static void main(String[] argv) throws Exception
|
||||||
{
|
{
|
||||||
// set headless for non-gui workstations
|
// set headless for non-gui workstations
|
||||||
@@ -776,10 +793,19 @@ public class MediaFilterManager
|
|||||||
b.setFormat(bf);
|
b.setFormat(bf);
|
||||||
b.update();
|
b.update();
|
||||||
|
|
||||||
//Inherit policies from the source bitstream
|
//Set permissions on the derivative bitstream
|
||||||
//(first remove any existing policies)
|
//- First remove any existing policies
|
||||||
AuthorizeManager.removeAllPolicies(c, b);
|
AuthorizeManager.removeAllPolicies(c, b);
|
||||||
AuthorizeManager.inheritPolicies(c, source, b);
|
|
||||||
|
//- Determine if this is a public-derivative format
|
||||||
|
if(publicFiltersClasses.contains(formatFilter.getClass().getSimpleName())) {
|
||||||
|
//- Set derivative bitstream to be publicly accessible
|
||||||
|
Group anonymous = Group.find(c, 0);
|
||||||
|
AuthorizeManager.addPolicy(c, b, Constants.READ, anonymous);
|
||||||
|
} else {
|
||||||
|
//- Inherit policies from the source bitstream
|
||||||
|
AuthorizeManager.inheritPolicies(c, source, b);
|
||||||
|
}
|
||||||
|
|
||||||
// fixme - set date?
|
// fixme - set date?
|
||||||
// we are overwriting, so remove old bitstream
|
// we are overwriting, so remove old bitstream
|
||||||
|
@@ -454,6 +454,11 @@ filter.org.dspace.app.mediafilter.PowerPointFilter.inputFormats = Microsoft Powe
|
|||||||
filter.org.dspace.app.mediafilter.JPEGFilter.inputFormats = BMP, GIF, JPEG, image/png
|
filter.org.dspace.app.mediafilter.JPEGFilter.inputFormats = BMP, GIF, JPEG, image/png
|
||||||
filter.org.dspace.app.mediafilter.BrandedPreviewJPEGFilter.inputFormats = BMP, GIF, JPEG, image/png
|
filter.org.dspace.app.mediafilter.BrandedPreviewJPEGFilter.inputFormats = BMP, GIF, JPEG, image/png
|
||||||
|
|
||||||
|
#Publicly accessible thumbnails of restricted content.
|
||||||
|
#List the MediaFilter name's that would get publicly accessible permissions
|
||||||
|
#Any media filters not listed will instead inherit the permissions of the parent bitstream
|
||||||
|
#filter.org.dspace.app.mediafilter.publicPermission = JPEGFilter, XPDF2Thumbnail
|
||||||
|
|
||||||
#Custom settings for PDFFilter
|
#Custom settings for PDFFilter
|
||||||
# If true, all PDF extractions are written to temp files as they are indexed...this
|
# If true, all PDF extractions are written to temp files as they are indexed...this
|
||||||
# is slower, but helps ensure that PDFBox software DSpace uses doesn't eat up
|
# is slower, but helps ensure that PDFBox software DSpace uses doesn't eat up
|
||||||
|
Reference in New Issue
Block a user