protected void checkConstraint ( final Optional < Graph > graph , final IRI type , final RDFSyntax syntax ) { graph . ifPresent ( g -> { final List < ConstraintViolation > violations = constraintServices . stream ( ) . parallel ( ) . flatMap ( svc -> svc . constrainedBy ( type , g ) ) . collect ( toList ( ) ) ; if ( ! violations . isEmpty ( ) ) { final ResponseBuilder err = status ( CONFLICT ) ; violations . forEach ( v -> err . link ( v . getConstraint ( ) . getIRIString ( ) , LDP . constrainedBy . getIRIString ( ) ) ) ; final StreamingOutput stream = new StreamingOutput ( ) { @ Override public void write ( final OutputStream out ) throws IOException { getServices ( ) . getIOService ( ) . write ( violations . stream ( ) . flatMap ( v2 -> v2 . getTriples ( ) . stream ( ) ) , out , syntax ) ; } } ; throw new ClientErrorException ( err . entity ( stream ) . build ( ) ) ; } } ) ; }
Check the constraints of a graph .