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