fr.paris.lutece.plugins.jcr.business
Class AbstractRepositoryContentDAO

java.lang.Object
  extended by fr.paris.lutece.plugins.jcr.business.AbstractRepositoryDAO
      extended by fr.paris.lutece.plugins.jcr.business.AbstractRepositoryContentDAO
All Implemented Interfaces:
IJsr170DAO, IRepositoryFileDAO
Direct Known Subclasses:
AlfrescoRepositoryFileDAO, JcrRepositoryFileDAO

public abstract class AbstractRepositoryContentDAO
extends AbstractRepositoryDAO
implements IRepositoryFileDAO

Provides basic methods for node manipulation

Author:
lutecer

Field Summary
protected static String ATTRIBUTE_NODE_SIZE
           
protected static String DEFAULT_MIME_TYPE
           
protected static String MIXIN_REFERENCEABLE
           
protected static String MIXIN_VERSIONNABLE
           
protected static String NODE_TYPE_FILE
           
protected static String NODE_TYPE_FILE_RESOURCE
           
protected static String NODE_TYPE_FOLDER
           
protected static String NODE_TYPE_JCR_CONTENT
           
protected static String PROPERTY_JCR_DATA
           
protected static String PROPERTY_JCR_LASTMODIFIED
           
protected static String PROPERTY_JCR_MIMETYPE
           
protected static String PROPERTY_JCR_NAME
           
protected static String REGEXP_ABSOLUTE_PATH
           
protected static String ROOT_NODE_PATH
           
 
Fields inherited from class fr.paris.lutece.plugins.jcr.business.AbstractRepositoryDAO
_jcrTemplate, _repositoryInitializer, _strDefaultWorkspaceName
 
Constructor Summary
AbstractRepositoryContentDAO()
           
 
Method Summary
 void create(String strWorkspace, String strPath)
          Create a directory in workspace strWorkspace at absolute path strPath
 void create(String strWorkspace, String strFileName, File file, String strMimeType)
          Create a file in workspace strWorkspace at absolute path strPath, with file content.
 void delete(String strWorkspace, String strPath)
          Remove a file from repository
protected abstract  boolean exists(javax.jcr.Node node)
          Tells if a node is present in the repository It must be overloaded by children classes
 IRepositoryFile findById(String strWorkspace, String strId)
          Find a file by its id
 IRepositoryFile findById(String strWorkspace, String strId, String strVersion)
          Find a file by its id
 IRepositoryFile findByPath(String strWorkspace, String strPath)
          Find a file by its path
protected abstract  String getAbsolutePath(javax.jcr.Node node)
          Returns the entire path (absolute)
protected abstract  Calendar getCreated(javax.jcr.Node node)
          Gets the creation date of the node It must be overloaded by children classes
protected  int getDepth()
           
protected abstract  InputStream getFileContent(javax.jcr.Node node)
          Gives access to node content.
 List<IRepositoryFile> getHistory(String strWorkspace, String strNodeId)
          Get all versions for this file
protected abstract  Calendar getLastModified(javax.jcr.Node node)
          Gets the date of last modification It must be overloaded by children classes
protected abstract  String getMimeType(javax.jcr.Node node)
          Gives the Mime Type of a node It must be overloaded by children classes
protected abstract  String getName(javax.jcr.Node node)
          Gives the name of a node It must be overloaded by children classes
protected  String getParentUUID(javax.jcr.Node node)
          Gives the reference of the parent
protected abstract  String getPath(javax.jcr.Node node)
          Gives the path of a node It must be overloaded by children classes
 List<IRepositoryFile> getPathToFile(String strWorkspace, String strFilePath)
           
protected abstract  Properties getProperties()
          Gives a way to the configuration properties
protected  String getProperty(String strPropertyName)
          Retrieves a configuration property
protected abstract  long getSize(javax.jcr.Node node)
          Gets the size of the content node It must only apply to node of type "file" It must be overloaded by children classes
