📄 cmsresource.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/file/CmsResource.java,v $
* Date : $Date: 2001/10/16 09:00:35 $
* Version: $Revision: 1.37 $
*
* This library is part of OpenCms -
* the Open Source Content Mananagement System
*
* Copyright (C) 2001 The OpenCms Group
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* For further information about OpenCms, please see the
* OpenCms Website: http://www.opencms.org
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.opencms.file;
import java.util.*;
import java.io.*;
import com.opencms.core.*;
/**
* This class describes a resource in the Cms.
* This resource can be a A_CmsFile or a A_CmsFolder.
*
* @author Michael Emmerich
* @version $Revision: 1.37 $ $Date: 2001/10/16 09:00:35 $
*/
public class CmsResource implements I_CmsConstants,
Cloneable,
Serializable {
/**
* The database ID
*/
private int m_resourceId;
/**
* The database Parent ID
*/
private int m_parentId;
/**
* The database Parent ID
*/
private int m_fileId;
/**
* The name of this resource.
*/
private String m_resourceName;
/**
* The type of this resource.
*/
private int m_resourceType;
/**
* The flags of this resource ( not used yet; the Accessflags are stored in m_accessFlags).
*/
private int m_resourceFlags;
/**
* The project id this recouce belongs to.
*/
private int m_projectId;
/**
* The owner of this resource.
*/
private int m_user;
/**
* The group of this resource.
*/
private int m_group;
/**
* The access flags of this resource.
*/
private int m_accessFlags;
/**
* The creation date of this resource.
*/
private long m_dateCreated;
/**
* The date of the last modification of this resource.
*/
private long m_dateLastModified;
/**
* The size of the file content.
*/
protected int m_size;
/**
* The state of this resource. <br>
* A resource can have the following states:
* <ul>
* <li> unchanged </li>
* <li> changed </li>
* <li> new </li>
* <li> deleted </li>
* </ul>
*/
private int m_state;
/**
* The user id of the usrer who locked this resource.
*/
private int m_lockedBy;
/**
* The type of the launcher which is used to process this resource.
*/
private int m_launcherType;
/**
* The Java class thas is invoked by the launcher to process this resource.
*/
private String m_launcherClassname;
/**
* The UserId of the user who modified this resource last.
*/
private int m_resourceLastModifiedBy;
/**
* The projectId of the project where the resource was locked or modified in
*/
private int m_lockedInProject;
/**
* Constructor, creates a new CmsRecource object.
*
* @param resourceId The database Id.
* @param parentId The database Id of the parent folder.
* @param fileId The id of the content.
* @param resourceName The name (including complete path) of the resouce.
* @param resourceType The type of this resource.
* @param rescourceFlags The flags of thei resource.
* @param userId The id of the user of this resource.
* @param groupId The id of the group of this resource.
* @param projectId The project id this resource belongs to.
* @param accessFlags The access flags of this resource.
* @param state The state of this resource.
* @param lockedBy The user id of the user who has locked this resource.
* @param launcherType The launcher that is require to process this recource.
* @param launcherClassname The name of the Java class invoked by the launcher.
* @param dateCreated The creation date of this resource.
* @param dateLastModified The date of the last modification of the resource.
* @param resourceLastModifiedBy The user who changed the file.
*/
public CmsResource(int resourceId, int parentId,
int fileId,String resourceName,
int resourceType, int resourceFlags,
int user, int group, int projectId,
int accessFlags, int state, int lockedBy,
int launcherType, String launcherClassname,
long dateCreated, long dateLastModified,
int resourceLastModifiedBy,int size, int lockedInProject){
m_resourceId = resourceId;
m_parentId = parentId;
m_fileId = fileId;
m_resourceName=resourceName;
m_resourceType=resourceType;
m_resourceFlags=resourceFlags;
m_user=user;
m_group=group;
m_projectId=projectId;
m_accessFlags=accessFlags;
m_launcherType=launcherType;
m_launcherClassname=launcherClassname;
m_state=state;
m_lockedBy=lockedBy;
m_dateCreated=dateCreated;
m_dateLastModified=dateLastModified;
m_resourceLastModifiedBy = resourceLastModifiedBy;
m_size=size;
m_lockedInProject=lockedInProject;
}
/**
* Clones the CmsResource by creating a new CmsObject.
* @return Cloned CmsObject.
*/
public Object clone() {
return new CmsResource(m_resourceId, m_parentId,m_fileId,
m_resourceName, m_resourceType, m_resourceFlags,
m_user, m_group, m_projectId,
m_accessFlags, m_state, m_lockedBy,
m_launcherType, m_launcherClassname,
m_dateCreated, m_dateLastModified,
m_resourceLastModifiedBy,m_size, m_lockedInProject);
}
/**
* Compares the overgiven object with this object.
*
* @return true, if the object is identically else it returns false.
*/
public boolean equals(Object obj) {
boolean equal=false;
// check if the object is a CmsResource object
if (obj instanceof CmsResource) {
// same ID than the current user?
if (((CmsResource)obj).getResourceName().equals(m_resourceName)){
equal = true;
}
}
return equal;
}
/**
* Returns the absolute path for this resource.<BR/>
* Example: retuns /system/def/language.cms
*
* @return the absolute path for this resource.
*/
public String getAbsolutePath(){
int rootIndex = m_resourceName.indexOf("/", m_resourceName.indexOf("/",1)+1);
return m_resourceName.substring(rootIndex);
}
/**
* Returns the root name for this resource.<BR/>
* Example: returns /Site_a/vfs
*
* @return the root name for this resource.
*/
public String getRootName(){
int rootIndex = m_resourceName.indexOf("/",m_resourceName.indexOf("/",1)+1);
return m_resourceName.substring(0, rootIndex);
}
/**
* Returns the resource name for this resource.<BR/>
* Example: returns /Site_a/vfs/system/def/language.cms
*
* @return the resource name for this resource.
*/
public String getResourceName(){
return m_resourceName;
}
/**
* Returns the accessflags of this resource.
*
* @return the accessflags of this resource.
*/
public int getAccessFlags() {
return m_accessFlags;
}
/**
* Returns the date of the creation for this resource.
*
* @return the date of the creation for this resource.
*/
public long getDateCreated() {
return m_dateCreated;
}
/**
* Returns the date of the last modification for this resource.
*
* @return the date of the last modification for this resource.
*/
public long getDateLastModified() {
return m_dateLastModified;
}
/**
* Gets the File id for this resource.
*
* @return the File id of this resource.
*/
public int getFileId(){
return m_fileId;
}
/**
* Returns the flags of this resource ( not used yet; the Accessflags are served in getAccessFlags).
*
* @return the flags of this resource (this are not the AccessFlags!!).
*/
public int getFlags() {
return m_resourceFlags;
}
/**
* Creates a Unix-Style string of access rights from the access right flag of a
* CmsResource
*
* @return String of access rights
*/
public String getFlagString()
{
String str = "";
str += ((m_accessFlags & C_ACCESS_OWNER_READ)>0?"r":"-");
str += ((m_accessFlags & C_ACCESS_OWNER_WRITE)>0?"w":"-");
str += ((m_accessFlags & C_ACCESS_OWNER_VISIBLE)>0?"v":"-");
str += ((m_accessFlags & C_ACCESS_GROUP_READ)>0?"r":"-");
str += ((m_accessFlags & C_ACCESS_GROUP_WRITE)>0?"w":"-");
str += ((m_accessFlags & C_ACCESS_GROUP_VISIBLE)>0?"v":"-");
str += ((m_accessFlags & C_ACCESS_PUBLIC_READ)>0?"r":"-");
str += ((m_accessFlags & C_ACCESS_PUBLIC_WRITE)>0?"w":"-");
str += ((m_accessFlags & C_ACCESS_PUBLIC_VISIBLE)>0?"v":"-");
str += ((m_accessFlags & C_ACCESS_INTERNAL_READ)>0?"i":"-");
return str;
}
/**
* Returns the groupid of this resource.
*
* @return the groupid of this resource.
*/
public int getGroupId() {
return m_group;
}
/**
* Gets the launcher classname for this resource.
*
* @return the launcher classname for this resource.
*/
public String getLauncherClassname() {
return m_launcherClassname;
}
/**
* Gets the launcher type id for this resource.
*
* @return the launcher type id of this resource.
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -