001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/file/history/CmsHistoryFolder.java,v $
003: * Date : $Date: 2008-02-27 12:05:25 $
004: * Version: $Revision: 1.4 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.file.history;
033:
034: import org.opencms.db.CmsResourceState;
035: import org.opencms.file.CmsFolder;
036: import org.opencms.file.CmsObject;
037: import org.opencms.main.CmsException;
038: import org.opencms.security.CmsPrincipal;
039: import org.opencms.util.CmsUUID;
040:
041: import java.io.Serializable;
042:
043: /**
044: * A historical version of a file in the OpenCms VFS resource history.<p>
045: *
046: * @author Michael Moossen
047: *
048: * @version $Revision: 1.4 $
049: *
050: * @since 6.9.1
051: */
052: public class CmsHistoryFolder extends CmsFolder implements
053: I_CmsHistoryResource, Cloneable, Serializable, Comparable {
054:
055: /** Serial version UID required for safe serialization. */
056: private static final long serialVersionUID = -374285965677032786L;
057:
058: /** The structure id of the parent of this historical resource. */
059: private CmsUUID m_parentId;
060:
061: /** The publish tag of this historical resource. */
062: private int m_publishTag;
063:
064: /** The version number of the resource part for this historical resource. */
065: private int m_resourceVersion;
066:
067: /** The version number of the structure part for this historical resource. */
068: private int m_structureVersion;
069:
070: /**
071: * Constructor from a history resource.<p>
072: *
073: * @param resource the base history resource
074: */
075: public CmsHistoryFolder(I_CmsHistoryResource resource) {
076:
077: this (resource.getPublishTag(), resource.getStructureId(),
078: resource.getResourceId(), resource.getRootPath(),
079: resource.getTypeId(), resource.getFlags(), resource
080: .getProjectLastModified(), resource.getState(),
081: resource.getDateCreated(), resource.getUserCreated(),
082: resource.getDateLastModified(), resource
083: .getUserLastModified(), resource
084: .getDateReleased(), resource.getDateExpired(),
085: resource.getVersion(), resource.getParentId(), resource
086: .getResourceVersion(), resource
087: .getStructureVersion());
088: }
089:
090: /**
091: * Default Constructor.<p>
092: *
093: * @param publishTag the publish tag of this historical resource
094: * @param structureId the id of this resources structure record
095: * @param resourceId the id of this resources resource record
096: * @param path the filename of this resouce
097: * @param type the type of this resource
098: * @param flags the flags of this resource
099: * @param projectId the project id this resource was last modified in
100: * @param state the state of this resource
101: * @param dateCreated the creation date of this resource
102: * @param userCreated the id of the user who created this resource
103: * @param dateLastModified the date of the last modification of this resource
104: * @param userLastModified the id of the user who did the last modification of this resource
105: * @param dateReleased the release date of this resource
106: * @param dateExpired the expiration date of this resource
107: * @param version the version number of this resource
108: * @param parentId structure id of the parent of this historical resource
109: * @param resourceVersion the version number of the resource part for this historical resource
110: * @param structureVersion the version number of the structure part for this historical resource
111: */
112: public CmsHistoryFolder(int publishTag, CmsUUID structureId,
113: CmsUUID resourceId, String path, int type, int flags,
114: CmsUUID projectId, CmsResourceState state,
115: long dateCreated, CmsUUID userCreated,
116: long dateLastModified, CmsUUID userLastModified,
117: long dateReleased, long dateExpired, int version,
118: CmsUUID parentId, int resourceVersion, int structureVersion) {
119:
120: super (structureId, resourceId, path, type, flags, projectId,
121: state, dateCreated, userCreated, dateLastModified,
122: userLastModified, dateReleased, dateExpired, version);
123:
124: m_publishTag = publishTag;
125: m_parentId = parentId;
126: m_resourceVersion = resourceVersion;
127: m_structureVersion = structureVersion;
128: }
129:
130: /**
131: * Returns a clone of this Objects instance.<p>
132: *
133: * @return a clone of this instance
134: */
135: public Object clone() {
136:
137: return new CmsHistoryFolder(getPublishTag(), getStructureId(),
138: getResourceId(), getRootPath(), getTypeId(),
139: getFlags(), getProjectLastModified(), getState(),
140: getDateCreated(), getUserCreated(),
141: getDateLastModified(), getUserLastModified(),
142: getDateReleased(), getDateExpired(), getVersion(),
143: getParentId(), getResourceVersion(),
144: getStructureVersion());
145: }
146:
147: /**
148: * @see org.opencms.file.history.I_CmsHistoryResource#getBackupId()
149: *
150: * @deprecated this field has been removed
151: */
152: public CmsUUID getBackupId() {
153:
154: return new CmsUUID();
155: }
156:
157: /**
158: * @see org.opencms.file.history.I_CmsHistoryResource#getCreatedByName()
159: *
160: * @deprecated use {@link #getUserCreatedName(CmsObject)} instead
161: */
162: public String getCreatedByName() {
163:
164: return getUserCreated().toString();
165: }
166:
167: /**
168: * @see org.opencms.file.history.I_CmsHistoryResource#getLastModifiedByName()
169: *
170: * @deprecated use {@link #getUserLastModifiedName(CmsObject)} instead
171: */
172: public String getLastModifiedByName() {
173:
174: return getUserLastModified().toString();
175: }
176:
177: /**
178: * @see org.opencms.file.history.I_CmsHistoryResource#getParentId()
179: */
180: public CmsUUID getParentId() {
181:
182: return m_parentId;
183: }
184:
185: /**
186: * @see org.opencms.file.history.I_CmsHistoryResource#getPublishTag()
187: */
188: public int getPublishTag() {
189:
190: return m_publishTag;
191: }
192:
193: /**
194: * @see org.opencms.file.history.I_CmsHistoryResource#getPublishTagId()
195: *
196: * @deprecated use {@link #getPublishTag()} instead
197: */
198: public int getPublishTagId() {
199:
200: return getPublishTag();
201: }
202:
203: /**
204: * @see org.opencms.file.history.I_CmsHistoryResource#getResourceVersion()
205: */
206: public int getResourceVersion() {
207:
208: return m_resourceVersion;
209: }
210:
211: /**
212: * @see org.opencms.file.history.I_CmsHistoryResource#getStructureVersion()
213: */
214: public int getStructureVersion() {
215:
216: return m_structureVersion;
217: }
218:
219: /**
220: * Returns the name of the user that created this resource.<p>
221: *
222: * @param cms the current cms context
223: *
224: * @return the name of the user that created this resource
225: */
226: public String getUserCreatedName(CmsObject cms) {
227:
228: try {
229: return CmsPrincipal.readPrincipalIncludingHistory(cms,
230: getUserCreated()).getName();
231: } catch (CmsException e) {
232: return getUserCreated().toString();
233: }
234: }
235:
236: /**
237: * Returns the name of the user that last modified this resource.<p>
238: *
239: * @param cms the current cms context
240: *
241: * @return the name of the user that last modified this resource
242: */
243: public String getUserLastModifiedName(CmsObject cms) {
244:
245: try {
246: return CmsPrincipal.readPrincipalIncludingHistory(cms,
247: getUserLastModified()).getName();
248: } catch (CmsException e) {
249: return getUserLastModified().toString();
250: }
251: }
252:
253: /**
254: * @see org.opencms.file.CmsResource#toString()
255: */
256: public String toString() {
257:
258: StringBuffer result = new StringBuffer();
259:
260: result.append("[");
261: result.append(super .toString());
262: result.append(", resource version: ");
263: result.append(m_resourceVersion);
264: result.append(", structure version ");
265: result.append(m_structureVersion);
266: result.append(", parent id: ");
267: result.append(m_parentId);
268: result.append(", publish tag: ");
269: result.append(m_publishTag);
270: result.append("]");
271:
272: return result.toString();
273: }
274: }
|