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.gwt.shared.rpc;
029
030import org.opencms.gwt.CmsRpcException;
031import org.opencms.gwt.shared.CmsDeleteResourceBean;
032import org.opencms.gwt.shared.CmsExternalLinkInfoBean;
033import org.opencms.gwt.shared.CmsHistoryResourceCollection;
034import org.opencms.gwt.shared.CmsHistoryVersion;
035import org.opencms.gwt.shared.CmsListInfoBean;
036import org.opencms.gwt.shared.CmsLockReportInfo;
037import org.opencms.gwt.shared.CmsPrepareEditResponse;
038import org.opencms.gwt.shared.CmsPreviewInfo;
039import org.opencms.gwt.shared.CmsQuickLaunchData;
040import org.opencms.gwt.shared.CmsQuickLaunchParams;
041import org.opencms.gwt.shared.CmsRenameInfoBean;
042import org.opencms.gwt.shared.CmsReplaceInfo;
043import org.opencms.gwt.shared.CmsResourceStatusBean;
044import org.opencms.gwt.shared.CmsRestoreInfoBean;
045import org.opencms.gwt.shared.CmsVfsEntryBean;
046import org.opencms.gwt.shared.alias.CmsAliasBean;
047import org.opencms.gwt.shared.property.CmsPropertiesBean;
048import org.opencms.gwt.shared.property.CmsPropertyChangeSet;
049import org.opencms.util.CmsUUID;
050import org.opencms.xml.content.CmsXmlContentProperty;
051
052import java.util.ArrayList;
053import java.util.List;
054import java.util.Map;
055
056import com.google.gwt.core.shared.SerializableThrowable;
057import com.google.gwt.user.client.rpc.RemoteService;
058
059/**
060 * A service interface for retrieving information about the VFS tree.<p>
061 *
062 * @since 8.0.0
063 */
064public interface I_CmsVfsService extends RemoteService {
065
066    /**
067     * Creates a new external link resource.<p>
068     *
069     * @param title the title
070     * @param link the link
071     * @param resourceName the name of the link resource to create
072     * @param parentFolderPath the parent folder site path
073     *
074     * @throws CmsRpcException if something goes wrong
075     */
076    void createNewExternalLink(String title, String link, String resourceName, String parentFolderPath)
077    throws CmsRpcException;
078
079    /**
080     * Creates a new property definition.<p>
081     *
082     * @param propDef the name of the property
083     *
084     * @throws CmsRpcException if something goes wrong
085     */
086    void createPropertyDefinition(String propDef) throws CmsRpcException;
087
088    /**
089     * Deletes a resource from the VFS.<p>
090     *
091     * @param structureId the structure id of the resource to delete
092     *
093     * @throws CmsRpcException if something goes wrong
094     */
095    void deleteResource(CmsUUID structureId) throws CmsRpcException;
096
097    /**
098     * Deletes a resource from the VFS.<p>
099     *
100     * @param sitePath the site path of the resource to delete
101     *
102     * @throws CmsRpcException if something goes wrong
103     */
104    void deleteResource(String sitePath) throws CmsRpcException;
105
106    /**
107     * Forces a resource to be unlocked. In case the given resource is a folder, all sub-resources are also unlocked.<p>
108     *
109     * @param structureId the structure id of the resource to unlock
110     *
111     * @throws CmsRpcException if something goes wrong
112     */
113    void forceUnlock(CmsUUID structureId) throws CmsRpcException;
114
115    /**
116     * Fetches the aliases for a given page.<p>
117     *
118     * @param uuid the structure id of the page
119     *
120     * @return the lists of aliases for the page
121     *
122     * @throws CmsRpcException if something goes wrong
123     */
124    List<CmsAliasBean> getAliasesForPage(CmsUUID uuid) throws CmsRpcException;
125
126    /**
127     * Returns a list of potentially broken links, if the given resource was deleted.<p>
128     *
129     * @param structureId the resource structure id
130     *
131     * @return a list of potentially broken links
132     *
133     * @throws CmsRpcException if something goes wrong
134     */
135    CmsDeleteResourceBean getBrokenLinks(CmsUUID structureId) throws CmsRpcException;
136
137    /**
138     * Returns a list of potentially broken links, if the given resource was deleted.<p>
139     *
140     * @param sitePath the resource site-path
141     *
142     * @return a list of potentially broken links
143     *
144     * @throws CmsRpcException if something goes wrong
145     */
146    CmsDeleteResourceBean getBrokenLinks(String sitePath) throws CmsRpcException;
147
148    /**
149     * Fetches the list of children of a path.<p>
150     *
151     * @param path the path for which the list of children should be retrieved
152     *
153     * @return the children of the path
154     *
155     * @throws CmsRpcException if something goes wrong
156     */
157    List<CmsVfsEntryBean> getChildren(String path) throws CmsRpcException;
158
159    /**
160     * Loads a thumbnail for a dataview record.<p>
161     *
162     * @param config the dataview configuration string
163     * @param id the record id
164     *
165     * @return the URL of the thumbnail
166     * @throws CmsRpcException if something goes wrong
167     */
168    String getDataViewThumbnail(String config, String id) throws CmsRpcException;
169
170    /**
171     * Gets the default property configurations for the given structure ids.<p>
172     *
173     * @param structureIds the structure ids for which the property configurations should be fetched
174     * @return a map from the given structure ids to their default property configurations
175     *
176     * @throws CmsRpcException if something goes wrong
177     */
178    Map<CmsUUID, Map<String, CmsXmlContentProperty>> getDefaultProperties(List<CmsUUID> structureIds)
179    throws CmsRpcException;
180
181    /**
182     * Gets the names of defined properties.<p>
183     *
184     * @return the list of names for all defined properties
185     *
186     * @throws CmsRpcException if something goes wrong
187     */
188    ArrayList<String> getDefinedProperties() throws CmsRpcException;
189
190    /**
191     * Gets the detail name for the given structure id.
192     *
193     * @param id the structure id of a content
194     * @param locale the locale to use
195     * @return the detail name for the structure id
196     *
197     * @throws CmsRpcException if something goes wrong
198     */
199    String getDetailName(CmsUUID id, String locale) throws CmsRpcException;
200
201    /**
202     * Returns the file replace info.<p>
203     *
204     * @param structureId the structure id of the file to replace
205     *
206     * @return the file replace info
207     *
208     * @throws CmsRpcException if the RPC call goes wrong
209     */
210    CmsReplaceInfo getFileReplaceInfo(CmsUUID structureId) throws CmsRpcException;
211
212    /**
213     * Gets the preview information for a historic version.<p>
214     *
215     * @param structureId the structure id of the resource
216     * @param locale the locale
217     * @param version the version number
218     *
219     * @return the preview information for the historic resource version
220     *
221     * @throws CmsRpcException if something goes wrong
222     */
223    CmsPreviewInfo getHistoryPreviewInfo(CmsUUID structureId, String locale, CmsHistoryVersion version)
224    throws CmsRpcException;
225
226    /**
227     * Returns the lock report info.<p>
228     *
229     * @param structureId the structure id of the resource to get the report for
230     *
231     * @return the lock report info
232     *
233     * @throws CmsRpcException if something goes wrong
234     */
235    CmsLockReportInfo getLockReportInfo(CmsUUID structureId) throws CmsRpcException;
236
237    /**
238     * Returns a {@link CmsListInfoBean} for a given resource.<p>
239     *
240     * @param structureId the structure id to create the {@link CmsListInfoBean} for
241     *
242     * @return the {@link CmsListInfoBean} for a given resource
243     *
244     * @throws CmsRpcException if the RPC call goes wrong
245     */
246    CmsListInfoBean getPageInfo(CmsUUID structureId) throws CmsRpcException;
247
248    /**
249     * Returns a {@link CmsListInfoBean} for a given resource.<p>
250     *
251     * @param vfsPath the vfs path to create the {@link CmsListInfoBean} for
252     *
253     * @return the {@link CmsListInfoBean} for a given resource
254     *
255     * @throws CmsRpcException if the RPC call goes wrong
256     */
257    CmsListInfoBean getPageInfo(String vfsPath) throws CmsRpcException;
258
259    /**
260     * Returns the preview info for the given resource.<p>
261     *
262     * @param structureId the resource structure id
263     * @param locale the requested locale
264     *
265     * @return the preview info
266     *
267     * @throws CmsRpcException if something goes wrong
268     */
269    CmsPreviewInfo getPreviewInfo(CmsUUID structureId, String locale) throws CmsRpcException;
270
271    /**
272     * Returns the preview info for the given resource.<p>
273     *
274     * @param sitePath the resource site path
275     * @param locale the requested locale
276     *
277     * @return the preview info
278     *
279     * @throws CmsRpcException if something goes wrong
280     */
281    CmsPreviewInfo getPreviewInfo(String sitePath, String locale) throws CmsRpcException;
282
283    /***
284     * Gets the information necessary for the rename dialog.<p>
285     *
286     * @param structureId the structure id of the resource to rename
287     *
288     * @return the information needed for the rename dialog
289     *
290     * @throws CmsRpcException if something goes wrong
291     */
292    CmsRenameInfoBean getRenameInfo(CmsUUID structureId) throws CmsRpcException;
293
294    /**
295     * Gets the resource history for a given structure id.<p>
296     *
297     * @param structureId the structure id of a resource
298     * @return the history for the given resource
299     *
300     * @throws CmsRpcException if something goes wrong
301     */
302    CmsHistoryResourceCollection getResourceHistory(CmsUUID structureId) throws CmsRpcException;
303
304    /**
305     * Gets a bean containing status information for a given resource.<p>
306     *
307     * @param structureId the structure id of a resource
308     * @param locale the locale for which we want the resource information
309     * @param includeTargets true if relation targets should also be fetched
310     * @param detailContentId the structure id of the detail content if present
311     * @param context additional context-dependent parameters used for providing additional information
312     *
313     * @return the resource status
314     *
315     * @throws CmsRpcException if something goes wrong
316     */
317    CmsResourceStatusBean getResourceStatus(
318        CmsUUID structureId,
319        String locale,
320        boolean includeTargets,
321        CmsUUID detailContentId,
322        Map<String, String> context)
323    throws CmsRpcException;
324
325    /**
326     * Gets the information which is necessary for opening the 'Restore' dialog for a resource.<p>
327     *
328     * @param structureId the structure id of the resource
329     * @return the information for the resource
330     *
331     * @throws CmsRpcException if something goes wrong
332     */
333    CmsRestoreInfoBean getRestoreInfo(CmsUUID structureId) throws CmsRpcException;
334
335    /**
336     * Returns the root entries of the VFS.<p>
337     *
338     * @return a list of root entries
339     *
340     * @throws CmsRpcException if something goes wrong
341     */
342    List<CmsVfsEntryBean> getRootEntries() throws CmsRpcException;
343
344    /**
345     * Returns the site-path for the resource with the given id.<p>
346     *
347     * @param structureId the structure id
348     *
349     * @return the site-path or <code>null</code> if not available
350     *
351     * @throws CmsRpcException if something goes wrong
352     */
353    String getSitePath(CmsUUID structureId) throws CmsRpcException;
354
355    /**
356     * Gets the site paths corresponding to a list of structure ids.
357     *
358     * <p>If for any of the structure ids in the input list the corresponding resource can not be read, it will be skipped.
359     *
360     * @param ids a list of structure ids
361     * @return the list of paths corresponding to the structure ids
362     * @throws CmsRpcException
363     */
364    List<String> getSitePaths(List<CmsUUID> ids) throws CmsRpcException;
365
366    /**
367     * Gets the structure id for a given site path.
368     *
369     * @param vfsPath the site path
370     * @return the structure id
371     * @throws CmsRpcException if something goes wrong
372     */
373    CmsUUID getStructureId(String vfsPath) throws CmsRpcException;
374
375    /**
376     * Gets the resource info to display for an upload folder.
377     *
378     * @param path the folder path
379     * @return the info to display
380     * @throws CmsRpcException if something goes wrong
381     */
382    CmsListInfoBean getUploadFolderInfo(String path) throws CmsRpcException;
383
384    /**
385     * Loads the external link info.<p>
386     *
387     * @param structureId the external link structure id
388     *
389     * @return the external link info
390     *
391     * @throws CmsRpcException if something goes wrong
392     */
393    CmsExternalLinkInfoBean loadLinkInfo(CmsUUID structureId) throws CmsRpcException;
394
395    /**
396     * Load the data necessary to edit the properties of a resource.<p>
397     *
398     * @param id the structure id of a resource
399     * @return the property information for that resource
400     * @throws CmsRpcException if something goes wrong
401     */
402    CmsPropertiesBean loadPropertyData(CmsUUID id) throws CmsRpcException;
403
404    /**
405     * Loads the items for the quick launch menu.<p>
406     *
407     * @param params the quick launch parameters
408     *
409     * @return the list of quick launch items
410     *
411     * @throws CmsRpcException if something goes wrong
412     */
413    List<CmsQuickLaunchData> loadQuickLaunchItems(CmsQuickLaunchParams params) throws CmsRpcException;
414
415    /**
416     * Prepares to edit a file in the XML content editor.<p>
417     *
418     * @param currentPage the current page from which the editor should be opened
419     * @param fileNameWithMacros the file name, which may contain macros
420     *
421     * @return a bean with more information about the file to edit
422     * @throws CmsRpcException if something goes wrong
423     */
424    CmsPrepareEditResponse prepareEdit(CmsUUID currentPage, String fileNameWithMacros) throws CmsRpcException;
425
426    /**
427     * Renames a resource.<p>
428     *
429     * @param structureId the structure id of the resource to rename
430     * @param newName the new resource name
431     *
432     * @return null or an error message
433     *
434     * @throws CmsRpcException if something goes wrong
435     */
436    String renameResource(CmsUUID structureId, String newName) throws CmsRpcException;
437
438    /**
439     * Reverts a resource to a previous historic version.<p>
440     *
441     * @param structureId the structure id of the resource to revert
442     * @param version the version to which the resource should be reverted
443     *
444     * @throws CmsRpcException  if something goes wrong
445     */
446    void restoreResource(CmsUUID structureId, int version) throws CmsRpcException;
447
448    /**
449     * Saves aliases for a page.<p>
450     *
451     * @param structureId the structure id of the page
452     *
453     * @param aliases the aliases which should be saved for the page
454     * @throws CmsRpcException if something goes wrong
455     */
456    void saveAliases(CmsUUID structureId, List<CmsAliasBean> aliases) throws CmsRpcException;
457
458    /**
459     * Saves the external link.<p>
460     *
461     * @param structureId the link structure id
462     * @param title the link title
463     * @param link the link
464     * @param fileName the file name
465     *
466     * @throws CmsRpcException if something goes wrong
467     */
468    void saveExternalLink(CmsUUID structureId, String title, String link, String fileName) throws CmsRpcException;
469
470    /**
471     * Saves  a set of property changes.<p>
472     *
473     * @param changes a set of property changes
474     * @param updateIndex true if the index should be updated after saving the property changes
475     *
476     * @throws CmsRpcException if something goes wrong
477     */
478    void saveProperties(CmsPropertyChangeSet changes, boolean updateIndex) throws SerializableThrowable;
479
480    /**
481     * Returns the absolute link to the given root path.<p>
482     *
483     * @param currentSiteRoot the current site
484     * @param rootPath the root path
485     *
486     * @return the absolute link
487     *
488     * @throws CmsRpcException if something goes wrong processing the request
489     */
490    String substituteLinkForRootPath(String currentSiteRoot, String rootPath) throws CmsRpcException;
491
492    /**
493     * Deletes a resource from the VFS.<p>
494     *
495     * @param structureId the structure id of the resource to delete
496     *
497     * @throws CmsRpcException if something goes wrong
498     */
499    void syncDeleteResource(CmsUUID structureId) throws CmsRpcException;
500
501    /**
502     * Undeletes a resource.<p>
503     *
504     * @param structureId the structure id of the resource to undelete
505     *
506     * @throws CmsRpcException if something goes wrong
507     */
508    void undelete(CmsUUID structureId) throws CmsRpcException;
509
510    /**
511     * Undoes the changes to a given resource, i.e. restores its online content to its offline version.<p>
512     *
513     * @param structureId the structure id of the resource to undo
514     * @param undoMove true if move operations should be undone
515     *
516     * @throws CmsRpcException if something goes wrong
517     */
518    void undoChanges(CmsUUID structureId, boolean undoMove) throws CmsRpcException;
519
520    /**
521     * Validates alias paths for a page.<p>
522     *
523     * @param uuid the structure id of the page
524     * @param aliasPaths a map from (arbitrary) id strings to alias paths
525     *
526     * @return a map which maps the same id strings to validation results
527     *
528     * @throws CmsRpcException if something goes wrong
529     */
530    Map<String, String> validateAliases(CmsUUID uuid, Map<String, String> aliasPaths) throws CmsRpcException;
531
532}