Merge pull request #1104 from tdonohue/DS-2654-common-config

DS-2654: Enhanced Configurations via Apache Commons Configuration
This commit is contained in:
Mark H. Wood
2016-01-29 13:49:03 -05:00
323 changed files with 5126 additions and 5525 deletions

6
.gitignore vendored
View File

@@ -24,8 +24,14 @@ nb-configuration.xml
META-INF/ META-INF/
## Ignore all *.properties file in root folder, EXCEPT build.properties (the default) ## Ignore all *.properties file in root folder, EXCEPT build.properties (the default)
## KEPT FOR BACKWARDS COMPATIBILITY WITH 5.x (build.properties is now replaced with local.cfg)
/*.properties /*.properties
!/build.properties !/build.properties
# Ignore a local.cfg file in root folder, if it exists
/local.cfg
# Also ignore it under dspace/config
/dspace/config/local.cfg
##Mac noise ##Mac noise
.DS_Store .DS_Store

View File

@@ -1,163 +0,0 @@
# DSpace build.properties
# This file should be customised to suit your build environment.
# Note that not all configuration is handled here, only the most common
# properties that tend to differ between build environments.
# For adjusting global settings or more complex settings, edit the relevant config file.
#
# IMPORTANT: Do not remove or comment out settings in build.properties
# When you edit the "build.properties" file (or a custom *.properties file),
# take care not to remove or comment out any settings. Doing so, may cause
# your final "dspace.cfg" file to be misconfigured with regards to that
# particular setting. Instead, if you wish to remove/disable a particular
# setting, just clear out its value. For example, if you don't want to be
# notified of new user registrations, ensure the "mail.registration.notify"
# setting has no value, e.g. "mail.registration.notify="
#
##########################
# SERVER CONFIGURATION #
##########################
# DSpace installation directory. This is the location where you want
# to install DSpace. NOTE: this value will be copied over to the
# "dspace.dir" setting in the final "dspace.cfg" file. It can be
# modified later on in your "dspace.cfg", if needed.
dspace.install.dir=/dspace
# DSpace host name - should match base URL. Do not include port number
dspace.hostname = localhost
# DSpace base host URL. Include port number etc.
dspace.baseUrl = http://localhost:8080
# The user interface you will be using for DSpace. Common usage is either xmlui or jspui
dspace.ui = xmlui
# Full link your end users will use to access DSpace. In most cases, this will be the baseurl followed by
# the context path to the UI you are using.
#
# Alternatively, you can use a url redirect or deploy the web application under the servlet container root.
# In this case, make sure to remove the /${dspace.ui} from the dspace.url property.
dspace.url = ${dspace.baseUrl}/${dspace.ui}
# Name of the site
dspace.name = DSpace at My University
# Solr server
solr.server=http://localhost:8080/solr
# Default language for metadata values
default.language = en_US
##########################
# DATABASE CONFIGURATION #
##########################
# Uncomment the appropriate block below for your database.
# postgres
db.driver=org.postgresql.Driver
db.dialect=org.dspace.storage.rdbms.hibernate.postgres.DSpacePostgreSQL82Dialect
db.url=jdbc:postgresql://localhost:5432/dspace
db.username=dspace
db.password=dspace
db.schema = public
# oracle
#db.driver= oracle.jdbc.OracleDriver
#db.dialect=org.hibernate.dialect.Oracle10gDialect
#db.url=jdbc:oracle:thin:@//localhost:1521/xe
#db.username=dspace
#db.password=dspace
# The schema in oracle is the usually the user name
#db.schema = dspace
# Maximum number of DB connections in pool
db.maxconnections = 30
# Maximum time to wait before giving up if all connections in pool are busy (milliseconds)
db.maxwait = 5000
# Maximum number of idle connections in pool (-1 = unlimited)
db.maxidle = -1
#######################
# EMAIL CONFIGURATION #
#######################
# SMTP mail server
mail.server = smtp.example.com
# SMTP mail server authentication username and password (if required)
# mail.server.username = myusername
# mail.server.password = mypassword
mail.server.username=
mail.server.password=
# SMTP mail server alternate port (defaults to 25)
mail.server.port = 25
# From address for mail
mail.from.address = dspace-noreply@myu.edu
# Currently limited to one recipient!
mail.feedback.recipient = dspace-help@myu.edu
# General site administration (Webmaster) e-mail
mail.admin = dspace-help@myu.edu
# Recipient for server errors and alerts
#mail.alert.recipient = email-address-here
mail.alert.recipient=
# Recipient for new user registration emails
#mail.registration.notify = email-address-here
mail.registration.notify=
########################
# HANDLE CONFIGURATION #
########################
# Canonical Handle URL prefix
#
# By default, DSpace is configured to use http://hdl.handle.net/
# as the canonical URL prefix when generating dc.identifier.uri
# during submission, and in the 'identifier' displayed in JSPUI
# item record pages.
#
# If you do not subscribe to CNRI's handle service, you can change this
# to match the persistent URL service you use, or you can force DSpace
# to use your site's URL, eg.
#handle.canonical.prefix = ${dspace.url}/handle/
#
# Note that this will not alter dc.identifer.uri metadata for existing
# items (only for subsequent submissions), but it will alter the URL
# in JSPUI's 'identifier' message on item record pages for existing items.
#
# If omitted, the canonical URL prefix will be http://hdl.handle.net/
handle.canonical.prefix = http://hdl.handle.net/
# CNRI Handle prefix
handle.prefix = 123456789
#######################
# PROXY CONFIGURATION #
#######################
# uncomment and specify both properties if proxy server required
# proxy server for external http requests - use regular hostname without port number
http.proxy.host =
# port number of proxy server
http.proxy.port =
#####################
# LOGLEVEL SETTINGS #
#####################
loglevel.other = INFO
# loglevel.other: Log level for other third-party tools/APIs used by DSpace
# Possible values (from most to least info): DEBUG, INFO, WARN, ERROR, FATAL
loglevel.dspace = INFO
# loglevel.dspace: Log level for all DSpace-specific code (org.dspace.*)
# Possible values (from most to least info): DEBUG, INFO, WARN, ERROR, FATAL

View File

@@ -219,81 +219,14 @@
</executions> </executions>
</plugin> </plugin>
<!-- FileWeaver plugin is in charge of initializing & "weaving" together
the dspace.cfg file to be used by the Unit Testing environment.
It weaves two files, the default 'dspace.cfg' and 'dspace.cfg.more',
both of which are included in the testEnvironment.zip. -->
<plugin>
<groupId>edu.iu.ul.maven.plugins</groupId>
<artifactId>fileweaver</artifactId>
<version>1.0</version>
<configuration>
<outputs>
<output>
<outputPath>${agnostic.build.dir}/testing</outputPath>
<name>dspace.cfg.woven</name>
<parts>
<part>
<path>${agnostic.build.dir}/testing/dspace/config/dspace.cfg</path>
</part>
<part>
<path>${agnostic.build.dir}/testing/dspace.cfg.more</path>
</part>
</parts>
<properties>
<dspace.install.dir>${agnostic.build.dir}/testing/dspace</dspace.install.dir>
</properties>
</output>
</outputs>
</configuration>
<executions>
<execution>
<id>edit-dspace-cfg</id>
<phase>process-test-resources</phase>
<goals>
<goal>weave</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- The ant plugin below ensures that the final "woven" dspace.cfg
ends up in the /target/testing/dspace/ directory. This becomes
our final dspace.cfg for the Unit Testing environment. The dspace
service manager needs this "woven" configuration file when it starts.-->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-test-resources</phase>
<configuration>
<target>
<!-- Ant task to copy dspace.cfg.woven to location of test dspace.cfg file -->
<copy file="${agnostic.build.dir}/testing/dspace.cfg.woven" tofile="${agnostic.build.dir}/testing/dspace/config/dspace.cfg" />
<!-- Now, do one final filter of our Test configs, replacing any remaining "${dspace.dir}"
placeholders, with the full path of our Unit Test directory -->
<!-- NOTE: This final filtering is necessary, because dspace.dir doesn't get filled out
in our test dspace.cfg until Fileweaver runs above. -->
<replace dir="${agnostic.build.dir}/testing/dspace/config/" value="${agnostic.build.dir}/testing/dspace">
<include name="**/*"/>
<replacetoken>${dspace.dir}</replacetoken>
</replace>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Run Unit Testing! This plugin just kicks off the tests (when enabled). --> <!-- Run Unit Testing! This plugin just kicks off the tests (when enabled). -->
<plugin> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration> <configuration>
<systemPropertyVariables> <systemPropertyVariables>
<!-- Specify the dspace.cfg file to use for test environment --> <!-- Specify the dspace.dir to use for test environment -->
<dspace.configuration>${agnostic.build.dir}/testing/dspace/config/dspace.cfg</dspace.configuration> <!-- This system property is loaded by AbstractDSpaceTest to initialize the test environment -->
<dspace.dir>${agnostic.build.dir}/testing/dspace/</dspace.dir>
<!-- Turn off any DSpace logging --> <!-- Turn off any DSpace logging -->
<dspace.log.init.disable>true</dspace.log.init.disable> <dspace.log.init.disable>true</dspace.log.init.disable>
</systemPropertyVariables> </systemPropertyVariables>
@@ -305,8 +238,8 @@
<artifactId>maven-failsafe-plugin</artifactId> <artifactId>maven-failsafe-plugin</artifactId>
<configuration> <configuration>
<systemPropertyVariables> <systemPropertyVariables>
<!-- Specify the dspace.cfg file to use for test environment --> <!-- Specify the dspace.dir to use for test environment -->
<dspace.configuration>${agnostic.build.dir}/testing/dspace/config/dspace.cfg</dspace.configuration> <dspace.dir>${agnostic.build.dir}/testing/dspace/</dspace.dir>
<!-- Turn off any DSpace logging --> <!-- Turn off any DSpace logging -->
<dspace.log.init.disable>true</dspace.log.init.disable> <dspace.log.init.disable>true</dspace.log.init.disable>
</systemPropertyVariables> </systemPropertyVariables>
@@ -556,7 +489,6 @@
<dependency> <dependency>
<groupId>commons-configuration</groupId> <groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId> <artifactId>commons-configuration</artifactId>
<version>1.8</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.maxmind.geoip</groupId> <groupId>com.maxmind.geoip</groupId>

View File

