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 static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
25 import org.openecomp.core.util.UniqueValueUtil;
26 import org.openecomp.sdc.activityLog.ActivityLogManager;
27 import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
28 import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
29 import org.openecomp.sdc.common.errors.CoreException;
30 import org.openecomp.sdc.common.errors.ErrorCode;
31 import org.openecomp.sdc.datatypes.error.ErrorLevel;
32 import org.openecomp.sdc.logging.api.Logger;
33 import org.openecomp.sdc.logging.api.LoggerFactory;
34 import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
35 import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
36 import org.openecomp.sdc.logging.types.LoggerConstants;
37 import org.openecomp.sdc.logging.types.LoggerErrorCode;
38 import org.openecomp.sdc.logging.types.LoggerErrorDescription;
39 import org.openecomp.sdc.logging.types.LoggerServiceName;
40 import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
41 import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
42 import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
43 import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
44 import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
45 import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
46 import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory;
47 import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
48 import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory;
49 import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
50 import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory;
51 import org.openecomp.sdc.vendorlicense.dao.LimitDao;
52 import org.openecomp.sdc.vendorlicense.dao.LimitDaoFactory;
53 import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
54 import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory;
55 import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
56 import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
57 import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel;
58 import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
59 import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel;
60 import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
61 import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
62 import org.openecomp.sdc.vendorlicense.dao.types.LimitType;
63 import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
64 import org.openecomp.sdc.vendorlicense.errors.InvalidDateErrorBuilder;
65 import org.openecomp.sdc.vendorlicense.errors.LimitErrorBuilder;
66 import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
67 import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
68 import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
69 import org.openecomp.sdc.versioning.VersioningManager;
70 import org.openecomp.sdc.versioning.VersioningManagerFactory;
71 import org.openecomp.sdc.versioning.VersioningUtil;
72 import org.openecomp.sdc.versioning.dao.types.Version;
73 import org.openecomp.sdc.versioning.dao.types.VersionStatus;
74 import org.openecomp.sdc.versioning.types.VersionInfo;
75 import org.openecomp.sdc.versioning.types.VersionableEntityAction;
76 import org.openecomp.sdcrests.activitylog.types.ActivityType;
78 import java.time.LocalDate;
79 import java.time.format.DateTimeFormatter;
80 import java.util.ArrayList;
81 import java.util.Collection;
82 import java.util.List;
84 import java.util.Optional;
87 public class VendorLicenseManagerImpl implements VendorLicenseManager {
88 private VersioningManager versioningManager;
89 private VendorLicenseFacade vendorLicenseFacade;
90 private VendorLicenseModelDao vendorLicenseModelDao;
91 private LicenseAgreementDao licenseAgreementDao;
92 private FeatureGroupDao featureGroupDao;
93 private EntitlementPoolDao entitlementPoolDao;
94 private LicenseKeyGroupDao licenseKeyGroupDao;
95 private LimitDao limitDao;
96 private ActivityLogManager activityLogManager;
98 private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
99 private static final Logger logger =
100 LoggerFactory.getLogger(VendorLicenseManagerImpl.class);
102 public VendorLicenseManagerImpl(VersioningManager versioningManager,
103 VendorLicenseFacade vendorLicenseFacade,
104 VendorLicenseModelDao vendorLicenseModelDao,
105 LicenseAgreementDao licenseAgreementDao,
106 FeatureGroupDao featureGroupDao,
107 EntitlementPoolDao entitlementPoolDao,
108 LicenseKeyGroupDao licenseKeyGroupDao,
109 ActivityLogManager activityLogManager,
111 this.versioningManager = versioningManager;
112 this.vendorLicenseFacade = vendorLicenseFacade;
113 this.vendorLicenseModelDao = vendorLicenseModelDao;
114 this.licenseAgreementDao = licenseAgreementDao;
115 this.featureGroupDao = featureGroupDao;
116 this.entitlementPoolDao = entitlementPoolDao;
117 this.licenseKeyGroupDao = licenseKeyGroupDao;
118 this.activityLogManager = activityLogManager;
119 this.limitDao = limitDao;
123 private static void sortVlmListByModificationTimeDescOrder(
124 List<VersionedVendorLicenseModel> vendorLicenseModels) {
125 vendorLicenseModels.sort((o1, o2) -> o2.getVendorLicenseModel().getWritetimeMicroSeconds()
126 .compareTo(o1.getVendorLicenseModel().getWritetimeMicroSeconds()));
130 public void checkout(String vendorLicenseModelId, String user) {
132 mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
134 Version newVersion = versioningManager
135 .checkout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user);
137 ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor()+1),
138 ActivityType.CHECKOUT.toString(), user, true, "", "");
139 activityLogManager.addActionLog(activityLogEntity, user);
141 newVersion.setStatus(VersionStatus.Locked);
142 vendorLicenseFacade.updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
144 mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
148 public void undoCheckout(String vendorLicenseModelId, String user) {
150 mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
152 Version newVersion = versioningManager
153 .undoCheckout(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user);
154 vendorLicenseFacade.updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
156 mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
160 public void checkin(String vendorLicenseModelId, String user) {
162 mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
164 Version newVersion = vendorLicenseFacade.checkin(vendorLicenseModelId, user);
166 ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId,
167 String.valueOf(newVersion.getMajor()+1), ActivityType.CHECKIN.toString(), user, true, "", "");
168 activityLogManager.addActionLog(activityLogEntity, user);
170 mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
174 public void submit(String vendorLicenseModelId, String user) {
176 mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelId);
178 Version newVersion = vendorLicenseFacade.submit(vendorLicenseModelId, user);
180 ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelId, String.valueOf(newVersion.getMajor()),
181 ActivityType.SUBMIT.toString(), user, true, "", "");
182 activityLogManager.addActionLog(activityLogEntity, user);
184 mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelId);
188 public Collection<VersionedVendorLicenseModel> listVendorLicenseModels(String versionFilter,
190 mdcDataDebugMessage.debugEntryMessage(null);
192 Map<String, VersionInfo> idToVersionsInfo = versioningManager
193 .listEntitiesVersionInfo(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, user,
194 VersionableEntityAction.Read);
196 List<VersionedVendorLicenseModel> vendorLicenseModels = new ArrayList<>();
197 for (Map.Entry<String, VersionInfo> entry : idToVersionsInfo.entrySet()) {
198 VersionInfo versionInfo = entry.getValue();
199 if (versionFilter != null && versionFilter.equals(VersionStatus.Final.name())) {
200 if (versionInfo.getLatestFinalVersion() == null) {
203 versionInfo.setActiveVersion(versionInfo.getLatestFinalVersion());
204 versionInfo.setStatus(VersionStatus.Final);
205 versionInfo.setLockingUser(null);
208 Version version = versionInfo.getActiveVersion();
209 if (user.equals(versionInfo.getLockingUser())) {
210 version.setStatus(VersionStatus.Locked);
214 VendorLicenseModelEntity vlm =
215 vendorLicenseModelDao.get(new VendorLicenseModelEntity(entry.getKey(), version));
217 VersionedVendorLicenseModel versionedVlm = new VersionedVendorLicenseModel();
218 versionedVlm.setVendorLicenseModel(vlm);
219 versionedVlm.setVersionInfo(versionInfo);
220 vendorLicenseModels.add(versionedVlm);
222 }catch(RuntimeException rte){
223 logger.error("Error trying to retrieve vlm["+entry.getKey()+"] version["+version.toString
230 sortVlmListByModificationTimeDescOrder(vendorLicenseModels);
232 mdcDataDebugMessage.debugExitMessage(null);
233 return vendorLicenseModels;
237 public VendorLicenseModelEntity createVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity, String user) {
239 VendorLicenseModelEntity vendorLicenseModelCreated = vendorLicenseFacade.createVendorLicenseModel(vendorLicenseModelEntity, user);
241 ActivityLogEntity activityLogEntity = new ActivityLogEntity(vendorLicenseModelCreated.getId(),
242 String.valueOf(vendorLicenseModelCreated.getVersion().getMajor()+1),
243 ActivityType.CREATE_NEW.toString(), user, true, "", "");
244 activityLogManager.addActionLog(activityLogEntity, user);
246 return vendorLicenseModelCreated;
250 public void updateVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity,
252 mdcDataDebugMessage.debugEntryMessage("VLM id", vendorLicenseModelEntity.getId());
254 Version version = resloveVersion(vendorLicenseModelEntity.getId(),null,
255 getVersionInfo(vendorLicenseModelEntity.getId(), VersionableEntityAction.Write, user),
257 vendorLicenseModelEntity.setVersion(version);
259 String existingVendorName = vendorLicenseModelDao.get(vendorLicenseModelEntity).getVendorName();
261 updateUniqueName(VendorLicenseConstants.UniqueValues.VENDOR_NAME, existingVendorName,
262 vendorLicenseModelEntity.getVendorName());
263 vendorLicenseModelDao.update(vendorLicenseModelEntity);
266 .updateVlmLastModificationTime(vendorLicenseModelEntity.getId(), version);
268 mdcDataDebugMessage.debugExitMessage("VLM id", vendorLicenseModelEntity.getId());
272 public VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version,
274 return vendorLicenseFacade.getVendorLicenseModel(vlmId, version, user);
278 public void deleteVendorLicenseModel(String vlmId, String user) {
279 MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
280 LoggerTragetServiceName.DELETE_ENTITY, ErrorLevel.ERROR.name(),
281 LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.UNSUPPORTED_OPERATION);
282 throw new UnsupportedOperationException(VendorLicenseConstants.UNSUPPORTED_OPERATION_ERROR);
286 public Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version,
288 mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
289 mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
290 LicenseAgreementEntity licenseAgreementEntity = createLicenseAgreementForList(vlmId, version,
292 // return licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, VersioningUtil
293 // .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
295 return licenseAgreementDao.list(licenseAgreementEntity);
299 public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement,
302 .debugEntryMessage("VLM id", licenseAgreement.getVendorLicenseModelId());
304 .debugExitMessage("VLM id", licenseAgreement.getVendorLicenseModelId());
305 return vendorLicenseFacade.createLicenseAgreement(licenseAgreement, user);
309 public void updateLicenseAgreement(LicenseAgreementEntity licenseAgreement,
310 Set<String> addedFeatureGroupIds,
311 Set<String> removedFeatureGroupIds, String user) {
312 mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", licenseAgreement
313 .getVendorLicenseModelId(), licenseAgreement.getId());
315 Version version = VersioningUtil.resolveVersion(licenseAgreement.getVersion(),
316 getVersionInfo(licenseAgreement.getVendorLicenseModelId(), VersionableEntityAction.Write,
318 licenseAgreement.setVersion(version);
319 LicenseAgreementEntity retrieved = licenseAgreementDao.get(licenseAgreement);
321 .validateEntityExistence(retrieved, licenseAgreement, VendorLicenseModelEntity.ENTITY_TYPE);
322 VersioningUtil.validateContainedEntitiesExistence(new FeatureGroupEntity().getEntityType(),
323 removedFeatureGroupIds, retrieved, retrieved.getFeatureGroupIds());
324 VersioningUtil.validateEntitiesExistence(addedFeatureGroupIds,
325 new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), version, null),
326 featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
328 updateUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
329 retrieved.getName(), licenseAgreement.getName(), licenseAgreement.getVendorLicenseModelId(),
330 licenseAgreement.getVersion().toString());
331 licenseAgreementDao.updateColumnsAndDeltaFeatureGroupIds(licenseAgreement, addedFeatureGroupIds,
332 removedFeatureGroupIds);
334 addFeatureGroupsToLicenseAgreementRef(addedFeatureGroupIds, licenseAgreement);
335 removeFeatureGroupsToLicenseAgreementRef(removedFeatureGroupIds, licenseAgreement);
338 .updateVlmLastModificationTime(licenseAgreement.getVendorLicenseModelId(), version);
340 mdcDataDebugMessage.debugExitMessage("VLM id, LA id", licenseAgreement
341 .getVendorLicenseModelId(), licenseAgreement.getId());
345 public LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
346 String licenseAgreementId, String user) {
348 mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId);
349 mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId);
350 return vendorLicenseFacade.getLicenseAgreementModel(vlmId, version, licenseAgreementId, user);
354 public void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId,
356 mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId);
358 version = VersioningUtil
359 .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Write, user), user);
360 LicenseAgreementEntity input =
361 new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
362 LicenseAgreementEntity retrieved = licenseAgreementDao.get(input);
363 VersioningUtil.validateEntityExistence(retrieved, input, VendorLicenseModelEntity.ENTITY_TYPE);
365 removeFeatureGroupsToLicenseAgreementRef(retrieved.getFeatureGroupIds(), retrieved);
367 licenseAgreementDao.delete(retrieved);
369 deleteUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
370 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
371 retrieved.getName());
374 .updateVlmLastModificationTime(input.getVendorLicenseModelId(), input.getVersion());
376 mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId);
380 public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version,
382 mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
383 mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
384 return vendorLicenseFacade.listFeatureGroups(vlmId, version, user);
388 public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user) {
390 .debugEntryMessage("VLM id", featureGroup.getVendorLicenseModelId());
391 mdcDataDebugMessage.debugExitMessage("VLM id", featureGroup.getId());
392 return vendorLicenseFacade.createFeatureGroup(featureGroup, user);
396 public void updateFeatureGroup(FeatureGroupEntity featureGroup,
397 Set<String> addedLicenseKeyGroups,
398 Set<String> removedLicenseKeyGroups,
399 Set<String> addedEntitlementPools,
400 Set<String> removedEntitlementPools,
402 mdcDataDebugMessage.debugEntryMessage("VLM id, FG id", featureGroup
403 .getVendorLicenseModelId(), featureGroup.getId());
405 Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
406 getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write, user),
408 featureGroup.setVersion(version);
410 FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
412 .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
414 VersioningUtil.validateContainedEntitiesExistence(new LicenseKeyGroupEntity().getEntityType(),
415 removedLicenseKeyGroups, retrieved, retrieved.getLicenseKeyGroupIds());
416 VersioningUtil.validateContainedEntitiesExistence(new EntitlementPoolEntity().getEntityType(),
417 removedEntitlementPools, retrieved, retrieved.getEntitlementPoolIds());
419 VersioningUtil.validateEntitiesExistence(addedLicenseKeyGroups,
420 new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), version, null),
421 licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
422 VersioningUtil.validateEntitiesExistence(addedEntitlementPools,
423 new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), version, null),
424 entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
426 updateUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
427 retrieved.getName(), featureGroup.getName(), featureGroup.getVendorLicenseModelId(),
428 featureGroup.getVersion().toString());
430 addLicenseKeyGroupsToFeatureGroupsRef(addedLicenseKeyGroups, featureGroup);
431 removeLicenseKeyGroupsToFeatureGroupsRef(removedLicenseKeyGroups, featureGroup);
432 addEntitlementPoolsToFeatureGroupsRef(addedEntitlementPools, featureGroup);
433 removeEntitlementPoolsToFeatureGroupsRef(removedEntitlementPools, featureGroup);
435 featureGroupDao.updateFeatureGroup(featureGroup, addedEntitlementPools, removedEntitlementPools,
436 addedLicenseKeyGroups, removedLicenseKeyGroups);
439 .updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(), version);
441 mdcDataDebugMessage.debugExitMessage("VLM id, FG id", featureGroup
442 .getVendorLicenseModelId(), featureGroup.getId());
446 public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user) {
447 mdcDataDebugMessage.debugEntryMessage("VLM id, FG id",
448 featureGroup.getVendorLicenseModelId(), featureGroup.getId());
450 mdcDataDebugMessage.debugExitMessage("VLM id, FG id",
451 featureGroup.getVendorLicenseModelId(), featureGroup.getId());
452 return vendorLicenseFacade.getFeatureGroupModel(featureGroup, user);
456 public void deleteFeatureGroup(FeatureGroupEntity featureGroup, String user) {
457 mdcDataDebugMessage.debugEntryMessage("VLM id, FG id",
458 featureGroup.getVendorLicenseModelId(), featureGroup.getId());
460 Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
461 getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
463 featureGroup.setVersion(version);
464 FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
466 .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
468 removeLicenseKeyGroupsToFeatureGroupsRef(retrieved.getLicenseKeyGroupIds(), featureGroup);
469 removeEntitlementPoolsToFeatureGroupsRef(retrieved.getEntitlementPoolIds(), featureGroup);
471 for (String licenceAgreementId : retrieved.getReferencingLicenseAgreements()) {
472 licenseAgreementDao.removeFeatureGroup(
473 new LicenseAgreementEntity(featureGroup.getVendorLicenseModelId(), version,
474 licenceAgreementId), featureGroup.getId());
477 featureGroupDao.delete(featureGroup);
479 deleteUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
480 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
481 retrieved.getName());
483 vendorLicenseFacade.updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(),
484 featureGroup.getVersion());
487 .debugExitMessage("VLM id, FG id",
488 featureGroup.getVendorLicenseModelId(), featureGroup.getId());
492 public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version,
494 mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
495 mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
496 return vendorLicenseFacade.listEntitlementPools(vlmId, version, user);
500 public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool,
503 .debugEntryMessage("VLM id", entitlementPool.getVendorLicenseModelId());
505 .debugExitMessage("VLM id", entitlementPool.getVendorLicenseModelId());
507 entitlementPool.setStartDate(entitlementPool.getStartDate() != null ? (entitlementPool
508 .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate()+"T00:00:00Z"
510 entitlementPool.setExpiryDate(entitlementPool.getExpiryDate() != null ? (entitlementPool
511 .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate()+"T23:59:59Z"
514 validateCreateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(),
515 entitlementPool.getVendorLicenseModelId());
516 return vendorLicenseFacade.createEntitlementPool(entitlementPool, user);
519 private void validateCreateDate(String startDate, String expiryDate, String vendorLicenseModelId){
520 mdcDataDebugMessage.debugEntryMessage("Start date and end date", startDate
523 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
525 if(startDate != null && expiryDate != null) {
526 if (LocalDate.parse(startDate, formatter).atStartOfDay().isBefore
527 (LocalDate.now().atStartOfDay()) || LocalDate.parse(expiryDate, formatter).atStartOfDay()
528 .isEqual(LocalDate.parse(startDate, formatter).atStartOfDay()) || LocalDate
529 .parse(expiryDate, formatter).isBefore(LocalDate.parse(startDate, formatter))) {
530 MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
531 LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
532 LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
533 throw new CoreException(
534 new InvalidDateErrorBuilder(vendorLicenseModelId)
539 if(startDate != null && expiryDate == null) {
540 if (LocalDate.parse(startDate, formatter).atStartOfDay().isBefore
541 (LocalDate.now().atStartOfDay())) {
542 MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
543 LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
544 LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
545 throw new CoreException(
546 new InvalidDateErrorBuilder(vendorLicenseModelId)
551 if(startDate == null && expiryDate != null) {
552 MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
553 LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
554 LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
555 throw new CoreException(
556 new InvalidDateErrorBuilder(vendorLicenseModelId)
561 mdcDataDebugMessage.debugExitMessage(null,null);
564 private void validateUpdateDate(String startDate, String expiryDate, String vendorLicenseModelId){
565 mdcDataDebugMessage.debugEntryMessage("Start date and end date", startDate
568 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
570 if(startDate != null && expiryDate != null) {
571 if (LocalDate.parse(expiryDate, formatter).atStartOfDay()
572 .isEqual(LocalDate.parse(startDate, formatter).atStartOfDay()) ||
573 LocalDate.parse(expiryDate, formatter).isBefore(LocalDate.parse(startDate, formatter))) {
574 MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
575 LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
576 LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
577 throw new CoreException(
578 new InvalidDateErrorBuilder(vendorLicenseModelId)
583 if(startDate == null && expiryDate != null) {
584 MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
585 LoggerTragetServiceName.VALIDATE_DATE_RANGE,ErrorLevel.ERROR.name(),
586 LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.INVALID_VALUE);
587 throw new CoreException(
588 new InvalidDateErrorBuilder(vendorLicenseModelId)
593 mdcDataDebugMessage.debugExitMessage(null,null);
597 public void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user) {
598 mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool
599 .getVendorLicenseModelId(), entitlementPool.getId());
601 entitlementPool.setStartDate(entitlementPool.getStartDate() != null ? (entitlementPool
602 .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate()+"T00:00:00Z"
604 entitlementPool.setExpiryDate(entitlementPool.getExpiryDate() != null ? (entitlementPool
605 .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate()+"T23:59:59Z"
608 validateUpdateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(),
609 entitlementPool.getVendorLicenseModelId());
610 Version version = VersioningUtil.resolveVersion(entitlementPool.getVersion(),
611 getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
614 .updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(), version);
615 vendorLicenseFacade.updateEntitlementPool(entitlementPool, user);
617 mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool
618 .getVendorLicenseModelId(), entitlementPool.getId());
622 public EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool,
624 mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool
625 .getVendorLicenseModelId(), entitlementPool.getId());
627 entitlementPool.setVersion(VersioningUtil.resolveVersion(entitlementPool.getVersion(),
628 getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Read,
631 EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
633 .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
635 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
636 DateTimeFormatter targetFormatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
637 if(retrieved.getStartDate() != null){
638 retrieved.setStartDate(LocalDate.parse(retrieved.getStartDate(),formatter).format
642 if(retrieved.getExpiryDate() != null){
643 retrieved.setExpiryDate(LocalDate.parse(retrieved.getExpiryDate(),formatter).format
647 mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool
648 .getVendorLicenseModelId(), entitlementPool.getId());
653 public void deleteEntitlementPool(EntitlementPoolEntity entitlementPool, String user) {
654 mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", entitlementPool
655 .getVendorLicenseModelId(), entitlementPool.getId());
657 Version version = VersioningUtil.resolveVersion(entitlementPool.getVersion(),
658 getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
660 entitlementPool.setVersion(version);
662 EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
664 .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
666 for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
667 featureGroupDao.removeEntitlementPool(
668 new FeatureGroupEntity(entitlementPool.getVendorLicenseModelId(), version,
669 referencingFeatureGroupId), entitlementPool.getId());
672 deleteChildLimits(entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(), entitlementPool.getId(), user);
674 entitlementPoolDao.delete(entitlementPool);
676 deleteUniqueName(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
677 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
678 retrieved.getName());
680 vendorLicenseFacade.updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(),
681 entitlementPool.getVersion());
683 mdcDataDebugMessage.debugExitMessage("VLM id, EP id", entitlementPool
684 .getVendorLicenseModelId(), entitlementPool.getId());
687 protected void deleteChildLimits(String vlmId, Version version, String epLkgId, String user) {
688 Optional<Collection<LimitEntity>> limitEntities = Optional.ofNullable(
689 listLimits(vlmId, version, epLkgId, user));
690 limitEntities.ifPresent(entities->
691 entities.forEach(entity->
692 deleteLimit(entity, user)));
696 public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
698 mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
699 mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
700 return vendorLicenseFacade.listLicenseKeyGroups(vlmId, version, user);
704 public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
707 .debugEntryMessage("VLM id", licenseKeyGroup.getVendorLicenseModelId());
709 mdcDataDebugMessage.debugExitMessage("VLM id", licenseKeyGroup
710 .getVendorLicenseModelId());
712 licenseKeyGroup.setStartDate(licenseKeyGroup.getStartDate() != null ? (licenseKeyGroup
713 .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate()+"T00:00:00Z"
715 licenseKeyGroup.setExpiryDate(licenseKeyGroup.getExpiryDate() != null ? (licenseKeyGroup
716 .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate()+"T23:59:59Z"
719 validateCreateDate(licenseKeyGroup.getStartDate(), licenseKeyGroup.getExpiryDate(),
720 licenseKeyGroup.getVendorLicenseModelId());
721 return vendorLicenseFacade.createLicenseKeyGroup(licenseKeyGroup, user);
725 public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) {
726 mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup
727 .getVendorLicenseModelId(), licenseKeyGroup.getId());
729 licenseKeyGroup.setStartDate(licenseKeyGroup.getStartDate() != null ? (licenseKeyGroup
730 .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate()+"T00:00:00Z"
732 licenseKeyGroup.setExpiryDate(licenseKeyGroup.getExpiryDate() != null ? (licenseKeyGroup
733 .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate()+"T23:59:59Z"
736 validateUpdateDate(licenseKeyGroup.getStartDate(), licenseKeyGroup.getExpiryDate(),
737 licenseKeyGroup.getVendorLicenseModelId());
739 Version version = VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
740 getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
743 .updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(), version);
745 vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroup, user);
747 mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup
748 .getVendorLicenseModelId(), licenseKeyGroup.getId());
752 public LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
754 mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup
755 .getVendorLicenseModelId(), licenseKeyGroup.getId());
757 licenseKeyGroup.setVersion(VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
758 getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Read,
761 LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
763 .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
765 mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup
766 .getVendorLicenseModelId(), licenseKeyGroup.getId());
771 public void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) {
772 mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", licenseKeyGroup
773 .getVendorLicenseModelId(), licenseKeyGroup.getId());
775 Version version = VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
776 getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
778 licenseKeyGroup.setVersion(version);
780 LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
782 .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
784 for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
785 featureGroupDao.removeLicenseKeyGroup(
786 new FeatureGroupEntity(licenseKeyGroup.getVendorLicenseModelId(), version,
787 referencingFeatureGroupId), licenseKeyGroup.getId());
790 deleteChildLimits(licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(), licenseKeyGroup.getId(), user);
792 licenseKeyGroupDao.delete(licenseKeyGroup);
794 deleteUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
795 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
796 retrieved.getName());
798 vendorLicenseFacade.updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(),
799 licenseKeyGroup.getVersion());
801 mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", licenseKeyGroup
802 .getVendorLicenseModelId(), licenseKeyGroup.getId());
806 public LimitEntity createLimit(LimitEntity limit, String user) {
808 .debugEntryMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
811 .debugExitMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
813 validateLimit(limit, user);
814 LimitEntity createdLimit = vendorLicenseFacade.createLimit(limit, user);
815 updateParentForLimit(limit,user);
819 private void validateLimit(LimitEntity limit, String user) {
820 Version version = VersioningUtil.resolveVersion(limit.getVersion(),
821 getVersionInfo(limit.getVendorLicenseModelId(), VersionableEntityAction.Write,
823 Collection<LimitEntity> limitList = listLimits(limit.getVendorLicenseModelId(),version
824 ,limit.getEpLkgId(), user);
826 if (!isLimitNameUnique(limitList,limit.getName(), limit.getType(), limit.getId())) {
827 final ErrorCode duplicateLimitNameErrorBuilder =
828 LimitErrorBuilder.getDuplicateNameErrorbuilder(limit.getName(), limit.getType().name());
829 MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
830 LoggerServiceName.Create_LIMIT.toString(), ErrorLevel.ERROR.name(),
831 LoggerErrorCode.DATA_ERROR.getErrorCode(),
832 duplicateLimitNameErrorBuilder.message());
833 throw new CoreException(duplicateLimitNameErrorBuilder);
837 private boolean isLimitNameUnique(Collection<LimitEntity> limitList, String name, LimitType
839 for (LimitEntity limit : limitList) {
840 if(limit.getName().equalsIgnoreCase(name) &&
841 limit.getType().name().equalsIgnoreCase(type.name())) {
842 if(id != null && limit.getId().equals(id)){
852 public Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId,
854 mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId, "EP/LKGId", epLkgId);
855 mdcDataDebugMessage.debugExitMessage("VLM id", vlmId, "EP/LKGId", epLkgId);
856 return vendorLicenseFacade.listLimits(vlmId, version, epLkgId, user);
860 public void deleteLimit(LimitEntity limitEntity, String user) {
861 mdcDataDebugMessage.debugEntryMessage("VLM id, EP id, Limit Id", limitEntity
862 .getVendorLicenseModelId(), limitEntity.getEpLkgId(), limitEntity.getId());
864 Version version = VersioningUtil.resolveVersion(limitEntity.getVersion(),
865 getVersionInfo(limitEntity.getVendorLicenseModelId(), VersionableEntityAction.Write,
867 limitEntity.setVersion(version);
869 if ( !isLimitPresent(limitEntity)) {
871 .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
873 LimitEntity retrieved = limitDao.get(limitEntity);
875 .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
877 limitDao.delete(limitEntity);
879 vendorLicenseFacade.updateVlmLastModificationTime(limitEntity.getVendorLicenseModelId(),
880 limitEntity.getVersion());
882 updateParentForLimit(limitEntity,user);
884 mdcDataDebugMessage.debugExitMessage("VLM id, EP id, Limit Id", limitEntity
885 .getVendorLicenseModelId(), limitEntity.getEpLkgId(), limitEntity.getId());
889 public void updateLimit(LimitEntity limit, String user) {
891 .debugEntryMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
893 getLimit(limit,user);
894 validateLimit(limit, user);
895 vendorLicenseFacade.updateLimit(limit, user);
896 updateParentForLimit(limit,user);
898 .debugExitMessage("VLM id", limit.getVendorLicenseModelId(), "EP/LKGId", limit
902 private boolean isLimitPresent(LimitEntity limit) {
903 return limitDao.isLimitPresent(limit);
907 public LimitEntity getLimit(LimitEntity limitEntity,
909 mdcDataDebugMessage.debugEntryMessage("VLM id", limitEntity.getVendorLicenseModelId(),
910 "EP/LKGId", limitEntity.getEpLkgId());
912 limitEntity.setVersion(VersioningUtil.resolveVersion(limitEntity.getVersion(),
913 getVersionInfo(limitEntity.getVendorLicenseModelId(), VersionableEntityAction.Read,
915 if(!isLimitPresent(limitEntity)){
917 .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
919 LimitEntity retrieved = limitDao.get(limitEntity);
921 .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
923 mdcDataDebugMessage.debugExitMessage("VLM id", limitEntity.getVendorLicenseModelId(),
924 "EP/LKGId", limitEntity.getEpLkgId());
929 * update Parent of limit (EP/LKG) versionuuid when limit is modified so that limit updates are
930 * captured in VLM XML
934 private void updateParentForLimit(LimitEntity limit, String user) {
935 mdcDataDebugMessage.debugEntryMessage("VLM id", limit.getVendorLicenseModelId(),
936 "EP/LKGId", limit.getEpLkgId(), "Limit Parent ", limit.getParent());
937 if ("EntitlementPool".equals(limit.getParent()) ) {
938 EntitlementPoolEntity entitlementPoolEntity =
939 entitlementPoolDao.get(new EntitlementPoolEntity(limit.getVendorLicenseModelId(),
940 limit.getVersion(), limit.getEpLkgId()));
941 vendorLicenseFacade.updateEntitlementPool(entitlementPoolEntity, user);
944 if ("LicenseKeyGroup".equals(limit.getParent())) {
945 LicenseKeyGroupEntity licenseKeyGroupEntity = licenseKeyGroupDao.get(
946 new LicenseKeyGroupEntity(limit.getVendorLicenseModelId(), limit.getVersion(),
947 limit.getEpLkgId()));
948 vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroupEntity, user);
951 mdcDataDebugMessage.debugEntryMessage("VLM id", limit.getVendorLicenseModelId(),
952 "EP/LKGId", limit.getEpLkgId(), "Limit Parent ", limit.getParent());
955 protected void addFeatureGroupsToLicenseAgreementRef(Set<String> featureGroupIds,
956 LicenseAgreementEntity licenseAgreement) {
957 if (featureGroupIds != null) {
958 for (String featureGroupId : featureGroupIds) {
959 featureGroupDao.addReferencingLicenseAgreement(
960 new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
961 licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
966 protected void removeFeatureGroupsToLicenseAgreementRef(Set<String> featureGroupIds,
967 LicenseAgreementEntity licenseAgreement) {
968 if (featureGroupIds != null) {
969 for (String featureGroupId : featureGroupIds) {
970 featureGroupDao.removeReferencingLicenseAgreement(
971 new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
972 licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
977 protected void addLicenseKeyGroupsToFeatureGroupsRef(Set<String> licenseKeyGroupIds,
978 FeatureGroupEntity featureGroup) {
979 if (licenseKeyGroupIds != null) {
980 for (String licenseKeyGroupId : licenseKeyGroupIds) {
981 licenseKeyGroupDao.addReferencingFeatureGroup(
982 new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
983 featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
988 protected void removeLicenseKeyGroupsToFeatureGroupsRef(Set<String> licenseKeyGroupIds,
989 FeatureGroupEntity featureGroup) {
990 if (licenseKeyGroupIds != null) {
991 for (String licenseKeyGroupId : licenseKeyGroupIds) {
992 licenseKeyGroupDao.removeReferencingFeatureGroup(
993 new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
994 featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
999 protected void addEntitlementPoolsToFeatureGroupsRef(Set<String> entitlementPoolIds,
1000 FeatureGroupEntity featureGroup) {
1001 if (entitlementPoolIds != null) {
1002 for (String entitlementPoolId : entitlementPoolIds) {
1003 entitlementPoolDao.addReferencingFeatureGroup(
1004 new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
1005 featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
1010 protected void removeEntitlementPoolsToFeatureGroupsRef(Set<String> entitlementPoolIds,
1011 FeatureGroupEntity featureGroup) {
1012 if (entitlementPoolIds != null) {
1013 for (String entitlementPoolId : entitlementPoolIds) {
1014 entitlementPoolDao.removeReferencingFeatureGroup(
1015 new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
1016 featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
1021 protected VersionInfo getVersionInfo(String vendorLicenseModelId, VersionableEntityAction action,
1023 return vendorLicenseFacade.getVersionInfo(vendorLicenseModelId, action, user);
1026 protected LicenseAgreementEntity createLicenseAgreementForList(String vlmId, Version version,
1028 return new LicenseAgreementEntity(vlmId, VersioningUtil
1029 .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
1033 protected void updateUniqueName(String uniqueValueType ,String oldName, String newName,String ...
1036 .updateUniqueValue(uniqueValueType, oldName, newName,context);
1039 protected void deleteUniqueName(String uniqueValueType,String ... uniqueCombination) {
1040 UniqueValueUtil.deleteUniqueValue(uniqueValueType, uniqueCombination);
1043 protected Version resloveVersion(String vlmId,Version requestedVersion, VersionInfo versionInfo,
1045 return VersioningUtil.resolveVersion(null,
1046 getVersionInfo(vlmId, VersionableEntityAction.Write, user), user);