aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-11-16 13:36:27 +0100
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2017-11-16 13:44:54 +0100
commite03482f7967d7f226426ba8d17aab9367e767857 (patch)
treeef04c3fa83786d265dcab0f249400216a9b95734 /src/main/java
parente86e6fd2af438fc9b63651aef607d5e470cc53d1 (diff)
Rework ModelProperties
Rework ModelProperties and add a new exception for BPMN Change-Id: I5fc184c7833d419944cb15f10ca34461a865213f Issue-ID: CLAMP-74 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/exception/ModelBpmnException.java62
-rw-r--r--src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java46
2 files changed, 82 insertions, 26 deletions
diff --git a/src/main/java/org/onap/clamp/clds/exception/ModelBpmnException.java b/src/main/java/org/onap/clamp/clds/exception/ModelBpmnException.java
new file mode 100644
index 000000000..e4217578a
--- /dev/null
+++ b/src/main/java/org/onap/clamp/clds/exception/ModelBpmnException.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.clamp.clds.exception;
+
+/**
+ * The exception used in case of issues when decoding the ModelBpmn JSON
+ * generated by the Designer UI (Converted from XML to JSON by XSLT in the
+ * code).
+ *
+ *
+ */
+public class ModelBpmnException extends RuntimeException {
+ /**
+ * Generated ID.
+ */
+ private static final long serialVersionUID = 8452294782552680244L;
+
+ /**
+ * This constructor can be used to create a new ModelBpmnException.
+ *
+ * @param message
+ * A string message detailing the problem
+ * @param e
+ * The exception sent by the code
+ */
+ public ModelBpmnException(String message, Throwable e) {
+ super(message, e);
+ }
+
+ /**
+ * This constructor can be used to create a new ModelBpmnException. Use this
+ * constructor only if you are creating a new exception stack, not if an
+ * exception was already raised by another code.
+ *
+ * @param message
+ * A string message detailing the problem
+ */
+ public ModelBpmnException(String message) {
+ super(message);
+ }
+}
diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java
index 7111f1dd5..fae5e584c 100644
--- a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java
+++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java
@@ -38,6 +38,7 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.clamp.clds.exception.ModelBpmnException;
import org.onap.clamp.clds.model.CldsEvent;
import org.onap.clamp.clds.model.CldsModel;
import org.onap.clamp.clds.service.CldsService;
@@ -50,26 +51,19 @@ public class ModelProperties {
.getLogger(CldsService.class);
protected static final EELFLogger auditLogger = EELFManager.getInstance()
.getAuditLogger();
-
private ModelBpmn modelBpmn;
private JsonNode modelJson;
-
private final String modelName;
private final String controlName;
private final String actionCd;
// Flag indicate whether it is triggered by Validation Test button from UI
- private final boolean isTest;
-
+ private final boolean testOnly;
private Global global;
-
private final Map<String, AbstractModelElement> modelElements = new ConcurrentHashMap<>();
-
private String currentModelElementId;
private String policyUniqueId;
-
private static final Object lock = new Object();
private static Map<Class<? extends AbstractModelElement>, String> modelElementClasses = new ConcurrentHashMap<>();
-
static {
synchronized (lock) {
modelElementClasses.put(Policy.class, Policy.getType());
@@ -88,26 +82,27 @@ public class ModelProperties {
* The closed loop name coming from the UI
* @param actionCd
* Type of operation PUT,UPDATE,DELETE
- * @param isTest
+ * @param isATest
* The test flag coming from the UI (for validation only, no
* query are physically executed)
* @param modelBpmnText
* The BPMN flow in JSON from the UI
* @param modelPropText
* The BPMN parameters for all boxes defined in modelBpmnTest
- * @throws IOException
- * In case there is an issue with the JSON decoding
*/
- public ModelProperties(String modelName, String controlName, String actionCd, boolean isTest, String modelBpmnText,
- String modelPropText) throws IOException {
- this.modelName = modelName;
- this.controlName = controlName;
- this.actionCd = actionCd;
- this.isTest = isTest;
- modelBpmn = ModelBpmn.create(modelBpmnText);
- modelJson = new ObjectMapper().readTree(modelPropText);
-
- instantiateMissingModelElements();
+ public ModelProperties(String modelName, String controlName, String actionCd, boolean isATest, String modelBpmnText,
+ String modelPropText) {
+ try {
+ this.modelName = modelName;
+ this.controlName = controlName;
+ this.actionCd = actionCd;
+ this.testOnly = isATest;
+ modelBpmn = ModelBpmn.create(modelBpmnText);
+ modelJson = new ObjectMapper().readTree(modelPropText);
+ instantiateMissingModelElements();
+ } catch (IOException e) {
+ throw new ModelBpmnException("Exception occurred when trying to decode the BPMN Properties JSON", e);
+ }
}
/**
@@ -172,14 +167,13 @@ public class ModelProperties {
* @throws JsonProcessingException
* @throws IOException
*/
- public static ModelProperties create(DelegateExecution execution) throws IOException {
+ public static ModelProperties create(DelegateExecution execution) {
String modelProp = new String((byte[]) execution.getVariable("modelProp"));
String modelBpmnProp = (String) execution.getVariable("modelBpmnProp");
String modelName = (String) execution.getVariable("modelName");
String controlName = (String) execution.getVariable("controlName");
String actionCd = (String) execution.getVariable("actionCd");
boolean isTest = (boolean) execution.getVariable("isTest");
-
return new ModelProperties(modelName, controlName, actionCd, isTest, modelBpmnProp, modelProp);
}
@@ -308,10 +302,10 @@ public class ModelProperties {
}
/**
- * @return the isTest
+ * @return the testOnly
*/
- public boolean isTest() {
- return isTest;
+ public boolean isTestOnly() {
+ return testOnly;
}
/**