@GET @Path("/bootstrap.css") @Produces("text/css") @Cache(maxAge = 2629740, mustRevalidate = false) byte[] getBootstrapCSS(); }
protected CacheControl initCacheControl(Cache methodCached) { CacheControl cacheControl = new CacheControl(); if (methodCached.isPrivate()) { cacheControl.setPrivate(true); } if (methodCached.maxAge() > -1) { cacheControl.setMaxAge(methodCached.maxAge()); } if (methodCached.sMaxAge() > -1) { cacheControl.setSMaxAge(methodCached.sMaxAge()); } cacheControl.setMustRevalidate((methodCached.mustRevalidate())); cacheControl.setNoStore((methodCached.noStore())); cacheControl.setNoTransform((methodCached.noTransform())); cacheControl.setProxyRevalidate(methodCached.proxyRevalidate()); cacheControl.setNoCache(methodCached.noCache()); return cacheControl; }
protected CacheControl initCacheControl(Cache methodCached) { CacheControl cacheControl = new CacheControl(); if (methodCached.isPrivate()) { cacheControl.setPrivate(true); } if (methodCached.maxAge() > -1) { cacheControl.setMaxAge(methodCached.maxAge()); } if (methodCached.sMaxAge() > -1) { cacheControl.setSMaxAge(methodCached.sMaxAge()); } cacheControl.setMustRevalidate((methodCached.mustRevalidate())); cacheControl.setNoStore((methodCached.noStore())); cacheControl.setNoTransform((methodCached.noTransform())); cacheControl.setProxyRevalidate(methodCached.proxyRevalidate()); return cacheControl; }
@GET @Cache(maxAge = ONE_DAY_IN_SECONDS, sMaxAge = ONE_DAY_IN_SECONDS, isPrivate = true) @Path("/{path:.*}") Response getBinary(@PathParam("path") String path); }
protected CacheControl initCacheControl(Cache methodCached) { CacheControl cacheControl = new CacheControl(); if (methodCached.isPrivate()) { cacheControl.setPrivate(true); } if (methodCached.maxAge() > -1) { cacheControl.setMaxAge(methodCached.maxAge()); } if (methodCached.sMaxAge() > -1) { cacheControl.setSMaxAge(methodCached.sMaxAge()); } cacheControl.setMustRevalidate((methodCached.mustRevalidate())); cacheControl.setNoStore((methodCached.noStore())); cacheControl.setNoTransform((methodCached.noTransform())); cacheControl.setProxyRevalidate(methodCached.proxyRevalidate()); cacheControl.setNoCache(methodCached.noCache()); return cacheControl; }
@Cache(maxAge = 600) @GET @Path("{id}") @ApiOperation(value = "Return information about the resource type with the passed id",responseClass = "ResourceTypeRest") @ApiError(code = 404, reason = "There is no type with the passed id") public Response getTypeById( @PathParam("id") int resourceTypeId, @Context HttpHeaders headers, @Context UriInfo uriInfo) { ResourceType type; try { type = typeManager.getResourceTypeById(caller,resourceTypeId); } catch (ResourceTypeNotFoundException e) { throw new StuffNotFoundException("Resource type with id " + resourceTypeId); } ResourceTypeRest rtr = resourceTypeToResourceTypeRest(type); MediaType mediaType = headers.getAcceptableMediaTypes().get(0); Response.ResponseBuilder builder = Response.ok(); builder.type(mediaType); builder.entity(rtr); return builder.build(); }
@GZIP @GET @Path("/platforms") @Cache(isPrivate = true,maxAge = 300) @ApiOperation(value = "List all platforms in the system", multiValueResponse = true, responseClass = "ResourceWithType") public Response getPlatforms( @ApiParam("Page size for paging") @QueryParam("ps") @DefaultValue("20") int pageSize, @ApiParam("Page for paging, 0-based") @QueryParam("page") @DefaultValue("0") Integer page, @Context HttpHeaders headers, @Context UriInfo uriInfo) { PageControl pc = new PageControl(page, pageSize); pc.setPrimarySort("id",PageOrdering.ASC); PageList<Resource> ret = resMgr.findResourcesByCategory(caller, ResourceCategory.PLATFORM, InventoryStatus.COMMITTED, pc); Response.ResponseBuilder builder = getResponseBuilderForResourceList(headers, uriInfo, ret); return builder.build(); }
@GET @Cache(maxAge = 300) @Path("/{id}/definition") @ApiOperation("Get the alert definition (basics) for the alert") public AlertDefinitionRest getDefinitionForAlert(@ApiParam("Id of the alert to show the definition") @PathParam("id") int alertId, @Context UriInfo uriInfo) { Alert al = findAlertWithId(alertId); AlertDefinition def = al.getAlertDefinition(); AlertDefinitionHandlerBean adhb = new AlertDefinitionHandlerBean(); AlertDefinitionRest ret = adhb.definitionToDomain(def, false, uriInfo); // TODO allow 'full' parameter? return ret; }
@Cache(isPrivate = true,maxAge = 60) @GET @Path("{id}") @ApiOperation(value = "Get the group with the passed id") @ApiError(code = 404, reason = "Group with passed id not found") public Response getGroup(@ApiParam(value = "Id of the group") @PathParam("id") int id, @Context HttpHeaders headers, @Context UriInfo uriInfo) { ResourceGroup group = fetchGroup(id, false); GroupRest groupRest = fillGroup(group, uriInfo); MediaType mediaType = headers.getAcceptableMediaTypes().get(0); Response.ResponseBuilder builder = Response.ok(); builder.type(mediaType); if (mediaType.equals(MediaType.TEXT_HTML_TYPE)) { builder.entity(renderTemplate("group", groupRest)); } else { builder.entity(groupRest); } return builder.build(); }
@GZIP @GET @Path("{id}/resources") @Cache(isPrivate = true,maxAge = 60) @ApiOperation(value="Get the resources of the group", multiValueResponse = true, responseClass = "ResourceWithType") @ApiError(code = 404, reason = "Group with passed id does not exist") public Response getResources(@ApiParam("Id of the group to retrieve the resources for") @PathParam("id") int id, @Context HttpHeaders headers, @Context UriInfo uriInfo) { ResourceGroup resourceGroup = fetchGroup(id, false); Set<Resource> resources = resourceGroup.getExplicitResources(); List<ResourceWithType> rwtList = new ArrayList<ResourceWithType>(resources.size()); for (Resource res: resources) { rwtList.add(fillRWT(res,uriInfo)); } MediaType mediaType = headers.getAcceptableMediaTypes().get(0); Response.ResponseBuilder builder; if (mediaType.equals(MediaType.TEXT_HTML_TYPE)) { builder = Response.ok(renderTemplate("listResourceWithType", rwtList), mediaType); } else { GenericEntity<List<ResourceWithType>> list = new GenericEntity<List<ResourceWithType>>(rwtList){}; builder = Response.ok(list); } return builder.build(); }
@GET @Cache(maxAge = 60) @Path("/{id}") @ApiOperation(value = "Get one alert with the passed id", responseClass = "AlertRest") public Response getAlert( @ApiParam("Id of the alert to retrieve") @PathParam("id") int id, @ApiParam(value = "Should full resources and definitions be sent") @QueryParam("slim") @DefaultValue("false") boolean slim, @Context UriInfo uriInfo, @Context Request request, @Context HttpHeaders headers) { Alert al = findAlertWithId(id); MediaType type = headers.getAcceptableMediaTypes().get(0); EntityTag eTag = new EntityTag(Integer.toHexString(al.hashCode())); Response.ResponseBuilder builder = request.evaluatePreconditions(eTag); if (builder==null) { AlertRest ar = alertToDomain(al, uriInfo, slim); if (type.equals(MediaType.TEXT_HTML_TYPE)) { builder = Response.ok(renderTemplate("alert.ftl",ar),type); } else { builder = Response.ok(ar); } } builder.tag(eTag); return builder.build(); }
@GET @Path("/{id:\\d+}") @Cache(isPrivate = true,maxAge = 120) @ApiOperation(value = "Retrieve a single resource", responseClass = "ResourceWithType") @ApiError(code = 404, reason = NO_RESOURCE_FOR_ID) public Response getResource(@ApiParam("Id of the resource to retrieve") @PathParam("id") int id, @Context Request request, @Context HttpHeaders headers, @Context UriInfo uriInfo) { Resource res; res = fetchResource(id); long mtime = res.getMtime(); EntityTag eTag = new EntityTag(Long.toOctalString(res.hashCode() + mtime)); // factor in mtime in etag Response.ResponseBuilder builder = request.evaluatePreconditions(new Date(mtime), eTag); if (builder != null) { return builder.build(); } ResourceWithType rwt = fillRWT(res, uriInfo); // What media type does the user request? MediaType mediaType = headers.getAcceptableMediaTypes().get(0); if (mediaType.equals(MediaType.TEXT_HTML_TYPE)) { builder = Response.ok(renderTemplate("resourceWithType", rwt), mediaType); } else { builder = Response.ok(rwt); } return builder.build(); }
@GET @Path("/{id}/notifications") @Cache(maxAge = 60) @ApiOperation(value = "Return the notification logs for the given alert") public Response getNotificationLogs(@ApiParam("Id of the alert to retrieve") @PathParam("id") int id,
@GZIP @GET @Path("/definition/{id}") @Cache(isPrivate = true,maxAge = 60) @ApiOperation(value = "Retrieve a single GroupDefinition by id", responseClass = "GroupDefinitionRest") @ApiError(code = 404, reason = "Group definition with the passed id does not exist.") public Response getGroupDefinition( @ApiParam("The id of the definition to retrieve") @PathParam("id") int definitionId, @Context HttpHeaders headers, @Context UriInfo uriInfo) { try { GroupDefinition def = definitionManager.getById(definitionId); GroupDefinitionRest gdr = buildGDRestFromDefinition(def); createLinksForGDRest(uriInfo,gdr); MediaType mediaType = headers.getAcceptableMediaTypes().get(0); Response.ResponseBuilder builder; if (mediaType.equals(MediaType.TEXT_HTML_TYPE)) { builder = Response.ok(renderTemplate("groupDefinition", gdr), mediaType); } else { builder= Response.ok(gdr); } return builder.build(); } catch (GroupDefinitionNotFoundException e) { throw new StuffNotFoundException("Group definition with id " + definitionId); } }
@Path("/{id}/schedules") @LinkResource(rel="schedules",value = MetricSchedule.class) @Cache(isPrivate = true,maxAge = 60) @ApiOperation(value ="Get the metric schedules of the passed resource id", multiValueResponse = true, responseClass = "MetricSchedule") @ApiError(code = 404, reason = NO_RESOURCE_FOR_ID)
@GET @Path("/{id}/conditions") @Cache(maxAge = 300) @ApiOperation(value = "Return the condition logs for the given alert") public Response getConditionLogs(@ApiParam("Id of the alert to retrieve") @PathParam("id") int id,
@GET @Path("definition/{id}") @Cache(maxAge = 1200) @ApiOperation("Retrieve a single operation definition by its id") public Response getOperationDefinition(
@GZIP @GET @Path("definitions") @Cache(maxAge = 1200) @ApiOperation("List all operation definitions for a resource") public Response getOperationDefinitions(
@GET @Cache(maxAge = 600) @Path("{id}") @ApiOperation(value = "Get info about a user", responseClass = "UserRest") public Response getUserDetails(@ApiParam(value = "Login of the user") @PathParam("id") String loginName, @Context Request request, @Context HttpHeaders headers) { Subject subject = subjectManager.getSubjectByName(loginName); if (subject == null) { throw new StuffNotFoundException("User with login " + loginName); } EntityTag eTag = new EntityTag(Long.toOctalString(subject.hashCode())); Response.ResponseBuilder builder = request.evaluatePreconditions(eTag); if (builder == null) { UserRest user = new UserRest(subject.getId(), subject.getName()); user.setFirstName(subject.getFirstName()); user.setLastName(subject.getLastName()); user.setEmail(subject.getEmailAddress()); user.setTel(subject.getPhoneNumber()); MediaType mediaType = headers.getAcceptableMediaTypes().get(0); builder = Response.ok(user, mediaType); builder.tag(eTag); } return builder.build(); }