1 31 32 package org.opencms.file; 33 34 import org.opencms.db.CmsSecurityManager; 35 import org.opencms.loader.CmsLoaderException; 36 import org.opencms.main.CmsIllegalArgumentException; 37 import org.opencms.main.CmsLog; 38 import org.opencms.main.OpenCms; 39 import org.opencms.util.CmsUUID; 40 41 import java.io.Serializable ; 42 43 import org.apache.commons.logging.Log; 44 45 57 public class CmsFolder extends CmsResource implements Cloneable , Serializable , Comparable { 58 59 60 private static final Log LOG = CmsLog.getLog(CmsSecurityManager.class); 61 62 private static final long serialVersionUID = 5527163725725725452L; 63 64 69 public CmsFolder(CmsResource resource) { 70 71 this( 72 resource.getStructureId(), 73 resource.getResourceId(), 74 resource.getRootPath(), 75 resource.getTypeId(), 76 resource.getFlags(), 77 resource.getProjectLastModified(), 78 resource.getState(), 79 resource.getDateCreated(), 80 resource.getUserCreated(), 81 resource.getDateLastModified(), 82 resource.getUserLastModified(), 83 resource.getSiblingCount(), 84 resource.getDateReleased(), 85 resource.getDateExpired()); 86 } 87 88 105 public CmsFolder( 106 CmsUUID structureId, 107 CmsUUID resourceId, 108 String path, 109 int type, 110 int flags, 111 int projectId, 112 int state, 113 long dateCreated, 114 CmsUUID userCreated, 115 long dateLastModified, 116 CmsUUID userLastModified, 117 int linkCount, 118 long dateReleased, 119 long dateExpired) { 120 121 super( 122 structureId, 123 resourceId, 124 path, 125 type, 126 true, 127 flags, 128 projectId, 129 state, 130 dateCreated, 131 userCreated, 132 dateLastModified, 133 userLastModified, 134 dateReleased, 135 dateExpired, 136 linkCount, 137 -1); 138 } 139 140 148 public static final boolean isFolderType(int typeId) { 149 150 try { 151 return OpenCms.getResourceManager().getResourceType(typeId).isFolder(); 152 } catch (CmsLoaderException e) { 153 if (LOG.isWarnEnabled()) { 154 LOG.warn(Messages.get().getBundle().key(Messages.ERR_UNKNOWN_RESOURCE_TYPE_1, new Integer (typeId)), e); 155 } 156 } 157 return false; 158 } 159 160 167 public static final boolean isFolderType(String typeName) { 168 169 try { 170 return OpenCms.getResourceManager().getResourceType(typeName).isFolder(); 171 } catch (CmsLoaderException e) { 172 throw new CmsIllegalArgumentException(Messages.get().container( 173 Messages.ERR_UNKNOWN_RESOURCE_TYPE_1, 174 typeName), e); 175 } 176 } 177 178 183 public Object clone() { 184 185 CmsResource clone = new CmsFolder( 186 getStructureId(), 187 getResourceId(), 188 getRootPath(), 189 getTypeId(), 190 getFlags(), 191 getProjectLastModified(), 192 getState(), 193 getDateCreated(), 194 getUserCreated(), 195 getDateLastModified(), 196 getUserLastModified(), 197 getSiblingCount(), 198 getDateReleased(), 199 getDateExpired()); 200 201 if (isTouched()) { 202 clone.setDateLastModified(getDateLastModified()); 203 } 204 205 return clone; 206 } 207 208 211 public int getLength() { 212 213 return -1; 214 } 215 216 219 public boolean isFile() { 220 221 return false; 222 } 223 224 227 public boolean isFolder() { 228 229 return true; 230 } 231 } | Popular Tags |