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.containerpage.shared.rpc;
029
030import org.opencms.ade.containerpage.shared.CmsCntPageData;
031import org.opencms.ade.containerpage.shared.CmsContainer;
032import org.opencms.ade.containerpage.shared.CmsContainerElement;
033import org.opencms.ade.containerpage.shared.CmsContainerElementData;
034import org.opencms.ade.containerpage.shared.CmsContainerPageGalleryData;
035import org.opencms.ade.containerpage.shared.CmsContainerPageRpcContext;
036import org.opencms.ade.containerpage.shared.CmsCreateElementData;
037import org.opencms.ade.containerpage.shared.CmsDialogOptionsAndInfo;
038import org.opencms.ade.containerpage.shared.CmsElementSettingsConfig;
039import org.opencms.ade.containerpage.shared.CmsGroupContainer;
040import org.opencms.ade.containerpage.shared.CmsGroupContainerSaveResult;
041import org.opencms.ade.containerpage.shared.CmsInheritanceContainer;
042import org.opencms.ade.containerpage.shared.CmsRemovedElementStatus;
043import org.opencms.gwt.CmsRpcException;
044import org.opencms.util.CmsUUID;
045
046import java.util.Collection;
047import java.util.List;
048import java.util.Map;
049import java.util.Set;
050
051import com.google.gwt.user.client.rpc.RemoteService;
052
053/**
054 * The RPC service interface used by the container-page editor.<p>
055 *
056 * @since 8.0.0
057 */
058public interface I_CmsContainerpageService extends RemoteService {
059
060    /**
061     * Adds an element specified by it's id to the favorite list.<p>
062     *
063     * @param context the rpc context
064     * @param clientId the element id
065     *
066     * @throws CmsRpcException if something goes wrong processing the request
067     */
068    void addToFavoriteList(CmsContainerPageRpcContext context, String clientId) throws CmsRpcException;
069
070    /**
071     * Adds an element specified by it's id to the recent list.<p>
072     *
073     * @param context the rpc context
074     * @param clientId the element id
075     *
076     * @throws CmsRpcException if something goes wrong processing the request
077     */
078    void addToRecentList(CmsContainerPageRpcContext context, String clientId) throws CmsRpcException;
079
080    /**
081     * Check if a page or its elements have been changed.<p>
082     *
083     * @param structureId the structure id of the resource
084     * @param detailContentId the structure id of the detail content (may be null)
085     * @param contentLocale the content locale
086     *
087     * @return true if there were changes in the page or its elements
088     *
089     * @throws CmsRpcException if the RPC call fails
090     */
091    boolean checkContainerpageOrElementsChanged(CmsUUID structureId, CmsUUID detailContentId, String contentLocale)
092    throws CmsRpcException;
093
094    /**
095     * To create a new element of the given type this method will check if a model resource needs to be selected, otherwise creates the new element.
096     * Returns a bean containing either the new element data or a list of model resources to select.<p>
097     *
098     * @param pageStructureId the container page structure id
099     * @param clientId the client id of the new element (this will be the structure id of the configured new resource)
100     * @param resourceType the resource tape of the new element
101     * @param container the parent container
102     * @param locale the content locale
103     *
104     * @return the bean containing either the new element data or a list of model resources to select
105     *
106     * @throws CmsRpcException if something goes wrong processing the request
107     */
108    CmsCreateElementData checkCreateNewElement(
109        CmsUUID pageStructureId,
110        String clientId,
111        String resourceType,
112        CmsContainer container,
113        String locale)
114    throws CmsRpcException;
115
116    /**
117     * Checks whether the Acacia widgets are available for all fields of the content.<p>
118     *
119     * @param structureId the structure id of the content
120     * @return true if Acacia widgets are available for all fields
121     *
122     * @throws CmsRpcException if something goes wrong
123     */
124    boolean checkNewWidgetsAvailable(CmsUUID structureId) throws CmsRpcException;
125
126    /**
127     * Creates  a new element with a given model element and returns the copy'S structure id.<p>
128     *
129     * @param pageId the container page id
130     * @param originalElementId the model element id
131     * @param locale the content locale
132     *
133     * @return the structure id of the copy
134     *
135     * @throws CmsRpcException if something goes wrong
136     */
137    CmsUUID copyElement(CmsUUID pageId, CmsUUID originalElementId, String locale) throws CmsRpcException;
138
139    /**
140     * Creates a new element of the given type and returns the new element data containing structure id and site path.<p>
141     *
142     * @param pageStructureId the container page structure id
143     * @param clientId the client id of the new element (this will be the structure id of the configured new resource)
144     * @param resourceType the resource tape of the new element
145     * @param modelResourceStructureId the model resource structure id
146     * @param locale the content locale
147     *
148     * @return the new element data containing structure id and site path
149     *
150     * @throws CmsRpcException if something goes wrong processing the request
151     */
152    CmsContainerElement createNewElement(
153        CmsUUID pageStructureId,
154        String clientId,
155        String resourceType,
156        CmsUUID modelResourceStructureId,
157        String locale)
158    throws CmsRpcException;
159
160    /**
161     * This method is used for serialization purposes only.<p>
162     *
163     * @return container info
164     */
165    CmsContainer getContainerInfo();
166
167    /**
168     * Returns the delete options.<p>
169     *
170     * @param clientId the client element id
171     * @param pageStructureId the current page structure id
172     * @param requestParams optional request parameters
173     *
174     * @return the delete options
175     *
176     * @throws CmsRpcException in case something goes wrong
177     */
178    CmsDialogOptionsAndInfo getDeleteOptions(String clientId, CmsUUID pageStructureId, String requestParams)
179    throws CmsRpcException;
180
181    /**
182     * Returns the edit options.<p>
183     *
184     * @param clientId the client element id
185     * @param pageStructureId the current page structure id
186     * @param requestParams optional request parameters
187     * @param isListElement in case a list element, not a container element is about to be edited
188     *
189     * @return the edit options
190     *
191     * @throws CmsRpcException in case something goes wrong
192     */
193    CmsDialogOptionsAndInfo getEditOptions(
194        String clientId,
195        CmsUUID pageStructureId,
196        String requestParams,
197        boolean isListElement)
198    throws CmsRpcException;
199
200    /**
201     * This method is used for serialization purposes only.<p>
202     *
203     * @return element info
204     */
205    CmsContainerElement getElementInfo();
206
207    /**
208     * Returns container element data by client id.<p>
209     *
210     * @param  context the rpc context
211     * @param detailContentId the detail content structure id
212     * @param reqParams optional request parameters
213     * @param clientIds the requested element id's
214     * @param containers the containers of the current page
215     * @param alwaysCopy <code>true</code> in case reading data for a clipboard element used as a copy group
216     * @param dndSource the drag and drop source container (if we are getting the data for the drag and drop case)
217     * @param locale the content locale
218     *
219     * @return the element data
220     *
221     * @throws CmsRpcException if something goes wrong processing the request
222     */
223    Map<String, CmsContainerElementData> getElementsData(
224        CmsContainerPageRpcContext context,
225        CmsUUID detailContentId,
226        String reqParams,
227        Collection<String> clientIds,
228        Collection<CmsContainer> containers,
229        boolean alwaysCopy,
230        String dndSource,
231        String locale)
232    throws CmsRpcException;
233
234    /**
235     * Returns container element settings config data.<p>
236     *
237     * @param  context the rpc context
238     * @param clientId the requested element id
239     * @param containerId the parent container id
240     * @param containers the containers of the current page
241     * @param locale the content locale
242     *
243     * @return the element data
244     *
245     * @throws CmsRpcException if something goes wrong processing the request
246     */
247    CmsElementSettingsConfig getElementSettingsConfig(
248        CmsContainerPageRpcContext context,
249        String clientId,
250        String containerId,
251        Collection<CmsContainer> containers,
252        String locale)
253    throws CmsRpcException;
254
255    /**
256     * Checks which structure ids of a given set belong to resources locked for publishing by the current user, and then returns those.
257     *
258     * @param idsToCheck the set of ids to check
259     * @return the subset of ids which belong to resources locked for publishing by the current user
260     *
261     * @throws CmsRpcException if something goes wrong
262     */
263    Set<CmsUUID> getElementsLockedForPublishing(Set<CmsUUID> idsToCheck) throws CmsRpcException;
264
265    /**
266     * Gets the element data for an id and a map of settings.<p>
267     *
268     * @param context the RPC context
269     * @param detailContentId the detail content structure id
270     * @param reqParams optional request parameters
271     * @param clientId the requested element ids
272     * @param settings the settings for which the element data should be loaded
273     * @param containers the containers of the current page
274     * @param locale the content locale
275     *
276     * @return the element data
277     *
278     * @throws CmsRpcException if something goes wrong processing the request
279     */
280    CmsContainerElementData getElementWithSettings(
281        CmsContainerPageRpcContext context,
282        CmsUUID detailContentId,
283        String reqParams,
284        String clientId,
285        Map<String, String> settings,
286        Collection<CmsContainer> containers,
287        String locale)
288    throws CmsRpcException;
289
290    /**
291     * Returns the container element data of the favorite list.<p>
292     *
293     * @param pageStructureId the container page structure id
294     * @param detailContentId the detail content structure id
295     * @param containers the containers of the current page
296     * @param locale the content locale
297     *
298     * @return the favorite list element data
299     *
300     * @throws CmsRpcException if something goes wrong processing the request
301     */
302    List<CmsContainerElementData> getFavoriteList(
303        CmsUUID pageStructureId,
304        CmsUUID detailContentId,
305        Collection<CmsContainer> containers,
306        String locale)
307    throws CmsRpcException;
308
309    /**
310     * Returns the gallery configuration data according to the current page containers and the selected element view.<p>
311     *
312     * @param containers the page containers
313     * @param elementView the element view
314     * @param uri the page URI
315     * @param locale the content locale
316     *
317     * @return the gallery data
318     *
319     * @throws CmsRpcException in case something goes wrong
320     */
321    CmsContainerPageGalleryData getGalleryDataForPage(
322        List<CmsContainer> containers,
323        CmsUUID elementView,
324        String uri,
325        String locale)
326    throws CmsRpcException;
327
328    /**
329     * Returns new container element data for the given resource type name.<p>
330     *
331     * @param context the RPC context
332     * @param detailContentId the detail content structure id
333     * @param reqParams optional request parameters
334     * @param resourceType the requested element resource type name
335     * @param containers the containers of the current page
336     * @param locale the content locale
337     *
338     * @return the element data
339     *
340     * @throws CmsRpcException if something goes wrong processing the request
341     */
342    CmsContainerElementData getNewElementData(
343        CmsContainerPageRpcContext context,
344        CmsUUID detailContentId,
345        String reqParams,
346        String resourceType,
347        Collection<CmsContainer> containers,
348        String locale)
349    throws CmsRpcException;
350
351    /**
352     * Gets the edit handler options for creating a new element.<p>
353     *
354     * @param clientId the client id of the selected element
355     * @param pageStructureId the container page structure id
356     * @param requestParams the request parameter string
357     *
358     * @return the dialog option data from the edit handler
359     * @throws CmsRpcException if something goes wrong
360     */
361    CmsDialogOptionsAndInfo getNewOptions(String clientId, CmsUUID pageStructureId, String requestParams)
362    throws CmsRpcException;
363
364    /**
365     * Returns the container element data of the recent list.<p>
366     *
367     * @param pageStructureId the container page structure id
368     * @param detailContentId the detail content structure id
369     * @param containers the containers of the current page
370     * @param locale the content locale
371     *
372     * @return the recent list element data
373     *
374     * @throws CmsRpcException if something goes wrong processing the request
375     */
376    List<CmsContainerElementData> getRecentList(
377        CmsUUID pageStructureId,
378        CmsUUID detailContentId,
379        Collection<CmsContainer> containers,
380        String locale)
381    throws CmsRpcException;
382
383    /**
384     * Gets the status of a removed element.<p>
385     *
386     * @param id the client id of the removed element
387     * @param containerpageId the id of the page which should be excluded from the relation check, or null if no page should be excluded
388     *
389     * @return the status of the removed element
390     *
391     * @throws CmsRpcException if something goes wrong
392     */
393    CmsRemovedElementStatus getRemovedElementStatus(String id, CmsUUID containerpageId) throws CmsRpcException;
394
395    /**
396     * Handles the element deletion.<p>
397     *
398     * @param clientId the client element id
399     * @param deleteOption the selected delete option
400     * @param pageStructureId the current page structure id
401     * @param requestParams optional request parameters
402     *
403     * @throws CmsRpcException in case something goes wrong
404     */
405    void handleDelete(String clientId, String deleteOption, CmsUUID pageStructureId, String requestParams)
406    throws CmsRpcException;
407
408    /**
409     * Loads the index of the clipboard tab last selected by the user.<p>
410     *
411     * @return the clipboard tab index
412     */
413    int loadClipboardTab();
414
415    /**
416     * Returns the initialization data.<p>
417     *
418     * @return the initialization data
419     *
420     * @throws CmsRpcException if something goes wrong
421     */
422    CmsCntPageData prefetch() throws CmsRpcException;
423
424    /**
425     * Prepares an element to be edited.<p>
426     *
427     * @param clientId the client element id
428     * @param editOption the selected delete option
429     * @param pageStructureId the current page structure id
430     * @param requestParams optional request parameters
431     *
432     * @return the structure ID of the content to edit
433     *
434     * @throws CmsRpcException in case something goes wrong
435     */
436    CmsUUID prepareForEdit(String clientId, String editOption, CmsUUID pageStructureId, String requestParams)
437    throws CmsRpcException;
438
439    /**
440     * Returns the element data to replace a given content element with another while keeping it's settings.<p>
441     *
442     * @param  context the rpc context
443     * @param detailContentId the detail content structure id
444     * @param reqParams optional request parameters
445     * @param clientId the id of the element to replace
446     * @param replaceId the id of the replacing element
447     * @param containers the containers of the current page
448     * @param locale the content locale
449     *
450     * @return the element data
451     *
452     * @throws CmsRpcException if something goes wrong processing the request
453     */
454    CmsContainerElementData replaceElement(
455        CmsContainerPageRpcContext context,
456        CmsUUID detailContentId,
457        String reqParams,
458        String clientId,
459        String replaceId,
460        Collection<CmsContainer> containers,
461        String locale)
462    throws CmsRpcException;
463
464    /**
465     * Saves the index of the clipboard tab selected by the user.<p>
466     *
467     * @param tabIndex the index of the selected clipboard tab
468     */
469    void saveClipboardTab(int tabIndex);
470
471    /**
472     * Saves the container-page.<p>
473     *
474     * @param pageStructureId the container page structure id
475     * @param containers the container-page's containers
476     *
477     * @return the server time stamp of time of saving
478     *
479     * @throws CmsRpcException if something goes wrong processing the request
480     */
481    long saveContainerpage(CmsUUID pageStructureId, List<CmsContainer> containers) throws CmsRpcException;
482
483    /**
484     * Saves the detail containers.<p>
485     *
486     * @param detailId the detail content id
487     * @param detailContainerResource the detail container resource path
488     * @param containers the container-page's containers
489     *
490     * @return the server time stamp of time of saving
491     *
492     * @throws CmsRpcException if something goes wrong processing the request
493     */
494    long saveDetailContainers(CmsUUID detailId, String detailContainerResource, List<CmsContainer> containers)
495    throws CmsRpcException;
496
497    /**
498     * Saves the settings for the given element to the container page and returns the updated element data.<p>
499     *
500     * @param context the RPC context
501     * @param detailContentId the detail content structure id
502     * @param reqParams optional request parameters
503     * @param clientId the requested element ids
504     * @param settings the settings for which the element data should be loaded
505     * @param containers the containers of the current page
506     * @param locale the content locale
507     * @return the element data
508     *
509     * @throws CmsRpcException if something goes wrong processing the request
510     */
511    CmsContainerElementData saveElementSettings(
512        CmsContainerPageRpcContext context,
513        CmsUUID detailContentId,
514        String reqParams,
515        String clientId,
516        Map<String, String> settings,
517        List<CmsContainer> containers,
518        String locale)
519    throws CmsRpcException;
520
521    /**
522     * Saves the favorite list.<p>
523     *
524     * @param clientIds favorite list element id's
525     * @param uri the container page URI
526     *
527     * @throws CmsRpcException if something goes wrong processing the request
528     */
529    void saveFavoriteList(List<String> clientIds, String uri) throws CmsRpcException;
530
531    /**
532     * Saves a group-container element.<p>
533     *
534     * @param context the RPC context
535     * @param detailContentId the detail content structure id
536     * @param reqParams optional request parameters
537     * @param groupContainer the group-container to save
538     * @param containers the containers of the current page
539     * @param locale the content locale
540     *
541     * @return the data of the saved group container
542     *
543     * @throws CmsRpcException if something goes wrong processing the request
544     */
545    CmsGroupContainerSaveResult saveGroupContainer(
546        CmsContainerPageRpcContext context,
547        CmsUUID detailContentId,
548        String reqParams,
549        CmsGroupContainer groupContainer,
550        Collection<CmsContainer> containers,
551        String locale)
552    throws CmsRpcException;
553
554    /**
555     * Saves an inheritance container.<p>
556     *
557     * @param pageStructureId the current page's structure id
558     * @param detailContentId the detail content structure id
559     * @param inheritanceContainer the inheritance container to save
560     * @param containers the containers of the current page
561     * @param locale the requested locale
562     *
563     * @return the element data of the saved container
564     *
565     * @throws CmsRpcException if something goes wrong
566     */
567    Map<String, CmsContainerElementData> saveInheritanceContainer(
568        CmsUUID pageStructureId,
569        CmsUUID detailContentId,
570        CmsInheritanceContainer inheritanceContainer,
571        Collection<CmsContainer> containers,
572        String locale)
573    throws CmsRpcException;
574
575    /**
576     * Saves the recent list.<p>
577     *
578     * @param clientIds recent list element id's
579     * @param uri the container page URI
580     *
581     * @throws CmsRpcException if something goes wrong processing the request
582     */
583    void saveRecentList(List<String> clientIds, String uri) throws CmsRpcException;
584
585    /**
586     * Enables or disables editing for small elements on page load.<p>
587     *
588     * @param editSmallElements the defautl setting for the small element editability
589     *
590     * @throws CmsRpcException if something goes wrong
591     */
592    void setEditSmallElements(boolean editSmallElements) throws CmsRpcException;
593
594    /**
595     * Sets the element view.<p>
596     *
597     * @param elementView the element view
598     *
599     * @throws CmsRpcException if something goes wrong processing the request
600     */
601    void setElementView(CmsUUID elementView) throws CmsRpcException;
602
603    /**
604     * Stores information about the container page last edited.<p>
605     *
606     * @param pageId the page id
607     * @param detailId the detail content id
608     *
609     * @throws CmsRpcException if something goes wrong
610     */
611    void setLastPage(CmsUUID pageId, CmsUUID detailId) throws CmsRpcException;
612}