import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
-import java.util.Optional;
import java.util.function.Predicate;
import javax.inject.Named;
import javax.ws.rs.core.Response;
public Response getLicenseModel(String vlmId, String versionId, String user) {
Version version = versioningManager.get(vlmId, new Version(versionId));
VendorLicenseModelEntity vlm = vendorLicenseManager.getVendorLicenseModel(vlmId, version);
- vlm.setWritetimeMicroSeconds(version.getModificationTime().getTime());
try {
- Optional<Version> healedVersion = HealingManagerFactory.getInstance().createInterface()
- .healItemVersion(vlmId, version, ItemType.vlm,
- false);
-
- if (healedVersion.isPresent()) {
- vlm.setVersion(healedVersion.get());
- if (version.getStatus() == VersionStatus.Certified) {
- submitHealedVersion(vlmId, healedVersion.get(), versionId, user);
- }
- }
+ HealingManagerFactory.getInstance().createInterface()
+ .healItemVersion(vlmId, version, ItemType.vlm, false)
+ .ifPresent(healedVersion -> {
+ vlm.setVersion(healedVersion);
+ if (version.getStatus() == VersionStatus.Certified) {
+ submitHealedVersion(vlmId, healedVersion, versionId, user);
+ }
+ });
} catch (Exception e) {
LOGGER.error(String.format("Error while auto healing VLM with Id %s and version %s", vlmId, versionId), e);
}
public Response getVsp(String vspId, String versionId, String user) {
Version version = versioningManager.get(vspId, new Version(versionId));
VspDetails vspDetails = vendorSoftwareProductManager.getVsp(vspId, version);
- vspDetails.setWritetimeMicroSeconds(version.getModificationTime().getTime());
try {
HealingManagerFactory.getInstance().createInterface()
versioningManager.get(vspDetails.getVendorId(), vspDetails.getVlmVersion());
}
- Optional<ValidationResponse> validationResponse =
- submit(vspDetails.getId(), vspDetails.getVersion(), "Submit healed Vsp", user);
- // TODO: 8/9/2017 before collaboration checkout was done at this scenario (equivalent
- // to new version in collaboration). need to decide what should be done now.
- validationResponse.ifPresent(validationResponse1 -> {
- throw new IllegalStateException("Certified vsp after healing failed on validation");
- });
+ submit(vspDetails.getId(), vspDetails.getVersion(), "Submit healed Vsp", user)
+ .ifPresent(validationResponse -> {
+ throw new IllegalStateException("Certified vsp after healing failed on validation");
+ });
vendorSoftwareProductManager.createPackage(vspDetails.getId(), vspDetails.getVersion());
} catch (Exception ex) {
LOGGER.error(String.format(SUBMIT_HEALED_VERSION_ERROR, vspDetails.getId(), vspDetails.getVersion().getId(),
.updateUniqueName(VendorLicenseConstants.UniqueValues.VENDOR_NAME,
existingVlm.getVendorName(), updatedVlm.getVendorName());
- existingVlm.setWritetimeMicroSeconds(8L);
-
doReturn(existingVlm).when(vendorLicenseModelDaoMcok).get(any(VendorLicenseModelEntity.class));
vendorLicenseManager.updateVendorLicenseModel(updatedVlm);
createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon",
"category_updated",
"subCategory", "456", null);
- existingVsp.setWritetimeMicroSeconds(8L);
doReturn(existingVsp).when(vspInfoDaoMock)
.get(any(VspDetails.class));
doNothing().when(vendorSoftwareProductManager)
createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon",
"category_updated",
"subCategory", "456", updFgs);
- existingVsp.setWritetimeMicroSeconds(8L);
doReturn(existingVsp).when(vspInfoDaoMock)
.get(any(VspDetails.class));
doNothing().when(vendorSoftwareProductManager)
createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
"category",
"subCategory", "456", null);
- existingVsp.setWritetimeMicroSeconds(8L);
doReturn(existingVsp).when(vspInfoDaoMock).get(any(VspDetails.class));
VspDetails actualVsp =
createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
"category",
"subCategory", "456", null);
- existingVsp.setWritetimeMicroSeconds(8L);
doReturn(existingVsp)
.when(vspInfoDaoMock).get(any(VspDetails.class));
&& Objects.equals(description, that.description)
&& Objects.equals(iconRef, that.iconRef);
}
-
- public Long getWritetimeMicroSeconds() {
- return writetimeMicroSeconds;
- }
-
- public void setWritetimeMicroSeconds(Long writetimeMicroSeconds) {
- this.writetimeMicroSeconds = writetimeMicroSeconds;
- }
}
@Override
public void delete(VendorLicenseModelEntity entity) {
-
+ throw new UnsupportedOperationException("Delete vlm version is done using versioning manager");
}
-
private ZusammenElement mapVlmToZusammenElement(VendorLicenseModelEntity vendorLicenseModel,
Action action) {
ZusammenElement generalElement =
info.addProperty(InfoPropertyName.name.name(), vendorLicenseModel.getVendorName());
info.addProperty(InfoPropertyName.description.name(), vendorLicenseModel.getDescription());
info.addProperty(InfoPropertyName.iconRef.name(), vendorLicenseModel.getIconRef());
- info.addProperty(InfoPropertyName.oldVersion.name(), vendorLicenseModel.getOldVersion());
}
-
public enum InfoPropertyName {
name,
description,
iconRef,
- oldVersion
}
}
}
-
private VendorLicenseModelEntity mapInfoToVendorLicenseModelEntity(Info info) {
VendorLicenseModelEntity vendorLicenseModelEntity = new VendorLicenseModelEntity();
VendorLicenseModelDaoZusammenImpl.InfoPropertyName.description.name()));
vendorLicenseModelEntity.setIconRef(info.getProperty(
VendorLicenseModelDaoZusammenImpl.InfoPropertyName.iconRef.name()));
- vendorLicenseModelEntity.setOldVersion(info.getProperty(
- VendorLicenseModelDaoZusammenImpl.InfoPropertyName.oldVersion.name()));
-
return vendorLicenseModelEntity;
}
-
-
}
private List<String> featureGroups;
- private Long writetimeMicroSeconds;
-
private String onboardingMethod;
public VspDetails() {
this.featureGroups = featureGroups;
}
- public Long getWritetimeMicroSeconds() {
- return this.writetimeMicroSeconds;
- }
-
- public void setWritetimeMicroSeconds(Long writetimeMicroSeconds) {
- this.writetimeMicroSeconds = writetimeMicroSeconds;
- }
-
- /*public boolean isOldVersion() {
- return this.oldVersion;
- }*/
-
public String getOnboardingMethod() {
return onboardingMethod;
}
this.onboardingMethod = onboardingMethod;
}
-
@Override
public String toString() {
return String.format(