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

java.lang.Object
  extended by fr.paris.lutece.plugins.jcr.business.RepositoryFileHome

public class RepositoryFileHome
extends java.lang.Object

Home class for JCR repository operations


Field Summary
static java.lang.String CONTEXT_NAME
           
static java.lang.String SPRING_JSR170_JCRLIST
           
static java.lang.String SPRING_REPOSITORY_FILEdao
           
static java.lang.String SPRINGworkspaceDao
           
 
Constructor Summary
protected RepositoryFileHome()
          Default constructor
 
Method Summary
 void addFile(AdminWorkspace workspace, java.lang.String path, java.io.File file, java.lang.String strMimeType, JsrUser user)
          Create a file in workspace strWorkspace in directory designed by path with content file
 boolean canAccess(AdminWorkspace adminWorkspace, java.lang.String strAccessType, java.lang.String[] userRoles, JsrUser user)
          Tests if the workspace strWorkspace can be accessed with roles in userRoles and access of type strAccessType
 boolean canCreateWorkspace(java.lang.String strJcrType)
          This is part of admin functionalities
 void createFolder(AdminWorkspace workspace, java.lang.String path, JsrUser user)
          Create a directory in workspace strWorkspace at location path
 void createWorkspace(java.lang.String strJcrType, java.lang.String strWorkspaceName)
          Create a new workspace
 void doRecursive(AdminWorkspace adminWorkspace, AdminView view, java.lang.String strStartPath, INodeAction<org.apache.lucene.document.Document,java.util.Collection<org.apache.lucene.document.Document>> action, JsrUser user)
          Recursively delegates an specific action on a JCR content.
 java.util.Map<java.lang.String,java.lang.Boolean> getAvailableAccess(AdminWorkspace adminWorkspace, java.lang.String[] userRoles, JsrUser user)
          Get all available access, given some roles
 fr.paris.lutece.util.ReferenceList getAvailableJcr()
           
 java.util.List<java.lang.String> getAvailableJcrList()
           
 fr.paris.lutece.util.ReferenceList getAvailableWorkspaces(java.lang.String strJcrType)
          Get all available workspaces
 java.util.List<IRepositoryFile> getFileHistory(AdminWorkspace adminWorkspace, java.lang.String strFileId, JsrUser user)
          Gets the file history
static RepositoryFileHome getInstance()
          Returns the instance of the singleton
 java.util.Map<java.lang.String,JcrLock> getLocks(AdminWorkspace adminWorkspace, AdminView view, JsrUser user)
          Returns a list of all files locked
 java.util.List<IRepositoryFile> getPathToFile(AdminWorkspace adminWorkspace, java.lang.String strFileId, JsrUser user)
          Gives a list of files from the root node to the given node
 java.lang.String getPrettyAbsolutePath(AdminWorkspace adminWorkspace, IRepositoryFile rootFile, JsrUser jsrUser)
           
 IRepositoryFile getRepositoryFile(AdminWorkspace workspace, java.lang.String path, JsrUser user)
          Get the file in workspace strWorkspace in directory path
 IRepositoryFile getRepositoryFileById(AdminWorkspace workspace, java.lang.String strFileId, JsrUser user)
          Get the file in workspace strWorkspace in directory path
 java.util.List<IRepositoryFile> getRepositoryFileList(AdminWorkspace workspace, JsrUser user)
          Get the files in workspace strWorkspace
 java.util.List<IRepositoryFile> getRepositoryFileList(AdminWorkspace workspace, java.lang.String parent, JsrUser user)
          Get the files in workspace strWorkspace in directory parent
 IRepositoryFile getRepositoryFileVersionById(AdminWorkspace workspace, java.lang.String strFileId, java.lang.String strVersion, JsrUser user)
          Get the file in workspace strWorkspace in directory path
 IWorkspace getWorkspace(AdminWorkspace workspace, JsrUser user)
          Get workspace informations
 void modify(AdminWorkspace adminWorkspace, IWorkspace workspace, JsrUser user)
          Modify workspace acces rights This is part of admin functionalities
 void removeRepositoryFile(AdminWorkspace workspace, java.lang.String strPath, JsrUser user)
          Remove element in workspace strWorkspace at path strPath
 void removeWorkspace(AdminWorkspace adminWorkspace, JsrUser user)
          Removes a workspace This is part of admin functionalities
 void setLock(AdminWorkspace adminWorkspace, IRepositoryFile file, JsrUser user)
          Puts a lock on a node
 void setVersionnable(AdminWorkspace adminWorkspace, java.lang.String strFileId, boolean isVersionnable, JsrUser user)
          Adds a file to the version manager
 void unLock(AdminWorkspace adminWorkspace, IRepositoryFile file, JsrUser user)
          Unlock a locked node
 void unLock(AdminWorkspace adminWorkspace, IRepositoryFile file, JsrUser user, java.util.Collection<JcrLock> jcrLocks)
           
 void update(AdminWorkspace adminWorkspace, IRepositoryFile file, JsrUser user)
          Modifies a file in a workspace The file must not be locked by another user
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_NAME

