diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java')
14 files changed, 1835 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java new file mode 100644 index 0000000000..f65dde1af5 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/buildingblock/OofHomingV2.java @@ -0,0 +1,615 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.buildingblock; + +import org.apache.commons.lang.SerializationUtils; +import org.camunda.bpm.engine.delegate.BpmnError; +import java.util.ArrayList; +import org.json.JSONArray; +import org.json.JSONObject; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.core.json.JsonUtils; +import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource; +import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy; +import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.generalobjects.License; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestParameters; +import org.onap.so.bpmn.servicedecomposition.homingobjects.Candidate; +import org.onap.so.bpmn.servicedecomposition.homingobjects.CandidateType; +import org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionCandidates; +import org.onap.so.bpmn.servicedecomposition.homingobjects.SolutionInfo; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoMetadata; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.client.exception.BadResponseException; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.client.oof.OofClient; +import org.onap.so.client.oof.OofValidator; +import org.onap.so.client.oof.beans.ModelInfo; +import org.onap.so.client.oof.beans.OofRequest; +import org.onap.so.client.oof.beans.OofRequestParameters; +import org.onap.so.client.oof.beans.PlacementDemand; +import org.onap.so.client.oof.beans.PlacementInfo; +import org.onap.so.client.oof.beans.RequestInfo; +import org.onap.so.client.oof.beans.ResourceModelInfo; +import org.onap.so.client.oof.beans.ServiceInfo; +import org.onap.so.client.oof.beans.SubscriberInfo; +import org.onap.so.db.catalog.beans.OrchestrationStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; +import org.springframework.web.util.UriUtils; + +import java.time.Duration; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import static org.apache.commons.lang3.StringUtils.isBlank; +import static org.apache.commons.lang3.StringUtils.isNotBlank; + + +/** + * The oof homing building block obtains licensing and homing solutions for a given + * resource or set of resources. + * + */ +@Component("OofHoming") +public class OofHomingV2 { + + private static final Logger logger = LoggerFactory.getLogger(OofHomingV2.class); + private JsonUtils jsonUtils = new JsonUtils(); + @Autowired + private Environment env; + @Autowired + private OofClient client; + @Autowired + private OofValidator oofValidator; + @Autowired + private ExceptionBuilder exceptionUtil; + private static final String MODEL_NAME = "modelName"; + private static final String MODEL_INVARIANT_ID = "modelInvariantId"; + private static final String MODEL_VERSION_ID = "modelVersionId"; + private static final String MODEL_VERSION = "modelVersion"; + private static final String SERVICE_RESOURCE_ID = "serviceResourceId"; + private static final String RESOURCE_MODULE_NAME = "resourceModuleName"; + private static final String RESOURCE_MODEL_INFO = "resourceModelInfo"; + private static final String IDENTIFIER_TYPE = "identifierType"; + private static final String INVENTORY_TYPE = "inventoryType"; + private static final String SOLUTIONS = "solutions"; + private static final String RESOURCE_MISSING_DATA = "Resource does not contain: "; + private static final String SERVICE_MISSING_DATA = "Service Instance does not contain: "; + private static final String UNPROCESSABLE = "422"; + private static final int INTERNAL = 500; + + /** + * Generates the request payload then sends to Oof to perform homing and + * licensing for the provided demands + * + * @param execution + */ + public void callOof(BuildingBlockExecution execution){ + logger.trace("Started Sniro Homing Call Sniro"); + try{ + GeneralBuildingBlock bb = execution.getGeneralBuildingBlock(); + + RequestContext requestContext = bb.getRequestContext(); + RequestParameters requestParams = requestContext.getRequestParameters(); + String requestId = requestContext.getMsoRequestId(); + + ServiceInstance serviceInstance = bb.getCustomer().getServiceSubscription().getServiceInstances().get(0); + Customer customer = bb.getCustomer(); + + String timeout = execution.getVariable("timeout"); + if(isBlank(timeout)){ + timeout = env.getProperty("oof.timeout", "PT30M"); + } + + OofRequest request = new OofRequest(); + + RequestInfo requestInfo = (RequestInfo)buildRequestInfo(requestId, timeout); + request.setRequestInformation(requestInfo); + + ServiceInfo serviceInfo = buildServiceInfo(serviceInstance); + request.setServiceInformation(serviceInfo); + + PlacementInfo placementInfo = buildPlacementInfo(customer, requestParams); + + ArrayList<PlacementDemand> placementDemands = buildPlacementDemands(serviceInstance); + placementInfo.setPlacementDemands(placementDemands); + request.setPlacementInformation(placementInfo); + + JSONObject licenseInfo = new JSONObject(); + + JSONArray licenseDemands = buildLicenseDemands(serviceInstance); + licenseInfo.put("licenseDemands", licenseDemands); + request.setLicenseInformation(licenseInfo.toString()); + + if(placementDemands.size() > 0 || licenseDemands.length() > 0){ + client.postDemands(request); + }else{ + logger.debug(SERVICE_MISSING_DATA + " resources eligible for homing or licensing"); + throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + " resources eligible for homing or licensing"); + } + + //Variables for ReceiveWorkflowMessage subflow + execution.setVariable("asyncCorrelator", requestId); + execution.setVariable("asyncMessageType", "OofResponse"); + execution.setVariable("asyncTimeout", timeout); + + logger.trace("Completed Oof Homing Call Oof"); + }catch(BpmnError e){ + exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage()); + }catch(BadResponseException e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage()); + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while preparing oof request: " + e.getMessage()); + } + } + + /** + * Validates, processes, and sets the homing and licensing solutions that are returned by + * Oof + * + * @param execution + * @param asyncResponse + */ + public void processSolution(BuildingBlockExecution execution, String asyncResponse){ + logger.trace("Started Oof Homing Process Solution"); + try{ + oofValidator.validateSolution(asyncResponse); + ServiceInstance serviceInstance = execution.getGeneralBuildingBlock().getCustomer().getServiceSubscription().getServiceInstances().get(0); + + logger.debug("Processing Oof asyncronous response"); + JSONObject response = new JSONObject(asyncResponse); + if(response.has(SOLUTIONS)){ + JSONObject allSolutions = response.getJSONObject(SOLUTIONS); + if(allSolutions.has("placementSolutions")){ + JSONArray placementSolutions = allSolutions.getJSONArray("placementSolutions"); + for(int i = 0; i < placementSolutions.length(); i++){ + JSONArray placements = placementSolutions.getJSONArray(i); + processPlacementSolution(serviceInstance, placements, i); + } + } + if(allSolutions.has("licenseSolutions")){ + JSONArray licenseSolutions = allSolutions.getJSONArray("licenseSolutions"); + if(licenseSolutions.length() > 0){ + processLicenseSolution(serviceInstance, licenseSolutions); + } + } + }else{ + throw new BpmnError(UNPROCESSABLE, "Oof response does not contain: " + SOLUTIONS); + } + + execution.setVariable("generalBuildingBlock", execution.getGeneralBuildingBlock()); + + logger.trace("Completed Oof Homing Process Solution"); + }catch(BpmnError e){ + exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(e.getErrorCode()), e.getMessage()); + }catch(BadResponseException e){ + exceptionUtil.buildAndThrowWorkflowException(execution, 400, e.getMessage()); + }catch(Exception e){ + exceptionUtil.buildAndThrowWorkflowException(execution, INTERNAL, "Internal Error - occurred while processing Oof asynchronous response: " + e.getMessage()); + } + } + + /** + * Builds the request information section for the homing/licensing request + * + * @throws Exception + */ + private RequestInfo buildRequestInfo(String requestId, String timeout) throws Exception{ + logger.trace("Building request information"); + RequestInfo requestInfo = new RequestInfo(); + if(requestId != null){ + String host = env.getProperty("mso.workflow.message.endpoint"); + String callbackUrl = host + "/" + UriUtils.encodePathSegment("OofResponse", "UTF-8") + "/" + UriUtils.encodePathSegment(requestId, "UTF-8"); + + Duration d = Duration.parse(timeout); + long timeoutSeconds = d.getSeconds(); + + requestInfo.setTransactionId(requestId); + requestInfo.setRequestId(requestId); + requestInfo.setCallbackUrl(callbackUrl); + requestInfo.setSourceId("mso"); + requestInfo.setRequestType("create"); + requestInfo.setTimeout(timeoutSeconds); + } else{ + throw new BpmnError(UNPROCESSABLE, "Request Context does not contain: requestId"); + } + return requestInfo; + } + + /** + * Builds the request information section for the homing/licensing request + * + */ + private ServiceInfo buildServiceInfo(ServiceInstance serviceInstance){ + logger.trace("Building service information"); + ServiceInfo info = new ServiceInfo(); + ModelInfoServiceInstance modelInfo = serviceInstance.getModelInfoServiceInstance(); + if(isNotBlank(modelInfo.getModelInvariantUuid()) && isNotBlank(modelInfo.getModelUuid())){ + info.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + if(modelInfo.getServiceType() != null && modelInfo.getServiceType().length() > 0){ //temp solution + info.setServiceName(modelInfo.getServiceType()); + } + info.setModelInfo(buildModelInfo(serviceInstance.getModelInfoServiceInstance())); + }else{ + throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + MODEL_VERSION_ID + ", " + MODEL_INVARIANT_ID); + } + return info; + } + + /** + * Builds initial section of placement info for the homing/licensing request + * + */ + private PlacementInfo buildPlacementInfo(Customer customer, RequestParameters requestParams){ + PlacementInfo placementInfo = new PlacementInfo(); + if(customer != null){ + logger.debug("Adding subscriber to placement information"); + SubscriberInfo subscriberInfo = new SubscriberInfo(); + subscriberInfo.setGlobalSubscriberId(customer.getGlobalCustomerId()); + subscriberInfo.setSubscriberName(customer.getSubscriberName()); + subscriberInfo.setSubscriberCommonSiteId(customer.getSubscriberCommonSiteId()); + placementInfo.setSubscriberInfo(subscriberInfo); + if(requestParams != null){ + logger.debug("Adding request parameters to placement information"); + OofRequestParameters oofRequestParams = new OofRequestParameters(); + for (Map requestParam : requestParams.getUserParams()){ + if (requestParam.containsKey("customerLatitude")){ + oofRequestParams.setCustomerLatitude(requestParam.get("customerLatitude").toString()); + } + if (requestParam.containsKey("customerLongitude")){ + oofRequestParams.setCustomerLongitude(requestParam.get("customerLongitude").toString()); + } + if (requestParam.containsKey("customerName")){ + oofRequestParams.setCustomerName(requestParam.get("customerName").toString()); + } + } + placementInfo.setRequestParameters(oofRequestParams); + } + }else{ + throw new BpmnError(UNPROCESSABLE, SERVICE_MISSING_DATA + "customer"); + } + return placementInfo; + + } + + /** + * Builds the placement demand list for the homing/licensing request + * + */ + private ArrayList<PlacementDemand> buildPlacementDemands(ServiceInstance serviceInstance){ + logger.trace("Building placement information demands"); + ArrayList<PlacementDemand> placementDemands = new ArrayList(); + + List<AllottedResource> allottedResourceList = serviceInstance.getAllottedResources(); + if(!allottedResourceList.isEmpty()){ + logger.debug("Adding allotted resources to placement demands list"); + for(AllottedResource ar : allottedResourceList){ + if(isBlank(ar.getId())){ + ar.setId(UUID.randomUUID().toString()); + } + PlacementDemand demand = buildDemand(ar.getId(), ar.getModelInfoAllottedResource()); + //addCandidates(ar, demand); + placementDemands.add(demand); + } + } + List<VpnBondingLink> vpnBondingLinkList = serviceInstance.getVpnBondingLinks(); + if(!vpnBondingLinkList.isEmpty()){ + logger.debug("Adding vpn bonding links to placement demands list"); + for(VpnBondingLink vbl:vpnBondingLinkList){ + List<ServiceProxy> serviceProxyList = vbl.getServiceProxies(); + for(ServiceProxy sp : serviceProxyList){ + if(isBlank(sp.getId())){ + sp.setId(UUID.randomUUID().toString()); + } + PlacementDemand demand = buildDemand(sp.getId(), sp.getModelInfoServiceProxy()); + //addCandidates(sp, demand); + placementDemands.add(demand); + } + } + } + return placementDemands; + } + + /** + * Builds the license demand list for the homing/licensing request + * + */ + private JSONArray buildLicenseDemands(ServiceInstance serviceInstance){ + logger.trace("Building license information"); + JSONArray licenseDemands = new JSONArray(); + List<GenericVnf> vnfList = serviceInstance.getVnfs(); + if(!vnfList.isEmpty()){ + logger.debug("Adding vnfs to license demands list"); + for(GenericVnf vnf : vnfList){ + JSONObject demand = buildLicenseDemand(vnf.getVnfId(), vnf.getModelInfoGenericVnf()); + licenseDemands.put(demand); + } + } + return licenseDemands; + } + + /** + * Builds a single license demand object + * + */ + private JSONObject buildLicenseDemand(String id, ModelInfoMetadata metadata){ + logger.debug("Building demand for service or resource: " + id); + JSONObject demand = new JSONObject(); + if(isNotBlank(id) && isNotBlank(metadata.getModelInstanceName())){ + demand.put(SERVICE_RESOURCE_ID, id); + demand.put(RESOURCE_MODULE_NAME, metadata.getModelInstanceName()); + demand.put(RESOURCE_MODEL_INFO, buildModelInfo(metadata)); + }else{ + throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + "modelInstanceName"); + } + return demand; + } + + /** + * Builds a single demand object + * + */ + private PlacementDemand buildDemand(String id, ModelInfoMetadata metadata){ + logger.debug("Building demand for service or resource: " + id); + PlacementDemand placementDemand = new PlacementDemand(); + if(isNotBlank(id) && isNotBlank(metadata.getModelInstanceName())){ + placementDemand.setServiceResourceId(id); + placementDemand.setResourceModuleName(metadata.getModelInstanceName()); + placementDemand.setResourceModelInfo((ResourceModelInfo) buildModelInfo(metadata)); + }else{ + throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + "modelInstanceName"); + } + return placementDemand; + } + + /** + * Builds the resource model info section + * + */ + private ModelInfo buildModelInfo(ModelInfoMetadata metadata){ + ModelInfo modelInfo = new ModelInfo(); + String invariantUuid = metadata.getModelInvariantUuid(); + String modelUuid = metadata.getModelUuid(); + if(isNotBlank(invariantUuid) && isNotBlank(modelUuid)){ + modelInfo.setModelInvariantId(invariantUuid); + modelInfo.setModelVersionId(modelUuid); + modelInfo.setModelName(metadata.getModelName()); + modelInfo.setModelVersion(metadata.getModelVersion()); + }else if(isNotBlank(invariantUuid)){ + throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + MODEL_VERSION_ID); + }else{ + throw new BpmnError(UNPROCESSABLE, RESOURCE_MISSING_DATA + MODEL_INVARIANT_ID); + } + return modelInfo; + } + + /** + * Adds required, excluded, and existing candidates to a demand + * + */ + private void addCandidates(SolutionCandidates candidates, JSONObject demand){ + List<Candidate> required = candidates.getRequiredCandidates(); + List<Candidate> excluded = candidates.getExcludedCandidates(); + if(!required.isEmpty()){ + demand.put("requiredCandidates", required); + } + if(!excluded.isEmpty()){ + demand.put("excludedCandidates", excluded); + } + //TODO support existing candidates + } + + /** + * Processes the license solutions and sets to the corresponding generic vnf + * + */ + private void processLicenseSolution(ServiceInstance serviceInstance, JSONArray licenseSolutions){ + List<GenericVnf> vnfs = serviceInstance.getVnfs(); + + logger.debug("Processing the license solution"); + for(int i = 0; i < licenseSolutions.length(); i++){ + JSONObject licenseSolution = licenseSolutions.getJSONObject(i); + for(GenericVnf vnf:vnfs){ + if(licenseSolution.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())){ + License license = new License(); + JSONArray entitlementPools = licenseSolution.getJSONArray("entitlementPoolUUID"); + List<String> entitlementPoolsList = jsonUtils.StringArrayToList(entitlementPools); + license.setEntitlementPoolUuids(entitlementPoolsList); + JSONArray licenseKeys = licenseSolution.getJSONArray("licenseKeyGroupUUID"); + List<String> licenseKeysList = jsonUtils.StringArrayToList(licenseKeys); + license.setLicenseKeyGroupUuids(licenseKeysList); + + vnf.setLicense(license); + } + } + } + } + + /** + * Processes a placement solution list then correlates and sets each placement solution + * to its corresponding resource + * + */ + private void processPlacementSolution(ServiceInstance serviceInstance, JSONArray placements, int i){ + List<VpnBondingLink> links = serviceInstance.getVpnBondingLinks(); + List<AllottedResource> allottes = serviceInstance.getAllottedResources(); + List<GenericVnf> vnfs = serviceInstance.getVnfs(); + + logger.debug("Processing placement solution " + i+1); + for(int p = 0; p < placements.length(); p++){ + JSONObject placement = placements.getJSONObject(p); + SolutionInfo solutionInfo = new SolutionInfo(); + solutionInfo.setSolutionId(i + 1); + search: { + for(VpnBondingLink vbl:links){ + List<ServiceProxy> proxies = vbl.getServiceProxies(); + for(ServiceProxy sp:proxies){ + if(placement.getString(SERVICE_RESOURCE_ID).equals(sp.getId())){ + if(i > 0){ + if(p % 2 == 0){ + VpnBondingLink vblNew = (VpnBondingLink) SerializationUtils.clone(vbl); + vblNew.setVpnBondingLinkId(UUID.randomUUID().toString()); + links.add(vblNew); + } + links.get(links.size() - 1).getServiceProxy(sp.getId()).setServiceInstance(setSolution(solutionInfo, placement)); + }else{ + sp.setServiceInstance(setSolution(solutionInfo, placement)); + } + break search; + } + } + } + for(AllottedResource ar:allottes){ + if(placement.getString(SERVICE_RESOURCE_ID).equals(ar.getId())){ + ar.setParentServiceInstance(setSolution(solutionInfo, placement)); + break search; + } + } + for(GenericVnf vnf:vnfs){ + if(placement.getString(SERVICE_RESOURCE_ID).equals(vnf.getVnfId())){ + ServiceInstance si = setSolution(solutionInfo, placement); + serviceInstance.setSolutionInfo(si.getSolutionInfo()); + serviceInstance.getVnfs().add(si.getVnfs().get(0)); + break search; + } + } + } + } + } + + + /** + * Creates and sets necessary pojos with placement solution data for a given demand + * + */ + private ServiceInstance setSolution(SolutionInfo solutionInfo, JSONObject placement){ + logger.debug("Mapping placement solution"); + String invalidMessage = "Oof Response contains invalid: "; + + JSONObject solution = placement.getJSONObject("solution"); + String identifierType = solution.getString(IDENTIFIER_TYPE); + List<String> identifiersList = jsonUtils.StringArrayToList(solution.getJSONArray("identifiers").toString()); + String identifierValue = identifiersList.get(0); + + JSONArray assignments = placement.getJSONArray("assignmentInfo"); + Map<String, String> assignmentsMap = jsonUtils.entryArrayToMap(assignments.toString(), "key", "value"); + solutionInfo.setRehome(Boolean.parseBoolean(assignmentsMap.get("isRehome"))); + String type = placement.getString(INVENTORY_TYPE); + + ServiceInstance si = new ServiceInstance(); + CloudRegion cloud = setCloud(assignmentsMap); + if(type.equals("service")){ + if(identifierType.equals(CandidateType.SERVICE_INSTANCE_ID.toString())){ + solutionInfo.setHomed(true); + si.setServiceInstanceId(identifierValue); + si.setOrchestrationStatus(OrchestrationStatus.CREATED); + cloud.setLcpCloudRegionId(assignmentsMap.get("cloudRegionId")); + if(assignmentsMap.containsKey("vnfHostName")){ + logger.debug("Resources has been homed to a vnf"); + GenericVnf vnf = setVnf(assignmentsMap); + vnf.setCloudRegion(cloud); + si.getVnfs().add(vnf); + + }else if(assignmentsMap.containsKey("primaryPnfName")){ + logger.debug("Resources has been homed to a pnf"); + Pnf priPnf = setPnf(assignmentsMap, "primary"); + priPnf.setCloudRegion(cloud); + si.getPnfs().add(priPnf); + if(assignmentsMap.containsKey("secondaryPnfName")){ + Pnf secPnf = setPnf(assignmentsMap, "secondary"); + secPnf.setCloudRegion(cloud); + si.getPnfs().add(secPnf); + } + } + }else{ + logger.debug(invalidMessage + IDENTIFIER_TYPE); + throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE); + } + }else if(type.equals("cloud")){ + if(identifierType.equals(CandidateType.CLOUD_REGION_ID.toString())){ + logger.debug("Resources has been homed to a cloud region"); + cloud.setLcpCloudRegionId(identifierValue); + solutionInfo.setHomed(false); + solutionInfo.setTargetedCloudRegion(cloud); + si.setOrchestrationStatus(OrchestrationStatus.PRECREATED); + }else{ + logger.debug(invalidMessage + IDENTIFIER_TYPE); + throw new BpmnError(UNPROCESSABLE, invalidMessage + IDENTIFIER_TYPE); + } + }else{ + logger.debug(invalidMessage + INVENTORY_TYPE); + throw new BpmnError(UNPROCESSABLE, invalidMessage + INVENTORY_TYPE); + } + si.setSolutionInfo(solutionInfo); + return si; + } + + /** + * Sets the cloud data to a cloud region object + * + */ + private CloudRegion setCloud(Map<String, String> assignmentsMap){ + CloudRegion cloud = new CloudRegion(); + cloud.setCloudOwner(assignmentsMap.get("cloudOwner")); + cloud.setCloudRegionVersion(assignmentsMap.get("aicVersion")); + cloud.setComplex(assignmentsMap.get("aicClli")); + return cloud; + } + + /** + * Sets the vnf data to a generic vnf object + * + */ + private GenericVnf setVnf(Map<String, String> assignmentsMap){ + GenericVnf vnf = new GenericVnf(); + vnf.setOrchestrationStatus(OrchestrationStatus.CREATED); + vnf.setVnfName(assignmentsMap.get("vnfHostName")); + vnf.setVnfId(assignmentsMap.get("vnfId")); + return vnf; + } + + /** + * Sets the pnf data to a pnf object + * + */ + private Pnf setPnf(Map<String, String> assignmentsMap, String role){ + Pnf pnf = new Pnf(); + pnf.setRole(role); + pnf.setOrchestrationStatus(OrchestrationStatus.CREATED); + pnf.setPnfName(assignmentsMap.get(role + "PnfName")); + return pnf; + } + + + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java new file mode 100644 index 0000000000..fa039c235c --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofClient.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof; + + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.onap.so.bpmn.common.baseclient.BaseClient; +import org.onap.so.bpmn.core.UrnPropertiesReader; +import org.onap.so.client.exception.BadResponseException; +import org.onap.so.client.oof.beans.OofProperties; +import org.onap.so.client.oof.beans.OofRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; + +import com.fasterxml.jackson.core.JsonProcessingException; +import java.util.LinkedHashMap; + +@Component +public class OofClient { + + private static final Logger logger = LoggerFactory.getLogger(OofClient.class); + public static final String X_MINOR_VERSION = "X-MinorVersion"; + public static final String X_PATCH_VERSION = "X-PatchVersion"; + public static final String X_LATEST_VERSION = "X-LatestVersion"; + + @Autowired + private OofProperties oofProperties; + + @Autowired + private OofValidator validator; + + + /** + * Makes a rest call to oof to perform homing and licensing for a + * list of demands + * + * @param homingRequest + * @return + * @throws JsonProcessingException + * @throws BpmnError + */ + public void postDemands(OofRequest homingRequest) throws BadResponseException, JsonProcessingException{ + logger.trace("Started oof Client Post Demands"); + String url = oofProperties.getHost() + oofProperties.getUri(); + logger.debug("Post demands url: " + url); + logger.debug("Post demands payload: " + homingRequest.toJsonString()); + + HttpHeaders header = new HttpHeaders(); + header.setContentType(MediaType.APPLICATION_JSON); + header.set(HttpHeaders.AUTHORIZATION, oofProperties.getHeaders().get("auth")); + header.set(X_PATCH_VERSION, oofProperties.getHeaders().get("patchVersion")); + header.set(X_MINOR_VERSION, oofProperties.getHeaders().get("minorVersion")); + header.set(X_LATEST_VERSION, oofProperties.getHeaders().get("latestVersion")); + BaseClient<String, LinkedHashMap<?, ?>> baseClient = new BaseClient<>(); + + baseClient.setTargetUrl(url); + baseClient.setHttpHeader(header); + + LinkedHashMap<?, ?> response = baseClient.post(homingRequest.toJsonString(), new ParameterizedTypeReference<LinkedHashMap<? ,?>>() {}); + validator.validateDemandsResponse(response); + logger.trace("Completed OOF Client Post Demands"); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java new file mode 100644 index 0000000000..252ff0d6a6 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/OofValidator.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof; + + +import org.json.JSONObject; +import org.onap.so.client.exception.BadResponseException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.util.LinkedHashMap; + +import static org.apache.commons.lang.StringUtils.isNotBlank; + + +@Component +public class OofValidator { + + private static final Logger logger = LoggerFactory.getLogger(OofValidator.class); + + /** + * Validates the synchronous homing response from oof + * + * @throws BadResponseException + */ + public void validateDemandsResponse(LinkedHashMap<?, ?> response) throws BadResponseException { + logger.debug("Validating oofs synchronous response"); + if(!response.isEmpty()){ + JSONObject jsonResponse = new JSONObject(response); + if(jsonResponse.has("requestStatus")){ + String status = jsonResponse.getString("requestStatus"); + if(status.equals("accepted")){ + logger.debug("oofs synchronous response indicates accepted"); + }else{ + String message = jsonResponse.getString("statusMessage"); + if(isNotBlank(message)){ + logger.debug("oofs response indicates failed: " + message); + }else{ + logger.debug("oofs response indicates failed: no status message provided"); + message = "error message not provided"; + } + throw new BadResponseException("oofs synchronous response indicates failed: " + message); + } + }else{ + logger.debug("oofs synchronous response does not contain: request status"); + throw new BadResponseException("oofs synchronous response does not contain: request status"); + } + }else{ + logger.debug("oofs synchronous response is empty"); + throw new BadResponseException("oofs synchronous response i is empty"); + } + } + + /** + * Validates the asynchronous/callback response from oof which + * contains the homing and licensing solutions + * + * @throws BadResponseException + */ + public void validateSolution(String response) throws BadResponseException{ + logger.debug("Validating oofs asynchronous callback response"); + if(isNotBlank(response)) { + JSONObject jsonResponse = new JSONObject(response); + if(!jsonResponse.has("serviceException")){ + logger.debug("oofs asynchronous response is valid"); + }else{ + String message = jsonResponse.getJSONObject("serviceException").getString("text"); + if(isNotBlank(message)){ + logger.debug("oofs response contains a service exception: " + message); + }else{ + logger.debug("oofs response contains a service exception: no service exception text provided"); + message = "error message not provided"; + } + throw new BadResponseException("oofs asynchronous response contains a service exception: " + message); + } + }else{ + logger.debug("oofs asynchronous response is empty"); + throw new BadResponseException("oofs asynchronous response is empty"); + } + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java new file mode 100644 index 0000000000..8e136e9f18 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ModelInfo.java @@ -0,0 +1,123 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang.builder.ToStringBuilder; + +import java.io.Serializable; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "modelType", + "modelInvariantId", + "modelVersionId", + "modelName", + "modelVersion", + "modelCustomizationName" +}) +@JsonRootName("modelInfo") +public class ModelInfo implements Serializable { + + private static final long serialVersionUID = -759180997599143791L; + + @JsonProperty("modelType") + private String modelType; + @JsonProperty("modelInvariantId") + private String modelInvariantId; + @JsonProperty("modelVersionId") + private String modelVersionId; + @JsonProperty("modelName") + private String modelName; + @JsonProperty("modelVersion") + private String modelVersion; + @JsonProperty("modelCustomizationName") + private String modelCustomizationName; + + @JsonProperty("modelType") + public String getModelType() { + return modelType; + } + + @JsonProperty("modelType") + public void setModelType(String modelType) { + this.modelType = modelType; + } + + @JsonProperty("modelInvariantId") + public String getModelInvariantId() { + return modelInvariantId; + } + + @JsonProperty("modelInvariantId") + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + @JsonProperty("modelVersionId") + public String getModelVersionId() { + return modelVersionId; + } + + @JsonProperty("modelVersionId") + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + + @JsonProperty("modelName") + public String getModelName() { + return modelName; + } + + @JsonProperty("modelName") + public void setModelName(String modelName) { + this.modelName = modelName; + } + + @JsonProperty("modelVersion") + public String getModelVersion() { + return modelVersion; + } + + @JsonProperty("modelVersion") + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + + @JsonProperty("modelCustomizationName") + public String getModelCustomizationName() { + return modelCustomizationName; + } + + @JsonProperty("modelCustomizationName") + public void setModelCustomizationName(String modelCustomizationName) { + this.modelCustomizationName = modelCustomizationName; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelType", modelType).append("modelInvariantId", modelInvariantId).append("modelVersionId", modelVersionId).append("modelName", modelName).append("modelVersion", modelVersion).append("modelCustomizationName", modelCustomizationName).toString(); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java new file mode 100644 index 0000000000..507eaeaf5e --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofProperties.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof.beans; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.util.Map; + +@Configuration +@ConfigurationProperties(prefix = "oof") +public class OofProperties { + + private String host; + private String uri; + + private Map<String, String> headers; + + + public String getHost() { + return host; + } + public void setHost(String host) { + this.host = host; + } + public String getUri() { + return uri; + } + public void setUri(String uri) { + this.uri = uri; + } + public Map<String, String> getHeaders() { + return headers; + } + public void setHeaders(Map<String, String> headers) { + this.headers = headers; + } + + + + + + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java new file mode 100644 index 0000000000..7dfd6849a6 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequest.java @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRawValue; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectWriter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.Serializable; + + +public class OofRequest implements Serializable{ + + private static final long serialVersionUID = -1541132882892163132L; + private static final Logger logger = LoggerFactory.getLogger(OofRequest.class); + + @JsonRawValue + @JsonProperty("requestInfo") + private RequestInfo requestInformation; + @JsonRawValue + @JsonProperty("serviceInfo") + private ServiceInfo serviceInformation; + @JsonRawValue + @JsonProperty("placementInfo") + private PlacementInfo placementInformation; + @JsonRawValue + @JsonProperty("licenseInfo") + private String licenseInformation; + + + public RequestInfo getRequestInformation() { + return requestInformation; + } + public void setRequestInformation(RequestInfo requestInformation) { + this.requestInformation = requestInformation; + } + public ServiceInfo getServiceInformation() { + return serviceInformation; + } + public void setServiceInformation(ServiceInfo serviceInformation) { + this.serviceInformation = serviceInformation; + } + public PlacementInfo getPlacementInformation() { + return placementInformation; + } + public void setPlacementInformation(PlacementInfo placementInformation) { + this.placementInformation = placementInformation; + } + public String getLicenseInformation() { + return licenseInformation; + } + public void setLicenseInformation(String licenseInformation) { + this.licenseInformation = licenseInformation; + } + + + @JsonInclude(Include.NON_NULL) + public String toJsonString(){ + String json = ""; + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter(); + try{ + json = ow.writeValueAsString(this); + }catch (Exception e){ + logger.error("Unable to convert oofRequest to string", e); + } + return json.replaceAll("\\\\", ""); + } + + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java new file mode 100644 index 0000000000..34b05e2f0f --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/OofRequestParameters.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang.builder.ToStringBuilder; + +import java.io.Serializable; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "customerLatitude", + "customerLongitude", + "customerName" +}) +@JsonRootName("requestParameters") +public class OofRequestParameters implements Serializable { + + private static final long serialVersionUID = -759180997599143791L; + + + @JsonProperty("customerLatitude") + private String customerLatitude; + @JsonProperty("customerLongitude") + private String customerLongitude; + @JsonProperty("customerName") + private String customerName; + + @JsonProperty("customerLatitude") + public String getCustomerLatitude() { + return customerLatitude; + } + + @JsonProperty("customerLatitude") + public void setCustomerLatitude(String customerLatitude) { + this.customerLatitude = customerLatitude; + } + + @JsonProperty("customerLongitude") + public String getCustomerLongitude() { + return customerLongitude; + } + + @JsonProperty("customerLongitude") + public void setCustomerLongitude(String customerLongitude) { + this.customerLongitude = customerLongitude; + } + + @JsonProperty("customerName") + public String getCustomerName() { + return customerName; + } + + @JsonProperty("customerName") + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("customerLatitude", customerLatitude).append("customerLongitude", customerLongitude).append("customerName", customerName).toString(); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java new file mode 100644 index 0000000000..a213723f76 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementDemand.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang.builder.ToStringBuilder; + +import java.io.Serializable; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "resourceModuleName", + "serviceResourceId", + "tenantId", + "resourceModelInfo" +}) +@JsonRootName("placementDemand") +public class PlacementDemand implements Serializable { + + private static final long serialVersionUID = -759180997599143791L; + + @JsonProperty("resourceModuleName") + private String resourceModuleName; + @JsonProperty("serviceResourceId") + private String serviceResourceId; + @JsonProperty("tenantId") + private String tenantId; + @JsonProperty("resourceModelInfo") + private ResourceModelInfo resourceModelInfo; + + @JsonProperty("resourceModuleName") + public String getResourceModuleName() { + return resourceModuleName; + } + + @JsonProperty("resourceModuleName") + public void setResourceModuleName(String resourceModuleName) { + this.resourceModuleName = resourceModuleName; + } + + @JsonProperty("serviceResourceId") + public String getServiceResourceId() { + return serviceResourceId; + } + + @JsonProperty("serviceResourceId") + public void setServiceResourceId(String serviceResourceId) { + this.serviceResourceId = serviceResourceId; + } + + @JsonProperty("tenantId") + public String getTenantId() { + return tenantId; + } + + @JsonProperty("tenantId") + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + @JsonProperty("resourceModelInfo") + public ResourceModelInfo getResourceModelInfo() { + return resourceModelInfo; + } + + @JsonProperty("resourceModelInfo") + public void setResourceModelInfo(ResourceModelInfo resourceModelInfo) { + this.resourceModelInfo = resourceModelInfo; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("resourceModuleName", resourceModuleName).append("serviceResourceId", serviceResourceId).append("tenantId", tenantId).append("resourceModelInfo", resourceModelInfo).toString(); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java new file mode 100644 index 0000000000..5bda42fefe --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/PlacementInfo.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof.beans; + +import java.io.Serializable; +import java.util.ArrayList; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "requestParameters", + "subscriberInfo", + "placementDemands" +}) +@JsonRootName("placementInfo") +public class PlacementInfo implements Serializable { + + private static final long serialVersionUID = -759180997599143791L; + + @JsonProperty("requestParameters") + private OofRequestParameters requestParameters; + @JsonProperty("subscriberInfo") + private SubscriberInfo subscriberInfo; + @JsonProperty("placementDemands") + private ArrayList<PlacementDemand> placementDemands = null; + + @JsonProperty("requestParameters") + public OofRequestParameters getRequestParameters() { + return requestParameters; + } + + @JsonProperty("requestParameters") + public void setRequestParameters(OofRequestParameters requestParameters) { + this.requestParameters = requestParameters; + } + + @JsonProperty("subscriberInfo") + public SubscriberInfo getSubscriberInfo() { + return subscriberInfo; + } + + @JsonProperty("subscriberInfo") + public void setSubscriberInfo(SubscriberInfo subscriberInfo) { + this.subscriberInfo = subscriberInfo; + } + + @JsonProperty("placementDemands") + public ArrayList<PlacementDemand> getPlacementDemands() { + return placementDemands; + } + + @JsonProperty("placementDemands") + public void setPlacementDemands(ArrayList<PlacementDemand> placementDemands) { + this.placementDemands = placementDemands; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("requestParameters", requestParameters).append("subscriberInfo", subscriberInfo).append("placementDemands", placementDemands).toString(); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java new file mode 100644 index 0000000000..ea33a26672 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/RequestInfo.java @@ -0,0 +1,149 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof.beans; + +import java.io.Serializable; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang.builder.ToStringBuilder; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "transactionId", + "requestId", + "callbackUrl", + "sourceId", + "requestType", + "numSolutions", + "optimizers", + "timeout" +}) +@JsonRootName("requestInfo") +public class RequestInfo implements Serializable { + + private static final long serialVersionUID = -759180997599143791L; + + @JsonProperty("transactionId") + private String transactionId; + @JsonProperty("requestId") + private String requestId; + @JsonProperty("callbackUrl") + private String callbackUrl; + @JsonProperty("sourceId") + private String sourceId; + @JsonProperty("requestType") + private String requestType; + @JsonProperty("numSolutions") + private Integer numSolutions; + @JsonProperty("optimizers") + private List<String> optimizers = null; + @JsonProperty("timeout") + private Long timeout; + + @JsonProperty("transactionId") + public String getTransactionId() { + return transactionId; + } + + @JsonProperty("transactionId") + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + + @JsonProperty("requestId") + public String getRequestId() { + return requestId; + } + + @JsonProperty("requestId") + public void setRequestId(String requestId) { + this.requestId = requestId; + } + + @JsonProperty("callbackUrl") + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty("callbackUrl") + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + @JsonProperty("sourceId") + public String getSourceId() { + return sourceId; + } + + @JsonProperty("sourceId") + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + @JsonProperty("requestType") + public String getRequestType() { + return requestType; + } + + @JsonProperty("requestType") + public void setRequestType(String requestType) { + this.requestType = requestType; + } + + @JsonProperty("numSolutions") + public Integer getNumSolutions() { + return numSolutions; + } + + @JsonProperty("numSolutions") + public void setNumSolutions(Integer numSolutions) { + this.numSolutions = numSolutions; + } + + @JsonProperty("optimizers") + public List<String> getOptimizers() { + return optimizers; + } + + @JsonProperty("optimizers") + public void setOptimizers(List<String> optimizers) { + this.optimizers = optimizers; + } + + @JsonProperty("timeout") + public Long getTimeout() { + return timeout; + } + + @JsonProperty("timeout") + public void setTimeout(Long timeout) { + this.timeout = timeout; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("transactionId", transactionId).append("requestId", requestId).append("callbackUrl", callbackUrl).append("sourceId", sourceId).append("requestType", requestType).append("numSolutions", numSolutions).append("optimizers", optimizers).append("timeout", timeout).toString(); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/Resource.java new file mode 100644 index 0000000000..fea7437a93 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/Resource.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof.beans; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; + +public class Resource implements Serializable{ + + private static final long serialVersionUID = 5949861520571440421L; + + @JsonProperty("service-resource-id") + private String serviceResourceId; + @JsonProperty("status") + private String status; + + + public String getServiceResourceId(){ + return serviceResourceId; + } + + public void setServiceResourceId(String serviceResourceId){ + this.serviceResourceId = serviceResourceId; + } + + public String getStatus(){ + return status; + } + + public void setStatus(String status){ + this.status = status; + } + + + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java new file mode 100644 index 0000000000..63aec130ba --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ResourceModelInfo.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang.builder.ToStringBuilder; + +import java.io.Serializable; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonRootName("resourceModelInfo") +public class ResourceModelInfo extends ModelInfo implements Serializable { + + private static final long serialVersionUID = -759180997599143791L; + + @JsonProperty("modelInvariantId") + private String modelInvariantId; + @JsonProperty("modelVersionId") + private String modelVersionId; + @JsonProperty("modelName") + private String modelName; + @JsonProperty("modelType") + private String modelType; + @JsonProperty("modelVersion") + private String modelVersion; + @JsonProperty("modelCustomizationName") + private String modelCustomizationName; + + @JsonProperty("modelInvariantId") + public String getModelInvariantId() { + return modelInvariantId; + } + + @JsonProperty("modelInvariantId") + public void setModelInvariantId(String modelInvariantId) { + this.modelInvariantId = modelInvariantId; + } + + @JsonProperty("modelVersionId") + public String getModelVersionId() { + return modelVersionId; + } + + @JsonProperty("modelVersionId") + public void setModelVersionId(String modelVersionId) { + this.modelVersionId = modelVersionId; + } + + @JsonProperty("modelName") + public String getModelName() { + return modelName; + } + + @JsonProperty("modelName") + public void setModelName(String modelName) { + this.modelName = modelName; + } + + @JsonProperty("modelType") + public String getModelType() { + return modelType; + } + + @JsonProperty("modelType") + public void setModelType(String modelType) { + this.modelType = modelType; + } + + @JsonProperty("modelVersion") + public String getModelVersion() { + return modelVersion; + } + + @JsonProperty("modelVersion") + public void setModelVersion(String modelVersion) { + this.modelVersion = modelVersion; + } + + @JsonProperty("modelCustomizationName") + public String getModelCustomizationName() { + return modelCustomizationName; + } + + @JsonProperty("modelCustomizationName") + public void setModelCustomizationName(String modelCustomizationName) { + this.modelCustomizationName = modelCustomizationName; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("modelInvariantId", modelInvariantId).append("modelVersionId", modelVersionId).append("modelName", modelName).append("modelType", modelType).append("modelVersion", modelVersion).append("modelCustomizationName", modelCustomizationName).toString(); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java new file mode 100644 index 0000000000..90443ce379 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/ServiceInfo.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang.builder.ToStringBuilder; + +import java.io.Serializable; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "serviceInstanceId", + "serviceName", + "modelInfo" +}) +@JsonRootName("serviceInfo") +public class ServiceInfo implements Serializable { + + private static final long serialVersionUID = -759180997599143791L; + + @JsonProperty("serviceInstanceId") + private String serviceInstanceId; + @JsonProperty("serviceName") + private String serviceName; + @JsonProperty("modelInfo") + private ModelInfo modelInfo; + + @JsonProperty("serviceInstanceId") + public String getServiceInstanceId() { + return serviceInstanceId; + } + + @JsonProperty("serviceInstanceId") + public void setServiceInstanceId(String serviceInstanceId) { + this.serviceInstanceId = serviceInstanceId; + } + + @JsonProperty("serviceName") + public String getServiceName() { + return serviceName; + } + + @JsonProperty("serviceName") + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + @JsonProperty("modelInfo") + public ModelInfo getModelInfo() { + return modelInfo; + } + + @JsonProperty("modelInfo") + public void setModelInfo(ModelInfo modelInfo) { + this.modelInfo = modelInfo; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId).append("serviceName", serviceName).append("modelInfo", modelInfo).toString(); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java new file mode 100644 index 0000000000..bc283c803c --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/oof/beans/SubscriberInfo.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2018 Intel Corp. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.oof.beans; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.apache.commons.lang.builder.ToStringBuilder; + +import java.io.Serializable; + +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ + "globalSubscriberId", + "subscriberName", + "subscriberCommonSiteId" +}) +@JsonRootName("subscriberInfo") +public class SubscriberInfo implements Serializable { + + private static final long serialVersionUID = -759180997599143791L; + + @JsonProperty("globalSubscriberId") + private String globalSubscriberId; + @JsonProperty("subscriberName") + private String subscriberName; + @JsonProperty("subscriberCommonSiteId") + private String subscriberCommonSiteId; + + @JsonProperty("globalSubscriberId") + public String getGlobalSubscriberId() { + return globalSubscriberId; + } + + @JsonProperty("globalSubscriberId") + public void setGlobalSubscriberId(String globalSubscriberId) { + this.globalSubscriberId = globalSubscriberId; + } + + @JsonProperty("subscriberName") + public String getSubscriberName() { + return subscriberName; + } + + @JsonProperty("subscriberName") + public void setSubscriberName(String subscriberName) { + this.subscriberName = subscriberName; + } + + @JsonProperty("subscriberCommonSiteId") + public String getSubscriberCommonSiteId() { + return subscriberCommonSiteId; + } + + @JsonProperty("subscriberCommonSiteId") + public void setSubscriberCommonSiteId(String subscriberCommonSiteId) { + this.subscriberCommonSiteId = subscriberCommonSiteId; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("globalSubscriberId", globalSubscriberId).append("subscriberName", subscriberName).append("subscriberCommonSiteId", subscriberCommonSiteId).toString(); + } + +} |