KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > file > CmsResource


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/file/CmsResource.java,v $
3  * Date : $Date: 2006/03/28 12:14:36 $
4  * Version: $Revision: 1.45 $
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.file;
33
34 import org.opencms.main.CmsIllegalArgumentException;
35 import org.opencms.util.CmsStringUtil;
36 import org.opencms.util.CmsUUID;
37
38 import java.io.Serializable JavaDoc;
39 import java.util.Comparator JavaDoc;
40
41 /**
42  * Base class for all OpenCms VFS resources like <code>{@link CmsFile}</code> or <code>{@link CmsFolder}</code>.<p>
43  *
44  * @author Alexander Kandzior
45  * @author Michael Emmerich
46  * @author Thomas Weckert
47  *
48  * @version $Revision: 1.45 $
49  *
50  * @since 6.0.0
51  */

52 public class CmsResource extends Object JavaDoc implements Cloneable JavaDoc, Serializable JavaDoc, Comparable JavaDoc {
53
54     /**
55      * A comparator for the release date of 2 resources.<p>
56      *
57      * If the release date of a resource is not set, the
58      * creation date is used instead.<p>
59      */

60     public static final Comparator JavaDoc COMPARE_DATE_RELEASED = new Comparator JavaDoc() {
61
62         /**
63          * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
64          */

65         public int compare(Object JavaDoc o1, Object JavaDoc o2) {
66
67             if ((o1 == o2) || !(o1 instanceof CmsResource) || !(o2 instanceof CmsResource)) {
68                 return 0;
69             }
70
71             CmsResource r1 = (CmsResource)o1;
72             CmsResource r2 = (CmsResource)o2;
73
74             long date1 = r1.getDateReleased();
75             if (date1 == CmsResource.DATE_RELEASED_DEFAULT) {
76                 // use creation date if release date is not set
77
date1 = r1.getDateLastModified();
78             }
79
80             long date2 = r2.getDateReleased();
81             if (date2 == CmsResource.DATE_RELEASED_DEFAULT) {
82                 // use creation date if release date is not set
83
date2 = r2.getDateLastModified();
84             }
85
86             return (date1 > date2) ? -1 : (date1 < date2) ? 1 : 0;
87         }
88     };
89
90     /**
91      * A comparator for the root path of 2 resources.<p>
92      */

93     public static final Comparator JavaDoc COMPARE_ROOT_PATH = new Comparator JavaDoc() {
94
95         /**
96          * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
97          */

98         public int compare(Object JavaDoc o1, Object JavaDoc o2) {
99
100             if ((o1 == o2) || !(o1 instanceof CmsResource) || !(o2 instanceof CmsResource)) {
101                 return 0;
102             }
103
104             CmsResource r1 = (CmsResource)o1;
105             CmsResource r2 = (CmsResource)o2;
106
107             return r1.getRootPath().compareTo(r2.getRootPath());
108         }
109     };
110
111     /**
112      * A comparator for the root path of 2 resources ignoring case differences.<p>
113      */

114     public static final Comparator JavaDoc COMPARE_ROOT_PATH_IGNORE_CASE = new Comparator JavaDoc() {
115
116         /**
117          * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
118          */

119         public int compare(Object JavaDoc o1, Object JavaDoc o2) {
120
121             if ((o1 == o2) || !(o1 instanceof CmsResource) || !(o2 instanceof CmsResource)) {
122                 return 0;
123             }
124
125             CmsResource r1 = (CmsResource)o1;
126             CmsResource r2 = (CmsResource)o2;
127
128             return r1.getRootPath().compareToIgnoreCase(r2.getRootPath());
129         }
130     };
131
132     /**
133      * A comparator for the root path of 2 resources ignoring case differences, putting folders before files.<p>
134      */

135     public static final Comparator JavaDoc COMPARE_ROOT_PATH_IGNORE_CASE_FOLDERS_FIRST = new Comparator JavaDoc() {
136
137         /**
138          * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
139          */

140         public int compare(Object JavaDoc o1, Object JavaDoc o2) {
141
142             if ((o1 == o2) || !(o1 instanceof CmsResource) || !(o2 instanceof CmsResource)) {
143                 return 0;
144             }
145
146             CmsResource r1 = (CmsResource)o1;
147             CmsResource r2 = (CmsResource)o2;
148
149             if (r1.isFolder() && !r2.isFolder()) {
150                 return -1;
151             } else if (r2.isFolder() && !r1.isFolder()) {
152                 return 1;
153             }
154             // if same type, compare the name of the resource
155
return r1.getRootPath().compareToIgnoreCase(r2.getRootPath());
156         }
157     };
158
159     /** Copy mode for copy resources as new resource. */
160     public static final int COPY_AS_NEW = 1;
161
162     /** Copy mode for copy resources as sibling. */
163     public static final int COPY_AS_SIBLING = 2;
164
165     /** Copy mode to preserve siblings during copy. */
166     public static final int COPY_PRESERVE_SIBLING = 3;
167
168     /** The default expiration date of a resource (which is: never expires). */
169     public static final long DATE_EXPIRED_DEFAULT = Long.MAX_VALUE;
170
171     /** The default release date of a resource (which is: always released). */
172     public static final long DATE_RELEASED_DEFAULT = 0;
173
174     /** Signals that siblings of this resource should not be deleted. */
175     public static final int DELETE_PRESERVE_SIBLINGS = 0;
176
177     /** Signals that siblings of this resource should be deleted. */
178     public static final int DELETE_REMOVE_SIBLINGS = 1;
179
180     /** Flag to indicate that this is an internal resource, that can't be accessed directly. */
181     public static final int FLAG_INTERNAL = 512;
182
183     /** The resource is linked inside a site folder specified in the OpenCms configuration. */
184     public static final int FLAG_LABELED = 2;
185
186     /** Flag to indicate that this is a temporary resource. */
187     public static final int FLAG_TEMPFILE = 1024;
188
189     /** The name constraints when generating new resources. */
190     public static final String JavaDoc NAME_CONSTRAINTS = "-._~$";
191
192     /** Indicates if a resource has been changed in the offline version when compared to the online version. */
193     public static final int STATE_CHANGED = 1;
194
195     /** Indicates if a resource has been deleted in the offline version when compared to the online version. */
196     public static final int STATE_DELETED = 3;
197
198     /**
199      * Special state value that indicates the current state must be kept on a resource,
200      * this value must never be written to the database.
201      */

202     public static final int STATE_KEEP = 99;
203
204     /** Indicates if a resource is new in the offline version when compared to the online version. */
205     public static final int STATE_NEW = 2;
206
207     /** Indicates if a resource is unchanged in the offline version when compared to the online version. */
208     public static final int STATE_UNCHANGED = 0;
209
210     /** Flag for leaving a date unchanged during a touch operation. */
211     public static final long TOUCH_DATE_UNCHANGED = -1;
212
213     /** The vfs path of the channel folder. */
214     public static final String JavaDoc VFS_FOLDER_CHANNELS = "/channels";
215
216     /** The vfs path of the sites master folder. */
217     public static final String JavaDoc VFS_FOLDER_SITES = "/sites";
218
219     /** The vfs path of the system folder. */
220     public static final String JavaDoc VFS_FOLDER_SYSTEM = "/system";
221
222     /** Serial version UID required for safe serialization. */
223     private static final long serialVersionUID = 257325098790850498L;
224
225     /** The size of the content. */
226     protected int m_length;
227
228     /** The creation date of this resource. */
229     private long m_dateCreated;
230
231     /** The expiration date of this resource. */
232     private long m_dateExpired;
233
234     /** The date of the last modification of this resource. */
235     private long m_dateLastModified;
236
237     /** The release date of this resource. */
238     private long m_dateReleased;
239
240     /** The flags of this resource. */
241     private int m_flags;
242
243     /** Indicates if this resource is a folder or not. */
244     private boolean m_isFolder;
245
246     /** Boolean flag whether the timestamp of this resource was modified by a touch command. */
247     private boolean m_isTouched;
248
249     /** The project id where this resource has been last modified in. */
250     private int m_projectLastModified;
251
252     /** The id of the resource database record. */
253     private CmsUUID m_resourceId;
254
255     /** The name of a resource with it's full path from the root folder including the current site root. */
256     private String JavaDoc m_rootPath;
257
258     /** The number of links that point to this resource. */
259     private int m_siblingCount;
260
261     /** The state of this resource. */
262     private int m_state;
263
264     /** The id of the structure database record. */
265     private CmsUUID m_structureId;
266
267     /** The resource type id of this resource. */
268     private int m_typeId;
269
270     /** The id of the user who created this resource. */
271     private CmsUUID m_userCreated;
272
273     /** The id of the user who modified this resource last. */
274     private CmsUUID m_userLastModified;
275
276     /**
277      * Constructor, creates a new CmsRecource object.<p>
278      *
279      * @param structureId the id of this resources structure record
280      * @param resourceId the id of this resources resource record
281      * @param rootPath the root path to the resource
282      * @param type the type of this resource
283      * @param isFolder must be true if thr resource is a folder, or false if it is a file
284      * @param flags the flags of this resource
285      * @param projectId the project id this resource was last modified in
286      * @param state the state of this resource
287      * @param dateCreated the creation date of this resource
288      * @param userCreated the id of the user who created this resource
289      * @param dateLastModified the date of the last modification of this resource
290      * @param userLastModified the id of the user who did the last modification of this resource
291      * @param dateReleased the release date of this resource
292      * @param dateExpired the expiration date of this resource
293      * @param linkCount the count of all siblings of this resource
294      * @param size the size of the file content of this resource
295      */

296     public CmsResource(
297         CmsUUID structureId,
298         CmsUUID resourceId,
299         String JavaDoc rootPath,
300         int type,
301         boolean isFolder,
302         int flags,
303         int projectId,
304         int state,
305         long dateCreated,
306         CmsUUID userCreated,
307         long dateLastModified,
308         CmsUUID userLastModified,
309         long dateReleased,
310         long dateExpired,
311         int linkCount,
312         int size) {
313
314         m_structureId = structureId;
315         m_resourceId = resourceId;
316         m_rootPath = rootPath;
317         m_typeId = type;
318         m_isFolder = isFolder;
319         m_flags = flags;
320         m_projectLastModified = projectId;
321         m_state = state;
322         m_dateCreated = dateCreated;
323         m_userCreated = userCreated;
324         m_dateLastModified = dateLastModified;
325         m_userLastModified = userLastModified;
326         m_length = size;
327         m_siblingCount = linkCount;
328         m_dateReleased = dateReleased;
329         m_dateExpired = dateExpired;
330         m_isTouched = false;
331     }
332
333     /**
334      * Checks if the provided resource name is a valid resource name,
335      * that is contains only valid characters.<p>
336      *
337      * A resource name can only be composed of digits,
338      * standard ASCII letters and the symbols defined in {@link #NAME_CONSTRAINTS}.
339      * A resource name must also not contain only dots.<p>
340      *
341      * @param name the resource name to check
342      *
343      * @throws CmsIllegalArgumentException if the given resource name is not valid
344      */

345     public static void checkResourceName(String JavaDoc name) throws CmsIllegalArgumentException {
346
347         if (CmsStringUtil.isEmptyOrWhitespaceOnly(name)) {
348             throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_BAD_RESOURCENAME_EMPTY_0, name));
349         }
350
351         CmsStringUtil.checkName(name, NAME_CONSTRAINTS, Messages.ERR_BAD_RESOURCENAME_4, Messages.get());
352
353         // check for filenames that have only dots (which will cause issues in the static export)
354
boolean onlydots = true;
355         // this must be done only for the last name (not for parent folders)
356
String JavaDoc lastName = CmsResource.getName(name);
357         int l = lastName.length();
358         for (int i = 0; i < l; i++) {
359             char c = lastName.charAt(i);
360             if ((c != '.') && (c != '/')) {
361                 onlydots = false;
362             }
363         }
364         if (onlydots) {
365             throw new CmsIllegalArgumentException(Messages.get().container(
366                 Messages.ERR_BAD_RESOURCENAME_DOTS_1,
367                 lastName));
368         }
369     }
370
371     /**
372      * Returns the folder path of the resource with the given name,
373      * if the resource is a folder (i.e. ends with a "/"), the complete path of the folder
374      * is returned (not the parent folder path).<p>
375      *
376      * This is achived by just cutting of everthing behind the last occurence of a "/" character
377      * in the String, no check if performed if the resource exists or not in the VFS,
378      * only resources that end with a "/" are considered to be folders.
379      *
380      * Example: Returns <code>/system/def/</code> for the
381      * resource <code>/system/def/file.html</code> and
382      * <code>/system/def/</code> for the (folder) resource <code>/system/def/</code>.
383      *
384      * @param resource the name of a resource
385      * @return the folder of the given resource
386      */

387     public static String JavaDoc getFolderPath(String JavaDoc resource) {
388
389         return resource.substring(0, resource.lastIndexOf('/') + 1);
390     }
391
392     /**
393      * Returns the name of a resource without the path information.<p>
394      *
395      * The resource name of a file is the name of the file.
396      * The resource name of a folder is the folder name with trailing "/".
397      * The resource name of the root folder is <code>/</code>.<p>
398      *
399      * Example: <code>/system/workplace/</code> has the resource name <code>workplace/</code>.
400      *
401      * @param resource the resource to get the name for
402      * @return the name of a resource without the path information
403      */

404     public static String JavaDoc getName(String JavaDoc resource) {
405
406         if ("/".equals(resource)) {
407             return "/";
408         }
409         // remove the last char, for a folder this will be "/", for a file it does not matter
410
String JavaDoc parent = (resource.substring(0, resource.length() - 1));
411         // now as the name does not end with "/", check for the last "/" which is the parent folder name
412
return resource.substring(parent.lastIndexOf('/') + 1);
413     }
414
415     /**
416      * Returns the absolute parent folder name of a resource.<p>
417      *
418      * The parent resource of a file is the folder of the file.
419      * The parent resource of a folder is the parent folder.
420      * The parent resource of the root folder is <code>null</code>.<p>
421      *
422      * Example: <code>/system/workplace/</code> has the parent <code>/system/</code>.
423      *
424      * @param resource the resource to find the parent folder for
425      * @return the calculated parent absolute folder path, or <code>null</code> for the root folder
426      */

