mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
added permissions to repository
This commit is contained in:
157
scm-core/src/main/java/sonia/scm/repository/Permission.java
Normal file
157
scm-core/src/main/java/sonia/scm/repository/Permission.java
Normal 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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user