com.opencms.file
Interface I_CmsResourceType

All Known Implementing Classes:
CmsResourceTypeFolder, CmsResourceTypePage, CmsResourceTypePlain

public interface I_CmsResourceType

Defines of all methods that a specific resource type has to implement.

Author:
Thomas Weckert (t.weckert@alkacon.com)

Method Summary
 void changeLockedInProject(CmsObject cms, int newProjectId, String resourcename)
          Changes the project-id of the resource to the new project for publishing the resource directly
 void chgrp(CmsObject cms, String filename, String newGroup, boolean chRekursive)
          Changes the group of a resource.
 void chmod(CmsObject cms, String filename, int flags, boolean chRekursive)
          Changes the flags of a resource.
 void chown(CmsObject cms, String filename, String newOwner, boolean chRekursive)
          Changes the owner of a resource.
 void chtype(CmsObject cms, String filename, String newType)
          Changes the resourcetype of a resource.
 void copyResource(CmsObject cms, String source, String destination, boolean keepFlags)
          Copies a Resource.
 void copyResourceToProject(CmsObject cms, String resourceName)
          Copies the resourcename to the current offline project
 CmsResource createResource(CmsObject cms, String newResourceName, Map properties, byte[] contents, Object parameter)
          Creates a new resource.
 void deleteResource(CmsObject cms, String filename)
          Deletes a resource.
 CmsFile exportResource(CmsObject cms, CmsFile file)
          Does the Linkmanagement when a resource will be exported.
 String getLauncherClass()
          Returns the name of the Java class loaded by the launcher.
 int getLauncherType()
          Returns the launcher type needed for this resource-type.
 int getResourceType()
          Returns the type of this resource-type.
 String getResourceTypeName()
          Returns the name for this resource-type.
 CmsResource importResource(CmsObject cms, String source, String destination, String type, String user, String group, String access, long lastmodified, Map properties, String launcherStartClass, byte[] content, String importPath)
          Does the Linkmanagement when a resource is imported.
 void init(int resourceType, int launcherType, String resourceTypeName, String launcherClass)
          init a new CmsResourceType object.
 void lockResource(CmsObject cms, String resource, boolean force)
          Locks a given resource.
 void moveResource(CmsObject cms, String source, String destination)
          Moves a file to the given destination.
 void renameResource(CmsObject cms, String oldname, String newname)
          Renames the file to the new name.
 void restoreResource(CmsObject cms, int versionId, String filename)
          Restores a file in the current project with a version in the backup
 void touch(CmsObject cms, String resourceName, long timestamp, boolean touchRecursive)
          Change the timestamp of a resource.
 void undeleteResource(CmsObject cms, String filename)
          Deletes a resource.
 void undoChanges(CmsObject cms, String filename)
          Undo all changes in the resource, restore the online file.
 void unlockResource(CmsObject cms, String resource)
          Unlocks a resource.
 

Method Detail

init

public void init(int resourceType,
                 int launcherType,
                 String resourceTypeName,
                 String launcherClass)
init a new CmsResourceType object.

Parameters:
resourceType - The id of the resource type.
launcherType - The id of the required launcher.
resourceTypeName - The printable name of the resource type.
launcherClass - The Java class that should be invoked by the launcher. This value is null if the default invokation class should be used.

getLauncherClass

public String getLauncherClass()
Returns the name of the Java class loaded by the launcher. This method returns null if the default class for this type is used.

Returns:
the name of the Java class.

getLauncherType

public int getLauncherType()
Returns the launcher type needed for this resource-type.

Returns:
the launcher type for this resource-type.

getResourceTypeName

public String getResourceTypeName()
Returns the name for this resource-type.

Returns:
the name for this resource-type.

getResourceType

public int getResourceType()
Returns the type of this resource-type.

Returns:
the type of this resource-type.

chgrp

public void chgrp(CmsObject cms,
                  String filename,
                  String newGroup,
                  boolean chRekursive)
           throws CmsException
Changes the group of a resource.
Only the group of a resource in an offline project can be changed. The state of the resource is set to CHANGED (1). If the content of this resource is not existing in the offline project already, it is read from the online project and written into the offline project.

Security: Access is granted, if:

Parameters:
filename - the complete path to the resource.
newGroup - the name of the new group for this resource.
chRekursive - shows if the subResources (of a folder) should be changed too.
Throws:
CmsException - if operation was not successful.

chmod

public void chmod(CmsObject cms,
                  String filename,
                  int flags,
                  boolean chRekursive)
           throws CmsException
Changes the flags of a resource.
Only the flags of a resource in an offline project can be changed. The state of the resource is set to CHANGED (1). If the content of this resource is not existing in the offline project already, it is read from the online project and written into the offline project. The user may change the flags, if he is admin of the resource.

Security: Access is granted, if:

Parameters:
filename - the complete path to the resource.
flags - the new flags for the resource.
chRekursive - shows if the subResources (of a folder) should be changed too.
Throws:
CmsException - if operation was not successful. for this resource.

chown

public void chown(CmsObject cms,
                  String filename,
                  String newOwner,
                  boolean chRekursive)
           throws CmsException
Changes the owner of a resource.
Only the owner of a resource in an offline project can be changed. The state of the resource is set to CHANGED (1). If the content of this resource is not existing in the offline project already, it is read from the online project and written into the offline project. The user may change this, if he is admin of the resource.

Security: Access is granted, if:

Parameters:
filename - the complete path to the resource.
newOwner - the name of the new owner for this resource.
chRekursive - shows if the subResources (of a folder) should be changed too.
Throws:
CmsException - if operation was not successful.

