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