mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-12 12:33:18 +00:00
Fix API classes using comma-separated configs (and ensure they all use ConfigurationService)
This commit is contained in:
@@ -11,15 +11,17 @@ import org.apache.log4j.Logger;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.curate.AbstractCurationTask;
|
||||
import org.dspace.curate.Curator;
|
||||
import org.dspace.curate.Distributive;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* MicrosoftTranslator translates stuff
|
||||
*
|
||||
@@ -43,6 +45,9 @@ public abstract class AbstractTranslator extends AbstractCurationTask
|
||||
|
||||
protected List<String> results = new ArrayList<String>();
|
||||
|
||||
private final transient ConfigurationService configurationService
|
||||
= DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
|
||||
@Override
|
||||
public void init(Curator curator, String taskId) throws IOException
|
||||
@@ -50,12 +55,10 @@ public abstract class AbstractTranslator extends AbstractCurationTask
|
||||
super.init(curator, taskId);
|
||||
|
||||
// Load configuration
|
||||
authLang = ConfigurationManager.getProperty("default.locale");
|
||||
authLangField = ConfigurationManager.getProperty(PLUGIN_PREFIX, "field.language");
|
||||
String toTranslateStr = ConfigurationManager.getProperty(PLUGIN_PREFIX, "field.targets");
|
||||
String langsStr = ConfigurationManager.getProperty(PLUGIN_PREFIX, "language.targets");
|
||||
toTranslate = toTranslateStr.split(",");
|
||||
langs = langsStr.split(",");
|
||||
authLang = configurationService.getProperty("default.locale");
|
||||
authLangField = configurationService.getProperty(PLUGIN_PREFIX + ".field.language");
|
||||
String[] toTranslate = configurationService.getArrayProperty(PLUGIN_PREFIX + ".field.targets");
|
||||
String[] langs = configurationService.getArrayProperty(PLUGIN_PREFIX + ".language.targets");
|
||||
|
||||
if(!(toTranslate.length > 0 && langs.length > 0))
|
||||
{
|
||||
|
@@ -25,7 +25,6 @@ import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.*;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.curate.AbstractCurationTask;
|
||||
import org.dspace.curate.Curator;
|
||||
import org.dspace.curate.Suspendable;
|
||||
@@ -74,10 +73,10 @@ public class ClamScan extends AbstractCurationTask
|
||||
public void init(Curator curator, String taskId) throws IOException
|
||||
{
|
||||
super.init(curator, taskId);
|
||||
host = ConfigurationManager.getProperty(PLUGIN_PREFIX, "service.host");
|
||||
port = ConfigurationManager.getIntProperty(PLUGIN_PREFIX, "service.port");
|
||||
timeout = ConfigurationManager.getIntProperty(PLUGIN_PREFIX, "socket.timeout");
|
||||
failfast = ConfigurationManager.getBooleanProperty(PLUGIN_PREFIX, "scan.failfast");
|
||||
host = configurationService.getProperty(PLUGIN_PREFIX + ".service.host");
|
||||
port = configurationService.getIntProperty(PLUGIN_PREFIX + ".service.port");
|
||||
timeout = configurationService.getIntProperty(PLUGIN_PREFIX + ".socket.timeout");
|
||||
failfast = configurationService.getBooleanProperty(PLUGIN_PREFIX + ".scan.failfast");
|
||||
bitstreamService = ContentServiceFactory.getInstance().getBitstreamService();
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,6 @@ import org.xml.sax.SAXException;
|
||||
import org.dspace.authorize.AuthorizeException;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.curate.AbstractCurationTask;
|
||||
import org.dspace.curate.Curator;
|
||||
@@ -167,7 +166,7 @@ public class MetadataWebService extends AbstractCurationTask implements Namespac
|
||||
@Override
|
||||
public void init(Curator curator, String taskId) throws IOException {
|
||||
super.init(curator, taskId);
|
||||
lang = ConfigurationManager.getProperty("default.language");
|
||||
lang = configurationService.getProperty("default.language");
|
||||
String fldSep = taskProperty("separator");
|
||||
fieldSeparator = (fldSep != null) ? fldSep : " ";
|
||||
urlTemplate = taskProperty("template");
|
||||
@@ -177,7 +176,7 @@ public class MetadataWebService extends AbstractCurationTask implements Namespac
|
||||
lookupField = parsed[0];
|
||||
lookupTransform = parsed[1];
|
||||
dataList = new ArrayList<DataInfo>();
|
||||
for (String entry : taskProperty("datamap").split(",")) {
|
||||
for (String entry : taskArrayProperty("datamap")) {
|
||||
entry = entry.trim();
|
||||
String src = entry;
|
||||
String mapping = null;
|
||||
|
@@ -11,8 +11,8 @@ import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.content.Collection;
|
||||
@@ -22,11 +22,12 @@ import org.dspace.content.Item;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.CommunityService;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.handle.factory.HandleServiceFactory;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* AbstractCurationTask encapsulates a few common patterns of task use,
|
||||
@@ -40,14 +41,12 @@ public abstract class AbstractCurationTask implements CurationTask
|
||||
protected Curator curator = null;
|
||||
// curator-assigned taskId
|
||||
protected String taskId = null;
|
||||
// optional task configuration properties
|
||||
private Properties taskProps = null;
|
||||
// logger
|
||||
private static Logger log = Logger.getLogger(AbstractCurationTask.class);
|
||||
protected CommunityService communityService;
|
||||
protected ItemService itemService;
|
||||
protected HandleService handleService;
|
||||
|
||||
protected ConfigurationService configurationService;
|
||||
|
||||
@Override
|
||||
public void init(Curator curator, String taskId) throws IOException
|
||||
@@ -57,6 +56,7 @@ public abstract class AbstractCurationTask implements CurationTask
|
||||
communityService = ContentServiceFactory.getInstance().getCommunityService();
|
||||
itemService = ContentServiceFactory.getInstance().getItemService();
|
||||
handleService = HandleServiceFactory.getInstance().getHandleService();
|
||||
configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -235,29 +235,15 @@ public abstract class AbstractCurationTask implements CurationTask
|
||||
*/
|
||||
protected String taskProperty(String name)
|
||||
{
|
||||
if (taskProps == null)
|
||||
// If a taskID/Name is specified, prepend it on the configuration name
|
||||
if(StringUtils.isNotBlank(taskId))
|
||||
{
|
||||
// load properties
|
||||
taskProps = new Properties();
|
||||
StringBuilder modName = new StringBuilder();
|
||||
for (String segment : taskId.split("\\."))
|
||||
return configurationService.getProperty(taskId + "." + name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// load property segments if present
|
||||
modName.append(segment);
|
||||
Properties modProps = ConfigurationManager.getProperties(modName.toString());
|
||||
if (modProps != null)
|
||||
{
|
||||
taskProps.putAll(modProps);
|
||||
return configurationService.getProperty(name);
|
||||
}
|
||||
modName.append(".");
|
||||
}
|
||||
// warn if *no* properties found
|
||||
if (taskProps.size() == 0)
|
||||
{
|
||||
log.warn("Warning: No configuration properties found for task: " + taskId);
|
||||
}
|
||||
}
|
||||
return taskProps.getProperty(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,20 +260,15 @@ public abstract class AbstractCurationTask implements CurationTask
|
||||
*/
|
||||
protected int taskIntProperty(String name, int defaultValue)
|
||||
{
|
||||
int intVal = defaultValue;
|
||||
String strVal = taskProperty(name);
|
||||
if (strVal != null)
|
||||
// If a taskID/Name is specified, prepend it on the configuration name
|
||||
if(StringUtils.isNotBlank(taskId))
|
||||
{
|
||||
try
|
||||
return configurationService.getIntProperty(taskId + "." + name, defaultValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
intVal = Integer.parseInt(strVal.trim());
|
||||
return configurationService.getIntProperty(name, defaultValue);
|
||||
}
|
||||
catch(NumberFormatException nfE)
|
||||
{
|
||||
log.warn("Warning: Number format error in module: " + taskId + " property: " + name);
|
||||
}
|
||||
}
|
||||
return intVal;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -304,20 +285,15 @@ public abstract class AbstractCurationTask implements CurationTask
|
||||
*/
|
||||
protected long taskLongProperty(String name, long defaultValue)
|
||||
{
|
||||
long longVal = defaultValue;
|
||||
String strVal = taskProperty(name);
|
||||
if (strVal != null)
|
||||
// If a taskID/Name is specified, prepend it on the configuration name
|
||||
if(StringUtils.isNotBlank(taskId))
|
||||
{
|
||||
try
|
||||
return configurationService.getLongProperty(taskId + "." + name, defaultValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
longVal = Long.parseLong(strVal.trim());
|
||||
return configurationService.getLongProperty(name, defaultValue);
|
||||
}
|
||||
catch(NumberFormatException nfE)
|
||||
{
|
||||
log.warn("Warning: Number format error in module: " + taskId + " property: " + name);
|
||||
}
|
||||
}
|
||||
return longVal;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -334,13 +310,37 @@ public abstract class AbstractCurationTask implements CurationTask
|
||||
*/
|
||||
protected boolean taskBooleanProperty(String name, boolean defaultValue)
|
||||
{
|
||||
String strVal = taskProperty(name);
|
||||
if (strVal != null)
|
||||
// If a taskID/Name is specified, prepend it on the configuration name
|
||||
if(StringUtils.isNotBlank(taskId))
|
||||
{
|
||||
strVal = strVal.trim();
|
||||
return strVal.equalsIgnoreCase("true") ||
|
||||
strVal.equalsIgnoreCase("yes");
|
||||
return configurationService.getBooleanProperty(taskId + "." + name, defaultValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
return configurationService.getBooleanProperty(name, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns task configuration Array property value for passed name, else
|
||||
* <code>null</code> if no properties defined or no value for passed key.
|
||||
*
|
||||
* @param name
|
||||
* the property name
|
||||
* @return value
|
||||
* the property value, or null
|
||||
*
|
||||
*/
|
||||
protected String[] taskArrayProperty(String name)
|
||||
{
|
||||
// If a taskID/Name is specified, prepend it on the configuration name
|
||||
if(StringUtils.isNotBlank(taskId))
|
||||
{
|
||||
return configurationService.getArrayProperty(taskId + "." + name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return configurationService.getArrayProperty(name);
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
@@ -20,8 +20,8 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
|
||||
/**
|
||||
* FileTaskQueue provides a TaskQueue implementation based on flat files
|
||||
@@ -33,7 +33,7 @@ public class FileTaskQueue implements TaskQueue
|
||||
{
|
||||
private static Logger log = Logger.getLogger(TaskQueue.class);
|
||||
// base directory for curation task queues
|
||||
protected String tqDir = ConfigurationManager.getProperty("curate", "taskqueue.dir");
|
||||
protected String tqDir;
|
||||
|
||||
// ticket for queue readers
|
||||
protected long readTicket = -1L;
|
||||
@@ -42,6 +42,7 @@ public class FileTaskQueue implements TaskQueue
|
||||
|
||||
public FileTaskQueue()
|
||||
{
|
||||
tqDir = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("curate.taskqueue.dir");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -23,8 +23,8 @@ import javax.script.ScriptException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* TaskResolver takes a logical name of a curation task and attempts to deliver
|
||||
@@ -71,13 +71,14 @@ public class TaskResolver
|
||||
|
||||
// base directory of task scripts & catalog name
|
||||
protected static final String CATALOG = "task.catalog";
|
||||
protected static final String scriptDir = ConfigurationManager.getProperty("curate", "script.dir");
|
||||
protected final String scriptDir;
|
||||
|
||||
// catalog of script tasks
|
||||
protected Properties catalog;
|
||||
|
||||
public TaskResolver()
|
||||
{
|
||||
scriptDir = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("curate.script.dir");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -968,14 +968,10 @@ public class SolrServiceImpl implements SearchService, IndexingService {
|
||||
|
||||
|
||||
List<String> toProjectionFields = new ArrayList<String>();
|
||||
String projectionFieldsString = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("discovery.index.projection");
|
||||
if(projectionFieldsString != null){
|
||||
if(projectionFieldsString.indexOf(",") != -1){
|
||||
for (int i = 0; i < projectionFieldsString.split(",").length; i++) {
|
||||
toProjectionFields.add(projectionFieldsString.split(",")[i].trim());
|
||||
}
|
||||
} else {
|
||||
toProjectionFields.add(projectionFieldsString);
|
||||
String[] projectionFields = DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty("discovery.index.projection");
|
||||
if(projectionFields != null){
|
||||
for (String field : projectionFields) {
|
||||
toProjectionFields.add(field.trim());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,6 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -37,7 +36,6 @@ import org.dspace.content.crosswalk.CrosswalkException;
|
||||
import org.dspace.content.crosswalk.IngestionCrosswalk;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.*;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.core.Email;
|
||||
@@ -50,6 +48,8 @@ import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.harvest.factory.HarvestServiceFactory;
|
||||
import org.dspace.harvest.service.HarvestedCollectionService;
|
||||
import org.dspace.harvest.service.HarvestedItemService;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.jdom.Document;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.Namespace;
|
||||
@@ -90,6 +90,7 @@ public class OAIHarvester {
|
||||
protected HarvestedItemService harvestedItemService;
|
||||
protected WorkspaceItemService workspaceItemService;
|
||||
protected PluginService pluginService;
|
||||
protected ConfigurationService configurationService;
|
||||
|
||||
// The collection this harvester instance is dealing with
|
||||
Collection targetCollection;
|
||||
@@ -168,20 +169,17 @@ public class OAIHarvester {
|
||||
private static Namespace getORENamespace() {
|
||||
String ORESerializationString = null;
|
||||
String ORESeialKey = null;
|
||||
String oreString = "oai.harvester.oreSerializationFormat.";
|
||||
String oreString = "oai.harvester.oreSerializationFormat";
|
||||
|
||||
Enumeration pe = ConfigurationManager.propertyNames("oai");
|
||||
List<String> keys = DSpaceServicesFactory.getInstance().getConfigurationService().getPropertyKeys(oreString);
|
||||
|
||||
while (pe.hasMoreElements())
|
||||
for(String key : keys)
|
||||
{
|
||||
String key = (String)pe.nextElement();
|
||||
if (key.startsWith(oreString)) {
|
||||
ORESeialKey = key.substring(oreString.length());
|
||||
ORESerializationString = ConfigurationManager.getProperty("oai", key);
|
||||
ORESeialKey = key.substring(oreString.length()+1);
|
||||
ORESerializationString = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty(key);
|
||||
|
||||
return Namespace.getNamespace(ORESeialKey, ORESerializationString);
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback if the configuration option is not present
|
||||
return Namespace.getNamespace("ore", ATOM_NS.getURI());
|
||||
@@ -195,16 +193,14 @@ public class OAIHarvester {
|
||||
*/
|
||||
private static Namespace getDMDNamespace(String metadataKey) {
|
||||
String metadataString = null;
|
||||
String metaString = "oai.harvester.metadataformats.";
|
||||
String metaString = "oai.harvester.metadataformats";
|
||||
|
||||
Enumeration pe = ConfigurationManager.propertyNames("oai");
|
||||
List<String> keys = DSpaceServicesFactory.getInstance().getConfigurationService().getPropertyKeys(metaString);
|
||||
|
||||
while (pe.hasMoreElements())
|
||||
for(String key : keys)
|
||||
{
|
||||
String key = (String)pe.nextElement();
|
||||
|
||||
if (key.startsWith(metaString) && key.substring(metaString.length()).equals((metadataKey))) {
|
||||
metadataString = ConfigurationManager.getProperty("oai", key);
|
||||
if (key.substring(metaString.length()+1).equals((metadataKey))) {
|
||||
metadataString = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty(key);
|
||||
String namespacePiece;
|
||||
if (metadataString.indexOf(',') != -1)
|
||||
{
|
||||
@@ -296,7 +292,7 @@ public class OAIHarvester {
|
||||
harvestedCollection.update(ourContext, harvestRow);
|
||||
|
||||
// expiration timer starts
|
||||
int expirationInterval = ConfigurationManager.getIntProperty("oai", "harvester.threadTimeout");
|
||||
int expirationInterval = configurationService.getIntProperty("oai.harvester.threadTimeout");
|
||||
if (expirationInterval == 0)
|
||||
{
|
||||
expirationInterval = 24;
|
||||
@@ -613,25 +609,22 @@ public class OAIHarvester {
|
||||
*/
|
||||
protected String extractHandle(Item item)
|
||||
{
|
||||
String acceptedHandleServersString = ConfigurationManager.getProperty("oai", "harvester.acceptedHandleServer");
|
||||
if (acceptedHandleServersString == null)
|
||||
String[] acceptedHandleServers = configurationService.getArrayProperty("oai.harvester.acceptedHandleServer");
|
||||
if (acceptedHandleServers == null)
|
||||
{
|
||||
acceptedHandleServersString = "hdl.handle.net";
|
||||
acceptedHandleServers = new String[]{"hdl.handle.net"};
|
||||
}
|
||||
|
||||
String rejectedHandlePrefixString = ConfigurationManager.getProperty("oai", "harvester.rejectedHandlePrefix");
|
||||
if (rejectedHandlePrefixString == null)
|
||||
String[] rejectedHandlePrefixes = configurationService.getArrayProperty("oai.harvester.rejectedHandlePrefix");
|
||||
if (rejectedHandlePrefixes == null)
|
||||
{
|
||||
rejectedHandlePrefixString = "123456789";
|
||||
rejectedHandlePrefixes = new String[]{"123456789"};
|
||||
}
|
||||
|
||||
List<MetadataValue> values = itemService.getMetadata(item, "dc", "identifier", Item.ANY, Item.ANY);
|
||||
|
||||
if (values.size() > 0 && !acceptedHandleServersString.equals(""))
|
||||
if (values.size() > 0 && acceptedHandleServers != null)
|
||||
{
|
||||
String[] acceptedHandleServers = acceptedHandleServersString.split(",");
|
||||
String[] rejectedHandlePrefixes = rejectedHandlePrefixString.split(",");
|
||||
|
||||
for (MetadataValue value : values)
|
||||
{
|
||||
// 0 1 2 3 4
|
||||
@@ -667,7 +660,7 @@ public class OAIHarvester {
|
||||
* @return a string in the format 'yyyy-mm-ddThh:mm:ssZ' and converted to UTC timezone
|
||||
*/
|
||||
private String processDate(Date date) {
|
||||
Integer timePad = ConfigurationManager.getIntProperty("oai", "harvester.timePadding");
|
||||
Integer timePad = configurationService.getIntProperty("oai.harvester.timePadding");
|
||||
|
||||
if (timePad == 0) {
|
||||
timePad = 120;
|
||||
@@ -748,7 +741,7 @@ public class OAIHarvester {
|
||||
protected void alertAdmin(int status, Exception ex)
|
||||
{
|
||||
try {
|
||||
String recipient = ConfigurationManager.getProperty("alert.recipient");
|
||||
String recipient = configurationService.getProperty("alert.recipient");
|
||||
|
||||
if (StringUtils.isNotBlank(recipient)) {
|
||||
Email email = Email.getEmail(I18nUtil.getEmailFilename(Locale.getDefault(), "harvesting_error"));
|
||||
|
@@ -18,6 +18,7 @@ import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import org.dspace.core.factory.CoreServiceFactory;
|
||||
import org.dspace.core.service.PluginService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* @author LINDAT/CLARIN dev team
|
||||
@@ -70,7 +71,7 @@ public class Report {
|
||||
// create check list
|
||||
public static LinkedHashMap<String, Check> checks() {
|
||||
LinkedHashMap<String, Check> checks = new LinkedHashMap<>();
|
||||
String check_names[] = ConfigurationManager.getProperty("healthcheck", "checks").split(",");
|
||||
String check_names[] = DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty("healthcheck.checks");
|
||||
PluginService pluginService = CoreServiceFactory.getInstance().getPluginService();
|
||||
for ( String check_name : check_names ) {
|
||||
Check check = (Check) pluginService.getNamedPlugin(
|
||||
|
@@ -32,7 +32,8 @@ import org.jdom.JDOMException;
|
||||
import org.jdom.input.SAXBuilder;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -45,9 +46,9 @@ public class CCLookup {
|
||||
/** log4j logger */
|
||||
private static Logger log = Logger.getLogger(CCLookup.class);
|
||||
|
||||
private static String cc_root = ConfigurationManager.getProperty("cc.api.rooturl");
|
||||
private static String jurisdiction;
|
||||
private static List<String> lcFilter = new ArrayList<String>();
|
||||
private String cc_root;
|
||||
private String jurisdiction;
|
||||
private List<String> lcFilter = new ArrayList<String>();
|
||||
|
||||
private Document license_doc = null;
|
||||
private String rdfString = null;
|
||||
@@ -58,24 +59,26 @@ public class CCLookup {
|
||||
private List<CCLicense> licenses = new ArrayList<CCLicense>();
|
||||
private List<CCLicenseField> licenseFields = new ArrayList<CCLicenseField>();
|
||||
|
||||
static {
|
||||
String jurisProp = ConfigurationManager.getProperty("cc.license.jurisdiction");
|
||||
jurisdiction = (jurisProp != null) ? jurisProp : "";
|
||||
|
||||
String filterList = ConfigurationManager.getProperty("cc.license.classfilter");
|
||||
if (filterList != null) {
|
||||
for (String name: filterList.split(",")) {
|
||||
lcFilter.add(name.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new instance with the default web services root.
|
||||
*
|
||||
*/
|
||||
public CCLookup() {
|
||||
super();
|
||||
|
||||
ConfigurationService configurationService = DSpaceServicesFactory.getInstance().getConfigurationService();
|
||||
|
||||
cc_root = configurationService.getProperty("cc.api.rooturl");
|
||||
|
||||
String jurisProp = configurationService.getProperty("cc.license.jurisdiction");
|
||||
jurisdiction = (jurisProp != null) ? jurisProp : "";
|
||||
|
||||
String[] filters = configurationService.getArrayProperty("cc.license.classfilter");
|
||||
if (filters != null) {
|
||||
for (String name: filters) {
|
||||
lcFilter.add(name.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -11,7 +11,6 @@ import au.com.bytecode.opencsv.CSVReader;
|
||||
import au.com.bytecode.opencsv.CSVWriter;
|
||||
import com.maxmind.geoip.Location;
|
||||
import com.maxmind.geoip.LookupService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -39,11 +38,11 @@ import org.dspace.content.Collection;
|
||||
import org.dspace.content.factory.ContentServiceFactory;
|
||||
import org.dspace.content.service.BitstreamService;
|
||||
import org.dspace.content.service.DSpaceObjectLegacySupportService;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.core.Constants;
|
||||
import org.dspace.core.Context;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.dspace.eperson.Group;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.statistics.service.SolrLoggerService;
|
||||
import org.dspace.statistics.util.DnsLookup;
|
||||
import org.dspace.statistics.util.LocationUtils;
|
||||
@@ -90,6 +89,8 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
||||
protected BitstreamService bitstreamService;
|
||||
@Autowired(required = true)
|
||||
protected ContentServiceFactory contentServiceFactory;
|
||||
@Autowired(required = true)
|
||||
private ConfigurationService configurationService;
|
||||
|
||||
public static enum StatisticsType {
|
||||
VIEW ("view"),
|
||||
@@ -114,20 +115,20 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
log.info("solr-statistics.spidersfile:" + ConfigurationManager.getProperty("solr-statistics", "spidersfile"));
|
||||
log.info("solr-statistics.server:" + ConfigurationManager.getProperty("solr-statistics", "server"));
|
||||
log.info("usage-statistics.dbfile:" + ConfigurationManager.getProperty("usage-statistics", "dbfile"));
|
||||
log.info("solr-statistics.spidersfile:" + configurationService.getProperty("solr-statistics.spidersfile"));
|
||||
log.info("solr-statistics.server:" + configurationService.getProperty("solr-statistics.server"));
|
||||
log.info("usage-statistics.dbfile:" + configurationService.getProperty("usage-statistics.dbfile"));
|
||||
|
||||
HttpSolrServer server = null;
|
||||
|
||||
if (ConfigurationManager.getProperty("solr-statistics", "server") != null)
|
||||
if (configurationService.getProperty("solr-statistics.server") != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
server = new HttpSolrServer(ConfigurationManager.getProperty("solr-statistics", "server"));
|
||||
server = new HttpSolrServer(configurationService.getProperty("solr-statistics.server"));
|
||||
|
||||
//Attempt to retrieve all the statistic year cores
|
||||
File solrDir = new File(ConfigurationManager.getProperty("dspace.dir") + "/solr/");
|
||||
File solrDir = new File(configurationService.getProperty("dspace.dir") + File.separator + "solr" + File.separator);
|
||||
File[] solrCoreFiles = solrDir.listFiles(new FileFilter() {
|
||||
|
||||
@Override
|
||||
@@ -158,7 +159,7 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
||||
|
||||
LookupService service = null;
|
||||
// Get the db file for the location
|
||||
String dbfile = ConfigurationManager.getProperty("usage-statistics", "dbfile");
|
||||
String dbfile = configurationService.getProperty("usage-statistics.dbfile");
|
||||
if (dbfile != null)
|
||||
{
|
||||
try
|
||||
@@ -181,15 +182,7 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
||||
}
|
||||
locationService = service;
|
||||
|
||||
if ("true".equals(ConfigurationManager.getProperty("useProxies")))
|
||||
{
|
||||
useProxies = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
useProxies = false;
|
||||
}
|
||||
|
||||
useProxies = configurationService.getBooleanProperty("useProxies");
|
||||
log.info("useProxies=" + useProxies);
|
||||
}
|
||||
|
||||
@@ -287,7 +280,7 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
||||
protected SolrInputDocument getCommonSolrDoc(DSpaceObject dspaceObject, HttpServletRequest request, EPerson currentUser) throws SQLException {
|
||||
boolean isSpiderBot = request != null && SpiderDetector.isSpider(request);
|
||||
if(isSpiderBot &&
|
||||
!ConfigurationManager.getBooleanProperty("usage-statistics", "logBots", true))
|
||||
!configurationService.getBooleanProperty("usage-statistics.logBots", true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -381,7 +374,7 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
||||
protected SolrInputDocument getCommonSolrDoc(DSpaceObject dspaceObject, String ip, String userAgent, String xforwardedfor, EPerson currentUser) throws SQLException {
|
||||
boolean isSpiderBot = SpiderDetector.isSpider(ip);
|
||||
if(isSpiderBot &&
|
||||
!ConfigurationManager.getBooleanProperty("usage-statistics", "logBots", true))
|
||||
!configurationService.getBooleanProperty("usage-statistics.logBots", true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -1088,14 +1081,14 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
||||
// not be influenced
|
||||
|
||||
// Choose to filter by the Legacy spider IP list (may get too long to properly filter all IP's
|
||||
if(ConfigurationManager.getBooleanProperty("solr-statistics", "query.filter.spiderIp",false))
|
||||
if(configurationService.getBooleanProperty("solr-statistics.query.filter.spiderIp",false))
|
||||
{
|
||||
solrQuery.addFilterQuery(getIgnoreSpiderIPs());
|
||||
}
|
||||
|
||||
// Choose to filter by isBot field, may be overriden in future
|
||||
// to allow views on stats based on bots.
|
||||
if(ConfigurationManager.getBooleanProperty("solr-statistics", "query.filter.isBot",true))
|
||||
if(configurationService.getBooleanProperty("solr-statistics.query.filter.isBot",true))
|
||||
{
|
||||
solrQuery.addFilterQuery("-isBot:true");
|
||||
}
|
||||
@@ -1104,8 +1097,8 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
||||
solrQuery.setSortField(sort, (ascending ? SolrQuery.ORDER.asc : SolrQuery.ORDER.desc));
|
||||
}
|
||||
|
||||
String bundles;
|
||||
if((bundles = ConfigurationManager.getProperty("solr-statistics", "query.filter.bundles")) != null && 0 < bundles.length()){
|
||||
String[] bundles = configurationService.getArrayProperty("solr-statistics.query.filter.bundles");
|
||||
if(bundles != null && bundles.length > 0){
|
||||
|
||||
/**
|
||||
* The code below creates a query that will allow only records which do not have a bundlename
|
||||
@@ -1114,11 +1107,10 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
||||
StringBuffer bundleQuery = new StringBuffer();
|
||||
//Also add the possibility that if no bundle name is there these results will also be returned !
|
||||
bundleQuery.append("-(bundleName:[* TO *]");
|
||||
String[] split = bundles.split(",");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
String bundle = split[i].trim();
|
||||
for (int i = 0; i < bundles.length; i++) {
|
||||
String bundle = bundles[i].trim();
|
||||
bundleQuery.append("-bundleName:").append(bundle);
|
||||
if(i != split.length - 1){
|
||||
if(i != bundles.length - 1){
|
||||
bundleQuery.append(" AND ");
|
||||
}
|
||||
}
|
||||
@@ -1207,7 +1199,7 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
||||
yearRangeQuery.add(FacetParams.FACET_MINCOUNT, String.valueOf(1));
|
||||
|
||||
//Create a temp directory to store our files in !
|
||||
File tempDirectory = new File(ConfigurationManager.getProperty("dspace.dir") + File.separator + "temp" + File.separator);
|
||||
File tempDirectory = new File(configurationService.getProperty("dspace.dir") + File.separator + "temp" + File.separator);
|
||||
tempDirectory.mkdirs();
|
||||
|
||||
|
||||
@@ -1292,7 +1284,7 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
||||
}
|
||||
|
||||
protected HttpSolrServer createCore(HttpSolrServer solr, String coreName) throws IOException, SolrServerException {
|
||||
String solrDir = ConfigurationManager.getProperty("dspace.dir") + File.separator + "solr" +File.separator;
|
||||
String solrDir = configurationService.getProperty("dspace.dir") + File.separator + "solr" +File.separator;
|
||||
String baseSolrUrl = solr.getBaseURL().replace("statistics", "");
|
||||
CoreAdminRequest.Create create = new CoreAdminRequest.Create();
|
||||
create.setCoreName(coreName);
|
||||
@@ -1320,7 +1312,7 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
||||
addAdditionalSolrYearCores(query);
|
||||
long totalRecords = solr.query(query).getResults().getNumFound();
|
||||
|
||||
File tempDirectory = new File(ConfigurationManager.getProperty("dspace.dir") + File.separator + "temp" + File.separator);
|
||||
File tempDirectory = new File(configurationService.getProperty("dspace.dir") + File.separator + "temp" + File.separator);
|
||||
tempDirectory.mkdirs();
|
||||
List<File> tempCsvFiles = new ArrayList<File>();
|
||||
for(int i = 0; i < totalRecords; i+=10000){
|
||||
@@ -1432,7 +1424,7 @@ public class SolrLoggerServiceImpl implements SolrLoggerService, InitializingBea
|
||||
public void exportHits() throws Exception {
|
||||
Context context = new Context();
|
||||
|
||||
File tempDirectory = new File(ConfigurationManager.getProperty("dspace.dir") + File.separator + "temp" + File.separator);
|
||||
File tempDirectory = new File(configurationService.getProperty("dspace.dir") + File.separator + "temp" + File.separator);
|
||||
tempDirectory.mkdirs();
|
||||
|
||||
try {
|
||||
|
@@ -18,7 +18,7 @@ import java.util.Set;
|
||||
import java.util.Collections;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -107,7 +107,7 @@ public class SpiderDetector {
|
||||
if (table == null) {
|
||||
table = new IPTable();
|
||||
|
||||
String filePath = ConfigurationManager.getProperty("dspace.dir");
|
||||
String filePath = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir");
|
||||
|
||||
try {
|
||||
File spidersDir = new File(filePath, "config/spiders");
|
||||
@@ -156,7 +156,7 @@ public class SpiderDetector {
|
||||
*/
|
||||
private static void loadPatterns(String directory, List<Pattern> patternList)
|
||||
{
|
||||
String dspaceHome = ConfigurationManager.getProperty("dspace.dir");
|
||||
String dspaceHome = DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir");
|
||||
File spidersDir = new File(dspaceHome, "config/spiders");
|
||||
File patternsDir = new File(spidersDir, directory);
|
||||
if (patternsDir.exists() && patternsDir.isDirectory())
|
||||
@@ -296,7 +296,7 @@ public class SpiderDetector {
|
||||
|
||||
private static boolean isUseProxies() {
|
||||
if(useProxies == null) {
|
||||
useProxies = "true".equals(ConfigurationManager.getProperty("useProxies"));
|
||||
useProxies = DSpaceServicesFactory.getInstance().getConfigurationService().getBooleanProperty("useProxies");
|
||||
}
|
||||
|
||||
return useProxies;
|
||||
|
@@ -10,12 +10,12 @@ package org.dspace.statistics.util;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.tools.ant.taskdefs.Get;
|
||||
import org.dspace.core.ConfigurationManager;
|
||||
import org.dspace.statistics.factory.StatisticsServiceFactory;
|
||||
import org.dspace.statistics.service.SolrLoggerService;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
|
||||
/**
|
||||
* Class to load intermediate statistics files into solr
|
||||
@@ -54,7 +54,7 @@ public class StatisticsClient
|
||||
|
||||
options.addOption("u", "update-spider-files", false,
|
||||
"Update Spider IP Files from internet into " +
|
||||
ConfigurationManager.getProperty("dspace.dir") + "/config/spiders");
|
||||
DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir") + "/config/spiders");
|
||||
|
||||
options.addOption("m", "mark-spiders", false, "Update isBot Flag in Solr");
|
||||
options.addOption("f", "delete-spiders-by-flag", false, "Delete Spiders in Solr By isBot Flag");
|
||||
@@ -123,23 +123,22 @@ public class StatisticsClient
|
||||
System.out.println("Downloading latest spider IP addresses:");
|
||||
|
||||
// Get the list URLs to download from
|
||||
String urls = ConfigurationManager.getProperty("solr-statistics", "spiderips.urls");
|
||||
if ((urls == null) || ("".equals(urls)))
|
||||
String[] urls = DSpaceServicesFactory.getInstance().getConfigurationService().getArrayProperty("solr-statistics.spiderips.urls");
|
||||
if((urls == null) || (urls.length==0))
|
||||
{
|
||||
System.err.println(" - Missing setting from dspace.cfg: solr.spiderips.urls");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// Get the location of spiders directory
|
||||
File spiders = new File(ConfigurationManager.getProperty("dspace.dir"),"config/spiders");
|
||||
File spiders = new File(DSpaceServicesFactory.getInstance().getConfigurationService().getProperty("dspace.dir"),"config/spiders");
|
||||
|
||||
if (!spiders.exists() && !spiders.mkdirs())
|
||||
{
|
||||
log.error("Unable to create spiders directory");
|
||||
}
|
||||
|
||||
String[] values = urls.split(",");
|
||||
for (String value : values)
|
||||
for (String value : urls)
|
||||
{
|
||||
value = value.trim();
|
||||
System.out.println(" Downloading: " + value);
|
||||
|
Reference in New Issue
Block a user