Search in sources :

Example 96 with PathParam

use of javax.ws.rs.PathParam in project indy by Commonjava.

the class DeprecatedFoloContentAccessResource method doCreate.

@ApiOperation("Store and track file/artifact content under the given artifact store (type/name) and path.")
@ApiResponses({ @ApiResponse(code = 201, message = "Content was stored successfully"), @ApiResponse(code = 400, message = "No appropriate storage location was found in the specified store (this store, or a member if a group is specified).") })
@PUT
@Path("/{path: (.*)}")
public Response doCreate(@ApiParam("User-assigned tracking session key") @PathParam("id") final String id, @ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @PathParam("name") final String name, @PathParam("path") final String path, @Context final HttpServletRequest request, @Context final UriInfo uriInfo) {
    final TrackingKey tk = new TrackingKey(id);
    EventMetadata metadata = new EventMetadata().set(TRACKING_KEY, tk).set(ACCESS_CHANNEL, AccessChannel.MAVEN_REPO);
    final Supplier<URI> uriSupplier = () -> uriInfo.getBaseUriBuilder().path(getClass()).path(path).build(id, type, name);
    final Consumer<Response.ResponseBuilder> deprecation = builder -> {
        String alt = Paths.get("/api/folo/track/", id, MAVEN_PKG_KEY, type, name, path).toString();
        responseHelper.markDeprecated(builder, alt);
    };
    return handler.doCreate(MAVEN_PKG_KEY, type, name, path, request, metadata, uriSupplier, deprecation);
}
Also used : PathParam(javax.ws.rs.PathParam) IndyDeployment(org.commonjava.indy.bind.jaxrs.IndyDeployment) REST(org.commonjava.indy.bind.jaxrs.util.REST) CHECK_CACHE_ONLY(org.commonjava.indy.IndyContentConstants.CHECK_CACHE_ONLY) GET(javax.ws.rs.GET) LoggerFactory(org.slf4j.LoggerFactory) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) ApiResponses(io.swagger.annotations.ApiResponses) Supplier(java.util.function.Supplier) Inject(javax.inject.Inject) ApiOperation(io.swagger.annotations.ApiOperation) TrackingKey(org.commonjava.indy.folo.model.TrackingKey) HttpServletRequest(javax.servlet.http.HttpServletRequest) QueryParam(javax.ws.rs.QueryParam) Api(io.swagger.annotations.Api) URI(java.net.URI) ACCESS_CHANNEL(org.commonjava.indy.folo.ctl.FoloConstants.ACCESS_CHANNEL) MAVEN_PKG_KEY(org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor.MAVEN_PKG_KEY) Logger(org.slf4j.Logger) Context(javax.ws.rs.core.Context) ContentAccessHandler(org.commonjava.indy.core.bind.jaxrs.ContentAccessHandler) ResponseHelper(org.commonjava.indy.bind.jaxrs.util.ResponseHelper) IndyResources(org.commonjava.indy.bind.jaxrs.IndyResources) AccessChannel(org.commonjava.indy.model.core.AccessChannel) StreamingOutput(javax.ws.rs.core.StreamingOutput) Consumer(java.util.function.Consumer) Response(javax.ws.rs.core.Response) Paths(java.nio.file.Paths) TRACKING_KEY(org.commonjava.indy.folo.ctl.FoloConstants.TRACKING_KEY) ApiResponse(io.swagger.annotations.ApiResponse) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) PUT(javax.ws.rs.PUT) UriInfo(javax.ws.rs.core.UriInfo) HEAD(javax.ws.rs.HEAD) URI(java.net.URI) TrackingKey(org.commonjava.indy.folo.model.TrackingKey) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Path(javax.ws.rs.Path) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses) PUT(javax.ws.rs.PUT)

Example 97 with PathParam

use of javax.ws.rs.PathParam in project indy by Commonjava.

the class DeprecatedContentAccessResource method doDelete.

