CStockage 4.2_beta-RC-1
API Documentation

org.esupportail.portal.channels.CStockage.spacesPersonalization
Class DataBaseAccess

java.lang.Object
  extended byorg.esupportail.portal.channels.CStockage.spacesPersonalization.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
static boolean initialized
          If the database parameters are still initialized
static java.lang.String TARGET_ALL
           
static java.lang.String TARGET_IS_ALL
           
static java.lang.String TARGET_IS_GROUP
           
static java.lang.String TARGET_IS_USER
           
 
Constructor Summary
DataBaseAccess()
          Constructor Initialize the parameters for a connexion to the database
 
Method Summary
 int addStorageAvailableSpace(java.lang.String id, java.lang.String serverName, java.lang.String xmlServer, java.lang.String fromKey, java.lang.String owner, java.lang.String rootPath)
          Add sharing properties into the database
 int addStorageAvailableSpaceTarget(java.lang.String targetKey, java.lang.String targetType, java.lang.String serverId, java.lang.String spaceKey, boolean obliged)
          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 delStorageAvailableSpaceTarget(java.lang.String id)
          Delete sharing properties into the database
 int delStorageAvailableSpaceTargetAll(java.lang.String serverId, java.lang.String spaceId)
          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 getAdministratedSpaces()
          Get the servers and spaces set into the administration database
 java.util.Vector getAvailableSpace(java.lang.String serverName)
          Get the users for whose the resource is shared
 java.util.Vector getAvailableSpacesForTarget(java.lang.String targetKey, java.lang.String targetType, boolean obliged)
          Get the available spaces for a group or a user
 java.util.Vector[] getIdAndXmlOfSharing(java.lang.String serverName)
          Get the id of shared spaces from url and path
 java.util.Vector[] getIdOfSpacesWithServerName(java.lang.String serverName)
          Get the id of shared spaces from url and path
 java.util.Vector getKeyOfSpacesFromPreferences(java.lang.String targetKey)
          Get the list of ids of spaces which has already been selected by the current user
 java.util.Vector getTargetsOfAdministratedSpaces(java.lang.String idStorageAvailableSpaces, java.lang.String spaceKey)
          Get the targets set into the administration database
 java.util.Vector getTargetsOfAvailableSpace(java.lang.String serverName)
          Get the users for whose the resource is shared
 java.util.Vector getTargetsOfSpace(java.lang.String serverId, java.lang.String spaceId)
          Get the users for whose the resource is shared
 boolean isAlreadyAvailableForTarget(org.esupportail.portal.utils.database.Query queryManager, java.lang.String serverId, java.lang.String targetKey, java.lang.String targetType, java.lang.String spaceKey)
          Check if the space is already shared for a specified user
 int updatePathOfSharing(java.lang.String serverName, java.lang.String xml, java.lang.String id)
          Update the path of shared spaces
 int updateServerNameAvailableSpace(java.lang.String serverId, java.lang.String newName)
          Update the name of the server of the sharing properties into the database
 int updateXmlServerAvailableSpace(java.lang.String xmlServer, java.lang.String id)
          Update the label of the sharing properties into the database
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initialized

public static boolean initialized
If the database parameters are still initialized


TARGET_IS_USER

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

TARGET_IS_GROUP

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

TARGET_IS_ALL

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

TARGET_ALL

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

DataBaseAccess

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

Throws:
PropertiesException
Method Detail

getAvailableSpace

public java.util.Vector getAvailableSpace(java.lang.String serverName)
                                   throws DataBaseException
Get the users for whose the resource is shared

Parameters:
serverName - the name of the server
Returns:
a vector. Each element is an array of [serverId, xmlServer, availableSpaceTargetId, targetKey, targetIsUser:'T'|'F', read:'T'|'F', write:'T'|'F', share:'T'|'F']
Throws:
DataBaseException

getTargetsOfAvailableSpace

public java.util.Vector getTargetsOfAvailableSpace(java.lang.String serverName)
                                            throws DataBaseException
Get the users for whose the resource is shared

Parameters:
serverName - the name of the server
Returns:
a vector. Each element is an array of [serverId, xmlServer, availableSpaceTargetId, targetKey, targetIsUser:'T'|'F', read:'T'|'F', write:'T'|'F', share:'T'|'F']
Throws:
DataBaseException

getTargetsOfSpace

public java.util.Vector getTargetsOfSpace(java.lang.String serverId,
                                          java.lang.String spaceId)
                                   throws DataBaseException
Get the users for whose the resource is shared

Parameters:
serverId - the id of the server
spaceId - the id of the space
Returns:
a vector containing each target id
Throws:
DataBaseException

isAlreadyAvailableForTarget

