mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 07:25:44 +01:00
added RepositoryResource
This commit is contained in:
176
scm-webapp/src/main/java/sonia/scm/Repository.java
Normal file
176
scm-webapp/src/main/java/sonia/scm/Repository.java
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@XmlRootElement(name = "repositories")
|
||||
@XmlType(propOrder =
|
||||
{
|
||||
"type", "name", "contact", "description"
|
||||
})
|
||||
public class Repository implements Serializable
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = 3486560714961909711L;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public Repository() {}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* @param name
|
||||
*/
|
||||
public Repository(String type, String name)
|
||||
{
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* @param name
|
||||
* @param contact
|
||||
* @param description
|
||||
*/
|
||||
public Repository(String type, String name, String contact,
|
||||
String description)
|
||||
{
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.contact = contact;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getContact()
|
||||
{
|
||||
return contact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param contact
|
||||
*/
|
||||
public void setContact(String contact)
|
||||
{
|
||||
this.contact = contact;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param description
|
||||
*/
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private String contact;
|
||||
|
||||
/** Field description */
|
||||
private String description;
|
||||
|
||||
/** Field description */
|
||||
private String name;
|
||||
|
||||
/** Field description */
|
||||
private String type;
|
||||
}
|
||||
@@ -40,14 +40,14 @@ import javax.ws.rs.core.UriInfo;
|
||||
@Singleton
|
||||
@Path("groups")
|
||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||
public class GroupsResource
|
||||
public class GroupResource
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public GroupsResource()
|
||||
public GroupResource()
|
||||
{
|
||||
groupStore = new LinkedHashMap<String, Group>();
|
||||
groupStore.put("csit",
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.api.rest.resources;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.Repository;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
@Path("repositories")
|
||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||
public class RepositoryResource
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public RepositoryResource()
|
||||
{
|
||||
repositoryStore = new LinkedHashMap<String, Repository>();
|
||||
repositoryStore.put("sonia.lib",
|
||||
new Repository("hg", "sonia.lib", "csit@ostfalia.de",
|
||||
"SONIA Library"));
|
||||
repositoryStore.put("sonia.misc",
|
||||
new Repository("hg", "sonia.misc", "csit@ostfalia.de",
|
||||
"SONIA Miscelanious"));
|
||||
repositoryStore.put("PWA",
|
||||
new Repository("svn", "PWA",
|
||||
"csit@fh-wolfenbuettel.de", "PWA"));
|
||||
repositoryStore.put("sonia.app",
|
||||
new Repository("hg", "sonia.app", "csit@ostfalia.de",
|
||||
"SONIA Applications"));
|
||||
repositoryStore.put("sonia.webapps",
|
||||
new Repository("hg", "sonia.webapps",
|
||||
"csit@ostfalia.de",
|
||||
"SONIA WebApplications"));
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GET
|
||||
@Path("{name}")
|
||||
public Repository get(@PathParam("name") String name)
|
||||
{
|
||||
Repository repository = repositoryStore.get(name);
|
||||
|
||||
if (repository == null)
|
||||
{
|
||||
throw new WebApplicationException(Status.NOT_FOUND);
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GET
|
||||
public Repository[] getAll()
|
||||
{
|
||||
Collection<Repository> repositoryCollection = repositoryStore.values();
|
||||
|
||||
return repositoryCollection.toArray(
|
||||
new Repository[repositoryCollection.size()]);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private HashMap<String, Repository> repositoryStore;
|
||||
}
|
||||
Reference in New Issue
Block a user