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.client.orchestration;
23 import java.util.ArrayList;
24 import java.util.List;
26 import org.onap.namingservice.model.Element;
27 import org.onap.namingservice.model.Deleteelement;
28 import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
29 import org.onap.so.client.exception.BadResponseException;
30 import org.onap.so.client.namingservice.NamingClient;
31 import org.onap.so.client.namingservice.NamingRequestObjectBuilder;
32 import org.onap.so.logger.MsoLogger;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.stereotype.Component;
37 public class NamingServiceResources {
38 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, NamingServiceResources.class);
39 private static final String NAMING_TYPE = "instanceGroup";
42 private NamingClient namingClient;
45 private NamingRequestObjectBuilder namingRequestObjectBuilder;
47 public String generateInstanceGroupName(InstanceGroup instanceGroup, String policyInstanceName, String nfNamingCode) throws BadResponseException {
48 Element element = namingRequestObjectBuilder.elementMapper(instanceGroup.getId(), policyInstanceName, NAMING_TYPE, nfNamingCode, instanceGroup.getInstanceGroupName());
49 List<Element> elements = new ArrayList<Element>();
50 elements.add(element);
51 return(namingClient.postNameGenRequest(namingRequestObjectBuilder.nameGenRequestMapper(elements)));
54 public String deleteInstanceGroupName(InstanceGroup instanceGroup) throws BadResponseException {
55 Deleteelement deleteElement = namingRequestObjectBuilder.deleteElementMapper(instanceGroup.getId());
56 List<Deleteelement> deleteElements = new ArrayList<Deleteelement>();
57 deleteElements.add(deleteElement);
58 return(namingClient.deleteNameGenRequest(namingRequestObjectBuilder.nameGenDeleteRequestMapper(deleteElements)));