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;
029
030import org.opencms.configuration.CmsConfigurationManager;
031import org.opencms.file.CmsObject;
032import org.opencms.main.CmsException;
033import org.opencms.main.OpenCms;
034import org.opencms.module.A_CmsModuleAction;
035import org.opencms.module.CmsModule;
036
037/**
038 * The workplace manager class to get the admin CmsObject.<p>
039 *
040 * @since 7.5.0
041 */
042public class CmsWorkplaceAction extends A_CmsModuleAction {
043
044    /** The initialized singleton login manager instance. */
045    private static CmsWorkplaceAction m_instance;
046
047    /** The CmsObject initialized as an administrator during startup. */
048    private CmsObject m_cmsAdmin;
049
050    /**
051     * Constructor for a photo album manager object.<p>
052     *
053     */
054    public CmsWorkplaceAction() {
055
056        // nothing has to be done here
057    }
058
059    /**
060     * Returns the instance of the login manager to use.<p>
061     *
062     * @return the instance of the login manager to use
063     */
064    public static synchronized CmsWorkplaceAction getInstance() {
065
066        if (m_instance == null) {
067            m_instance = new CmsWorkplaceAction();
068        }
069        return m_instance;
070    }
071
072    /**
073     * Gets the admin cmsObject.<p>
074     *
075     * @return Admin cmsObject
076     *
077     * @throws CmsException is something goes wrong
078     */
079    public CmsObject getCmsAdminObject() throws CmsException {
080
081        return OpenCms.initCmsObject(m_cmsAdmin);
082    }
083
084    /**
085     * @see org.opencms.module.A_CmsModuleAction#initialize(org.opencms.file.CmsObject, org.opencms.configuration.CmsConfigurationManager, org.opencms.module.CmsModule)
086     */
087    @Override
088    public void initialize(CmsObject adminCms, CmsConfigurationManager configurationManager, CmsModule module) {
089
090        super.initialize(adminCms, configurationManager, module);
091
092        // set the CmsObject initialized as an administrator at the only existing instance
093        m_cmsAdmin = adminCms;
094        m_instance = this;
095    }
096}