org.esupportail.portal.channels.CStockage.channelAction.classic.sharing
Class DataBaseAccess

java.lang.Object
  extended byorg.esupportail.portal.channels.CStockage.channelAction.classic.sharing.DataBaseAccess

public class DataBaseAccess
extends java.lang.Object

Id: DataBaseAccess.java,v 1.0 13 janv. 2005 Copyright (c) 2005 Esup Portail (www.esup-portail.org) Classes: DataBaseAccess Original Author: Yohan Colmant This class manage the access to the database, for the sharing actions.


Field Summary
private static org.esupportail.portal.utils.database.Database dataBaseAccess
          The database access object
static boolean initialized
          If the database parameters are still initialized
protected static Log log
          Logger object
 
Constructor Summary
DataBaseAccess()
          Constructor Initialize the parameters for a connexion to the database
 
Method Summary
 int addStorageAvailableSpace(java.lang.String serverUrl, java.lang.String path, java.lang.String label, java.lang.String targetKey, boolean targetIsUser, java.lang.String ownerUserKey, java.lang.String xmlSpace, boolean reading, boolean writing, boolean manage)
          Add sharing properties into the database
 int addStorageUsersPreferences(java.lang.String id, java.lang.String userKey)
          Add a user preference into the database
 int delStorageAvailableSpace(java.lang.String id)
          Delete sharing properties into the database
 int delStorageUsersPreferences(java.lang.String id)
          Delete users preferences for a shared space from the database
 int delStorageUsersPreferencesForUser(java.lang.String id, java.lang.String userKey)
          Delete a user preference from the database
 java.util.Vector getAvailableSpacesForTarget(java.lang.String targetKey, boolean targetIsUser)
          Get the available spaces for a group or a user
 java.util.Vector getIdOfSpaceFromPreferences(java.lang.String targetKey)
          Get the list of ids of spaces which has already been selected by the current user
 java.util.Vector getIdOfSpacesWithPath(java.lang.String url, java.lang.String path)
          Get the id of shared spaces from url and path
 java.util.Vector getTargetsOfAvailableSpace(java.lang.String serverUrl, java.lang.String path, boolean targetIsUser)
          Get the users for whose the resource is shared
private  boolean isAlreadyAvailableForTarget(org.esupportail.portal.utils.database.Query queryManager, java.lang.String serverUrl, java.lang.String path, java.lang.String targetKey, boolean targetIsUser)
          Check if the space is already shared for a specified user
private  boolean isAlreadyInPreferencesForUser(org.esupportail.portal.utils.database.Query queryManager, java.lang.String id, java.lang.String userKey)
          Check if the space is already in the user preferences
 int updateLabelAvailableSpace(java.lang.String newLabel, java.lang.String serverUrl, java.lang.String path)
          Update the label of the sharing properties into the database
 int updatePathOfSharing(java.lang.String url, java.lang.String oldPath, java.lang.String newPath)
          Update the path of shared spaces
 int updateReadAndWriteAndManageSpaceUser(boolean reading, boolean writing, boolean manage, java.lang.String serverUrl, java.lang.String path, java.lang.String targetKey, boolean targetIsUser)
          Update the "reading" and "writing" attributes for a specifical sharing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final Log log
Logger object


initialized

public static boolean initialized
If the database parameters are still initialized


dataBaseAccess

private static org.esupportail.portal.utils.database.Database dataBaseAccess
The database access object

Constructor Detail

DataBaseAccess

public DataBaseAccess()
               throws PropertiesException
Constructor Initialize the parameters for a connexion to the database

Throws:
PropertiesException
Method Detail

addStorageAvailableSpace

public int addStorageAvailableSpace(java.lang.String serverUrl,
                                    java.lang.String path,
                                    java.lang.String label,
                                    java.lang.String targetKey,
                                    boolean targetIsUser,
                                    java.lang.String ownerUserKey,
                                    java.lang.String xmlSpace,
                                    boolean reading,
                                    boolean writing,
                                    boolean manage)
                             throws DataBaseException
Add sharing properties into the database

Parameters:
serverUrl - the url of the server
path - the resource path
label - the space's label
targetKey - the key of the target user
ownerUserKey - the key of the owner
xmlSpace - the space into an xml format
reading - if we have the reading rights
writing - if we have the writing rights
manage - if we have the sharing rights
Returns:
the result of the query
Throws:
DataBaseException

delStorageAvailableSpace

public int delStorageAvailableSpace(java.lang.String id)
                             throws DataBaseException
Delete sharing properties into the database

Parameters:
id - the space id
Returns:
the result of the query
Throws:
DataBaseException

getTargetsOfAvailableSpace

public java.util.Vector getTargetsOfAvailableSpace(java.lang.String serverUrl,
                                                   java.lang.String path,
                                                   boolean targetIsUser)
                                            throws DataBaseException
Get the users for whose the resource is shared

