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.db.CmsResourceState;
031import org.opencms.gwt.shared.CmsBroadcastMessage;
032import org.opencms.gwt.shared.CmsCategoryTreeEntry;
033import org.opencms.gwt.shared.CmsContextMenuEntryBean;
034import org.opencms.gwt.shared.CmsCoreData;
035import org.opencms.gwt.shared.CmsCoreData.AdeContext;
036import org.opencms.gwt.shared.CmsCoreData.UserInfo;
037import org.opencms.gwt.shared.CmsResourceCategoryInfo;
038import org.opencms.gwt.shared.CmsReturnLinkInfo;
039import org.opencms.gwt.shared.CmsUserSettingsBean;
040import org.opencms.gwt.shared.CmsValidationQuery;
041import org.opencms.gwt.shared.CmsValidationResult;
042import org.opencms.util.CmsUUID;
043
044import java.util.List;
045import java.util.Map;
046import java.util.Set;
047
048import com.google.gwt.user.client.rpc.AsyncCallback;
049import com.google.gwt.user.client.rpc.SynchronizedRpcRequest;
050
051/**
052 * Provides general core services.<p>
053 *
054 * @since 8.0.0
055 *
056 * @see org.opencms.gwt.CmsCoreService
057 * @see org.opencms.gwt.shared.rpc.I_CmsCoreService
058 * @see org.opencms.gwt.shared.rpc.I_CmsCoreServiceAsync
059 */
060public interface I_CmsCoreServiceAsync {
061
062    /**
063    * Changes the password of the current user.<p>
064    *
065    * @param oldPassword the old password
066    * @param newPassword the value entered for the new password
067    * @param newPasswordConfirm the value entered for the confirmation of the new password
068    *
069    * @param callback the callback for the result
070    */
071    void changePassword(
072        String oldPassword,
073        String newPassword,
074        String newPasswordConfirm,
075        AsyncCallback<String> callback);
076
077    /**
078     * Creates a new UUID.<p>
079     *
080     * @param callback the async callback
081     */
082    void createUUID(AsyncCallback<CmsUUID> callback);
083
084    /**
085     * Returns the latest messages for the current user.<p>
086     *
087     * @param callback the async callback
088     */
089    void getBroadcast(AsyncCallback<List<CmsBroadcastMessage>> callback);
090
091    /**
092     * Returns the categories for the given search parameters.<p>
093     *
094     * @param fromCatPath the category path to start with, can be <code>null</code> or empty to use the root
095     * @param includeSubCats if to include all categories, or first level child categories only
096     * @param refVfsPath the reference path (site-relative path according to which the available category repositories are determined),
097     *        can be <code>null</code> to only use the system repository
098     * @param callback the async callback
099     */
100    void getCategories(
101        String fromCatPath,
102        boolean includeSubCats,
103        String refVfsPath,
104        AsyncCallback<List<CmsCategoryTreeEntry>> callback);
105
106    /**
107     * Returns the categories for the given search parameters.<p>
108     *
109     * @param fromCatPath the category path to start with, can be <code>null</code> or empty to use the root
110     * @param includeSubCats if to include all categories, or first level child categories only
111     * @param refVfsPath the reference path (site-relative path according to which the available category repositories are determined),
112     *        can be <code>null</code> to only use the system repository
113     * @param withRepositories flag, indicating if also the category repositories should be returned as category
114     * @param callback the async callback
115     */
116    void getCategories(
117        String fromCatPath,
118        boolean includeSubCats,
119        String refVfsPath,
120        boolean withRepositories,
121        AsyncCallback<List<CmsCategoryTreeEntry>> callback);
122
123    /**
124     * Returns the categories for the given reference site-path.<p>
125     *
126     * @param sitePath the reference site-path
127     * @param callback the async callback
128     */
129    void getCategoriesForSitePath(String sitePath, AsyncCallback<List<CmsCategoryTreeEntry>> callback);
130
131    /**
132     * Returns the category information for the given resource.<p>
133     *
134     * @param structureId the resource structure id
135     * @param callback the callback which receives the result
136     */
137    void getCategoryInfo(CmsUUID structureId, AsyncCallback<CmsResourceCategoryInfo> callback);
138
139    /**
140     * Returns a list of menu entry beans for the context menu.<p>
141     *
142     * @param structureId the structure id of the resource for which to get the context menu
143     * @param context the ade context (sitemap or containerpage)
144     * @param callback the asynchronous callback
145     */
146    void getContextMenuEntries(
147        CmsUUID structureId,
148        AdeContext context,
149        AsyncCallback<List<CmsContextMenuEntryBean>> callback);
150
151    /**
152     * Returns a list of menu entry beans for the context menu.<p>
153     *
154     * @param structureId the structure id of the resource for which to get the context menu
155     * @param context the ade context (sitemap or containerpage)
156     * @param params additional context information that the server side can use to decide menu item availability
157     * @param callback the asynchronous callback
158     */
159    void getContextMenuEntries(
160        CmsUUID structureId,
161        AdeContext context,
162        Map<String, String> params,
163        AsyncCallback<List<CmsContextMenuEntryBean>> callback);
164
165    /**
166     * Given a return code, returns the link to the page which corresponds to the return code.<p>
167     *
168     * @param returnCode the return code
169     * @param callback the asynchronous callback
170     */
171    void getLinkForReturnCode(String returnCode, AsyncCallback<CmsReturnLinkInfo> callback);
172
173    /**
174     * Gets the resource state of a resource.<p>
175     *
176     * @param structureId the structure id of the resource
177     * @param callback the callback which receives the result
178     */
179    void getResourceState(CmsUUID structureId, AsyncCallback<CmsResourceState> callback);
180
181    /**
182     * Returns a unique filename for the given base name and the parent folder.<p>
183     *
184     * This is executed in a synchronized request.<p>
185     *
186     * @param parentFolder the parent folder of the file
187     * @param baseName the proposed file name
188     * @param callback the callback which receives the result
189     */
190    void getUniqueFileName(String parentFolder, String baseName, AsyncCallback<String> callback);
191
192    /**
193     * Returns the user info.<p>
194     *
195     * @param callback the callback
196     */
197    void getUserInfo(AsyncCallback<UserInfo> callback);
198
199    /**
200     * Returns a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the
201     * site of the given explorerRootPath and show the folder given in the explorerRootPath.<p>
202     *
203     * @param structureId the structure id of the resource for which to open the workplace
204     * @param callback the callback which receives the result
205     */
206    void getWorkplaceLink(CmsUUID structureId, AsyncCallback<String> callback);
207
208    /**
209     * Gets the workplace link for the given path.
210     *
211     * @param path the path
212     * @param action the callback for the result
213     */
214    void getWorkplaceLinkForPath(String path, AsyncCallback<String> action);
215
216    /**
217     * Loads the user settings for the current user.<p>
218     *
219     * @param callback the callback to call with the result
220     */
221    void loadUserSettings(AsyncCallback<CmsUserSettingsBean> callback);
222
223    /**
224     * Locks the given resource with a temporary lock if it exists.<p>
225     * If the resource does not exist yet, the closest existing ancestor folder will check if it is lockable.<p>
226     *
227     * @param sitePath the site path of the resource to lock
228     * @param callback the async callback
229     */
230    void lockIfExists(String sitePath, AsyncCallback<String> callback);
231
232    /**
233     * Locks the given resource with a temporary lock if it exists.<p>
234     * If the resource does not exist yet, the closest existing ancestor folder will check if it is lockable.<p>
235     *
236     * @param sitePath the site path of the resource to lock
237     * @param loadTime the time when the requested resource was loaded
238     * @param callback the async callback
239     */
240    void lockIfExists(String sitePath, long loadTime, AsyncCallback<String> callback);
241
242    /**
243     * Locks the given resource with a temporary lock.<p>
244     *
245     * @param structureId the resource structure id
246     * @param callback the async callback
247     */
248    void lockTemp(CmsUUID structureId, AsyncCallback<String> callback);
249
250    /**
251     * Locks the given resource with a temporary lock.<p>
252     * Locking will fail in case the requested resource has been changed since the given load time.<p>
253     *
254     * @param structureId the resource structure id
255     * @param loadTime the time when the requested resource was loaded
256     * @param callback the async callback
257     */
258    void lockTemp(CmsUUID structureId, long loadTime, AsyncCallback<String> callback);
259
260    /**
261     * Generates core data for prefetching in the host page.<p>
262     *
263     * @param callback the async callback
264     */
265    void prefetch(AsyncCallback<CmsCoreData> callback);
266
267    /**
268     * Saves the user settings for the current user.<p>
269     *
270     * @param userSettings the new values for the user settings
271     * @param edited the keys of the user settings which were actually edited
272     * @param resultCallback the callback to call when the operation has finished
273     */
274    void saveUserSettings(Map<String, String> userSettings, Set<String> edited, AsyncCallback<Void> resultCallback);
275
276    /**
277     * Sets the categories of the given resource. Will remove all other categories.<p>
278     *
279     * @param structureId the resource structure id
280     * @param categories the categories to set
281     * @param callback the callback which receives the result
282     */
283    void setResourceCategories(CmsUUID structureId, List<String> categories, AsyncCallback<Void> callback);
284
285    /**
286     * Sets the show editor help flag.<p>
287     *
288     * @param showHelp the show help flag
289     * @param callback the asynchronous callback
290     */
291    void setShowEditorHelp(boolean showHelp, AsyncCallback<Void> callback);
292
293    /**
294     * Writes the tool-bar visibility into the session cache.<p>
295     *
296     * @param visible <code>true</code> if the tool-bar is visible
297     * @param callback the call-back executed on response
298     */
299    void setToolbarVisible(boolean visible, AsyncCallback<Void> callback);
300
301    /**
302     * Unlocks the given resource.<p>
303     *
304     * @param structureId the resource structure id
305     * @param callback the async callback
306     */
307    @SynchronizedRpcRequest
308    void unlock(CmsUUID structureId, AsyncCallback<String> callback);
309
310    /**
311     * Unlocks the given resource.<p>
312     *
313     * @param rootPath the resource root path
314     * @param callback the async callback
315     */
316    @SynchronizedRpcRequest
317    void unlock(String rootPath, AsyncCallback<String> callback);
318
319    /**
320     * Performs a batch of validations and returns the results.<p>
321     *
322     * @param validationQueries a map from field names to validation queries
323     * @param callback the asynchronous callback
324     */
325    void validate(
326        Map<String, CmsValidationQuery> validationQueries,
327        AsyncCallback<Map<String, CmsValidationResult>> callback);
328
329    /**
330     * Performs a batch of validations using a custom form validator class.<p>
331     *
332     * @param formValidatorClass the class name of the form validator
333     * @param validationQueries a map from field names to validation queries
334     * @param values the map of all field values
335     * @param config the form validator configuration string
336     * @param callback the asynchronous callback
337     */
338    void validate(
339        String formValidatorClass,
340        Map<String, CmsValidationQuery> validationQueries,
341        Map<String, String> values,
342        String config,
343        AsyncCallback<Map<String, CmsValidationResult>> callback);
344
345}