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.openecomp.sdc.vendorlicense.impl;
23 import org.openecomp.core.util.UniqueValueUtil;
24 import org.openecomp.sdc.activityLog.ActivityLogManager;
25 import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
26 import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
27 import org.openecomp.sdc.datatypes.error.ErrorLevel;
28 import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
29 import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
30 import org.openecomp.sdc.logging.types.LoggerConstants;
31 import org.openecomp.sdc.logging.types.LoggerErrorCode;
32 import org.openecomp.sdc.logging.types.LoggerErrorDescription;
33 import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
34 import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
35 import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
36 import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
37 import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
38 import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
39 import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory;
40 import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
41 import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory;
42 import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
43 import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory;
44 import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
45 import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory;
46 import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
47 import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
48 import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel;
49 import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
50 import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel;
51 import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
52 import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
53 import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
54 import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
55 import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
56 import org.openecomp.sdc.versioning.VersioningManager;
57 import org.openecomp.sdc.versioning.VersioningManagerFactory;
58 import org.openecomp.sdc.versioning.VersioningUtil;
59 import org.openecomp.sdc.versioning.dao.types.Version;
60 import org.openecomp.sdc.versioning.dao.types.VersionStatus;
61 import org.openecomp.sdc.versioning.types.VersionInfo;
62 import org.openecomp.sdc.versioning.types.VersionableEntityAction;
63 import org.openecomp.sdcrests.activitylog.types.ActivityType;
65 import java.util.ArrayList;
66 import java.util.Collection;
67 import java.util.List;
71 import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
73 public class VendorLicenseManagerImpl implements VendorLicenseManager {
74 private static final VersioningManager versioningManager =
75 VersioningManagerFactory.getInstance().createInterface();
76 private static final VendorLicenseFacade vendorLicenseFacade =
77 VendorLicenseFacadeFactory.getInstance().createInterface();
78 private static final VendorLicenseModelDao vendorLicenseModelDao =
79 VendorLicenseModelDaoFactory.getInstance().createInterface();
80 private static final LicenseAgreementDao licenseAgreementDao =
81 LicenseAgreementDaoFactory.getInstance().createInterface();
82 private static final FeatureGroupDao featureGroupDao =
83 FeatureGroupDaoFactory.getInstance().createInterface();
84 private static final EntitlementPoolDao entitlementPoolDao =
85 EntitlementPoolDaoFactory.getInstance().createInterface();
86 private static final LicenseKeyGroupDao licenseKeyGroupDao =
87 LicenseKeyGroupDaoFactory.getInstance().createInterface();
88 private ActivityLogManager activityLogManager = ActivityLogManagerFactory.getInstance().createInterface();
89 private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
91 private static void sortVlmListByModificationTimeDescOrder(
92 List<VersionedVendorLicenseModel> vendorLicenseModels) {
93 vendorLicenseModels.sort((o1, o2) -> o2.getVendorLicenseModel().getWritetimeMicroSeconds()
94 .compareTo(o1.getVendorLicenseModel().getWritetimeMicroSeconds()));
98 public void checkout(String vendorLicenseModelId, String user) {
100 mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
102 Version newVersion = versioningManager
103 .checkout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user);
105 ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor()+1),
106 ActivityType.CHECKOUT.toString(), user, true, "", "");
107 activityLogManager.addActionLog(activityLogEntity, user);
109 newVersion.setStatus(VersionStatus.Locked);
110 vendorLicenseFacade.updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
112 mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
116 public void undoCheckout(String vendorLicenseModelId, String user) {
118 mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
120 Version newVersion = versioningManager
121 .undoCheckout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user);
122 vendorLicenseFacade.updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
124 mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
128 public void checkin(String vendorLicenseModelId, String user) {
130 mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
132 Version newVersion = vendorLicenseFacade.checkin(vendorLicenseModelId, user);
134 ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId,
135 String.valueOf(newVersion.getMajor()+1), ActivityType.CHECKIN.toString(), user, true, "", "");
136 activityLogManager.addActionLog(activityLogEntity, user);
138 mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
142 public void submit(String vendorLicenseModelId, String user) {
144 mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
146 Version newVersion = vendorLicenseFacade.submit(vendorLicenseModelId, user);
148 ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor()),
149 ActivityType.SUBMIT.toString(), user, true, "", "");
150 activityLogManager.addActionLog(activityLogEntity, user);
152 mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
156 public Collection<VersionedVendorLicenseModel> listVendorLicenseModels(String versionFilter,
158 mdcDataDebugMessage.debugEntryMessage(null);
160 Map<String, VersionInfo> idToVersionsInfo = versioningManager
161 .listEntitiesVersionInfo(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, user,
162 VersionableEntityAction.Read);
164 List<VersionedVendorLicenseModel> vendorLicenseModels = new ArrayList<>();
165 for (Map.Entry<String, VersionInfo> entry : idToVersionsInfo.entrySet()) {
166 VersionInfo versionInfo = entry.getValue();
167 if (versionFilter != null && versionFilter.equals(VersionStatus.Final.name())) {
168 if (versionInfo.getLatestFinalVersion() == null) {
171 versionInfo.setActiveVersion(versionInfo.getLatestFinalVersion());
172 versionInfo.setStatus(VersionStatus.Final);
173 versionInfo.setLockingUser(null);
176 Version version = versionInfo.getActiveVersion();
177 if (user.equals(versionInfo.getLockingUser())) {
178 version.setStatus(VersionStatus.Locked);
181 VendorLicenseModelEntity vlm =
182 vendorLicenseModelDao.get(new VendorLicenseModelEntity(entry.getKey(), version));
184 VersionedVendorLicenseModel versionedVlm = new VersionedVendorLicenseModel();
185 versionedVlm.setVendorLicenseModel(vlm);
186 versionedVlm.setVersionInfo(versionInfo);
187 vendorLicenseModels.add(versionedVlm);
191 sortVlmListByModificationTimeDescOrder(vendorLicenseModels);
193 mdcDataDebugMessage.debugExitMessage(null);
194 return vendorLicenseModels;
198 public VendorLicenseModelEntity createVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity, String user) {
200 VendorLicenseModelEntity vendorLicenseModelCreated = vendorLicenseFacade.createVendorLicenseModel(vendorLicenseModelEntity, user);
202 ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelCreated.getId(),
203 String.valueOf(vendorLicenseModelCreated.getVersion().getMajor()+1),
204 ActivityType.CREATE_NEW.toString(), user, true, "", "");
205 activityLogManager.addActionLog(activityLogEntity, user);
207 return vendorLicenseModelCreated;
211 public void updateVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity,
213 mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelEntity.getId());
215 Version version = VersioningUtil.resolveVersion(null,
216 getVersionInfo(vendorLicenseModelEntity.getId(), VersionableEntityAction.Write, user),
218 vendorLicenseModelEntity.setVersion(version);
220 String existingVendorName = vendorLicenseModelDao.get(vendorLicenseModelEntity).getVendorName();
222 .updateUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME, existingVendorName,
223 vendorLicenseModelEntity.getVendorName());
224 vendorLicenseModelDao.update(vendorLicenseModelEntity);
227 .updateVlmLastModificationTime(vendorLicenseModelEntity.getId(), version);
229 mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelEntity.getId());
233 public VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version,
235 return vendorLicenseFacade.getVendorLicenseModel(vlmId, version, user);
239 public void deleteVendorLicenseModel(String vlmId, String user) {
240 MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
241 LoggerTragetServiceName.DELETE_ENTITY, ErrorLevel.ERROR.name(),
242 LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION);
243 throw new UnsupportedOperationException(VendorLicenseConstants.UNSUPPORTED_OPERATION_ERROR);
247 public Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version,
249 mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
250 mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
251 return licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, VersioningUtil
252 .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
257 public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement,
260 .debugEntryMessage("VLM id", licenseAgreement.getVendorLicenseModelId());
262 .debugExitMessage("VLM id", licenseAgreement.getVendorLicenseModelId());
263 return vendorLicenseFacade.createLicenseAgreement(licenseAgreement, user);
267 public void updateLicenseAgreement(LicenseAgreementEntity licenseAgreement,
268 Set<String> addedFeatureGroupIds,
269 Set<String> removedFeatureGroupIds, String user) {
270 mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", licenseAgreement
271 .getVendorLicenseModelId(), licenseAgreement.getId());
273 Version version = VersioningUtil.resolveVersion(licenseAgreement.getVersion(),
274 getVersionInfo(licenseAgreement.getVendorLicenseModelId(), VersionableEntityAction.Write,
276 licenseAgreement.setVersion(version);
277 LicenseAgreementEntity retrieved = licenseAgreementDao.get(licenseAgreement);
279 .validateEntityExistence(retrieved, licenseAgreement, VendorLicenseModelEntity.ENTITY_TYPE);
280 VersioningUtil.validateContainedEntitiesExistence(new FeatureGroupEntity().getEntityType(),
281 removedFeatureGroupIds, retrieved, retrieved.getFeatureGroupIds());
282 VersioningUtil.validateEntitiesExistence(addedFeatureGroupIds,
283 new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), version, null),
284 featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
286 UniqueValueUtil.updateUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
287 retrieved.getName(), licenseAgreement.getName(), licenseAgreement.getVendorLicenseModelId(),
288 licenseAgreement.getVersion().toString());
289 licenseAgreementDao.updateColumnsAndDeltaFeatureGroupIds(licenseAgreement, addedFeatureGroupIds,
290 removedFeatureGroupIds);
292 addFeatureGroupsToLicenseAgreementRef(addedFeatureGroupIds, licenseAgreement);
293 removeFeatureGroupsToLicenseAgreementRef(removedFeatureGroupIds, licenseAgreement);
296 .updateVlmLastModificationTime(licenseAgreement.getVendorLicenseModelId(), version);
298 mdcDataDebugMessage.debugExitMessage("VLM id, LA id", licenseAgreement
299 .getVendorLicenseModelId(), licenseAgreement.getId());
303 public LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
304 String licenseAgreementId, String user) {
306 mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId);
307 mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId);
308 return vendorLicenseFacade.getLicenseAgreementModel(vlmId, version, licenseAgreementId, user);
312 public void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId,
314 mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId);
316 version = VersioningUtil
317 .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Write, user), user);
318 LicenseAgreementEntity input =
319 new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
320 LicenseAgreementEntity retrieved = licenseAgreementDao.get(input);
321 VersioningUtil.validateEntityExistence(retrieved, input, VendorLicenseModelEntity.ENTITY_TYPE);
323 removeFeatureGroupsToLicenseAgreementRef(retrieved.getFeatureGroupIds(), retrieved);
325 licenseAgreementDao.delete(input);
326 UniqueValueUtil.deleteUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
327 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
328 retrieved.getName());
331 .updateVlmLastModificationTime(input.getVendorLicenseModelId(), input.getVersion());
333 mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId);
337 public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version,
339 mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
340 mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
341 return featureGroupDao.list(new FeatureGroupEntity(vlmId, VersioningUtil
342 .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
347 public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user) {
349 .debugEntryMessage("VLM id", featureGroup.getVendorLicenseModelId());
350 mdcDataDebugMessage.debugExitMessage("VLM id", featureGroup.getId());
351 return vendorLicenseFacade.createFeatureGroup(featureGroup, user);
355 public void updateFeatureGroup(FeatureGroupEntity featureGroup,
356 Set<String> addedLicenseKeyGroups,
357 Set<String> removedLicenseKeyGroups,
358 Set<String> addedEntitlementPools,
359 Set<String> removedEntitlementPools,
361 mdcDataDebugMessage.debugEntryMessage("VLM id, FG id", featureGroup
362 .getVendorLicenseModelId(), featureGroup.getId());
364 Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
365 getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write, user),
367 featureGroup.setVersion(version);
369 FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
371 .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
373 VersioningUtil.validateContainedEntitiesExistence(new LicenseKeyGroupEntity().getEntityType(),
374 removedLicenseKeyGroups, retrieved, retrieved.getLicenseKeyGroupIds());
375 VersioningUtil.validateContainedEntitiesExistence(new EntitlementPoolEntity().getEntityType(),
376 removedEntitlementPools, retrieved, retrieved.getEntitlementPoolIds());
378 VersioningUtil.validateEntitiesExistence(addedLicenseKeyGroups,
379 new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), version, null),
380 licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
381 VersioningUtil.validateEntitiesExistence(addedEntitlementPools,
382 new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), version, null),
383 entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
384 UniqueValueUtil.updateUniqueValue(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
385 retrieved.getName(), featureGroup.getName(), featureGroup.getVendorLicenseModelId(),
386 featureGroup.getVersion().toString());
388 addLicenseKeyGroupsToFeatureGroupsRef(addedLicenseKeyGroups, featureGroup);
389 removeLicenseKeyGroupsToFeatureGroupsRef(removedLicenseKeyGroups, featureGroup);
390 addEntitlementPoolsToFeatureGroupsRef(addedEntitlementPools, featureGroup);
391 removeEntitlementPoolsToFeatureGroupsRef(removedEntitlementPools, featureGroup);
393 featureGroupDao.updateFeatureGroup(featureGroup, addedEntitlementPools, removedEntitlementPools,
394 addedLicenseKeyGroups, removedLicenseKeyGroups);
397 .updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(), version);
399 mdcDataDebugMessage.debugExitMessage("VLM id, FG id", featureGroup
400 .getVendorLicenseModelId(), featureGroup.getId());
404 public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user) {
405 mdcDataDebugMessage.debugEntryMessage("VLM id, FG id",
406 featureGroup.getVendorLicenseModelId(), featureGroup.getId());
408 mdcDataDebugMessage.debugExitMessage("VLM id, FG id",
409 featureGroup.getVendorLicenseModelId(), featureGroup.getId());
410 return vendorLicenseFacade.getFeatureGroupModel(featureGroup, user);
414 public void deleteFeatureGroup(FeatureGroupEntity featureGroup, String user) {
415 mdcDataDebugMessage.debugEntryMessage("VLM id, FG id",
416 featureGroup.getVendorLicenseModelId(), featureGroup.getId());
418 Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
419 getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
421 featureGroup.setVersion(version);
422 FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
424 .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
426 removeLicenseKeyGroupsToFeatureGroupsRef(retrieved.getLicenseKeyGroupIds(), featureGroup);
427 removeEntitlementPoolsToFeatureGroupsRef(retrieved.getEntitlementPoolIds(), featureGroup);
429 for (String licenceAgreementId : retrieved.getReferencingLicenseAgreements()) {
430 licenseAgreementDao.removeFeatureGroup(
431 new LicenseAgreementEntity(featureGroup.getVendorLicenseModelId(), version,
432 licenceAgreementId), featureGroup.getId());
435 featureGroupDao.delete(featureGroup);
436 UniqueValueUtil.deleteUniqueValue(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
437 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
438 retrieved.getName());
440 vendorLicenseFacade.updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(),
441 featureGroup.getVersion());
444 .debugExitMessage("VLM id, FG id",
445 featureGroup.getVendorLicenseModelId(), featureGroup.getId());
449 public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version,
451 mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
452 mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
453 return vendorLicenseFacade.listEntitlementPools(vlmId, version, user);
457 public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool,
460 .debugEntryMessage("VLM id", entitlementPool.getVendorLicenseModelId());
462 .debugExitMessage("VLM id", entitlementPool.getVendorLicenseModelId());
463 return vendorLicenseFacade.createEntitlementPool(entitlementPool, user);
467 public void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user) {
468 mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool
469 .getVendorLicenseModelId(), entitlementPool.getId());
471 Version version = VersioningUtil.resolveVersion(entitlementPool.getVersion(),
472 getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
475 .updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(), version);
476 vendorLicenseFacade.updateEntitlementPool(entitlementPool, user);
478 mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool
479 .getVendorLicenseModelId(), entitlementPool.getId());
483 public EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool,
485 mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool
486 .getVendorLicenseModelId(), entitlementPool.getId());
488 entitlementPool.setVersion(VersioningUtil.resolveVersion(entitlementPool.getVersion(),
489 getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Read,
492 EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
494 .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
496 mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool
497 .getVendorLicenseModelId(), entitlementPool.getId());
502 public void deleteEntitlementPool(EntitlementPoolEntity entitlementPool, String user) {
503 mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool
504 .getVendorLicenseModelId(), entitlementPool.getId());
506 Version version = VersioningUtil.resolveVersion(entitlementPool.getVersion(),
507 getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
509 entitlementPool.setVersion(version);
511 EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
513 .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
515 for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
516 featureGroupDao.removeEntitlementPool(
517 new FeatureGroupEntity(entitlementPool.getVendorLicenseModelId(), version,
518 referencingFeatureGroupId), entitlementPool.getId());
521 entitlementPoolDao.delete(entitlementPool);
523 UniqueValueUtil.deleteUniqueValue(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
524 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
525 retrieved.getName());
527 vendorLicenseFacade.updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(),
528 entitlementPool.getVersion());
530 mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool
531 .getVendorLicenseModelId(), entitlementPool.getId());
535 public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
537 mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
538 mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
539 return vendorLicenseFacade.listLicenseKeyGroups(vlmId, version, user);
543 public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
546 .debugEntryMessage("VLM id", licenseKeyGroup.getVendorLicenseModelId());
548 mdcDataDebugMessage.debugExitMessage("VLM id", licenseKeyGroup
549 .getVendorLicenseModelId());
550 return vendorLicenseFacade.createLicenseKeyGroup(licenseKeyGroup, user);
554 public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) {
555 mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup
556 .getVendorLicenseModelId(), licenseKeyGroup.getId());
558 Version version = VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
559 getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
562 .updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(), version);
564 vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroup, user);
566 mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup
567 .getVendorLicenseModelId(), licenseKeyGroup.getId());
571 public LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
573 mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup
574 .getVendorLicenseModelId(), licenseKeyGroup.getId());
576 licenseKeyGroup.setVersion(VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
577 getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Read,
580 LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
582 .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
584 mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup
585 .getVendorLicenseModelId(), licenseKeyGroup.getId());
590 public void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) {
591 mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup
592 .getVendorLicenseModelId(), licenseKeyGroup.getId());
594 Version version = VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
595 getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
597 licenseKeyGroup.setVersion(version);
599 LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
601 .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
603 for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
604 featureGroupDao.removeLicenseKeyGroup(
605 new FeatureGroupEntity(licenseKeyGroup.getVendorLicenseModelId(), version,
606 referencingFeatureGroupId), licenseKeyGroup.getId());
609 licenseKeyGroupDao.delete(licenseKeyGroup);
611 UniqueValueUtil.deleteUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
612 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
613 retrieved.getName());
615 vendorLicenseFacade.updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(),
616 licenseKeyGroup.getVersion());
618 mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup
619 .getVendorLicenseModelId(), licenseKeyGroup.getId());
622 private void addFeatureGroupsToLicenseAgreementRef(Set<String> featureGroupIds,
623 LicenseAgreementEntity licenseAgreement) {
624 if (featureGroupIds != null) {
625 for (String featureGroupId : featureGroupIds) {
626 featureGroupDao.addReferencingLicenseAgreement(
627 new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
628 licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
633 private void removeFeatureGroupsToLicenseAgreementRef(Set<String> featureGroupIds,
634 LicenseAgreementEntity licenseAgreement) {
635 if (featureGroupIds != null) {
636 for (String featureGroupId : featureGroupIds) {
637 featureGroupDao.removeReferencingLicenseAgreement(
638 new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
639 licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
644 private void addLicenseKeyGroupsToFeatureGroupsRef(Set<String> licenseKeyGroupIds,
645 FeatureGroupEntity featureGroup) {
646 if (licenseKeyGroupIds != null) {
647 for (String licenseKeyGroupId : licenseKeyGroupIds) {
648 licenseKeyGroupDao.addReferencingFeatureGroup(
649 new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
650 featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
655 private void removeLicenseKeyGroupsToFeatureGroupsRef(Set<String> licenseKeyGroupIds,
656 FeatureGroupEntity featureGroup) {
657 if (licenseKeyGroupIds != null) {
658 for (String licenseKeyGroupId : licenseKeyGroupIds) {
659 licenseKeyGroupDao.removeReferencingFeatureGroup(
660 new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
661 featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
666 private void addEntitlementPoolsToFeatureGroupsRef(Set<String> entitlementPoolIds,
667 FeatureGroupEntity featureGroup) {
668 if (entitlementPoolIds != null) {
669 for (String entitlementPoolId : entitlementPoolIds) {
670 entitlementPoolDao.addReferencingFeatureGroup(
671 new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
672 featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
677 private void removeEntitlementPoolsToFeatureGroupsRef(Set<String> entitlementPoolIds,
678 FeatureGroupEntity featureGroup) {
679 if (entitlementPoolIds != null) {
680 for (String entitlementPoolId : entitlementPoolIds) {
681 entitlementPoolDao.removeReferencingFeatureGroup(
682 new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
683 featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
688 private VersionInfo getVersionInfo(String vendorLicenseModelId, VersionableEntityAction action,
690 return vendorLicenseFacade.getVersionInfo(vendorLicenseModelId, action, user);