aboutsummaryrefslogtreecommitdiffstats
path: root/asdctool
diff options
context:
space:
mode:
authorChris André <chris.andre@yoppworks.com>2020-04-16 17:48:06 -0400
committerOfir Sonsino <ofir.sonsino@intl.att.com>2020-04-23 05:38:30 +0000
commit3bb06374d5b6747d32ea9554259596d0a45fadc2 (patch)
treecd3773269ca74b22d2056e2054a60f9c121050b1 /asdctool
parenta994931dc349c93ba9b5c9bc7b517b9dd89a10cc (diff)
Added early check for null value for `containerV`
- Formatting code following project's code style - Added early check for null value for `containerV` Issue-ID: SDC-2905 Signed-off-by: Chris Andre <chris.andre@yoppworks.com> Change-Id: I648e9a4a04be3f2e7cd3e30a70c04de2257a99d3
Diffstat (limited to 'asdctool')
-rw-r--r--asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCERTIFIEDstateMigration.java81
1 files changed, 48 insertions, 33 deletions
diff --git a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCERTIFIEDstateMigration.java b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCERTIFIEDstateMigration.java
index 1d7d3d1298..9cf56cf325 100644
--- a/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCERTIFIEDstateMigration.java
+++ b/asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCERTIFIEDstateMigration.java
@@ -70,7 +70,7 @@ public class SdcCollapsingRolesCERTIFIEDstateMigration extends InstanceMigration
public MigrationResult migrate() {
StorageOperationStatus status = updateServiceLifeCycleState();
return status == StorageOperationStatus.OK ?
- MigrationResult.success() : MigrationResult.error("failed to service state. Error : " + status);
+ MigrationResult.success() : MigrationResult.error("failed to service state. Error : " + status);
}
protected StorageOperationStatus updateServiceLifeCycleState() {
@@ -79,7 +79,9 @@ public class SdcCollapsingRolesCERTIFIEDstateMigration extends InstanceMigration
propertiesToMatch.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
- Either<List<GraphVertex>, JanusGraphOperationStatus> byCriteria = janusGraphDao.getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+ Either<List<GraphVertex>, JanusGraphOperationStatus> byCriteria = janusGraphDao
+ .getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch,
+ JsonParseFlagEnum.ParseAll);
return byCriteria.either(this::proceed, this::handleError);
}
@@ -87,51 +89,64 @@ public class SdcCollapsingRolesCERTIFIEDstateMigration extends InstanceMigration
protected StorageOperationStatus handleOneContainer(GraphVertex containerVorig) {
StorageOperationStatus status = StorageOperationStatus.NOT_FOUND;
GraphVertex containerV = getVertexById(containerVorig.getUniqueId());
- try {
- //update edges to meet above change
- // update LS eges from RFC to NOT_CERTIFIED_CHECKIN
+ if (containerV == null) {
+ log.error("Unexpected null value for `containerV`");
+ } else {
+ try {
- updateEdgeProperty(EdgePropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name(), getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.LAST_STATE));
+ //update edges to meet above change
+ // update LS eges from RFC to NOT_CERTIFIED_CHECKIN
- if (containerV.getMetadataProperty(GraphPropertyEnum.DISTRIBUTION_STATUS).equals(DistributionStatusEnum.DISTRIBUTION_APPROVED.name()) || containerV.getMetadataProperty(GraphPropertyEnum.DISTRIBUTION_STATUS).equals(DistributionStatusEnum.DISTRIBUTION_REJECTED.name())) {
+ updateEdgeProperty(EdgePropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN.name(),
+ getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.LAST_STATE));
- // update vertex state property from DISTRIBUTION_APPROVED/REJECTED to DISTRIBUTION_NOT_APPROVED state
+ if (containerV.getMetadataProperty(GraphPropertyEnum.DISTRIBUTION_STATUS)
+ .equals(DistributionStatusEnum.DISTRIBUTION_APPROVED.name()) || containerV
+ .getMetadataProperty(GraphPropertyEnum.DISTRIBUTION_STATUS)
+ .equals(DistributionStatusEnum.DISTRIBUTION_REJECTED.name())) {
- Map<GraphPropertyEnum, Object> metadataProperties = containerV.getMetadataProperties();
- metadataProperties.put(GraphPropertyEnum.DISTRIBUTION_STATUS, DistributionStatusEnum.DISTRIBUTION_NOT_APPROVED.name());
- containerV.setMetadataProperties(metadataProperties);
+ // update vertex state property from DISTRIBUTION_APPROVED/REJECTED to DISTRIBUTION_NOT_APPROVED state
- //update edges to meet above change
- //delete LAST_DISTRIBUTION_STATE_MODIFIER edge
+ Map<GraphPropertyEnum, Object> metadataProperties = containerV.getMetadataProperties();
+ metadataProperties.put(GraphPropertyEnum.DISTRIBUTION_STATUS,
+ DistributionStatusEnum.DISTRIBUTION_NOT_APPROVED.name());
+ containerV.setMetadataProperties(metadataProperties);
- removeEdges(getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.LAST_DISTRIBUTION_STATE_MODIFIER));
+ //update edges to meet above change
+ //delete LAST_DISTRIBUTION_STATE_MODIFIER edge
- }
+ removeEdges(
+ getVertexEdge(containerV, Direction.IN, EdgeLabelEnum.LAST_DISTRIBUTION_STATE_MODIFIER));
+
+ }
- status = updateVertexAndCommit(containerV);
+ status = updateVertexAndCommit(containerV);
- } catch (NullPointerException e) {
- log.error("Null Pointer Exception occurred - this mean we have zombie vertex, migration task will continue anyway", e);
- status = StorageOperationStatus.EXEUCTION_FAILED;
- } catch (Exception e) {
- //it is happy flow as well
- log.error("Exception occurred:", e);
- log.error("Migration task will continue anyway, please find below vertex details related to this exception", e);
- if (containerV != null) {
+ } catch (NullPointerException e) {
+ log.error(
+ "Null Pointer Exception occurred - this mean we have zombie vertex, migration task will continue anyway",
+ e);
+ status = StorageOperationStatus.EXEUCTION_FAILED;
+ } catch (Exception e) {
+ //it is happy flow as well
+ log.error("Exception occurred:", e);
+ log.error(
+ "Migration task will continue anyway, please find below vertex details related to this exception",
+ e);
log.error("containerV.getUniqueId() ---> {} ", containerV.getUniqueId());
- }
- } finally {
- if (status != StorageOperationStatus.OK) {
- janusGraphDao.rollback();
- log.info("failed to update vertex ID {} ", containerV.getUniqueId());
- log.info("Storage Operation Status {}", status.toString());
- } else {
- log.info("vertex ID {} successfully updated", containerV.getUniqueId());
+ } finally {
+ if (status != StorageOperationStatus.OK) {
+ janusGraphDao.rollback();
+ log.info("failed to update vertex ID {} ", containerV.getUniqueId());
+ log.info("Storage Operation Status {}", status.toString());
+ } else {
+ log.info("vertex ID {} successfully updated", containerV.getUniqueId());
+ }
}
-
}
+
return status;
}