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