2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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.adapters.inventory.create;
23 import java.security.GeneralSecurityException;
25 import javax.annotation.PostConstruct;
27 import org.camunda.bpm.client.ExternalTaskClient;
28 import org.camunda.bpm.client.backoff.ExponentialBackoffStrategy;
29 import org.camunda.bpm.client.interceptor.ClientRequestInterceptor;
30 import org.camunda.bpm.client.interceptor.auth.BasicAuthProvider;
31 import org.onap.so.utils.CryptoUtils;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.context.annotation.Profile;
36 import org.springframework.core.env.Environment;
37 import org.springframework.stereotype.Component;
41 public class CreateInventoryService {
43 private static final Logger logger = LoggerFactory.getLogger(CreateInventoryService.class);
46 public Environment env;
49 private CreateInventoryTask createInventory;
52 public void auditAAIInventory() {
55 auth = CryptoUtils.decrypt(env.getRequiredProperty("mso.auth"), env.getRequiredProperty("mso.msoKey"));
56 } catch (IllegalStateException | GeneralSecurityException e) {
57 logger.error("Error Decrypting Password", e);
59 ClientRequestInterceptor interceptor = new BasicAuthProvider(env.getRequiredProperty("mso.config.cadi.aafId"),
61 ExternalTaskClient client = ExternalTaskClient.create()
62 .baseUrl(env.getRequiredProperty("mso.workflow.endpoint")).maxTasks(1).addInterceptor(interceptor)
63 .asyncResponseTimeout(120000).backoffStrategy(new ExponentialBackoffStrategy(0, 0, 0)).build();
64 client.subscribe("InventoryCreate").lockDuration(60000)
65 .handler(createInventory::executeExternalTask).open();