Parameters:
serverUrl - the url of the server
path - the path of the resource
targetIsUser - to know if the target of this sharing is a user or not
Returns:
a vector. Each element is an array of [id, label, targetKey, read:'T'|'F', write:'T'|'F', manage:'T'|'F']
Throws:
DataBaseException

isAlreadyAvailableForTarget

private boolean isAlreadyAvailableForTarget(org.esupportail.portal.utils.database.Query queryManager,
                                            java.lang.String serverUrl,
                                            java.lang.String path,
                                            java.lang.String targetKey,
                                            boolean targetIsUser)
                                     throws DataBaseException
Check if the space is already shared for a specified user

Parameters:
queryManager - the query manager for the database access
serverUrl - the url of the server
path - the path of the resource
targetKey - the key of the user we want to check
targetIsUser - to know if the target of this sharing is a user or not
Returns:
true if already shared, else false
Throws:
DataBaseException

updateLabelAvailableSpace

public int updateLabelAvailableSpace(java.lang.String newLabel,
                                     java.lang.String serverUrl,
                                     java.lang.String path)
                              throws DataBaseException
Update the label of the sharing properties into the database

Parameters:
newLabel - the new label of the shared spaces
serverUrl - the url of the server
path - the resource path
Returns:
the result of the query
Throws:
DataBaseException

updateReadAndWriteAndManageSpaceUser

public int updateReadAndWriteAndManageSpaceUser(boolean reading,
                                                boolean writing,
                                                boolean manage,
                                                java.lang.String serverUrl,
                                                java.lang.String path,
                                                java.lang.String targetKey,
                                                boolean targetIsUser)
                                         throws DataBaseException
Update the "reading" and "writing" attributes for a specifical sharing

Parameters:
reading - the reading value 'T' or 'F'
writing - the writing value 'T' or 'F'
manage - the manage value 'T' or 'F'
serverUrl - the url of the server
path - the resource path
targetKey - the key of the target
targetIsUser - to know if the target of this sharing is a user or not
Returns:
the result of the query
Throws:
DataBaseException

getAvailableSpacesForTarget

public java.util.Vector getAvailableSpacesForTarget(java.lang.String targetKey,
                                                    boolean targetIsUser)
                                             throws DataBaseException
Get the available spaces for a group or a user

Parameters:
targetKey - the key of the target
targetIsUser - to know if the target of this sharing is a user or not
Returns:
a vector. Each element is an array of [id, url, path, label, owner, xmlSpace, read:'T'|'F', write:'T'|'F']
Throws:
DataBaseException

addStorageUsersPreferences

public int addStorageUsersPreferences(java.lang.String id,
                                      java.lang.String userKey)
                               throws DataBaseException
Add a user preference into the database

Parameters:
id - the id of the sharement in the other database
userKey - the key of the user who wants to add preference into the database
Returns:
the result of the query
Throws:
DataBaseException

isAlreadyInPreferencesForUser

private boolean isAlreadyInPreferencesForUser(org.esupportail.portal.utils.database.Query queryManager,
                                              java.lang.String id,
                                              java.lang.String userKey)
                                       throws DataBaseException
Check if the space is already in the user preferences

Parameters:
queryManager - the query manager to access the database
id - the id of the shared space
userKey - the key of the user to check
Returns:
true if already shared, else false
Throws:
DataBaseException

getIdOfSpaceFromPreferences

public java.util.Vector getIdOfSpaceFromPreferences(java.lang.String targetKey)
                                             throws DataBaseException
Get the list of ids of spaces which has already been selected by the current user

Parameters:
targetKey - the user or group target key
Returns:
a Vector
Throws:
DataBaseException

delStorageUsersPreferencesForUser

public int delStorageUsersPreferencesForUser(java.lang.String id,
                                             java.lang.String userKey)
                                      throws DataBaseException
Delete a user preference from the database

Parameters:
id - the id of the sharement in the other database
userKey - the key of the user
Returns:
the result of the query
Throws:
DataBaseException

delStorageUsersPreferences

public int delStorageUsersPreferences(java.lang.String id)
                               throws DataBaseException
Delete users preferences for a shared space from the database

Parameters:
id - the id of the sharement in the other database
Returns:
the result of the query
Throws:
DataBaseException

getIdOfSpacesWithPath

public java.util.Vector getIdOfSpacesWithPath(java.lang.String url,
                                              java.lang.String path)
                                       throws DataBaseException
Get the id of shared spaces from url and path

Parameters:
url - the url of the space
path - the path of the space
Returns:
the list of ids
Throws:
DataBaseException

updatePathOfSharing

public int updatePathOfSharing(java.lang.String url,
                               java.lang.String oldPath,
                               java.lang.String newPath)
                        throws DataBaseException
Update the path of shared spaces

Parameters:
url - the url of the space
oldPath - the old path of the space
newPath - the new path of the space
Returns:
the result of the query
Throws:
DataBaseException