⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmsshellcommands.java

📁 java 编写的程序
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*
* File   : $Source: /usr/local/cvs/opencms/src/com/opencms/core/CmsShellCommands.java,v $
* Date   : $Date: 2002/04/24 07:17:27 $
* Version: $Revision: 1.48 $
*
* 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.core;

import java.util.*;
import java.io.*;
import com.opencms.file.*;
import java.lang.reflect.*;
import source.org.apache.java.util.*;

/**
 * This class is a commadnlineinterface for the opencms. It can be used to test
 * the opencms, and for the initial setup. It uses the OpenCms-Object.
 *
 * @author Andreas Schouten
 * @author Anders Fugmann
 * @version $Revision: 1.48 $ $Date: 2002/04/24 07:17:27 $
 */
public class CmsShellCommands implements I_CmsConstants {

    /**
     * The resource broker to get access to the cms.
     */
    private CmsObject m_cms;

    /**
     * The open-cms.
     */
    private A_OpenCms m_openCms;

    /**
     * Insert the method's description here.
     * Creation date: (10/05/00 %r)
     * @author:
     */
    public CmsShellCommands(A_OpenCms openCms, CmsObject cms) throws Exception {
        m_openCms = openCms;
        m_cms = cms;
        m_openCms.initUser(m_cms, null, null, C_USER_GUEST, C_GROUP_GUEST, C_PROJECT_ONLINE_ID, null);

        // print the version-string
        version();
        copyright();
        printHelpText();
    }

    /**
     * Accept a task from the Cms.
     *
     * @param taskid the id of the task to accept.
     */
    public void acceptTask(String taskId) {
        try {
            int id = Integer.parseInt(taskId);
            m_cms.acceptTask(id);
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Checks, if the user may create this resource.
     *
     * @param resource the resource to check.
     */
    public void accessCreate(String resource) {
        try {

            //System.out.println(m_cms.accessCreate(m_cms.readFileHeader(resource)));
            // ednfal: resource is read later in resourcebroker
            System.out.println(m_cms.accessCreate(resource));
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Checks, if the user may lock this resource.
     *
     * @param resource the resource to check.
     */
    public void accessLock(String resource) {
        try {

            //System.out.println(m_cms.accessLock(m_cms.readFileHeader(resource)));
            // ednfal: resource is read later in resourcebroker
            System.out.println(m_cms.accessLock(resource));
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Tests if the user can access the project.
     *
     * @param id the id of the project.
     */
    public void accessProject(String id) {
        try {
            int projectId = Integer.parseInt(id);
            System.out.println(m_cms.accessProject(projectId));
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Checks, if the user may read this resource.
     *
     * @param resource The resource to check.
     */
    public void accessRead(String resource) {
        try {

            //System.out.println(m_cms.accessRead(m_cms.readFileHeader(resource)));
            // ednfal: resource is read later in resourcebroker
            System.out.println(m_cms.accessRead(resource));
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Tests if the user can write the resource.
     *
     * @param resource the name of the resource.
     */
    public void accessWrite(String resource) {
        try {

            //CmsResource res = m_cms.readFileHeader(resource);
            //System.out.println( m_cms.accessWrite(res) );
            // ednfal: resource is read later in resourcebroker
            System.out.println(m_cms.accessWrite(resource));
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * adds a file extension.
     * @param extension a file extension, e.g. 'html'
     * @param resourceType, name of a resource type like 'page'
     */
    public void addFileExtension(String extension, String resourceType) {
        try {
            m_cms.addFileExtension(extension, resourceType);
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Adds a Group to the cms.
     *
     * @param name The name of the new group.
     * @param description The description for the new group.
     */
    public void addGroup(String name, String description) {
        try {
            m_cms.addGroup(name, description, C_FLAG_ENABLED, null);
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Adds a Group to the cms.
     *
     * @param name The name of the new group.
     * @param description The description for the new group.
     * @int flags The flags for the new group.
     * @param name The name of the parent group (or null).
     */
    public void addGroup(String name, String description, String flags, String parent) {
        try {
            m_cms.addGroup(name, description, Integer.parseInt(flags), parent);
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Adds a user to the cms.
     *
     * @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.
     */
    public void addUser(String name, String password, String group, String description) {
        try {
            System.out.println(m_cms.addUser(name, password, group, description, new Hashtable(), C_FLAG_ENABLED));
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Adds a user to the cms.
     *
     * @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 flags The flags for the user.
     */
    public void addUser(String name, String password, String group, String description, String flags) {
        try {
            System.out.println(m_cms.addUser(name, password, group, description, new Hashtable(), Integer.parseInt(flags)));
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Adds a user to the cms.
     *
     * @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 flags The flags for the user.
     */
    public void addUser(String name, String password, String group, String description, String firstname, String lastname, String email) {
        try {
            CmsUser user = m_cms.addUser(name, password, group, description, new Hashtable(), C_FLAG_ENABLED);
            user.setEmail(email);
            user.setFirstname(firstname);
            user.setLastname(lastname);
            m_cms.writeUser(user);
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Adds 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.
     */
    public void addUserToGroup(String username, String groupname) {
        try {
            m_cms.addUserToGroup(username, groupname);
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * 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 flags the flags for a user (e.g. C_FLAG_ENABLED)
     *
     */
    public void addWebUser(String name, String password, String group, String description, String flags) {
        try {
            int intFlags = Integer.parseInt(flags);
            System.out.println(m_cms.addWebUser(name, password, group, description, new Hashtable(), intFlags));
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * 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 the additional group for the user.
     * @param description the description for the user.
     * @param flags the flags for a user (e.g. C_FLAG_ENABLED)
     *
     */
    public void addWebUser(String name, String password, String group, String additionalGroup, String description, String flags) {
        try {
            int intFlags = Integer.parseInt(flags);
            System.out.println(m_cms.addWebUser(name, password, group, additionalGroup, description, new Hashtable(), intFlags));
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Returns the anonymous user object.
     *
     * @return a <code>CmsUser</code> object representing the anonymous user.
     */
    public void anonymousUser() {
        try {
            System.out.println(m_cms.anonymousUser());
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Changes the group for this resource<BR/>
     *
     * The user may change this, if he is admin of the resource.
     *
     * @param filename The complete path to the resource.
     * @param newGroup The new of the new group for this resource.
     */
    public void chgrp(String filename, String newGroup) {
        try {
            m_cms.chgrp(filename, newGroup);
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Changes the flags for this resource<BR/>
     *
     * The user may change the flags, if he is admin of the resource.
     *
     * @param filename The complete path to the resource.
     * @param flags The new flags for the resource.
     */
    public void chmod(String filename, String flags) {
        try {
            m_cms.chmod(filename, Integer.parseInt(flags));
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Changes the owner for this resource<BR/>
     *
     * The user may change this, if he is admin of the resource.
     *
     * @param filename The complete path to the resource.
     * @param newOwner The name of the new owner for this resource.
     */
    public void chown(String filename, String newOwner) {
        try {
            m_cms.chown(filename, newOwner);
        }
        catch(Exception exc) {
            CmsShell.printException(exc);
        }
    }

    /**
     * Changes the resourcetype for this resource<BR/>
     *
     * The user may change this, if he is admin of the resource.
     *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -