001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.file;
029
030import org.opencms.db.CmsResourceState;
031import org.opencms.file.types.I_CmsResourceType;
032import org.opencms.util.CmsUUID;
033
034/**
035 * This class allows the developer to build a CmsResource object by filling out individual fields one after the
036 * other.
037 */
038public class CmsResourceBuilder {
039
040    /** The date of the last modification of the content of this resource. */
041    protected long m_dateContent = System.currentTimeMillis();
042
043    /** The size of the content. */
044    protected int m_length;
045
046    /** The creation date of this resource. */
047    private long m_dateCreated;
048
049    /** The expiration date of this resource. */
050    private long m_dateExpired;
051
052    /** The date of the last modification of this resource. */
053    private long m_dateLastModified;
054
055    /** The release date of this resource. */
056    private long m_dateReleased;
057
058    /** The flags of this resource. */
059    private int m_flags;
060
061    /** Indicates if this resource is a folder or not. */
062    private boolean m_isFolder;
063
064    /** Boolean flag whether the timestamp of this resource was modified by a touch command. */
065    private boolean m_isTouched;
066
067    /** The project id where this resource has been last modified in. */
068    private CmsUUID m_projectLastModified;
069
070    /** The id of the resource database record. */
071    private CmsUUID m_resourceId;
072
073    /** The name of a resource with it's full path from the root folder including the current site root. */
074    private String m_rootPath;
075
076    /** The number of links that point to this resource. */
077    private int m_siblingCount;
078
079    /** The state of this resource. */
080    private CmsResourceState m_state;
081
082    /** The id of the structure database record. */
083    private CmsUUID m_structureId;
084
085    /** The m type. */
086    private I_CmsResourceType m_type;
087
088    /** The id of the user who created this resource. */
089    private CmsUUID m_userCreated;
090
091    /** The id of the user who modified this resource last. */
092    private CmsUUID m_userLastModified;
093
094    /** The version number of this resource. */
095    private int m_version;
096
097    /**
098     * Builds the resource.
099     *
100     * @return the cms resource
101     */
102    public CmsResource buildResource() {
103
104        return new CmsResource(
105            m_structureId,
106            m_resourceId,
107            m_rootPath,
108            m_type,
109            m_flags,
110            m_projectLastModified,
111            m_state,
112            m_dateCreated,
113            m_userCreated,
114            m_dateLastModified,
115            m_userLastModified,
116            m_dateReleased,
117            m_dateExpired,
118            m_length,
119            m_flags,
120            m_dateContent,
121            m_version);
122    }
123
124    /**
125     * Gets the date content.
126     *
127     * @return the date content
128     */
129    public long getDateContent() {
130
131        return m_dateContent;
132    }
133
134    /**
135     * Gets the date created.
136     *
137     * @return the date created
138     */
139    public long getDateCreated() {
140
141        return m_dateCreated;
142    }
143
144    /**
145     * Gets the date expired.
146     *
147     * @return the date expired
148     */
149    public long getDateExpired() {
150
151        return m_dateExpired;
152    }
153
154    /**
155     * Gets the date last modified.
156     *
157     * @return the date last modified
158     */
159    public long getDateLastModified() {
160
161        return m_dateLastModified;
162    }
163
164    /**
165     * Gets the date released.
166     *
167     * @return the date released
168     */
169    public long getDateReleased() {
170
171        return m_dateReleased;
172    }
173
174    /**
175     * Gets the flags.
176     *
177     * @return the flags
178     */
179    public int getFlags() {
180
181        return m_flags;
182    }
183
184    /**
185     * Gets the length.
186     *
187     * @return the length
188     */
189    public int getLength() {
190
191        return m_length;
192    }
193
194    /**
195     * Gets the project last modified.
196     *
197     * @return the project last modified
198     */
199    public CmsUUID getProjectLastModified() {
200
201        return m_projectLastModified;
202    }
203
204    /**
205     * Gets the resource id.
206     *
207     * @return the resource id
208     */
209    public CmsUUID getResourceId() {
210
211        return m_resourceId;
212    }
213
214    /**
215     * Gets the root path.
216     *
217     * @return the root path
218     */
219    public String getRootPath() {
220
221        return m_rootPath;
222    }
223
224    /**
225     * Gets the sibling count.
226     *
227     * @return the sibling count
228     */
229    public int getSiblingCount() {
230
231        return m_siblingCount;
232    }
233
234    /**
235     * Gets the state.
236     *
237     * @return the state
238     */
239    public CmsResourceState getState() {
240
241        return m_state;
242    }
243
244    /**
245     * Gets the structure id.
246     *
247     * @return the structure id
248     */
249    public CmsUUID getStructureId() {
250
251        return m_structureId;
252    }
253
254    /**
255     * Gets the type.
256     *
257     * @return the type
258     */
259    public I_CmsResourceType getType() {
260
261        return m_type;
262    }
263
264    /**
265     * Gets the user created.
266     *
267     * @return the user created
268     */
269    public CmsUUID getUserCreated() {
270
271        return m_userCreated;
272    }
273
274    /**
275     * Gets the user last modified.
276     *
277     * @return the user last modified
278     */
279    public CmsUUID getUserLastModified() {
280
281        return m_userLastModified;
282    }
283
284    /**
285     * Gets the version.
286     *
287     * @return the version
288     */
289    public int getVersion() {
290
291        return m_version;
292    }
293
294    /**
295     * Checks if is folder.
296     *
297     * @return true, if is folder
298     */
299    public boolean isFolder() {
300
301        return m_isFolder;
302    }
303
304    /**
305     * Checks if is touched.
306     *
307     * @return true, if is touched
308     */
309    public boolean isTouched() {
310
311        return m_isTouched;
312    }
313
314    /**
315     * Sets the date content.
316     *
317     * @param dateContent the new date content
318     */
319    public void setDateContent(long dateContent) {
320
321        m_dateContent = dateContent;
322    }
323
324    /**
325     * Sets the date created.
326     *
327     * @param dateCreated the new date created
328     */
329    public void setDateCreated(long dateCreated) {
330
331        m_dateCreated = dateCreated;
332    }
333
334    /**
335     * Sets the date expired.
336     *
337     * @param dateExpired the new date expired
338     */
339    public void setDateExpired(long dateExpired) {
340
341        m_dateExpired = dateExpired;
342    }
343
344    /**
345     * Sets the date last modified.
346     *
347     * @param dateLastModified the new date last modified
348     */
349    public void setDateLastModified(long dateLastModified) {
350
351        m_dateLastModified = dateLastModified;
352    }
353
354    /**
355     * Sets the date released.
356     *
357     * @param dateReleased the new date released
358     */
359    public void setDateReleased(long dateReleased) {
360
361        m_dateReleased = dateReleased;
362    }
363
364    /**
365     * Sets the flags.
366     *
367     * @param flags the new flags
368     */
369    public void setFlags(int flags) {
370
371        m_flags = flags;
372    }
373
374    /**
375     * Sets the folder.
376     *
377     * @param isFolder the new folder
378     */
379    public void setFolder(boolean isFolder) {
380
381        m_isFolder = isFolder;
382    }
383
384    /**
385     * Sets the length.
386     *
387     * @param length the new length
388     */
389    public void setLength(int length) {
390
391        m_length = length;
392    }
393
394    /**
395     * Sets the project last modified.
396     *
397     * @param projectLastModified the new project last modified
398     */
399    public void setProjectLastModified(CmsUUID projectLastModified) {
400
401        m_projectLastModified = projectLastModified;
402    }
403
404    /**
405     * Sets the resource id.
406     *
407     * @param resourceId the new resource id
408     */
409    public void setResourceId(CmsUUID resourceId) {
410
411        m_resourceId = resourceId;
412    }
413
414    /**
415     * Sets the root path.
416     *
417     * @param rootPath the new root path
418     */
419    public void setRootPath(String rootPath) {
420
421        m_rootPath = rootPath;
422    }
423
424    /**
425     * Sets the sibling count.
426     *
427     * @param siblingCount the new sibling count
428     */
429    public void setSiblingCount(int siblingCount) {
430
431        m_siblingCount = siblingCount;
432    }
433
434    /**
435     * Sets the state.
436     *
437     * @param state the new state
438     */
439    public void setState(CmsResourceState state) {
440
441        m_state = state;
442    }
443
444    /**
445     * Sets the structure id.
446     *
447     * @param structureId the new structure id
448     */
449    public void setStructureId(CmsUUID structureId) {
450
451        m_structureId = structureId;
452    }
453
454    /**
455     * Sets the touched.
456     *
457     * @param isTouched the new touched
458     */
459    public void setTouched(boolean isTouched) {
460
461        m_isTouched = isTouched;
462    }
463
464    /**
465     * Sets the type.
466     *
467     * @param type the new type
468     */
469    public void setType(I_CmsResourceType type) {
470
471        m_type = type;
472    }
473
474    /**
475     * Sets the user created.
476     *
477     * @param userCreated the new user created
478     */
479    public void setUserCreated(CmsUUID userCreated) {
480
481        m_userCreated = userCreated;
482    }
483
484    /**
485     * Sets the user last modified.
486     *
487     * @param userLastModified the new user last modified
488     */
489    public void setUserLastModified(CmsUUID userLastModified) {
490
491        m_userLastModified = userLastModified;
492    }
493
494    /**
495     * Sets the version.
496     *
497     * @param version the new version
498     */
499    public void setVersion(int version) {
500
501        m_version = version;
502    }
503
504}