427     public static String JavaDoc getParentFolder(String JavaDoc resource) {
428
429         if ("/".equals(resource)) {
430             return null;
431         }
432         // remove the last char, for a folder this will be "/", for a file it does not matter
433
String JavaDoc parent = (resource.substring(0, resource.length() - 1));
434         // now as the name does not end with "/", check for the last "/" which is the parent folder name
435
return parent.substring(0, parent.lastIndexOf('/') + 1);
436     }
437
438     /**
439      * Returns the directory level of a resource.<p>
440      *
441      * The root folder "/" has level 0,
442      * a folder "/foo/" would have level 1,
443      * a folfer "/foo/bar/" level 2 etc.<p>
444      *
445      * @param resource the resource to determin the directory level for
446      * @return the directory level of a resource
447      */

448     public static int getPathLevel(String JavaDoc resource) {
449
450         int level = -1;
451         int pos = 0;
452         while (resource.indexOf('/', pos) >= 0) {
453             pos = resource.indexOf('/', pos) + 1;
454             level++;
455         }
456         return level;
457     }
458
459     /**
460      * Returns the name of a parent folder of the given resource,
461      * that is either minus levels up
462      * from the current folder, or that is plus levels down from the
463      * root folder.<p>
464      *
465      * @param resource the name of a resource
466      * @param level of levels to walk up or down
467      * @return the name of a parent folder of the given resource
468      */

