|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.file.wrapper.CmsObjectWrapper
public class CmsObjectWrapper
This class contains a subset of the methods of CmsObject
and uses the
configured resource wrappers (I_CmsResourceWrapper
) to change the view
to the existing resources in the VFS.
Almost every method in this class iterates through the configured list of
I_CmsResourceWrapper
and calls the same method there. The first resource
wrapper in the list which feels responsible for that action handles it and the
iteration ends. So the resource wrappers should check in every method if it is
responsible or not. Be careful if there are more than one resource wrapper for
the same resource in the VFS, because the first in the list wins. If the iteration is
finished and no resource wrapper felt responsible the default action is to call the
method in the CmsObject
.
It is possible to create an unchanged access to the resource in the VFS by creating a new instance of the CmsObjectWrapper with an empty list of resource wrappers.
Field Summary | |
---|---|
static java.lang.String |
ATTRIBUTE_NAME
The name of the attribute in the CmsRequestContext where the current CmsObjectWrapper can be found. |
Constructor Summary | |
---|---|
CmsObjectWrapper(CmsObject cms,
java.util.List wrappers)
Constructor with the CmsObject to wrap and the resource wrappers to use. |
Method Summary | |
---|---|
void |
copyResource(java.lang.String source,
java.lang.String destination,
CmsResource.CmsResourceCopyMode siblingMode)
Copies a resource. |
CmsResource |
createResource(java.lang.String resourcename,
int type)
Creates a new resource of the given resource type with empty content and no properties. |
CmsResource |
createResource(java.lang.String resourcename,
int type,
byte[] content,
java.util.List properties)
Creates a new resource of the given resource type with the provided content and properties. |
void |
deleteResource(java.lang.String resourcename,
CmsResource.CmsResourceDeleteMode siblingMode)
Deletes a resource given its name. |
boolean |
existsResource(java.lang.String resourcename)
Checks the availability of a resource in the VFS, using the CmsResourceFilter.DEFAULT filter. |
CmsLock |
getLock(CmsResource resource)
Returns the lock state for a specified resource. |
CmsRequestContext |
getRequestContext()
Delegate method for CmsObject.getRequestContext() . |
java.util.List |
getResourcesInFolder(java.lang.String resourcename,
CmsResourceFilter filter)
Returns all child resources of a resource, that is the resources contained in a folder. |
java.lang.String |
getSitePath(CmsResource resource)
Delegate method for CmsObject.getSitePath(CmsResource) . |
java.util.List |
getWrappers()
Returns the configured resource wrappers used by this instance. |
void |
lockResource(java.lang.String resourcename)
Locks a resource. |
void |
moveResource(java.lang.String source,
java.lang.String destination)
Moves a resource to the given destination. |
CmsFile |
readFile(java.lang.String resourcename,
CmsResourceFilter filter)
Reads a file resource (including it's binary content) from the VFS, using the specified resource filter. |
CmsProperty |
readPropertyObject(CmsResource resource,
java.lang.String property,
boolean search)
Delegate method for CmsObject.readPropertyObject(CmsResource, String, boolean) . |
CmsResource |
readResource(CmsUUID structureID,
CmsResourceFilter filter)
Delegate method for CmsObject.readResource(CmsUUID, CmsResourceFilter) . |
CmsResource |
readResource(java.lang.String resourcename,
CmsResourceFilter filter)
Reads a resource from the VFS, using the filter. |
CmsUser |
readUser(CmsUUID userId)
Delegate method for CmsObject.readUser(CmsUUID) . |
java.lang.String |
restoreLink(java.lang.String path)
Returns a link to an existing resource in the VFS. |
java.lang.String |
rewriteLink(java.lang.String path)
Returns a link to a resource after it was wrapped by the CmsObjectWrapper. |
void |
unlockResource(java.lang.String resourcename)
Unlocks a resource. |
CmsFile |
writeFile(CmsFile resource)
Writes a resource to the OpenCms VFS, including it's content. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String ATTRIBUTE_NAME
CmsRequestContext
where the current CmsObjectWrapper can be found.
Constructor Detail |
---|
public CmsObjectWrapper(CmsObject cms, java.util.List wrappers)
cms
- the initialized CmsObjectwrappers
- the configured wrappers to use (entries of type I_CmsResourceWrapper
)Method Detail |
---|
public void copyResource(java.lang.String source, java.lang.String destination, CmsResource.CmsResourceCopyMode siblingMode) throws CmsException, CmsIllegalArgumentException
Iterates through all configured resource wrappers till the first returns true
.
source
- the name of the resource to copy (full path)destination
- the name of the copy destination (full path)siblingMode
- indicates how to handle siblings during copy
CmsException
- if something goes wrong
CmsIllegalArgumentException
- if the destination
argument is null or of length 0I_CmsResourceWrapper.copyResource(CmsObject, String, String, CmsResource.CmsResourceCopyMode)
,
CmsObject.copyResource(String, String, CmsResource.CmsResourceCopyMode)
public CmsResource createResource(java.lang.String resourcename, int type) throws CmsException, CmsIllegalArgumentException
resourcename
- the name of the resource to create (full path)type
- the type of the resource to create
CmsException
- if something goes wrong
CmsIllegalArgumentException
- if the given resourcename
is null or of length 0createResource(String, int, byte[], List)
public CmsResource createResource(java.lang.String resourcename, int type, byte[] content, java.util.List properties) throws CmsException, CmsIllegalArgumentException
Iterates through all configured resource wrappers till the first returns not null
.
resourcename
- the name of the resource to create (full path)type
- the type of the resource to createcontent
- the contents for the new resourceproperties
- the properties for the new resource
CmsException
- if something goes wrong
CmsIllegalArgumentException
- if the resourcename
argument is null or of length 0I_CmsResourceWrapper.createResource(CmsObject, String, int, byte[], List)
,
CmsObject.createResource(String, int, byte[], List)
public void deleteResource(java.lang.String resourcename, CmsResource.CmsResourceDeleteMode siblingMode) throws CmsException
Iterates through all configured resource wrappers till the first returns true
.
resourcename
- the name of the resource to delete (full path)siblingMode
- indicates how to handle siblings of the deleted resource
CmsException
- if something goes wrongI_CmsResourceWrapper.deleteResource(CmsObject, String, CmsResource.CmsResourceDeleteMode)
,
CmsObject.deleteResource(String, CmsResource.CmsResourceDeleteMode)
public boolean existsResource(java.lang.String resourcename)
CmsResourceFilter.DEFAULT
filter.
Here it will be first checked if the resource exists in the VFS by calling
CmsObject.existsResource(String)
. Only if it doesn't exist
in the VFS the method I_CmsResourceWrapper.readResource(CmsObject, String, CmsResourceFilter)
in the configured resource wrappers are called till the first does not throw an exception or returns
null
.
resourcename
- the name of the resource to check (full path)
true
if the resource is availablepublic CmsLock getLock(CmsResource resource) throws CmsException
Iterates through all configured resource wrappers till the first returns not null
.
resource
- the resource to return the lock state for
CmsException
- if something goes wrongI_CmsResourceWrapper.getLock(CmsObject, CmsResource)
,
CmsObject.getLock(CmsResource)
public CmsRequestContext getRequestContext()
CmsObject.getRequestContext()
.
CmsObject.getRequestContext()
public java.util.List getResourcesInFolder(java.lang.String resourcename, CmsResourceFilter filter) throws CmsException
First fetch all child resources from VFS by calling CmsObject.getResourcesInFolder(String, CmsResourceFilter)
.
After that all resource wrapper are called I_CmsResourceWrapper.addResourcesToFolder(CmsObject, String, CmsResourceFilter)
to have the chance to add additional resources to those already existing. In that list every resource is given to
the appropriate resource wrapper (I_CmsResourceWrapper.wrapResource(CmsObject, CmsResource)
) to have the
possibility to change the existing resources. The matching resource wrapper for a resource is found by a call to
I_CmsResourceWrapper.isWrappedResource(CmsObject, CmsResource)
.
resourcename
- the full path of the resource to return the child resources forfilter
- the resource filter to use
CmsResource
s
CmsException
- if something goes wrongI_CmsResourceWrapper.addResourcesToFolder(CmsObject, String, CmsResourceFilter)
,
CmsObject.getResourcesInFolder(String, CmsResourceFilter)
public java.lang.String getSitePath(CmsResource resource)
CmsObject.getSitePath(CmsResource)
.
resource
- the resource to get the adjusted site root path for
CmsObject.getSitePath(org.opencms.file.CmsResource)
public java.util.List getWrappers()
Entries in list are from type I_CmsResourceWrapper
.
public void lockResource(java.lang.String resourcename) throws CmsException
Iterates through all configured resource wrappers till the first returns true
.
resourcename
- the name of the resource to lock (full path)
CmsException
- if something goes wrongI_CmsResourceWrapper.lockResource(CmsObject, String)
,
CmsObject.lockResource(String)
public void moveResource(java.lang.String source, java.lang.String destination) throws CmsException
Iterates through all configured resource wrappers till the first returns true
.
source
- the name of the resource to move (full path)destination
- the destination resource name (full path)
CmsException
- if something goes wrongI_CmsResourceWrapper.moveResource(CmsObject, String, String)
,
CmsObject.moveResource(String, String)
public CmsFile readFile(java.lang.String resourcename, CmsResourceFilter filter) throws CmsException
Iterates through all configured resource wrappers till the first returns not null
.
If the resource contains textual content and the encoding is UTF-8, then the byte order mask for UTF-8 is added at the start of the content to make sure that a client using this content displays it correctly.
resourcename
- the name of the resource to read (full path)filter
- the resource filter to use while reading
CmsException
- if the file resource could not be read for any reasonI_CmsResourceWrapper.readFile(CmsObject, String, CmsResourceFilter)
,
CmsObject.readFile(String, CmsResourceFilter)
public CmsProperty readPropertyObject(CmsResource resource, java.lang.String property, boolean search) throws CmsException
CmsObject.readPropertyObject(CmsResource, String, boolean)
.
resource
- the resource where the property is attached toproperty
- the property namesearch
- if true, the property is searched on all parent folders of the resource,
if it's not found attached directly to the resource
CmsProperty.getNullProperty()
if the property was not found
CmsException
- if something goes wrongCmsObject.readPropertyObject(CmsResource, String, boolean)
public CmsResource readResource(CmsUUID structureID, CmsResourceFilter filter) throws CmsException
CmsObject.readResource(CmsUUID, CmsResourceFilter)
.
structureID
- the ID of the structure to readfilter
- the resource filter to use while reading
CmsException
- if the resource could not be read for any reasonCmsObject.readResource(CmsUUID, CmsResourceFilter)
public CmsResource readResource(java.lang.String resourcename, CmsResourceFilter filter) throws CmsException
CmsResourceFilter.DEFAULT
filter.
Iterates through all configured resource wrappers till the first returns not null
.
resourcename
- The name of the resource to read (full path)filter
- the resource filter to use while reading
CmsException
- if the resource could not be read for any reasonI_CmsResourceWrapper.readResource(CmsObject, String, CmsResourceFilter)
,
CmsObject.readResource(String, CmsResourceFilter)
public CmsUser readUser(CmsUUID userId) throws CmsException
CmsObject.readUser(CmsUUID)
.
userId
- the id of the user to be read
CmsException
- if something goes wrongCmsObject.readUser(CmsUUID)
public java.lang.String restoreLink(java.lang.String path)
Because it is possible through the CmsObjectWrapper
to create "virtual" resources,
which can not be found in the VFS, it is necessary to change the links in pages
as well, so that they point to resources which really exists in the VFS.
Iterates through all configured resource wrappers till the first returns not null
.
path
- the path to the resource
rewriteLink(String)
,
I_CmsResourceWrapper.restoreLink(CmsObject, String)
public java.lang.String rewriteLink(java.lang.String path)
Because it is possible to change the names of resources inside the VFS by this
CmsObjectWrapper
, it is necessary to change the links used in pages
as well, so that they point to the changed name of the resource.
For example: /sites/default/index.html
becomes to
/sites/default/index.html.jsp
, because it is a jsp page, the links
in pages where corrected so that they point to the new name (with extension "jsp").
Used for the link processing in the class CmsLink
.
Iterates through all configured resource wrappers till the first returns not null
.
path
- the full path where to find the resource
restoreLink(String)
,
I_CmsResourceWrapper.rewriteLink(CmsObject, CmsResource)
public void unlockResource(java.lang.String resourcename) throws CmsException
Iterates through all configured resource wrappers till the first returns true
.
resourcename
- the name of the resource to unlock (full path)
CmsException
- if something goes wrongI_CmsResourceWrapper.unlockResource(CmsObject, String)
,
CmsObject.unlockResource(String)
public CmsFile writeFile(CmsFile resource) throws CmsException
Iterates through all configured resource wrappers till the first returns not null
.
resource
- the resource to write
CmsException
- if something goes wrongI_CmsResourceWrapper.writeFile(CmsObject, CmsFile)
,
CmsObject.writeFile(CmsFile)
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |