diff options
135 files changed, 1796 insertions, 1244 deletions
diff --git a/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseData.java b/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseData.java index 842c70c..58a2850 100644 --- a/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseData.java +++ b/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseData.java @@ -1,44 +1,30 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
+ * ============LICENSE_START=======================================================================================
+ * Copyright (c) 2019 AT&T Intellectual Property.
+ * ===================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * OF ANY KIND, either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
- *
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
+ * ============LICENSE_END=========================================================================================
+ *
+ */
package org.onap.optf.cmso.liquibase;
import javax.sql.DataSource;
+import liquibase.integration.spring.SpringLiquibase;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
-import liquibase.integration.spring.SpringLiquibase;
/*
* Make sure following exceptions before build:
@@ -60,6 +46,11 @@ public class LiquibaseData { @Value("${changeLogFile}")
private String changeLogFile;
+ /**
+ * Liquibase.
+ *
+ * @return the spring liquibase
+ */
@Bean
public SpringLiquibase liquibase() {
SpringLiquibase liquibase = new SpringLiquibase();
diff --git a/cmso-optimizer/src/main/docker/extra-files/startService.sh b/cmso-optimizer/src/main/docker/extra-files/startService.sh index 6efd912..0549dfd 100644 --- a/cmso-optimizer/src/main/docker/extra-files/startService.sh +++ b/cmso-optimizer/src/main/docker/extra-files/startService.sh @@ -1,11 +1,28 @@ #!/bin/sh AUTHENTICATION=${AUTHENTICATION:-proprietary-auth} -JAVA_TRUSTSTORE=${JAVA_TRUSTSTORE:-etc/config/truststoreONAPall.jks} VM_ARGS="${VM_ARGS} -Dserver.local.startpath=${RESOURCES_HOME}" -VM_ARGS="${VM_ARGS} -Djavax.net.ssl.trustStore==${JAVA_TRUSTSTORE}" +if [ "${JAVA_TRUSTSTORE}" != ''] +then + VM_ARGS="${VM_ARGS} -Djavax.net.ssl.trustStore=${JAVA_TRUSTSTORE}" +fi + +if [ "${JAVA_TRUSTSTORE_PASSWORD}" != ''] +then + VM_ARGS="${VM_ARGS} -Djavax.net.ssl.trustStorePassword=${JAVA_TRUSTSTORE_PASSWORD}" +fi + +if [ "${SSL_KEYSTORE}" != '' ] +then + VM_ARGS="${VM_ARGS} -Dserver.ssl.key-store=${SSL_KEYSTORE}" +fi + +if [ "${SSL_KEYSTORE_PASSWORD}" != '' ] +then + VM_ARGS="${VM_ARGS} -Dserver.ssl.key-password=${SSL_KEYSTORE_PASSWORD}" +fi echo "VM_ARGS="${VM_ARGS} diff --git a/cmso-optimizer/src/main/java/org/onap/observations/MessageHeaders.java b/cmso-optimizer/src/main/java/org/onap/observations/MessageHeaders.java index fe6cea2..ccb7e56 100644 --- a/cmso-optimizer/src/main/java/org/onap/observations/MessageHeaders.java +++ b/cmso-optimizer/src/main/java/org/onap/observations/MessageHeaders.java @@ -65,7 +65,7 @@ public class MessageHeaders { } /** The Constant supportedMajorVersions. */ - public static final Map<String, String> supportedMajorVersions = new HashMap<String, String>(); + private static final Map<String, String> supportedMajorVersions = new HashMap<String, String>(); static { supportedMajorVersions.put("v1", "0"); @@ -73,7 +73,7 @@ public class MessageHeaders { } /** The Constant supportedMajorMinorVersions. */ - public static final Set<String> supportedMajorMinorVersions = new HashSet<String>(); + private static final Set<String> supportedMajorMinorVersions = new HashSet<String>(); static { supportedMajorMinorVersions.add("v1.0"); @@ -81,10 +81,10 @@ public class MessageHeaders { } /** The Constant latestVersion. */ - public static final String latestVersion = "2.0.0"; + private static final String latestVersion = "2.0.0"; /** The Constant patchVersion. */ - public static final String patchVersion = "0"; + private static final String patchVersion = "0"; /** * From string. @@ -152,4 +152,20 @@ public class MessageHeaders { } return true; } + + public static Map<String, String> getSupportedmajorversions() { + return supportedMajorVersions; + } + + public static Set<String> getSupportedmajorminorversions() { + return supportedMajorMinorVersions; + } + + public static String getLatestversion() { + return latestVersion; + } + + public static String getPatchversion() { + return patchVersion; + } } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManager.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManager.java index d82932b..58d3355 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManager.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManager.java @@ -33,12 +33,21 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; +/** + * The Class PolicyManager. + */ @Component public class PolicyManager { @Autowired Environment env; + /** + * Gets the time limit and vertical topology by name. + * + * @param name the name + * @return the time limit and vertical topology by name + */ public TimeLimitAndVerticalTopology getTimeLimitAndVerticalTopologyByName(String name) { Policy policy = getPolicyForName(name); TimeLimitAndVerticalTopology returnPolicy = null; @@ -54,6 +63,12 @@ public class PolicyManager { } + /** + * Gets the policy for name. + * + * @param name the name + * @return the policy for name + */ public Policy getPolicyForName(String name) { Policy policy = null; try { @@ -64,6 +79,12 @@ public class PolicyManager { return policy; } + /** + * Gets the local policy for name. + * + * @param name the name + * @return the local policy for name + */ public Policy getLocalPolicyForName(String name) { String policyFolder = env.getProperty("cmso.local.policy.folder", "data/policies"); Policy policy = null; @@ -80,6 +101,11 @@ public class PolicyManager { return policy; } + /** + * Gets the supported policies. + * + * @return the supported policies + */ public List<Policy> getSupportedPolicies() { List<Policy> policies = new ArrayList<>(); try { @@ -90,6 +116,11 @@ public class PolicyManager { return policies; } + /** + * Gets the local supported policies. + * + * @return the local supported policies + */ public List<Policy> getLocalSupportedPolicies() { String policyFolder = env.getProperty("cmso.local.policy.folder", "data/policies"); List<Policy> policies = new ArrayList<>(); diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/PolicyScope.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/PolicyScope.java index d569274..3e07748 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/PolicyScope.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/PolicyScope.java @@ -34,6 +34,7 @@ public class PolicyScope { public enum ServiceType { networkOnDemand } + public enum EntityType { vnf } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeLimitAndVerticalTopology.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeLimitAndVerticalTopology.java index 7af22e3..b883a86 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeLimitAndVerticalTopology.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeLimitAndVerticalTopology.java @@ -56,6 +56,7 @@ public class TimeLimitAndVerticalTopology { public enum ConflictScope { timeLimitAndVerticalTopology, } + public enum Type { vnf_pserver, } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeRange.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeRange.java index 0f8f851..cd23301 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeRange.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/policies/model/TimeRange.java @@ -19,6 +19,9 @@ package org.onap.optf.cmso.optimizer.availability.policies.model; +import com.fasterxml.jackson.annotation.JsonGetter; +import com.fasterxml.jackson.annotation.JsonSetter; + /* { @@ -28,23 +31,28 @@ package org.onap.optf.cmso.optimizer.availability.policies.model; */ public class TimeRange { - private String start_time; - private String end_time; + private String startTime; + private String endTime; - public String getStart_time() { - return start_time; + @JsonGetter("start_time") + public String getStartTime() { + return startTime; } - public void setStart_time(String start_time) { - this.start_time = start_time; + @JsonSetter("start_time") + public void setStartTime(String startTime) { + this.startTime = startTime; } - public String getEnd_time() { - return end_time; + @JsonGetter("end_time") + public String getEndTime() { + return endTime; } - public void setEnd_time(String end_time) { - this.end_time = end_time; + @JsonSetter("end_time") + public void setEndTime(String endTime) { + this.endTime = endTime; } + } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/timewindows/RecurringWindows.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/timewindows/RecurringWindows.java index c3536b7..81a848e 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/timewindows/RecurringWindows.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/availability/timewindows/RecurringWindows.java @@ -127,8 +127,8 @@ public class RecurringWindows { List<TimeRange> ranges = available.getTimeRange(); if (ranges.size() == 0) { TimeRange range = new TimeRange(); - range.setStart_time("00:00:00+00:00"); - range.setStart_time("23:59:59+00:00"); + range.setStartTime("00:00:00+00:00"); + range.setEndTime("23:59:59+00:00"); ranges.add(range); } StringBuilder rdata = new StringBuilder(); @@ -148,8 +148,9 @@ public class RecurringWindows { Instant cwStartInstant = changeWindow.getStartTime().toInstant(); Instant cwEndInstant = changeWindow.getEndTime().toInstant(); - List<DateTime> startList = getRecurringList(range.getStart_time(), cwStartInstant, rdata, cwEndInstant, -1); - List<DateTime> endList = getRecurringList(range.getEnd_time(), cwStartInstant, rdata, cwEndInstant, startList.size()); + List<DateTime> startList = getRecurringList(range.getStartTime(), cwStartInstant, rdata, cwEndInstant, -1); + List<DateTime> endList = getRecurringList(range.getEndTime(), cwStartInstant, + rdata, cwEndInstant, startList.size()); // Pair them up to make change windows // Everything should be UTC time for (int i = 0; i < startList.size(); i++) { @@ -181,8 +182,8 @@ public class RecurringWindows { DateTime next = recur.next(); // System.out.println(next.toString()); if (endingSize == -1) { - if (next.isAfter(cwEndInstant.toEpochMilli())) { - break; + if (next.isAfter(cwEndInstant.toEpochMilli())) { + break; } } else { @@ -218,10 +219,18 @@ public class RecurringWindows { return instant.plus(date.toEpochMilli(), ChronoUnit.MILLIS); } + /** + * Gets the recurring list for change window. + * + * @param window the window + * @param durationInSeconds the duration in seconds + * @return the recurring list for change window + * @throws ParseException the parse exception + */ public static DateTimeIterator getRecurringListForChangeWindow(ChangeWindow window, Long durationInSeconds) throws ParseException { - String rdata = "RRULE:FREQ=MINUTELY;INTERVAL=" + durationInSeconds/60; + String rdata = "RRULE:FREQ=MINUTELY;INTERVAL=" + durationInSeconds / 60; DateTime start = new DateTime(window.getStartTime().toInstant().toEpochMilli()); DateTimeIterator recur = DateTimeIteratorFactory.createDateTimeIterator(rdata, start, DateTimeZone.UTC, true); diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementAvailability.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementAvailability.java index ffaeeb9..ac5d2e7 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementAvailability.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementAvailability.java @@ -37,7 +37,10 @@ import org.onap.optf.cmso.optimizer.clients.topology.models.TopologyResponse; import org.onap.optf.cmso.optimizer.service.rs.models.ChangeWindow; import org.onap.optf.cmso.optimizer.service.rs.models.OptimizerRequest; -public class ElementAvailability extends ElementWindowMapping{ +/** + * The Class ElementAvailability. + */ +public class ElementAvailability extends ElementWindowMapping { private List<TimeLimitAndVerticalTopology> policies; private ActiveTicketsResponse ticketResponse; @@ -48,6 +51,15 @@ public class ElementAvailability extends ElementWindowMapping{ private Map<String, List<TicketData>> nodeUnAvailability = new TreeMap<>(); + /** + * Instantiates a new element availability. + * + * @param policies the policies + * @param optimizerRequest the optimizer request + * @param topologyResponse the topology response + * @param ticketResponse the ticket response + * @throws ParseException the parse exception + */ public ElementAvailability(List<TimeLimitAndVerticalTopology> policies, OptimizerRequest optimizerRequest, TopologyResponse topologyResponse, ActiveTicketsResponse ticketResponse) throws ParseException { super(optimizerRequest, topologyResponse); @@ -55,6 +67,12 @@ public class ElementAvailability extends ElementWindowMapping{ this.ticketResponse = ticketResponse; } + /** + * Populate. + * + * @param parameters the parameters + * @throws ParseException the parse exception + */ public void populate(OptimizerParameters parameters) throws ParseException { this.parameters = parameters; for (ChangeWindow changeWindow : optimizerRequest.getChangeWindows()) { @@ -78,7 +96,7 @@ public class ElementAvailability extends ElementWindowMapping{ parameters.setNumLoaders(1L); Long loaderCapacity = parameters.getNumElements(); List<Long> capacity = new ArrayList<>(); - for (Long slot =0L ; slot < parameters.getMaxTime() ; slot++) { + for (Long slot = 0L ; slot < parameters.getMaxTime() ; slot++) { capacity.add(loaderCapacity); } parameters.getLoaderCapacity().add(capacity); @@ -90,7 +108,7 @@ public class ElementAvailability extends ElementWindowMapping{ limit = parameters.getNumElements(); } - for (Long slot =0L ; slot < parameters.getMaxTime() ; slot++) { + for (Long slot = 0L ; slot < parameters.getMaxTime() ; slot++) { capacity.add(limit); } parameters.setElementSlotCapacity(capacity); @@ -137,10 +155,9 @@ public class ElementAvailability extends ElementWindowMapping{ } - private long calculateNumberOfSlotsInWindow(ChangeWindow window, Long duration) - { + private long calculateNumberOfSlotsInWindow(ChangeWindow window, Long duration) { long windowSize = window.getEndTime().getTime() - window.getStartTime().getTime(); - long numberOfSlots = windowSize /duration; + long numberOfSlots = windowSize / duration; return numberOfSlots; } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementWindowMapping.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementWindowMapping.java index 246a725..d2565f0 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementWindowMapping.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/ElementWindowMapping.java @@ -41,6 +41,9 @@ import org.onap.optf.cmso.optimizer.service.rs.models.UnScheduledElement; import org.onap.optf.cmso.optimizer.service.rs.models.UnScheduledElement.NotScheduledReason; // This class ensures that the node indices nodes and the time slots are the +/** + * The Class ElementWindowMapping. + */ // same when processing the optimizer engine response as when initiating. public class ElementWindowMapping { @@ -50,6 +53,13 @@ public class ElementWindowMapping { protected Map<String, TopologyElementInfo> nodeInfo = new TreeMap<>(); private List<TopologyElementInfo> nodeArray = null; + /** + * Instantiates a new element window mapping. + * + * @param optimizerRequest the optimizer request + * @param topologyResponse the topology response + * @throws ParseException the parse exception + */ public ElementWindowMapping(OptimizerRequest optimizerRequest, TopologyResponse topologyResponse) throws ParseException { this.optimizerRequest = optimizerRequest; @@ -76,14 +86,24 @@ public class ElementWindowMapping { return recur; } + /** + * Initialize for process result. + */ public void initializeForProcessResult() { - // we need nodeInfo to be an array to speed up the result processing. - // but we need it sorted by elementId as when we created it.... - nodeArray = nodeInfo.values().stream().collect(Collectors.toList()); - nodeInfo.clear(); + // we need nodeInfo to be an array to speed up the result processing. + // but we need it sorted by elementId as when we created it.... + nodeArray = nodeInfo.values().stream().collect(Collectors.toList()); + nodeInfo.clear(); } + /** + * Process result. + * + * @param result the result + * @return the optimizer schedule info + * @throws ParseException the parse exception + */ public OptimizerScheduleInfo processResult(OptimizerSchedule result) throws ParseException { // When considering the memory vs performance // 5 minute duration for a month long change window is 8928 slots @@ -98,8 +118,9 @@ public class ElementWindowMapping { Integer slotIndex = 1; while (iter.hasNext()) { DateTime dateTime = iter.next(); - if (dateTime.isAfter(endWindow)) + if (dateTime.isAfter(endWindow)) { break; + } List<ElementSlot> list = mapSlotToElement.get(slotIndex); if (list != null) { list.stream().forEach(x -> x.setTime(dateTime.getMillis())); @@ -117,7 +138,7 @@ public class ElementWindowMapping { } private void updateInfo(ElementSlot slot, OptimizerScheduleInfo info) { - TopologyElementInfo element = nodeArray.get(slot.getElementIndex()-1); + TopologyElementInfo element = nodeArray.get(slot.getElementIndex() - 1); if (slot.getSlot() > 0) { ScheduledElement scheduled = new ScheduledElement(); Integer durationInSeconds = optimizerRequest.getNormalDuration(); @@ -127,7 +148,7 @@ public class ElementWindowMapping { scheduled.setDurationSeconds(durationInSeconds.longValue()); scheduled.setElementId(element.getElementId()); scheduled.setStartTime(new Date(slot.getTime())); - scheduled.setEndTime(new Date(slot.getTime() + (durationInSeconds*1000))); + scheduled.setEndTime(new Date(slot.getTime() + (durationInSeconds * 1000))); scheduled.setScheduleType(ScheduleType.INDIVIDUAL); scheduled.setGroupId(getGroupId(scheduled.getElementId())); info.getScheduledElements().add(scheduled); diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerClient.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerClient.java index b382278..b42ff9c 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerClient.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerClient.java @@ -230,7 +230,7 @@ public class OptimizerClient { apiResponse.setErrorMessage(LogMessages.UNEXPECTED_EXCEPTION.format(e.getMessage())); Observation.report(LogMessages.UNEXPECTED_RESPONSE, e, e.getMessage()); } finally { - if (process.isAlive()) { + if (process != null && process.isAlive()) { process.destroyForcibly(); } if (workingFolder.exists()) { @@ -243,8 +243,6 @@ public class OptimizerClient { private ProcessBuilder buildCommand(Path inputFileName, Path outputFileName, String timeLimit) { ProcessBuilder processBuilder = new ProcessBuilder(); List<String> command = new ArrayList<>(); - String commandline = - env.getProperty("cmso.minizinc.command.commandline", "/bin/bash -x scripts/minizinc/run.sh"); String minizinc = env.getProperty("cmso.minizinc.command.exe", "minizinc"); String solver = env.getProperty("cmso.minizinc.command.solver", "OSICBC"); String script = env.getProperty("cmso.minizinc.command.mzn", "scripts/minizinc/generic_attributes.mzn"); @@ -255,6 +253,8 @@ public class OptimizerClient { environment.put("MINIZINC_OUTPUT", outputFileName.toString()); environment.put("MINIZINC_MZN", script); environment.put("MINIZINC_DZN", inputFileName.toString()); + String commandline = + env.getProperty("cmso.minizinc.command.commandline", "/bin/bash -x scripts/minizinc/run.sh"); for (String arg : commandline.split(" ")) { command.add(arg); } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerRequestManager.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerRequestManager.java index c911804..cfe23ba 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerRequestManager.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/OptimizerRequestManager.java @@ -76,7 +76,7 @@ public class OptimizerRequestManager { */ public OptimizerEngineResponse createOptimizerRequest(Request requestRow) { // - if (okToDispatch()) { + if (okToDispatch(false)) { Optimizer optimizer = getExistingOptmizer(requestRow.getUuid()); if (optimizer == null) { optimizer = new Optimizer(); @@ -105,19 +105,15 @@ public class OptimizerRequestManager { private void buildFinalResponse(Request requestRow, OptimizerEngineResponse apiResponse) { Optional<Response> opt = responseDao.findById(requestRow.getUuid()); Response responseRow = null; - if (opt.isPresent()) - { + if (opt.isPresent()) { responseRow = opt.get(); } - if (responseRow == null) - { + if (responseRow == null) { responseRow = new Response(); responseRow.setUuid(requestRow.getUuid()); } - try - { - OptimizerResults results = apiResponse.getOptimizerResults(); + try { OptimizerResponse response = new OptimizerResponse(); response.setRequestId(requestRow.getUuid().toString()); response.setStatus(OptimizeScheduleStatus.COMPLETED); @@ -127,6 +123,7 @@ public class OptimizerRequestManager { TopologyResponse topologyResponse = topologyRequestManager.getTopologyResponse(requestRow.getUuid()); ElementWindowMapping ewm = new ElementWindowMapping(optimizerResquest, topologyResponse); ewm.initializeForProcessResult(); + OptimizerResults results = apiResponse.getOptimizerResults(); for (OptimizerSchedule result : results.getSchedules()) { OptimizerScheduleInfo info = ewm.processResult(result); if (info != null) { @@ -137,9 +134,7 @@ public class OptimizerRequestManager { requestRow.setStatus(OptimizeScheduleStatus.COMPLETED.toString()); responseDao.save(responseRow); requestDao.save(requestRow); - } - catch (Exception e) - { + } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); requestRow.setStatus(OptimizeScheduleStatus.FAILED.toString()); requestRow.setMessage(e.getMessage()); @@ -151,11 +146,14 @@ public class OptimizerRequestManager { - private boolean okToDispatch() { - // TODO Auto-generated method stub - - // Will probably change to @Async on makeRequest to queue requests in a different thread. - return true; + private boolean okToDispatch(boolean checkDispatchability) { + if (checkDispatchability) { + // not yet implemented + return false; + } + else { + return true; + } } @@ -175,5 +173,4 @@ public class OptimizerRequestManager { - } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerEngineResponse.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerEngineResponse.java index 7315b31..c353221 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerEngineResponse.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerEngineResponse.java @@ -18,8 +18,7 @@ package org.onap.optf.cmso.optimizer.clients.optimizer.models; -public class OptimizerEngineResponse -{ +public class OptimizerEngineResponse { public enum OptimizerEngineResponseStatus { IN_PROGRESS, COMPLETED, FAILED, IN_QUEUE, @@ -30,33 +29,43 @@ public class OptimizerEngineResponse private OptimizerEngineResponseStatus status; private Integer pollingSeconds; private String errorMessage; + public String getRequestId() { return requestId; } + public void setRequestId(String requestId) { this.requestId = requestId; } + public OptimizerResults getOptimizerResults() { return optimizerResults; } + public void setOptimizerResults(OptimizerResults oprimizerResults) { this.optimizerResults = oprimizerResults; } + public OptimizerEngineResponseStatus getStatus() { return status; } + public void setStatus(OptimizerEngineResponseStatus status) { this.status = status; } + public Integer getPollingSeconds() { return pollingSeconds; } + public void setPollingSeconds(Integer pollingSeconds) { this.pollingSeconds = pollingSeconds; } + public String getErrorMessage() { return errorMessage; } + public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerOutResults.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerOutResults.java index 2c1c777..db880c3 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerOutResults.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerOutResults.java @@ -31,8 +31,8 @@ public class OptimizerOutResults { return elapsedMillis; } - public void setElapsedMillis(Long elapsed_millis) { - this.elapsedMillis = elapsed_millis; + public void setElapsedMillis(Long elapsedMillis) { + this.elapsedMillis = elapsedMillis; } public List<OptimizerOutSchedule> getResults() { diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerParameters.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerParameters.java index be74e37..6af307c 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerParameters.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerParameters.java @@ -22,6 +22,9 @@ import java.util.ArrayList; import java.util.List; +/** + * The Class OptimizerParameters. + */ /* * numElements = 5; maxTime = 5; @@ -56,88 +59,193 @@ public class OptimizerParameters { private List<List<Long>> attributes = new ArrayList<>(); private List<List<Long>> attributeConcurrencyLimit = new ArrayList<>(); + /** + * Gets the num elements. + * + * @return the num elements + */ public Long getNumElements() { return numElements; } + /** + * Sets the num elements. + * + * @param numElements the new num elements + */ public void setNumElements(Long numElements) { this.numElements = numElements; } + /** + * Gets the max time. + * + * @return the max time + */ public Long getMaxTime() { return maxTime; } + /** + * Sets the max time. + * + * @param maxTime the new max time + */ public void setMaxTime(Long maxTime) { this.maxTime = maxTime; } + /** + * Gets the num loaders. + * + * @return the num loaders + */ public Long getNumLoaders() { return numLoaders; } + /** + * Sets the num loaders. + * + * @param numLoaders the new num loaders + */ public void setNumLoaders(Long numLoaders) { this.numLoaders = numLoaders; } + /** + * Gets the no conflict. + * + * @return the no conflict + */ public List<List<Boolean>> getNoConflict() { return noConflict; } + /** + * Sets the no conflict. + * + * @param noConflict the new no conflict + */ public void setNoConflict(List<List<Boolean>> noConflict) { this.noConflict = noConflict; } + /** + * Gets the element slot capacity. + * + * @return the element slot capacity + */ public List<Long> getElementSlotCapacity() { return elementSlotCapacity; } + /** + * Sets the element slot capacity. + * + * @param slotCapacity the new element slot capacity + */ public void setElementSlotCapacity(List<Long> slotCapacity) { this.elementSlotCapacity = slotCapacity; } + /** + * Gets the loader capacity. + * + * @return the loader capacity + */ public List<List<Long>> getLoaderCapacity() { return loaderCapacity; } + /** + * Sets the loader capacity. + * + * @param loaderCapacity the new loader capacity + */ public void setLoaderCapacity(List<List<Long>> loaderCapacity) { this.loaderCapacity = loaderCapacity; } + /** + * Gets the num attributes. + * + * @return the num attributes + */ public Long getNumAttributes() { return numAttributes; } + /** + * Sets the num attributes. + * + * @param numAttributes the new num attributes + */ public void setNumAttributes(Long numAttributes) { this.numAttributes = numAttributes; } + /** + * Gets the attributes range. + * + * @return the attributes range + */ public List<Long> getAttributesRange() { return attributesRange; } + /** + * Sets the attributes range. + * + * @param attributesRange the new attributes range + */ public void setAttributesRange(List<Long> attributesRange) { this.attributesRange = attributesRange; } + /** + * Gets the attributes. + * + * @return the attributes + */ public List<List<Long>> getAttributes() { return attributes; } + /** + * Sets the attributes. + * + * @param attributes the new attributes + */ public void setAttributes(List<List<Long>> attributes) { this.attributes = attributes; } + /** + * Gets the attribute concurrency limit. + * + * @return the attribute concurrency limit + */ public List<List<Long>> getAttributeConcurrencyLimit() { return attributeConcurrencyLimit; } + /** + * Sets the attribute concurrency limit. + * + * @param attributeConcurrencyLimit the new attribute concurrency limit + */ public void setAttributeConcurrencyLimit(List<List<Long>> attributeConcurrencyLimit) { this.attributeConcurrencyLimit = attributeConcurrencyLimit; } + /** + * To mini zinc. + * + * @return the string + */ public String toMiniZinc() { StringBuilder sb = new StringBuilder(); appendAttribute(sb, "numElements", numElements.toString()); @@ -152,21 +260,17 @@ public class OptimizerParameters { if (attributesRange.size() > 0) { appendAttribute(sb, "attributesRange", "[" + formatLongList(attributesRange) + "]"); - } - else { + } else { appendAttribute(sb, "attributesRange", "[]"); } if (attributes.size() > 0) { appendAttribute(sb, "attributes", "[|\n" + formatLongRows(attributes) + "|]"); - } - else { + } else { appendAttribute(sb, "attributes", "array2d(1..numElements, 1..numAttributes, [])"); } if (attributeConcurrencyLimit.size() > 0) { appendAttribute(sb, "attributeConcurrencyLimit", "[|\n" + formatLongRows(attributeConcurrencyLimit) + "|]"); - } - else - { + } else { appendAttribute(sb, "attributeConcurrencyLimit", "array2d(1..numAttributes, 1..maxTime, [])"); } return sb.toString(); diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResponseUtility.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResponseUtility.java index 89208b2..595bc0d 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResponseUtility.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResponseUtility.java @@ -31,8 +31,17 @@ import org.yaml.snakeyaml.constructor.Constructor; import org.yaml.snakeyaml.introspector.Property; import org.yaml.snakeyaml.introspector.PropertyUtils; +/** + * The Class OptimizerResponseUtility. + */ public class OptimizerResponseUtility extends PropertyUtils { + /** + * Parses the optimizer result. + * + * @param resultsFile the results file + * @return the optimizer results + */ public OptimizerResults parseOptimizerResult(File resultsFile) { OptimizerResults results = null; try (InputStream input = new FileInputStream(resultsFile)) { @@ -73,6 +82,13 @@ public class OptimizerResponseUtility extends PropertyUtils { return optimizerSchedule; } + /** + * Gets the property. + * + * @param type the type + * @param name the name + * @return the property + */ @Override public Property getProperty(Class<? extends Object> type, String name) { name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name); diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResults.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResults.java index 9c31a9f..ca8a78b 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResults.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/OptimizerResults.java @@ -31,8 +31,8 @@ public class OptimizerResults { return elapsedMillis; } - public void setElapsedMillis(Long elapsed_millis) { - this.elapsedMillis = elapsed_millis; + public void setElapsedMillis(Long elapsedMillis) { + this.elapsedMillis = elapsedMillis; } public List<OptimizerSchedule> getSchedules() { diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/Results.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/Results.java index 402bdf2..57698f6 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/Results.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/optimizer/models/Results.java @@ -31,8 +31,8 @@ public class Results { return elapsedMillis; } - public void setElapsedMillis(Long elapsed_millis) { - this.elapsedMillis = elapsed_millis; + public void setElapsedMillis(Long elapsedMillis) { + this.elapsedMillis = elapsedMillis; } public List<OptimizerSchedule> getSchedules() { diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/TicketMgtRequestManager.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/TicketMgtRequestManager.java index 8520809..85ff950 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/TicketMgtRequestManager.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/TicketMgtRequestManager.java @@ -61,21 +61,22 @@ public class TicketMgtRequestManager { * @return the active tickets response */ public ActiveTicketsResponse createTicketsRequest(Request requestRow) { - Ticket row = null; - Optional<Ticket> rowOpt = ticketDao.findById(requestRow.getUuid()); - if (rowOpt.isPresent()) { - row = rowOpt.get(); + Ticket row = null; + Optional<Ticket> rowOpt = ticketDao.findById(requestRow.getUuid()); + if (rowOpt.isPresent()) { + row = rowOpt.get(); + + } + if (row == null) { + row = new Ticket(); + row.setUuid(requestRow.getUuid()); + row.setTicketsRetries(0); + } + ActiveTicketsResponse apiResponse = ticketmgtClient.makeRequest(requestRow, row); + ticketDao.save(row); + return apiResponse; + } - } - if (row == null) { - row = new Ticket(); - row.setUuid(requestRow.getUuid()); - row.setTicketsRetries(0); - } - ActiveTicketsResponse apiResponse = ticketmgtClient.makeRequest(requestRow, row); - ticketDao.save(row); - return apiResponse; - } /** * Gets the existing tickets. * diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/ActiveTicketsRequest.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/ActiveTicketsRequest.java index f03c6f3..b83212a 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/ActiveTicketsRequest.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/ActiveTicketsRequest.java @@ -51,7 +51,8 @@ public class ActiveTicketsRequest implements Serializable { private String requestId; @ApiModelProperty( - value = "Implementation specific name value pairs provided to be passed to Ticket Management query .") + value = "Implementation specific name value pairs provided" + + " to be passed to Ticket Management query .") private List<NameValue> commonData; @ApiModelProperty(value = "Lists of desired change windows for which TicketData will be returned.") diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/Availability.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/Availability.java index 37995bb..e5f1929 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/Availability.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/Availability.java @@ -1,33 +1,34 @@ /******************************************************************************* - * + * * Copyright © 2019 AT&T Intellectual Property. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ + package org.onap.optf.cmso.optimizer.clients.ticketmgt.models; public enum Availability { diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/TicketData.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/TicketData.java index 07b9f94..7ab7a0c 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/TicketData.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/ticketmgt/models/TicketData.java @@ -28,6 +28,7 @@ * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ + package org.onap.optf.cmso.optimizer.clients.ticketmgt.models; import com.att.eelf.configuration.EELFLogger; diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyClient.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyClient.java index c333651..ca6bdb3 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyClient.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyClient.java @@ -21,7 +21,6 @@ package org.onap.optf.cmso.optimizer.clients.topology; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import com.att.eelf.i18n.EELFResourceManager; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.ArrayList; @@ -102,6 +101,7 @@ public class TopologyClient { topologyResponse.setStatus(TopologyRequestStatus.FAILED); topologyResponse.setErrorMessage(LogMessages.UNEXPECTED_EXCEPTION.format(e.getMessage())); Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); + return topologyResponse; } topologyRequest = new TopologyRequest(); topologyRequest.setRequestId(optimizerRequest.getRequestId()); diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyRequestManager.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyRequestManager.java index a1cb51d..f62a851 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyRequestManager.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/clients/topology/TopologyRequestManager.java @@ -87,10 +87,19 @@ public class TopologyRequestManager { } - public TopologyResponse getTopologyResponse(UUID uuid) throws JsonParseException, JsonMappingException, IOException { + /** + * Gets the topology response. + * + * @param uuid the uuid + * @return the topology response + * @throws JsonParseException the json parse exception + * @throws JsonMappingException the json mapping exception + * @throws IOException Signals that an I/O exception has occurred. + */ + public TopologyResponse getTopologyResponse(UUID uuid) + throws JsonParseException, JsonMappingException, IOException { Topology row = getExistingTopology(uuid); - if (row != null) - { + if (row != null) { String responseString = row.getTopology(); return new ObjectMapper().readValue(responseString, TopologyResponse.class); } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/core/OptimizerManager.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/core/OptimizerManager.java index d2e3153..b61ec08 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/core/OptimizerManager.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/core/OptimizerManager.java @@ -163,13 +163,10 @@ public class OptimizerManager { initiateDataGathering(requestRow); requestDao.save(requestRow); OptimizeScheduleStatus status = OptimizeScheduleStatus.valueOf(requestRow.getStatus()); - if (status == OptimizeScheduleStatus.COMPLETED) - { + if (status == OptimizeScheduleStatus.COMPLETED) { // COmpletely synchronous optimization optimizerResponse = getCompletedOptimizerResponse(uuid); - } - else - { + } else { // One or more steps are asynchronous optimizerResponse.setStatus(status); optimizerResponse.setErrorMessage(""); @@ -195,7 +192,7 @@ public class OptimizerManager { case IN_PROGRESS: requestRow.setRequestStart(System.currentTimeMillis()); requestRow.setStatus(OptimizeScheduleStatus.TOPOLOGY_IN_PROGRESS.toString()); - return; + return; default: break; } @@ -259,17 +256,19 @@ public class OptimizerManager { requestRow.getUuid().toString()); } - public OptimizerResponse getCompletedOptimizerResponse(UUID uuid) - { + /** + * Gets the completed optimizer response. + * + * @param uuid the uuid + * @return the completed optimizer response + */ + public OptimizerResponse getCompletedOptimizerResponse(UUID uuid) { OptimizerResponse response = null; - Response responseRow = getResponseRow(uuid); - try - { + Response responseRow = getResponseRow(uuid); + try { String responseStr = responseRow.getRepsonse(); response = new ObjectMapper().readValue(responseStr, OptimizerResponse.class); - } - catch (Exception e) - { + } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); response = new OptimizerResponse(); response.setRequestId(uuid.toString()); @@ -279,11 +278,15 @@ public class OptimizerManager { return response; } - public Response getResponseRow(UUID uuid) - { + /** + * Gets the response row. + * + * @param uuid the uuid + * @return the response row + */ + public Response getResponseRow(UUID uuid) { Optional<Response> opt = responseDao.findById(uuid); - if (opt.isPresent()) - { + if (opt.isPresent()) { return opt.get(); } return null; @@ -296,8 +299,8 @@ public class OptimizerManager { if (requestOptional.isPresent()) { return requestOptional.get(); } - throw new CmsoException(Status.INTERNAL_SERVER_ERROR, LogMessages.EXPECTED_DATA_NOT_FOUND, - uuid.toString(), "Request table"); + throw new CmsoException(Status.INTERNAL_SERVER_ERROR, LogMessages.EXPECTED_DATA_NOT_FOUND, uuid.toString(), + "Request table"); } diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/filters/CmsoContainerFilters.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/filters/CmsoContainerFilters.java index e8fe5f0..3a13805 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/filters/CmsoContainerFilters.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/filters/CmsoContainerFilters.java @@ -68,8 +68,8 @@ public class CmsoContainerFilters implements ContainerRequestFilter, ContainerRe MultivaluedMap<String, Object> respHeaders = responseContext.getHeaders(); String minorVersion = reqHeaders.getFirst(HeadersEnum.MinorVersion.toString()); respHeaders.add(HeadersEnum.MinorVersion.toString(), minorVersion); - respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.latestVersion); - respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.patchVersion); + respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.getLatestversion()); + respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.getPatchversion()); } catch (Exception e) { if (e instanceof WebApplicationException) { @@ -110,7 +110,7 @@ public class CmsoContainerFilters implements ContainerRequestFilter, ContainerRe } String minorVersion = headers.getFirst(HeadersEnum.MinorVersion.toString()); if (minorVersion == null) { - minorVersion = MessageHeaders.supportedMajorVersions.get(majorVersion); + minorVersion = MessageHeaders.getSupportedmajorversions().get(majorVersion); headers.add(HeadersEnum.MinorVersion.toString(), minorVersion); } if (!MessageHeaders.validateMajorMinorVersion(majorVersion, minorVersion)) { diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/OptimizerInterfaceImpl.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/OptimizerInterfaceImpl.java index a2a018a..b475861 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/OptimizerInterfaceImpl.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/OptimizerInterfaceImpl.java @@ -76,8 +76,7 @@ public class OptimizerInterfaceImpl implements OptimizerInterface { try { optimizerManager.validate(request); // Throws CmsException if invalid message OptimizerResponse optimizerResponse = optimizerManager.processOptimizerRequest(request); - if (optimizerResponse != null) - { + if (optimizerResponse != null) { response = Response.ok(optimizerResponse).build(); } else { // Request will be processed asynchronously diff --git a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ChangeWindow.java b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ChangeWindow.java index e9218b2..bec1de7 100644 --- a/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ChangeWindow.java +++ b/cmso-optimizer/src/main/java/org/onap/optf/cmso/optimizer/service/rs/models/ChangeWindow.java @@ -107,7 +107,7 @@ public class ChangeWindow implements Serializable { return true; } // end is before start or start is before end, cannot overlap - if (endstart == -1 || startend == 1) { + if (endstart < 0 || startend > 0) { return false; } return true; @@ -132,7 +132,8 @@ public class ChangeWindow implements Serializable { * absolute UTC times provided in tickets which should already be adjusted for time zone. * * @param test the test - * @param timeZoneOffset the time zone offset + * @param startTimeZoneOffset the starting time zone offset + * @param endTimeZoneOffset the ending time zone offset * @return true, if successful */ public boolean containsInTimeZone(ChangeWindow test, Integer startTimeZoneOffset, Integer endTimeZoneOffset) { @@ -147,6 +148,13 @@ public class ChangeWindow implements Serializable { return false; } + /** + * Contains in time zone. + * + * @param test the test + * @param timeZone the time zone + * @return true, if successful + */ public boolean containsInTimeZone(ChangeWindow test, String timeZone) { TimeZone tz = TimeZone.getTimeZone(timeZone); Integer startTimeZoneOffset = tz.getOffset(startTime.toInstant().truncatedTo(ChronoUnit.DAYS).toEpochMilli()); diff --git a/cmso-optimizer/src/test/java/org/onap/optf/cmso/AuthProviderTest.java b/cmso-optimizer/src/test/java/org/onap/optf/cmso/AuthProviderTest.java index d2852d2..112b3a1 100644 --- a/cmso-optimizer/src/test/java/org/onap/optf/cmso/AuthProviderTest.java +++ b/cmso-optimizer/src/test/java/org/onap/optf/cmso/AuthProviderTest.java @@ -36,6 +36,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; + import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.runners.MockitoJUnitRunner; diff --git a/cmso-optimizer/src/test/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManagerTest.java b/cmso-optimizer/src/test/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManagerTest.java index 817c8de..50c9969 100644 --- a/cmso-optimizer/src/test/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManagerTest.java +++ b/cmso-optimizer/src/test/java/org/onap/optf/cmso/optimizer/availability/policies/PolicyManagerTest.java @@ -50,7 +50,6 @@ public class PolicyManagerTest { @Test public void getPolicyByName() { - String policyName = "Weekday_00_06"; String result = "CMSO.Weekday_00_06,CMSO.Weekday_00_06,CMSO.Weekday_00_06,CMSO.Weekday_00_06,"; List<Policy> policies = policyManager.getSupportedPolicies(); @@ -60,6 +59,7 @@ public class PolicyManagerTest { } System.out.println(" String result = \"" + sb.toString() + "\";"); Assert.assertTrue(result.equals(sb.toString())); + String policyName = "Weekday_00_06"; Policy policy = policyManager.getPolicyForName(policyName); Assert.assertTrue(policy != null); TimeLimitAndVerticalTopology top = policyManager.getTimeLimitAndVerticalTopologyByName(policyName); diff --git a/cmso-optimizer/src/test/java/org/onap/optf/cmso/service/rs/MockHttpServletRequest.java b/cmso-optimizer/src/test/java/org/onap/optf/cmso/service/rs/MockHttpServletRequest.java index f7d0939..84dbf54 100644 --- a/cmso-optimizer/src/test/java/org/onap/optf/cmso/service/rs/MockHttpServletRequest.java +++ b/cmso-optimizer/src/test/java/org/onap/optf/cmso/service/rs/MockHttpServletRequest.java @@ -3,24 +3,25 @@ * Copyright (c) 2019 AT&T Intellectual Property. * ======================================================================= * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. You may obtain a + * not use this file except in compliance with the License. You may obtain a * copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing * permissions and limitations under the License. * ============LICENSE_END================================================= - * + * */ package org.onap.optf.cmso.service.rs; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; + import javax.servlet.http.HttpServletRequest; public class MockHttpServletRequest { diff --git a/cmso-service/etc/config/cmso.properties b/cmso-service/etc/config/cmso.properties index e9bec86..c28783a 100644 --- a/cmso-service/etc/config/cmso.properties +++ b/cmso-service/etc/config/cmso.properties @@ -44,7 +44,7 @@ spring.datasource.tomcat.initialSize=5 spring.datasource.tomcat.max-active=25
spring.datasource.tomcat.test-on-borrow=true
-spring.jpa.show-sql=true
+spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
diff --git a/cmso-service/src/main/java/org/onap/observations/Mdc.java b/cmso-service/src/main/java/org/onap/observations/Mdc.java index 28d0ec8..a27080a 100644 --- a/cmso-service/src/main/java/org/onap/observations/Mdc.java +++ b/cmso-service/src/main/java/org/onap/observations/Mdc.java @@ -114,8 +114,7 @@ public class Mdc { */ public static void setCaller(int back) { String caller = MDC.get(Enum.ClassName.name()); - if (caller == null) - { + if (caller == null) { MDC.put(Enum.ClassName.name(), getCaller(back)); } } @@ -187,8 +186,7 @@ public class Mdc { */ public static void restore(Map<String, String> mdcSave) { MDC.clear(); - for (String name : mdcSave.keySet()) - { + for (String name : mdcSave.keySet()) { MDC.put(name, mdcSave.get(name)); } } diff --git a/cmso-service/src/main/java/org/onap/observations/ObservationObject.java b/cmso-service/src/main/java/org/onap/observations/ObservationObject.java index 17bd939..f1c1277 100644 --- a/cmso-service/src/main/java/org/onap/observations/ObservationObject.java +++ b/cmso-service/src/main/java/org/onap/observations/ObservationObject.java @@ -45,7 +45,7 @@ public class ObservationObject implements ObservationInterface { // private Enum<?> value = null; - private Level level = null;; + private Level level = null; private String message = null; private Status status = null; private String domain = null; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/Application.java b/cmso-service/src/main/java/org/onap/optf/cmso/Application.java index 42e86f2..af1f88d 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/Application.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/Application.java @@ -17,6 +17,9 @@ package org.onap.optf.cmso;
+import com.att.eelf.configuration.Configuration;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.net.InetAddress;
import java.util.TimeZone;
import javax.annotation.PostConstruct;
@@ -34,9 +37,6 @@ import org.springframework.boot.web.servlet.support.SpringBootServletInitializer import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
-import com.att.eelf.configuration.Configuration;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
@SpringBootApplication
@ComponentScan(basePackages = {"org.onap.optf.cmso"})
@@ -61,11 +61,11 @@ public class Application extends SpringBootServletInitializer { }
public static void main(String[] args) {
- initMDCData();
+ initMdcData();
SpringApplication.run(Application.class, args);
}
- protected static void initMDCData() {
+ protected static void initMdcData() {
MDC.clear();
try {
MDC.put(Configuration.MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName());
@@ -78,6 +78,11 @@ public class Application extends SpringBootServletInitializer { }
}
+ /**
+ * Servlet container.
+ *
+ * @return the servlet web server factory
+ */
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java b/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java index 3d98897..1cff495 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java @@ -1,35 +1,37 @@ /* * Copyright © 2018 AT&T Intellectual Property. * Modifications Copyright © 2019 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ + package org.onap.optf.cmso; +import java.util.ArrayList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.core.env.Environment; @@ -38,29 +40,24 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio import org.springframework.security.core.Authentication; import org.springframework.stereotype.Component; -import java.util.ArrayList; - @Component @Profile(SpringProfiles.PROPRIETARY__AUTHENTICATION) -public class AuthProvider - implements AuthenticationProvider { - - @Autowired - Environment env; - +public class AuthProvider implements AuthenticationProvider { + + @Autowired + Environment env; + @Override public Authentication authenticate(Authentication authentication) { String name = authentication.getName(); String password = authentication.getCredentials().toString(); - //TODO check credentials until we enable AAF - return new UsernamePasswordAuthenticationToken( - name, password, new ArrayList<>()); + // TODO check credentials until we enable AAF + return new UsernamePasswordAuthenticationToken(name, password, new ArrayList<>()); } - + @Override public boolean supports(Class<?> authentication) { - return authentication.equals( - UsernamePasswordAuthenticationToken.class); + return authentication.equals(UsernamePasswordAuthenticationToken.class); } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java b/cmso-service/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java index 2de080e..c26abec 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java @@ -26,9 +26,11 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.MutablePropertySources;
-public class CMSEnvironmentPostProcessor implements EnvironmentPostProcessor {
- // TODO tested in ONAP springboot and this is called before all of the properties files have been loaded...
- // perhaps there is a post post processor? Until this works. DB password will be in the clear in the proeprties files.
+public class CmsoEnvironmentPostProcessor implements EnvironmentPostProcessor {
+ // TODO tested in ONAP springboot and this is called before all of the properties files have been
+ // loaded...
+ // perhaps there is a post post processor? Until this works. DB password will be in the clear in the
+ // proeprties files.
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
String pwd = environment.getProperty("cmso.database.password");
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/CMSQuartzConfiguration.java b/cmso-service/src/main/java/org/onap/optf/cmso/CmsoQuartzConfiguration.java index 5ae3f05..e0cbeea 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/CMSQuartzConfiguration.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/CmsoQuartzConfiguration.java @@ -1,27 +1,27 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- *
+ *
+ *
* Unless otherwise specified, all documentation contained herein is licensed
* under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* https://creativecommons.org/licenses/by/4.0/
- *
+ *
* Unless required by applicable law or agreed to in writing, documentation
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -49,11 +49,16 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration
@ComponentScan({"org.onap.optf.cmso"})
@EnableTransactionManagement
-public class CMSQuartzConfiguration {
+public class CmsoQuartzConfiguration {
@Autowired
Environment env;
+ /**
+ * Eventq trigger factory bean.
+ *
+ * @return the simple trigger factory bean
+ */
@Bean
public SimpleTriggerFactoryBean eventqTriggerFactoryBean() {
@@ -66,6 +71,11 @@ public class CMSQuartzConfiguration { return stFactory;
}
+ /**
+ * Eventq detail factory bean.
+ *
+ * @return the job detail factory bean
+ */
@Bean
public JobDetailFactoryBean eventqDetailFactoryBean() {
JobDetailFactoryBean factory = new JobDetailFactoryBean();
@@ -73,6 +83,11 @@ public class CMSQuartzConfiguration { return factory;
}
+ /**
+ * Status trigger factory bean.
+ *
+ * @return the simple trigger factory bean
+ */
@Bean
public SimpleTriggerFactoryBean statusTriggerFactoryBean() {
@@ -85,6 +100,11 @@ public class CMSQuartzConfiguration { return stFactory;
}
+ /**
+ * Status detail factory bean.
+ *
+ * @return the job detail factory bean
+ */
@Bean
public JobDetailFactoryBean statusDetailFactoryBean() {
JobDetailFactoryBean factory = new JobDetailFactoryBean();
@@ -92,6 +112,11 @@ public class CMSQuartzConfiguration { return factory;
}
+ /**
+ * Optimizer trigger factory bean.
+ *
+ * @return the simple trigger factory bean
+ */
@Bean
public SimpleTriggerFactoryBean optimizerTriggerFactoryBean() {
@@ -104,6 +129,11 @@ public class CMSQuartzConfiguration { return stFactory;
}
+ /**
+ * Optimizer detail factory bean.
+ *
+ * @return the job detail factory bean
+ */
@Bean
public JobDetailFactoryBean optimizerDetailFactoryBean() {
JobDetailFactoryBean factory = new JobDetailFactoryBean();
@@ -111,6 +141,12 @@ public class CMSQuartzConfiguration { return factory;
}
+ /**
+ * Job factory.
+ *
+ * @param applicationContext the application context
+ * @return the job factory
+ */
@Bean
public JobFactory jobFactory(ApplicationContext applicationContext) {
AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
@@ -118,6 +154,12 @@ public class CMSQuartzConfiguration { return jobFactory;
}
+ /**
+ * Cmso factory bean.
+ *
+ * @param jobFactory the job factory
+ * @return the scheduler factory bean
+ */
@Bean
public SchedulerFactoryBean cmsoFactoryBean(JobFactory jobFactory) {
SchedulerFactoryBean cmso = new SchedulerFactoryBean();
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java b/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java index 46db256..2ba5fa3 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/JerseyConfiguration.java @@ -1,27 +1,27 @@ /*
* Copyright © 2017-2019 AT&T Intellectual Property.
* Modifications Copyright © 2018 IBM.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- *
+ *
+ *
* Unless otherwise specified, all documentation contained herein is licensed
* under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* https://creativecommons.org/licenses/by/4.0/
- *
+ *
* Unless required by applicable law or agreed to in writing, documentation
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,6 +31,11 @@ package org.onap.optf.cmso;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
import java.util.logging.Logger;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.client.Client;
@@ -51,17 +56,17 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.MapperFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
@Component
@ApplicationPath("/")
public class JerseyConfiguration extends ResourceConfig {
private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName());
+ /**
+ * Object mapper.
+ *
+ * @return the object mapper
+ */
@Bean
@Primary
public ObjectMapper objectMapper() {
@@ -73,6 +78,9 @@ public class JerseyConfiguration extends ResourceConfig { return objectMapper;
}
+ /**
+ * Instantiates a new jersey configuration.
+ */
@Autowired
public JerseyConfiguration( /* LogRequestFilter lrf */ ) {
register(CmsoServiceImpl.class);
@@ -92,6 +100,11 @@ public class JerseyConfiguration extends ResourceConfig { register(CmsoContainerFilters.class);
}
+ /**
+ * Jersey client.
+ *
+ * @return the client
+ */
@Bean
public Client jerseyClient() {
ClientConfig client = new ClientConfig();
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java b/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java index ef12a6d..01ca120 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java @@ -1,33 +1,34 @@ /* * Copyright © 2018 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ + package org.onap.optf.cmso; import org.springframework.beans.factory.annotation.Autowired; @@ -44,20 +45,20 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur @ComponentScan("org.onap.optf") @Profile(SpringProfiles.PROPRIETARY__AUTHENTICATION) public class SecurityConfig extends WebSecurityConfigurerAdapter { - + @Autowired private AuthProvider authProvider; - + @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { - + auth.authenticationProvider(authProvider); } - + @Override protected void configure(HttpSecurity http) throws Exception { - + http.csrf().disable().authorizeRequests().anyRequest().authenticated().and().httpBasic(); - + } }
\ No newline at end of file diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/SpringProfiles.java b/cmso-service/src/main/java/org/onap/optf/cmso/SpringProfiles.java index a2fdc69..f4cb73e 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/SpringProfiles.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/SpringProfiles.java @@ -17,10 +17,10 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.optf.cmso; -public class SpringProfiles -{ +public class SpringProfiles { public static final String AAF_AUTHENTICATION = "aaf-auth"; public static final String PROPRIETARY__AUTHENTICATION = "proprietary-auth"; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafAuthorizationFilter.java b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafAuthorizationFilter.java index f3b36f5..ac4b726 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafAuthorizationFilter.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafAuthorizationFilter.java @@ -1,32 +1,33 @@ /******************************************************************************* * Copyright © 2019 AT&T Intellectual Property. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ + package org.onap.optf.cmso.aaf; import java.io.IOException; @@ -40,7 +41,7 @@ import org.onap.aaf.cadi.Permission; import org.onap.observations.Observation; import org.onap.optf.cmso.SpringProfiles; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter; import org.springframework.context.annotation.Profile; @@ -77,7 +78,7 @@ public class AafAuthorizationFilter extends OrderedRequestContextFilter { filterChain.doFilter(request, response); } else { Observation.report(LogMessages.UNAUTHORIZED); - ResponseFormatter.errorResponse(request, response, new CMSException( + ResponseFormatter.errorResponse(request, response, new CmsoException( LogMessages.UNAUTHORIZED.getStatus(), LogMessages.UNAUTHORIZED, "")); } } else { @@ -86,7 +87,7 @@ public class AafAuthorizationFilter extends OrderedRequestContextFilter { } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); ResponseFormatter.errorResponse(request, response, - new CMSException(LogMessages.UNAUTHORIZED.getStatus(), LogMessages.UNAUTHORIZED, "")); + new CmsoException(LogMessages.UNAUTHORIZED.getStatus(), LogMessages.UNAUTHORIZED, "")); } } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafFilter.java b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafFilter.java index 586822f..5a93481 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafFilter.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/AafFilter.java @@ -42,7 +42,7 @@ import org.onap.observations.Observation; import org.onap.optf.cmso.Application; import org.onap.optf.cmso.SpringProfiles; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; @@ -77,7 +77,8 @@ public class AafFilter extends OrderedRequestContextFilter { if (response.getStatus() == 401) { Observation.report(LogMessages.UNAUTHENTICATED); ResponseFormatter.errorResponse(request, response, - new CMSException(LogMessages.UNAUTHENTICATED.getStatus(), LogMessages.UNAUTHENTICATED, "")); + new CmsoException(LogMessages.UNAUTHENTICATED.getStatus(), + LogMessages.UNAUTHENTICATED, "")); } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/ResponseFormatter.java b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/ResponseFormatter.java index e7ddcdf..b9c287f 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/aaf/ResponseFormatter.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/aaf/ResponseFormatter.java @@ -33,12 +33,12 @@ package org.onap.optf.cmso.aaf; import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; class ResponseFormatter { - static void errorResponse(HttpServletRequest request, HttpServletResponse response, CMSException error) + static void errorResponse(HttpServletRequest request, HttpServletResponse response, CmsoException error) throws IOException { response.setStatus(error.getStatus().getStatusCode()); response.getWriter().write(error.getRequestError().toString()); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSRequestError.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/CmsoRequestError.java index ec3804a..403178b 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSRequestError.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/CmsoRequestError.java @@ -38,17 +38,17 @@ import java.io.Serializable; import java.util.ArrayList;
import java.util.List;
-public class CMSRequestError implements Serializable {
+public class CmsoRequestError implements Serializable {
private static final long serialVersionUID = 1L;
- private static EELFLogger log = EELFManager.getInstance().getLogger(CMSRequestError.class);
+ private static EELFLogger log = EELFManager.getInstance().getLogger(CmsoRequestError.class);
@JsonProperty
RequestError requestError;
- public CMSRequestError(String messageId, String text, List<String> variables) {
+ public CmsoRequestError(String messageId, String text, List<String> variables) {
requestError = new RequestError(messageId, text, variables);
}
- public CMSRequestError(String messageId, String text) {
+ public CmsoRequestError(String messageId, String text) {
requestError = new RequestError(messageId, text, new ArrayList<String>());
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSStatusEnum.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/CmsoStatusEnum.java index 62eaec2..135e1f1 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/CMSStatusEnum.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/CmsoStatusEnum.java @@ -31,7 +31,10 @@ package org.onap.optf.cmso.common;
-public enum CMSStatusEnum {
+/**
+ * The Enum CMSStatusEnum.
+ */
+public enum CmsoStatusEnum {
PendingSchedule("Pending Schedule",
"Schedule request as been accepted. Pending determination of recommended schedule."),
SchedulingFailed("Scheduling Failed", "Failed to determine recommended schedule."),
@@ -58,29 +61,49 @@ public enum CMSStatusEnum { private final String text;
private final String description;
- private CMSStatusEnum(String text, String description) {
+ private CmsoStatusEnum(String text, String description) {
this.text = text;
this.description = description;
}
+ /**
+ * To string.
+ *
+ * @return the string
+ */
@Override
public String toString() {
return text;
}
- public CMSStatusEnum fromString(String text) {
- for (CMSStatusEnum e : CMSStatusEnum.values())
- if (e.text.equals(text))
+ /**
+ * From string.
+ *
+ * @param text the text
+ * @return the CMS status enum
+ */
+ public CmsoStatusEnum fromString(String text) {
+ for (CmsoStatusEnum e : CmsoStatusEnum.values()) {
+ if (e.text.equals(text)) {
return e;
+ }
+ }
return null;
}
+ /**
+ * The main method.
+ *
+ * @param argv the arguments
+ */
// To include in the AID.
- public static void main(String argv[]) {
+ public static void main(String[] argv) {
StringBuilder sb = new StringBuilder();
sb.append("<html><body><table border=\"1\">\n");
- for (CMSStatusEnum v : CMSStatusEnum.values())
- sb.append("<tr><td>").append(v.text).append("</td><td>").append(v.description).append("</td></tr>\n");
+ for (CmsoStatusEnum v : CmsoStatusEnum.values()) {
+ sb.append("<tr><td>").append(v.text).append("</td><td>").append(v.description)
+ .append("</td></tr>\n");
+ }
sb.append("</table></body></html>\n");
System.out.println(sb.toString());
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/Mdc.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/Mdc.java index 3230933..d18ded4 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/Mdc.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/Mdc.java @@ -1,27 +1,27 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- *
+ *
+ *
* Unless otherwise specified, all documentation contained herein is licensed
* under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* https://creativecommons.org/licenses/by/4.0/
- *
+ *
* Unless required by applicable law or agreed to in writing, documentation
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -47,6 +47,8 @@ import static com.att.eelf.configuration.Configuration.MDC_SERVICE_NAME; import static com.att.eelf.configuration.Configuration.MDC_STATUS_CODE;
import static com.att.eelf.configuration.Configuration.MDC_TARGET_ENTITY;
import static com.att.eelf.configuration.Configuration.MDC_TARGET_SERVICE_NAME;
+
+import com.att.eelf.utils.Stopwatch;
import java.net.InetAddress;
import java.net.URI;
import java.util.Date;
@@ -57,7 +59,6 @@ import javax.ws.rs.core.Response; import org.onap.optf.cmso.filters.MessageHeaders;
import org.quartz.JobExecutionContext;
import org.slf4j.MDC;
-import com.att.eelf.utils.Stopwatch;
/**
* EELF logging MDC fields not defined in the MDC Configuration (i.e.
@@ -90,6 +91,12 @@ public class Mdc { ErrorCode, ErrorDescription, Timer,
}
+ /**
+ * Begin.
+ *
+ * @param request the request
+ * @param requestId the request id
+ */
public static void begin(HttpServletRequest request, String requestId) {
MDC.clear();
Stopwatch.start();
@@ -143,11 +150,17 @@ public class Mdc { if (transactionId == null) {
transactionId = requestId;
}
- if (transactionId == null)
+ if (transactionId == null) {
transactionId = "Unknown";
+ }
MDC.put(MDC_KEY_REQUEST_ID, transactionId);
}
+ /**
+ * End.
+ *
+ * @param response the response
+ */
public static void end(Response response) {
Stopwatch.stop();
// MDC.put(MDC_ALERT_SEVERITY, "");
@@ -168,8 +181,9 @@ public class Mdc { // MDC.put(MDC_SERVICE_INSTANCE_ID, "");
// MDC.put(MDC_SERVICE_NAME, "");
MDC.put(MDC_STATUS_CODE, "COMPLETE");
- if (response.getStatus() == 500)
+ if (response.getStatus() == 500) {
MDC.put(MDC_STATUS_CODE, "ERROR");
+ }
// MDC.put(MDC_TARGET_ENTITY, "");
// MDC.put(MDC_TARGET_SERVICE_NAME, "");
// MDC.put(MDC_TARGET_VIRTUAL_ENTITY, "");
@@ -191,6 +205,11 @@ public class Mdc { return stackTraceElements[back].getClassName() + "." + stackTraceElements[back].getMethodName();
}
+ /**
+ * Quartz job begin.
+ *
+ * @param context the context
+ */
public static void quartzJobBegin(JobExecutionContext context) {
MDC.clear();
Stopwatch.start();
@@ -235,6 +254,11 @@ public class Mdc { }
+ /**
+ * Quartz job end.
+ *
+ * @param context the context
+ */
public static void quartzJobEnd(JobExecutionContext context) {
Stopwatch.stop();
// MDC.put(MDC_ALERT_SEVERITY, "");
@@ -278,12 +302,24 @@ public class Mdc { return save;
}
+ /**
+ * Restore.
+ *
+ * @param mdcSave the mdc save
+ */
public static void restore(Map<String, String> mdcSave) {
MDC.clear();
- for (String name : mdcSave.keySet())
+ for (String name : mdcSave.keySet()) {
MDC.put(name, mdcSave.get(name));
+ }
}
+ /**
+ * Metric start.
+ *
+ * @param requestId the request id
+ * @param url the url
+ */
public static void metricStart(String requestId, String url) {
MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(new Date()));
// MDC.put(MDC_ELAPSED_TIME, String.valueOf(Stopwatch.getDuration()));
@@ -321,6 +357,11 @@ public class Mdc { }
+ /**
+ * Metric end.
+ *
+ * @param response the response
+ */
public static void metricEnd(Response response) {
// MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(new Date()));
@@ -349,8 +390,9 @@ public class Mdc { // MDC.put(MDC_SERVICE_INSTANCE_ID, "UNKNOWN");
// MDC.put(MDC_SERVICE_NAME, "cmso");
MDC.put(MDC_STATUS_CODE, "COMPLETE");
- if (response.getStatus() == 500)
+ if (response.getStatus() == 500) {
MDC.put(MDC_STATUS_CODE, "ERROR");
+ }
// MDC.put(MDC_TARGET_ENTITY, "");
// MDC.put(MDC_TARGET_SERVICE_NAME, "");
// MDC.put(MDC_TARGET_VIRTUAL_ENTITY, "");
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSAlreadyExistsException.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoAlreadyExistsException.java index d461e4f..f668a72 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSAlreadyExistsException.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoAlreadyExistsException.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,10 +34,10 @@ package org.onap.optf.cmso.common.exceptions; import javax.ws.rs.core.Response.Status;
import org.onap.optf.cmso.common.LogMessages;
-public class CMSAlreadyExistsException extends CMSException {
+public class CmsoAlreadyExistsException extends CmsoException {
private static final long serialVersionUID = 1L;
- public CMSAlreadyExistsException(String... args) {
+ public CmsoAlreadyExistsException(String... args) {
super(Status.CONFLICT, LogMessages.SCHEDULE_ALREADY_EXISTS, args);
}
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoException.java index c49d02f..b604b94 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoException.java @@ -1,27 +1,27 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- *
+ *
+ *
* Unless otherwise specified, all documentation contained herein is licensed
* under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* https://creativecommons.org/licenses/by/4.0/
- *
+ *
* Unless required by applicable law or agreed to in writing, documentation
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,28 +31,36 @@ package org.onap.optf.cmso.common.exceptions;
+import com.att.eelf.i18n.EELFResourceManager;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.core.Response.Status;
-import org.onap.optf.cmso.common.CMSRequestError;
+import org.onap.optf.cmso.common.CmsoRequestError;
import org.onap.optf.cmso.common.LogMessages;
-import com.att.eelf.i18n.EELFResourceManager;
-public class CMSException extends Exception {
+public class CmsoException extends Exception {
private static final long serialVersionUID = 1L;
- protected CMSRequestError requestError = null;
+ protected CmsoRequestError requestError = null;
private List<String> variables = new ArrayList<String>();
protected LogMessages messageCode;
protected Status status;
- public CMSException(Status status, LogMessages messageCode, String... args) {
+ /**
+ * Instantiates a new CMS exception.
+ *
+ * @param status the status
+ * @param messageCode the message code
+ * @param args the args
+ */
+ public CmsoException(Status status, LogMessages messageCode, String... args) {
super(EELFResourceManager.format(messageCode, args));
this.status = status;
this.messageCode = messageCode;
- for (String arg : args)
+ for (String arg : args) {
variables.add(arg);
- requestError = new CMSRequestError(messageCode.name(), getMessage(), variables);
+ }
+ requestError = new CmsoRequestError(messageCode.name(), getMessage(), variables);
}
public Status getStatus() {
@@ -67,7 +75,7 @@ public class CMSException extends Exception { return variables.toArray(new String[variables.size()]);
}
- public CMSRequestError getRequestError() {
+ public CmsoRequestError getRequestError() {
return requestError;
}
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSNotFoundException.java b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoNotFoundException.java index 2a46e21..39cb82f 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CMSNotFoundException.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoNotFoundException.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,10 +34,10 @@ package org.onap.optf.cmso.common.exceptions; import javax.ws.rs.core.Response.Status;
import org.onap.optf.cmso.common.LogMessages;
-public class CMSNotFoundException extends CMSException {
+public class CmsoNotFoundException extends CmsoException {
private static final long serialVersionUID = 1L;
- public CMSNotFoundException(String... args) {
+ public CmsoNotFoundException(String... args) {
super(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, args);
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java index 256878c..192258e 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmJob.java @@ -47,9 +47,9 @@ import org.onap.optf.cmso.common.LogMessages; import org.onap.optf.cmso.common.PropertiesManagement;
import org.onap.optf.cmso.eventq.DispatchedEventList;
import org.onap.optf.cmso.filters.CmsoClientFilters;
-import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
-import org.onap.optf.cmso.model.dao.ScheduleDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao;
+import org.onap.optf.cmso.model.dao.ScheduleDao;
import org.onap.optf.cmso.ticketmgt.TmClient;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
@@ -74,16 +74,16 @@ public class CmJob implements Job { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
@Autowired
- CMSOClient vidClient;
+ CmsoClient vidClient;
@Autowired
- ChangeManagementScheduleDAO cmScheduleDao;
+ ChangeManagementScheduleDao cmScheduleDao;
@Autowired
- ChangeManagementGroupDAO cmGroupDAO;
+ ChangeManagementGroupDao cmGroupDao;
@Autowired
- ScheduleDAO scheduleDAO;
+ ScheduleDao scheduleDao;
@Autowired
TmClient tmClient;
@@ -113,6 +113,11 @@ public class CmJob implements Job { debug.debug(LogMessages.CM_JOB, "Exited");
}
+ /**
+ * Loopback.
+ *
+ * @param id the id
+ */
public void loopback(String id) {
Map<String, String> mdcSave = Mdc.save();
try {
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CMSOClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmsoClient.java index d726107..c31c275 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CMSOClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/CmsoClient.java @@ -45,15 +45,15 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.onap.optf.cmso.common.BasicAuthenticatorFilter;
-import org.onap.optf.cmso.common.CMSStatusEnum;
+import org.onap.optf.cmso.common.CmsoStatusEnum;
import org.onap.optf.cmso.common.LogMessages;
import org.onap.optf.cmso.common.PropertiesManagement;
import org.onap.optf.cmso.filters.CmsoClientFilters;
import org.onap.optf.cmso.model.ChangeManagementSchedule;
import org.onap.optf.cmso.model.Schedule;
-import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
-import org.onap.optf.cmso.model.dao.ScheduleDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao;
+import org.onap.optf.cmso.model.dao.ScheduleDao;
import org.onap.optf.cmso.ticketmgt.TmClient;
import org.onap.optf.cmso.wf.bean.WfChangeManagementResponse;
import org.onap.optf.cmso.wf.bean.WfVidCmResponse;
@@ -64,20 +64,20 @@ import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional;
@Component
-public class CMSOClient {
- private static EELFLogger log = EELFManager.getInstance().getLogger(CMSOClient.class);
+public class CmsoClient {
+ private static EELFLogger log = EELFManager.getInstance().getLogger(CmsoClient.class);
private static EELFLogger metrics = EELFManager.getInstance().getMetricsLogger();
private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();
private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
@Autowired
- ChangeManagementScheduleDAO cmScheduleDAO;
+ ChangeManagementScheduleDao cmScheduleDao;
@Autowired
- ChangeManagementGroupDAO cmGroupDAO;
+ ChangeManagementGroupDao cmGroupDao;
@Autowired
- ScheduleDAO scheduleDAO;
+ ScheduleDao scheduleDao;
@Autowired
@@ -89,19 +89,27 @@ public class CMSOClient { @Autowired
TmClient tmClient;
+ /**
+ * Dispatch.
+ *
+ * @param cmSchedule the cm schedule
+ * @param schedule the schedule
+ */
public void dispatch(ChangeManagementSchedule cmSchedule, Schedule schedule) {
try {
String url = env.getProperty("so.url");
- if (!url.endsWith("/"))
+ if (!url.endsWith("/")) {
url += "/";
+ }
url = url + "schedule/" + cmSchedule.getVnfName();
String callbackData = cmSchedule.getRequest();
String user = env.getProperty("so.user", "");
String pass = pm.getProperty("so.pass", "");
Client client = ClientBuilder.newClient();
- if (!user.equals(""))
+ if (!user.equals("")) {
client.register(new BasicAuthenticatorFilter(user, pass));
+ }
client.register(new CmsoClientFilters());
WebTarget target = client.target(url);
ObjectMapper om = new ObjectMapper();
@@ -127,7 +135,7 @@ public class CMSOClient { default: {
errors.error(LogMessages.UNEXPECTED_RESPONSE.toString(), "VID", response.getStatus(),
response.toString());
- cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString());
cmSchedule.setStatusMessage(response.toString());
updateScheduleStatus(cmSchedule, schedule);
return;
@@ -137,19 +145,19 @@ public class CMSOClient { // No sense in retrying. These are time sensitive actions
catch (ResponseProcessingException e) {
errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString());
cmSchedule.setStatusMessage(e.toString());
updateScheduleStatus(cmSchedule, schedule);
} catch (ProcessingException e) {
errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString());
cmSchedule.setStatusMessage(e.toString());
updateScheduleStatus(cmSchedule, schedule);
}
} catch (Exception e) {
errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString());
cmSchedule.setStatusMessage(e.toString());
updateScheduleStatus(cmSchedule, schedule);
}
@@ -160,7 +168,7 @@ public class CMSOClient { WfChangeManagementResponse resp = response.readEntity(WfChangeManagementResponse.class);
for (WfVidCmResponse cmResponse : resp.getCmResponses()) {
if (cmResponse.getVnfName().equals(cmSchedule.getVnfName())) {
- cmSchedule.setStatus(CMSStatusEnum.Triggered.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.Triggered.toString());
cmSchedule.setDispatchTimeMillis(System.currentTimeMillis());
cmSchedule.setMsoRequestId(cmResponse.getOrchestratorRequestId());
// Push the state up to the schedule.
@@ -169,7 +177,7 @@ public class CMSOClient { return;
}
}
- cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString());
cmSchedule.setStatusMessage("Response did not contain vnfName=" + cmSchedule.getVnfName());
updateScheduleStatus(cmSchedule, schedule);
}
@@ -187,7 +195,7 @@ public class CMSOClient { if (rr != null) {
JsonNode requestId = rr.get("requestId");
if (requestId != null) {
- cmSchedule.setStatus(CMSStatusEnum.Triggered.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.Triggered.toString());
cmSchedule.setDispatchTimeMillis(System.currentTimeMillis());
cmSchedule.setMsoRequestId(requestId.asText());
// Push the state up to the schedule.
@@ -197,7 +205,7 @@ public class CMSOClient { }
}
}
- cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString());
cmSchedule.setStatusMessage(node.toString());
updateScheduleStatus(cmSchedule, schedule);
}
@@ -205,19 +213,27 @@ public class CMSOClient { private void updateTicket(ChangeManagementSchedule cmSchedule, Schedule schedule) {
try {
String changeId = cmSchedule.getTmChangeId();
- if (changeId != null && !changeId.equals(""))
+ if (changeId != null && !changeId.equals("")) {
tmClient.updateTicket(schedule, cmSchedule, changeId);
+ }
} catch (Exception e) {
errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
}
}
+ /**
+ * Update schedule status.
+ *
+ * @param cmSchedule the cm schedule
+ * @param schedule the schedule
+ */
@Transactional
public void updateScheduleStatus(ChangeManagementSchedule cmSchedule, Schedule schedule) {
- cmScheduleDAO.save(cmSchedule);
- if (schedule != null)
- scheduleDAO.save(schedule);
+ cmScheduleDao.save(cmSchedule);
+ if (schedule != null) {
+ scheduleDao.save(schedule);
+ }
}
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java index 49be23a..ccbc430 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/dispatcher/DispatchJob.java @@ -39,14 +39,14 @@ import java.util.Date; import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
-import org.onap.optf.cmso.common.CMSStatusEnum;
+import org.onap.optf.cmso.common.CmsoStatusEnum;
import org.onap.optf.cmso.common.LogMessages;
import org.onap.optf.cmso.model.ChangeManagementGroup;
import org.onap.optf.cmso.model.ChangeManagementSchedule;
import org.onap.optf.cmso.model.Schedule;
-import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
-import org.onap.optf.cmso.model.dao.ScheduleDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao;
+import org.onap.optf.cmso.model.dao.ScheduleDao;
import org.onap.optf.cmso.ticketmgt.TmClient;
import org.onap.optf.cmso.ticketmgt.bean.TmApprovalStatusEnum;
import org.onap.optf.cmso.ticketmgt.bean.TmChangeInfo;
@@ -69,16 +69,16 @@ public class DispatchJob { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
@Autowired
- CMSOClient vidClient;
+ CmsoClient vidClient;
@Autowired
- ChangeManagementScheduleDAO cmScheduleDAO;
+ ChangeManagementScheduleDao cmScheduleDao;
@Autowired
- ChangeManagementGroupDAO cmGroupDAO;
+ ChangeManagementGroupDao cmGroupDao;
@Autowired
- ScheduleDAO scheduleDAO;
+ ScheduleDao scheduleDao;
@Autowired
TmClient tmClient;
@@ -86,19 +86,26 @@ public class DispatchJob { @Autowired
Environment env;
+ /**
+ * Execute.
+ *
+ * @param id the id
+ * @throws JobExecutionException the job execution exception
+ */
public void execute(UUID id) throws JobExecutionException {
debug.debug(LogMessages.CM_JOB, "Entered");
try {
// No other instance can read this cmso until we are done.
- ChangeManagementSchedule cmSchedule = cmScheduleDAO.lockOne(id);
+ ChangeManagementSchedule cmSchedule = cmScheduleDao.lockOne(id);
cmSchedule.setDispatcherInstance(InetAddress.getLocalHost().getHostAddress());
- ChangeManagementGroup group = cmGroupDAO.findById(cmSchedule.getChangeManagementGroupUuid()).orElse(null);
+ ChangeManagementGroup group = cmGroupDao.findById(cmSchedule.getChangeManagementGroupUuid()).orElse(null);
if (group != null) {
- Schedule schedule = scheduleDAO.findById(group.getSchedulesUuid()).orElse(null);
+ Schedule schedule = scheduleDao.findById(group.getSchedulesUuid()).orElse(null);
if (schedule != null) {
- schedule.setStatus(CMSStatusEnum.NotificationsInitiated.toString());
- if (safeToDispatch(cmSchedule, schedule))
+ schedule.setStatus(CmsoStatusEnum.NotificationsInitiated.toString());
+ if (safeToDispatch(cmSchedule, schedule)) {
vidClient.dispatch(cmSchedule, schedule);
+ }
}
}
@@ -111,7 +118,6 @@ public class DispatchJob { private boolean safeToDispatch(ChangeManagementSchedule cmSchedule, Schedule schedule) {
- Integer leadTime = env.getProperty("cmso.cm.dispatch.lead.time.ms", Integer.class, 1000);
Boolean scheduleImmediateEnabled = env.getProperty("cmso.cm.dispatch.immediate.enabled", Boolean.class, false);
// *******************************************************************
@@ -122,9 +128,8 @@ public class DispatchJob { // *******************************************************************
// Validate that the state is accurate.
// Another instance may have dispatched
- Long startTime = cmSchedule.getStartTimeMillis();
- if (!cmSchedule.getStatus().equals(CMSStatusEnum.Scheduled.toString())
- && !cmSchedule.getStatus().equals(CMSStatusEnum.ScheduledImmediate.toString())) {
+ if (!cmSchedule.getStatus().equals(CmsoStatusEnum.Scheduled.toString())
+ && !cmSchedule.getStatus().equals(CmsoStatusEnum.ScheduledImmediate.toString())) {
log.info("Attempt to dispatch an event that is in the incorrect state scheduleId={0}, vnf={1}, status={2}",
schedule.getScheduleId(), cmSchedule.getVnfName(), cmSchedule.getStatus());
return false;
@@ -156,7 +161,7 @@ public class DispatchJob { String message = "Attempt to schedule immediate when immmediate scheduling is disabled: "
+ cmSchedule.getVnfName();
log.info(message);
- cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString());
cmSchedule.setStatusMessage(message);
updateScheduleStatus(cmSchedule, schedule);
return false;
@@ -169,13 +174,15 @@ public class DispatchJob { // Do not account for lead time. This should be inconsequential, maybe????
//
long now = System.currentTimeMillis();
+ Long startTime = cmSchedule.getStartTimeMillis();
+
long startMillis = startTime;
if (now > startMillis) {
String message = EELFResourceManager.format(LogMessages.SCHEDULE_PAST_DUE, schedule.getScheduleId(),
cmSchedule.getVnfName(), new Date(now).toString(), new Date(startMillis).toString());
log.info(message);
- cmSchedule.setStatus(CMSStatusEnum.PastDue.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.PastDue.toString());
cmSchedule.setStatusMessage(message);
updateScheduleStatus(cmSchedule, schedule);
return false;
@@ -184,6 +191,7 @@ public class DispatchJob { // *******************************************************************
// (Sleep until actual dispatch time...)
// leadTime allows for preparing call to VID to the start of workflow.
+ Integer leadTime = env.getProperty("cmso.cm.dispatch.lead.time.ms", Integer.class, 1000);
long sleep = (startMillis - leadTime) - System.currentTimeMillis();
if (sleep > 0L) {
try {
@@ -235,16 +243,22 @@ public class DispatchJob { cmSchedule.getVnfName(), cmSchedule.getTmChangeId());
errors.error(message);
}
- cmSchedule.setStatus(CMSStatusEnum.SchedulingFailed.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.SchedulingFailed.toString());
cmSchedule.setStatusMessage(message);
updateScheduleStatus(cmSchedule, schedule);
return false;
}
+ /**
+ * Update schedule status.
+ *
+ * @param cmSchedule the cm schedule
+ * @param schedule the schedule
+ */
@Transactional
public void updateScheduleStatus(ChangeManagementSchedule cmSchedule, Schedule schedule) {
- cmScheduleDAO.save(cmSchedule);
- scheduleDAO.save(schedule);
+ cmScheduleDao.save(cmSchedule);
+ scheduleDao.save(schedule);
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJob.java index 7816f72..2ae0913 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJob.java @@ -35,7 +35,7 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager;
import org.onap.observations.Mdc;
import org.onap.optf.cmso.common.LogMessages;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
@@ -55,7 +55,7 @@ public class CmQuartzJob extends QuartzJobBean { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
@Autowired
- CMSQueueJob qqJob;
+ CmsoQueueJob qqJob;
// This is not called directly. Using @Autowired to ensure that startup
// Runs before the fist invocation of executeInternal
@@ -63,10 +63,9 @@ public class CmQuartzJob extends QuartzJobBean { CmQuartzJobStartup startup;
@Autowired
- ChangeManagementScheduleDAO cmScheduleDao;
+ ChangeManagementScheduleDao cmScheduleDao;
@Override
- @Transactional
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
Mdc.quartzJobBegin(context);
debug.debug(LogMessages.CM_QUARTZ_JOB, "Entered");
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJobStartup.java b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJobStartup.java index add1478..dfb9fc5 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJobStartup.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmQuartzJobStartup.java @@ -35,7 +35,7 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager;
import java.net.InetAddress;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -55,7 +55,7 @@ public class CmQuartzJobStartup { private static EELFLogger log = EELFManager.getInstance().getLogger(CmQuartzJobStartup.class);
@Autowired
- ChangeManagementScheduleDAO cmScheduleDao;
+ ChangeManagementScheduleDao cmScheduleDao;
private AtomicBoolean started = new AtomicBoolean(false);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmsoQueueJob.java index cb0ca87..de85e2c 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CMSQueueJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/eventq/CmsoQueueJob.java @@ -35,11 +35,11 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager;
import java.util.Date;
import java.util.List;
-import org.onap.optf.cmso.common.CMSStatusEnum;
+import org.onap.optf.cmso.common.CmsoStatusEnum;
import org.onap.optf.cmso.common.LogMessages;
import org.onap.optf.cmso.dispatcher.CmJob;
import org.onap.optf.cmso.model.ChangeManagementSchedule;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Trigger;
@@ -60,11 +60,11 @@ import org.springframework.transaction.annotation.Transactional; * memory....
*/
@Component
-public class CMSQueueJob {
+public class CmsoQueueJob {
private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
@Autowired
- ChangeManagementScheduleDAO cmScheduleDao;
+ ChangeManagementScheduleDao cmScheduleDao;
@Autowired
SchedulerFactoryBean qsScheduler;
@@ -86,7 +86,7 @@ public class CMSQueueJob { long now = System.currentTimeMillis();
Long endTime = now + (interval * lookahead);
List<ChangeManagementSchedule> schedules =
- cmScheduleDao.findByStatusAndEndTime(CMSStatusEnum.Scheduled.toString(), endTime);
+ cmScheduleDao.findByStatusAndEndTime(CmsoStatusEnum.Scheduled.toString(), endTime);
if (schedules.size() == 0) {
return false;
}
@@ -99,12 +99,12 @@ public class CMSQueueJob { } catch (org.quartz.SchedulerException e) {
debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
// WIll keep trying until it goes Past due
- schedule.setStatus(CMSStatusEnum.Scheduled.toString());
+ schedule.setStatus(CmsoStatusEnum.Scheduled.toString());
schedule.setDispatcherInstance("");
updateScheduleStatus(schedule);
} catch (Exception e) {
debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- schedule.setStatus(CMSStatusEnum.Scheduled.toString());
+ schedule.setStatus(CmsoStatusEnum.Scheduled.toString());
schedule.setDispatcherInstance("");
updateScheduleStatus(schedule);
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/filters/CmsoContainerFilters.java b/cmso-service/src/main/java/org/onap/optf/cmso/filters/CmsoContainerFilters.java index d62f5c2..e52df57 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/filters/CmsoContainerFilters.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/filters/CmsoContainerFilters.java @@ -72,8 +72,8 @@ public class CmsoContainerFilters implements ContainerRequestFilter, ContainerRe MultivaluedMap<String, Object> respHeaders = responseContext.getHeaders(); String minorVersion = reqHeaders.getFirst(HeadersEnum.MinorVersion.toString()); respHeaders.add(HeadersEnum.MinorVersion.toString(), minorVersion); - respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.latestVersion); - respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.patchVersion); + respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.getLatestversion()); + respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.getPatchversion()); } catch (Exception e) { if (e instanceof WebApplicationException) { @@ -114,7 +114,7 @@ public class CmsoContainerFilters implements ContainerRequestFilter, ContainerRe } String minorVersion = headers.getFirst(HeadersEnum.MinorVersion.toString()); if (minorVersion == null) { - minorVersion = MessageHeaders.supportedMajorVersions.get(majorVersion); + minorVersion = MessageHeaders.getSupportedmajorversions().get(majorVersion); headers.add(HeadersEnum.MinorVersion.toString(), minorVersion); } if (!MessageHeaders.validateMajorMinorVersion(majorVersion, minorVersion)) { diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/filters/MessageHeaders.java b/cmso-service/src/main/java/org/onap/optf/cmso/filters/MessageHeaders.java index b62cce2..d671768 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/filters/MessageHeaders.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/filters/MessageHeaders.java @@ -69,7 +69,7 @@ public class MessageHeaders { }
/** The Constant supportedMajorVersions. */
- public static final Map<String, String> supportedMajorVersions = new HashMap<String, String>();
+ private static final Map<String, String> supportedMajorVersions = new HashMap<String, String>();
static {
supportedMajorVersions.put("v1", "0");
@@ -77,7 +77,7 @@ public class MessageHeaders { }
/** The Constant supportedMajorMinorVersions. */
- public static final Set<String> supportedMajorMinorVersions = new HashSet<String>();
+ private static final Set<String> supportedMajorMinorVersions = new HashSet<String>();
static {
supportedMajorMinorVersions.add("v1.0");
@@ -85,10 +85,10 @@ public class MessageHeaders { }
/** The Constant latestVersion. */
- public static final String latestVersion = "2.0.0";
+ private static final String latestVersion = "2.0.0";
/** The Constant patchVersion. */
- public static final String patchVersion = "0";
+ private static final String patchVersion = "0";
/**
* From string.
@@ -156,4 +156,20 @@ public class MessageHeaders { }
return true;
}
+
+ public static Map<String, String> getSupportedmajorversions() {
+ return supportedMajorVersions;
+ }
+
+ public static Set<String> getSupportedmajorminorversions() {
+ return supportedMajorMinorVersions;
+ }
+
+ public static String getLatestversion() {
+ return latestVersion;
+ }
+
+ public static String getPatchversion() {
+ return patchVersion;
+ }
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDao.java index 9e4b546..48d489d 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ApprovalTypeDao.java @@ -39,7 +39,7 @@ import org.onap.optf.cmso.model.ApprovalType; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
-public interface ApprovalTypeDAO extends PagingAndSortingRepository<ApprovalType, UUID> {
+public interface ApprovalTypeDao extends PagingAndSortingRepository<ApprovalType, UUID> {
Optional<ApprovalType> findById(UUID id);
ApprovalType save(ApprovalType persisted);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDao.java index 976a57f..945d9ed 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementChangeWindowDao.java @@ -40,7 +40,7 @@ import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
-public interface ChangeManagementChangeWindowDAO
+public interface ChangeManagementChangeWindowDao
extends PagingAndSortingRepository<ChangeManagementChangeWindow, UUID> {
Optional<ChangeManagementChangeWindow> findById(UUID id);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDao.java index 7dabf5e..9fae8bf 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDao.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ package org.onap.optf.cmso.model.dao; import java.util.List;
import org.onap.optf.cmso.model.ChangeManagementDetail;
-public interface ChangeManagementDetailDAO {
+public interface ChangeManagementDetailDao {
List<ChangeManagementDetail> searchScheduleDetails(String where, int limit);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDaoImpl.java index 2543c77..03b05d4 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDAOImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementDetailDaoImpl.java @@ -39,7 +39,7 @@ import org.onap.optf.cmso.model.ChangeManagementDetail; import org.springframework.stereotype.Repository;
@Repository
-public class ChangeManagementDetailDAOImpl implements ChangeManagementDetailDAO {
+public class ChangeManagementDetailDaoImpl implements ChangeManagementDetailDao {
@PersistenceContext
private EntityManager manager;
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDao.java index 7694d8d..b4bcaf0 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementGroupDao.java @@ -39,7 +39,7 @@ import org.onap.optf.cmso.model.ChangeManagementGroup; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
-public interface ChangeManagementGroupDAO extends PagingAndSortingRepository<ChangeManagementGroup, UUID> {
+public interface ChangeManagementGroupDao extends PagingAndSortingRepository<ChangeManagementGroup, UUID> {
Optional<ChangeManagementGroup> findById(UUID id);
ChangeManagementGroup save(ChangeManagementGroup persisted);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDao.java index 8741587..172221a 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ChangeManagementScheduleDao.java @@ -41,7 +41,7 @@ import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
-public interface ChangeManagementScheduleDAO extends PagingAndSortingRepository<ChangeManagementSchedule, UUID> {
+public interface ChangeManagementScheduleDao extends PagingAndSortingRepository<ChangeManagementSchedule, UUID> {
@Override Optional<ChangeManagementSchedule> findById(UUID id);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDao.java index 75299a1..e9d7e1e 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/DomainDataDao.java @@ -37,7 +37,7 @@ import java.util.UUID; import org.onap.optf.cmso.model.DomainData;
import org.springframework.data.repository.PagingAndSortingRepository;
-public interface DomainDataDAO extends PagingAndSortingRepository<DomainData, UUID> {
+public interface DomainDataDao extends PagingAndSortingRepository<DomainData, UUID> {
Optional<DomainData> findById(UUID id);
DomainData save(DomainData persisted);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ElementDataDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ElementDataDao.java index dada4e1..8a05a4c 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ElementDataDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ElementDataDao.java @@ -36,7 +36,7 @@ import java.util.UUID; import org.onap.optf.cmso.model.ElementData; import org.springframework.data.repository.PagingAndSortingRepository; -public interface ElementDataDAO extends PagingAndSortingRepository<ElementData, UUID> { +public interface ElementDataDao extends PagingAndSortingRepository<ElementData, UUID> { @Override Optional<ElementData> findById(UUID id); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDao.java index 3fabd63..8d62256 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleApprovalDao.java @@ -37,7 +37,7 @@ import java.util.UUID; import org.onap.optf.cmso.model.ScheduleApproval;
import org.springframework.data.repository.PagingAndSortingRepository;
-public interface ScheduleApprovalDAO extends PagingAndSortingRepository<ScheduleApproval, UUID> {
+public interface ScheduleApprovalDao extends PagingAndSortingRepository<ScheduleApproval, UUID> {
Optional<ScheduleApproval> findById(UUID id);
ScheduleApproval save(ScheduleApproval persisted);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDao.java index 14d3143..f73ed96 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleDao.java @@ -42,7 +42,7 @@ import org.springframework.data.jpa.repository.Lock; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
-public interface ScheduleDAO extends PagingAndSortingRepository<Schedule, UUID> {
+public interface ScheduleDao extends PagingAndSortingRepository<Schedule, UUID> {
Optional<Schedule> findById(UUID id);
Schedule save(Schedule persited);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAO.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDao.java index f974eb5..14a9a13 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAO.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDao.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ package org.onap.optf.cmso.model.dao; import java.util.List;
import org.onap.optf.cmso.model.ScheduleQuery;
-public interface ScheduleQueryDAO {
+public interface ScheduleQueryDao {
List<ScheduleQuery> searchSchedules(String where, int limit);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDaoImpl.java index b5a6e57..7b2def6 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDAOImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/dao/ScheduleQueryDaoImpl.java @@ -39,7 +39,7 @@ import org.onap.optf.cmso.model.ScheduleQuery; import org.springframework.stereotype.Repository;
@Repository
-public class ScheduleQueryDAOImpl implements ScheduleQueryDAO {
+public class ScheduleQueryDaoImpl implements ScheduleQueryDao {
@PersistenceContext
private EntityManager manager;
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerClient.java index 898339a..269c4b5 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerClient.java @@ -45,13 +45,13 @@ import javax.ws.rs.core.Response; import org.onap.observations.Mdc; import org.onap.observations.Observation; import org.onap.optf.cmso.common.BasicAuthenticatorFilter; -import org.onap.optf.cmso.common.CMSStatusEnum; +import org.onap.optf.cmso.common.CmsoStatusEnum; import org.onap.optf.cmso.common.LogMessages; import org.onap.optf.cmso.common.PropertiesManagement; import org.onap.optf.cmso.filters.CmsoClientFilters; import org.onap.optf.cmso.model.DomainData; import org.onap.optf.cmso.model.Schedule; -import org.onap.optf.cmso.model.dao.ScheduleDAO; +import org.onap.optf.cmso.model.dao.ScheduleDao; import org.onap.optf.cmso.optimizer.model.OptimizerElementInfo; import org.onap.optf.cmso.optimizer.model.OptimizerRequest; import org.onap.optf.cmso.optimizer.model.OptimizerResponse; @@ -72,7 +72,7 @@ public class CmsoOptimizerClient { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired Environment env; @@ -93,10 +93,10 @@ public class CmsoOptimizerClient { try { // Ensure that only one cmso is requsting this call to optimizer Schedule schedule = scheduleDao.lockOne(uuid); - if (schedule.getStatus().equals(CMSStatusEnum.PendingSchedule.toString())) { + if (schedule.getStatus().equals(CmsoStatusEnum.PendingSchedule.toString())) { scheduleNewOptimization(schedule); } - if (schedule.getStatus().equals(CMSStatusEnum.OptimizationInProgress.toString())) { + if (schedule.getStatus().equals(CmsoStatusEnum.OptimizationInProgress.toString())) { pollOptimizer(schedule); } return; @@ -121,7 +121,7 @@ public class CmsoOptimizerClient { // message, try the next one. We don't want bad data to // if (schedule.getOptimizerAttemptsToSchedule() >= maxAttempts) { - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerMessage("Maximum number of attempts exceeded " + maxAttempts); updateScheduleStatus(schedule); return; @@ -134,7 +134,7 @@ public class CmsoOptimizerClient { } } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerMessage("Unexpected exception: " + e.getMessage()); updateScheduleStatus(schedule); return; @@ -168,7 +168,7 @@ public class CmsoOptimizerClient { // schedule.setOptimizerTransactionId(cmReq.getRequestId()); schedule.setOptimizerDateTimeMillis(System.currentTimeMillis()); - schedule.setStatus(CMSStatusEnum.OptimizationInProgress.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationInProgress.toString()); updateScheduleStatus(schedule); debug.debug("optimizer url / user: " + optimizerurl + " / " + username); debug.debug("optimizer Request: " + new ObjectMapper().writeValueAsString(cmReq)); @@ -193,7 +193,7 @@ public class CmsoOptimizerClient { schedule.setOptimizerStatus("HTTP Status: " + response.getStatus()); String message = response.readEntity(String.class); schedule.setOptimizerMessage(message); - schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString()); + schedule.setStatus(CmsoStatusEnum.ScheduleFailed.toString()); // Need to understand the cause of this error. May be teh same as optimizer // down. int tries = schedule.getOptimizerAttemptsToSchedule(); @@ -209,7 +209,7 @@ public class CmsoOptimizerClient { schedule.setOptimizerDateTimeMillis(System.currentTimeMillis()); int tries = schedule.getOptimizerAttemptsToSchedule(); tries++; - schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString()); + schedule.setStatus(CmsoStatusEnum.ScheduleFailed.toString()); schedule.setOptimizerAttemptsToSchedule(tries); String message = response.readEntity(String.class); schedule.setOptimizerMessage(message); @@ -223,7 +223,7 @@ public class CmsoOptimizerClient { } catch (ResponseProcessingException e) { schedule.setOptimizerDateTimeMillis(System.currentTimeMillis()); schedule.setOptimizerStatus("Failed to parse optimizer response"); - schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString()); + schedule.setStatus(CmsoStatusEnum.ScheduleFailed.toString()); // Need to understand the cause of this error. May be teh same as optimizer down. int tries = schedule.getOptimizerAttemptsToSchedule(); tries++; @@ -235,7 +235,7 @@ public class CmsoOptimizerClient { } catch (ProcessingException e) { // Don't track number of retries on IO error (optimizer is down) schedule.setOptimizerDateTimeMillis(System.currentTimeMillis()); - schedule.setStatus(CMSStatusEnum.PendingSchedule.toString()); + schedule.setStatus(CmsoStatusEnum.PendingSchedule.toString()); updateScheduleStatus(schedule); /// Cannot connect to optimizer Observation.report(LogMessages.OPTIMIZER_EXCEPTION, e, e.getMessage()); @@ -264,7 +264,7 @@ public class CmsoOptimizerClient { } Long now = System.currentTimeMillis(); if (now > schedule.getOptimizerDateTimeMillis() + (timeout * 1000)) { - schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString()); + schedule.setStatus(CmsoStatusEnum.ScheduleFailed.toString()); updateScheduleStatus(schedule); return; } @@ -299,7 +299,7 @@ public class CmsoOptimizerClient { schedule.setOptimizerStatus("HTTP Status: " + response.getStatus()); String message = response.readEntity(String.class); schedule.setOptimizerMessage(message); - schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString()); + schedule.setStatus(CmsoStatusEnum.ScheduleFailed.toString()); updateScheduleStatus(schedule); Observation.report(LogMessages.OPTIMIZER_EXCEPTION, message); } @@ -308,7 +308,7 @@ public class CmsoOptimizerClient { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); schedule.setOptimizerDateTimeMillis(System.currentTimeMillis()); schedule.setOptimizerMessage(e.getMessage()); - schedule.setStatus(CMSStatusEnum.ScheduleFailed.toString()); + schedule.setStatus(CmsoStatusEnum.ScheduleFailed.toString()); updateScheduleStatus(schedule); } } @@ -336,7 +336,7 @@ public class CmsoOptimizerClient { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, "Unable to parse message. Format changed?"); schedule.setOptimizerStatus("Failed to parse optimizer request"); schedule.setOptimizerDateTimeMillis(System.currentTimeMillis()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); scheduleDao.save(schedule); } return null; diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerHandler.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerHandler.java index cb658bb..7b1dd58 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerHandler.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/CmsoOptimizerHandler.java @@ -33,17 +33,17 @@ import java.util.List; import java.util.Map; import javax.ws.rs.core.Response.Status; import org.onap.observations.Observation; -import org.onap.optf.cmso.common.CMSStatusEnum; +import org.onap.optf.cmso.common.CmsoStatusEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; import org.onap.optf.cmso.model.ChangeManagementGroup; import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.onap.optf.cmso.model.Schedule; -import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.onap.optf.cmso.model.dao.ScheduleDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDao; +import org.onap.optf.cmso.model.dao.ChangeManagementDetailDao; +import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.model.dao.ScheduleDao; import org.onap.optf.cmso.optimizer.model.OptimizerResponse; import org.onap.optf.cmso.optimizer.model.OptimizerScheduleInfo; import org.onap.optf.cmso.optimizer.model.ScheduledElement; @@ -63,19 +63,19 @@ public class CmsoOptimizerHandler { Environment env; @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired - ChangeManagementGroupDAO cmGroupDao; + ChangeManagementGroupDao cmGroupDao; @Autowired - ChangeManagementChangeWindowDAO cmChangeWindowDao; + ChangeManagementChangeWindowDao cmChangeWindowDao; @Autowired - ChangeManagementDetailDAO cmDetailsDao; + ChangeManagementDetailDao cmDetailsDao; /** * Handle optimizer response. @@ -88,7 +88,7 @@ public class CmsoOptimizerHandler { // Note that transaction ID and schedule ID are currently the same value. String id = response.getRequestId(); - CMSStatusEnum status = CMSStatusEnum.PendingApproval.fromString(schedule.getStatus()); + CmsoStatusEnum status = CmsoStatusEnum.PendingApproval.fromString(schedule.getStatus()); debug.debug("Status at time of optimizer status is " + status.toString() + " for " + id); switch (status) { // PendingSchedule may be a valid status in the cases where SNIRO async call @@ -100,8 +100,8 @@ public class CmsoOptimizerHandler { scheduleDao.save(schedule); break; default: - throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR, - CMSStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString()); + throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR, + CmsoStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString()); } } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); @@ -118,7 +118,7 @@ public class CmsoOptimizerHandler { saveSchedules(response, schedule); break; case FAILED: - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); break; case PENDING_OPTIMIZER: case PENDING_TICKETS: @@ -129,20 +129,20 @@ public class CmsoOptimizerHandler { break; } scheduleDao.save(schedule); - } catch (CMSException e) { + } catch (CmsoException e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerStatus(e.getStatus().toString()); schedule.setOptimizerMessage(e.getLocalizedMessage()); } catch (Exception e) { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerStatus("Exception"); schedule.setOptimizerMessage(e.getLocalizedMessage()); } } - private void saveSchedules(OptimizerResponse response, Schedule schedule) throws CMSException { + private void saveSchedules(OptimizerResponse response, Schedule schedule) throws CmsoException { // TODO: Persist the list of schedules in the DB @@ -153,12 +153,12 @@ public class CmsoOptimizerHandler { OptimizerScheduleInfo osi = chooseSchedule(schedules); if (osi == null) { - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerMessage("No schedules returned for COMPLETED status"); return; } if (osi.getScheduledElements().size() == 0) { - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerMessage("No elements scheduled for COMPLETED status"); return; } @@ -174,7 +174,7 @@ public class CmsoOptimizerHandler { cmScheduleDao.findOneByScheduleUuidGroupIdAndVnfName(schedule.getUuid(), groupId, vnfName); cms.setStartTimeMillis(element.getStartTime().getTime()); cms.setFinishTimeMillis(element.getEndTime().getTime()); - cms.setStatus(CMSStatusEnum.PendingApproval.toString()); + cms.setStatus(CmsoStatusEnum.PendingApproval.toString()); cmScheduleDao.save(cms); } if (osi.getUnScheduledElements() != null) { @@ -183,7 +183,7 @@ public class CmsoOptimizerHandler { String vnfName = element.getElementId(); ChangeManagementSchedule cms = cmScheduleDao.findOneByScheduleUuidGroupIdAndVnfName(schedule.getUuid(), groupId, vnfName); - cms.setStatus(CMSStatusEnum.NotScheduled.toString()); + cms.setStatus(CmsoStatusEnum.NotScheduled.toString()); cmScheduleDao.save(cms); } @@ -193,7 +193,7 @@ public class CmsoOptimizerHandler { for (ChangeManagementGroup cmg : updatedGroups.values()) { cmGroupDao.save(cmg); } - schedule.setStatus(CMSStatusEnum.PendingApproval.toString()); + schedule.setStatus(CmsoStatusEnum.PendingApproval.toString()); } private void updateGroup(ScheduledElement element, List<ChangeManagementGroup> groups, @@ -214,7 +214,7 @@ public class CmsoOptimizerHandler { } } if (cmg == null) { - throw new CMSException(Status.INTERNAL_SERVER_ERROR, LogMessages.MISSING_VALID_GROUP_FOR_ELEMENT, + throw new CmsoException(Status.INTERNAL_SERVER_ERROR, LogMessages.MISSING_VALID_GROUP_FOR_ELEMENT, element.getElementId()); } Long elementStartTime = element.getStartTime().getTime(); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java index 0021c0d..e5bbd52 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/OptimizerQuartzJob.java @@ -44,13 +44,13 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response;
import org.onap.observations.Mdc;
import org.onap.optf.cmso.common.BasicAuthenticatorFilter;
-import org.onap.optf.cmso.common.CMSStatusEnum;
+import org.onap.optf.cmso.common.CmsoStatusEnum;
import org.onap.optf.cmso.common.DomainsEnum;
import org.onap.optf.cmso.common.LogMessages;
import org.onap.optf.cmso.common.PropertiesManagement;
import org.onap.optf.cmso.filters.CmsoClientFilters;
import org.onap.optf.cmso.model.Schedule;
-import org.onap.optf.cmso.model.dao.ScheduleDAO;
+import org.onap.optf.cmso.model.dao.ScheduleDao;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
@@ -71,7 +71,7 @@ public class OptimizerQuartzJob extends QuartzJobBean { private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();
@Autowired
- ScheduleDAO scheduleDao;
+ ScheduleDao scheduleDao;
@Autowired
PropertiesManagement pm;
@@ -96,12 +96,12 @@ public class OptimizerQuartzJob extends QuartzJobBean { // schedule the request and update the status to PendingSchedule
// and update the state to OptimizationInProgress
List<Schedule> schedules = scheduleDao.findByDomainStatus(DomainsEnum.ChangeManagement.toString(),
- CMSStatusEnum.PendingSchedule.toString());
+ CmsoStatusEnum.PendingSchedule.toString());
for (Schedule s : schedules) {
scheduleOptimization(s);
}
List<Schedule> inProgressSchedules = scheduleDao.findByDomainStatus(DomainsEnum.ChangeManagement.toString(),
- CMSStatusEnum.OptimizationInProgress.toString());
+ CmsoStatusEnum.OptimizationInProgress.toString());
for (Schedule s : inProgressSchedules) {
scheduleOptimization(s);
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerRequest.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerRequest.java index e9e80c4..05ab753 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerRequest.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerRequest.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ package org.onap.optf.cmso.optimizer.bean;
-public class CMOptimizerRequest {
+public class CmsoOptimizerRequest {
/*
*
@@ -39,35 +39,35 @@ public class CMOptimizerRequest { * "2017-02-15T00:00:00+05:00", "endTime": "2017-02-18T23:59:00+05:00",
* "normalDurationInSecs": 60, "additionalDurationInSecs": 0, // for backout
* "concurrencyLimit": 10, "policyId": ["SNIRO.TimeLimitAndVerticalTopology"],
- * "vnfDetails": [{ “node�: "satmo415vbc", “groupId�: “group1�//optional }, {
- * “node�: "satmo415vbc", “groupId�: “group1�//optional }] }, "requestInfo": {
- * “transactionId�: �__TRANSACTIONID__�, //logging "requestId":
- * "CM-<__SCHEDULE ID__>", "sourceId": "cm-portal", “optimizer�: [“scheduling�],
+ * "vnfDetails": [{ “node�?: "satmo415vbc", “groupId�?: “group1�?//optional }, {
+ * “node�?: "satmo415vbc", “groupId�?: “group1�?//optional }] }, "requestInfo": {
+ * “transactionId�?: �?__TRANSACTIONID__�?, //logging "requestId":
+ * "CM-<__SCHEDULE ID__>", "sourceId": "cm-portal", “optimizer�?: [“scheduling�?],
* "callbackUrl": "http://callbackurl.onap.org:8080/callback" } }
*
*/
- private CMSchedulingInfo schedulingInfo;
- private CMRequestInfo requestInfo;
+ private CmsoSchedulingInfo schedulingInfo;
+ private CmsoRequestInfo requestInfo;
- public CMOptimizerRequest() {
- schedulingInfo = new CMSchedulingInfo();
- requestInfo = new CMRequestInfo();
+ public CmsoOptimizerRequest() {
+ schedulingInfo = new CmsoSchedulingInfo();
+ requestInfo = new CmsoRequestInfo();
}
- public CMSchedulingInfo getSchedulingInfo() {
+ public CmsoSchedulingInfo getSchedulingInfo() {
return schedulingInfo;
}
- public void setSchedulingInfo(CMSchedulingInfo schedulingInfo) {
+ public void setSchedulingInfo(CmsoSchedulingInfo schedulingInfo) {
this.schedulingInfo = schedulingInfo;
}
- public CMRequestInfo getRequestInfo() {
+ public CmsoRequestInfo getRequestInfo() {
return requestInfo;
}
- public void setRequestInfo(CMRequestInfo requestInfo) {
+ public void setRequestInfo(CmsoRequestInfo requestInfo) {
this.requestInfo = requestInfo;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerResponse.java index 6dd7bdf..1660866 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMOptimizerResponse.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoOptimizerResponse.java @@ -36,7 +36,7 @@ import io.swagger.annotations.ApiModelProperty; @ApiModel(value = "Response from schedule optimizer",
description = "Asynchronous response to schedule oprimizer request.")
-public class CMOptimizerResponse {
+public class CmsoOptimizerResponse {
/*
*
@@ -69,9 +69,9 @@ public class CMOptimizerResponse { private String description;
@ApiModelProperty(value = "List of schedules returned, one per group. Only 1 group supported at this time.")
- private CMSchedule[] schedule;
+ private CmsoSchedule[] schedule;
- public CMOptimizerResponse() {}
+ public CmsoOptimizerResponse() {}
public String getTransactionId() {
return transactionId;
@@ -113,11 +113,11 @@ public class CMOptimizerResponse { this.status = status;
}
- public CMSchedule[] getSchedule() {
+ public CmsoSchedule[] getSchedule() {
return schedule;
}
- public void setSchedule(CMSchedule[] schedule) {
+ public void setSchedule(CmsoSchedule[] schedule) {
this.schedule = schedule;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMRequestInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoRequestInfo.java index 5d8ee69..dd74db2 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMRequestInfo.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoRequestInfo.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,14 +31,14 @@ package org.onap.optf.cmso.optimizer.bean;
-public class CMRequestInfo {
+public class CmsoRequestInfo {
private String transactionId;
private String requestId;
private String sourceId;
private String[] optimizer;
private String callbackUrl;
- public CMRequestInfo() {}
+ public CmsoRequestInfo() {}
public String getTransactionId() {
return transactionId;
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMSchedule.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedule.java index 184e782..0d56fbd 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMSchedule.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedule.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,14 +34,14 @@ package org.onap.optf.cmso.optimizer.bean; import java.util.ArrayList;
import java.util.List;
-public class CMSchedule {
+public class CmsoSchedule {
private String groupId;
private String startTime;
private String finishTime;
private String latestInstanceStartTime;
private List<String> node;
- public CMSchedule() {
+ public CmsoSchedule() {
node = new ArrayList<String>();
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMSchedulingInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedulingInfo.java index 5e86dd7..840cbb7 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMSchedulingInfo.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoSchedulingInfo.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ package org.onap.optf.cmso.optimizer.bean;
-public class CMSchedulingInfo {
+public class CmsoSchedulingInfo {
private String scheduleId;
private String startTime;
private String endTime;
@@ -39,9 +39,9 @@ public class CMSchedulingInfo { private int additionalDurationInSecs;
private int concurrencyLimit;
private String[] policyId;
- private CMVnfDetails[] vnfDetails;
+ private CmsoVnfDetails[] vnfDetails;
- public CMSchedulingInfo() {}
+ public CmsoSchedulingInfo() {}
public String getScheduleId() {
return scheduleId;
@@ -99,11 +99,11 @@ public class CMSchedulingInfo { this.policyId = policyId;
}
- public CMVnfDetails[] getVnfDetails() {
+ public CmsoVnfDetails[] getVnfDetails() {
return vnfDetails;
}
- public void setVnfDetails(CMVnfDetails[] vnfDetails) {
+ public void setVnfDetails(CmsoVnfDetails[] vnfDetails) {
this.vnfDetails = vnfDetails;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMVnfDetails.java b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoVnfDetails.java index 4da1ab1..4ee6053 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CMVnfDetails.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/optimizer/bean/CmsoVnfDetails.java @@ -1,6 +1,6 @@ /*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
+ * Copyright � 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright � 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,13 +31,13 @@ package org.onap.optf.cmso.optimizer.bean;
-public class CMVnfDetails {
+public class CmsoVnfDetails {
private String node;
private String groupId;
- public CMVnfDetails() {}
+ public CmsoVnfDetails() {}
- public CMVnfDetails(String groupId) {
+ public CmsoVnfDetails(String groupId) {
this.groupId = groupId;
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java index 816a80e..faea625 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java @@ -35,19 +35,19 @@ import java.util.Map; import java.util.UUID;
import javax.ws.rs.core.Response.Status;
import org.onap.optf.cmso.common.ApprovalStatusEnum;
-import org.onap.optf.cmso.common.CMSStatusEnum;
+import org.onap.optf.cmso.common.CmsoStatusEnum;
import org.onap.optf.cmso.common.LogMessages;
-import org.onap.optf.cmso.common.exceptions.CMSAlreadyExistsException;
-import org.onap.optf.cmso.common.exceptions.CMSException;
-import org.onap.optf.cmso.common.exceptions.CMSNotFoundException;
+import org.onap.optf.cmso.common.exceptions.CmsoAlreadyExistsException;
+import org.onap.optf.cmso.common.exceptions.CmsoException;
+import org.onap.optf.cmso.common.exceptions.CmsoNotFoundException;
import org.onap.optf.cmso.model.ApprovalType;
import org.onap.optf.cmso.model.DomainData;
import org.onap.optf.cmso.model.Schedule;
import org.onap.optf.cmso.model.ScheduleApproval;
-import org.onap.optf.cmso.model.dao.ApprovalTypeDAO;
-import org.onap.optf.cmso.model.dao.DomainDataDAO;
-import org.onap.optf.cmso.model.dao.ScheduleApprovalDAO;
-import org.onap.optf.cmso.model.dao.ScheduleDAO;
+import org.onap.optf.cmso.model.dao.ApprovalTypeDao;
+import org.onap.optf.cmso.model.dao.DomainDataDao;
+import org.onap.optf.cmso.model.dao.ScheduleApprovalDao;
+import org.onap.optf.cmso.model.dao.ScheduleDao;
import org.onap.optf.cmso.service.rs.models.ApprovalMessage;
import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage;
import org.springframework.beans.factory.annotation.Autowired;
@@ -58,24 +58,24 @@ public class BaseSchedulerServiceImpl { private static EELFLogger log = EELFManager.getInstance().getLogger(BaseSchedulerServiceImpl.class);
@Autowired
- protected ScheduleDAO scheduleDao;
+ protected ScheduleDao scheduleDao;
@Autowired
- DomainDataDAO domainDataDao;
+ DomainDataDao domainDataDao;
@Autowired
- ApprovalTypeDAO approvalTypeDao;
+ ApprovalTypeDao approvalTypeDao;
@Autowired
- ScheduleApprovalDAO scheduleApprovalDao;
+ ScheduleApprovalDao scheduleApprovalDao;
protected Schedule validateAndAddScheduleRequest(OptimizedScheduleMessage scheduleMessage,
- List<DomainData> domainData) throws CMSException {
+ List<DomainData> domainData) throws CmsoException {
messageValidations(scheduleMessage);
Schedule sch = scheduleDao.findByDomainScheduleId(scheduleMessage.getDomain(), scheduleMessage.getScheduleId());
if (sch != null) {
- throw new CMSAlreadyExistsException(scheduleMessage.getDomain(), scheduleMessage.getScheduleId());
+ throw new CmsoAlreadyExistsException(scheduleMessage.getDomain(), scheduleMessage.getScheduleId());
}
sch = new Schedule();
sch.setUuid(UUID.randomUUID());
@@ -90,7 +90,7 @@ public class BaseSchedulerServiceImpl { sch.setScheduleName(scheduleMessage.getScheduleName());
sch.setOptimizerAttemptsToSchedule(0);
sch.setScheduleInfo(scheduleMessage.getSchedulingData().toString());
- sch.setStatus(CMSStatusEnum.PendingSchedule.toString());
+ sch.setStatus(CmsoStatusEnum.PendingSchedule.toString());
scheduleDao.save(sch);
for (DomainData dd : domainData) {
dd.setUuid(UUID.randomUUID());
@@ -101,51 +101,51 @@ public class BaseSchedulerServiceImpl { return sch;
}
- private void messageValidations(OptimizedScheduleMessage scheduleMessage) throws CMSException {
+ private void messageValidations(OptimizedScheduleMessage scheduleMessage) throws CmsoException {
if (scheduleMessage.getScheduleName() == null || scheduleMessage.getScheduleName().equals("")) {
- throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "schedulerName", "");
+ throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "schedulerName", "");
}
if (scheduleMessage.getUserId() == null || scheduleMessage.getUserId().equals("")) {
- throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "userId", "");
+ throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "userId", "");
}
}
- protected void deleteScheduleRequest(String domain, String scheduleId) throws CMSException {
+ protected void deleteScheduleRequest(String domain, String scheduleId) throws CmsoException {
Schedule sch = scheduleDao.findByDomainScheduleId(domain, scheduleId);
if (sch == null) {
- throw new CMSNotFoundException(domain, scheduleId);
+ throw new CmsoNotFoundException(domain, scheduleId);
}
- CMSStatusEnum currentStatus = CMSStatusEnum.Completed.fromString(sch.getStatus());
+ CmsoStatusEnum currentStatus = CmsoStatusEnum.Completed.fromString(sch.getStatus());
sch.setDeleteDateTimeMillis(System.currentTimeMillis());
switch (currentStatus) {
case Scheduled:
// TODO CLose all tickets....
- sch.setStatus(CMSStatusEnum.Cancelled.toString());
+ sch.setStatus(CmsoStatusEnum.Cancelled.toString());
break;
case NotificationsInitiated:
- throw new CMSException(Status.NOT_ACCEPTABLE, LogMessages.CANNOT_CANCEL_IN_PROGRESS);
+ throw new CmsoException(Status.NOT_ACCEPTABLE, LogMessages.CANNOT_CANCEL_IN_PROGRESS);
default:
- sch.setStatus(CMSStatusEnum.Deleted.toString());
+ sch.setStatus(CmsoStatusEnum.Deleted.toString());
}
scheduleDao.save(sch);
}
protected Schedule processApproval(Schedule sch, String domain, ApprovalMessage approvalMessage)
- throws CMSException {
+ throws CmsoException {
String scheduleId = sch.getScheduleId();
ApprovalType approvalType =
approvalTypeDao.findByDomainAndType(domain, approvalMessage.getApprovalType().toString());
if (approvalType == null) {
- throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "approvalType",
+ throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "approvalType",
approvalMessage.getApprovalType().toString());
}
- if (!sch.getStatus().equals(CMSStatusEnum.PendingApproval.toString())) {
- throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.NOT_PENDING_APPROVAL, domain, scheduleId,
+ if (!sch.getStatus().equals(CmsoStatusEnum.PendingApproval.toString())) {
+ throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.NOT_PENDING_APPROVAL, domain, scheduleId,
sch.getStatus());
}
if (approvalMessage.getApprovalUserId() == null || approvalMessage.getApprovalUserId().equals("")) {
- throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "userId");
+ throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "userId");
}
ScheduleApproval sa = null;
// only 1 approval per user....
@@ -171,10 +171,10 @@ public class BaseSchedulerServiceImpl { sch.addScheduleApproval(sa);
scheduleDao.save(sch);
if (sa.getStatus().equals(ApprovalStatusEnum.Rejected.toString())) {
- sch.setStatus(CMSStatusEnum.Rejected.toString());
+ sch.setStatus(CmsoStatusEnum.Rejected.toString());
} else {
if (allApprovalsReceived(sch, sa)) {
- sch.setStatus(CMSStatusEnum.Accepted.toString());
+ sch.setStatus(CmsoStatusEnum.Accepted.toString());
}
}
scheduleDao.save(sch);
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java index 2e9ade3..442abe3 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmQueryParameters.java @@ -33,7 +33,7 @@ import javax.ws.rs.core.Response.Status; import org.joda.time.DateTime;
import org.joda.time.format.ISODateTimeFormat;
import org.onap.optf.cmso.common.LogMessages;
-import org.onap.optf.cmso.common.exceptions.CMSException;
+import org.onap.optf.cmso.common.exceptions.CmsoException;
import org.onap.optf.cmso.model.DomainData;
/**
@@ -102,12 +102,12 @@ public class CmQueryParameters { * @param urlName the url name
* @param values the values
* @return the string
- * @throws CMSException the CMS exception
+ * @throws CmsoException the CMS exception
*/
- public static String buildClause(String urlName, List<String> values) throws CMSException {
+ public static String buildClause(String urlName, List<String> values) throws CmsoException {
QueryColumns qc = getQueryColumn(urlName);
if (qc == null) {
- throw new CMSException(Status.BAD_REQUEST, LogMessages.UNDEFINED_FILTER_ATTRIBUTE, urlName);
+ throw new CmsoException(Status.BAD_REQUEST, LogMessages.UNDEFINED_FILTER_ATTRIBUTE, urlName);
}
if (qc.type == Date.class) {
return formatDate(urlName, values, qc);
@@ -169,7 +169,7 @@ public class CmQueryParameters { return clause.toString();
}
- private static String formatDate(String urlName, List<String> values, QueryColumns qc) throws CMSException {
+ private static String formatDate(String urlName, List<String> values, QueryColumns qc) throws CmsoException {
List<String> clauses = new ArrayList<String>();
for (String value : values) {
String[] dates = value.split(",");
@@ -181,7 +181,7 @@ public class CmQueryParameters { formatDatePair(qc, dates[0].trim(), "", clauses);
break;
default:
- throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, value);
+ throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, value);
}
}
StringBuilder clause = new StringBuilder();
@@ -197,7 +197,7 @@ public class CmQueryParameters { }
private static void formatDatePair(QueryColumns qc, String lowDate, String highDate, List<String> clauses)
- throws CMSException {
+ throws CmsoException {
StringBuilder clause = new StringBuilder();
DateTime date1 = null;
DateTime date2 = null;
@@ -222,12 +222,12 @@ public class CmQueryParameters { }
}
- private static DateTime convertDate(String utcDate, String urlName) throws CMSException {
+ private static DateTime convertDate(String utcDate, String urlName) throws CmsoException {
DateTime dateTime = ISODateTimeFormat.dateTimeParser().parseDateTime(utcDate);
if (dateTime != null) {
return dateTime;
}
- throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, utcDate);
+ throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_DATE_FILTER, urlName, utcDate);
}
// public static void main(String argv[])
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleService.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleService.java index 9874ea8..6236adb 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleService.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleService.java @@ -43,7 +43,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.onap.optf.cmso.common.CMSRequestError; +import org.onap.optf.cmso.common.CmsoRequestError; import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage; @Api("CMSO Optimized Schedule API") @@ -59,7 +59,7 @@ public interface CmsoOptimizedScheduleService { @ApiResponses( value = {@ApiResponse(code = 202, message = "Schedule request accepted for optimization."), @ApiResponse(code = 409, message = "Schedule request already exists for this schedule id.", - response = CMSRequestError.class), + response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error")}) public Response createScheduleRequest( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleServiceImpl.java index 290d21e..2b6a928 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizedScheduleServiceImpl.java @@ -33,7 +33,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import org.onap.observations.Observation; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; import org.onap.optf.cmso.service.rs.models.v2.OptimizedScheduleMessage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; @@ -63,7 +63,7 @@ public class CmsoOptimizedScheduleServiceImpl extends CommonServiceImpl implemen try { createSchedule(scheduleMessage, scheduleId, request); response = Response.accepted().build(); - } catch (CMSException e) { + } catch (CmsoException e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallback.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallback.java index d6cefb6..b6b81e6 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallback.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallback.java @@ -43,7 +43,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.onap.optf.cmso.optimizer.bean.CMOptimizerResponse; +import org.onap.optf.cmso.optimizer.bean.CmsoOptimizerResponse; @Api("CMSO Optimized Schedule API") @Path("/{apiVersion}") @@ -59,6 +59,6 @@ public interface CmsoOptimizerCallback { @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response sniroCallback( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, - @ApiParam(value = "Return schedules > lastScheduleId") CMOptimizerResponse reponse); + @ApiParam(value = "Return schedules > lastScheduleId") CmsoOptimizerResponse reponse); } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallbackImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallbackImpl.java index 6a7b1b3..ffe00c5 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallbackImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoOptimizerCallbackImpl.java @@ -46,20 +46,20 @@ import javax.ws.rs.core.UriInfo; import org.joda.time.DateTime; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.ISODateTimeFormat; -import org.onap.optf.cmso.common.CMSStatusEnum; +import org.onap.optf.cmso.common.CmsoStatusEnum; import org.onap.optf.cmso.common.DomainsEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; -import org.onap.optf.cmso.common.exceptions.CMSNotFoundException; +import org.onap.optf.cmso.common.exceptions.CmsoException; +import org.onap.optf.cmso.common.exceptions.CmsoNotFoundException; import org.onap.optf.cmso.model.ChangeManagementGroup; import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.onap.optf.cmso.model.Schedule; -import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.onap.optf.cmso.optimizer.bean.CMOptimizerResponse; -import org.onap.optf.cmso.optimizer.bean.CMSchedule; +import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDao; +import org.onap.optf.cmso.model.dao.ChangeManagementDetailDao; +import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.optimizer.bean.CmsoOptimizerResponse; +import org.onap.optf.cmso.optimizer.bean.CmsoSchedule; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -80,16 +80,16 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired - ChangeManagementGroupDAO cmGroupDao; + ChangeManagementGroupDao cmGroupDao; @Autowired - ChangeManagementChangeWindowDAO cmChangeWindowDao; + ChangeManagementChangeWindowDao cmChangeWindowDao; @Autowired - ChangeManagementDetailDAO cmDetailsDaoO; + ChangeManagementDetailDao cmDetailsDaoO; /** * Sniro callback. @@ -100,7 +100,7 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen */ @Override @Transactional - public Response sniroCallback(String apiVersion, CMOptimizerResponse sniroResponse) { + public Response sniroCallback(String apiVersion, CmsoOptimizerResponse sniroResponse) { Response response = null; log.info(LogMessages.PROCESS_OPTIMIZER_CALLBACK, "Received", request.getRemoteAddr(), ""); log.info(LogMessages.OPTIMIZER_REQUEST, "Callback received", sniroResponse.getTransactionId(), @@ -123,11 +123,11 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen Schedule schedule = scheduleDao.lockOneByTransactionId(transactionId); if (schedule == null) { - throw new CMSNotFoundException(DomainsEnum.ChangeManagement.toString(), + throw new CmsoNotFoundException(DomainsEnum.ChangeManagement.toString(), "(OptimizerTransactionID=" + transactionId + ")"); } - CMSStatusEnum status = CMSStatusEnum.PendingApproval.fromString(schedule.getStatus()); + CmsoStatusEnum status = CmsoStatusEnum.PendingApproval.fromString(schedule.getStatus()); debug.debug("Status at time of SNIRO callback is " + status.toString()); switch (status) { // PendingSchedule may be a valid status in the cases where SNIRO async call @@ -140,10 +140,10 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen response = Response.ok().build(); break; default: - throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR, - CMSStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString()); + throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.OPTIMIZER_CALLBACK_STATE_ERROR, + CmsoStatusEnum.OptimizationInProgress.toString(), schedule.getStatus().toString()); } - } catch (CMSException e) { + } catch (CmsoException e) { errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); } catch (Exception e) { @@ -153,25 +153,25 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen return response; } - private void processSniroResponse(CMOptimizerResponse sniroResponse, Schedule schedule) { + private void processSniroResponse(CmsoOptimizerResponse sniroResponse, Schedule schedule) { try { schedule.setOptimizerReturnDateTimeMillis(System.currentTimeMillis()); schedule.setOptimizerStatus(sniroResponse.getRequestState()); schedule.setOptimizerMessage(sniroResponse.getDescription()); String scheduleId = sniroResponse.getScheduleId(); ObjectMapper om = new ObjectMapper(); - CMSchedule[] scheduleArray = sniroResponse.getSchedule(); + CmsoSchedule[] scheduleArray = sniroResponse.getSchedule(); if (scheduleArray != null && scheduleArray.length > 0) { String scheduleString = om.writeValueAsString(scheduleArray); schedule.setSchedule(scheduleString); log.debug("scheduleId={0} schedule={1}", scheduleId, scheduleString); - for (CMSchedule sniroSchedule : sniroResponse.getSchedule()) { + for (CmsoSchedule sniroSchedule : sniroResponse.getSchedule()) { String groupId = sniroSchedule.getGroupId(); DateTime finishTime = convertDate(sniroSchedule.getFinishTime(), "finishTime"); DateTime startTime = convertDate(sniroSchedule.getStartTime(), "startTime"); ChangeManagementGroup group = cmGroupDao.findOneBySchedulesIdGroupId(schedule.getUuid(), groupId); if (group == null) { - throw new CMSException(Status.PRECONDITION_FAILED, + throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.CHANGE_MANAGEMENT_GROUP_NOT_FOUND, schedule.getScheduleId(), groupId); } group.setStartTimeMillis(startTime.getMillis()); @@ -189,19 +189,19 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen processNode(schedule, group, node, startAndFinishTimeMap); } } - schedule.setStatus(CMSStatusEnum.PendingApproval.toString()); + schedule.setStatus(CmsoStatusEnum.PendingApproval.toString()); } else { debug.debug("scheduleId={0} schedule=null status={1} ", scheduleId, schedule.getOptimizerStatus()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); } - } catch (CMSException e) { + } catch (CmsoException e) { errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerStatus(e.getStatus().toString()); schedule.setOptimizerMessage(e.getLocalizedMessage()); } catch (Exception e) { errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); - schedule.setStatus(CMSStatusEnum.OptimizationFailed.toString()); + schedule.setStatus(CmsoStatusEnum.OptimizationFailed.toString()); schedule.setOptimizerStatus("Exception"); schedule.setOptimizerMessage(e.getLocalizedMessage()); } @@ -216,10 +216,10 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen * @param totalDuration the total duration * @param nodeList the node list * @param startAndFinishTimeMap the start and finish time map - * @throws CMSException the CMS exception + * @throws CmsoException the CMS exception */ public static void makeMap(Long startTime, Long latestInstanceStartTime, int concurrencyLimit, long totalDuration, - List<String> nodeList, Map<String, Map<String, Long>> startAndFinishTimeMap) throws CMSException { + List<String> nodeList, Map<String, Map<String, Long>> startAndFinishTimeMap) throws CmsoException { Long nextStartTime = null; Long nextFinishTime = null; for (int nodeNumber = 0; nodeNumber < nodeList.size(); nodeNumber++) { @@ -231,7 +231,7 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen nextStartTime = nextStartTime + totalDuration; } if (nextStartTime > latestInstanceStartTime) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_ALLOCATE_VNF_TIMESLOTS, + throw new CmsoException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_ALLOCATE_VNF_TIMESLOTS, startTime.toString(), latestInstanceStartTime.toString(), String.valueOf(totalDuration), String.valueOf(concurrencyLimit), String.valueOf(nodeList.size())); } @@ -247,17 +247,17 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen } private void processNode(Schedule schedule, ChangeManagementGroup group, String node, - Map<String, Map<String, Long>> startAndFinishTimeMap) throws CMSException { + Map<String, Map<String, Long>> startAndFinishTimeMap) throws CmsoException { Map<String, Long> map = startAndFinishTimeMap.get(node); ChangeManagementSchedule detail = cmScheduleDao.findOneByGroupUuidAndVnfName(group.getUuid(), node); if (detail == null) { - throw new CMSException(Status.NOT_FOUND, LogMessages.UNABLE_TO_LOCATE_SCHEDULE_DETAIL, + throw new CmsoException(Status.NOT_FOUND, LogMessages.UNABLE_TO_LOCATE_SCHEDULE_DETAIL, schedule.getScheduleId(), group.getGroupId(), node); } detail.setStartTimeMillis(map.get("startTime")); detail.setFinishTimeMillis(map.get("finishTime")); detail.setVnfId(""); - detail.setStatus(CMSStatusEnum.PendingApproval.toString()); + detail.setStatus(CmsoStatusEnum.PendingApproval.toString()); cmScheduleDao.save(detail); } @@ -267,9 +267,9 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen * @param utcDate the utc date * @param attrName the attr name * @return the date time - * @throws CMSException the CMS exception + * @throws CmsoException the CMS exception */ - public static DateTime convertDate(String utcDate, String attrName) throws CMSException { + public static DateTime convertDate(String utcDate, String attrName) throws CmsoException { try { DateTime dateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss").withZoneUTC().parseDateTime(utcDate); if (dateTime != null) { @@ -278,7 +278,7 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen } catch (Exception e) { debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate); } /** @@ -287,9 +287,9 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen * @param utcDate the utc date * @param attrName the attr name * @return the date time - * @throws CMSException the CMS exception + * @throws CmsoException the CMS exception */ - public static DateTime convertIsoDate(String utcDate, String attrName) throws CMSException { + public static DateTime convertIsoDate(String utcDate, String attrName) throws CmsoException { try { DateTime dateTime = ISODateTimeFormat.dateTimeParser().parseDateTime(utcDate); if (dateTime != null) { @@ -298,7 +298,7 @@ public class CmsoOptimizerCallbackImpl extends BaseSchedulerServiceImpl implemen } catch (Exception e) { debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage()); } - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, attrName, utcDate); } } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoService.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoService.java index d9b338e..bf28b1c 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoService.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoService.java @@ -49,7 +49,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; -import org.onap.optf.cmso.common.CMSRequestError; +import org.onap.optf.cmso.common.CmsoRequestError; import org.onap.optf.cmso.model.Schedule; import org.onap.optf.cmso.service.rs.models.ApprovalMessage; import org.onap.optf.cmso.service.rs.models.CmDetailsMessage; @@ -66,7 +66,7 @@ public interface CmsoService { @ApiOperation(value = "", notes = "Returns a list of Scheduler Requests based upon the filter criteria.", response = Schedule.class, responseContainer = "List") @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"), - @ApiResponse(code = 404, message = "No records found", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "No records found", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response searchScheduleRequests( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @@ -92,7 +92,7 @@ public interface CmsoService { @ApiResponses( value = {@ApiResponse(code = 202, message = "Schedule request accepted for optimization."), @ApiResponse(code = 409, message = "Schedule request already exists for this schedule id.", - response = CMSRequestError.class), + response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error")}) public Response createScheduleRequest( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @@ -108,7 +108,7 @@ public interface CmsoService { @Produces({MediaType.APPLICATION_JSON}) @ApiOperation(value = "", notes = "Cancels the schedule request for scheduleId") @ApiResponses(value = {@ApiResponse(code = 204, message = "Delete successful"), - @ApiResponse(code = 404, message = "No record found", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "No record found", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error")}) public Response deleteScheduleRequest( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @@ -153,7 +153,7 @@ public interface CmsoService { @ApiOperation(value = "", notes = "Returns a list of Schedule request details based upon the filter criteria.", response = CmDetailsMessage.class, responseContainer = "List") @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"), - @ApiResponse(code = 404, message = "No records found", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "No records found", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response searchScheduleRequestDetails( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoServiceImpl.java index 7ffd606..b9d0b60 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CmsoServiceImpl.java @@ -49,21 +49,21 @@ import org.joda.time.DateTime; import org.onap.observations.Observation; import org.onap.optf.cmso.common.DomainsEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; -import org.onap.optf.cmso.common.exceptions.CMSNotFoundException; -import org.onap.optf.cmso.eventq.CMSQueueJob; +import org.onap.optf.cmso.common.exceptions.CmsoException; +import org.onap.optf.cmso.common.exceptions.CmsoNotFoundException; +import org.onap.optf.cmso.eventq.CmsoQueueJob; import org.onap.optf.cmso.model.ChangeManagementDetail; import org.onap.optf.cmso.model.ChangeManagementGroup; import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.onap.optf.cmso.model.Schedule; import org.onap.optf.cmso.model.ScheduleQuery; -import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.onap.optf.cmso.model.dao.ElementDataDAO; -import org.onap.optf.cmso.model.dao.ScheduleDAO; -import org.onap.optf.cmso.model.dao.ScheduleQueryDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDao; +import org.onap.optf.cmso.model.dao.ChangeManagementDetailDao; +import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.model.dao.ElementDataDao; +import org.onap.optf.cmso.model.dao.ScheduleDao; +import org.onap.optf.cmso.model.dao.ScheduleQueryDao; import org.onap.optf.cmso.service.rs.models.ApprovalMessage; import org.onap.optf.cmso.service.rs.models.ChangeWindowMessage; import org.onap.optf.cmso.service.rs.models.CmDetailsMessage; @@ -90,31 +90,31 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired - CMSQueueJob qqJob; + CmsoQueueJob qqJob; @Autowired Environment env; @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired - ChangeManagementGroupDAO cmGroupDao; + ChangeManagementGroupDao cmGroupDao; @Autowired - ChangeManagementChangeWindowDAO cmChangeWindowDao; + ChangeManagementChangeWindowDao cmChangeWindowDao; @Autowired - ChangeManagementDetailDAO cmDetailsDao; + ChangeManagementDetailDao cmDetailsDao; @Autowired - ScheduleQueryDAO scheduleQueryDao; + ScheduleQueryDao scheduleQueryDao; @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired - ElementDataDAO elementDataDao; + ElementDataDao elementDataDao; @Autowired TmClient tmClient; @@ -139,7 +139,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { // buildWhere(qp, where); List<ScheduleQuery> list = scheduleQueryDao.searchSchedules(where.toString(), maxRows); if (list == null || !list.iterator().hasNext()) { - throw new CMSException(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, + throw new CmsoException(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, DomainsEnum.ChangeManagement.toString(), scheduleId); } Iterator<ScheduleQuery> iter = list.iterator(); @@ -159,7 +159,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { } } response = Response.ok(schedules.toArray(new Schedule[schedules.size()])).build(); - } catch (CMSException e) { + } catch (CmsoException e) { Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); } catch (Exception e) { @@ -183,7 +183,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { OptimizedScheduleMessage osm = adaptScheduleMessage(scheduleMessage); createSchedule(osm, scheduleId, request); response = Response.accepted().build(); - } catch (CMSException e) { + } catch (CmsoException e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); @@ -198,7 +198,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { } private OptimizedScheduleMessage adaptScheduleMessage(CmsoMessage sm) - throws CMSException, JsonParseException, JsonMappingException, IOException { + throws CmsoException, JsonParseException, JsonMappingException, IOException { OptimizedScheduleMessage osm = new OptimizedScheduleMessage(); osm.setScheduleId(sm.getScheduleId()); osm.setDomain(sm.getDomain()); @@ -220,7 +220,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { osm.setCommonData(dd); CmsoInfo sinfo = sm.getSchedulingInfo(); if (sinfo == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "schedulingInfo"); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "schedulingInfo"); } SchedulingData sd = new SchedulingData(); osm.setSchedulingData(sd); @@ -236,7 +236,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { List<VnfDetailsMessage> details = sinfo.getVnfDetails(); if (details == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "vnfDetails"); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "vnfDetails"); } List<ChangeWindow> windows = new ArrayList<>(); List<ElementInfo> elements = new ArrayList<>(); @@ -265,7 +265,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { } private Object getRequestFromCallbackData(String node, String value) - throws CMSException, JsonParseException, JsonMappingException, IOException { + throws CmsoException, JsonParseException, JsonMappingException, IOException { ObjectMapper om = new ObjectMapper(); JsonNode json = om.readValue(value, JsonNode.class); JsonNode details = json.get("requestDetails"); @@ -277,7 +277,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { return request; } } - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "CallbackData", ""); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "CallbackData", ""); } @Override @@ -288,12 +288,12 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { try { Schedule schedule = scheduleDao.findByDomainScheduleId(DomainsEnum.ChangeManagement.toString(), scheduleId); if (schedule == null) { - throw new CMSNotFoundException(DomainsEnum.ChangeManagement.toString(), scheduleId); + throw new CmsoNotFoundException(DomainsEnum.ChangeManagement.toString(), scheduleId); } deleteChangeManagement(schedule); deleteScheduleRequest(DomainsEnum.ChangeManagement.toString(), scheduleId); response = Response.noContent().build(); - } catch (CMSException e) { + } catch (CmsoException e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); @@ -315,11 +315,11 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { try { schedule = scheduleDao.findByDomainScheduleId(DomainsEnum.ChangeManagement.toString(), scheduleId); if (schedule == null) { - throw new CMSException(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, + throw new CmsoException(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, DomainsEnum.ChangeManagement.toString(), scheduleId); } response = Response.ok().entity(schedule).build(); - } catch (CMSException e) { + } catch (CmsoException e) { Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); } catch (Exception e) { @@ -342,11 +342,11 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { String domain = DomainsEnum.ChangeManagement.toString(); Schedule sch = scheduleDao.findByDomainScheduleId(domain, scheduleId); if (sch == null) { - throw new CMSNotFoundException(domain, scheduleId); + throw new CmsoNotFoundException(domain, scheduleId); } processApproveScheduleRequest(sch, approval, sch.getDomainData()); response = Response.noContent().build(); - } catch (CMSException e) { + } catch (CmsoException e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); @@ -388,7 +388,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { buildWhere(qp, where); List<ChangeManagementDetail> list = cmDetailsDao.searchScheduleDetails(where.toString(), maxRows); if (list == null || !list.iterator().hasNext()) { - throw new CMSException(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, + throw new CmsoException(Status.NOT_FOUND, LogMessages.SCHEDULE_NOT_FOUND, DomainsEnum.ChangeManagement.toString(), scheduleId); } Iterator<ChangeManagementDetail> iter = list.iterator(); @@ -399,7 +399,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { schedules.add(msg); } response = Response.ok(schedules.toArray(new CmDetailsMessage[schedules.size()])).build(); - } catch (CMSException e) { + } catch (CmsoException e) { Observation.report(LogMessages.EXPECTED_EXCEPTION, e, e.getMessage()); response = Response.status(e.getStatus()).entity(e.getRequestError()).build(); } catch (Exception e) { @@ -411,7 +411,7 @@ public class CmsoServiceImpl extends CommonServiceImpl implements CmsoService { return response; } - private void buildWhere(MultivaluedMap<String, String> qp, StringBuilder where) throws CMSException { + private void buildWhere(MultivaluedMap<String, String> qp, StringBuilder where) throws CmsoException { String delim = " where "; for (String urlName : qp.keySet()) { List<String> values = qp.get(urlName); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CommonServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CommonServiceImpl.java index 750d0a7..e4dec7c 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CommonServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/CommonServiceImpl.java @@ -39,24 +39,24 @@ import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response.Status; import org.onap.optf.cmso.common.ApprovalStatusEnum; import org.onap.optf.cmso.common.ApprovalTypesEnum; -import org.onap.optf.cmso.common.CMSStatusEnum; +import org.onap.optf.cmso.common.CmsoStatusEnum; import org.onap.optf.cmso.common.DomainsEnum; import org.onap.optf.cmso.common.LogMessages; -import org.onap.optf.cmso.common.exceptions.CMSException; -import org.onap.optf.cmso.eventq.CMSQueueJob; +import org.onap.optf.cmso.common.exceptions.CmsoException; +import org.onap.optf.cmso.eventq.CmsoQueueJob; import org.onap.optf.cmso.model.ChangeManagementChangeWindow; import org.onap.optf.cmso.model.ChangeManagementGroup; import org.onap.optf.cmso.model.ChangeManagementSchedule; import org.onap.optf.cmso.model.DomainData; import org.onap.optf.cmso.model.ElementData; import org.onap.optf.cmso.model.Schedule; -import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementDetailDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO; -import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO; -import org.onap.optf.cmso.model.dao.ElementDataDAO; -import org.onap.optf.cmso.model.dao.ScheduleDAO; -import org.onap.optf.cmso.model.dao.ScheduleQueryDAO; +import org.onap.optf.cmso.model.dao.ChangeManagementChangeWindowDao; +import org.onap.optf.cmso.model.dao.ChangeManagementDetailDao; +import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao; +import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao; +import org.onap.optf.cmso.model.dao.ElementDataDao; +import org.onap.optf.cmso.model.dao.ScheduleDao; +import org.onap.optf.cmso.model.dao.ScheduleQueryDao; import org.onap.optf.cmso.service.rs.models.ApprovalMessage; import org.onap.optf.cmso.service.rs.models.v2.ChangeWindow; import org.onap.optf.cmso.service.rs.models.v2.ElementInfo; @@ -75,31 +75,31 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); @Autowired - CMSQueueJob qqJob; + CmsoQueueJob qqJob; @Autowired Environment env; @Autowired - ChangeManagementScheduleDAO cmScheduleDao; + ChangeManagementScheduleDao cmScheduleDao; @Autowired - ChangeManagementGroupDAO cmGroupDao; + ChangeManagementGroupDao cmGroupDao; @Autowired - ChangeManagementChangeWindowDAO cmChangeWindowDao; + ChangeManagementChangeWindowDao cmChangeWindowDao; @Autowired - ChangeManagementDetailDAO cmDetailsDao; + ChangeManagementDetailDao cmDetailsDao; @Autowired - ScheduleQueryDAO scheduleQueryDao; + ScheduleQueryDao scheduleQueryDao; @Autowired - ScheduleDAO scheduleDao; + ScheduleDao scheduleDao; @Autowired - ElementDataDAO elementDataDao; + ElementDataDao elementDataDao; @Autowired TmClient tmClient; @@ -109,13 +109,13 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { protected void createSchedule(OptimizedScheduleMessage scheduleMessage, String scheduleId, - HttpServletRequest request) throws CMSException, JsonProcessingException { + HttpServletRequest request) throws CmsoException, JsonProcessingException { if (!scheduleMessage.getDomain().equals(DomainsEnum.ChangeManagement.toString())) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "domain", + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "domain", scheduleMessage.getDomain()); } if (scheduleMessage.getScheduleId() == null || !scheduleMessage.getScheduleId().equals(scheduleId)) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "schedulerId", + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "schedulerId", scheduleMessage.getScheduleId()); } // Force the name to be = to the ID because there is no way fot the provide a @@ -145,56 +145,56 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { * Returns whether this is an immediate request. */ private boolean validate(OptimizedScheduleMessage scheduleMessage, Map<String, List<ElementInfo>> groups) - throws CMSException { + throws CmsoException { SchedulingData info = scheduleMessage.getSchedulingData(); boolean immediate = true; if (info == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_PARSE_SCHEDULING_INFO); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.UNABLE_TO_PARSE_SCHEDULING_INFO); } if (info.getAdditionalDurationInSeconds() == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "additionalDurationInSeconds"); } if (info.getNormalDurationInSeconds() == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "normalDurationInSeconds"); } if (info.getAdditionalDurationInSeconds() < 0) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "additionalDurationInSeconds", + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "additionalDurationInSeconds", info.getAdditionalDurationInSeconds().toString()); } if (info.getNormalDurationInSeconds() < 1) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "normalDurationInSeconds", + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "normalDurationInSeconds", info.getNormalDurationInSeconds().toString()); } if (info.getChangeWindows() != null && info.getChangeWindows().size() > 0) { for (ChangeWindow cw : info.getChangeWindows()) { immediate = false; if (cw.getStartTime() == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "startTime"); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "startTime"); } if (cw.getEndTime() == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "endTime"); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "endTime"); } Date start = cw.getStartTime(); Date end = cw.getEndTime(); if (!end.after(start)) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_CHANGE_WINDOW, start.toString(), + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_CHANGE_WINDOW, start.toString(), end.toString()); } } if (info.getConcurrencyLimit() == null) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "concurrencyLimit"); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "concurrencyLimit"); } if (info.getConcurrencyLimit() < 1) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "concurrencyLimit", + throw new CmsoException(Status.BAD_REQUEST, LogMessages.INVALID_ATTRIBUTE, "concurrencyLimit", info.getConcurrencyLimit().toString()); } } if (info.getElements() == null || info.getElements().size() == 0) { - throw new CMSException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "elements"); + throw new CmsoException(Status.BAD_REQUEST, LogMessages.MISSING_REQUIRED_ATTRIBUTE, "elements"); } for (ElementInfo element : info.getElements()) { @@ -213,7 +213,7 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { } private void createChangeManagement(Schedule schedule, OptimizedScheduleMessage scheduleMessage, - Map<String, List<ElementInfo>> groups) throws CMSException { + Map<String, List<ElementInfo>> groups) throws CmsoException { SchedulingData schedulingInfo = scheduleMessage.getSchedulingData(); for (String groupId : groups.keySet()) { @@ -240,7 +240,7 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { cms.setUuid(UUID.randomUUID()); cms.setChangeManagementGroupUuid(cmg.getUuid()); cms.setVnfName(element.getElementId()); - cms.setStatus(CMSStatusEnum.PendingSchedule.toString()); + cms.setStatus(CmsoStatusEnum.PendingSchedule.toString()); cms.setRequest(element.getRequest().toString()); cmScheduleDao.save(cms); // Save elementData @@ -266,7 +266,7 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { } private void createChangeManagementImmediate(Schedule schedule, OptimizedScheduleMessage scheduleMessage, - Map<String, List<ElementInfo>> groups) throws CMSException, JsonProcessingException { + Map<String, List<ElementInfo>> groups) throws CmsoException, JsonProcessingException { SchedulingData schedulingInfo = scheduleMessage.getSchedulingData(); for (String groupId : groups.keySet()) { ChangeManagementGroup cmg = new ChangeManagementGroup(); @@ -286,33 +286,33 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { cms.setChangeManagementGroupUuid(cmg.getUuid()); cms.setVnfName(element.getElementId()); cms.setRequest(element.getRequest().toString()); - cms.setStatus(CMSStatusEnum.PendingApproval.toString()); + cms.setStatus(CmsoStatusEnum.PendingApproval.toString()); cmScheduleDao.save(cms); } - schedule.setStatus(CMSStatusEnum.PendingApproval.toString()); + schedule.setStatus(CmsoStatusEnum.PendingApproval.toString()); scheduleDao.save(schedule); } } - protected void deleteChangeManagement(Schedule schedule) throws CMSException { + protected void deleteChangeManagement(Schedule schedule) throws CmsoException { List<ChangeManagementGroup> cmgs = cmGroupDao.findBySchedulesId(schedule.getUuid()); for (ChangeManagementGroup cmg : cmgs) { List<ChangeManagementSchedule> schedules = cmScheduleDao.findByChangeManagementGroupId(cmg.getUuid()); for (ChangeManagementSchedule s : schedules) { - CMSStatusEnum currentState = CMSStatusEnum.Completed.fromString(s.getStatus()); + CmsoStatusEnum currentState = CmsoStatusEnum.Completed.fromString(s.getStatus()); switch (currentState) { case Scheduled: if (s.getTmChangeId() != null && !s.getTmChangeId().equals("")) { tmClient.cancelTicket(schedule, s, s.getTmChangeId()); } - s.setStatus(CMSStatusEnum.Cancelled.toString()); + s.setStatus(CmsoStatusEnum.Cancelled.toString()); break; case Triggered: // Too late... break; default: - s.setStatus(CMSStatusEnum.Deleted.toString()); + s.setStatus(CmsoStatusEnum.Deleted.toString()); } cmScheduleDao.save(s); } @@ -324,7 +324,7 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { // Marshall commonData into DB DomainData // No validation. // - private List<DomainData> marshallDomainData(OptimizedScheduleMessage scheduleMessage) throws CMSException { + private List<DomainData> marshallDomainData(OptimizedScheduleMessage scheduleMessage) throws CmsoException { List<NameValue> domainData = scheduleMessage.getCommonData(); List<DomainData> domainDataList = new ArrayList<DomainData>(); for (NameValue nameValue : domainData) { @@ -341,19 +341,19 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { protected void processApproveScheduleRequest(Schedule sch, ApprovalMessage approval, List<DomainData> domainData) - throws CMSException { + throws CmsoException { sch = scheduleDao.lockOne(sch.getUuid()); String domain = DomainsEnum.ChangeManagement.toString(); processApproval(sch, domain, approval); - if (sch.getStatus().equals(CMSStatusEnum.Accepted.toString())) { + if (sch.getStatus().equals(CmsoStatusEnum.Accepted.toString())) { openTickets(sch, domainData); } - if (sch.getStatus().equals(CMSStatusEnum.Rejected.toString())) { - updateChangeManagementSchedules(sch, CMSStatusEnum.ApprovalRejected); + if (sch.getStatus().equals(CmsoStatusEnum.Rejected.toString())) { + updateChangeManagementSchedules(sch, CmsoStatusEnum.ApprovalRejected); } } - private void openTickets(Schedule sch, List<DomainData> domainData) throws CMSException { + private void openTickets(Schedule sch, List<DomainData> domainData) throws CmsoException { debug.debug("Entered openTickets scheduleId=" + sch.getScheduleId()); Integer maxvnfsperticket = env.getProperty("tm.vnfs.per.ticket", Integer.class, 1); @@ -379,7 +379,7 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { } private void openTicketForList(Schedule schedule, ChangeManagementGroup group, List<ChangeManagementSchedule> list, - List<DomainData> domainData) throws CMSException { + List<DomainData> domainData) throws CmsoException { List<String> vnfNames = new ArrayList<>(); for (ChangeManagementSchedule cms : list) { vnfNames.add(cms.getVnfName()); @@ -396,18 +396,18 @@ public class CommonServiceImpl extends BaseSchedulerServiceImpl { cms.setTmApprovalStatus(TmApprovalStatusEnum.Approved.toString()); // cms.setStatus(CMSStatusEnum.PendingApproval.toString()); if (cms.getStartTimeMillis() == null) { - cms.setStatus(CMSStatusEnum.ScheduledImmediate.toString()); + cms.setStatus(CmsoStatusEnum.ScheduledImmediate.toString()); } else { - cms.setStatus(CMSStatusEnum.Scheduled.toString()); + cms.setStatus(CmsoStatusEnum.Scheduled.toString()); } cmScheduleDao.save(cms); } - schedule.setStatus(CMSStatusEnum.Scheduled.toString()); + schedule.setStatus(CmsoStatusEnum.Scheduled.toString()); scheduleDao.save(schedule); } - private void updateChangeManagementSchedules(Schedule sch, CMSStatusEnum approvalrejected) { + private void updateChangeManagementSchedules(Schedule sch, CmsoStatusEnum approvalrejected) { debug.debug("Entered updateChangeManagementSchedules"); List<ChangeManagementGroup> groups = cmGroupDao.findBySchedulesId(sch.getUuid()); for (ChangeManagementGroup group : groups) { diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java index 79094d3..c6728fd 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java @@ -37,7 +37,7 @@ import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
-import org.onap.optf.cmso.model.dao.ApprovalTypeDAO;
+import org.onap.optf.cmso.model.dao.ApprovalTypeDao;
import org.onap.optf.cmso.optimizer.CmsoOptimizerClient;
import org.onap.optf.cmso.service.rs.models.HealthCheckComponent;
import org.onap.optf.cmso.service.rs.models.HealthCheckMessage;
@@ -69,7 +69,7 @@ public class HealthCheckImpl implements HealthCheck { CmsoOptimizerClient optimizerClient;
@Autowired
- ApprovalTypeDAO approvalTypeDao;
+ ApprovalTypeDao approvalTypeDao;
@Autowired
Environment env;
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSInfo.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSInfo.java deleted file mode 100644 index d39798f..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSInfo.java +++ /dev/null @@ -1,121 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.onap.optf.cmso.service.rs.models;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * The persistent class for the approval_types database table.
- *
- */
-@ApiModel(value = "Change Management Scheduling Info", description = "Details of schedule being requested")
-public class CMSInfo implements Serializable {
- private static EELFLogger log = EELFManager.getInstance().getLogger(CMSInfo.class);
-
- private static final long serialVersionUID = 1L;
-
- @ApiModelProperty(value = "Expected duration (in seconds) of a successful execution of a single VNF change.")
- private Integer normalDurationInSeconds;
-
- @ApiModelProperty(
- value = "Additional duration (in seconds) to be added to support backout of an unsuccessful VNF change.")
- private Integer additionalDurationInSeconds;
-
- @ApiModelProperty(value = "Maximum number of VNF changes to schedule concurrently")
- private Integer concurrencyLimit;
-
- @ApiModelProperty(
- value = "Name of schedule optimization policy used by the"
- + " change management cmso optimizer to determine available time slot")
- private String policyId;
-
- @ApiModelProperty(value = "Lists of the VNFs to be changed and the desired change windows")
- private List<VnfDetailsMessage> vnfDetails;
-
- @Override
- public String toString() {
- ObjectMapper mapper = new ObjectMapper();
- try {
- return mapper.writeValueAsString(this);
- } catch (JsonProcessingException e) {
- log.debug("Error in toString()", e);
- }
- return "";
- }
-
- public Integer getNormalDurationInSeconds() {
- return normalDurationInSeconds;
- }
-
- public void setNormalDurationInSeconds(Integer normalDurationInSeconds) {
- this.normalDurationInSeconds = normalDurationInSeconds;
- }
-
- public Integer getAdditionalDurationInSeconds() {
- return additionalDurationInSeconds;
- }
-
- public void setAdditionalDurationInSeconds(Integer additionalDurationInSeconds) {
- this.additionalDurationInSeconds = additionalDurationInSeconds;
- }
-
- public Integer getConcurrencyLimit() {
- return concurrencyLimit;
- }
-
- public void setConcurrencyLimit(Integer concurrencyLimit) {
- this.concurrencyLimit = concurrencyLimit;
- }
-
- public String getPolicyId() {
- return policyId;
- }
-
- public void setPolicyId(String policyId) {
- this.policyId = policyId;
- }
-
- public List<VnfDetailsMessage> getVnfDetails() {
- return vnfDetails;
- }
-
- public void setVnfDetails(List<VnfDetailsMessage> vnfDetails) {
- this.vnfDetails = vnfDetails;
- }
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSMessage.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSMessage.java deleted file mode 100644 index 9e236e2..0000000 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/models/CMSMessage.java +++ /dev/null @@ -1,73 +0,0 @@ -/*
- * Copyright © 2017-2018 AT&T Intellectual Property.
- * Modifications Copyright © 2018 IBM.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- * Unless otherwise specified, all documentation contained herein is licensed
- * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
- * you may not use this documentation except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://creativecommons.org/licenses/by/4.0/
- *
- * Unless required by applicable law or agreed to in writing, documentation
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.onap.optf.cmso.service.rs.models;
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import io.swagger.annotations.ApiModel;
-import java.io.Serializable;
-import org.onap.optf.cmso.common.LogMessages;
-
-/**
- * The persistent class for the approval_types database table.
- *
- */
-@ApiModel
-public class CMSMessage extends ScheduleMessage implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private static EELFLogger errors = EELFManager.getInstance().getErrorLogger();
- private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
-
- private CMSInfo schedulingInfo;
-
- @Override
- public CMSInfo getSchedulingInfo() {
- // TODO Auto-generated method stub
- return schedulingInfo;
- }
-
- @Override
- public void setSchedulingInfo(Object info) {
- ObjectMapper mapper = new ObjectMapper();
- try {
- String jsonString = mapper.writeValueAsString(info);
- schedulingInfo = mapper.readValue(jsonString, CMSInfo.class);
- } catch (Exception e) {
- debug.debug(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- errors.error(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- }
-
- }
-
-}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java index e760b85..a5960f5 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java @@ -44,14 +44,14 @@ import javax.ws.rs.core.Response; import org.onap.observations.Mdc;
import org.onap.observations.Observation;
import org.onap.optf.cmso.common.BasicAuthenticatorFilter;
-import org.onap.optf.cmso.common.CMSStatusEnum;
+import org.onap.optf.cmso.common.CmsoStatusEnum;
import org.onap.optf.cmso.common.LogMessages;
import org.onap.optf.cmso.common.PropertiesManagement;
import org.onap.optf.cmso.filters.CmsoClientFilters;
import org.onap.optf.cmso.model.ChangeManagementSchedule;
-import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
-import org.onap.optf.cmso.model.dao.ScheduleDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao;
+import org.onap.optf.cmso.model.dao.ScheduleDao;
import org.onap.optf.cmso.service.rs.models.HealthCheckComponent;
import org.onap.optf.cmso.so.bean.MsoOrchestrationQueryResponse;
import org.onap.optf.cmso.so.bean.MsoOrchestrationQueryResponse.MsoStatus;
@@ -66,13 +66,13 @@ public class MsoStatusClient { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
@Autowired
- ChangeManagementScheduleDAO cmScheduleDao;
+ ChangeManagementScheduleDao cmScheduleDao;
@Autowired
- ChangeManagementGroupDAO cmGroupdao;
+ ChangeManagementGroupDao cmGroupdao;
@Autowired
- ScheduleDAO scheduleDao;
+ ScheduleDao scheduleDao;
@Autowired
Environment env;
@@ -146,18 +146,18 @@ public class MsoStatusClient { switch (msoStatus) {
case COMPLETE:
cmSchedule.setExecutionCompletedTimeMillis(finishTime);
- cmSchedule.setStatus(CMSStatusEnum.Completed.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.Completed.toString());
break;
case FAILED:
cmSchedule.setExecutionCompletedTimeMillis(finishTime);
- cmSchedule.setStatus(CMSStatusEnum.Failed.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.Failed.toString());
break;
case UNKNOWN:
default:
}
} else {
// Do not keep polling...
- cmSchedule.setStatus(CMSStatusEnum.Error.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.Error.toString());
cmSchedule.setMsoStatus("Bad Response");
cmSchedule.setMsoMessage("Unable to parse :" + respString);
@@ -167,21 +167,21 @@ public class MsoStatusClient { break;
case 404: { // Not found
// Do not keep polling...
- cmSchedule.setStatus(CMSStatusEnum.Failed.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.Failed.toString());
cmSchedule.setMsoStatus("Not found");
cmSchedule.setMsoMessage("Call to MSO Failed :" + response.toString());
}
break;
case 400: { // Bad request
// Do not keep polling...
- cmSchedule.setStatus(CMSStatusEnum.Error.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.Error.toString());
cmSchedule.setMsoStatus("Bad Request");
cmSchedule.setMsoMessage("Call to MSO Failed :" + response.toString());
}
break;
case 500:
default: {
- cmSchedule.setStatus(CMSStatusEnum.Error.toString());
+ cmSchedule.setStatus(CmsoStatusEnum.Error.toString());
cmSchedule.setMsoStatus("Failed");
cmSchedule.setMsoMessage("Call to MSO Failed :" + response.toString());
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java index 0a4c2f2..bfb7bb6 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusJob.java @@ -32,7 +32,7 @@ import java.util.UUID; import org.onap.observations.Mdc;
import org.onap.optf.cmso.common.LogMessages;
import org.onap.optf.cmso.model.ChangeManagementSchedule;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
@@ -57,7 +57,7 @@ public class MsoStatusJob implements Job { MsoStatusClient mso;
@Autowired
- ChangeManagementScheduleDAO cmScheduleDao;
+ ChangeManagementScheduleDao cmScheduleDao;
@Autowired
Environment env;
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java index 9eacfd1..3de62e0 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/ScheduleStatusJob.java @@ -51,8 +51,8 @@ import org.onap.optf.cmso.common.PropertiesManagement; import org.onap.optf.cmso.filters.CmsoClientFilters;
import org.onap.optf.cmso.model.ChangeManagementSchedule;
import org.onap.optf.cmso.model.Schedule;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
-import org.onap.optf.cmso.model.dao.ScheduleDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao;
+import org.onap.optf.cmso.model.dao.ScheduleDao;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
@@ -73,10 +73,10 @@ public class ScheduleStatusJob implements Job { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger();
@Autowired
- ScheduleDAO scheduleDao;
+ ScheduleDao scheduleDao;
@Autowired
- ChangeManagementScheduleDAO cmScheduleDao;
+ ChangeManagementScheduleDao cmScheduleDao;
@Autowired
PropertiesManagement pm;
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmClient.java index c8cae12..1864da7 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmClient.java @@ -56,13 +56,13 @@ import org.onap.optf.cmso.common.BasicAuthenticatorFilter; import org.onap.optf.cmso.common.CmHelpers;
import org.onap.optf.cmso.common.LogMessages;
import org.onap.optf.cmso.common.PropertiesManagement;
-import org.onap.optf.cmso.common.exceptions.CMSException;
+import org.onap.optf.cmso.common.exceptions.CmsoException;
import org.onap.optf.cmso.filters.CmsoClientFilters;
import org.onap.optf.cmso.model.ChangeManagementGroup;
import org.onap.optf.cmso.model.ChangeManagementSchedule;
import org.onap.optf.cmso.model.DomainData;
import org.onap.optf.cmso.model.Schedule;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao;
import org.onap.optf.cmso.service.rs.models.CmDomainDataEnum;
import org.onap.optf.cmso.service.rs.models.HealthCheckComponent;
import org.onap.optf.cmso.ticketmgt.TmEndpoints.Endpoint;
@@ -89,7 +89,7 @@ public class TmClient { PropertiesManagement pm;
@Autowired
- ChangeManagementScheduleDAO cmScheduleDao;
+ ChangeManagementScheduleDao cmScheduleDao;
@Autowired
BuildCreateRequest buildCreateRequest;
@@ -105,10 +105,10 @@ public class TmClient { * @param vnfNames the vnf names
* @param domainData the domain data
* @return the string
- * @throws CMSException the CMS exception
+ * @throws CmsoException the CMS exception
*/
public String createChangeTicket(Schedule schedule, ChangeManagementGroup group, List<String> vnfNames,
- List<DomainData> domainData) throws CMSException {
+ List<DomainData> domainData) throws CmsoException {
String changeId = "";
String workflowName = CmHelpers.getDomainData(domainData, CmDomainDataEnum.WorkflowName);
@@ -129,10 +129,10 @@ public class TmClient { * @param changeId the change id
* @param closureCode the closure code
* @param closingComments the closing comments
- * @throws CMSException the CMS exception
+ * @throws CmsoException the CMS exception
*/
public void closeTicket(Schedule schedule, ChangeManagementGroup group, List<ChangeManagementSchedule> cmSchedules,
- String changeId, ClosureCode closureCode, String closingComments) throws CMSException {
+ String changeId, ClosureCode closureCode, String closingComments) throws CmsoException {
Map<String, Object> variables =
getCloseVariables(schedule, group, cmSchedules, changeId, closureCode, closingComments);
JsonNode closeChangeRecord = buildCreateRequest.createCloseCancelChangeRecord(variables);
@@ -146,9 +146,9 @@ public class TmClient { * @param schedule the schedule
* @param cms the cms
* @param changeId the change id
- * @throws CMSException the CMS exception
+ * @throws CmsoException the CMS exception
*/
- public void cancelTicket(Schedule schedule, ChangeManagementSchedule cms, String changeId) throws CMSException {
+ public void cancelTicket(Schedule schedule, ChangeManagementSchedule cms, String changeId) throws CmsoException {
Map<String, Object> variables = getCancelVariables(schedule, changeId);
JsonNode cancelChangeRecord = buildCreateRequest.createCancelChangeRecord(variables);
debug.debug("cancelChangeRecord=" + cancelChangeRecord.toString());
@@ -161,9 +161,9 @@ public class TmClient { * @param schedule the schedule
* @param cms the cms
* @param changeId the change id
- * @throws CMSException the CMS exception
+ * @throws CmsoException the CMS exception
*/
- public void updateTicket(Schedule schedule, ChangeManagementSchedule cms, String changeId) throws CMSException {
+ public void updateTicket(Schedule schedule, ChangeManagementSchedule cms, String changeId) throws CmsoException {
Map<String, Object> variables = getUpdateVariables(schedule, changeId);
JsonNode updateChangeRecord = buildCreateRequest.createUpdateChangeRecord(variables);
debug.debug("updateChangeRecord=" + updateChangeRecord.toString());
@@ -269,7 +269,7 @@ public class TmClient { }
private void postCloseChangeTicket(JsonNode closeChangeRecord, String scheduleId, String changeId)
- throws CMSException {
+ throws CmsoException {
Map<String, String> mdcSave = Mdc.save();
try {
Response response = null;
@@ -290,7 +290,7 @@ public class TmClient { if (!isAlreadyClosed(respString)) {
Observation.report(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()),
response.toString() + " : " + respString);
- throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_CLOSE_CHANGE_TICKET,
+ throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_CLOSE_CHANGE_TICKET,
scheduleId, changeId, respString);
}
}
@@ -299,13 +299,13 @@ public class TmClient { String message = response.readEntity(String.class);
Observation.report(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()),
response.toString() + " : " + message);
- throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_CLOSE_CHANGE_TICKET,
+ throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_CLOSE_CHANGE_TICKET,
scheduleId, changeId, message);
}
}
} catch (ProcessingException e) {
Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_CLOSE_CHANGE_TICKET, scheduleId,
+ throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_CLOSE_CHANGE_TICKET, scheduleId,
changeId, e.toString());
} finally {
Mdc.restore(mdcSave);
@@ -411,7 +411,7 @@ public class TmClient { }
- private String postCreateChangeTicket(JsonNode createChangeRecord, String scheduleId) throws CMSException {
+ private String postCreateChangeTicket(JsonNode createChangeRecord, String scheduleId) throws CmsoException {
String changeId = null;
Map<String, String> mdcSave = Mdc.save();
try {
@@ -435,7 +435,7 @@ public class TmClient { } else {
Observation.report(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()),
response.toString() + " : " + "Response is empty");
- throw new CMSException(Status.EXPECTATION_FAILED, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET,
+ throw new CmsoException(Status.EXPECTATION_FAILED, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET,
scheduleId, "Response is empty");
}
}
@@ -444,13 +444,13 @@ public class TmClient { String message = response.readEntity(String.class);
Observation.report(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()),
response.toString() + " : " + message);
- throw new CMSException(Status.EXPECTATION_FAILED, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET,
+ throw new CmsoException(Status.EXPECTATION_FAILED, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET,
scheduleId, message);
}
}
} catch (ProcessingException e) {
Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- throw new CMSException(Status.EXPECTATION_FAILED, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId,
+ throw new CmsoException(Status.EXPECTATION_FAILED, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET, scheduleId,
e.toString());
} finally {
Mdc.restore(mdcSave);
@@ -459,7 +459,7 @@ public class TmClient { }
private String postUpdateChangeTicket(JsonNode updateChangeRecord, String scheduleId, String changeId)
- throws CMSException {
+ throws CmsoException {
Map<String, String> mdcSave = Mdc.save();
try {
String url = env.getProperty("vtm.url") + env.getProperty("vtm.updatePath");
@@ -480,13 +480,13 @@ public class TmClient { String message = response.readEntity(String.class);
Observation.report(LogMessages.UNEXPECTED_RESPONSE, "vTM", String.valueOf(response.getStatus()),
response.toString() + " : " + message);
- throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_UPDATE_CHANGE_TICKET,
+ throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_UPDATE_CHANGE_TICKET,
scheduleId, changeId, message);
}
}
} catch (ProcessingException e) {
Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.getMessage());
- throw new CMSException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_UPDATE_CHANGE_TICKET, scheduleId,
+ throw new CmsoException(Status.PRECONDITION_FAILED, LogMessages.UNABLE_TO_UPDATE_CHANGE_TICKET, scheduleId,
changeId, e.toString());
} finally {
Mdc.restore(mdcSave);
@@ -495,7 +495,7 @@ public class TmClient { }
- private Response tmPost(Endpoint ep, Object request, String scheduleId) throws CMSException {
+ private Response tmPost(Endpoint ep, Object request, String scheduleId) throws CmsoException {
Response response = null;
List<String> endpoints = new ArrayList<>();
String url = tmEndpoints.getEndpoint(ep, endpoints);
@@ -525,12 +525,12 @@ public class TmClient { Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.toString());
url = tmEndpoints.getNextEndpoint(ep, endpoints);
if (url == null || !tryNextUrl(e)) {
- throw new CMSException(Status.INTERNAL_SERVER_ERROR, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET,
+ throw new CmsoException(Status.INTERNAL_SERVER_ERROR, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET,
scheduleId, e.getMessage());
}
} catch (Exception e) {
Observation.report(LogMessages.UNEXPECTED_EXCEPTION, e, e.toString());
- throw new CMSException(Status.INTERNAL_SERVER_ERROR, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET,
+ throw new CmsoException(Status.INTERNAL_SERVER_ERROR, LogMessages.UNABLE_TO_CREATE_CHANGE_TICKET,
scheduleId, e.getMessage());
}
}
diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java index a7ae5ed..4ace561 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/ticketmgt/TmStatusClient.java @@ -37,15 +37,15 @@ import java.util.Map; import java.util.Set;
import java.util.UUID;
import javax.transaction.Transactional;
-import org.onap.optf.cmso.common.CMSStatusEnum;
+import org.onap.optf.cmso.common.CmsoStatusEnum;
import org.onap.optf.cmso.common.LogMessages;
-import org.onap.optf.cmso.common.exceptions.CMSException;
+import org.onap.optf.cmso.common.exceptions.CmsoException;
import org.onap.optf.cmso.model.ChangeManagementGroup;
import org.onap.optf.cmso.model.ChangeManagementSchedule;
import org.onap.optf.cmso.model.Schedule;
-import org.onap.optf.cmso.model.dao.ChangeManagementGroupDAO;
-import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDAO;
-import org.onap.optf.cmso.model.dao.ScheduleDAO;
+import org.onap.optf.cmso.model.dao.ChangeManagementGroupDao;
+import org.onap.optf.cmso.model.dao.ChangeManagementScheduleDao;
+import org.onap.optf.cmso.model.dao.ScheduleDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
@@ -80,13 +80,13 @@ public class TmStatusClient { Environment env;
@Autowired
- ScheduleDAO scheduleDao;
+ ScheduleDao scheduleDao;
@Autowired
- ChangeManagementScheduleDAO cmScheduleDao;
+ ChangeManagementScheduleDao cmScheduleDao;
@Autowired
- ChangeManagementGroupDAO cmGroupDao;
+ ChangeManagementGroupDao cmGroupDao;
@Autowired
TmClient tmClient;
@@ -103,8 +103,8 @@ public class TmStatusClient { // Multiple cmso instance support - re-get the record with a Schedule lock
UUID uuid = UUID.fromString(id);
Schedule sch = scheduleDao.lockOne(uuid);
- if (!sch.getStatus().equals(CMSStatusEnum.NotificationsInitiated.toString())) {
- debug.debug(sch.getScheduleId() + " is no longer in " + CMSStatusEnum.NotificationsInitiated.toString()
+ if (!sch.getStatus().equals(CmsoStatusEnum.NotificationsInitiated.toString())) {
+ debug.debug(sch.getScheduleId() + " is no longer in " + CmsoStatusEnum.NotificationsInitiated.toString()
+ " : it is " + sch.getStatus());
// Attempt at avoiding race condition in a load balance env. ?
return;
@@ -135,10 +135,10 @@ public class TmStatusClient { }
//
if (groupStatus.containsKey(GroupAuditStatus.CompletedWithErrors)) {
- sch.setStatus(CMSStatusEnum.CompletedWithError.toString());
+ sch.setStatus(CmsoStatusEnum.CompletedWithError.toString());
}
if (groupStatus.containsKey(GroupAuditStatus.Completed)) {
- sch.setStatus(CMSStatusEnum.Completed.toString());
+ sch.setStatus(CmsoStatusEnum.Completed.toString());
}
scheduleDao.save(sch);
} catch (Exception e) {
@@ -149,7 +149,7 @@ public class TmStatusClient { }
}
- private void processGroup(Schedule sch, ChangeManagementGroup group) throws CMSException {
+ private void processGroup(Schedule sch, ChangeManagementGroup group) throws CmsoException {
debug.debug("{Processing status of " + sch.getScheduleId() + " group=" + group.getGroupId());
// Get status of all VNFs within a ticket within the group (Tickets will not
// span groups)
@@ -161,7 +161,7 @@ public class TmStatusClient { for (ChangeManagementSchedule cmSchedule : cmSchedules) {
String status = cmSchedule.getStatus();
String tmStatus = cmSchedule.getTmStatus();
- CMSStatusEnum cmsStatus = CMSStatusEnum.Completed.fromString(status);
+ CmsoStatusEnum cmsStatus = CmsoStatusEnum.Completed.fromString(status);
switch (cmsStatus) {
case Scheduled:
case Triggered:
@@ -241,7 +241,7 @@ public class TmStatusClient { allNames.add(vnfName);
String status = cmSchedule.getStatus();
String tmStatus = cmSchedule.getTmStatus();
- CMSStatusEnum cmsStatus = CMSStatusEnum.Completed.fromString(status);
+ CmsoStatusEnum cmsStatus = CmsoStatusEnum.Completed.fromString(status);
switch (cmsStatus) {
case Scheduled:
case Triggered:
@@ -307,7 +307,7 @@ public class TmStatusClient { private void closeTheTicket(Schedule sch, ChangeManagementGroup group, String changeId,
List<ChangeManagementSchedule> list, ClosureCode closureCode, String closingComments)
- throws CMSException {
+ throws CmsoException {
debug.debug("Closing ticket " + changeId + ":" + closureCode);
try {
tmClient.closeTicket(sch, group, list, changeId, closureCode, closingComments);
@@ -315,7 +315,7 @@ public class TmStatusClient { cms.setTmStatus("Closed");
cmScheduleDao.save(cms);
}
- } catch (CMSException e) {
+ } catch (CmsoException e) {
throw e;
}
diff --git a/cmso-ticketmgt/src/main/java/org/onap/observations/Mdc.java b/cmso-ticketmgt/src/main/java/org/onap/observations/Mdc.java index 32aa60c..41fd3df 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/observations/Mdc.java +++ b/cmso-ticketmgt/src/main/java/org/onap/observations/Mdc.java @@ -1,32 +1,33 @@ /* * Copyright © 2019 AT&T Intellectual Property. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ + package org.onap.observations; import static com.att.eelf.configuration.Configuration.MDC_BEGIN_TIMESTAMP; @@ -39,6 +40,7 @@ import static com.att.eelf.configuration.Configuration.MDC_RESPONSE_DESC; import static com.att.eelf.configuration.Configuration.MDC_STATUS_CODE; import static com.att.eelf.configuration.Configuration.MDC_TARGET_ENTITY; import static com.att.eelf.configuration.Configuration.MDC_TARGET_SERVICE_NAME; + import com.att.eelf.utils.Stopwatch; import java.net.URI; import java.util.Date; @@ -58,8 +60,13 @@ import org.slf4j.MDC; * EELF logging MDC fields not defined in the MDC Configuration (i.e. MDC_ALERT_SEVERITY) **/ public class Mdc { + + /** The Constant SERVICE_NAME. */ public static final String SERVICE_NAME = "CSS-Scheduler"; + /** + * The Enum Enum. + */ public enum Enum { // BeginTimestamp, // EndTimeStamp, @@ -92,54 +99,105 @@ public class Mdc { Timer, } + /** + * Gets the caller. + * + * @param back the back + * @return the caller + */ public static String getCaller(int back) { StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace(); return stackTraceElements[back].getClassName() + "." + stackTraceElements[back].getMethodName(); } + /** + * Sets the caller. + * + * @param back the new caller + */ public static void setCaller(int back) { String caller = MDC.get(Enum.ClassName.name()); - if (caller == null) + if (caller == null) { MDC.put(Enum.ClassName.name(), getCaller(back)); + } } - public static void setObservation(ObservationInterface o) { - MDC.put(Enum.CustomField4.name(), o.name()); + /** + * Sets the observation. + * + * @param obs the new observation + */ + public static void setObservation(ObservationInterface obs) { + MDC.put(Enum.CustomField4.name(), obs.name()); } + /** + * Clear caller. + */ public static void clearCaller() { MDC.remove(Enum.ClassName.name()); } + /** + * Save. + * + * @return the map + */ public static Map<String, String> save() { Map<String, String> save = MDC.getCopyOfContextMap(); return save; } + /** + * Restore. + * + * @param mdcSave the mdc save + */ public static void restore(Map<String, String> mdcSave) { MDC.clear(); - for (String name : mdcSave.keySet()) + for (String name : mdcSave.keySet()) { MDC.put(name, mdcSave.get(name)); + } } + /** + * Sets the request id if not set. + * + * @param requestId the new request id if not set + */ public static void setRequestIdIfNotSet(String requestId) { if (MDC.get(MDC_KEY_REQUEST_ID) == null || MDC.get(MDC_KEY_REQUEST_ID).equals("")) { setRequestId(requestId); } } + /** + * Sets the request id. + * + * @param requestId the new request id + */ public static void setRequestId(String requestId) { MDC.put(MDC_KEY_REQUEST_ID, requestId); } + /** + * Metric start. + * + * @param requestContext the request context + */ public static void metricStart(ClientRequestContext requestContext) { MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(new Date())); MDC.put(MDC_END_TIMESTAMP, MDC.get(MDC_BEGIN_TIMESTAMP)); setPartnerTargetFromUri(requestContext.getUri()); } + /** + * Metric end. + * + * @param response the response + */ public static void metricEnd(ClientResponseContext response) { Date now = new Date(); @@ -149,13 +207,19 @@ public class Mdc { } + /** + * Audit start. + * + * @param requestContext the request context + * @param servletRequest the servlet request + */ public static void auditStart(ContainerRequestContext requestContext, HttpServletRequest servletRequest) { MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(new Date())); MDC.put(MDC_END_TIMESTAMP, MDC.get(MDC_BEGIN_TIMESTAMP)); MDC.put(MDC_REMOTE_HOST, servletRequest.getRemoteHost()); MDC.put(Enum.ClassName.name(), getCaller(4)); MultivaluedMap<String, String> headers = requestContext.getHeaders(); - String transactionId = (String) headers.getFirst(HeadersEnum.TransactionID.toString()); + String transactionId = headers.getFirst(HeadersEnum.TransactionID.toString()); if (transactionId != null) { setRequestId(transactionId); } else { @@ -164,6 +228,12 @@ public class Mdc { } + /** + * Audit end. + * + * @param requestContext the request context + * @param response the response + */ public static void auditEnd(ContainerRequestContext requestContext, ContainerResponseContext response) { Date now = new Date(); // MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(now)); @@ -185,10 +255,15 @@ public class Mdc { MDC.put(MDC_STATUS_CODE, completed); } - public static void setEvent(String requestID) { + /** + * Sets the event. + * + * @param requestId the new event + */ + public static void setEvent(String requestId) { MDC.put(MDC_BEGIN_TIMESTAMP, Stopwatch.isoFormatter.format(new Date())); MDC.put(MDC_END_TIMESTAMP, MDC.get(MDC_BEGIN_TIMESTAMP)); - setRequestId(requestID); + setRequestId(requestId); } private static void setPartnerTargetFromUri(URI uri) { diff --git a/cmso-ticketmgt/src/main/java/org/onap/observations/MessageHeaders.java b/cmso-ticketmgt/src/main/java/org/onap/observations/MessageHeaders.java index c936444..e968728 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/observations/MessageHeaders.java +++ b/cmso-ticketmgt/src/main/java/org/onap/observations/MessageHeaders.java @@ -35,7 +35,14 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +/** + * The Class MessageHeaders. + */ public class MessageHeaders { + + /** + * The Enum HeadersEnum. + */ public enum HeadersEnum { UNDEFINED("UNDEFINED"), TransactionID("X-TransactionId"), @@ -50,51 +57,98 @@ public class MessageHeaders { this.text = text; } + /** + * To string. + * + * @return the string + */ @Override public String toString() { return text; } } - public static final Map<String, String> supportedMajorVersions = new HashMap<String, String>(); + /** The Constant supportedMajorVersions. */ + private static final Map<String, String> supportedMajorVersions = new HashMap<String, String>(); + static { supportedMajorVersions.put("v1", "0"); supportedMajorVersions.put("v2", "0"); } - public static final Set<String> supportedMajorMinorVersions = new HashSet<String>(); + + /** The Constant supportedMajorMinorVersions. */ + private static final Set<String> supportedMajorMinorVersions = new HashSet<String>(); + static { supportedMajorMinorVersions.add("v1.0"); supportedMajorMinorVersions.add("v2.0"); } - public static final String latestVersion = "2.0.0"; - public static final String patchVersion = "0"; + /** The Constant latestVersion. */ + private static final String latestVersion = "2.0.0"; + + /** The Constant patchVersion. */ + private static final String patchVersion = "0"; + + /** + * From string. + * + * @param text the text + * @return the headers enum + */ public static HeadersEnum fromString(String text) { - for (HeadersEnum e : HeadersEnum.values()) - if (e.text.equals(text)) + for (HeadersEnum e : HeadersEnum.values()) { + if (e.text.equals(text)) { return e; + } + } return HeadersEnum.UNDEFINED; } + /** + * Gets the patch version. + * + * @return the patch version + */ public static String getPatchVersion() { return patchVersion; } + /** + * Gets the latest version. + * + * @return the latest version + */ public static String getLatestVersion() { return latestVersion; } + /** + * Validate major version. + * + * @param major the major + * @return true, if successful + */ public static boolean validateMajorVersion(String major) { String majorKey = major.toLowerCase(); - if (!supportedMajorVersions.containsKey(majorKey)) + if (!supportedMajorVersions.containsKey(majorKey)) { return false; + } return true; } + /** + * Validate major minor version. + * + * @param major the major + * @param minor the minor + * @return true, if successful + */ public static boolean validateMajorMinorVersion(String major, String minor) { String majorKey = major.toLowerCase(); - if (!supportedMajorVersions.containsKey(majorKey)) + if (!supportedMajorVersions.containsKey(majorKey)) { return false; + } if (minor != null) { String majorMinorKey = majorKey + "." + minor; @@ -102,4 +156,20 @@ public class MessageHeaders { } return true; } + + public static Map<String, String> getSupportedmajorversions() { + return supportedMajorVersions; + } + + public static Set<String> getSupportedmajorminorversions() { + return supportedMajorMinorVersions; + } + + public static String getLatestversion() { + return latestVersion; + } + + public static String getPatchversion() { + return patchVersion; + } } diff --git a/cmso-ticketmgt/src/main/java/org/onap/observations/Observation.java b/cmso-ticketmgt/src/main/java/org/onap/observations/Observation.java index 83b8f8d..8d053bf 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/observations/Observation.java +++ b/cmso-ticketmgt/src/main/java/org/onap/observations/Observation.java @@ -1,32 +1,33 @@ /* * Copyright © 2019 AT&T Intellectual Property. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ + package org.onap.observations; import com.att.eelf.configuration.EELFLogger; @@ -41,73 +42,86 @@ public class Observation { private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); + /** + * Report. + * + * @param obs the obs + * @param exc the exc + * @param arguments the arguments + */ // ************************************************************************************************* - public static void report(ObservationInterface o, Exception e, String... arguments) { + public static void report(ObservationInterface obs, Exception exc, String... arguments) { Mdc.setCaller(4); - Mdc.setObservation(o); - if (o.getAudit()) { - audit.info(o, e, arguments); + Mdc.setObservation(obs); + if (obs.getAudit()) { + audit.info(obs, exc, arguments); } - if (o.getMetric()) { - metrics.info(o, e, arguments); + if (obs.getMetric()) { + metrics.info(obs, exc, arguments); } - Level l = o.getLevel(); - switch (l.toInt()) { + Level lev = obs.getLevel(); + switch (lev.toInt()) { case Level.WARN_INT: - errors.warn(o, arguments); - debug.debug(o, e, arguments); + errors.warn(obs, arguments); + debug.debug(obs, exc, arguments); break; case Level.INFO_INT: - log.info(o, e, arguments); - debug.debug(o, e, arguments); + log.info(obs, exc, arguments); + debug.debug(obs, exc, arguments); break; case Level.ERROR_INT: - errors.error(o, arguments); - debug.debug(o, e, arguments); + errors.error(obs, arguments); + debug.debug(obs, exc, arguments); break; case Level.TRACE_INT: - debug.trace(o, e, arguments); + debug.trace(obs, exc, arguments); break; case Level.DEBUG_INT: - debug.debug(o, e, arguments); + debug.debug(obs, exc, arguments); break; default: - log.info(o, e, arguments); + log.info(obs, exc, arguments); } Mdc.clearCaller(); } - public static void report(ObservationInterface o, String... arguments) { + /** + * Report. + * + * @param obs the obs + * @param arguments the arguments + */ + public static void report(ObservationInterface obs, String... arguments) { Mdc.setCaller(4); - Mdc.setObservation(o); - if (o.getAudit()) { - audit.info(o, arguments); + Mdc.setObservation(obs); + if (obs.getAudit()) { + audit.info(obs, arguments); } - if (o.getMetric()) { - metrics.info(o, arguments); + if (obs.getMetric()) { + metrics.info(obs, arguments); } - Level l = o.getLevel(); - switch (l.toInt()) { + Level lev = obs.getLevel(); + switch (lev.toInt()) { case Level.WARN_INT: - errors.warn(o, arguments); - debug.debug(o, arguments); + errors.warn(obs, arguments); + debug.debug(obs, arguments); break; case Level.INFO_INT: - log.info(o, arguments); - debug.debug(o, arguments); + log.info(obs, arguments); + debug.debug(obs, arguments); break; case Level.ERROR_INT: - errors.error(o, arguments); - debug.debug(o, arguments); + errors.error(obs, arguments); + debug.debug(obs, arguments); break; case Level.TRACE_INT: - debug.debug(o, arguments); + debug.debug(obs, arguments); break; case Level.DEBUG_INT: - debug.debug(o, arguments); + debug.debug(obs, arguments); break; default: - log.info(o, arguments); + log.info(obs, arguments); } Mdc.clearCaller(); } diff --git a/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationInterface.java b/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationInterface.java index 7a16a3f..ebe657a 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationInterface.java +++ b/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationInterface.java @@ -1,32 +1,33 @@ /* * Copyright © 2019 AT&T Intellectual Property. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ + package org.onap.observations; import com.att.eelf.i18n.EELFResolvableErrorEnum; diff --git a/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationObject.java b/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationObject.java index f41c134..8544047 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationObject.java +++ b/cmso-ticketmgt/src/main/java/org/onap/observations/ObservationObject.java @@ -1,32 +1,33 @@ /* * Copyright © 2019 AT&T Intellectual Property. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ + package org.onap.observations; import com.att.eelf.i18n.EELFResolvableErrorEnum; @@ -44,24 +45,30 @@ public class ObservationObject implements ObservationInterface { // // private Enum<?> value = null; - private Level level = null;; + private Level level = null; private String message = null; private Status status = null; private String domain = null; private Boolean metric = false; private Boolean audit = false; - public ObservationObject(ObservationInterface o) { - this.value = o.getValue(); - this.level = o.getLevel(); - this.message = o.getMessage(); - this.status = o.getStatus(); - this.domain = o.getDomain(); - this.metric = o.getMetric(); - this.audit = o.getAudit(); + /** + * Instantiates a new observation object. + * + * @param obs the o + */ + public ObservationObject(ObservationInterface obs) { + this.value = obs.getValue(); + this.level = obs.getLevel(); + this.message = obs.getMessage(); + this.status = obs.getStatus(); + this.domain = obs.getDomain(); + this.metric = obs.getMetric(); + this.audit = obs.getAudit(); } + @Override public Enum<?> getValue() { return value; } @@ -71,6 +78,11 @@ public class ObservationObject implements ObservationInterface { return message; } + public String getMessage(String... arguments) { + return EELFResourceManager.format((EELFResolvableErrorEnum) value, arguments); + } + + @Override public Status getStatus() { return status; @@ -101,10 +113,6 @@ public class ObservationObject implements ObservationInterface { return metric; } - public String getMessage(String... arguments) { - return EELFResourceManager.format((EELFResolvableErrorEnum) value, arguments); - } - public void setValue(Enum<?> value) { this.value = value; } diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java index eb9ddad..2426a5c 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/CmsoEnvironmentPostProcessor.java @@ -40,7 +40,7 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MutablePropertySources; -public class CMSEnvironmentPostProcessor implements EnvironmentPostProcessor { +public class CmsoEnvironmentPostProcessor implements EnvironmentPostProcessor { // TODO tested in ONAP springboot and this is called before all of the properties files have been // loaded... // perhaps there is a post post processor? Until this works. DB password will be in the clear in the diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/BasicAuthenticatorFilter.java b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/BasicAuthenticatorFilter.java index e02a47b..6b0275e 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/BasicAuthenticatorFilter.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/BasicAuthenticatorFilter.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -46,6 +46,12 @@ public class BasicAuthenticatorFilter implements ClientRequestFilter { private final String user; private final String password; + /** + * Instantiates a new basic authenticator filter. + * + * @param user the user + * @param password the password + */ public BasicAuthenticatorFilter(String user, String password) { this.user = user; this.password = password; @@ -68,6 +74,12 @@ public class BasicAuthenticatorFilter implements ClientRequestFilter { } } + /** + * Gets the user. + * + * @param request the request + * @return the user + */ public static String getUser(HttpServletRequest request) { String user = ""; String header = request.getHeader("Authorization"); diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/CMSRequestError.java b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/CmsoRequestError.java index 4ba7d48..ba28a2d 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/CMSRequestError.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/CmsoRequestError.java @@ -36,16 +36,16 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; -public class CMSRequestError implements Serializable { +public class CmsoRequestError implements Serializable { private static final long serialVersionUID = 1L; @JsonProperty RequestError requestError; - public CMSRequestError(String messageId, String text, List<String> variables) { + public CmsoRequestError(String messageId, String text, List<String> variables) { requestError = new RequestError(messageId, text, variables); } - public CMSRequestError(String messageId, String text) { + public CmsoRequestError(String messageId, String text) { requestError = new RequestError(messageId, text, new ArrayList<String>()); } diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/PropertiesManagement.java b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/PropertiesManagement.java index 77fdb11..bcd9ca1 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/PropertiesManagement.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/PropertiesManagement.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -41,28 +41,44 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; +/** + * The Class PropertiesManagement. + */ @Component public class PropertiesManagement { private static EELFLogger debug = EELFManager.getInstance().getDebugLogger(); private static EELFLogger errors = EELFManager.getInstance().getErrorLogger(); - private final static String algorithm = "AES"; - private final static String cipherMode = "CBC"; - private final static String paddingScheme = "PKCS5Padding"; - private final static String transformation = algorithm + "/" + cipherMode + "/" + paddingScheme; + private static final String algorithm = "AES"; + private static final String cipherMode = "CBC"; + private static final String paddingScheme = "PKCS5Padding"; + private static final String transformation = algorithm + "/" + cipherMode + "/" + paddingScheme; private static final String initVector = "ONAPCMSOVECTORIV"; // 16 bytes IV @Autowired Environment env; + /** + * Gets the property. + * + * @param key the key + * @param defaultValue the default value + * @return the property + */ public String getProperty(String key, String defaultValue) { String value = env.getProperty(key, defaultValue); value = getDecryptedValue(value); return value; } + /** + * Gets the decrypted value. + * + * @param value the value + * @return the decrypted value + */ public static String getDecryptedValue(String value) { if (value.startsWith("enc:")) { String secret = getSecret(); @@ -71,6 +87,12 @@ public class PropertiesManagement { return value; } + /** + * Gets the encrypted value. + * + * @param value the value + * @return the encrypted value + */ public static String getEncryptedValue(String value) { String secret = getSecret(); value = encrypt(secret, initVector, value); diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoException.java index 0ab80a0..c80cd56 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/exceptions/CMSException.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/cmso/common/exceptions/CmsoException.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,23 +36,31 @@ import java.util.ArrayList; import java.util.List; import javax.ws.rs.core.Response.Status; import org.onap.observations.ObservationInterface; -import org.onap.optf.cmso.common.CMSRequestError; +import org.onap.optf.cmso.common.CmsoRequestError; -public class CMSException extends Exception { +public class CmsoException extends Exception { private static final long serialVersionUID = 1L; - protected CMSRequestError requestError = null; + protected CmsoRequestError requestError = null; private List<String> variables = new ArrayList<String>(); protected ObservationInterface messageCode; protected Status status; - public CMSException(Status status, ObservationInterface messageCode, String... args) { + /** + * Instantiates a new CMS exception. + * + * @param status the status + * @param messageCode the message code + * @param args the args + */ + public CmsoException(Status status, ObservationInterface messageCode, String... args) { super(EELFResourceManager.format(messageCode, args)); this.status = status; this.messageCode = messageCode; - for (String arg : args) + for (String arg : args) { variables.add(arg); - requestError = new CMSRequestError(messageCode.name(), getMessage(), variables); + } + requestError = new CmsoRequestError(messageCode.name(), getMessage(), variables); } public Status getStatus() { @@ -67,7 +75,7 @@ public class CMSException extends Exception { return variables.toArray(new String[variables.size()]); } - public CMSRequestError getRequestError() { + public CmsoRequestError getRequestError() { return requestError; } } diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/Application.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/Application.java index 7392e2b..cf0b0a8 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/Application.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/Application.java @@ -73,11 +73,11 @@ public class Application extends SpringBootServletInitializer { } public static void main(String[] args) { - initMDCData(); + initMdcData(); SpringApplication.run(Application.class, args); } - protected static void initMDCData() { + protected static void initMdcData() { MDC.clear(); try { MDC.put(Configuration.MDC_SERVER_FQDN, InetAddress.getLocalHost().getHostName()); diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/ApplicationPropertiesFiles.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/ApplicationPropertiesFiles.java index 0fd1c45..f11f737 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/ApplicationPropertiesFiles.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/ApplicationPropertiesFiles.java @@ -1,33 +1,34 @@ /* * Copyright © 2018-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ + package org.onap.optf.ticketmgt; import org.springframework.context.annotation.Configuration; diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/AuthProvider.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/AuthProvider.java index 6749b72..4a066d7 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/AuthProvider.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/AuthProvider.java @@ -1,33 +1,34 @@ /* * Copyright © 2018 AT&T Intellectual Property. * Modifications Copyright © 2019 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ + package org.onap.optf.ticketmgt; import java.util.ArrayList; diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/CMSEnvironmentPostProcessor.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/CmsoEnvironmentPostProcessor.java index d955e75..1230591 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/CMSEnvironmentPostProcessor.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/CmsoEnvironmentPostProcessor.java @@ -40,7 +40,7 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MutablePropertySources; -public class CMSEnvironmentPostProcessor implements EnvironmentPostProcessor { +public class CmsoEnvironmentPostProcessor implements EnvironmentPostProcessor { // TODO tested in ONAP springboot and this is called before all of the properties files have been // loaded... // perhaps there is a post post processor? Until this works. DB password will be in the clear in the diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/JerseyConfiguration.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/JerseyConfiguration.java index 46c99ee..1cbf19c 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/JerseyConfiguration.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/JerseyConfiguration.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,7 +44,7 @@ import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.logging.LoggingFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.servlet.ServletProperties; -import org.onap.optf.ticketmgt.filters.CMSOContainerFilters; +import org.onap.optf.ticketmgt.filters.CmsoContainerFilters; import org.onap.optf.ticketmgt.service.rs.AdminToolImpl; import org.onap.optf.ticketmgt.service.rs.AvailabilityInterfaceImpl; import org.onap.optf.ticketmgt.service.rs.HealthCheckImpl; @@ -59,6 +59,11 @@ import org.springframework.stereotype.Component; public class JerseyConfiguration extends ResourceConfig { private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName()); + /** + * Object mapper. + * + * @return the object mapper + */ @Bean @Primary public ObjectMapper objectMapper() { @@ -70,6 +75,9 @@ public class JerseyConfiguration extends ResourceConfig { return objectMapper; } + /** + * Instantiates a new jersey configuration. + */ @Autowired public JerseyConfiguration( /* LogRequestFilter lrf */ ) { register(HealthCheckImpl.class); @@ -83,9 +91,14 @@ public class JerseyConfiguration extends ResourceConfig { // TODO: Examine which logging features to enable register(new LoggingFeature(log)); - register(CMSOContainerFilters.class); + register(CmsoContainerFilters.class); } + /** + * Jersey client. + * + * @return the client + */ @Bean public Client jerseyClient() { ClientConfig client = new ClientConfig(); diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/SecurityConfig.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/SecurityConfig.java index 8abccf0..09e1c8e 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/SecurityConfig.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/SecurityConfig.java @@ -1,33 +1,34 @@ /* * Copyright © 2018 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ + package org.onap.optf.ticketmgt; import org.springframework.beans.factory.annotation.Autowired; diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/SpringProfiles.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/SpringProfiles.java index b73959d..1ca525e 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/SpringProfiles.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/SpringProfiles.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.optf.ticketmgt; public class SpringProfiles { diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafAuthorizationFilter.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafAuthorizationFilter.java index 9f1f2d1..ea044a4 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafAuthorizationFilter.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafAuthorizationFilter.java @@ -17,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.optf.ticketmgt.aaf; import java.io.IOException; @@ -25,7 +26,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.onap.observations.Observation; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; import org.onap.optf.ticketmgt.SpringProfiles; import org.onap.optf.ticketmgt.common.LogMessages; import org.springframework.beans.factory.annotation.Value; @@ -35,7 +36,7 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype.Component; /** - * AAF authorization filter + * AAF authorization filter. */ @Component @@ -49,6 +50,9 @@ public class AafAuthorizationFilter extends OrderedRequestContextFilter { @Value("${permission.instance}") String instance; + /** + * Instantiates a new aaf authorization filter. + */ public AafAuthorizationFilter() { this.setOrder(FilterPriority.AAF_AUTHORIZATION.getPriority()); @@ -65,7 +69,7 @@ public class AafAuthorizationFilter extends OrderedRequestContextFilter { if (!request.isUserInRole(permission)) { Observation.report(LogMessages.UNAUTHORIZED); ResponseFormatter.errorResponse(request, response, - new CMSException(LogMessages.UNAUTHORIZED.getStatus(), LogMessages.UNAUTHORIZED, "")); + new CmsoException(LogMessages.UNAUTHORIZED.getStatus(), LogMessages.UNAUTHORIZED, "")); } else { filterChain.doFilter(request, response); } diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafFilter.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafFilter.java index 4d6c44f..1f27fee 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafFilter.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/AafFilter.java @@ -17,8 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -package org.onap.optf.ticketmgt.aaf; +package org.onap.optf.ticketmgt.aaf; import java.io.IOException; import java.util.Properties; @@ -29,7 +29,7 @@ import javax.servlet.http.HttpServletResponse; import org.onap.aaf.cadi.PropAccess; import org.onap.aaf.cadi.filter.CadiFilter; import org.onap.observations.Observation; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; import org.onap.optf.ticketmgt.Application; import org.onap.optf.ticketmgt.SpringProfiles; import org.onap.optf.ticketmgt.common.LogMessages; @@ -38,7 +38,7 @@ import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; /** - * AAF authentication filter + * AAF authentication filter. */ @Component @@ -47,6 +47,12 @@ public class AafFilter extends OrderedRequestContextFilter { private final CadiFilter cadiFilter; + /** + * Instantiates a new aaf filter. + * + * @throws IOException Signals that an I/O exception has occurred. + * @throws ServletException the servlet exception + */ public AafFilter() throws IOException, ServletException { Properties cadiProperties = new Properties(); cadiProperties.load(Application.class.getClassLoader().getResourceAsStream("cadi.properties")); @@ -61,7 +67,7 @@ public class AafFilter extends OrderedRequestContextFilter { cadiFilter.doFilter(request, response, filterChain); if (response.getStatus() >= 400 && response.getStatus() < 500) { Observation.report(LogMessages.UNAUTHENTICATED); - ResponseFormatter.errorResponse(request, response, new CMSException( + ResponseFormatter.errorResponse(request, response, new CmsoException( LogMessages.UNAUTHENTICATED.getStatus(), LogMessages.UNAUTHENTICATED, "")); } } else { diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/FilterPriority.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/FilterPriority.java index 4b9bd9d..f1dff2c 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/FilterPriority.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/FilterPriority.java @@ -17,19 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.optf.ticketmgt.aaf; import org.springframework.core.Ordered; public enum FilterPriority { AAF_AUTHENTICATION(Ordered.HIGHEST_PRECEDENCE), AAF_AUTHORIZATION(Ordered.HIGHEST_PRECEDENCE + 1); // higher number - // = lower - // priority private final int priority; - FilterPriority(final int p) { - priority = p; + FilterPriority(final int pri) { + priority = pri; } public int getPriority() { diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/ResponseFormatter.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/ResponseFormatter.java index 16dd74e..156b3ce 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/ResponseFormatter.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/aaf/ResponseFormatter.java @@ -17,17 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.optf.ticketmgt.aaf; import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.onap.optf.cmso.common.exceptions.CMSException; +import org.onap.optf.cmso.common.exceptions.CmsoException; class ResponseFormatter { - static void errorResponse(HttpServletRequest request, HttpServletResponse response, CMSException error) + static void errorResponse(HttpServletRequest request, HttpServletResponse response, CmsoException error) throws IOException { response.setStatus(error.getStatus().getStatusCode()); response.getWriter().write(error.getRequestError().toString()); diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/Availability.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/Availability.java index c650354..0003de8 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/Availability.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/Availability.java @@ -1,33 +1,34 @@ /******************************************************************************* - * + * * Copyright © 2019 AT&T Intellectual Property. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ + package org.onap.optf.ticketmgt.common; public enum Availability { diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/LogMessages.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/LogMessages.java index be7b4c9..b007074 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/LogMessages.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/common/LogMessages.java @@ -1,27 +1,27 @@ /******************************************************************************* - * + * * Copyright © 2019 AT&T Intellectual Property. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -89,9 +89,9 @@ public enum LogMessages implements ObservationInterface { private final Boolean metric; - private LogMessages(String message, Status code, Level l) { + private LogMessages(String message, Status code, Level lev) { defaultMessage = message; - level = l; + level = lev; status = code; this.defaultId = this.name(); this.defaultResolution = "No resolution needed"; @@ -100,9 +100,9 @@ public enum LogMessages implements ObservationInterface { this.metric = false; } - private LogMessages(String message, Status code, Level l, Boolean audit, Boolean metric) { + private LogMessages(String message, Status code, Level lev, Boolean audit, Boolean metric) { defaultMessage = message; - level = l; + level = lev; status = code; this.audit = audit; this.metric = metric; @@ -111,8 +111,8 @@ public enum LogMessages implements ObservationInterface { this.defaultAction = "No action is required"; } - private LogMessages(String message, Status code, Level l, String id, String resolution, String action) { - level = l; + private LogMessages(String message, Status code, Level lev, String id, String resolution, String action) { + level = lev; status = code; defaultMessage = message; this.defaultId = id; @@ -126,6 +126,11 @@ public enum LogMessages implements ObservationInterface { EELFResourceManager.loadMessageBundle("logmessages"); } + /** + * Gen properties. + * + * @return the string + */ public String genProperties() { // Use this to regenerate properties file. The desire to change messages without updating code is // well understood, but the developer should be able to code the defaults without having to update 2 @@ -181,7 +186,12 @@ public enum LogMessages implements ObservationInterface { return metric; } - public static void main(String argv[]) { + /** + * The main method. + * + * @param argv the arguments + */ + public static void main(String[] argv) { System.out.println(LogMessages.UNEXPECTED_EXCEPTION.genProperties()); try { Files.write(Paths.get("src/main/resources/logmessages.properties"), diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CMSOClientFilters.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CmsoClientFilters.java index c013453..ac1569c 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CMSOClientFilters.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CmsoClientFilters.java @@ -32,6 +32,7 @@ package org.onap.optf.ticketmgt.filters; import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID; + import java.io.IOException; import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.client.ClientRequestFilter; @@ -48,7 +49,7 @@ import org.springframework.stereotype.Component; // @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection") @Component -public class CMSOClientFilters implements ClientRequestFilter, ClientResponseFilter { +public class CmsoClientFilters implements ClientRequestFilter, ClientResponseFilter { private static String appId = "cmso"; @@ -72,9 +73,11 @@ public class CMSOClientFilters implements ClientRequestFilter, ClientResponseFil String transactionId = (String) headers.getFirst(MessageHeaders.HeadersEnum.TransactionID.toString()); String mdcId = MDC.get(MDC_KEY_REQUEST_ID); - if (transactionId == null || transactionId.equals("")) - if (mdcId != null) + if (transactionId == null || transactionId.equals("")) { + if (mdcId != null) { headers.add(HeadersEnum.TransactionID.toString(), mdcId); + } + } headers.add(HeadersEnum.FromAppID.toString(), appId); } diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CMSOContainerFilters.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CmsoContainerFilters.java index 162a6ba..5b73a85 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CMSOContainerFilters.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/filters/CmsoContainerFilters.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -55,7 +55,7 @@ import org.springframework.stereotype.Component; @Priority(1) @Provider @Component -public class CMSOContainerFilters implements ContainerRequestFilter, ContainerResponseFilter { +public class CmsoContainerFilters implements ContainerRequestFilter, ContainerResponseFilter { @Context @@ -71,10 +71,10 @@ public class CMSOContainerFilters implements ContainerRequestFilter, ContainerRe responseContext.getStatusInfo().toString()); MultivaluedMap<String, String> reqHeaders = requestContext.getHeaders(); MultivaluedMap<String, Object> respHeaders = responseContext.getHeaders(); - String minorVersion = (String) reqHeaders.getFirst(HeadersEnum.MinorVersion.toString()); + String minorVersion = reqHeaders.getFirst(HeadersEnum.MinorVersion.toString()); respHeaders.add(HeadersEnum.MinorVersion.toString(), minorVersion); - respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.latestVersion); - respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.patchVersion); + respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.getLatestversion()); + respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.getPatchversion()); } catch (Exception e) { if (e instanceof WebApplicationException) { @@ -96,8 +96,9 @@ public class CMSOContainerFilters implements ContainerRequestFilter, ContainerRe String majorVersion = requestContext.getUriInfo().getPath(); if (majorVersion != null) { - if (majorVersion.startsWith("dispatch/")) + if (majorVersion.startsWith("dispatch/")) { return; + } majorVersion = majorVersion.replaceAll("/.*$", ""); } if (!MessageHeaders.validateMajorVersion(majorVersion)) { @@ -107,14 +108,14 @@ public class CMSOContainerFilters implements ContainerRequestFilter, ContainerRe throw new WebApplicationException(builder.build()); } MultivaluedMap<String, String> headers = requestContext.getHeaders(); - String transactionId = (String) headers.getFirst(HeadersEnum.TransactionID.toString()); + String transactionId = headers.getFirst(HeadersEnum.TransactionID.toString()); if (transactionId == null) { transactionId = UUID.randomUUID().toString(); headers.add(HeadersEnum.TransactionID.toString(), transactionId); } - String minorVersion = (String) headers.getFirst(HeadersEnum.MinorVersion.toString()); + String minorVersion = headers.getFirst(HeadersEnum.MinorVersion.toString()); if (minorVersion == null) { - minorVersion = MessageHeaders.supportedMajorVersions.get(majorVersion); + minorVersion = MessageHeaders.getSupportedmajorversions().get(majorVersion); headers.add(HeadersEnum.MinorVersion.toString(), minorVersion); } if (!MessageHeaders.validateMajorMinorVersion(majorVersion, minorVersion)) { diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AdminToolImpl.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AdminToolImpl.java index f619711..249779a 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AdminToolImpl.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AdminToolImpl.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -54,8 +54,9 @@ public class AdminToolImpl implements AdminTool { @Override public Response exec(String apiVersion, String id) { log.info("AdminTool.exec entered " + uri.getPath()); - if (id.length() < 4) + if (id.length() < 4) { return Response.ok("").build(); + } String encrypted = PropertiesManagement.getEncryptedValue(id); Response response = Response.ok(encrypted).build(); return response; diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterface.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterface.java index cf9c269..df23f7d 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterface.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/AvailabilityInterface.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -45,7 +45,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.onap.optf.cmso.common.CMSRequestError; +import org.onap.optf.cmso.common.CmsoRequestError; import org.onap.optf.ticketmgt.service.rs.models.ActiveTicketsRequest; import org.onap.optf.ticketmgt.service.rs.models.ActiveTicketsResponse; import org.springframework.web.bind.annotation.PathVariable; @@ -65,17 +65,20 @@ public interface AvailabilityInterface { consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON) @ApiOperation(value = "Request Active Tickets", notes = "API to support conflict avoidance. Retrieves the active ticket data for the " - + "passed criteria to detemine availability of passed elements within the passed time window." - + "\nIf the request results in asynchronous processging, IN_PROGRESS status will be returned and the " + + "passed criteria to detemine availability of passed elements" + + " within the passed time window." + + "\nIf the request results in asynchronous processging, IN_PROGRESS" + + " status will be returned and the " + "optimizer will begin to poll the request until COMPLETED.", response = ActiveTicketsResponse.class) @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"), - @ApiResponse(code = 400, message = "Bad request", response = CMSRequestError.class), + @ApiResponse(code = 400, message = "Bad request", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response getActiveTickets( @ApiParam(value = "v1") @PathParam("apiVersion") @PathVariable( value = "v1") @DefaultValue("v1") String apiVersion, - @ApiParam(value = "Active ticket criteria (elements and change windows).") ActiveTicketsRequest activeTicketsRequest); + @ApiParam(value = "Active ticket criteria (elements and change windows).") + ActiveTicketsRequest activeTicketsRequest); @GET @Path("/activetickets/{id}") @@ -84,11 +87,12 @@ public interface AvailabilityInterface { consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON) @ApiOperation(value = "Poll Active Tickets Request", notes = "Poll for the status of the request id. Optimizser will " - + " poll until status is COMPLETED and issue acknowledge (DELETE) API to acknowledge the " + + " poll until status is COMPLETED and issue acknowledge" + + " (DELETE) API to acknowledge the " + "receipt of the response.", response = ActiveTicketsResponse.class) @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"), - @ApiResponse(code = 404, message = "Not found.", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "Not found.", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response pollActiveTickets( @ApiParam(value = "v1") @PathParam("apiVersion") @PathVariable( @@ -101,11 +105,13 @@ public interface AvailabilityInterface { @RequestMapping(value = "/{apiVersion}/activetickets/{id}", method = RequestMethod.DELETE, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON) @ApiOperation(value = "Acknowledge Active Tickets Response", notes = "API call used to acknowledge the receipt" - + " of a COMPLETED asynchronous request to enable the Ticket Management service to remove it from their cache." - + " The service may remove from the cache on the poll request. The optimizer will treat Not found reponse on as normal.", + + " of a COMPLETED asynchronous request to enable the Ticket Management service" + + " to remove it from their cache." + + " The service may remove from the cache on the poll request. The optimizer will" + + " treat Not found reponse on as normal.", response = ActiveTicketsResponse.class) @ApiResponses(value = {@ApiResponse(code = 204, message = "OK"), - @ApiResponse(code = 404, message = "Not found", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "Not found", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response deleteActiveTicketsRequest( @ApiParam(value = "v1") @PathParam("apiVersion") @PathVariable( diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/HealthCheckImpl.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/HealthCheckImpl.java index efc57ec..72b80bb 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/HealthCheckImpl.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/HealthCheckImpl.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -65,24 +65,32 @@ public class HealthCheckImpl implements HealthCheck { HealthCheckMessage hc = new HealthCheckMessage(); hc.setHealthy(true); - addToHealthCheckMessage(hc, this.healthCheck()); + //addToHealthCheckMessage(hc, this.healthCheckDb()); - if (hc.getHealthy()) + if (hc.getHealthy()) { response = Response.ok().entity(hc).build(); - else + } + else { response = Response.status(Response.Status.BAD_REQUEST).entity(hc).build(); + } return response; } private void addToHealthCheckMessage(HealthCheckMessage hc, HealthCheckComponent hcc) { - if (!hcc.getHealthy()) + if (!hcc.getHealthy()) { hc.setHealthy(false); + } hc.setHostname(System.getenv("HOSTNAME")); hc.addComponent(hcc); } - public HealthCheckComponent healthCheck() { + /** + * Health check. + * + * @return the health check component + */ + public HealthCheckComponent healthCheckDb() { HealthCheckComponent hcc = new HealthCheckComponent(); hcc.setName("Ticket Management Database"); String url = env.getProperty("spring.datasource.url"); diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java index 96c2ada..60a517b 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/TicketManagement.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,7 +47,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import org.onap.optf.cmso.common.CMSRequestError; +import org.onap.optf.cmso.common.CmsoRequestError; import org.onap.optf.ticketmgt.service.rs.models.TicketData; @Api("Ticket Management") @@ -61,7 +61,7 @@ public interface TicketManagement { @ApiOperation(value = "Fetch Ticket", notes = "Returns ticket information for the provided ticket id.", response = TicketData.class) @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"), - @ApiResponse(code = 404, message = "No record found", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "No record found", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response fetchTicket(@ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @ApiParam(value = "Unique ticket identifier") @PathParam("id") String id); @@ -74,7 +74,7 @@ public interface TicketManagement { @ApiResponses(value = { @ApiResponse(code = 200, message = "Ticket Created. Ticket Id returned.", response = TicketData.class), - @ApiResponse(code = 400, message = "Bad request.", response = CMSRequestError.class), + @ApiResponse(code = 400, message = "Bad request.", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response createTicket(@ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @ApiParam(value = "Data for creating a ticket") TicketData ticketData); @@ -85,7 +85,7 @@ public interface TicketManagement { @Produces({MediaType.APPLICATION_JSON}) @ApiOperation(value = "Update Ticket", notes = "Updates a ticket to the passed data") @ApiResponses(value = {@ApiResponse(code = 204, message = "Ticket Updated."), - @ApiResponse(code = 400, message = "Bad request.", response = CMSRequestError.class), + @ApiResponse(code = 400, message = "Bad request.", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response updateTicket(@ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @ApiParam(value = "Data for updating a ticket") TicketData ticketData); @@ -96,12 +96,13 @@ public interface TicketManagement { @Produces({MediaType.APPLICATION_JSON}) @ApiOperation(value = "Cancel the ticket", notes = "Cancels the ticket.") @ApiResponses(value = {@ApiResponse(code = 204, message = "Delete successful"), - @ApiResponse(code = 404, message = "No record found", response = CMSRequestError.class), - @ApiResponse(code = 400, message = "Bad request", response = CMSRequestError.class), + @ApiResponse(code = 404, message = "No record found", response = CmsoRequestError.class), + @ApiResponse(code = 400, message = "Bad request", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response deleteScheduleRequest( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, - @ApiParam(value = "Ticket id to uniquely identify the ticket being deleted.") @PathParam("id") String id); + @ApiParam(value = "Ticket id to uniquely identify the ticket being deleted.") + @PathParam("id") String id); @@ -112,7 +113,7 @@ public interface TicketManagement { @ApiOperation(value = "Search Tickets", notes = "Returns a list of based upon the filter criteria.", response = TicketData.class, responseContainer = "List") @ApiResponses(value = {@ApiResponse(code = 200, message = "OK"), - @ApiResponse(code = 400, message = "Bad request", response = CMSRequestError.class), + @ApiResponse(code = 400, message = "Bad request", response = CmsoRequestError.class), @ApiResponse(code = 500, message = "Unexpected Runtime error", response = Exception.class)}) public Response searchTcikets( @ApiParam(value = "v1") @PathParam("apiVersion") @DefaultValue("v1") String apiVersion, @@ -122,7 +123,8 @@ public interface TicketManagement { allowMultiple = true) @QueryParam("startTime") String startTime, @ApiParam(value = "Finish time <low>,<high>", allowMultiple = true) @QueryParam("finishTime") String finishTime, - @ApiParam(value = "Maximum number of tickets to return") @QueryParam("maxTickets") Integer maxTickets, + @ApiParam(value = "Maximum number of tickets to return") + @QueryParam("maxTickets") Integer maxTickets, @ApiParam(value = "Return tickets > last id") @QueryParam("lastId") String lastId); } diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsRequest.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsRequest.java index 34093f9..4955e24 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsRequest.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsRequest.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -51,7 +51,8 @@ public class ActiveTicketsRequest implements Serializable { private String requestId; @ApiModelProperty( - value = "Implementation specific name value pairs provided to be passed to Ticket Management query .") + value = "Implementation specific name value pairs provided" + + " to be passed to Ticket Management query .") private List<NameValue> commonData; @ApiModelProperty(value = "Lists of desired change windows for which TicketData will be returned.") @@ -100,6 +101,7 @@ public class ActiveTicketsRequest implements Serializable { } + @Override public String toString() { ObjectMapper mapper = new ObjectMapper(); try { diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsResponse.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsResponse.java index 579f36a..bad6eac 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsResponse.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ActiveTicketsResponse.java @@ -55,7 +55,8 @@ public class ActiveTicketsResponse implements Serializable { private String requestId; @ApiModelProperty( - value = "List of TicketData for the requested elements. A single ticket may apply to more than 1 passed elementId.") + value = "List of TicketData for the requested elements." + + " A single ticket may apply to more than 1 passed elementId.") private List<TicketData> elements = new ArrayList<>(); @ApiModelProperty( diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ChangeWindow.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ChangeWindow.java index 31a49de..55b6523 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ChangeWindow.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ChangeWindow.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -70,6 +70,12 @@ public class ChangeWindow implements Serializable { this.endTime = endTime; } + /** + * To string. + * + * @return the string + */ + @Override public String toString() { ObjectMapper mapper = new ObjectMapper(); try { diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ElementCriteria.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ElementCriteria.java index 0043dd3..babceb7 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ElementCriteria.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/ElementCriteria.java @@ -1,33 +1,34 @@ /******************************************************************************* - * + * * Copyright © 2019 AT&T Intellectual Property. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ + package org.onap.optf.ticketmgt.service.rs.models; import io.swagger.annotations.ApiModel; diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/HealthCheckComponent.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/HealthCheckComponent.java index dafe38e..cb88d7a 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/HealthCheckComponent.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/HealthCheckComponent.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -80,6 +80,7 @@ public class HealthCheckComponent implements Serializable { this.status = status; } + @Override public String toString() { ObjectMapper mapper = new ObjectMapper(); try { diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/HealthCheckMessage.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/HealthCheckMessage.java index e36f54e..6f9a733 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/HealthCheckMessage.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/HealthCheckMessage.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -96,6 +96,7 @@ public class HealthCheckMessage implements Serializable { this.components.add(components); } + @Override public String toString() { ObjectMapper mapper = new ObjectMapper(); try { diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/NameValue.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/NameValue.java index c5c53b2..29cf86d 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/NameValue.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/NameValue.java @@ -1,27 +1,27 @@ /* * Copyright © 2017-2019 AT&T Intellectual Property. * Modifications Copyright © 2018 IBM. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -71,6 +71,7 @@ public class NameValue implements Serializable { } + @Override public String toString() { ObjectMapper mapper = new ObjectMapper(); try { diff --git a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/TicketData.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/TicketData.java index 486034f..e2c58c5 100644 --- a/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/TicketData.java +++ b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/service/rs/models/TicketData.java @@ -1,47 +1,48 @@ /******************************************************************************* - * + * * Copyright © 2019 AT&T Intellectual Property. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * - * + * + * * Unless otherwise specified, all documentation contained herein is licensed * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); * you may not use this documentation except in compliance with the License. * You may obtain a copy of the License at - * + * * https://creativecommons.org/licenses/by/4.0/ - * + * * Unless required by applicable law or agreed to in writing, documentation * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ + package org.onap.optf.ticketmgt.service.rs.models; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import org.onap.optf.ticketmgt.common.Availability; -import org.springframework.format.annotation.DateTimeFormat; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import org.onap.optf.ticketmgt.common.Availability; +import org.springframework.format.annotation.DateTimeFormat; @ApiModel(value = "Ticket Data", description = "Change Management Ticket Information.") public class TicketData implements Serializable { @@ -117,6 +118,7 @@ public class TicketData implements Serializable { this.changeDetails = changeDetails; } + @Override public String toString() { ObjectMapper mapper = new ObjectMapper(); try { diff --git a/cmso-topology/src/main/java/org/onap/observations/MessageHeaders.java b/cmso-topology/src/main/java/org/onap/observations/MessageHeaders.java index fe6cea2..ccb7e56 100644 --- a/cmso-topology/src/main/java/org/onap/observations/MessageHeaders.java +++ b/cmso-topology/src/main/java/org/onap/observations/MessageHeaders.java @@ -65,7 +65,7 @@ public class MessageHeaders { } /** The Constant supportedMajorVersions. */ - public static final Map<String, String> supportedMajorVersions = new HashMap<String, String>(); + private static final Map<String, String> supportedMajorVersions = new HashMap<String, String>(); static { supportedMajorVersions.put("v1", "0"); @@ -73,7 +73,7 @@ public class MessageHeaders { } /** The Constant supportedMajorMinorVersions. */ - public static final Set<String> supportedMajorMinorVersions = new HashSet<String>(); + private static final Set<String> supportedMajorMinorVersions = new HashSet<String>(); static { supportedMajorMinorVersions.add("v1.0"); @@ -81,10 +81,10 @@ public class MessageHeaders { } /** The Constant latestVersion. */ - public static final String latestVersion = "2.0.0"; + private static final String latestVersion = "2.0.0"; /** The Constant patchVersion. */ - public static final String patchVersion = "0"; + private static final String patchVersion = "0"; /** * From string. @@ -152,4 +152,20 @@ public class MessageHeaders { } return true; } + + public static Map<String, String> getSupportedmajorversions() { + return supportedMajorVersions; + } + + public static Set<String> getSupportedmajorminorversions() { + return supportedMajorMinorVersions; + } + + public static String getLatestversion() { + return latestVersion; + } + + public static String getPatchversion() { + return patchVersion; + } } diff --git a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoContainerFilters.java b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoContainerFilters.java index 2418aec..2729613 100644 --- a/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoContainerFilters.java +++ b/cmso-topology/src/main/java/org/onap/optf/cmso/topology/filters/CmsoContainerFilters.java @@ -68,8 +68,8 @@ public class CmsoContainerFilters implements ContainerRequestFilter, ContainerRe MultivaluedMap<String, Object> respHeaders = responseContext.getHeaders(); String minorVersion = reqHeaders.getFirst(HeadersEnum.MinorVersion.toString()); respHeaders.add(HeadersEnum.MinorVersion.toString(), minorVersion); - respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.latestVersion); - respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.patchVersion); + respHeaders.add(HeadersEnum.LatestVersion.toString(), MessageHeaders.getLatestversion()); + respHeaders.add(HeadersEnum.PatchVersion.toString(), MessageHeaders.getPatchVersion()); } catch (Exception e) { if (e instanceof WebApplicationException) { @@ -110,7 +110,7 @@ public class CmsoContainerFilters implements ContainerRequestFilter, ContainerRe } String minorVersion = headers.getFirst(HeadersEnum.MinorVersion.toString()); if (minorVersion == null) { - minorVersion = MessageHeaders.supportedMajorVersions.get(majorVersion); + minorVersion = MessageHeaders.getSupportedmajorversions().get(majorVersion); headers.add(HeadersEnum.MinorVersion.toString(), minorVersion); } if (!MessageHeaders.validateMajorMinorVersion(majorVersion, minorVersion)) { |