public boolean isAlreadyAvailableForTarget(org.esupportail.portal.utils.database.Query queryManager,
                                           java.lang.String serverId,
                                           java.lang.String targetKey,
                                           java.lang.String targetType,
                                           java.lang.String spaceKey)
                                    throws DataBaseException
Check if the space is already shared for a specified user

Parameters:
queryManager - the query manager for the database access. can be null
serverId - the id of the server
targetKey - the key of the user we want to check
targetType - to know if the target of this sharing is a user or other
spaceKey - the key of the space
Returns:
true if already shared, else false
Throws:
DataBaseException

addStorageAvailableSpace

public int addStorageAvailableSpace(java.lang.String id,
                                    java.lang.String serverName,
                                    java.lang.String xmlServer,
                                    java.lang.String fromKey,
                                    java.lang.String owner,
                                    java.lang.String rootPath)
                             throws DataBaseException
Add sharing properties into the database

Parameters:
id - the id of the server
serverName - the name of the server
xmlServer - the server into an xml format
fromKey - the key of the people who shares
Returns:
the result of the query
Throws:
DataBaseException

addStorageAvailableSpaceTarget

public int addStorageAvailableSpaceTarget(java.lang.String targetKey,
                                          java.lang.String targetType,
                                          java.lang.String serverId,
                                          java.lang.String spaceKey,
                                          boolean obliged)
                                   throws DataBaseException
Add sharing properties into the database

Parameters:
targetKey - the key of the target user
targetType - if the target is a user or not
serverId - theid of the server
spaceKey - the key of the space
obliged - if we are obliged to see this space
Returns:
the result of the query
Throws:
DataBaseException

delStorageAvailableSpaceTarget

public int delStorageAvailableSpaceTarget(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

delStorageAvailableSpaceTargetAll

public int delStorageAvailableSpaceTargetAll(java.lang.String serverId,
                                             java.lang.String spaceId)
                                      throws DataBaseException
Delete sharing properties into the database

Parameters:
serverId - the server id
spaceId - the space id
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

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

updateXmlServerAvailableSpace

public int updateXmlServerAvailableSpace(java.lang.String xmlServer,
                                         java.lang.String id)
                                  throws DataBaseException
Update the label of the sharing properties into the database

Parameters:
xmlServer - the xml of the server
id - the id of the server
Returns:
the result of the query
Throws:
DataBaseException

getIdOfSpacesWithServerName

public java.util.Vector[] getIdOfSpacesWithServerName(java.lang.String serverName)
                                               throws DataBaseException
Get the id of shared spaces from url and path

Parameters:
serverName - the name of the server
Returns:
the list of ids in 2 vectors: the first for the storage_available_spaces and the other for storage_available_spaces_targets
Throws:
DataBaseException

getIdAndXmlOfSharing

public java.util.Vector[] getIdAndXmlOfSharing(java.lang.String serverName)
                                        throws DataBaseException
Get the id of shared spaces from url and path

Parameters:
serverName - the name of the server
Returns:
the list of ids and xml in 2 vectors
Throws:
DataBaseException

updatePathOfSharing

public int updatePathOfSharing(java.lang.String serverName,
                               java.lang.String xml,
                               java.lang.String id)
                        throws DataBaseException
Update the path of shared spaces

Parameters:
serverName - the name of the server
xml - the xml for the server
id - the name of the server
Returns:
the result of the query
Throws:
DataBaseException

getAvailableSpacesForTarget

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

Parameters:
targetKey - the key of the target
targetType - 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

getKeyOfSpacesFromPreferences

public java.util.Vector getKeyOfSpacesFromPreferences(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

getAdministratedSpaces

public java.util.Vector getAdministratedSpaces()
                                        throws DataBaseException
Get the servers and spaces set into the administration database

Returns:
a vector. Each element is an array of [serverId, serverName, xmlServer]
Throws:
DataBaseException

getTargetsOfAdministratedSpaces

public java.util.Vector getTargetsOfAdministratedSpaces(java.lang.String idStorageAvailableSpaces,
                                                        java.lang.String spaceKey)
                                                 throws DataBaseException
Get the targets set into the administration database

Parameters:
idStorageAvailableSpaces - the id of storage target
spaceKey - the key of the space
Returns:
a vector. Each element is an array of [availableSpaceTargetId, targetKey, targetIsUser:'T'|'F', read:'T'|'F', write:'T'|'F', share:'T'|'F', obliged:'T'|'F']
Throws:
DataBaseException

updateServerNameAvailableSpace

public int updateServerNameAvailableSpace(java.lang.String serverId,
                                          java.lang.String newName)
                                   throws DataBaseException
Update the name of the server of the sharing properties into the database

Parameters:
serverId - the id of the server
newName - the new name of the server administration
Returns:
the result of the query
Throws:
DataBaseException

CStockage 4.2_beta-RC-1
API Documentation