KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dspace > core > Constants


1 /*
2  * Constants.java
3  *
4  * Version: $Revision: 1.17 $
5  *
6  * Date: $Date: 2006/02/13 10:33:49 $
7  *
8  * Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
9  * Institute of Technology. All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are
13  * met:
14  *
15  * - Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  *
18  * - Redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution.
21  *
22  * - Neither the name of the Hewlett-Packard Company nor the name of the
23  * Massachusetts Institute of Technology nor the names of their
24  * contributors may be used to endorse or promote products derived from
25  * this software without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
34  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
38  * DAMAGE.
39  */

40 package org.dspace.core;
41
42 /**
43  * Class with constants and matching strings, for DSpace types. These numbers
44  * must never be changed!!
45  *
46  * @author David Stuve
47  * @version $Revision: 1.17 $
48  */

49 public class Constants
50 {
51     /** Type of bitstream objects */
52     public static final int BITSTREAM = 0;
53
54     /** Type of bundle objects */
55     public static final int BUNDLE = 1;
56
57     /** Type of item objects */
58     public static final int ITEM = 2;
59
60     /** Type of collection objects */
61     public static final int COLLECTION = 3;
62
63     /** Type of community objects */
64     public static final int COMMUNITY = 4;
65
66     /** DSpace site type */
67     public static final int SITE = 5;
68
69     /** Type of eperson groups */
70     public static final int GROUP = 6;
71
72     /** Type of individual eperson objects */
73     public static final int EPERSON = 7;
74
75     /**
76      * lets you look up type names from the type IDs
77      */

78     public static final String JavaDoc[] typeText = { "BITSTREAM", "BUNDLE", "ITEM",
79             "COLLECTION", "COMMUNITY", "SITE", "GROUP", "EPERSON", };
80
81     /**
82      * Special Bundle and Bitstream Names:
83      */

84
85     /** Magic name of item license, as bitstream in LICENSE_BUNDLE_NAME */
86     public static final String JavaDoc LICENSE_BITSTREAM_NAME = "license.txt";
87
88     /** Magic name of bundle containing item license */
89     public static final String JavaDoc LICENSE_BUNDLE_NAME = "LICENSE";
90
91     /**
92      * Default bundle name for the "original" item content;
93      * "derived" content such as thumbnails goes in other bundles.
94      */

95     public static final String JavaDoc DEFAULT_BUNDLE_NAME = "ORIGINAL";
96
97     /**
98      * Name of bundle for user-visible "content" (same as default for now).
99      */

100     public static final String JavaDoc CONTENT_BUNDLE_NAME = "ORIGINAL";
101
102     /** Bundle name for structured metadata bitstreams. */
103     public static final String JavaDoc METADATA_BUNDLE_NAME = "METADATA";
104
105
106     /** Action of reading, viewing or downloading something */
107     public static final int READ = 0;
108
109     /** Action of modifying something */
110     public static final int WRITE = 1;
111
112     /**
113      * Action of deleting something. Different from removing something from a
114      * container. (DELETE is now obsolete)
115      *
116      * @see #REMOVE
117      */

118     public static final int DELETE = 2;
119
120     /**
121      * Action of adding something to a container. For example, to add an item to
122      * a collection, a user must have <code>ADD</code> permission on the
123      * collection.
124      */

125     public static final int ADD = 3;
126
127     /**
128      * Action of removing something from a container. Different from deletion.
129      *
130      * @see #DELETE
131      */

132     public static final int REMOVE = 4;
133
134     /** Action of performing workflow step 1 */
135     public static final int WORKFLOW_STEP_1 = 5;
136
137     /** Action of performing workflow step 2 */
138     public static final int WORKFLOW_STEP_2 = 6;
139
140     /** Action of performing workflow step 3 */
141     public static final int WORKFLOW_STEP_3 = 7;
142
143     /** Action of performing a workflow */
144     public static final int WORKFLOW_ABORT = 8;
145
146     /** Default Read policies for Bitstreams submitted to container */
147     public static final int DEFAULT_BITSTREAM_READ = 9;
148
149     /** Default Read policies for Items submitted to container */
150     public static final int DEFAULT_ITEM_READ = 10;
151
152     /**
153      * collection admin -- metadata, logo, item metadata, submitters, withdraw
154      * items, etc.
155      */

156     public static final int COLLECTION_ADMIN = 11;
157
158     /** Position of front page news item -- top box */
159     public static final int NEWS_TOP = 0;
160
161     /** Position of front page news item -- sidebar */
162     public static final int NEWS_SIDE = 1;
163
164     /**
165      * lets you look up action names from the action IDs
166      */

167     public static final String JavaDoc[] actionText = { "READ", "WRITE",
168             "OBSOLETE (DELETE)", "ADD", "REMOVE", "WORKFLOW_STEP_1",
169             "WORKFLOW_STEP_2", "WORKFLOW_STEP_3", "WORKFLOW_ABORT",
170             "DEFAULT_BITSTREAM_READ", "DEFAULT_ITEM_READ", "COLLECTION_ADMIN" };
171
172     /**
173      * constants for the relevance array generating dynamicallis is simple: just
174      * 1 < < TYPE
175      */

176     public static final int RBITSTREAM = 1 << BITSTREAM;
177
178     public static final int RBUNDLE = 1 << BUNDLE;
179
180     public static final int RITEM = 1 << ITEM;
181
182     public static final int RCOLLECTION = 1 << COLLECTION;
183
184     public static final int RCOMMUNITY = 1 << COMMUNITY;
185
186     /**
187      * Array of relevances of actions to objects - used by the UI to only
188      * display actions that are relevant to an object type To see if an action
189      * is relevant to an object, just OR the relevance type above with the value
190      * in actionTypeRelevance[] (To see if READ is relevant to community, just
191      * test actionTypeRelevance[READ] | RCOMMUNITY, 0 = irrelevant
192      */

193     public static final int[] actionTypeRelevance = {
194             RBITSTREAM | RBUNDLE | RITEM | RCOLLECTION | RCOMMUNITY, // 0 - READ
195
RBITSTREAM | RBUNDLE | RITEM | RCOLLECTION | RCOMMUNITY, // 1 -
196
// WRITE
197
0, // 2 - DELETE (obsolete)
198
RBUNDLE | RITEM | RCOLLECTION | RCOMMUNITY, // 3 - ADD
199
RBUNDLE | RITEM | RCOLLECTION | RCOMMUNITY, // 4 - REMOVE
200
0, // 5 - WORKFLOW_STEP_1
201
0, // 6 - WORKFLOW_STEP_2
202
0, // 7 - WORKFLOW_STEP_3
203
0, // 8 - WORKFLOW_ABORT
204
RCOLLECTION, // 9 - DEFAULT_BITSTREAM_READ
205
RCOLLECTION, // 10 - DEFAULT_ITEM_READ
206
RCOLLECTION // 11 - COLLECTION_ADMIN
207
};
208
209     public static final String JavaDoc DEFAULT_ENCODING = "UTF-8";
210
211     /**
212      * If you know the type string, look up the corresponding type ID constant.
213      *
214      * @param type
215      * String with the name of the type (must be exact match)
216      *
217      * @return the corresponding type ID, or <code>-1</code> if the type
218      * string is unknown
219      */

220     public static int getTypeID(String JavaDoc type)
221     {
222         for (int i = 0; i < typeText.length; i++)
223         {
224             if (typeText[i].equals(type))
225             {
226                 return i;
227             }
228         }
229
230         return -1;
231     }
232
233     /**
234      * If you know the action string, look up the corresponding type ID
235      * constant.
236      *
237      * @param action
238      * String with the name of the action (must be exact match)
239      *
240      * @return the corresponding action ID, or <code>-1</code> if the action
241      * string is unknown
242      */

243     public static int getActionID(String JavaDoc action)
244     {
245         for (int i = 0; i < actionText.length; i++)
246         {
247             if (actionText[i].equals(action))
248             {
249                 return i;
250             }
251         }
252
253         return -1;
254     }
255 }
256
Popular Tags