@ApiOperation("Delete file/artifact content under the given artifact store (type/name) and path.")
@ApiResponses({ @ApiResponse(code = 404, message = "Content is not available"), @ApiResponse(code = 204, message = "Content was deleted successfully") })
@DELETE
@Path("/{path: (.*)}")
public Response doDelete(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @ApiParam(required = true) @PathParam("name") final String name, @PathParam("path") final String path) {
    String packageType = MavenPackageTypeDescriptor.MAVEN_PKG_KEY;
    final Consumer<Response.ResponseBuilder> deprecated = builder -> {
        String alt = Paths.get("/api/maven", type, name, path).toString();
        responseHelper.markDeprecated(builder, alt);
    };
    return handler.doDelete(packageType, type, name, path, new EventMetadata(), deprecated);
}
Also used : PathParam(javax.ws.rs.PathParam) IndyDeployment(org.commonjava.indy.bind.jaxrs.IndyDeployment) REST(org.commonjava.indy.bind.jaxrs.util.REST) CHECK_CACHE_ONLY(org.commonjava.indy.IndyContentConstants.CHECK_CACHE_ONLY) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) ApiResponses(io.swagger.annotations.ApiResponses) Supplier(java.util.function.Supplier) Inject(javax.inject.Inject) ApiOperation(io.swagger.annotations.ApiOperation) HttpServletRequest(javax.servlet.http.HttpServletRequest) MavenPackageTypeDescriptor(org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor) QueryParam(javax.ws.rs.QueryParam) Api(io.swagger.annotations.Api) URI(java.net.URI) STORE_HTTP_HEADERS(org.commonjava.maven.galley.spi.cache.CacheProvider.STORE_HTTP_HEADERS) DELETE(javax.ws.rs.DELETE) Context(javax.ws.rs.core.Context) ResponseHelper(org.commonjava.indy.bind.jaxrs.util.ResponseHelper) RequestUtils(org.commonjava.indy.core.bind.jaxrs.util.RequestUtils) IndyResources(org.commonjava.indy.bind.jaxrs.IndyResources) StreamingOutput(javax.ws.rs.core.StreamingOutput) Consumer(java.util.function.Consumer) Response(javax.ws.rs.core.Response) Paths(java.nio.file.Paths) ApiResponse(io.swagger.annotations.ApiResponse) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) ApplicationScoped(javax.enterprise.context.ApplicationScoped) PUT(javax.ws.rs.PUT) UriInfo(javax.ws.rs.core.UriInfo) HEAD(javax.ws.rs.HEAD) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 98 with PathParam

use of javax.ws.rs.PathParam in project indy by Commonjava.

the class DeprecatedContentAccessResource method doGet.

@ApiOperation("Retrieve root listing under the given artifact store (type/name).")
@ApiResponses({ @ApiResponse(code = 200, response = String.class, message = "Rendered root content listing"), @ApiResponse(code = 200, response = StreamingOutput.class, message = "Content stream") })
@GET
@Path("/")
public Response doGet(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type, @ApiParam(required = true) @PathParam("name") final String name, @Context final UriInfo uriInfo, @Context final HttpServletRequest request) {
    String packageType = MavenPackageTypeDescriptor.MAVEN_PKG_KEY;
    final String baseUri = uriInfo.getBaseUriBuilder().path(IndyDeployment.API_PREFIX).build().toString();
    final Consumer<Response.ResponseBuilder> deprecated = builder -> {
        String alt = Paths.get("/api/maven", type, name).toString();
        responseHelper.markDeprecated(builder, alt);
    };
    return handler.doGet(packageType, type, name, "", baseUri, request, new EventMetadata(), deprecated);
}
Also used : PathParam(javax.ws.rs.PathParam) IndyDeployment(org.commonjava.indy.bind.jaxrs.IndyDeployment) REST(org.commonjava.indy.bind.jaxrs.util.REST) CHECK_CACHE_ONLY(org.commonjava.indy.IndyContentConstants.CHECK_CACHE_ONLY) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) ApiResponses(io.swagger.annotations.ApiResponses) Supplier(java.util.function.Supplier) Inject(javax.inject.Inject) ApiOperation(io.swagger.annotations.ApiOperation) HttpServletRequest(javax.servlet.http.HttpServletRequest) MavenPackageTypeDescriptor(org.commonjava.indy.pkg.maven.model.MavenPackageTypeDescriptor) QueryParam(javax.ws.rs.QueryParam) Api(io.swagger.annotations.Api) URI(java.net.URI) STORE_HTTP_HEADERS(org.commonjava.maven.galley.spi.cache.CacheProvider.STORE_HTTP_HEADERS) DELETE(javax.ws.rs.DELETE) Context(javax.ws.rs.core.Context) ResponseHelper(org.commonjava.indy.bind.jaxrs.util.ResponseHelper) RequestUtils(org.commonjava.indy.core.bind.jaxrs.util.RequestUtils) IndyResources(org.commonjava.indy.bind.jaxrs.IndyResources) StreamingOutput(javax.ws.rs.core.StreamingOutput) Consumer(java.util.function.Consumer) Response(javax.ws.rs.core.Response) Paths(java.nio.file.Paths) ApiResponse(io.swagger.annotations.ApiResponse) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) ApplicationScoped(javax.enterprise.context.ApplicationScoped) PUT(javax.ws.rs.PUT) UriInfo(javax.ws.rs.core.UriInfo) HEAD(javax.ws.rs.HEAD) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 99 with PathParam

use of javax.ws.rs.PathParam in project verify-hub by alphagov.

the class CertificatesResource method getEncryptionCertificate.

@GET
@Path(Urls.ConfigUrls.ENCRYPTION_CERTIFICATE_PATH)
@Timed
public CertificateDto getEncryptionCertificate(@PathParam(Urls.SharedUrls.ENTITY_ID_PARAM) String entityId) {
    try {
        Certificate certificate = certificateService.encryptionCertificateFor(entityId);
        Optional<String> base64Encoded = certificate.getBase64Encoded();
        return certificate.getBase64Encoded().map(base64 -> aCertificateDto(entityId, base64Encoded.get(), CertificateDto.KeyUse.Encryption, certificate.getFederationEntityType())).orElseThrow(() -> exceptionFactory.createNoDataForEntityException(entityId));
    } catch (NoCertificateFoundException ncfe) {
        throw exceptionFactory.createNoDataForEntityException(entityId);
    } catch (CertificateDisabledException cde) {
        throw exceptionFactory.createDisabledTransactionException(entityId);
    }
}
Also used : PathParam(javax.ws.rs.PathParam) ExceptionFactory(uk.gov.ida.hub.config.exceptions.ExceptionFactory) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) CertificateDto(uk.gov.ida.hub.config.dto.CertificateDto) Inject(javax.inject.Inject) MediaType(javax.ws.rs.core.MediaType) InvalidCertificateDto(uk.gov.ida.hub.config.dto.InvalidCertificateDto) Urls(uk.gov.ida.hub.config.Urls) NoCertificateFoundException(uk.gov.ida.hub.config.exceptions.NoCertificateFoundException) Certificate(uk.gov.ida.hub.config.domain.Certificate) Collection(java.util.Collection) CertificateDto.aCertificateDto(uk.gov.ida.hub.config.dto.CertificateDto.aCertificateDto) ConfigConfiguration(uk.gov.ida.hub.config.ConfigConfiguration) CertificateHealthCheckDto(uk.gov.ida.hub.config.dto.CertificateHealthCheckDto) Set(java.util.Set) CertificateService(uk.gov.ida.hub.config.application.CertificateService) CertificateDisabledException(uk.gov.ida.hub.config.exceptions.CertificateDisabledException) Timed(com.codahale.metrics.annotation.Timed) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Response(javax.ws.rs.core.Response) OCSPCertificateChainValidityChecker(uk.gov.ida.hub.config.domain.OCSPCertificateChainValidityChecker) Optional(java.util.Optional) NoCertificateFoundException(uk.gov.ida.hub.config.exceptions.NoCertificateFoundException) CertificateDisabledException(uk.gov.ida.hub.config.exceptions.CertificateDisabledException) Certificate(uk.gov.ida.hub.config.domain.Certificate) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 100 with PathParam

use of javax.ws.rs.PathParam in project cxf by apache.

the class JAXRSContainerTest method checkComplexPathMethod.

private void checkComplexPathMethod(Method m, String suffix) {
    assertNotNull(m.getAnnotation(GET.class));
    Path path = m.getAnnotation(Path.class);
    assertNotNull(path);
    assertEquals("/get-add-method", path.value());
    assertEquals("getGetaddmethod" + suffix, m.getName());
    Class<?>[] paramTypes = m.getParameterTypes();
    assertEquals(1, paramTypes.length);
    Annotation[][] paramAnns = m.getParameterAnnotations();
    assertEquals(String.class, paramTypes[0]);
    assertEquals(1, paramAnns[0].length);
    PathParam methodPathParam1 = (PathParam) paramAnns[0][0];
    assertEquals("id", methodPathParam1.value());
}
Also used : Path(javax.ws.rs.Path) GET(javax.ws.rs.GET) PathParam(javax.ws.rs.PathParam)

Aggregations

PathParam (javax.ws.rs.PathParam)127 Path (javax.ws.rs.Path)105 GET (javax.ws.rs.GET)96 Produces (javax.ws.rs.Produces)96 Response (javax.ws.rs.core.Response)93 QueryParam (javax.ws.rs.QueryParam)82 List (java.util.List)72 MediaType (javax.ws.rs.core.MediaType)72 POST (javax.ws.rs.POST)71 DELETE (javax.ws.rs.DELETE)70 Consumes (javax.ws.rs.Consumes)66 Inject (javax.inject.Inject)62 Api (io.swagger.annotations.Api)60 ApiOperation (io.swagger.annotations.ApiOperation)59 Map (java.util.Map)59 ApiResponse (io.swagger.annotations.ApiResponse)58 ApiResponses (io.swagger.annotations.ApiResponses)57 Collectors (java.util.stream.Collectors)57 Logger (org.slf4j.Logger)52 LoggerFactory (org.slf4j.LoggerFactory)52