summaryrefslogtreecommitdiffstats
path: root/appc-dg/appc-dg-shared/appc-dg-license-manager/src
diff options
context:
space:
mode:
Diffstat (limited to 'appc-dg/appc-dg-shared/appc-dg-license-manager/src')
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/LicenseManagerPlugin.java53
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/impl/LicenseManagerPluginImpl.java145
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/resources/OSGI-INF/blueprint/blueprint.xml38
3 files changed, 236 insertions, 0 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/LicenseManagerPlugin.java b/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/LicenseManagerPlugin.java
new file mode 100644
index 000000000..6ca6b6ab5
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/LicenseManagerPlugin.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.appc.dg.licmgr;
+
+import java.util.Map;
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
+
+
+
+public interface LicenseManagerPlugin extends SvcLogicJavaPlugin {
+ /**
+ * Retrieves license model from APPC database and populate flags into svc context
+ * @param params map with parameters:
+ * org.openecomp.appc.vftype - the vnf type / service type;
+ * org.openecomp.appc.resource-version - the vnf version / service version
+ * @param ctx service logic context
+ * 1. supposed properties already in context:
+ * aai.input.data.entitlement-assignment-group-uuid - entitlement-group-uuid asset tag already stored in AAI
+ * aai.input.data.license-assignment-group-uuid - license-key-uuid asset tag already stored in AAI
+ * 2. properties and flags stored in context after bean execution:
+ * model.entitlement.pool.uuid - entitlement-group-uuid from license model
+ * model.license.key.uuid - license-key-uuid from license model
+ * is.acquire-entitlement.require
+ * is.release-entitlement.require
+ * is.acquire-license.require
+ * is.release-license.require
+ *
+ * @throws APPCException throws in case of any error
+ */
+ void retrieveLicenseModel(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/impl/LicenseManagerPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/impl/LicenseManagerPluginImpl.java
new file mode 100644
index 000000000..536a9916e
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/java/org/openecomp/appc/dg/licmgr/impl/LicenseManagerPluginImpl.java
@@ -0,0 +1,145 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.appc.dg.licmgr.impl;
+
+import java.util.Map;
+
+import org.openecomp.appc.dg.licmgr.LicenseManagerPlugin;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.licmgr.Constants;
+import org.openecomp.appc.licmgr.LicenseManager;
+import org.openecomp.appc.licmgr.exception.DataAccessException;
+import org.openecomp.appc.licmgr.objects.LicenseModel;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.openecomp.sdnc.sli.SvcLogicContext;
+
+
+
+public class LicenseManagerPluginImpl implements LicenseManagerPlugin {
+
+ private static EELFLogger logger = EELFManager.getInstance().getApplicationLogger();
+
+ // populated by blueprint framework
+ private LicenseManager licenseManager;
+
+ public void setLicenseManager(LicenseManager licenseManager) {
+ this.licenseManager = licenseManager;
+ }
+
+ /**
+ * Retrieves license model from APPC database and populate flags into svc context
+ * @param params map with parameters:
+ * org.openecomp.appc.vftype - the vnf type / service type;
+ * org.openecomp.appc.resource-version - the vnf version / service version
+ * @param ctx service logic context
+ * 1. supposed properties already in context:
+ * aai.input.data.entitlement-assignment-group-uuid - entitlement-group-uuid asset tag already stored in AAI
+ * aai.input.data.license-assignment-group-uuid - license-key-uuid asset tag already stored in AAI
+ * 2. properties and flags stored in context after bean execution:
+ * model.entitlement.pool.uuid - entitlement-group-uuid from license model
+ * model.license.key.uuid - license-key-uuid from license model
+ * is.acquire-entitlement.require
+ * is.release-entitlement.require
+ * is.acquire-license.require
+ * is.release-license.require
+ * is.aai-entitlement-update.require
+ * is.aai-license-update.require
+ *
+ * @throws APPCException throws in case of any error
+ */
+ @Override
+ public void retrieveLicenseModel(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+
+ try {
+
+ LicenseModel licenseModel = licenseManager.retrieveLicenseModel(params.get(Constants.VNF_TYPE_FIELD_NAME), params.get(Constants.VNF_RESOURCE_VERSION_FIELD_NAME));
+
+ String modelEntitlementPoolUuid = licenseModel.getEntitlementPoolUuid(); if (null == modelEntitlementPoolUuid) modelEntitlementPoolUuid = "";
+ String aaiEntitlementPoolUuid = ctx.getAttribute(Constants.AAI_ENTITLMENT_POOL_UUID_NAME); if (null == aaiEntitlementPoolUuid) aaiEntitlementPoolUuid = "";
+ boolean isAcquireEntitlementRequire = !modelEntitlementPoolUuid.isEmpty() && !modelEntitlementPoolUuid.equals(aaiEntitlementPoolUuid);
+ boolean isReleaseEntitlementRequire = !aaiEntitlementPoolUuid.isEmpty() && (isAcquireEntitlementRequire || modelEntitlementPoolUuid.isEmpty());
+ boolean isAAIEntitlementUpdateRequire = isAcquireEntitlementRequire || isReleaseEntitlementRequire;
+ ctx.setAttribute(Constants.MODEL_ENTITLMENT_POOL_UUID_NAME, modelEntitlementPoolUuid);
+ ctx.setAttribute(Constants.IS_ACQUIRE_ENTITLEMENT_REQUIRE, Boolean.toString(isAcquireEntitlementRequire));
+ ctx.setAttribute(Constants.IS_RELEASE_ENTITLEMENT_REQUIRE, Boolean.toString(isReleaseEntitlementRequire));
+ ctx.setAttribute(Constants.IS_AAI_ENTITLEMENT_UPDATE_REQUIRE, Boolean.toString(isAAIEntitlementUpdateRequire));
+
+
+ String modelLicenseKeyGroupUuid = licenseModel.getLicenseKeyGroupUuid(); if (null == modelLicenseKeyGroupUuid) modelLicenseKeyGroupUuid = "";
+ String aaiLicenseKeyGroupUuid = ctx.getAttribute(Constants.AAI_LICENSE_KEY_UUID_NAME); if (null == aaiLicenseKeyGroupUuid) aaiLicenseKeyGroupUuid = "";
+ String aaiLicenseKeyValue = ctx.getAttribute(Constants.AAI_LICENSE_KEY_VALUE); if (null == aaiLicenseKeyValue) aaiLicenseKeyValue = "";
+ boolean isAcquireLicenseRequire = !modelLicenseKeyGroupUuid.isEmpty() && !modelLicenseKeyGroupUuid.equals(aaiLicenseKeyGroupUuid);
+ boolean isReleaseLicenseRequire = !aaiLicenseKeyGroupUuid.isEmpty() && (isAcquireLicenseRequire || modelLicenseKeyGroupUuid.isEmpty());
+ boolean isAAILicenseUpdateRequire = isAcquireLicenseRequire || isReleaseLicenseRequire;
+ ctx.setAttribute(Constants.MODEL_LICENSE_KEY_UUID_NAME, modelLicenseKeyGroupUuid);
+ ctx.setAttribute(Constants.IS_ACQUIRE_LICENSE_REQUIRE, Boolean.toString(isAcquireLicenseRequire));
+ ctx.setAttribute(Constants.IS_RELEASE_LICENSE_REQUIRE, Boolean.toString(isReleaseLicenseRequire));
+ ctx.setAttribute(Constants.IS_AAI_LICENSE_UPDATE_REQUIRE, Boolean.toString(isAAILicenseUpdateRequire));
+
+ ctx.setAttribute("license-key", aaiLicenseKeyValue);
+
+ } catch (DataAccessException le) {
+ logger.error("Error " + le.getMessage());
+ ctx.setAttribute("output.status.message", le.getMessage());
+ throw new APPCException(le);
+ }
+
+ }
+
+
+
+ //////// code uses jaxb license model, should be fixed
+ /*
+ final VfLicenseModel.FeatureGroupList featureGroupList = licenseModel.getFeatureGroupList();
+ if (null != featureGroupList) {
+ final VfLicenseModel.FeatureGroupList.FeatureGroup featureGroup = featureGroupList.getFeatureGroup();
+ if (null != featureGroup) {
+ final VfLicenseModel.FeatureGroupList.FeatureGroup.EntitlementPoolList
+ entitlementPoolList = featureGroup.getEntitlementPoolList();
+ if (null != entitlementPoolList) {
+ final VfLicenseModel.FeatureGroupList.FeatureGroup.EntitlementPoolList.EntitlementPool
+ entitlementPool = entitlementPoolList.getEntitlementPool();
+ if (null != entitlementPool) {
+ final String entitlementPoolUuid = entitlementPool.getEntitlementPoolUuid();
+ // add entitlementPoolUuid into context
+ ctx.setAttribute(Constants.MODEL_ENTITLMENT_POOL_UUID_NAME, entitlementPoolUuid);
+ }
+ }
+
+ final VfLicenseModel.FeatureGroupList.FeatureGroup.LicenseKeyGroupList
+ licenseKeyGroupList = featureGroup.getLicenseKeyGroupList();
+ if (null != licenseKeyGroupList) {
+ final VfLicenseModel.FeatureGroupList.FeatureGroup.LicenseKeyGroupList.LicenseKeyGroup
+ licenseKeyGroup = licenseKeyGroupList.getLicenseKeyGroup();
+ if (null != licenseKeyGroup) {
+ final String licenseKeyGroupUuid = licenseKeyGroup.getLicenseKeyGroupUuid();
+ // add licenseKeyGroupUuid into context
+ ctx.setAttribute(Constants.MODEL_LICENSE_KEY_UUID_NAME, licenseKeyGroupUuid);
+ }
+ }
+ }
+ }
+ */
+
+
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100644
index 000000000..ab2df8ba9
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-license-manager/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : APP-C
+ ================================================================================
+ Copyright (C) 2017 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=========================================================
+ -->
+
+<!--
+ Starter Blueprint Camel Definition appc-aai-adapter-blueprint
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+
+ <reference id="LicenseManagerRef" availability="mandatory" activation="eager" interface="org.openecomp.appc.licmgr.LicenseManager" />
+
+ <bean id="LicenseManagerPluginBean" class="org.openecomp.appc.dg.licmgr.impl.LicenseManagerPluginImpl" scope="singleton">
+ <property name="licenseManager" ref="LicenseManagerRef" />
+ </bean>
+ <service id="LicenseManagerPlugin" interface="org.openecomp.appc.dg.licmgr.LicenseManagerPlugin" ref="LicenseManagerPluginBean"/>
+
+</blueprint>