touch

public void touch(CmsObject cms,
                  String resourceName,
                  long timestamp,
                  boolean touchRecursive)
           throws CmsException
Change the timestamp of a resource.

Parameters:
resourceName - the name of the resource to change
timestamp - timestamp the new timestamp of the changed resource
CmsException

chtype

public void chtype(CmsObject cms,
                   String filename,
                   String newType)
            throws CmsException
Changes the resourcetype of a resource.
Only the resourcetype of a resource in an offline project can be changed. The state of the resource is set to CHANGED (1). If the content of this resource is not exisiting in the offline project already, it is read from the online project and written into the offline project. The user may change this, if he is admin of the resource.

Security: Access is granted, if:

Parameters:
filename - the complete path to the resource.
newType - the name of the new resourcetype for this resource.
Throws:
CmsException - if operation was not successful.

copyResource

public void copyResource(CmsObject cms,
                         String source,
                         String destination,
                         boolean keepFlags)
                  throws CmsException
Copies a Resource.

Parameters:
source - the complete path of the sourcefile.
destination - the complete path of the destinationfolder.
keepFlags - true if the copy should keep the source file's flags, false if the copy should get the user's default flags.
Throws:
CmsException - if the file couldn't be copied, or the user has not the appropriate rights to copy the file.

copyResourceToProject

public void copyResourceToProject(CmsObject cms,
                                  String resourceName)
                           throws CmsException
Copies the resourcename to the current offline project

Parameters:
cms - The CmsObject
resourceName - The name of the resource
Throws:
CmsException - if operation was not successful.

createResource

public CmsResource createResource(CmsObject cms,
                                  String newResourceName,
                                  Map properties,
                                  byte[] contents,
                                  Object parameter)
                           throws CmsException
Creates a new resource.

Parameters:
contents - the contents of the new file.
Returns:
file a CmsFile object representing the newly created file.
Throws:
CmsException - if the resourcetype is set to folder. The CmsException is also thrown, if the filename is not valid or if the user has not the appropriate rights to create a new file.

deleteResource

public void deleteResource(CmsObject cms,
                           String filename)
                    throws CmsException
Deletes a resource.

Parameters:
filename - the complete path of the file.
Throws:
CmsException - if the file couldn't be deleted, or if the user has not the appropriate rights to delete the file.

undeleteResource

public void undeleteResource(CmsObject cms,
                             String filename)
                      throws CmsException
Deletes a resource.

Parameters:
filename - the complete path of the file.
Throws:
CmsException - if the file couldn't be deleted, or if the user has not the appropriate rights to delete the file.

exportResource

public CmsFile exportResource(CmsObject cms,
                              CmsFile file)
                       throws CmsException
Does the Linkmanagement when a resource will be exported. When a resource has to be exported, the IDīs inside the Linkmanagement-Tags have to be changed to the corresponding URLīs

Parameters:
file - is the file that has to be changed
CmsException

importResource

public CmsResource importResource(CmsObject cms,
                                  String source,
                                  String destination,
                                  String type,
                                  String user,
                                  String group,
                                  String access,
                                  long lastmodified,
                                  Map properties,
                                  String launcherStartClass,
                                  byte[] content,
                                  String importPath)
                           throws CmsException
Does the Linkmanagement when a resource is imported. When a resource has to be imported, the URLīs of the Links inside the resources have to be saved and changed to the corresponding IDīs

CmsException

lockResource

public void lockResource(CmsObject cms,
                         String resource,
                         boolean force)
                  throws CmsException
Locks a given resource.
A user can lock a resource, so he is the only one who can write this resource.

Parameters:
resource - the complete path to the resource to lock.
force - if force is true, a existing locking will be overwritten.
Throws:
CmsException - if the user has not the rights to lock this resource. It will also be thrown, if there is a existing lock and force was set to false.

moveResource

public void moveResource(CmsObject cms,
                         String source,
                         String destination)
                  throws CmsException
Moves a file to the given destination.

Parameters:
source - the complete path of the sourcefile.
destination - the complete path of the destinationfile.
Throws:
CmsException - if the user has not the rights to move this resource, or if the file couldn't be moved.

renameResource

public void renameResource(CmsObject cms,
                           String oldname,
                           String newname)
                    throws CmsException
Renames the file to the new name.

Parameters:
oldname - the complete path to the file which will be renamed.
newname - the new name of the file.
Throws:
CmsException - if the user has not the rights to rename the file, or if the file couldn't be renamed.

restoreResource

public void restoreResource(CmsObject cms,
                            int versionId,
                            String filename)
                     throws CmsException
Restores a file in the current project with a version in the backup

Parameters:
cms - The CmsObject
versionId - The version id of the resource
filename - The name of the file to restore
Throws:
CmsException - Throws CmsException if operation was not succesful.

undoChanges

public void undoChanges(CmsObject cms,
                        String filename)
                 throws CmsException
Undo all changes in the resource, restore the online file.

Throws:
CmsException - Throws CmsException if something goes wrong.

unlockResource

public void unlockResource(CmsObject cms,
                           String resource)
                    throws CmsException
Unlocks a resource.
A user can unlock a resource, so other users may lock this file.

Parameters:
resource - the complete path to the resource to be unlocked.
Throws:
CmsException - if the user has not the rights to unlock this resource.

changeLockedInProject

public void changeLockedInProject(CmsObject cms,
                                  int newProjectId,
                                  String resourcename)
                           throws CmsException
Changes the project-id of the resource to the new project for publishing the resource directly

Parameters:
newProjectId - The Id of the new project
resourcename - The name of the resource to change
CmsException