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.so.asdc.activity;
23 import javax.annotation.PostConstruct;
24 import java.util.ArrayList;
25 import java.util.List;
26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.core.env.Environment;
28 import org.springframework.stereotype.Component;
29 import org.onap.so.asdc.activity.beans.ActivitySpec;
30 import org.onap.so.db.catalog.client.CatalogDbClient;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
35 public class DeployActivitySpecs {
37 private ActivitySpecsActions activitySpecsActions;
40 private Environment env;
42 private static final String SDC_ENDPOINT = "mso.asdc.config.activity.endpoint";
44 protected static final Logger logger = LoggerFactory.getLogger(DeployActivitySpecs.class);
46 public void deployActivities() throws Exception {
47 String hostname = this.env.getProperty(SDC_ENDPOINT);
48 List<ActivitySpec> activitySpecs = new ArrayList<ActivitySpec>();
50 // Initialize activitySpecs from Catalog DB
52 for (ActivitySpec activitySpec : activitySpecs) {
53 String activitySpecId = activitySpecsActions.createActivitySpec(hostname, activitySpec);
54 if (activitySpecId != null) {
55 logger.info("{} {}", "Successfully created activitySpec", activitySpec.getName());
56 boolean certificationResult = activitySpecsActions.certifyActivitySpec(hostname, activitySpecId);
57 if (certificationResult) {
58 logger.info("{} {}", "Successfully certified activitySpec", activitySpec.getName());
60 logger.info("{} {}", "Failed to certify activitySpec", activitySpec.getName());
63 logger.info("{} {}", "Failed to create activitySpec", activitySpec.getName());