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