mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 22:45:45 +01:00
added permissions to repository
This commit is contained in:
@@ -40,6 +40,17 @@ public class HgConfig
|
|||||||
return configDirectory;
|
return configDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getHgBinary()
|
||||||
|
{
|
||||||
|
return hgBinary;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -64,6 +75,17 @@ public class HgConfig
|
|||||||
this.configDirectory = configDirectory;
|
this.configDirectory = configDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param hgBinary
|
||||||
|
*/
|
||||||
|
public void setHgBinary(String hgBinary)
|
||||||
|
{
|
||||||
|
this.hgBinary = hgBinary;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -80,6 +102,9 @@ public class HgConfig
|
|||||||
/** Field description */
|
/** Field description */
|
||||||
private File configDirectory;
|
private File configDirectory;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private String hgBinary = "hg";
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private File repositoryDirectory;
|
private File repositoryDirectory;
|
||||||
}
|
}
|
||||||
|
|||||||
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;
|
package sonia.scm.repository;
|
||||||
|
|
||||||
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import sonia.scm.util.Util;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import java.io.Serializable;
|
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.XmlRootElement;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
@@ -21,7 +29,7 @@ import javax.xml.bind.annotation.XmlType;
|
|||||||
@XmlRootElement(name = "repositories")
|
@XmlRootElement(name = "repositories")
|
||||||
@XmlType(propOrder =
|
@XmlType(propOrder =
|
||||||
{
|
{
|
||||||
"type", "name", "contact", "description"
|
"type", "name", "contact", "description", "permissions"
|
||||||
})
|
})
|
||||||
public class Repository implements Serializable
|
public class Repository implements Serializable
|
||||||
{
|
{
|
||||||
@@ -58,14 +66,21 @@ public class Repository implements Serializable
|
|||||||
* @param name
|
* @param name
|
||||||
* @param contact
|
* @param contact
|
||||||
* @param description
|
* @param description
|
||||||
|
* @param permissions
|
||||||
*/
|
*/
|
||||||
public Repository(String type, String name, String contact,
|
public Repository(String type, String name, String contact,
|
||||||
String description)
|
String description, Permission... permissions)
|
||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.contact = contact;
|
this.contact = contact;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
|
this.permissions = new ArrayList<Permission>();
|
||||||
|
|
||||||
|
if (Util.isNotEmpty(permissions))
|
||||||
|
{
|
||||||
|
this.permissions.addAll(Arrays.asList(permissions));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
@@ -103,6 +118,17 @@ public class Repository implements Serializable
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Permission> getPermissions()
|
||||||
|
{
|
||||||
|
return permissions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -149,6 +175,17 @@ public class Repository implements Serializable
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param permissions
|
||||||
|
*/
|
||||||
|
public void setPermissions(List<Permission> permissions)
|
||||||
|
{
|
||||||
|
this.permissions = permissions;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
@@ -171,6 +208,9 @@ public class Repository implements Serializable
|
|||||||
/** Field description */
|
/** Field description */
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
/** Field description */
|
||||||
|
private List<Permission> permissions;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private String type;
|
private String type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ package sonia.scm.api.rest;
|
|||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import sonia.scm.group.Group;
|
import sonia.scm.group.Group;
|
||||||
|
import sonia.scm.repository.Repository;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import com.sun.jersey.api.json.JSONConfiguration;
|
import com.sun.jersey.api.json.JSONConfiguration;
|
||||||
@@ -41,7 +43,9 @@ public class JsonJaxbContextResolver implements ContextResolver<JAXBContext>
|
|||||||
{
|
{
|
||||||
this.context = new JSONJAXBContext(
|
this.context = new JSONJAXBContext(
|
||||||
JSONConfiguration.mapped().rootUnwrapping(true).arrays(
|
JSONConfiguration.mapped().rootUnwrapping(true).arrays(
|
||||||
"member", "groups").build(), types.toArray(new Class[0]));
|
"member", "groups", "permissions").nonStrings(
|
||||||
|
"readable", "writeable", "groupPermission").build(), types.toArray(
|
||||||
|
new Class[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
@@ -68,6 +72,6 @@ public class JsonJaxbContextResolver implements ContextResolver<JAXBContext>
|
|||||||
private JAXBContext context;
|
private JAXBContext context;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private List<Class> types = Arrays.asList(new Class[] {
|
private List<Class> types = Arrays.asList(new Class[] { Group.class,
|
||||||
Group.class });
|
Repository.class });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ package sonia.scm.api.rest.resources;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import sonia.scm.repository.Permission;
|
||||||
import sonia.scm.repository.Repository;
|
import sonia.scm.repository.Repository;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
@@ -47,20 +48,32 @@ public class RepositoryResource extends AbstractResource<Repository>
|
|||||||
repositoryStore = new LinkedHashMap<String, Repository>();
|
repositoryStore = new LinkedHashMap<String, Repository>();
|
||||||
repositoryStore.put("sonia.lib",
|
repositoryStore.put("sonia.lib",
|
||||||
new Repository("hg", "sonia.lib", "csit@ostfalia.de",
|
new Repository("hg", "sonia.lib", "csit@ostfalia.de",
|
||||||
"SONIA Library"));
|
"SONIA Library",
|
||||||
|
new Permission("csit", true, true,
|
||||||
|
true)));
|
||||||
repositoryStore.put("sonia.misc",
|
repositoryStore.put("sonia.misc",
|
||||||
new Repository("hg", "sonia.misc", "csit@ostfalia.de",
|
new Repository("hg", "sonia.misc", "csit@ostfalia.de",
|
||||||
"SONIA Miscelanious"));
|
"SONIA Miscelanious",
|
||||||
|
new Permission("csit", true, true,
|
||||||
|
true)));
|
||||||
repositoryStore.put("PWA",
|
repositoryStore.put("PWA",
|
||||||
new Repository("svn", "PWA",
|
new Repository("svn", "PWA",
|
||||||
"csit@fh-wolfenbuettel.de", "PWA"));
|
"csit@fh-wolfenbuettel.de", "PWA",
|
||||||
|
new Permission("th", true, true),
|
||||||
|
new Permission("sdorra", true, true),
|
||||||
|
new Permission("oelkersd", true,
|
||||||
|
false)));
|
||||||
repositoryStore.put("sonia.app",
|
repositoryStore.put("sonia.app",
|
||||||
new Repository("hg", "sonia.app", "csit@ostfalia.de",
|
new Repository("hg", "sonia.app", "csit@ostfalia.de",
|
||||||
"SONIA Applications"));
|
"SONIA Applications",
|
||||||
|
new Permission("csit", true, true,
|
||||||
|
true)));
|
||||||
repositoryStore.put("sonia.webapps",
|
repositoryStore.put("sonia.webapps",
|
||||||
new Repository("hg", "sonia.webapps",
|
new Repository("hg", "sonia.webapps",
|
||||||
"csit@ostfalia.de",
|
"csit@ostfalia.de",
|
||||||
"SONIA WebApplications"));
|
"SONIA WebApplications",
|
||||||
|
new Permission("csit", true, true,
|
||||||
|
true)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user