diff options
Diffstat (limited to 'src/main/java/org')
15 files changed, 283 insertions, 1714 deletions
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java index 11a91f8..fdb4ee4 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/App.java @@ -21,13 +21,14 @@ package org.onap.dcaegen2.services.pmmapper; import ch.qos.logback.classic.util.ContextInitializer; -import io.undertow.Handlers; import io.undertow.Undertow; +import io.undertow.server.RoutingHandler; import io.undertow.util.StatusCodes; +import java.util.Arrays; +import lombok.Data; import lombok.NonNull; import org.onap.dcaegen2.services.pmmapper.config.ConfigHandler; -import org.onap.dcaegen2.services.pmmapper.config.Configurable; import org.onap.dcaegen2.services.pmmapper.config.DynamicConfiguration; import org.onap.dcaegen2.services.pmmapper.datarouter.DeliveryHandler; import org.onap.dcaegen2.services.pmmapper.exceptions.CBSServerError; @@ -41,6 +42,7 @@ import org.onap.dcaegen2.services.pmmapper.messagerouter.VESPublisher; import org.onap.dcaegen2.services.pmmapper.model.Event; import org.onap.dcaegen2.services.pmmapper.model.MapperConfig; import org.onap.dcaegen2.services.pmmapper.healthcheck.HealthCheckHandler; +import org.onap.dcaegen2.services.pmmapper.model.ServerHandler; import org.onap.dcaegen2.services.pmmapper.ssl.SSLContextFactory; import org.onap.dcaegen2.services.pmmapper.utils.DataRouterUtils; import org.onap.dcaegen2.services.pmmapper.utils.MeasConverter; @@ -60,65 +62,121 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; +@Data public class App { - static { System.setProperty(ContextInitializer.CONFIG_FILE_PROPERTY, "/opt/app/pm-mapper/etc/logback.xml"); } private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(App.class)); + private static final int HTTP_PORT = 8081; + private static final int HTTPS_PORT = 8443; private static Path mappingTemplate = Paths.get("/opt/app/pm-mapper/etc/mapping.ftl"); private static Path xmlSchema = Paths.get("/opt/app/pm-mapper/etc/measCollec_plusString.xsd"); - private static FluxSink<Event> fluxSink; - - public static void main(String[] args) throws EnvironmentConfigException, CBSServerError, MapperConfigException, IOException { - Flux<Event> flux = Flux.create(eventFluxSink -> fluxSink = eventFluxSink); - HealthCheckHandler healthCheckHandler = new HealthCheckHandler(); - MapperConfig mapperConfig = new ConfigHandler().getMapperConfig(); - MetadataFilter metadataFilter = new MetadataFilter(mapperConfig); - MeasConverter measConverter = new MeasConverter(); - MeasFilterHandler filterHandler = new MeasFilterHandler(measConverter); - Mapper mapper = new Mapper(mappingTemplate, measConverter); - MeasSplitter splitter = new MeasSplitter(measConverter); - XMLValidator validator = new XMLValidator(xmlSchema); - VESPublisher vesPublisher = new VESPublisher(mapperConfig); - - flux.onBackpressureDrop(App::handleBackPressure) + + private MapperConfig mapperConfig; + private MetadataFilter metadataFilter; + private MeasConverter measConverter; + private MeasFilterHandler filterHandler; + private Mapper mapper; + private MeasSplitter splitter; + private XMLValidator validator; + private VESPublisher vesPublisher; + private DeliveryHandler deliveryHandler; + private DynamicConfiguration dynamicConfiguration; + private HealthCheckHandler healthCheckHandler; + private int httpPort; + private int httpsPort; + + private Undertow applicationServer; + private List<ServerHandler> serverHandlers; + private Flux<Event> flux; + private FluxSink<Event> fluxSink; + + /** + * Creates an instance of the application. + * @param mappingTemplate path to template used to convert xml to VES. + * @param xmlSchema path to schema used to verify incoming XML will work with template. + * @param httpPort http port to start http server on. + * @param httpsPort https port to start https server on. + * @param configHandler instance of the ConfigurationHandler used to acquire config. + */ + public App(Path mappingTemplate, Path xmlSchema, int httpPort, int httpsPort, ConfigHandler configHandler) { + try { + this.mapperConfig = configHandler.getMapperConfig(); + } catch (EnvironmentConfigException | CBSServerError | MapperConfigException e) { + logger.unwrap().error("Failed to acquire initial configuration, Application cannot start", e); + throw new IllegalStateException("Config acquisition failed"); + } + this.httpPort = httpPort; + this.httpsPort = httpsPort; + this.metadataFilter = new MetadataFilter(mapperConfig); + this.measConverter = new MeasConverter(); + this.filterHandler = new MeasFilterHandler(measConverter); + this.mapper = new Mapper(mappingTemplate, this.measConverter); + this.splitter = new MeasSplitter(measConverter); + this.validator = new XMLValidator(xmlSchema); + this.vesPublisher = new VESPublisher(mapperConfig); + this.flux = Flux.create(eventFluxSink -> this.fluxSink = eventFluxSink); + + this.flux.onBackpressureDrop(App::handleBackPressure) .doOnNext(App::receiveRequest) .limitRate(1) .parallel() .runOn(Schedulers.newParallel(""), 1) .doOnNext(event -> MDC.setContextMap(event.getMdc())) - .filter(metadataFilter::filter) - .filter(event -> App.filterByFileType(filterHandler, event, mapperConfig)) - .filter(event -> App.validate(validator, event, mapperConfig)) - .concatMap(event -> App.split(splitter,event, mapperConfig)) - .filter(events -> App.filter(filterHandler, events, mapperConfig)) - .concatMap(events -> App.map(mapper, events, mapperConfig)) - .concatMap(vesPublisher::publish) - .subscribe(event -> App.sendEventProcessed(mapperConfig, event)); - - DeliveryHandler deliveryHandler = new DeliveryHandler(fluxSink::next); - ArrayList<Configurable> configurables = new ArrayList<>(); - configurables.add(mapperConfig); - DynamicConfiguration dynamicConfiguration = new DynamicConfiguration(configurables, mapperConfig); + .filter(this.metadataFilter::filter) + .filter(event -> App.filterByFileType(this.filterHandler, event, this.mapperConfig)) + .filter(event -> App.validate(this.validator, event, this.mapperConfig)) + .concatMap(event -> App.split(this.splitter,event, this.mapperConfig)) + .filter(events -> App.filter(this.filterHandler, events, this.mapperConfig)) + .concatMap(events -> App.map(this.mapper, events, this.mapperConfig)) + .concatMap(this.vesPublisher::publish) + .subscribe(event -> App.sendEventProcessed(this.mapperConfig, event)); - Undertow.Builder builder = Undertow.builder(); + this.healthCheckHandler = new HealthCheckHandler(); + this.deliveryHandler = new DeliveryHandler(fluxSink::next); + this.dynamicConfiguration = new DynamicConfiguration(Arrays.asList(mapperConfig), mapperConfig); + this.serverHandlers = Arrays.asList(healthCheckHandler, deliveryHandler, dynamicConfiguration); + try { + this.applicationServer = server(this.mapperConfig, this.serverHandlers); + } catch (IOException e) { + logger.unwrap().error("Failed to create server instance.", e); + throw new IllegalStateException("Server instantiation failed"); + } + } - SSLContextFactory sslContextFactory = new SSLContextFactory(mapperConfig); - SSLContext sslContext = sslContextFactory.createSSLContext(mapperConfig); - SSLContext.setDefault(sslContext); + /** + * Starts the application server. + */ + public void start() { + this.applicationServer.start(); + } + + /** + * Stops the application server. + */ + public void stop() { + this.applicationServer.stop(); + } - if(mapperConfig.getEnableHttp()) { - builder.addHttpListener(8081, "0.0.0.0"); + private Undertow server(MapperConfig config, List<ServerHandler> serverHandlers) throws IOException { + SSLContextFactory sslContextFactory = new SSLContextFactory(config); + SSLContext sslContext = sslContextFactory.createSSLContext(config); + SSLContext.setDefault(sslContext); + Undertow.Builder builder = Undertow.builder(); + if (config.getEnableHttp()) { + builder.addHttpListener(this.httpPort, "0.0.0.0"); } + RoutingHandler routes = new RoutingHandler(); + serverHandlers.forEach(handler -> routes.add(handler.getMethod(), handler.getTemplate(), handler.getHandler())); + return builder.addHttpsListener(this.httpsPort, "0.0.0.0", sslContext) + .setHandler(routes) + .build(); + } - builder.addHttpsListener(8443, "0.0.0.0", sslContext) - .setHandler(Handlers.routing() - .add("put", "/delivery/{filename}", deliveryHandler) - .add("get", "/healthcheck", healthCheckHandler) - .add("get", "/reconfigure", dynamicConfiguration)) - .build().start(); + public static void main(String[] args) { + new App(mappingTemplate, xmlSchema, HTTP_PORT, HTTPS_PORT, new ConfigHandler()).start(); } public static boolean filterByFileType(MeasFilterHandler filterHandler,Event event, MapperConfig config) { diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandler.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandler.java index fef1d19..273c953 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandler.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/config/ConfigHandler.java @@ -63,11 +63,8 @@ public class ConfigHandler { * Retrieves PM-Mapper Configuration from DCAE's ConfigBinding Service. * * @throws EnvironmentConfigException - * @throws CBSServerError - * @throws MapperConfigException */ - public MapperConfig getMapperConfig() throws EnvironmentConfigException, - CBSServerError, MapperConfigException { + public MapperConfig getMapperConfig() throws EnvironmentConfigException { String mapperConfigJson = ""; String cbsSocketAddress = this.environmentConfig.getCBSHostName() + ":" + this.environmentConfig.getCBSPort(); String requestURL = "http://" + cbsSocketAddress + "/service_component/" + this.environmentConfig.getServiceName(); @@ -84,7 +81,7 @@ public class ConfigHandler { return convertMapperConfigToObject(mapperConfigJson); } - private MapperConfig convertMapperConfigToObject(String mapperConfigJson) throws MapperConfigException { + private MapperConfig convertMapperConfigToObject(String mapperConfigJson) { MapperConfig mapperConfig; try { JsonObject config = new Gson().fromJson(mapperConfigJson, JsonObject.class); diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/config/DynamicConfiguration.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/config/DynamicConfiguration.java index 7e2c894..4516183 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/config/DynamicConfiguration.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/config/DynamicConfiguration.java @@ -27,13 +27,16 @@ import java.util.List; import lombok.Data; import org.onap.dcaegen2.services.pmmapper.exceptions.ReconfigurationException; import org.onap.dcaegen2.services.pmmapper.model.MapperConfig; +import org.onap.dcaegen2.services.pmmapper.model.ServerHandler; import org.onap.dcaegen2.services.pmmapper.utils.HttpServerExchangeAdapter; import org.onap.logging.ref.slf4j.ONAPLogAdapter; import org.slf4j.LoggerFactory; @Data -public class DynamicConfiguration implements HttpHandler { +public class DynamicConfiguration implements HttpHandler, ServerHandler { private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(DynamicConfiguration.class)); + private static final String METHOD = "get"; + private static final String ENDPOINT_TEMPLATE = "/reconfigure"; private List<Configurable> configurables; private MapperConfig originalConfig; private ConfigHandler configHandler; @@ -87,4 +90,19 @@ public class DynamicConfiguration implements HttpHandler { logger.exiting(); } } + + @Override + public String getMethod() { + return METHOD; + } + + @Override + public String getTemplate() { + return ENDPOINT_TEMPLATE; + } + + @Override + public HttpHandler getHandler() { + return this; + } } diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/datarouter/DeliveryHandler.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/datarouter/DeliveryHandler.java index 4d6af29..ba218cb 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/datarouter/DeliveryHandler.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/datarouter/DeliveryHandler.java @@ -34,6 +34,7 @@ import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; import io.undertow.util.StatusCodes; +import org.onap.dcaegen2.services.pmmapper.model.ServerHandler; import org.onap.dcaegen2.services.pmmapper.utils.HttpServerExchangeAdapter; import org.onap.dcaegen2.services.pmmapper.utils.RequiredFieldDeserializer; import org.onap.logging.ref.slf4j.ONAPLogAdapter; @@ -47,7 +48,7 @@ import java.util.Optional; * Provides an undertow HttpHandler to be used as an endpoint for data router to send events to. */ @Data -public class DeliveryHandler implements HttpHandler { +public class DeliveryHandler implements HttpHandler, ServerHandler { public static final String METADATA_HEADER = "X-DMAAP-DR-META"; public static final String PUB_ID_HEADER = "X-DMAAP-DR-PUBLISH-ID"; @@ -56,6 +57,8 @@ public class DeliveryHandler implements HttpHandler { private static final String BAD_METADATA_MESSAGE = "Malformed Metadata."; private static final String NO_METADATA_MESSAGE = "Missing Metadata."; + private static final String METHOD = "put"; + private static final String ENDPOINT_TEMPLATE = "/delivery/{filename}"; private Gson metadataBuilder; @@ -116,4 +119,19 @@ public class DeliveryHandler implements HttpHandler { logger.exiting(); } } + + @Override + public String getMethod() { + return METHOD; + } + + @Override + public String getTemplate() { + return ENDPOINT_TEMPLATE; + } + + @Override + public HttpHandler getHandler() { + return this; + } } diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/CBSServerError.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/CBSServerError.java index 787d21f..58262ba 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/CBSServerError.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/CBSServerError.java @@ -19,7 +19,7 @@ */
package org.onap.dcaegen2.services.pmmapper.exceptions;
-public class CBSServerError extends Exception {
+public class CBSServerError extends RuntimeException {
public CBSServerError(String message, Throwable cause) {
super(message, cause);
}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/MapperConfigException.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/MapperConfigException.java index e78da98..4669871 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/MapperConfigException.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/MapperConfigException.java @@ -19,7 +19,7 @@ */
package org.onap.dcaegen2.services.pmmapper.exceptions;
-public class MapperConfigException extends Exception {
+public class MapperConfigException extends RuntimeException {
public MapperConfigException(String message, Throwable cause) {
super(message, cause);
}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/TooManyTriesException.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/RequestFailure.java index 922239b..776634b 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/TooManyTriesException.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/RequestFailure.java @@ -17,13 +17,11 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ + package org.onap.dcaegen2.services.pmmapper.exceptions; -/** - * Exception indicates that a task has been attempted too many times. - */ -public class TooManyTriesException extends Exception { - public TooManyTriesException(String errorMessage){ - super(errorMessage); +public class RequestFailure extends RuntimeException { + public RequestFailure(Throwable cause) { + super(cause); } } diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/ServerResponseException.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/ServerResponseException.java index b52e2d4..a392bb5 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/ServerResponseException.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/exceptions/ServerResponseException.java @@ -20,7 +20,7 @@ package org.onap.dcaegen2.services.pmmapper.exceptions; -public class ServerResponseException extends Exception { +public class ServerResponseException extends RuntimeException { public ServerResponseException(String message, Throwable cause) { super(message, cause); } diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandler.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandler.java index 0438530..562f46c 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandler.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandler.java @@ -57,12 +57,12 @@ public class MeasFilterHandler { Optional<Filter> filter = Optional.ofNullable(event.getFilter()); MeasCollecFile measCollecFile = event.getMeasCollecFile(); - if(hasNoFilters(filter)) { + if (hasNoFilters(filter)) { logger.unwrap().info("Skipping filtering by measTypes as filter config does not contain measTypes."); return true; } - if(measCollecFile.getMeasData().isEmpty()) { + if (measCollecFile.getMeasData().isEmpty()) { logger.unwrap().info("Measurement file will not be processed further as MeasData is empty."); return false; } @@ -72,13 +72,12 @@ public class MeasFilterHandler { List<MeasInfo> measInfos = measData.getMeasInfo(); List<MeasInfo> filteredMeasInfos = new ArrayList<>(); - for (int i = 0; i < measInfos.size(); i++) { - MeasInfo currentMeasInfo = measInfos.get(i); + for (MeasInfo currentMeasInfo : measInfos) { List<String> measTypesNode = currentMeasInfo.getMeasTypes(); - if(!measTypesNode.isEmpty()) { - setMeasInfosFromMeasTypes(currentMeasInfo,filteredMeasInfos, filter.get()); - }else { - setMeasInfoFromMeasType(currentMeasInfo,filteredMeasInfos, filter.get()); + if (measTypesNode != null && !measTypesNode.isEmpty()) { + setMeasInfosFromMeasTypes(currentMeasInfo, filteredMeasInfos, filter.get()); + } else { + setMeasInfoFromMeasType(currentMeasInfo, filteredMeasInfos, filter.get()); } } diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/healthcheck/HealthCheckHandler.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/healthcheck/HealthCheckHandler.java index 70a9596..ddf55c7 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/healthcheck/HealthCheckHandler.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/healthcheck/HealthCheckHandler.java @@ -22,6 +22,7 @@ package org.onap.dcaegen2.services.pmmapper.healthcheck; +import org.onap.dcaegen2.services.pmmapper.model.ServerHandler; import org.onap.dcaegen2.services.pmmapper.utils.HttpServerExchangeAdapter; import org.onap.logging.ref.slf4j.ONAPLogAdapter; import org.slf4j.LoggerFactory; @@ -30,8 +31,11 @@ import io.undertow.server.HttpHandler; import io.undertow.server.HttpServerExchange; import io.undertow.util.StatusCodes; -public class HealthCheckHandler implements HttpHandler { +public class HealthCheckHandler implements HttpHandler, ServerHandler { private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(HealthCheckHandler.class)); + private static final String METHOD = "get"; + private static final String ENDPOINT_TEMPLATE = "/healthcheck"; + @Override public void handleRequest(HttpServerExchange exchange) { try { @@ -45,4 +49,18 @@ public class HealthCheckHandler implements HttpHandler { } } + @Override + public String getMethod() { + return METHOD; + } + + @Override + public String getTemplate() { + return ENDPOINT_TEMPLATE; + } + + @Override + public HttpHandler getHandler() { + return this; + } } diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/messagerouter/VESPublisher.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/messagerouter/VESPublisher.java index 744696a..6aaf1d6 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/messagerouter/VESPublisher.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/messagerouter/VESPublisher.java @@ -53,8 +53,8 @@ public class VESPublisher { try {
events.forEach(e -> this.publish(e.getVes()));
logger.unwrap().info("Successfully published VES events to messagerouter.");
- } catch(MRPublisherException e) {
- logger.unwrap().error("Failed to publish VES event(s) to messagerouter. {}", e.getMessage());
+ } catch (MRPublisherException e) {
+ logger.unwrap().error("Failed to publish VES event(s) to messagerouter.", e);
return Flux.empty();
}
return Flux.just(event);
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasCollecFile.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasCollecFile.java index 6e9e254..cc6ca0f 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasCollecFile.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasCollecFile.java @@ -17,10 +17,10 @@ * SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
+
package org.onap.dcaegen2.services.pmmapper.model;
import java.math.BigInteger;
-import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@@ -36,183 +36,8 @@ import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import javax.xml.datatype.Duration;
import javax.xml.datatype.XMLGregorianCalendar;
+import lombok.Data;
-/**
- * <p>
- * Generated Java class using XJC to represent 3GPP PM Measurement file
- *
- * <p>
- * The following schema fragment specifies the expected content contained within
- * this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="fileHeader">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="fileSender">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="localDn" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="elementType" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <element name="measCollec">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="beginTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * </sequence>
- * <attribute name="fileFormatVersion" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="vendorName" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="dnPrefix" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <element name="measData" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="managedElement">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="localDn" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="userLabel" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="swVersion" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <element name="measInfo" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="job" minOccurs="0">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="jobId" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <element name="granPeriod">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
- * <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <element name="repPeriod" minOccurs="0">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <choice>
- * <element name="measTypes">
- * <simpleType>
- * <list itemType="{http://www.w3.org/2001/XMLSchema}Name" />
- * </simpleType>
- * </element>
- * <element name="measType" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.w3.org/2001/XMLSchema>Name">
- * <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </element>
- * </choice>
- * <element name="measValue" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <choice>
- * <element name="measResults">
- * <simpleType>
- * <list itemType="{http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec}measResultType" />
- * </simpleType>
- * </element>
- * <element name="r" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec>measResultType">
- * <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </element>
- * </choice>
- * <element name="suspect" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
- * </sequence>
- * <attribute name="measObjLdn" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * </sequence>
- * <attribute name="measInfoId" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <element name="fileFooter">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="measCollec">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"fileHeader",
@@ -220,6 +45,7 @@ import javax.xml.datatype.XMLGregorianCalendar; "fileFooter"
})
@XmlRootElement(name = "measCollecFile")
+@Data
public class MeasCollecFile {
@XmlElement(required = true)
@@ -227,247 +53,34 @@ public class MeasCollecFile { protected List<MeasCollecFile.MeasData> measData;
@XmlElement(required = true)
protected MeasCollecFile.FileFooter fileFooter;
-
- /**
- * Gets the value of the fileHeader property.
- *
- * @return
- * possible object is
- * {@link MeasCollecFile.FileHeader }
- *
- */
- public MeasCollecFile.FileHeader getFileHeader() {
- return fileHeader;
- }
-
- /**
- * Sets the value of the fileHeader property.
- *
- * @param value
- * allowed object is
- * {@link MeasCollecFile.FileHeader }
- *
- */
- public void setFileHeader(MeasCollecFile.FileHeader value) {
- this.fileHeader = value;
- }
-
- /**
- * Gets the value of the measData property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the measData property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getMeasData().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link MeasCollecFile.MeasData }
- *
- *
- */
- public List<MeasCollecFile.MeasData> getMeasData() {
- if (measData == null) {
- measData = new ArrayList<MeasCollecFile.MeasData>();
- }
- return this.measData;
- }
-
- /**
- * Gets the value of the fileFooter property.
- *
- * @return
- * possible object is
- * {@link MeasCollecFile.FileFooter }
- *
- */
- public MeasCollecFile.FileFooter getFileFooter() {
- return fileFooter;
- }
-
- /**
- * Sets the value of the fileFooter property.
- *
- * @param value
- * allowed object is
- * {@link MeasCollecFile.FileFooter }
- *
- */
- public void setFileFooter(MeasCollecFile.FileFooter value) {
- this.fileFooter = value;
- }
-
-
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="measCollec">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"measCollec"
})
+ @Data
public static class FileFooter {
@XmlElement(required = true)
protected MeasCollecFile.FileFooter.MeasCollec measCollec;
- /**
- * Gets the value of the measCollec property.
- *
- * @return
- * possible object is
- * {@link MeasCollecFile.FileFooter.MeasCollec }
- *
- */
- public MeasCollecFile.FileFooter.MeasCollec getMeasCollec() {
- return measCollec;
- }
-
- /**
- * Sets the value of the measCollec property.
- *
- * @param value
- * allowed object is
- * {@link MeasCollecFile.FileFooter.MeasCollec }
- *
- */
- public void setMeasCollec(MeasCollecFile.FileFooter.MeasCollec value) {
- this.measCollec = value;
- }
-
-
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
public static class MeasCollec {
-
@XmlAttribute(name = "endTime", required = true)
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar endTime;
-
- /**
- * Gets the value of the endTime property.
- *
- * @return
- * possible object is
- * {@link XMLGregorianCalendar }
- *
- */
- public XMLGregorianCalendar getEndTime() {
- return endTime;
- }
-
- /**
- * Sets the value of the endTime property.
- *
- * @param value
- * allowed object is
- * {@link XMLGregorianCalendar }
- *
- */
- public void setEndTime(XMLGregorianCalendar value) {
- this.endTime = value;
- }
-
}
}
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="fileSender">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="localDn" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="elementType" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <element name="measCollec">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="beginTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * </sequence>
- * <attribute name="fileFormatVersion" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="vendorName" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="dnPrefix" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"fileSender",
"measCollec"
})
+ @Data
public static class FileHeader {
-
@XmlElement(required = true)
protected MeasCollecFile.FileHeader.FileSender fileSender;
@XmlElement(required = true)
@@ -479,632 +92,52 @@ public class MeasCollecFile { @XmlAttribute(name = "dnPrefix")
protected String dnPrefix;
- /**
- * Gets the value of the fileSender property.
- *
- * @return
- * possible object is
- * {@link MeasCollecFile.FileHeader.FileSender }
- *
- */
- public MeasCollecFile.FileHeader.FileSender getFileSender() {
- return fileSender;
- }
-
- /**
- * Sets the value of the fileSender property.
- *
- * @param value
- * allowed object is
- * {@link MeasCollecFile.FileHeader.FileSender }
- *
- */
- public void setFileSender(MeasCollecFile.FileHeader.FileSender value) {
- this.fileSender = value;
- }
-
- /**
- * Gets the value of the measCollec property.
- *
- * @return
- * possible object is
- * {@link MeasCollecFile.FileHeader.MeasCollec }
- *
- */
- public MeasCollecFile.FileHeader.MeasCollec getMeasCollec() {
- return measCollec;
- }
-
- /**
- * Sets the value of the measCollec property.
- *
- * @param value
- * allowed object is
- * {@link MeasCollecFile.FileHeader.MeasCollec }
- *
- */
- public void setMeasCollec(MeasCollecFile.FileHeader.MeasCollec value) {
- this.measCollec = value;
- }
-
- /**
- * Gets the value of the fileFormatVersion property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getFileFormatVersion() {
- return fileFormatVersion;
- }
-
- /**
- * Sets the value of the fileFormatVersion property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setFileFormatVersion(String value) {
- this.fileFormatVersion = value;
- }
-
- /**
- * Gets the value of the vendorName property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getVendorName() {
- return vendorName;
- }
-
- /**
- * Sets the value of the vendorName property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setVendorName(String value) {
- this.vendorName = value;
- }
-
- /**
- * Gets the value of the dnPrefix property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getDnPrefix() {
- return dnPrefix;
- }
-
- /**
- * Sets the value of the dnPrefix property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setDnPrefix(String value) {
- this.dnPrefix = value;
- }
-
-
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="localDn" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="elementType" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
+ @Data
public static class FileSender {
-
@XmlAttribute(name = "localDn")
protected String localDn;
@XmlAttribute(name = "elementType")
protected String elementType;
-
- /**
- * Gets the value of the localDn property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getLocalDn() {
- return localDn;
- }
-
- /**
- * Sets the value of the localDn property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setLocalDn(String value) {
- this.localDn = value;
- }
-
- /**
- * Gets the value of the elementType property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getElementType() {
- return elementType;
- }
-
- /**
- * Sets the value of the elementType property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setElementType(String value) {
- this.elementType = value;
- }
-
}
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="beginTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
+ @Data
public static class MeasCollec {
-
@XmlAttribute(name = "beginTime", required = true)
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar beginTime;
-
- /**
- * Gets the value of the beginTime property.
- *
- * @return
- * possible object is
- * {@link XMLGregorianCalendar }
- *
- */
- public XMLGregorianCalendar getBeginTime() {
- return beginTime;
- }
-
- /**
- * Sets the value of the beginTime property.
- *
- * @param value
- * allowed object is
- * {@link XMLGregorianCalendar }
- *
- */
- public void setBeginTime(XMLGregorianCalendar value) {
- this.beginTime = value;
- }
-
}
}
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="managedElement">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="localDn" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="userLabel" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="swVersion" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <element name="measInfo" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="job" minOccurs="0">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="jobId" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <element name="granPeriod">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
- * <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <element name="repPeriod" minOccurs="0">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <choice>
- * <element name="measTypes">
- * <simpleType>
- * <list itemType="{http://www.w3.org/2001/XMLSchema}Name" />
- * </simpleType>
- * </element>
- * <element name="measType" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.w3.org/2001/XMLSchema>Name">
- * <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </element>
- * </choice>
- * <element name="measValue" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <choice>
- * <element name="measResults">
- * <simpleType>
- * <list itemType="{http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec}measResultType" />
- * </simpleType>
- * </element>
- * <element name="r" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec>measResultType">
- * <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </element>
- * </choice>
- * <element name="suspect" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
- * </sequence>
- * <attribute name="measObjLdn" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * </sequence>
- * <attribute name="measInfoId" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * </sequence>
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"managedElement",
"measInfo"
})
+ @Data
public static class MeasData {
-
@XmlElement(required = true)
protected MeasCollecFile.MeasData.ManagedElement managedElement;
protected List<MeasCollecFile.MeasData.MeasInfo> measInfo;
- /**
- * Gets the value of the managedElement property.
- *
- * @return
- * possible object is
- * {@link MeasCollecFile.MeasData.ManagedElement }
- *
- */
- public MeasCollecFile.MeasData.ManagedElement getManagedElement() {
- return managedElement;
- }
-
- /**
- * Sets the value of the managedElement property.
- *
- * @param value
- * allowed object is
- * {@link MeasCollecFile.MeasData.ManagedElement }
- *
- */
- public void setManagedElement(MeasCollecFile.MeasData.ManagedElement value) {
- this.managedElement = value;
- }
-
- /**
- * Gets the value of the measInfo property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the measInfo property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getMeasInfo().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link MeasCollecFile.MeasData.MeasInfo }
- *
- *
- */
- public List<MeasCollecFile.MeasData.MeasInfo> getMeasInfo() {
- if (measInfo == null) {
- measInfo = new ArrayList<MeasCollecFile.MeasData.MeasInfo>();
- }
- return this.measInfo;
- }
-
-
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="localDn" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="userLabel" type="{http://www.w3.org/2001/XMLSchema}string" />
- * <attribute name="swVersion" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
+ @Data
public static class ManagedElement {
-
@XmlAttribute(name = "localDn")
protected String localDn;
@XmlAttribute(name = "userLabel")
protected String userLabel;
@XmlAttribute(name = "swVersion")
protected String swVersion;
-
- /**
- * Gets the value of the localDn property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getLocalDn() {
- return localDn;
- }
-
- /**
- * Sets the value of the localDn property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setLocalDn(String value) {
- this.localDn = value;
- }
-
- /**
- * Gets the value of the userLabel property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getUserLabel() {
- return userLabel;
- }
-
- /**
- * Sets the value of the userLabel property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setUserLabel(String value) {
- this.userLabel = value;
- }
-
- /**
- * Gets the value of the swVersion property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getSwVersion() {
- return swVersion;
- }
-
- /**
- * Sets the value of the swVersion property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setSwVersion(String value) {
- this.swVersion = value;
- }
-
}
-
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <element name="job" minOccurs="0">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="jobId" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <element name="granPeriod">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
- * <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <element name="repPeriod" minOccurs="0">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * <choice>
- * <element name="measTypes">
- * <simpleType>
- * <list itemType="{http://www.w3.org/2001/XMLSchema}Name" />
- * </simpleType>
- * </element>
- * <element name="measType" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.w3.org/2001/XMLSchema>Name">
- * <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </element>
- * </choice>
- * <element name="measValue" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <choice>
- * <element name="measResults">
- * <simpleType>
- * <list itemType="{http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec}measResultType" />
- * </simpleType>
- * </element>
- * <element name="r" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec>measResultType">
- * <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </element>
- * </choice>
- * <element name="suspect" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
- * </sequence>
- * <attribute name="measObjLdn" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </element>
- * </sequence>
- * <attribute name="measInfoId" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"job",
@@ -1114,6 +147,7 @@ public class MeasCollecFile { "measType",
"measValue"
})
+ @Data
public static class MeasInfo {
protected MeasCollecFile.MeasData.MeasInfo.Job job;
@@ -1127,343 +161,32 @@ public class MeasCollecFile { @XmlAttribute(name = "measInfoId")
protected String measInfoId;
- /**
- * Gets the value of the job property.
- *
- * @return
- * possible object is
- * {@link MeasCollecFile.MeasData.MeasInfo.Job }
- *
- */
- public MeasCollecFile.MeasData.MeasInfo.Job getJob() {
- return job;
- }
-
- /**
- * Sets the value of the job property.
- *
- * @param value
- * allowed object is
- * {@link MeasCollecFile.MeasData.MeasInfo.Job }
- *
- */
- public void setJob(MeasCollecFile.MeasData.MeasInfo.Job value) {
- this.job = value;
- }
-
- /**
- * Gets the value of the granPeriod property.
- *
- * @return
- * possible object is
- * {@link MeasCollecFile.MeasData.MeasInfo.GranPeriod }
- *
- */
- public MeasCollecFile.MeasData.MeasInfo.GranPeriod getGranPeriod() {
- return granPeriod;
- }
-
- /**
- * Sets the value of the granPeriod property.
- *
- * @param value
- * allowed object is
- * {@link MeasCollecFile.MeasData.MeasInfo.GranPeriod }
- *
- */
- public void setGranPeriod(MeasCollecFile.MeasData.MeasInfo.GranPeriod value) {
- this.granPeriod = value;
- }
-
- /**
- * Gets the value of the repPeriod property.
- *
- * @return
- * possible object is
- * {@link MeasCollecFile.MeasData.MeasInfo.RepPeriod }
- *
- */
- public MeasCollecFile.MeasData.MeasInfo.RepPeriod getRepPeriod() {
- return repPeriod;
- }
-
- /**
- * Sets the value of the repPeriod property.
- *
- * @param value
- * allowed object is
- * {@link MeasCollecFile.MeasData.MeasInfo.RepPeriod }
- *
- */
- public void setRepPeriod(MeasCollecFile.MeasData.MeasInfo.RepPeriod value) {
- this.repPeriod = value;
- }
-
- /**
- * Gets the value of the measTypes property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the measTypes property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getMeasTypes().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link String }
- *
- *
- */
- public List<String> getMeasTypes() {
- if (measTypes == null) {
- measTypes = new ArrayList<String>();
- }
- return this.measTypes;
- }
-
- /**
- * Gets the value of the measType property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the measType property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getMeasType().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link MeasCollecFile.MeasData.MeasInfo.MeasType }
- *
- *
- */
- public List<MeasCollecFile.MeasData.MeasInfo.MeasType> getMeasType() {
- if (measType == null) {
- measType = new ArrayList<MeasCollecFile.MeasData.MeasInfo.MeasType>();
- }
- return this.measType;
- }
-
- /**
- * Gets the value of the measValue property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the measValue property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getMeasValue().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link MeasCollecFile.MeasData.MeasInfo.MeasValue }
- *
- *
- */
- public List<MeasCollecFile.MeasData.MeasInfo.MeasValue> getMeasValue() {
- if (measValue == null) {
- measValue = new ArrayList<MeasCollecFile.MeasData.MeasInfo.MeasValue>();
- }
- return this.measValue;
- }
-
- /**
- * Gets the value of the measInfoId property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getMeasInfoId() {
- return measInfoId;
- }
-
- /**
- * Sets the value of the measInfoId property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setMeasInfoId(String value) {
- this.measInfoId = value;
- }
-
-
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
- * <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
+ @Data
public static class GranPeriod {
-
@XmlAttribute(name = "duration", required = true)
protected Duration duration;
@XmlAttribute(name = "endTime", required = true)
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar endTime;
-
- /**
- * Gets the value of the duration property.
- *
- * @return
- * possible object is
- * {@link Duration }
- *
- */
- public Duration getDuration() {
- return duration;
- }
-
- /**
- * Sets the value of the duration property.
- *
- * @param value
- * allowed object is
- * {@link Duration }
- *
- */
- public void setDuration(Duration value) {
- this.duration = value;
- }
-
- /**
- * Gets the value of the endTime property.
- *
- * @return
- * possible object is
- * {@link XMLGregorianCalendar }
- *
- */
- public XMLGregorianCalendar getEndTime() {
- return endTime;
- }
-
- /**
- * Sets the value of the endTime property.
- *
- * @param value
- * allowed object is
- * {@link XMLGregorianCalendar }
- *
- */
- public void setEndTime(XMLGregorianCalendar value) {
- this.endTime = value;
- }
-
}
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="jobId" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
+ @Data
public static class Job {
-
@XmlAttribute(name = "jobId", required = true)
protected String jobId;
-
- /**
- * Gets the value of the jobId property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getJobId() {
- return jobId;
- }
-
- /**
- * Sets the value of the jobId property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setJobId(String value) {
- this.jobId = value;
- }
-
}
-
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.w3.org/2001/XMLSchema>Name">
- * <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"value"
})
+ @Data
public static class MeasType {
-
@XmlValue
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name = "Name")
@@ -1471,102 +194,16 @@ public class MeasCollecFile { @XmlAttribute(name = "p", required = true)
@XmlSchemaType(name = "positiveInteger")
protected BigInteger p;
-
- /**
- * Gets the value of the value property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Sets the value of the value property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setValue(String value) {
- this.value = value;
- }
-
- /**
- * Gets the value of the p property.
- *
- * @return
- * possible object is
- * {@link BigInteger }
- *
- */
- public BigInteger getP() {
- return p;
- }
-
- /**
- * Sets the value of the p property.
- *
- * @param value
- * allowed object is
- * {@link BigInteger }
- *
- */
- public void setP(BigInteger value) {
- this.p = value;
- }
-
}
-
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <sequence>
- * <choice>
- * <element name="measResults">
- * <simpleType>
- * <list itemType="{http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec}measResultType" />
- * </simpleType>
- * </element>
- * <element name="r" maxOccurs="unbounded" minOccurs="0">
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec>measResultType">
- * <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </element>
- * </choice>
- * <element name="suspect" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
- * </sequence>
- * <attribute name="measObjLdn" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"measResults",
"r",
"suspect"
})
+ @Data
public static class MeasValue {
-
@XmlList
protected List<String> measResults;
protected List<MeasCollecFile.MeasData.MeasInfo.MeasValue.R> r;
@@ -1574,256 +211,36 @@ public class MeasCollecFile { @XmlAttribute(name = "measObjLdn", required = true)
protected String measObjLdn;
- /**
- * Gets the value of the measResults property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the measResults property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getMeasResults().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link String }
- *
- *
- */
- public List<String> getMeasResults() {
- if (measResults == null) {
- measResults = new ArrayList<String>();
- }
- return this.measResults;
- }
-
- /**
- * Gets the value of the r property.
- *
- * <p>
- * This accessor method returns a reference to the live list,
- * not a snapshot. Therefore any modification you make to the
- * returned list will be present inside the JAXB object.
- * This is why there is not a <CODE>set</CODE> method for the r property.
- *
- * <p>
- * For example, to add a new item, do as follows:
- * <pre>
- * getR().add(newItem);
- * </pre>
- *
- *
- * <p>
- * Objects of the following type(s) are allowed in the list
- * {@link MeasCollecFile.MeasData.MeasInfo.MeasValue.R }
- *
- *
- */
- public List<MeasCollecFile.MeasData.MeasInfo.MeasValue.R> getR() {
- if (r == null) {
- r = new ArrayList<MeasCollecFile.MeasData.MeasInfo.MeasValue.R>();
- }
- return this.r;
- }
-
- /**
- * Gets the value of the suspect property.
- *
- * @return
- * possible object is
- * {@link Boolean }
- *
- */
- public Boolean isSuspect() {
- return suspect;
- }
-
- /**
- * Sets the value of the suspect property.
- *
- * @param value
- * allowed object is
- * {@link Boolean }
- *
- */
- public void setSuspect(Boolean value) {
- this.suspect = value;
- }
-
- /**
- * Gets the value of the measObjLdn property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getMeasObjLdn() {
- return measObjLdn;
- }
-
- /**
- * Sets the value of the measObjLdn property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setMeasObjLdn(String value) {
- this.measObjLdn = value;
- }
-
-
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <simpleContent>
- * <extension base="<http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec>measResultType">
- * <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
- * </extension>
- * </simpleContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"value"
})
+ @Data
public static class R {
-
@XmlValue
protected String value;
@XmlAttribute(name = "p", required = true)
@XmlSchemaType(name = "positiveInteger")
protected BigInteger p;
-
- /**
- * Gets the value of the value property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getValue() {
- return value;
- }
-
- /**
- * Sets the value of the value property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setValue(String value) {
- this.value = value;
- }
-
- /**
- * Gets the value of the p property.
- *
- * @return
- * possible object is
- * {@link BigInteger }
- *
- */
- public BigInteger getP() {
- return p;
- }
-
- /**
- * Sets the value of the p property.
- *
- * @param value
- * allowed object is
- * {@link BigInteger }
- *
- */
- public void setP(BigInteger value) {
- this.p = value;
- }
-
}
-
-
public void replaceR(List<R> filteredRs) {
this.r = filteredRs;
}
-
public void replaceMeasResults(List<String> filteredMeasResults) {
this.measResults = filteredMeasResults;
}
-
}
-
-
- /**
- * <p>Java class for anonymous complex type.
- *
- * <p>The following schema fragment specifies the expected content contained within this class.
- *
- * <pre>
- * <complexType>
- * <complexContent>
- * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- * <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
- * </restriction>
- * </complexContent>
- * </complexType>
- * </pre>
- *
- *
- */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
+ @Data
public static class RepPeriod {
@XmlAttribute(name = "duration", required = true)
protected Duration duration;
-
- /**
- * Gets the value of the duration property.
- *
- * @return
- * possible object is
- * {@link Duration }
- *
- */
- public Duration getDuration() {
- return duration;
- }
-
- /**
- * Sets the value of the duration property.
- *
- * @param value
- * allowed object is
- * {@link Duration }
- *
- */
- public void setDuration(Duration value) {
- this.duration = value;
- }
}
-
public void replaceMeasTypes(List<String> newMeasTypes) {
this.measTypes = newMeasTypes;
}
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/ServerHandler.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/ServerHandler.java new file mode 100644 index 0000000..9212375 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/ServerHandler.java @@ -0,0 +1,34 @@ +/* + * - + * * ============LICENSE_START======================================================= + * * Copyright (C) 2019 Nordix Foundation. + * * ================================================================================ + * * 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. + * * + * * SPDX-License-Identifier: Apache-2.0 + * * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcaegen2.services.pmmapper.model; + +import io.undertow.server.HttpHandler; + +public interface ServerHandler { + + String getMethod(); + + String getTemplate(); + + HttpHandler getHandler(); +} diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasSplitter.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasSplitter.java index 1821803..92d9e17 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasSplitter.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasSplitter.java @@ -42,7 +42,7 @@ public class MeasSplitter { public MeasSplitter(MeasConverter converter) {
this.converter = converter;
}
- +
/**
* Splits the MeasCollecFile to multiple MeasCollecFile based on the number of MeasData
**/
@@ -50,10 +50,10 @@ public class MeasSplitter { logger.unwrap().debug("Splitting 3GPP xml MeasData to individual MeasCollecFile");
MeasCollecFile currentMeasurement = converter.convert(event.getBody());
event.setMeasCollecFile(currentMeasurement);
- if(currentMeasurement.getMeasData().isEmpty()) {
+ if (currentMeasurement.getMeasData() == null || currentMeasurement.getMeasData().isEmpty()) {
throw new NoSuchElementException("MeasData is empty.");
}
- return currentMeasurement.getMeasData().stream().map( measData -> {
+ return currentMeasurement.getMeasData().stream().map(measData -> {
Event newEvent = generateNewEvent(event);
MeasCollecFile newMeasCollec = generateNewMeasCollec(newEvent,measData);
newEvent.setMeasCollecFile(newMeasCollec);
diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/RequestSender.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/RequestSender.java index 411196c..9938eed 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/RequestSender.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/RequestSender.java @@ -27,10 +27,12 @@ import java.io.OutputStream; import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
+import java.security.NoSuchAlgorithmException;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
+import org.onap.dcaegen2.services.pmmapper.exceptions.RequestFailure;
import org.onap.dcaegen2.services.pmmapper.exceptions.ServerResponseException;
import org.onap.dcaegen2.services.pmmapper.model.MapperConfig;
import org.onap.logging.ref.slf4j.ONAPLogAdapter;
@@ -56,7 +58,7 @@ public class RequestSender { * is set to {@code GET} by default.
* @see RequestSender#send(String,String,String)
*/
- public String send(final String urlString) throws Exception {
+ public String send(final String urlString) throws InterruptedException {
return send("GET", urlString);
}
@@ -65,7 +67,7 @@ public class RequestSender { * is set to empty String by default.
* @see RequestSender#send(String,String,String)
*/
- public String send(String method, final String urlString) throws Exception {
+ public String send(String method, final String urlString) throws InterruptedException {
return send(method,urlString,"");
}
@@ -74,7 +76,7 @@ public class RequestSender { * is set to empty String by default.
* @see RequestSender#send(String,String,String,String)
*/
- public String send(String method, final String urlString, final String body) throws Exception {
+ public String send(String method, final String urlString, final String body) throws InterruptedException {
return send(method,urlString,body,"");
}
@@ -85,56 +87,47 @@ public class RequestSender { * @param body of the request as json
* @param encodedCredentials base64-encoded username password credentials
* @return http response body
- * @throws Exception
+ * @throws InterruptedException
*/
- public String send(String method, final String urlString, final String body, final String encodedCredentials) throws Exception {
- String invocationID = Optional.ofNullable((String)MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID))
- .orElse(logger.invoke(ONAPLogConstants.InvocationMode.SYNCHRONOUS).toString());
+ public String send(String method, final String urlString, final String body, final String encodedCredentials)
+ throws InterruptedException {
+ String invocationID = Optional.ofNullable((String)MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID))
+ .orElse(logger.invoke(ONAPLogConstants.InvocationMode.SYNCHRONOUS).toString());
String requestID = Optional.ofNullable((String)MDC.get(ONAPLogConstants.MDCs.REQUEST_ID))
- .orElse( UUID.randomUUID().toString());
+ .orElse(UUID.randomUUID().toString());
String result = "";
+ boolean status = false;
+ int attempts = 1;
+ try {
+ while (!status && attempts <= MAX_RETRIES) {
+ final URL url = new URL(urlString);
+ final HttpURLConnection connection = getHttpURLConnection(method, url, invocationID, requestID);
+
+ if ("https".equalsIgnoreCase(url.getProtocol())) {
+ HttpsURLConnection.setDefaultSSLSocketFactory(SSLContext.getDefault().getSocketFactory());
+ }
- for (int i = 1; i <= MAX_RETRIES; i++) {
- final URL url = new URL(urlString);
- final HttpURLConnection connection = getHttpURLConnection(method, url, invocationID, requestID);
-
-
- if("https".equalsIgnoreCase(url.getProtocol())) {
- HttpsURLConnection.setDefaultSSLSocketFactory(SSLContext.getDefault().getSocketFactory());
- }
-
- if(!encodedCredentials.isEmpty()) {
- connection.setRequestProperty("Authorization", "Basic " + encodedCredentials);
- }
-
- if(!body.isEmpty()) {
- setMessageBody(connection, body);
- }
-
- logger.unwrap().info("Sending {} request to {}.", method, urlString);
-
- try (InputStream is = connection.getInputStream();
- BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
- result = reader.lines()
- .collect(Collectors.joining("\n"));
- int responseCode = connection.getResponseCode();
- if (!(isWithinErrorRange(responseCode))) {
- logger.unwrap().info("Response code: {}, Server Response Received:\n{}",responseCode, result);
- break;
+ if (!encodedCredentials.isEmpty()) {
+ connection.setRequestProperty("Authorization", "Basic " + encodedCredentials);
}
- } catch (Exception e) {
- if (retryLimitReached(i)) {
- logger.unwrap().error("Execution error: {}", connection.getResponseMessage(), e);
- throw new ServerResponseException(SERVER_ERROR_MESSAGE + ": " + connection.getResponseMessage(), e);
+
+ if (!body.isEmpty()) {
+ setMessageBody(connection, body);
}
+ result = getResult(attempts, connection);
+ status = !isWithinErrorRange(connection.getResponseCode());
+ attempts++;
+ Thread.sleep(RETRY_INTERVAL);
}
-
- Thread.sleep(RETRY_INTERVAL);
+ } catch (IOException | NoSuchAlgorithmException ex) {
+ logger.unwrap().warn("Request failure", ex);
+ throw new RequestFailure(ex);
}
return result;
}
- private HttpURLConnection getHttpURLConnection(String method, URL url, String invocationID, String requestID) throws IOException {
+ private HttpURLConnection getHttpURLConnection(String method, URL url, String invocationID, String requestID)
+ throws IOException {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setReadTimeout(DEFAULT_READ_TIMEOUT);
connection.setRequestProperty(ONAPLogConstants.Headers.REQUEST_ID, requestID);
@@ -161,4 +154,23 @@ public class RequestSender { private boolean isWithinErrorRange(final int responseCode) {
return responseCode >= ERROR_START_RANGE;
}
+
+ private String getResult(int attemptNumber, HttpURLConnection connection) throws IOException {
+ logger.unwrap().info("Sending {} request to {}.", connection.getRequestMethod(), connection.getURL());
+ String result = "";
+ try (InputStream is = connection.getInputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
+ result = reader.lines().collect(Collectors.joining("\n"));
+ int responseCode = connection.getResponseCode();
+ if (!(isWithinErrorRange(responseCode))) {
+ logger.unwrap().info("Response code: {}, Server Response Received:\n{}", responseCode, result);
+ }
+ } catch (Exception e) {
+ if (retryLimitReached(attemptNumber)) {
+ logger.unwrap().error("Execution error: {}", connection.getResponseMessage(), e);
+ throw new ServerResponseException(SERVER_ERROR_MESSAGE + ": " + connection.getResponseMessage(), e);
+ }
+ }
+ return result;
+ }
}
\ No newline at end of file |