469     public static String JavaDoc getPathPart(String JavaDoc resource, int level) {
470
471         resource = getFolderPath(resource);
472         String JavaDoc result = null;
473         int pos = 0, count = 0;
474         if (level >= 0) {
475             // Walk down from the root folder /
476
while ((count < level) && (pos > -1)) {
477                 count++;
478                 pos = resource.indexOf('/', pos + 1);
479             }
480         } else {
481             // Walk up from the current folder
482
pos = resource.length();
483             while ((count > level) && (pos > -1)) {
484                 count--;
485                 pos = resource.lastIndexOf('/', pos - 1);
486             }
487         }
488         if (pos > -1) {
489             // To many levels walked
490
result = resource.substring(0, pos + 1);
491         } else {
492             // Add trailing slash
493
result = (level < 0) ? "/" : resource;
494         }
495         return result;
496     }
497
498     /**
499      * Returns true if the resource name is a folder name, i.e. ends with a "/".<p>
500      *
501      * @param resource the resource to check
502      * @return true if the resource name is a folder name, i.e. ends with a "/"
503      */

504     public static boolean isFolder(String JavaDoc resource) {
505
506         return CmsStringUtil.isNotEmpty(resource) && (resource.charAt(resource.length() - 1) == '/');
507     }
508
509     /**
510      * Returns a clone of this Objects instance.<p>
511      *
512      * @return a clone of this instance
513      */

