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);
}
}
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();
}
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;
}
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();
}
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());
}
Aggregations