- rename package name from org.onap.portal.prefs to org.onap.portalng.preferences
- replace all other occurences of portal-prefs with preferences
Other:
- remove Sonarqube plugin
Issue-ID: PORTALNG-39
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Change-Id: Iced79a26460d988c5b22eb5fcac86d350528a1a2
-# Portal-prefs
+# Preferences
This microservice manages the user specific config for the `portal-ui` frontend application. It is a Spring Boot application that is build upon a MongoDB and Webflux.
## Build
development/run.sh
```
-Example request against the portal-prefs service can be run in your preferred IDE with the `request.http` file from the development folder.
+Example request against the preferences service can be run in your preferred IDE with the `request.http` file from the development folder.
You can access the Keycloak UI via browser.
URL: http://localhost:8080
**username:** admin
**password:** password
-To stop the portal-prefs service, Keycloak and the databases run:
+To stop the preferences service, Keycloak and the databases run:
```sh
development/stop.sh
```
id 'io.spring.dependency-management'
id 'org.springframework.boot'
id 'jacoco'
- id 'org.sonarqube'
id 'com.gorylenko.gradle-git-properties'
}
targetCompatibility = '17'
application {
- mainClass = 'org.onap.portal.prefs.PortalPrefsApplication'
+ mainClass = 'org.onap.portalng.preferences.PreferencesApplication'
}
configurations {
}
}
-sonarqube {
- properties {
- property "sonar.projectKey", "tnap.SONAR.portal.portal-prefs"
- property "sonar.projectName", "portal-prefs"
- }
-}
-
configurations.implementation.setCanBeResolved(true)
// avoid generating X.X.X-plain.jar
springBoot {
buildInfo {
properties {
- artifact = "onap-portal-prefs"
+ artifact = "onap-portal-ng-preferences"
version = rootProject.file('version').text.trim()
- group = "org.onap"
- name = "Portal user preferences service"
+ group = "org.onap.portalng"
+ name = "Portal-ng user preferences service"
}
}
}
*
*/
-package org.onap.portal.prefs;
+package org.onap.portalng.preferences;
-import org.onap.portal.prefs.configuration.PortalPrefsConfig;
+import org.onap.portalng.preferences.configuration.PreferencesConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
-@EnableConfigurationProperties(PortalPrefsConfig.class)
+@EnableConfigurationProperties(PreferencesConfig.class)
@SpringBootApplication
-public class PortalPrefsApplication {
+public class PreferencesApplication {
public static void main(String[] args) {
- SpringApplication.run(PortalPrefsApplication.class, args);
+ SpringApplication.run(PreferencesApplication.class, args);
}
}
*
*/
-package org.onap.portal.prefs.configuration;
+package org.onap.portalng.preferences.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
*
*/
-package org.onap.portal.prefs.configuration;
+package org.onap.portalng.preferences.configuration;
-import org.onap.portal.prefs.util.Logger;
+import org.onap.portalng.preferences.util.Logger;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.reactive.ServerWebExchangeContextFilter;
import org.springframework.web.server.ServerWebExchange;
*
*/
-package org.onap.portal.prefs.configuration;
+package org.onap.portalng.preferences.configuration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import lombok.Data;
@Data
-@ConfigurationProperties("portal-prefs")
-public class PortalPrefsConfig {
+@ConfigurationProperties("preferences")
+public class PreferencesConfig {
@NotBlank
private final String realm;
*
*/
-package org.onap.portal.prefs.configuration;
+package org.onap.portalng.preferences.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
*
*/
-package org.onap.portal.prefs.controller;
-import org.onap.portal.prefs.exception.ProblemException;
-import org.onap.portal.prefs.openapi.api.PreferencesApi;
-import org.onap.portal.prefs.openapi.model.Preferences;
-import org.onap.portal.prefs.services.PreferencesService;
-import org.onap.portal.prefs.util.IdTokenExchange;
-import org.onap.portal.prefs.util.Logger;
+package org.onap.portalng.preferences.controller;
+import org.onap.portalng.preferences.exception.ProblemException;
+import org.onap.portalng.preferences.openapi.api.PreferencesApi;
+import org.onap.portalng.preferences.openapi.model.Preferences;
+import org.onap.portalng.preferences.services.PreferencesService;
+import org.onap.portalng.preferences.util.IdTokenExchange;
+import org.onap.portalng.preferences.util.Logger;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
preferencesService.getPreferences(userid)
.map(ResponseEntity::ok))
.onErrorResume(ProblemException.class, ex -> {
- Logger.errorLog(xRequestId,"user preferences", null, "portal-prefs" );
+ Logger.errorLog(xRequestId,"user preferences", null, "preferences" );
return Mono.error(ex);
})
.onErrorReturn(new ResponseEntity<>(HttpStatus.BAD_REQUEST));
.savePreferences(xRequestId, userid, pref)))
.map( ResponseEntity::ok)
.onErrorResume(ProblemException.class, ex -> {
- Logger.errorLog(xRequestId,"user preferences", null, "portal-prefs" );
+ Logger.errorLog(xRequestId,"user preferences", null, "preferences" );
return Mono.error(ex);
})
.onErrorReturn(new ResponseEntity<>(HttpStatus.BAD_REQUEST));
*
*/
-package org.onap.portal.prefs.entities;
+package org.onap.portalng.preferences.entities;
import lombok.Getter;
import lombok.Setter;
*
*/
-package org.onap.portal.prefs.exception;
+package org.onap.portalng.preferences.exception;
import lombok.AllArgsConstructor;
import lombok.Builder;
import java.net.URI;
-/** The default portal-prefs exception */
+/** The default preferences exception */
@Data
@Builder
@AllArgsConstructor
*
*/
-package org.onap.portal.prefs.repository;
+package org.onap.portalng.preferences.repository;
-import org.onap.portal.prefs.entities.PreferencesDto;
+import org.onap.portalng.preferences.entities.PreferencesDto;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
public interface PreferencesRepository extends ReactiveMongoRepository<PreferencesDto, String> {
*
*/
-package org.onap.portal.prefs.services;
+package org.onap.portalng.preferences.services;
-import org.onap.portal.prefs.entities.PreferencesDto;
-import org.onap.portal.prefs.exception.ProblemException;
-import org.onap.portal.prefs.openapi.model.Preferences;
-import org.onap.portal.prefs.repository.PreferencesRepository;
-import org.onap.portal.prefs.util.Logger;
+import org.onap.portalng.preferences.entities.PreferencesDto;
+import org.onap.portalng.preferences.exception.ProblemException;
+import org.onap.portalng.preferences.openapi.model.Preferences;
+import org.onap.portalng.preferences.repository.PreferencesRepository;
+import org.onap.portalng.preferences.util.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
.save(preferencesDto)
.map(this::toPreferences)
.onErrorResume(ProblemException.class, ex -> {
- Logger.errorLog(xRequestId,"user prefrences", userId, "portal-prefs" );
+ Logger.errorLog(xRequestId,"user prefrences", userId, "preferences" );
return Mono.error(ex);
});
*
*/
-package org.onap.portal.prefs.util;
+package org.onap.portalng.preferences.util;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.JWTParser;
*
*/
-package org.onap.portal.prefs.util;
+package org.onap.portalng.preferences.util;
import java.net.URI;
private Logger(){}
public static void requestLog(String xRequestId, HttpMethod methode, URI path) {
- log.info("Portal-prefs - request - X-Request-Id {} {} {}", xRequestId, methode, path);
+ log.info("Preferences - request - X-Request-Id {} {} {}", xRequestId, methode, path);
}
public static void responseLog(String xRequestId, HttpStatusCode httpStatusCode) {
- log.info("Portal-prefs - response - X-Request-Id {} {}", xRequestId, httpStatusCode);
+ log.info("Preferences - response - X-Request-Id {} {}", xRequestId, httpStatusCode);
}
public static void errorLog(String xRequestId, String msg, String id, String app) {
log.info(
- "Portal-prefs - error - X-Request-Id {} {} {} not found in {}", xRequestId, msg, id, app);
+ "Preferences - error - X-Request-Id {} {} {} not found in {}", xRequestId, msg, id, app);
}
public static void errorLog(
String xRequestId, String msg, String id, String app, String errorDetails) {
log.info(
- "Portal-prefs - error - X-Request-Id {} {} {} not found in {} error message: {}",
+ "Preferences - error - X-Request-Id {} {} {} not found in {} error message: {}",
xRequestId,
msg,
id,
jwk-set-uri: http://localhost:8080/auth/realms/ONAP/protocol/openid-connect/certs #Keycloak Endpoint
data:
mongodb:
- database: portal_prefs
+ database: portal_preferences
host: localhost
port: 27017
username: root
password: password
-portal-prefs:
+preferences:
realm: ONAP
management:
jwk-set-uri: ${KEYCLOAK_URL}/auth/realms/${KEYCLOAK_REALM}/protocol/openid-connect/certs #Keycloak Endpoint
data:
mongodb:
- database: ${PORTALPREFS_DATABASE}
- host: ${PORTALPREFS_HOST}
- port: ${PORTALPREFS_PORT}
- username: ${PORTALPREFS_USERNAME}
- password: ${PORTALPREFS_PASSWORD}
+ database: ${PREFERENCES_DATABASE}
+ host: ${PREFERENCES_HOST}
+ port: ${PREFERENCES_PORT}
+ username: ${PREFERENCES_USERNAME}
+ password: ${PREFERENCES_PASSWORD}
-portal-prefs:
+preferences:
realm: ${KEYCLOAK_REALM}
-
management:
endpoints:
web:
*
*/
-package org.onap.portal.prefs;
+package org.onap.portalng.preferences;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.tomakehurst.wiremock.client.WireMock;
import com.nimbusds.jose.jwk.JWKSet;
-import org.onap.portal.prefs.util.IdTokenExchange;
-import org.onap.portal.prefs.configuration.PortalPrefsConfig;
+import org.onap.portalng.preferences.util.IdTokenExchange;
+import org.onap.portalng.preferences.configuration.PreferencesConfig;
import io.restassured.RestAssured;
import io.restassured.filter.log.RequestLoggingFilter;
import io.restassured.filter.log.ResponseLoggingFilter;
public abstract class BaseIntegrationTest {
@LocalServerPort protected int port;
- @Value("${portal-prefs.realm}")
+ @Value("${preferences.realm}")
protected String realm;
@Autowired protected ObjectMapper objectMapper;
@Autowired private TokenGenerator tokenGenerator;
- @Autowired protected PortalPrefsConfig portalPrefsConfig;
+ @Autowired protected PreferencesConfig preferencesConfig;
@BeforeAll
public static void setup() {
*
*/
-package org.onap.portal.prefs;
+package org.onap.portalng.preferences;
import java.time.Clock;
import java.time.Duration;
*
*/
-package org.onap.portal.prefs.actuator;
+package org.onap.portalng.preferences.actuator;
import static org.assertj.core.api.Assertions.assertThat;
-import org.onap.portal.prefs.BaseIntegrationTest;
+import org.onap.portalng.preferences.BaseIntegrationTest;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.availability.ApplicationAvailability;
*
*/
-package org.onap.portal.prefs.preferences;
+package org.onap.portalng.preferences.preferences;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
-import org.onap.portal.prefs.BaseIntegrationTest;
-import org.onap.portal.prefs.openapi.model.Preferences;
-import org.onap.portal.prefs.services.PreferencesService;
+import org.onap.portalng.preferences.BaseIntegrationTest;
+import org.onap.portalng.preferences.openapi.model.Preferences;
+import org.onap.portalng.preferences.services.PreferencesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
jwt:
jwk-set-uri: http://localhost:${wiremock.server.port}/auth/realms/ONAP/protocol/openid-connect/certs #Keycloak Endpoint
-portal-prefs:
+preferences:
realm: ONAP
management:
generateApiDocumentation = false
generateModelTests = false
generateModelDocumentation = false
- invokerPackage = "org.onap.portal.prefs.openapi"
- apiPackage = "org.onap.portal.prefs.openapi.api"
- modelPackage = "org.onap.portal.prefs.openapi.model"
+ invokerPackage = "org.onap.portalng.preferences.openapi"
+ apiPackage = "org.onap.portalng.preferences.openapi.api"
+ modelPackage = "org.onap.portalng.preferences.openapi.model"
}
compileJava {
+++ /dev/null
-{
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
- "extends": [
- "config:base"
- ]
-}
pluginManagement {
// https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_version_management
plugins {
- id 'io.spring.dependency-management' version '1.0.13.RELEASE'
+ id 'io.spring.dependency-management' version '1.1.2'
id 'org.springframework.boot' version '3.1.2'
- id 'org.sonarqube' version '3.4.0.2513'
id 'com.github.hierynomus.license' version '0.16.1'
id 'com.gorylenko.gradle-git-properties' version '2.4.1'
id 'org.openapi.generator' version '7.0.0-beta'
// https://docs.gradle.org/current/userguide/plugins.html#sec:custom_plugin_repositories
repositories {
mavenCentral()
- maven {
- url "https://plugins.gradle.org/m2/"
- }
+ gradlePluginPortal()
}
}
// }
// }
-rootProject.name = 'portal-prefs'
+rootProject.name = 'preferences'
include 'openapi'
include 'app'