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.facade.impl;
23 import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE;
24 import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP;
25 import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG;
26 import static org.openecomp.sdc.vendorlicense.errors.UncompletedVendorLicenseModelErrorType.SUBMIT_UNCOMPLETED_VLM_MSG_MISSING_LA;
28 import org.openecomp.core.util.UniqueValueUtil;
29 import org.openecomp.core.utilities.CommonMethods;
30 import org.openecomp.sdc.common.errors.CoreException;
31 import org.openecomp.sdc.common.errors.ErrorCode;
32 import org.openecomp.sdc.datatypes.error.ErrorLevel;
33 import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
34 import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
35 import org.openecomp.sdc.logging.types.LoggerConstants;
36 import org.openecomp.sdc.logging.types.LoggerErrorCode;
37 import org.openecomp.sdc.logging.types.LoggerErrorDescription;
38 import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
39 import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
40 import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
41 import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
42 import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
43 import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory;
44 import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
45 import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory;
46 import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
47 import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDaoFactory;
48 import org.openecomp.sdc.vendorlicense.dao.LimitDao;
49 import org.openecomp.sdc.vendorlicense.dao.LimitDaoFactory;
50 import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
51 import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDaoFactory;
52 import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
53 import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
54 import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel;
55 import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
56 import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel;
57 import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
58 import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
59 import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
60 import org.openecomp.sdc.vendorlicense.errors.SubmitUncompletedLicenseModelErrorBuilder;
61 import org.openecomp.sdc.vendorlicense.errors.VendorLicenseModelNotFoundErrorBuilder;
62 import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
63 import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
64 import org.openecomp.sdc.versioning.VersioningManager;
65 import org.openecomp.sdc.versioning.VersioningManagerFactory;
66 import org.openecomp.sdc.versioning.VersioningUtil;
67 import org.openecomp.sdc.versioning.dao.types.Version;
68 import org.openecomp.sdc.versioning.errors.RequestedVersionInvalidErrorBuilder;
69 import org.openecomp.sdc.versioning.errors.VersionableSubEntityNotFoundErrorBuilder;
70 import org.openecomp.sdc.versioning.types.VersionInfo;
71 import org.openecomp.sdc.versioning.types.VersionableEntityAction;
73 import java.util.ArrayList;
74 import java.util.Collection;
75 import java.util.Collections;
76 import java.util.List;
78 public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
80 private static final VersioningManager versioningManager =
81 VersioningManagerFactory.getInstance().createInterface();
83 private static final VendorLicenseModelDao
84 vendorLicenseModelDao = VendorLicenseModelDaoFactory.getInstance().createInterface();
85 private static final LicenseAgreementDao
86 licenseAgreementDao = LicenseAgreementDaoFactory.getInstance().createInterface();
87 private static final FeatureGroupDao featureGroupDao =
88 FeatureGroupDaoFactory.getInstance().createInterface();
89 private static final EntitlementPoolDao
90 entitlementPoolDao = EntitlementPoolDaoFactory.getInstance().createInterface();
91 private static final LicenseKeyGroupDao
92 licenseKeyGroupDao = LicenseKeyGroupDaoFactory.getInstance().createInterface();
93 private static final LimitDao limitDao = LimitDaoFactory.getInstance().createInterface();
94 private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
97 * Instantiates a new Vendor license facade.
99 public VendorLicenseFacadeImpl() {
100 vendorLicenseModelDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
101 licenseAgreementDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
102 featureGroupDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
103 entitlementPoolDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
104 licenseKeyGroupDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
105 limitDao.registerVersioning(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE);
109 public Version checkin(String vendorLicenseModelId, String user) {
110 Version newVersion = versioningManager
111 .checkin(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user, null);
112 updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
117 public Version submit(String vendorLicenseModelId, String user) {
118 validateCompletedVendorLicenseModel(vendorLicenseModelId, user);
119 Version newVersion = versioningManager
120 .submit(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user, null);
121 updateVlmLastModificationTime(vendorLicenseModelId, newVersion);
126 public FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup, String user) {
127 Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
128 getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Read,
130 featureGroup.setVersion(version);
133 return getFeatureGroup(featureGroup);
136 private FeatureGroupEntity getFeatureGroup(FeatureGroupEntity featureGroup) {
137 FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
139 .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
140 if(retrieved.getManufacturerReferenceNumber() == null){
141 Object[] entitlementPoolIdsList = retrieved.getEntitlementPoolIds().toArray();
142 if(entitlementPoolIdsList != null && entitlementPoolIdsList.length > 0){
143 String entitlementPoolId = entitlementPoolIdsList[0].toString();
144 EntitlementPoolEntity entitlementPoolEntity = new EntitlementPoolEntity(retrieved.getVendorLicenseModelId(),
145 retrieved.getVersion(), entitlementPoolId);
146 entitlementPoolEntity = entitlementPoolDao.get(entitlementPoolEntity);
147 retrieved.setManufacturerReferenceNumber(entitlementPoolDao.getManufacturerReferenceNumber(
148 entitlementPoolEntity));
149 featureGroupDao.update(retrieved);
157 public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup, String user) {
158 FeatureGroupEntity retrieved = getFeatureGroup(featureGroup, user);
160 FeatureGroupModel featureGroupModel = new FeatureGroupModel();
161 featureGroupModel.setFeatureGroup(retrieved);
163 for (String licenseKeyGroupId : retrieved.getLicenseKeyGroupIds()) {
164 featureGroupModel.getLicenseKeyGroups().add(licenseKeyGroupDao.get(
165 new LicenseKeyGroupEntity(retrieved.getVendorLicenseModelId(), retrieved.getVersion(),
166 licenseKeyGroupId)));
168 for (String entitlementPoolId : retrieved.getEntitlementPoolIds()) {
169 featureGroupModel.getEntitlementPools().add(entitlementPoolDao.get(
170 new EntitlementPoolEntity(retrieved.getVendorLicenseModelId(), retrieved.getVersion(),
171 entitlementPoolId)));
174 return featureGroupModel;
178 public LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
179 String licenseAgreementId, String user) {
180 LicenseAgreementEntity retrieved =
181 getLicenseAgreement(vlmId, version, licenseAgreementId, user);
183 LicenseAgreementModel licenseAgreementModel = new LicenseAgreementModel();
184 licenseAgreementModel.setLicenseAgreement(retrieved);
186 for (String featureGroupId : retrieved.getFeatureGroupIds()) {
187 licenseAgreementModel.getFeatureGroups().add(featureGroupDao
188 .get(new FeatureGroupEntity(vlmId, retrieved.getVersion(), featureGroupId)));
191 return licenseAgreementModel;
195 public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool,
197 entitlementPool.setVersion(VersioningUtil.resolveVersion(entitlementPool.getVersion(),
198 getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
200 //entitlementPool.setId(CommonMethods.nextUuId());
201 entitlementPool.setVersionUuId(CommonMethods.nextUuId());
202 UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
203 entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion().toString(),
204 entitlementPool.getName());
205 entitlementPoolDao.create(entitlementPool);
206 updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(),
207 entitlementPool.getVersion());
208 return entitlementPool;
212 public void updateEntitlementPool(EntitlementPoolEntity entitlementPool, String user) {
213 entitlementPool.setVersion(VersioningUtil.resolveVersion(entitlementPool.getVersion(),
214 getVersionInfo(entitlementPool.getVendorLicenseModelId(), VersionableEntityAction.Write,
216 EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
218 .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
220 UniqueValueUtil.updateUniqueValue(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
221 retrieved.getName(), entitlementPool.getName(), entitlementPool.getVendorLicenseModelId(),
222 entitlementPool.getVersion().toString());
223 entitlementPool.setVersionUuId(CommonMethods.nextUuId());
224 entitlementPoolDao.update(entitlementPool);
226 updateVlmLastModificationTime(entitlementPool.getVendorLicenseModelId(),
227 entitlementPool.getVersion());
232 public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version,
234 return licenseKeyGroupDao.list(new LicenseKeyGroupEntity(vlmId, VersioningUtil
235 .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
240 public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version,
242 return entitlementPoolDao.list(new EntitlementPoolEntity(vlmId, VersioningUtil
243 .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
248 public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup, String user) {
249 licenseKeyGroup.setVersion(VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
250 getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
252 LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
253 licenseKeyGroup.setVersionUuId((CommonMethods.nextUuId()));
255 .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
256 UniqueValueUtil.updateUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
257 retrieved.getName(), licenseKeyGroup.getName(), licenseKeyGroup.getVendorLicenseModelId(),
258 licenseKeyGroup.getVersion().toString());
259 licenseKeyGroupDao.update(licenseKeyGroup);
261 updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(),
262 licenseKeyGroup.getVersion());
266 public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
268 licenseKeyGroup.setVersion(VersioningUtil.resolveVersion(licenseKeyGroup.getVersion(),
269 getVersionInfo(licenseKeyGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
271 //licenseKeyGroup.setId(CommonMethods.nextUuId());
272 licenseKeyGroup.setVersionUuId(CommonMethods.nextUuId());
273 UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
274 licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion().toString(),
275 licenseKeyGroup.getName());
276 licenseKeyGroupDao.create(licenseKeyGroup);
277 updateVlmLastModificationTime(licenseKeyGroup.getVendorLicenseModelId(),
278 licenseKeyGroup.getVersion());
279 return licenseKeyGroup;
283 public VersionedVendorLicenseModel getVendorLicenseModel(String vlmId, Version version,
285 mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId);
287 VersionInfo versionInfo = getVersionInfo(vlmId, VersionableEntityAction.Read, user);
289 VendorLicenseModelEntity vendorLicenseModel = vendorLicenseModelDao.get(
290 new VendorLicenseModelEntity(vlmId,
291 VersioningUtil.resolveVersion(version, versionInfo, user)));
292 if (vendorLicenseModel == null) {
293 MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
294 LoggerTragetServiceName.GET_VLM, ErrorLevel.ERROR.name(),
295 LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.ENTITY_NOT_FOUND);
296 throw new CoreException(new VendorLicenseModelNotFoundErrorBuilder(vlmId).build());
299 mdcDataDebugMessage.debugExitMessage("VLM id", vlmId);
300 return new VersionedVendorLicenseModel(vendorLicenseModel, versionInfo);
304 public VendorLicenseModelEntity createVendorLicenseModel(
305 VendorLicenseModelEntity vendorLicenseModelEntity, String user) {
307 mdcDataDebugMessage.debugEntryMessage(null, null);
309 UniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME,
310 vendorLicenseModelEntity.getVendorName());
311 //vendorLicenseModelEntity.setId(CommonMethods.nextUuId());
313 vendorLicenseModelDao.create(vendorLicenseModelEntity);
314 UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME,
315 vendorLicenseModelEntity.getVendorName());
317 Version version = versioningManager
318 .create(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelEntity.getId(), user);
319 vendorLicenseModelEntity.setVersion(version);
321 mdcDataDebugMessage.debugExitMessage(null, null);
322 return vendorLicenseModelEntity;
326 public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement,
328 Version version = VersioningUtil.resolveVersion(licenseAgreement.getVersion(),
329 getVersionInfo(licenseAgreement.getVendorLicenseModelId(), VersionableEntityAction.Write,
331 licenseAgreement.setVersion(version);
332 //licenseAgreement.setId(CommonMethods.nextUuId());
333 VersioningUtil.validateEntitiesExistence(licenseAgreement.getFeatureGroupIds(),
334 new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), version, null),
335 featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
337 UniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
338 licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().toString(),
339 licenseAgreement.getName());
341 licenseAgreementDao.create(licenseAgreement);
342 UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
343 licenseAgreement.getVendorLicenseModelId(), licenseAgreement.getVersion().toString(),
344 licenseAgreement.getName());
345 if (licenseAgreement.getFeatureGroupIds() != null) {
346 for (String addedFgId : licenseAgreement.getFeatureGroupIds()) {
347 featureGroupDao.addReferencingLicenseAgreement(
348 new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(), version,
349 addedFgId), licenseAgreement.getId());
352 updateVlmLastModificationTime(licenseAgreement.getVendorLicenseModelId(),
353 licenseAgreement.getVersion());
355 return licenseAgreement;
359 public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup, String user) {
360 Version version = VersioningUtil.resolveVersion(featureGroup.getVersion(),
361 getVersionInfo(featureGroup.getVendorLicenseModelId(), VersionableEntityAction.Write,
363 //featureGroup.setId(CommonMethods.nextUuId());
364 featureGroup.setVersion(version);
365 VersioningUtil.validateEntitiesExistence(featureGroup.getLicenseKeyGroupIds(),
366 new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), version, null),
367 licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
368 VersioningUtil.validateEntitiesExistence(featureGroup.getEntitlementPoolIds(),
369 new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), version, null),
370 entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
371 UniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
372 featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().toString(),
373 featureGroup.getName());
375 featureGroupDao.create(featureGroup);
376 UniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
377 featureGroup.getVendorLicenseModelId(), featureGroup.getVersion().toString(),
378 featureGroup.getName());
380 if (featureGroup.getLicenseKeyGroupIds() != null) {
381 for (String addedLkgId : featureGroup.getLicenseKeyGroupIds()) {
382 licenseKeyGroupDao.addReferencingFeatureGroup(
383 new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), version, addedLkgId),
384 featureGroup.getId());
388 if (featureGroup.getEntitlementPoolIds() != null) {
389 for (String addedEpId : featureGroup.getEntitlementPoolIds()) {
390 entitlementPoolDao.addReferencingFeatureGroup(
391 new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), version, addedEpId),
392 featureGroup.getId());
396 updateVlmLastModificationTime(featureGroup.getVendorLicenseModelId(),
397 featureGroup.getVersion());
403 public Collection<ErrorCode> validateLicensingData(String vlmId, Version version,
404 String licenseAgreementId,
405 Collection<String> featureGroupIds) {
407 VersionInfo versionInfo = getVersionInfo(vlmId, VersionableEntityAction.Read, "");
408 if (version == null || !version.isFinal()
409 || !versionInfo.getViewableVersions().contains(version)) {
410 return Collections.singletonList(new RequestedVersionInvalidErrorBuilder().build());
412 } catch (CoreException exception) {
413 return Collections.singletonList(exception.code());
416 List<ErrorCode> errorMessages = new ArrayList<>();
419 getLicenseAgreement(vlmId, licenseAgreementId, version);
420 } catch (CoreException exception) {
421 errorMessages.add(exception.code());
424 for (String featureGroupId : featureGroupIds) {
426 FeatureGroupEntity featureGroup =
427 getFeatureGroup(new FeatureGroupEntity(vlmId, version, featureGroupId));
428 if (!featureGroup.getReferencingLicenseAgreements().contains(licenseAgreementId)) {
429 errorMessages.add(new VersionableSubEntityNotFoundErrorBuilder(
430 featureGroup.getEntityType(),
432 LicenseAgreementEntity.ENTITY_TYPE,
436 } catch (CoreException exception) {
437 errorMessages.add(exception.code());
441 return errorMessages;
445 public VersionInfo getVersionInfo(String vendorLicenseModelId, VersionableEntityAction action,
447 return versioningManager
448 .getEntityVersionInfo(VENDOR_LICENSE_MODEL_VERSIONABLE_TYPE, vendorLicenseModelId, user,
453 public void updateVlmLastModificationTime(String vendorLicenseModelId, Version version) {
454 VendorLicenseModelEntity retrieved =
455 vendorLicenseModelDao.get(new VendorLicenseModelEntity(vendorLicenseModelId, version));
456 vendorLicenseModelDao.update(retrieved);
460 public LicenseAgreementEntity getLicenseAgreement(String vlmId, Version version,
461 String licenseAgreementId, String user) {
462 return getLicenseAgreement(vlmId, licenseAgreementId, VersioningUtil
463 .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user));
467 public LimitEntity createLimit(LimitEntity limit, String user) {
468 limit.setVersion(VersioningUtil.resolveVersion(limit.getVersion(),
469 getVersionInfo(limit.getVendorLicenseModelId(), VersionableEntityAction.Write,
471 //limit.setVersionUuId(CommonMethods.nextUuId());
472 limitDao.create(limit);
473 updateVlmLastModificationTime(limit.getVendorLicenseModelId(),
479 public Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId,
481 return limitDao.list(new LimitEntity(vlmId, VersioningUtil
482 .resolveVersion(version, getVersionInfo(vlmId, VersionableEntityAction.Read, user), user),
488 public void updateLimit(LimitEntity limit, String user) {
489 limit.setVersion(VersioningUtil.resolveVersion(limit.getVersion(),
490 getVersionInfo(limit.getVendorLicenseModelId(), VersionableEntityAction.Write,
492 //limit.setVersionUuId(CommonMethods.nextUuId());
493 limitDao.update(limit);
494 updateVlmLastModificationTime(limit.getVendorLicenseModelId(),
498 private LicenseAgreementEntity getLicenseAgreement(String vlmId, String licenseAgreementId,
500 LicenseAgreementEntity input = new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
501 LicenseAgreementEntity retrieved = licenseAgreementDao.get(input);
502 VersioningUtil.validateEntityExistence(retrieved, input, VendorLicenseModelEntity.ENTITY_TYPE);
506 private void validateCompletedVendorLicenseModel(String vendorLicenseModelId, String user) {
507 Version version = VersioningUtil.resolveVersion(null,
508 getVersionInfo(vendorLicenseModelId, VersionableEntityAction.Read, user), user);
509 Collection<LicenseAgreementEntity> licenseAgreements = licenseAgreementDao
510 .list(new LicenseAgreementEntity(vendorLicenseModelId, version, null));
512 if (licenseAgreements == null || licenseAgreements.isEmpty()) {
513 MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
514 LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
515 LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
516 throw new CoreException(
517 new SubmitUncompletedLicenseModelErrorBuilder(SUBMIT_UNCOMPLETED_VLM_MSG_MISSING_LA).build());
520 for (LicenseAgreementEntity licenseAgreement : licenseAgreements) {
521 if (licenseAgreement.getFeatureGroupIds() == null || licenseAgreement.getFeatureGroupIds().isEmpty()) {
522 MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
523 LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
524 LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
525 throw new CoreException(
526 new SubmitUncompletedLicenseModelErrorBuilder(SUBMIT_UNCOMPLETED_VLM_MSG_LA_MISSING_FG).build());
530 Collection<FeatureGroupEntity> featureGroupEntities =
531 featureGroupDao.list(new FeatureGroupEntity(vendorLicenseModelId, version, null));
532 for (FeatureGroupEntity featureGroupEntity : featureGroupEntities) {
533 if (featureGroupEntity.getEntitlementPoolIds() == null || featureGroupEntity.getEntitlementPoolIds().isEmpty()) {
534 MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
535 LoggerTragetServiceName.SUBMIT_ENTITY, ErrorLevel.ERROR.name(),
536 LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.SUBMIT_ENTITY);
537 throw new CoreException(
538 new SubmitUncompletedLicenseModelErrorBuilder(SUBMIT_UNCOMPLETED_VLM_MSG_FG_MISSING_EP).build());