Search in sources :

Example 1 with HEAD

use of javax.ws.rs.HEAD in project OpenOLAT by OpenOLAT.

the class UserWebService method getPortraitHead.

/**
 * Retrieves the portrait of an user
 * @response.representation.200.mediaType application/octet-stream
 * @response.representation.200.doc The portrait as image
 * @response.representation.404.doc The identity or the portrait not found
 * @param identityKey The identity key of the user being searched
 * @return The image
 */
@HEAD
@Path("{identityKey}/portrait")
@Produces({ "image/jpeg", "image/jpg", MediaType.APPLICATION_OCTET_STREAM })
public Response getPortraitHead(@PathParam("identityKey") Long identityKey) {
    try {
        IdentityShort identity = BaseSecurityManager.getInstance().loadIdentityShortByKey(identityKey);
        if (identity == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        }
        File portrait = DisplayPortraitManager.getInstance().getBigPortrait(identity.getName());
        if (portrait == null || !portrait.exists()) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        }
        Date lastModified = new Date(portrait.lastModified());
        return Response.ok().lastModified(lastModified).build();
    } catch (Throwable e) {
        throw new WebApplicationException(e);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) IdentityShort(org.olat.basesecurity.IdentityShort) File(java.io.File) Date(java.util.Date) Path(javax.ws.rs.Path) HEAD(javax.ws.rs.HEAD) Produces(javax.ws.rs.Produces)

Example 2 with HEAD

use of javax.ws.rs.HEAD in project narayana by jbosstm.

the class LoggingRestATResource method headParticipant.

/**
 * Returns links to the participant terminator.
 *
 * @return Link to the participant terminator.
 */
@HEAD
public Response headParticipant(@Context UriInfo uriInfo) {
    LOG.info("LoggingRestATResource.headParticipant()");
    invocations.add("LoggingRestATResource.headParticipant()");
    String serviceURL = uriInfo.getBaseUri() + uriInfo.getPath();
    String linkHeader = new TxSupport().makeTwoPhaseAwareParticipantLinkHeader(serviceURL, false, null, null);
    return Response.ok().header("Link", linkHeader).build();
}
Also used : TxSupport(org.jboss.jbossts.star.util.TxSupport) HEAD(javax.ws.rs.HEAD)

Example 3 with HEAD

use of javax.ws.rs.HEAD in project ovirt-engine by oVirt.

the class V3SystemServer method head.

@HEAD
public Response head() {
    // We need the V4 response for the GET method, as the response for the HEAD response doesn't contain an entity
    // and thus doesn't contain the links:
    Response response = adaptResponse(getDelegate()::get);
    // Replace the "Link" header with links calculated from the response body:
    response = replaceLinkHeader(response);
    // Clear the response body:
    response = Response.fromResponse(response).entity(null).build();
    return response;
}
Also used : Response(javax.ws.rs.core.Response) HEAD(javax.ws.rs.HEAD)

Example 4 with HEAD

use of javax.ws.rs.HEAD in project OpenOLAT by OpenOLAT.

the class CertificationWebService method getCertificateInfo.

@HEAD
@Path("{identityKey}")
@Produces({ "application/pdf" })
public Response getCertificateInfo(@PathParam("identityKey") Long identityKey, @PathParam("resourceKey") Long resourceKey, @Context HttpServletRequest request) {
    if (!isAdmin(request)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    CertificatesManager certificatesManager = CoreSpringFactory.getImpl(CertificatesManager.class);
    BaseSecurity baseSecurity = CoreSpringFactory.getImpl(BaseSecurity.class);
    Identity identity = baseSecurity.loadIdentityByKey(identityKey);
    if (identity == null) {
        return Response.serverError().status(Response.Status.NOT_FOUND).build();
    }
    OLATResourceable courseOres = OresHelper.createOLATResourceableInstance("CourseModule", resourceKey);
    OLATResourceManager resourceManager = CoreSpringFactory.getImpl(OLATResourceManager.class);
    OLATResource resource = resourceManager.findResourceable(courseOres);
    if (resource == null) {
        resource = resourceManager.findResourceById(resourceKey);
    }
    if (resource == null) {
        return Response.serverError().status(Response.Status.NOT_FOUND).build();
    }
    Certificate certificate = certificatesManager.getLastCertificate(identity, resource.getKey());
    if (certificate == null) {
        return Response.serverError().status(Response.Status.NOT_FOUND).build();
    }
    VFSLeaf certificateFile = certificatesManager.getCertificateLeaf(certificate);
    if (certificateFile == null || !certificateFile.exists()) {
        return Response.serverError().status(Response.Status.NOT_FOUND).build();
    }
    return Response.ok().build();
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) OLATResourceable(org.olat.core.id.OLATResourceable) CertificatesManager(org.olat.course.certificate.CertificatesManager) OLATResourceManager(org.olat.resource.OLATResourceManager) OLATResource(org.olat.resource.OLATResource) Identity(org.olat.core.id.Identity) BaseSecurity(org.olat.basesecurity.BaseSecurity) Certificate(org.olat.course.certificate.Certificate) Path(javax.ws.rs.Path) HEAD(javax.ws.rs.HEAD) Produces(javax.ws.rs.Produces)

Example 5 with HEAD

use of javax.ws.rs.HEAD in project component-runtime by Talend.

the class AdminResource method reload.

@HEAD
@Path("{familyId}")
public void reload(@PathParam("familyId") final String familyId) {
    final ComponentFamilyMeta family = ofNullable(componentFamilyDao.findById(familyId)).orElseThrow(() -> new WebApplicationException(Response.Status.NOT_FOUND));
    service.manager().findPlugin(family.getPlugin()).orElseThrow(() -> new WebApplicationException(Response.Status.NOT_FOUND)).get(ContainerManager.Actions.class).reload();
    log.info("Reloaded family {}", family.getName());
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) ComponentFamilyMeta(org.talend.sdk.component.runtime.manager.ComponentFamilyMeta) Path(javax.ws.rs.Path) HEAD(javax.ws.rs.HEAD)

Aggregations

HEAD (javax.ws.rs.HEAD)24 Path (javax.ws.rs.Path)19 ApiOperation (io.swagger.annotations.ApiOperation)8 ApiResponses (io.swagger.annotations.ApiResponses)8 Produces (javax.ws.rs.Produces)8 Response (javax.ws.rs.core.Response)8 Date (java.util.Date)6 WebApplicationException (javax.ws.rs.WebApplicationException)6 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)6 ApiResponse (io.swagger.annotations.ApiResponse)4 File (java.io.File)4 GET (javax.ws.rs.GET)4 IdentityShort (org.olat.basesecurity.IdentityShort)4 PUT (javax.ws.rs.PUT)3 PathParam (javax.ws.rs.PathParam)3 QueryParam (javax.ws.rs.QueryParam)3 TrackingKey (org.commonjava.indy.folo.model.TrackingKey)3 Api (io.swagger.annotations.Api)2 ApiParam (io.swagger.annotations.ApiParam)2 URI (java.net.URI)2