org.nuxeo.core.resources.model
Interface ISiteResource

All Superinterfaces:
org.eclipse.core.runtime.IAdaptable
All Known Subinterfaces:
ISite, ISiteFile, ISiteFolder
All Known Implementing Classes:
Site, SiteFile, SiteFolder, SiteResource

public interface ISiteResource
extends org.eclipse.core.runtime.IAdaptable

A Site resource is a resource specific to a site context. Thus, it belongs to a site and is locally identified by a relative path in the site.
Site resources are the nodes of a tree that forms the site tree, so every resource have a parent resource.

There are two fundamental types of site resources: container resources and leaf resources corresponding to node types in a tree.

The site resources ensure only that underlying objects are organized in a tree structure but they are not constraining in any way the type of these objects. These objects may be of any type: folder or files in a file system, users or groups in a permission system or any other type of objects that make sense in a tree structure

Underlying objects are described by an IResourceMetadata object

Any site resource may support having contents even folders and sites.
Operations on resources available through the ISiteResource API are allways synchronous operations even if you use the ISiteOperation.ASYNCHRONOUS flag. This flag is cleared before executing the operation to ensure synchornous execution.

Author:
Bogdan Stefanescu
See Also:
IResourceMetadata

Field Summary
static int FILE
           
static int FOLDER
           
static int SITE
           
 
Method Summary
 boolean accept(ISiteResourceVisitor visitor, java.lang.Object context)
          Accept a visitor on this node of the resource tree
 void create(IResourceMetadata metadata, IContentSource content, org.eclipse.core.runtime.IProgressMonitor monitor, int flags)
          Create the resource underlying object using the given metadata and content.
 void delete(org.eclipse.core.runtime.IProgressMonitor monitor, int flags)
          Delete the underlying object if any from its store
 void edit(IResourceMetadata metadata, IContentSource content, org.eclipse.core.runtime.IProgressMonitor monitor, int flags)
          Create or modify the resource by replacing it's metadata with the given one and optionally setting its content.
 boolean exists()
          Check whether the object underlying this handle is existing or not
 IContentSource getContents(org.eclipse.core.runtime.IProgressMonitor monitor, int flags)
          Get the contents under this resource.
 IResourceMetadata getMetadata()
          Get the resource metadata.
 java.lang.String getName()
          Get the local name of the resource in its parent.
 ISiteFolder getParent()
          Get the parent resource.
 java.lang.String getPath()
          The path of the resource relative to the owner site
 ISite getSite()
          Get the owner site.
 int getType()
          Get the resource type.
 java.lang.String getURI()
          Get the Unique resource identifier
 void modify(IResourceMetadata metadata, IContentSource content, org.eclipse.core.runtime.IProgressMonitor monitor, int flags)
          Modify an existing resource.
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

SITE

static final int SITE
See Also:
Constant Field Values

FILE

static final int FILE
See Also:
Constant Field Values

FOLDER

static final int FOLDER
See Also:
Constant Field Values
Method Detail

getURI

java.lang.String getURI()
Get the Unique resource identifier

Returns:
the resource URI. Cannot be null

getName

java.lang.String getName()
Get the local name of the resource in its parent. This is the last segment of the resource path.

Returns:
the local name. Cannot be null

getParent

ISiteFolder getParent()
Get the parent resource. This is a handle operation - the parent resource may not exists

Returns:
the parent resource or null if none

getSite

ISite getSite()
Get the owner site.

Returns:
the owner site. Cannot be null

getPath

java.lang.String getPath()
The path of the resource relative to the owner site

Returns:
the resource relative path to the site. Cannot be null

getType

int getType()
Get the resource type.

Returns:
the resource type

accept

boolean accept(ISiteResourceVisitor visitor,
               java.lang.Object context)
Accept a visitor on this node of the resource tree

Parameters:
visitor - the visitor
context - a context object to be used by the visitor or null
Returns:
true if the traversal must continue otherwise false

exists

boolean exists()
               throws org.eclipse.core.runtime.CoreException
Check whether the object underlying this handle is existing or not

Returns:
true if the underlying resource exists, false otherwise
Throws:
org.eclipse.core.runtime.CoreException - if an error occurs

getMetadata

IResourceMetadata getMetadata()
                              throws org.eclipse.core.runtime.CoreException
Get the resource metadata.

Returns:
the resource metadata or nulol if no metadata was defined
Throws:
org.eclipse.core.runtime.CoreException - if an error occurs

getContents

IContentSource getContents(org.eclipse.core.runtime.IProgressMonitor monitor,
                           int flags)
                           throws org.eclipse.core.runtime.CoreException
Get the contents under this resource. Any resource may have a content set

Parameters:
monitor - the progress monitor to use or null if no monitoring is required
flags - the ISiteOperation flags to use.
Returns:
the resource content as a content source or null if no content is supported The content source stream must be closed when no more needed.
Throws:
org.eclipse.core.runtime.CoreException - if an exception occurs

delete

void delete(org.eclipse.core.runtime.IProgressMonitor monitor,
            int flags)
            throws org.eclipse.core.runtime.CoreException
Delete the underlying object if any from its store

Parameters:
monitor - the progress monitor to use or null if no ptogress monitoring is required
flags - the ISiteOperation flags to use.
Throws:
org.eclipse.core.runtime.CoreException - if the underling object is not existing or other error occured

create

void create(IResourceMetadata metadata,
            IContentSource content,
            org.eclipse.core.runtime.IProgressMonitor monitor,
            int flags)
            throws org.eclipse.core.runtime.CoreException
Create the resource underlying object using the given metadata and content.
The metatada argument must be not null!
If this resource is already existing throws an error

Parameters:
metadata - the resource metadata.
content - the content to set if any or null otherwise
monitor - a progress monitor if progress monitoring is required or null otherwise
flags - the ISiteOperation flags to use.
Throws:
org.eclipse.core.runtime.CoreException - if an error occurs or the resource is already existing

modify

void modify(IResourceMetadata metadata,
            IContentSource content,
            org.eclipse.core.runtime.IProgressMonitor monitor,
            int flags)
            throws org.eclipse.core.runtime.CoreException
Modify an existing resource. If the resource is not existing throws an exception.

Be warned that doing a modify operation may change the resource type (for ex. from file to folder) so be carefull to recreate the resource instance if needed

Parameters:
metadata - the resource metadata. If null metadata is not changed
content - the content to set if any or null otherwise
monitor - a progress monitor if progress monitoring is required or null otherwise
flags - the ISiteOperation flags to use.
Throws:
org.eclipse.core.runtime.CoreException - if an exception occurs or if the resource is not existing

edit

void edit(IResourceMetadata metadata,
          IContentSource content,
          org.eclipse.core.runtime.IProgressMonitor monitor,
          int flags)
          throws org.eclipse.core.runtime.CoreException
Create or modify the resource by replacing it's metadata with the given one and optionally setting its content.

If the resource is not existing the resource will be created - in this case the function is behaving exactly like create(IResourceMetadata, IContentSource, IProgressMonitor, int) so any restricitons applying to this functions applies here too.

If the resource is existing the function will modify it - in this case the fucntion behaves exactly like the modify(IResourceMetadata, IContentSource, IProgressMonitor, int) so any restriction applying to this function applies here too.

Parameters:
metadata - the metadata to set
content - the content to set if any or null otherwise
monitor - the progress monitor or null if no progress monitoring is required
flags - the ISiteOperation flags to use.
Throws:
org.eclipse.core.runtime.CoreException - if an exception occurs