protected  String getUUID(javax.jcr.Node node)
          Gives the reference of a node
protected abstract  boolean isDirectory(javax.jcr.Node node)
          Tells if a node is a directory Note on data structure : a directory doesn't contain anything except other directories and files.
protected abstract  boolean isFile(javax.jcr.Node node)
          Tells if a node is a file.
protected  boolean isVersionnable(javax.jcr.Node node)
          Tells whether a node is versionable
 List<IRepositoryFile> listFiles(String strWorkspace, String strPath)
          List all files in a directory
protected  boolean ownsLock(javax.jcr.Node node)
          Tells if the current user owns a lock on node
 String removeLock(String strWorkspace, IRepositoryFile file)
           
protected  boolean setContent(javax.jcr.Node node, InputStream inputStream, String strFileName, String strMimeType)
          Set the content of a node
 String setLock(String strWorkspace, IRepositoryFile file, String strUsername)
           
 void setVersionnable(String strWorkspace, String strNodeId, boolean isVersionnable)
          Set versionable feature for the specified node
 void store(String strWorkspace, IRepositoryFile file)
          Submit file changes in repository
 
Methods inherited from class fr.paris.lutece.plugins.jcr.business.AbstractRepositoryDAO
execute, execute, free, init, isAlive, releaseSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fr.paris.lutece.plugins.jcr.business.IJsr170DAO
free, isAlive
 

Field Detail

NODE_TYPE_FOLDER

protected static final String NODE_TYPE_FOLDER
See Also:
Constant Field Values

NODE_TYPE_FILE

protected static final String NODE_TYPE_FILE
See Also:
Constant Field Values

NODE_TYPE_FILE_RESOURCE

protected static final String NODE_TYPE_FILE_RESOURCE
See Also:
Constant Field Values

ATTRIBUTE_NODE_SIZE

protected static final String ATTRIBUTE_NODE_SIZE
See Also:
Constant Field Values

NODE_TYPE_JCR_CONTENT

protected static final String NODE_TYPE_JCR_CONTENT
See Also:
Constant Field Values

REGEXP_ABSOLUTE_PATH

protected static final String REGEXP_ABSOLUTE_PATH
See Also:
Constant Field Values

MIXIN_REFERENCEABLE

protected static final String MIXIN_REFERENCEABLE
See Also:
Constant Field Values

MIXIN_VERSIONNABLE

protected static final String MIXIN_VERSIONNABLE
See Also:
Constant Field Values

ROOT_NODE_PATH

protected static final String ROOT_NODE_PATH
See Also:
Constant Field Values

DEFAULT_MIME_TYPE

protected static final String DEFAULT_MIME_TYPE
See Also:
Constant Field Values

PROPERTY_JCR_MIMETYPE

protected static final String PROPERTY_JCR_MIMETYPE
See Also:
Constant Field Values

PROPERTY_JCR_DATA

protected static final String PROPERTY_JCR_DATA
See Also:
Constant Field Values

PROPERTY_JCR_LASTMODIFIED

protected static final String PROPERTY_JCR_LASTMODIFIED
See Also:
Constant Field Values

PROPERTY_JCR_NAME

protected static final String PROPERTY_JCR_NAME
See Also:
Constant Field Values
Constructor Detail

AbstractRepositoryContentDAO

public AbstractRepositoryContentDAO()
Method Detail

create

public void create(String strWorkspace,
                   String strPath)
Description copied from interface: IRepositoryFileDAO
Create a directory in workspace strWorkspace at absolute path strPath

Specified by:
create in interface IRepositoryFileDAO
Parameters:
strWorkspace - the workspace name
strPath - the absolute path
See Also:
IRepositoryFileDAO.create(java.lang.String, java.lang.String)

create

public void create(String strWorkspace,
                   String strFileName,
                   File file,
                   String strMimeType)
Description copied from interface: IRepositoryFileDAO
Create a file in workspace strWorkspace at absolute path strPath, with file content.

