KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/file/CmsBackupResource.java,v $
3  * Date : $Date: 2005/07/03 09:41:52 $
4  * Version: $Revision: 1.18 $
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.util.CmsUUID;
35
36 import java.io.Serializable JavaDoc;
37
38 /**
39  * A backup resource for the OpenCms VFS resource history.<p>
40  *
41  * Backup resources are basic resources that contain additional information
42  * used to describe the backup state.
43  * Backup resource extend CmsFile since the might contain binary content,
44  * but they can also in fact be backup resources for a folder.<p>
45  *
46  * Backup resources contain the names of the users that
47  * created or last modified the resource as a String because
48  * a user id might have been deleted.<p>
49  *
50  * @author Alexander Kandzior
51  *
52  * @version $Revision: 1.18 $
53  *
54  * @since 6.0.0
55  */

56 public class CmsBackupResource extends CmsFile implements Cloneable JavaDoc, Serializable JavaDoc, Comparable JavaDoc {
57
58     /** Serial version UID required for safe serialization. */
59     private static final long serialVersionUID = -6659773406054276891L;
60
61     /** The backup id of the resource. */
62     private CmsUUID m_backupId;
63
64     /**
65      * The name of the user who created the resource.
66      */

67     private String JavaDoc m_createdByName;
68
69     /** The name of the last user who modified the resource. */
70     private String JavaDoc m_lastModifiedByName;
71
72     /**
73      * The tag id of the version.
74      */

75     private int m_tagId;
76
77     /** The id of the backup version. */
78     private int m_versionId;
79
80     /**
81      * Constructor, creates a new CmsBackupResource object.
82      * @param backupId the backup id of this backup resource
83      * @param tagId the tag id of this backup resource
84      * @param versionId the version id of this backup resource
85      * @param structureId the id of this resources structure record
86      * @param resourceId the id of this resources resource record
87      * @param contentId the id of this resources content record
88      * @param path the filename of this resouce
89      * @param type the type of this resource
90      * @param flags the flags of this resource
91      * @param projectId the project id this resource was last modified in
92      * @param state the state of this resource
93      * @param dateCreated the creation date of this resource
94      * @param userCreated the id of the user who created this resource
95      * @param userCreatedName the name of the user who created this resource
96      * @param dateLastModified the date of the last modification of this resource
97      * @param userLastModified the id of the user who did the last modification of this resource
98      * @param userLastModifiedName the name of the user who did the last modification of this resource
99      * @param dateReleased the release date of this resource
100      * @param dateExpired the expiration date of this resource
101      * @param size the size of the file content of this resource
102      * @param content the binary content data of this file
103      */

104     public CmsBackupResource(
105         CmsUUID backupId,
106         int tagId,
107         int versionId,
108         CmsUUID structureId,
109         CmsUUID resourceId,
110         CmsUUID contentId,
111         String JavaDoc path,
112         int type,
113         int flags,
114         int projectId,
115         int state,
116         long dateCreated,
117         CmsUUID userCreated,
118         String JavaDoc userCreatedName,
119         long dateLastModified,
120         CmsUUID userLastModified,
121         String JavaDoc userLastModifiedName,
122         long dateReleased,
123         long dateExpired,
124         int size,
125         byte[] content) {
126
127         // create the backup CmsResource.
128
super(
129             structureId,
130             resourceId,
131             contentId,
132             path,
133             type,
134             flags,
135             projectId,
136             state,
137             dateCreated,
138             userCreated,
139             dateLastModified,
140             userLastModified,
141             dateReleased,
142             dateExpired,
143             0,
144             size,
145             content);
146
147         m_backupId = backupId;
148
149         // set tag id
150
m_tagId = tagId;
151
152         // set version id
153
m_versionId = versionId;
154
155         // set createdByName
156
m_createdByName = userCreatedName;
157
158         // set lastModifiedByName
159
m_lastModifiedByName = userLastModifiedName;
160     }
161
162     /**
163      * Returns a clone of this Objects instance.<p>
164      *
165      * @return a clone of this instance
166      */

167     public Object JavaDoc clone() {
168
169         byte[] newContent = new byte[this.getContents().length];
170         System.arraycopy(getContents(), 0, newContent, 0, getContents().length);
171
172         return new CmsBackupResource(
173             getBackupId(),
174             getTagId(),
175             getVersionId(),
176             getStructureId(),
177             getResourceId(),
178             getContentId(),
179             getRootPath(),
180             getTypeId(),
181             getFlags(),
182             getProjectLastModified(),
183             getState(),
184             getDateCreated(),
185             getUserCreated(),
186             getCreatedByName(),
187             getDateLastModified(),
188             getUserLastModified(),
189             getLastModifiedByName(),
190             getDateReleased(),
191             getDateExpired(),
192             getLength(),
193             newContent);
194     }
195
196     /**
197      * Returns the backup id of this resource.
198      *
199      * @return the backup id of this resource
200      */

201     public CmsUUID getBackupId() {
202
203         return m_backupId;
204     }
205
206     /**
207      * Returns the user name of the creator of this backup resource.<p>
208      *
209      * @return the user name of the creator of this backup resource
210      */

211     public String JavaDoc getCreatedByName() {
212
213         return m_createdByName;
214     }
215
216     /**
217      * Returns the name of the user who last changed this backup resource.<p>
218      *
219      * @return the name of the user who last changed this backup resource
220      */

221     public String JavaDoc getLastModifiedByName() {
222
223         return m_lastModifiedByName;
224     }
225
226     /**
227      * Returns the tag id of this resource.
228      *
229      * @return the tag id of this resource
230      */

231     public int getTagId() {
232
233         return m_tagId;
234     }
235
236     /**
237      * Returns the version id of this backup resource.
238      *
239      * @return the version id of this resource
240      */

241     public int getVersionId() {
242
243         return m_versionId;
244     }
245 }
246
Popular Tags