514     public Object JavaDoc clone() {
515
516         CmsResource clone = new CmsResource(
517             m_structureId,
518             m_resourceId,
519             m_rootPath,
520             m_typeId,
521             m_isFolder,
522             m_flags,
523             m_projectLastModified,
524             m_state,
525             m_dateCreated,
526             m_userCreated,
527             m_dateLastModified,
528             m_userLastModified,
529             m_dateReleased,
530             m_dateExpired,
531             m_siblingCount,
532             m_length);
533
534         if (isTouched()) {
535             clone.setDateLastModified(m_dateLastModified);
536         }
537
538         return clone;
539     }
540
541     /**
542      * @see java.lang.Comparable#compareTo(java.lang.Object)
543      */

544     public int compareTo(Object JavaDoc obj) {
545
546         if (obj == this) {
547             return 0;
548         }
549         if (obj instanceof CmsResource) {
550             return m_rootPath.compareTo(((CmsResource)obj).m_rootPath);
551         }
552         return 0;
553     }
554
555     /**
556      * @see java.lang.Object#equals(java.lang.Object)
557      */

558     public boolean equals(Object JavaDoc obj) {
559
560         if (obj == this) {
561             return true;
562         }
563         if (obj instanceof CmsResource) {
564             return ((CmsResource)obj).m_structureId.equals(m_structureId);
565         }
566         return false;
567     }
568
569     /**
570      * Returns the date of the creation of this resource.<p>
571      *
572      * @return the date of the creation of this resource
573      */

574     public long getDateCreated() {
575
576         return m_dateCreated;
577     }
578
579     /**
580      * Returns the expiration date this resource.<p>
581      *
582      * @return the expiration date of this resource
583      */

584     public long getDateExpired() {
585
586         return m_dateExpired;
587     }
588
589     /**
590      * Returns the date of the last modification of this resource.<p>
591      *
592      * @return the date of the last modification of this resource
593      */

594     public long getDateLastModified() {
595
596         return m_dateLastModified;
597     }
598
599     /**
600      * Returns the release date this resource.<p>
601      *
602      * @return the release date of this resource
603      */

604     public long getDateReleased() {
605
606         return m_dateReleased;
607     }
608
609     /**
610      * Returns the flags of this resource.<p>
611      *
612      * @return the flags of this resource
613      */

614     public int getFlags() {
615
616         return m_flags;
617     }
618
619     /**
620      * Returns the length of the resource.<p>
621      *
622      * If the resource is a file, then this is the byte size of the file content.
623      * If the resource is a folder, then the size is always -1.<p>
624      *
625      * @return the length of the content
626      */

