mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
javadoc and rest docs
This commit is contained in:
@@ -37,6 +37,8 @@ import com.google.inject.Inject;
|
|||||||
|
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
|
|
||||||
|
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
|
||||||
|
|
||||||
import sonia.scm.security.KeyGenerator;
|
import sonia.scm.security.KeyGenerator;
|
||||||
import sonia.scm.security.Role;
|
import sonia.scm.security.Role;
|
||||||
|
|
||||||
@@ -54,6 +56,7 @@ import javax.ws.rs.core.MediaType;
|
|||||||
* @since 1.41
|
* @since 1.41
|
||||||
*/
|
*/
|
||||||
@Path("security/key")
|
@Path("security/key")
|
||||||
|
@ExternallyManagedLifecycle
|
||||||
public class KeyResource
|
public class KeyResource
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -72,7 +75,7 @@ public class KeyResource
|
|||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a unique key. This method can only executed with administration
|
* Generates a unique key. This method can only executed with administration
|
||||||
* privileges.<br />
|
* privileges.<br />
|
||||||
* <br />
|
* <br />
|
||||||
* <ul>
|
* <ul>
|
||||||
@@ -93,6 +96,6 @@ public class KeyResource
|
|||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** key generator */
|
||||||
private final KeyGenerator keyGenerator;
|
private final KeyGenerator keyGenerator;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ package sonia.scm.api.rest.resources;
|
|||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
|
||||||
|
|
||||||
import org.codehaus.enunciate.jaxrs.TypeHint;
|
import org.codehaus.enunciate.jaxrs.TypeHint;
|
||||||
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
|
import org.codehaus.enunciate.modules.jersey.ExternallyManagedLifecycle;
|
||||||
@@ -47,12 +46,15 @@ import org.slf4j.LoggerFactory;
|
|||||||
import sonia.scm.NotSupportedFeatuerException;
|
import sonia.scm.NotSupportedFeatuerException;
|
||||||
import sonia.scm.Type;
|
import sonia.scm.Type;
|
||||||
import sonia.scm.repository.Repository;
|
import sonia.scm.repository.Repository;
|
||||||
|
import sonia.scm.repository.RepositoryException;
|
||||||
import sonia.scm.repository.RepositoryHandler;
|
import sonia.scm.repository.RepositoryHandler;
|
||||||
import sonia.scm.repository.RepositoryManager;
|
import sonia.scm.repository.RepositoryManager;
|
||||||
import sonia.scm.util.SecurityUtil;
|
import sonia.scm.util.SecurityUtil;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -65,12 +67,13 @@ import javax.ws.rs.Produces;
|
|||||||
import javax.ws.rs.WebApplicationException;
|
import javax.ws.rs.WebApplicationException;
|
||||||
import javax.ws.rs.core.GenericEntity;
|
import javax.ws.rs.core.GenericEntity;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Rest resource for importing repositories.
|
||||||
*
|
*
|
||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
@Singleton
|
|
||||||
@Path("import/repositories")
|
@Path("import/repositories")
|
||||||
@ExternallyManagedLifecycle
|
@ExternallyManagedLifecycle
|
||||||
public class RepositoryImportResource
|
public class RepositoryImportResource
|
||||||
@@ -85,11 +88,9 @@ public class RepositoryImportResource
|
|||||||
//~--- constructors ---------------------------------------------------------
|
//~--- constructors ---------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs ...
|
* Constructs a new repository import resource.
|
||||||
*
|
*
|
||||||
*
|
* @param manager repository manager
|
||||||
* @param manager
|
|
||||||
* @param securityContextProvider
|
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public RepositoryImportResource(RepositoryManager manager)
|
public RepositoryImportResource(RepositoryManager manager)
|
||||||
@@ -100,19 +101,26 @@ public class RepositoryImportResource
|
|||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Imports repositories of the given type from the configured repository
|
||||||
|
* directory. This method requires admin privileges.<br />
|
||||||
|
* <br />
|
||||||
|
* Status codes:
|
||||||
|
* <ul>
|
||||||
|
* <li>200 ok, successful</li>
|
||||||
|
* <li>400 bad request, the import feature is not
|
||||||
|
* supported by this type of repositories.</li>
|
||||||
|
* <li>500 internal server error</li>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
|
* @param type repository type
|
||||||
*
|
*
|
||||||
* @param type
|
* @return imported repositories
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Path("{type}")
|
@Path("{type}")
|
||||||
@TypeHint(Repository[].class)
|
@TypeHint(Repository[].class)
|
||||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public GenericEntity<List<Repository>> importRepositories(
|
public Response importRepositories(@PathParam("type") String type)
|
||||||
@PathParam("type") String type)
|
|
||||||
{
|
{
|
||||||
SecurityUtil.assertIsAdmin();
|
SecurityUtil.assertIsAdmin();
|
||||||
|
|
||||||
@@ -144,7 +152,15 @@ public class RepositoryImportResource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (NotSupportedFeatuerException ex)
|
||||||
|
{
|
||||||
|
throw new WebApplicationException(ex, Response.Status.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
throw new WebApplicationException(ex);
|
||||||
|
}
|
||||||
|
catch (RepositoryException ex)
|
||||||
{
|
{
|
||||||
throw new WebApplicationException(ex);
|
throw new WebApplicationException(ex);
|
||||||
}
|
}
|
||||||
@@ -154,22 +170,33 @@ public class RepositoryImportResource
|
|||||||
logger.warn("could not find handler for type {}", type);
|
logger.warn("could not find handler for type {}", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GenericEntity<List<Repository>>(repositories) {}
|
//J-
|
||||||
;
|
return Response.ok(
|
||||||
|
new GenericEntity<List<Repository>>(repositories) {}
|
||||||
|
).build();
|
||||||
|
//J+
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Returns a list of repository types, which support the import feature.
|
||||||
|
* This method requires admin privileges.<br />
|
||||||
|
* <br />
|
||||||
|
* Status codes:
|
||||||
|
* <ul>
|
||||||
|
* <li>200 ok, successful</li>
|
||||||
|
* <li>400 bad request, the import feature is not
|
||||||
|
* supported by this type of repositories.</li>
|
||||||
|
* <li>500 internal server error</li>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
*
|
* @return list of repository types
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@TypeHint(Type[].class)
|
@TypeHint(Type[].class)
|
||||||
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
|
||||||
public GenericEntity<List<Type>> getImportableTypes()
|
public Response getImportableTypes()
|
||||||
{
|
{
|
||||||
SecurityUtil.assertIsAdmin();
|
SecurityUtil.assertIsAdmin();
|
||||||
|
|
||||||
@@ -208,12 +235,15 @@ public class RepositoryImportResource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GenericEntity<List<Type>>(types) {}
|
//J-
|
||||||
;
|
return Response.ok(
|
||||||
|
new GenericEntity<List<Type>>(types) {}
|
||||||
|
).build();
|
||||||
|
//J+
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** repository manager */
|
||||||
private RepositoryManager manager;
|
private final RepositoryManager manager;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user