added permissions to repository

This commit is contained in:
Sebastian Sdorra
2010-09-09 10:11:58 +02:00
parent e553f3fc34
commit db6ddfb59e
5 changed files with 249 additions and 10 deletions

View File

@@ -0,0 +1,157 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sonia.scm.repository;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author Sebastian Sdorra
*/
@XmlRootElement(name="permissions")
@XmlAccessorType(XmlAccessType.FIELD)
public class Permission
{
/**
* Constructs ...
*
*/
public Permission() {}
/**
* Constructs ...
*
*
* @param name
* @param readable
* @param writeable
*/
public Permission(String name, boolean readable, boolean writeable)
{
this.name = name;
this.readable = readable;
this.writeable = writeable;
this.groupPermission = false;
}
/**
* Constructs ...
*
*
* @param name
* @param readable
* @param writeable
* @param groupPermission
*/
public Permission(String name, boolean readable, boolean writeable,
boolean groupPermission)
{
this.name = name;
this.readable = readable;
this.writeable = writeable;
this.groupPermission = groupPermission;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String toString()
{
StringBuilder buffer = new StringBuilder();
buffer.append(name);
if (groupPermission)
{
buffer.append(" (Group)");
}
buffer.append(" - ");
if (readable)
{
buffer.append("r");
}
if (writeable)
{
buffer.append("w");
}
return buffer.toString();
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getName()
{
return name;
}
/**
* Method description
*
*
* @return
*/
public boolean isGroupPermission()
{
return groupPermission;
}
/**
* Method description
*
*
* @return
*/
public boolean isReadable()
{
return readable;
}
/**
* Method description
*
*
* @return
*/
public boolean isWriteable()
{
return writeable;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private boolean groupPermission;
/** Field description */
private String name;
/** Field description */
private boolean readable;
/** Field description */
private boolean writeable;
}

View File

@@ -7,10 +7,18 @@
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@@ -21,7 +29,7 @@ import javax.xml.bind.annotation.XmlType;
@XmlRootElement(name = "repositories")
@XmlType(propOrder =
{
"type", "name", "contact", "description"
"type", "name", "contact", "description", "permissions"
})
public class Repository implements Serializable
{
@@ -58,14 +66,21 @@ public class Repository implements Serializable
* @param name
* @param contact
* @param description
* @param permissions
*/
public Repository(String type, String name, String contact,
String description)
String description, Permission... permissions)
{
this.type = type;
this.name = name;
this.contact = contact;
this.description = description;
this.permissions = new ArrayList<Permission>();
if (Util.isNotEmpty(permissions))
{
this.permissions.addAll(Arrays.asList(permissions));
}
}
//~--- get methods ----------------------------------------------------------
@@ -103,6 +118,17 @@ public class Repository implements Serializable
return name;
}
/**
* Method description
*
*
* @return
*/
public List<Permission> getPermissions()
{
return permissions;
}
/**
* Method description
*
@@ -149,6 +175,17 @@ public class Repository implements Serializable
this.name = name;
}
/**
* Method description
*
*
* @param permissions
*/
public void setPermissions(List<Permission> permissions)
{
this.permissions = permissions;
}
/**
* Method description
*
@@ -171,6 +208,9 @@ public class Repository implements Serializable
/** Field description */
private String name;
/** Field description */
private List<Permission> permissions;
/** Field description */
private String type;
}