1 package org.onap.sdc.dcae.composition.controller;
3 import com.google.gson.JsonParseException;
4 import org.apache.commons.collections.ListUtils;
5 import org.apache.commons.collections.MapUtils;
6 import org.apache.commons.lang3.StringUtils;
7 import org.onap.sdc.common.onaplog.Enums.LogLevel;
8 import org.onap.sdc.dcae.composition.restmodels.sdc.Artifact;
9 import org.onap.sdc.dcae.composition.restmodels.sdc.Asset;
10 import org.onap.sdc.dcae.composition.restmodels.sdc.ResourceDetailed;
11 import org.onap.sdc.dcae.composition.CompositionConfig;
12 import org.onap.sdc.dcae.utils.Normalizers;
13 import org.onap.sdc.dcae.composition.restmodels.ruleeditor.*;
14 import org.onap.sdc.dcae.composition.util.DcaeBeConstants;
15 import org.onap.sdc.dcae.enums.ArtifactType;
16 import org.onap.sdc.dcae.enums.AssetType;
17 import org.onap.sdc.dcae.errormng.ActionStatus;
18 import org.onap.sdc.dcae.errormng.ErrConfMgr;
19 import org.onap.sdc.dcae.errormng.ErrConfMgr.ApiType;
20 import org.onap.sdc.dcae.errormng.ServiceException;
21 import org.onap.sdc.dcae.rule.editor.impl.RulesBusinessLogic;
22 import org.onap.sdc.dcae.rule.editor.utils.RulesPayloadUtils;
23 import org.onap.sdc.dcae.utils.SdcRestClientUtils;
24 import org.onap.sdc.dcae.ves.VesDataItemsDefinition;
25 import org.onap.sdc.dcae.ves.VesDataTypeDefinition;
26 import org.onap.sdc.dcae.ves.VesSimpleTypesEnum;
27 import org.onap.sdc.dcae.ves.VesStructureLoader;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
30 import org.springframework.http.HttpStatus;
31 import org.springframework.http.ResponseEntity;
32 import org.springframework.util.Base64Utils;
33 import org.springframework.util.CollectionUtils;
34 import org.springframework.web.bind.annotation.*;
37 import java.util.Map.Entry;
38 import java.util.stream.Collectors;
39 import java.util.stream.Stream;
42 @EnableAutoConfiguration
44 @RequestMapping("/rule-editor")
45 public class RuleEditorController extends BaseController {
47 private static final String EXCEPTION = "Exception {}";
49 private CompositionConfig compositionConfig;
52 private RulesBusinessLogic rulesBusinessLogic;
54 @RequestMapping(value = "/list-events-by-versions", method = RequestMethod.GET)
55 public ResponseEntity getEventsByVersion() {
58 Map<String, Set<String>> eventsByVersions = VesStructureLoader.getAvailableVersionsAndEventTypes();
60 List<EventTypesByVersionUI> resBody = eventsByVersions.entrySet().stream().map(entry -> {
61 Set<String> events = entry.getValue().stream().filter(event -> !EventTypesByVersionUI.DEFAULT_EVENTS.contains(event)).collect(Collectors.toSet());
62 return new EventTypesByVersionUI(entry.getKey(), events);
63 }).collect(Collectors.toList());
65 debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Got a request to return all ves event types by versions {}", eventsByVersions);
66 return new ResponseEntity<>(resBody, HttpStatus.OK);
68 } catch (Exception e) {
69 errLogger.log(LogLevel.ERROR, this.getClass().getName(), EXCEPTION, e);
70 return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.VES_SCHEMA_NOT_FOUND);
74 @RequestMapping(value = { "/definition/{version:.*}/{eventType}" }, method = { RequestMethod.GET }, produces = { "application/json" })
75 public ResponseEntity getDefinition(@PathVariable("version") String version,
76 @PathVariable("eventType") String eventType) {
79 List<EventTypeDefinitionUI> result = getEventTypeDefinitionUIs(version, eventType);
81 return new ResponseEntity<>(result, HttpStatus.OK);
83 } catch (Exception e) {
84 errLogger.log(LogLevel.ERROR, this.getClass().getName(), EXCEPTION, e);
85 return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.VES_SCHEMA_NOT_FOUND);
90 * This endpoint functions as a 'create/update' service for the rule editor UI
92 * @param json - json representing the saved rule
93 * @param vfcmtUuid - VFCMT that the rule editor ui is saved in
94 * @param dcaeCompLabel - the name of the DCAE Component which the rule is applied to
95 * @param nid - A unique id of the DCAE Component which the rule is applied to - exists also in the cdump
96 * @param configParam - the name of the DCAE Component configuration property the rule is linked to
97 * @return json representing the rule editor UI
99 * 1. That the user is able to edit the VFCMT
100 * 2. That the cdump holds a dcae component with such nid (to avoid orphan rules)
101 * 3. Check that the fetched VFCMT is actually a VFCMT and not a regular VF
103 @RequestMapping(value = "/rule/{vfcmtUuid}/{dcaeCompLabel}/{nid}/{configParam}", method = { RequestMethod.POST }, produces = "application/json")
104 public ResponseEntity saveRule(@RequestBody String json, @ModelAttribute("requestId") String requestId,
105 @RequestHeader("USER_ID") String userId,
106 @PathVariable("vfcmtUuid") String vfcmtUuid,
107 @PathVariable("dcaeCompLabel") String dcaeCompLabel,
108 @PathVariable("nid") String nid,
109 @PathVariable("configParam") String configParam) {
111 Rule rule = RulesPayloadUtils.parsePayloadToRule(json);
113 return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.INVALID_RULE_FORMAT);
116 List<ServiceException> errors = rulesBusinessLogic.validateRule(rule);
117 if(!errors.isEmpty()){
118 return ErrConfMgr.INSTANCE.buildErrorArrayResponse(errors);
121 ResourceDetailed vfcmt = baseBusinessLogic.getSdcRestClient().getResource(vfcmtUuid, requestId);
122 checkVfcmtType(vfcmt);
124 if (CollectionUtils.isEmpty(vfcmt.getArtifacts())) {
125 return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.SAVE_RULE_FAILED);
128 String artifactLabel = Normalizers.normalizeArtifactLabel(dcaeCompLabel + nid + configParam);
130 // check for MappingRules artifact in existing artifacts
131 Artifact artifactFound = vfcmt.getArtifacts().stream()
132 .filter(a -> artifactLabel.equals(Normalizers.normalizeArtifactLabel(a.getArtifactLabel())))
133 .findAny().orElse(null);
135 // exception thrown if vfcmt is checked out and current user is not its owner
136 // performs vfcmt checkout if required
137 String vfcmtId = assertOwnershipOfVfcmtId(userId, vfcmt, requestId);
138 // new mappingRules artifact, validate nid exists in composition before creating new artifact
139 if (null == artifactFound) {
140 if(cdumpContainsNid(vfcmt, nid, requestId)) {
141 return saveNewRulesArtifact(rule, vfcmtId, generateMappingRulesFileName(dcaeCompLabel, nid, configParam), artifactLabel , userId, requestId);
143 return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.NODE_NOT_FOUND, "", dcaeCompLabel);
146 //update artifact flow - append new rule or edit existing rule
147 return addOrEditRuleInArtifact(rule, vfcmtId, userId, artifactFound, requestId);
149 } catch (JsonParseException je) {
150 errLogger.log(LogLevel.ERROR, this.getClass().getName(), "Error: Rule format is invalid: {}", je);
151 return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.INVALID_RULE_FORMAT, "", je.getMessage());
152 } catch (Exception e) {
153 return handleException(e, ErrConfMgr.ApiType.SAVE_RULE_ARTIFACT);
160 * This endpoint functions as a 'fetch' service for the rule editor UI
162 * @param vfcmtUuid - VFCMT that the rule editor ui is saved in
163 * @param dcaeCompLabel - the name of the DCAE Component which the rule is applied to
164 * @param nid - A unique id of the DCAE Component which the rule is applied to - exists also in the cdump
165 * @param configParam - the name of the DCAE Component configuration property the rule is linked to
166 * @return json representing the rule editor UI
168 @RequestMapping(value = "/rule/{vfcmtUuid}/{dcaeCompLabel}/{nid}/{configParam}", method = { RequestMethod.GET }, produces = "application/json")
169 public ResponseEntity getRules(
170 @PathVariable("vfcmtUuid") String vfcmtUuid,
171 @PathVariable("dcaeCompLabel") String dcaeCompLabel,
172 @PathVariable("nid") String nid,
173 @PathVariable("configParam") String configParam,
174 @ModelAttribute("requestId") String requestId) {
177 ResourceDetailed vfcmt = baseBusinessLogic.getSdcRestClient().getResource(vfcmtUuid, requestId);
178 if (CollectionUtils.isEmpty(vfcmt.getArtifacts())) {
179 return new ResponseEntity<>("{}", HttpStatus.OK);
181 String artifactLabel = Normalizers.normalizeArtifactLabel(dcaeCompLabel + nid + configParam);
183 // check for MappingRules artifact in existing artifacts
184 Artifact artifactListed = vfcmt.getArtifacts().stream().filter(a -> artifactLabel.equals(Normalizers.normalizeArtifactLabel(a.getArtifactLabel()))).findAny().orElse(null);
185 if (null == artifactListed) {
186 return new ResponseEntity<>("{}", HttpStatus.OK);
188 String ruleFile = baseBusinessLogic.getSdcRestClient().getResourceArtifact(vfcmtUuid, artifactListed.getArtifactUUID(), requestId);
190 // To avoid opening the file for reading we search for the eventType and SchemaVer from the artifact metadata's description
191 SchemaInfo schemainfo = RulesPayloadUtils.extractInfoFromDescription(artifactListed);
192 List<EventTypeDefinitionUI> schema = null == schemainfo? new ArrayList<>() : getEventTypeDefinitionUIs(schemainfo.getVersion(), schemainfo.getEventType());
193 return new ResponseEntity<>(RulesPayloadUtils.buildSchemaAndRulesResponse(ruleFile, schema), HttpStatus.OK);
194 } catch (Exception e) {
195 return handleException(e, ApiType.GET_RULE_ARTIFACT);
201 * This endpoint functions as a 'delete' service for the rule editor UI
203 * @param vfcmtUuid - VFCMT that the rule editor ui is saved in
204 * @param dcaeCompLabel - the name of the DCAE Component which the rule is applied to
205 * @param nid - A unique id of the DCAE Component which the rule is applied to - exists also in the cdump
206 * @param configParam - the name of the DCAE Component configuration property the rule is linked to
207 * @param ruleUid - the unique id of the rule to delete
208 * @return operation result
210 @RequestMapping(value = "/rule/{vfcmtUuid}/{dcaeCompLabel}/{nid}/{configParam}/{ruleUid}", method = { RequestMethod.DELETE }, produces = "application/json")
211 public ResponseEntity deleteRule(
212 @RequestHeader("USER_ID") String userId,
213 @PathVariable("vfcmtUuid") String vfcmtUuid,
214 @PathVariable("dcaeCompLabel") String dcaeCompLabel,
215 @PathVariable("nid") String nid,
216 @PathVariable("configParam") String configParam,
217 @PathVariable("ruleUid") String ruleUid,
218 @ModelAttribute("requestId") String requestId){
221 ResourceDetailed vfcmt = baseBusinessLogic.getSdcRestClient().getResource(vfcmtUuid, requestId);
222 if (null == vfcmt.getArtifacts()) {
223 errLogger.log(LogLevel.ERROR, this.getClass().getName(), "VFCMT {} doesn't have artifacts", vfcmtUuid);
224 return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.DELETE_RULE_FAILED);
226 String artifactLabel = Normalizers.normalizeArtifactLabel(dcaeCompLabel + nid + configParam);
228 // check for MappingRules artifact in existing artifacts
229 Artifact mappingRuleFile = vfcmt.getArtifacts().stream()
230 .filter(a -> artifactLabel.equals(Normalizers.normalizeArtifactLabel(a.getArtifactLabel())))
231 .findAny().orElse(null);
233 if (null == mappingRuleFile) {
234 errLogger.log(LogLevel.ERROR, this.getClass().getName(), "{} doesn't exist for VFCMT {}", artifactLabel, vfcmtUuid);
235 return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.DELETE_RULE_FAILED);
238 String vfcmtId = assertOwnershipOfVfcmtId(userId, vfcmt, requestId);
239 String payload = baseBusinessLogic.getSdcRestClient().getResourceArtifact(vfcmtId, mappingRuleFile.getArtifactUUID(), requestId);
240 MappingRules rules = RulesPayloadUtils.parseMappingRulesArtifactPayload(payload);
241 Rule removedRule = rulesBusinessLogic.deleteRule(rules, ruleUid);
242 if(null == removedRule){
243 errLogger.log(LogLevel.ERROR, this.getClass().getName(), "Rule {} not found.", ruleUid);
244 return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.DELETE_RULE_FAILED);
246 if(rules.isEmpty()){ // if file doesn't contain any rules after last deletion -> let's delete the file
247 baseBusinessLogic.getSdcRestClient().deleteResourceArtifact(userId, vfcmtId, mappingRuleFile.getArtifactUUID(), requestId);
249 updateRulesArtifact(vfcmtId, userId, mappingRuleFile, rules, requestId);
251 return checkInAndReturnSaveArtifactResult(removedRule, vfcmtId, userId, requestId);
252 } catch (Exception e) {
253 return handleException(e, ApiType.SAVE_RULE_ARTIFACT);
259 * This endpoint functions as a 'translate' service for the rule editor UI
261 * @param vfcmtUuid - VFCMT that the rule editor ui is saved in
262 * @param dcaeCompLabel - the name of the DCAE Component which the rule is applied to
263 * @param nid - A unique id of the DCAE Component which the rule is applied to - exists also in the cdump
264 * @param configParam - the name of the DCAE Component configuration property the rule is linked to
265 * @param flowType - the mapping rules flow type (SNMP,Syslog,FOI)
266 * @return translateJson representing the translated Rules
268 * 1. That the user is able to edit the VFCMT
269 * 2. That the cdump holds a dcae component with such nid (to avoid orphan rules)
270 * 3. Check that the fetched VFCMT is actually a VFCMT and not a regular VF
273 @RequestMapping(value = "/rule/translate/{vfcmtUuid}/{dcaeCompLabel}/{nid}/{configParam}", method = { RequestMethod.GET }, produces = "application/json")
274 public ResponseEntity translateRules(@PathVariable("vfcmtUuid") String vfcmtUuid, @ModelAttribute("requestId") String requestId,
275 @PathVariable("dcaeCompLabel") String dcaeCompLabel,
276 @PathVariable("nid") String nid,
277 @PathVariable("configParam") String configParam,
278 @RequestParam("flowType") String flowType) throws Exception {
282 if (StringUtils.isBlank(flowType) || MapUtils.isEmpty(compositionConfig.getFlowTypesMap()) || null == compositionConfig.getFlowTypesMap().get(flowType)) {
283 return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.TRANSLATE_FAILED, "", "Flow type " + flowType + " not found");
286 // extract entry phase name and last phase name from configuration:
287 String entryPointPhaseName = compositionConfig.getFlowTypesMap().get(flowType).getEntryPointPhaseName();
288 String lastPhaseName = compositionConfig.getFlowTypesMap().get(flowType).getLastPhaseName();
290 ResourceDetailed vfcmt = baseBusinessLogic.getSdcRestClient().getResource(vfcmtUuid, requestId);
291 checkVfcmtType(vfcmt);
293 if (CollectionUtils.isEmpty(vfcmt.getArtifacts())) {
294 return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.TRANSLATE_FAILED, "", "No rules found on VFCMT " + vfcmtUuid);
296 String artifactLabel = Normalizers.normalizeArtifactLabel(dcaeCompLabel + nid + configParam);
298 // check for MappingRules artifact in existing artifacts
299 Artifact rulesArtifact = vfcmt.getArtifacts().stream().filter(a -> artifactLabel.equals(Normalizers.normalizeArtifactLabel(a.getArtifactLabel()))).findAny().orElse(null);
301 if (rulesArtifact == null) {
302 return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.TRANSLATE_FAILED, "", artifactLabel + " doesn't exist on VFCMT " + vfcmtUuid);
305 String payload = baseBusinessLogic.getSdcRestClient().getResourceArtifact(vfcmtUuid, rulesArtifact.getArtifactUUID(), requestId);
306 debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Retrieved mapping rules artifact {}, start parsing rules...", artifactLabel);
307 MappingRules rules = RulesPayloadUtils.parseMappingRulesArtifactPayload(payload);
308 debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Finished parsing rules, calling validator...");
309 List<ServiceException> errors = rulesBusinessLogic.validateRules(rules);
310 if (!errors.isEmpty()) {
311 return ErrConfMgr.INSTANCE.buildErrorArrayResponse(errors);
314 debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Validation completed successfully, calling translator...");
315 String translateJson = rulesBusinessLogic.translateRules(rules, entryPointPhaseName, lastPhaseName, vfcmt.getName());
316 debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Translation completed successfully");
317 return new ResponseEntity<>(translateJson, HttpStatus.OK);
318 } catch (Exception e) {
319 return handleException(e, ApiType.SAVE_RULE_ARTIFACT);
324 ///////////////////PRIVATE METHODS////////////////////////////////////////////////////////////////////////
326 private String assertOwnershipOfVfcmtId(String userId, ResourceDetailed vfcmt, String requestId) throws Exception {
327 checkUserIfResourceCheckedOut(userId, vfcmt);
328 String newVfcmtId = vfcmt.getUuid(); // may change after checking out a certified vfcmt
329 if (isNeedToCheckOut(vfcmt.getLifecycleState())) {
330 Asset result = checkout(userId, newVfcmtId, AssetType.RESOURCE, requestId);
331 if (result != null) {
332 newVfcmtId = result.getUuid();
333 debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "New resource after checkout is: {}", newVfcmtId);
341 // called after validating vfcmt.getArtifacts() is not null
342 private boolean cdumpContainsNid(ResourceDetailed vfcmt, String nid, String requestId) {
343 Artifact cdump = vfcmt.getArtifacts().stream()
344 .filter(a -> DcaeBeConstants.Composition.fileNames.COMPOSITION_YML.equalsIgnoreCase(a.getArtifactName()))
345 .findAny().orElse(null);
346 if (null == cdump || null == cdump.getArtifactUUID()) {
347 errLogger.log(LogLevel.ERROR, this.getClass().getName(), "No {} found on vfcmt {}", DcaeBeConstants.Composition.fileNames.COMPOSITION_YML, vfcmt.getUuid());
351 String artifact = baseBusinessLogic.getSdcRestClient().getResourceArtifact(vfcmt.getUuid(), cdump.getArtifactUUID(), requestId);
352 if (!artifact.contains("\"nid\":\""+nid)) {
353 errLogger.log(LogLevel.ERROR, this.getClass().getName(), "{} doesn't contain nid {}. Cannot save mapping rule file", DcaeBeConstants.Composition.fileNames.COMPOSITION_YML, nid);
356 } catch (Exception e) {
357 errLogger.log(LogLevel.ERROR, this.getClass().getName(), EXCEPTION, e);
363 private ResponseEntity<String> saveNewRulesArtifact(Rule rule, String vfcmtUuid, String artifactFileName, String artifactLabel, String userId, String requestId) throws Exception {
364 MappingRules body = new MappingRules(rule);
365 Artifact artifact = SdcRestClientUtils.generateDeploymentArtifact(body.describe(), artifactFileName, ArtifactType.OTHER.name(), artifactLabel, body.convertToPayload());
366 baseBusinessLogic.getSdcRestClient().createResourceArtifact(userId, vfcmtUuid, artifact, requestId);
367 return checkInAndReturnSaveArtifactResult(rule, vfcmtUuid, userId, requestId);
370 private ResponseEntity addOrEditRuleInArtifact(Rule rule, String vfcmtUuid, String userId, Artifact rulesArtifact, String requestId) throws Exception {
371 String payload = baseBusinessLogic.getSdcRestClient().getResourceArtifact(vfcmtUuid, rulesArtifact.getArtifactUUID(), requestId);
372 MappingRules rules = RulesPayloadUtils.parseMappingRulesArtifactPayload(payload);
374 // in case the rule id is passed but the rule doesn't exist on the mapping rule file:
375 if(!rulesBusinessLogic.addOrEditRule(rules, rule)) {
376 return ErrConfMgr.INSTANCE.buildErrorResponse(ActionStatus.SAVE_RULE_FAILED);
378 updateRulesArtifact(vfcmtUuid, userId, rulesArtifact, rules, requestId);
379 return checkInAndReturnSaveArtifactResult(rule, vfcmtUuid, userId, requestId);
382 // regardless of check in result, return save artifact success
383 private ResponseEntity<String> checkInAndReturnSaveArtifactResult(Rule rule, String vfcmtUuid, String userId, String requestId) {
385 checkin(userId, vfcmtUuid, AssetType.RESOURCE, requestId);
386 } catch (Exception e) {
387 // swallowing the exception intentionally since it is on the check in action
388 errLogger.log(LogLevel.ERROR, this.getClass().getName(), "Error occurred while performing check in on VFCMT {}:{}", vfcmtUuid, e);
390 return new ResponseEntity<>(rule.toJson(), HttpStatus.OK);
393 private void updateRulesArtifact(String vfcmtUuid, String userId, Artifact artifactInfo, MappingRules rules, String requestId) throws Exception {
394 artifactInfo.setPayloadData(Base64Utils.encodeToString(rules.convertToPayload()));
395 // POST must contain 'description' while GET returns 'artifactDescription'
396 artifactInfo.setDescription(artifactInfo.getArtifactDescription());
397 baseBusinessLogic.getSdcRestClient().updateResourceArtifact(userId, vfcmtUuid, artifactInfo, requestId);
402 * @param eventMapStream
407 private List<EventTypeDefinitionUI> convertToEventTypeDefinition(Stream<Entry<String, VesDataTypeDefinition>> eventMapStream, VesDataTypeDefinition parent, String path) {
409 return eventMapStream.map(entry -> {
410 Map<String, VesDataTypeDefinition> properties = entry.getValue().getProperties();
411 VesDataItemsDefinition items = entry.getValue().getItems();
412 String newPath = path + "." + entry.getKey();
413 List<EventTypeDefinitionUI> children = (properties == null) ? null : convertToEventTypeDefinition(properties.entrySet().stream(), entry.getValue(), newPath);
414 if(VesSimpleTypesEnum.ARRAY.getType().equals(entry.getValue().getType())) {
416 if(innerTypeIsComplex(items)) {
417 children = convertComplexArrayType(items, newPath);
418 } else if(innerTypeIsArray(items)) {
423 boolean isRequired = (parent != null) ? parent.getRequired().contains(entry.getKey()) : false;
424 return new EventTypeDefinitionUI(entry.getKey(), children, isRequired, newPath);
425 }).collect(Collectors.toList());
428 private boolean innerTypeIsComplex(VesDataItemsDefinition items){
429 return items != null && items.stream().anyMatch(p -> p.getProperties() != null);
432 private boolean innerTypeIsArray(VesDataItemsDefinition items){
433 return items != null && items.stream().anyMatch(p -> p.getItems() != null);
436 private List<EventTypeDefinitionUI> convertComplexArrayType(VesDataItemsDefinition items, String path){
437 return items.stream().map(item -> item.getProperties() != null ? convertToEventTypeDefinition(item.getProperties().entrySet().stream(), item, path) : new ArrayList<EventTypeDefinitionUI>())
438 .flatMap(List::stream).collect(Collectors.toList());
442 private String generateMappingRulesFileName(String dcaeCompLabel, String nid, String configParam) {
443 return dcaeCompLabel + "_" + nid + "_" + configParam + DcaeBeConstants.Composition.fileNames.MAPPING_RULE_POSTFIX;
446 private List<EventTypeDefinitionUI> getEventTypeDefinitionUIs(String version, String eventType) {
447 List<String> eventNamesToReturn = ListUtils.union(EventTypesByVersionUI.DEFAULT_EVENTS, Arrays.asList(eventType));
448 Map<String, VesDataTypeDefinition> eventDefs = VesStructureLoader.getEventListenerDefinitionByVersion(version);
449 Stream<Entry<String, VesDataTypeDefinition>> filteredEvents = eventDefs.entrySet().stream().filter(entry -> eventNamesToReturn.contains(entry.getKey()));
451 return convertToEventTypeDefinition(filteredEvents, null, "event");