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

📄 cmsobject.java

📁 OpenCms 是一个J2EE的产品
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * Returns all child resources of a resource, that is the resources
     * contained in a folder.<p>
     * 
     * With the <code>{@link CmsResourceFilter}</code> provided as parameter
     * you can control if you want to include deleted, invisible or 
     * time-invalid resources in the result.<p>
     * 
     * This method is mainly used by the workplace explorer.<p>
     * 
     * @param resourcename the full path of the resource to return the child resources for
     * @param filter the resource filter to use
     * 
     * @return a list of all child <code>{@link CmsResource}</code>s
     * 
     * @throws CmsException if something goes wrong
     */
    public List getResourcesInFolder(String resourcename, CmsResourceFilter filter) throws CmsException {

        CmsResource resource = readResource(resourcename, CmsResourceFilter.ALL);
        return m_securityManager.readChildResources(m_context, resource, filter, true, true);
    }

    /**
     * Returns a list with all sub resources of the given parent folder (and all of it's subfolders) 
     * that have been modified in the given time range.<p>
     * 
     * The result list is descending sorted (newest resource first).<p>
     *
     * @param folder the folder to get the subresources from
     * @param starttime the begin of the time range
     * @param endtime the end of the time range
     * 
     * @return a list with all <code>{@link CmsResource}</code> objects 
     *               that have been modified in the given time range.
     *
     * @throws CmsException if operation was not succesful
     */
    public List getResourcesInTimeRange(String folder, long starttime, long endtime) throws CmsException {

        return m_securityManager.getResourcesInTimeRange(m_context, addSiteRoot(folder), starttime, endtime);
    }

    /**
     * Adjusts the absolute resource root path for the current site.<p> 
     * 
     * The full root path of a resource is always available using
     * <code>{@link CmsResource#getRootPath()}</code>. From this name this method cuts 
     * of the current site root using 
     * <code>{@link CmsRequestContext#removeSiteRoot(String)}</code>.<p>
     * 
     * If the resource root path does not start with the current site root,
     * it is left untouched.<p>
     * 
     * @param resource the resource to get the adjusted site root path for
     * 
     * @return the absolute resource path adjusted for the current site
     * 
     * @see CmsRequestContext#removeSiteRoot(String)
     * @see CmsRequestContext#getSitePath(CmsResource)
     * @see CmsResource#getRootPath()
     */
    public String getSitePath(CmsResource resource) {

        return m_context.getSitePath(resource);
    }

    /**
     * Returns all folder resources contained in a folder.<p>
     * 
     * The result is filtered according to the rules of 
     * the <code>{@link CmsResourceFilter#DEFAULT}</code> filter.<p>
     * 
     * @param resourcename the full path of the resource to return the child resources for. 
     * 
     * @return a list of all child file <code>{@link CmsResource}</code>s
     * 
     * @throws CmsException if something goes wrong
     * 
     * @see #getSubFolders(String, CmsResourceFilter)
     */
    public List getSubFolders(String resourcename) throws CmsException {

        return getSubFolders(resourcename, CmsResourceFilter.DEFAULT);
    }

    /**
     * Returns all folder resources contained in a folder.<p>
     * 
     * With the <code>{@link CmsResourceFilter}</code> provided as parameter
     * you can control if you want to include deleted, invisible or 
     * time-invalid resources in the result.<p>
     * 
     * @param resourcename the full path of the resource to return the child resources for. 
     * 
     * @return a list of all child folder <code>{@link CmsResource}</code>s
     * @param filter the resource filter to use
     * 
     * @throws CmsException if something goes wrong
     */
    public List getSubFolders(String resourcename, CmsResourceFilter filter) throws CmsException {

        CmsResource resource = readResource(resourcename, CmsResourceFilter.ALL);
        return m_securityManager.readChildResources(m_context, resource, filter, true, false);
    }

    /**
     * Returns the current session info manager object.<p>
     * 
     * @return the current session info manager object
     */
    public CmsTaskService getTaskService() {

        return new CmsTaskService(m_context, m_securityManager);
    }

    /**
     * Returns all users.<p>
     *
     * @return a list of all <code>{@link CmsUser}</code> objects
     * 
     * @throws CmsException if operation was not successful
     */
    public List getUsers() throws CmsException {

        return m_securityManager.getUsers(m_context);
    }

    /**
     * Returns all users of the given type.<p>
     *
     * @param type the type of the users
     * 
     * @return a list of all <code>{@link CmsUser}</code> objects of the given type
     * 
     * @throws CmsException if operation was not successful
     */
    public List getUsers(int type) throws CmsException {

        return (m_securityManager.getUsers(m_context, type));
    }

    /**
     * Returns all direct users of a given group.<p>
     *
     * Users that are "indirectly" in the group are not returned in the result.<p>
     *
     * @param groupname the name of the group to get all users for
     * 
     * @return all <code>{@link CmsUser}</code> objects in the group
     *
     * @throws CmsException if operation was not successful
     */
    public List getUsersOfGroup(String groupname) throws CmsException {

        return (m_securityManager.getUsersOfGroup(m_context, groupname));
    }

    /**
     * Checks if the current user has required permissions to access a given resource.<p>
     * 
     * @param resource the resource to check the permissions for
     * @param requiredPermissions the set of permissions to check for
     * 
     * @return <code>true</code> if the required permissions are satisfied
     * 
     * @throws CmsException if something goes wrong
     */
    public boolean hasPermissions(CmsResource resource, CmsPermissionSet requiredPermissions) throws CmsException {

        return CmsSecurityManager.PERM_ALLOWED == m_securityManager.hasPermissions(
            m_context,
            resource,
            requiredPermissions,
            true,
            CmsResourceFilter.ALL);
    }

    /**
     * Checks if the current user has required permissions to access a given resource.<p>
     * 
     * @param resource the resource to check the permissions for
     * @param requiredPermissions the set of permissions to check for
     * @param checkLock if <code>true</code>, a lock for the current user is required for 
     *      all write operations, if <code>false</code> it's ok to write as long as the resource
     *      is not locked by another user.
     * @param filter the resource filter to use
     * 
     * @return <code>true</code> if the required permissions are satisfied
     * 
     * @throws CmsException if something goes wrong
     */
    public boolean hasPermissions(
        CmsResource resource,
        CmsPermissionSet requiredPermissions,
        boolean checkLock,
        CmsResourceFilter filter) throws CmsException {

        return CmsSecurityManager.PERM_ALLOWED == m_securityManager.hasPermissions(
            m_context,
            resource,
            requiredPermissions,
            checkLock,
            filter);
    }

    /**
     * Checks if the given resource or the current project can be published by the current user 
     * using his current OpenCms context.<p>
     * 
     * If the resource parameter is <code>null</code>, then the current project is checked,
     * otherwise the resource is checked for direct publish permissions.<p>
     * 
     * @param resourcename the direct publish resource name (optional, if null only the current project is checked)
     * 
     * @return <code>true</code>, if the current user can direct publish the given resource in his current context
     */
    public boolean hasPublishPermissions(String resourcename) {

        CmsResource resource = null;
        if (resourcename != null) {
            // resource name is optional
            try {
                resource = readResource(resourcename, CmsResourceFilter.ALL);
                checkPublishPermissions(new CmsPublishList(Collections.singletonList(resource), false));
            } catch (CmsException e) {
                // if any exception (e.g. security) occurs the result is false
                return false;
            }
        }
        // no exception means permissions are granted
        return true;
    }

    /**
     * Checks if the user of the current OpenCms context 
     * is a member of at last one of the roles in the given role set.<p>
     *  
     * @param roles the role to check
     * 
     * @return <code>true</code> if the user of the current OpenCms context is at a member of at last 
     *      one of the roles in the given role set
     */
    public boolean hasRole(CmsRole roles) {

        return m_securityManager.hasRole(m_context, roles);
    }

    /**
     * Writes a list of access control entries as new access control entries of a given resource.<p>
     * 
     * Already existing access control entries of this resource are removed before.<p>
     * 
     * @param resource the resource to attach the control entries to
     * @param acEntries a list of <code>{@link CmsAccessControlEntry}</code> objects
     * 
     * @throws CmsException if something goes wrong
     */
    public void importAccessControlEntries(CmsResource resource, List acEntries) throws CmsException {

        m_securityManager.importAccessControlEntries(m_context, resource, acEntries);
    }

    /**
     * Imports a resource to the OpenCms VFS.<p>
     * 
     * If a resource already exists in the VFS (i.e. has the same name and 
     * same id) it is replaced by the imported resource.<p>
     * 
     * If a resource with the same name but a different id exists, 
     * the imported resource is (usually) moved to the "lost and found" folder.<p> 
     *
     * @param resourcename the name for the resource after import (full path)
     * @param resource the resource object to be imported
     * @param content the content of the resource
     * @param properties the properties of the resource
     * 
     * @return the imported resource
     * 
     * @throws CmsException if something goes wrong
     * 
     * @see CmsObject#moveToLostAndFound(String)
     */
    public CmsResource importResource(String resourcename, CmsResource resource, byte[] content, List properties)
    throws CmsException {

        return getResourceType(resource.getTypeId()).importResource(
            this,
            m_securityManager,
            resourcename,
            resource,
            content,
            properties);
    }

    /**
     * Creates a new user by import.<p>
     * 
     * @param id the id of the user
     * @param name the new name for the user
     * @param password 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 address the address of the user
     * @param flags the flags for a user (for example <code>{@link I_CmsPrincipal#FLAG_ENABLED}</code>)
     * @param type the type of the user
     * @param additionalInfos the additional user infos
     * 
     * @return the imported user
     *
     * @throws CmsException if something goes wrong
     */
    public CmsUser importUser(
        String id,
        String name,
        String password,
        String description,
        String firstname,
        String lastname,
        String email,
        String address,
        int flags,
        int type,
        Map additionalInfos) throws CmsException {

        return m_securityManager.importUser(
            m_context,
            id,
            name,
            password,
            description,
            firstname,
            lastname,
            email,
            address,
            flags,
            type,
   

⌨️ 快捷键说明

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