Skip to content

Commit

Permalink
POC cont. cleanup, non-functional changes.
Browse files Browse the repository at this point in the history
Signed-off-by: Ljupcho Palashevski <lpalashevski@gmail.com>
  • Loading branch information
lpalashevski committed Sep 8, 2023
1 parent 7b9ce1c commit 92cb917
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ dependencies {
implementation 'org.projectlombok:lombok'
// implementation 'org.yaml:snakeyaml'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
implementation 'com.fasterxml.jackson.core:jackson-core'
annotationProcessor 'org.projectlombok:lombok'

runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
runtimeOnly 'ch.qos.logback:logback-classic'
runtimeOnly 'org.hibernate:hibernate-validator'
compileOnly 'io.swagger.core.v3:swagger-annotations-jakarta'
// runtimeOnly 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
runtimeOnly 'com.fasterxml.jackson.core:jackson-core'

compileOnly project(':open-metadata-implementation:common-services:ffdc-services')
implementation project(':open-metadata-implementation:frameworks:open-connector-framework')
// implementation project(':open-metadata-implementation:frameworks:open-connector-framework')
implementation project(':open-metadata-implementation:adapters:authentication-plugins:http-helper')
implementation project(':open-metadata-implementation:admin-services:admin-services-api')
implementation project(':open-metadata-implementation:server-operations:server-operations-api')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,18 @@
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.odpi.openmetadata.adapters.repositoryservices.ConnectorConfigurationFactory;
import org.odpi.openmetadata.adminservices.configuration.properties.LocalRepositoryConfig;
import org.odpi.openmetadata.adminservices.configuration.properties.OMAGServerConfig;
import org.odpi.openmetadata.adminservices.configuration.properties.RepositoryServicesConfig;
import org.odpi.openmetadata.frameworks.connectors.properties.beans.Connection;
import org.odpi.openmetadata.frameworks.connectors.properties.beans.ConnectorType;
import org.odpi.openmetadata.repositoryservices.admin.OMRSConfigurationFactory;
import org.odpi.openmetadata.serverchassis.springboot.constants.Extensions;
import org.odpi.openmetadata.serverchassis.springboot.exception.OMAGServerActivationError;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;

import java.io.IOException;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;


@EnableConfigurationProperties(OMAGServerProperties.class)
Expand Down Expand Up @@ -86,34 +79,14 @@ public void loadConfig() throws OMAGServerActivationError {
//TODO: This is POC implementation. We need better code to deal with yaml i.e. one option is to use Jackson and Yaml data format.
// Yaml yaml = new Yaml();
// omagServerConfig = yaml.loadAs(serverConfigFile.getInputStream(), OMAGServerConfig.class);

omagServerConfig = yamlObjectMapper.reader()
.readValue(serverConfigFile.getInputStream(), OMAGServerConfig.class);
}

} else if (isPropertiesConfiguration()) {

log.info("Configuring server using omag. application properties [EXPERIMENTAL]");

OMAGServerProperties.Server omagServer = serverProperties.getServer();

omagServerConfig = new OMAGServerConfig();
omagServerConfig.setLocalServerName(omagServer.getName());
omagServerConfig.setLocalServerUserId(omagServer.getUser());
omagServerConfig.setMaxPageSize(omagServer.getMaxPageSize());

if (omagServer.getRepositoryServices() != null) {
RepositoryServicesConfig repositoryServicesConfig = omrsConfigurationFactory.getDefaultRepositoryServicesConfig();

if (omagServer.getRepositoryServices().getAuditLogConnectors() != null) {

repositoryServicesConfig.setAuditLogConnections(getAuditLogConnectors());
}
//TODO: Work in progress currently using default in-mem local repo.
LocalRepositoryConfig localRepositoryConfig = getLocalRepositoryConfig();
repositoryServicesConfig.setLocalRepositoryConfig(localRepositoryConfig);
omagServerConfig.setRepositoryServicesConfig(repositoryServicesConfig);
}
log.info("[EXPERIMENTAL] Configuring server using omag. application properties");
omagServerConfig = serverProperties.getServerConfig();
}

log.info("Configuration document for server: {} - loaded successfully", omagServerConfig.getLocalServerName());
Expand Down Expand Up @@ -143,40 +116,7 @@ private boolean isYamlConfigurationFile(Resource serverConfigFile) {
}

private boolean isPropertiesConfiguration() {
return serverProperties.getServer() != null;
}

private List<Connection> getAuditLogConnectors() {

return serverProperties.getServer()
.getRepositoryServices()
.getAuditLogConnectors()
.stream()
.map(o -> getConnection(o))
.collect(Collectors.toList());
}

private Connection getConnection(OMAGServerProperties.Connector o) {
Connection c = new Connection();
ConnectorType ct = new ConnectorType();
ct.setConnectorProviderClassName(o.getProviderClassName());
c.setConnectorType(ct);
//TODO: Fix binding problem. The type of supportedSeverities in configurationProperties should be resolved to List instead of Map!!!
c.setConfigurationProperties(o.getConfigurationProperties());
return c;
}

private LocalRepositoryConfig getLocalRepositoryConfig() {
LocalRepositoryConfig localRepositoryConfig = new LocalRepositoryConfig();

OMAGServerProperties.LocalRepository localRepository =
getServerProperties().getServer().getRepositoryServices().getLocalRepository();

localRepositoryConfig.setEventsToSendRule(localRepository.getEventsToSend());
localRepositoryConfig.setEventsToSaveRule(localRepository.getEventsToSave());
localRepositoryConfig.setMetadataCollectionId(localRepository.getMetadataCollectionId());
localRepositoryConfig.setLocalRepositoryLocalConnection(connectorConfigurationFactory.getInMemoryLocalRepositoryLocalConnection());
return localRepositoryConfig;
return serverProperties.getServerConfig() != null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@

import lombok.Getter;
import lombok.Setter;
import org.odpi.openmetadata.adminservices.configuration.properties.OpenMetadataExchangeRule;
import org.odpi.openmetadata.adminservices.configuration.registration.ServerTypeClassification;
import org.odpi.openmetadata.adminservices.configuration.properties.OMAGServerConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.core.io.Resource;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import java.util.Map;

/**
* This class provides validation support for OMAG specific application properties.
Expand All @@ -27,51 +24,6 @@ public class OMAGServerProperties {
*/
// @NotNull
private Resource serverConfigFile;

/**
* Server bean represents simplified OMAG server configuration model used for YAML based application configuration.
*/
private Server server;

@Getter
@Setter
public static class Server {
private String name;
private ServerTypeClassification type;
private String user;
private int maxPageSize;
private RepositoryServices repositoryServices;
}

@Getter
@Setter
public static class RepositoryServices {
private List<Connector> auditLogConnectors;
private LocalRepository localRepository;
}

@Getter
@Setter
public static class Connector {
private String providerClassName;
private Map<String, Object> configurationProperties;
private Endpoint endpoint;
}

@Getter
@Setter
public static class LocalRepository {
String metadataCollectionId;
Connector localConnection;
Connector remoteConnection;
OpenMetadataExchangeRule eventsToSave;
OpenMetadataExchangeRule eventsToSend;
}

@Getter
@Setter
public static class Endpoint {
private String address;
}
private OMAGServerConfig serverConfig;

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/* SPDX-License-Identifier: Apache-2.0 */
/* Copyright Contributors to the ODPi Egeria project. */
package org.odpi.openmetadata.serverchassis.springboot.constants;

import java.io.Serializable;
import java.util.stream.Stream;

/**
* Created by YM21WO on egeria
* on 17/08/2023 at 11:19
*/
public enum Extensions implements Serializable {

YAML(".yaml"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ management.endpoint.metrics.enabled=true
management.endpoints.web.exposure.include=metrics,health

#omag.server-config-file=classpath:samples/metadata-repository-server.json
omag.server-config-file=classpath:samples/metadata-repository-server2.yml
omag.server-config-file=classpath:samples/metadata-repository-server.yml


Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
---
omag:
server:
max-page-size: 1000
name: cocoMDS1
user: system
type: OMAG_SERVER
repository-services:
audit-log-connectors:
- provider-class-name: "org.odpi.openmetadata.adapters.repositoryservices.auditlogstore.console.ConsoleAuditLogStoreProvider"
configuration-properties:
server-config:
localServerName: cocoMDS1
localServerUserId: OMAGServer
maxPageSize: 1000
repositoryServicesConfig:
auditLogConnections:
- connectorType:
connectorProviderClassName: >-
org.odpi.openmetadata.adapters.repositoryservices.auditlogstore.console.ConsoleAuditLogStoreProvider
configurationProperties:
supportedSeverities:
- Error
dummySecretProperty: "${app-secrets.dummyPassword}"
local-repository:
metadata-collection-id: "838005fc-e09f-4688-af89-58254a155cc6"
local-connection:
provider-class-name: "org.odpi.openmetadata.adapters.repositoryservices.inmemory.repositoryconnector.InMemoryOMRSRepositoryConnectorProvider"
remote-connection:
provider-class-name: "org.odpi.openmetadata.adapters.repositoryservices.rest.repositoryconnector.OMRSRESTRepositoryConnectorProvider"
localRepositoryConfig:
metadataCollectionId: 838005fc-e09f-4688-af89-58254a155cc6
localRepositoryLocalConnection:
connectorType:
connectorProviderClassName: >-
org.odpi.openmetadata.adapters.repositoryservices.inmemory.repositoryconnector.InMemoryOMRSRepositoryConnectorProvider
localRepositoryRemoteConnection:
connectorType:
connectorProviderClassName: >-
org.odpi.openmetadata.adapters.repositoryservices.rest.repositoryconnector.OMRSRESTRepositoryConnectorProvider
endpoint:
address: "https://localhost:9443/servers/cocoMDS1"
events-to-save: ALL
events-to-send: ALL
address: https://localhost:9443/servers/cocoMDS1
eventsToSaveRule: ALL
eventsToSendRule: ALL
---
app-secrets:
dummyPassword: top-secret
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
---
class: OMAGServerConfig
localServerName: cocoMDS1
localServerType: Open Metadata and Governance Server
localServerUserId: OMAGServer
maxPageSize: 1000
repositoryServicesConfig:
class: RepositoryServicesConfig
auditLogConnections:
- class: Connection
connectorType:
class: ConnectorType
- connectorType:
connectorProviderClassName: >-
org.odpi.openmetadata.adapters.repositoryservices.auditlogstore.console.ConsoleAuditLogStoreProvider
configurationProperties:
supportedSeverities:
- Error
localRepositoryConfig:
class: LocalRepositoryConfig
metadataCollectionId: 838005fc-e09f-4688-af89-58254a155cc6
localRepositoryLocalConnection:
class: Connection
connectorType:
class: ConnectorType
connectorProviderClassName: >-
org.odpi.openmetadata.adapters.repositoryservices.inmemory.repositoryconnector.InMemoryOMRSRepositoryConnectorProvider
localRepositoryRemoteConnection:
class: Connection
connectorType:
class: ConnectorType
connectorProviderClassName: >-
org.odpi.openmetadata.adapters.repositoryservices.rest.repositoryconnector.OMRSRESTRepositoryConnectorProvider
endpoint:
class: Endpoint
address: https://localhost:9443/servers/cocoMDS1
eventsToSaveRule: ALL
eventsToSendRule: ALL

0 comments on commit 92cb917

Please sign in to comment.