KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > test > OpenCmsTestResourceStorageEntry


1 /*
2  * File : $Source: /usr/local/cvs/opencms/test/org/opencms/test/OpenCmsTestResourceStorageEntry.java,v $
3  * Date : $Date: 2005/06/27 23:22:21 $
4  * Version: $Revision: 1.17 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31  
32 package org.opencms.test;
33
34 import org.opencms.file.CmsObject;
35 import org.opencms.file.CmsProperty;
36 import org.opencms.file.CmsResource;
37 import org.opencms.file.CmsResourceFilter;
38 import org.opencms.lock.CmsLock;
39 import org.opencms.main.CmsException;
40 import org.opencms.security.CmsAccessControlList;
41 import org.opencms.util.CmsUUID;
42
43 import java.util.ArrayList JavaDoc;
44 import java.util.Iterator JavaDoc;
45 import java.util.List JavaDoc;
46
47 /**
48  * A single entry of the OpenCmsTestResourceStorage.<p>
49  *
50  * @author Michael Emmerich
51  * @version $Revision: 1.17 $
52  */

53 public class OpenCmsTestResourceStorageEntry {
54
55     /** The size of the content. */
56     protected int m_length;
57     
58     /** The ccess control list entries. */
59     private List m_accessControlEntries;
60     
61     /** The access control list. */
62     private CmsAccessControlList m_accessControlList;
63     
64        /** The ID of the content database record. */
65     // private CmsUUID m_contentId;
66

67     /** The content of the resource. If the resource is a folder, the content is null. */
68     private byte[] m_contents;
69
70     /** The creation date of this resource. */
71     private long m_dateCreated;
72
73     /** The expiration date of this resource. */
74     private long m_dateExpired;
75
76     /** The date of the last modification of this resource. */
77     private long m_dateLastModified;
78
79     /** The release date of this resource. */
80     private long m_dateReleased;
81     
82     /** The flags of this resource ( not used yet; the Accessflags are stored in m_accessFlags). */
83     private int m_flags;
84
85     /** Boolean flag whether the timestamp of this resource was modified by a touch command. */
86     private boolean m_isTouched;
87
88     /** The id of the loader which is used to process this resource. */
89     private int m_loaderId;
90     
91     /** The lockstate of the resource. */
92     private CmsLock m_lockstate;
93     
94     /** The name of this resource. */
95     private String JavaDoc m_name;
96
97     /** The project id where this resource has been last modified in. */
98     private int m_projectLastModified;
99     
100     /** The properties of the resource. */
101     private List m_properties;
102
103     /** The ID of the resource database record. */
104     private CmsUUID m_resourceId;
105
106     /** The number of links that point to this resource. */
107     private int m_siblingCount;
108
109     /** The state of this resource. */
110     private int m_state;
111
112     /** The ID of the structure database record. */
113     private CmsUUID m_structureId;
114
115     /** The type of this resource. */
116     private int m_type;
117     
118     /** The id of the user who created this resource. */
119     private CmsUUID m_userCreated;
120     
121     /** The id of the user who modified this resource last. */
122     private CmsUUID m_userLastModified;
123     
124     /**
125      * Creates a new empty OpenCmsTestResourceStorageEntry.<p>
126      */

127     public OpenCmsTestResourceStorageEntry() {
128         // noop
129
}
130     
131     /**
132      * Creates a new OpenCmsTestResourceStorageEntry.<p>
133      *
134      * @param cms current CmsObject
135      * @param resourceName the complete name of the resource
136      * @param res the CmsResource to store.
137      * @throws CmsException if something goes wrong
138      */

139     public OpenCmsTestResourceStorageEntry(CmsObject cms, String JavaDoc resourceName, CmsResource res) throws CmsException {
140         // m_contentId = res.getContentId();
141
m_dateCreated = res.getDateCreated();
142         m_dateLastModified = res.getDateLastModified();
143         m_dateReleased = res.getDateReleased();
144         m_dateExpired = res.getDateExpired();
145         m_flags = res.getFlags();
146         m_isTouched = res.isTouched();
147         m_length = res.getLength();
148         m_siblingCount = res.getSiblingCount();
149         m_name = res.getName();
150         m_projectLastModified = res.getProjectLastModified();
151         m_resourceId = res.getResourceId();
152         m_state = res.getState();
153         m_structureId = res.getStructureId();
154         m_type = res.getTypeId();
155         m_userCreated = res.getUserCreated();
156         m_userLastModified = res.getUserLastModified();
157         m_lockstate = cms.getLock(res);
158         if (res.isFile()) {
159             m_contents = cms.readFile(resourceName, CmsResourceFilter.ALL).getContents();
160         } else {
161             m_contents = null;
162         }
163         
164         m_properties = new ArrayList JavaDoc();
165         List properties = cms.readPropertyObjects(resourceName, false);
166         Iterator JavaDoc i = properties.iterator();
167         while (i.hasNext()) {
168             CmsProperty prop = (CmsProperty)i.next();
169             m_properties.add(prop.clone());
170         }
171         
172         m_accessControlList = cms.getAccessControlList(resourceName);
173         m_accessControlEntries = cms.getAccessControlEntries(resourceName);
174     }
175     
176
177     /**
178      * Returns the access control entries of the resource.<p>
179      *
180      * @return the access control entries of the resource
181      */

182     public List getAccessControlEntries() {
183         return m_accessControlEntries;
184     }
185     
186     
187
188     /**
189      * Returns the access control list of the resource.<p>
190      *
191      * @return the access control list of the resource
192      */

193     public CmsAccessControlList getAccessControlList() {
194         return m_accessControlList;
195     }
196     
197     /**
198      * Returns the date of the creation of this resource.<p>
199      *
200      * @return the date of the creation of this resource
201      */

202     public byte[] getContents() {
203         return m_contents;
204     }
205     
206     
207     /**
208      * Returns the date of the creation of this resource.<p>
209      *
210      * @return the date of the creation of this resource
211      */

212     public long getDateCreated() {
213         return m_dateCreated;
214     }
215     
216     /**
217      * Returns the expiration date this resource.<p>
218      *
219      * @return the expiration date of this resource
220      */

221     public long getDateExpired() {
222         return m_dateExpired;
223     }
224     
225     /**
226      * Returns the date of the last modification of this resource.<p>
227      *
228      * @return the date of the last modification of this resource
229      */

230     public long getDateLastModified() {
231         return m_dateLastModified;
232     }
233     
234     /**
235      * Returns the release date this resource.<p>
236      *
237      * @return the release date of this resource
238      */

239     public long getDateReleased() {
240         return m_dateReleased;
241     }
242
243     /**
244      * Gets the id of the file content database entry.<p>
245      *
246      * @return the ID of the file content database entry
247      */

248     /* public CmsUUID getFileId() {
249         return m_contentId;
250     } */

251
252     /**
253      * Returns the flags of this resource.<p>
254      *
255      * @return the flags of this resource
256      */

257     public int getFlags() {
258         return m_flags;
259     }
260     
261     /**
262      * Gets the length of the content (i.e. the file size).<p>
263      *
264      * @return the length of the content
265      */

266     public int getLength() {
267         return m_length;
268     }
269     
270     /**
271      * Gets the loader id of this resource.<p>
272      *
273      * @return the loader type id of this resource
274      */

275     public int getLoaderId() {
276         return m_loaderId;
277     }
278     
279     /**
280      * Gets the lockstate of this resource.<p>
281      *
282      * @return the lockstate of this resource
283      */

284     public CmsLock getLock() {
285         return m_lockstate;
286     }
287
288
289     /**
290      * Returns the name of this resource, e.g. <code>index.html</code>.<p>
291      *
292      * @return the name of this resource
293      */

294     public String JavaDoc getName() {
295         return m_name;
296     }
297     
298     /**
299      * Returns the name of this resource including the full path in the current site,
300      * but without the current site root.<p>
301      *
302      * @return the name of this resource including the full path in the current site
303      */

304     public String JavaDoc getPath() {
305         // TODO: Must be implemented
306
return null;
307     }
308
309     /**
310      * Returns the id of the project where the resource has been last modified.<p>
311      *
312      * @return the id of the project where the resource has been last modified
313      */

314     public int getProjectLastModified() {
315         return m_projectLastModified;
316     }
317     
318
319     /**
320      * Returns the properties of the resource.<p>
321      *
322      * @return the properties of the resource
323      */

324     public List getProperties() {
325         return m_properties;
326     }
327     
328
329     /**
330      * Returns the id of the resource database entry of this resource.<p>
331      *
332      * @return the id of the resource database entry
333      */

334     public CmsUUID getResourceId() {
335         return m_resourceId;
336     }
337
338     /**
339      * Gets the number of references to the resource.<p>
340      *
341      * @return the number of links
342      */

343     public int getSiblingCount() {
344         return m_siblingCount;
345     }
346
347     
348     /**
349      * Returns the state of this resource.<p>
350      *
351      * This may be STATE_UNCHANGED, STATE_CHANGED, STATE_NEW or STATE_DELETED.<p>
352      *
353      * @return the state of this resource
354      */

355     public int getState() {
356         return m_state;
357     }
358
359     /**
360      * Returns the id of the structure record of this resource.<p>
361      *
362      * @return the id of the structure record of this resource
363      */

364     public CmsUUID getStructureId() {
365         return m_structureId;
366     }
367     
368     /**
369      * Returns the type id for this resource.<p>
370      *
371      * @return the type id of this resource.
372      */

373     public int getType() {
374         return m_type;
375     }
376
377     /**
378      * Returns the user id of the user who created this resource.<p>
379      *
380      * @return the user id
381      */

382     public CmsUUID getUserCreated() {
383         return m_userCreated;
384     }
385     
386     /**
387      * Returns the user id of the user who made the last change on this resource.<p>
388      *
389      * @return the user id of the user who made the last change<p>
390      */

391     public CmsUUID getUserLastModified() {
392         return m_userLastModified;
393     }
394     
395     /**
396      * Returns true if this resource was touched.<p>
397      *
398      * @return boolean true if this resource was touched
399      */

400     public boolean isTouched() {
401         return m_isTouched;
402     }
403
404     
405     
406 }
407
Popular Tags