📄 cmsobject.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/file/CmsObject.java,v $
* Date : $Date: 2002/05/10 20:17:14 $
* Version: $Revision: 1.230.2.1 $
*
* 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 javax.servlet.http.*;
import source.org.apache.java.util.*;
import com.opencms.core.*;
import com.opencms.util.*;
import com.opencms.launcher.*;
import com.opencms.template.cache.*;
/**
* This class provides access to the OpenCms and its resources.
* <br>
* The CmsObject encapsulates user identification and client requests and
* is the central object to transport information in the Cms Servlet.
* <br>
* All operations on the CmsObject are forwarded to the class which extends A_CmsRessourceBroker
* to ensure user authentification in all operations.
*
* @author Andreas Schouten
* @author Michaela Schleich
* @author Michael Emmerich
*
* @version $Revision: 1.230.2.1 $ $Date: 2002/05/10 20:17:14 $
*
*/
public class CmsObject implements I_CmsConstants {
/**
* Method that can be invoked to find out all currently logged in users.
*/
private CmsCoreSession m_sessionStorage = null;
/**
* The current version-number of OpenCms
*/
private static String c_versionNumber = null;
/**
* The resource broker to access the cms.
*/
private I_CmsResourceBroker m_rb = null;
/**
* The resource broker to access the cms.
*/
private CmsRequestContext m_context = null;
/**
* The launcher manager used with this object,
* Is needed to clear the template caches.
*/
private CmsLauncherManager m_launcherManager = null;
/**
* The class for processing links.
*/
private LinkSubstitution m_linkSubstitution = null;
/**
* the modus the cmsObject runs in (used i.e. for static export)
*/
private int m_mode = C_MODUS_AUTO;
/**
* The default constructor.
*/
public CmsObject () {
}
/**
* Accept a task from the Cms.
*
* @param taskid the id of the task to accept.
*
* @exception CmsException if operation was not successful.
*/
public void acceptTask(int taskId) throws CmsException {
m_rb.acceptTask(m_context.currentUser(), m_context.currentProject(), taskId);
}
/**
* Checks, if the user may create this resource.
*
* @param resource the resource to check.
* @return <code>true</code> if the user has the appropriate rigths to create the resource; <code>false</code> otherwise
*
* @exception CmsException if operation was not successful.
*/
public boolean accessCreate(String resource) throws CmsException {
try {
return m_rb.accessCreate(m_context.currentUser(), m_context.currentProject(), getSiteRoot(resource));
} catch (Exception exc) {
throw new CmsException(CmsException.C_UNKNOWN_EXCEPTION, exc);
}
}
/**
* Checks, if the user may lock this resource.
*
* @param resource the resource to check.
* @return <code>true</code> if the user has the appropriate rights to lock this resource; <code>false</code> otherwise
*
* @exception CmsException if operation was not successful.
*/
public boolean accessLock(String resource) throws CmsException {
try {
return m_rb.accessLock(m_context.currentUser(), m_context.currentProject(), getSiteRoot(resource));
} catch (Exception exc) {
throw new CmsException(CmsException.C_UNKNOWN_EXCEPTION, exc);
}
}
/**
* Checks if the user can access the project.
*
* @param projectId the id of the project.
* @return <code>true</code>, if the user may access this project; <code>false</code> otherwise
*
* @exception CmsException if operation was not successful.
*/
public boolean accessProject(int projectId) throws CmsException {
return (m_rb.accessProject(m_context.currentUser(), m_context.currentProject(), projectId));
}
/**
* Checks, if the user may read this resource.
*
* @param resource The resource to check.
* @return <code>true</code>, if the user has the appropriate rigths to read the resource; <code>false</code> otherwise.
*
* @exception CmsException if operation was not successful.
*/
public boolean accessRead(String resource) throws CmsException {
try {
return m_rb.accessRead(m_context.currentUser(), m_context.currentProject(), getSiteRoot(resource));
} catch (Exception exc) {
throw new CmsException(CmsException.C_UNKNOWN_EXCEPTION, exc);
}
}
/**
* Checks, if the user may write this resource.
*
* @param resource the resource to check.
* @return <code>true</code>, if the user has the appropriate rigths to write the resource; <code>false</code> otherwise.
*
* @exception CmsException if operation was not successful.
*/
public boolean accessWrite(String resource) throws CmsException {
try {
return m_rb.accessWrite(m_context.currentUser(), m_context.currentProject(), getSiteRoot(resource));
} catch (Exception exc) {
throw new CmsException(CmsException.C_UNKNOWN_EXCEPTION, exc);
}
}
/**
* Adds a file extension to the list of known file extensions.
* <p>
* <b>Security:</b>
* Only members of the group administrators are allowed to add a file extension.
*
* @param extension a file extension like "html","txt" etc.
* @param resTypeName name of the resource type associated with the extension.
*
* @exception CmsException if operation was not successful.
*/
public void addFileExtension(String extension, String resTypeName) throws CmsException {
m_rb.addFileExtension(m_context.currentUser(), m_context.currentProject(), extension, resTypeName);
}
/**
* Adds a new group to the Cms.
* <p>
* <b>Security:</b>
* Only members of the group administrators are allowed to add a new group.
*
* @param name the name of the new group.
* @param description the description of the new group.
* @int flags the flags for the new group.
*
* @return a <code>CmsGroup</code> object representing the newly created group.
*
* @exception CmsException if operation was not successful.
*/
public CmsGroup addGroup(String name, String description, int flags, String parent) throws CmsException {
return (m_rb.addGroup(m_context.currentUser(), m_context.currentProject(), name, description, flags, parent));
}
/**
* Adds a user to the Cms.
* <p>
* <b>Security:</b>
* Only members of the group administrators are allowed to add a user.
*
* @param name the new name for the user.
* @param password the new password for the user.
* @param group the default groupname for the user.
* @param description the description for the user.
* @param additionalInfos a Hashtable with additional infos for the user. These
* Infos may be stored into the Usertables (depending on the implementation).
* @param flags the flags for a user (e.g. C_FLAG_ENABLED).
*
* @return a <code>CmsUser</code> object representing the added user.
*
* @exception CmsException if operation was not successful.
*/
public CmsUser addUser(String name, String password, String group, String description, Hashtable additionalInfos, int flags) throws CmsException {
return (m_rb.addUser(m_context.currentUser(), m_context.currentProject(), name, password, group, description, additionalInfos, flags));
}
/**
* Adds a user to the Cms by import.
* <p>
* <b>Security:</b>
* Only members of the group administrators are allowed to add a user.
*
* @param name the new name for the user.
* @param password the new password for the user.
* @param recoveryPassword the new password for the user.
* @param description the description for the user.
* @param firstname the firstname of the user.
* @param lastname the lastname of the user.
* @param email the email of the user.
* @param flags the flags for a user (e.g. C_FLAG_ENABLED).
* @param additionalInfos a Hashtable with additional infos for the user. These
* Infos may be stored into the Usertables (depending on the implementation).
* @param defaultGroup the default groupname for the user.
* @param address the address of the user.
* @param section the section of the user.
* @param type the type of the user.
*
* @return a <code>CmsUser</code> object representing the added user.
*
* @exception CmsException if operation was not successful.
*/
public CmsUser addImportUser(String name, String password, String recoveryPassword, String description,
String firstname, String lastname, String email, int flags, Hashtable additionalInfos,
String defaultGroup, String address, String section, int type) throws CmsException {
return (m_rb.addImportUser(m_context.currentUser(), m_context.currentProject(), name, password,
recoveryPassword, description, firstname, lastname, email, flags, additionalInfos,
defaultGroup, address, section, type));
}
/**
* Adds a user to a group.
* <p>
* <b>Security:</b>
* Only members of the group administrators are allowed to add a user to a group.
*
* @param username the name of the user that is to be added to the group.
* @param groupname the name of the group.
* @exception CmsException if operation was not successful.
*/
public void addUserToGroup(String username, String groupname) throws CmsException {
m_rb.addUserToGroup(m_context.currentUser(), m_context.currentProject(), username, groupname);
}
/**
* Adds a web user to the Cms.
* <br>
* A web user has no access to the workplace but is able to access personalized
* functions controlled by the OpenCms.
*
* @param name the new name for the user.
* @param password the new password for the user.
* @param group the default groupname for the user.
* @param description the description for the user.
* @param additionalInfos a Hashtable with additional infos for the user. These
* Infos may be stored into the Usertables (depending on the implementation).
* @param flags the flags for a user (e.g. C_FLAG_ENABLED)
*
* @return a <code>CmsUser</code> object representing the newly created user.
*
* @exception CmsException if operation was not successful.
*/
public CmsUser addWebUser(String name, String password, String group, String description, Hashtable additionalInfos, int flags) throws CmsException {
return (m_rb.addWebUser(m_context.currentUser(), m_context.currentProject(), name, password, group, description, additionalInfos, flags));
}
/**
* Adds a web user to the Cms.
* <br>
* A web user has no access to the workplace but is able to access personalized
* functions controlled by the OpenCms.
*
* @param name the new name for the user.
* @param password the new password for the user.
* @param group the default groupname for the user.
* @param additionalGroup An additional group for the user.
* @param description the description for the user.
* @param additionalInfos a Hashtable with additional infos for the user. These
* Infos may be stored into the Usertables (depending on the implementation).
* @param flags the flags for a user (e.g. C_FLAG_ENABLED)
*
* @return a <code>CmsUser</code> object representing the newly created user.
*
* @exception CmsException if operation was not successful.
*/
public CmsUser addWebUser(String name, String password, String group, String additionalGroup, String description, Hashtable additionalInfos, int flags) throws CmsException {
CmsUser newWebUser = m_rb.addWebUser(m_context.currentUser(), m_context.currentProject(), name, password, group, additionalGroup, description, additionalInfos, flags);
return newWebUser;
}
/**
* Returns the anonymous user object.
*
* @return a <code>CmsUser</code> object representing the anonymous user.
* @exception CmsException if operation was not successful.
*/
public CmsUser anonymousUser() throws CmsException {
return (m_rb.anonymousUser(m_context.currentUser(), m_context.currentProject()));
}
/**
* Changes the group of a resource.
* <br>
* Only the group of a resource in an offline project can be changed. The state
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -