1 31 32 package org.opencms.db; 33 34 import org.opencms.file.CmsResource; 35 import org.opencms.util.CmsUUID; 36 37 import java.io.Serializable ; 38 39 56 public class CmsPublishedResource implements Serializable , Cloneable , Comparable { 57 58 59 private static final long serialVersionUID = -1054065812825770479L; 60 61 62 private int m_backupTagId; 63 64 65 private boolean m_isFolder; 66 67 68 private CmsUUID m_resourceId; 69 70 71 private int m_resourceState; 72 73 74 private int m_resourceType; 75 76 77 private String m_rootPath; 78 79 80 private int m_siblingCount; 81 82 83 private CmsUUID m_structureId; 84 85 92 public CmsPublishedResource(CmsResource resource) { 93 94 m_structureId = resource.getStructureId(); 95 m_resourceId = resource.getResourceId(); 96 m_backupTagId = -1; 97 m_rootPath = resource.getRootPath(); 98 m_resourceType = resource.getTypeId(); 99 m_resourceState = resource.getState(); 100 m_siblingCount = resource.getSiblingCount(); 101 m_isFolder = resource.isFolder(); 102 } 103 104 110 public CmsPublishedResource(CmsResource resource, int backupTagId) { 111 112 m_structureId = resource.getStructureId(); 113 m_resourceId = resource.getResourceId(); 114 m_backupTagId = backupTagId; 115 m_rootPath = resource.getRootPath(); 116 m_resourceType = resource.getTypeId(); 117 m_resourceState = resource.getState(); 118 m_siblingCount = resource.getSiblingCount(); 119 m_isFolder = resource.isFolder(); 120 } 121 122 134 public CmsPublishedResource( 135 CmsUUID structureId, 136 CmsUUID resourceId, 137 int backupTagId, 138 String rootPath, 139 int resourceType, 140 boolean isFolder, 141 int resourceState, 142 int siblingCount) { 143 144 m_structureId = structureId; 145 m_resourceId = resourceId; 146 m_backupTagId = backupTagId; 147 m_rootPath = rootPath; 148 m_resourceType = resourceType; 149 m_resourceState = resourceState; 150 m_siblingCount = siblingCount; 151 m_isFolder = isFolder; 152 } 153 154 157 public int compareTo(Object obj) { 158 159 if (obj == this) { 160 return 0; 161 } 162 if (obj instanceof CmsPublishedResource) { 163 if (m_rootPath != null) { 164 return m_rootPath.compareTo(((CmsPublishedResource)obj).m_rootPath); 165 } 166 } 167 return 0; 168 } 169 170 173 public boolean equals(Object obj) { 174 175 if (obj == this) { 176 return true; 177 } 178 if (obj instanceof CmsPublishedResource) { 179 if (m_structureId.isNullUUID()) { 180 return ((CmsPublishedResource)obj).m_resourceId.equals(m_resourceId); 181 } else { 182 return ((CmsPublishedResource)obj).m_structureId.equals(m_structureId); 183 } 184 } 185 return false; 186 } 187 188 193 public int getBackupTagId() { 194 195 return m_backupTagId; 196 } 197 198 203 public CmsUUID getResourceId() { 204 205 return m_resourceId; 206 } 207 208 213 public String getRootPath() { 214 215 return m_rootPath; 216 } 217 218 226 public int getSiblingCount() { 227 228 return m_siblingCount; 229 } 230 231 236 public int getState() { 237 238 return m_resourceState; 239 } 240 241 246 public CmsUUID getStructureId() { 247 248 return m_structureId; 249 } 250 251 256 public int getType() { 257 258 return m_resourceType; 259 } 260 261 264 public int hashCode() { 265 266 return m_structureId.isNullUUID() ? m_resourceId.hashCode() : m_structureId.hashCode(); 267 } 268 269 274 public boolean isChanged() { 275 276 return getState() == CmsResource.STATE_CHANGED; 277 } 278 279 284 public boolean isDeleted() { 285 286 return getState() == CmsResource.STATE_DELETED; 287 } 288 289 294 public boolean isFile() { 295 296 return !m_isFolder; 297 } 298 299 304 public boolean isFolder() { 305 306 return m_isFolder; 307 } 308 309 314 public boolean isNew() { 315 316 return getState() == CmsResource.STATE_NEW; 317 } 318 319 324 public boolean isUnChanged() { 325 326 return getState() == CmsResource.STATE_UNCHANGED; 327 } 328 329 337 public boolean isVfsResource() { 338 339 return !getStructureId().equals(CmsUUID.getNullUUID()); 340 } 341 342 345 public String toString() { 346 347 StringBuffer result = new StringBuffer (128); 348 349 result.append("["); 350 result.append(this.getClass().getName()); 351 result.append(": root path: "); 352 result.append(m_rootPath); 353 result.append(", structure ID: "); 354 result.append(m_structureId); 355 result.append(", resource ID: "); 356 result.append(m_resourceId); 357 result.append(", backup tag ID: "); 358 result.append(m_backupTagId); 359 result.append(", siblings: "); 360 result.append(m_siblingCount); 361 result.append(", state: "); 362 result.append(m_resourceState); 363 result.append(", type: "); 364 result.append(m_resourceType); 365 result.append("]"); 366 367 return result.toString(); 368 } 369 370 373 protected void finalize() throws Throwable { 374 375 try { 376 m_structureId = null; 377 m_resourceId = null; 378 m_rootPath = null; 379 } catch (Throwable t) { 380 } 382 super.finalize(); 383 } 384 }
| Popular Tags
|