- if (metadata != null) {
- for (Entry<String, String> metadataEntry : metadata.entrySet()) {
- metadataEntry.setValue(metadataEntry.getValue().trim());
- }
- }
- }
-
- @Override
- public PfValidationResult validate(final PfValidationResult resultIn) {
- PfValidationResult result = resultIn;
-
- if (key.isNullKey()) {
- result.addValidationMessage(
- new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID, "key is a null key"));
- }
-
- result = key.validate(result);
-
- if (type == null || type.isNullKey()) {
- result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "property type may not be null"));
- }
-
- return validateFields(result);
- }
-
- /**
- * Validate the property fields.
- *
- * @param resultIn the incoming validation results so far
- * @return the validation results including this validation
- */
- private PfValidationResult validateFields(final PfValidationResult resultIn) {
- PfValidationResult result = resultIn;
-
- if (description != null && description.trim().length() == 0) {
- result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "property description may not be blank"));
- }
-
- if (defaultValue != null && defaultValue.trim().length() == 0) {
- result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "property default value may not be null"));
- }
-
- if (constraints != null) {
- for (JpaToscaConstraint constraint : constraints) {
- if (constraint == null) {
- result.addValidationMessage(new PfValidationMessage(key, this.getClass(), ValidationResult.INVALID,
- "property constraint may not be null "));
- }
- }
- }
- return (entrySchema != null ? entrySchema.validate(result) : result);