private static final String WAS_DEFINED_FOR_THE_NODE_TYPE = " was defined for the node type ";
private static final String UNKNOWN = "Unknown ";
private static final String TYPE = " type ";
+ public static final String IMPORTED_FROM = "',imported from ";
private Target target = null; //what we're validating at the moment
return false;
}
- for (Iterator<Map.Entry<String, Map>> ai = augs.entrySet().iterator(); ai.hasNext(); ) {
- Map.Entry<String, Map> ae = ai.next();
-
+ for (Map.Entry<String, Map> ae : augs.entrySet()) {
//make sure it was declared by the type
Map facetDef = catalog.getFacetDefinition(theConstruct, theSpecType, theFacet, ae.getKey());
if (facetDef == null) {
private String patchWhitespaces(String thePath) {
String[] elems = thePath.split("/");
- StringBuffer path = new StringBuffer();
+ StringBuilder path = new StringBuilder();
for (int i = 0; i < elems.length; i++) {
if (spacePattern.matcher(elems[i]).find()) {
path.append("[@name='")
hookHandler = Invokable.from(m);
} catch (NoSuchMethodException nsmx) {
//that's ok, not every rule has to have a handler
- debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), getClass().getName(), "That's ok, not every rule has to have a handler. Method name =", theHookName);
+ debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), getClass().getName(), "That's ok, not every rule has to have a handler. Method name is:{}. Exception:{}", theHookName,nsmx);
}
if (hookHandler != null) {
debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), getClass().getName(), "entering range_definition {}",
theContext.getPath());
- assert theRule.getType().equals("seq");
+ assert "seq".equals(theRule.getType());
List bounds = (List) theValue;
if (bounds.size() != 2) {
* early processing (validation time) of the imports allows us to catalog
* their types before those declared in the main document.
*/
- protected void imports_post_validation_handler(Object theValue, Rule theRule,
- Validator.ValidationContext theContext) {
+ protected void imports_post_validation_handler(Object theValue, Rule theRule, Validator.ValidationContext theContext) {
debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "entering imports {}", theContext.getPath());
- assert theRule.getType().equals("seq");
+
+ assert "seq".equals(theRule.getType());
Target tgt = ((TOSCAValidator) theContext.getValidator()).getTarget();
try {
List<Target> tgtis = parseTarget(tgti);
- if (tgtis.isEmpty())
- continue;
+ if (tgtis.isEmpty()) {
+ continue;
+ }
if (tgtis.size() > 1) {
theContext.addError(
tgti = tgtis.get(0);
- // tgti = parseTarget(tgti);
if (tgt.getReport().hasErrors()) {
- theContext.addError("Failure parsing import '" + tgti + "',imported from " + tgt, theRule, null,
+ theContext.addError("Failure parsing import '" + tgti + IMPORTED_FROM + tgt, theRule, null,
null);
continue;
}
validateTarget(tgti);
if (tgt.getReport().hasErrors()) {
- theContext.addError("Failure validating import '" + tgti + "',imported from " + tgt, theRule,
+ theContext.addError("Failure validating import '" + tgti + IMPORTED_FROM + tgt, theRule,
null, null);
continue;
}
} catch (CheckerException cx) {
- theContext.addError("Failure validating import '" + tgti + "',imported from " + tgt, theRule, cx,
+ theContext.addError("Failure validating import '" + tgti + IMPORTED_FROM + tgt, theRule, cx,
null);
}
}
Validator.ValidationContext theContext) {
debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "entering node_templates_post_validation_handler {}",
theContext.getPath());
- assert theRule.getType().equals("map");
+ assert "map".equals(theRule.getType());
Map<String, Map> nodeTemplates = (Map<String, Map>) theValue;
for (Iterator<Map.Entry<String, Map>> i = nodeTemplates.entrySet().iterator(); i.hasNext();) {
Map.Entry<String, Map> node = i.next();
private void process(String theProcessorSpec) throws CheckerException {
String[] spec = theProcessorSpec.split(" ");
- if (spec.length == 0)
- throw new IllegalArgumentException("Incomplete processor specification");
+ if (spec.length == 0) {
+ throw new IllegalArgumentException("Incomplete processor specification");
+ }
- Class processorClass = null;
+ Class processorClass;
try {
processorClass = Class.forName(spec[0]);
} catch (ClassNotFoundException cnfx) {
throw new CheckerException("Cannot find processor implementation", cnfx);
}
- Processor proc = null;
+ Processor proc;
try {
proc = (Processor) ConstructorUtils.invokeConstructor(processorClass,
Arrays.copyOfRange(spec, 1, spec.length));
return;
}
// check artifact type
- if (!checkType(Construct.Artifact, theDef, theContext))
- return;
+ if (!checkType(Construct.Artifact, theDef, theContext)) {
+ return;
+ }
} finally {
theContext.exit();
}
return;
}
- if (theDefinition.containsKey("properties")) {
- check_properties((Map<String, Map>) theDefinition.get("properties"), theContext);
+ if (theDefinition.containsKey(PROPERTIES)) {
+ check_properties((Map<String, Map>) theDefinition.get(PROPERTIES), theContext);
checkTypeConstructFacet(Construct.Policy, theName, theDefinition, Facet.properties, theContext);
}
return;
}
- if (theDefinition.containsKey("properties")) {
- check_properties((Map<String, Map>) theDefinition.get("properties"), theContext);
+ if (theDefinition.containsKey(PROPERTIES)) {
+ check_properties((Map<String, Map>) theDefinition.get(PROPERTIES), theContext);
checkTypeConstructFacet(Construct.Group, theName, theDefinition, Facet.properties, theContext);
}
return;
}
- if (theDefinition.containsKey("properties")) {
- check_properties((Map<String, Map>) theDefinition.get("properties"), theContext);
+ if (theDefinition.containsKey(PROPERTIES)) {
+ check_properties((Map<String, Map>) theDefinition.get(PROPERTIES), theContext);
checkTypeConstructFacet(Construct.Node, theName, theDefinition, Facet.properties, theContext);
}
}
// capabilities
- if (theDefinition.containsKey("capabilities")) {
- check_capabilities((Map<String, Map>) theDefinition.get("capabilities"), theContext);
+ if (theDefinition.containsKey(CAPABILITIES)) {
+ check_capabilities((Map<String, Map>) theDefinition.get(CAPABILITIES), theContext);
}
// interfaces:
return;
}
- if (theDefinition.containsKey("properties")) {
- check_properties((Map<String, Map>) theDefinition.get("properties"), theContext);
+ if (theDefinition.containsKey(PROPERTIES)) {
+ check_properties((Map<String, Map>) theDefinition.get(PROPERTIES), theContext);
checkTypeConstructFacet(Construct.Relationship, theName, theDefinition, Facet.properties, theContext);
}
theContext.exit();
}
- if (theDefinition.containsKey("valid_target_types")) {
+ if (theDefinition.containsKey(VALID_TARGET_TYPES)) {
checkTypeReference(Construct.Capability, theContext,
- ((List<String>) theDefinition.get("valid_target_types")).toArray(EMPTY_STRING_ARRAY));
+ ((List<String>) theDefinition.get(VALID_TARGET_TYPES)).toArray(EMPTY_STRING_ARRAY));
}
} finally {
theContext.exit();
return;
}
- if (theDefinition.containsKey("properties")) {
- check_properties((Map<String, Map>) theDefinition.get("properties"), theContext);
+ if (theDefinition.containsKey(PROPERTIES)) {
+ check_properties((Map<String, Map>) theDefinition.get(PROPERTIES), theContext);
checkTypeConstructFacet(Construct.Capability, theName, theDefinition, Facet.properties, theContext);
}
return;
}
- if (theDefinition.containsKey("properties")) {
- check_properties((Map<String, Map>) theDefinition.get("properties"), theContext);
+ if (theDefinition.containsKey(PROPERTIES)) {
+ check_properties((Map<String, Map>) theDefinition.get(PROPERTIES), theContext);
checkTypeConstructFacet(Construct.Data, theName, theDefinition, Facet.properties, theContext);
}
} finally {
public void check_attributes(Map<String, Map> theDefinitions, CheckContext theContext) {
theContext.enter("attributes");
try {
- if (!checkDefinition("attributes", theDefinitions, theContext))
- return;
+ if (!checkDefinition("attributes", theDefinitions, theContext)) {
+ return;
+ }
for (Iterator<Map.Entry<String, Map>> i = theDefinitions.entrySet().iterator(); i.hasNext();) {
Map.Entry<String, Map> e = i.next();
}
public void check_properties(Map<String, Map> theDefinitions, CheckContext theContext) {
- theContext.enter("properties");
+ theContext.enter(PROPERTIES);
try {
- if (!checkDefinition("properties", theDefinitions, theContext))
- return;
+ if (!checkDefinition(PROPERTIES, theDefinitions, theContext)) {
+ return;
+ }
for (Iterator<Map.Entry<String, Map>> i = theDefinitions.entrySet().iterator(); i.hasNext();) {
Map.Entry<String, Map> e = i.next();