Specified by:
create in interface IRepositoryFileDAO
Parameters:
strWorkspace - the workspace name
strFileName - the absolute filename to create
file - the file content
See Also:
fr.paris.lutece.plugins.jcr.business.IRepositoryFileDAO#create(java.lang.String, java.lang.String, java.io.File)

delete

public void delete(String strWorkspace,
                   String strPath)
Description copied from interface: IRepositoryFileDAO
Remove a file from repository

Specified by:
delete in interface IRepositoryFileDAO
Parameters:
strWorkspace - the workspace name
strPath - the absolute path to delete
See Also:
IRepositoryFileDAO.delete(java.lang.String, java.lang.String)

listFiles

public List<IRepositoryFile> listFiles(String strWorkspace,
                                       String strPath)
Description copied from interface: IRepositoryFileDAO
List all files in a directory

Specified by:
listFiles in interface IRepositoryFileDAO
Parameters:
strWorkspace - the workspace name
strPath - the absolute path
Returns:
a collection of IRepositoryFile contained in strPath
See Also:
IRepositoryFileDAO.listFiles(java.lang.String, java.lang.String)

findById

public IRepositoryFile findById(String strWorkspace,
                                String strId)
Description copied from interface: IRepositoryFileDAO
Find a file by its id

Specified by:
findById in interface IRepositoryFileDAO
Parameters:
strWorkspace - the workspace name
strId - the id to find
Returns:
an IRepositoryFile
See Also:
IRepositoryFileDAO.findById(java.lang.String, java.lang.String)

findById

public IRepositoryFile findById(String strWorkspace,
                                String strId,
                                String strVersion)
Description copied from interface: IRepositoryFileDAO
Find a file by its id

Specified by:
findById in interface IRepositoryFileDAO
Parameters:
strWorkspace - the workspace name
strId - the id to find
strVersion - the version name to retrieve
Returns:
an IRepositoryFile
See Also:
IRepositoryFileDAO.findById(java.lang.String, java.lang.String)

setContent

protected boolean setContent(javax.jcr.Node node,
                             InputStream inputStream,
                             String strFileName,
                             String strMimeType)
Set the content of a node

Parameters:
node - the node
inputStream - a stream with the content
strFileName - the file name, the mime type is determined with this file name
Returns:
true if the transfer is ok and node is a file, false otherwise
Throws:
FileNotFoundException

findByPath

public IRepositoryFile findByPath(String strWorkspace,
                                  String strPath)
Description copied from interface: IRepositoryFileDAO
Find a file by its path

Specified by:
findByPath in interface IRepositoryFileDAO
Parameters:
strWorkspace - the workspace name
strPath - the absolute path
Returns:
an IRepositoryFile
See Also:
IRepositoryFileDAO.findByPath(java.lang.String, java.lang.String)

store

public void store(String strWorkspace,
                  IRepositoryFile file)
Description copied from interface: IRepositoryFileDAO
Submit file changes in repository

Specified by:
store in interface IRepositoryFileDAO
Parameters:
strWorkspace - the workspace name
file - the file containing the modifications

setVersionnable

public void setVersionnable(String strWorkspace,
                            String strNodeId,
                            boolean isVersionnable)
Description copied from interface: IRepositoryFileDAO
Set versionable feature for the specified node

Specified by:
setVersionnable in interface IRepositoryFileDAO
Parameters:
strWorkspace - the workspace name
strNodeId - the node id
isVersionnable - true to make the node versionable

getHistory

public List<IRepositoryFile> getHistory(String strWorkspace,
                                        String strNodeId)
Description copied from interface: IRepositoryFileDAO
Get all versions for this file

Specified by:
getHistory in interface IRepositoryFileDAO
Parameters:
strWorkspace - the workspace name
strNodeId - the node id
Returns:
the versions of the node or an emtpy list if this node isn't versionable

isVersionnable

