private synchronized ConstraintReportId nextConstraintReportId() { String failureId=null; do { failureId=UUID.randomUUID().toString(); } while(this.reports.containsKey(failureId)); ConstraintReportId reportId=ConstraintReportId.create(this.id, failureId); this.reports.put(failureId, reportId); return reportId; }
private synchronized ConstraintReportId nextConstraintReportId() { String failureId=null; do { failureId=UUID.randomUUID().toString(); } while(this.failures.contains(failureId)); ConstraintReportId reportId=ConstraintReportId.create(this.id, failureId); this.failures.add(failureId); return reportId; }
/** * {@inheritDoc} */ @Override public Set<ConstraintReportId> constraintReports() { Set<String> currentFailures=null; synchronized(this) { currentFailures=ImmutableSet.copyOf(this.failures); } Builder<ConstraintReportId> builder=ImmutableSet.builder(); for(String failure:currentFailures) { builder.add(ConstraintReportId.create(this.id,failure)); } return builder.build(); }
/** * {@inheritDoc} */ @Override public void removeByResource(Resource resource) { checkNotNull(resource,"Resource cannot be null"); this.lock.writeLock().lock(); try { ResourceId resourceId = resource.id(); for(String constraintsId:this.failureIds.get(resourceId)) { this.reports.remove(ConstraintReportId.create(resourceId, constraintsId)); } this.failureIds.removeAll(resourceId); } finally { this.lock.writeLock().unlock(); } }
private ConstraintReportId constraintReportId(String name, String failureId) { return ConstraintReportId.create(resourceId(name), failureId); }
DataSet getConstraintReport(Endpoint endpoint, String constraintsId) throws ApplicationExecutionException { ResourceId resourceId=endpoint.resourceId(); // TODO: Check if it is really necessary Resource resource = loadResource(resourceId); if(resource==null) { String errorMessage = applicationFailureMessage(COULD_NOT_FIND_RESOURCE_FOR_ENDPOINT,endpoint); LOGGER.error(errorMessage); throw new ApplicationExecutionException(errorMessage); } ConstraintReport report= this.constraintReportRepository. constraintReportOfId( ConstraintReportId. create(resource.id(),constraintsId)); if(report==null) { return null; } return ConstraintReportTransformer. create(resource, report). transform(endpoint); }
ResourceId resourceId = ResourceId.createId(name("resource"),"template"); Date date = new Date(); final ConstraintReport ep1 = new JPAConstraintReport(ConstraintReportId.create(resourceId, "failure1"), new Date(date.getTime()-3600000),httpRequest(),constraints()); final ConstraintReport ep2 = new JPAConstraintReport(ConstraintReportId.create(resourceId, "failure2"), date,httpRequest(),null); withinTransaction( new Task<ConstraintReportRepository>("Creating reports") {