001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.workplace.editors.directedit;
029
030import org.opencms.file.CmsResource;
031import org.opencms.lock.CmsLock;
032
033/**
034 * Contains information about a resource that is direct edited.<p>
035 *
036 * For example, the information in this class allows implementations
037 * of a {@link I_CmsDirectEditProvider} to render HTML
038 * with extended information about the resource displayed on the buttons.<p>
039 *
040 * @since 6.2.3
041 */
042public class CmsDirectEditResourceInfo {
043
044    /** Constant for inactive permissions without further resource info. */
045    public static final CmsDirectEditResourceInfo INACTIVE = new CmsDirectEditResourceInfo(
046        CmsDirectEditPermissions.INACTIVE);
047
048    /** The lock on the direct edit resource. */
049    CmsLock m_lock;
050
051    /** The direct edit permissions of the resource. */
052    CmsDirectEditPermissions m_permissions;
053
054    /** The resource that is to be direct edited. */
055    CmsResource m_resource;
056
057    /**
058     * Creates a new direct edit resource info container without any
059     * specific information about the resource to be direct edited.<p>
060     *
061     * @param permissions the direct edit permissions of the resource
062     */
063    public CmsDirectEditResourceInfo(CmsDirectEditPermissions permissions) {
064
065        this(permissions, null, null);
066    }
067
068    /**
069     * Creates a new direct edit resource info container.<p>
070     *
071     * @param permissions the direct edit permissions of the resource
072     * @param resource the resource that is to be direct edited
073     * @param lock the lock on the direct edit resource
074     */
075    public CmsDirectEditResourceInfo(CmsDirectEditPermissions permissions, CmsResource resource, CmsLock lock) {
076
077        m_permissions = permissions;
078        m_resource = resource;
079        m_lock = lock;
080    }
081
082    /**
083     * Returns the lock on the direct edit resource.<p>
084     *
085     * This may be <code>null</code> in case the result is {@link #INACTIVE}.<p>
086     *
087     * @return the lock on the direct edit resource
088     */
089    public CmsLock getLock() {
090
091        return m_lock;
092    }
093
094    /**
095     * Returns the direct edit permissions of the resource.<p>
096     *
097     * The result is ensured not to be <code>null</code>.<p>
098     *
099     * @return the direct edit permissions of the resource
100     */
101    public CmsDirectEditPermissions getPermissions() {
102
103        return m_permissions;
104    }
105
106    /**
107     * Returns the resource that is to be direct edited.<p>
108     *
109     * This may be <code>null</code> in case the result is {@link #INACTIVE}.<p>
110     *
111     * @return the resource that is to be direct edited
112     */
113    public CmsResource getResource() {
114
115        return m_resource;
116    }
117}