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 GmbH & Co. KG, 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.file.types; 029 030import org.opencms.configuration.CmsConfigurationCopyResource; 031import org.opencms.configuration.CmsConfigurationException; 032import org.opencms.configuration.I_CmsConfigurationParameterHandler; 033import org.opencms.db.CmsSecurityManager; 034import org.opencms.file.CmsFile; 035import org.opencms.file.CmsObject; 036import org.opencms.file.CmsProperty; 037import org.opencms.file.CmsResource; 038import org.opencms.lock.CmsLockType; 039import org.opencms.main.CmsException; 040import org.opencms.main.CmsIllegalArgumentException; 041import org.opencms.xml.containerpage.CmsFormatterConfiguration; 042 043import java.io.Serializable; 044import java.util.List; 045 046/** 047 * Resource type descriptors for all resources in the VFS.<p> 048 * 049 * Each file in the VFS must belong to an initialized resource type. 050 * The available resource type are read during system startup from the configuration 051 * file <code>opencms-vfs.xml</code>.<p> 052 * 053 * Certain resource types may require special handling for certain operations. 054 * This is usually required for write operations, or other operations that 055 * modify the VFS database. 056 * Therefore, the {@link org.opencms.file.CmsObject} defers handling of this 057 * operations to implementations of this interface.<p> 058 * 059 * If you implement a new resource type, it's a good idea to extend the 060 * abstract class {@link org.opencms.file.types.A_CmsResourceType}.<p> 061 * 062 * Important: The {@link org.opencms.file.CmsObject} passes the {@link org.opencms.db.CmsSecurityManager} 063 * object to implementations of this class. Using this object correctly is key to the 064 * resource type operations. Mistakes made in the implementation of a resource type 065 * can screw up the system security and the database structure, and make you unhappy. <p> 066 * 067 * @since 6.0.0 068 */ 069public interface I_CmsResourceType extends I_CmsConfigurationParameterHandler, Serializable { 070 071 /** Resource formatter. */ 072 enum Formatter { 073 074 /** The gallery list item formatter. */ 075 ADE_LIST("formatter_ade_list", "/system/workplace/editors/ade/default-list-formatter.jsp"), 076 077 /** The gallery list item formatter. */ 078 GALLERY_LIST("formatter_gallery_list", "/system/workplace/editors/ade/default-list-formatter.jsp"), 079 080 /** The gallery preview formatter. */ 081 GALLERY_PREVIEW("formatter_gallery_preview", "/system/workplace/editors/ade/default-preview-formatter.jsp"), 082 083 /** The gallery list item formatter. */ 084 PUBLISH_LIST("formatter_publish_list", "/system/workplace/editors/ade/default-list-formatter.jsp"), 085 086 /** The sitemap formatter. */ 087 SITEMAP("formatter_sitemap", "/system/workplace/editors/sitemap/default-formatter.jsp"); 088 089 /** Formatter default path. */ 090 private String m_defaultPath; 091 092 /** Formatter name. */ 093 private String m_name; 094 095 /** 096 * Constructor.<p> 097 * 098 * @param name the formatter name 099 * @param defaultPath the default formatter path 100 */ 101 private Formatter(String name, String defaultPath) { 102 103 m_name = name; 104 m_defaultPath = defaultPath; 105 } 106 107 /** 108 * Get the default path.<p> 109 * 110 * @return the default path 111 */ 112 public String getDefaultPath() { 113 114 return m_defaultPath; 115 } 116 117 /** 118 * Get the name.<p> 119 * 120 * @return the name 121 */ 122 public String getName() { 123 124 return m_name; 125 } 126 } 127 128 /** The name of the addMapping() method. */ 129 String ADD_MAPPING_METHOD = "addMappingType"; 130 131 /** Name of the addResourceType() method to add a resource type from the configuration. */ 132 String ADD_RESOURCE_TYPE_METHOD = "addResourceType"; 133 134 /** Configuration key prefix for properties that are attached when creating a new resource. */ 135 String CONFIGURATION_PROPERTY_CREATE = "property.create."; 136 137 /** Configuration key for the resource type id. */ 138 String CONFIGURATION_RESOURCE_TYPE_ID = "resource.type.id"; 139 140 /** Configuration key for the resource type name. */ 141 String CONFIGURATION_RESOURCE_TYPE_NAME = "resource.type.name"; 142 143 /** Store the property on resource record. */ 144 String PROPERTY_ON_RESOURCE = "resource"; 145 146 /** Store the property on structure record. */ 147 String PROPERTY_ON_STRUCTURE = "structure"; 148 149 /** 150 * Maps a file extension to a resource type.<p> 151 * 152 * When uploading files into OpenCms, they must be mapped to the different 153 * OpenCms resource types. The configuration, to map which extension to which 154 * resouce type is done in the OpenCms VFS configuration. 155 * 156 * @param mapping the file extension mapped to the resource type 157 */ 158 void addMappingType(String mapping); 159 160 /** 161 * Changes the lock of a resource to the current user, 162 * that is "steals" the lock from another user.<p> 163 * 164 * @param cms the current cms context 165 * @param securityManager the initialized OpenCms security manager 166 * @param resource the name of the resource to change the lock with complete path 167 * 168 * @throws CmsException if something goes wrong 169 * 170 * @see CmsObject#changeLock(String) 171 * @see CmsSecurityManager#changeLock(org.opencms.file.CmsRequestContext, CmsResource) 172 */ 173 void changeLock(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) throws CmsException; 174 175 /** 176 * Changes the resource flags of a resource.<p> 177 * 178 * The resource flags are used to indicate various "special" conditions 179 * for a resource. Most notably, the "internal only" setting which signals 180 * that a resource can not be directly requested with it's URL.<p> 181 * 182 * @param cms the initialized CmsObject 183 * @param securityManager the initialized OpenCms security manager 184 * @param resource the resource to change the flags for 185 * @param flags the new resource flags for this resource 186 * 187 * @throws CmsException if something goes wrong 188 * 189 * @see CmsObject#chflags(String, int) 190 * @see CmsSecurityManager#chflags(org.opencms.file.CmsRequestContext, CmsResource, int) 191 */ 192 void chflags(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int flags) 193 throws CmsException; 194 195 /** 196 * Changes the resource type of a resource.<p> 197 * 198 * OpenCms handles resources according to the resource type, 199 * not the file suffix. This is e.g. why a JSP in OpenCms can have the 200 * suffix ".html" instead of ".jsp" only. Changing the resource type 201 * makes sense e.g. if you want to make a plain text file a JSP resource, 202 * or a binary file an image, etc.<p> 203 * 204 * @param cms the initialized CmsObject 205 * @param securityManager the initialized OpenCms security manager 206 * @param resource the resource to change the type for 207 * @param type the new resource type for this resource 208 * 209 * @throws CmsException if something goes wrong 210 * 211 * @see CmsObject#chtype(String, int) 212 * @see CmsSecurityManager#chtype(org.opencms.file.CmsRequestContext, CmsResource, int) 213 */ 214 void chtype(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, I_CmsResourceType type) 215 throws CmsException; 216 217 /** 218 * Changes the resource type of a resource.<p> 219 * 220 * OpenCms handles resources according to the resource type, 221 * not the file suffix. This is e.g. why a JSP in OpenCms can have the 222 * suffix ".html" instead of ".jsp" only. Changing the resource type 223 * makes sense e.g. if you want to make a plain text file a JSP resource, 224 * or a binary file an image, etc.<p> 225 * 226 * @param cms the initialized CmsObject 227 * @param securityManager the initialized OpenCms security manager 228 * @param resource the resource to change the type for 229 * @param type the new resource type for this resource 230 * 231 * @throws CmsException if something goes wrong 232 * 233 * @see CmsObject#chtype(String, int) 234 * @see CmsSecurityManager#chtype(org.opencms.file.CmsRequestContext, CmsResource, int) 235 * 236 * @deprecated 237 * Use {@link #chtype(CmsObject, CmsSecurityManager, CmsResource, I_CmsResourceType)} instead. 238 * Resource types should always be referenced either by this type class (preferred) or by type name. 239 * Use of int based resource type references will be discontinued in a future OpenCms release. 240 */ 241 @Deprecated 242 void chtype(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int type) throws CmsException; 243 244 /** 245 * Copies a resource.<p> 246 * 247 * You must ensure that the destination path is an absolute, valid and 248 * existing VFS path. Relative paths from the source are currently not supported.<p> 249 * 250 * The copied resource will always be locked to the current user 251 * after the copy operation.<p> 252 * 253 * In case the target resource already exists, it is overwritten with the 254 * source resource.<p> 255 * 256 * The <code>siblingMode</code> parameter controls how to handle siblings 257 * during the copy operation.<br> 258 * Possible values for this parameter are: <br> 259 * <ul> 260 * <li><code>{@link org.opencms.file.CmsResource#COPY_AS_NEW}</code></li> 261 * <li><code>{@link org.opencms.file.CmsResource#COPY_AS_SIBLING}</code></li> 262 * <li><code>{@link org.opencms.file.CmsResource#COPY_PRESERVE_SIBLING}</code></li> 263 * </ul><p> 264 * 265 * @param cms the initialized CmsObject 266 * @param securityManager the initialized OpenCms security manager 267 * @param source the resource to copy 268 * @param destination the name of the copy destination with complete path 269 * @param siblingMode indicates how to handle siblings during copy 270 * 271 * @throws CmsIllegalArgumentException if the <code>destination</code> argument is null or of length 0 272 * @throws CmsException if something goes wrong 273 * 274 * @see CmsObject#copyResource(String, String, CmsResource.CmsResourceCopyMode) 275 * @see CmsSecurityManager#copyResource(org.opencms.file.CmsRequestContext, CmsResource, String, CmsResource.CmsResourceCopyMode) 276 */ 277 void copyResource( 278 CmsObject cms, 279 CmsSecurityManager securityManager, 280 CmsResource source, 281 String destination, 282 CmsResource.CmsResourceCopyMode siblingMode) 283 throws CmsException, CmsIllegalArgumentException; 284 285 /** 286 * Copies a resource to the current project of the user.<p> 287 * 288 * This is used to extend the current users project with the 289 * specified resource, in case that the resource is not yet part of the project. 290 * The resource is not really copied like in a regular copy operation, 291 * it is in fact only "enabled" in the current users project.<p> 292 * 293 * @param cms the initialized CmsObject 294 * @param securityManager the initialized OpenCms security manager 295 * @param resource the resource to apply this operation to 296 * 297 * @throws CmsException if something goes wrong 298 * @throws CmsIllegalArgumentException if the <code>resource</code> argument is null or of length 0 299 * 300 * @see CmsObject#copyResourceToProject(String) 301 * @see CmsSecurityManager#copyResourceToProject(org.opencms.file.CmsRequestContext, CmsResource) 302 */ 303 void copyResourceToProject(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) 304 throws CmsException, CmsIllegalArgumentException; 305 306 /** 307 * Creates a new resource of the given resource type 308 * with the provided content and properties.<p> 309 * 310 * @param cms the initialized CmsObject 311 * @param securityManager the initialized OpenCms security manager 312 * @param resourcename the name of the resource to create (full path) 313 * @param content the content for the new resource 314 * @param properties the properties for the new resource 315 * 316 * @return the created resource 317 * 318 * @throws CmsException if something goes wrong 319 * @throws CmsIllegalArgumentException if the <code>source</code> argument is null or of length 0 320 * 321 * @see CmsObject#createResource(String, int, byte[], List) 322 * @see CmsObject#createResource(String, int) 323 * @see CmsSecurityManager#createResource(org.opencms.file.CmsRequestContext, String, int, byte[], List) 324 */ 325 CmsResource createResource( 326 CmsObject cms, 327 CmsSecurityManager securityManager, 328 String resourcename, 329 byte[] content, 330 List<CmsProperty> properties) 331 throws CmsException, CmsIllegalArgumentException; 332 333 /** 334 * Creates a new sibling of the source resource.<p> 335 * 336 * @param cms the current cms context 337 * @param securityManager the initialized OpenCms security manager 338 * @param source the resource to create a sibling for 339 * @param destination the name of the sibling to create with complete path 340 * @param properties the individual properties for the new sibling 341 * 342 * @return the new created sibling 343 * 344 * @throws CmsException if something goes wrong 345 * 346 * @see CmsObject#createSibling(String, String, List) 347 * @see CmsSecurityManager#createSibling(org.opencms.file.CmsRequestContext, CmsResource, String, List) 348 */ 349 CmsResource createSibling( 350 CmsObject cms, 351 CmsSecurityManager securityManager, 352 CmsResource source, 353 String destination, 354 List<CmsProperty> properties) 355 throws CmsException; 356 357 /** 358 * Deletes a resource given its name.<p> 359 * 360 * The <code>siblingMode</code> parameter controls how to handle siblings 361 * during the delete operation.<br> 362 * Possible values for this parameter are: <br> 363 * <ul> 364 * <li><code>{@link CmsResource#DELETE_REMOVE_SIBLINGS}</code></li> 365 * <li><code>{@link CmsResource#DELETE_PRESERVE_SIBLINGS}</code></li> 366 * </ul><p> 367 * 368 * @param cms the initialized CmsObject 369 * @param securityManager the initialized OpenCms security manager 370 * @param resource the resource to delete 371 * @param siblingMode indicates how to handle siblings of the deleted resource 372 * 373 * @throws CmsException if something goes wrong 374 * 375 * @see CmsObject#deleteResource(String, CmsResource.CmsResourceDeleteMode) 376 * @see CmsSecurityManager#deleteResource(org.opencms.file.CmsRequestContext, CmsResource, CmsResource.CmsResourceDeleteMode) 377 */ 378 void deleteResource( 379 CmsObject cms, 380 CmsSecurityManager securityManager, 381 CmsResource resource, 382 CmsResource.CmsResourceDeleteMode siblingMode) 383 throws CmsException; 384 385 /** 386 * Gets the folder for which the links should be adjusted after processing the copy resources.<p> 387 * 388 * @return the path of the folder for which the links should be adjusted 389 */ 390 String getAdjustLinksFolder(); 391 392 /** 393 * Returns the default for the <code>cache</code> property setting of this resource type.<p> 394 * 395 * The <code>cache</code> property is used by the Flex cache implementation 396 * to build the cache key that controls the caching behaviour of a resource.<p> 397 * 398 * If <code>null</code> is returnd, this is the same as turning the cache 399 * off by default for this resource type.<p> 400 * 401 * @return the default for the <code>cache</code> property setting of this resource type 402 * 403 * @see org.opencms.flex.CmsFlexCache 404 * @see org.opencms.flex.CmsFlexCacheKey 405 */ 406 String getCachePropertyDefault(); 407 408 /** 409 * Returns the class name configured for this resource type.<p> 410 * 411 * This may be different from the instance class name in case the configured class could not 412 * be instantiated. If the configured class is unavailable, an instance of 413 * <code>{@link CmsResourceTypeUnknown}</code> is used. This enables the import of modules that contain their 414 * own resource types classes (which are not available before the module is fully imported).<p> 415 * 416 * @return the class name configured for this resource type 417 */ 418 String getClassName(); 419 420 /** 421 * Returns the configured copy resources for this resource type in an unmodifiable List.<p> 422 * 423 * @return the configured copy resources for this resource type in an unmodifiable List 424 */ 425 List<CmsConfigurationCopyResource> getConfiguredCopyResources(); 426 427 /** 428 * Returns the configured default properties for this resource type in an unmodifiable List.<p> 429 * 430 * @return the configured default properties for this resource type in an unmodifiable List 431 */ 432 List<CmsProperty> getConfiguredDefaultProperties(); 433 434 /** 435 * Returns the file extensions mappings for this resource type in an unmodifiable List.<p> 436 * 437 * @return a list of file extensions mappings for this resource type in an unmodifiable List 438 */ 439 List<String> getConfiguredMappings(); 440 441 /** 442 * Returns the formatter configuration for the given resource.<p> 443 * 444 * @param cms the current cms context 445 * @param resource the resource to get the formatter configuration for 446 * 447 * @return the formatter configuration for the given resource 448 */ 449 CmsFormatterConfiguration getFormattersForResource(CmsObject cms, CmsResource resource); 450 451 /** 452 * Returns the gallery preview provider class name.<p> 453 * 454 * @return the gallery preview provider class name 455 */ 456 String getGalleryPreviewProvider(); 457 458 /** 459 * Returns the gallery types for this resource type.<p> 460 * 461 * @return the gallery types, if no gallery is configured <code>null</code> will be returned 462 */ 463 List<I_CmsResourceType> getGalleryTypes(); 464 465 /** 466 * Returns the loader type id of this resource type.<p> 467 * 468 * @return the loader type id of this resource type 469 */ 470 int getLoaderId(); 471 472 /** 473 * Returns the module name if this is an additional resource type which is defined in a module, or <code>null</code>.<p> 474 * 475 * @return the module name if this is an additional resource type which is defined in a module, or <code>null</code> 476 */ 477 String getModuleName(); 478 479 /** 480 * Returns the type id of this resource type.<p> 481 * 482 * @return the type id of this resource type 483 * 484 * @deprecated 485 * Use this class or {@link #getTypeName()} instead. 486 * Resource types should always be referenced either by this type class (preferred) or by type name. 487 * Use of int based resource type references will be discontinued in a future OpenCms release. 488 */ 489 @Deprecated 490 int getTypeId(); 491 492 /** 493 * Returns the name of this resource type.<p> 494 * 495 * @return the name of this resource type 496 */ 497 String getTypeName(); 498 499 /** 500 * Imports a resource to the OpenCms VFS.<p> 501 * 502 * If a resource already exists in the VFS (i.e. has the same name and 503 * same id) it is replaced by the imported resource.<p> 504 * 505 * If a resource with the same name but a different id exists, 506 * the imported resource is (usually) moved to the "lost and found" folder.<p> 507 * 508 * @param cms the initialized CmsObject 509 * @param securityManager the initialized OpenCms security manager 510 * @param resourcename the target name (with full path) for the resource after import 511 * @param resource the resource to be imported 512 * @param content the content of the resource 513 * @param properties the properties of the resource 514 * 515 * @return the imported resource 516 * 517 * @throws CmsException if something goes wrong 518 * 519 * @see CmsSecurityManager#moveToLostAndFound(org.opencms.file.CmsRequestContext, CmsResource, boolean) 520 * @see CmsObject#importResource(String, CmsResource, byte[], List) 521 * @see CmsSecurityManager#importResource(org.opencms.file.CmsRequestContext, String, CmsResource, byte[], List, boolean) 522 */ 523 CmsResource importResource( 524 CmsObject cms, 525 CmsSecurityManager securityManager, 526 String resourcename, 527 CmsResource resource, 528 byte[] content, 529 List<CmsProperty> properties) 530 throws CmsException; 531 532 /** 533 * Special version of the configuration initialization used with resource types 534 * to set resource type, id and class name, required for the XML configuration.<p> 535 * 536 * <i>Please note:</i> Many resource types defined in the core have in fact 537 * a fixed resource type and a fixed id. Configurable name and id is used only 538 * for certain types.<p> 539 * 540 * The provided named class must implement this interface (<code>{@link I_CmsResourceType}</code>). 541 * Usually the provided class name should be the class name of the resource type instance, 542 * but this may be different in special cases or configuration errors. 543 * 544 * For example, if a module is imported that contains it's own resource type class files, 545 * the included class file are usually not be available until the server is restarted. 546 * If the named class given in the XML configuration (or module manifest.xml) is not available, 547 * or not implementing <code>{@link I_CmsResourceType}</code>, 548 * then <code>{@link CmsResourceTypeUnknown}</code> is used for the resource type instance.<p> 549 * 550 * @param name the resource type name 551 * @param id the resource type id 552 * @param className the class name of the resource type (read from the XML configuration) 553 * 554 * @throws CmsConfigurationException if the configuration is invalid 555 */ 556 void initConfiguration(String name, String id, String className) throws CmsConfigurationException; 557 558 /** 559 * Initializes this resource type.<p> 560 * 561 * This method will be called once during the OpenCms 562 * initialization processs. The VFS will already be available 563 * at the time the method is called.<p> 564 * 565 * @param cms a OpenCms context initialized with "Admin" permissions 566 */ 567 void initialize(CmsObject cms); 568 569 /** 570 * Indicates that this is an additional resource type which is defined in a module.<p> 571 * @return true or false 572 */ 573 boolean isAdditionalModuleResourceType(); 574 575 /** 576 * Returns <code>true</code> if this resource type is direct editable.<p> 577 * 578 * @return <code>true</code> if this resource type is direct editable 579 */ 580 boolean isDirectEditable(); 581 582 /** 583 * Returns <code>true</code> if this resource type is a folder.<p> 584 * 585 * @return <code>true</code> if this resource type is a folder 586 */ 587 boolean isFolder(); 588 589 /** 590 * Tests if the given resource type definition is identical to this resource type definition.<p> 591 * 592 * Two resource types are considered identical if their names {@link #getTypeName()} 593 * <b>and</b> their ids {@link #getTypeId()} are both the same.<p> 594 * 595 * <b>Please note:</b> Two resource type are considered equal in the sense of {@link Object#equals(Object)} if 596 * either if their names {@link #getTypeName()} <b>or</b> their ids {@link #getTypeId()} are equal.<p> 597 * 598 * @param type another resource type 599 * 600 * @return true, if the specified resource type is identical to this resource type 601 */ 602 boolean isIdentical(I_CmsResourceType type); 603 604 /** 605 * Locks a resource.<p> 606 * 607 * The <code>type</code> parameter controls what kind of lock is used.<br> 608 * Possible values for this parameter are: <br> 609 * <ul> 610 * <li><code>{@link org.opencms.lock.CmsLockType#EXCLUSIVE}</code></li> 611 * <li><code>{@link org.opencms.lock.CmsLockType#TEMPORARY}</code></li> 612 * </ul><p> 613 * 614 * @param cms the initialized CmsObject 615 * @param securityManager the initialized OpenCms security manager 616 * @param resource the resource to lock 617 * @param type type of the lock 618 * 619 * @throws CmsException if something goes wrong 620 * 621 * @see CmsObject#lockResource(String) 622 * @see CmsSecurityManager#lockResource(org.opencms.file.CmsRequestContext, CmsResource, CmsLockType) 623 */ 624 void lockResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, CmsLockType type) 625 throws CmsException; 626 627 /** 628 * Moves a resource to the given destination.<p> 629 * 630 * A move operation in OpenCms is always a copy (as sibling) followed by a delete, 631 * this is a result of the online/offline structure of the 632 * OpenCms VFS. This way you can see the deleted files/folders in the offline 633 * project, and you will be unable to undelete them.<p> 634 * 635 * @param cms the current cms context 636 * @param securityManager the initialized OpenCms security manager 637 * @param resource the resource to move 638 * @param destination the destination resource name 639 * 640 * @throws CmsException if something goes wrong 641 * @throws CmsIllegalArgumentException if the <code>source</code> argument is null or of length 0 642 * 643 * 644 * @see CmsObject#moveResource(String, String) 645 * @see CmsObject#renameResource(String, String) 646 * @see CmsSecurityManager#copyResource(org.opencms.file.CmsRequestContext, CmsResource, String, CmsResource.CmsResourceCopyMode) 647 * @see CmsSecurityManager#deleteResource(org.opencms.file.CmsRequestContext, CmsResource, CmsResource.CmsResourceDeleteMode) 648 */ 649 void moveResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, String destination) 650 throws CmsException, CmsIllegalArgumentException; 651 652 /** 653 * Removes a resource from the current project of the user.<p> 654 * 655 * This is used to reduce the current users project with the 656 * specified resource, in case that the resource is already part of the project. 657 * The resource is not really removed like in a regular copy operation, 658 * it is in fact only "disabled" in the current users project.<p> 659 * 660 * @param cms the initialized CmsObject 661 * @param securityManager the initialized OpenCms security manager 662 * @param resource the resource to apply this operation to 663 * 664 * @throws CmsException if something goes wrong 665 * @throws CmsIllegalArgumentException if the <code>resource</code> argument is null or of length 0 666 * 667 * @see CmsObject#copyResourceToProject(String) 668 * @see CmsSecurityManager#copyResourceToProject(org.opencms.file.CmsRequestContext, CmsResource) 669 */ 670 void removeResourceFromProject(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) 671 throws CmsException, CmsIllegalArgumentException; 672 673 /** 674 * Replaces the content, type and properties of a resource.<p> 675 * 676 * @param cms the current cms context 677 * @param securityManager the initialized OpenCms security manager 678 * @param resource the name of the resource to replace 679 * @param type the new type of the resource 680 * @param content the new content of the resource 681 * @param properties the new properties of the resource 682 * 683 * @throws CmsException if something goes wrong 684 * 685 * @see CmsObject#replaceResource(String, int, byte[], List) 686 * @see CmsSecurityManager#replaceResource(org.opencms.file.CmsRequestContext, CmsResource, int, byte[], List) 687 */ 688 void replaceResource( 689 CmsObject cms, 690 CmsSecurityManager securityManager, 691 CmsResource resource, 692 I_CmsResourceType type, 693 byte[] content, 694 List<CmsProperty> properties) 695 throws CmsException; 696 697 /** 698 * Replaces the content, type and properties of a resource.<p> 699 * 700 * @param cms the current cms context 701 * @param securityManager the initialized OpenCms security manager 702 * @param resource the name of the resource to replace 703 * @param type the new type of the resource 704 * @param content the new content of the resource 705 * @param properties the new properties of the resource 706 * 707 * @throws CmsException if something goes wrong 708 * 709 * @see CmsObject#replaceResource(String, int, byte[], List) 710 * @see CmsSecurityManager#replaceResource(org.opencms.file.CmsRequestContext, CmsResource, int, byte[], List) 711 * 712 * @deprecated 713 * Use {@link #replaceResource(CmsObject, CmsSecurityManager, CmsResource, I_CmsResourceType, byte[], List)} instead. 714 * Resource types should always be referenced either by this type class (preferred) or by type name. 715 * Use of int based resource type references will be discontinued in a future OpenCms release. 716 */ 717 @Deprecated 718 void replaceResource( 719 CmsObject cms, 720 CmsSecurityManager securityManager, 721 CmsResource resource, 722 int type, 723 byte[] content, 724 List<CmsProperty> properties) 725 throws CmsException; 726 727 /** 728 * Restores a resource in the current project with a version from the historical archive.<p> 729 * 730 * @param cms the current cms context 731 * @param securityManager the initialized OpenCms security manager 732 * @param resource the resource to restore from the archive 733 * @param version the version number of the resource to restore 734 * 735 * @throws CmsException if something goes wrong 736 * 737 * @see CmsObject#restoreResourceVersion(org.opencms.util.CmsUUID, int) 738 * @see CmsSecurityManager#restoreResource(org.opencms.file.CmsRequestContext, CmsResource, int) 739 */ 740 void restoreResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, int version) 741 throws CmsException; 742 743 /** 744 * Sets the additional resource type flag.<p> 745 * @param additionalType true or false 746 */ 747 void setAdditionalModuleResourceType(boolean additionalType); 748 749 /** 750 * Sets the folder for adjusting links after copying the copy-resources.<p> 751 * 752 * @param adjustLinksFolder the folder for which links should be adjusted 753 */ 754 void setAdjustLinksFolder(String adjustLinksFolder); 755 756 /** 757 * Changes the "expire" date of a resource.<p> 758 * 759 * @param cms the current cms context 760 * @param securityManager the initialized OpenCms security manager 761 * @param resource the resource to touch 762 * @param dateExpired the new expire date of the changed resource 763 * @param recursive if this operation is to be applied recursively to all resources in a folder 764 * 765 * @throws CmsException if something goes wrong 766 * 767 * @see CmsObject#setDateExpired(String, long, boolean) 768 * @see CmsSecurityManager#setDateExpired(org.opencms.file.CmsRequestContext, CmsResource, long) 769 */ 770 void setDateExpired( 771 CmsObject cms, 772 CmsSecurityManager securityManager, 773 CmsResource resource, 774 long dateExpired, 775 boolean recursive) 776 throws CmsException; 777 778 /** 779 * Changes the "last modified" date of a resource.<p> 780 * 781 * @param cms the current cms context 782 * @param securityManager the initialized OpenCms security manager 783 * @param resource the resource to touch 784 * @param dateLastModified timestamp the new timestamp of the changed resource 785 * @param recursive if this operation is to be applied recursively to all resources in a folder 786 * 787 * @throws CmsException if something goes wrong 788 * 789 * @see CmsObject#setDateLastModified(String, long, boolean) 790 * @see CmsSecurityManager#setDateLastModified(org.opencms.file.CmsRequestContext, CmsResource, long) 791 */ 792 void setDateLastModified( 793 CmsObject cms, 794 CmsSecurityManager securityManager, 795 CmsResource resource, 796 long dateLastModified, 797 boolean recursive) 798 throws CmsException; 799 800 /** 801 * Changes the "release" date of a resource.<p> 802 * 803 * @param cms the current cms context 804 * @param securityManager the initialized OpenCms security manager 805 * @param resource the resource to touch 806 * @param dateReleased the new release date of the changed resource 807 * @param recursive if this operation is to be applied recursively to all resources in a folder 808 * 809 * @throws CmsException if something goes wrong 810 * 811 * @see CmsObject#setDateReleased(String, long, boolean) 812 * @see CmsSecurityManager#setDateReleased(org.opencms.file.CmsRequestContext, CmsResource, long) 813 */ 814 void setDateReleased( 815 CmsObject cms, 816 CmsSecurityManager securityManager, 817 CmsResource resource, 818 long dateReleased, 819 boolean recursive) 820 throws CmsException; 821 822 /** 823 * Sets the module name if this is an additional resource type which is defined in a module, or <code>null</code>.<p> 824 * 825 * @param moduleName the module name if this is an additional resource type which is defined in a module, or <code>null</code> 826 */ 827 void setModuleName(String moduleName); 828 829 /** 830 * Undeletes a resource.<p> 831 * 832 * Only resources that have already been published once can be undeleted, 833 * if a "new" resource is deleted it can not be undeleted.<p> 834 * 835 * @param cms the current cms context 836 * @param securityManager the initialized OpenCms security manager 837 * @param resource the resource to undelete 838 * @param recursive if this operation is to be applied recursively to all resources in a folder 839 * 840 * @throws CmsException if something goes wrong 841 * 842 * @see CmsObject#undeleteResource(String, boolean) 843 * @see CmsSecurityManager#undelete(org.opencms.file.CmsRequestContext, CmsResource) 844 */ 845 void undelete(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource, boolean recursive) 846 throws CmsException; 847 848 /** 849 * Undos all changes in the resource by restoring the version from the 850 * online project to the current offline project.<p> 851 * 852 * @param cms the current cms context 853 * @param securityManager the initialized OpenCms security manager 854 * @param resource the resource to undo the changes for 855 * @param mode the undo mode, one of the <code>{@link org.opencms.file.CmsResource.CmsResourceUndoMode}#UNDO_XXX</code> constants 856 * 857 * @throws CmsException if something goes wrong 858 * 859 * @see CmsResource#UNDO_CONTENT 860 * @see CmsResource#UNDO_CONTENT_RECURSIVE 861 * @see CmsResource#UNDO_MOVE_CONTENT 862 * @see CmsResource#UNDO_MOVE_CONTENT_RECURSIVE 863 * @see CmsObject#undoChanges(String, CmsResource.CmsResourceUndoMode) 864 * @see CmsSecurityManager#undoChanges(org.opencms.file.CmsRequestContext, CmsResource, org.opencms.file.CmsResource.CmsResourceUndoMode) 865 */ 866 void undoChanges( 867 CmsObject cms, 868 CmsSecurityManager securityManager, 869 CmsResource resource, 870 CmsResource.CmsResourceUndoMode mode) 871 throws CmsException; 872 873 /** 874 * Unlocks a resource.<p> 875 * 876 * @param cms the current cms context 877 * @param securityManager the initialized OpenCms security manager 878 * @param resource the resource to unlock 879 * 880 * @throws CmsException if something goes wrong 881 * 882 * @see CmsObject#unlockResource(String) 883 * @see CmsSecurityManager#unlockResource(org.opencms.file.CmsRequestContext, CmsResource) 884 */ 885 void unlockResource(CmsObject cms, CmsSecurityManager securityManager, CmsResource resource) throws CmsException; 886 887 /** 888 * Writes a resource, including it's content.<p> 889 * 890 * Applies only to resources of type <code>{@link CmsFile}</code> 891 * that have a binary content attached.<p> 892 * 893 * @param cms the current cms context 894 * @param securityManager the initialized OpenCms security manager 895 * @param resource the resource to apply this operation to 896 * 897 * @return the written resource 898 * 899 * @throws CmsException if something goes wrong 900 * 901 * @see CmsObject#writeFile(CmsFile) 902 * @see CmsSecurityManager#writeFile(org.opencms.file.CmsRequestContext, CmsFile) 903 */ 904 CmsFile writeFile(CmsObject cms, CmsSecurityManager securityManager, CmsFile resource) throws CmsException; 905 906 /** 907 * Writes a property for a specified resource.<p> 908 * 909 * @param cms the current cms context 910 * @param securityManager the initialized OpenCms security manager 911 * @param resource the resource to write the property for 912 * @param property the property to write 913 * 914 * @throws CmsException if something goes wrong 915 * 916 * @see CmsObject#writePropertyObject(String, CmsProperty) 917 * @see CmsSecurityManager#writePropertyObject(org.opencms.file.CmsRequestContext, CmsResource, CmsProperty) 918 */ 919 void writePropertyObject( 920 CmsObject cms, 921 CmsSecurityManager securityManager, 922 CmsResource resource, 923 CmsProperty property) 924 throws CmsException; 925 926 /** 927 * Writes a list of properties for a specified resource.<p> 928 * 929 * Code calling this method has to ensure that the no properties 930 * <code>a, b</code> are contained in the specified list so that <code>a.equals(b)</code>, 931 * otherwise an exception is thrown.<p> 932 * 933 * @param cms the current cms context 934 * @param securityManager the initialized OpenCms security manager 935 * @param resource the resource to write the properties for 936 * @param properties the list of properties to write 937 * 938 * @throws CmsException if something goes wrong 939 * 940 * @see CmsObject#writePropertyObjects(String, List) 941 * @see CmsSecurityManager#writePropertyObjects(org.opencms.file.CmsRequestContext, CmsResource, List) 942 */ 943 void writePropertyObjects( 944 CmsObject cms, 945 CmsSecurityManager securityManager, 946 CmsResource resource, 947 List<CmsProperty> properties) 948 throws CmsException; 949}