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 withRepositories flag, indicating if also the category repositories should be returned as category
099     * @param selected a set of paths of currently selected categories (which should be included in the result even if they are marked as hidden)
100     * @param callback the async callback
101     */
102    void getCategories(
103        String fromCatPath,
104        boolean includeSubCats,
105        String refVfsPath,
106        boolean withRepositories,
107        Set<String> selected,
108        AsyncCallback<List<CmsCategoryTreeEntry>> callback);
109
110    /**
111     * Returns the categories for the given reference site-path.<p>
112     *
113     * @param sitePath the reference site-path
114     * @param callback the async callback
115     */
116    void getCategoriesForSitePath(String sitePath, AsyncCallback<List<CmsCategoryTreeEntry>> callback);
117
118    /**
119     * Returns the category information for the given resource.<p>
120     *
121     * @param structureId the resource structure id
122     * @param callback the callback which receives the result
123     */
124    void getCategoryInfo(CmsUUID structureId, AsyncCallback<CmsResourceCategoryInfo> callback);
125
126    /**
127     * Returns a list of menu entry beans for the context menu.<p>
128     *
129     * @param structureId the structure id of the resource for which to get the context menu
130     * @param context the ade context (sitemap or containerpage)
131     * @param callback the asynchronous callback
132     */
133    void getContextMenuEntries(
134        CmsUUID structureId,
135        AdeContext context,
136        AsyncCallback<List<CmsContextMenuEntryBean>> callback);
137
138    /**
139     * Returns a list of menu entry beans for the context menu.<p>
140     *
141     * @param structureId the structure id of the resource for which to get the context menu
142     * @param context the ade context (sitemap or containerpage)
143     * @param params additional context information that the server side can use to decide menu item availability
144     * @param callback the asynchronous callback
145     */
146    void getContextMenuEntries(
147        CmsUUID structureId,
148        AdeContext context,
149        Map<String, String> params,
150        AsyncCallback<List<CmsContextMenuEntryBean>> callback);
151
152    /**
153     * Given a return code, returns the link to the page which corresponds to the return code.<p>
154     *
155     * @param returnCode the return code
156     * @param callback the asynchronous callback
157     */
158    void getLinkForReturnCode(String returnCode, AsyncCallback<CmsReturnLinkInfo> callback);
159
160    /**
161     * Gets the resource state of a resource.<p>
162     *
163     * @param structureId the structure id of the resource
164     * @param callback the callback which receives the result
165     */
166    void getResourceState(CmsUUID structureId, AsyncCallback<CmsResourceState> callback);
167
168    /**
169     * Returns a unique filename for the given base name and the parent folder.<p>
170     *
171     * This is executed in a synchronized request.<p>
172     *
173     * @param parentFolder the parent folder of the file
174     * @param baseName the proposed file name
175     * @param callback the callback which receives the result
176     */
177    void getUniqueFileName(String parentFolder, String baseName, AsyncCallback<String> callback);
178
179    /**
180     * Returns the user info.<p>
181     *
182     * @param callback the callback
183     */
184    void getUserInfo(AsyncCallback<UserInfo> callback);
185
186    /**
187     * Returns a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the
188     * site of the given explorerRootPath and show the folder given in the explorerRootPath.<p>
189     *
190     * @param structureId the structure id of the resource for which to open the workplace
191     * @param callback the callback which receives the result
192     */
193    void getWorkplaceLink(CmsUUID structureId, AsyncCallback<String> callback);
194
195    /**
196     * Gets the workplace link for the given path.
197     *
198     * @param path the path
199     * @param action the callback for the result
200     */
201    void getWorkplaceLinkForPath(String path, AsyncCallback<String> action);
202
203    /**
204     * Loads the user settings for the current user.<p>
205     *
206     * @param callback the callback to call with the result
207     */
208    void loadUserSettings(AsyncCallback<CmsUserSettingsBean> callback);
209
210    /**
211     * Locks the given resource with a temporary lock if it exists.<p>
212     * If the resource does not exist yet, the closest existing ancestor folder will check if it is lockable.<p>
213     *
214     * @param sitePath the site path of the resource to lock
215     * @param callback the async callback
216     */
217    void lockIfExists(String sitePath, AsyncCallback<String> callback);
218
219    /**
220     * Locks the given resource with a temporary lock if it exists.<p>
221     * If the resource does not exist yet, the closest existing ancestor folder will check if it is lockable.<p>
222     *
223     * @param sitePath the site path of the resource to lock
224     * @param loadTime the time when the requested resource was loaded
225     * @param callback the async callback
226     */
227    void lockIfExists(String sitePath, long loadTime, AsyncCallback<String> callback);
228
229    /**
230     * Locks the given resource with a temporary lock.<p>
231     *
232     * @param structureId the resource structure id
233     * @param callback the async callback
234     */
235    void lockTemp(CmsUUID structureId, AsyncCallback<String> callback);
236
237    /**
238     * Locks the given resource with a temporary lock.<p>
239     * Locking will fail in case the requested resource has been changed since the given load time.<p>
240     *
241     * @param structureId the resource structure id
242     * @param loadTime the time when the requested resource was loaded
243     * @param callback the async callback
244     */
245    void lockTemp(CmsUUID structureId, long loadTime, AsyncCallback<String> callback);
246
247    /**
248     * Generates core data for prefetching in the host page.<p>
249     *
250     * @param callback the async callback
251     */
252    void prefetch(AsyncCallback<CmsCoreData> callback);
253
254    /**
255     * Saves the user settings for the current user.<p>
256     *
257     * @param userSettings the new values for the user settings
258     * @param edited the keys of the user settings which were actually edited
259     * @param resultCallback the callback to call when the operation has finished
260     */
261    void saveUserSettings(Map<String, String> userSettings, Set<String> edited, AsyncCallback<Void> resultCallback);
262
263    /**
264     * Sets the categories of the given resource. Will remove all other categories.<p>
265     *
266     * @param structureId the resource structure id
267     * @param categories the categories to set
268     * @param callback the callback which receives the result
269     */
270    void setResourceCategories(CmsUUID structureId, List<String> categories, AsyncCallback<Void> callback);
271
272    /**
273     * Sets the show editor help flag.<p>
274     *
275     * @param showHelp the show help flag
276     * @param callback the asynchronous callback
277     */
278    void setShowEditorHelp(boolean showHelp, AsyncCallback<Void> callback);
279
280    /**
281     * Writes the tool-bar visibility into the session cache.<p>
282     *
283     * @param visible <code>true</code> if the tool-bar is visible
284     * @param callback the call-back executed on response
285     */
286    void setToolbarVisible(boolean visible, AsyncCallback<Void> callback);
287
288    /**
289     * Unlocks the given resource.<p>
290     *
291     * @param structureId the resource structure id
292     * @param callback the async callback
293     */
294    @SynchronizedRpcRequest
295    void unlock(CmsUUID structureId, AsyncCallback<String> callback);
296
297    /**
298     * Unlocks the given resource.<p>
299     *
300     * @param rootPath the resource root path
301     * @param callback the async callback
302     */
303    @SynchronizedRpcRequest
304    void unlock(String rootPath, AsyncCallback<String> callback);
305
306    /**
307     * Performs a batch of validations and returns the results.<p>
308     *
309     * @param validationQueries a map from field names to validation queries
310     * @param callback the asynchronous callback
311     */
312    void validate(
313        Map<String, CmsValidationQuery> validationQueries,
314        AsyncCallback<Map<String, CmsValidationResult>> callback);
315
316    /**
317     * Performs a batch of validations using a custom form validator class.<p>
318     *
319     * @param formValidatorClass the class name of the form validator
320     * @param validationQueries a map from field names to validation queries
321     * @param values the map of all field values
322     * @param config the form validator configuration string
323     * @param callback the asynchronous callback
324     */
325    void validate(
326        String formValidatorClass,
327        Map<String, CmsValidationQuery> validationQueries,
328        Map<String, String> values,
329        String config,
330        AsyncCallback<Map<String, CmsValidationResult>> callback);
331
332}