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.ade.containerpage.shared.CmsDialogOptions;
031import org.opencms.file.CmsObject;
032import org.opencms.file.collectors.I_CmsCollectorPostCreateHandler;
033import org.opencms.main.CmsException;
034import org.opencms.util.CmsUUID;
035import org.opencms.xml.containerpage.CmsContainerElementBean;
036
037import java.util.Locale;
038import java.util.Map;
039
040/**
041 * Edit handlers are optional and can be configured within the XSD-schema of a resource type.<p>
042 * Edit handlers may be used to enhance content editing within the container page editor.
043 * They allow edit pre-processing, and specific delete operations.<p>
044 */
045public interface I_CmsEditHandler {
046
047    /**
048     * Returns a map of delete options. The value being the option description displayed to the user.<p>
049     *
050     * @param cms the cms context
051     * @param elementBean the container element to be deleted
052     * @param pageContextId the structure id of the context containerpage
053     * @param requestParams the request parameters
054     *
055     * @return the available delete options
056     */
057    CmsDialogOptions getDeleteOptions(
058        CmsObject cms,
059        CmsContainerElementBean elementBean,
060        CmsUUID pageContextId,
061        Map<String, String[]> requestParams);
062
063    /**
064     * Returns a map of edit options. The value being the option description displayed to the user.<p>
065     *
066     * @param cms the cms context
067     * @param elementBean the container element to be edited
068     * @param pageContextId the structure id of the context containerpage
069     * @param requestParams the request parameters
070     * @param isListElement in case a list element, not a container element is about to be edited
071     *
072     * @return the available edit options
073     */
074    CmsDialogOptions getEditOptions(
075        CmsObject cms,
076        CmsContainerElementBean elementBean,
077        CmsUUID pageContextId,
078        Map<String, String[]> requestParams,
079        boolean isListElement);
080
081    /**
082     * Gets the options for the 'New' (plus) operation in the page editor.<p>
083     *
084     * If this returns null, the default behavior for the 'New' operation will be used instead.
085     *
086     * @param cms the cms context
087     * @param elementBean the container element bean from which the 'New' operation was initiated
088     * @param pageContextId the structure id of the container page
089     * @param requestParam the request parameters
090     *
091     * @return the available options, or null if the default behavior should be used
092     */
093    CmsDialogOptions getNewOptions(
094        CmsObject cms,
095        CmsContainerElementBean elementBean,
096        CmsUUID pageContextId,
097        Map<String, String[]> requestParam);
098
099    /**
100     * Executes the actual delete.<p>
101     *
102     * @param cms the cms context
103     * @param elementBean the container element to delete
104     * @param deleteOption the selected delete option
105     * @param pageContextId the structure id of the context containerpage
106     * @param requestParams the request parameters
107     *
108     * @throws CmsException if something goes wrong
109     */
110    void handleDelete(
111        CmsObject cms,
112        CmsContainerElementBean elementBean,
113        String deleteOption,
114        CmsUUID pageContextId,
115        Map<String, String[]> requestParams)
116    throws CmsException;
117
118    /**
119     * Creates a new resource to edit.<p>
120     *
121     * @param cms The CmsObject of the current request
122     * @param newLink A string, specifying where which new content should be created.
123     * @param locale The locale
124     * @param referenceSitePath site path of the currently edited content.
125     * @param modelFileSitePath site path of the model file
126     * @param postCreateHandler optional class name of an {@link I_CmsCollectorPostCreateHandler} which is invoked after the content has been created.
127     * @param element the container element bean
128     * @param pageId the page id
129     * @param requestParams the request parameters
130     * @param choice the option chosen by the user
131     *
132     * @return The site-path of the newly created resource.
133     * @throws CmsException if something goes wrong
134     */
135    String handleNew(
136        CmsObject cms,
137        String newLink,
138        Locale locale,
139        String referenceSitePath,
140        String modelFileSitePath,
141        String postCreateHandler,
142        CmsContainerElementBean element,
143        CmsUUID pageId,
144        Map<String, String[]> requestParams,
145        String choice)
146    throws CmsException;
147
148    /**
149     * Prepares the resource to be edited.<p>
150     *
151     * @param cms the cms context
152     * @param elementBean the container element to be edited
153     * @param editOption the selected edit option
154     * @param pageContextId the structure id of the context containerpage
155     * @param requestParams the request parameters
156     *
157     * @return the structure id of the resource to be edited, may differ from the original element id
158     *
159     * @throws CmsException if something goes wrong
160     */
161    CmsUUID prepareForEdit(
162        CmsObject cms,
163        CmsContainerElementBean elementBean,
164        String editOption,
165        CmsUUID pageContextId,
166        Map<String, String[]> requestParams)
167    throws CmsException;
168
169    /**
170     * Sets parameters for the edit handler.<p>
171     *
172     * @param params the parameters
173     */
174    void setParameters(Map<String, String> params);
175
176}