/
Constants.java
227 lines (184 loc) · 6.93 KB
/
Constants.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/**
* 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;
/**
* Class with constants and matching strings, for DSpace types. These numbers
* must never be changed!!
*
* @author David Stuve
* @version $Revision$
*/
public class Constants
{
/** Type of bitstream objects */
public static final int BITSTREAM = 0;
/** Type of bundle objects */
public static final int BUNDLE = 1;
/** Type of item objects */
public static final int ITEM = 2;
/** Type of collection objects */
public static final int COLLECTION = 3;
/** Type of community objects */
public static final int COMMUNITY = 4;
/** DSpace site type */
public static final int SITE = 5;
/** Type of eperson groups */
public static final int GROUP = 6;
/** Type of individual eperson objects */
public static final int EPERSON = 7;
/**
* lets you look up type names from the type IDs
*/
public static final String[] typeText = { "BITSTREAM", "BUNDLE", "ITEM",
"COLLECTION", "COMMUNITY", "SITE", "GROUP", "EPERSON" };
/**
* Special Bundle and Bitstream Names:
*/
/** Magic name of item license, as bitstream in LICENSE_BUNDLE_NAME */
public static final String LICENSE_BITSTREAM_NAME = "license.txt";
/** Magic name of bundle containing item license */
public static final String LICENSE_BUNDLE_NAME = "LICENSE";
/**
* Default bundle name for the "original" item content;
* "derived" content such as thumbnails goes in other bundles.
*/
public static final String DEFAULT_BUNDLE_NAME = "ORIGINAL";
/**
* Name of bundle for user-visible "content" (same as default for now).
*/
public static final String CONTENT_BUNDLE_NAME = "ORIGINAL";
/** Bundle name for structured metadata bitstreams. */
public static final String METADATA_BUNDLE_NAME = "METADATA";
/** Action of reading, viewing or downloading something */
public static final int READ = 0;
/** Action of modifying something */
public static final int WRITE = 1;
/**
* Action of deleting something. Different from removing something from a
* container. (DELETE is now obsolete)
*
* @see #REMOVE
*/
public static final int DELETE = 2;
/**
* Action of adding something to a container. For example, to add an item to
* a collection, a user must have <code>ADD</code> permission on the
* collection.
*/
public static final int ADD = 3;
/**
* Action of removing something from a container. Different from deletion.
*
* @see #DELETE
*/
public static final int REMOVE = 4;
/** Action of performing workflow step 1 */
public static final int WORKFLOW_STEP_1 = 5;
/** Action of performing workflow step 2 */
public static final int WORKFLOW_STEP_2 = 6;
/** Action of performing workflow step 3 */
public static final int WORKFLOW_STEP_3 = 7;
/** Action of performing a workflow */
public static final int WORKFLOW_ABORT = 8;
/** Default Read policies for Bitstreams submitted to container */
public static final int DEFAULT_BITSTREAM_READ = 9;
/** Default Read policies for Items submitted to container */
public static final int DEFAULT_ITEM_READ = 10;
/**
* @deprecated As of DSpace 1.6, replaced by Constants.ADMIN
*/
public static final int COLLECTION_ADMIN = 11;
/**
* Administrative actions - System Admin, Community Admin, Collection Admin
*/
public static final int ADMIN = 11;
/** Position of front page news item -- top box */
public static final int NEWS_TOP = 0;
/** Position of front page news item -- sidebar */
public static final int NEWS_SIDE = 1;
/**
* lets you look up action names from the action IDs
*/
public static final String[] actionText = { "READ", "WRITE",
"OBSOLETE (DELETE)", "ADD", "REMOVE", "WORKFLOW_STEP_1",
"WORKFLOW_STEP_2", "WORKFLOW_STEP_3", "WORKFLOW_ABORT",
"DEFAULT_BITSTREAM_READ", "DEFAULT_ITEM_READ", "ADMIN" };
/**
* constants for the relevance array generating dynamicallis is simple: just
* 1 < < TYPE
*/
public static final int RBITSTREAM = 1 << BITSTREAM;
public static final int RBUNDLE = 1 << BUNDLE;
public static final int RITEM = 1 << ITEM;
public static final int RCOLLECTION = 1 << COLLECTION;
public static final int RCOMMUNITY = 1 << COMMUNITY;
/**
* Array of relevances of actions to objects - used by the UI to only
* display actions that are relevant to an object type To see if an action
* is relevant to an object, just OR the relevance type above with the value
* in actionTypeRelevance[] (To see if READ is relevant to community, just
* test actionTypeRelevance[READ] | RCOMMUNITY, 0 = irrelevant
*/
public static final int[] actionTypeRelevance = {
RBITSTREAM | RBUNDLE | RITEM | RCOLLECTION | RCOMMUNITY, // 0 - READ
RBITSTREAM | RBUNDLE | RITEM | RCOLLECTION | RCOMMUNITY, // 1 -
// WRITE
0, // 2 - DELETE (obsolete)
RBUNDLE | RITEM | RCOLLECTION | RCOMMUNITY, // 3 - ADD
RBUNDLE | RITEM | RCOLLECTION | RCOMMUNITY, // 4 - REMOVE
0, // 5 - WORKFLOW_STEP_1
0, // 6 - WORKFLOW_STEP_2
0, // 7 - WORKFLOW_STEP_3
0, // 8 - WORKFLOW_ABORT
RCOLLECTION, // 9 - DEFAULT_BITSTREAM_READ
RCOLLECTION, // 10 - DEFAULT_ITEM_READ
RITEM | RCOLLECTION | RCOMMUNITY // 11 - ADMIN
};
public static final String DEFAULT_ENCODING = "UTF-8";
/**
* If you know the type string, look up the corresponding type ID constant.
*
* @param type
* String with the name of the type (must be exact match)
*
* @return the corresponding type ID, or <code>-1</code> if the type
* string is unknown
*/
public static int getTypeID(String type)
{
for (int i = 0; i < typeText.length; i++)
{
if (typeText[i].equals(type))
{
return i;
}
}
return -1;
}
/**
* If you know the action string, look up the corresponding type ID
* constant.
*
* @param action
* String with the name of the action (must be exact match)
*
* @return the corresponding action ID, or <code>-1</code> if the action
* string is unknown
*/
public static int getActionID(String action)
{
for (int i = 0; i < actionText.length; i++)
{
if (actionText[i].equals(action))
{
return i;
}
}
return -1;
}
}