627     public int getLength() {
628
629         // make sure folders always have a -1 size
630
return m_isFolder ? -1 : m_length;
631     }
632
633     /**
634      * Returns the name of this resource, e.g. <code>index.html</code>.<p>
635      *
636      * @return the name of this resource
637      */

638     public String JavaDoc getName() {
639
640         String JavaDoc name = getName(m_rootPath);
641         if (name.charAt(name.length() - 1) == '/') {
642             return name.substring(0, name.length() - 1);
643         } else {
644             return name;
645         }
646     }
647
648     /**
649      * Returns the id of the project where the resource has been last modified.<p>
650      *
651      * @return the id of the project where the resource has been last modified
652      */

653     public int getProjectLastModified() {
654
655         return m_projectLastModified;
656     }
657
658     /**
659      * Returns the id of the resource database entry of this resource.<p>
660      *
661      * @return the id of the resource database entry
662      */

663     public CmsUUID getResourceId() {
664
665         return m_resourceId;
666     }
667
668     /**
669      * Returns the name of a resource with it's full path from the root folder
670      * including the current site root,
671      * for example <code>/sites/default/myfolder/index.html</code>.<p>
672      *
673      * In a presentation level application usually the current site root must be
674      * cut of from the root path. Use {@link CmsObject#getSitePath(CmsResource)}
675      * to get the "absolute" path of a resource in the current site.<p>
676      *
677      * @return the name of a resource with it's full path from the root folder
678      * including the current site root
679      *
680      * @see CmsObject#getSitePath(CmsResource)
681      * @see CmsRequestContext#getSitePath(CmsResource)
682      * @see CmsRequestContext#removeSiteRoot(String)
683      */

684     public String JavaDoc getRootPath() {
685
686         return m_rootPath;
687     }
688
689     /**
690      * Returns the number of siblings of the resource, also counting this resource.<p>
691      *
692      * If a resource has no sibling, the total sibling count for this resource is <code>1</code>,
693      * if a resource has <code>n</code> siblings, the sibling count is <code>n + 1</code>.<p>
694      *
695      * @return the number of siblings
696      */

697     public int getSiblingCount() {
698
699         return m_siblingCount;
700     }
701
702     /**
703      * Returns the state of this resource.<p>
704      *
705      * This may be STATE_UNCHANGED, STATE_CHANGED, STATE_NEW or STATE_DELETED.<p>
706      *
707      * @return the state of this resource
708      */

709     public int getState() {
710
711         return m_state;
712     }
713
714     /**
715      * Returns the id of the structure record of this resource.<p>
716      *
717      * @return the id of the structure record of this resource
718      */

719     public CmsUUID getStructureId() {
720
721         return m_structureId;
722     }
723
724     /**
725      * Returns the resource type id for this resource.<p>
726      *
727      * @return the resource type id of this resource
728      */

729     public int getTypeId() {
730
731         return m_typeId;
732     }
733
734     /**
735      * Returns the user id of the user who created this resource.<p>
736      *
737      * @return the user id
738      */

739     public CmsUUID getUserCreated() {
740
741         return m_userCreated;
742     }
743
744     /**
745      * Returns the user id of the user who made the last change on this resource.<p>
746      *
747      * @return the user id of the user who made the last change<p>
748      */

749     public CmsUUID getUserLastModified() {
750
751         return m_userLastModified;
752     }
753
754     /**
755      * @see java.lang.Object#hashCode()
756      */

757     public int hashCode() {
758
759         if (m_structureId != null) {
760             return m_structureId.hashCode();
761         }
762
763         return CmsUUID.getNullUUID().hashCode();
764     }
765
766     /**
767      * Returns <code>true</code> if the resource is a file, i.e. can have no sub-resources.<p>
768      *
769      * @return true if this resource is a file, false otherwise
770      */

771     public boolean isFile() {
772
773         return !m_isFolder;
774     }
775
776     /**
777      * Returns <code>true</code> if the resource is a folder, i.e. can have sub-resources.<p>
778      *
779      * @return true if this resource is a folder, false otherwise
780      */

