/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
+ * Copyright © 2017-2018 AT&T Intellectual Property. Modifications Copyright © 2018 IBM.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software distributed under the License\r
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
+ * or implied. See the License for the specific language governing permissions and limitations under\r
+ * the License.\r
+ *\r
+ *\r
+ * Unless otherwise specified, all documentation contained herein is licensed under the Creative\r
+ * Commons License, Attribution 4.0 Intl. (the "License"); you may not use this documentation except\r
+ * in compliance with the License. You may obtain a copy of the License at\r
+ *\r
+ * https://creativecommons.org/licenses/by/4.0/\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, documentation distributed under the\r
+ * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\r
+ * express or implied. See the License for the specific language governing permissions and\r
* limitations under the License.\r
- * \r
- * \r
- * Unless otherwise specified, all documentation contained herein is licensed\r
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
- * you may not use this documentation except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * https://creativecommons.org/licenses/by/4.0/\r
- * \r
- * Unless required by applicable law or agreed to in writing, documentation\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
-*/\r
+ */\r
\r
package org.onap.optf.cmso.ticketmgt;\r
\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+import com.att.eelf.i18n.EELFResourceManager;\r
import java.util.ArrayList;\r
import java.util.HashMap;\r
import java.util.HashSet;\r
import java.util.Map;\r
import java.util.Set;\r
import java.util.UUID;\r
-\r
import javax.transaction.Transactional;\r
import org.onap.optf.cmso.common.CMSStatusEnum;\r
import org.onap.optf.cmso.common.LogMessages;\r
import org.springframework.core.env.Environment;\r
import org.springframework.stereotype.Component;\r
import org.springframework.transaction.interceptor.TransactionAspectSupport;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.att.eelf.i18n.EELFResourceManager;\r
\r
@Component\r
public class TmStatusClient {\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(TmStatusClient.class);\r
private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();\r
private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();\r
\r
Environment env;\r
\r
@Autowired\r
- ScheduleDAO scheduleDAO;\r
+ ScheduleDAO scheduleDao;\r
\r
@Autowired\r
- ChangeManagementScheduleDAO cmScheduleDAO;\r
+ ChangeManagementScheduleDAO cmScheduleDao;\r
\r
@Autowired\r
- ChangeManagementGroupDAO cmGroupDAO;\r
+ ChangeManagementGroupDAO cmGroupDao;\r
\r
@Autowired\r
TmClient tmClient;\r
\r
+ /**\r
+ * Check status.\r
+ *\r
+ * @param id the id\r
+ */\r
@Transactional\r
public void checkStatus(String id) {\r
debug.debug("Entered checkStatus id=" + id);\r
try {\r
// Multiple cmso instance support - re-get the record with a Schedule lock\r
- UUID uuid = UUID.fromString(id);\r
- Schedule s = scheduleDAO.lockOne(uuid);\r
- if (!s.getStatus().equals(CMSStatusEnum.NotificationsInitiated.toString())) {\r
- debug.debug(s.getScheduleId() + " is no longer in " + CMSStatusEnum.NotificationsInitiated.toString()\r
- + " : it is " + s.getStatus());\r
+ UUID uuid = UUID.fromString(id);\r
+ Schedule sch = scheduleDao.lockOne(uuid);\r
+ if (!sch.getStatus().equals(CMSStatusEnum.NotificationsInitiated.toString())) {\r
+ debug.debug(sch.getScheduleId() + " is no longer in " + CMSStatusEnum.NotificationsInitiated.toString()\r
+ + " : it is " + sch.getStatus());\r
// Attempt at avoiding race condition in a load balance env. ?\r
return;\r
}\r
Map<GroupAuditStatus, List<ChangeManagementGroup>> groupStatus =\r
- new HashMap<GroupAuditStatus, List<ChangeManagementGroup>>();\r
- List<ChangeManagementGroup> groups = cmGroupDAO.findBySchedulesID(uuid);\r
+ new HashMap<GroupAuditStatus, List<ChangeManagementGroup>>();\r
+ List<ChangeManagementGroup> groups = cmGroupDao.findBySchedulesID(uuid);\r
\r
// Close tickets for completed VNFs\r
for (ChangeManagementGroup group : groups) {\r
- processGroup(s, group);\r
+ processGroup(sch, group);\r
}\r
\r
// Check overall status of schedule.\r
//\r
for (ChangeManagementGroup group : groups) {\r
- GroupAuditStatus status = auditGroupStatus(s, group);\r
+ GroupAuditStatus status = auditGroupStatus(sch, group);\r
List<ChangeManagementGroup> list = groupStatus.get(status);\r
if (list == null) {\r
list = new ArrayList<ChangeManagementGroup>();\r
list.add(group);\r
}\r
// In progress\r
- if (groupStatus.containsKey(GroupAuditStatus.InProgress))\r
+ if (groupStatus.containsKey(GroupAuditStatus.InProgress)) {\r
return;\r
+ }\r
//\r
if (groupStatus.containsKey(GroupAuditStatus.CompletedWithErrors)) {\r
- s.setStatus(CMSStatusEnum.CompletedWithError.toString());\r
+ sch.setStatus(CMSStatusEnum.CompletedWithError.toString());\r
}\r
if (groupStatus.containsKey(GroupAuditStatus.Completed)) {\r
- s.setStatus(CMSStatusEnum.Completed.toString());\r
+ sch.setStatus(CMSStatusEnum.Completed.toString());\r
}\r
- scheduleDAO.save(s);\r
+ scheduleDao.save(sch);\r
} catch (Exception e) {\r
errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());\r
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();\r
}\r
}\r
\r
- private void processGroup(Schedule s, ChangeManagementGroup group) throws CMSException {\r
- debug.debug("{Processing status of " + s.getScheduleId() + " group=" + group.getGroupId());\r
+ private void processGroup(Schedule sch, ChangeManagementGroup group) throws CMSException {\r
+ debug.debug("{Processing status of " + sch.getScheduleId() + " group=" + group.getGroupId());\r
// Get status of all VNFs within a ticket within the group (Tickets will not\r
// span groups)\r
Map<String, List<ChangeManagementSchedule>> failed = new HashMap<String, List<ChangeManagementSchedule>>();\r
Map<String, List<ChangeManagementSchedule>> inProgress = new HashMap<String, List<ChangeManagementSchedule>>();\r
Map<String, List<ChangeManagementSchedule>> completed = new HashMap<String, List<ChangeManagementSchedule>>();\r
Map<String, List<ChangeManagementSchedule>> tmClosed = new HashMap<String, List<ChangeManagementSchedule>>();\r
- List<ChangeManagementSchedule> cmSchedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid());\r
+ List<ChangeManagementSchedule> cmSchedules = cmScheduleDao.findByChangeManagementGroupId(group.getUuid());\r
for (ChangeManagementSchedule cmSchedule : cmSchedules) {\r
String status = cmSchedule.getStatus();\r
- String changeId = cmSchedule.getTmChangeId();\r
String tmStatus = cmSchedule.getTmStatus();\r
CMSStatusEnum cmsStatus = CMSStatusEnum.Completed.fromString(status);\r
switch (cmsStatus) {\r
case ScheduledImmediate:\r
default:\r
errors.applicationEvent(\r
- "Unexpected Change Management schedule event status {0} encountered after notification : scheduleId={1} vnfName={2}",\r
- status, s.getScheduleId(), cmSchedule.getVnfName());\r
+ "Unexpected Change Management schedule event status {0} encountered "\r
+ + "after notification : scheduleId={1} vnfName={2}",\r
+ status, sch.getScheduleId(), cmSchedule.getVnfName());\r
break;\r
}\r
- if (tmStatus != null && tmStatus.equals("Closed"))\r
+ if (tmStatus != null && tmStatus.equals("Closed")) {\r
addTo(tmClosed, cmSchedule);\r
+ }\r
}\r
- debug.debug("{Status of " + s.getScheduleId() + " Group " + group.getGroupId() + "\ncompleted="\r
- + completed.keySet().toString() + "\ninProgress=" + inProgress.keySet().toString() + "\nfailed="\r
- + failed.keySet().toString() + "\ntmCLosed=" + tmClosed.keySet().toString());\r
+ debug.debug("{Status of " + sch.getScheduleId() + " Group " + group.getGroupId() + "\ncompleted="\r
+ + completed.keySet().toString() + "\ninProgress=" + inProgress.keySet().toString() + "\nfailed="\r
+ + failed.keySet().toString() + "\ntmCLosed=" + tmClosed.keySet().toString());\r
\r
// Remove all tickets from completed where there are still 'Triggered' VNFs\r
- for (String changeId : inProgress.keySet())\r
+ for (String changeId : inProgress.keySet()) {\r
completed.remove(changeId);\r
+ }\r
// Remove all tickets from completed where the ticket is already closed.\r
- for (String changeId : tmClosed.keySet())\r
+ for (String changeId : tmClosed.keySet()) {\r
completed.remove(changeId);\r
+ }\r
\r
// Do not know what to do with failed\r
for (String changeId : failed.keySet()) {\r
completed.remove(changeId);\r
- closeTheTicket(s, group, changeId, failed.get(changeId), ClosureCode.Unsuccessful,\r
- "Change management request failed for one or more VNFs");\r
+ closeTheTicket(sch, group, changeId, failed.get(changeId), ClosureCode.Unsuccessful,\r
+ "Change management request failed for one or more VNFs");\r
}\r
\r
// Remaining completed tickets should be closed\r
- debug.debug("{Final status of " + s.getScheduleId() + " Group " + group.getGroupId() + "\ncompleted="\r
- + completed.keySet().toString() + "\ninProgress=" + inProgress.keySet().toString() + "\nfailed="\r
- + failed.keySet().toString() + "\ntmCLosed=" + tmClosed.keySet().toString());\r
+ debug.debug("{Final status of " + sch.getScheduleId() + " Group " + group.getGroupId() + "\ncompleted="\r
+ + completed.keySet().toString() + "\ninProgress=" + inProgress.keySet().toString() + "\nfailed="\r
+ + failed.keySet().toString() + "\ntmCLosed=" + tmClosed.keySet().toString());\r
for (String changeId : completed.keySet()) {\r
- closeTheTicket(s, group, changeId, completed.get(changeId), ClosureCode.Successful,\r
- ClosureCode.Successful.toString());\r
+ closeTheTicket(sch, group, changeId, completed.get(changeId), ClosureCode.Successful,\r
+ ClosureCode.Successful.toString());\r
}\r
\r
}\r
\r
- private GroupAuditStatus auditGroupStatus(Schedule s, ChangeManagementGroup group) {\r
+ private GroupAuditStatus auditGroupStatus(Schedule sch, ChangeManagementGroup group) {\r
// Determine group status and synchronize VNF status with Ticket status.\r
Map<String, List<ChangeManagementSchedule>> failed = new HashMap<String, List<ChangeManagementSchedule>>();\r
Map<String, List<ChangeManagementSchedule>> inProgress = new HashMap<String, List<ChangeManagementSchedule>>();\r
Set<String> allNames = new HashSet<String>();\r
Set<String> failedNames = new HashSet<String>();\r
Set<String> completedNames = new HashSet<String>();\r
- Long startDate = group.getStartTimeMillis();\r
- List<ChangeManagementSchedule> cmSchedules = cmScheduleDAO.findByChangeManagementGroupId(group.getUuid());\r
+ List<ChangeManagementSchedule> cmSchedules = cmScheduleDao.findByChangeManagementGroupId(group.getUuid());\r
for (ChangeManagementSchedule cmSchedule : cmSchedules) {\r
String vnfName = cmSchedule.getVnfName();\r
vnfNames.add(vnfName);\r
case ScheduledImmediate:\r
default:\r
errors.applicationEvent(\r
- "Unexpected Change Management schedule event status {0} encountered after notification : scheduleId={1} vnfName={2}",\r
- status, s.getScheduleId(), cmSchedule.getVnfName());\r
+ "Unexpected Change Management schedule event status {0} encountered"\r
+ + " after notification : scheduleId={1} vnfName={2}",\r
+ status, sch.getScheduleId(), cmSchedule.getVnfName());\r
break;\r
}\r
- if (tmStatus != null && tmStatus.equals("Closed"))\r
+ if (tmStatus != null && tmStatus.equals("Closed")) {\r
addTo(tmClosed, cmSchedule);\r
+ }\r
}\r
\r
// We have at least 1 ticket with VNFs in progress. Leave schedule status as is.\r
- if (inProgress.size() > 0)\r
+ if (inProgress.size() > 0) {\r
return GroupAuditStatus.InProgress;\r
+ }\r
\r
// All VNFs are either failed or completed (or there is a bug.)\r
\r
}\r
\r
private void addTo(Map<String, List<ChangeManagementSchedule>> map, ChangeManagementSchedule cmSchedule) {\r
- String status = cmSchedule.getStatus();\r
String changeId = cmSchedule.getTmChangeId();\r
List<ChangeManagementSchedule> list = map.get(changeId);\r
if (list == null) {\r
\r
}\r
\r
- private void closeTheTicket(Schedule s, ChangeManagementGroup group, String changeId,\r
- List<ChangeManagementSchedule> list, ClosureCode closureCode, String closingComments) throws CMSException {\r
+ private void closeTheTicket(Schedule sch, ChangeManagementGroup group, String changeId,\r
+ List<ChangeManagementSchedule> list, ClosureCode closureCode, String closingComments)\r
+ throws CMSException {\r
debug.debug("Closing ticket " + changeId + ":" + closureCode);\r
try {\r
- tmClient.closeTicket(s, group, list, changeId, closureCode, closingComments);\r
+ tmClient.closeTicket(sch, group, list, changeId, closureCode, closingComments);\r
for (ChangeManagementSchedule cms : list) {\r
cms.setTmStatus("Closed");\r
- cmScheduleDAO.save(cms);\r
+ cmScheduleDao.save(cms);\r
}\r
} catch (CMSException e) {\r
throw e;\r
/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- * \r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ *\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* you may not use this file except in compliance with the License.\r
* You may obtain a copy of the License at\r
- * \r
+ *\r
* http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
+ *\r
* Unless required by applicable law or agreed to in writing, software\r
* distributed under the License is distributed on an "AS IS" BASIS,\r
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
- * \r
- * \r
+ *\r
+ *\r
* Unless otherwise specified, all documentation contained herein is licensed\r
* under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
* you may not use this documentation except in compliance with the License.\r
* You may obtain a copy of the License at\r
- * \r
+ *\r
* https://creativecommons.org/licenses/by/4.0/\r
- * \r
+ *\r
* Unless required by applicable law or agreed to in writing, documentation\r
* distributed under the License is distributed on an "AS IS" BASIS,\r
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
\r
package org.onap.optf.cmso.ticketmgt.bean;\r
\r
+import com.att.eelf.configuration.EELFLogger;\r
+import com.att.eelf.configuration.EELFManager;\r
+import com.fasterxml.jackson.databind.JsonNode;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+import com.fasterxml.jackson.databind.node.ObjectNode;\r
+import com.fasterxml.jackson.databind.node.TextNode;\r
+import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;\r
import java.io.File;\r
import java.util.Iterator;\r
import java.util.List;\r
import org.springframework.beans.factory.annotation.Autowired;\r
import org.springframework.core.env.Environment;\r
import org.springframework.stereotype.Component;\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-import com.fasterxml.jackson.databind.node.TextNode;\r
-import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;\r
\r
+/**\r
+ * The Class BuildCreateRequest.\r
+ */\r
@Component\r
public class BuildCreateRequest {\r
\r
// This is for example purposes only ans every provider\r
// will have unique requirements.\r
// This assumes multiple VNFs can appear on a single ticket\r
+ /**\r
+ * The Enum Variables.\r
+ */\r
//\r
public enum Variables {\r
vnfList(168), requesterId(50), plannedStartDate(15), plannedEndDate(15), validationStartTime(\r
this.maxLength = max;\r
}\r
\r
+ /**\r
+ * Gets the max length.\r
+ *\r
+ * @return the max length\r
+ */\r
public int getMaxLength() {\r
return maxLength;\r
}\r
}\r
\r
- private static EELFLogger log = EELFManager.getInstance().getLogger(BuildCreateRequest.class);\r
- private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger();\r
private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();\r
private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();\r
\r
@Autowired\r
Environment env;\r
\r
+ /**\r
+ * Creates the change record request.\r
+ *\r
+ * @param variables the variables\r
+ * @param assetList the asset list\r
+ * @param workflowName the workflow name\r
+ * @return the json node\r
+ */\r
public JsonNode createChangeRecordRequest(Map<String, Object> variables, List<TmAsset> assetList,\r
String workflowName) {\r
JsonNode rawjson = getYaml("CreateChangeTicket");\r
return json;\r
}\r
\r
+ /**\r
+ * Creates the close cancel change record.\r
+ *\r
+ * @param variables the variables\r
+ * @return the json node\r
+ */\r
public JsonNode createCloseCancelChangeRecord(Map<String, Object> variables) {\r
JsonNode rawjson = getYaml("CloseCancelChangeRecord");\r
JsonNode json = substituteJson(rawjson, variables);\r
return json;\r
}\r
\r
+ /**\r
+ * Creates the cancel change record.\r
+ *\r
+ * @param variables the variables\r
+ * @return the json node\r
+ */\r
public JsonNode createCancelChangeRecord(Map<String, Object> variables) {\r
JsonNode rawjson = getYaml("CancelChangeRecord");\r
JsonNode json = substituteJson(rawjson, variables);\r
return json;\r
}\r
\r
+ /**\r
+ * Creates the update change record.\r
+ *\r
+ * @param variables the variables\r
+ * @return the json node\r
+ */\r
public JsonNode createUpdateChangeRecord(Map<String, Object> variables) {\r
JsonNode rawjson = getYaml("UpdateChangeRecord");\r
JsonNode json = substituteJson(rawjson, variables);\r
return json;\r
}\r
\r
+ /**\r
+ * Creates the get change record.\r
+ *\r
+ * @param variables the variables\r
+ * @return the json node\r
+ */\r
public JsonNode createGetChangeRecord(Map<String, Object> variables) {\r
JsonNode rawjson = getYaml("GetChangeRecord");\r
JsonNode json = substituteJson(rawjson, variables);\r
}\r
\r
private boolean isInteger(String name) {\r
- if (name.equals(Variables.plannedEndDate.toString()))\r
+ if (name.equals(Variables.plannedEndDate.toString())) {\r
return true;\r
- if (name.equals(Variables.plannedStartDate.toString()))\r
+ }\r
+ if (name.equals(Variables.plannedStartDate.toString())) {\r
return true;\r
- if (name.equals(Variables.actualStartDate.toString()))\r
+ }\r
+ if (name.equals(Variables.actualStartDate.toString())) {\r
return true;\r
- if (name.equals(Variables.actualEndDate.toString()))\r
+ }\r
+ if (name.equals(Variables.actualEndDate.toString())) {\r
return true;\r
+ }\r
return false;\r
}\r
\r
+ /**\r
+ * Gets the yaml.\r
+ *\r
+ * @param workflowName the workflow name\r
+ * @return the yaml\r
+ */\r
public JsonNode getYaml(String workflowName) {\r
JsonNode json = null;\r
// Get the YAML file for this workflow\r