|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.cocoon.jcr.source.JCRSourceFactory
public class JCRSourceFactory
JCRSourceFactory is an implementation of
ModifiableTraversableSource
on top of a JCR (aka JSR-170) repository.
Since JCR allows a repository to define its own node types, it is necessary to configure this source factory with a description of what node types map to "files" and "folders" and the properties used to store source-related data.
A typical configuration for a naked Jackrabbit repository is as follows:
<source-factories> <component-instance class="org.apache.cocoon.jcr.source.JCRSourceFactory" name="jcr"> <folder-node type="rep:root" new-file="nt:file" new-folder="nt:folder"/> <folder-node type="nt:folder" new-file="nt:file"/> <file-node type="nt:file" content-path="jcr:content" content-type="nt:resource"/> <file-node type="nt:linkedFile" content-ref="jcr:content"/> <content-node type="nt:resource" content-prop="jcr:data" mimetype-prop="jcr:mimeType" lastmodified-prop="jcr:lastModified" validity-prop="jcr:lastModified"/> </component-instance> </source-factories>A
<folder-node>
defines a node type that is mapped to a
non-terminal source (i.e. that can have children). The new-file
and new-folder
attributes respectively define what node types
should be used to create a new terminal and non-terminal source.
A <file-node>
defines a note type that is mapped to a
terminal source (i.e. that can have some content). The
content-path
attribute defines the path to the node's child
that actually holds the content, and content-type
defines the
type of this content node.
The content-ref
attribute is used to comply with JCR's
nt:linkedFile
definition where the content node is not a
direct child of the file node, but is referenced by a property of this file
node. Such node types are read-only as there's no way to indicate where the
referenced content node should be created.
A <content-node>
defines a node type that actually holds
the content of a file-node
. The content-prop
attribute must be present and gives the name of the node's binary property
that will hold the actual content. Other attributes are optional:
mimetype-prop
defines a string property holding the
content's MIME type, lastmodified-prop
defines a date property holding the
node's last modification date. It is automatically updated when content is
written to the content-node
. validity-prop
defines a property that gives the validity
of the content, used by Cocoon's cache. If not specified,
lastmodified-prop
is used, if present. Otherwise the source
has no validity and won't be cacheable. The format of URIs for this source is a path in the repository, and it is therefore currently limited to repository traversal. Further work will add the ability to specify query strings.
Nested Class Summary | |
---|---|
protected static class |
JCRSourceFactory.ContentTypeInfo
|
protected static class |
JCRSourceFactory.FileTypeInfo
|
protected static class |
JCRSourceFactory.FolderTypeInfo
|
protected static class |
JCRSourceFactory.NodeTypeInfo
|
Field Summary | |
---|---|
protected ServiceManager |
manager
|
protected Repository |
repo
The repository we use |
protected String |
scheme
Scheme, lazily computed at the first call to getSource() |
protected Map |
typeInfos
The NodeTypeInfo for each of the types described in the configuration |
Fields inherited from interface org.apache.excalibur.source.SourceFactory |
---|
ROLE |
Constructor Summary | |
---|---|
JCRSourceFactory()
|
Method Summary | |
---|---|
void |
configure(Configuration config)
|
Node |
createContentNode(Node fileNode)
Create the content node for a file node. |
Node |
createFileNode(Node folderNode,
String name)
Create a child file node in a folder node. |
JCRNodeSource |
createSource(JCRNodeSource parent,
Node node)
Creates a new source given its parent and its node |
JCRNodeSource |
createSource(Session session,
String path)
Creates a new source given a session and a path |
Node |
getContentNode(Node node)
Get the content node for a given node |
Property |
getContentProperty(Node node)
Get the content property for a given node |
String |
getFolderNodeType(Node folderNode)
Get the node type to create a new subfolder of a given folder node. |
Property |
getLastModifiedDateProperty(Node node)
Get the lastmodified property for a given node |
Property |
getMimeTypeProperty(Node node)
Get the mime-type property for a given node |
String |
getScheme()
|
Source |
getSource(String uri,
Map parameters)
|
JCRSourceFactory.NodeTypeInfo |
getTypeInfo(Node node)
Get the type info for a node. |
Property |
getValidityProperty(Node node)
Get the validity property for a given node |
boolean |
isCollection(Node node)
Does a node represent a collection (i.e. folder-node)? |
protected void |
lazyInit()
|
void |
release(Source source)
|
void |
service(ServiceManager manager)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Repository repo
protected String scheme
protected Map typeInfos
protected ServiceManager manager
Constructor Detail |
---|
public JCRSourceFactory()
Method Detail |
---|
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void configure(Configuration config) throws ConfigurationException
configure
in interface Configurable
ConfigurationException
protected void lazyInit()
public Source getSource(String uri, Map parameters) throws IOException, MalformedURLException
getSource
in interface SourceFactory
IOException
MalformedURLException
public void release(Source source)
release
in interface SourceFactory
public String getScheme()
public JCRSourceFactory.NodeTypeInfo getTypeInfo(Node node) throws RepositoryException
node
- the node
RepositoryException
- if node type couldn't be accessed or if no type info is foundpublic Node getContentNode(Node node) throws RepositoryException
node
- the node for which we want the content node
RepositoryException
- if some error occurs, or if the given node isn't a file node or a content nodepublic JCRNodeSource createSource(JCRNodeSource parent, Node node) throws SourceException
parent
- the parentnode
- the node
SourceException
public JCRNodeSource createSource(Session session, String path) throws SourceException
session
- the sessionpath
- the absolute path
SourceException
public Node createFileNode(Node folderNode, String name) throws RepositoryException
folderNode
- the folder nodename
- the child's name
RepositoryException
- if some error occurspublic Node createContentNode(Node fileNode) throws RepositoryException
fileNode
- the file node
RepositoryException
- if some error occurspublic Property getContentProperty(Node node) throws RepositoryException
node
- a file or content node
RepositoryException
- if some error occurspublic Property getMimeTypeProperty(Node node) throws RepositoryException
node
- a file or content node
null
if no such property exists
RepositoryException
- if some error occurspublic Property getLastModifiedDateProperty(Node node) throws RepositoryException
node
- a file or content node
null
if no such property exists
RepositoryException
- if some error occurspublic Property getValidityProperty(Node node) throws RepositoryException
node
- a file or content node
null
if no such property exists
RepositoryException
- if some error occurspublic boolean isCollection(Node node) throws RepositoryException
node
- the node
true
if it's a collection
RepositoryException
- if some error occurspublic String getFolderNodeType(Node folderNode) throws RepositoryException
folderNode
-
RepositoryException
- if some error occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |