throw new StuffNotFoundException("Schedule with id " + scheduleId);
else
putToCache(scheduleId, MeasurementSchedule.class, schedule);
}
MeasurementDefinition definition = schedule.getDefinition();
// MetricSchedule metricSchedule = getMetricScheduleInternal(uriInfo,schedule,definition); todo
MetricSchedule metricSchedule = new MetricSchedule(schedule.getId(), definition.getName(),
definition.getDisplayName(),
schedule.isEnabled(), schedule.getInterval(), definition.getUnits().toString(),
definition.getDataType().toString());
metricSchedule.setDefinitionId(definition.getId());
if (schedule.getMtime()!=null)
metricSchedule.setMtime(schedule.getMtime());
// Check for conditional get again
// Interestingly computing the hashCode of the original schedule is slower, as it also
// pulls in data from the definition and the resource
long tim = schedule.getMtime() != null ? schedule.getMtime() : 0;
EntityTag eTag = new EntityTag(Long.toOctalString(schedule.hashCode()+tim));
builder = request.evaluatePreconditions(new Date(tim),eTag); // factor in mtime in etag
if (builder==null) {
// preconditions not met, we need to send the resource
UriBuilder uriBuilder;
URI uri;
Link link;
if (definition.getDataType()==DataType.MEASUREMENT) {
// create link to metrics
uriBuilder = uriInfo.getBaseUriBuilder();
uriBuilder.path("metric/data/" + scheduleId);
uri = uriBuilder.build();
link = new Link("metric",uri.toString());