agave-metadata/metadata-core/src/main/java/org/iplantc/service/metadata/search/MetadataValidation.java
/**
     * Validate that fields in node conform to MetadataItem field constraints
     *
     * @param node {@link JsonNode} to validate
     * @return validated {@link MetadataItem}
     * @throws MetadataValidationException if fields do not confirm to MetadataItem constraints
     */
Validate that fields in node conform to MetadataItem field constraints
@param node  JsonNode to validate
@return validated  MetadataItem
@throws MetadataValidationException if fields do not confirm to MetadataItem constraints
Validate that fields in node conform to MetadataItem field constraints @param node JsonNode to validate @return validated MetadataItem @throws MetadataValidationException if fields do not confirm to MetadataItem constraints
public MetadataItem validateMetadataNodeFields(JsonNode node, String username) throws MetadataValidationException {
        MetadataItem item;
        JsonHandler handler = new JsonHandler();
        try {
            item = handler.parseJsonMetadata(node);
            item.setOwner(username);
            item.setInternalUsername(username);
            Validator validator;
            ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
            validator = validatorFactory.getValidator();
            Set<ConstraintViolation<MetadataItem>> constraintViolations = validator.validate(item);
            if (constraintViolations.size() != 0) {
                String violationMessages = constraintViolations.stream().map(cv -> {
                    return cv.getMessage();
                }).collect(Collectors.joining(","));
                throw new MetadataValidationException(violationMessages);
            }
            return item;
        }
        catch (MetadataValidationException e) {
            throw e;
        }
        catch (Exception e) {
            throw new MetadataValidationException(e);
        }
    }
public MetadataItem validateMetadataNodeFields ( JsonNode node , String username ) throws MetadataValidationException { MetadataItem item ; JsonHandler handler = new JsonHandler ( ) ; try { item = handler . parseJsonMetadata ( node ) ; item . setOwner ( username ) ; item . setInternalUsername ( username ) ; Validator validator ; ValidatorFactory validatorFactory = Validation . buildDefaultValidatorFactory ( ) ; validator = validatorFactory . getValidator ( ) ; Set < ConstraintViolation < MetadataItem > > constraintViolations = validator . validate ( item ) ; if ( constraintViolations . size ( ) != 0 ) { String violationMessages = constraintViolations . stream ( ) . map ( cv -> { return cv . getMessage ( ) ; } ) . collect ( Collectors . joining ( "," ) ) ; throw new MetadataValidationException ( violationMessages ) ; } return item ; } catch ( MetadataValidationException e ) { throw e ; } catch ( Exception e ) { throw new MetadataValidationException ( e ) ; } }
Validate that fields in node conform to MetadataItem field constraints
 @param node {@link JsonNode} to validate
 @return validated {@link MetadataItem}
 @throws MetadataValidationException if fields do not confirm to MetadataItem constraints
Validate that fields in node conform to MetadataItem field constraints @param node { @link JsonNode } to validate @return validated { @link MetadataItem } @throws MetadataValidationException if fields do not confirm to MetadataItem constraints
//validator