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 structure id for a given site path.
356     *
357     * @param vfsPath the site path
358     * @return the structure id
359     * @throws CmsRpcException if something goes wrong
360     */
361    CmsUUID getStructureId(String vfsPath) throws CmsRpcException;
362
363    /**
364     * Gets the resource info to display for an upload folder.
365     *
366     * @param path the folder path
367     * @return the info to display
368     * @throws CmsRpcException if something goes wrong
369     */
370    CmsListInfoBean getUploadFolderInfo(String path) throws CmsRpcException;
371
372    /**
373     * Loads the external link info.<p>
374     *
375     * @param structureId the external link structure id
376     *
377     * @return the external link info
378     *
379     * @throws CmsRpcException if something goes wrong
380     */
381    CmsExternalLinkInfoBean loadLinkInfo(CmsUUID structureId) throws CmsRpcException;
382
383    /**
384     * Load the data necessary to edit the properties of a resource.<p>
385     *
386     * @param id the structure id of a resource
387     * @return the property information for that resource
388     * @throws CmsRpcException if something goes wrong
389     */
390    CmsPropertiesBean loadPropertyData(CmsUUID id) throws CmsRpcException;
391
392    /**
393     * Loads the items for the quick launch menu.<p>
394     *
395     * @param params the quick launch parameters
396     *
397     * @return the list of quick launch items
398     *
399     * @throws CmsRpcException if something goes wrong
400     */
401    List<CmsQuickLaunchData> loadQuickLaunchItems(CmsQuickLaunchParams params) throws CmsRpcException;
402
403    /**
404     * Prepares to edit a file in the XML content editor.<p>
405     *
406     * @param currentPage the current page from which the editor should be opened
407     * @param fileNameWithMacros the file name, which may contain macros
408     *
409     * @return a bean with more information about the file to edit
410     * @throws CmsRpcException if something goes wrong
411     */
412    CmsPrepareEditResponse prepareEdit(CmsUUID currentPage, String fileNameWithMacros) throws CmsRpcException;
413
414    /**
415     * Renames a resource.<p>
416     *
417     * @param structureId the structure id of the resource to rename
418     * @param newName the new resource name
419     *
420     * @return null or an error message
421     *
422     * @throws CmsRpcException if something goes wrong
423     */
424    String renameResource(CmsUUID structureId, String newName) throws CmsRpcException;
425
426    /**
427     * Reverts a resource to a previous historic version.<p>
428     *
429     * @param structureId the structure id of the resource to revert
430     * @param version the version to which the resource should be reverted
431     *
432     * @throws CmsRpcException  if something goes wrong
433     */
434    void restoreResource(CmsUUID structureId, int version) throws CmsRpcException;
435
436    /**
437     * Saves aliases for a page.<p>
438     *
439     * @param structureId the structure id of the page
440     *
441     * @param aliases the aliases which should be saved for the page
442     * @throws CmsRpcException if something goes wrong
443     */
444    void saveAliases(CmsUUID structureId, List<CmsAliasBean> aliases) throws CmsRpcException;
445
446    /**
447     * Saves the external link.<p>
448     *
449     * @param structureId the link structure id
450     * @param title the link title
451     * @param link the link
452     * @param fileName the file name
453     *
454     * @throws CmsRpcException if something goes wrong
455     */
456    void saveExternalLink(CmsUUID structureId, String title, String link, String fileName) throws CmsRpcException;
457
458    /**
459     * Saves  a set of property changes.<p>
460     *
461     * @param changes a set of property changes
462     * @param updateIndex true if the index should be updated after saving the property changes
463     *
464     * @throws CmsRpcException if something goes wrong
465     */
466    void saveProperties(CmsPropertyChangeSet changes, boolean updateIndex) throws CmsRpcException;
467
468    /**
469     * Returns the absolute link to the given root path.<p>
470     *
471     * @param currentSiteRoot the current site
472     * @param rootPath the root path
473     *
474     * @return the absolute link
475     *
476     * @throws CmsRpcException if something goes wrong processing the request
477     */
478    String substituteLinkForRootPath(String currentSiteRoot, String rootPath) throws CmsRpcException;
479
480    /**
481     * Deletes a resource from the VFS.<p>
482     *
483     * @param structureId the structure id of the resource to delete
484     *
485     * @throws CmsRpcException if something goes wrong
486     */
487    void syncDeleteResource(CmsUUID structureId) throws CmsRpcException;
488
489    /**
490     * Undeletes a resource.<p>
491     *
492     * @param structureId the structure id of the resource to undelete
493     *
494     * @throws CmsRpcException if something goes wrong
495     */
496    void undelete(CmsUUID structureId) throws CmsRpcException;
497
498    /**
499     * Undoes the changes to a given resource, i.e. restores its online content to its offline version.<p>
500     *
501     * @param structureId the structure id of the resource to undo
502     * @param undoMove true if move operations should be undone
503     *
504     * @throws CmsRpcException if something goes wrong
505     */
506    void undoChanges(CmsUUID structureId, boolean undoMove) throws CmsRpcException;
507
508    /**
509     * Validates alias paths for a page.<p>
510     *
511     * @param uuid the structure id of the page
512     * @param aliasPaths a map from (arbitrary) id strings to alias paths
513     *
514     * @return a map which maps the same id strings to validation results
515     *
516     * @throws CmsRpcException if something goes wrong
517     */
518    Map<String, String> validateAliases(CmsUUID uuid, Map<String, String> aliasPaths) throws CmsRpcException;
519
520}