diff options
Diffstat (limited to 'asdctool/src/main/java')
-rw-r--r-- | asdctool/src/main/java/org/openecomp/sdc/asdctool/migration/tasks/mig2002/SdcCollapsingRolesCERTIFIEDstateMigration.java | 81 |
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; } |