001/*
002 * #%L
003 * Netarchivesuite - common
004 * %%
005 * Copyright (C) 2005 - 2018 The Royal Danish Library, 
006 *             the National Library of France and the Austrian National Library.
007 * %%
008 * This program is free software: you can redistribute it and/or modify
009 * it under the terms of the GNU Lesser General Public License as
010 * published by the Free Software Foundation, either version 2.1 of the
011 * License, or (at your option) any later version.
012 * 
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Lesser Public License for more details.
017 * 
018 * You should have received a copy of the GNU General Lesser Public
019 * License along with this program.  If not, see
020 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
021 * #L%
022 */
023package dk.netarkivet.common;
024
025import dk.netarkivet.common.utils.Settings;
026
027/**
028 * Settings common to the entire NetarchiveSuite.
029 */
030public class CommonSettings {
031    /** The default place in classpath where the settings file can be found. */
032    private static final String DEFAULT_SETTINGS_CLASSPATH = "dk/netarkivet/common/settings.xml";
033
034    /*
035     * The static initialiser is called when the class is loaded. It will add default values for all settings defined in
036     * this class, by loading them from a settings.xml file in classpath.
037     */
038    static {
039        Settings.addDefaultClasspathSettings(DEFAULT_SETTINGS_CLASSPATH);
040    }
041
042    // NOTE: The constants defining setting names below are left non-final on
043    // purpose! Otherwise, the static initialiser that loads default values
044    // will not run.
045
046    /** The path in the XML-tree for the settings branch. (Used by deploy). */
047    public static String SETTINGS = "settings";
048
049    /**
050     * <b>settings.common.environmentName</b>: <br>
051     * The name of the environment in which this code is running. E.g. PROD, RELEASETEST. It is used as a Common prefix
052     * to all JMS channels created in a NetarchiveSuite installation.
053     */
054    public static String ENVIRONMENT_NAME = "settings.common.environmentName";
055
056    /**
057     * <b>settings.common.tempDir</b>: <br>
058     * Common temporary directory for all applications. Some subdirs of this directory must be set to have AllPermision
059     * in the conf/security.conf file, or the web pages won't work.
060     */
061    public static String DIR_COMMONTEMPDIR = "settings.common.tempDir";
062
063    /**
064     * <b>settings.common.remoteFile.class</b>: <br>
065     * The class to use for RemoteFile objects (for transferring files around). This class must implement the
066     * dk.netarkivet.common.distribute.RemoteFile interface.
067     */
068    public static String REMOTE_FILE_CLASS = "settings.common.remoteFile.class";
069
070    /**
071     * <b>settings.common.jms.class</b>: <br>
072     * Selects the broker class to be used. Must be subclass of dk.netarkivet.common.distribute.JMSConnection.
073     */
074    public static String JMS_BROKER_CLASS = "settings.common.jms.class";
075
076    /**
077     * <b>settings.common.jms.retries</b>: <br>
078     * Selects the number of times the JMS connection tries to reconnect to the broker.
079     */
080    public static String JMS_BROKER_RETRIES = "settings.common.jms.retries";
081
082    /**
083     * <b>settings.common.http.port</b>: <br>
084     * The *unique* (per host) port number that may or may not be used to serve http.
085     */
086    public static String HTTP_PORT_NUMBER = "settings.common.http.port";
087
088    /**
089     * <b>settings.common.arcrepositoryClient.class</b>: <br>
090     * The class that implements the ArcRepositoryClient. The class must implement the interface
091     * dk.netarkivet.common.distribute.arcrepository.ArcRepositoryClient This class will be instantiated by the
092     * ArcRepositoryClientFactory.
093     */
094    public static String ARC_REPOSITORY_CLIENT = "settings.common.arcrepositoryClient.class";
095
096    /**
097     * <b>settings.common.batch.maxExceptions</b>: <br>
098     * The maximum number of exceptions to be stored for a batch job.
099     */
100    public static String MAX_NUM_BATCH_EXCEPTIONS = "settings.common.batch.maxExceptions";
101
102    /**
103     * <b>settings.common.batch.loggingInterval</b>: <br/>
104     * The time between logging the status of a batch job.
105     */
106    public static String BATCH_LOGGING_INTERVAL = "settings.common.batch.loggingInterval";
107
108    /**
109     * <b>settings.common.batch.defaultBatchTimeout</b>: <br/>
110     * The default timeout for batchjobs. This will be used for batchjobs which has the batchJobTimeout set to -1
111     * (inherited value from FileBatchJob).
112     */
113    public static String BATCH_DEFAULT_TIMEOUT = "settings.common.batch.defaultBatchTimeout";
114
115    /**
116     * <b>settings.common.monitorregistryClient.class</b>: <br>
117     * Which class to use for monitor registry. Must implement the interface
118     * dk.netarkivet.common.distribute.monitorregistry.MonitorRegistryClient.
119     */
120    public static String MONITOR_REGISTRY_CLIENT = "settings.common.monitorregistryClient.class";
121
122    /**
123     * <b>settings.common.monitorregistryClient.reregisterdelay</b>: <br>
124     * Delay between every reregistering in minutes, e.g. 1 for one minute.
125     */
126    public static String MONITOR_REGISTRY_CLIENT_REREGISTERDELAY = "settings.common.monitorregistryClient.reregisterdelay";
127
128    /**
129     * <b>settings.common.indexClient.class</b>: <br>
130     * The class instantiated to give access to indices. The class must implement the interface
131     * dk.netarkivet.common.distribute.indexserver.JobIndexCache The class instantiations are manufactored by
132     * IndexClientFactory.
133     */
134    public static String INDEXSERVER_CLIENT = "settings.common.indexClient.class";
135
136    /**
137     * <b>settings.common.unixSort.useCommonTempDir</b>: <br>
138     * When using the Unix sort command, by default it stores temporary files in the system temp dir, but if this
139     * setting is set to true, then it will be configured to use the common temp dir defined by common.settings.tempDir.
140     * By default the value is false (use system temp), which is the legacy behavior. This setting is part of the fix
141     * for Jira issue NAS-1995.
142     *
143     * @see #DIR_COMMONTEMPDIR
144     */
145    public static String UNIX_SORT_USE_COMMON_TEMP_DIR = "settings.common.unixSort.useCommonTempDir";
146
147    /**
148     * <b>settings.common.cacheDir</b>: <br>
149     * The name of the directory where cache data global to the entire machine can be stored. Various kinds of caches
150     * should be stored in subdirectories of this.
151     */
152    public static String CACHE_DIR = "settings.common.cacheDir";
153
154    // TODO Currently only used by heritrix shutdown - move to harvester
155    // settings?
156    /**
157     * <b>settings.common.processTimeout</b>: <br>
158     * The number of milliseconds we wait for processes to react to shutdown requests.
159     */
160    public static String PROCESS_TIMEOUT = "settings.common.processTimeout";
161
162    /**
163     * <b>settings.common.notifications.class</b>: <br>
164     * The implementation class for notifications, e.g. error notification. The class must extend
165     * dk.netarkivet.common.utils.Notifications
166     */
167    public static String NOTIFICATIONS_CLASS = "settings.common.notifications.class";
168
169    /**
170     * <b>settings.common.mail.server</b>: <br>
171     * The mail server to use when sending mails.
172     */
173    public static String MAIL_SERVER = "settings.common.mail.server";
174
175    /**
176     * <b>settings.common.jmx.port</b>: <br>
177     * The port to use for JMX.
178     */
179    public static String JMX_PORT = "settings.common.jmx.port";
180
181    /**
182     * <b>settings.common.jmx.rmiPort</b>: <br>
183     * The JMX's RMI port to use for internal communication with beans.
184     */
185    public static String JMX_RMI_PORT = "settings.common.jmx.rmiPort";
186
187    /**
188     * <b>settings.common.jmx.passwordFile</b>: <br>
189     * The password file, containing information about who may connect to the beans. The file has a format defined by
190     * the JMX standard,
191     *
192     * @see <URL:http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html#PasswordAccessFiles>
193     */
194    public static String JMX_PASSWORD_FILE = "settings.common.jmx.passwordFile";
195
196    /**
197     * <b>settings.common.jmx.accessFile</b>: <br>
198     * The access file, containing information about who have which JMX roles have which access privileges. The file has
199     * a format defined by the JMX standard,
200     *
201     * @see <URL:http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html#PasswordAccessFiles>
202     */
203    public static String JMX_ACCESS_FILE = "settings.common.jmx.accessFile";
204
205    /**
206     * <b>settings.common.jmx.timeout</b>: <br>
207     * How many seconds we will wait before giving up on a JMX connection.
208     */
209    public static String JMX_TIMEOUT = "settings.common.jmx.timeout";
210
211    /**
212     * <b>settings.common.webinterface</b>: <br>
213     * The entire webinterface setting structure.
214     */
215    public static String WEBINTERFACE_SETTINGS = "settings.common.webinterface";
216
217    /**
218     * <b>settings.common.webinterface.hideInactiveTemplates</b>;<br/>
219     * Boolean valued String. If true, inactive harvest templates are entirely hidden in the GUI - it will be impossible
220     * to see them or change their state to "active". If false, the GUI will include functionality to change the
221     * status of template from inactive to active and vice-versa.
222     */
223    public static String HIDE_INACTIVE_TEMPLATES = "settings.common.webinterface.hideInactiveTemplates";
224
225    /**
226     * settings.common.webinterface.<b>language</b>: <br>
227     * The entire language setting structure under the webinterface setting. Is repeated for each language
228     */
229    public static String WEBINTERFACE_LANGUAGE = "language";
230
231    /**
232     * settings.common.webinterface.language.<b>locale</b>: <br>
233     * The locale the GUI is available as under specific language setting.
234     */
235    public static String WEBINTERFACE_LANGUAGE_LOCALE = "locale";
236
237    /**
238     * settings.common.webinterface.language.<b>name</b>: <br>
239     * The native name of the language for the locale under specific language setting.
240     */
241    public static String WEBINTERFACE_LANGUAGE_NAME = "name";
242
243    /**
244     * <b>settings.common.webinterface.siteSection.class</b>: <br>
245     * The subclass of SiteSection that defines a part of the web interface. Is part of repeated siteSection settings
246     * for each part.
247     */
248    public static String SITESECTION_CLASS = "settings.common.webinterface.siteSection.class";
249
250    /**
251     * <b>settings.common.webinterface.siteSection.webapplication</b>: <br>
252     * The directory or war-file containing the web application for a site section. Is part of repeated siteSection
253     * settings for each part.
254     */
255    public static String SITESECTION_WEBAPPLICATION = "settings.common.webinterface.siteSection.webapplication";
256
257    /**
258     * <b>settings.common.webinterface.harvestStatus.defaultPageSize</b>: <br>
259     * The default number of jobs to show in the harvest status section, on one result page.
260     */
261    public static String HARVEST_STATUS_DFT_PAGE_SIZE = "settings.common.webinterface.harvestStatus.defaultPageSize";
262    
263    /**
264     * <b>settings.common.topLevelDomains.tld</b>: <br>
265     * Extra valid top level domain, like .co.uk, .dk, .org., not part of current embedded public_suffix_list.dat file 
266     * in common/common-core/src/main/resources/dk/netarkivet/common/utils/public_suffix_list.dat
267     * downloaded from https://www.publicsuffix.org/list/public_suffix_list.dat
268     */
269    public static String TLDS = "settings.common.topLevelDomains.tld";
270    
271    /**
272     * <b>settings.common.topLevelDomains.silentlyIgnoreStarredTlds</b>: <br>
273     * If set to true, silently ignores starred TLDS and excluded tlds which are currently not supported by NetarchiveSuite (NAS-2689).
274     * default: true
275     */
276    public static String TLD_SILENTLY_IGNORE_STARRED_TLDS = "settings.common.topLevelDomains.silentlyIgnoreStarredTlds";
277        
278    // TODO move database settings to harvester settings?
279    /**
280     * <b>settings.common.database.class</b>: <br>
281     * The class that defines DB-specific methods. This class must extend the DBSpecifics class
282     */
283    public static String DB_SPECIFICS_CLASS = "settings.common.database.class";
284
285    /**
286     * If DB_SPECIFICS_CLASS contains this string then a Derby database is in use.
287     */
288    public static String DB_IS_DERBY_IF_CONTAINS = "Derby";
289
290    /**
291     * <b>settings.common.database.baseUrl</b>: <br>
292     * The URL to use to connect to the database specified in the DB_SPECIFICS_CLASS setting.
293     */
294    public static String DB_BASE_URL = "settings.common.database.baseUrl";
295
296    /**
297     * <b>settings.common.database.machine</b>: <br>
298     * Used for the external harvest definition database. The machine where the harvest definition database is located.
299     */
300    public static String DB_MACHINE = "settings.common.database.machine";
301
302    /**
303     * <b>settings.common.database.port</b>: <br>
304     * Used for the external harvest definition database. The port where the external harvest definition database is
305     * attached.
306     */
307    public static String DB_PORT = "settings.common.database.port";
308
309    /**
310     * <b>settings.common.database.dir</b>: <br>
311     * Used for the external harvest definition database. The directory where the external harvest definition database
312     * is located.
313     */
314    public static String DB_DIR = "settings.common.database.dir";
315
316    /**
317     * <b>settings.common.database.validityCheckTimeout</b>: <br>
318     * Timeout in seconds to check for the validity of a JDBC connection on the server. This is the time in seconds to
319     * wait for the database operation used to validate the connection to complete. If the timeout period expires before
320     * the operation completes, this method returns false. A value of 0 indicates a timeout is not applied to the
321     * database operation.
322     * <p>
323     * {@link java.sql.Connection#isValid(int)}
324     */
325    public static String DB_CONN_VALID_CHECK_TIMEOUT = "settings.common.database.validityCheckTimeout";
326
327    /**
328     * <b>settings.common.database.pool.minSize</b>: <br>
329     * Configure the minimum size of the DB connection pool. Default value is 5.
330     */
331    public static String DB_POOL_MIN_SIZE = "settings.common.database.pool.minSize";
332
333    /**
334     * <b>settings.common.database.pool.maxSize</b>: <br>
335     * Configure the maximum size of the DB connection pool. Default value is 10.
336     */
337    public static String DB_POOL_MAX_SIZE = "settings.common.database.pool.maxSize";
338
339    /**
340     * <b>settings.common.database.pool.acquireInc</b>: <br>
341     * Configure the increment size DB connection pool. Default value is 5 (half the max size).
342     */
343    public static String DB_POOL_ACQ_INC = "settings.common.database.pool.acquireInc";
344
345    /**
346     * <b>settings.common.database.pool.maxStm</b>: <br>
347     * Configure statement pooling, by setting the global maximum number of pooled prepared statements for a data
348     * source. Default value is 0. Note that if both {@link #DB_POOL_MAX_STM} and {@link #DB_POOL_MAX_STM_PER_CONN} are
349     * set to zero, statement pooling is fully deactivated.
350     *
351     * @see <a href="http://www.mchange.com/projects/c3p0/index.html">c3p0 documentation</a>
352     */
353    public static String DB_POOL_MAX_STM = "settings.common.database.pool.maxStm";
354
355    /**
356     * <b>settings.common.database.pool.maxStmPerConn</b>: <br>
357     * Configure statement pooling, by setting the global maximum number of pooled prepared statements for a data
358     * source. Default value is 0. Note that if both {@link #DB_POOL_MAX_STM} and {@link #DB_POOL_MAX_STM_PER_CONN} are
359     * set to zero, statement pooling is fully deactivated.
360     *
361     * @see <a href="http://www.mchange.com/projects/c3p0/index.html">c3p0 documentation</a>
362     */
363    public static String DB_POOL_MAX_STM_PER_CONN = "settings.common.database.pool.maxStmPerConn";
364
365    /**
366     * <b>settings.common.database.pool.idleConnTestPeriod</b>: <br>
367     * Configure idle connection testing period in seconds. Default is 0, which means no idle connection testing
368     *
369     * @see <a href="http://www.mchange.com/projects/c3p0/index.html#idleConnectionTestPeriod"/>
370     */
371    public static String DB_POOL_IDLE_CONN_TEST_PERIOD = "settings.common.database.pool.idleConnTestPeriod";
372
373    /**
374     * <b>settings.common.database.pool.idleConnTestOnCheckin</b>: <br>
375     * Configure if a connection validity should be checked when returned to the pool. Default is false.
376     *
377     * @see <a href="http://www.mchange.com/projects/c3p0/index.html#testConnectionOnCheckin"/>
378     */
379    public static String DB_POOL_IDLE_CONN_TEST_ON_CHECKIN = "settings.common.database.pool.idleConnTestOnCheckin";
380
381    /**
382     * <b>settings.common.database.pool.idleConnTestQuery</b>: <br>
383     * The SQL query to be used when testing an idle connection. Default is empty, which means using c3p0 defaults.
384     *
385     * @see <a href="http://www.mchange.com/projects/c3p0/index.html#preferredTestQuery"/>
386     */
387    public static String DB_POOL_IDLE_CONN_TEST_QUERY = "settings.common.database.pool.idleConnTestQuery";
388
389    /**
390     * <b>settings.common.database.pool.maxConnectionAge</b>: <br>
391     * The maxConnectionAge in seconds for each connection in the pool.
392     * The default is one hour (3600 seconds)
393     *
394     * @see <a href="http://www.mchange.com/projects/c3p0/index.html#maxConnectionAge"/>
395     */
396    public static String DB_POOL_MAX_CONNECTION_AGE = "settings.common.database.pool.maxConnectionAge";
397    
398    /**
399     * The username for login to the harvest database.
400     */
401    public static String DB_USERNAME = "settings.common.database.username";
402
403    /**
404     * The password for login to the harvest database.
405     */
406    public static String DB_PASSWORD = "settings.common.database.password";
407
408    /**
409     * <b>settings.common.repository.limitForRecordDatatransferInFile</b>: <br>
410     * When the length record exceeds this number, the contents of the record will be transferred using a RemoteFile.
411     */
412    public static String BITARCHIVE_LIMIT_FOR_RECORD_DATATRANSFER_IN_FILE = "settings.common.repository.limitForRecordDatatransferInFile";
413
414    /**
415     * <b>settings.common.replicas</b>: <br>
416     * The entire settings for all replicas in the environment. NOTE: settings for checksum replicas are not use yet
417     */
418    public static String REPLICAS_SETTINGS = "settings.common.replicas";
419
420    /**
421     * settings.common.replicas.<b>replica</b>: <br>
422     * The path to settings belonging to an individual replica, placed under the replicas setting.
423     */
424    public static String REPLICA_TAG = "replica";
425
426    /**
427     * settings.common.replicas.replica.<b>replicaId</b>: <br>
428     * The tags for identifier of the replica, placed under the replica tag. The replica id is used internally in e.g.
429     * naming of channels.
430     */
431    public static String REPLICAID_TAG = "replicaId";
432    /**
433     * settings.common.replicas.replica.<b>replicaName</b>: <br>
434     * The tags for name of the replica, placed under the replica tag. The replica name is used in interfaces like the
435     * GUI or command-line batch-programs. The name can be the same value as the id.
436     */
437    public static String REPLICANAME_TAG = "replicaName";
438    /**
439     * settings.common.replicas.replica.<b>replicaType</b>: <br>
440     * The tags for type of the replica, placed under the replica tag. The type is used to identify whether it is a
441     * bitarchive or a checksum replica. NOTE: checksum replicas are not implemented yet Possible values are defined in
442     * ReplicaType
443     */
444    public static String REPLICATYPE_TAG = "replicaType";
445
446    /**
447     * <b>settings.common.replicas.replica.replicaId</b>: <br>
448     * The identifiers of all replicas in the environment.
449     */
450    public static String REPLICA_IDS = REPLICAS_SETTINGS + "." + REPLICA_TAG + "." + REPLICAID_TAG;
451
452    /**
453     * <b>settings.common.useReplicaId</b>: <br>
454     * Default bitarchive to use for e.g. batch jobs (if none is specified).
455     */
456    public static String USE_REPLICA_ID = "settings.common.useReplicaId";
457
458    /**
459     * <b>settings.common.thisPhysicalLocation</b>: <br>
460     * Physical location of where the application is running. Only use for System state GUI and deploy
461     */
462    public static String THIS_PHYSICAL_LOCATION = "settings.common.thisPhysicalLocation";
463
464    /**
465     * <b>settings.common.applicationName</b>: <br>
466     * The name of the application, e.g. "BitarchiveServerApplication". The monitor puts this with each log message.
467     */
468    public static String APPLICATION_NAME = "settings.common.applicationName";
469
470    /**
471     * <b>settings.common.applicationInstanceId</b>: <br>
472     * The identifier of the instance of the application. This is used when there are more than one of the same
473     * application running on the same machine, e.g. when more harvesters are running on the same machine or more
474     * bitarchive applications are running on the same machine.
475     */
476    public static String APPLICATION_INSTANCE_ID = "settings.common.applicationInstanceId";
477
478    /**
479     * <b>settings.common.freespaceprovider.class</b>: <br>
480     * The implementation class for free space provider, e.g. dk.netarkivet.common.utils.DefaultFreeSpaceProvider. The
481     * class must implement FreeSpaceProvider-Interface.
482     */
483    public static String FREESPACE_PROVIDER_CLASS = "settings.common.freespaceprovider.class";
484
485    /**
486     * <b>settings.common.batch.batchjobs.batchjob.class</b>: <br/>
487     * The list of batchjobs to be runnable from the GUI. Must be the complete path to the batchjob classes (e.g.
488     * dk.netarkivet.archive.arcrepository.bitpreservation.ChecksumJob). Must inherit FileBatchJob.
489     */
490    public static String BATCHJOBS_CLASS = "settings.common.batch.batchjobs.batchjob.class";
491
492    /**
493     * <b>settings.common.batch.batchjobs.batchjob.jarfile</b>: <br/>
494     * The list of the corresponding jar-files containing the batchjob. This will be used for LoadableJarBatchJobs. If
495     * no file is specified, it is assumed, that the batchjob exists with the default classpath of the involved
496     * applications (BitarchiveMonitor, ArcRepository, GUIWebServer and BitArchive).
497     */
498    public static String BATCHJOBS_JARFILE = "settings.common.batch.batchjobs.batchjob.jarfile";
499
500    /**
501     * <b>settings.common.batch.baseDir</b>: <br/>
502     * The directory where the resulting files will be placed when running a batchjob through the GUI interface.
503     */
504    public static String BATCHJOBS_BASEDIR = "settings.common.batch.baseDir";
505    /**
506     * <b>settings.common.remoteFile.serverName</b>: <br>
507     * The setting for the FTP-server used.
508     */
509    public static String FTP_SERVER_NAME = "settings.common.remoteFile.serverName";
510    /**
511     * <b>settings.common.remoteFile.serverPort</b>: <br>
512     * The setting for the FTP-server port used.
513     */
514    public static String FTP_SERVER_PORT = "settings.common.remoteFile.serverPort";
515    /**
516     * <b>settings.common.remoteFile.userName</b>: <br>
517     * The setting for the FTP username.
518     */
519    public static String FTP_USER_NAME = "settings.common.remoteFile.userName";
520    /**
521     * <b>settings.common.remoteFile.userPassword</b>: <br>
522     * The setting for the FTP password. *
523     */
524    public static String FTP_USER_PASSWORD = "settings.common.remoteFile.userPassword";
525    /**
526     * <b>settings.common.remoteFile.retries</b>: <br>
527     * The setting for the number of times FTPRemoteFile should try before giving up a copyTo operation or logOn
528     * operation.
529     */
530    public static String FTP_RETRIES_SETTINGS = "settings.common.remoteFile.retries";
531    /**
532     * <b>settings.common.remoteFile.datatimeout</b>: <br>
533     * The setting for the FTP data timeout in seconds. The default value is 600 (10 minutes).
534     */
535    public static String FTP_DATATIMEOUT_SETTINGS = "settings.common.remoteFile.datatimeout";
536
537    /**
538     * <b>settings.common.organization</b>: <br>
539     * The name of the organization responsible. The default value is netarkivet.dk
540     */
541    public static String ORGANIZATION = "settings.common.organization";
542
543    /**
544     * Specifies the suffix of a regex which can identify valid metadata files by job number. Thus preceding
545     * the value of this setting with .* will find all metadata files.
546     */
547    public static String METADATAFILE_REGEX_SUFFIX = "settings.common.metadata.fileregexsuffix";
548    
549}