public static final java.lang.String CONTEXT_NAME
See Also:
Constant Field Values

SPRING_JSR170_JCRLIST

public static final java.lang.String SPRING_JSR170_JCRLIST
See Also:
Constant Field Values

SPRING_REPOSITORY_FILEdao

public static final java.lang.String SPRING_REPOSITORY_FILEdao
See Also:
Constant Field Values

SPRINGworkspaceDao

public static final java.lang.String SPRINGworkspaceDao
See Also:
Constant Field Values
Constructor Detail

RepositoryFileHome

protected RepositoryFileHome()
Default constructor

Method Detail

getInstance

public static RepositoryFileHome getInstance()
Returns the instance of the singleton

Returns:
The instance of the singleton

getRepositoryFileList

public java.util.List<IRepositoryFile> getRepositoryFileList(AdminWorkspace workspace,
                                                             JsrUser user)
Get the files in workspace strWorkspace

Parameters:
workspace - the workspace name
Returns:
a list of IRepositoryFile

getRepositoryFileById

public IRepositoryFile getRepositoryFileById(AdminWorkspace workspace,
                                             java.lang.String strFileId,
                                             JsrUser user)
Get the file in workspace strWorkspace in directory path

Parameters:
workspace - the workspace name
strFileId - an absolute path to the directory
user - the current user
Returns:
the IRepositoryFile

getRepositoryFileVersionById

public IRepositoryFile getRepositoryFileVersionById(AdminWorkspace workspace,
                                                    java.lang.String strFileId,
                                                    java.lang.String strVersion,
                                                    JsrUser user)
Get the file in workspace strWorkspace in directory path

Parameters:
workspace - the workspace name
strFileId - an absolute path to the directory
strVersion - the version name to retrieve
user - the current user
Returns:
the IRepositoryFile

getRepositoryFile

public IRepositoryFile getRepositoryFile(AdminWorkspace workspace,
                                         java.lang.String path,
                                         JsrUser user)
Get the file in workspace strWorkspace in directory path

Parameters:
workspace - the workspace
path - an absolute path to the directory
user - the current user
Returns:
the IRepositoryFile

getRepositoryFileList

public java.util.List<IRepositoryFile> getRepositoryFileList(AdminWorkspace workspace,
                                                             java.lang.String parent,
                                                             JsrUser user)
Get the files in workspace strWorkspace in directory parent

Parameters:
workspace - the workspace
parent - the parent directory absolute path
user - the current user
Returns:
a list of IRepositoryFile

addFile

public void addFile(AdminWorkspace workspace,
                    java.lang.String path,
                    java.io.File file,
                    java.lang.String strMimeType,
                    JsrUser user)
Create a file in workspace strWorkspace in directory designed by path with content file

Parameters:
workspace - the workspace
path - the parent directory absolute path
file - the file content
user - the current user

createFolder

public void createFolder(AdminWorkspace workspace,
                         java.lang.String path,
                         JsrUser user)
Create a directory in workspace strWorkspace at location path

Parameters:
workspace - the workspace
path - the directory absolute path
user - the current user

removeRepositoryFile

public void removeRepositoryFile(AdminWorkspace workspace,
                                 java.lang.String strPath,
                                 JsrUser user)
Remove element in workspace strWorkspace at path strPath

Parameters:
workspace - the workspace
strPath - the absolute path
user - the current user

getAvailableWorkspaces

public fr.paris.lutece.util.ReferenceList getAvailableWorkspaces(java.lang.String strJcrType)
Get all available workspaces

Parameters:
strJcrType - the type of the jcr repository
Returns:
a ReferenceList with all workspace names

createWorkspace

public void createWorkspace(java.lang.String strJcrType,
                            java.lang.String strWorkspaceName)
Create a new workspace

Parameters:
strJcrType - the type of the jcr repository
strWorkspaceName - the workspace name

getWorkspace

public IWorkspace getWorkspace(AdminWorkspace workspace,
                               JsrUser user)
Get workspace informations

Parameters:
workspace - the workspace
user - the current user
Returns:
the workspace

modify

public void modify(AdminWorkspace adminWorkspace,
                   IWorkspace workspace,
                   JsrUser user)
Modify workspace acces rights This is part of admin functionalities

Parameters:
adminWorkspace - the admin workspace
workspace - the workspace instance
user - the current user

canAccess

public boolean canAccess(AdminWorkspace adminWorkspace,
                         java.lang.String strAccessType,
                         java.lang.String[] userRoles,
                         JsrUser user)
