</parent>
<groupId>org.o-ran-sc.nonrtric.plt.ranpm</groupId>
<artifactId>datafile-app-server</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<java.version>17</java.version>
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
- <docker-client.version>8.7.1</docker-client.version>
- <springfox.version>3.0.0</springfox.version>
- <gson.version>2.9.0</gson.version>
+ <gson.version>2.9.1</gson.version>
<docker-maven-plugin>0.30.0</docker-maven-plugin>
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
+ <springdoc.version>2.0.2</springdoc.version>
+ <springdoc.openapi-ui.version>1.6.14</springdoc.openapi-ui.version>
+ <exec.skip>true</exec.skip>
</properties>
<dependencies>
+ <dependency>
+ <groupId>org.springdoc</groupId>
+ <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
+ <version>${springdoc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springdoc</groupId>
+ <artifactId>springdoc-openapi-ui</artifactId>
+ <version>${springdoc.openapi-ui.version}</version>
+ </dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
- <version>2.9.1</version>
+ <version>${gson.version}</version>
</dependency>
<dependency>
<groupId>io.projectreactor.kafka</groupId>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
- <dependency>
- <groupId>com.spotify</groupId>
- <artifactId>docker-client</artifactId>
- <version>${docker-client.version}</version>
- </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webflux</artifactId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <version>5.7.0</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
- <!--REQUIRED
- TO GENERATE DOCUMENTATION -->
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-spring-web</artifactId>
- <version>${springfox.version}</version>
- </dependency>
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-spi</artifactId>
- <version>${springfox.version}</version>
- </dependency>
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-core</artifactId>
- <version>${springfox.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springdoc</groupId>
- <artifactId>springdoc-openapi-ui</artifactId>
- <version>1.6.3</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger2</artifactId>
- <version>${springfox.version}</version>
- </dependency>
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger-ui</artifactId>
- <version>${springfox.version}</version>
- </dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
- <version>3.6</version>
+ <version>3.9.0</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>pl.project13.maven</groupId>
- <artifactId>git-commit-id-plugin</artifactId>
- <executions>
- <execution>
- <id>get-the-git-infos</id>
- <goals>
- <goal>revision</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <verbose>true</verbose>
- <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
- <dateFormat>MM-dd-yyyy '@' HH:mm:ss Z</dateFormat>
- <generateGitPropertiesFile>true</generateGitPropertiesFile>
- <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
- </generateGitPropertiesFilename>
- <failOnNoGitDirectory>true</failOnNoGitDirectory>
- </configuration>
- </plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
package org.onap.dcaegen2.collectors.datafile.controllers;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.onap.dcaegen2.collectors.datafile.model.Counters;
@Operation(summary = "Returns liveness of DATAFILE service")
@ApiResponses(
value = { //
- @ApiResponse(code = 200, message = "DATAFILE service is living"),
- @ApiResponse(code = 401, message = "You are not authorized to view the resource"),
- @ApiResponse(code = 403, message = "Accessing the resource you were trying to reach is forbidden"),
- @ApiResponse(code = 404, message = "The resource you were trying to reach is not found")})
+ @ApiResponse(responseCode = "200", description = "DATAFILE service is living"),
+ @ApiResponse(responseCode = "401", description = "You are not authorized to view the resource"),
+ @ApiResponse(
+ responseCode = "403",
+ description = "Accessing the resource you were trying to reach is forbidden"),
+ @ApiResponse(responseCode = "404", description = "The resource you were trying to reach is not found")})
public Mono<ResponseEntity<String>> heartbeat(@RequestHeader HttpHeaders headers) {
logger.info("ENTRY {}", "Heartbeat request");
@Operation(summary = "Returns status and statistics of DATAFILE service")
@ApiResponses(
value = { //
- @ApiResponse(code = 200, message = "DATAFILE service is living"),
- @ApiResponse(code = 401, message = "You are not authorized to view the resource"),
- @ApiResponse(code = 403, message = "Accessing the resource you were trying to reach is forbidden"),
- @ApiResponse(code = 404, message = "The resource you were trying to reach is not found")})
+ @ApiResponse(responseCode = "200", description = "DATAFILE service is living"),
+ @ApiResponse(responseCode = "401", description = "You are not authorized to view the resource"),
+ @ApiResponse(
+ responseCode = "403",
+ description = "Accessing the resource you were trying to reach is forbidden"),
+ @ApiResponse(responseCode = "404", description = "The resource you were trying to reach is not found")})
public Mono<ResponseEntity<String>> status(@RequestHeader HttpHeaders headers) {
logger.info("ENTRY {}", "Status request");
import org.onap.dcaegen2.collectors.datafile.model.FileReadyMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;
*
* @param applicationConfiguration - application configuration
*/
- @Autowired
public CollectAndReportFiles(AppConfig applicationConfiguration) {
this.appConfig = applicationConfiguration;
this.kafkaSender = KafkaSender.create(kafkaSenderOptions());
package org.onap.dcaegen2.collectors.datafile.tasks;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.Optional;
-import org.apache.commons.io.FileUtils;
import org.onap.dcaegen2.collectors.datafile.commons.FileCollectClient;
import org.onap.dcaegen2.collectors.datafile.commons.Scheme;
import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
try (FileCollectClient currentClient = createClient(fileData)) {
currentClient.open();
- FileUtils.forceMkdirParent(localFile.toFile());
+ Files.createDirectories(localFile.getParent());
currentClient.collectFile(remoteFile, localFile);
counters.incNoOfCollectedFiles();
return Mono.just(Optional.of(createFilePublishInformation(fileData)));
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import java.io.File;
import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
-import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.context.annotation.Bean;
import org.springframework.test.context.TestPropertySource;
+import org.springframework.util.FileSystemUtils;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
-@TestPropertySource(properties = { //
+@TestPropertySource(
+ properties = { //
"app.ssl.key-store-password-file=./config/ftps_keystore.pass", //
"app.ssl.key-store=./config/ftps_keystore.p12", //
"app.ssl.trust-store-password-file=./config/truststore.pass", //
"app.s3.accessKeyId=minio", //
"app.s3.secretAccessKey=miniostorage", //
"app.s3.bucket=ropfiles", //
- "app.s3.locksBucket=locks" })
+ "app.s3.locksBucket=locks"})
@SuppressWarnings("squid:S3577") // Not containing any tests since it is a mock.
class MockDatafile {
private static final String PM_FILE_NAME = "PM_FILE_NAME";
// This can be any downloadable file on the net
- private static final String FTPES_LOCATION = "ftpes:// onap:pano@ftp-ftpes-6:2021/A20000626.2315+0200-2330+0200_GNODEB-15-4.xml.gz";
- private static final String LOCATION = "https://launchpad.net/ubuntu/+source/perf-tools-unstable/1.0+git7ffb3fd-1ubuntu1/+build/13630748/+files/perf-tools-unstable_1.0+git7ffb3fd-1ubuntu1_all.deb";
+ private static final String FTPES_LOCATION =
+ "ftpes:// onap:pano@ftp-ftpes-6:2021/A20000626.2315+0200-2330+0200_GNODEB-15-4.xml.gz";
+ private static final String LOCATION =
+ "https://launchpad.net/ubuntu/+source/perf-tools-unstable/1.0+git7ffb3fd-1ubuntu1/+build/13630748/+files/perf-tools-unstable_1.0+git7ffb3fd-1ubuntu1_all.deb";
private static final String GZIP_COMPRESSION = "gzip";
private static final String FILE_FORMAT_TYPE = "org.3GPP.32.435#measCollec";
private static final String FILE_FORMAT_VERSION = "V10";
private static final Logger logger = LoggerFactory.getLogger(MockDatafile.class);
private static Gson gson = new GsonBuilder() //
- .disableHtmlEscaping() //
- .create(); //
+ .disableHtmlEscaping() //
+ .create(); //
@LocalServerPort
private int port;
// Create a listener to the output topic. The KafkaTopicListener happens to be
// suitable for that,
- KafkaTopicListener topicListener = new KafkaTopicListener(applicationConfig.getKafkaBootStrapServers(),
- "MockDatafile", outputTopic);
+ KafkaTopicListener topicListener =
+ new KafkaTopicListener(applicationConfig.getKafkaBootStrapServers(), "MockDatafile", outputTopic);
topicListener.getFlux() //
- .doOnNext(this::set) //
- .doFinally(sig -> logger.info("Finally " + sig)) //
- .subscribe();
+ .doOnNext(this::set) //
+ .doFinally(sig -> logger.info("Finally " + sig)) //
+ .subscribe();
}
private void set(DataFromTopic receivedKafkaOutput) {
FilePublishInformation i = fc.createFilePublishInformation(fileData);
try {
- File from = new File("config/application.yaml");
- File to = new File(this.appConfig.collectedFilesPath + "/" + fileData.name());
- FileUtils.forceMkdirParent(to);
- com.google.common.io.Files.copy(from, to);
+ Path from = Path.of("config/application.yaml");
+ Path to = Path.of(this.appConfig.collectedFilesPath, fileData.name());
+ Files.createDirectories(to.getParent());
+ Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
} catch (Exception e) {
logger.error("Could not copy file {}", e.getMessage());
}
}
private void deleteAllFiles() {
-
try {
- FileUtils.deleteDirectory(new File(this.appConfig.collectedFilesPath));
+ FileSystemUtils.deleteRecursively(Path.of(this.appConfig.collectedFilesPath));
} catch (IOException e) {
}
}
Instant startTime = Instant.now();
Flux.range(1, NO_OF_OBJECTS) //
- .map(i -> gson.toJson(fileReadyMessage("testS3Concurrency_" + i))) //
- .flatMap(fileReadyMessage -> scheduledTask.sendDataToStream(appConfig.fileReadyEventTopic, "key",
- fileReadyMessage)) //
- .blockLast(); //
+ .map(i -> gson.toJson(fileReadyMessage("testS3Concurrency_" + i))) //
+ .flatMap(fileReadyMessage -> scheduledTask.sendDataToStream(appConfig.fileReadyEventTopic, "key",
+ fileReadyMessage)) //
+ .blockLast(); //
while (kafkaReceiver.count < NO_OF_OBJECTS) {
logger.info("sleeping {}", kafkaReceiver.count);
FileReadyMessage.Event event(String fileName) {
MessageMetaData messageMetaData = MessageMetaData.builder() //
- .lastEpochMicrosec(LAST_EPOCH_MICROSEC) //
- .sourceName(SOURCE_NAME) //
- .startEpochMicrosec(START_EPOCH_MICROSEC) //
- .timeZoneOffset(TIME_ZONE_OFFSET) //
- .changeIdentifier(CHANGE_IDENTIFIER) //
- .eventName("Noti_RnNode-Ericsson_FileReady").build();
+ .lastEpochMicrosec(LAST_EPOCH_MICROSEC) //
+ .sourceName(SOURCE_NAME) //
+ .startEpochMicrosec(START_EPOCH_MICROSEC) //
+ .timeZoneOffset(TIME_ZONE_OFFSET) //
+ .changeIdentifier(CHANGE_IDENTIFIER) //
+ .eventName("Noti_RnNode-Ericsson_FileReady").build();
FileReadyMessage.FileInfo fileInfo = FileReadyMessage.FileInfo //
- .builder() //
- .fileFormatType(FILE_FORMAT_TYPE) //
- .location(LOCATION) //
- .fileFormatVersion(FILE_FORMAT_VERSION) //
- .compression(GZIP_COMPRESSION) //
- .build();
+ .builder() //
+ .fileFormatType(FILE_FORMAT_TYPE) //
+ .location(LOCATION) //
+ .fileFormatVersion(FILE_FORMAT_VERSION) //
+ .compression(GZIP_COMPRESSION) //
+ .build();
FileReadyMessage.ArrayOfNamedHashMap arrayOfNamedHashMap = FileReadyMessage.ArrayOfNamedHashMap //
- .builder() //
- .name(fileName) //
- .hashMap(fileInfo) //
- .build();
+ .builder() //
+ .name(fileName) //
+ .hashMap(fileInfo) //
+ .build();
List<FileReadyMessage.ArrayOfNamedHashMap> arrayOfNamedHashMapList = new ArrayList<>();
arrayOfNamedHashMapList.add(arrayOfNamedHashMap);
FileReadyMessage.NotificationFields notificationFields = FileReadyMessage.NotificationFields //
- .builder().notificationFieldsVersion("notificationFieldsVersion") //
- .changeType(CHANGE_TYPE).changeIdentifier(CHANGE_IDENTIFIER) //
- .arrayOfNamedHashMap(arrayOfNamedHashMapList) //
- .build();
+ .builder().notificationFieldsVersion("notificationFieldsVersion") //
+ .changeType(CHANGE_TYPE).changeIdentifier(CHANGE_IDENTIFIER) //
+ .arrayOfNamedHashMap(arrayOfNamedHashMapList) //
+ .build();
return FileReadyMessage.Event.builder() //
- .commonEventHeader(messageMetaData) //
- .notificationFields(notificationFields).build();
+ .commonEventHeader(messageMetaData) //
+ .notificationFields(notificationFields).build();
}
private FileReadyMessage fileReadyMessage(String fileName) {
FileReadyMessage message = FileReadyMessage.builder() //
- .event(event(fileName)) //
- .build();
+ .event(event(fileName)) //
+ .build();
return message;
}
@Override
public void setParams(HttpParams params) {
}
-
};
}
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
<swagger-codegen-maven-plugin.version>3.0.11</swagger-codegen-maven-plugin.version>
<springdoc.version>2.0.2</springdoc.version>
+ <springdoc.openapi-ui.version>1.6.14</springdoc.openapi-ui.version>
<exec.skip>true</exec.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
- <version>${springdoc.version}</version>
+ <version>${springdoc.openapi-ui.version}</version>
</dependency>
<dependency>
<groupId>com.influxdb</groupId>
</dependency>
<!-- TEST -->
<!-- https://mvnrepository.com/artifact/com.github.erosb/everit-json-schema -->
- <dependency>
- <groupId>org.springdoc</groupId>
- <artifactId>springdoc-openapi-ui</artifactId>
- <version>1.6.3</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>com.github.erosb</groupId>
<artifactId>everit-json-schema</artifactId>
<system>JIRA</system>
<url>https://jira.o-ran-sc.org/</url>
</issueManagement>
-</project>
\ No newline at end of file
+</project>
</parent>
<groupId>org.o-ran-sc.nonrtric.plt</groupId>
<artifactId>pmproducer</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<docker-maven-plugin>0.30.0</docker-maven-plugin>
<sonar-maven-plugin.version>3.7.0.1746</sonar-maven-plugin.version>
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
- <exec.skip>true</exec.skip>
- <protobuf.version>4.0.0-rc-2</protobuf.version>
- <protobuf-java-format.version>1.4</protobuf-java-format.version>
<springdoc.version>2.0.2</springdoc.version>
+ <springdoc.openapi-ui.version>1.6.14</springdoc.openapi-ui.version>
+ <exec.skip>true</exec.skip>
</properties>
<dependencies>
<dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
- <version>${springdoc.version}</version>
- </dependency>
- <dependency>
- <groupId>com.google.protobuf</groupId>
- <artifactId>protobuf-java</artifactId>
- <version>${protobuf.version}</version>
- </dependency>
- <dependency>
- <groupId>com.googlecode.protobuf-java-format</groupId>
- <artifactId>protobuf-java-format</artifactId>
- <version>${protobuf-java-format.version}</version>
- </dependency>
- <dependency>
- <groupId>com.google.protobuf</groupId>
- <artifactId>protobuf-java-util</artifactId>
- <version>3.21.5</version>
+ <version>${springdoc.openapi-ui.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
</dependency>
<!-- TEST -->
<!-- https://mvnrepository.com/artifact/com.github.erosb/everit-json-schema -->
- <dependency>
- <groupId>org.springdoc</groupId>
- <artifactId>springdoc-openapi-ui</artifactId>
- <version>1.6.3</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>com.github.erosb</groupId>
<artifactId>everit-json-schema</artifactId>
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
-import com.google.protobuf.AbstractMessage.Builder;
-import com.google.protobuf.Message;
-import com.google.protobuf.MessageOrBuilder;
-import com.google.protobuf.util.JsonFormat;
-import java.io.IOException;
import java.lang.invoke.MethodHandles;
-import java.lang.reflect.InvocationTargetException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
class PmReportFilterTest {
- public static class ProtoJsonUtil {
-
- /**
- * Makes a Json from a given message or builder
- *
- * @param messageOrBuilder is the instance
- * @return The string representation
- * @throws IOException if any error occurs
- */
- public static String toJson(MessageOrBuilder messageOrBuilder) throws IOException {
- return JsonFormat.printer().print(messageOrBuilder);
- }
-
- /**
- * Makes a new instance of message based on the json and the class
- *
- * @param <T> is the class type
- * @param json is the json instance
- * @param clazz is the class instance
- * @return An instance of T based on the json values
- * @throws IOException if any error occurs
- */
- @SuppressWarnings({"unchecked", "rawtypes"})
- public static <T extends Message> T fromJson(String json, Class<T> clazz) throws IOException {
- // https://stackoverflow.com/questions/27642021/calling-parsefrom-method-for-generic-protobuffer-class-in-java/33701202#33701202
- Builder builder = null;
- try {
- // Since we are dealing with a Message type, we can call newBuilder()
- builder = (Builder) clazz.getMethod("newBuilder").invoke(null);
-
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | NoSuchMethodException | SecurityException e) {
- return null;
- }
-
- // The instance is placed into the builder values
- JsonFormat.parser().ignoringUnknownFields().merge(json, builder);
-
- // the instance will be from the build
- return (T) builder.build();
- }
- }
-
private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static Gson gson = new GsonBuilder() //