com.soebes.subversion.sapm
Class AccessRule

java.lang.Object
  extended by com.soebes.subversion.sapm.AccessRule

public class AccessRule
extends Object

This class describes an AccessRule which comprises of an repository name and a repository path which is usually defined like the following in the Subversion Access file.

 [repository:/trunk]
 @group = rw
 harry = r
 
Example:
 User userBrian = UserFactory.createInstance("brian");
 Group group = new Group("group");
 group.add(userBrian)

 User userHarry = UserFactory.createInstance("harry");

 AccessRule accessRule = new AccessRule("repository", "/test/trunk");
 accessRule.add(userHarry, AccessLevel.READ);
 accessRule.add(group, AccessLevel.READ_WRITE);

 AccessLevel level = accessRule.getAccess("hugo", "repository", "/trunk/test/Test.java");
 ....
 

Author:
Karl Heinz Marbaise

Field Summary
private  ArrayList<Access> accessList
           
private  String repositoryName
          The name of the repository which this AccessRule represents.
private  String repositoryPath
          The path inside the repository which is represented by this AccessRule.
 
Constructor Summary
AccessRule(String path)
          This is used if you have no particular repository defined for example like the following.
AccessRule(String repositoryName, String path)
          This is used if you have given both the repository name and the path within the repository.
 
Method Summary
 void add(Access access)
          Convenience method for usage in grammar.
 void add(Group group, AccessLevel accessLevel)
          Add the given group to the access list with it's appropriate AccessLevel.
 void add(User user, AccessLevel accessLevel)
          Add the user to the access list with it's appropriate AccessLevel.
 void addNegative(Group group, AccessLevel accessLevel)
          Add the given group to the access list with it's appropriate AccessLevel.
 void addNegative(User user, AccessLevel accessLevel)
          Add the user to the access list with it's appropriate AccessLevel but this rule means not this user (~user)
 AccessLevel getAccess(String user, String repository, String path)
          Get the AccessLevel for the user who want's to get access to the path inside the given repository.
 AccessLevel getAccess(User user, String repository, String path)
          Convenience method if you have a User object instead of user name as a string.
 AccessLevel getAccessForPrincipal(String user)
          Will get the AccessLevel for the given user.
 AccessLevel getAccessForPrincipal(User user)
           
 ArrayList<Access> getAccessList()
           
 String getRepositoryName()
           
 String getRepositoryPath()
           
private  void init(String repositoryName, String path)
           
 void setAccessList(ArrayList<Access> accessList)
           
 void setRepositoryName(String repositoryName)
           
 void setRepositoryPath(String path)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

accessList

private ArrayList<Access> accessList

repositoryName

private String repositoryName
The name of the repository which this AccessRule represents.


repositoryPath

private String repositoryPath
The path inside the repository which is represented by this AccessRule.

Constructor Detail

AccessRule

public AccessRule(String path)
This is used if you have no particular repository defined for example like the following.
 [/test/trunk]
 ...
 

Parameters:
path -

AccessRule

public AccessRule(String repositoryName,
                  String path)
This is used if you have given both the repository name and the path within the repository.

Parameters:
repositoryName - The name of the repository.
path - The path inside the repository.
Method Detail

init

private void init(String repositoryName,
                  String path)

getRepositoryName

public String getRepositoryName()

setRepositoryName

public void setRepositoryName(String repositoryName)

getRepositoryPath

public String getRepositoryPath()

setRepositoryPath

public void setRepositoryPath(String path)

setAccessList

public void setAccessList(ArrayList<Access> accessList)

getAccessList

public ArrayList<Access> getAccessList()

add

public void add(User user,
                AccessLevel accessLevel)
Add the user to the access list with it's appropriate AccessLevel.

Parameters:
user - The user which will be used.
accessLevel - The accessLevel which will be given to the user.

addNegative

public void addNegative(User user,
                        AccessLevel accessLevel)
Add the user to the access list with it's appropriate AccessLevel but this rule means not this user (~user)

Parameters:
user - The user which it shouldn't be.
accessLevel - The level of access for the non users.

add

public void add(Group group,
                AccessLevel accessLevel)
Add the given group to the access list with it's appropriate AccessLevel.

Parameters:
group - The group which will be added to the access list.
accessLevel - The accessLevel which will be given to the group.

addNegative

public void addNegative(Group group,
                        AccessLevel accessLevel)
Add the given group to the access list with it's appropriate AccessLevel. Negate the rule.
 ~group = rw
 
This means that everybody who is NOT member of the group will get the permission (rw).

Parameters:
group - The group which will be added to the access list.
accessLevel - The accessLevel which will be given to the group.

add

public void add(Access access)
Convenience method for usage in grammar.

Parameters:
access - The Access

getAccess

public AccessLevel getAccess(User user,
                             String repository,
                             String path)
Convenience method if you have a User object instead of user name as a string.

Parameters:
user - The user for which you like to know the access level.
repository - The repository which will be checked for.
path - The path within the repository.
Returns:
The AccessLevel which represents the permission for the given user in the repository and the given path.

getAccess

public AccessLevel getAccess(String user,
                             String repository,
                             String path)
Get the AccessLevel for the user who want's to get access to the path inside the given repository.

Parameters:
user - The user who will be checked against the permission rules.
repository - The repository to which the user tries to get access.
path - The path within the repository.
Returns:
AccessLevel of the user within the given path and repository.

getAccessForPrincipal

public AccessLevel getAccessForPrincipal(User user)

getAccessForPrincipal

public AccessLevel getAccessForPrincipal(String user)
Will get the AccessLevel for the given user.

Parameters:
user - The user which will be searched for.
Returns:
The AccessLevel of the given user @{link AccessLevel.NOTHING} if the user will not be found.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010-2011 SoftwareEntwicklung Beratung Schulung. All Rights Reserved.