protected boolean isVersionnable(javax.jcr.Node node)
Tells whether a node is versionable

Parameters:
node - to test
Returns:
true if it is versionable (ie contains a mixin cm:versionable)

getProperty

protected String getProperty(String strPropertyName)
Retrieves a configuration property

Parameters:
strPropertyName - the property key
Returns:
the value

ownsLock

protected boolean ownsLock(javax.jcr.Node node)
Tells if the current user owns a lock on node

Parameters:
node - the node
Returns:
true if the user has a lock on this node

getCreated

protected abstract Calendar getCreated(javax.jcr.Node node)
Gets the creation date of the node It must be overloaded by children classes

Parameters:
node - the node
Returns:
the creation date of the node

getSize

protected abstract long getSize(javax.jcr.Node node)
Gets the size of the content node It must only apply to node of type "file" It must be overloaded by children classes

Parameters:
node - the node
Returns:
the size (in bytes) of the node. Undetermined if the node is a directory.

getLastModified

protected abstract Calendar getLastModified(javax.jcr.Node node)
Gets the date of last modification It must be overloaded by children classes

Parameters:
node - the node
Returns:
the last modification date

getFileContent

protected abstract InputStream getFileContent(javax.jcr.Node node)
Gives access to node content. It must be overloaded by children classes

Parameters:
node - the node
Returns:
an inputstream to the file content

getMimeType

protected abstract String getMimeType(javax.jcr.Node node)
Gives the Mime Type of a node It must be overloaded by children classes

Parameters:
node - the node
Returns:
the mime type (if unknown, it should return application/octet-stream)

getPath

protected abstract String getPath(javax.jcr.Node node)
Gives the path of a node It must be overloaded by children classes

Parameters:
node - the node
Returns:
the path in the JCR

getUUID

protected String getUUID(javax.jcr.Node node)
Gives the reference of a node

Parameters:
node - the node
Returns:
a reference (like 60c92f6b-a6d2-49d9-b9ec-03345a00e606)

getParentUUID

protected String getParentUUID(javax.jcr.Node node)
Gives the reference of the parent

Parameters:
node - the node
Returns:
a reference of the parent if it exists, null otherwise.

getName

protected abstract String getName(javax.jcr.Node node)
Gives the name of a node It must be overloaded by children classes

Parameters:
node - the node
Returns:
the name (generally, it is the file name)

isFile

protected abstract boolean isFile(javax.jcr.Node node)
Tells if a node is a file. Note on data structure : a file has content and has no child. It must be overloaded by children classes

Parameters:
node - the node
Returns:
true if the node is a file, false otherwise

isDirectory

protected abstract boolean isDirectory(javax.jcr.Node node)
Tells if a node is a directory Note on data structure : a directory doesn't contain anything except other directories and files. It must be overloaded by children classes

Parameters:
node - the node
Returns:
true if the node is a directory, false otherwise

exists

protected abstract boolean exists(javax.jcr.Node node)
Tells if a node is present in the repository It must be overloaded by children classes

Parameters:
node - the node
Returns:
true if the node exists, false otherwise

getAbsolutePath

protected abstract String getAbsolutePath(javax.jcr.Node node)
Returns the entire path (absolute)

Parameters:
node - the node
Returns:
the absolute path of the node

getProperties

protected abstract Properties getProperties()
Gives a way to the configuration properties

Returns:
a Properties object

setLock

public String setLock(String strWorkspace,
                      IRepositoryFile file,
                      String strUsername)
Specified by:
setLock in interface IRepositoryFileDAO

removeLock

public String removeLock(String strWorkspace,
                         IRepositoryFile file)
Specified by:
removeLock in interface IRepositoryFileDAO

getDepth

protected int getDepth()

getPathToFile

public List<IRepositoryFile> getPathToFile(String strWorkspace,
                                           String strFilePath)
Specified by:
getPathToFile in interface IRepositoryFileDAO


Copyright © 2014 Mairie de Paris. All Rights Reserved.