diff options
57 files changed, 895 insertions, 393 deletions
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..7c6db2a 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 @@ -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..6724551 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 @@ -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()); @@ -175,5 +170,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/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/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..0e8b758 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 @@ -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-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..f140aec 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; } } + /** The Constant supportedMajorVersions. */ public static final Map<String, String> supportedMajorVersions = new HashMap<String, String>(); + static { supportedMajorVersions.put("v1", "0"); supportedMajorVersions.put("v2", "0"); } + + /** The Constant supportedMajorMinorVersions. */ public static final Set<String> supportedMajorMinorVersions = new HashSet<String>(); + static { supportedMajorMinorVersions.add("v1.0"); supportedMajorMinorVersions.add("v2.0"); } + + /** The Constant latestVersion. */ public static final String latestVersion = "2.0.0"; + + /** The Constant patchVersion. */ public 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; 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/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/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/CMSException.java index 0ab80a0..e8b5e03 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/CMSException.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. @@ -46,12 +46,20 @@ public class CMSException extends Exception { protected ObservationInterface messageCode; protected Status status; + /** + * Instantiates a new CMS exception. + * + * @param status the status + * @param messageCode the message code + * @param args the args + */ public CMSException(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); } 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/JerseyConfiguration.java b/cmso-ticketmgt/src/main/java/org/onap/optf/ticketmgt/JerseyConfiguration.java index 46c99ee..c4fe51a 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. @@ -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); @@ -86,6 +94,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-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..ffbd94e 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; @@ -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()); 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..c0c8106 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; @@ -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")); 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..b9b222c 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,6 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.optf.ticketmgt.aaf; import java.io.IOException; 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..54b1b38 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; @@ -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..4f6b8e7 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. @@ -71,7 +71,7 @@ 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); @@ -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,12 +108,12 @@ 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); headers.add(HeadersEnum.MinorVersion.toString(), 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..3360927 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. @@ -65,8 +65,10 @@ 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"), @@ -75,7 +77,8 @@ public interface AvailabilityInterface { 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,7 +87,8 @@ 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"), @@ -101,8 +105,10 @@ 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), 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..16346bf 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. @@ -101,7 +101,8 @@ public interface TicketManagement { @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); @@ -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 { |