001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (C) Alkacon Software (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.ade.properties;
029
030import org.opencms.ade.properties.shared.I_CmsAdePropertiesConstants;
031import org.opencms.file.CmsObject;
032import org.opencms.file.CmsResource;
033import org.opencms.file.CmsResourceFilter;
034import org.opencms.gwt.CmsGwtActionElement;
035import org.opencms.gwt.shared.CmsCoreData;
036import org.opencms.main.OpenCms;
037
038import javax.servlet.http.HttpServletRequest;
039import javax.servlet.http.HttpServletResponse;
040import javax.servlet.jsp.PageContext;
041
042/**
043 * Action element class for opening the ADE properties dialog.<p>
044 */
045public class CmsPropertiesActionElement extends CmsGwtActionElement {
046
047    /** The OpenCms module name. */
048    public static final String CMS_MODULE_NAME = "org.opencms.ade.properties";
049
050    /** The GWT module name. */
051    public static final String GWT_MODULE_NAME = CmsCoreData.ModuleKey.properties.name();
052
053    /**
054     * Creates a new instance.<p>
055     *
056     * @param context the current page context
057     * @param req the request
058     * @param res the response
059     */
060    public CmsPropertiesActionElement(PageContext context, HttpServletRequest req, HttpServletResponse res) {
061
062        super(context, req, res);
063    }
064
065    /**
066     * @see org.opencms.gwt.CmsGwtActionElement#export()
067     */
068    @Override
069    public String export() throws Exception {
070
071        String resourcePath = getRequest().getParameter(I_CmsAdePropertiesConstants.PARAM_RESOURCE);
072        CmsObject cms = getCmsObject();
073        CmsResource resource = cms.readResource(resourcePath, CmsResourceFilter.IGNORE_EXPIRATION);
074        StringBuffer buffer = new StringBuffer();
075        buffer.append(exportMeta(I_CmsAdePropertiesConstants.META_RESOURCE, resource.getStructureId().toString()));
076        buffer.append(
077            exportMeta(
078                I_CmsAdePropertiesConstants.META_BACKLINK,
079                OpenCms.getLinkManager().substituteLinkForUnknownTarget(
080                    cms,
081                    "/system/workplace/views/explorer/explorer_files.jsp")));
082        return buffer.toString();
083    }
084
085    /**
086     * @see org.opencms.gwt.CmsGwtActionElement#exportAll()
087     */
088    @Override
089    public String exportAll() throws Exception {
090
091        StringBuffer buffer = new StringBuffer();
092        buffer.append(super.export());
093        buffer.append(export());
094        buffer.append(exportModuleScriptTag(GWT_MODULE_NAME));
095        return buffer.toString();
096    }
097
098}