public static ResponseBuilder notModified(EntityTag tag) { ResponseBuilder b = notModified(); b.tag(tag); return b; }
public static ResponseBuilder notModified(String tag) { ResponseBuilder b = notModified(); b.tag(tag); return b; }
@POST @Path( "/rename/{id}/{path}/{newName}/{type}/{oldName}" ) public Response rename( @PathParam( "id" ) String id, @PathParam( "path" ) String path, @PathParam( "newName" ) String newName, @PathParam( "type" ) String type, @PathParam( "oldName" ) String oldName ) { try { ObjectId objectId = repositoryBrowserController.rename( id, path, newName, type, oldName ); if ( objectId != null ) { return Response.ok( objectId ).build(); } } catch ( KettleObjectExistsException koee ) { return Response.status( Response.Status.CONFLICT ).build(); } catch ( KettleTransException | KettleJobException ktje ) { return Response.status( Response.Status.NOT_ACCEPTABLE ).build(); } catch ( KettleException ke ) { return Response.notModified().build(); } return Response.notModified().build(); }
private Response.ResponseBuilder evaluateIfModifiedSince(final long lastModified, final String ifModifiedSinceHeader) { try { final long ifModifiedSince = HttpHeaderReader.readDate(ifModifiedSinceHeader).getTime(); if (roundDown(lastModified) <= ifModifiedSince) { // 304 Not modified return Response.notModified(); } } catch (final ParseException ex) { // Ignore the header if parsing error } return null; }
private Response.ResponseBuilder evaluateIfModifiedSince(final long lastModified, final String ifModifiedSinceHeader) { try { final long ifModifiedSince = HttpHeaderReader.readDate(ifModifiedSinceHeader).getTime(); if (roundDown(lastModified) <= ifModifiedSince) { // 304 Not modified return Response.notModified(); } } catch (final ParseException ex) { // Ignore the header if parsing error } return null; }
private Response.ResponseBuilder evaluateIfNoneMatch(final EntityTag eTag, final Set<? extends EntityTag> matchingTags, final boolean isGetOrHead) { if (isGetOrHead) { if (matchingTags == MatchingEntityTag.ANY_MATCH) { // 304 Not modified return Response.notModified(eTag); } // The weak comparison function may be used to compare entity tags if (matchingTags.contains(eTag) || matchingTags.contains(new EntityTag(eTag.getValue(), !eTag.isWeak()))) { // 304 Not modified return Response.notModified(eTag); } } else { // The strong comparison function must be used to compare the entity // tags. Thus if the entity tag of the entity is weak then matching // of entity tags in the If-None-Match header should fail if the // HTTP method is not GET or not HEAD. if (eTag.isWeak()) { return null; } if (matchingTags == MatchingEntityTag.ANY_MATCH || matchingTags.contains(eTag)) { // 412 Precondition Failed return Response.status(Response.Status.PRECONDITION_FAILED); } } return null; }
@DELETE @Path("/{id}") @RequiresPermissions(SidecarRestPermissions.COLLECTORS_DELETE) @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "Delete a collector") @AuditEvent(type = SidecarAuditEventTypes.COLLECTOR_DELETE) public Response deleteCollector(@ApiParam(name = "id", required = true) @PathParam("id") String id) { final long configurationsForCollector = configurationService.all().stream() .filter(configuration -> configuration.collectorId().equals(id)) .count(); if (configurationsForCollector > 0) { throw new BadRequestException("Collector still in use, cannot delete."); } int deleted = collectorService.delete(id); if (deleted == 0) { return Response.notModified().build(); } etagService.invalidateAll(); return Response.accepted().build(); }
private Response.ResponseBuilder evaluateIfNoneMatch(final EntityTag eTag, final Set<? extends EntityTag> matchingTags, final boolean isGetOrHead) { if (isGetOrHead) { if (matchingTags == MatchingEntityTag.ANY_MATCH) { // 304 Not modified return Response.notModified(eTag); } // The weak comparison function may be used to compare entity tags if (matchingTags.contains(eTag) || matchingTags.contains(new EntityTag(eTag.getValue(), !eTag.isWeak()))) { // 304 Not modified return Response.notModified(eTag); } } else { // The strong comparison function must be used to compare the entity // tags. Thus if the entity tag of the entity is weak then matching // of entity tags in the If-None-Match header should fail if the // HTTP method is not GET or not HEAD. if (eTag.isWeak()) { return null; } if (matchingTags == MatchingEntityTag.ANY_MATCH || matchingTags.contains(eTag)) { // 412 Precondition Failed return Response.status(Response.Status.PRECONDITION_FAILED); } } return null; }
@DELETE @Path("/{id}") @RequiresPermissions(SidecarRestPermissions.CONFIGURATIONS_DELETE) @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "Delete a configuration") @AuditEvent(type = SidecarAuditEventTypes.CONFIGURATION_DELETE) public Response deleteConfiguration(@ApiParam(name = "id", required = true) @PathParam("id") String id) { if (isConfigurationInUse(id)) { throw new BadRequestException("Configuration still in use, cannot delete."); } int deleted = configurationService.delete(id); if (deleted == 0) { return Response.notModified().build(); } etagService.invalidateAll(); return Response.accepted().build(); }
@DELETE @Path("/{id}") @RequiresPermissions(SidecarRestPermissions.CONFIGURATIONS_UPDATE) @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "Delete a configuration variable") @AuditEvent(type = SidecarAuditEventTypes.CONFIGURATION_VARIABLE_DELETE) public Response deleteConfigurationVariable(@ApiParam(name = "id", required = true) @PathParam("id") String id) { final ConfigurationVariable configurationVariable = findVariableOrFail(id); final List<Configuration> configurations = this.configurationService.findByConfigurationVariable(configurationVariable); if (!configurations.isEmpty()) { final ValidationResult validationResult = new ValidationResult(); validationResult.addError("name", "Variable is still used in the following configurations: " + configurations.stream().map(c -> c.name()).collect(Collectors.joining(", "))); return Response.status(Response.Status.BAD_REQUEST).entity(validationResult).build(); } int deleted = configurationVariableService.delete(id); if (deleted == 0) { return Response.notModified().build(); } etagService.invalidateAll(); return Response.accepted().build(); }
private ResponseBuilder evaluateIfNoneMatch( EntityTag eTag, Set<MatchingEntityTag> matchingTags, boolean isGetOrHead) { if (isGetOrHead) { if (matchingTags == MatchingEntityTag.ANY_MATCH) { // 304 Not modified return Response.notModified(eTag); } // The weak comparison function may be used to compare entity tags if (matchingTags.contains(eTag) || matchingTags.contains(new EntityTag(eTag.getValue(), !eTag.isWeak()))) { // 304 Not modified return Response.notModified(eTag); } } else { // The strong comparison function must be used to compare the entity // tags. Thus if the entity tag of the entity is weak then matching // of entity tags in the If-None-Match header should fail if the // HTTP method is not GET or not HEAD. if (eTag.isWeak()) { return null; } if (matchingTags == MatchingEntityTag.ANY_MATCH || matchingTags.contains(eTag)) { // 412 Precondition Failed return Responses.preconditionFailed(); } } return null; }
if (etagService.isPresent(etag.toString())) { etagCached = true; builder = Response.notModified(); builder.tag(etag);
if (etagService.isPresent(etag.toString())) { etagCached = true; builder = Response.notModified(); builder.tag(etag);
queryLifecycle.emitLogsAndMetrics(null, req.getRemoteAddr(), -1); successfulQueryCount.incrementAndGet(); return Response.notModified().build();
public Response.ResponseBuilder ifModifiedSince(String strDate, Date lastModified) { Date date = DateUtil.parseDate(strDate); if (date.getTime() >= lastModified.getTime()) { return Response.notModified(); } return null; }
private Response.ResponseBuilder evaluateIfModifiedSince(final long lastModified, final String ifModifiedSinceHeader) { try { final long ifModifiedSince = HttpHeaderReader.readDate(ifModifiedSinceHeader).getTime(); if (roundDown(lastModified) <= ifModifiedSince) { // 304 Not modified return Response.notModified(); } } catch (final ParseException ex) { // Ignore the header if parsing error } return null; }
public Response.ResponseBuilder ifNoneMatch(List<EntityTag> ifMatch, EntityTag eTag) { boolean match = false; for (EntityTag tag : ifMatch) { if (tag.equals(eTag) || tag.getValue().equals("*")) { match = true; break; } } if (match) { if ("GET".equals(httpMethod) || "HEAD".equals(httpMethod)) { return Response.notModified(eTag); } return Response.status(SC_PRECONDITION_FAILED).tag(eTag); } return null; }
private Response.ResponseBuilder evaluateIfNoneMatch(final EntityTag eTag, final Set<? extends EntityTag> matchingTags, final boolean isGetOrHead) { if (isGetOrHead) { if (matchingTags == MatchingEntityTag.ANY_MATCH) { // 304 Not modified return Response.notModified(eTag); } // The weak comparison function may be used to compare entity tags if (matchingTags.contains(eTag) || matchingTags.contains(new EntityTag(eTag.getValue(), !eTag.isWeak()))) { // 304 Not modified return Response.notModified(eTag); } } else { // The strong comparison function must be used to compare the entity // tags. Thus if the entity tag of the entity is weak then matching // of entity tags in the If-None-Match header should fail if the // HTTP method is not GET or not HEAD. if (eTag.isWeak()) { return null; } if (matchingTags == MatchingEntityTag.ANY_MATCH || matchingTags.contains(eTag)) { // 412 Precondition Failed return Response.status(Response.Status.PRECONDITION_FAILED); } } return null; }
return Response.notModified().build();
/** * Create a new ResponseBuilder with a not-modified status. * * @param tag a tag for the unmodified entity. * @return a new response builder. * @throws java.lang.IllegalArgumentException * if tag is {@code null}. */ public static ResponseBuilder notModified(EntityTag tag) { return notModified().tag(tag); }