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.CmsRpcException; 032import org.opencms.gwt.shared.CmsBroadcastMessage; 033import org.opencms.gwt.shared.CmsCategoryTreeEntry; 034import org.opencms.gwt.shared.CmsContextMenuEntryBean; 035import org.opencms.gwt.shared.CmsCoreData; 036import org.opencms.gwt.shared.CmsCoreData.AdeContext; 037import org.opencms.gwt.shared.CmsCoreData.UserInfo; 038import org.opencms.gwt.shared.CmsResourceCategoryInfo; 039import org.opencms.gwt.shared.CmsReturnLinkInfo; 040import org.opencms.gwt.shared.CmsUserSettingsBean; 041import org.opencms.gwt.shared.CmsValidationQuery; 042import org.opencms.gwt.shared.CmsValidationResult; 043import org.opencms.util.CmsUUID; 044 045import java.util.List; 046import java.util.Map; 047import java.util.Set; 048 049import com.google.gwt.user.client.rpc.RemoteService; 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_CmsCoreService extends RemoteService { 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 * @return an error message if an error occurred, or null if the password was successfully changed 070 * 071 * @throws CmsRpcException if something goes wrong 072 */ 073 String changePassword(String oldPassword, String newPassword, String newPasswordConfirm) throws CmsRpcException; 074 075 /** 076 * Creates a new UUID.<p> 077 * 078 * @return the created UUID 079 * 080 * @throws CmsRpcException if something goes wrong 081 */ 082 CmsUUID createUUID() throws CmsRpcException; 083 084 /** 085 * Returns the latest messages for the current user.<p> 086 * 087 * @return the messages 088 * 089 * @throws CmsRpcException if anything goes wrong 090 */ 091 List<CmsBroadcastMessage> getBroadcast() throws CmsRpcException; 092 093 /** 094 * Returns the categories for the given search parameters.<p> 095 * 096 * @param fromCatPath the category path to start with, can be <code>null</code> or empty to use the root 097 * @param includeSubCats if to include all categories, or first level child categories only 098 * @param refVfsPath the reference path (site-relative path according to which the available category repositories are determined), 099 * can be <code>null</code> to only use the system repository 100 * @param withRepositories flag, indicating if also the category repositories should be returned as category 101 * @param selected a set of paths of currently selected categories (which should be included in the result even if they are marked as hidden) 102 * 103 * @return the resource categories 104 * 105 * @throws CmsRpcException if something goes wrong 106 */ 107 List<CmsCategoryTreeEntry> getCategories( 108 String fromCatPath, 109 boolean includeSubCats, 110 String refVfsPath, 111 boolean withRepositories, 112 Set<String> selected) 113 throws CmsRpcException; 114 115 /** 116 * Returns the categories for the given reference site-path.<p> 117 * 118 * @param sitePath the reference site-path 119 * 120 * @return the categories for the given reference site-path 121 * 122 * @throws CmsRpcException if something goes wrong 123 */ 124 List<CmsCategoryTreeEntry> getCategoriesForSitePath(String sitePath) throws CmsRpcException; 125 126 /** 127 * Returns the category information for the given resource.<p> 128 * 129 * @param structureId the resource structure id 130 * 131 * @return the category information 132 * 133 * @throws CmsRpcException if something goes wrong 134 */ 135 CmsResourceCategoryInfo getCategoryInfo(CmsUUID structureId) throws CmsRpcException; 136 137 /** 138 * Returns the context menu entries for the given URI.<p> 139 * 140 * @param structureId the currently requested structure id 141 * @param context the ade context (sitemap or containerpage) 142 * 143 * @return the context menu entries 144 * 145 * @throws CmsRpcException if something goes wrong 146 */ 147 List<CmsContextMenuEntryBean> getContextMenuEntries(CmsUUID structureId, AdeContext context) throws CmsRpcException; 148 149 /** 150 * Returns the context menu entries for the given URI.<p> 151 * 152 * @param structureId the currently requested structure id 153 * @param context the ade context (sitemap or containerpage) 154 * @param params additional context information the server side can use to determine menu item availability 155 * 156 * @return the context menu entries 157 * 158 * @throws CmsRpcException if something goes wrong 159 */ 160 161 List<CmsContextMenuEntryBean> getContextMenuEntries( 162 CmsUUID structureId, 163 AdeContext context, 164 Map<String, String> params) 165 throws CmsRpcException; 166 167 /** 168 * Given a return code, returns the link to the page which corresponds to the return code.<p> 169 * 170 * @param returnCode the return code 171 * 172 * @return the link for the return code 173 * 174 * @throws CmsRpcException if something goes wrong 175 */ 176 CmsReturnLinkInfo getLinkForReturnCode(String returnCode) throws CmsRpcException; 177 178 /** 179 * Gets the resource state for a resource with a given path.<p> 180 * 181 * @param structureId the resource structure id 182 * 183 * @return the resource state of the resource 184 * 185 * @throws CmsRpcException if something goes wrong 186 */ 187 CmsResourceState getResourceState(CmsUUID structureId) throws CmsRpcException; 188 189 /** 190 * Returns a unique filename for the given base name and the parent folder.<p> 191 * 192 * @param parentFolder the parent folder of the file 193 * @param baseName the proposed file name 194 * 195 * @return the unique file name 196 * 197 * @throws CmsRpcException if something goes wrong 198 */ 199 String getUniqueFileName(String parentFolder, String baseName) throws CmsRpcException; 200 201 /** 202 * Returns the user info.<p> 203 * 204 * @return the user info 205 * 206 * @throws CmsRpcException in case something goes wrong 207 */ 208 UserInfo getUserInfo() throws CmsRpcException; 209 210 /** 211 * Returns a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the 212 * site of the given explorerRootPath and show the folder given in the explorerRootPath.<p> 213 * 214 * @param structureId the structure id of the resource for which to open the workplace 215 * 216 * @return a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the 217 * site of the given explorerRootPath and show the folder given in the explorerRootPath. 218 * 219 * @throws CmsRpcException if something goes wrong 220 */ 221 String getWorkplaceLink(CmsUUID structureId) throws CmsRpcException; 222 223 /** 224 * Gets the workplace link for the given path. 225 * 226 * @param path the path 227 * @return the workplace link for the path 228 * @throws CmsRpcException if something goes wrong 229 */ 230 String getWorkplaceLinkForPath(String path) throws CmsRpcException; 231 232 /** 233 * Loads the user settings for the current user.<p> 234 * 235 * @return the user settings for the current user 236 * 237 * @throws CmsRpcException if something goes wrong 238 */ 239 CmsUserSettingsBean loadUserSettings() throws CmsRpcException; 240 241 /** 242 * Locks the given resource with a temporary lock if it exists.<p> 243 * If the resource does not exist yet, the closest existing ancestor folder will check if it is lockable.<p> 244 * 245 * @param sitePath the site path of the resource to lock 246 * 247 * @return <code>null</code> if successful, an error message if not 248 * 249 * @throws CmsRpcException if something goes wrong 250 */ 251 String lockIfExists(String sitePath) throws CmsRpcException; 252 253 /** 254 * Locks the given resource with a temporary lock if it exists.<p> 255 * If the resource does not exist yet, the closest existing ancestor folder will check if it is lockable.<p> 256 * 257 * @param sitePath the site path of the resource to lock 258 * @param loadTime the time when the requested resource was loaded 259 * 260 * @return <code>null</code> if successful, an error message if not 261 * 262 * @throws CmsRpcException if something goes wrong 263 */ 264 String lockIfExists(String sitePath, long loadTime) throws CmsRpcException; 265 266 /** 267 * Locks the given resource with a temporary lock.<p> 268 * 269 * @param structureId the structure id of the resource to lock 270 * 271 * @return <code>null</code> if successful, an error message if not 272 * 273 * @throws CmsRpcException if something goes wrong 274 */ 275 String lockTemp(CmsUUID structureId) throws CmsRpcException; 276 277 /** 278 * Locks the given resource with a temporary lock.<p> 279 * Locking will fail in case the requested resource has been changed since the given load time.<p> 280 * 281 * @param structureId the resource structure id 282 * @param loadTime the time when the requested resource was loaded 283 * 284 * @return <code>null</code> if successful, an error message if not 285 * 286 * @throws CmsRpcException if something goes wrong 287 */ 288 String lockTemp(CmsUUID structureId, long loadTime) throws CmsRpcException; 289 290 /** 291 * Generates core data for prefetching in the host page.<p> 292 * 293 * @return the core data 294 * 295 * @throws CmsRpcException if something goes wrong 296 */ 297 CmsCoreData prefetch() throws CmsRpcException; 298 299 /** 300 * Saves a category used by the current user. 301 * 302 * @param category the category 303 * 304 * @throws CmsRpcException if something goes wrong 305 */ 306 void saveUsedCategory(String category) throws CmsRpcException; 307 308 /** 309 * Saves the user settings for the current user.<p> 310 * 311 * @param userSettings the new values for the user settings 312 * @param edited the keys of the user settings which were actually edited 313 * 314 * @throws CmsRpcException if something goes wrong 315 */ 316 void saveUserSettings(Map<String, String> userSettings, Set<String> edited) throws CmsRpcException; 317 318 /** 319 * Sets the categories of the given resource. Will remove all other categories.<p> 320 * 321 * @param structureId the resource structure id 322 * @param categories the categories to set 323 * 324 * @throws CmsRpcException if something goes wrong 325 */ 326 void setResourceCategories(CmsUUID structureId, List<String> categories) throws CmsRpcException; 327 328 /** 329 * Sets the show editor help flag.<p> 330 * 331 * @param showHelp the show help flag 332 * 333 * @throws CmsRpcException if something goes wrong 334 */ 335 void setShowEditorHelp(boolean showHelp) throws CmsRpcException; 336 337 /** 338 * Writes the tool-bar visibility into the session cache.<p> 339 * 340 * @param visible <code>true</code> if the tool-bar is visible 341 * 342 * @throws CmsRpcException if something goes wrong 343 */ 344 void setToolbarVisible(boolean visible) throws CmsRpcException; 345 346 /** 347 * Unlocks the given resource.<p> 348 * 349 * @param structureId the structure id of the resource to unlock 350 * 351 * @return <code>null</code> if successful, an error message if not 352 * 353 * @throws CmsRpcException if something goes wrong 354 */ 355 String unlock(CmsUUID structureId) throws CmsRpcException; 356 357 /** 358 * Unlocks the given resource.<p> 359 * 360 * @param rootPath the root path of the resource to unlock 361 * 362 * @return <code>null</code> if successful, an error message if not 363 * 364 * @throws CmsRpcException if something goes wrong 365 */ 366 String unlock(String rootPath) throws CmsRpcException; 367 368 /** 369 * Performs a batch of validations and returns the results.<p> 370 * 371 * @param validationQueries a map from field names to validation queries 372 * 373 * @return a map from field names to validation results 374 * 375 * @throws CmsRpcException if something goes wrong 376 */ 377 Map<String, CmsValidationResult> validate(Map<String, CmsValidationQuery> validationQueries) throws CmsRpcException; 378 379 /** 380 * Performs a batch of validations using a custom form validator class.<p> 381 * 382 * @param formValidatorClass the class name of the form validator 383 * @param validationQueries a map from field names to validation queries 384 * @param values the map of all field values 385 * @param config the form validator configuration string 386 * 387 * @return a map from field names to validation results 388 * 389 * @throws CmsRpcException if the RPC call goes wrong 390 */ 391 Map<String, CmsValidationResult> validate( 392 String formValidatorClass, 393 Map<String, CmsValidationQuery> validationQueries, 394 Map<String, String> values, 395 String config) 396 throws CmsRpcException; 397 398}