aboutsummaryrefslogtreecommitdiffstats
path: root/datafile-commons/src/main/java
diff options
context:
space:
mode:
authorelinuxhenrik <henrik.b.andersson@est.tech>2019-03-26 10:22:23 +0100
committerelinuxhenrik <henrik.b.andersson@est.tech>2019-04-11 08:55:15 +0200
commit314a1e4310545e5b70ff64e328f3e7eae281c5b4 (patch)
tree0a96b6a05676f219db1dbaaa8fa65e36b534f325 /datafile-commons/src/main/java
parent5983d76f162aef34740a05ae4e78c7d9e2b3c20a (diff)
Housekeeping
No functional changes made in this commit. Removed CheckStyle and Sonar warnings. Formatted code. Renamed methods and classes for better understanding. Removed unnecessary classes. Moved all code to single project. Change-Id: Ie3feb6c6a985e94a382812aa083dcf57bc46c7b3 Issue-ID: DCAEGEN2-1367 Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
Diffstat (limited to 'datafile-commons/src/main/java')
-rw-r--r--datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/exceptions/DatafileTaskException.java35
-rw-r--r--datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/CommonFunctions.java63
-rw-r--r--datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/ConsumerDmaapModel.java73
-rw-r--r--datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/FileMetaData.java45
-rw-r--r--datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/MessageMetaData.java45
-rw-r--r--datafile-commons/src/main/java/org/onap/dcaegen2/collectors/datafile/model/logging/MappedDiagnosticContext.java92
6 files changed, 0 insertions, 353 deletions
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();
- }
-}