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 * 101 * @return the resource categories 102 * 103 * @throws CmsRpcException if something goes wrong 104 */ 105 List<CmsCategoryTreeEntry> getCategories(String fromCatPath, boolean includeSubCats, String refVfsPath) 106 throws CmsRpcException; 107 108 /** 109 * Returns the categories for the given search parameters.<p> 110 * 111 * @param fromCatPath the category path to start with, can be <code>null</code> or empty to use the root 112 * @param includeSubCats if to include all categories, or first level child categories only 113 * @param refVfsPath the reference path (site-relative path according to which the available category repositories are determined), 114 * can be <code>null</code> to only use the system repository 115 * @param withRepositories flag, indicating if also the category repositories should be returned as category 116 * 117 * @return the resource categories 118 * 119 * @throws CmsRpcException if something goes wrong 120 */ 121 List<CmsCategoryTreeEntry> getCategories( 122 String fromCatPath, 123 boolean includeSubCats, 124 String refVfsPath, 125 boolean withRepositories) 126 throws CmsRpcException; 127 128 /** 129 * Returns the categories for the given reference site-path.<p> 130 * 131 * @param sitePath the reference site-path 132 * 133 * @return the categories for the given reference site-path 134 * 135 * @throws CmsRpcException if something goes wrong 136 */ 137 List<CmsCategoryTreeEntry> getCategoriesForSitePath(String sitePath) throws CmsRpcException; 138 139 /** 140 * Returns the category information for the given resource.<p> 141 * 142 * @param structureId the resource structure id 143 * 144 * @return the category information 145 * 146 * @throws CmsRpcException if something goes wrong 147 */ 148 CmsResourceCategoryInfo getCategoryInfo(CmsUUID structureId) 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 * 156 * @return the context menu entries 157 * 158 * @throws CmsRpcException if something goes wrong 159 */ 160 List<CmsContextMenuEntryBean> getContextMenuEntries(CmsUUID structureId, AdeContext context) throws CmsRpcException; 161 162 /** 163 * Given a return code, returns the link to the page which corresponds to the return code.<p> 164 * 165 * @param returnCode the return code 166 * 167 * @return the link for the return code 168 * 169 * @throws CmsRpcException if something goes wrong 170 */ 171 CmsReturnLinkInfo getLinkForReturnCode(String returnCode) throws CmsRpcException; 172 173 /** 174 * Gets the resource state for a resource with a given path.<p> 175 * 176 * @param structureId the resource structure id 177 * 178 * @return the resource state of the resource 179 * 180 * @throws CmsRpcException if something goes wrong 181 */ 182 CmsResourceState getResourceState(CmsUUID structureId) throws CmsRpcException; 183 184 /** 185 * Returns a unique filename for the given base name and the parent folder.<p> 186 * 187 * @param parentFolder the parent folder of the file 188 * @param baseName the proposed file name 189 * 190 * @return the unique file name 191 * 192 * @throws CmsRpcException if something goes wrong 193 */ 194 String getUniqueFileName(String parentFolder, String baseName) throws CmsRpcException; 195 196 /** 197 * Returns the user info.<p> 198 * 199 * @return the user info 200 * 201 * @throws CmsRpcException in case something goes wrong 202 */ 203 UserInfo getUserInfo() throws CmsRpcException; 204 205 /** 206 * Returns a link for the OpenCms workplace that will reload the whole workplace, switch to the explorer view, the 207 * site of the given explorerRootPath and show the folder given in the explorerRootPath.<p> 208 * 209 * @param structureId the structure id of the resource for which to open the workplace 210 * 211 * @return 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. 213 * 214 * @throws CmsRpcException if something goes wrong 215 */ 216 String getWorkplaceLink(CmsUUID structureId) throws CmsRpcException; 217 218 /** 219 * Loads the user settings for the current user.<p> 220 * 221 * @return the user settings for the current user 222 * 223 * @throws CmsRpcException if something goes wrong 224 */ 225 CmsUserSettingsBean loadUserSettings() throws CmsRpcException; 226 227 /** 228 * Locks the given resource with a temporary lock if it exists.<p> 229 * If the resource does not exist yet, the closest existing ancestor folder will check if it is lockable.<p> 230 * 231 * @param sitePath the site path of the resource to lock 232 * 233 * @return <code>null</code> if successful, an error message if not 234 * 235 * @throws CmsRpcException if something goes wrong 236 */ 237 String lockIfExists(String sitePath) throws CmsRpcException; 238 239 /** 240 * Locks the given resource with a temporary lock if it exists.<p> 241 * If the resource does not exist yet, the closest existing ancestor folder will check if it is lockable.<p> 242 * 243 * @param sitePath the site path of the resource to lock 244 * @param loadTime the time when the requested resource was loaded 245 * 246 * @return <code>null</code> if successful, an error message if not 247 * 248 * @throws CmsRpcException if something goes wrong 249 */ 250 String lockIfExists(String sitePath, long loadTime) throws CmsRpcException; 251 252 /** 253 * Locks the given resource with a temporary lock.<p> 254 * 255 * @param structureId the structure id of the resource to lock 256 * 257 * @return <code>null</code> if successful, an error message if not 258 * 259 * @throws CmsRpcException if something goes wrong 260 */ 261 String lockTemp(CmsUUID structureId) throws CmsRpcException; 262 263 /** 264 * Locks the given resource with a temporary lock.<p> 265 * Locking will fail in case the requested resource has been changed since the given load time.<p> 266 * 267 * @param structureId the resource structure id 268 * @param loadTime the time when the requested resource was loaded 269 * 270 * @return <code>null</code> if successful, an error message if not 271 * 272 * @throws CmsRpcException if something goes wrong 273 */ 274 String lockTemp(CmsUUID structureId, long loadTime) throws CmsRpcException; 275 276 /** 277 * Generates core data for prefetching in the host page.<p> 278 * 279 * @return the core data 280 * 281 * @throws CmsRpcException if something goes wrong 282 */ 283 CmsCoreData prefetch() throws CmsRpcException; 284 285 /** 286 * Saves the user settings for the current user.<p> 287 * 288 * @param userSettings the new values for the user settings 289 * @param edited the keys of the user settings which were actually edited 290 * 291 * @throws CmsRpcException if something goes wrong 292 */ 293 void saveUserSettings(Map<String, String> userSettings, Set<String> edited) throws CmsRpcException; 294 295 /** 296 * Sets the categories of the given resource. Will remove all other categories.<p> 297 * 298 * @param structureId the resource structure id 299 * @param categories the categories to set 300 * 301 * @throws CmsRpcException if something goes wrong 302 */ 303 void setResourceCategories(CmsUUID structureId, List<String> categories) throws CmsRpcException; 304 305 /** 306 * Sets the show editor help flag.<p> 307 * 308 * @param showHelp the show help flag 309 * 310 * @throws CmsRpcException if something goes wrong 311 */ 312 void setShowEditorHelp(boolean showHelp) throws CmsRpcException; 313 314 /** 315 * Writes the tool-bar visibility into the session cache.<p> 316 * 317 * @param visible <code>true</code> if the tool-bar is visible 318 * 319 * @throws CmsRpcException if something goes wrong 320 */ 321 void setToolbarVisible(boolean visible) throws CmsRpcException; 322 323 /** 324 * Unlocks the given resource.<p> 325 * 326 * @param structureId the structure id of the resource to unlock 327 * 328 * @return <code>null</code> if successful, an error message if not 329 * 330 * @throws CmsRpcException if something goes wrong 331 */ 332 String unlock(CmsUUID structureId) throws CmsRpcException; 333 334 /** 335 * Unlocks the given resource.<p> 336 * 337 * @param rootPath the root path of the resource to unlock 338 * 339 * @return <code>null</code> if successful, an error message if not 340 * 341 * @throws CmsRpcException if something goes wrong 342 */ 343 String unlock(String rootPath) throws CmsRpcException; 344 345 /** 346 * Performs a batch of validations and returns the results.<p> 347 * 348 * @param validationQueries a map from field names to validation queries 349 * 350 * @return a map from field names to validation results 351 * 352 * @throws CmsRpcException if something goes wrong 353 */ 354 Map<String, CmsValidationResult> validate(Map<String, CmsValidationQuery> validationQueries) throws CmsRpcException; 355 356 /** 357 * Performs a batch of validations using a custom form validator class.<p> 358 * 359 * @param formValidatorClass the class name of the form validator 360 * @param validationQueries a map from field names to validation queries 361 * @param values the map of all field values 362 * @param config the form validator configuration string 363 * 364 * @return a map from field names to validation results 365 * 366 * @throws CmsRpcException if the RPC call goes wrong 367 */ 368 Map<String, CmsValidationResult> validate( 369 String formValidatorClass, 370 Map<String, CmsValidationQuery> validationQueries, 371 Map<String, String> values, 372 String config) 373 throws CmsRpcException; 374 375}