Fix more API classes using comma-separated configs (and ensure they all use getArrayProperty)

This commit is contained in:
Tim Donohue
2016-02-25 16:49:14 -06:00
parent f22a9fe6af
commit 9317f341e1
10 changed files with 148 additions and 160 deletions

View File

@@ -14,11 +14,15 @@ import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.content.DSpaceObject;
import org.dspace.content.Item;
import org.dspace.core.*;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.SelfNamedPlugin;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.handle.factory.HandleServiceFactory;
import java.util.*;
import org.dspace.core.factory.CoreServiceFactory;
import org.apache.commons.lang.ArrayUtils;
import org.dspace.services.factory.DSpaceServicesFactory;
/**
* MediaFilterManager is the class that invokes the media/format filters over the
@@ -40,7 +44,6 @@ public class MediaFilterCLITool {
//suffix (in dspace.cfg) for input formats supported by each filter
private static final String INPUT_FORMATS_SUFFIX = "inputFormats";
public static void main(String[] argv) throws Exception
{
// set headless for non-gui workstations
@@ -162,8 +165,7 @@ public class MediaFilterCLITool {
else
{
//retrieve list of all enabled media filter plugins!
String enabledPlugins = ConfigurationManager.getProperty(MEDIA_FILTER_PLUGINS_KEY);
filterNames = enabledPlugins.split(",\\s*");
filterNames = DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty(MEDIA_FILTER_PLUGINS_KEY);
}
MediaFilterService mediaFilterService = MediaFilterServiceFactory.getInstance().getMediaFilterService();
@@ -210,13 +212,14 @@ public class MediaFilterCLITool {
// filter.<class-name>.<plugin-name>.inputFormats
//For other MediaFilters, format of key is:
// filter.<class-name>.inputFormats
String formats = ConfigurationManager.getProperty(
String[] formats =
DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty(
FILTER_PREFIX + "." + filterClassName +
(pluginName!=null ? "." + pluginName : "") +
"." + INPUT_FORMATS_SUFFIX);
//add to internal map of filters to supported formats
if (formats != null)
if (ArrayUtils.isNotEmpty(formats))
{
//For SelfNamedPlugins, map key is:
// <class-name><separator><plugin-name>
@@ -224,7 +227,7 @@ public class MediaFilterCLITool {
// <class-name>
filterFormats.put(filterClassName +
(pluginName!=null ? MediaFilterService.FILTER_PLUGIN_SEPARATOR + pluginName : ""),
Arrays.asList(formats.split(",[\\s]*")));
Arrays.asList(formats));
}
}//end if filter!=null
}//end for

View File

@@ -28,6 +28,7 @@ import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.log4j.Logger;
import org.dspace.content.Collection;
import org.dspace.content.Community;
@@ -36,9 +37,10 @@ import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.CollectionService;
import org.dspace.content.service.CommunityService;
import org.dspace.content.service.ItemService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
/**
* Command-line utility for generating HTML and Sitemaps.org protocol Sitemaps.
@@ -54,6 +56,7 @@ public class GenerateSitemaps
private static final CommunityService communityService = ContentServiceFactory.getInstance().getCommunityService();
private static final CollectionService collectionService = ContentServiceFactory.getInstance().getCollectionService();
private static final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
private static final ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
public static void main(String[] args) throws Exception
{
@@ -157,14 +160,14 @@ public class GenerateSitemaps
public static void generateSitemaps(boolean makeHTMLMap,
boolean makeSitemapOrg) throws SQLException, IOException
{
String sitemapStem = ConfigurationManager.getProperty("dspace.url")
String sitemapStem = configurationService.getProperty("dspace.url")
+ "/sitemap";
String htmlMapStem = ConfigurationManager.getProperty("dspace.url")
String htmlMapStem = configurationService.getProperty("dspace.url")
+ "/htmlmap";
String handleURLStem = ConfigurationManager.getProperty("dspace.url")
String handleURLStem = configurationService.getProperty("dspace.url")
+ "/handle/";
File outputDir = new File(ConfigurationManager.getProperty("sitemap.dir"));
File outputDir = new File(configurationService.getProperty("sitemap.dir"));
if (!outputDir.exists() && !outputDir.mkdir())
{
log.error("Unable to create output directory");
@@ -264,17 +267,10 @@ public class GenerateSitemaps
public static void pingConfiguredSearchEngines()
throws UnsupportedEncodingException
{
String engineURLProp = ConfigurationManager
.getProperty("sitemap.engineurls");
String engineURLs[] = null;
if (engineURLProp != null)
{
engineURLs = engineURLProp.trim().split("\\s*,\\s*");
}
if (engineURLProp == null || engineURLs == null
|| engineURLs.length == 0 || engineURLs[0].trim().equals(""))
String[] engineURLs = configurationService
.getArrayProperty("sitemap.engineurls");
if (ArrayUtils.isEmpty(engineURLs))
{
log.warn("No search engine URLs configured to ping");
return;
@@ -309,17 +305,17 @@ public class GenerateSitemaps
throws MalformedURLException, UnsupportedEncodingException
{
// Set up HTTP proxy
if ((StringUtils.isNotBlank(ConfigurationManager.getProperty("http.proxy.host")))
&& (StringUtils.isNotBlank(ConfigurationManager.getProperty("http.proxy.port"))))
if ((StringUtils.isNotBlank(configurationService.getProperty("http.proxy.host")))
&& (StringUtils.isNotBlank(configurationService.getProperty("http.proxy.port"))))
{
System.setProperty("proxySet", "true");
System.setProperty("proxyHost", ConfigurationManager
System.setProperty("proxyHost", configurationService
.getProperty("http.proxy.host"));
System.getProperty("proxyPort", ConfigurationManager
System.getProperty("proxyPort", configurationService
.getProperty("http.proxy.port"));
}
String sitemapURL = ConfigurationManager.getProperty("dspace.url")
String sitemapURL = configurationService.getProperty("dspace.url")
+ "/sitemap";
URL url = new URL(engineURL + URLEncoder.encode(sitemapURL, "UTF-8"));

View File

@@ -50,6 +50,8 @@ import com.sun.syndication.io.SyndFeedOutput;
import com.sun.syndication.io.FeedException;
import org.apache.log4j.Logger;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
/**
* Invoke ROME library to assemble a generic model of a syndication
@@ -83,38 +85,43 @@ public class SyndicationFeed
protected String defaultTitleField = "dc.title";
protected String defaultAuthorField = "dc.contributor.author";
protected String defaultDateField = "dc.date.issued";
private static String defaultDescriptionFields = "dc.description.abstract, dc.description, dc.title.alternative, dc.title";
private static final String[] defaultDescriptionFields = new String[]{"dc.description.abstract", "dc.description", "dc.title.alternative", "dc.title"};
protected String defaultExternalMedia = "dc.source.uri";
private final ConfigurationService configurationService =
DSpaceServicesFactory.getInstance().getConfigurationService();
// metadata field for Item title in entry:
protected String titleField =
getDefaultedConfiguration("webui.feed.item.title", defaultTitleField);
protected String titleField =
configurationService.getProperty("webui.feed.item.title", defaultTitleField);
// metadata field for Item publication date in entry:
protected String dateField =
getDefaultedConfiguration("webui.feed.item.date", defaultDateField);
protected String dateField =
configurationService.getProperty("webui.feed.item.date", defaultDateField);
// metadata field for Item description in entry:
private static String descriptionFields[] =
getDefaultedConfiguration("webui.feed.item.description", defaultDescriptionFields).split("\\s*,\\s*");
protected String authorField =
getDefaultedConfiguration("webui.feed.item.author", defaultAuthorField);
private static final String descriptionFields[] =
DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty("webui.feed.item.description", defaultDescriptionFields);
protected String authorField =
configurationService.getProperty("webui.feed.item.author", defaultAuthorField);
// metadata field for Podcast external media source url
protected String externalSourceField = getDefaultedConfiguration("webui.feed.podcast.sourceuri", defaultExternalMedia);
protected String externalSourceField =
configurationService.getProperty("webui.feed.podcast.sourceuri", defaultExternalMedia);
// metadata field for Item dc:creator field in entry's DCModule (no default)
protected String dcCreatorField = ConfigurationManager.getProperty("webui.feed.item.dc.creator");
protected String dcCreatorField = configurationService.getProperty("webui.feed.item.dc.creator");
// metadata field for Item dc:date field in entry's DCModule (no default)
protected String dcDateField = ConfigurationManager.getProperty("webui.feed.item.dc.date");
protected String dcDateField = configurationService.getProperty("webui.feed.item.dc.date");
// metadata field for Item dc:author field in entry's DCModule (no default)
protected String dcDescriptionField = ConfigurationManager.getProperty("webui.feed.item.dc.description");
protected String dcDescriptionField = configurationService.getProperty("webui.feed.item.dc.description");
// List of available mimetypes that we'll add to podcast feed. Multiple values separated by commas
protected String podcastableMIMETypes = getDefaultedConfiguration("webui.feed.podcast.mimetypes", "audio/x-mpeg");
protected String[] podcastableMIMETypes =
configurationService.getArrayProperty("webui.feed.podcast.mimetypes", new String[]{"audio/x-mpeg"});
// -------- Instance variables:
@@ -374,7 +381,7 @@ public class SyndicationFeed
List<Bitstream> bits = bunds.get(0).getBitstreams();
for (Bitstream bit : bits) {
String mime = bit.getFormat(context).getMIMEType();
if (podcastableMIMETypes.contains(mime)) {
if (ArrayUtils.contains(podcastableMIMETypes,mime)) {
SyndEnclosure enc = new SyndEnclosureImpl();
enc.setType(bit.getFormat(context).getMIMEType());
enc.setLength(bit.getSize());

View File

@@ -93,7 +93,7 @@ public class IPAuthentication implements AuthenticationMethod
if (nameParts.length == 2)
{
addMatchers(nameParts[1], DSpaceServicesFactory.getInstance().getConfigurationService().getProperty(propName));
addMatchers(nameParts[1], DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty(propName));
}
else
{
@@ -111,11 +111,9 @@ public class IPAuthentication implements AuthenticationMethod
* @param ipRanges
* IP ranges
*/
protected void addMatchers(String groupName, String ipRanges)
protected void addMatchers(String groupName, String[] ipRanges)
{
String[] ranges = ipRanges.split("\\s*,\\s*");
for (String entry : ranges)
for (String entry : ipRanges)
{
try
{

View File

@@ -30,11 +30,11 @@ import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.log4j.Logger;
import org.dspace.authenticate.factory.AuthenticateServiceFactory;
import org.dspace.authenticate.service.AuthenticationService;
import org.dspace.authorize.AuthorizeException;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
import org.dspace.eperson.EPerson;
@@ -42,6 +42,8 @@ import org.dspace.eperson.Group;
import org.dspace.eperson.factory.EPersonServiceFactory;
import org.dspace.eperson.service.EPersonService;
import org.dspace.eperson.service.GroupService;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
/**
* Implicit authentication method that gets credentials from the X.509 client
@@ -118,6 +120,8 @@ public class X509Authentication implements AuthenticationMethod
protected AuthenticationService authenticationService = AuthenticateServiceFactory.getInstance().getAuthenticationService();
protected EPersonService ePersonService = EPersonServiceFactory.getInstance().getEPersonService();
protected GroupService groupService = EPersonServiceFactory.getInstance().getGroupService();
protected ConfigurationService configurationService =
DSpaceServicesFactory.getInstance().getConfigurationService();
/**
@@ -127,21 +131,23 @@ public class X509Authentication implements AuthenticationMethod
*/
static
{
ConfigurationService configurationService =
DSpaceServicesFactory.getInstance().getConfigurationService();
/*
* allow identification of alternative entry points for certificate
* authentication when selected by the user rather than implicitly.
*/
loginPageTitle = ConfigurationManager
.getProperty("authentication-x509", "chooser.title.key");
loginPageURL = ConfigurationManager
.getProperty("authentication-x509", "chooser.uri");
loginPageTitle = configurationService
.getProperty("authentication-x509.chooser.title.key");
loginPageURL = configurationService
.getProperty("authentication-x509.hooser.uri");
String keystorePath = ConfigurationManager
.getProperty("authentication-x509", "keystore.path");
String keystorePassword = ConfigurationManager
.getProperty("authentication-x509", "keystore.password");
String caCertPath = ConfigurationManager
.getProperty("authentication-x509", "ca.cert");
String keystorePath = configurationService
.getProperty("authentication-x509.keystore.path");
String keystorePassword = configurationService
.getProperty("authentication-x509.keystore.password");
String caCertPath = configurationService
.getProperty("authentication-x509.ca.cert");
// First look for keystore full of trusted certs.
if (keystorePath != null)
@@ -386,8 +392,8 @@ public class X509Authentication implements AuthenticationMethod
public boolean canSelfRegister(Context context, HttpServletRequest request,
String username) throws SQLException
{
return ConfigurationManager
.getBooleanProperty("authentication-x509", "autoregister");
return configurationService
.getBooleanProperty("authentication-x509.autoregister");
}
/**
@@ -428,17 +434,14 @@ public class X509Authentication implements AuthenticationMethod
{
List<String> groupNames = new ArrayList<String>();
String x509GroupConfig = null;
x509GroupConfig = ConfigurationManager
.getProperty("authentication-x509", "groups");
String[] groups = configurationService
.getArrayProperty("authentication-x509.groups");
if (null != x509GroupConfig && !"".equals(x509GroupConfig))
if(ArrayUtils.isNotEmpty(groups))
{
String[] groups = x509GroupConfig.split("\\s*,\\s*");
for (int i = 0; i < groups.length; i++)
for (String group : groups)
{
groupNames.add(groups[i].trim());
groupNames.add(group.trim());
}
}

View File

@@ -69,7 +69,6 @@ import org.dspace.content.crosswalk.StreamDisseminationCrosswalk;
import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.BitstreamService;
import org.dspace.content.service.SiteService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.LogManager;
@@ -78,6 +77,8 @@ import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import org.dspace.license.factory.LicenseServiceFactory;
import org.dspace.license.service.CreativeCommonsService;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.jdom.Element;
import org.jdom.Namespace;
import org.jdom.output.Format;
@@ -128,6 +129,7 @@ public abstract class AbstractMETSDisseminator
protected final BitstreamService bitstreamService = ContentServiceFactory.getInstance().getBitstreamService();
protected final SiteService siteService = ContentServiceFactory.getInstance().getSiteService();
protected final CreativeCommonsService creativeCommonsService = LicenseServiceFactory.getInstance().getCreativeCommonsService();
protected final ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
// for gensym()
protected int idCounter = 1;
@@ -1498,7 +1500,7 @@ public abstract class AbstractMETSDisseminator
}
if (handle != null)
{
return ConfigurationManager
return configurationService
.getProperty("dspace.url")
+ "/bitstream/"
+ handle
@@ -1510,7 +1512,7 @@ public abstract class AbstractMETSDisseminator
else
{ //no Handle assigned, so persistent(-ish) URI for bitstream is
// Format: {site-base-url}/retrieve/{bitstream-internal-id}
return ConfigurationManager
return configurationService
.getProperty("dspace.url")
+ "/retrieve/"
+ String.valueOf(bitstream.getID());

View File

@@ -25,7 +25,6 @@ import org.dspace.content.Collection;
import org.dspace.content.Community;
import org.dspace.content.crosswalk.CrosswalkException;
import org.dspace.core.Constants;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import edu.harvard.hul.ois.mets.Agent;
@@ -41,7 +40,10 @@ import edu.harvard.hul.ois.mets.Type;
import edu.harvard.hul.ois.mets.helper.MetsException;
import edu.harvard.hul.ois.mets.helper.PCData;
import java.util.Date;
import org.apache.commons.lang.ArrayUtils;
import org.dspace.core.Utils;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
/**
* Subclass of the METS packager framework to disseminate a DSpace
@@ -117,6 +119,10 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator
protected List<String> filterBundles = new ArrayList<String>();
// Whether 'filterBundles' specifies an exclusion list (default) or inclusion list.
protected boolean excludeBundles = true;
protected ConfigurationService configurationService =
DSpaceServicesFactory.getInstance().getConfigurationService();
@Override
public void disseminate(Context context, DSpaceObject dso,
@@ -257,17 +263,14 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator
public String [] getDmdTypes(Context context, DSpaceObject dso, PackageParameters params)
throws SQLException, IOException, AuthorizeException
{
String dmdTypes = ConfigurationManager.getProperty("aip.disseminate.dmd");
if (dmdTypes == null)
String[] dmdTypes = configurationService.getArrayProperty("aip.disseminate.dmd");
if (ArrayUtils.isEmpty(dmdTypes))
{
String result[] = new String[2];
result[0] = "MODS";
result[1] = "DIM";
return result;
return new String[] { "MODS","DIM"};
}
else
{
return dmdTypes.split("\\s*,\\s*");
return dmdTypes;
}
}
@@ -289,14 +292,12 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator
public String[] getTechMdTypes(Context context, DSpaceObject dso, PackageParameters params)
throws SQLException, IOException, AuthorizeException
{
String techTypes = ConfigurationManager.getProperty("aip.disseminate.techMD");
if (techTypes == null)
String[] techTypes = configurationService.getArrayProperty("aip.disseminate.techMD");
if (ArrayUtils.isEmpty(techTypes))
{
if (dso.getType() == Constants.BITSTREAM)
{
String result[] = new String[1];
result[0] = "PREMIS";
return result;
return new String[]{"PREMIS"};
}
else
{
@@ -305,7 +306,7 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator
}
else
{
return techTypes.split("\\s*,\\s*");
return techTypes;
}
}
@@ -331,16 +332,14 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator
public String[] getSourceMdTypes(Context context, DSpaceObject dso, PackageParameters params)
throws SQLException, IOException, AuthorizeException
{
String sourceTypes = ConfigurationManager.getProperty("aip.disseminate.sourceMD");
if (sourceTypes == null)
String[] sourceTypes = configurationService.getArrayProperty("aip.disseminate.sourceMD");
if (ArrayUtils.isEmpty(sourceTypes))
{
String result[] = new String[1];
result[0] = "AIP-TECHMD";
return result;
return new String[] {"AIP-TECHMD"};
}
else
{
return sourceTypes.split("\\s*,\\s*");
return sourceTypes;
}
}
@@ -362,14 +361,14 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator
public String[] getDigiprovMdTypes(Context context, DSpaceObject dso, PackageParameters params)
throws SQLException, IOException, AuthorizeException
{
String dpTypes = ConfigurationManager.getProperty("aip.disseminate.digiprovMD");
if (dpTypes == null)
String[] dpTypes = configurationService.getArrayProperty("aip.disseminate.digiprovMD");
if (ArrayUtils.isEmpty(dpTypes))
{
return new String[0];
}
else
{
return dpTypes.split("\\s*,\\s*");
return dpTypes;
}
}
@@ -394,10 +393,10 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator
{
List<String> result = new ArrayList<String>();
String rTypes = ConfigurationManager.getProperty("aip.disseminate.rightsMD");
String[] rTypes = configurationService.getArrayProperty("aip.disseminate.rightsMD");
//If unspecified in configuration file, add default settings
if (rTypes == null)
if (ArrayUtils.isEmpty(rTypes))
{
// Licenses only apply to an Item
if (dso.getType() == Constants.ITEM)
@@ -424,7 +423,7 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator
}
else
{
return rTypes.split("\\s*,\\s*");
return rTypes;
}
return result.toArray(new String[result.size()]);

View File

@@ -9,10 +9,11 @@ package org.dspace.event;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.pool2.KeyedObjectPool;
import org.apache.commons.pool2.KeyedPooledObjectFactory;
@@ -22,9 +23,10 @@ import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
import org.apache.log4j.Logger;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context;
import org.dspace.event.service.EventService;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
/**
* Class for managing the content event environment. The EventManager mainly
@@ -48,7 +50,10 @@ public class EventServiceImpl implements EventService
protected Map<String, Integer> consumerIndicies = null;
protected String CONSUMER_PFX = "event.consumer.";
protected String CONSUMER_PFX = "event.consumer";
private static final ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
protected EventServiceImpl()
{
@@ -140,7 +145,8 @@ public class EventServiceImpl implements EventService
protected void enumerateConsumers()
{
Enumeration propertyNames = ConfigurationManager.propertyNames();
// Get all configs starting with CONSUMER_PFX
List<String> propertyNames = configurationService.getPropertyKeys(CONSUMER_PFX);
int bitSetIndex = 0;
if (consumerIndicies == null)
@@ -148,13 +154,11 @@ public class EventServiceImpl implements EventService
consumerIndicies = new HashMap<String, Integer>();
}
while (propertyNames.hasMoreElements())
for(String ckey : propertyNames)
{
String ckey = ((String) propertyNames.nextElement()).trim();
if (ckey.startsWith(CONSUMER_PFX) && ckey.endsWith(".class"))
if (ckey.endsWith(".class"))
{
String consumerName = ckey.substring(CONSUMER_PFX.length(),
String consumerName = ckey.substring(CONSUMER_PFX.length()+1,
ckey.length() - 6);
consumerIndicies.put(consumerName, (Integer) bitSetIndex);
@@ -167,7 +171,7 @@ public class EventServiceImpl implements EventService
{
// Prefix of keys in DSpace Configuration
private static final String PROP_PFX = "event.dispatcher.";
private static final String PROP_PFX = "event.dispatcher";
// Cache of event dispatchers, keyed by name, for re-use.
protected Map<String, String> dispatchers = new HashMap<String, String>();
@@ -201,37 +205,23 @@ public class EventServiceImpl implements EventService
dispatcher = (Dispatcher) dc.newInstance(args);
// OK, now get its list of consumers/filters
String consumerKey = PROP_PFX + dispatcherName
String consumerKey = PROP_PFX + "." + dispatcherName
+ ".consumers";
String consumerList = ConfigurationManager
.getProperty(consumerKey);
if (consumerList == null)
String[] consumers = configurationService
.getArrayProperty(consumerKey);
if (ArrayUtils.isEmpty(consumers))
{
throw new IllegalStateException(
"No Configuration entry found for consumer list of event Dispatcher: \""
+ consumerKey + "\"");
}
// Consumer list format:
// <consumer-name>:<mode>, ...
String[] consumerStanza = consumerList.trim().split(
"\\s*,\\s*");
// I think this should be a fatal error.. --lcs
if (consumerStanza.length < 1)
{
throw new IllegalStateException(
"Cannot initialize Dispatcher, malformed Configuration value for "
+ consumerKey);
}
ConsumerProfile consumerProfile = null;
// parts: 0 is name, part 1 is mode.
for (int i = 0; i < consumerStanza.length; i++)
for (String consumer : consumers)
{
consumerProfile = ConsumerProfile
.makeConsumerProfile(consumerStanza[i]);
.makeConsumerProfile(consumer);
consumerProfile.getConsumer().initialize();
dispatcher.addConsumerProfile(consumerProfile);
@@ -346,16 +336,16 @@ public class EventServiceImpl implements EventService
*/
private void parseEventConfig()
{
Enumeration propertyNames = ConfigurationManager.propertyNames();
while (propertyNames.hasMoreElements())
// Get all configs starting with PROP_PFX
List<String> propertyNames = configurationService.getPropertyKeys(PROP_PFX);
for(String ckey : propertyNames)
{
String ckey = ((String) propertyNames.nextElement()).trim();
if (ckey.startsWith(PROP_PFX) && ckey.endsWith(".class"))
if (ckey.endsWith(".class"))
{
String name = ckey.substring(PROP_PFX.length(), ckey
String name = ckey.substring(PROP_PFX.length()+1, ckey
.length() - 6);
String dispatcherClass = ConfigurationManager
String dispatcherClass = configurationService
.getProperty(ckey);
// Can we grab all of the consumers configured for this

View File

@@ -203,29 +203,23 @@ public class MetadataConverterPlugin implements ConverterPlugin
protected Model loadConfiguration()
{
String mappingPathes = configurationService.getProperty(METADATA_MAPPING_PATH_KEY);
if (StringUtils.isEmpty(mappingPathes))
{
return null;
}
String[] mappings = mappingPathes.split(",\\s*");
if (mappings == null || mappings.length == 0)
InputStream is = null;
Model config = ModelFactory.createDefaultModel();
String mapping = configurationService.getProperty(METADATA_MAPPING_PATH_KEY);
if (StringUtils.isEmpty(mapping))
{
log.error("Cannot find metadata mappings (looking for "
+ "property " + METADATA_MAPPING_PATH_KEY + ")!");
return null;
}
InputStream is = null;
Model config = ModelFactory.createDefaultModel();
for (String mappingPath : mappings)
else
{
is = FileManager.get().open(mappingPath);
is = FileManager.get().open(mapping);
if (is == null)
{
log.warn("Cannot find file '" + mappingPath + "', ignoring...");
log.warn("Cannot find file '" + mapping + "', ignoring...");
}
config.read(is, "file://" + mappingPath, FileUtils.guessLang(mappingPath));
config.read(is, "file://" + mapping, FileUtils.guessLang(mapping));
try {
// Make sure that we have an input stream to avoid NullPointer
if(is != null)

View File

@@ -12,7 +12,7 @@ import java.util.*;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.dspace.core.ConfigurationManager;
import org.dspace.services.factory.DSpaceServicesFactory;
/**
* Implements MARC 21 standards to disregard initial
@@ -278,18 +278,15 @@ public class MARC21InitialArticleWord extends InitialArticleWord
}
// Setup default stop words for null languages
String defaultLangs = ConfigurationManager.getProperty("marc21wordfilter.defaultlang");
if (!StringUtils.isEmpty(defaultLangs))
String[] defaultLangs = DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty("marc21wordfilter.defaultlang");
if (ArrayUtils.isNotEmpty(defaultLangs))
{
String[] langArr = defaultLangs.split("[, ]+");
if (langArr != null && langArr.length > 0)
{
int wordCount = 0;
ArticlesForLang[] afl = new ArticlesForLang[langArr.length];
ArticlesForLang[] afl = new ArticlesForLang[defaultLangs.length];
for (int idx = 0; idx < afl.length; idx++)
{
Language l = Language.getLanguage(langArr[idx]);
Language l = Language.getLanguage(defaultLangs[idx]);
if (l != null && ianaArticleMap.containsKey(l.IANA))
{
afl[idx] = ianaArticleMap.get(l.IANA);
@@ -313,7 +310,6 @@ public class MARC21InitialArticleWord extends InitialArticleWord
}
}
}
}
}
}