Revision 9473
Added by Jing Tao about 9 years ago
src/edu/ucsb/nceas/metacat/ReadOnlyChecker.java | ||
---|---|---|
1 |
/** |
|
2 |
* '$RCSfile$' |
|
3 |
* Copyright: 215 Regents of the University of California and the |
|
4 |
* National Center for Ecological Analysis and Synthesis |
|
5 |
* Authors: Jing Tao |
|
6 |
* |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or modify |
|
9 |
* it under the terms of the GNU General Public License as published by |
|
10 |
* the Free Software Foundation; either version 2 of the License, or |
|
11 |
* (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
*/ |
|
22 |
package edu.ucsb.nceas.metacat; |
|
23 |
|
|
24 |
import org.dataone.configuration.Settings; |
|
25 |
|
|
26 |
|
|
27 |
/** |
|
28 |
* A checker to determine if the Metacat is in the read-only mode by checking |
|
29 |
* the property of database.readOnly. |
|
30 |
* @author tao |
|
31 |
* |
|
32 |
*/ |
|
33 |
public class ReadOnlyChecker { |
|
34 |
|
|
35 |
|
|
36 |
/** |
|
37 |
* Default constructor |
|
38 |
*/ |
|
39 |
public ReadOnlyChecker() { |
|
40 |
|
|
41 |
} |
|
42 |
|
|
43 |
|
|
44 |
/** |
|
45 |
* Check if the mode is the read-only. |
|
46 |
* @return true if the value of "application.readOnlyMode" is not null and is equal, ignoring case, to the string true. |
|
47 |
*/ |
|
48 |
public boolean isReadOnly() { |
|
49 |
//we haven't checked, read |
|
50 |
String readOnlyStr =Settings.getConfiguration().getString("application.readOnlyMode"); |
|
51 |
boolean readOnly = Boolean.parseBoolean(readOnlyStr);//this method return true when readOnlyStr is "true". |
|
52 |
return readOnly; |
|
53 |
} |
|
54 |
|
|
55 |
} |
Also available in: Unified diff
Add a class to determine if the metacat is in the readonly mode.