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.CmsSitemapAttributeData;
038import org.opencms.ade.sitemap.shared.CmsSitemapCategoryData;
039import org.opencms.ade.sitemap.shared.CmsSitemapChange;
040import org.opencms.ade.sitemap.shared.CmsSitemapData;
041import org.opencms.ade.sitemap.shared.CmsSitemapData.EditorMode;
042import org.opencms.gwt.CmsRpcException;
043import org.opencms.gwt.shared.alias.CmsAliasEditValidationReply;
044import org.opencms.gwt.shared.alias.CmsAliasEditValidationRequest;
045import org.opencms.gwt.shared.alias.CmsAliasImportResult;
046import org.opencms.gwt.shared.alias.CmsAliasInitialFetchResult;
047import org.opencms.gwt.shared.alias.CmsAliasSaveValidationRequest;
048import org.opencms.gwt.shared.alias.CmsRewriteAliasValidationReply;
049import org.opencms.gwt.shared.alias.CmsRewriteAliasValidationRequest;
050import org.opencms.gwt.shared.property.CmsPropertyModification;
051import org.opencms.util.CmsUUID;
052
053import java.util.List;
054import java.util.Map;
055
056import com.google.gwt.user.client.rpc.RemoteService;
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     * Loads the data for the attribute editor dialog and locks the sitemap configuration.
150     *
151     * @param rootId the root ID of the current sitemap
152     * @return the data for the attribute editor dialog
153     * @throws CmsRpcException if something goes wrong
154     */
155    CmsSitemapAttributeData editAttributeData(CmsUUID rootId) throws CmsRpcException;
156
157    /**
158     * Gets the alias import results from the server.<p>
159     *
160     * @param resultKey the key which identifies the alias import results to get
161     * @return the list of alias import results
162     *
163     * @throws CmsRpcException if something goes wrong
164     */
165    List<CmsAliasImportResult> getAliasImportResult(String resultKey) throws CmsRpcException;
166
167    /**
168     * Gets the initial data for the bulk alias editor.<p>
169     *
170     * @return the initial data for the alias editor
171     *
172     * @throws CmsRpcException if something goes wrong
173     */
174    CmsAliasInitialFetchResult getAliasTable() throws CmsRpcException;
175
176    /**
177     * Gets the category data for the given entry point.<p>
178     *
179     * @param entryPoint the entry point
180     * @return the category data
181     *
182     * @throws CmsRpcException if something goes wrong
183     **/
184    CmsSitemapCategoryData getCategoryData(String entryPoint) throws CmsRpcException;
185
186    /**
187     * Returns the sitemap children for the given path.<p>
188     *
189     * @param entryPointUri the URI of the sitemap entry point
190     * @param entryId the entry id
191     * @param levels the count of child levels to read
192     *
193     * @return the sitemap children
194     *
195     * @throws CmsRpcException if something goes wrong
196     */
197    CmsClientSitemapEntry getChildren(String entryPointUri, CmsUUID entryId, int levels) throws CmsRpcException;
198
199    /**
200     * Returns the gallery data to this sub site.<p>
201     *
202     * @param entryPointUri the sub site folder
203     *
204     * @return the gallery data to this sub site
205     *
206     * @throws CmsRpcException if something goes wrong
207     */
208    Map<CmsGalleryType, List<CmsGalleryFolderEntry>> getGalleryData(String entryPointUri) throws CmsRpcException;
209
210    /**
211     * Gets the model pages for the given structure id of the sitemap root folder.<p>
212     *
213     * @param rootId structure id of a folder
214     * @return the model pages available in the given folder
215     *
216     * @throws CmsRpcException if something goes wrong
217     */
218    CmsModelInfo getModelInfos(CmsUUID rootId) throws CmsRpcException;
219
220    /**
221     * Loads the model page data for the "add" menu.<p>
222     *
223     * @param entryPointUri the entry point uri
224     * @return the list of resource info beans for the model pages
225     *
226     * @throws CmsRpcException if something goes wrong
227     */
228    List<CmsNewResourceInfo> getNewElementInfo(String entryPointUri) throws CmsRpcException;
229
230    /**
231     * Fetches the link for a resource selected in the sitemap editor.<p>
232     *
233     * @param baseId the structure id of the current sitemap root entry
234     * @param sitePath the site path of a resource
235     * @return the link to the resource
236     *
237     * @throws CmsRpcException if something goes wrong
238     */
239    String getResourceLink(CmsUUID baseId, String sitePath) throws CmsRpcException;
240
241    /**
242     * Loads the data needed by the property editor in the locale comparison view.<p>
243     *
244     * @param id the id of the resource for which the property editor should be opened
245     * @param rootId the structure id of the resource which corresponds to the tree root in locale compare mode
246     *
247     * @return the property data for locale comparison mode
248     *
249     * @throws CmsRpcException if something goes wrong
250     */
251    CmsLocaleComparePropertyData loadPropertyDataForLocaleCompareView(CmsUUID id, CmsUUID rootId)
252    throws CmsRpcException;
253
254    /**
255     * Merges a sub-sitemap into it's parent sitemap.<p>
256     *
257     * @param entryPoint the sitemap entry point
258     * @param subSitemapId the structure id of the sub sitemap folder
259     *
260     * @return the result of the merge operation
261     *
262     * @throws CmsRpcException if something goes wrong
263     */
264    CmsSitemapChange mergeSubSitemap(String entryPoint, CmsUUID subSitemapId) throws CmsRpcException;
265
266    /**
267     * Returns the initialization data for the given sitemap.<p>
268     *
269     * @param sitemapUri the site relative path
270     *
271     * @return the initialization data
272     *
273     * @throws CmsRpcException if something goes wrong
274     */
275    CmsSitemapData prefetch(String sitemapUri) throws CmsRpcException;
276
277    /**
278     * Prepares sitemap reloading for the given sitemap root.<p>
279     *
280     * This method may change the currently set site root. If the given root id is not in a valid site,
281     * null will be returned, otherwise the URL which the client should use to reload the sitemap will be returned.
282     *
283     * @param rootId the structure id of the new sitemap root
284     * @param mode the new editor mode
285     *
286     * @return the URL which should be used to reload the sitemap
287     *
288     * @throws CmsRpcException if something goes wrong
289     */
290    String prepareReloadSitemap(CmsUUID rootId, EditorMode mode) throws CmsRpcException;
291
292    /**
293     * Removes a model page from the current sitemap configuration.<p>
294     *
295     * @param baseUri the base uri for the current sitemap
296     * @param modelPageId structure id of the model page to remove
297     *
298     * @throws CmsRpcException if something goes wrong
299     */
300    void removeModelPage(String baseUri, CmsUUID modelPageId) throws CmsRpcException;
301
302    /**
303     * Saves the change to the given sitemap.<p>
304     *
305     * @param sitemapUri the sitemap URI
306     * @param change the change to save
307     *
308     * @return the updated change
309     *
310     * @throws CmsRpcException if something goes wrong
311     */
312    CmsSitemapChange save(String sitemapUri, CmsSitemapChange change) throws CmsRpcException;
313
314    /**
315     * Saves the aliases for the bulk alias editor.<p>
316     *
317     * @param saveRequest the object containing the data to save
318     * @return the result of saving the aliases
319     *
320     * @throws CmsRpcException if something goes wrong
321     */
322    CmsAliasEditValidationReply saveAliases(CmsAliasSaveValidationRequest saveRequest) throws CmsRpcException;
323
324    /**
325     * Saves the changed properties in locale comparison mode.<p>
326     *
327     * @param id the structure id
328     * @param newUrlName the new URL name
329     * @param propertyChanges the property changes
330     * @param editedName true if the name was edited
331     *
332     * @throws CmsRpcException if something goes wrong
333     */
334    void savePropertiesForLocaleCompareMode(
335        CmsUUID id,
336        String newUrlName,
337        List<CmsPropertyModification> propertyChanges,
338        boolean editedName)
339    throws CmsRpcException;
340
341    /**
342     * Saves the data from the sitemap attribute editor dialog to the sitemap configuration.
343     *
344     * @param rootId the root ID
345     * @param attributes the sitemap attributes
346     * @throws CmsRpcException if something goes wrong
347     */
348    void saveSitemapAttributes(CmsUUID rootId, Map<String, String> attributes) throws CmsRpcException;
349
350    /**
351     * Sets the default model page for the given sub-sitemap, returns the updated model info.<p>
352     *
353     * @param rootId structure id of the sub-sitemap root folder
354     * @param modelId the id of the model page to set as default
355     *
356     * @return the updated model info
357     *
358     * @throws CmsRpcException if something goes wrong
359     */
360    CmsModelInfo setDefaultModel(CmsUUID rootId, CmsUUID modelId) throws CmsRpcException;
361
362    /**
363     * Sets the editor mode in the current user session.<p>
364     *
365     * @param editorMode the editor mode to set
366     *
367     * @throws CmsRpcException in case something goes wrong
368     */
369    void setEditorMode(EditorMode editorMode) throws CmsRpcException;
370
371    /**
372     * Updates the alias editor status.<p>
373     *
374     * This is used to keep two users from editing the alias table for a site root concurrently.<p>
375     *
376     * @param editing true to indicate that the table is still being edited, false to indicate that the table isn't being edited anymore
377     *
378     * @throws CmsRpcException if something goes wrong
379     */
380    void updateAliasEditorStatus(boolean editing) throws CmsRpcException;
381
382    /**
383     * Validates the aliases for the bulk alias editor.<p>
384     *
385     * @param validationRequest an object indicating the type of validation to perform
386     * @return the validation result
387     *
388     * @throws CmsRpcException if something goes wrong
389     */
390    CmsAliasEditValidationReply validateAliases(CmsAliasEditValidationRequest validationRequest) throws CmsRpcException;
391
392    /**
393     * Validates rewrite aliases.<p>
394     *
395     * @param validationRequest the rewrite alias data to validate
396     * @return the validation result
397     *
398     * @throws CmsRpcException if something goes wrong
399     */
400    CmsRewriteAliasValidationReply validateRewriteAliases(CmsRewriteAliasValidationRequest validationRequest)
401    throws CmsRpcException;
402
403}