diff options
Diffstat (limited to 'datafile-commons')
9 files changed, 0 insertions, 561 deletions
diff --git a/datafile-commons/pom.xml b/datafile-commons/pom.xml deleted file mode 100644 index fdf62c6e..00000000 --- a/datafile-commons/pom.xml +++ /dev/null @@ -1,87 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ ============LICENSE_START======================================================= - ~ Copyright (C) 2018 NOKIA Intellectual Property, 2018 Nordix Foundation. All rights reserved. - ~ ================================================================================ - ~ 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. - ~ ============LICENSE_END========================================================= - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.onap.dcaegen2.collectors</groupId> - <artifactId>datafile</artifactId> - <version>1.1.1-SNAPSHOT</version> - </parent> - - <groupId>org.onap.dcaegen2.collectors.datafile</groupId> - <artifactId>datafile-commons</artifactId> - <packaging>jar</packaging> - - <dependencies> - <dependency> - <groupId>org.onap.dcaegen2.services.sdk.rest.services</groupId> - <artifactId>common-dependency</artifactId> - </dependency> - <dependency> - <groupId>org.immutables</groupId> - <artifactId>value</artifactId> - </dependency> - <dependency> - <groupId>org.immutables</groupId> - <artifactId>gson</artifactId> - </dependency> - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter-api</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter-engine</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>ch.qos.logback</groupId> - <artifactId>logback-classic</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jul-to-slf4j</artifactId> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>log4j-over-slf4j</artifactId> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-web</artifactId> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - </dependency> - <dependency> - <groupId>org.apache.httpcomponents</groupId> - <artifactId>httpclient</artifactId> - </dependency> - </dependencies> -</project> diff --git a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DatafileTaskException.java b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DatafileTaskException.java deleted file mode 100644 index 5e08efc7..00000000 --- a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DatafileTaskException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * ============LICENSE_START====================================================================== - * Copyright (C) 2018-2019 Nordix Foundation. All rights reserved. - * =============================================================================================== - * 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. - * ============LICENSE_END======================================================================== - */ - -package org.onap.dcaegen2.collectors.datafile.exceptions; - -/** - * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a> - */ -public class DatafileTaskException extends Exception { - - private static final long serialVersionUID = 1L; - - public DatafileTaskException(String message) { - super(message); - } - - public DatafileTaskException(String message, Exception e) { - super(message, e); - } -} diff --git a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctions.java b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctions.java deleted file mode 100644 index f115dba7..00000000 --- a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctions.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * ============LICENSE_START====================================================================== - * Copyright (C) 2018 NOKIA Intellectual Property, 2018-2019 Nordix Foundation. All rights reserved. - * =============================================================================================== - * 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. - * ============LICENSE_END======================================================================== - */ - -package org.onap.dcaegen2.collectors.datafile.model; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -import java.lang.reflect.Type; -import java.nio.file.Path; - -/** - * Helper class to serialize object. - */ -public class CommonFunctions { - - private static Gson gson = - new GsonBuilder().registerTypeHierarchyAdapter(Path.class, new PathConverter()).serializeNulls().create(); - - private CommonFunctions() { - } - - /** - * Serializes a <code>ConsumerDmaapModel</code>. - * - * @param consumerDmaapModel model to serialize. - * - * @return a string with the serialized model. - */ - public static String createJsonBody(ConsumerDmaapModel consumerDmaapModel) { - return gson.toJson(consumerDmaapModel); - } - - /** - * Json serializer that handles Path serializations, since <code>Path</code> does not implement the - * <code>Serializable</code> interface. - */ - public static class PathConverter implements JsonSerializer<Path> { - @Override - public JsonElement serialize(Path path, Type type, JsonSerializationContext jsonSerializationContext) { - return new JsonPrimitive(path.toString()); - } - } -} diff --git a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModel.java b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModel.java deleted file mode 100644 index 2337485a..00000000 --- a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModel.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * ============LICENSE_START====================================================================== - * Copyright (C) 2018 NOKIA Intellectual Property, 2018-2019 Nordix Foundation. All rights reserved. - * =============================================================================================== - * 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. - * ============LICENSE_END======================================================================== - */ - -package org.onap.dcaegen2.collectors.datafile.model; - -import com.google.gson.annotations.SerializedName; - -import java.nio.file.Path; - -import org.immutables.gson.Gson; -import org.immutables.value.Value; -import org.onap.dcaegen2.services.sdk.rest.services.model.DmaapModel; - -/** - * @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 5/8/18 - * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a> - */ - -@Value.Immutable -@Gson.TypeAdapters -public interface ConsumerDmaapModel extends DmaapModel { - - @SerializedName("productName") - String getProductName(); - - @SerializedName("vendorName") - String getVendorName(); - - @SerializedName("lastEpochMicrosec") - String getLastEpochMicrosec(); - - @SerializedName("sourceName") - String getSourceName(); - - @SerializedName("startEpochMicrosec") - String getStartEpochMicrosec(); - - @SerializedName("timeZoneOffset") - String getTimeZoneOffset(); - - @SerializedName("name") - String getName(); - - @SerializedName("location") - String getLocation(); - - @SerializedName("internalLocation") - Path getInternalLocation(); - - @SerializedName("compression") - String getCompression(); - - @SerializedName("fileFormatType") - String getFileFormatType(); - - @SerializedName("fileFormatVersion") - String getFileFormatVersion(); - - -} diff --git a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/FileMetaData.java b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/FileMetaData.java deleted file mode 100644 index c50148b4..00000000 --- a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/FileMetaData.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018-2019 Nordix Foundation. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.collectors.datafile.model; - -import org.immutables.gson.Gson; -import org.immutables.value.Value; - -/** - * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a> - */ -@Value.Immutable -@Gson.TypeAdapters -public interface FileMetaData { - String productName(); - - String vendorName(); - - String lastEpochMicrosec(); - - String sourceName(); - - String startEpochMicrosec(); - - String timeZoneOffset(); - - String changeIdentifier(); - - String changeType(); -} diff --git a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/MessageMetaData.java b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/MessageMetaData.java deleted file mode 100644 index 012de744..00000000 --- a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/MessageMetaData.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018-2019 Nordix Foundation. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.dcaegen2.collectors.datafile.model; - -import org.immutables.gson.Gson; -import org.immutables.value.Value; - -/** - * @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a> - */ -@Value.Immutable -@Gson.TypeAdapters -public interface MessageMetaData { - public String productName(); - - public String vendorName(); - - public String lastEpochMicrosec(); - - public String sourceName(); - - public String startEpochMicrosec(); - - public String timeZoneOffset(); - - public String changeIdentifier(); - - public String changeType(); -} diff --git a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/logging/MappedDiagnosticContext.java b/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/logging/MappedDiagnosticContext.java deleted file mode 100644 index bda889c2..00000000 --- a/datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/logging/MappedDiagnosticContext.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ============LICENSE_START====================================================================== - * Copyright (C) 2018 NOKIA Intellectual Property, 2019 Nordix Foundation. All rights reserved. - * =============================================================================================== - * 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. - * ============LICENSE_END======================================================================== - */ - -package org.onap.dcaegen2.collectors.datafile.model.logging; - -import java.util.Map; -import java.util.UUID; - -import org.apache.commons.lang3.StringUtils; -import org.apache.http.client.methods.HttpRequestBase; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.slf4j.Marker; -import org.slf4j.MarkerFactory; -import org.springframework.http.HttpHeaders; - -/** - * Support functions for MDC - */ -public final class MappedDiagnosticContext { - - private static final String X_ONAP_REQUEST_ID = "X-ONAP-RequestID"; - private static final String X_INVOCATION_ID = "X-InvocationID"; - private static final String REQUEST_ID = "RequestID"; - private static final String INVOCATION_ID = "InvocationID"; - public static final String RESPONSE_CODE = "ResponseCode"; - public static final String SERVICE_NAME = "ServiceName"; - - public static final Marker ENTRY = MarkerFactory.getMarker("ENTRY"); - public static final Marker EXIT = MarkerFactory.getMarker("EXIT"); - private static final Marker INVOKE = MarkerFactory.getMarker("INVOKE"); - - private static final Logger logger = LoggerFactory.getLogger(MappedDiagnosticContext.class); - - private MappedDiagnosticContext() {} - - /** - * Inserts the relevant trace information in the HTTP header - * @param httpRequest a request - */ - public static void appendTraceInfo(HttpRequestBase httpRequest) { - String requestId = MDC.get(REQUEST_ID); - httpRequest.addHeader(X_ONAP_REQUEST_ID, requestId); - httpRequest.addHeader("X-RequestID", requestId); // deprecated - httpRequest.addHeader("X-TransactionID", requestId); // deprecated - - String invocationId = UUID.randomUUID().toString(); - httpRequest.addHeader(X_INVOCATION_ID, invocationId); - logger.info(INVOKE, "Invoking request with invocation ID {}", invocationId); - } - - /** - * Initialize MDC from relevant information in a received HTTP header - * @param headers a received HTPP header - */ - public static void initializeTraceContext(HttpHeaders headers) { - String requestId = headers.getFirst(X_ONAP_REQUEST_ID); - if (StringUtils.isBlank(requestId)) { - requestId = UUID.randomUUID().toString(); - } - String invocationId = headers.getFirst(X_INVOCATION_ID); - if (StringUtils.isBlank(invocationId)) { - invocationId = UUID.randomUUID().toString(); - } - MDC.put(REQUEST_ID, requestId); - MDC.put(INVOCATION_ID, invocationId); - } - - /** - * Initialize the MDC when a new context is started. - * @return a copy of the new trace context - */ - public static Map<String, String> initializeTraceContext() { - MDC.clear(); - MDC.put(REQUEST_ID, UUID.randomUUID().toString()); - return MDC.getCopyOfContextMap(); - } -} diff --git a/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctionsTest.java b/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctionsTest.java deleted file mode 100644 index 25f0dbfc..00000000 --- a/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctionsTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============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.collectors.datafile.model; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.nio.file.Paths; - -import org.junit.jupiter.api.Test; - -public class CommonFunctionsTest { - @Test - public void createJsonBody_success() { - ImmutableConsumerDmaapModel consumerDmaapModel = ImmutableConsumerDmaapModel // - .builder() // - .productName("") // - .vendorName("") // - .lastEpochMicrosec("") // - .sourceName("") // - .startEpochMicrosec("") // - .timeZoneOffset("") // - .name("") // - .location("") // - .internalLocation(Paths.get("internalLocation")) // - .compression("") // - .fileFormatType("") // - .fileFormatVersion("") // - .build(); - String actualBody = CommonFunctions.createJsonBody(consumerDmaapModel); - - assertTrue(actualBody.contains("\"internalLocation\":\"internalLocation\"")); - } -} diff --git a/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModelTest.java b/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModelTest.java deleted file mode 100644 index 0c1ac436..00000000 --- a/datafile-commons/src/test/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModelTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * ============LICENSE_START====================================================================== - * Copyright (C) 2018 NOKIA Intellectual Property, 2018-2019 Nordix Foundation. All rights reserved. - * =============================================================================================== - * 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. - * ============LICENSE_END======================================================================== - */ - -package org.onap.dcaegen2.collectors.datafile.model; - -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -public class ConsumerDmaapModelTest { - private static final String PRODUCT_NAME = "NrRadio"; - private static final String VENDOR_NAME = "Ericsson"; - private static final String LAST_EPOCH_MICROSEC = "8745745764578"; - private static final String SOURCE_NAME = "oteNB5309"; - private static final String START_EPOCH_MICROSEC = "8745745764578"; - private static final String TIME_ZONE_OFFSET = "UTC+05:00"; - private static final String NAME = "A20161224.1030-1045.bin.gz"; - private static final String LOCATION = "ftpes://192.168.0.101:22/ftp/rop/A20161224.1030-1145.bin.gz"; - private static final Path INTERNAL_LOCATION = Paths.get("target/A20161224.1030-1045.bin.gz"); - private static final String COMPRESSION = "gzip"; - private static final String FILE_FORMAT_TYPE = "org.3GPP.32.435#measCollec"; - private static final String FILE_FORMAT_VERSION = "V10"; - - @Test - public void consumerDmaapModelBuilder_shouldBuildAnObject() { - ConsumerDmaapModel consumerDmaapModel = ImmutableConsumerDmaapModel.builder() // - .productName(PRODUCT_NAME) // - .vendorName(VENDOR_NAME) // - .lastEpochMicrosec(LAST_EPOCH_MICROSEC) // - .sourceName(SOURCE_NAME) // - .startEpochMicrosec(START_EPOCH_MICROSEC) // - .timeZoneOffset(TIME_ZONE_OFFSET) // - .name(NAME) // - .location(LOCATION) // - .internalLocation(INTERNAL_LOCATION) // - .compression(COMPRESSION) // - .fileFormatType(FILE_FORMAT_TYPE) // - .fileFormatVersion(FILE_FORMAT_VERSION) // - .build(); - - Assertions.assertNotNull(consumerDmaapModel); - Assertions.assertEquals(PRODUCT_NAME, consumerDmaapModel.getProductName()); - Assertions.assertEquals(VENDOR_NAME, consumerDmaapModel.getVendorName()); - Assertions.assertEquals(LAST_EPOCH_MICROSEC, consumerDmaapModel.getLastEpochMicrosec()); - Assertions.assertEquals(SOURCE_NAME, consumerDmaapModel.getSourceName()); - Assertions.assertEquals(START_EPOCH_MICROSEC, consumerDmaapModel.getStartEpochMicrosec()); - Assertions.assertEquals(TIME_ZONE_OFFSET, consumerDmaapModel.getTimeZoneOffset()); - Assertions.assertEquals(NAME, consumerDmaapModel.getName()); - Assertions.assertEquals(LOCATION, consumerDmaapModel.getLocation()); - Assertions.assertEquals(INTERNAL_LOCATION, consumerDmaapModel.getInternalLocation()); - Assertions.assertEquals(COMPRESSION, consumerDmaapModel.getCompression()); - Assertions.assertEquals(FILE_FORMAT_TYPE, consumerDmaapModel.getFileFormatType()); - Assertions.assertEquals(FILE_FORMAT_VERSION, consumerDmaapModel.getFileFormatVersion()); - } -} |