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.ade.sitemap.shared.rpc;
029
030import org.opencms.ade.sitemap.shared.CmsClientSitemapEntry;
031import org.opencms.ade.sitemap.shared.CmsGalleryFolderEntry;
032import org.opencms.ade.sitemap.shared.CmsGalleryType;
033import org.opencms.ade.sitemap.shared.CmsLocaleComparePropertyData;
034import org.opencms.ade.sitemap.shared.CmsModelInfo;
035import org.opencms.ade.sitemap.shared.CmsModelPageEntry;
036import org.opencms.ade.sitemap.shared.CmsNewResourceInfo;
037import org.opencms.ade.sitemap.shared.CmsSitemapCategoryData;
038import org.opencms.ade.sitemap.shared.CmsSitemapChange;
039import org.opencms.ade.sitemap.shared.CmsSitemapData;
040import org.opencms.ade.sitemap.shared.CmsSitemapData.EditorMode;
041import org.opencms.gwt.CmsRpcException;
042import org.opencms.gwt.shared.alias.CmsAliasEditValidationReply;
043import org.opencms.gwt.shared.alias.CmsAliasEditValidationRequest;
044import org.opencms.gwt.shared.alias.CmsAliasImportResult;
045import org.opencms.gwt.shared.alias.CmsAliasInitialFetchResult;
046import org.opencms.gwt.shared.alias.CmsAliasSaveValidationRequest;
047import org.opencms.gwt.shared.alias.CmsRewriteAliasValidationReply;
048import org.opencms.gwt.shared.alias.CmsRewriteAliasValidationRequest;
049import org.opencms.gwt.shared.property.CmsPropertyModification;
050import org.opencms.util.CmsUUID;
051
052import java.util.List;
053import java.util.Map;
054
055import com.google.gwt.user.client.rpc.RemoteService;
056import com.google.gwt.user.client.rpc.SynchronizedRpcRequest;
057
058/**
059 * Handles all RPC services related to the sitemap.<p>
060 *
061 * @since 8.0.0
062 *
063 * @see org.opencms.ade.sitemap.CmsVfsSitemapService
064 * @see org.opencms.ade.sitemap.shared.rpc.I_CmsSitemapService
065 * @see org.opencms.ade.sitemap.shared.rpc.I_CmsSitemapServiceAsync
066 */
067public interface I_CmsSitemapService extends RemoteService {
068
069    /**
070     * Sets the name and title of the given category.<p>
071     *
072     * @param entryPoint the current entry point
073     * @param id the category id
074     * @param title the new title
075     * @param name the new name
076     * @throws CmsRpcException if something goes wrong
077     */
078    void changeCategory(String entryPoint, CmsUUID id, String title, String name) throws CmsRpcException;
079
080    /**
081     * Creates a new category.<p>
082     *
083     * @param entryPoint the entry point
084     * @param id the parent category id
085     * @param title the title
086     * @param name the category name
087     *
088     * @throws CmsRpcException if something goes wrong
089     */
090    void createCategory(String entryPoint, CmsUUID id, String title, String name) throws CmsRpcException;
091
092    /**
093     * Creates a new gallery folder.<p>
094     *
095     * @param parentFolder the parent folder path
096     * @param title the title property
097     * @param folderTypeId the resource type id
098     *
099     * @return the new gallery folder data
100     *
101     * @throws CmsRpcException if something goes wrong
102     */
103    CmsGalleryFolderEntry createNewGalleryFolder(String parentFolder, String title, int folderTypeId)
104    throws CmsRpcException;
105
106    /**
107     * Creates a new model page.<p>
108     *
109     * @param entryPointUri the uri of the entry point
110     * @param title the title for the model page
111     * @param description the description for the model page
112     * @param copyId the structure id of the resource to copy to create a new model page; if null, the model page is created as an empty container page
113     * @param isModelGroup <code>true</code> to create a new model group page
114     *
115     * @return a bean representing the created model page
116     * @throws CmsRpcException if something goes wrong
117     */
118    CmsModelPageEntry createNewModelPage(
119        String entryPointUri,
120        String title,
121        String description,
122        CmsUUID copyId,
123        boolean isModelGroup)
124    throws CmsRpcException;
125
126    /**
127     * Creates a sub-sitemap of the given sitemap starting from the given entry.<p>
128     *
129     * @param entryId the structure id of the sitemap entry to create a sub sitemap of
130     *
131     * @return the sub-sitemap creation result
132     *
133     * @throws CmsRpcException if something goes wrong
134     */
135    CmsSitemapChange createSubSitemap(CmsUUID entryId) throws CmsRpcException;
136
137    /**
138     * Sets the disabled flag of a model page within the current sitemap configuration.<p>
139     *
140     * @param baseUri the base uri for the current sitemap
141     * @param modelPageId structure id of the model page to remove
142     * @param disabled the disabled flag
143     *
144     * @throws CmsRpcException if something goes wrong
145     */
146    void disableModelPage(String baseUri, CmsUUID modelPageId, boolean disabled) throws CmsRpcException;
147
148    /**
149     * Gets the alias import results from the server.<p>
150     *
151     * @param resultKey the key which identifies the alias import results to get
152     * @return the list of alias import results
153     *
154     * @throws CmsRpcException if something goes wrong
155     */
156    List<CmsAliasImportResult> getAliasImportResult(String resultKey) throws CmsRpcException;
157
158    /**
159     * Gets the initial data for the bulk alias editor.<p>
160     *
161     * @return the initial data for the alias editor
162     *
163     * @throws CmsRpcException if something goes wrong
164     */
165    CmsAliasInitialFetchResult getAliasTable() throws CmsRpcException;
166
167    /**
168     * Gets the category data for the given entry point.<p>
169     *
170     * @param entryPoint the entry point
171     * @return the category data
172     *
173     * @throws CmsRpcException if something goes wrong
174     **/
175    CmsSitemapCategoryData getCategoryData(String entryPoint) throws CmsRpcException;
176
177    /**
178     * Returns the sitemap children for the given path.<p>
179     *
180     * @param entryPointUri the URI of the sitemap entry point
181     * @param entryId the entry id
182     * @param levels the count of child levels to read
183     *
184     * @return the sitemap children
185     *
186     * @throws CmsRpcException if something goes wrong
187     */
188    CmsClientSitemapEntry getChildren(String entryPointUri, CmsUUID entryId, int levels) throws CmsRpcException;
189
190    /**
191     * Returns the gallery data to this sub site.<p>
192     *
193     * @param entryPointUri the sub site folder
194     *
195     * @return the gallery data to this sub site
196     *
197     * @throws CmsRpcException if something goes wrong
198     */
199    Map<CmsGalleryType, List<CmsGalleryFolderEntry>> getGalleryData(String entryPointUri) throws CmsRpcException;
200
201    /**
202     * Gets the model pages for the given structure id of the sitemap root folder.<p>
203     *
204     * @param rootId structure id of a folder
205     * @return the model pages available in the given folder
206     *
207     * @throws CmsRpcException if something goes wrong
208     */
209    CmsModelInfo getModelInfos(CmsUUID rootId) throws CmsRpcException;
210
211    /**
212     * Loads the model page data for the "add" menu.<p>
213     *
214     * @param entryPointUri the entry point uri
215     * @return the list of resource info beans for the model pages
216     *
217     * @throws CmsRpcException if something goes wrong
218     */
219    List<CmsNewResourceInfo> getNewElementInfo(String entryPointUri) throws CmsRpcException;
220
221    /**
222     * Loads the data needed by the property editor in the locale comparison view.<p>
223     *
224     * @param id the id of the resource for which the property editor should be opened
225     * @param rootId the structure id of the resource which corresponds to the tree root in locale compare mode
226     *
227     * @return the property data for locale comparison mode
228     *
229     * @throws CmsRpcException if something goes wrong
230     */
231    CmsLocaleComparePropertyData loadPropertyDataForLocaleCompareView(CmsUUID id, CmsUUID rootId)
232    throws CmsRpcException;
233
234    /**
235     * Merges a sub-sitemap into it's parent sitemap.<p>
236     *
237     * @param entryPoint the sitemap entry point
238     * @param subSitemapId the structure id of the sub sitemap folder
239     *
240     * @return the result of the merge operation
241     *
242     * @throws CmsRpcException if something goes wrong
243     */
244    CmsSitemapChange mergeSubSitemap(String entryPoint, CmsUUID subSitemapId) throws CmsRpcException;
245
246    /**
247     * Returns the initialization data for the given sitemap.<p>
248     *
249     * @param sitemapUri the site relative path
250     *
251     * @return the initialization data
252     *
253     * @throws CmsRpcException if something goes wrong
254     */
255    CmsSitemapData prefetch(String sitemapUri) throws CmsRpcException;
256
257    /**
258     * Prepares sitemap reloading for the given sitemap root.<p>
259     *
260     * This method may change the currently set site root. If the given root id is not in a valid site,
261     * null will be returned, otherwise the URL which the client should use to reload the sitemap will be returned.
262     *
263     * @param rootId the structure id of the new sitemap root
264     * @param mode the new editor mode
265     *
266     * @return the URL which should be used to reload the sitemap
267     *
268     * @throws CmsRpcException if something goes wrong
269     */
270    String prepareReloadSitemap(CmsUUID rootId, EditorMode mode) throws CmsRpcException;
271
272    /**
273     * Removes a model page from the current sitemap configuration.<p>
274     *
275     * @param baseUri the base uri for the current sitemap
276     * @param modelPageId structure id of the model page to remove
277     *
278     * @throws CmsRpcException if something goes wrong
279     */
280    void removeModelPage(String baseUri, CmsUUID modelPageId) throws CmsRpcException;
281
282    /**
283     * Saves the change to the given sitemap.<p>
284     *
285     * @param sitemapUri the sitemap URI
286     * @param change the change to save
287     *
288     * @return the updated change
289     *
290     * @throws CmsRpcException if something goes wrong
291     */
292    CmsSitemapChange save(String sitemapUri, CmsSitemapChange change) throws CmsRpcException;
293
294    /**
295     * Saves the aliases for the bulk alias editor.<p>
296     *
297     * @param saveRequest the object containing the data to save
298     * @return the result of saving the aliases
299     *
300     * @throws CmsRpcException if something goes wrong
301     */
302    CmsAliasEditValidationReply saveAliases(CmsAliasSaveValidationRequest saveRequest) throws CmsRpcException;
303
304    /**
305     * Saves the changed properties in locale comparison mode.<p>
306     *
307     * @param id the structure id
308     * @param newUrlName the new URL name
309     * @param propertyChanges the property changes
310     * @param editedName true if the name was edited
311     *
312     * @throws CmsRpcException if something goes wrong
313     */
314    void savePropertiesForLocaleCompareMode(
315        CmsUUID id,
316        String newUrlName,
317        List<CmsPropertyModification> propertyChanges,
318        boolean editedName)
319    throws CmsRpcException;
320
321    /**
322     * Saves the change to the given sitemap.<p>
323     *
324     * @param sitemapUri the sitemap URI
325     * @param change the change to save
326     *
327     * @return the updated change
328     *
329     * @throws CmsRpcException if something goes wrong
330     */
331    @SynchronizedRpcRequest
332    CmsSitemapChange saveSync(String sitemapUri, CmsSitemapChange change) throws CmsRpcException;
333
334    /**
335     * Sets the default model page for the given sub-sitemap, returns the updated model info.<p>
336     *
337     * @param rootId structure id of the sub-sitemap root folder
338     * @param modelId the id of the model page to set as default
339     *
340     * @return the updated model info
341     *
342     * @throws CmsRpcException if something goes wrong
343     */
344    CmsModelInfo setDefaultModel(CmsUUID rootId, CmsUUID modelId) throws CmsRpcException;
345
346    /**
347     * Sets the editor mode in the current user session.<p>
348     *
349     * @param editorMode the editor mode to set
350     *
351     * @throws CmsRpcException in case something goes wrong
352     */
353    void setEditorMode(EditorMode editorMode) throws CmsRpcException;
354
355    /**
356     * Updates the alias editor status.<p>
357     *
358     * This is used to keep two users from editing the alias table for a site root concurrently.<p>
359     *
360     * @param editing true to indicate that the table is still being edited, false to indicate that the table isn't being edited anymore
361     *
362     * @throws CmsRpcException if something goes wrong
363     */
364    void updateAliasEditorStatus(boolean editing) throws CmsRpcException;
365
366    /**
367     * Validates the aliases for the bulk alias editor.<p>
368     *
369     * @param validationRequest an object indicating the type of validation to perform
370     * @return the validation result
371     *
372     * @throws CmsRpcException if something goes wrong
373     */
374    CmsAliasEditValidationReply validateAliases(CmsAliasEditValidationRequest validationRequest) throws CmsRpcException;
375
376    /**
377     * Validates rewrite aliases.<p>
378     *
379     * @param validationRequest the rewrite alias data to validate
380     * @return the validation result
381     *
382     * @throws CmsRpcException if something goes wrong
383     */
384    CmsRewriteAliasValidationReply validateRewriteAliases(CmsRewriteAliasValidationRequest validationRequest)
385    throws CmsRpcException;
386
387}