📄 cmsobject.java
字号:
/*
* File : $Source: /usr/local/cvs/opencms/src/com/opencms/file/CmsObject.java,v $
* Date : $Date: 2004/01/06 12:45:04 $
* Version: $Revision: 1.268.2.2 $
*
* 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 com.opencms.boot.I_CmsLogChannels;
import com.opencms.core.*;
import com.opencms.flex.util.CmsResourceTranslator;
import com.opencms.launcher.CmsLauncherManager;
import com.opencms.linkmanagement.CmsPageLinks;
import com.opencms.linkmanagement.LinkChecker;
import com.opencms.report.CmsShellReport;
import com.opencms.report.I_CmsReport;
import com.opencms.template.cache.CmsElementCache;
import com.opencms.util.LinkSubstitution;
import com.opencms.util.Utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.Vector;
import source.org.apache.java.util.Configurations;
/**
* 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 Michael Emmerich
* @author Alexander Kandzior (a.kandzior@alkacon.com)
* @author Michaela Schleich
*
* @version $Revision: 1.268.2.2 $
*/
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 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 linkmanagement.
*/
private LinkChecker m_linkChecker = 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 () {
}
/** Internal debug flag, set to 9 for maximum verbosity */
private static final int DEBUG = 0;
/**
* Accept a task from the Cms.
*
* @param taskid the id of the task to accept.
*
* @throws 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
*
* @throws 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
*
* @throws 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
*
* @throws 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.
*
* @throws 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.
*
* @throws 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.
*
* @throws 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
* @param flags the flags for the new group
* @param parent the parent group
*
* @return a <code>CmsGroup</code> object representing the newly created group.
*
* @throws 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.
*
* @throws 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(this, 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.
*
* @throws 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.
* @throws 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.
*
* @throws 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(this, 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).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -