diff options
author | Determe, Sebastien (sd378r) <sd378r@intl.att.com> | 2017-08-08 03:08:14 -0700 |
---|---|---|
committer | Sébastien Determe <sd378r@intl.att.com> | 2017-08-08 12:35:34 +0000 |
commit | 5ff37e6b05bfd235ba782462e83355c5289018a1 (patch) | |
tree | e81d4ea6cce037b04300a2c741b0f7cbc297b06a /src | |
parent | 8727db8683fcd11fa3695b2cb4e9a7834a3280e1 (diff) |
Rework the Clds DAO and properties associated
Rework the Clds DAO and Prop classes collector, modelBPMN, policy,
service Config
Change-Id: If64573d9d513b54f286f46db26ef57fcc7830617
Issue-Id: CLAMP-1
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src')
16 files changed, 968 insertions, 593 deletions
diff --git a/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java index 5c5ba5742..5b48e8d88 100644 --- a/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/CsiLoggingConfiguration.java @@ -23,11 +23,12 @@ package org.onap.clamp.clds.config; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + import com.att.ajsc.csilogging.common.AsyncSupport; import com.att.ajsc.csilogging.interceptors.CsiLoggingCamelPostInterceptor; import com.att.ajsc.csilogging.interceptors.CsiLoggingCamelPreInterceptor; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; @Configuration public class CsiLoggingConfiguration { diff --git a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java index 67e4d1b84..d54976b84 100644 --- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java +++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java @@ -5,16 +5,16 @@ * 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. + * 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 + * + * 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============================================ * =================================================================== @@ -23,18 +23,6 @@ package org.onap.clamp.clds.dao; -import org.onap.clamp.clds.model.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.dao.EmptyResultDataAccessException; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.RowMapper; -import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; -import org.springframework.jdbc.core.namedparam.SqlParameterSource; -import org.springframework.jdbc.core.simple.SimpleJdbcCall; -import org.springframework.stereotype.Repository; - -import javax.sql.DataSource; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; @@ -46,25 +34,48 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.sql.DataSource; + +import org.onap.clamp.clds.model.CldsDBServiceCache; +import org.onap.clamp.clds.model.CldsEvent; +import org.onap.clamp.clds.model.CldsModel; +import org.onap.clamp.clds.model.CldsModelInstance; +import org.onap.clamp.clds.model.CldsServiceData; +import org.onap.clamp.clds.model.CldsTemplate; +import org.onap.clamp.clds.model.ValueItem; +import org.springframework.dao.EmptyResultDataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowMapper; +import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; +import org.springframework.jdbc.core.namedparam.SqlParameterSource; +import org.springframework.jdbc.core.simple.SimpleJdbcCall; +import org.springframework.stereotype.Repository; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + /** * Data Access for CLDS Model tables. */ @Repository("cldsDao") public class CldsDao { - private static final Logger logger = LoggerFactory.getLogger(CldsDao.class); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); - private JdbcTemplate jdbcTemplateObject; - private SimpleJdbcCall procGetModel; - private SimpleJdbcCall procGetModelTemplate; - private SimpleJdbcCall procSetModel; - private SimpleJdbcCall procInsEvent; - private SimpleJdbcCall procUpdEvent; - private SimpleJdbcCall procSetTemplate; - private SimpleJdbcCall procGetTemplate; - private SimpleJdbcCall procDelAllModelInstances; - private SimpleJdbcCall procInsModelInstance; - private SimpleJdbcCall procDelModelInstance; + private JdbcTemplate jdbcTemplateObject; + private SimpleJdbcCall procGetModel; + private SimpleJdbcCall procGetModelTemplate; + private SimpleJdbcCall procSetModel; + private SimpleJdbcCall procInsEvent; + private SimpleJdbcCall procUpdEvent; + private SimpleJdbcCall procSetTemplate; + private SimpleJdbcCall procGetTemplate; + private SimpleJdbcCall procDelAllModelInstances; + private SimpleJdbcCall procInsModelInstance; + private SimpleJdbcCall procDelModelInstance; + + private static final String healthcheck = "Select 1"; /** * Log message when instantiating @@ -121,8 +132,7 @@ public class CldsDao { private CldsModel getModel(String modelName, String controlNameUuid) { CldsModel model = new CldsModel(); model.setName(modelName); - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_model_name", modelName) + SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName) .addValue("v_control_name_uuid", controlNameUuid); Map<String, Object> out = logSqlExecution(procGetModel, in); model.setControlNamePrefix((String) out.get("v_control_name_prefix")); @@ -131,28 +141,31 @@ public class CldsDao { model.setTemplateId((String) (out.get("v_template_id"))); model.setTemplateName((String) (out.get("v_template_name"))); model.setBpmnId((String) (out.get("v_template_bpmn_id"))); - model.setBpmnUserid((String) out.get("v_template_bpmn_userid")); + model.setBpmnUserid((String) out.get("v_template_bpmn_user_id")); model.setBpmnText((String) out.get("v_template_bpmn_text")); model.setPropId((String) (out.get("v_model_prop_id"))); - model.setPropUserid((String) out.get("v_model_prop_userid")); + model.setPropUserid((String) out.get("v_model_prop_user_id")); model.setPropText((String) out.get("v_model_prop_text")); model.setImageId((String) (out.get("v_template_image_id"))); - model.setImageUserid((String) out.get("v_template_image_userid")); + model.setImageUserid((String) out.get("v_template_image_user_id")); model.setImageText((String) out.get("v_template_image_text")); model.setDocId((String) (out.get("v_template_doc_id"))); - model.setDocUserid((String) out.get("v_template_doc_userid")); + model.setDocUserid((String) out.get("v_template_doc_user_id")); model.setDocText((String) out.get("v_template_doc_text")); model.setBlueprintText((String) out.get("v_model_blueprint_text")); model.getEvent().setId((String) (out.get("v_event_id"))); model.getEvent().setActionCd((String) out.get("v_action_cd")); model.getEvent().setActionStateCd((String) out.get("v_action_state_cd")); model.getEvent().setProcessInstanceId((String) out.get("v_event_process_instance_id")); - model.getEvent().setUserid((String) out.get("v_event_userid")); + model.getEvent().setUserid((String) out.get("v_event_user_id")); + model.setTypeId((String) out.get("v_service_type_id")); + model.setDeploymentId((String) out.get("v_deployment_id")); return model; } /** - * Get a model and template information from the database given the model name. + * Get a model and template information from the database given the model + * name. * * @param modelName * @return model @@ -169,23 +182,25 @@ public class CldsDao { model.setTemplateId((String) (out.get("v_template_id"))); model.setTemplateName((String) (out.get("v_template_name"))); model.setBpmnId((String) (out.get("v_template_bpmn_id"))); - model.setBpmnUserid((String) out.get("v_template_bpmn_userid")); + model.setBpmnUserid((String) out.get("v_template_bpmn_user_id")); model.setBpmnText((String) out.get("v_template_bpmn_text")); model.setPropId((String) (out.get("v_model_prop_id"))); - model.setPropUserid((String) out.get("v_model_prop_userid")); + model.setPropUserid((String) out.get("v_model_prop_user_id")); model.setPropText((String) out.get("v_model_prop_text")); model.setImageId((String) (out.get("v_template_image_id"))); - model.setImageUserid((String) out.get("v_template_image_userid")); + model.setImageUserid((String) out.get("v_template_image_user_id")); model.setImageText((String) out.get("v_template_image_text")); model.setDocId((String) (out.get("v_template_doc_id"))); - model.setDocUserid((String) out.get("v_template_doc_userid")); + model.setDocUserid((String) out.get("v_template_doc_user_id")); model.setDocText((String) out.get("v_template_doc_text")); model.setBlueprintText((String) out.get("v_model_blueprint_text")); model.getEvent().setId((String) (out.get("v_event_id"))); model.getEvent().setActionCd((String) out.get("v_action_cd")); model.getEvent().setActionStateCd((String) out.get("v_action_state_cd")); model.getEvent().setProcessInstanceId((String) out.get("v_event_process_instance_id")); - model.getEvent().setUserid((String) out.get("v_event_userid")); + model.getEvent().setUserid((String) out.get("v_event_user_id")); + model.setTypeId((String) out.get("v_service_type_id")); + model.setDeploymentId((String) out.get("v_deployment_id")); Map<String, Object> modelResults = logSqlExecution(procGetModel, in); Object modelResultObject = modelResults.get("#result-set-1"); @@ -207,19 +222,19 @@ public class CldsDao { } /** - * Update model in the database using parameter values and return updated model object. + * Update model in the database using parameter values and return updated + * model object. * * @param model * @param userid * @return */ public CldsModel setModel(CldsModel model, String userid) { - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_model_name", model.getName()) - .addValue("v_template_id", model.getTemplateId()) - .addValue("v_userid", userid) + SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", model.getName()) + .addValue("v_template_id", model.getTemplateId()).addValue("v_user_id", userid) .addValue("v_model_prop_text", model.getPropText()) .addValue("v_model_blueprint_text", model.getBlueprintText()) + .addValue("v_service_type_id", model.getTypeId()).addValue("v_deployment_id", model.getDeploymentId()) .addValue("v_control_name_prefix", model.getControlNamePrefix()) .addValue("v_control_name_uuid", model.getControlNameUuid()); Map<String, Object> out = logSqlExecution(procSetModel, in); @@ -227,19 +242,20 @@ public class CldsDao { model.setControlNameUuid((String) out.get("v_control_name_uuid")); model.setId((String) (out.get("v_model_id"))); model.setPropId((String) (out.get("v_model_prop_id"))); - model.setPropUserid((String) (out.get("v_model_prop_userid"))); + model.setPropUserid((String) (out.get("v_model_prop_user_id"))); model.setBlueprintId((String) (out.get("v_model_blueprint_id"))); - model.setBlueprintUserid((String) out.get("v_model_blueprint_userid")); + model.setBlueprintUserid((String) out.get("v_model_blueprint_user_id")); model.getEvent().setId((String) (out.get("v_event_id"))); model.getEvent().setActionCd((String) out.get("v_action_cd")); model.getEvent().setActionStateCd((String) out.get("v_action_state_cd")); model.getEvent().setProcessInstanceId((String) out.get("v_event_process_instance_id")); - model.getEvent().setUserid((String) out.get("v_event_userid")); + model.getEvent().setUserid((String) out.get("v_event_user_id")); return model; } /** - * Inserts new modelInstance in the database using parameter values and return updated model object. + * Inserts new modelInstance in the database using parameter values and + * return updated model object. * * @param model * @param modelInstancesList @@ -273,10 +289,12 @@ public class CldsDao { } /** - * Delete a list of modelInstance from the database using parameter values and returns updated model object. - * This method is defunct - DCAE Proxy will not undeploy individual instances. It will send an empty list of - * deployed instances to indicate all have been removed. Or it will send an updated list to indicate those that - * are still deployed with any not on the list considered undeployed. + * Delete a list of modelInstance from the database using parameter values + * and returns updated model object. This method is defunct - DCAE Proxy + * will not undeploy individual instances. It will send an empty list of + * deployed instances to indicate all have been removed. Or it will send an + * updated list to indicate those that are still deployed with any not on + * the list considered undeployed. * * @param controlNameUUid * @param modelInstancesList @@ -285,8 +303,7 @@ public class CldsDao { private CldsModel delModelInstance(String controlNameUUid, List<CldsModelInstance> modelInstancesList) { CldsModel model = new CldsModel(); for (CldsModelInstance currModelInstance : modelInstancesList) { - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_control_name_uuid", controlNameUUid) + SqlParameterSource in = new MapSqlParameterSource().addValue("v_control_name_uuid", controlNameUUid) .addValue("v_vm_name", currModelInstance.getVmName()); Map<String, Object> out = logSqlExecution(procDelModelInstance, in); model.setId((String) (out.get("v_model_id"))); @@ -295,7 +312,9 @@ public class CldsDao { } /** - * Insert an event in the database - require either modelName or controlNamePrefix/controlNameUuid. + * Insert an event in the database - require either modelName or + * controlNamePrefix/controlNameUuid. + * * @param modelName * @param controlNamePrefix * @param controlNameUuid @@ -304,12 +323,9 @@ public class CldsDao { */ public CldsEvent insEvent(String modelName, String controlNamePrefix, String controlNameUuid, CldsEvent cldsEvent) { CldsEvent event = new CldsEvent(); - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_model_name", modelName) - .addValue("v_control_name_prefix", controlNamePrefix) - .addValue("v_control_name_uuid", controlNameUuid) - .addValue("v_userid", cldsEvent.getUserid()) - .addValue("v_action_cd", cldsEvent.getActionCd()) + SqlParameterSource in = new MapSqlParameterSource().addValue("v_model_name", modelName) + .addValue("v_control_name_prefix", controlNamePrefix).addValue("v_control_name_uuid", controlNameUuid) + .addValue("v_user_id", cldsEvent.getUserid()).addValue("v_action_cd", cldsEvent.getActionCd()) .addValue("v_action_state_cd", cldsEvent.getActionStateCd()) .addValue("v_process_instance_id", cldsEvent.getProcessInstanceId()); Map<String, Object> out = logSqlExecution(procInsEvent, in); @@ -324,8 +340,7 @@ public class CldsDao { * @return */ private String delAllModelInstances(String controlNameUUid) { - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_control_name_uuid", controlNameUUid); + SqlParameterSource in = new MapSqlParameterSource().addValue("v_control_name_uuid", controlNameUUid); Map<String, Object> out = logSqlExecution(procDelAllModelInstances, in); return (String) (out.get("v_model_id")); } @@ -337,8 +352,7 @@ public class CldsDao { * @param processInstanceId */ public void updEvent(String eventId, String processInstanceId) { - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_event_id", eventId) + SqlParameterSource in = new MapSqlParameterSource().addValue("v_event_id", eventId) .addValue("v_process_instance_id", processInstanceId); logSqlExecution(procUpdEvent, in); } @@ -347,6 +361,7 @@ public class CldsDao { * Generic mapper for list of values */ private static final class ValueItemMapper implements RowMapper<ValueItem> { + @Override public ValueItem mapRow(ResultSet rs, int rowNum) throws SQLException { ValueItem item = new ValueItem(); item.setValue(rs.getString(1)); @@ -358,6 +373,7 @@ public class CldsDao { * Generic mapper for CldsDBServiceCache */ private static final class CldsServiceDataMapper implements RowMapper<CldsServiceData> { + @Override public CldsServiceData mapRow(ResultSet rs, int rowNum) throws SQLException { CldsServiceData cldsServiceData = new CldsServiceData(); long age; @@ -387,29 +403,28 @@ public class CldsDao { } /** - * Update template in the database using parameter values and return updated template object. + * Update template in the database using parameter values and return updated + * template object. * * @param template * @param userid * @return */ public CldsTemplate setTemplate(CldsTemplate template, String userid) { - SqlParameterSource in = new MapSqlParameterSource() - .addValue("v_template_name", template.getName()) - .addValue("v_userid", userid) - .addValue("v_template_bpmn_text", template.getBpmnText()) + SqlParameterSource in = new MapSqlParameterSource().addValue("v_template_name", template.getName()) + .addValue("v_user_id", userid).addValue("v_template_bpmn_text", template.getBpmnText()) .addValue("v_template_image_text", template.getImageText()) .addValue("v_template_doc_text", template.getPropText()); Map<String, Object> out = logSqlExecution(procSetTemplate, in); template.setId((String) (out.get("v_template_id"))); - template.setBpmnUserid((String) (out.get("v_template_bpmn_userid"))); + template.setBpmnUserid((String) (out.get("v_template_bpmn_user_id"))); template.setBpmnId((String) (out.get("v_template_bpmn_id"))); template.setBpmnText((String) (out.get("v_template_bpmn_text"))); template.setImageId((String) (out.get("v_template_image_id"))); - template.setImageUserid((String) out.get("v_template_image_userid")); + template.setImageUserid((String) out.get("v_template_image_user_id")); template.setImageText((String) out.get("v_template_image_text")); template.setPropId((String) (out.get("v_template_doc_id"))); - template.setPropUserid((String) out.get("v_template_doc_userid")); + template.setPropUserid((String) out.get("v_template_doc_user_id")); template.setPropText((String) out.get("v_template_doc_text")); return template; } @@ -436,24 +451,26 @@ public class CldsDao { SqlParameterSource in = new MapSqlParameterSource().addValue("v_template_name", templateName); Map<String, Object> out = logSqlExecution(procGetTemplate, in); template.setId((String) (out.get("v_template_id"))); - template.setBpmnUserid((String) (out.get("v_template_bpmn_userid"))); + template.setBpmnUserid((String) (out.get("v_template_bpmn_user_id"))); template.setBpmnId((String) (out.get("v_template_bpmn_id"))); template.setBpmnText((String) (out.get("v_template_bpmn_text"))); template.setImageId((String) (out.get("v_template_image_id"))); - template.setImageUserid((String) out.get("v_template_image_userid")); + template.setImageUserid((String) out.get("v_template_image_user_id")); template.setImageText((String) out.get("v_template_image_text")); template.setPropId((String) (out.get("v_template_doc_id"))); - template.setPropUserid((String) out.get("v_template_doc_userid")); + template.setPropUserid((String) out.get("v_template_doc_user_id")); template.setPropText((String) out.get("v_template_doc_text")); return template; } - public CldsServiceData getCldsServiceCache(String invariantUUID) throws SQLException, IOException, ClassNotFoundException { + public CldsServiceData getCldsServiceCache(String invariantUUID) + throws SQLException, IOException, ClassNotFoundException { CldsServiceData cldsServiceData = null; List<CldsServiceData> cldsServiceDataList = new ArrayList<>(); try { String getCldsServiceSQL = "SELECT * , TIMESTAMPDIFF(SECOND, timestamp, CURRENT_TIMESTAMP()) FROM clds_service_cache where invariant_service_id = ? "; - cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[]{invariantUUID}, new CldsServiceDataMapper()); + cldsServiceData = jdbcTemplateObject.queryForObject(getCldsServiceSQL, new Object[] { invariantUUID }, + new CldsServiceDataMapper()); logger.info("value of cldsServiceDataList: {}", cldsServiceDataList); } catch (EmptyResultDataAccessException e) { logger.info("cache row not found for invariantUUID: {}", invariantUUID); @@ -462,24 +479,29 @@ public class CldsDao { } public void setCldsServiceCache(CldsDBServiceCache cldsDBServiceCache) throws SQLException, IOException { - if (cldsDBServiceCache != null && cldsDBServiceCache.getInvariantId() != null && cldsDBServiceCache.getServiceId() != null) { - String invariantUUID = cldsDBServiceCache.getInvariantId(); - String serviceUUID = cldsDBServiceCache.getServiceId(); + if (cldsDBServiceCache != null && cldsDBServiceCache.getInvariantId() != null + && cldsDBServiceCache.getServiceId() != null) { + String invariantUuid = cldsDBServiceCache.getInvariantId(); + String serviceUuid = cldsDBServiceCache.getServiceId(); InputStream is = cldsDBServiceCache.getCldsDataInstream(); - String insertCldsServiceCacheSQL = "INSERT INTO clds_service_cache" + String insertCldsServiceCacheSql = "INSERT INTO clds_service_cache" + "(invariant_service_id,service_id,timestamp,object_data) VALUES" + "(?,?,CURRENT_TIMESTAMP,?) ON DUPLICATE KEY UPDATE invariant_service_id = VALUES(invariant_service_id) , timestamp = CURRENT_TIMESTAMP , object_data = VALUES(object_data) "; - jdbcTemplateObject.update(insertCldsServiceCacheSQL, invariantUUID, serviceUUID, is); + jdbcTemplateObject.update(insertCldsServiceCacheSql, invariantUuid, serviceUuid, is); } } private static Map<String, Object> logSqlExecution(SimpleJdbcCall call, SqlParameterSource source) { - try { - return call.execute(source); - } catch (Exception e) { - logger.error("Exception occured in " + source.getClass().getCanonicalName() + ": " + e); - throw e; - } + try { + return call.execute(source); + } catch (Exception e) { + logger.error("Exception occured in " + source.getClass().getCanonicalName() + ": " + e); + throw e; + } + } + + public void doHealthCheck() throws SQLException, IOException { + jdbcTemplateObject.execute(healthcheck); } } diff --git a/src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java b/src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java index 41023acec..6aeadc546 100644 --- a/src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java +++ b/src/main/java/org/onap/clamp/clds/exception/AjscExceptionMapper.java @@ -23,18 +23,19 @@ package org.onap.clamp.clds.exception; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + import com.att.ajsc.common.AjscProvider; import com.att.ajsc.common.exception.ServerErrorException; import com.att.ajsc.common.exception.ServiceException; -import javax.ws.rs.core.Response; -import javax.ws.rs.ext.ExceptionMapper; - @AjscProvider public class AjscExceptionMapper implements ExceptionMapper<Exception> { @Override public Response toResponse(final Exception exception) { - return exception instanceof ServiceException ? ((ServiceException) exception).toResponse() : new ServerErrorException(exception.getMessage()).toResponse(); + return exception instanceof ServiceException ? ((ServiceException) exception).toResponse() + : new ServerErrorException(exception.getMessage()).toResponse(); } } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Collector.java b/src/main/java/org/onap/clamp/clds/model/prop/Collector.java index 84bc38f0c..bcb9cf01d 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Collector.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Collector.java @@ -5,16 +5,16 @@ * 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. + * 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 + * + * 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============================================ * =================================================================== @@ -23,15 +23,18 @@ package org.onap.clamp.clds.model.prop; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; -import java.util.logging.Logger; - /** * Parse Collector json properties. */ public class Collector extends ModelElement { - private static final Logger logger = Logger.getLogger(Collector.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Collector.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private static final String TYPE_COLLECTOR = "collector"; /** * Parse Collector given json node. @@ -44,4 +47,8 @@ public class Collector extends ModelElement { topicPublishes = getValueByName("topicPublishes"); } + public static final String getType() { + return TYPE_COLLECTOR; + } + } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Global.java b/src/main/java/org/onap/clamp/clds/model/prop/Global.java index f8986b361..2fb7d5040 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Global.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Global.java @@ -5,16 +5,16 @@ * 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. + * 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 + * + * 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============================================ * =================================================================== @@ -23,23 +23,29 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.databind.JsonNode; - import java.util.List; -import java.util.logging.Logger; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; /** * Parse global json properties. * <p> - * Example json: "global":[{"name":"service","value":["vUSP"]},{"name":"vnf","value":["vCTS","v3CDB"]},{"name":"location","value":["san_diego","san_antonio","kansas_city","kings_mountain","Secaucus","lisle","concord","houston","akron"]}] + * Example json: + * "global":[{"name":"service","value":["vUSP"]},{"name":"vnf","value":["vCTS", + * "v3CDB"]},{"name":"location","value":["san_diego","san_antonio","kansas_city" + * ,"kings_mountain","Secaucus","lisle","concord","houston","akron"]}] */ public class Global { - private static final Logger logger = Logger.getLogger(Global.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Global.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private String service; - private List<String> resourceVf; - private List<String> resourceVfc; - private List<String> location; + private String service; + private String actionSet; + private List<String> resourceVf; + private List<String> resourceVfc; + private List<String> location; /** * Parse global given json node. @@ -49,6 +55,7 @@ public class Global { public Global(JsonNode modelJson) { JsonNode globalNode = modelJson.get("global"); service = ModelElement.getValueByName(globalNode, "service"); + actionSet = ModelElement.getValueByName(globalNode, "actionSet"); resourceVf = ModelElement.getValuesByName(globalNode, "vf"); resourceVfc = ModelElement.getValuesByName(globalNode, "vfc"); location = ModelElement.getValuesByName(globalNode, "location"); @@ -62,13 +69,21 @@ public class Global { } /** - * @param service the service to set + * @param service + * the service to set */ public void setService(String service) { this.service = service; } /** + * @return the actionSet + */ + public String getActionSet() { + return actionSet; + } + + /** * @return the resourceVf */ public List<String> getResourceVf() { @@ -76,7 +91,8 @@ public class Global { } /** - * @param resourceVf the resourceVf to set + * @param resourceVf + * the resourceVf to set */ public void setResourceVf(List<String> resourceVf) { this.resourceVf = resourceVf; @@ -90,7 +106,8 @@ public class Global { } /** - * @param resourceVfc the resourceVfc to set + * @param resourceVfc + * the resourceVfc to set */ public void setResourceVfc(List<String> resourceVfc) { this.resourceVfc = resourceVfc; @@ -104,7 +121,8 @@ public class Global { } /** - * @param location the location to set + * @param location + * the location to set */ public void setLocation(List<String> location) { this.location = location; diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java index b4cc11dc2..63a03058d 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmn.java @@ -5,16 +5,16 @@ * 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. + * 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 + * + * 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============================================ * =================================================================== @@ -23,6 +23,18 @@ package org.onap.clamp.clds.model.prop; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.onap.clamp.clds.service.CldsService; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; @@ -30,18 +42,17 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import java.io.IOException; -import java.util.*; -import java.util.Map.Entry; -import java.util.logging.Logger; - /** * Parse Model BPMN properties. * <p> - * Example json: {"collector":[{"id":"Collector_11r50j1", "from":"StartEvent_1"}],"stringMatch":[{"id":"StringMatch_0h6cbdv"}],"policy":[{"id":"Policy_0oxeocn", "from":"StringMatch_0h6cbdv"}]} + * Example json: {"collector":[{"id":"Collector_11r50j1", + * "from":"StartEvent_1"}],"stringMatch":[{"id":"StringMatch_0h6cbdv"}],"policy" + * :[{"id":"Policy_0oxeocn", "from":"StringMatch_0h6cbdv"}]} */ public class ModelBpmn { - private static final Logger logger = Logger.getLogger(ModelBpmn.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance() + .getLogger(CldsService.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); // for each type, an array of entries private final Map<String, List<ModelBpmnEntry>> entriesByType = new HashMap<>(); @@ -65,7 +76,8 @@ public class ModelBpmn { ModelBpmn modelBpmn = new ModelBpmn(); ObjectMapper objectMapper = new ObjectMapper(); ObjectNode root = objectMapper.readValue(modelBpmnPropText, ObjectNode.class); - // iterate over each entry like: "collector":[{"id":"Collector_11r50j1","from":"StartEvent_1"}] + // iterate over each entry like: + // "collector":[{"id":"Collector_11r50j1","from":"StartEvent_1"}] Iterator<Entry<String, JsonNode>> entryItr = root.fields(); List<String> bpmnElementIdList = new ArrayList<>(); while (entryItr.hasNext()) { @@ -73,7 +85,8 @@ public class ModelBpmn { Entry<String, JsonNode> entry = entryItr.next(); String type = entry.getKey(); ArrayNode arrayNode = (ArrayNode) entry.getValue(); - // process each id/from object, like: {"id":"Collector_11r50j1","from":"StartEvent_1"} + // process each id/from object, like: + // {"id":"Collector_11r50j1","from":"StartEvent_1"} for (JsonNode anArrayNode : arrayNode) { ObjectNode node = (ObjectNode) anArrayNode; String id = node.get("id").asText(); @@ -110,8 +123,8 @@ public class ModelBpmn { } /** - * - * + * + * * @param type * @return true if the element is found or false otherwise */ @@ -123,14 +136,22 @@ public class ModelBpmn { * @return the id field given the ModelElement type */ public String getId(String type) { - return entriesByType.get(type).get(0).getId(); + String modelElementId = ""; + if (entriesByType.get(type) != null) { + modelElementId = entriesByType.get(type).get(0).getId(); + } + return modelElementId; } /** * @return the fromId field given the ModelElement type */ public String getFromId(String type) { - return entriesByType.get(type).get(0).getFromId(); + String modelElementFromIdId = ""; + if (entriesByType.get(type) != null) { + modelElementFromIdId = entriesByType.get(type).get(0).getFromId(); + } + return modelElementFromIdId; } /** diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java index 8002f447f..210795be4 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelBpmnEntry.java @@ -5,16 +5,16 @@ * 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. + * 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 + * + * 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============================================ * =================================================================== @@ -23,22 +23,27 @@ package org.onap.clamp.clds.model.prop; -import java.util.logging.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; /** * Model BPMN property entry * <p> - * Example json: {"collector":[{"id":"Collector_11r50j1", "from":"StartEvent_1"}],"stringMatch":[{"id":"StringMatch_0h6cbdv"],"policy":[{"id":"Policy_0oxeocn", "from":"StringMatch_0h6cbdv"}]} + * Example json: {"collector":[{"id":"Collector_11r50j1", + * "from":"StartEvent_1"}],"stringMatch":[{"id":"StringMatch_0h6cbdv"],"policy": + * [{"id":"Policy_0oxeocn", "from":"StringMatch_0h6cbdv"}]} */ public class ModelBpmnEntry { - private static final Logger logger = Logger.getLogger(ModelBpmnEntry.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelBpmnEntry.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private String type; - private String id; - private String fromId; + private String type; + private String id; + private String fromId; /** - * Parse the json so that the "id" and "from" fields can be retrieved on demand. + * Parse the json so that the "id" and "from" fields can be retrieved on + * demand. * * @param type * @param id @@ -58,7 +63,8 @@ public class ModelBpmnEntry { } /** - * @param type the type to set + * @param type + * the type to set */ public void setType(String type) { this.type = type; @@ -72,7 +78,8 @@ public class ModelBpmnEntry { } /** - * @param id the id to set + * @param id + * the id to set */ public void setId(String id) { this.id = id; @@ -86,7 +93,8 @@ public class ModelBpmnEntry { } /** - * @param fromId the fromId to set + * @param fromId + * the fromId to set */ public void setFromId(String fromId) { this.fromId = fromId; diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java index d8e903060..ed038db66 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelElement.java @@ -5,16 +5,16 @@ * 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. + * 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 + * + * 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============================================ * =================================================================== @@ -23,38 +23,37 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.databind.JsonNode; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.logging.Logger; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; /** * Provide base ModelElement functionality. */ public abstract class ModelElement { - private final static Logger sLOGGER = Logger.getLogger(ModelElement.class.getName()); - private static final Logger logger = Logger.getLogger(ModelElement.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ModelElement.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - public static final String TYPE_COLLECTOR = "collector"; - public static final String TYPE_STRING_MATCH = "stringMatch"; - public static final String TYPE_POLICY = "policy"; - public static final String TYPE_TCA = "tca"; + public static final String TYPE_POLICY = "policy"; + public static final String TYPE_TCA = "tca"; - private final String type; - private final ModelBpmn modelBpmn; - private final String id; - protected String topicPublishes; - protected final JsonNode meNode; - private boolean isFound; + private final String type; + private final ModelBpmn modelBpmn; + private final String id; + protected String topicPublishes; + protected final JsonNode meNode; + private boolean isFound; - private final ModelProperties modelProp; + private final ModelProperties modelProp; /** * Perform base parsing of properties for a ModelElement (such as, * Collector, StringMatch, Policy and Tca) - * + * * @param type * @param modelProp * @param modelBpmn @@ -117,9 +116,9 @@ public abstract class ModelElement { } } if (value == null || value.length() == 0) { - sLOGGER.warning(name + "=" + value); + logger.warn(name + "=" + value); } else { - sLOGGER.fine(name + "=" + value); + logger.debug(name + "=" + value); } return value; } @@ -157,9 +156,9 @@ public abstract class ModelElement { } } if (values == null || values.size() == 0) { - sLOGGER.warning(name + "=" + values); + logger.warn(name + "=" + values); } else { - sLOGGER.fine(name + "=" + values); + logger.debug(name + "=" + values); } return values; } @@ -228,5 +227,4 @@ public abstract class ModelElement { public boolean isFound() { return isFound; } - } 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 014b8c77e..1cfd46165 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 @@ -5,16 +5,16 @@ * 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. + * 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 + * + * 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============================================ * =================================================================== @@ -23,38 +23,62 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.clamp.clds.model.CldsEvent; import org.onap.clamp.clds.model.CldsModel; -import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.clamp.clds.service.CldsService; -import java.io.IOException; -import java.util.List; -import java.util.logging.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; /** * Parse model properties. */ public class ModelProperties { - private static final Logger logger = Logger.getLogger(ModelProperties.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance() + .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 Global global; + private Tca tca; - private ModelBpmn modelBpmn; - private JsonNode modelJson; + private final Map<String, ModelElement> modelElements = new ConcurrentHashMap<>(); - private final String modelName; - private final String controlName; - private final String actionCd; + private String currentModelElementId; + private String policyUniqueId; - private Global global; - private Collector collector; - private StringMatch stringMatch; - private Policy policy; - private Tca tca; + private static final Object lock = new Object(); + private static Map<Class<? extends ModelElement>, String> modelElementClasses = new ConcurrentHashMap<>(); - private String currentModelElementId; - private String policyUniqueId; + static { + synchronized (lock) { + modelElementClasses.put(Collector.class, Collector.getType()); + modelElementClasses.put(Policy.class, Policy.getType()); + modelElementClasses.put(StringMatch.class, StringMatch.getType()); + modelElementClasses.put(Tca.class, Tca.getType()); + } + } /** * Retain data required to parse the ModelElement objects. (Rather than @@ -63,18 +87,53 @@ public class ModelProperties { * @param modelName * @param controlName * @param actionCd + * @param isTest * @param modelBpmnPropText * @param modelPropText * @throws JsonProcessingException * @throws IOException */ - public ModelProperties(String modelName, String controlName, String actionCd, String modelBpmnPropText, String modelPropText) throws IOException { + public ModelProperties(String modelName, String controlName, String actionCd, boolean isTest, String modelBpmnPropText, + String modelPropText) throws IOException { this.modelName = modelName; this.controlName = controlName; this.actionCd = actionCd; + this.isTest = isTest; modelBpmn = ModelBpmn.create(modelBpmnPropText); - ObjectMapper mapper = new ObjectMapper(); - modelJson = mapper.readTree(modelPropText); + modelJson = new ObjectMapper().readTree(modelPropText); + + instantiateMissingModelElements(); + } + + /** + * This method is meant to ensure that one ModelElement instance exists for + * each ModelElement class. + * + * As new ModelElement classes could have been registered after + * instantiation of this ModelProperties, we need to build the missing + * ModelElement instances. + */ + private final void instantiateMissingModelElements() { + if (modelElementClasses.size() != modelElements.size()) { + Set<String> missingTypes = new HashSet<>(modelElementClasses.values()); + missingTypes.removeAll(modelElements.keySet()); + // Parse the list of base Model Elements and build up the + // ModelElements + modelElementClasses.entrySet().stream().parallel() + .filter(entry -> (ModelElement.class.isAssignableFrom(entry.getKey()) + && missingTypes.contains(entry.getValue()))) + .forEach(entry -> { + try { + modelElements.put(entry.getValue(), + (entry.getKey() + .getConstructor(ModelProperties.class, ModelBpmn.class, JsonNode.class) + .newInstance(this, modelBpmn, modelJson))); + } catch (InstantiationException | NoSuchMethodException | IllegalAccessException + | InvocationTargetException e) { + logger.warn("Unable to instantiate a ModelElement, exception follows: " + e); + } + }); + } } /** @@ -109,13 +168,15 @@ public class ModelProperties { * @throws IOException */ public static ModelProperties create(DelegateExecution execution) throws IOException { - String modelProp = (String) execution.getVariable("modelProp"); + // String modelProp = (String) execution.getVariable("modelProp"); + 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, modelBpmnProp, modelProp); + return new ModelProperties(modelName, controlName, actionCd, isTest, modelBpmnProp, modelProp); } /** @@ -125,24 +186,11 @@ public class ModelProperties { * @return */ public ModelElement getModelElementByType(String type) { - ModelElement me; - switch (type) { - case ModelElement.TYPE_COLLECTOR: - me = getCollector(); - break; - case ModelElement.TYPE_STRING_MATCH: - me = getStringMatch(); - break; - case ModelElement.TYPE_POLICY: - me = getPolicy(); - break; - case ModelElement.TYPE_TCA: - me = getTca(); - break; - default: - throw new IllegalArgumentException("Invalid ModelElement type: " + type); + ModelElement modelElement = modelElements.get(type); + if (modelElement == null) { + throw new IllegalArgumentException("Invalid or not found ModelElement type: " + type); } - return me; + return modelElement; } /** @@ -181,6 +229,13 @@ public class ModelProperties { } /** + * @return the policyScopeAndNameWithUniqueId + */ + public String getPolicyScopeAndNameWithUniqueId() { + return normalizePolicyScopeName(modelName + "." + getCurrentPolicyName() + "_" + policyUniqueId); + } + + /** * @return the currentPolicyScopeAndFullPolicyName */ public String getCurrentPolicyScopeAndFullPolicyName(String policyNamePrefix) { @@ -233,7 +288,7 @@ public class ModelProperties { /** * When generating a policy request for a model element, must set the unique * id of that policy using this method. Used to generate the policy name. - * + * * @param policyUniqueId * the policyUniqueId to set */ @@ -242,22 +297,19 @@ public class ModelProperties { } /** - * @return the collector - */ - public Collector getCollector() { - if (collector == null) { - collector = new Collector(this, modelBpmn, modelJson); - } - return collector; - } - - /** * @return the actionCd */ public String getActionCd() { return actionCd; } + /** + * @return the isTest + */ + public boolean isTest() { + return isTest; + } + /** * @return the isCreateRequest */ @@ -288,24 +340,17 @@ public class ModelProperties { return global; } - /** - * @return the stringMatch - */ - public StringMatch getStringMatch() { - if (stringMatch == null) { - stringMatch = new StringMatch(this, modelBpmn, modelJson); + public static final synchronized void registerModelElement(Class<? extends ModelElement> modelElementClass, + String type) { + if (!modelElementClasses.containsKey(modelElementClass.getClass())) { + modelElementClasses.put(modelElementClass, type); } - return stringMatch; } - /** - * @return the policy - */ - public Policy getPolicy() { - if (policy == null) { - policy = new Policy(this, modelBpmn, modelJson); - } - return policy; + public <T extends ModelElement> T getType(Class<T> clazz) { + instantiateMissingModelElements(); + String type = modelElementClasses.get(clazz); + return (type != null ? (T) modelElements.get(type) : null); } /** diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Policy.java b/src/main/java/org/onap/clamp/clds/model/prop/Policy.java index 729eb4381..6673af213 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Policy.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Policy.java @@ -5,16 +5,16 @@ * 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. + * 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 + * + * 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============================================ * =================================================================== @@ -23,23 +23,38 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.databind.JsonNode; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.logging.Logger; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; /** * Parse Policy json properties. * <p> - * Example json: "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]}],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":["vf3RtPi"]}]]}] + * Example json: + * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[ + * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{ + * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{ + * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]} + * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""] + * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""] + * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]} + * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]} + * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS" + * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[ + * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[ + * "vf3RtPi"]}]]}] */ public class Policy extends ModelElement { - private static final Logger logger = Logger.getLogger(Policy.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Policy.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private final Integer timeout; - private final List<PolicyItem> policyItems; + private List<PolicyChain> policyChains; + + private static final String TYPE_POLICY = "policy"; /** * Parse Policy given json node. @@ -49,30 +64,27 @@ public class Policy extends ModelElement { * @param modelJson */ public Policy(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { - super(TYPE_POLICY, modelProp, modelBpmn, modelJson); - timeout = getIntValueByName(meNode.get(0), "timeout"); + super(ModelElement.TYPE_POLICY, modelProp, modelBpmn, modelJson); // process policies - JsonNode policyNode = meNode.get(1).get("policyConfigurations"); - Iterator<JsonNode> itr = policyNode.elements(); - policyItems = new ArrayList<>(); - while (itr.hasNext()) { - policyItems.add(new PolicyItem(itr.next())); + if (meNode != null) { + Iterator<JsonNode> itr = meNode.elements(); + policyChains = new ArrayList<PolicyChain>(); + while (itr.hasNext()) { + policyChains.add(new PolicyChain(itr.next())); + } } } /** - * @return the timeout + * @return the policyChains */ - public Integer getTimeout() { - return timeout; + public List<PolicyChain> getPolicyChains() { + return policyChains; } - /** - * @return the policyItems - */ - public List<PolicyItem> getPolicyItems() { - return policyItems; + public static final String getType() { + return TYPE_POLICY; } } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java b/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java index a943f1840..d1729cda1 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/PolicyItem.java @@ -5,16 +5,16 @@ * 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. + * 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 + * + * 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============================================ * =================================================================== @@ -23,25 +23,40 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.databind.JsonNode; - import java.util.List; -import java.util.logging.Logger; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; /** * Parse policyConfigurations from Policy json properties. * <p> - * Example json: "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[{"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""]}],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]},{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]},{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":["vf3RtPi"]}]]}] + * Example json: + * "Policy_005sny1":[[{"name":"timeout","value":"5"}],{"policyConfigurations":[[ + * {"name":"recipe","value":["restart"]},{"name":"maxRetries","value":["3"]},{ + * "name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["vf3RtPi"]},{ + * "name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS"]} + * ,{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[""] + * },{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[""] + * }],[{"name":"recipe","value":["rebuild"]},{"name":"maxRetries","value":["3"]} + * ,{"name":"retryTimeLimit","value":["180"]},{"name":"_id","value":["89z8Ncl"]} + * ,{"name":"location","value":["san_diego"]},{"name":"resource","value":["vCTS" + * ]},{"name":"onMaxRetriesLimit","value":[""]},{"name":"onTimeLimit","value":[ + * ""]},{"name":"onOtherFailure","value":[""]},{"name":"policy_parent","value":[ + * "vf3RtPi"]}]]}] */ -public class PolicyItem { - private static final Logger logger = Logger.getLogger(Policy.class.getName()); +public class PolicyItem implements Cloneable { + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyItem.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private final String id; - private final String recipe; - private final int maxRetries; - private final int retryTimeLimit; - private final String parentPolicy; - private final List<String> parentPolicyConditions; + private String id; + private String recipe; + private int maxRetries; + private int retryTimeLimit; + private String parentPolicy; + private List<String> parentPolicyConditions; + private String actor; /** * Parse Policy given json node. @@ -73,6 +88,48 @@ public class PolicyItem { } /** + * @set the id + */ + public void setId(String id) { + this.id = id; + } + + /** + * @set the recipe + */ + public void setRecipe(String recipe) { + this.recipe = recipe; + } + + /** + * @set the parentPolicy + */ + public void setParentPolicy(String parentPolicy) { + this.parentPolicy = parentPolicy; + } + + /** + * @set the maxRetries + */ + public void setMaxRetries(int maxRetries) { + this.maxRetries = maxRetries; + } + + /** + * @set the retryTimeLimit + */ + public void setRetryTimeLimit(int retryTimeLimit) { + this.retryTimeLimit = retryTimeLimit; + } + + /** + * @set the parentPolicyConditions + */ + public void setParentPolicyConditions(List<String> parentPolicyConditions) { + this.parentPolicyConditions = parentPolicyConditions; + } + + /** * @return the maxRetries */ public int getMaxRetries() { @@ -100,4 +157,22 @@ public class PolicyItem { return parentPolicyConditions; } + /** + * @return the actor + */ + public String getActor() { + return actor; + } + + /** + * @set the actor + */ + public void setActor(String actor) { + this.actor = actor; + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java b/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java index 498f852e9..186cc2192 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ServiceConfiguration.java @@ -5,16 +5,16 @@ * 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. + * 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 + * + * 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============================================ * =================================================================== @@ -23,32 +23,59 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.databind.JsonNode; - import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.logging.Logger; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; /** * Parse serviceConfigurations from StringMatch json properties. * <p> - * Example json: "StringMatch_0c2cy0c":[[{"name":"topicPublishes","value":"DCAE-CL-EVENT"}],{"serviceConfigurations":[[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VNFNAME","LOCID"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Initial"]},{"name":"outputEventName","value":["OnSet"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}],[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VMID","Identiy","VNFNAME"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Close"]},{"name":"outputEventName","value":["Abatement"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}]]}] + * Example json: + * {"StringMatch_0aji7go":{"Group1":[{"name":"rgname","value":"1493749598520"},{ + * "name":"rgfriendlyname","value":"Group1"},{"name":"policyName","value": + * "Policy1"},{"name":"policyId","value":"1"},{"serviceConfigurations":[[{"name" + * :"aaiMatchingFields","value":["complex.city","vserver.vserver-name"]},{"name" + * :"aaiSendFields","value":["complex.city","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["OK"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["100"]},{"name":"ageLimit","value":["100"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}]]}],"Group2":[{"name":"rgname","value": + * "1493749665149"},{"name":"rgfriendlyname","value":"Group2"},{"name": + * "policyName","value":"Policy2"},{"name":"policyId","value":"2"},{ + * "serviceConfigurations":[[{"name":"aaiMatchingFields","value":[ + * "cloud-region.identity-url","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["cloud-region.identity-url","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["1000"]},{"name":"ageLimit","value":["1000"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}],[{"name":"aaiMatchingFields","value":[ + * "generic-vnf.vnf-name","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["generic-vnf.vnf-name","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["CRITICAL"]},{"name":"eventSourceType","value":[""]} + * ,{"name":"timeWindow","value":["3000"]},{"name":"ageLimit","value":["3000"]}, + * {"name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ABATED"]}]]}]}} + * */ public class ServiceConfiguration { - private static final Logger logger = Logger.getLogger(ServiceConfiguration.class.getName()); - - private final List<String> aaiMatchingFields; - private final List<String> aaiSendFields; - private final String groupNumber; - private final List<String> resourceVf; - private final List<String> resourceVfc; - private final String timeWindow; - private final String ageLimit; - private final String createClosedLoopEventId; - private final String outputEventName; + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(ServiceConfiguration.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private final List<String> aaiMatchingFields; + private final List<String> aaiSendFields; + // private final String groupNumber; + private final List<String> resourceVf; + private final List<String> resourceVfc; + private final String timeWindow; + private final String ageLimit; + private final String createClosedLoopEventId; + private final String outputEventName; private final Map<String, String> stringSet; /** @@ -59,7 +86,7 @@ public class ServiceConfiguration { public ServiceConfiguration(JsonNode node) { aaiMatchingFields = ModelElement.getValuesByName(node, "aaiMatchingFields"); aaiSendFields = ModelElement.getValuesByName(node, "aaiSendFields"); - groupNumber = ModelElement.getValueByName(node, "groupNumber"); + // groupNumber = ModelElement.getValueByName(node, "groupNumber"); resourceVf = ModelElement.getValuesByName(node, "vf"); resourceVfc = ModelElement.getValuesByName(node, "vfc"); timeWindow = ModelElement.getValueByName(node, "timeWindow"); @@ -77,7 +104,7 @@ public class ServiceConfiguration { String value = ssNode.path("value").path(0).asText(); if (key.length() != 0 && value.length() != 0) { // only add string set field if not null - logger.fine("stringSet: " + key + "=" + value); + logger.debug("stringSet: " + key + "=" + value); stringSet.put(key, value); } } @@ -99,11 +126,9 @@ public class ServiceConfiguration { /** * @return the groupNumber - */ - public String getGroupNumber() { - return groupNumber; - } - + */ /* + * public String getGroupNumber() { return groupNumber; } + */ /** * @return the resourceVf */ diff --git a/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java b/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java index d7092c4e6..b20db0aff 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/StringMatch.java @@ -5,16 +5,16 @@ * 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. + * 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 + * + * 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============================================ * =================================================================== @@ -23,22 +23,51 @@ package org.onap.clamp.clds.model.prop; -import com.fasterxml.jackson.databind.JsonNode; - import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.logging.Logger; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.JsonNode; /** * Parse StringMatch json properties. * <p> - * Example json: "StringMatch_0c2cy0c":[[{"name":"topicPublishes","value":"DCAE-CL-EVENT"}],{"serviceConfigurations":[[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VNFNAME","LOCID"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Initial"]},{"name":"outputEventName","value":["OnSet"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}],[{"name":"aaiMatchingFields","value":["VMID"]},{"name":"aaiSendFields","value":["VMID","Identiy","VNFNAME"]},{"name":"vnf","value":["aSBG"]},{"name":"timeWindow","value":["0"]},{"name":"ageLimit","value":["1600"]},{"name":"createClosedLoopEventId","value":["Close"]},{"name":"outputEventName","value":["Abatement"]},{"stringSet":[{"name":"alarmCondition","value":["authenticationFailure"]},{"name":"eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":["f5BigIP"]}]}]]}] + * Example json: + * {"StringMatch_0aji7go":{"Group1":[{"name":"rgname","value":"1493749598520"},{ + * "name":"rgfriendlyname","value":"Group1"},{"name":"policyName","value": + * "Policy1"},{"name":"policyId","value":"1"},{"serviceConfigurations":[[{"name" + * :"aaiMatchingFields","value":["complex.city","vserver.vserver-name"]},{"name" + * :"aaiSendFields","value":["complex.city","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["OK"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["100"]},{"name":"ageLimit","value":["100"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}]]}],"Group2":[{"name":"rgname","value": + * "1493749665149"},{"name":"rgfriendlyname","value":"Group2"},{"name": + * "policyName","value":"Policy2"},{"name":"policyId","value":"2"},{ + * "serviceConfigurations":[[{"name":"aaiMatchingFields","value":[ + * "cloud-region.identity-url","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["cloud-region.identity-url","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["NORMAL"]},{"name":"eventSourceType","value":[""]},{ + * "name":"timeWindow","value":["1000"]},{"name":"ageLimit","value":["1000"]},{ + * "name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ONSET"]}],[{"name":"aaiMatchingFields","value":[ + * "generic-vnf.vnf-name","vserver.vserver-name"]},{"name":"aaiSendFields", + * "value":["generic-vnf.vnf-name","vserver.vserver-name"]},{"name": + * "eventSeverity","value":["CRITICAL"]},{"name":"eventSourceType","value":[""]} + * ,{"name":"timeWindow","value":["3000"]},{"name":"ageLimit","value":["3000"]}, + * {"name":"createClosedLoopEventId","value":["Initial"]},{"name": + * "outputEventName","value":["ABATED"]}]]}]}} + * */ public class StringMatch extends ModelElement { - private static final Logger logger = Logger.getLogger(StringMatch.class.getName()); + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(StringMatch.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - private final List<ServiceConfiguration> serviceConfigurations; + private List<ResourceGroup> resourceGroups; + + private static final String TYPE_STRING_MATCH = "stringMatch"; /** * Parse StringMatch given json node. @@ -47,24 +76,27 @@ public class StringMatch extends ModelElement { * @param modelJson */ public StringMatch(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { - super(ModelElement.TYPE_STRING_MATCH, modelProp, modelBpmn, modelJson); - - topicPublishes = getValueByName(meNode.get(0), "topicPublishes"); + super(TYPE_STRING_MATCH, modelProp, modelBpmn, modelJson); // process Server_Configurations - JsonNode serviceConfigurationsNode = meNode.get(1).get("serviceConfigurations"); - Iterator<JsonNode> itr = serviceConfigurationsNode.elements(); - serviceConfigurations = new ArrayList<>(); - while (itr.hasNext()) { - serviceConfigurations.add(new ServiceConfiguration(itr.next())); + if (meNode != null) { + Iterator<JsonNode> itr = meNode.elements(); + resourceGroups = new ArrayList<ResourceGroup>(); + while (itr.hasNext()) { + resourceGroups.add(new ResourceGroup(itr.next())); + } } } /** - * @return the serviceConfigurations + * @return the resourceGroups */ - public List<ServiceConfiguration> getServiceConfigurations() { - return serviceConfigurations; + public List<ResourceGroup> getResourceGroups() { + return resourceGroups; + } + + public static final String getType() { + return TYPE_STRING_MATCH; } } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/Tca.java b/src/main/java/org/onap/clamp/clds/model/prop/Tca.java index c7b23608a..b94f52304 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/Tca.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/Tca.java @@ -1,47 +1,88 @@ +/*- + * ============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.model.prop; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.logging.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; /** * Parse Tca json properties. - * - * Example json: {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1",">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value":"Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">","2"]]}]}} - * + * + * Example json: + * {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab", + * "value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value" + * :"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{ + * "name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1", + * ">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value": + * "Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"}, + * {"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name": + * "tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{ + * "serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">" + * ,"2"]]}]}} + * * */ public class Tca extends ModelElement { - - private static final Logger logger = Logger.getLogger(StringMatch.class.getName()); - - private List<TcaItem> tcaItems; - - /** - * Parse Tca given json node - * - * @param modelProp - * @param modelBpmn - * @param modelJson - */ - public Tca(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { - super(ModelElement.TYPE_TCA, modelProp, modelBpmn, modelJson); - - // process Server_Configurations - if(meNode != null){ - Iterator<JsonNode> itr = meNode.elements(); - tcaItems = new ArrayList<TcaItem>(); - while(itr.hasNext()) { - tcaItems.add(new TcaItem(itr.next())); - } - } - } - - public List<TcaItem> getTcaItems() { - return tcaItems; - } + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(Tca.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private List<TcaItem> tcaItems; + + private static final String TYPE_TCA = "tca"; + + /** + * Parse Tca given json node + * + * @param modelProp + * @param modelBpmn + * @param modelJson + */ + public Tca(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) { + super(TYPE_TCA, modelProp, modelBpmn, modelJson); + + // process Server_Configurations + if (meNode != null) { + Iterator<JsonNode> itr = meNode.elements(); + tcaItems = new ArrayList<TcaItem>(); + while (itr.hasNext()) { + tcaItems.add(new TcaItem(itr.next())); + } + } + } + + public List<TcaItem> getTcaItems() { + return tcaItems; + } + + public static final String getType() { + return TYPE_TCA; + } } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java b/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java index 5792c0574..aa1abde17 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/TcaItem.java @@ -1,128 +1,163 @@ +/*- + * ============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.model.prop; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.logging.Logger; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; /** * Parse Tca Item json properties. - * - * Example json: {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1",">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value":"Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">","2"]]}]}} - * + * + * Example json: + * {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab", + * "value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value" + * :"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{ + * "name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1", + * ">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value": + * "Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"}, + * {"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name": + * "tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{ + * "serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">" + * ,"2"]]}]}} + * * */ public class TcaItem { - private static final Logger logger = Logger.getLogger(TcaItem.class.getName()); - - private String tcaName; - private String tcaUuId; - private String nfNamingCode; - private String tcaEnable; - private String policyId; - private Integer interval; - private String severity; - private Integer violations; - private List<TcaThreshhold> tcaThreshholds; - - /** - * Parse Tca Item given json node - * - * @param node - */ - public TcaItem(JsonNode node) { - - tcaName = ModelElement.getValueByName(node, "tname"); - tcaUuId = ModelElement.getValueByName(node, "tuuid"); - nfNamingCode = ModelElement.getValueByName(node, "tnfc"); - tcaEnable = ModelElement.getValueByName(node, "tcaEnab"); - policyId = ModelElement.getValueByName(node, "tcaPolId"); - if(ModelElement.getValueByName(node, "tcaInt") != null){ - interval = Integer.valueOf(ModelElement.getValueByName(node, "tcaInt")); - } - severity = ModelElement.getValueByName(node, "tcaSev"); - if(ModelElement.getValueByName(node, "tcaVio") != null){ - violations = Integer.valueOf(ModelElement.getValueByName(node, "tcaVio")); - } - - // process service Configurations - JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations"); - Iterator<JsonNode> itr = serviceConfigurationsNode.elements(); - tcaThreshholds = new ArrayList<TcaThreshhold>(); - while(itr.hasNext()) { - tcaThreshholds.add(new TcaThreshhold(itr.next())); - } - } - - public String getTcaName() { - return tcaName; - } - - public void setTcaName(String tcaName) { - this.tcaName = tcaName; - } - - public String getTcaUuId() { - return tcaUuId; - } - - public void setTcaUuId(String tcaUuId) { - this.tcaUuId = tcaUuId; - } - - public String getNfNamingCode() { - return nfNamingCode; - } - - public void setNfNamingCode(String nfNamingCode) { - this.nfNamingCode = nfNamingCode; - } - - public String getTcaEnable() { - return tcaEnable; - } - - public void setTcaEnable(String tcaEnable) { - this.tcaEnable = tcaEnable; - } - - public String getPolicyId() { - return policyId; - } - - public void setPolicyId(String policyId) { - this.policyId = policyId; - } - - public Integer getInterval() { - return interval; - } - - public void setInterval(Integer interval) { - this.interval = interval; - } - - public String getSeverity() { - return severity; - } - - public void setSeverity(String severity) { - this.severity = severity; - } - - public Integer getViolations() { - return violations; - } - - public void setViolations(Integer violations) { - this.violations = violations; - } - - public List<TcaThreshhold> getTcaThreshholds() { - return tcaThreshholds; - } - + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaItem.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String tcaName; + private String tcaUuId; + private String nfNamingCode; + private String tcaEnable; + private String policyId; + private Integer interval; + private String severity; + private Integer violations; + private List<TcaThreshhold> tcaThreshholds; + + /** + * Parse Tca Item given json node + * + * @param node + */ + public TcaItem(JsonNode node) { + + tcaName = ModelElement.getValueByName(node, "tname"); + tcaUuId = ModelElement.getValueByName(node, "tuuid"); + nfNamingCode = ModelElement.getValueByName(node, "tnfc"); + tcaEnable = ModelElement.getValueByName(node, "tcaEnab"); + policyId = ModelElement.getValueByName(node, "tcaPolId"); + if (ModelElement.getValueByName(node, "tcaInt") != null) { + interval = Integer.valueOf(ModelElement.getValueByName(node, "tcaInt")); + } + severity = ModelElement.getValueByName(node, "tcaSev"); + if (ModelElement.getValueByName(node, "tcaVio") != null) { + violations = Integer.valueOf(ModelElement.getValueByName(node, "tcaVio")); + } + + // process service Configurations + JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations"); + Iterator<JsonNode> itr = serviceConfigurationsNode.elements(); + tcaThreshholds = new ArrayList<TcaThreshhold>(); + while (itr.hasNext()) { + tcaThreshholds.add(new TcaThreshhold(itr.next())); + } + } + + public String getTcaName() { + return tcaName; + } + + public void setTcaName(String tcaName) { + this.tcaName = tcaName; + } + + public String getTcaUuId() { + return tcaUuId; + } + + public void setTcaUuId(String tcaUuId) { + this.tcaUuId = tcaUuId; + } + + public String getNfNamingCode() { + return nfNamingCode; + } + + public void setNfNamingCode(String nfNamingCode) { + this.nfNamingCode = nfNamingCode; + } + + public String getTcaEnable() { + return tcaEnable; + } + + public void setTcaEnable(String tcaEnable) { + this.tcaEnable = tcaEnable; + } + + public String getPolicyId() { + return policyId; + } + + public void setPolicyId(String policyId) { + this.policyId = policyId; + } + + public Integer getInterval() { + return interval; + } + + public void setInterval(Integer interval) { + this.interval = interval; + } + + public String getSeverity() { + return severity; + } + + public void setSeverity(String severity) { + this.severity = severity; + } + + public Integer getViolations() { + return violations; + } + + public void setViolations(Integer violations) { + this.violations = violations; + } + + public List<TcaThreshhold> getTcaThreshholds() { + return tcaThreshholds; + } + } diff --git a/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshhold.java b/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshhold.java index 47f2c6fd5..39369f171 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshhold.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/TcaThreshhold.java @@ -1,76 +1,110 @@ -package org.onap.clamp.clds.model.prop; +/*- + * ============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. + */ -import java.util.logging.Logger; +package org.onap.clamp.clds.model.prop; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.databind.JsonNode; /** * Parse Tca Threshhold json properties. - * - * Example json: {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1",">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value":"Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"},{"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">","2"]]}]}} - * + * + * Example json: + * {"TCA_0lm6cix":{"Narra":[{"name":"tname","value":"Narra"},{"name":"tcaEnab", + * "value":"on"},{"name":"tcaPol","value":"Polcicy1"},{"name":"tcaPolId","value" + * :"1"},{"name":"tcaInt","value":"1"},{"name":"tcaSev","value":"Critical"},{ + * "name":"tcaVio","value":"1"},{"serviceConfigurations":[["FIELDPATH_test_1", + * ">","4"],["FIELDPATH_test_1","=","5"]]}],"Srini":[{"name":"tname","value": + * "Srini"},{"name":"tcaEnab","value":"on"},{"name":"tcaPol","value":"Policy1"}, + * {"name":"tcaPolId","value":"1"},{"name":"tcaInt","value":"1"},{"name": + * "tcaSev","value":"Major"},{"name":"tcaVio","value":"1"},{ + * "serviceConfigurations":[["FIELDPATH_test_2","=","3"],["FIELDPATH_test_1",">" + * ,"2"]]}]}} + * * */ public class TcaThreshhold { - private static final Logger logger = Logger.getLogger(TcaThreshhold.class.getName()); - - private String metric; - private String fieldPath; - private String operator; - private Integer threshhold; - - /** - * Parse Tca Threshhold given json node - * - * @param node - */ - public TcaThreshhold(JsonNode node) { - - if(node.get(0) != null){ - metric = node.get(0).asText(); - } - if(node.get(1) != null){ - operator = node.get(1).asText(); - } - if(node.get(2) != null){ - threshhold = Integer.valueOf(node.get(2).asText()); - } - if(node.get(3) != null){ - fieldPath = node.get(3).asText(); - } - } - - public String getMetric() { - return metric; - } - - public void setMetric(String metric) { - this.metric = metric; - } - - public String getFieldPath() { - return fieldPath; - } - - public void setFieldPath(String fieldPath) { - this.fieldPath = fieldPath; - } - - public String getOperator() { - return operator; - } - - public void setOperator(String operator) { - this.operator = operator; - } - - public Integer getThreshhold() { - return threshhold; - } - - public void setThreshhold(Integer threshhold) { - this.threshhold = threshhold; - } - + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(TcaThreshhold.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + + private String metric; + private String fieldPath; + private String operator; + private Integer threshhold; + + /** + * Parse Tca Threshhold given json node + * + * @param node + */ + public TcaThreshhold(JsonNode node) { + + if (node.get(0) != null) { + metric = node.get(0).asText(); + } + if (node.get(1) != null) { + operator = node.get(1).asText(); + } + if (node.get(2) != null) { + threshhold = Integer.valueOf(node.get(2).asText()); + } + if (node.get(3) != null) { + fieldPath = node.get(3).asText(); + } + } + + public String getMetric() { + return metric; + } + + public void setMetric(String metric) { + this.metric = metric; + } + + public String getFieldPath() { + return fieldPath; + } + + public void setFieldPath(String fieldPath) { + this.fieldPath = fieldPath; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public Integer getThreshhold() { + return threshhold; + } + + public void setThreshhold(Integer threshhold) { + this.threshhold = threshhold; + } + } |