Tests if the workspace strWorkspace can be accessed with roles in userRoles and access of type strAccessType

Parameters:
adminWorkspace - the workspace
strAccessType - the access type, it must be in IWorkspace.AVAILABLE_ACCESS
userRoles - an array of roles
user - the current user
Returns:
true if it is accessible, false otherwise

getAvailableAccess

public java.util.Map<java.lang.String,java.lang.Boolean> getAvailableAccess(AdminWorkspace adminWorkspace,
                                                                            java.lang.String[] userRoles,
                                                                            JsrUser user)
Get all available access, given some roles

Parameters:
adminWorkspace - the workspace
userRoles - an array of roles
user - the current user
Returns:
a map containing access types associated with access value

getAvailableJcr

public fr.paris.lutece.util.ReferenceList getAvailableJcr()
Returns:
jcr defined in Spring context

getAvailableJcrList

public java.util.List<java.lang.String> getAvailableJcrList()
Returns:
a list of available jcr types from the Spring context and technically instantiable

canCreateWorkspace

public boolean canCreateWorkspace(java.lang.String strJcrType)
This is part of admin functionalities

Parameters:
strJcrType - the type of jcr
Returns:
true if workspace can be created in this jcr

removeWorkspace

public void removeWorkspace(AdminWorkspace adminWorkspace,
                            JsrUser user)
Removes a workspace This is part of admin functionalities

Parameters:
adminWorkspace - the name of the workspace to remove
user - the current user

getPrettyAbsolutePath

public java.lang.String getPrettyAbsolutePath(AdminWorkspace adminWorkspace,
                                              IRepositoryFile rootFile,
                                              JsrUser jsrUser)
Parameters:
adminWorkspace - the workspace to use
rootFile - the file to get the pretty path from
user - the current user
Returns:
a path where each element is the name of the file

update

public void update(AdminWorkspace adminWorkspace,
                   IRepositoryFile file,
                   JsrUser user)
Modifies a file in a workspace The file must not be locked by another user

Parameters:
adminWorkspace - the current workspace
file - the new file content
user - the current user

setVersionnable

public void setVersionnable(AdminWorkspace adminWorkspace,
                            java.lang.String strFileId,
                            boolean isVersionnable,
                            JsrUser user)
Adds a file to the version manager

Parameters:
adminWorkspace - the current workspace
strFileId - the id of the file to modify
isVersionnable - true : sets the file as versionable, if false : remove the file from the file manager
user - the current user

getFileHistory

public java.util.List<IRepositoryFile> getFileHistory(AdminWorkspace adminWorkspace,
                                                      java.lang.String strFileId,
                                                      JsrUser user)
Gets the file history

Parameters:
adminWorkspace - the current workspace
strFileId - the id of the file
user - the current user
Returns:
a list of all the version of the file as IRepositoryFile instances

doRecursive

public void doRecursive(AdminWorkspace adminWorkspace,
                        AdminView view,
                        java.lang.String strStartPath,
                        INodeAction<org.apache.lucene.document.Document,java.util.Collection<org.apache.lucene.document.Document>> action,
                        JsrUser user)
Recursively delegates an specific action on a JCR content. If action returns null, no result is appended to the result list.

Type Parameters:
T - the result element type
L - the result list type
Parameters:
adminWorkspace - the workspace to work on
view - the view to browse
strStartPath - the start point of the browsing
action - the action to perform on each node
user - the current user

setLock

public void setLock(AdminWorkspace adminWorkspace,
                    IRepositoryFile file,
                    JsrUser user)
Puts a lock on a node

Parameters:
adminWorkspace - the workspace
file - the node to lock
user - the current user

unLock

public void unLock(AdminWorkspace adminWorkspace,
                   IRepositoryFile file,
                   JsrUser user)
Unlock a locked node

Parameters:
adminWorkspace - the workspace
file - the file to unlock
user - the current user

unLock

public void unLock(AdminWorkspace adminWorkspace,
                   IRepositoryFile file,
                   JsrUser user,
                   java.util.Collection<JcrLock> jcrLocks)

getPathToFile

public java.util.List<IRepositoryFile> getPathToFile(AdminWorkspace adminWorkspace,
                                                     java.lang.String strFileId,
                                                     JsrUser user)
Gives a list of files from the root node to the given node

Parameters:
adminWorkspace - the workspace
strFileId - the id of the node
user - the current user
Returns:
a list of file (ordered from rootnode to given node)

getLocks

public java.util.Map<java.lang.String,JcrLock> getLocks(AdminWorkspace adminWorkspace,
                                                        AdminView view,
                                                        JsrUser user)
Returns a list of all files locked

Parameters:
adminWorkspace - the workspace
view - the vie
user - the user
Returns:
a map of lock associated with files


Copyright © 2009 Mairie de Paris. All Rights Reserved.