2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.sdc.generator.aai;
24 import java.io.FileInputStream;
25 import java.io.IOException;
26 import java.util.Collection;
27 import java.util.HashMap;
28 import java.util.HashSet;
29 import java.util.Iterator;
30 import java.util.LinkedList;
31 import java.util.List;
33 import java.util.Objects;
34 import java.util.Properties;
36 import org.onap.sdc.generator.aai.model.AllotedResource;
37 import org.onap.sdc.generator.aai.model.L3NetworkWidget;
38 import org.onap.sdc.generator.aai.model.Model;
39 import org.onap.sdc.generator.aai.model.ProvidingService;
40 import org.onap.sdc.generator.aai.model.Resource;
41 import org.onap.sdc.generator.aai.model.Service;
42 import org.onap.sdc.generator.aai.model.TunnelXconnectWidget;
43 import org.onap.sdc.generator.aai.model.VfModule;
44 import org.onap.sdc.generator.aai.model.Widget;
45 import org.onap.sdc.generator.aai.tosca.GroupDefinition;
46 import org.onap.sdc.generator.aai.tosca.NodeTemplate;
47 import org.onap.sdc.generator.aai.tosca.ToscaTemplate;
48 import org.onap.sdc.generator.aai.types.ModelType;
49 import org.onap.sdc.generator.data.AdditionalParams;
50 import org.onap.sdc.generator.data.Artifact;
51 import org.onap.sdc.generator.data.ArtifactType;
52 import org.onap.sdc.generator.data.GenerationData;
53 import org.onap.sdc.generator.data.GeneratorConstants;
54 import org.onap.sdc.generator.data.GeneratorUtil;
55 import org.onap.sdc.generator.data.GroupType;
56 import org.onap.sdc.generator.data.WidgetConfigurationUtil;
57 import org.onap.sdc.generator.intf.ArtifactGenerator;
58 import org.onap.sdc.generator.intf.Generator;
59 import org.onap.sdc.generator.logging.annotations.Audit;
60 import org.onap.sdc.generator.util.ArtifactGeneratorUtil;
61 import org.openecomp.sdc.logging.api.Logger;
62 import org.openecomp.sdc.logging.api.LoggerFactory;
65 @Generator(artifactType = ArtifactType.AAI)
66 public class AaiArtifactGenerator implements ArtifactGenerator {
68 private static final Logger log = LoggerFactory.getLogger(AaiArtifactGenerator.class.getName());
71 * Implementation of the method to generate AAI artifacts.
73 * @param input List of input tosca files
74 * @return Translated/Error data as a {@link GenerationData} object
78 public GenerationData generateArtifact(List<Artifact> input,
79 Map<String, String> additionalParams) {
81 if (input != null && input.size() != 0 ) {
82 ArtifactGeneratorUtil.initializeArtifactLoggingContext(input.get(0));
84 initWidgetConfiguration();
85 return generateArtifactInternal(input, additionalParams);
86 } catch (Exception exception) {
87 ArtifactGeneratorUtil.logError(exception.getMessage(), exception);
88 GenerationData generationData = new GenerationData();
89 generationData.add(ArtifactType.AAI.name(), exception.getMessage());
90 return generationData;
95 * Helper method to generate AAI artifacts.
97 * @param input List of input tosca files
98 * @return Translated/Error data as a {@link GenerationData} object
100 private GenerationData generateArtifactInternal(List<Artifact> input,
101 Map<String, String> additionalParams) {
102 final GenerationData generationData = new GenerationData();
104 List<Resource> resources = new LinkedList<>();
105 Map<String, String> idTypeStore = new HashMap<>();
106 Map<String, String> resourcesVersion = new HashMap<>();
108 List<ToscaTemplate> toscas = new LinkedList<>();
110 String serviceVersion = additionalParams.get(AdditionalParams.ServiceVersion.getName());
111 if (serviceVersion == null) {
112 throw new IllegalArgumentException(GeneratorConstants
113 .GENERATOR_AAI_ERROR_MISSING_SERVICE_VERSION);
115 String versionRegex = "^[1-9]\\d*(\\.0)$";
116 if (! (serviceVersion.matches(versionRegex))) {
117 throw new IllegalArgumentException(GeneratorConstants
118 .GENERATOR_AAI_INVALID_SERVICE_VERSION);
122 for (Artifact inputArtifact : input) {
123 ToscaTemplate tosca = getToscaModel(inputArtifact, serviceVersion);
124 validateTosca(tosca, inputArtifact);
125 ToscaTemplate processedTosca = preProcessingTosca(tosca);
126 toscas.add(processedTosca);
129 //Get the service tosca from the list of artifacts
130 ToscaTemplate serviceTosca = getServiceTosca(toscas);
131 if (serviceTosca == null) {
132 throw new IllegalArgumentException(GeneratorConstants
133 .GENERATOR_AAI_ERROR_MISSING_SERVICE_TOSCA);
136 Service service = new Service();
137 //Populate basic service model metadata
138 service.populateModelIdentificationInformation(serviceTosca.getMetadata());
140 if (serviceTosca.getTopology_template() != null
141 && serviceTosca.getTopology_template().getNode_templates() != null) {
142 processServiceTosca(service, idTypeStore,resourcesVersion, serviceTosca);
144 validateResourceToscaAgainstService(idTypeStore, toscas);
146 //Process the resource tosca files
147 List<Resource> currentToscaResources = new LinkedList<>();
148 while (toscas.size() > 0) {
149 ToscaTemplate resourceTemplate = toscas.remove(0);
150 String resourceUuId = resourceTemplate.getMetadata().get("UUID");
151 String mapValue = idTypeStore.get(resourceUuId);
152 if (mapValue == null) {
154 "Additional tosca file found with resource version id : "
158 //update resource version with version from service tosca
159 String resourceVersion = resourcesVersion.get(resourceUuId);
160 resourceTemplate.getMetadata().put("version", resourceVersion);
161 Model model = Model.getModelFor(idTypeStore.get(resourceTemplate.getModelVersionId()));
163 log.debug("Inside Resource artifact generation for resource");
164 model.populateModelIdentificationInformation(
165 resourceTemplate.getMetadata()); //Get base resource metadata information
166 //Found model from the type store so removing the same
167 idTypeStore.remove(model.getModelNameVersionId());
168 if (resourceTemplate.getTopology_template() != null
169 && resourceTemplate.getTopology_template().getNode_templates() != null) {
170 processVfTosca(idTypeStore, resourceTemplate, model);
173 //Process group information from tosca for vfModules
174 if (resourceTemplate.getTopology_template() != null
175 && resourceTemplate.getTopology_template().getGroups() != null) {
176 processVfModule(resources, currentToscaResources, resourceTemplate, model);
178 model.getWidgets().clear();
181 if ("Tunnel XConnect".equals(resourceTemplate.getMetadata().get("subcategory"))
182 && "Allotted Resource".equals(resourceTemplate.getMetadata().get("category"))) {
183 model.addWidget(new TunnelXconnectWidget());
186 resources.add((Resource) model);
187 currentToscaResources
188 .clear(); //Clearing the current tosca resource list for the next iteration
191 AaiModelGenerator modelGenerator = AaiModelGenerator.getInstance();
192 //Generate AAI XML service model
193 MDC.put(GeneratorConstants.ARTIFACT_MODEL_INFO , service.getModelName() + "," + getArtifactLabel(service));
194 String aaiServiceModel = modelGenerator.generateModelFor(service);
195 generationData.add(getServiceArtifact(service, aaiServiceModel));
197 //Generate AAI XML resource model
198 for (Resource res : resources) {
199 MDC.put(GeneratorConstants.ARTIFACT_MODEL_INFO , res.getModelName() + "," + getArtifactLabel(res));
200 String aaiResourceModel = modelGenerator.generateModelFor(res);
201 generationData.add(getResourceArtifact(res, aaiResourceModel));
204 //Resetting logging parameters since they get overridden while writing metrics logs
205 // recursively for service, resource and widgets.
206 if (input != null && input.size() != 0 ) {
207 ArtifactGeneratorUtil.initializeArtifactLoggingContext(input.get(0));
210 return generationData;
213 private void validateResourceToscaAgainstService(Map<String, String> idTypeStore,
214 List<ToscaTemplate> toscas) {
215 for (String resourceUuidFromService : idTypeStore.keySet()) {
216 Iterator<ToscaTemplate> itr = toscas.iterator();
217 boolean toscaFound = false;
218 while (itr.hasNext()) {
219 ToscaTemplate toscaTemplate = itr.next();
220 String resourceUuId = toscaTemplate.getMetadata().get("UUID");
221 if (resourceUuidFromService.equals(resourceUuId)) {
227 throw new IllegalArgumentException(
228 String.format(GeneratorConstants.GENERATOR_AAI_ERROR_MISSING_RESOURCE_TOSCA, resourceUuidFromService));
234 private ToscaTemplate preProcessingTosca(ToscaTemplate tosca) {
235 if (tosca.getTopology_template() != null
236 && tosca.getTopology_template().getNode_templates() != null) {
237 Collection<NodeTemplate> coll =
238 tosca.getTopology_template().getNode_templates().values();
239 for (NodeTemplate node : coll) {
241 if (node.getType().contains("org.openecomp.resource.vf.") && node.getMetadata().get("category")
242 .equals("Allotted Resource")) {
243 node.setType("org.openecomp.resource.vf.allottedResource");
245 if (node.getType().contains("org.openecomp.resource.vfc.") && node.getMetadata().get
247 .equals("Allotted Resource")) {
248 node.setType("org.openecomp.resource.vfc.AllottedResource");
255 private void processVfTosca(Map<String, String> idTypeStore, ToscaTemplate resourceTemplate,
257 Set<String> keys = resourceTemplate.getTopology_template().getNode_templates().keySet();
258 boolean flag = false;
259 for (String key : keys) {
260 NodeTemplate node = resourceTemplate.getTopology_template().getNode_templates().get(key);
261 Model resourceNode = Model.getModelFor(node.getType());
262 if (resourceNode != null) {
263 if (resourceNode instanceof ProvidingService) {
265 Map<String, String> properties = new HashMap<>();
266 Map<String, Object> nodeProperties = node.getProperties();
267 if (nodeProperties.get("providing_service_uuid") == null || nodeProperties.get(
268 "providing_service_invariant_uuid") == null) {
269 throw new IllegalArgumentException(String.format(
270 GeneratorConstants.GENERATOR_AAI_PROVIDING_SERVICE_METADATA_MISSING
271 , model.getModelId()));
273 for (String key1 : nodeProperties.keySet()) {
274 if (nodeProperties.get(key1) instanceof String) {
275 properties.put(key1, nodeProperties.get(key1).toString());
278 properties.put("version","1.0");
279 resourceNode.populateModelIdentificationInformation(properties);
280 model.addResource((Resource) resourceNode);
281 } else if (resourceNode instanceof Resource && !(resourceNode.getWidgetType().equals(
284 idTypeStore.put(resourceNode.getModelNameVersionId(), node.getType());
285 model.addResource((Resource) resourceNode);
289 if(model instanceof AllotedResource){
291 throw new IllegalArgumentException(String.format(
292 GeneratorConstants.GENERATOR_AAI_PROVIDING_SERVICE_MISSING,
293 model.getModelId()));
298 /* private void vfWarnScenario(Map<String, String> idTypeStore, ToscaTemplate resourceTemplate) {
299 if (idTypeStore.size() == 0) {
300 //Log message for extra model file
302 "Additional tosca file found with resource version id : "
303 + resourceTemplate.getModelVersionId());
305 //Log message for missing model files.. Replace with logger statement
306 log.warn("Service-Resource Tosca mapping not found for : "
307 + idTypeStore.keySet().toString());
312 private void processVfModule(List<Resource> resources, List<Resource> currentToscaResources,
313 ToscaTemplate resourceTemplate, Model model) {
314 log.debug("Inside Resource artifact generation for group/vfModule");
315 Collection<GroupDefinition> groups =
316 resourceTemplate.getTopology_template().getGroups().values();
317 Set<String> nodeNameListForGroups = new HashSet<>();
318 for (GroupDefinition gd : groups) {
319 Model group = Model.getModelFor(gd.getType());
321 group.populateModelIdentificationInformation(gd.getMetadata());
322 Map<String, String> properties = new HashMap<>();
323 Map<String, Object> groupProperties = gd.getProperties();
324 for (String key : groupProperties.keySet()) {
325 if (groupProperties.get(key) instanceof String) {
326 properties.put(key, groupProperties.get(key).toString());
329 group.populateModelIdentificationInformation(properties);
330 if (group instanceof VfModule && !currentToscaResources.contains(group)) {
331 if (gd.getMembers() != null && !gd.getMembers().isEmpty()) {
332 ((VfModule) group).setMembers(gd.getMembers());
333 nodeNameListForGroups.addAll(gd.getMembers());
334 Set<String> groupMembers = new HashSet<>(gd.getMembers());
336 for (String member : groupMembers) {
338 resourceTemplate.getTopology_template().getNode_templates().get(member);
341 //L3-network inside vf-module to be generated as Widget a special handling.
342 if (node.getType().contains("org.openecomp.resource.vl")) {
343 resourceNode = new L3NetworkWidget();
345 resourceNode = Model.getModelFor(node.getType());
347 if (resourceNode != null) {
348 if (!(resourceNode instanceof Resource)) {
349 Widget widget = (Widget) resourceNode;
350 widget.addKey(member);
351 //Add the widget element encountered
352 // in the resource tosca in the resource model
353 boolean isAdded = group.addWidget(widget);
355 //Add only widgets which are members of vf module and remove others
357 model.addWidget(widget);
365 model.addResource((Resource) group); //Added group (VfModule) to the (VF) model
366 currentToscaResources
367 .add((Resource) group); //Adding the VfModule group to file specific resources
368 //Check if we have already encountered the same VfModule across all the artifacts
369 if (!resources.contains(group)) {
370 resources.add((Resource) group);
376 Iterator<Widget> iter = model.getWidgets().iterator();
377 while (iter.hasNext()) {
378 iter.next().allInstancesUsed(nodeNameListForGroups);
383 private void processServiceTosca(Service service, Map<String, String> idTypeStore,Map<String,
384 String> resourcesVersion,ToscaTemplate serviceTosca) {
385 Collection<NodeTemplate> coll =
386 serviceTosca.getTopology_template().getNode_templates().values();
387 log.debug("Inside Service Tosca ");
388 //Get the resource/widgets in the service according to the node-template types
389 for (NodeTemplate node : coll) {
390 Model model = Model.getModelFor(node.getType());
392 model.populateModelIdentificationInformation(node.getMetadata());
393 if (model instanceof Resource) {
394 String resourceVersion = node.getMetadata().get("version");
395 validateVersion(resourceVersion,model.getModelNameVersionId());
396 //Keeping track of resource types and
397 // their uuid for identification during resource tosca processing
398 idTypeStore.put(model.getModelNameVersionId(), node.getType());
399 resourcesVersion.put(model.getModelNameVersionId(),resourceVersion);
400 service.addResource((Resource) model);
402 service.addWidget((Widget) model);
409 * Create Service artifact model from the AAI xml model string.
411 * @param serviceModel Model of the service artifact
412 * @param aaiServiceModel AAI model as string
413 * @return Generated {@link Artifact} model for the service
415 private Artifact getServiceArtifact(Model serviceModel, String aaiServiceModel) {
416 return getArtifactForModel(serviceModel, aaiServiceModel);
419 private Artifact getArtifactForModel(Model serviceModel, String aaiServiceModel) {
421 new Artifact(ArtifactType.MODEL_INVENTORY_PROFILE.name(), GroupType.DEPLOYMENT.name(),
422 GeneratorUtil.checkSum(aaiServiceModel.getBytes()),
423 GeneratorUtil.encode(aaiServiceModel.getBytes()));
424 String serviceArtifactName = getArtifactName(serviceModel);
425 String serviceArtifactLabel = getArtifactLabel(serviceModel);
426 artifact.setName(serviceArtifactName);
427 artifact.setLabel(serviceArtifactLabel);
428 String description = getArtifactDescription(serviceModel);
429 artifact.setDescription(description);
434 * Create Resource artifact model from the AAI xml model string.
436 * @param resourceModel Model of the resource artifact
437 * @param aaiResourceModel AAI model as string
438 * @return Generated {@link Artifact} model for the resource
440 private Artifact getResourceArtifact(Model resourceModel, String aaiResourceModel) {
441 return getArtifactForModel(resourceModel, aaiResourceModel);
445 * Method to generate the artifact name for an AAI model.
447 * @param model AAI artifact model
448 * @return Model artifact name
450 private String getArtifactName(Model model) {
451 StringBuilder artifactName = new StringBuilder(ArtifactType.AAI.name());
452 artifactName.append("-");
454 String truncatedArtifactName = truncateName(model.getModelName());
455 artifactName.append(truncatedArtifactName);
457 artifactName.append("-");
458 artifactName.append(model.getModelType().name().toLowerCase());
459 artifactName.append("-");
460 artifactName.append(model.getModelVersion());
461 artifactName.append(".");
462 artifactName.append(GeneratorConstants.GENERATOR_AAI_GENERATED_ARTIFACT_EXTENSION);
463 return artifactName.toString();
466 private String getArtifactLabel(Model model) {
467 StringBuilder artifactName = new StringBuilder(ArtifactType.AAI.name());
468 artifactName.append("-");
469 artifactName.append(model.getModelType().name().toLowerCase());
470 artifactName.append("-");
471 artifactName.append(hashCodeUuId(model.getModelNameVersionId()));
472 return (artifactName.toString()).replaceAll("[^a-zA-Z0-9 +]+", "-");
475 private int hashCodeUuId(String uuId) {
477 for (int i = 0; i < uuId.length(); i++) {
478 hashcode = 31 * hashcode + uuId.charAt(i);
484 private String truncateName(String name) {
485 String truncatedName = name;
486 if (name.length() >= 200) {
487 truncatedName = name.substring(0, 199);
489 return truncatedName;
492 private String getArtifactDescription(Model model) {
493 String artifactDesc = model.getModelDescription();
494 if (model.getModelType().equals(ModelType.SERVICE)) {
495 artifactDesc = "AAI Service Model";
496 } else if (model.getModelType().equals(ModelType.RESOURCE)) {
497 artifactDesc = "AAI Resource Model";
502 private void validateVersion(String version, String uuId) {
503 String versionRegex = "^[0-9]\\d*(\\.\\d+)$";
504 if (null == version || Objects.equals(version, "")) {
505 throw new IllegalArgumentException(String
506 .format(GeneratorConstants.GENERATOR_AAI_ERROR_NULL_RESOURCE_VERSION_IN_SERVICE_TOSCA,
508 } else if ( version.equals("0.0") || !(version.matches(versionRegex))) {
509 throw new IllegalArgumentException(String
510 .format(GeneratorConstants.GENERATOR_AAI_ERROR_INVALID_RESOURCE_VERSION_IN_SERVICE_TOSCA,
515 * Get the tosca java model from the tosca input artifact.
517 * @param input Input tosca file and its metadata information as {@link Artifact} object
518 * @return Translated {@link ToscaTemplate tosca} object
521 private ToscaTemplate getToscaModel(Artifact input, String serviceVersion)
522 throws SecurityException {
523 byte[] decodedInput = GeneratorUtil.decoder(input.getPayload());
524 String checksum = GeneratorUtil.checkSum(decodedInput);
526 if (checksum.equalsIgnoreCase(input.getChecksum())) {
528 log.debug("Input yaml name " + input.getName() + "payload " + new String(decodedInput));
529 tosca = GeneratorUtil.translateTosca(new String(decodedInput), ToscaTemplate.class);
530 tosca.getMetadata().put("version", serviceVersion);
532 } catch (Exception exception) {
533 throw new IllegalArgumentException(
534 String.format(GeneratorConstants.GENERATOR_AAI_ERROR_INVALID_TOSCA, input.getName()), exception);
537 throw new SecurityException(GeneratorConstants.GENERATOR_AAI_ERROR_CHECKSUM_MISMATCH);
541 private void validateTosca(ToscaTemplate tosca, Artifact input) {
542 log.debug("Validating tosca for Artifact: " + input.getName());
543 if (tosca.getMetadata().containsKey("invariantUUID")) {
544 if (tosca.getMetadata().get("invariantUUID") == null
545 || Objects.equals(tosca.getMetadata().get("invariantUUID"), "")) {
546 throw new IllegalArgumentException(String
547 .format(GeneratorConstants.GENERATOR_AAI_ERROR_MANDATORY_METADATA_DEFINITION,
550 } else if (tosca.getMetadata().get("invariantUUID").length() != GeneratorConstants.ID_LENGTH) {
551 throw new IllegalArgumentException(String.format(
552 GeneratorConstants.GENERATOR_AAI_ERROR_INVALID_ID, "invariantUUID", input.getName()));
556 if (tosca.getMetadata().containsKey("UUID")) {
557 if (tosca.getMetadata().get("UUID") == null || Objects.equals(tosca.getMetadata().get("UUID"), "")) {
558 throw new IllegalArgumentException(String
559 .format(GeneratorConstants.GENERATOR_AAI_ERROR_MANDATORY_METADATA_DEFINITION, "UUID",
561 } else if (tosca.getMetadata().get("UUID").length() != GeneratorConstants.ID_LENGTH) {
562 throw new IllegalArgumentException(String
563 .format(GeneratorConstants.GENERATOR_AAI_ERROR_INVALID_ID, "UUID", input.getName()));
567 if (tosca.getMetadata().containsKey("name")) {
568 if (tosca.getMetadata().get("name") == null || Objects.equals(tosca.getMetadata().get("name"), "")) {
569 throw new IllegalArgumentException(String
570 .format(GeneratorConstants.GENERATOR_AAI_ERROR_MANDATORY_METADATA_DEFINITION, "name",
575 if (tosca.getTopology_template() != null && tosca.getTopology_template().getGroups() != null) {
576 validateVfModule(tosca, input);
580 private void validateVfModule(ToscaTemplate tosca, Artifact input) {
582 Collection<GroupDefinition> groups = tosca.getTopology_template().getGroups().values();
583 for (GroupDefinition gd : groups) {
584 Model group = Model.getModelFor(gd.getType());
585 if (group instanceof VfModule) {
586 if (gd.getMetadata().containsKey("vfModuleModelName")
587 && gd.getMetadata().get("vfModuleModelName") == null) {
588 throw new IllegalArgumentException(String
589 .format(GeneratorConstants.GENERATOR_AAI_ERROR_MANDATORY_METADATA_DEFINITION,
593 if (gd.getMetadata().containsKey("vfModuleModelInvariantUUID")
594 && gd.getMetadata().get("vfModuleModelInvariantUUID") == null) {
595 throw new IllegalArgumentException(String
596 .format(GeneratorConstants.GENERATOR_AAI_ERROR_MANDATORY_METADATA_DEFINITION,
597 "vfModuleModelInvariantUUID", input.getName()));
598 } else if (gd.getMetadata().get("vfModuleModelInvariantUUID").length() != GeneratorConstants.ID_LENGTH) {
599 throw new IllegalArgumentException(String.format(
600 GeneratorConstants.GENERATOR_AAI_ERROR_INVALID_ID, "vfModuleModelInvariantUUID",
604 if (gd.getMetadata().containsKey("vfModuleModelUUID")
605 && gd.getMetadata().get("vfModuleModelUUID") == null) {
606 throw new IllegalArgumentException(String
607 .format(GeneratorConstants.GENERATOR_AAI_ERROR_MANDATORY_METADATA_DEFINITION,
610 } else if (gd.getMetadata().get("vfModuleModelUUID").length() != GeneratorConstants.ID_LENGTH) {
611 throw new IllegalArgumentException(String.format(
612 GeneratorConstants.GENERATOR_AAI_ERROR_INVALID_ID, "vfModuleModelUUID",
615 if (gd.getMetadata().containsKey("vfModuleModelVersion")
616 && gd.getMetadata().get("vfModuleModelVersion") == null) {
617 throw new IllegalArgumentException(String
618 .format(GeneratorConstants.GENERATOR_AAI_ERROR_MANDATORY_METADATA_DEFINITION,
619 "vfModuleModelVersion",
627 * Identify the service tosca artifact from the list of translated tosca inputs.
629 * @param input List of translated {@link ToscaTemplate tosca} object models
630 * @return Identified service {@link ToscaTemplate tosca}
632 private ToscaTemplate getServiceTosca(List<ToscaTemplate> input) {
633 Iterator<ToscaTemplate> iter = input.iterator();
634 while (iter.hasNext()) {
635 ToscaTemplate tosca = iter.next();
636 if (tosca.isService()) {
644 private void initWidgetConfiguration() throws IOException {
645 log.debug("Getting Widget Configuration");
646 String configLocation = System.getProperty("artifactgenerator.config");
647 Properties properties;
648 if (configLocation != null) {
649 File file = new File(configLocation);
651 properties = new Properties();
652 properties.load(new FileInputStream(file));
653 WidgetConfigurationUtil.setConfig(properties);
655 throw new IllegalArgumentException(String.format(
656 GeneratorConstants.GENERATOR_AAI_CONFIGFILE_NOT_FOUND,
660 throw new IllegalArgumentException(GeneratorConstants.GENERATOR_AAI_CONFIGLOCATION_NOT_FOUND);