org.nuxeo.core.resources.model.impl
Class SiteResource

java.lang.Object
  extended by org.eclipse.core.runtime.PlatformObject
      extended by org.nuxeo.core.resources.model.impl.SiteResource
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, ISiteResource
Direct Known Subclasses:
SiteFile, SiteFolder

public abstract class SiteResource
extends org.eclipse.core.runtime.PlatformObject
implements ISiteResource

Abstract implementation of a site resource

Author:
Bogdan Stefanescu

Field Summary
 
Fields inherited from interface org.nuxeo.core.resources.model.ISiteResource
FILE, FOLDER, SITE
 
Constructor Summary
SiteResource(ISite site, java.lang.String path)
           
 
Method Summary
abstract  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.
 ISiteController getController()
           
 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.
abstract  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 class org.eclipse.core.runtime.PlatformObject
getAdapter
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Constructor Detail

SiteResource

public SiteResource(ISite site,
                    java.lang.String path)
Method Detail

getSite

public ISite getSite()
Description copied from interface: ISiteResource
Get the owner site.

Specified by:
getSite in interface ISiteResource
Returns:
the owner site. Cannot be null

getController

public ISiteController getController()

getPath

public java.lang.String getPath()
Description copied from interface: ISiteResource
The path of the resource relative to the owner site

Specified by:
getPath in interface ISiteResource
Returns:
the resource relative path to the site. Cannot be null

getType

public abstract int getType()
Description copied from interface: ISiteResource
Get the resource type.

Specified by:
getType in interface ISiteResource
Returns:
the resource type

accept

public abstract boolean accept(ISiteResourceVisitor visitor,
                               java.lang.Object context)
Description copied from interface: ISiteResource
Accept a visitor on this node of the resource tree

Specified by:
accept in interface ISiteResource
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

public boolean exists()
               throws org.eclipse.core.runtime.CoreException
Description copied from interface: ISiteResource
Check whether the object underlying this handle is existing or not

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

getMetadata

public IResourceMetadata getMetadata()
                              throws org.eclipse.core.runtime.CoreException
Description copied from interface: ISiteResource
Get the resource metadata.

Specified by:
getMetadata in interface ISiteResource
Returns:
the resource metadata or nulol if no metadata was defined
Throws:
org.eclipse.core.runtime.CoreException - if an error occurs

getContents

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

Specified by:
getContents in interface ISiteResource
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

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

Specified by:
delete in interface ISiteResource
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

public void create(IResourceMetadata metadata,
                   IContentSource content,
                   org.eclipse.core.runtime.IProgressMonitor monitor,
                   int flags)
            throws org.eclipse.core.runtime.CoreException
Description copied from interface: ISiteResource
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

Specified by:
create in interface ISiteResource
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

public void modify(IResourceMetadata metadata,
                   IContentSource content,
                   org.eclipse.core.runtime.IProgressMonitor monitor,
                   int flags)
            throws org.eclipse.core.runtime.CoreException
Description copied from interface: ISiteResource
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

Specified by:
modify in interface ISiteResource
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

public void edit(IResourceMetadata metadata,
                 IContentSource content,
                 org.eclipse.core.runtime.IProgressMonitor monitor,
                 int flags)
          throws org.eclipse.core.runtime.CoreException
Description copied from interface: ISiteResource
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 ISiteResource.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 ISiteResource.modify(IResourceMetadata, IContentSource, IProgressMonitor, int) so any restriction applying to this function applies here too.

Specified by:
edit in interface ISiteResource
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

getURI

public java.lang.String getURI()
Description copied from interface: ISiteResource
Get the Unique resource identifier

Specified by:
getURI in interface ISiteResource
Returns:
the resource URI. Cannot be null

getName

public java.lang.String getName()
Description copied from interface: ISiteResource
Get the local name of the resource in its parent. This is the last segment of the resource path.

Specified by:
getName in interface ISiteResource
Returns:
the local name. Cannot be null

getParent

public ISiteFolder getParent()
Description copied from interface: ISiteResource
Get the parent resource. This is a handle operation - the parent resource may not exists

Specified by:
getParent in interface ISiteResource
Returns:
the parent resource or null if none