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

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

public class RepositoryFileHome
extends Object

Home class for JCR repository operations


Field Summary
static String CONTEXT_NAME
           
static String SPRING_JSR170_JCRLIST
           
static String SPRING_JSR170_PREFIX
           
static String SPRING_REPOSITORY_FILEdao
           
static String SPRINGworkspaceDao
           
 
Constructor Summary
protected RepositoryFileHome()
          Default constructor
 
Method Summary
 void addFile(AdminWorkspace workspace, String path, File file, String strMimeType, JsrUser user)
          Create a file in workspace strWorkspace in directory designed by path with content file
 boolean canAccess(AdminWorkspace adminWorkspace, String strAccessType, String[] userRoles, JsrUser user)
          Tests if the workspace strWorkspace can be accessed with roles in userRoles and access of type strAccessType
 boolean canCreateWorkspace(String strJcrType)
          This is part of admin functionalities
 void createFolder(AdminWorkspace workspace, String path, JsrUser user)
          Create a directory in workspace strWorkspace at location path
 void createWorkspace(String strJcrType, String strWorkspaceName)
          Create a new workspace
 void doRecursive(AdminWorkspace adminWorkspace, AdminView view, String strStartPath, INodeAction<org.apache.lucene.document.Document,Collection<org.apache.lucene.document.Document>> action, JsrUser user)
          Recursively delegates an specific action on a JCR content.
protected  void doRecursive(AdminWorkspace adminWorkspace, IRepositoryFile parentFile, INodeAction<org.apache.lucene.document.Document,Collection<org.apache.lucene.document.Document>> action)
           
 Map<String,Boolean> getAvailableAccess(AdminWorkspace adminWorkspace, String[] userRoles, JsrUser user)
          Get all available access, given some roles
 fr.paris.lutece.util.ReferenceList getAvailableJcr()
           
 List<String> getAvailableJcrList()
           
 fr.paris.lutece.util.ReferenceList getAvailableWorkspaces(String strJcrType)
          Get all available workspaces
 List<IRepositoryFile> getFileHistory(AdminWorkspace adminWorkspace, String strFileId, JsrUser user)
          Gets the file history
static RepositoryFileHome getInstance()
          Returns the instance of the singleton
protected  IRepositoryFileDAO getIRepositoryFileDAO(String strJcrType)
          Returns an IRepositoryFileDAO of type strJcrType from the Spring context
 Map<String,JcrLock> getLocks(AdminWorkspace adminWorkspace, AdminView view, JsrUser user)
          Returns a list of all files locked
 List<IRepositoryFile> getPathToFile(AdminWorkspace adminWorkspace, String strFileId, JsrUser user)
          Gives a list of files from the root node to the given node
 String getPrettyAbsolutePath(AdminWorkspace adminWorkspace, IRepositoryFile rootFile, JsrUser jsrUser)
           
 IRepositoryFile getRepositoryFile(AdminWorkspace workspace, String path, JsrUser user)
          Get the file in workspace strWorkspace in directory path
 IRepositoryFile getRepositoryFileById(AdminWorkspace workspace, String strFileId, JsrUser user)
          Get the file in workspace strWorkspace in directory path
 List<IRepositoryFile> getRepositoryFileList(AdminWorkspace workspace, JsrUser user)
          Get the files in workspace strWorkspace
 List<IRepositoryFile> getRepositoryFileList(AdminWorkspace workspace, String parent, JsrUser user)
          Get the files in workspace strWorkspace in directory parent
 IRepositoryFile getRepositoryFileVersionById(AdminWorkspace workspace, String strFileId, 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, 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, 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, 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 String CONTEXT_NAME
See Also:
Constant Field Values

SPRING_JSR170_PREFIX

public static final String SPRING_JSR170_PREFIX
See Also:
Constant Field Values

SPRING_JSR170_JCRLIST

public static final String SPRING_JSR170_JCRLIST
See Also:
Constant Field Values

SPRING_REPOSITORY_FILEdao

public static final String SPRING_REPOSITORY_FILEdao
See Also:
Constant Field Values

SPRINGworkspaceDao

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

RepositoryFileHome

protected RepositoryFileHome()
Default constructor

Method Detail

getIRepositoryFileDAO

protected IRepositoryFileDAO getIRepositoryFileDAO(String strJcrType)
Returns an IRepositoryFileDAO of type strJcrType from the Spring context

Parameters:
strJcrType - the type of JCR. Available types are defined in the Spring context
Returns:
an instance of IRepositoryFileDAO

getInstance

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

Returns:
The instance of the singleton

getRepositoryFileList

public 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,
                                             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,
                                                    String strFileId,
                                                    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,
                                         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 List<IRepositoryFile> getRepositoryFileList(AdminWorkspace workspace,
                                                   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,
                    String path,
                    File file,
                    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,
                         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,
                                 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(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(String strJcrType,
                            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,
                         String strAccessType,
                         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 Map<String,Boolean> getAvailableAccess(AdminWorkspace adminWorkspace,
                                              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 List<String> getAvailableJcrList()
Returns:
a list of available jcr types from the Spring context and technically instantiable

canCreateWorkspace

public boolean canCreateWorkspace(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 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,
                            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 List<IRepositoryFile> getFileHistory(AdminWorkspace adminWorkspace,
                                            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,
                        String strStartPath,
                        INodeAction<org.apache.lucene.document.Document,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

doRecursive

protected void doRecursive(AdminWorkspace adminWorkspace,
                           IRepositoryFile parentFile,
                           INodeAction<org.apache.lucene.document.Document,Collection<org.apache.lucene.document.Document>> action)
Type Parameters:
T - the type of result elements
L - the collection type
Parameters:
adminWorkspace - the workspace
parentFile - the file to star from
action - the action to perform on each node

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,
                   Collection<JcrLock> jcrLocks)

getPathToFile

public List<IRepositoryFile> getPathToFile(AdminWorkspace adminWorkspace,
                                           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 Map<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 © 2014 Mairie de Paris. All Rights Reserved.