Class WorkSpaceManager

java.lang.Object
com.kheops.jmap.server.WorkSpaceManager

public class WorkSpaceManager extends Object
This class is used to manage user workspaces.
  • Constructor Details

    • WorkSpaceManager

      public WorkSpaceManager(File rootPath) throws IOException
      Creates a new workspace manager. The specified path is the root of the workspaces. It is created if it does not exist.
      Parameters:
      rootPath - the workspaces root path.
      Throws:
      IOException - if the path cannot be created
  • Method Details

    • getRootPath

      public File getRootPath()
      Returns the workspaces root path.
      Returns:
      the workspaces root path.
    • getUserWSDirectory

      public File getUserWSDirectory(String username)
      This method returns the workspace path of the specified user. It is created if it does not exist.
      Parameters:
      username - , the user name
      Returns:
      the workspace path of the specified user
    • emptyUserWS

      public boolean emptyUserWS(String username)
      This method empties the workspace of the specified user. All files and directories are deleted.
      Parameters:
      username - , the user name
      Returns:
      true if and only if the workspace is successfully emptied, false otherwise
    • deleteUserWS

      public boolean deleteUserWS(String username)
      Deletes the workspace of the specified user. All files and directories are deleted. The workspace directory for the user is also deleted.
      Parameters:
      username - , the user name
      Returns:
      true if and only if the workspace is successfully deleted, false otherwise
    • getUserParameter

      public UserParameter getUserParameter(String userName, int projectId, String parameterKey)
      Returns the UserParameter associated with the userName / projectId / parameterKey. null if not found.
      Parameters:
      userName - the user name
      projectId - the project id or JMapServerRequest.SaveUserParameters.GLOBAL_PARAMETERS
      parameterKey - the parameter key to search
    • setUserParameter

      public void setUserParameter(String userName, int projectId, UserParameter userParameter)
      Saves a UserParameter
      Parameters:
      userName - the user name
      projectId - the project id or JMapServerRequest.SaveUserParameters.GLOBAL_PARAMETERS
      userParameter - user parameter to save
    • saveUserParameter

      public boolean saveUserParameter(List<UserParameter> userParameters, String userName, int projectId)
      Saves user parameters to user_workspace / projectID / USER_PARAMETER_FILE.
      Parameters:
      userParameters - list of UserParameter to be saved.
      userName - user name used to get the directory where the user parameter file will be saved.
      projectId - project ID used to get the directory where the user parameter file will be saved.
      Returns:
      whether the parameter list was saved..
    • loadUserParameter

      public List<UserParameter> loadUserParameter(String userName, int projectId)
      Loads user parameters from user workspace / projectID.
      Parameters:
      userName - user name used to get the directory where the user parameter file will be saved.
      projectId - project ID used to get the directory where the user parameter file will be saved.
      Returns:
      a list of user parameter.