aboutsummaryrefslogtreecommitdiffstats
path: root/model/basic-model/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'model/basic-model/src/main/java')
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java6
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java13
-rw-r--r--model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java25
3 files changed, 25 insertions, 19 deletions
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java
index ce2c9fc56..e76d00e12 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelReader.java
@@ -211,13 +211,13 @@ public class ApexModelReader<C extends AxConcept> {
if (validateFlag) {
// Validate the configuration file
final AxValidationResult validationResult = apexConcept.validate(new AxValidationResult());
- LOGGER.debug(validationResult.toString());
if (validationResult.isValid()) {
return apexConcept;
}
else {
- LOGGER.error("Apex concept validation failed" + validationResult.toString());
- throw new ApexModelException("Apex concept validation failed" + validationResult.toString());
+ String message = "Apex concept validation failed" + validationResult.toString();
+ LOGGER.error(message);
+ throw new ApexModelException(message);
}
}
else {
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java
index 977a8e7c6..6cc542270 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/handling/ApexModelWriter.java
@@ -86,7 +86,8 @@ public class ApexModelWriter<C extends AxConcept> {
System.setProperty("javax.xml.bind.context.factory", "org.eclipse.persistence.jaxb.JAXBContextFactory");
try {
- final JAXBContext jaxbContext = JAXBContextFactory.createContext(new Class[] {rootConceptClass}, null);
+ final JAXBContext jaxbContext = JAXBContextFactory.createContext(new Class[]
+ { rootConceptClass }, null);
// Set up the unmarshaller to carry out validation
marshaller = jaxbContext.createMarshaller();
@@ -173,10 +174,11 @@ public class ApexModelWriter<C extends AxConcept> {
if (validateFlag) {
// Validate the concept first
final AxValidationResult validationResult = concept.validate(new AxValidationResult());
- LOGGER.debug(validationResult.toString());
if (!validationResult.isValid()) {
- LOGGER.warn(validationResult.toString());
- throw new ApexModelException("Apex concept xml (" + concept.getKey().getId() + ") validation failed");
+ String message = "Apex concept xml (" + concept.getKey().getId() + ") validation failed: "
+ + validationResult.toString();
+ LOGGER.warn(message);
+ throw new ApexModelException(message);
}
}
@@ -212,7 +214,7 @@ public class ApexModelWriter<C extends AxConcept> {
// Convert the cDataFieldSet into a space delimited string
domTransformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS,
- cdataFieldSet.toString().replaceAll("[\\[\\]\\,]", " "));
+ cdataFieldSet.toString().replaceAll("[\\[\\]\\,]", " "));
domTransformer.transform(new DOMSource(document), new StreamResult(apexConceptWriter));
} catch (JAXBException | TransformerException | ParserConfigurationException e) {
LOGGER.warn("Unable to marshal Apex concept XML", e);
@@ -221,7 +223,6 @@ public class ApexModelWriter<C extends AxConcept> {
LOGGER.debug("wrote Apex concept XML");
}
-
private Transformer getTransformer() throws TransformerConfigurationException {
// Transform the DOM to the output stream
final TransformerFactory transformerFactory = TransformerFactory.newInstance();
diff --git a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
index 81b3373e1..24c682de4 100644
--- a/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
+++ b/model/basic-model/src/main/java/org/onap/policy/apex/model/basicmodel/test/TestApexModel.java
@@ -225,8 +225,9 @@ public class TestApexModel<M extends AxModel> {
final AxValidationResult result = model.validate(new AxValidationResult());
if (!result.isValid()) {
- LOGGER.warn(MODEL_IS_INVALID + result.toString());
- throw new ApexException(MODEL_IS_INVALID + result.toString());
+ String message = MODEL_IS_INVALID + result.toString();
+ LOGGER.warn(message);
+ throw new ApexException(message);
}
LOGGER.debug("ran testApexModelVaid");
@@ -246,8 +247,9 @@ public class TestApexModel<M extends AxModel> {
final AxValidationResult result = model.validate(new AxValidationResult());
if (result.isValid()) {
- LOGGER.warn("model should not be valid " + result.toString());
- throw new ApexException("should not be valid " + result.toString());
+ String message = "model should not be valid " + result.toString();
+ LOGGER.warn(message);
+ throw new ApexException(message);
}
LOGGER.debug("ran testApexModelVaidateMalstructured");
@@ -267,8 +269,9 @@ public class TestApexModel<M extends AxModel> {
final AxValidationResult result = model.validate(new AxValidationResult());
if (!result.isValid()) {
- LOGGER.warn(MODEL_IS_INVALID + result.toString());
- throw new ApexException(MODEL_IS_INVALID + result.toString());
+ String message = MODEL_IS_INVALID + result.toString();
+ LOGGER.warn(message);
+ throw new ApexException(message);
}
if (!result.getValidationResult().equals(AxValidationResult.ValidationResult.OBSERVATION)) {
@@ -293,8 +296,9 @@ public class TestApexModel<M extends AxModel> {
final AxValidationResult result = model.validate(new AxValidationResult());
if (!result.isValid()) {
- LOGGER.warn(MODEL_IS_INVALID + result.toString());
- throw new ApexException(MODEL_IS_INVALID + result.toString());
+ String message = MODEL_IS_INVALID + result.toString();
+ LOGGER.warn(message);
+ throw new ApexException(message);
}
if (!result.getValidationResult().equals(AxValidationResult.ValidationResult.WARNING)) {
@@ -319,8 +323,9 @@ public class TestApexModel<M extends AxModel> {
final AxValidationResult result = model.validate(new AxValidationResult());
if (result.isValid()) {
- LOGGER.warn("model should not be valid " + result.toString());
- throw new ApexException("should not be valid " + result.toString());
+ String message = "model should not be valid " + result.toString();
+ LOGGER.warn(message);
+ throw new ApexException(message);
}
LOGGER.debug("ran testApexModelVaidateInvalidModel");