781     public boolean isFolder() {
782
783         return m_isFolder;
784     }
785
786     /**
787      * Checks if the resource is internal.<p>
788      *
789      * This state is stored as bit 1 in the resource flags.<p>
790      *
791      * @return true if the resource is internal, otherwise false
792      */

793     public boolean isInternal() {
794
795         return ((m_flags & FLAG_INTERNAL) > 0);
796     }
797
798     /**
799      * Checks if the link has to be labeled with a special icon in the explorer view.<p>
800      *
801      * This state is stored as bit 2 in the resource flags.<p>
802      *
803      * @return true if a link to the resource has to be labeled, otherwise false
804      */

805     public boolean isLabeled() {
806
807         return ((m_flags & CmsResource.FLAG_LABELED) > 0);
808     }
809
810     /**
811      * Returns true if this resource was touched.<p>
812      *
813      * @return boolean true if this resource was touched
814      */

815     public boolean isTouched() {
816
817         return m_isTouched;
818     }
819
820     /**
821      * Sets the expiration date this resource.<p>
822      *
823      * @param time the date to set
824      */

825     public void setDateExpired(long time) {
826
827         m_dateExpired = time;
828     }
829
830     /**
831      * Sets the date of the last modification of this resource.<p>
832      *
833      * @param time the date to set
834      */

835     public void setDateLastModified(long time) {
836
837         m_isTouched = true;
838         m_dateLastModified = time;
839     }
840
841     /**
842      * Sets the release date this resource.<p>
843      *
844      * @param time the date to set
845      */

846     public void setDateReleased(long time) {
847
848         m_dateReleased = time;
849     }
850
851     /**
852      * Sets the flags of this resource.<p>
853      *
854      * @param flags int value with flag values to set
855      */

856     public void setFlags(int flags) {
857
858         m_flags = flags;
859     }
860
861     /**
862      * Sets the state of this resource.<p>
863      *
864      * @param state the state to set
865      */

866     public void setState(int state) {
867
868         m_state = state;
869     }
870
871     /**
872      * Sets the type of this resource.<p>
873      *
874      * @param type the type to set
875      */

876     public void setType(int type) {
877
878         m_typeId = type;
879     }
880
881     /**
882      * Sets the user id of the user who changed this resource.<p>
883      *
884      * @param resourceLastModifiedByUserId the user id of the user who changed the resource
885      */

886     public void setUserLastModified(CmsUUID resourceLastModifiedByUserId) {
887
888         m_userLastModified = resourceLastModifiedByUserId;
889     }
890
891     /**
892      * @see java.lang.Object#toString()
893      */

894     public String JavaDoc toString() {
895
896         StringBuffer JavaDoc result = new StringBuffer JavaDoc();
897
898         result.append("[");
899         result.append(this.getClass().getName());
900         result.append(", path: ");
901         result.append(m_rootPath);
902         result.append(", structure id ");
903         result.append(m_structureId);
904         result.append(", resource id: ");
905         result.append(m_resourceId);
906         result.append(", type id: ");
907         result.append(m_typeId);
908         result.append(", folder: ");
909         result.append(m_isFolder);
910         result.append(", flags: ");
911         result.append(m_flags);
912         result.append(", project: ");
913         result.append(m_projectLastModified);
914         result.append(", state: ");
915         result.append(m_state);
916         result.append(", date created: ");
917         result.append(new java.util.Date JavaDoc(m_dateCreated));
918         result.append(", user created: ");
919         result.append(m_userCreated);
920         result.append(", date lastmodified: ");
921         result.append(new java.util.Date JavaDoc(m_dateLastModified));
922         result.append(", user lastmodified: ");
923         result.append(m_userLastModified);
924         result.append(", date released: ");
925         result.append(new java.util.Date JavaDoc(m_dateReleased));
926         result.append(", date expired: ");
927         result.append(new java.util.Date JavaDoc(m_dateExpired));
928         result.append(", size: ");
929         result.append(m_length);
930         result.append(" sibling count: ");
931         result.append(m_siblingCount);
932         result.append("]");
933
934         return result.toString();
935     }
936
937 }
Popular Tags