@@ -11,15 +11,18 @@ import org.apache.commons.lang3.StringUtils;
import org.dspace.authority.AuthorityValue; import org.dspace.authority.AuthorityValue;
import org.dspace.authority.factory.AuthorityServiceFactory; import org.dspace.authority.factory.AuthorityServiceFactory;
import org.dspace.authority.service.AuthorityValueService; import org.dspace.authority.service.AuthorityValueService;
import org.dspace.content.*;
import org.dspace.content.Collection; import org.dspace.content.Collection;
import org.dspace.content.Item;
import org.dspace.content.MetadataField;
import org.dspace.content.MetadataSchema;
import org.dspace.content.MetadataValue;
import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.ItemService; import org.dspace.content.service.ItemService;
import org.dspace.content.service.MetadataFieldService; import org.dspace.content.service.MetadataFieldService;
import org.dspace.content.service.MetadataSchemaService; import org.dspace.content.service.MetadataSchemaService;
import org.dspace.content.authority.Choices; import org.dspace.content.authority.Choices;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.services.factory.DSpaceServicesFactory;
import java.util.*; import java.util.*;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -268,14 +271,11 @@ public class DSpaceCSV implements Serializable
// Set the metadata fields to ignore // Set the metadata fields to ignore
ignore = new HashMap<>(); ignore = new HashMap<>();
String toIgnore = ConfigurationManager.getProperty("bulkedit", "ignore-on-export");
if ((toIgnore == null) || ("".equals(toIgnore.trim()))) // Specify default values
{ String[] defaultValues = new String[]{"dc.date.accessioned, dc.date.available, " +
// Set a default value "dc.date.updated, dc.description.provenance"};
toIgnore = "dc.date.accessioned, dc.date.available, " + String[] toIgnoreArray = DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty("bulkedit.ignore-on-export", defaultValues);
"dc.date.updated, dc.description.provenance";
}
String[] toIgnoreArray = toIgnore.split(",");
for (String toIgnoreString : toIgnoreArray) for (String toIgnoreString : toIgnoreArray)
{ {
if (!"".equals(toIgnoreString.trim())) if (!"".equals(toIgnoreString.trim()))
@@ -310,7 +310,7 @@ public class DSpaceCSV implements Serializable
private void setValueSeparator() private void setValueSeparator()
{ {
// Get the value separator // Get the value separator
valueSeparator = ConfigurationManager.getProperty("bulkedit", "valueseparator"); valueSeparator = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("bulkedit.valueseparator");
if ((valueSeparator != null) && (!"".equals(valueSeparator.trim()))) if ((valueSeparator != null) && (!"".equals(valueSeparator.trim())))
{ {
valueSeparator = valueSeparator.trim(); valueSeparator = valueSeparator.trim();
@@ -339,7 +339,7 @@ public class DSpaceCSV implements Serializable
private void setFieldSeparator() private void setFieldSeparator()
{ {
// Get the value separator // Get the value separator
fieldSeparator = ConfigurationManager.getProperty("bulkedit", "fieldseparator"); fieldSeparator =DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("bulkedit.fieldseparator");
if ((fieldSeparator != null) && (!"".equals(fieldSeparator.trim()))) if ((fieldSeparator != null) && (!"".equals(fieldSeparator.trim())))
{ {
fieldSeparator = fieldSeparator.trim(); fieldSeparator = fieldSeparator.trim();
@@ -381,7 +381,7 @@ public class DSpaceCSV implements Serializable
private void setAuthoritySeparator() private void setAuthoritySeparator()
{ {
// Get the value separator // Get the value separator
authoritySeparator = ConfigurationManager.getProperty("bulkedit", "authorityseparator"); authoritySeparator = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("bulkedit.authorityseparator");
if ((authoritySeparator != null) && (!"".equals(authoritySeparator.trim()))) if ((authoritySeparator != null) && (!"".equals(authoritySeparator.trim())))
{ {
authoritySeparator = authoritySeparator.trim(); authoritySeparator = authoritySeparator.trim();

View File

@@ -8,7 +8,7 @@
package org.dspace.app.itemexport.factory; package org.dspace.app.itemexport.factory;
import org.dspace.app.itemexport.service.ItemExportService; import org.dspace.app.itemexport.service.ItemExportService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the itemexport package, use ItemExportServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the itemexport package, use ItemExportServiceFactory.getInstance() to retrieve an implementation
@@ -20,6 +20,6 @@ public abstract class ItemExportServiceFactory {
public abstract ItemExportService getItemExportService(); public abstract ItemExportService getItemExportService();
public static ItemExportServiceFactory getInstance(){ public static ItemExportServiceFactory getInstance(){
return new DSpace().getServiceManager().getServiceByName("itemExportServiceFactory", ItemExportServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("itemExportServiceFactory", ItemExportServiceFactory.class);
} }
} }

View File

@@ -8,7 +8,7 @@
package org.dspace.app.itemimport.factory; package org.dspace.app.itemimport.factory;
import org.dspace.app.itemimport.service.ItemImportService; import org.dspace.app.itemimport.service.ItemImportService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the itemimport package, use ItemImportService.getInstance() to retrieve an implementation * Abstract factory to get services for the itemimport package, use ItemImportService.getInstance() to retrieve an implementation
@@ -20,6 +20,6 @@ public abstract class ItemImportServiceFactory {
public abstract ItemImportService getItemImportService(); public abstract ItemImportService getItemImportService();
public static ItemImportServiceFactory getInstance(){ public static ItemImportServiceFactory getInstance(){
return new DSpace().getServiceManager().getServiceByName("itemImportServiceFactory", ItemImportServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("itemImportServiceFactory", ItemImportServiceFactory.class);
} }
} }

View File

@@ -15,6 +15,7 @@ import java.io.Reader;
import java.io.StreamTokenizer; import java.io.StreamTokenizer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jdom.Document;
/** /**
* *
@@ -82,13 +83,14 @@ public class CommandRunner
int status = 0; int status = 0;
List<String> tokens = new ArrayList<String>(); List<String> tokens = new ArrayList<String>();
Document commandConfigs = ScriptLauncher.getConfig();
while (StreamTokenizer.TT_EOF != tokenizer.nextToken()) while (StreamTokenizer.TT_EOF != tokenizer.nextToken())
{ {
if (StreamTokenizer.TT_EOL == tokenizer.ttype) if (StreamTokenizer.TT_EOL == tokenizer.ttype)
{ {
if (tokens.size() > 0) if (tokens.size() > 0)
{ {
status = ScriptLauncher.runOneCommand(tokens.toArray(new String[tokens.size()])); status = ScriptLauncher.runOneCommand(commandConfigs, tokens.toArray(new String[tokens.size()]));
if (status > 0) if (status > 0)
{ {
break; break;

View File

@@ -12,7 +12,6 @@ import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List; import java.util.List;
import java.util.TreeMap; import java.util.TreeMap;
import org.dspace.core.ConfigurationManager;
import org.dspace.servicemanager.DSpaceKernelImpl; import org.dspace.servicemanager.DSpaceKernelImpl;
import org.dspace.servicemanager.DSpaceKernelInit; import org.dspace.servicemanager.DSpaceKernelInit;
import org.dspace.services.RequestService; import org.dspace.services.RequestService;
@@ -31,9 +30,6 @@ public class ScriptLauncher
/** The service manager kernel */ /** The service manager kernel */
private static transient DSpaceKernelImpl kernelImpl; private static transient DSpaceKernelImpl kernelImpl;
/** Definitions of all commands. */
private static final Document commandConfigs = getConfig();
/** /**
* Execute the DSpace script launcher * Execute the DSpace script launcher
* *
@@ -42,20 +38,13 @@ public class ScriptLauncher
public static void main(String[] args) public static void main(String[] args)
throws FileNotFoundException, IOException throws FileNotFoundException, IOException
{ {
// Check that there is at least one argument
if (args.length < 1)
{
System.err.println("You must provide at least one command argument");
display();
System.exit(1);
}
// Initialise the service manager kernel // Initialise the service manager kernel
try { try
{
kernelImpl = DSpaceKernelInit.getKernel(null); kernelImpl = DSpaceKernelInit.getKernel(null);
if (!kernelImpl.isRunning()) if (!kernelImpl.isRunning())
{ {
kernelImpl.start(ConfigurationManager.getProperty("dspace.dir")); kernelImpl.start();
} }
} catch (Exception e) } catch (Exception e)
{ {
@@ -68,14 +57,26 @@ public class ScriptLauncher
{ {
// Nothing to do // Nothing to do
} }
String message = "Failure during filter init: " + e.getMessage(); String message = "Failure during kernel init: " + e.getMessage();
System.err.println(message + ":" + e); System.err.println(message);
e.printStackTrace();
throw new IllegalStateException(message, e); throw new IllegalStateException(message, e);
} }
// Load up the ScriptLauncher's configuration
Document commandConfigs = getConfig();
// Check that there is at least one argument (if not display command options)
if (args.length < 1)
{
System.err.println("You must provide at least one command argument");
display(commandConfigs);
System.exit(1);
}
// Look up command in the configuration, and execute. // Look up command in the configuration, and execute.
int status; int status;
status = runOneCommand(args); status = runOneCommand(commandConfigs, args);
// Destroy the service kernel if it is still alive // Destroy the service kernel if it is still alive
if (kernelImpl != null) if (kernelImpl != null)
@@ -92,7 +93,7 @@ public class ScriptLauncher
* @param doc * @param doc
* @param args * @param args
*/ */
static int runOneCommand(String[] args) static int runOneCommand(Document commandConfigs, String[] args)
{ {
String request = args[0]; String request = args[0];
Element root = commandConfigs.getRootElement(); Element root = commandConfigs.getRootElement();
@@ -111,7 +112,7 @@ public class ScriptLauncher
{ {
// The command wasn't found // The command wasn't found
System.err.println("Command not found: " + args[0]); System.err.println("Command not found: " + args[0]);
display(); display(commandConfigs);
return 1; return 1;
} }
@@ -250,10 +251,10 @@ public class ScriptLauncher
* *
* @return The XML configuration file Document * @return The XML configuration file Document
*/ */
private static Document getConfig() protected static Document getConfig()
{ {
// Load the launcher configuration file // Load the launcher configuration file
String config = ConfigurationManager.getProperty("dspace.dir") + String config = kernelImpl.getConfigurationService().getProperty("dspace.dir") +
System.getProperty("file.separator") + "config" + System.getProperty("file.separator") + "config" +
System.getProperty("file.separator") + "launcher.xml"; System.getProperty("file.separator") + "launcher.xml";
SAXBuilder saxBuilder = new SAXBuilder(); SAXBuilder saxBuilder = new SAXBuilder();
@@ -266,6 +267,7 @@ public class ScriptLauncher
{ {
System.err.println("Unable to load the launcher configuration file: [dspace]/config/launcher.xml"); System.err.println("Unable to load the launcher configuration file: [dspace]/config/launcher.xml");
System.err.println(e.getMessage()); System.err.println(e.getMessage());
e.printStackTrace();
System.exit(1); System.exit(1);
} }
return doc; return doc;
@@ -274,7 +276,7 @@ public class ScriptLauncher
/** /**
* Display the commands that the current launcher config file knows about * Display the commands that the current launcher config file knows about
*/ */
private static void display() private static void display(Document commandConfigs)
{ {
// List all command elements // List all command elements
List<Element> commands = commandConfigs.getRootElement().getChildren("command"); List<Element> commands = commandConfigs.getRootElement().getChildren("command");

View File

@@ -18,6 +18,7 @@ import org.dspace.core.*;
import org.dspace.handle.factory.HandleServiceFactory; import org.dspace.handle.factory.HandleServiceFactory;
import java.util.*; import java.util.*;
import org.dspace.core.factory.CoreServiceFactory;
/** /**
* MediaFilterManager is the class that invokes the media/format filters over the * MediaFilterManager is the class that invokes the media/format filters over the
@@ -178,7 +179,7 @@ public class MediaFilterCLITool {
for(int i=0; i< filterNames.length; i++) for(int i=0; i< filterNames.length; i++)
{ {
//get filter of this name & add to list of filters //get filter of this name & add to list of filters
FormatFilter filter = (FormatFilter) PluginManager.getNamedPlugin(FormatFilter.class, filterNames[i]); FormatFilter filter = (FormatFilter) CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(FormatFilter.class, filterNames[i]);
if(filter==null) if(filter==null)
{ {
System.err.println("\nERROR: Unknown MediaFilter specified (either from command-line or in dspace.cfg): '" + filterNames[i] + "'"); System.err.println("\nERROR: Unknown MediaFilter specified (either from command-line or in dspace.cfg): '" + filterNames[i] + "'");

View File

@@ -10,18 +10,17 @@ package org.dspace.app.mediafilter;
import java.io.InputStream; import java.io.InputStream;
import java.util.*; import java.util.*;
import org.apache.log4j.Logger;
import org.dspace.app.mediafilter.service.MediaFilterService; import org.dspace.app.mediafilter.service.MediaFilterService;
import org.dspace.authorize.service.AuthorizeService; import org.dspace.authorize.service.AuthorizeService;
import org.dspace.content.*; import org.dspace.content.*;
import org.dspace.content.Collection; import org.dspace.content.Collection;
import org.dspace.content.service.*; import org.dspace.content.service.*;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.SelfNamedPlugin; import org.dspace.core.SelfNamedPlugin;
import org.dspace.eperson.Group; import org.dspace.eperson.Group;
import org.dspace.eperson.service.GroupService; import org.dspace.eperson.service.GroupService;
import org.dspace.services.ConfigurationService;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -52,6 +51,8 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
protected GroupService groupService; protected GroupService groupService;
@Autowired(required = true) @Autowired(required = true)
protected ItemService itemService; protected ItemService itemService;
@Autowired(required = true)
protected ConfigurationService configurationService;
protected int max2Process = Integer.MAX_VALUE; // maximum number items to process protected int max2Process = Integer.MAX_VALUE; // maximum number items to process
@@ -74,7 +75,7 @@ public class MediaFilterServiceImpl implements MediaFilterService, InitializingB
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
String publicPermissionFilters = ConfigurationManager.getProperty("filter.org.dspace.app.mediafilter.publicPermission"); String publicPermissionFilters = configurationService.getProperty("filter.org.dspace.app.mediafilter.publicPermission");
if(publicPermissionFilters != null) { if(publicPermissionFilters != null) {
String[] publicPermisionFiltersArray = publicPermissionFilters.split(","); String[] publicPermisionFiltersArray = publicPermissionFilters.split(",");
for(String filter : publicPermisionFiltersArray) { for(String filter : publicPermisionFiltersArray) {

View File

@@ -8,7 +8,7 @@
package org.dspace.app.mediafilter.factory; package org.dspace.app.mediafilter.factory;
import org.dspace.app.mediafilter.service.MediaFilterService; import org.dspace.app.mediafilter.service.MediaFilterService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the mediafilter package, use MediaFilterServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the mediafilter package, use MediaFilterServiceFactory.getInstance() to retrieve an implementation
@@ -20,6 +20,6 @@ public abstract class MediaFilterServiceFactory {
public abstract MediaFilterService getMediaFilterService(); public abstract MediaFilterService getMediaFilterService();
public static MediaFilterServiceFactory getInstance(){ public static MediaFilterServiceFactory getInstance(){
return new DSpace().getServiceManager().getServiceByName("mediaFilterServiceFactory", MediaFilterServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("mediaFilterServiceFactory", MediaFilterServiceFactory.class);
} }
} }

View File

@@ -29,7 +29,8 @@ import org.dspace.content.packager.PackageParameters;
import org.dspace.content.packager.PackageIngester; import org.dspace.content.packager.PackageIngester;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.PluginManager; import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import org.dspace.eperson.EPerson; import org.dspace.eperson.EPerson;
import org.dspace.eperson.factory.EPersonServiceFactory; import org.dspace.eperson.factory.EPersonServiceFactory;
import org.dspace.handle.factory.HandleServiceFactory; import org.dspace.handle.factory.HandleServiceFactory;
@@ -164,6 +165,7 @@ public class Packager
String[] parents = null; String[] parents = null;
String identifier = null; String identifier = null;
PackageParameters pkgParams = new PackageParameters(); PackageParameters pkgParams = new PackageParameters();
PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
//initialize a new packager -- we'll add all our current params as settings //initialize a new packager -- we'll add all our current params as settings
Packager myPackager = new Packager(); Packager myPackager = new Packager();
@@ -182,7 +184,7 @@ public class Packager
System.out.println("--------------------------------------------------------------"); System.out.println("--------------------------------------------------------------");
System.out.println("(These options may be specified using --option as described above)"); System.out.println("(These options may be specified using --option as described above)");
PackageIngester sip = (PackageIngester) PluginManager PackageIngester sip = (PackageIngester) pluginService
.getNamedPlugin(PackageIngester.class, line.getOptionValue('t')); .getNamedPlugin(PackageIngester.class, line.getOptionValue('t'));
if (sip != null) if (sip != null)
@@ -195,7 +197,7 @@ public class Packager
System.out.println("\nNo valid Submission plugin found for " + line.getOptionValue('t') + " type."); System.out.println("\nNo valid Submission plugin found for " + line.getOptionValue('t') + " type.");
} }
PackageDisseminator dip = (PackageDisseminator) PluginManager PackageDisseminator dip = (PackageDisseminator) pluginService
.getNamedPlugin(PackageDisseminator.class, line.getOptionValue('t')); .getNamedPlugin(PackageDisseminator.class, line.getOptionValue('t'));
if (dip != null) if (dip != null)
@@ -212,7 +214,7 @@ public class Packager
else //otherwise, display list of valid packager types else //otherwise, display list of valid packager types
{ {
System.out.println("\nAvailable Submission Package (SIP) types:"); System.out.println("\nAvailable Submission Package (SIP) types:");
String pn[] = PluginManager String pn[] = pluginService
.getAllPluginNames(PackageIngester.class); .getAllPluginNames(PackageIngester.class);
for (int i = 0; i < pn.length; ++i) for (int i = 0; i < pn.length; ++i)
{ {
@@ -220,7 +222,7 @@ public class Packager
} }
System.out System.out
.println("\nAvailable Dissemination Package (DIP) types:"); .println("\nAvailable Dissemination Package (DIP) types:");
pn = PluginManager.getAllPluginNames(PackageDisseminator.class); pn = pluginService.getAllPluginNames(PackageDisseminator.class);
for (int i = 0; i < pn.length; ++i) for (int i = 0; i < pn.length; ++i)
{ {
System.out.println(" " + pn[i]); System.out.println(" " + pn[i]);
@@ -329,7 +331,7 @@ public class Packager
//If we are in REPLACE mode //If we are in REPLACE mode
if(pkgParams.replaceModeEnabled()) if(pkgParams.replaceModeEnabled())
{ {
PackageIngester sip = (PackageIngester) PluginManager PackageIngester sip = (PackageIngester) pluginService
.getNamedPlugin(PackageIngester.class, myPackager.packageType); .getNamedPlugin(PackageIngester.class, myPackager.packageType);
if (sip == null) if (sip == null)
{ {
@@ -392,7 +394,7 @@ public class Packager
//else if normal SUBMIT mode (or basic RESTORE mode -- which is a special type of submission) //else if normal SUBMIT mode (or basic RESTORE mode -- which is a special type of submission)
else if (myPackager.submit || pkgParams.restoreModeEnabled()) else if (myPackager.submit || pkgParams.restoreModeEnabled())
{ {
PackageIngester sip = (PackageIngester) PluginManager PackageIngester sip = (PackageIngester) pluginService
.getNamedPlugin(PackageIngester.class, myPackager.packageType); .getNamedPlugin(PackageIngester.class, myPackager.packageType);
if (sip == null) if (sip == null)
{ {
@@ -444,7 +446,7 @@ public class Packager
else else
{ {
//retrieve specified package disseminator //retrieve specified package disseminator
PackageDisseminator dip = (PackageDisseminator) PluginManager PackageDisseminator dip = (PackageDisseminator) pluginService
.getNamedPlugin(PackageDisseminator.class, myPackager.packageType); .getNamedPlugin(PackageDisseminator.class, myPackager.packageType);
if (dip == null) if (dip == null)
{ {

View File

@@ -8,8 +8,7 @@
package org.dspace.app.requestitem.factory; package org.dspace.app.requestitem.factory;
import org.dspace.app.requestitem.service.RequestItemService; import org.dspace.app.requestitem.service.RequestItemService;
import org.dspace.handle.service.HandleService; import org.dspace.services.factory.DSpaceServicesFactory;
import org.dspace.utils.DSpace;
/** /**
* Abstract factory to get services for the requestitem package, use RequestItemServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the requestitem package, use RequestItemServiceFactory.getInstance() to retrieve an implementation
@@ -22,6 +21,6 @@ public abstract class RequestItemServiceFactory {
public static RequestItemServiceFactory getInstance() public static RequestItemServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("requestItemServiceFactory", RequestItemServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("requestItemServiceFactory", RequestItemServiceFactory.class);
} }
} }

View File

@@ -8,7 +8,7 @@
package org.dspace.app.sfx.factory; package org.dspace.app.sfx.factory;
import org.dspace.app.sfx.service.SFXFileReaderService; import org.dspace.app.sfx.service.SFXFileReaderService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the sfx package, use SfxServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the sfx package, use SfxServiceFactory.getInstance() to retrieve an implementation
@@ -20,6 +20,6 @@ public abstract class SfxServiceFactory {
public abstract SFXFileReaderService getSfxFileReaderService(); public abstract SFXFileReaderService getSfxFileReaderService();
public static SfxServiceFactory getInstance(){ public static SfxServiceFactory getInstance(){
return new DSpace().getServiceManager().getServiceByName("sfxServiceFactory", SfxServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("sfxServiceFactory", SfxServiceFactory.class);
} }
} }

View File

@@ -28,7 +28,7 @@ usage events may be transmitted, persisted, or processed.
<p> <p>
At appropriate points in the processing of user actions, events may be At appropriate points in the processing of user actions, events may be
assembled and "fired". What happens when an event is fired is configurable assembled and "fired". What happens when an event is fired is configurable
via the PluginManager. One must configure a plugin for the AbstractUsageEvent via the PluginService. One must configure a plugin for the AbstractUsageEvent
class, defined in this package, to select an event processing implementation. class, defined in this package, to select an event processing implementation.
</p> </p>

View File

@@ -10,12 +10,12 @@ package org.dspace.app.util;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.w3c.dom.*; import org.w3c.dom.*;
import javax.xml.parsers.*; import javax.xml.parsers.*;
import org.dspace.content.MetadataSchema; import org.dspace.content.MetadataSchema;
import org.dspace.core.ConfigurationManager;
/** /**
* Submission form generator for DSpace. Reads and parses the installation * Submission form generator for DSpace. Reads and parses the installation
@@ -53,10 +53,6 @@ public class DCInputsReader
/** Keyname for storing dropdown value-pair set name */ /** Keyname for storing dropdown value-pair set name */
static final String PAIR_TYPE_NAME = "value-pairs-name"; static final String PAIR_TYPE_NAME = "value-pairs-name";
/** The fully qualified pathname of the form definition XML file */
private String defsFile = ConfigurationManager.getProperty("dspace.dir")
+ File.separator + "config" + File.separator + FORM_DEF_FILE;
/** /**
* Reference to the collections to forms map, computed from the forms * Reference to the collections to forms map, computed from the forms
* definition file * definition file
@@ -91,6 +87,10 @@ public class DCInputsReader
public DCInputsReader() public DCInputsReader()
throws DCInputsReaderException throws DCInputsReaderException
{ {
// Load from default file
String defsFile = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
+ File.separator + "config" + File.separator + FORM_DEF_FILE;
buildInputs(defsFile); buildInputs(defsFile);
} }

View File

@@ -7,7 +7,6 @@
*/ */
package org.dspace.app.util; package org.dspace.app.util;
import org.dspace.core.ConfigurationManager;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import javax.servlet.ServletContextListener; import javax.servlet.ServletContextListener;
@@ -28,12 +27,6 @@ public class DSpaceContextListener implements ServletContextListener
{ {
private static Logger log = Logger.getLogger(DSpaceContextListener.class); private static Logger log = Logger.getLogger(DSpaceContextListener.class);
/**
* Name of the context parameter giving the path to the DSpace configuration file.
*/
public static final String DSPACE_CONFIG_PARAMETER = "dspace-config";
/** /**
* Initialize any resources required by the application. * Initialize any resources required by the application.
* @param event * @param event
@@ -41,7 +34,6 @@ public class DSpaceContextListener implements ServletContextListener
@Override @Override
public void contextInitialized(ServletContextEvent event) public void contextInitialized(ServletContextEvent event)
{ {
// On Windows, URL caches can cause problems, particularly with undeployment // On Windows, URL caches can cause problems, particularly with undeployment
// So, here we attempt to disable them if we detect that we are running on Windows // So, here we attempt to disable them if we detect that we are running on Windows
try try
@@ -65,54 +57,6 @@ public class DSpaceContextListener implements ServletContextListener
{ {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
// Paths to the various config files
String dspaceConfig = null;
/**
* Stage 1
*
* Locate the dspace config
*/
// first check the local per webapp parameter, then check the global parameter.
dspaceConfig = event.getServletContext().getInitParameter(DSPACE_CONFIG_PARAMETER);
// Finally, if no config parameter found throw an error
if (dspaceConfig == null || "".equals(dspaceConfig))
{
throw new IllegalStateException(
"\n\nDSpace has failed to initialize. This has occurred because it was unable to determine \n" +
"where the dspace.cfg file is located. The path to the configuration file should be stored \n" +
"in a context variable, '"+DSPACE_CONFIG_PARAMETER+"', in the global context. \n" +
"No context variable was found in either location.\n\n");
}
/**
* Stage 2
*
* Load the dspace config. Also may load log4j configuration.
* (Please rely on ConfigurationManager or Log4j to configure logging)
*
*/
try
{
ConfigurationManager.loadConfig(dspaceConfig);
}
catch (RuntimeException e)
{
throw e;
}
catch (Exception e)
{
throw new IllegalStateException(
"\n\nDSpace has failed to initialize, during stage 2. Error while attempting to read the \n" +
"DSpace configuration file (Path: '"+dspaceConfig+"'). \n" +
"This has likely occurred because either the file does not exist, or it's permissions \n" +
"are set incorrectly, or the path to the configuration file is incorrect. The path to \n" +
"the DSpace configuration file is stored in a context variable, 'dspace-config', in \n" +
"either the local servlet or global context.\n\n",e);
}
} }
/** /**

View File

@@ -13,7 +13,6 @@ import org.dspace.core.Context;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.net.URLEncoder; import java.net.URLEncoder;
@@ -21,6 +20,7 @@ import java.io.UnsupportedEncodingException;
import java.sql.SQLException; import java.sql.SQLException;
import org.dspace.handle.service.HandleService; import org.dspace.handle.service.HandleService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@@ -34,12 +34,13 @@ import org.jdom.output.XMLOutputter;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.content.DSpaceObject; import org.dspace.content.DSpaceObject;
import org.dspace.core.ConfigurationManager;
import com.sun.syndication.feed.module.opensearch.OpenSearchModule; import com.sun.syndication.feed.module.opensearch.OpenSearchModule;
import com.sun.syndication.feed.module.opensearch.entity.OSQuery; import com.sun.syndication.feed.module.opensearch.entity.OSQuery;
import com.sun.syndication.feed.module.opensearch.impl.OpenSearchModuleImpl; import com.sun.syndication.feed.module.opensearch.impl.OpenSearchModuleImpl;
import com.sun.syndication.io.FeedException; import com.sun.syndication.io.FeedException;
import java.util.Arrays;
import org.dspace.services.ConfigurationService;
/** /**
* Utility Class with static methods for producing OpenSearch-compliant search results, * Utility Class with static methods for producing OpenSearch-compliant search results,
@@ -83,21 +84,19 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
@Override @Override
public void afterPropertiesSet() throws Exception public void afterPropertiesSet() throws Exception
{ {
enabled = ConfigurationManager.getBooleanProperty("websvc.opensearch.enable"); ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
svcUrl = ConfigurationManager.getProperty("dspace.url") + "/" + enabled = config.getBooleanProperty("websvc.opensearch.enable");
ConfigurationManager.getProperty("websvc.opensearch.svccontext"); svcUrl = config.getProperty("dspace.url") + "/" +
uiUrl = ConfigurationManager.getProperty("dspace.url") + "/" + config.getProperty("websvc.opensearch.svccontext");
ConfigurationManager.getProperty("websvc.opensearch.uicontext"); uiUrl = config.getProperty("dspace.url") + "/" +
config.getProperty("websvc.opensearch.uicontext");
// read rest of config info if enabled // read rest of config info if enabled
formats = new ArrayList<String>(); formats = new ArrayList<String>();
if (enabled) if (enabled)
{ {
String fmtsStr = ConfigurationManager.getProperty("websvc.opensearch.formats"); String[] fmts = config.getArrayProperty("websvc.opensearch.formats");
if ( fmtsStr != null ) formats = Arrays.asList(fmts);
{
Collections.addAll(formats, fmtsStr.split(","));
}
} }
} }
@@ -215,31 +214,33 @@ public class OpenSearchServiceImpl implements OpenSearchService, InitializingBea
*/ */
protected org.jdom.Document getServiceDocument(String scope) protected org.jdom.Document getServiceDocument(String scope)
{ {
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
Namespace ns = Namespace.getNamespace(osNs); Namespace ns = Namespace.getNamespace(osNs);
Element root = new Element("OpenSearchDescription", ns); Element root = new Element("OpenSearchDescription", ns);
root.addContent(new Element("ShortName", ns).setText(ConfigurationManager.getProperty("websvc.opensearch.shortname"))); root.addContent(new Element("ShortName", ns).setText(config.getProperty("websvc.opensearch.shortname")));
root.addContent(new Element("LongName", ns).setText(ConfigurationManager.getProperty("websvc.opensearch.longname"))); root.addContent(new Element("LongName", ns).setText(config.getProperty("websvc.opensearch.longname")));
root.addContent(new Element("Description", ns).setText(ConfigurationManager.getProperty("websvc.opensearch.description"))); root.addContent(new Element("Description", ns).setText(config.getProperty("websvc.opensearch.description")));
root.addContent(new Element("InputEncoding", ns).setText("UTF-8")); root.addContent(new Element("InputEncoding", ns).setText("UTF-8"));
root.addContent(new Element("OutputEncoding", ns).setText("UTF-8")); root.addContent(new Element("OutputEncoding", ns).setText("UTF-8"));
// optional elements // optional elements
String sample = ConfigurationManager.getProperty("websvc.opensearch.samplequery"); String sample = config.getProperty("websvc.opensearch.samplequery");
if (sample != null && sample.length() > 0) if (sample != null && sample.length() > 0)
{ {
Element sq = new Element("Query", ns).setAttribute("role", "example"); Element sq = new Element("Query", ns).setAttribute("role", "example");
root.addContent(sq.setAttribute("searchTerms", sample)); root.addContent(sq.setAttribute("searchTerms", sample));
} }
String tags = ConfigurationManager.getProperty("websvc.opensearch.tags"); String tags = config.getProperty("websvc.opensearch.tags");
if (tags != null && tags.length() > 0) if (tags != null && tags.length() > 0)
{ {
root.addContent(new Element("Tags", ns).setText(tags)); root.addContent(new Element("Tags", ns).setText(tags));
} }
String contact = ConfigurationManager.getProperty("mail.admin"); String contact = config.getProperty("mail.admin");
if (contact != null && contact.length() > 0) if (contact != null && contact.length() > 0)
{ {
root.addContent(new Element("Contact", ns).setText(contact)); root.addContent(new Element("Contact", ns).setText(contact));
} }
String faviconUrl = ConfigurationManager.getProperty("websvc.opensearch.faviconurl"); String faviconUrl = config.getProperty("websvc.opensearch.faviconurl");
if (faviconUrl != null && faviconUrl.length() > 0) if (faviconUrl != null && faviconUrl.length() > 0)
{ {
String dim = String.valueOf(16); String dim = String.valueOf(16);

View File

@@ -15,7 +15,7 @@ import java.util.Properties;
import org.dspace.app.util.factory.UtilServiceFactory; import org.dspace.app.util.factory.UtilServiceFactory;
import org.dspace.services.ConfigurationService; import org.dspace.services.ConfigurationService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Display information about this DSpace, its environment, and how it was built. * Display information about this DSpace, its environment, and how it was built.
@@ -61,7 +61,7 @@ public class Version
} }
// Is Discovery available? // Is Discovery available?
ConfigurationService config = new DSpace().getConfigurationService(); ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
String consumers = config.getPropertyAsType("event.dispatcher.default.consumers", ""); // Avoid null pointer String consumers = config.getPropertyAsType("event.dispatcher.default.consumers", ""); // Avoid null pointer
List<String> consumerList = Arrays.asList(consumers.split("\\s*,\\s*")); List<String> consumerList = Arrays.asList(consumers.split("\\s*,\\s*"));
if (consumerList.contains("discovery")) if (consumerList.contains("discovery"))

View File

@@ -10,7 +10,7 @@ package org.dspace.app.util.factory;
import org.dspace.app.util.service.MetadataExposureService; import org.dspace.app.util.service.MetadataExposureService;
import org.dspace.app.util.service.OpenSearchService; import org.dspace.app.util.service.OpenSearchService;
import org.dspace.app.util.service.WebAppService; import org.dspace.app.util.service.WebAppService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the util package, use UtilServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the util package, use UtilServiceFactory.getInstance() to retrieve an implementation
@@ -27,7 +27,7 @@ public abstract class UtilServiceFactory
public static UtilServiceFactory getInstance() public static UtilServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("appUtilServiceFactory", UtilServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("appUtilServiceFactory", UtilServiceFactory.class);
} }
} }

View File

@@ -18,7 +18,7 @@ import java.util.List;
import org.dspace.authenticate.service.AuthenticationService; import org.dspace.authenticate.service.AuthenticationService;
import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeException;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.PluginManager; import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.eperson.EPerson; import org.dspace.eperson.EPerson;
import org.dspace.eperson.Group; import org.dspace.eperson.Group;
import org.dspace.eperson.service.EPersonService; import org.dspace.eperson.service.EPersonService;
@@ -68,7 +68,7 @@ public class AuthenticationServiceImpl implements AuthenticationService, Initial
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
methodStack = Arrays.asList((AuthenticationMethod[])PluginManager.getPluginSequence("authentication", AuthenticationMethod.class)); methodStack = Arrays.asList((AuthenticationMethod[])CoreServiceFactory.getInstance().getPluginService().getPluginSequence(AuthenticationMethod.class));
} }
@Override @Override

View File

@@ -8,7 +8,11 @@
package org.dspace.authenticate; package org.dspace.authenticate;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@@ -22,6 +26,7 @@ import org.dspace.eperson.EPerson;
import org.dspace.eperson.Group; import org.dspace.eperson.Group;
import org.dspace.eperson.factory.EPersonServiceFactory; import org.dspace.eperson.factory.EPersonServiceFactory;
import org.dspace.eperson.service.GroupService; import org.dspace.eperson.service.GroupService;
import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Adds users to special groups based on IP address. Configuration parameter * Adds users to special groups based on IP address. Configuration parameter
@@ -80,18 +85,15 @@ public class IPAuthentication implements AuthenticationMethod
ipMatcherGroupNames = new HashMap<>(); ipMatcherGroupNames = new HashMap<>();
groupService = EPersonServiceFactory.getInstance().getGroupService(); groupService = EPersonServiceFactory.getInstance().getGroupService();
Enumeration e = ConfigurationManager.propertyNames("authentication-ip"); List<String> propNames = DSpaceServicesFactory.getInstance().getConfigurationService().getPropertyKeys("authentication-ip");
while (e.hasMoreElements()) for(String propName : propNames)
{
String propName = (String) e.nextElement();
if (propName.startsWith("ip."))
{ {
String[] nameParts = propName.split("\\."); String[] nameParts = propName.split("\\.");
if (nameParts.length == 2) if (nameParts.length == 2)
{ {
addMatchers(nameParts[1], ConfigurationManager.getProperty("authentication-ip", propName)); addMatchers(nameParts[1], DSpaceServicesFactory.getInstance().getConfigurationService().getProperty(propName));
} }
else else
{ {
@@ -100,7 +102,6 @@ public class IPAuthentication implements AuthenticationMethod
} }
} }
} }
}
/** /**
* Add matchers for the given comma-delimited IP ranges and group. * Add matchers for the given comma-delimited IP ranges and group.

View File

@@ -16,12 +16,12 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.collections.ListUtils; import org.apache.commons.collections.ListUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.LogManager; import org.dspace.core.LogManager;
import org.dspace.eperson.EPerson; import org.dspace.eperson.EPerson;
import org.dspace.eperson.Group; import org.dspace.eperson.Group;
import org.dspace.eperson.factory.EPersonServiceFactory; import org.dspace.eperson.factory.EPersonServiceFactory;
import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* A stackable authentication method * A stackable authentication method
@@ -66,8 +66,8 @@ public class PasswordAuthentication
throws SQLException throws SQLException
{ {
// Is there anything set in domain.valid? // Is there anything set in domain.valid?
String domains = ConfigurationManager.getProperty("authentication-password", "domain.valid"); String[] domains = DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty("authentication-password.domain.valid");
if ((domains == null) || (domains.trim().equals(""))) if ((domains == null) || (domains.length==0))
{ {
// No conditions set, so must be able to self register // No conditions set, so must be able to self register
return true; return true;
@@ -75,12 +75,11 @@ public class PasswordAuthentication
else else
{ {
// Itterate through all domains // Itterate through all domains
String[] options = domains.trim().split(",");
String check; String check;
email = email.trim().toLowerCase(); email = email.trim().toLowerCase();
for (int i = 0; i < options.length; i++) for (int i = 0; i < domains.length; i++)
{ {
check = options[i].trim().toLowerCase(); check = domains[i].trim().toLowerCase();
if (email.endsWith(check)) if (email.endsWith(check))
{ {
// A match, so we can register this user // A match, so we can register this user
@@ -139,7 +138,7 @@ public class PasswordAuthentication
{ {
if (EPersonServiceFactory.getInstance().getEPersonService().getPasswordHash(context.getCurrentUser()) != null && !EPersonServiceFactory.getInstance().getEPersonService().getPasswordHash(context.getCurrentUser()).toString().equals("")) if (EPersonServiceFactory.getInstance().getEPersonService().getPasswordHash(context.getCurrentUser()) != null && !EPersonServiceFactory.getInstance().getEPersonService().getPasswordHash(context.getCurrentUser()).toString().equals(""))
{ {
String groupName = ConfigurationManager.getProperty("authentication-password", "login.specialgroup"); String groupName = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("authentication-password.login.specialgroup");
if ((groupName != null) && (!groupName.trim().equals(""))) if ((groupName != null) && (!groupName.trim().equals("")))
{ {
Group specialGroup = EPersonServiceFactory.getInstance().getGroupService().findByName(context, groupName); Group specialGroup = EPersonServiceFactory.getInstance().getGroupService().findByName(context, groupName);

View File

@@ -8,7 +8,7 @@
package org.dspace.authenticate.factory; package org.dspace.authenticate.factory;
import org.dspace.authenticate.service.AuthenticationService; import org.dspace.authenticate.service.AuthenticationService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the authenticate package, use AuthenticateServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the authenticate package, use AuthenticateServiceFactory.getInstance() to retrieve an implementation
@@ -21,6 +21,6 @@ public abstract class AuthenticateServiceFactory {
public static AuthenticateServiceFactory getInstance() public static AuthenticateServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("authenticateServiceFactory", AuthenticateServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("authenticateServiceFactory", AuthenticateServiceFactory.class);
} }
} }

View File

@@ -13,7 +13,7 @@ import org.dspace.authority.indexer.AuthorityIndexerInterface;
import org.dspace.authority.indexer.AuthorityIndexingService; import org.dspace.authority.indexer.AuthorityIndexingService;
import org.dspace.authority.service.AuthorityService; import org.dspace.authority.service.AuthorityService;
import org.dspace.authority.service.AuthorityValueService; import org.dspace.authority.service.AuthorityValueService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
import java.util.List; import java.util.List;
@@ -38,6 +38,6 @@ public abstract class AuthorityServiceFactory {
public static AuthorityServiceFactory getInstance() public static AuthorityServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("authorityServiceFactory", AuthorityServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("authorityServiceFactory", AuthorityServiceFactory.class);
} }
} }

View File

@@ -14,7 +14,7 @@ import org.dspace.authority.orcid.xml.XMLtoBio;
import org.dspace.authority.orcid.xml.XMLtoWork; import org.dspace.authority.orcid.xml.XMLtoWork;
import org.dspace.authority.rest.RestSource; import org.dspace.authority.rest.RestSource;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import java.net.URLEncoder; import java.net.URLEncoder;
@@ -39,7 +39,7 @@ public class Orcid extends RestSource {
public static Orcid getOrcid() { public static Orcid getOrcid() {
if (orcid == null) { if (orcid == null) {
orcid = new DSpace().getServiceManager().getServiceByName("OrcidSource", Orcid.class); orcid = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("OrcidSource", Orcid.class);
} }
return orcid; return orcid;
} }

View File

@@ -9,7 +9,7 @@ package org.dspace.authorize.factory;
import org.dspace.authorize.service.AuthorizeService; import org.dspace.authorize.service.AuthorizeService;
import org.dspace.authorize.service.ResourcePolicyService; import org.dspace.authorize.service.ResourcePolicyService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the authorize package, use AuthorizeServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the authorize package, use AuthorizeServiceFactory.getInstance() to retrieve an implementation
@@ -24,6 +24,6 @@ public abstract class AuthorizeServiceFactory {
public static AuthorizeServiceFactory getInstance() public static AuthorizeServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("authorizeServiceFactory", AuthorizeServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("authorizeServiceFactory", AuthorizeServiceFactory.class);
} }
} }

View File

@@ -8,7 +8,6 @@
package org.dspace.browse; package org.dspace.browse;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.core.ConfigurationManager;
/** /**
* Command-line executed class for initializing the Browse tables of the DSpace database. * Command-line executed class for initializing the Browse tables of the DSpace database.
@@ -31,7 +30,6 @@ public class InitializeBrowseDatabase
System.exit(1); System.exit(1);
} }
ConfigurationManager.loadConfig(null);
log.info("Initializing Browse Database"); log.info("Initializing Browse Database");
try try

View File

@@ -23,7 +23,7 @@ import org.dspace.discovery.DiscoverResult.FacetResult;
import org.dspace.discovery.SearchService; import org.dspace.discovery.SearchService;
import org.dspace.discovery.SearchServiceException; import org.dspace.discovery.SearchServiceException;
import org.dspace.discovery.configuration.DiscoveryConfigurationParameters; import org.dspace.discovery.configuration.DiscoveryConfigurationParameters;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Discovery (Solr) driver implementing ItemCountDAO interface to look up item * Discovery (Solr) driver implementing ItemCountDAO interface to look up item
@@ -52,11 +52,9 @@ public class ItemCountDAOSolr implements ItemCountDAO
/** Hold the collection item count obtained from SOLR after the first query **/ /** Hold the collection item count obtained from SOLR after the first query **/
private Map<String, Integer> collectionsCount = null; private Map<String, Integer> collectionsCount = null;
/** DSpace helper services access object */
DSpace dspace = new DSpace();
/** Solr search service */ /** Solr search service */
SearchService searcher = dspace.getServiceManager().getServiceByName(SearchService.class.getName(), SearchService.class); SearchService searcher = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(SearchService.class.getName(), SearchService.class);
/** /**
* Throw an ItemCountException as caching is not supported by ItemCountDAOSolr. * Throw an ItemCountException as caching is not supported by ItemCountDAOSolr.

View File

@@ -23,10 +23,10 @@ import org.dspace.content.service.ItemService;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.discovery.SolrServiceImpl; import org.dspace.discovery.SolrServiceImpl;
import org.dspace.discovery.SolrServiceIndexPlugin; import org.dspace.discovery.SolrServiceIndexPlugin;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.dspace.sort.OrderFormat; import org.dspace.sort.OrderFormat;
import org.dspace.sort.SortException; import org.dspace.sort.SortException;
import org.dspace.sort.SortOption; import org.dspace.sort.SortOption;
import org.dspace.utils.DSpace;
/** /**
* *
@@ -136,13 +136,11 @@ public class SolrBrowseCreateDAO implements BrowseCreateDAO,
{ {
int minConfidence = metadataAuthorityService.getMinConfidence(values.get(0).getMetadataField()); int minConfidence = metadataAuthorityService.getMinConfidence(values.get(0).getMetadataField());
boolean ignoreAuthority = new DSpace() boolean ignoreAuthority = DSpaceServicesFactory.getInstance().getConfigurationService()
.getConfigurationService()
.getPropertyAsType( .getPropertyAsType(
"discovery.browse.authority.ignore." "discovery.browse.authority.ignore."
+ bi.getName(), + bi.getName(),
new DSpace() DSpaceServicesFactory.getInstance().getConfigurationService()
.getConfigurationService()
.getPropertyAsType( .getPropertyAsType(
"discovery.browse.authority.ignore", "discovery.browse.authority.ignore",
new Boolean(false)), new Boolean(false)),
@@ -187,13 +185,11 @@ public class SolrBrowseCreateDAO implements BrowseCreateDAO,
distValuesForAC.add(values.get(x).getValue()); distValuesForAC.add(values.get(x).getValue());
String preferedLabel = null; String preferedLabel = null;
boolean ignorePrefered = new DSpace() boolean ignorePrefered = DSpaceServicesFactory.getInstance().getConfigurationService()
.getConfigurationService()
.getPropertyAsType( .getPropertyAsType(
"discovery.browse.authority.ignore-prefered." "discovery.browse.authority.ignore-prefered."
+ bi.getName(), + bi.getName(),
new DSpace() DSpaceServicesFactory.getInstance().getConfigurationService()
.getConfigurationService()
.getPropertyAsType( .getPropertyAsType(
"discovery.browse.authority.ignore-prefered", "discovery.browse.authority.ignore-prefered",
new Boolean( new Boolean(
@@ -206,13 +202,11 @@ public class SolrBrowseCreateDAO implements BrowseCreateDAO,
} }
List<String> variants = null; List<String> variants = null;
boolean ignoreVariants = new DSpace() boolean ignoreVariants = DSpaceServicesFactory.getInstance().getConfigurationService()
.getConfigurationService()
.getPropertyAsType( .getPropertyAsType(
"discovery.browse.authority.ignore-variants." "discovery.browse.authority.ignore-variants."
+ bi.getName(), + bi.getName(),
new DSpace() DSpaceServicesFactory.getInstance().getConfigurationService()
.getConfigurationService()
.getPropertyAsType( .getPropertyAsType(
"discovery.browse.authority.ignore-variants", "discovery.browse.authority.ignore-variants",
new Boolean( new Boolean(

View File

@@ -24,7 +24,7 @@ import org.dspace.discovery.DiscoverResult.SearchDocument;
import org.dspace.discovery.SearchService; import org.dspace.discovery.SearchService;
import org.dspace.discovery.SearchServiceException; import org.dspace.discovery.SearchServiceException;
import org.dspace.discovery.configuration.DiscoveryConfigurationParameters; import org.dspace.discovery.configuration.DiscoveryConfigurationParameters;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* *
@@ -127,9 +127,8 @@ public class SolrBrowseDAO implements BrowseDAO
// administrative attributes for this class // administrative attributes for this class
DSpace dspace = new DSpace();
SearchService searcher = dspace.getServiceManager().getServiceByName( SearchService searcher = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(
SearchService.class.getName(), SearchService.class); SearchService.class.getName(), SearchService.class);
private DiscoverResult sResponse = null; private DiscoverResult sResponse = null;

View File

@@ -8,9 +8,9 @@
package org.dspace.checker; package org.dspace.checker;
import org.dspace.content.Bitstream; import org.dspace.content.Bitstream;
import org.dspace.core.PluginManager;
import java.sql.SQLException; import java.sql.SQLException;
import org.dspace.core.factory.CoreServiceFactory;
/** /**
* Decorator that dispatches a specified number of bitstreams from a delegate * Decorator that dispatches a specified number of bitstreams from a delegate
@@ -30,11 +30,11 @@ public class LimitedCountDispatcher implements BitstreamDispatcher
private BitstreamDispatcher delegate = null; private BitstreamDispatcher delegate = null;
/** /**
* Default constructor uses PluginManager * Default constructor uses LegacyPluginServiceImpl
*/ */
public LimitedCountDispatcher() public LimitedCountDispatcher()
{ {
this((BitstreamDispatcher) PluginManager this((BitstreamDispatcher) CoreServiceFactory.getInstance().getPluginService()
.getSinglePlugin(BitstreamDispatcher.class)); .getSinglePlugin(BitstreamDispatcher.class));
} }

View File

@@ -11,7 +11,7 @@ import org.dspace.checker.service.SimpleReporterService;
import org.dspace.checker.service.ChecksumHistoryService; import org.dspace.checker.service.ChecksumHistoryService;
import org.dspace.checker.service.ChecksumResultService; import org.dspace.checker.service.ChecksumResultService;
import org.dspace.checker.service.MostRecentChecksumService; import org.dspace.checker.service.MostRecentChecksumService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the checker package, use CheckerServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the checker package, use CheckerServiceFactory.getInstance() to retrieve an implementation
@@ -30,6 +30,6 @@ public abstract class CheckerServiceFactory {
public static CheckerServiceFactory getInstance() public static CheckerServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("checkerServiceFactory", CheckerServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("checkerServiceFactory", CheckerServiceFactory.class);
} }
} }

View File

@@ -10,16 +10,16 @@ package org.dspace.content.authority;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.util.Enumeration; import java.util.Iterator;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.content.Collection; import org.dspace.content.Collection;
import org.dspace.content.MetadataValue; import org.dspace.content.MetadataValue;
import org.dspace.content.authority.service.ChoiceAuthorityService; import org.dspace.content.authority.service.ChoiceAuthorityService;
import org.dspace.core.ConfigurationManager; import org.dspace.core.service.PluginService;
import org.dspace.core.PluginManager; import org.dspace.services.ConfigurationService;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired;
/** /**
* Broker for ChoiceAuthority plugins, and for other information configured * Broker for ChoiceAuthority plugins, and for other information configured
@@ -40,7 +40,7 @@ import org.springframework.beans.factory.InitializingBean;
* @author Larry Stone * @author Larry Stone
* @see ChoiceAuthority * @see ChoiceAuthority
*/ */
public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService, InitializingBean public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService
{ {
private Logger log = Logger.getLogger(ChoiceAuthorityServiceImpl.class); private Logger log = Logger.getLogger(ChoiceAuthorityServiceImpl.class);
@@ -53,75 +53,18 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService,
// map of field key to closed value // map of field key to closed value
protected Map<String,Boolean> closed = new HashMap<String,Boolean>(); protected Map<String,Boolean> closed = new HashMap<String,Boolean>();
@Autowired(required = true)
protected ConfigurationService configurationService;
@Autowired(required = true)
protected PluginService pluginService;
private final String CHOICES_PLUGIN_PREFIX = "choices.plugin.";
private final String CHOICES_PRESENTATION_PREFIX = "choices.presentation.";
private final String CHOICES_CLOSED_PREFIX = "choices.closed.";
private ChoiceAuthorityServiceImpl() { private ChoiceAuthorityServiceImpl() {
} }
@Override
public void afterPropertiesSet() throws Exception
{
Enumeration pn = ConfigurationManager.propertyNames();
final String choicesPrefix = "choices.";
final String choicesPlugin = "choices.plugin.";
final String choicesPresentation = "choices.presentation.";
final String choicesClosed = "choices.closed.";
property:
while (pn.hasMoreElements())
{
String key = (String)pn.nextElement();
if (key.startsWith(choicesPrefix))
{
if (key.startsWith(choicesPlugin))
{
String fkey = config2fkey(key.substring(choicesPlugin.length()));
if (fkey == null)
{
log.warn("Skipping invalid ChoiceAuthority configuration property: "+key+": does not have schema.element.qualifier");
continue property;
}
// XXX FIXME maybe add sanity check, call
// MetadataField.findByElement to make sure it's a real field.
ChoiceAuthority ma = (ChoiceAuthority)
PluginManager.getNamedPlugin(ChoiceAuthority.class, ConfigurationManager.getProperty(key));
if (ma == null)
{
log.warn("Skipping invalid configuration for "+key+" because named plugin not found: "+ConfigurationManager.getProperty(key));
continue property;
}
controller.put(fkey, ma);
log.debug("Choice Control: For field="+fkey+", Plugin="+ma);
}
else if (key.startsWith(choicesPresentation))
{
String fkey = config2fkey(key.substring(choicesPresentation.length()));
if (fkey == null)
{
log.warn("Skipping invalid ChoiceAuthority configuration property: "+key+": does not have schema.element.qualifier");
continue property;
}
presentation.put(fkey, ConfigurationManager.getProperty(key));
}
else if (key.startsWith(choicesClosed))
{
String fkey = config2fkey(key.substring(choicesClosed.length()));
if (fkey == null)
{
log.warn("Skipping invalid ChoiceAuthority configuration property: "+key+": does not have schema.element.qualifier");
continue property;
}
closed.put(fkey, Boolean.valueOf(ConfigurationManager.getBooleanProperty(key)));
}
else
{
log.error("Illegal configuration property: " + key);
}
}
}
}
// translate tail of configuration key (supposed to be schema.element.qual) // translate tail of configuration key (supposed to be schema.element.qual)
// into field key // into field key
protected String config2fkey(String field) protected String config2fkey(String field)
@@ -156,7 +99,7 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService,
public Choices getMatches(String fieldKey, String query, Collection collection, public Choices getMatches(String fieldKey, String query, Collection collection,
int start, int limit, String locale) int start, int limit, String locale)
{ {
ChoiceAuthority ma = controller.get(fieldKey); ChoiceAuthority ma = getChoiceAuthorityMap().get(fieldKey);
if (ma == null) if (ma == null)
{ {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@@ -168,7 +111,7 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService,
@Override @Override
public Choices getMatches(String fieldKey, String query, Collection collection, int start, int limit, String locale, boolean externalInput) { public Choices getMatches(String fieldKey, String query, Collection collection, int start, int limit, String locale, boolean externalInput) {
ChoiceAuthority ma = controller.get(fieldKey); ChoiceAuthority ma = getChoiceAuthorityMap().get(fieldKey);
if (ma == null) { if (ma == null) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"No choices plugin was configured for field \"" + fieldKey "No choices plugin was configured for field \"" + fieldKey
@@ -184,7 +127,7 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService,
public Choices getBestMatch(String fieldKey, String query, Collection collection, public Choices getBestMatch(String fieldKey, String query, Collection collection,
String locale) String locale)
{ {
ChoiceAuthority ma = controller.get(fieldKey); ChoiceAuthority ma = getChoiceAuthorityMap().get(fieldKey);
if (ma == null) if (ma == null)
{ {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@@ -203,7 +146,7 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService,
@Override @Override
public String getLabel(String fieldKey, String authKey, String locale) public String getLabel(String fieldKey, String authKey, String locale)
{ {
ChoiceAuthority ma = controller.get(fieldKey); ChoiceAuthority ma = getChoiceAuthorityMap().get(fieldKey);
if (ma == null) if (ma == null)
{ {
throw new IllegalArgumentException("No choices plugin was configured for field \"" + fieldKey + "\"."); throw new IllegalArgumentException("No choices plugin was configured for field \"" + fieldKey + "\".");
@@ -214,25 +157,25 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService,
@Override @Override
public boolean isChoicesConfigured(String fieldKey) public boolean isChoicesConfigured(String fieldKey)
{ {
return controller.containsKey(fieldKey); return getChoiceAuthorityMap().containsKey(fieldKey);
} }
@Override @Override
public String getPresentation(String fieldKey) public String getPresentation(String fieldKey)
{ {
return presentation.get(fieldKey); return getPresentationMap().get(fieldKey);
} }
@Override @Override
public boolean isClosed(String fieldKey) public boolean isClosed(String fieldKey)
{ {
return closed.containsKey(fieldKey) && closed.get(fieldKey); return getClosedMap().containsKey(fieldKey) && getClosedMap().get(fieldKey);
} }
@Override @Override
public List<String> getVariants(MetadataValue metadataValue) public List<String> getVariants(MetadataValue metadataValue)
{ {
ChoiceAuthority ma = controller.get(metadataValue.getMetadataField().toString()); ChoiceAuthority ma = getChoiceAuthorityMap().get(metadataValue.getMetadataField().toString());
if (ma instanceof AuthorityVariantsSupport) if (ma instanceof AuthorityVariantsSupport)
{ {
AuthorityVariantsSupport avs = (AuthorityVariantsSupport) ma; AuthorityVariantsSupport avs = (AuthorityVariantsSupport) ma;
@@ -253,4 +196,102 @@ public final class ChoiceAuthorityServiceImpl implements ChoiceAuthorityService,
} }
} }
/**
* Return map of key to ChoiceAuthority plugin
* @return
*/
private Map<String,ChoiceAuthority> getChoiceAuthorityMap()
{
// If empty, load from configuration
if(controller.isEmpty())
{
// Get all configuration keys starting with a given prefix
List<String> propKeys = configurationService.getPropertyKeys(CHOICES_PLUGIN_PREFIX);
Iterator<String> keyIterator = propKeys.iterator();
while(keyIterator.hasNext())
{
String key = keyIterator.next();
String fkey = config2fkey(key.substring(CHOICES_PLUGIN_PREFIX.length()));
if (fkey == null)
{
log.warn("Skipping invalid ChoiceAuthority configuration property: "+key+": does not have schema.element.qualifier");
continue;
}
// XXX FIXME maybe add sanity check, call
// MetadataField.findByElement to make sure it's a real field.
ChoiceAuthority ma = (ChoiceAuthority)
pluginService.getNamedPlugin(ChoiceAuthority.class, configurationService.getProperty(key));
if (ma == null)
{
log.warn("Skipping invalid configuration for "+key+" because named plugin not found: "+configurationService.getProperty(key));
continue;
}
controller.put(fkey, ma);
log.debug("Choice Control: For field="+fkey+", Plugin="+ma);
}
}
return controller;
}
/**
* Return map of key to presentation
* @return
*/
private Map<String,String> getPresentationMap()
{
// If empty, load from configuration
if(presentation.isEmpty())
{
// Get all configuration keys starting with a given prefix
List<String> propKeys = configurationService.getPropertyKeys(CHOICES_PRESENTATION_PREFIX);
Iterator<String> keyIterator = propKeys.iterator();
while(keyIterator.hasNext())
{
String key = keyIterator.next();
String fkey = config2fkey(key.substring(CHOICES_PRESENTATION_PREFIX.length()));
if (fkey == null)
{
log.warn("Skipping invalid ChoiceAuthority configuration property: "+key+": does not have schema.element.qualifier");
continue;
}
presentation.put(fkey, configurationService.getProperty(key));
}
}
return presentation;
}
/**
* Return map of key to closed setting
* @return
*/
private Map<String,Boolean> getClosedMap()
{
// If empty, load from configuration
if(closed.isEmpty())
{
// Get all configuration keys starting with a given prefix
List<String> propKeys = configurationService.getPropertyKeys(CHOICES_CLOSED_PREFIX);
Iterator<String> keyIterator = propKeys.iterator();
while(keyIterator.hasNext())
{
String key = keyIterator.next();
String fkey = config2fkey(key.substring(CHOICES_CLOSED_PREFIX.length()));
if (fkey == null)
{
log.warn("Skipping invalid ChoiceAuthority configuration property: "+key+": does not have schema.element.qualifier");
continue;
}
closed.put(fkey, configurationService.getBooleanProperty(key));
}
}
return closed;
}
} }

View File

@@ -14,6 +14,7 @@ import java.io.File;
import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.ArrayUtils;
import org.dspace.content.Collection; import org.dspace.content.Collection;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import javax.xml.xpath.XPath; import javax.xml.xpath.XPath;
@@ -25,8 +26,8 @@ import org.xml.sax.InputSource;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.SelfNamedPlugin; import org.dspace.core.SelfNamedPlugin;
import org.dspace.services.ConfigurationService;
/** /**
* ChoiceAuthority source that reads the JSPUI-style hierarchical vocabularies * ChoiceAuthority source that reads the JSPUI-style hierarchical vocabularies
@@ -94,7 +95,7 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
return name.endsWith(".xml"); return name.endsWith(".xml");
} }
} }
String vocabulariesPath = ConfigurationManager.getProperty("dspace.dir") String vocabulariesPath = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
+ "/config/controlled-vocabularies/"; + "/config/controlled-vocabularies/";
String[] xmlFiles = (new File(vocabulariesPath)).list(new xmlFilter()); String[] xmlFiles = (new File(vocabulariesPath)).list(new xmlFilter());
List<String> names = new ArrayList<String>(); List<String> names = new ArrayList<String>();
@@ -111,13 +112,15 @@ public class DSpaceControlledVocabulary extends SelfNamedPlugin implements Choic
{ {
if (vocabulary == null) if (vocabulary == null)
{ {
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
log.info("Initializing " + this.getClass().getName()); log.info("Initializing " + this.getClass().getName());
vocabularyName = this.getPluginInstanceName(); vocabularyName = this.getPluginInstanceName();
String vocabulariesPath = ConfigurationManager.getProperty("dspace.dir") + "/config/controlled-vocabularies/"; String vocabulariesPath = config.getProperty("dspace.dir") + "/config/controlled-vocabularies/";
String configurationPrefix = "vocabulary.plugin." + vocabularyName; String configurationPrefix = "vocabulary.plugin." + vocabularyName;
storeHierarchy = ConfigurationManager.getBooleanProperty(configurationPrefix + ".hierarchy.store", storeHierarchy); storeHierarchy = config.getBooleanProperty(configurationPrefix + ".hierarchy.store", storeHierarchy);
suggestHierarchy = ConfigurationManager.getBooleanProperty(configurationPrefix + ".hierarchy.suggest", suggestHierarchy); suggestHierarchy = config.getBooleanProperty(configurationPrefix + ".hierarchy.suggest", suggestHierarchy);
String configuredDelimiter = ConfigurationManager.getProperty(configurationPrefix + ".delimiter"); String configuredDelimiter = config.getProperty(configurationPrefix + ".delimiter");
if (configuredDelimiter != null) if (configuredDelimiter != null)
{ {
hierarchyDelimiter = configuredDelimiter.replaceAll("(^\"|\"$)",""); hierarchyDelimiter = configuredDelimiter.replaceAll("(^\"|\"$)","");

View File

@@ -21,7 +21,7 @@ import org.apache.solr.common.params.CommonParams;
import org.dspace.authority.service.AuthorityValueService; import org.dspace.authority.service.AuthorityValueService;
import org.dspace.content.Collection; import org.dspace.content.Collection;
import org.dspace.core.ConfigurationManager; import org.dspace.core.ConfigurationManager;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@@ -38,7 +38,7 @@ import java.util.Map;
public class SolrAuthority implements ChoiceAuthority { public class SolrAuthority implements ChoiceAuthority {
private static final Logger log = Logger.getLogger(SolrAuthority.class); private static final Logger log = Logger.getLogger(SolrAuthority.class);
protected RestSource source = new DSpace().getServiceManager().getServiceByName("AuthoritySource", RestSource.class); protected RestSource source = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("AuthoritySource", RestSource.class);
protected boolean externalResults = false; protected boolean externalResults = false;
protected final AuthorityValueService authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService(); protected final AuthorityValueService authorityValueService = AuthorityServiceFactory.getInstance().getAuthorityValueService();
@@ -249,9 +249,7 @@ public class SolrAuthority implements ChoiceAuthority {
public static AuthoritySearchService getSearchService() { public static AuthoritySearchService getSearchService() {
DSpace dspace = new DSpace(); org.dspace.kernel.ServiceManager manager = DSpaceServicesFactory.getInstance().getServiceManager();
org.dspace.kernel.ServiceManager manager = dspace.getServiceManager();
return manager.getServiceByName(AuthoritySearchService.class.getName(), AuthoritySearchService.class); return manager.getServiceByName(AuthoritySearchService.class.getName(), AuthoritySearchService.class);
} }

View File

@@ -9,7 +9,7 @@ package org.dspace.content.authority.factory;
import org.dspace.content.authority.service.ChoiceAuthorityService; import org.dspace.content.authority.service.ChoiceAuthorityService;
import org.dspace.content.authority.service.MetadataAuthorityService; import org.dspace.content.authority.service.MetadataAuthorityService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the content.authority package, use ContentAuthorityServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the content.authority package, use ContentAuthorityServiceFactory.getInstance() to retrieve an implementation
@@ -23,6 +23,6 @@ public abstract class ContentAuthorityServiceFactory {
public abstract MetadataAuthorityService getMetadataAuthorityService(); public abstract MetadataAuthorityService getMetadataAuthorityService();
public static ContentAuthorityServiceFactory getInstance(){ public static ContentAuthorityServiceFactory getInstance(){
return new DSpace().getServiceManager().getServiceByName("contentAuthorityServiceFactory", ContentAuthorityServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("contentAuthorityServiceFactory", ContentAuthorityServiceFactory.class);
} }
} }

View File

@@ -22,7 +22,7 @@ import org.dspace.content.packager.PackageParameters;
import org.dspace.core.ConfigurationManager; import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.PluginManager; import org.dspace.core.factory.CoreServiceFactory;
import org.jdom.Document; import org.jdom.Document;
import org.jdom.Element; import org.jdom.Element;
import org.jdom.JDOMException; import org.jdom.JDOMException;
@@ -101,7 +101,7 @@ public class METSDisseminationCrosswalk
} }
PackageDisseminator dip = (PackageDisseminator) PackageDisseminator dip = (PackageDisseminator)
PluginManager.getNamedPlugin(PackageDisseminator.class, METS_PACKAGER_PLUGIN); CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(PackageDisseminator.class, METS_PACKAGER_PLUGIN);
if (dip == null) if (dip == null)
{ {
throw new CrosswalkInternalException("Cannot find a disseminate plugin for package=" + METS_PACKAGER_PLUGIN); throw new CrosswalkInternalException("Cannot find a disseminate plugin for package=" + METS_PACKAGER_PLUGIN);

View File

@@ -71,7 +71,7 @@ import org.jdom.xpath.XPath;
* Since there is significant overhead in reading the properties file to * Since there is significant overhead in reading the properties file to
* configure the crosswalk, and a crosswalk instance may be used any number * configure the crosswalk, and a crosswalk instance may be used any number
* of times, we recommend caching one instance of the crosswalk for each * of times, we recommend caching one instance of the crosswalk for each
* name and simply reusing those instances. The PluginManager does this * name and simply reusing those instances. The PluginService does this
* by default. * by default.
* *
* @author Larry Stone * @author Larry Stone
@@ -222,7 +222,7 @@ public class MODSDisseminationCrosswalk extends SelfNamedPlugin
String myAlias = getPluginInstanceName(); String myAlias = getPluginInstanceName();
if (myAlias == null) if (myAlias == null)
{ {
log.error("Must use PluginManager to instantiate MODSDisseminationCrosswalk so the class knows its name."); log.error("Must use PluginService to instantiate MODSDisseminationCrosswalk so the class knows its name.");
return; return;
} }
String cmPropName = CONFIG_PREFIX+myAlias; String cmPropName = CONFIG_PREFIX+myAlias;

View File

@@ -22,9 +22,10 @@ import org.dspace.content.*;
import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.ItemService; import org.dspace.content.service.ItemService;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.Utils; import org.dspace.core.Utils;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.jdom.Element; import org.jdom.Element;
import org.jdom.Namespace; import org.jdom.Namespace;
@@ -56,6 +57,7 @@ public class OREDisseminationCrosswalk
private static final Namespace DS_NS = private static final Namespace DS_NS =
Namespace.getNamespace("ds","http://www.dspace.org/objectModel/"); Namespace.getNamespace("ds","http://www.dspace.org/objectModel/");
protected final ItemService itemService = ContentServiceFactory.getInstance().getItemService(); protected final ItemService itemService = ContentServiceFactory.getInstance().getItemService();
protected final ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
private static final Namespace namespaces[] = { ATOM_NS, ORE_NS, ORE_ATOM, RDF_NS, DCTERMS_NS, DS_NS }; private static final Namespace namespaces[] = { ATOM_NS, ORE_NS, ORE_ATOM, RDF_NS, DCTERMS_NS, DS_NS };
@@ -86,12 +88,12 @@ public class OREDisseminationCrosswalk
private Element disseminateItem(Context context, Item item) throws CrosswalkException, IOException, SQLException, AuthorizeException private Element disseminateItem(Context context, Item item) throws CrosswalkException, IOException, SQLException, AuthorizeException
{ {
String oaiUrl = null; String oaiUrl = null;
String dsUrl = ConfigurationManager.getProperty("dspace.url"); String dsUrl = configurationService.getProperty("dspace.url");
String remSource = ConfigurationManager.getProperty("oai", "ore.authoritative.source"); String remSource = configurationService.getProperty("oai.ore.authoritative.source");
if (remSource == null || remSource.equalsIgnoreCase("oai")) if (remSource == null || remSource.equalsIgnoreCase("oai"))
{ {
oaiUrl = ConfigurationManager.getProperty("oai", "dspace.oai.url"); oaiUrl = configurationService.getProperty("oai.url");
} }
else if (remSource.equalsIgnoreCase("xmlui") || remSource.equalsIgnoreCase("manakin")) else if (remSource.equalsIgnoreCase("xmlui") || remSource.equalsIgnoreCase("manakin"))
{ {
@@ -143,7 +145,7 @@ public class OREDisseminationCrosswalk
Element remCreator = new Element("source",ATOM_NS); Element remCreator = new Element("source",ATOM_NS);
Element remGenerator = new Element("generator",ATOM_NS); Element remGenerator = new Element("generator",ATOM_NS);
remGenerator.addContent(ConfigurationManager.getProperty("dspace.name")); remGenerator.addContent(configurationService.getProperty("dspace.name"));
remGenerator.setAttribute("uri", oaiUrl); remGenerator.setAttribute("uri", oaiUrl);
remCreator.addContent(remGenerator); remCreator.addContent(remGenerator);

View File

@@ -62,7 +62,7 @@ import org.jdom.input.SAXBuilder;
* Since there is significant overhead in reading the properties file to * Since there is significant overhead in reading the properties file to
* configure the crosswalk, and a crosswalk instance may be used any number * configure the crosswalk, and a crosswalk instance may be used any number
* of times, we recommend caching one instance of the crosswalk for each * of times, we recommend caching one instance of the crosswalk for each
* alias and simply reusing those instances. The PluginManager does * alias and simply reusing those instances. The PluginService does
* this by default. * this by default.
* <p> * <p>
* Each named crosswalk has two other types of configuration lines: * Each named crosswalk has two other types of configuration lines:
@@ -219,7 +219,7 @@ public class QDCCrosswalk extends SelfNamedPlugin
if (myName == null) if (myName == null)
{ {
throw new CrosswalkInternalException("Cannot determine plugin name, " + throw new CrosswalkInternalException("Cannot determine plugin name, " +
"You must use PluginManager to instantiate QDCCrosswalk so the instance knows its name."); "You must use PluginService to instantiate QDCCrosswalk so the instance knows its name.");
} }
// grovel DSpace configuration for namespaces // grovel DSpace configuration for namespaces

View File

@@ -23,7 +23,7 @@ import org.dspace.content.packager.RoleDisseminator;
import org.dspace.core.ConfigurationManager; import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.PluginManager; import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.workflow.WorkflowException; import org.dspace.workflow.WorkflowException;
import org.jdom.Document; import org.jdom.Document;
import org.jdom.Element; import org.jdom.Element;
@@ -176,7 +176,7 @@ public class RoleCrosswalk
try try
{ {
PackageDisseminator dip = (PackageDisseminator) PackageDisseminator dip = (PackageDisseminator)
PluginManager.getNamedPlugin(PackageDisseminator.class, ROLE_PACKAGER_PLUGIN); CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(PackageDisseminator.class, ROLE_PACKAGER_PLUGIN);
if (dip == null) if (dip == null)
{ {
throw new CrosswalkInternalException("Cannot find a PackageDisseminator plugin named " + ROLE_PACKAGER_PLUGIN); throw new CrosswalkInternalException("Cannot find a PackageDisseminator plugin named " + ROLE_PACKAGER_PLUGIN);
@@ -286,7 +286,7 @@ public class RoleCrosswalk
//locate our "DSPACE-ROLES" PackageIngester plugin //locate our "DSPACE-ROLES" PackageIngester plugin
PackageIngester sip = (PackageIngester) PackageIngester sip = (PackageIngester)
PluginManager.getNamedPlugin(PackageIngester.class, ROLE_PACKAGER_PLUGIN); CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(PackageIngester.class, ROLE_PACKAGER_PLUGIN);
if (sip == null) if (sip == null)
{ {
throw new CrosswalkInternalException("Cannot find a PackageIngester plugin named " + ROLE_PACKAGER_PLUGIN); throw new CrosswalkInternalException("Cannot find a PackageIngester plugin named " + ROLE_PACKAGER_PLUGIN);

View File

@@ -65,14 +65,14 @@ import org.jdom.transform.XSLTransformer;
* was modified since it was last loaded. This lets you edit and test * was modified since it was last loaded. This lets you edit and test
* stylesheets without restarting DSpace. * stylesheets without restarting DSpace.
* <p> * <p>
* You must use the <code>PluginManager</code> to instantiate an * You must use the <code>PluginService</code> to instantiate an
* XSLT crosswalk plugin, e.g. * XSLT crosswalk plugin, e.g.
* <pre> IngestionCrosswalk xwalk = PluginManager.getPlugin(IngestionCrosswalk.class, "LOM");</pre> * <pre> IngestionCrosswalk xwalk = CoreServiceFactory.getInstance().getPluginService().getPlugin(IngestionCrosswalk.class, "LOM");</pre>
* <p> * <p>
* Since there is significant overhead in reading the properties file to * Since there is significant overhead in reading the properties file to
* configure the crosswalk, and a crosswalk instance may be used any number * configure the crosswalk, and a crosswalk instance may be used any number
* of times, we recommend caching one instance of the crosswalk for each * of times, we recommend caching one instance of the crosswalk for each
* alias and simply reusing those instances. The <code>PluginManager</code> * alias and simply reusing those instances. The <code>PluginService</code>
* does this automatically. * does this automatically.
* *
* @author Larry Stone * @author Larry Stone
@@ -138,7 +138,7 @@ public abstract class XSLTCrosswalk extends SelfNamedPlugin
String myAlias = getPluginInstanceName(); String myAlias = getPluginInstanceName();
if (myAlias == null) if (myAlias == null)
{ {
log.error("Must use PluginManager to instantiate XSLTCrosswalk so the class knows its name."); log.error("Must use PluginService to instantiate XSLTCrosswalk so the class knows its name.");
return null; return null;
} }
String cmPropName = CONFIG_PREFIX+direction+"."+myAlias+CONFIG_STYLESHEET; String cmPropName = CONFIG_PREFIX+direction+"."+myAlias+CONFIG_STYLESHEET;

View File

@@ -28,7 +28,7 @@ import org.dspace.content.service.ItemService;
import org.dspace.core.ConfigurationManager; import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.PluginManager; import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.handle.factory.HandleServiceFactory; import org.dspace.handle.factory.HandleServiceFactory;
import org.jdom.Document; import org.jdom.Document;
import org.jdom.Element; import org.jdom.Element;
@@ -110,8 +110,8 @@ public class XSLTDisseminationCrosswalk
String myAlias = getPluginInstanceName(); String myAlias = getPluginInstanceName();
if (myAlias == null) if (myAlias == null)
{ {
log.error("Must use PluginManager to instantiate XSLTDisseminationCrosswalk so the class knows its name."); log.error("Must use PluginService to instantiate XSLTDisseminationCrosswalk so the class knows its name.");
throw new CrosswalkInternalException("Must use PluginManager to instantiate XSLTDisseminationCrosswalk so the class knows its name."); throw new CrosswalkInternalException("Must use PluginService to instantiate XSLTDisseminationCrosswalk so the class knows its name.");
} }
// all configs for this plugin instance start with this: // all configs for this plugin instance start with this:
@@ -525,7 +525,7 @@ public class XSLTDisseminationCrosswalk
} }
} }
DisseminationCrosswalk xwalk = (DisseminationCrosswalk)PluginManager.getNamedPlugin( DisseminationCrosswalk xwalk = (DisseminationCrosswalk) CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(
DisseminationCrosswalk.class, xwalkname); DisseminationCrosswalk.class, xwalkname);
if (xwalk == null) if (xwalk == null)
{ {

View File

@@ -30,7 +30,7 @@ import org.dspace.content.service.CommunityService;
import org.dspace.content.service.ItemService; import org.dspace.content.service.ItemService;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.PluginManager; import org.dspace.core.factory.CoreServiceFactory;
import org.jdom.Document; import org.jdom.Document;
import org.jdom.Element; import org.jdom.Element;
import org.jdom.input.SAXBuilder; import org.jdom.input.SAXBuilder;
@@ -287,7 +287,7 @@ public class XSLTIngestionCrosswalk
++i; ++i;
list = true; list = true;
} }
IngestionCrosswalk xwalk = (IngestionCrosswalk)PluginManager.getNamedPlugin( IngestionCrosswalk xwalk = (IngestionCrosswalk) CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(
IngestionCrosswalk.class, argv[i]); IngestionCrosswalk.class, argv[i]);
if (xwalk == null) if (xwalk == null)
{ {

View File

@@ -11,9 +11,7 @@ import org.dspace.content.DSpaceObject;
import org.dspace.content.InProgressSubmission; import org.dspace.content.InProgressSubmission;
import org.dspace.content.WorkspaceItem; import org.dspace.content.WorkspaceItem;
import org.dspace.content.service.*; import org.dspace.content.service.*;
import org.dspace.core.Constants; import org.dspace.services.factory.DSpaceServicesFactory;
import org.dspace.eperson.factory.EPersonServiceFactory;
import org.dspace.utils.DSpace;
import org.dspace.workflow.factory.WorkflowServiceFactory; import org.dspace.workflow.factory.WorkflowServiceFactory;
import java.util.List; import java.util.List;
@@ -101,7 +99,7 @@ public abstract class ContentServiceFactory {
} }
public static ContentServiceFactory getInstance(){ public static ContentServiceFactory getInstance(){
return new DSpace().getServiceManager().getServiceByName("contentServiceFactory", ContentServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("contentServiceFactory", ContentServiceFactory.class);
} }
} }

View File

@@ -10,12 +10,12 @@ package org.dspace.content.license;
import java.util.Formattable; import java.util.Formattable;
import java.util.Formatter; import java.util.Formatter;
import org.dspace.core.PluginManager; import org.dspace.core.factory.CoreServiceFactory;
/** /**
* Wrapper class to make formattable any argument used in the license template. * Wrapper class to make formattable any argument used in the license template.
* The formatter behavior is delegated to a specific class on "type" basis * The formatter behavior is delegated to a specific class on "type" basis
* using the PluginManager * using the PluginService
* *
* @see Formattable * @see Formattable
* @see LicenseArgumentFormatter * @see LicenseArgumentFormatter
@@ -38,7 +38,7 @@ public class FormattableArgument implements Formattable
public void formatTo(Formatter formatter, int flags, int width, public void formatTo(Formatter formatter, int flags, int width,
int precision) int precision)
{ {
LicenseArgumentFormatter laf = (LicenseArgumentFormatter) PluginManager LicenseArgumentFormatter laf = (LicenseArgumentFormatter) CoreServiceFactory.getInstance().getPluginService()
.getNamedPlugin(LicenseArgumentFormatter.class, type); .getNamedPlugin(LicenseArgumentFormatter.class, type);
if (laf != null) if (laf != null)
{ {

View File

@@ -73,8 +73,9 @@ import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.LogManager; import org.dspace.core.LogManager;
import org.dspace.core.PluginManager;
import org.dspace.core.Utils; import org.dspace.core.Utils;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import org.dspace.license.factory.LicenseServiceFactory; import org.dspace.license.factory.LicenseServiceFactory;
import org.dspace.license.service.CreativeCommonsService; import org.dspace.license.service.CreativeCommonsService;
import org.jdom.Element; import org.jdom.Element;
@@ -583,14 +584,16 @@ public abstract class AbstractMETSDisseminator
xwalkName = typeSpec; xwalkName = typeSpec;
} }
PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
// First, check to see if the crosswalk we are using is a normal DisseminationCrosswalk // First, check to see if the crosswalk we are using is a normal DisseminationCrosswalk
boolean xwalkFound = PluginManager.hasNamedPlugin(DisseminationCrosswalk.class, xwalkName); boolean xwalkFound = pluginService.hasNamedPlugin(DisseminationCrosswalk.class, xwalkName);
if(xwalkFound) if(xwalkFound)
{ {
// Find the crosswalk we will be using to generate the metadata for this mdSec // Find the crosswalk we will be using to generate the metadata for this mdSec
DisseminationCrosswalk xwalk = (DisseminationCrosswalk) DisseminationCrosswalk xwalk = (DisseminationCrosswalk)
PluginManager.getNamedPlugin(DisseminationCrosswalk.class, xwalkName); pluginService.getNamedPlugin(DisseminationCrosswalk.class, xwalkName);
if (xwalk.canDisseminate(dso)) if (xwalk.canDisseminate(dso))
{ {
@@ -629,7 +632,7 @@ public abstract class AbstractMETSDisseminator
else else
{ {
StreamDisseminationCrosswalk sxwalk = (StreamDisseminationCrosswalk) StreamDisseminationCrosswalk sxwalk = (StreamDisseminationCrosswalk)
PluginManager.getNamedPlugin(StreamDisseminationCrosswalk.class, xwalkName); pluginService.getNamedPlugin(StreamDisseminationCrosswalk.class, xwalkName);
if (sxwalk != null) if (sxwalk != null)
{ {
if (sxwalk.canDisseminate(context, dso)) if (sxwalk.canDisseminate(context, dso))

View File

@@ -37,21 +37,10 @@ import java.util.List;
* <P> * <P>
* All Package disseminators should either extend this abstract class * All Package disseminators should either extend this abstract class
* or implement <code>PackageDisseminator</code> to better suit their needs. * or implement <code>PackageDisseminator</code> to better suit their needs.
* <P>
* WARNING: If you choose to extend this Abstract class, you must DISABLE
* plugin instance caching for your new class in dspace.cfg. This will ensure
* that "packageFileList" and any other global instance variables are RESET
* for each package dissemination. To DISABLE plugin instance caching, just place
* the following configuration in your dspace.cfg:
* <code>
* plugin.reusable.[full-class-name] = false
* </code>
* For more information see the org.dspace.core.PluginManager cacheMe() method,
* which defaults to caching all plugin class instances.
* *
* @author Tim Donohue * @author Tim Donohue
* @see PackageDisseminator * @see PackageDisseminator
* @see PluginManager * @see PluginService
*/ */
public abstract class AbstractPackageDisseminator public abstract class AbstractPackageDisseminator
implements PackageDisseminator implements PackageDisseminator

View File

@@ -50,21 +50,10 @@ import org.dspace.workflow.WorkflowException;
* <P> * <P>
* All Package ingesters should either extend this abstract class * All Package ingesters should either extend this abstract class
* or implement <code>PackageIngester</code> to better suit their needs. * or implement <code>PackageIngester</code> to better suit their needs.
* <P>
* WARNING: If you choose to extend this Abstract class, you must DISABLE
* plugin instance caching for your new class in dspace.cfg. This will ensure
* the "pkgIngestedMap" and any other global instance variables are RESET
* for each package ingest. To DISABLE plugin instance caching, just place
* the following configuration in your dspace.cfg:
* <code>
* plugin.reusable.[full-class-name] = false
* </code>
* For more information see the org.dspace.core.PluginManager cacheMe() method,
* which defaults to caching all plugin class instances.
* *
* @author Tim Donohue * @author Tim Donohue
* @see PackageIngester * @see PackageIngester
* @see PluginManager * @see PluginService
*/ */
public abstract class AbstractPackageIngester public abstract class AbstractPackageIngester
implements PackageIngester implements PackageIngester

View File

@@ -20,8 +20,9 @@ import org.dspace.content.crosswalk.CrosswalkException;
import org.dspace.content.crosswalk.MetadataValidationException; import org.dspace.content.crosswalk.MetadataValidationException;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.PluginManager;
import org.dspace.app.mediafilter.MediaFilter; import org.dspace.app.mediafilter.MediaFilter;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import org.jdom.Element; import org.jdom.Element;
@@ -199,12 +200,14 @@ public class DSpaceMETSIngester
// only needed when importing a SIP without canonical DSpace derived file naming. // only needed when importing a SIP without canonical DSpace derived file naming.
private String makeDerivedFilename(String bundleName, String origName) private String makeDerivedFilename(String bundleName, String origName)
{ {
PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
// get the MediaFilter that would create this bundle: // get the MediaFilter that would create this bundle:
String mfNames[] = PluginManager.getAllPluginNames(MediaFilter.class); String mfNames[] = pluginService.getAllPluginNames(MediaFilter.class);
for (int i = 0; i < mfNames.length; ++i) for (int i = 0; i < mfNames.length; ++i)
{ {
MediaFilter mf = (MediaFilter)PluginManager.getNamedPlugin(MediaFilter.class, mfNames[i]); MediaFilter mf = (MediaFilter)pluginService.getNamedPlugin(MediaFilter.class, mfNames[i]);
if (bundleName.equals(mf.getBundleName())) if (bundleName.equals(mf.getBundleName()))
{ {
return mf.getFilteredName(origName); return mf.getFilteredName(origName);

View File

@@ -32,7 +32,7 @@ import org.dspace.content.crosswalk.StreamIngestionCrosswalk;
import org.dspace.core.ConfigurationManager; import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.PluginManager; import org.dspace.core.factory.CoreServiceFactory;
import org.jdom.Document; import org.jdom.Document;
import org.jdom.Content; import org.jdom.Content;
import org.jdom.Element; import org.jdom.Element;
@@ -989,7 +989,7 @@ public class METSManifest
xwalkName = type; xwalkName = type;
} }
} }
return PluginManager.getNamedPlugin(clazz, xwalkName); return CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(clazz, xwalkName);
} }
/** /**

View File

@@ -7,61 +7,37 @@
*/ */
package org.dspace.core; package org.dspace.core;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties; import java.util.Properties;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationConverter;
import org.apache.log4j.Category;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.log4j.helpers.OptionConverter; import org.dspace.services.factory.DSpaceServicesFactory;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.LicenseService;
import org.dspace.core.service.NewsService;
/** /**
* Class for reading the DSpace system configuration. The main configuration is * Class for reading the DSpace system configuration. The main configuration is
* read in as properties from a standard properties file. * read in as properties from a standard properties file.
* <P> * <P>
* The main configuration is by default read from the <em>resource</em>
* <code>/dspace.cfg</code>.
* To specify a different configuration, the system property * To specify a different configuration, the system property
* <code>dspace.configuration</code> should be set to the <em>filename</em> * <code>dspace.dir</code> should be set to the DSpace installation directory.
* of the configuration file.
* <P> * <P>
* Other configuration files are read from the <code>config</code> directory * Other configuration files are read from the <code>config</code> directory
* of the DSpace installation directory (specified as the property * of the DSpace installation directory.
* <code>dspace.dir</code> in the main configuration file.)
* *
* *
* @author Robert Tansley * @author Robert Tansley
* @author Larry Stone - Interpolated values. * @author Larry Stone - Interpolated values.
* @author Mark Diggory - General Improvements to detection, logging and loading. * @author Mark Diggory - General Improvements to detection, logging and loading.
* @author Tim Donohue - Refactored to wrap ConfigurationService
* @version $Revision$ * @version $Revision$
* @deprecated Please use org.dspace.services.ConfigurationService. See examples below.
*/ */
public class ConfigurationManager public class ConfigurationManager
{ {
/** log4j category */ /** log4j category */
private static Logger log = Logger.getLogger(ConfigurationManager.class); private static Logger log = Logger.getLogger(ConfigurationManager.class);
/** The configuration properties */
private static Properties properties = null;
/** module configuration properties */
private static Map<String, Properties> moduleProps = new HashMap<String, Properties>();
// limit of recursive depth of property variable interpolation in
// configuration; anything greater than this is very likely to be a loop.
private static final int RECURSION_LIMIT = 9;
protected ConfigurationManager() protected ConfigurationManager()
{ {
@@ -73,40 +49,9 @@ public class ConfigurationManager
*/ */
public static boolean isConfigured() public static boolean isConfigured()
{ {
return properties != null; return DSpaceServicesFactory.getInstance().getConfigurationService() != null;
} }
public static boolean isConfigured(String module)
{
return moduleProps.get(module) != null;
}
/**
* REMOVED - Flushing the properties could be dangerous in the current DSpace state
* Need to consider how it will affect in-flight processes
*
* Discard all current properties - will force a reload from disk when
* any properties are requested.
*/
// public static void flush()
// {
// properties = null;
// }
/**
* REMOVED - Flushing the properties could be dangerous in the current DSpace state
* Need to consider how it will affect in-flight processes
*
* Discard properties for a module - will force a reload from disk
* when any of module's properties are requested
*
* @param module the module name
*/
// public static void flush(String module)
// {
// moduleProps.remove(module);
// }
/** /**
* Returns all properties in main configuration * Returns all properties in main configuration
* *
@@ -114,18 +59,7 @@ public class ConfigurationManager
*/ */
public static Properties getProperties() public static Properties getProperties()
{ {
Properties props = getMutableProperties(); return DSpaceServicesFactory.getInstance().getConfigurationService().getProperties();
return props == null ? null : (Properties)props.clone();
}
private static Properties getMutableProperties()
{
if (properties == null)
{
loadConfig(null);
}
return properties;
} }
/** /**
@@ -137,23 +71,11 @@ public class ConfigurationManager
*/ */
public static Properties getProperties(String module) public static Properties getProperties(String module)
{ {
Properties props = getMutableProperties(module); // Find subset of Configurations which have been prefixed with the module name
return props == null ? null : (Properties)props.clone(); Configuration subset = DSpaceServicesFactory.getInstance().getConfigurationService().getConfiguration().subset(module);
}
private static Properties getMutableProperties(String module) // Convert to a Properties object and return it
{ return ConfigurationConverter.getProperties(subset);
if (module == null)
return properties;
Properties retProps = moduleProps.get(module);
if (retProps == null)
{
loadModuleConfig(module);
retProps = moduleProps.get(module);
}
return retProps;
} }
/** /**
@@ -167,9 +89,7 @@ public class ConfigurationManager
*/ */
public static String getProperty(String property) public static String getProperty(String property)
{ {
Properties props = getMutableProperties(); return DSpaceServicesFactory.getInstance().getConfigurationService().getProperty(property);
String value = props == null ? null : props.getProperty(property);
return (value != null) ? value.trim() : null;
} }
/** /**
@@ -191,21 +111,8 @@ public class ConfigurationManager
return getProperty(property); return getProperty(property);
} }
String value = null; // Assume "module" properties are always prefixed with the module name
Properties modProps = getMutableProperties(module); return getProperty(module + "." + property);
if (modProps != null)
{
value = modProps.getProperty(property);
}
if (value == null)
{
// look in regular properties with module name prepended
value = getProperty(module + "." + property);
}
return (value != null) ? value.trim() : null;
} }
/** /**
@@ -220,7 +127,7 @@ public class ConfigurationManager
*/ */
public static int getIntProperty(String property) public static int getIntProperty(String property)
{ {
return getIntProperty(property, 0); return DSpaceServicesFactory.getInstance().getConfigurationService().getIntProperty(property);
} }
/** /**
@@ -238,7 +145,13 @@ public class ConfigurationManager
*/ */
public static int getIntProperty(String module, String property) public static int getIntProperty(String module, String property)
{ {
return getIntProperty(module, property, 0); if (module == null)
{
return getIntProperty(property);
}
// Assume "module" properties are always prefixed with the module name
return getIntProperty(module + "." + property);
} }
/** /**
@@ -257,7 +170,7 @@ public class ConfigurationManager
*/ */
public static int getIntProperty(String property, int defaultValue) public static int getIntProperty(String property, int defaultValue)
{ {
return getIntProperty(null, property, defaultValue); return DSpaceServicesFactory.getInstance().getConfigurationService().getIntProperty(property, defaultValue);
} }
/** /**
@@ -279,22 +192,13 @@ public class ConfigurationManager
*/ */
public static int getIntProperty(String module, String property, int defaultValue) public static int getIntProperty(String module, String property, int defaultValue)
{ {
String stringValue = getProperty(module, property); if (module == null)
int intValue = defaultValue;
if (stringValue != null)
{ {
try return getIntProperty(property, defaultValue);
{
intValue = Integer.parseInt(stringValue.trim());
}
catch (NumberFormatException e)
{
warn("Warning: Number format error in property: " + property);
}
} }
return intValue; // Assume "module" properties are always prefixed with the module name
return getIntProperty(module + "." + property, defaultValue);
} }
/** /**
@@ -309,7 +213,7 @@ public class ConfigurationManager
*/ */
public static long getLongProperty(String property) public static long getLongProperty(String property)
{ {
return getLongProperty(property, 0); return DSpaceServicesFactory.getInstance().getConfigurationService().getLongProperty(property);
} }
/** /**
@@ -326,7 +230,13 @@ public class ConfigurationManager
*/ */
public static long getLongProperty(String module, String property) public static long getLongProperty(String module, String property)
{ {
return getLongProperty(module, property, 0); if (module == null)
{
return getLongProperty(property);
}
// Assume "module" properties are always prefixed with the module name
return getLongProperty(module + "." + property);
} }
/** /**
@@ -346,7 +256,7 @@ public class ConfigurationManager
*/ */
public static long getLongProperty(String property, int defaultValue) public static long getLongProperty(String property, int defaultValue)
{ {
return getLongProperty(null, property, defaultValue); return DSpaceServicesFactory.getInstance().getConfigurationService().getLongProperty(property, defaultValue);
} }
/** /**
@@ -367,22 +277,13 @@ public class ConfigurationManager
*/ */
public static long getLongProperty(String module, String property, int defaultValue) public static long getLongProperty(String module, String property, int defaultValue)
{ {
String stringValue = getProperty(module, property); if (module == null)
long longValue = defaultValue;
if (stringValue != null)
{ {
try return getLongProperty(property, defaultValue);
{
longValue = Long.parseLong(stringValue.trim());
}
catch (NumberFormatException e)
{
warn("Warning: Number format error in property: " + property);
}
} }
return longValue; // Assume "module" properties are always prefixed with the module name
return getLongProperty(module + "." + property, defaultValue);
} }
/** /**
@@ -400,7 +301,7 @@ public class ConfigurationManager
*/ */
public static boolean getBooleanProperty(String property) public static boolean getBooleanProperty(String property)
{ {
return getBooleanProperty(property, false); return DSpaceServicesFactory.getInstance().getConfigurationService().getBooleanProperty(property);
} }
/** /**
@@ -420,7 +321,13 @@ public class ConfigurationManager
*/ */
public static boolean getBooleanProperty(String module, String property) public static boolean getBooleanProperty(String module, String property)
{ {
return getBooleanProperty(module, property, false); if (module == null)
{
return getBooleanProperty(property);
}
// Assume "module" properties are always prefixed with the module name
return getBooleanProperty(module + "." + property);
} }
/** /**
@@ -442,7 +349,7 @@ public class ConfigurationManager
*/ */
public static boolean getBooleanProperty(String property, boolean defaultValue) public static boolean getBooleanProperty(String property, boolean defaultValue)
{ {
return getBooleanProperty(null, property, defaultValue); return DSpaceServicesFactory.getInstance().getConfigurationService().getBooleanProperty(property, defaultValue);
} }
/** /**
@@ -466,32 +373,34 @@ public class ConfigurationManager
*/ */
public static boolean getBooleanProperty(String module, String property, boolean defaultValue) public static boolean getBooleanProperty(String module, String property, boolean defaultValue)
{ {
String stringValue = getProperty(module, property); if (module == null)
{
return getBooleanProperty(property, defaultValue);
}
if (stringValue != null) // Assume "module" properties are always prefixed with the module name
{ return getBooleanProperty(module + "." + property, defaultValue);
stringValue = stringValue.trim();
return stringValue.equalsIgnoreCase("true") ||
stringValue.equalsIgnoreCase("yes");
}
else
{
return defaultValue;
}
} }
/** /**
* Returns an enumeration of all the keys in the DSpace configuration * Returns an enumeration of all the keys in the DSpace configuration
* <P>
* As ConfigurationManager is now deprecated, older code using this method
* should consider using ConfigurationService.getPropertyKeys() directly.
* *
* @return an enumeration of all the keys in the DSpace configuration * @return an enumeration of all the keys in the DSpace configuration
*/ */
public static Enumeration<?> propertyNames() public static Enumeration<?> propertyNames()
{ {
return propertyNames(null); // Get a list of all property keys, and convert into an Enumeration
return java.util.Collections.enumeration(DSpaceServicesFactory.getInstance().getConfigurationService().getPropertyKeys());
} }
/** /**
* Returns an enumeration of all the keys in a module configuration * Returns an enumeration of all the keys in a module configuration
* <P>
* As ConfigurationManager is now deprecated, older code using this method
* should consider using ConfigurationService.getPropertyKeys(String prefix) directly.
* *
* @param module module, or <code>null</code> for regular property * @param module module, or <code>null</code> for regular property
* *
@@ -500,398 +409,8 @@ public class ConfigurationManager
*/ */
public static Enumeration<?> propertyNames(String module) public static Enumeration<?> propertyNames(String module)
{ {
Properties props = getProperties(module); // Get property keys beginning with this prefix, and convert into an Enumeration
return props == null ? null : props.propertyNames(); return java.util.Collections.enumeration(DSpaceServicesFactory.getInstance().getConfigurationService().getPropertyKeys(module));
}
/** The configuration that was loaded. */
private static File loadedFile = null;
/**
* Return the file that configuration was actually loaded from.
*
* @deprecated Please remove all direct usage of the configuration file.
* @return File naming configuration data file.
*/
protected static File getConfigurationFile()
{
// in case it hasn't been done yet.
if (loadedFile == null)
{
loadConfig(null);
}
return loadedFile;
}
private static synchronized void loadModuleConfig(String module)
{
// try to find it in modules
File modFile = null;
try
{
modFile = new File(getProperty("dspace.dir") +
File.separator + "config" +
File.separator + "modules" +
File.separator + module + ".cfg");
if (modFile.exists())
{
Properties modProps = new Properties();
InputStream modIS = null;
InputStreamReader modIR = null;
try
{
modIS = new FileInputStream(modFile);
modIR = new InputStreamReader(modIS, "UTF-8");
modProps.load(modIR);
}
finally
{
if (modIR != null)
{
modIR.close();
}
if (modIS != null)
{
modIS.close();
}
}
for (Enumeration pe = modProps.propertyNames(); pe.hasMoreElements(); )
{
String key = (String)pe.nextElement();
String ival = interpolate(key, modProps.getProperty(key), 1);
if (ival != null)
{
modProps.setProperty(key, ival);
}
}
moduleProps.put(module, modProps);
}
else
{
// log invalid request
warn("Requested configuration module: " + module + " not found");
}
}
catch (IOException ioE)
{
fatal("Can't load configuration: " +
(modFile == null ? "<unknown>" : modFile.getAbsolutePath()), ioE);
}
}
/**
* Load the DSpace configuration properties. Only does anything if
* properties are not already loaded. Properties are loaded in from the
* specified file, or default locations.
*
* @param configFile
* The <code>dspace.cfg</code> configuration file to use, or
* <code>null</code> to try default locations
*/
public static synchronized void loadConfig(String configFile)
{
if (properties != null)
{
return;
}
URL url = null;
InputStream is = null;
InputStreamReader reader = null;
try
{
String configProperty = null;
try
{
configProperty = System.getProperty("dspace.configuration");
}
catch (SecurityException se)
{
// A security manager may stop us from accessing the system properties.
// This isn't really a fatal error though, so catch and ignore
log.warn("Unable to access system properties, ignoring.", se);
}
// should only occur after a flush()
if (loadedFile != null)
{
info("Reloading current config file: " + loadedFile.getAbsolutePath());
url = loadedFile.toURI().toURL();
}
else if (configFile != null)
{
info("Loading provided config file: " + configFile);
loadedFile = new File(configFile);
url = loadedFile.toURI().toURL();
}
// Has the default configuration location been overridden?
else if (configProperty != null)
{
info("Loading system provided config property (-Ddspace.configuration): " + configProperty);
// Load the overriding configuration
loadedFile = new File(configProperty);
url = loadedFile.toURI().toURL();
}
// Load configuration from default location
else
{
url = ConfigurationManager.class.getResource("/dspace.cfg");
if (url != null)
{
info("Loading from classloader: " + url);
loadedFile = new File(url.getPath());
}
}
if (url == null)
{
fatal("Cannot find dspace.cfg");
throw new IllegalStateException("Cannot find dspace.cfg");
}
else
{
properties = new Properties();
is = url.openStream();
reader = new InputStreamReader(is, "UTF-8");
properties.load(reader);
// walk values, interpolating any embedded references.
for (Enumeration<?> pe = properties.propertyNames(); pe.hasMoreElements(); )
{
String key = (String)pe.nextElement();
String value = interpolate(key, properties.getProperty(key), 1);
if (value != null)
{
properties.setProperty(key, value);
}
}
}
}
catch (IOException e)
{
fatal("Can't load configuration: " + url, e);
// FIXME: Maybe something more graceful here, but without a
// configuration we can't do anything.
throw new IllegalStateException("Cannot load configuration: " + url, e);
}
finally
{
if (reader != null)
{
try {
reader.close();
}
catch (IOException ioe)
{
}
}
if (is != null)
{
try
{
is.close();
}
catch (IOException ioe)
{
}
}
}
try
{
/*
* Initialize Logging once ConfigurationManager is initialized.
*
* This is controlled by a property in dspace.cfg. If the property
* is absent then nothing will be configured and the application
* will use the defaults provided by log4j.
*
* Property format is:
*
* log.init.config = ${dspace.dir}/config/log4j.properties
* or
* log.init.config = ${dspace.dir}/config/log4j.xml
*
* See default log4j initialization documentation here:
* http://logging.apache.org/log4j/docs/manual.html
*
* If there is a problem with the file referred to in
* "log.configuration", it needs to be sent to System.err
* so do not instantiate another Logging configuration.
*
*/
String dsLogConfiguration = ConfigurationManager.getProperty("log.init.config");
if (dsLogConfiguration == null || System.getProperty("dspace.log.init.disable") != null)
{
/*
* Do nothing if log config not set in dspace.cfg or "dspace.log.init.disable"
* system property set. Leave it upto log4j to properly init its logging
* via classpath or system properties.
*/
info("Using default log4j provided log configuration." +
" If unintended, check your dspace.cfg for (log.init.config)");
}
else
{
info("Using dspace provided log configuration (log.init.config)");
File logConfigFile = new File(dsLogConfiguration);
if(logConfigFile.exists())
{
info("Loading: " + dsLogConfiguration);
OptionConverter.selectAndConfigure(logConfigFile.toURI()
.toURL(), null, org.apache.log4j.LogManager
.getLoggerRepository());
}
else
{
info("File does not exist: " + dsLogConfiguration);
}
}
}
catch (MalformedURLException e)
{
fatal("Can't load dspace provided log4j configuration", e);
throw new IllegalStateException("Cannot load dspace provided log4j configuration",e);
}
}
/**
* Wrapper for {@link NewsService#getNewsFilePath()}.
* @deprecated since 4.0
*/
public static String getNewsFilePath()
{
return CoreServiceFactory.getInstance().getNewsService().getNewsFilePath();
}
/**
* Wrapper for {@link NewsService#readNewsFile(java.lang.String)}.
* @deprecated since 4.0
*/
public static String readNewsFile(String name)
{
return CoreServiceFactory.getInstance().getNewsService().readNewsFile(name);
}
/**
* Wrapper for {@link NewsService#writeNewsFile(java.lang.String, java.lang.String)}.
* @deprecated since 4.0
*/
public static String writeNewsFile(String file, String news)
{
return CoreServiceFactory.getInstance().getNewsService().writeNewsFile(file, news);
}
/**
* Wrapper for {@link LicenseService#getLicenseText(java.lang.String)}.
* @deprecated since 4.0
*/
public static String getLicenseText(String licenseFile)
{
return CoreServiceFactory.getInstance().getLicenseService().getLicenseText(licenseFile);
}
/**
* Wrapper for {@link LicenseService#getDefaultSubmissionLicense()}.
* @deprecated since 4.0
*/
public static String getDefaultSubmissionLicense()
{
return CoreServiceFactory.getInstance().getLicenseService().getDefaultSubmissionLicense();
}
/**
* Wrapper for {@link LicenseService#writeLicenseFile(java.lang.String, java.lang.String)}.
* @deprecated since 4.0
*/
public static void writeLicenseFile(String licenseFile, String newLicense)
{
CoreServiceFactory.getInstance().getLicenseService().writeLicenseFile(licenseFile, newLicense);
}
/**
* Recursively interpolate variable references in value of
* property named "key".
* @return new value if it contains interpolations, or null
* if it had no variable references.
*/
private static String interpolate(String key, String value, int level)
{
if (level > RECURSION_LIMIT)
{
throw new IllegalArgumentException("ConfigurationManager: Too many levels of recursion in configuration property variable interpolation, property=" + key);
}
//String value = (String)properties.get(key);
int from = 0;
StringBuffer result = null;
while (from < value.length())
{
int start = value.indexOf("${", from);
if (start >= 0)
{
int end = value.indexOf('}', start);
if (end < 0)
{
break;
}
String var = value.substring(start+2, end);
if (result == null)
{
result = new StringBuffer(value.substring(from, start));
}
else
{
result.append(value.substring(from, start));
}
if (properties.containsKey(var))
{
String ivalue = interpolate(var, properties.getProperty(var), level+1);
if (ivalue != null)
{
result.append(ivalue);
properties.setProperty(var, ivalue);
}
else
{
result.append(((String)properties.getProperty(var)).trim());
}
}
else
{
log.warn("Interpolation failed in value of property \""+key+
"\", there is no property named \""+var+"\"");
}
from = end+1;
}
else
{
break;
}
}
if (result != null && from < value.length())
{
result.append(value.substring(from));
}
return (result == null) ? null : result.toString();
} }
/** /**
@@ -910,11 +429,11 @@ public class ConfigurationManager
{ {
if ((argv.length == 2) && argv[0].equals("-property")) if ((argv.length == 2) && argv[0].equals("-property"))
{ {
String val = getProperty(argv[1]); Object val = DSpaceServicesFactory.getInstance().getConfigurationService().getPropertyValue(argv[1]);
if (val != null) if (val != null)
{ {
System.out.println(val); System.out.println(val.toString());
} }
else else
{ {
@@ -926,11 +445,11 @@ public class ConfigurationManager
else if ((argv.length == 4) && argv[0].equals("-module") && else if ((argv.length == 4) && argv[0].equals("-module") &&
argv[2].equals("-property")) argv[2].equals("-property"))
{ {
String val = getProperty(argv[1], argv[3]); Object val = DSpaceServicesFactory.getInstance().getConfigurationService().getPropertyValue(argv[1] + "." + argv[3]);
if (val != null) if (val != null)
{ {
System.out.println(val); System.out.println(val.toString());
} }
else else
{ {
@@ -947,82 +466,4 @@ public class ConfigurationManager
System.exit(1); System.exit(1);
} }
private static void info(String string)
{
if (!isLog4jConfigured())
{
System.out.println("INFO: " + string);
}
else
{
log.info(string);
}
}
private static void warn(String string)
{
if (!isLog4jConfigured())
{
System.out.println("WARN: " + string);
}
else
{
log.warn(string);
}
}
private static void fatal(String string, Exception e)
{
if (!isLog4jConfigured())
{
System.out.println("FATAL: " + string);
e.printStackTrace();
}
else
{
log.fatal(string, e);
}
}
private static void fatal(String string)
{
if (!isLog4jConfigured())
{
System.out.println("FATAL: " + string);
}
else
{
log.fatal(string);
}
}
/*
* Only current solution available to detect
* if log4j is truly configured.
*/
private static boolean isLog4jConfigured()
{
Enumeration<?> en = org.apache.log4j.LogManager.getRootLogger()
.getAllAppenders();
if (!(en instanceof org.apache.log4j.helpers.NullEnumeration))
{
return true;
}
else
{
Enumeration<?> cats = Category.getCurrentCategories();
while (cats.hasMoreElements())
{
Category c = (Category) cats.nextElement();
if (!(c.getAllAppenders() instanceof org.apache.log4j.helpers.NullEnumeration))
{
return true;
}
}
}
return false;
}
} }

View File

@@ -37,15 +37,15 @@ import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart; import javax.mail.internet.MimeMultipart;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.services.EmailService; import org.dspace.services.ConfigurationService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Class representing an e-mail message, also used to send e-mails. * Class representing an e-mail message, also used to send e-mails.
* <P> * <P>
* Typical use: * Typical use:
* <P> * <P>
* <code>Email email = ConfigurationManager.getEmail(name);</code><br> * <code>Email email = new Email();</code><br>
* <code>email.addRecipient("foo@bar.com");</code><br> * <code>email.addRecipient("foo@bar.com");</code><br>
* <code>email.addArgument("John");</code><br> * <code>email.addArgument("John");</code><br>
* <code>email.addArgument("On the Testing of DSpace");</code><br> * <code>email.addArgument("On the Testing of DSpace");</code><br>
@@ -236,19 +236,20 @@ public class Email
*/ */
public void send() throws MessagingException, IOException public void send() throws MessagingException, IOException
{ {
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
// Get the mail configuration properties // Get the mail configuration properties
String from = ConfigurationManager.getProperty("mail.from.address"); String from = config.getProperty("mail.from.address");
boolean disabled = ConfigurationManager.getBooleanProperty("mail.server.disabled", false); boolean disabled = config.getBooleanProperty("mail.server.disabled", false);
// If no character set specified, attempt to retrieve a default // If no character set specified, attempt to retrieve a default
if (charset == null) if (charset == null)
{ {
charset = ConfigurationManager.getProperty("mail.charset"); charset = config.getProperty("mail.charset");
} }
// Get session // Get session
Session session = new DSpace().getServiceManager(). Session session = DSpaceServicesFactory.getInstance().getEmailService().getSession();
getServicesByType(EmailService.class).get(0).getSession();
// Create message // Create message
MimeMessage message = new MimeMessage(session); MimeMessage message = new MimeMessage(session);
@@ -462,10 +463,11 @@ public class Email
*/ */
public static void main(String[] args) public static void main(String[] args)
{ {
String to = ConfigurationManager.getProperty("mail.admin"); ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
String to = config.getProperty("mail.admin");
String subject = "DSpace test email"; String subject = "DSpace test email";
String server = ConfigurationManager.getProperty("mail.server"); String server = config.getProperty("mail.server");
String url = ConfigurationManager.getProperty("dspace.url"); String url = config.getProperty("dspace.url");
Email e = new Email(); Email e = new Email();
e.setSubject(subject); e.setSubject(subject);
e.addRecipient(to); e.addRecipient(to);
@@ -474,7 +476,7 @@ public class Email
System.out.println(" - To: " + to); System.out.println(" - To: " + to);
System.out.println(" - Subject: " + subject); System.out.println(" - Subject: " + subject);
System.out.println(" - Server: " + server); System.out.println(" - Server: " + server);
boolean disabled = ConfigurationManager.getBooleanProperty("mail.server.disabled", false); boolean disabled = config.getBooleanProperty("mail.server.disabled", false);
try try
{ {
if( disabled) if( disabled)

View File

@@ -18,6 +18,8 @@ import java.util.ResourceBundle;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.List; import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
import org.dspace.services.ConfigurationService;
import org.dspace.services.factory.DSpaceServicesFactory;
@@ -54,11 +56,12 @@ public class I18nUtil
*/ */
public static Locale getDefaultLocale() public static Locale getDefaultLocale()
{ {
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
// First, try configured default locale // First, try configured default locale
Locale defaultLocale = null; Locale defaultLocale = null;
if (!StringUtils.isEmpty(ConfigurationManager.getProperty("default.locale"))) if (config.hasProperty("default.locale"))
{ {
defaultLocale = makeLocale(ConfigurationManager.getProperty("default.locale")); defaultLocale = makeLocale(config.getProperty("default.locale"));
} }
// Finally, get the Locale of the JVM // Finally, get the Locale of the JVM
@@ -123,11 +126,12 @@ public class I18nUtil
*/ */
public static Locale[] getSupportedLocales() public static Locale[] getSupportedLocales()
{ {
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
String ll = ConfigurationManager.getProperty("webui.supported.locales"); String[] locales = config.getArrayProperty("webui.supported.locales");
if (ll != null) if (locales != null && locales.length>0)
{ {
return parseLocales(ll); return parseLocales(locales);
} }
else else
{ {
@@ -231,7 +235,7 @@ public class I18nUtil
String fileName = ""; String fileName = "";
final String FORM_DEF_FILE = "input-forms"; final String FORM_DEF_FILE = "input-forms";
final String FILE_TYPE = ".xml"; final String FILE_TYPE = ".xml";
String defsFilename = ConfigurationManager.getProperty("dspace.dir") String defsFilename = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
+ File.separator + "config" + File.separator + FORM_DEF_FILE; + File.separator + "config" + File.separator + FORM_DEF_FILE;
fileName = getFilename(locale, defsFilename, FILE_TYPE); fileName = getFilename(locale, defsFilename, FILE_TYPE);
return fileName; return fileName;
@@ -319,7 +323,7 @@ public class I18nUtil
/** Name of the default license */ /** Name of the default license */
final String DEF_LIC_FILE = "default"; final String DEF_LIC_FILE = "default";
final String FILE_TYPE = ".license"; final String FILE_TYPE = ".license";
String defsFilename = ConfigurationManager.getProperty("dspace.dir") String defsFilename = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
+ File.separator + "config" + File.separator + DEF_LIC_FILE; + File.separator + "config" + File.separator + DEF_LIC_FILE;
fileName = getFilename(locale, defsFilename, FILE_TYPE); fileName = getFilename(locale, defsFilename, FILE_TYPE);
@@ -419,7 +423,7 @@ public class I18nUtil
public static String getEmailFilename(Locale locale, String name) public static String getEmailFilename(Locale locale, String name)
{ {
String templateName = ""; String templateName = "";
String templateFile = ConfigurationManager.getProperty("dspace.dir") String templateFile = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
+ File.separator + "config" + File.separator + "emails" + File.separator + "config" + File.separator + "emails"
+ File.separator + name; + File.separator + name;
@@ -430,13 +434,13 @@ public class I18nUtil
/** /**
* Creates array of Locales from text list of locale-specifications. * Creates array of Locales from text list of locale-specifications.
* Used to parse lists in DSpace configuration properties. * Used to parse lists in DSpace configuration properties.
* @param ll locale list of comma-separated values * @param locales locale string array
* @return array of locale results, possibly empty * @return array of locale results, possibly empty
*/ */
public static Locale[] parseLocales(String ll) public static Locale[] parseLocales(String[] locales)
{ {
List<Locale> resultList = new ArrayList<Locale>(); List<Locale> resultList = new ArrayList<Locale>();
for (String ls : ll.trim().split("\\s*,\\s*")) for (String ls : locales)
{ {
Locale lc = makeLocale(ls); Locale lc = makeLocale(ls);
if (lc != null) if (lc != null)

View File

@@ -0,0 +1,721 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.core;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.dspace.core.service.PluginService;
import org.dspace.services.ConfigurationService;
import org.springframework.beans.factory.annotation.Autowired;
/**
* The Legacy Plugin Service is a very simple component container (based on the
* legacy PluginManager class from <=5.x). It reads defined "plugins" (interfaces)
* from config file(s) and makes them available to the API. (@TODO: Someday, this
* entire "plugin" framework needs to be replaced by Spring Beans.)
* <p>
* It creates and organizes components (plugins), and helps select a plugin in
* the cases where there are many possible choices. It also gives some limited
* control over the lifecycle of a plugin. It manages three different types
* (usage patterns) of plugins:
* <p>
* <ol><li> Singleton Plugin
* <br> There is only one implementation class for the plugin. It is indicated
* in the configuration. This type of plugin chooses an implementations of
* a service, for the entire system, at configuration time. Your
* application just fetches the plugin for that interface and gets the
* configured-in choice.
*
* <p><li> Sequence Plugins
* <br> You need a sequence or series of plugins, to implement a mechanism like
* StackableAuthenticationMethods or a pipeline, where each plugin is
* called in order to contribute its implementation of a process to the
* whole.
* <p><li> Named Plugins
* <br> Use a named plugin when the application has to choose one plugin
* implementation out of many available ones. Each implementation is bound
* to one or more names (symbolic identifiers) in the configuration.
* </ol><p>
* The name is just a <code>String</code> to be associated with the
* combination of implementation class and interface. It may contain
* any characters except for comma (,) and equals (=). It may contain
* embedded spaces. Comma is a special character used to separate
* names in the configuration entry.
*
* @author Larry Stone
* @author Tim Donohue (turned old PluginManager into a PluginService)
* @see SelfNamedPlugin
*/
public class LegacyPluginServiceImpl implements PluginService
{
/** log4j category */
private static Logger log = Logger.getLogger(LegacyPluginServiceImpl.class);
/**
* Prefixes of names of properties to look for in DSpace Configuration
*/
private static final String SINGLE_PREFIX = "plugin.single.";
private static final String SEQUENCE_PREFIX = "plugin.sequence.";
private static final String NAMED_PREFIX = "plugin.named.";
private static final String SELFNAMED_PREFIX = "plugin.selfnamed.";
/** Configuration name of paths to search for third-party plugins. */
private static final String CLASSPATH = "plugin.classpath";
// Separator character (from perl $;) to make "two dimensional"
// hashtable key out of interface classname and plugin name;
// this character separates the words.
private static final String SEP = "\034";
/** Paths to search for third-party plugins. */
private String[] classPath;
/** Custom class loader to search for third-party plugins. */
private PathsClassLoader loader;
@Autowired(required = true)
protected ConfigurationService configurationService;
private LegacyPluginServiceImpl() {
}
/**
* Initialize the bean (after dependency injection has already taken place).
* Ensures the configurationService is injected, so that we can load
* plugin classpath info from config.
* Called by "init-method" in Spring config.
*/
void init()
{
String path = configurationService.getProperty(CLASSPATH);
if (null == path)
classPath = new String[0];
else
classPath = path.split(":");
loader = new PathsClassLoader(LegacyPluginServiceImpl.class.getClassLoader(), classPath);
}
/**
* Returns an instance of the singleton (single) plugin implementing
* the given interface. There must be exactly one single plugin
* configured for this interface, otherwise the
* <code>PluginConfigurationError</code> is thrown.
* <p>
* Note that this is the only "get plugin" method which throws an
* exception. It is typically used at initialization time to set up
* a permanent part of the system so any failure is fatal.
*
* @param interfaceClass interface Class object
* @return instance of plugin
* @throws PluginConfigurationError
*/
@Override
public Object getSinglePlugin(Class interfaceClass)
throws PluginConfigurationError, PluginInstantiationException
{
String iname = interfaceClass.getName();
// NOTE: module name is ignored, as single plugins ALWAYS begin with SINGLE_PREFIX
String key = SINGLE_PREFIX+iname;
// configuration format is prefix.<interface> = <classname>
String classname = configurationService.getProperty(key);
if (classname != null)
{
return getAnonymousPlugin(classname.trim());
}
else
{
throw new PluginConfigurationError("No Single Plugin configured for interface \""+iname+"\"");
}
}
/**
* Returns instances of all plugins that implement the interface,
* in an Array. Returns an empty array if no there are no
* matching plugins.
* <p>
* The order of the plugins in the array is the same as their class
* names in the configuration's value field.
*
* @param interfaceClass interface for which to find plugins.
* @return an array of plugin instances; if none are
* available an empty array is returned.
*/
@Override
public Object[] getPluginSequence(Class interfaceClass)
throws PluginInstantiationException
{
// cache of config data for Sequence Plugins; format its
// <interface-name> -> [ <classname>.. ] (value is Array)
Map<String, String[]> sequenceConfig = new HashMap<String, String[]>();
// cache the configuration for this interface after grovelling it once:
// format is prefix.<interface> = <classname>
String iname = interfaceClass.getName();
String[] classname = null;
if (!sequenceConfig.containsKey(iname))
{
// NOTE: module name is ignored, as sequence plugins ALWAYS begin with SEQUENCE_PREFIX
String key = SEQUENCE_PREFIX+iname;
classname = configurationService.getArrayProperty(key);
if (classname == null || classname.length==0)
{
log.warn("No Configuration entry found for Sequence Plugin interface="+iname);
return (Object[]) Array.newInstance(interfaceClass, 0);
}
sequenceConfig.put(iname, classname);
}
else
{
classname = sequenceConfig.get(iname);
}
Object result[] = (Object[])Array.newInstance(interfaceClass, classname.length);
for (int i = 0; i < classname.length; ++i)
{
log.debug("Adding Sequence plugin for interface= "+iname+", class="+classname[i]);
result[i] = getAnonymousPlugin(classname[i]);
}
return result;
}
// Get possibly-cached plugin instance for un-named plugin,
// this is shared by Single and Sequence plugins.
private Object getAnonymousPlugin(String classname)
throws PluginInstantiationException
{
try
{
Class pluginClass = Class.forName(classname, true, loader);
return pluginClass.newInstance();
}
catch (ClassNotFoundException e)
{
throw new PluginInstantiationException("Cannot load plugin class: " +
e.toString(), e);
}
catch (InstantiationException|IllegalAccessException e)
{
throw new PluginInstantiationException(e);
}
}
// Map of named plugin classes, [intfc,name] -> class
// Also contains intfc -> "marker" to mark when interface has been loaded.
private Map<String, String> namedPluginClasses = new HashMap<String, String>();
// Map of cached (reusable) named plugin instances, [class,name] -> instance
private Map<Serializable, Object> namedInstanceCache = new HashMap<Serializable, Object>();
// load and cache configuration data for the given interface.
private void configureNamedPlugin(String iname)
throws ClassNotFoundException
{
int found = 0;
/**
* First load the class map for this interface (if not done yet):
* key is [intfc,name], value is class.
* There is ALSO a "marker key" of "intfc" by itself to show we
* loaded this intfc's configuration.
*/
if (!namedPluginClasses.containsKey(iname))
{
// 1. Get classes named by the configuration. format is:
// plugin.named.<INTF> = <CLASS> = <name>\, <name> [,] \
// <CLASS> = <name>\, <name> [ ... ]
// NOTE: module name is ignored, as named plugins ALWAYS begin with NAMED_PREFIX
String key = NAMED_PREFIX+iname;
String[] namedVals = configurationService.getArrayProperty(key);
if (namedVals != null && namedVals.length>0)
{
String prevClassName = null;
for(String namedVal : namedVals)
{
String[] valSplit = namedVal.trim().split("\\s*=\\s*");
String className = null;
String name = null;
// If there's no "=" separator in this value, assume it's
// just a "name" that belongs with previous class.
// (This may occur if there's an unescaped comma between names)
if(prevClassName!=null && valSplit.length==1)
{
className = prevClassName;
name = valSplit[0];
}
else
{
// first part is class name
className = valSplit[0];
prevClassName = className;
// second part is one or more names
name = valSplit[1];
}
// The name may be *multiple* names (separated by escaped commas: \,)
String[] names = name.trim().split("\\s*,\\s*");
found += installNamedConfigs(iname, className, names);
}
}
// 2. Get Self-named config entries:
// format is plugin.selfnamed.<INTF> = <CLASS> , <CLASS> ..
// NOTE: module name is ignored, as self-named plugins ALWAYS begin with SELFNAMED_PREFIX
key = SELFNAMED_PREFIX+iname;
String[] selfNamedVals = configurationService.getArrayProperty(key);
if (selfNamedVals != null && selfNamedVals.length>0)
{
for (String classname : selfNamedVals)
{
try
{
Class pluginClass = Class.forName(classname, true, loader);
String names[] = (String[])pluginClass.getMethod("getPluginNames").
invoke(null);
if (names == null || names.length == 0)
{
log.error("Self-named plugin class \"" + classname + "\" returned null or empty name list!");
}
else
{
found += installNamedConfigs(iname, classname, names);
}
}
catch (NoSuchMethodException e)
{
log.error("Implementation Class \""+classname+"\" is not a subclass of SelfNamedPlugin, it has no getPluginNames() method.");
}
catch (Exception e)
{
log.error("Error while configuring self-named plugin", e);
}
}
}
namedPluginClasses.put(iname, "org.dspace.core.marker");
if (found == 0)
{
log.error("No named plugins found for interface=" + iname);
}
}
}
// add info for a named plugin to cache, under all its names.
private int installNamedConfigs(String iname, String classname, String names[])
throws ClassNotFoundException
{
int found = 0;
for (int i = 0; i < names.length; ++i)
{
String key = iname+SEP+names[i];
if (namedPluginClasses.containsKey(key))
{
log.error("Name collision in named plugin, implementation class=\"" + classname +
"\", name=\"" + names[i] + "\"");
}
else
{
namedPluginClasses.put(key, classname);
}
log.debug("Got Named Plugin, intfc="+iname+", name="+names[i]+", class="+classname);
++found;
}
return found;
}
/**
* Returns an instance of a plugin that implements the interface
* and is bound to a name matching name. If there is no
* matching plugin, it returns null. The names are matched by
* String.equals().
*
* @param interfaceClass the interface class of the plugin
* @param name under which the plugin implementation is configured.
* @return instance of plugin implementation, or null if there is no match or an error.
*/
@Override
public Object getNamedPlugin(Class interfaceClass, String name)
throws PluginInstantiationException
{
try
{
String iname = interfaceClass.getName();
configureNamedPlugin(iname);
String key = iname + SEP + name;
String cname = namedPluginClasses.get(key);
if (cname == null)
{
log.warn("Cannot find named plugin for interface=" + iname + ", name=\"" + name + "\"");
}
else
{
Class pluginClass = Class.forName(cname, true, loader);
log.debug("Creating instance of: " + cname +
" for interface=" + iname +
" pluginName=" + name );
Object result = pluginClass.newInstance();
if (result instanceof SelfNamedPlugin)
{
((SelfNamedPlugin) result).setPluginInstanceName(name);
}
return result;
}
}
catch (ClassNotFoundException e)
{
throw new PluginInstantiationException("Cannot load plugin class: " +
e.toString(), e);
}
catch (InstantiationException|IllegalAccessException e)
{
throw new PluginInstantiationException(e);
}
return null;
}
/**
* Returns whether a plugin exists which implements the specified interface
* and has a specified name. If a matching plugin is found to be configured,
* return true. If there is no matching plugin, return false.
*
* @param interfaceClass the interface class of the plugin
* @param name under which the plugin implementation is configured.
* @return true if plugin was found to be configured, false otherwise
*/
@Override
public boolean hasNamedPlugin(Class interfaceClass, String name)
throws PluginInstantiationException
{
try
{
String iname = interfaceClass.getName();
configureNamedPlugin(iname);
String key = iname + SEP + name;
return namedPluginClasses.get(key) != null;
}
catch (ClassNotFoundException e)
{
throw new PluginInstantiationException("Cannot load plugin class: " +
e.toString(), e);
}
}
/**
* Returns all of the names under which a named plugin implementing
* the interface can be requested (with getNamedPlugin()).
* The array is empty if there are no matches. Use this to populate
* a menu of plugins for interactive selection, or to document what
* the possible choices are.
* <p>
* NOTE: The names are NOT returned in any deterministic order.
*
* @param interfaceClass plugin interface for which to return names.
* @return an array of strings with every name; if none are
* available an empty array is returned.
*/
@Override
public String[] getAllPluginNames(Class interfaceClass)
{
try
{
String iname = interfaceClass.getName();
configureNamedPlugin(iname);
String prefix = iname + SEP;
ArrayList<String> result = new ArrayList<String>();
for (String key : namedPluginClasses.keySet())
{
if (key.startsWith(prefix))
{
result.add(key.substring(prefix.length()));
}
}
if (result.size() == 0)
{
log.error("Cannot find any names for named plugin, interface=" + iname);
}
return result.toArray(new String[result.size()]);
}
catch (ClassNotFoundException e)
{
return new String[0];
}
}
/* -----------------------------------------------------------------
* Code to check configuration is all below this line
* -----------------------------------------------------------------
*/
// true if classname is valid and loadable.
private boolean checkClassname(String iname, String msg)
{
try
{
if (Class.forName(iname, true, loader) != null)
{
return true;
}
}
catch (ClassNotFoundException ce)
{
log.error("No class definition found for "+msg+": \""+iname+"\"");
}
return false;
}
// true if classname is loadable AND is subclass of SelfNamedPlugin
private boolean checkSelfNamed(String iname)
{
try
{
if (!checkSelfNamed(Class.forName(iname, true, loader)))
{
log.error("The class \"" + iname + "\" is NOT a subclass of SelfNamedPlugin but it should be!");
}
}
catch (ClassNotFoundException ce)
{
log.error("No class definition found for self-named class interface: \""+iname+"\"");
}
return false;
}
// recursively climb superclass stack until we find SelfNamedPlugin
private boolean checkSelfNamed(Class cls)
{
Class sup = cls.getSuperclass();
if (sup == null)
{
return false;
}
else if (sup.equals(SelfNamedPlugin.class))
{
return true;
}
else
{
return checkSelfNamed(sup);
}
}
// check named-plugin names by interface -- call the usual
// configuration and let it find missing or duplicate names.
private void checkNames(String iname)
{
try
{
configureNamedPlugin(iname);
}
catch (ClassNotFoundException ce)
{
// bogus classname should be old news by now.
}
}
/**
* Validate the entries in the DSpace Configuration relevant to
LegacyPluginServiceImpl. Look for inconsistencies, illegal syntax, etc.
* Announce violations with "log.error" so they appear in the log
* or in the standard error stream if this is run interactively.
* <ul>
* <li>Look for duplicate keys (by parsing the config file)
* <li>Interface in plugin.single, plugin.sequence, plugin.named, plugin.selfnamed is valid.
* <li>Classname in plugin.reusable exists and matches a plugin config.
* <li>Classnames in config values exist.
* <li>Classnames in plugin.selfnamed loads and is subclass of <code>SelfNamedPlugin</code>
* <li>Implementations of named plugin have no name collisions.
* <li>Named plugin entries lacking names.
* </ul>
*/
public void checkConfiguration()
throws IOException
{
FileReader fr = null;
BufferedReader cr = null;
/* XXX TODO: (maybe) test that implementation class is really a
* subclass or impl of the plugin "interface"
*/
// tables of config keys for each type of config line:
Map<String, String> singleKey = new HashMap<String, String>();
Map<String, String> sequenceKey = new HashMap<String, String>();
Map<String, String> namedKey = new HashMap<String, String>();
Map<String, String> selfnamedKey = new HashMap<String, String>();
// Find all property keys starting with "plugin."
List<String> keys = configurationService.getPropertyKeys("plugin.");
for(String key : keys)
{
if (key.startsWith(SINGLE_PREFIX))
{
singleKey.put(key.substring(SINGLE_PREFIX.length()), key);
}
else if (key.startsWith(SEQUENCE_PREFIX))
{
sequenceKey.put(key.substring(SEQUENCE_PREFIX.length()), key);
}
else if (key.startsWith(NAMED_PREFIX))
{
namedKey.put(key.substring(NAMED_PREFIX.length()), key);
}
else if (key.startsWith(SELFNAMED_PREFIX))
{
selfnamedKey.put(key.substring(SELFNAMED_PREFIX.length()), key);
}
else
{
log.error("Key with unknown prefix \"" + key + "\" in DSpace configuration");
}
}
// 2. Build up list of all interfaces and test that they are loadable.
// don't bother testing that they are "interface" rather than "class"
// since either one will work for the Plugin Manager.
ArrayList<String> allInterfaces = new ArrayList<String>();
allInterfaces.addAll(singleKey.keySet());
allInterfaces.addAll(sequenceKey .keySet());
allInterfaces.addAll(namedKey.keySet());
allInterfaces.addAll(selfnamedKey.keySet());
Iterator<String> ii = allInterfaces.iterator();
while (ii.hasNext())
{
checkClassname(ii.next(), "key interface or class");
}
// Check implementation classes:
// - each class is loadable.
// - plugin.selfnamed values are each subclass of SelfNamedPlugin
// - save classname in allImpls
Map<String, String> allImpls = new HashMap<String, String>();
// single plugins - just check that it has a valid impl. class
ii = singleKey.keySet().iterator();
while (ii.hasNext())
{
String key = ii.next();
String val = configurationService.getProperty(SINGLE_PREFIX+key);
if (val == null)
{
log.error("Single plugin config not found for: " + SINGLE_PREFIX + key);
}
else
{
val = val.trim();
if (checkClassname(val, "implementation class"))
{
allImpls.put(val, val);
}
}
}
// sequence plugins - all values must be classes
ii = sequenceKey.keySet().iterator();
while (ii.hasNext())
{
String key = ii.next();
String[] vals = configurationService.getArrayProperty(SEQUENCE_PREFIX+key);
if (vals == null || vals.length==0)
{
log.error("Sequence plugin config not found for: " + SEQUENCE_PREFIX + key);
}
else
{
for (String val : vals)
{
if (checkClassname(val, "implementation class"))
{
allImpls.put(val, val);
}
}
}
}
// 3. self-named plugins - grab and check all values
// then make sure it is a subclass of SelfNamedPlugin
ii = selfnamedKey.keySet().iterator();
while (ii.hasNext())
{
String key = ii.next();
String[] vals = configurationService.getArrayProperty(SELFNAMED_PREFIX+key);
if (vals == null || vals.length==0)
{
log.error("Selfnamed plugin config not found for: " + SELFNAMED_PREFIX + key);
}
else
{
for (String val : vals)
{
if (checkClassname(val, "selfnamed implementation class"))
{
allImpls.put(val, val);
checkSelfNamed(val);
}
}
checkNames(key);
}
}
// 4. named plugins - extract the classnames and treat same as sequence.
// use named plugin config mechanism to test for duplicates, unnamed.
ii = namedKey.keySet().iterator();
while (ii.hasNext())
{
String key = ii.next();
String[] vals = configurationService.getArrayProperty(NAMED_PREFIX+key);
if (vals == null || vals.length==0)
{
log.error("Named plugin config not found for: " + NAMED_PREFIX + key);
}
else
{
checkNames(key);
for (String val : vals)
{
// each named plugin has two parts to the value, format:
// [classname] = [plugin-name]
String val_split[] = val.split("\\s*=\\s*");
String classname = val_split[0];
if (checkClassname(classname, "implementation class"))
{
allImpls.put(classname, classname);
}
}
}
}
}
/**
* Invoking this class from the command line just runs
* <code>checkConfiguration</code> and shows the results.
* There are no command-line options.
*/
public void main(String[] argv) throws Exception
{
checkConfiguration();
}
}

View File

@@ -19,6 +19,7 @@ import java.io.OutputStreamWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
import org.dspace.core.service.LicenseService; import org.dspace.core.service.LicenseService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -127,7 +128,7 @@ public class LicenseServiceImpl implements LicenseService
*/ */
protected void init() protected void init()
{ {
File licenseFile = new File(ConfigurationManager.getProperty("dspace.dir") File licenseFile = new File(DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
+ File.separator + "config" + File.separator + "default.license"); + File.separator + "config" + File.separator + "default.license");
FileInputStream fir = null; FileInputStream fir = null;

View File

@@ -0,0 +1,217 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.core;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.Enumeration;
import java.util.Properties;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.apache.log4j.xml.DOMConfigurator;
import org.dspace.services.ConfigurationService;
import org.dspace.services.KernelStartupCallbackService;
import org.dspace.services.factory.DSpaceServicesFactory;
/**
* Service which simply initializes DSpace logging *after* the kernel starts
*
* @author Tim Donohue
*/
public class LoggerServiceImpl implements KernelStartupCallbackService
{
/** log4j category */
private static Logger log = Logger.getLogger(LoggerServiceImpl.class);
// System property which will disable DSpace's log4j setup
private final String LOG_DISABLE_PROPERTY = "dspace.log.init.disable";
// Logging settings which are specified in DSpace's configuration
private final String LOG_CONFIG_PROPERTY = "log.init.config";
/**
* After kernel starts up, initialize Log4j based on the logging settings
* in our ConfigurationService.
*/
@Override
public void executeCallback()
{
try
{
/*
* Initialize Logging once ConfigurationManager is initialized.
*
* This is controlled by a property in dspace.cfg. If the property
* is absent then nothing will be configured and the application
* will use the defaults provided by log4j.
*
* Property format is:
*
* log.init.config = ${dspace.dir}/config/log4j.properties
* or
* log.init.config = ${dspace.dir}/config/log4j.xml
*
* See default log4j initialization documentation here:
* http://logging.apache.org/log4j/docs/manual.html
*
* If there is a problem with the file referred to in
* "log.configuration", it needs to be sent to System.err
* so do not instantiate another Logging configuration.
*
*/
ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
String dsLogConfiguration = config.getProperty(LOG_CONFIG_PROPERTY);
if (dsLogConfiguration == null || System.getProperty(LOG_DISABLE_PROPERTY) != null)
{
/*
* Do nothing if log config not set in dspace.cfg or "dspace.log.init.disable"
* system property set. Leave it upto log4j to properly init its logging
* via classpath or system properties.
*/
info("Using default log4j provided log configuration." +
" If unintended, check your dspace.cfg for (" +LOG_CONFIG_PROPERTY+ ")");
}
else
{
info("Using dspace provided log configuration (" +LOG_CONFIG_PROPERTY+ ")");
File logConfigFile = new File(dsLogConfiguration);
if(logConfigFile.exists())
{
info("Loading: " + dsLogConfiguration);
// Check if we have an XML config
if(logConfigFile.getName().endsWith(".xml"))
{
// Configure log4j via the DOMConfigurator
DOMConfigurator.configure(logConfigFile.toURI().toURL());
}
else // Otherwise, assume a Properties file
{
// Parse our log4j properties file
Properties log4jProps = new Properties();
try(InputStream fis = new FileInputStream(logConfigFile))
{
log4jProps.load(fis);
}
catch(IOException e)
{
fatal("Can't load dspace provided log4j configuration from " + logConfigFile.getAbsolutePath(), e);
}
// Merge the loaded log4j props with those in ConfigurationService
// This ensures variable substitution can be used in log4j.properties (e.g. ${log.dir})
// NOTE: if the same setting exists in both places, the setting in ConfigurationService
// overwrites the one in log4j.properties. This lets you easily override default log4j
// settings in your DSpace configs
Properties mergedProps = new Properties();
mergedProps.putAll(log4jProps);
mergedProps.putAll(config.getProperties());
// Configure log4j based on all the loaded properties
PropertyConfigurator.configure(mergedProps);
}
}
else
{
info("File does not exist: " + dsLogConfiguration);
}
}
}
catch (MalformedURLException e)
{
fatal("Can't load dspace provided log4j configuration", e);
throw new IllegalStateException("Cannot load dspace provided log4j configuration",e);
}
}
/**
* Attempt to log an INFO statement. If Log4j is not yet setup, send to System OUT
* @param string
*/
private void info(String string)
{
if (!isLog4jConfigured())
{
System.out.println("INFO: " + string);
}
else
{
log.info(string);
}
}
/**
* Attempt to log a WARN statement. If Log4j is not yet setup, send to System OUT
* @param string
*/
private void warn(String string)
{
if (!isLog4jConfigured())
{
System.out.println("WARN: " + string);
}
else
{
log.warn(string);
}
}
/**
* Attempt to log a FATAL statement. If Log4j is not yet setup, send to System ERR
* @param string
* @param e
*/
private void fatal(String string, Exception e)
{
if (!isLog4jConfigured())
{
System.err.println("FATAL: " + string);
e.printStackTrace(System.err);
}
else
{
log.fatal(string, e);
}
}
/**
* Only current solution available to detect if log4j is truly configured.
* <p>
* Based on samples here: http://wiki.apache.org/logging-log4j/UsefulCode
*/
private boolean isLog4jConfigured()
{
Enumeration<?> appenders = org.apache.log4j.LogManager.getRootLogger()
.getAllAppenders();
if (!(appenders instanceof org.apache.log4j.helpers.NullEnumeration))
{
return true;
}
else
{
Enumeration<?> loggers = org.apache.log4j.LogManager.getCurrentLoggers();
while (loggers.hasMoreElements())
{
Logger c = (Logger) loggers.nextElement();
if (!(c.getAllAppenders() instanceof org.apache.log4j.helpers.NullEnumeration))
{
return true;
}
}
}
return false;
}
}

View File

@@ -16,8 +16,8 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
import org.dspace.core.service.NewsService; import org.dspace.core.service.NewsService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -95,8 +95,8 @@ public class NewsServiceImpl implements NewsService
@Override @Override
public String getNewsFilePath() public String getNewsFilePath()
{ {
String filePath = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir")
return ConfigurationManager.getProperty("dspace.dir")
+ File.separator + "config" + File.separator; + File.separator + "config" + File.separator;
return filePath;
} }
} }

View File

@@ -8,7 +8,7 @@
package org.dspace.core; package org.dspace.core;
/** /**
* Indicates fatal error in Plugin Manager configuration. * Indicates fatal error in PluginService configuration.
* <p> * <p>
* This error is only thrown when the effect of a configuration problem * This error is only thrown when the effect of a configuration problem
* (<i>e.g.</i> missing value for a Single Plugin) is likely to leave * (<i>e.g.</i> missing value for a Single Plugin) is likely to leave
@@ -16,7 +16,7 @@ package org.dspace.core;
* *
* @author Larry Stone * @author Larry Stone
* @version $Revision$ * @version $Revision$
* @see PluginManager * @see PluginService
*/ */
public class PluginConfigurationError extends Error public class PluginConfigurationError extends Error

View File

@@ -19,7 +19,7 @@ package org.dspace.core;
* *
* @author Larry Stone * @author Larry Stone
* @version $Revision$ * @version $Revision$
* @see PluginManager * @see PluginService
*/ */
public class PluginInstantiationException extends RuntimeException public class PluginInstantiationException extends RuntimeException

File diff suppressed because it is too large Load Diff

View File

@@ -22,11 +22,11 @@ package org.dspace.core;
* configuration file. * configuration file.
* <p> * <p>
* See the documentation in the * See the documentation in the
* <code>PluginManager</code> class for more details. * <code>PluginService</code> class for more details.
* *
* @author Larry Stone * @author Larry Stone
* @version $Revision$ * @version $Revision$
* @see PluginManager * @see PluginService
*/ */
public abstract class SelfNamedPlugin public abstract class SelfNamedPlugin
{ {
@@ -58,7 +58,7 @@ public abstract class SelfNamedPlugin
* Get an instance's particular name. * Get an instance's particular name.
* Returns the name by which the class was chosen when * Returns the name by which the class was chosen when
* this instance was created. Only works for instances created * this instance was created. Only works for instances created
* by <code>PluginManager</code>, or if someone remembers to call <code>setPluginName.</code> * by <code>PluginService</code>, or if someone remembers to call <code>setPluginName.</code>
* <p> * <p>
* Useful when the implementation class wants to be configured differently * Useful when the implementation class wants to be configured differently
* when it is invoked under different names. * when it is invoked under different names.
@@ -73,7 +73,7 @@ public abstract class SelfNamedPlugin
/** /**
* Set the name under which this plugin was instantiated. * Set the name under which this plugin was instantiated.
* Not to be invoked by application code, it is * Not to be invoked by application code, it is
* called automatically by <code>PluginManager.getNamedPlugin()</code> * called automatically by <code>PluginService.getNamedPlugin()</code>
* when the plugin is instantiated. * when the plugin is instantiated.
* *
* @param name -- name used to select this class. * @param name -- name used to select this class.

View File

@@ -9,7 +9,8 @@ package org.dspace.core.factory;
import org.dspace.core.service.LicenseService; import org.dspace.core.service.LicenseService;
import org.dspace.core.service.NewsService; import org.dspace.core.service.NewsService;
import org.dspace.utils.DSpace; import org.dspace.core.service.PluginService;
import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the core package, use CoreServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the core package, use CoreServiceFactory.getInstance() to retrieve an implementation
@@ -22,8 +23,10 @@ public abstract class CoreServiceFactory {
public abstract NewsService getNewsService(); public abstract NewsService getNewsService();
public abstract PluginService getPluginService();
public static CoreServiceFactory getInstance() public static CoreServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("coreServiceFactory", CoreServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("coreServiceFactory", CoreServiceFactory.class);
} }
} }

View File

@@ -9,6 +9,7 @@ package org.dspace.core.factory;
import org.dspace.core.service.LicenseService; import org.dspace.core.service.LicenseService;
import org.dspace.core.service.NewsService; import org.dspace.core.service.NewsService;
import org.dspace.core.service.PluginService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
/** /**
@@ -24,6 +25,9 @@ public class CoreServiceFactoryImpl extends CoreServiceFactory {
@Autowired(required = true) @Autowired(required = true)
private NewsService newsService; private NewsService newsService;
@Autowired(required = true)
private PluginService pluginService;
@Override @Override
public LicenseService getLicenseService() { public LicenseService getLicenseService() {
return licenseService; return licenseService;
@@ -33,4 +37,9 @@ public class CoreServiceFactoryImpl extends CoreServiceFactory {
public NewsService getNewsService() { public NewsService getNewsService() {
return newsService; return newsService;
} }
@Override
public PluginService getPluginService() {
return pluginService;
}
} }

View File

@@ -0,0 +1,88 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.core.service;
/**
* A service to manage "plugins". At this point, it's based off of the structure
* of the legacy PluginManager (<=5.x), until a better plugin definition is created.
* <p>
* In DSpace, a "plugin" corresponds simply to a Java interface. Plugin implementations
* are simply classes which implement that interface (and often they are given unique
* names by which the plugin implementations are referenced/loaded).
*
* @author Tim Donohue
*/
public interface PluginService
{
/**
* Returns all of the names under which a named plugin implementing
* the interface can be requested (with getNamedPlugin()).
* The array is empty if there are no matches. Use this to populate
* a menu of plugins for interactive selection, or to document what
* the possible choices are.
* <p>
* NOTE: The names are NOT returned in any deterministic order.
*
* @param interfaceClass plugin interface for which to return names.
* @return an array of strings with every name; if none are
* available an empty array is returned.
*/
public String[] getAllPluginNames(Class interfaceClass);
/**
* Returns an instance of a plugin that implements the interface
* and is bound to a name matching name. If there is no
* matching plugin, it returns null. The names are matched by
* String.equals().
*
* @param interfaceClass the interface class of the plugin
* @param name under which the plugin implementation is configured.
* @return instance of plugin implementation, or null if there is no match or an error.
*/
public Object getNamedPlugin(Class interfaceClass, String name);
/**
* Returns whether a plugin exists which implements the specified interface
* and has a specified name. If a matching plugin is found to be configured,
* return true. If there is no matching plugin, return false.
*
* @param interfaceClass the interface class of the plugin
* @param name under which the plugin implementation is configured.
* @return true if plugin was found to be configured, false otherwise
*/
public boolean hasNamedPlugin(Class interfaceClass, String name);
/**
* Returns instances of all plugins that implement the interface,
* in an Array. Returns an empty array if no there are no
* matching plugins.
* <p>
* The order of the plugins in the array is the same as their class
* names in the configuration's value field.
*
* @param interfaceClass interface for which to find plugins.
* @return an array of plugin instances; if none are
* available an empty array is returned.
*/
public Object[] getPluginSequence(Class interfaceClass);
/**
* Returns an instance of the singleton (single) plugin implementing
* the given interface. There must be exactly one single plugin
* configured for this interface, otherwise the
* <code>PluginConfigurationError</code> is thrown.
* <p>
* Note that this is the only "get plugin" method which throws an
* exception. It is typically used at initialization time to set up
* a permanent part of the system so any failure is fatal.
*
* @param interfaceClass interface Class object
* @return instance of plugin
*/
public Object getSinglePlugin(Class interfaceClass);
}

View File

@@ -51,9 +51,9 @@ public abstract class AbstractTranslator extends AbstractCurationTask
// Load configuration // Load configuration
authLang = ConfigurationManager.getProperty("default.locale"); authLang = ConfigurationManager.getProperty("default.locale");
authLangField = ConfigurationManager.getProperty(PLUGIN_PREFIX, "translate.field.language"); authLangField = ConfigurationManager.getProperty(PLUGIN_PREFIX, "field.language");
String toTranslateStr = ConfigurationManager.getProperty(PLUGIN_PREFIX, "translate.field.targets"); String toTranslateStr = ConfigurationManager.getProperty(PLUGIN_PREFIX, "field.targets");
String langsStr = ConfigurationManager.getProperty(PLUGIN_PREFIX, "translate.language.targets"); String langsStr = ConfigurationManager.getProperty(PLUGIN_PREFIX, "language.targets");
toTranslate = toTranslateStr.split(","); toTranslate = toTranslateStr.split(",");
langs = langsStr.split(","); langs = langsStr.split(",");
@@ -184,7 +184,7 @@ public abstract class AbstractTranslator extends AbstractCurationTask
/* /*
* Override this method in your translator * Override this method in your translator
* Only needed to set key, etc. * Only needed to set key, etc.
* apiKey = ConfigurationManager.getProperty(PLUGIN_PREFIX, "translate.api.key.[service]"); * apiKey = ConfigurationManager.getProperty(PLUGIN_PREFIX, "translator.api.key.[service]");
* *
*/ */
} }

View File

@@ -41,7 +41,7 @@ public class MicrosoftTranslator extends AbstractTranslator
@Override @Override
protected void initApi() { protected void initApi() {
apiKey = ConfigurationManager.getProperty(PLUGIN_PREFIX, "translate.api.key.microsoft"); apiKey = ConfigurationManager.getProperty(PLUGIN_PREFIX, "api.key.microsoft");
} }
@Override @Override

View File

@@ -19,7 +19,7 @@ import org.apache.commons.cli.PosixParser;
import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.PluginManager; import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.curate.factory.CurateServiceFactory; import org.dspace.curate.factory.CurateServiceFactory;
import org.dspace.eperson.EPerson; import org.dspace.eperson.EPerson;
import org.dspace.eperson.factory.EPersonServiceFactory; import org.dspace.eperson.factory.EPersonServiceFactory;
@@ -232,7 +232,7 @@ public class CurationCli
else else
{ {
// process the task queue // process the task queue
TaskQueue queue = (TaskQueue)PluginManager.getSinglePlugin("curate", TaskQueue.class); TaskQueue queue = (TaskQueue) CoreServiceFactory.getInstance().getPluginService().getSinglePlugin(TaskQueue.class);
if (queue == null) if (queue == null)
{ {
System.out.println("No implementation configured for queue"); System.out.println("No implementation configured for queue");

View File

@@ -20,7 +20,7 @@ import org.dspace.content.service.CommunityService;
import org.dspace.content.service.ItemService; import org.dspace.content.service.ItemService;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.PluginManager; import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.handle.factory.HandleServiceFactory; import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService; import org.dspace.handle.service.HandleService;
@@ -280,7 +280,7 @@ public class Curator
{ {
if (taskQ == null) if (taskQ == null)
{ {
taskQ = (TaskQueue)PluginManager.getSinglePlugin("curate", TaskQueue.class); taskQ = (TaskQueue) CoreServiceFactory.getInstance().getPluginService().getSinglePlugin(TaskQueue.class);
} }
if (taskQ != null) if (taskQ != null)
{ {

View File

@@ -24,12 +24,12 @@ import javax.script.ScriptException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.core.ConfigurationManager; import org.dspace.core.ConfigurationManager;
import org.dspace.core.PluginManager; import org.dspace.core.factory.CoreServiceFactory;
/** /**
* TaskResolver takes a logical name of a curation task and attempts to deliver * TaskResolver takes a logical name of a curation task and attempts to deliver
* a suitable implementation object. Supported implementation types include: * a suitable implementation object. Supported implementation types include:
* (1) Classpath-local Java classes configured and loaded via PluginManager. * (1) Classpath-local Java classes configured and loaded via PluginService.
* (2) Local script-based tasks, viz. coded in any scripting language whose * (2) Local script-based tasks, viz. coded in any scripting language whose
* runtimes are accessible via the JSR-223 scripting API. This really amounts * runtimes are accessible via the JSR-223 scripting API. This really amounts
* to the family of dynamic JVM languages: JRuby, Jython, Groovy, Javascript, etc * to the family of dynamic JVM languages: JRuby, Jython, Groovy, Javascript, etc
@@ -195,7 +195,7 @@ public class TaskResolver
*/ */
public ResolvedTask resolveTask(String taskName) public ResolvedTask resolveTask(String taskName)
{ {
CurationTask ctask = (CurationTask)PluginManager.getNamedPlugin("curate", CurationTask.class, taskName); CurationTask ctask = (CurationTask)CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(CurationTask.class, taskName);
if (ctask != null) if (ctask != null)
{ {
return new ResolvedTask(taskName, ctask); return new ResolvedTask(taskName, ctask);

View File

@@ -25,7 +25,6 @@ import org.apache.log4j.Logger;
import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeException;
import org.dspace.content.Collection; import org.dspace.content.Collection;
import org.dspace.content.service.CollectionService; import org.dspace.content.service.CollectionService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.LogManager; import org.dspace.core.LogManager;
import org.dspace.curate.service.WorkflowCuratorService; import org.dspace.curate.service.WorkflowCuratorService;
@@ -33,17 +32,18 @@ import org.dspace.eperson.EPerson;
import org.dspace.eperson.Group; import org.dspace.eperson.Group;
import org.dspace.eperson.service.EPersonService; import org.dspace.eperson.service.EPersonService;
import org.dspace.eperson.service.GroupService; import org.dspace.eperson.service.GroupService;
import org.dspace.services.ConfigurationService;
import org.dspace.workflow.factory.WorkflowServiceFactory; import org.dspace.workflow.factory.WorkflowServiceFactory;
import org.dspace.workflowbasic.BasicWorkflowItem; import org.dspace.workflowbasic.BasicWorkflowItem;
import org.dspace.workflowbasic.BasicWorkflowServiceImpl; import org.dspace.workflowbasic.BasicWorkflowServiceImpl;
import org.dspace.workflowbasic.service.BasicWorkflowItemService; import org.dspace.workflowbasic.service.BasicWorkflowItemService;
import org.dspace.workflowbasic.service.BasicWorkflowService; import org.dspace.workflowbasic.service.BasicWorkflowService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
// Warning - static import ahead! // Warning - static import ahead!
import static javax.xml.stream.XMLStreamConstants.*; import static javax.xml.stream.XMLStreamConstants.*;
/** /**
* WorkflowCurator manages interactions between curation and workflow. * WorkflowCurator manages interactions between curation and workflow.
* Specifically, it is invoked in WorkflowManager to allow the * Specifically, it is invoked in WorkflowManager to allow the
@@ -51,15 +51,12 @@ import static javax.xml.stream.XMLStreamConstants.*;
* *
* @author richardrodgers * @author richardrodgers
*/ */
public class WorkflowCuratorServiceImpl implements WorkflowCuratorService, InitializingBean { public class WorkflowCuratorServiceImpl implements WorkflowCuratorService
{
/** log4j logger */ /** log4j logger */
private Logger log = Logger.getLogger(WorkflowCuratorServiceImpl.class); private Logger log = Logger.getLogger(WorkflowCuratorServiceImpl.class);
protected File cfgFile = new File(ConfigurationManager.getProperty("dspace.dir") +
File.separator + "config" + File.separator +
"workflow-curation.xml");
protected Map<String, TaskSet> tsMap = new HashMap<String, TaskSet>(); protected Map<String, TaskSet> tsMap = new HashMap<String, TaskSet>();
protected final String[] flowSteps = { "step1", "step2", "step3", "archive" }; protected final String[] flowSteps = { "step1", "step2", "step3", "archive" };
@@ -74,11 +71,22 @@ public class WorkflowCuratorServiceImpl implements WorkflowCuratorService, Initi
protected BasicWorkflowService basicWorkflowService; protected BasicWorkflowService basicWorkflowService;
@Autowired(required = true) @Autowired(required = true)
protected WorkflowServiceFactory workflowServiceFactory; protected WorkflowServiceFactory workflowServiceFactory;
@Autowired(required = true)
protected ConfigurationService configurationService;
@Override /**
public void afterPropertiesSet() throws Exception { * Initialize the bean (after dependency injection has already taken place).
try { * Ensures the configurationService is injected, so that we can read the
loadTaskConfig(); * settings from configuration
* Called by "init-method" in Spring config.
*/
public void init() throws Exception {
File cfgFile = new File(configurationService.getProperty("dspace.dir") +
File.separator + "config" + File.separator +
"workflow-curation.xml");
try
{
loadTaskConfig(cfgFile);
if(workflowServiceFactory.getWorkflowService() instanceof BasicWorkflowItemService) if(workflowServiceFactory.getWorkflowService() instanceof BasicWorkflowItemService)
{ {
basicWorkflowService = (BasicWorkflowService) workflowServiceFactory.getWorkflowService(); basicWorkflowService = (BasicWorkflowService) workflowServiceFactory.getWorkflowService();
@@ -208,7 +216,7 @@ public class WorkflowCuratorServiceImpl implements WorkflowCuratorService, Initi
} }
} else if ("$siteadmin".equals(contact)) { } else if ("$siteadmin".equals(contact)) {
EPerson siteEp = ePersonService.findByEmail(c, EPerson siteEp = ePersonService.findByEmail(c,
ConfigurationManager.getProperty("mail.admin")); configurationService.getProperty("mail.admin"));
if (siteEp != null) { if (siteEp != null) {
epList.add(siteEp); epList.add(siteEp);
} }
@@ -271,7 +279,7 @@ public class WorkflowCuratorServiceImpl implements WorkflowCuratorService, Initi
return -1; return -1;
} }
protected void loadTaskConfig() throws IOException { protected void loadTaskConfig(File cfgFile) throws IOException {
Map<String, String> collMap = new HashMap<String, String>(); Map<String, String> collMap = new HashMap<String, String>();
Map<String, TaskSet> setMap = new HashMap<String, TaskSet>(); Map<String, TaskSet> setMap = new HashMap<String, TaskSet>();
TaskSet taskSet = null; TaskSet taskSet = null;

View File

@@ -8,7 +8,7 @@
package org.dspace.curate.factory; package org.dspace.curate.factory;
import org.dspace.curate.service.WorkflowCuratorService; import org.dspace.curate.service.WorkflowCuratorService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the curate package, use CurateServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the curate package, use CurateServiceFactory.getInstance() to retrieve an implementation
@@ -21,6 +21,6 @@ public abstract class CurateServiceFactory {
public static CurateServiceFactory getInstance() public static CurateServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("curateServiceFactory", CurateServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("curateServiceFactory", CurateServiceFactory.class);
} }
} }

View File

@@ -10,7 +10,7 @@ package org.dspace.discovery;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.commons.cli.*; import org.apache.commons.cli.*;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
import java.io.IOException; import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
@@ -102,9 +102,7 @@ public class IndexClient {
* new DSpace.getServiceManager().getServiceByName("org.dspace.discovery.SolrIndexer"); * new DSpace.getServiceManager().getServiceByName("org.dspace.discovery.SolrIndexer");
*/ */
DSpace dspace = new DSpace(); IndexingService indexer = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(IndexingService.class.getName(),IndexingService.class);
IndexingService indexer = dspace.getServiceManager().getServiceByName(IndexingService.class.getName(),IndexingService.class);
if (line.hasOption("r")) { if (line.hasOption("r")) {
log.info("Removing " + line.getOptionValue("r") + " from Index"); log.info("Removing " + line.getOptionValue("r") + " from Index");

View File

@@ -14,7 +14,7 @@ import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.event.Consumer; import org.dspace.event.Consumer;
import org.dspace.event.Event; import org.dspace.event.Event;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@@ -38,9 +38,7 @@ public class IndexEventConsumer implements Consumer {
// handles to delete since IDs are not useful by now. // handles to delete since IDs are not useful by now.
private Set<String> handlesToDelete = null; private Set<String> handlesToDelete = null;
DSpace dspace = new DSpace(); IndexingService indexer = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(IndexingService.class.getName(),IndexingService.class);
IndexingService indexer = dspace.getServiceManager().getServiceByName(IndexingService.class.getName(),IndexingService.class);
@Override @Override
public void initialize() throws Exception { public void initialize() throws Exception {

View File

@@ -12,7 +12,7 @@ import org.dspace.content.Collection;
import org.dspace.discovery.configuration.DiscoveryConfiguration; import org.dspace.discovery.configuration.DiscoveryConfiguration;
import org.dspace.discovery.configuration.DiscoveryConfigurationService; import org.dspace.discovery.configuration.DiscoveryConfigurationService;
import org.dspace.kernel.ServiceManager; import org.dspace.kernel.ServiceManager;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.*; import java.util.*;
@@ -32,8 +32,7 @@ public class SearchUtils {
public static SearchService getSearchService() public static SearchService getSearchService()
{ {
if(searchService == null){ if(searchService == null){
DSpace dspace = new DSpace(); org.dspace.kernel.ServiceManager manager = DSpaceServicesFactory.getInstance().getServiceManager();
org.dspace.kernel.ServiceManager manager = dspace.getServiceManager() ;
searchService = manager.getServiceByName(SearchService.class.getName(),SearchService.class); searchService = manager.getServiceByName(SearchService.class.getName(),SearchService.class);
} }
return searchService; return searchService;
@@ -62,8 +61,7 @@ public class SearchUtils {
} }
public static DiscoveryConfigurationService getConfigurationService() { public static DiscoveryConfigurationService getConfigurationService() {
DSpace dspace = new DSpace(); ServiceManager manager = DSpaceServicesFactory.getInstance().getServiceManager();
ServiceManager manager = dspace.getServiceManager();
return manager.getServiceByName(DiscoveryConfigurationService.class.getName(), DiscoveryConfigurationService.class); return manager.getServiceByName(DiscoveryConfigurationService.class.getName(), DiscoveryConfigurationService.class);
} }

View File

@@ -47,9 +47,9 @@ import org.dspace.content.service.ItemService;
import org.dspace.core.*; import org.dspace.core.*;
import org.dspace.discovery.configuration.*; import org.dspace.discovery.configuration.*;
import org.dspace.handle.service.HandleService; import org.dspace.handle.service.HandleService;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.dspace.storage.rdbms.DatabaseUtils; import org.dspace.storage.rdbms.DatabaseUtils;
import org.dspace.util.MultiFormatDateParser; import org.dspace.util.MultiFormatDateParser;
import org.dspace.utils.DSpace;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -127,7 +127,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
{ {
if ( solr == null) if ( solr == null)
{ {
String solrService = new DSpace().getConfigurationService().getProperty("discovery.search.server"); String solrService = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("discovery.search.server");
UrlValidator urlValidator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS); UrlValidator urlValidator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS);
if (urlValidator.isValid(solrService)||ConfigurationManager.getBooleanProperty("discovery","solr.url.validation.enabled",true)) if (urlValidator.isValid(solrService)||ConfigurationManager.getBooleanProperty("discovery","solr.url.validation.enabled",true))
@@ -771,7 +771,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.title", title); addContainerMetadataField(doc, highlightedMetadataFields, toIgnoreMetadataFields, "dc.title", title);
//Do any additional indexing, depends on the plugins //Do any additional indexing, depends on the plugins
List<SolrServiceIndexPlugin> solrServiceIndexPlugins = new DSpace().getServiceManager().getServicesByType(SolrServiceIndexPlugin.class); List<SolrServiceIndexPlugin> solrServiceIndexPlugins = DSpaceServicesFactory.getInstance().getServiceManager().getServicesByType(SolrServiceIndexPlugin.class);
for (SolrServiceIndexPlugin solrServiceIndexPlugin : solrServiceIndexPlugins) for (SolrServiceIndexPlugin solrServiceIndexPlugin : solrServiceIndexPlugins)
{ {
solrServiceIndexPlugin.additionalIndex(context, community, doc); solrServiceIndexPlugin.additionalIndex(context, community, doc);
@@ -827,7 +827,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
//Do any additional indexing, depends on the plugins //Do any additional indexing, depends on the plugins
List<SolrServiceIndexPlugin> solrServiceIndexPlugins = new DSpace().getServiceManager().getServicesByType(SolrServiceIndexPlugin.class); List<SolrServiceIndexPlugin> solrServiceIndexPlugins = DSpaceServicesFactory.getInstance().getServiceManager().getServicesByType(SolrServiceIndexPlugin.class);
for (SolrServiceIndexPlugin solrServiceIndexPlugin : solrServiceIndexPlugins) for (SolrServiceIndexPlugin solrServiceIndexPlugin : solrServiceIndexPlugins)
{ {
solrServiceIndexPlugin.additionalIndex(context, collection, doc); solrServiceIndexPlugin.additionalIndex(context, collection, doc);
@@ -958,7 +958,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
List<String> toProjectionFields = new ArrayList<String>(); List<String> toProjectionFields = new ArrayList<String>();
String projectionFieldsString = new DSpace().getConfigurationService().getProperty("discovery.index.projection"); String projectionFieldsString = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("discovery.index.projection");
if(projectionFieldsString != null){ if(projectionFieldsString != null){
if(projectionFieldsString.indexOf(",") != -1){ if(projectionFieldsString.indexOf(",") != -1){
for (int i = 0; i < projectionFieldsString.split(",").length; i++) { for (int i = 0; i < projectionFieldsString.split(",").length; i++) {
@@ -1008,12 +1008,10 @@ public class SolrServiceImpl implements SearchService, IndexingService {
if (isAuthorityControlled && meta.getAuthority() != null if (isAuthorityControlled && meta.getAuthority() != null
&& meta.getConfidence() >= minConfidence) && meta.getConfidence() >= minConfidence)
{ {
boolean ignoreAuthority = new DSpace() boolean ignoreAuthority = DSpaceServicesFactory.getInstance().getConfigurationService()
.getConfigurationService()
.getPropertyAsType( .getPropertyAsType(
"discovery.index.authority.ignore." + field, "discovery.index.authority.ignore." + field,
new DSpace() DSpaceServicesFactory.getInstance().getConfigurationService()
.getConfigurationService()
.getPropertyAsType( .getPropertyAsType(
"discovery.index.authority.ignore", "discovery.index.authority.ignore",
new Boolean(false)), true); new Boolean(false)), true);
@@ -1021,13 +1019,11 @@ public class SolrServiceImpl implements SearchService, IndexingService {
{ {
authority = meta.getAuthority(); authority = meta.getAuthority();
boolean ignorePrefered = new DSpace() boolean ignorePrefered = DSpaceServicesFactory.getInstance().getConfigurationService()
.getConfigurationService()
.getPropertyAsType( .getPropertyAsType(
"discovery.index.authority.ignore-prefered." "discovery.index.authority.ignore-prefered."
+ field, + field,
new DSpace() DSpaceServicesFactory.getInstance().getConfigurationService()
.getConfigurationService()
.getPropertyAsType( .getPropertyAsType(
"discovery.index.authority.ignore-prefered", "discovery.index.authority.ignore-prefered",
new Boolean(false)), new Boolean(false)),
@@ -1039,13 +1035,11 @@ public class SolrServiceImpl implements SearchService, IndexingService {
.getLabel(meta, meta.getLanguage()); .getLabel(meta, meta.getLanguage());
} }
boolean ignoreVariants = new DSpace() boolean ignoreVariants = DSpaceServicesFactory.getInstance().getConfigurationService()
.getConfigurationService()
.getPropertyAsType( .getPropertyAsType(
"discovery.index.authority.ignore-variants." "discovery.index.authority.ignore-variants."
+ field, + field,
new DSpace() DSpaceServicesFactory.getInstance().getConfigurationService()
.getConfigurationService()
.getPropertyAsType( .getPropertyAsType(
"discovery.index.authority.ignore-variants", "discovery.index.authority.ignore-variants",
new Boolean(false)), new Boolean(false)),
@@ -1070,7 +1064,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
for (DiscoverySearchFilter searchFilter : searchFilterConfigs) for (DiscoverySearchFilter searchFilter : searchFilterConfigs)
{ {
Date date = null; Date date = null;
String separator = new DSpace().getConfigurationService().getProperty("discovery.solr.facets.split.char"); String separator = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("discovery.solr.facets.split.char");
if(separator == null) if(separator == null)
{ {
separator = FILTER_SEPARATOR; separator = FILTER_SEPARATOR;
@@ -1387,7 +1381,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
} }
//Do any additional indexing, depends on the plugins //Do any additional indexing, depends on the plugins
List<SolrServiceIndexPlugin> solrServiceIndexPlugins = new DSpace().getServiceManager().getServicesByType(SolrServiceIndexPlugin.class); List<SolrServiceIndexPlugin> solrServiceIndexPlugins = DSpaceServicesFactory.getInstance().getServiceManager().getServicesByType(SolrServiceIndexPlugin.class);
for (SolrServiceIndexPlugin solrServiceIndexPlugin : solrServiceIndexPlugins) for (SolrServiceIndexPlugin solrServiceIndexPlugin : solrServiceIndexPlugins)
{ {
solrServiceIndexPlugin.additionalIndex(context, item, doc); solrServiceIndexPlugin.additionalIndex(context, item, doc);
@@ -1725,7 +1719,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
} }
//Add any configured search plugins ! //Add any configured search plugins !
List<SolrServiceSearchPlugin> solrServiceSearchPlugins = new DSpace().getServiceManager().getServicesByType(SolrServiceSearchPlugin.class); List<SolrServiceSearchPlugin> solrServiceSearchPlugins = DSpaceServicesFactory.getInstance().getServiceManager().getServicesByType(SolrServiceSearchPlugin.class);
for (SolrServiceSearchPlugin searchPlugin : solrServiceSearchPlugins) for (SolrServiceSearchPlugin searchPlugin : solrServiceSearchPlugins)
{ {
searchPlugin.additionalSearchParameters(context, discoveryQuery, solrQuery); searchPlugin.additionalSearchParameters(context, discoveryQuery, solrQuery);
@@ -2206,7 +2200,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|| field.endsWith("_acid")) || field.endsWith("_acid"))
{ {
//We have a filter make sure we split ! //We have a filter make sure we split !
String separator = new DSpace().getConfigurationService().getProperty("discovery.solr.facets.split.char"); String separator = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("discovery.solr.facets.split.char");
if(separator == null) if(separator == null)
{ {
separator = FILTER_SEPARATOR; separator = FILTER_SEPARATOR;
@@ -2239,7 +2233,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|| field.endsWith("_acid")) || field.endsWith("_acid"))
{ {
//We have a filter make sure we split ! //We have a filter make sure we split !
String separator = new DSpace().getConfigurationService().getProperty("discovery.solr.facets.split.char"); String separator = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("discovery.solr.facets.split.char");
if(separator == null) if(separator == null)
{ {
separator = FILTER_SEPARATOR; separator = FILTER_SEPARATOR;
@@ -2274,7 +2268,7 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|| field.endsWith("_acid")) || field.endsWith("_acid"))
{ {
//We have a filter make sure we split ! //We have a filter make sure we split !
String separator = new DSpace().getConfigurationService().getProperty("discovery.solr.facets.split.char"); String separator = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("discovery.solr.facets.split.char");
if(separator == null) if(separator == null)
{ {
separator = FILTER_SEPARATOR; separator = FILTER_SEPARATOR;

View File

@@ -7,7 +7,7 @@
*/ */
package org.dspace.discovery.configuration; package org.dspace.discovery.configuration;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -38,9 +38,8 @@ public class DiscoveryConfigurationService {
} }
public static void main(String[] args) { public static void main(String[] args) {
DSpace dspace = new DSpace(); System.out.println(DSpaceServicesFactory.getInstance().getServiceManager().getServicesNames().size());
System.out.println(dspace.getServiceManager().getServicesNames().size()); DiscoveryConfigurationService mainService = DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName(DiscoveryConfigurationService.class.getName(), DiscoveryConfigurationService.class);
DiscoveryConfigurationService mainService = dspace.getServiceManager().getServiceByName(DiscoveryConfigurationService.class.getName(), DiscoveryConfigurationService.class);
for(String key : mainService.getMap().keySet()){ for(String key : mainService.getMap().keySet()){
System.out.println(key); System.out.println(key);

View File

@@ -23,10 +23,10 @@ import org.dspace.content.Collection;
import org.dspace.content.service.BitstreamService; import org.dspace.content.service.BitstreamService;
import org.dspace.content.service.CommunityService; import org.dspace.content.service.CommunityService;
import org.dspace.content.service.ItemService; import org.dspace.content.service.ItemService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.disseminate.service.CitationDocumentService; import org.dspace.disseminate.service.CitationDocumentService;
import org.dspace.handle.service.HandleService; import org.dspace.handle.service.HandleService;
import org.dspace.services.ConfigurationService;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -70,22 +70,10 @@ public class CitationDocumentServiceImpl implements CitationDocumentService, Ini
*/ */
protected final Set<String> SVG_MIMES = new HashSet<String>(); protected final Set<String> SVG_MIMES = new HashSet<String>();
/**
* Comma separated list of collections handles to enable citation for.
* webui.citation.enabled_collections, default empty/none. ex: =1811/123, 1811/345
*/
protected String citationEnabledCollections = null;
/**
* Comma separated list of community handles to enable citation for.
* webui.citation.enabled_communties, default empty/none. ex: =1811/123, 1811/345
*/
protected String citationEnabledCommunities = null;
/** /**
* List of all enabled collections, inherited/determined for those under communities. * List of all enabled collections, inherited/determined for those under communities.
*/ */
protected ArrayList<String> citationEnabledCollectionsList; protected List<String> citationEnabledCollectionsList;
protected File tempDir; protected File tempDir;
@@ -102,6 +90,8 @@ public class CitationDocumentServiceImpl implements CitationDocumentService, Ini
protected CommunityService communityService; protected CommunityService communityService;
@Autowired(required = true) @Autowired(required = true)
protected ItemService itemService; protected ItemService itemService;
@Autowired(required = true)
protected ConfigurationService configurationService;
@Autowired(required = true) @Autowired(required = true)
protected HandleService handleService; protected HandleService handleService;
@@ -130,27 +120,22 @@ public class CitationDocumentServiceImpl implements CitationDocumentService, Ini
//Load enabled collections //Load enabled collections
citationEnabledCollections = ConfigurationManager.getProperty("disseminate-citation", "enabled_collections"); String[] citationEnabledCollections = configurationService.getArrayProperty("citation-page.enabled_collections");
citationEnabledCollectionsList = new ArrayList<String>(); citationEnabledCollectionsList = Arrays.asList(citationEnabledCollections);
if(citationEnabledCollections != null && citationEnabledCollections.length() > 0) {
String[] collectionChunks = citationEnabledCollections.split(",");
for(String collectionString : collectionChunks) {
citationEnabledCollectionsList.add(collectionString.trim());
}
}
//Load enabled communities, and add to collection-list //Load enabled communities, and add to collection-list
citationEnabledCommunities = ConfigurationManager.getProperty("disseminate-citation", "enabled_communities"); String[] citationEnabledCommunities = configurationService.getArrayProperty("citation-page.enabled_communities");
if(citationEnabledCollectionsList == null) { if(citationEnabledCollectionsList == null) {
citationEnabledCollectionsList = new ArrayList<String>(); citationEnabledCollectionsList = new ArrayList<String>();
} }
if(citationEnabledCommunities != null && citationEnabledCommunities.length() > 0) { if(citationEnabledCommunities != null && citationEnabledCommunities.length > 0)
try { {
String[] communityChunks = citationEnabledCommunities.split(","); Context context = null;
for(String communityString : communityChunks) { try
Context context = new Context(); {
context = new Context();
for(String communityString : citationEnabledCommunities) {
DSpaceObject dsoCommunity = handleService.resolveToObject(context, communityString.trim()); DSpaceObject dsoCommunity = handleService.resolveToObject(context, communityString.trim());
if(dsoCommunity instanceof Community) { if(dsoCommunity instanceof Community) {
Community community = (Community)dsoCommunity; Community community = (Community)dsoCommunity;
@@ -162,38 +147,39 @@ public class CitationDocumentServiceImpl implements CitationDocumentService, Ini
} else { } else {
log.error("Invalid community for citation.enabled_communities, value:" + communityString.trim()); log.error("Invalid community for citation.enabled_communities, value:" + communityString.trim());
} }
context.abort();
} }
} catch (SQLException e) { } catch (SQLException e) {
log.error(e.getMessage()); log.error(e.getMessage());
} }
finally {
if (context!=null)
context.abort();
}
} }
// Configurable text/fields, we'll set sane defaults // Configurable text/fields, we'll set sane defaults
String header1Config = ConfigurationManager.getProperty("disseminate-citation", "header1"); String header1Config = configurationService.getProperty("citation-page.header1");
if(StringUtils.isNotBlank(header1Config)) { if(StringUtils.isNotBlank(header1Config)) {
header1 = header1Config.split(","); header1 = header1Config.split(",");
} else { } else {
header1 = new String[]{"DSpace Institution", ""}; header1 = new String[]{"DSpace Institution", ""};
} }
String header2Config = ConfigurationManager.getProperty("disseminate-citation", "header2"); String header2Config = configurationService.getProperty("citation-page.header2");
if(StringUtils.isNotBlank(header2Config)) { if(StringUtils.isNotBlank(header2Config)) {
header2 = header2Config.split(","); header2 = header2Config.split(",");
} else { } else {
header2 = new String[]{"DSpace Repository", "http://dspace.org"}; header2 = new String[]{"DSpace Repository", "http://dspace.org"};
} }
String fieldsConfig = ConfigurationManager.getProperty("disseminate-citation", "fields"); String fieldsConfig = configurationService.getProperty("citation-page.fields");
if(StringUtils.isNotBlank(fieldsConfig)) { if(StringUtils.isNotBlank(fieldsConfig)) {
fields = fieldsConfig.split(","); fields = fieldsConfig.split(",");
} else { } else {
fields = new String[]{"dc.date.issued", "dc.title", "dc.creator", "dc.contributor.author", "dc.publisher", "_line_", "dc.identifier.citation", "dc.identifier.uri"}; fields = new String[]{"dc.date.issued", "dc.title", "dc.creator", "dc.contributor.author", "dc.publisher", "_line_", "dc.identifier.citation", "dc.identifier.uri"};
} }
String footerConfig = ConfigurationManager.getProperty("disseminate-citation", "footer"); String footerConfig = configurationService.getProperty("citation-page.footer");
if(StringUtils.isNotBlank(footerConfig)) { if(StringUtils.isNotBlank(footerConfig)) {
footer = footerConfig; footer = footerConfig;
} else { } else {
@@ -201,7 +187,7 @@ public class CitationDocumentServiceImpl implements CitationDocumentService, Ini
} }
//Ensure a temp directory is available //Ensure a temp directory is available
String tempDirString = ConfigurationManager.getProperty("dspace.dir") + "/temp"; String tempDirString = configurationService.getProperty("dspace.dir") + File.pathSeparator + "temp";
tempDir = new File(tempDirString); tempDir = new File(tempDirString);
if(!tempDir.exists()) { if(!tempDir.exists()) {
boolean success = tempDir.mkdir(); boolean success = tempDir.mkdir();
@@ -218,13 +204,13 @@ public class CitationDocumentServiceImpl implements CitationDocumentService, Ini
/** /**
* Boolean to determine is citation-functionality is enabled globally for entire site. * Boolean to determine is citation-functionality is enabled globally for entire site.
* config/module/disseminate-citation: enable_globally, default false. true=on, false=off * config/module/citation-page: enable_globally, default false. true=on, false=off
*/ */
protected Boolean citationEnabledGlobally = null; protected Boolean citationEnabledGlobally = null;
protected boolean isCitationEnabledGlobally() { protected boolean isCitationEnabledGlobally() {
if(citationEnabledGlobally == null) { if(citationEnabledGlobally == null) {
citationEnabledGlobally = ConfigurationManager.getBooleanProperty("disseminate-citation", "enable_globally", false); citationEnabledGlobally = configurationService.getBooleanProperty("citation-page.enable_globally", false);
} }
return citationEnabledGlobally; return citationEnabledGlobally;
@@ -277,7 +263,7 @@ public class CitationDocumentServiceImpl implements CitationDocumentService, Ini
protected Boolean isCitationFirstPage() { protected Boolean isCitationFirstPage() {
if(citationAsFirstPage == null) { if(citationAsFirstPage == null) {
citationAsFirstPage = ConfigurationManager.getBooleanProperty("disseminate-citation", "citation_as_first_page", true); citationAsFirstPage = configurationService.getBooleanProperty("citation-page.citation_as_first_page", true);
} }
return citationAsFirstPage; return citationAsFirstPage;

View File

@@ -8,7 +8,7 @@
package org.dspace.disseminate.factory; package org.dspace.disseminate.factory;
import org.dspace.disseminate.service.CitationDocumentService; import org.dspace.disseminate.service.CitationDocumentService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the disseminate package, use DisseminateServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the disseminate package, use DisseminateServiceFactory.getInstance() to retrieve an implementation
@@ -21,6 +21,6 @@ public abstract class DisseminateServiceFactory {
public static DisseminateServiceFactory getInstance() public static DisseminateServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("disseminateServiceFactory", DisseminateServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("disseminateServiceFactory", DisseminateServiceFactory.class);
} }
} }

View File

@@ -14,8 +14,8 @@ import java.util.Properties;
import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeException;
import org.dspace.content.DCDate; import org.dspace.content.DCDate;
import org.dspace.content.Item; import org.dspace.content.Item;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Plugin implementation of the embargo setting function. The parseTerms() * Plugin implementation of the embargo setting function. The parseTerms()
@@ -35,18 +35,8 @@ import org.dspace.core.Context;
*/ */
public class DayTableEmbargoSetter extends DefaultEmbargoSetter public class DayTableEmbargoSetter extends DefaultEmbargoSetter
{ {
private Properties termProps = new Properties();
public DayTableEmbargoSetter() { public DayTableEmbargoSetter() {
super(); super();
// load properties
String terms = ConfigurationManager.getProperty("embargo.terms.days");
if (terms != null && terms.length() > 0) {
for (String term : terms.split(",")) {
String[] parts = term.trim().split(":");
termProps.setProperty(parts[0].trim(), parts[1].trim());
}
}
} }
/** /**
@@ -61,6 +51,10 @@ public class DayTableEmbargoSetter extends DefaultEmbargoSetter
@Override @Override
public DCDate parseTerms(Context context, Item item, String terms) public DCDate parseTerms(Context context, Item item, String terms)
throws SQLException, AuthorizeException { throws SQLException, AuthorizeException {
String termsOpen = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("embargo.terms.open");
Properties termProps = getTermProperties();
if (terms != null) { if (terms != null) {
if (termsOpen.equals(terms)) { if (termsOpen.equals(terms)) {
return EmbargoServiceImpl.FOREVER; return EmbargoServiceImpl.FOREVER;
@@ -74,4 +68,23 @@ public class DayTableEmbargoSetter extends DefaultEmbargoSetter
} }
return null; return null;
} }
/**
* Get term properties from configuration
* @return Properties
*/
private Properties getTermProperties()
{
Properties termProps = new Properties();
String terms = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("embargo.terms.days");
if (terms != null && terms.length() > 0) {
for (String term : terms.split(",")) {
String[] parts = term.trim().split(":");
termProps.setProperty(parts[0].trim(), parts[1].trim());
}
}
return termProps;
}
} }

View File

@@ -19,7 +19,6 @@ import org.dspace.authorize.factory.AuthorizeServiceFactory;
import org.dspace.authorize.service.AuthorizeService; import org.dspace.authorize.service.AuthorizeService;
import org.dspace.authorize.service.ResourcePolicyService; import org.dspace.authorize.service.ResourcePolicyService;
import org.dspace.content.*; import org.dspace.content.*;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.embargo.factory.EmbargoServiceFactory; import org.dspace.embargo.factory.EmbargoServiceFactory;
@@ -27,6 +26,7 @@ import org.dspace.embargo.service.EmbargoService;
import org.dspace.eperson.Group; import org.dspace.eperson.Group;
import org.dspace.eperson.factory.EPersonServiceFactory; import org.dspace.eperson.factory.EPersonServiceFactory;
import org.dspace.license.CreativeCommonsServiceImpl; import org.dspace.license.CreativeCommonsServiceImpl;
import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Default plugin implementation of the embargo setting function. * Default plugin implementation of the embargo setting function.
@@ -40,15 +40,12 @@ import org.dspace.license.CreativeCommonsServiceImpl;
*/ */
public class DefaultEmbargoSetter implements EmbargoSetter public class DefaultEmbargoSetter implements EmbargoSetter
{ {
protected String termsOpen = null;
protected AuthorizeService authorizeService; protected AuthorizeService authorizeService;
protected ResourcePolicyService resourcePolicyService; protected ResourcePolicyService resourcePolicyService;
public DefaultEmbargoSetter() public DefaultEmbargoSetter()
{ {
super(); super();
termsOpen = ConfigurationManager.getProperty("embargo.terms.open");
} }
/** /**
@@ -65,6 +62,8 @@ public class DefaultEmbargoSetter implements EmbargoSetter
public DCDate parseTerms(Context context, Item item, String terms) public DCDate parseTerms(Context context, Item item, String terms)
throws SQLException, AuthorizeException throws SQLException, AuthorizeException
{ {
String termsOpen = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("embargo.terms.open");
if (terms != null && terms.length() > 0) if (terms != null && terms.length() > 0)
{ {
if (termsOpen.equals(terms)) if (termsOpen.equals(terms))

View File

@@ -17,11 +17,10 @@ import org.apache.log4j.Logger;
import org.dspace.authorize.AuthorizeException; import org.dspace.authorize.AuthorizeException;
import org.dspace.content.*; import org.dspace.content.*;
import org.dspace.content.service.ItemService; import org.dspace.content.service.ItemService;
import org.dspace.core.ConfigurationManager;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.PluginManager; import org.dspace.core.service.PluginService;
import org.dspace.embargo.service.EmbargoService; import org.dspace.embargo.service.EmbargoService;
import org.springframework.beans.factory.InitializingBean; import org.dspace.services.ConfigurationService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
/** /**
@@ -42,7 +41,7 @@ import org.springframework.beans.factory.annotation.Autowired;
* @author Larry Stone * @author Larry Stone
* @author Richard Rodgers * @author Richard Rodgers
*/ */
public class EmbargoServiceImpl implements EmbargoService, InitializingBean public class EmbargoServiceImpl implements EmbargoService
{ {
/** log4j category */ /** log4j category */
@@ -68,6 +67,12 @@ public class EmbargoServiceImpl implements EmbargoService, InitializingBean
@Autowired(required = true) @Autowired(required = true)
protected ItemService itemService; protected ItemService itemService;
@Autowired(required = true)
protected ConfigurationService configurationService;
@Autowired(required = true)
protected PluginService pluginService;
@Override @Override
public void setEmbargo(Context context, Item item) public void setEmbargo(Context context, Item item)
throws SQLException, AuthorizeException throws SQLException, AuthorizeException
@@ -156,14 +161,18 @@ public class EmbargoServiceImpl implements EmbargoService, InitializingBean
} }
// initialize - get plugins and MD field settings from config /**
@Override * Initialize the bean (after dependency injection has already taken place).
public void afterPropertiesSet() throws Exception * Ensures the configurationService is injected, so that we can
* get plugins and MD field settings from config.
* Called by "init-method" in Spring config.
*/
public void init() throws Exception
{ {
if (terms_schema == null) if (terms_schema == null)
{ {
String terms = ConfigurationManager.getProperty("embargo.field.terms"); String terms = configurationService.getProperty("embargo.field.terms");
String lift = ConfigurationManager.getProperty("embargo.field.lift"); String lift = configurationService.getProperty("embargo.field.lift");
if (terms == null || lift == null) if (terms == null || lift == null)
{ {
throw new IllegalStateException("Missing one or more of the required DSpace configuration properties for EmbargoManager, check your configuration file."); throw new IllegalStateException("Missing one or more of the required DSpace configuration properties for EmbargoManager, check your configuration file.");
@@ -175,12 +184,12 @@ public class EmbargoServiceImpl implements EmbargoService, InitializingBean
lift_element = getElementOf(lift); lift_element = getElementOf(lift);
lift_qualifier = getQualifierOf(lift); lift_qualifier = getQualifierOf(lift);
setter = (EmbargoSetter)PluginManager.getSinglePlugin(EmbargoSetter.class); setter = (EmbargoSetter)pluginService.getSinglePlugin(EmbargoSetter.class);
if (setter == null) if (setter == null)
{ {
throw new IllegalStateException("The EmbargoSetter plugin was not defined in DSpace configuration."); throw new IllegalStateException("The EmbargoSetter plugin was not defined in DSpace configuration.");
} }
lifter = (EmbargoLifter)PluginManager.getSinglePlugin(EmbargoLifter.class); lifter = (EmbargoLifter)pluginService.getSinglePlugin(EmbargoLifter.class);
if (lifter == null) if (lifter == null)
{ {
throw new IllegalStateException("The EmbargoLifter plugin was not defined in DSpace configuration."); throw new IllegalStateException("The EmbargoLifter plugin was not defined in DSpace configuration.");

View File

@@ -8,7 +8,7 @@
package org.dspace.embargo.factory; package org.dspace.embargo.factory;
import org.dspace.embargo.service.EmbargoService; import org.dspace.embargo.service.EmbargoService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the embargo package, use EmbargoServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the embargo package, use EmbargoServiceFactory.getInstance() to retrieve an implementation
@@ -21,6 +21,6 @@ public abstract class EmbargoServiceFactory {
public static EmbargoServiceFactory getInstance() public static EmbargoServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("embargoServiceFactory", EmbargoServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("embargoServiceFactory", EmbargoServiceFactory.class);
} }
} }

View File

@@ -16,7 +16,7 @@ import java.util.Arrays;
import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.binary.Hex;
import org.dspace.services.ConfigurationService; import org.dspace.services.ConfigurationService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -33,7 +33,7 @@ public class PasswordHash
{ {
private static final Logger log = LoggerFactory.getLogger(PasswordHash.class); private static final Logger log = LoggerFactory.getLogger(PasswordHash.class);
private static final ConfigurationService config private static final ConfigurationService config
= new DSpace().getConfigurationService(); = DSpaceServicesFactory.getInstance().getConfigurationService();
private static final Charset UTF_8 = Charset.forName("UTF-8"); // Should always succeed: UTF-8 is required private static final Charset UTF_8 = Charset.forName("UTF-8"); // Should always succeed: UTF-8 is required
private static final String DEFAULT_DIGEST_ALGORITHM = "SHA-512"; // XXX magic private static final String DEFAULT_DIGEST_ALGORITHM = "SHA-512"; // XXX magic

View File

@@ -8,7 +8,7 @@
package org.dspace.eperson.factory; package org.dspace.eperson.factory;
import org.dspace.eperson.service.*; import org.dspace.eperson.service.*;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the eperson package, use EPersonServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the eperson package, use EPersonServiceFactory.getInstance() to retrieve an implementation
@@ -30,6 +30,6 @@ public abstract class EPersonServiceFactory {
public abstract SupervisorService getSupervisorService(); public abstract SupervisorService getSupervisorService();
public static EPersonServiceFactory getInstance(){ public static EPersonServiceFactory getInstance(){
return new DSpace().getServiceManager().getServiceByName("ePersonServiceFactory", EPersonServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("ePersonServiceFactory", EPersonServiceFactory.class);
} }
} }

View File

@@ -8,7 +8,7 @@
package org.dspace.event.factory; package org.dspace.event.factory;
import org.dspace.event.service.EventService; import org.dspace.event.service.EventService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the event package, use EventServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the event package, use EventServiceFactory.getInstance() to retrieve an implementation
@@ -21,6 +21,6 @@ public abstract class EventServiceFactory {
public static EventServiceFactory getInstance() public static EventServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("eventServiceFactory", EventServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("eventServiceFactory", EventServiceFactory.class);
} }
} }

View File

@@ -17,7 +17,7 @@ import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.analytics.Analytics; import com.google.api.services.analytics.Analytics;
import com.google.api.services.analytics.AnalyticsScopes; import com.google.api.services.analytics.AnalyticsScopes;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
import java.io.File; import java.io.File;
import java.util.HashSet; import java.util.HashSet;
@@ -51,10 +51,10 @@ public class GoogleAccount {
private GoogleAccount() { private GoogleAccount() {
applicationName = new DSpace().getConfigurationService().getProperty("google-analytics.application.name"); applicationName = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("google-analytics.application.name");
tableId = new DSpace().getConfigurationService().getProperty("google-analytics.table.id"); tableId = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("google-analytics.table.id");
emailAddress = new DSpace().getConfigurationService().getProperty("google-analytics.account.email"); emailAddress = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("google-analytics.account.email");
certificateLocation = new DSpace().getConfigurationService().getProperty("google-analytics.certificate.location"); certificateLocation = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("google-analytics.certificate.location");
jsonFactory = JacksonFactory.getDefaultInstance(); jsonFactory = JacksonFactory.getDefaultInstance();

View File

@@ -16,15 +16,13 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair; import org.apache.http.message.BasicNameValuePair;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.content.DSpaceObject;
import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.DSpaceObjectService;
import org.dspace.core.ConfigurationManager; import org.dspace.core.ConfigurationManager;
import org.dspace.core.Constants; import org.dspace.core.Constants;
import org.dspace.services.factory.DSpaceServicesFactory;
import org.dspace.services.model.Event; import org.dspace.services.model.Event;
import org.dspace.usage.AbstractUsageEventListener; import org.dspace.usage.AbstractUsageEventListener;
import org.dspace.usage.UsageEvent; import org.dspace.usage.UsageEvent;
import org.dspace.utils.DSpace;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException; import java.io.IOException;
@@ -63,9 +61,9 @@ public class GoogleRecorderEventListener extends AbstractUsageEventListener {
log.debug("Usage event received " + event.getName()); log.debug("Usage event received " + event.getName());
// This is a wee bit messy but these keys should be combined in future. // This is a wee bit messy but these keys should be combined in future.
analyticsKey = new DSpace().getConfigurationService().getProperty("jspui.google.analytics.key"); analyticsKey = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("jspui.google.analytics.key");
if (analyticsKey == null ) { if (analyticsKey == null ) {
analyticsKey = new DSpace().getConfigurationService().getProperty("xmlui.google.analytics.key"); analyticsKey = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("xmlui.google.analytics.key");
} }
if (analyticsKey != null ) { if (analyticsKey != null ) {

View File

@@ -8,7 +8,7 @@
package org.dspace.handle.factory; package org.dspace.handle.factory;
import org.dspace.handle.service.HandleService; import org.dspace.handle.service.HandleService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the handle package, use HandleServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the handle package, use HandleServiceFactory.getInstance() to retrieve an implementation
@@ -21,6 +21,6 @@ public abstract class HandleServiceFactory {
public static HandleServiceFactory getInstance() public static HandleServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("handleServiceFactory", HandleServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("handleServiceFactory", HandleServiceFactory.class);
} }
} }

View File

@@ -42,8 +42,9 @@ import org.dspace.core.Constants;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.Email; import org.dspace.core.Email;
import org.dspace.core.I18nUtil; import org.dspace.core.I18nUtil;
import org.dspace.core.PluginManager;
import org.dspace.core.Utils; import org.dspace.core.Utils;
import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.core.service.PluginService;
import org.dspace.handle.factory.HandleServiceFactory; import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService; import org.dspace.handle.service.HandleService;
import org.dspace.harvest.factory.HarvestServiceFactory; import org.dspace.harvest.factory.HarvestServiceFactory;
@@ -88,7 +89,7 @@ public class OAIHarvester {
protected HandleService handleService; protected HandleService handleService;
protected HarvestedItemService harvestedItemService; protected HarvestedItemService harvestedItemService;
protected WorkspaceItemService workspaceItemService; protected WorkspaceItemService workspaceItemService;
protected PluginService pluginService;
// The collection this harvester instance is dealing with // The collection this harvester instance is dealing with
Collection targetCollection; Collection targetCollection;
@@ -98,12 +99,12 @@ public class OAIHarvester {
Context ourContext; Context ourContext;
// Namespace used by the ORE serialization format // Namespace used by the ORE serialization format
// Set in dspace.cfg as harvester.oai.oreSerializationFormat.{ORESerialKey} = {ORESerialNS} // Set in dspace.cfg as oai.harvester.oreSerializationFormat.{ORESerialKey} = {ORESerialNS}
private Namespace ORESerialNS; private Namespace ORESerialNS;
private String ORESerialKey; private String ORESerialKey;
// Namespace of the descriptive metadata that should be harvested in addition to the ORE // Namespace of the descriptive metadata that should be harvested in addition to the ORE
// Set in dspace.cfg as harvester.oai.metadataformats.{MetadataKey} = {MetadataNS},{Display Name} // Set in dspace.cfg as oai.harvester.metadataformats.{MetadataKey} = {MetadataNS},{Display Name}
private Namespace metadataNS; private Namespace metadataNS;
private String metadataKey; private String metadataKey;
@@ -126,6 +127,7 @@ public class OAIHarvester {
installItemService = ContentServiceFactory.getInstance().getInstallItemService(); installItemService = ContentServiceFactory.getInstance().getInstallItemService();
workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService(); workspaceItemService = ContentServiceFactory.getInstance().getWorkspaceItemService();
pluginService = CoreServiceFactory.getInstance().getPluginService();
if (dso.getType() != Constants.COLLECTION) if (dso.getType() != Constants.COLLECTION)
{ {
@@ -153,7 +155,7 @@ public class OAIHarvester {
metadataNS = OAIHarvester.getDMDNamespace(metadataKey); metadataNS = OAIHarvester.getDMDNamespace(metadataKey);
if (metadataNS == null) { if (metadataNS == null) {
log.error("No matching metadata namespace found for \"" + metadataKey + "\", see oai.cfg option \"harvester.oai.metadataformats.{MetadataKey} = {MetadataNS},{Display Name}\""); log.error("No matching metadata namespace found for \"" + metadataKey + "\", see oai.cfg option \"oai.harvester.metadataformats.{MetadataKey} = {MetadataNS},{Display Name}\"");
throw new HarvestingException("Metadata declaration not found"); throw new HarvestingException("Metadata declaration not found");
} }
} }
@@ -166,7 +168,7 @@ public class OAIHarvester {
private static Namespace getORENamespace() { private static Namespace getORENamespace() {
String ORESerializationString = null; String ORESerializationString = null;
String ORESeialKey = null; String ORESeialKey = null;
String oreString = "harvester.oai.oreSerializationFormat."; String oreString = "oai.harvester.oreSerializationFormat.";
Enumeration pe = ConfigurationManager.propertyNames("oai"); Enumeration pe = ConfigurationManager.propertyNames("oai");
@@ -193,7 +195,7 @@ public class OAIHarvester {
*/ */
private static Namespace getDMDNamespace(String metadataKey) { private static Namespace getDMDNamespace(String metadataKey) {
String metadataString = null; String metadataString = null;
String metaString = "harvester.oai.metadataformats."; String metaString = "oai.harvester.metadataformats.";
Enumeration pe = ConfigurationManager.propertyNames("oai"); Enumeration pe = ConfigurationManager.propertyNames("oai");
@@ -451,14 +453,14 @@ public class OAIHarvester {
// If we are only harvesting descriptive metadata, the record should already contain all we need // If we are only harvesting descriptive metadata, the record should already contain all we need
List<Element> descMD = record.getChild("metadata", OAI_NS).getChildren(); List<Element> descMD = record.getChild("metadata", OAI_NS).getChildren();
IngestionCrosswalk MDxwalk = (IngestionCrosswalk)PluginManager.getNamedPlugin(IngestionCrosswalk.class, this.metadataKey); IngestionCrosswalk MDxwalk = (IngestionCrosswalk)pluginService.getNamedPlugin(IngestionCrosswalk.class, this.metadataKey);
// Otherwise, obtain the ORE ReM and initiate the ORE crosswalk // Otherwise, obtain the ORE ReM and initiate the ORE crosswalk
IngestionCrosswalk ORExwalk = null; IngestionCrosswalk ORExwalk = null;
Element oreREM = null; Element oreREM = null;
if (harvestRow.getHarvestType() > 1) { if (harvestRow.getHarvestType() > 1) {
oreREM = getMDrecord(harvestRow.getOaiSource(), itemOaiID, OREPrefix).get(0); oreREM = getMDrecord(harvestRow.getOaiSource(), itemOaiID, OREPrefix).get(0);
ORExwalk = (IngestionCrosswalk)PluginManager.getNamedPlugin(IngestionCrosswalk.class, this.ORESerialKey); ORExwalk = (IngestionCrosswalk)pluginService.getNamedPlugin(IngestionCrosswalk.class, this.ORESerialKey);
} }
// Ignore authorization // Ignore authorization

View File

@@ -10,7 +10,7 @@ package org.dspace.harvest.factory;
import org.dspace.harvest.service.HarvestSchedulingService; import org.dspace.harvest.service.HarvestSchedulingService;
import org.dspace.harvest.service.HarvestedCollectionService; import org.dspace.harvest.service.HarvestedCollectionService;
import org.dspace.harvest.service.HarvestedItemService; import org.dspace.harvest.service.HarvestedItemService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the harvest package, use HarvestServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the harvest package, use HarvestServiceFactory.getInstance() to retrieve an implementation
@@ -27,6 +27,6 @@ public abstract class HarvestServiceFactory {
public static HarvestServiceFactory getInstance() public static HarvestServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("harvestServiceFactory", HarvestServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("harvestServiceFactory", HarvestServiceFactory.class);
} }
} }

View File

@@ -12,7 +12,7 @@ import org.apache.log4j.Logger;
import org.dspace.content.DSpaceObject; import org.dspace.content.DSpaceObject;
import org.dspace.content.crosswalk.DisseminationCrosswalk; import org.dspace.content.crosswalk.DisseminationCrosswalk;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.PluginManager; import org.dspace.core.factory.CoreServiceFactory;
import org.jdom.Element; import org.jdom.Element;
import org.jdom.output.XMLOutputter; import org.jdom.output.XMLOutputter;
@@ -93,7 +93,7 @@ public class DataCiteXMLCreator
if (null != this.xwalk) if (null != this.xwalk)
return; return;
this.xwalk = (DisseminationCrosswalk) PluginManager.getNamedPlugin( this.xwalk = (DisseminationCrosswalk) CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(
DisseminationCrosswalk.class, this.CROSSWALK_NAME); DisseminationCrosswalk.class, this.CROSSWALK_NAME);
if (this.xwalk == null) if (this.xwalk == null)

View File

@@ -33,7 +33,7 @@ import org.dspace.content.crosswalk.DisseminationCrosswalk;
import org.dspace.content.factory.ContentServiceFactory; import org.dspace.content.factory.ContentServiceFactory;
import org.dspace.content.service.DSpaceObjectService; import org.dspace.content.service.DSpaceObjectService;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.core.PluginManager; import org.dspace.core.factory.CoreServiceFactory;
import org.dspace.handle.factory.HandleServiceFactory; import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService; import org.dspace.handle.service.HandleService;
import org.dspace.identifier.DOI; import org.dspace.identifier.DOI;
@@ -198,7 +198,7 @@ implements DOIConnector
if (null != this.xwalk) if (null != this.xwalk)
return; return;
this.xwalk = (DisseminationCrosswalk) PluginManager.getNamedPlugin( this.xwalk = (DisseminationCrosswalk) CoreServiceFactory.getInstance().getPluginService().getNamedPlugin(
DisseminationCrosswalk.class, this.CROSSWALK_NAME); DisseminationCrosswalk.class, this.CROSSWALK_NAME);
if (this.xwalk == null) if (this.xwalk == null)

View File

@@ -9,7 +9,7 @@ package org.dspace.identifier.factory;
import org.dspace.identifier.service.DOIService; import org.dspace.identifier.service.DOIService;
import org.dspace.identifier.service.IdentifierService; import org.dspace.identifier.service.IdentifierService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the identifier package, use IdentifierServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the identifier package, use IdentifierServiceFactory.getInstance() to retrieve an implementation
@@ -23,6 +23,6 @@ public abstract class IdentifierServiceFactory {
public abstract DOIService getDOIService(); public abstract DOIService getDOIService();
public static IdentifierServiceFactory getInstance(){ public static IdentifierServiceFactory getInstance(){
return new DSpace().getServiceManager().getServiceByName("identifierServiceFactory", IdentifierServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("identifierServiceFactory", IdentifierServiceFactory.class);
} }
} }

View File

@@ -8,7 +8,7 @@
package org.dspace.license.factory; package org.dspace.license.factory;
import org.dspace.license.service.CreativeCommonsService; import org.dspace.license.service.CreativeCommonsService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* Abstract factory to get services for the license package, use LicenseServiceFactory.getInstance() to retrieve an implementation * Abstract factory to get services for the license package, use LicenseServiceFactory.getInstance() to retrieve an implementation
@@ -21,6 +21,6 @@ public abstract class LicenseServiceFactory {
public static LicenseServiceFactory getInstance() public static LicenseServiceFactory getInstance()
{ {
return new DSpace().getServiceManager().getServiceByName("licenseServiceFactory", LicenseServiceFactory.class); return DSpaceServicesFactory.getInstance().getServiceManager().getServiceByName("licenseServiceFactory", LicenseServiceFactory.class);
} }
} }

View File

@@ -15,7 +15,7 @@ import org.dspace.rdf.conversion.RDFConverter;
import org.dspace.rdf.storage.RDFStorage; import org.dspace.rdf.storage.RDFStorage;
import org.dspace.rdf.storage.URIGenerator; import org.dspace.rdf.storage.URIGenerator;
import org.dspace.services.ConfigurationService; import org.dspace.services.ConfigurationService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* *
@@ -115,7 +115,7 @@ public class RDFConfiguration {
public static String[] getDSOTypesToConvert() public static String[] getDSOTypesToConvert()
{ {
String dsoTypes = (new DSpace()).getConfigurationService().getProperty( String dsoTypes = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty(
CONVERTER_DSOTYPES_KEY); CONVERTER_DSOTYPES_KEY);
if (StringUtils.isEmpty(dsoTypes)) if (StringUtils.isEmpty(dsoTypes))
{ {
@@ -147,7 +147,7 @@ public class RDFConfiguration {
public static boolean isContentNegotiationEnabled() public static boolean isContentNegotiationEnabled()
{ {
ConfigurationService configurationService = ConfigurationService configurationService =
new DSpace().getConfigurationService(); DSpaceServicesFactory.getInstance().getConfigurationService();
return configurationService.getPropertyAsType(CONTENT_NEGOTIATION_KEY, return configurationService.getPropertyAsType(CONTENT_NEGOTIATION_KEY,
false); false);
} }
@@ -155,14 +155,14 @@ public class RDFConfiguration {
public static String getPublicSparqlEndpointAddress() public static String getPublicSparqlEndpointAddress()
{ {
ConfigurationService configurationService = ConfigurationService configurationService =
new DSpace().getConfigurationService(); DSpaceServicesFactory.getInstance().getConfigurationService();
return configurationService.getProperty(SPARQL_ENDPOINT_KEY); return configurationService.getProperty(SPARQL_ENDPOINT_KEY);
} }
public static String getInternalSparqlEndpointAddress() public static String getInternalSparqlEndpointAddress()
{ {
ConfigurationService configurationService = ConfigurationService configurationService =
new DSpace().getConfigurationService(); DSpaceServicesFactory.getInstance().getConfigurationService();
String internalSparqlEndpoint = String internalSparqlEndpoint =
configurationService.getProperty(STORAGE_SPARQL_ENDPOINT_KEY); configurationService.getProperty(STORAGE_SPARQL_ENDPOINT_KEY);
String externalSparqlEndpoint = String externalSparqlEndpoint =
@@ -175,7 +175,7 @@ public class RDFConfiguration {
public static String getDSpaceRDFModuleURI() public static String getDSpaceRDFModuleURI()
{ {
ConfigurationService configurationService = ConfigurationService configurationService =
new DSpace().getConfigurationService(); DSpaceServicesFactory.getInstance().getConfigurationService();
return configurationService.getProperty(CONTEXT_PATH_KEY); return configurationService.getProperty(CONTEXT_PATH_KEY);
} }
@@ -184,7 +184,7 @@ public class RDFConfiguration {
if (converter == null) if (converter == null)
{ {
ConfigurationService configurationService = ConfigurationService configurationService =
new DSpace().getConfigurationService(); DSpaceServicesFactory.getInstance().getConfigurationService();
converter = (RDFConverter) initializeClass(configurationService, converter = (RDFConverter) initializeClass(configurationService,
RDFCONVERTER_KEY, "RDFConverter"); RDFCONVERTER_KEY, "RDFConverter");
} }
@@ -204,7 +204,7 @@ public class RDFConfiguration {
if (generator == null) if (generator == null)
{ {
ConfigurationService configurationService = ConfigurationService configurationService =
new DSpace().getConfigurationService(); DSpaceServicesFactory.getInstance().getConfigurationService();
generator = (URIGenerator) initializeClass(configurationService, generator = (URIGenerator) initializeClass(configurationService,
URIGENERATOR_KEY, "URIGenerator"); URIGENERATOR_KEY, "URIGenerator");
} }
@@ -224,7 +224,7 @@ public class RDFConfiguration {
if (storage == null) if (storage == null)
{ {
ConfigurationService configurationService = ConfigurationService configurationService =
new DSpace().getConfigurationService(); DSpaceServicesFactory.getInstance().getConfigurationService();
storage = (RDFStorage) initializeClass(configurationService, storage = (RDFStorage) initializeClass(configurationService,
RDFSTORAGE_KEY, "RDFStorage"); RDFSTORAGE_KEY, "RDFStorage");
} }
@@ -240,13 +240,12 @@ public class RDFConfiguration {
*/ */
public static String[] loadConfigurationArray(String key) public static String[] loadConfigurationArray(String key)
{ {
String value = (new DSpace()).getConfigurationService().getProperty(key); ConfigurationService config = DSpaceServicesFactory.getInstance().getConfigurationService();
if (StringUtils.isEmpty(value)) if(config.hasProperty(key))
{ return config.getArrayProperty(key);
else
return null; return null;
} }
return value.split(",\\s*");
}
/* /*

View File

@@ -40,7 +40,7 @@ import org.dspace.core.Context;
import org.dspace.handle.factory.HandleServiceFactory; import org.dspace.handle.factory.HandleServiceFactory;
import org.dspace.handle.service.HandleService; import org.dspace.handle.service.HandleService;
import org.dspace.services.ConfigurationService; import org.dspace.services.ConfigurationService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* This class manages the handling of RDF data in DSpace. It generates * This class manages the handling of RDF data in DSpace. It generates
@@ -75,7 +75,7 @@ public class RDFizer {
public RDFizer() public RDFizer()
{ {
this.configurationService = new DSpace().getConfigurationService(); this.configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
this.stdout = false; this.stdout = false;
this.verbose = false; this.verbose = false;
this.dryrun = false; this.dryrun = false;

View File

@@ -19,7 +19,7 @@ import org.dspace.content.DSpaceObject;
import org.dspace.core.Context; import org.dspace.core.Context;
import org.dspace.rdf.RDFConfiguration; import org.dspace.rdf.RDFConfiguration;
import org.dspace.services.ConfigurationService; import org.dspace.services.ConfigurationService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* *
@@ -33,7 +33,7 @@ public class RDFConverterImpl implements RDFConverter
public RDFConverterImpl() public RDFConverterImpl()
{ {
this.configurationService = new DSpace().getConfigurationService(); this.configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
this.plugins = new ArrayList<ConverterPlugin>(); this.plugins = new ArrayList<ConverterPlugin>();
String pluginNames[] = RDFConfiguration.getConverterPlugins(); String pluginNames[] = RDFConfiguration.getConverterPlugins();

View File

@@ -32,7 +32,7 @@ import org.apache.jena.web.DatasetGraphAccessorHTTP;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.dspace.rdf.RDFConfiguration; import org.dspace.rdf.RDFConfiguration;
import org.dspace.services.ConfigurationService; import org.dspace.services.ConfigurationService;
import org.dspace.utils.DSpace; import org.dspace.services.factory.DSpaceServicesFactory;
/** /**
* *
@@ -54,7 +54,7 @@ implements RDFStorage
public RDFStorageImpl() public RDFStorageImpl()
{ {
this.configurationService = new DSpace().getConfigurationService(); this.configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
this.GRAPHSTORE_ENDPOINT = this.configurationService this.GRAPHSTORE_ENDPOINT = this.configurationService
.getProperty(RDFConfiguration.STORAGE_GRAPHSTORE_ENDPOINT_KEY); .getProperty(RDFConfiguration.STORAGE_GRAPHSTORE_ENDPOINT_KEY);

Some files were not shown because too many files have changed in this diff Show More