Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/odpi/egeria into code2023
Browse files Browse the repository at this point in the history
  • Loading branch information
mandy-chessell committed Jan 29, 2023
2 parents ba5845c + b8c0f65 commit 94823cc
Show file tree
Hide file tree
Showing 65 changed files with 1,041 additions and 382 deletions.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ allprojects {
junitjupiterVersion = '5.9.1'
junitplatformVersion = '1.9.1'
jwtVersion = '0.9.1'
jwtApiVersion = '0.11.5'
jwtImplVersion = '0.11.5'
jwtJacksonVersion = '0.11.5'
kafkaVersion = '3.3.1'
lang3Version = '3.12.0'
logbackVersion = '1.2.11'
Expand Down Expand Up @@ -162,6 +165,7 @@ allprojects {
implementation("org.apache.commons:commons-text:${commonstextVersion}")
implementation("io.github.classgraph:classgraph:${classgraphVersion}")
implementation("io.jsonwebtoken:jjwt:${jwtVersion}")
implementation("io.jsonwebtoken:jjwt-api:${jwtApiVersion}")
implementation("io.lettuce:lettuce-core:${lettuceVersion}")
implementation("io.micrometer:micrometer-registry-prometheus:${prometheusVersion}")
implementation("io.netty:netty-handler:${nettyVersion}")
Expand Down Expand Up @@ -280,6 +284,8 @@ allprojects {
runtimeOnly("org.janusgraph:janusgraph-es:${janusVersion}")
runtimeOnly("org.xerial.snappy:snappy-java:${snappyVersion}")
runtimeOnly("javax.servlet:javax.servlet-api:${servletVersion}")
runtimeOnly("io.jsonwebtoken:jjwt-impl:${jwtImplVersion}")
runtimeOnly("io.jsonwebtoken:jjwt-jackson:${jwtJacksonVersion}")
testImplementation("junit:junit:${junitVersion}")
testImplementation("org.glassfish:javax.json:${glassfishVersion}")
testImplementation("org.junit.jupiter:junit-jupiter:${junitjupiterVersion}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package org.odpi.openmetadata.conformance.client;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.odpi.openmetadata.adapters.connectors.restclients.ffdc.exceptions.RESTConfigurationException;
import org.odpi.openmetadata.adapters.connectors.restclients.ffdc.exceptions.RESTServerException;
Expand All @@ -25,12 +26,14 @@
*/
public class OpenMetadataConformanceTestReport
{
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
private static final ObjectWriter OBJECT_WRITER = OBJECT_MAPPER.writer();

private String serverName; /* Initialized in constructor */
private String serverURLRoot; /* Initialized in constructor */
private String testClientUserId; /* Initialized in constructor */
private RESTClient restClient; /* Initialized in constructor */

private final ObjectMapper objectMapper;
private RESTExceptionHandler exceptionHandler = new RESTExceptionHandler();

/**
Expand All @@ -49,7 +52,6 @@ private OpenMetadataConformanceTestReport(String serverName,
this.serverURLRoot = serverURLRoot;
this.testClientUserId = testClientUserId;

this.objectMapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
this.restClient = new RESTClient(serverName, serverURLRoot);
}

Expand All @@ -72,7 +74,6 @@ private OpenMetadataConformanceTestReport(String serverName,
this.serverURLRoot = serverURLRoot;
this.testClientUserId = testClientUserId;

this.objectMapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
this.restClient = new RESTClient(serverName, serverURLRoot, testClientUserId, testClientPassword);
}

Expand Down Expand Up @@ -290,7 +291,7 @@ private void writeJsonToFile(String path, Object value) throws IOException
{
String noSpaces = path.replaceAll("\\s+", "_");
File file = new File(noSpaces);
objectMapper.writeValue(file, value);
OBJECT_WRITER.writeValue(file, value);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,9 @@
/* Copyright Contributors to the ODPi Egeria project. */
package org.odpi.openmetadata.accessservices.analyticsmodeling.assets;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.apache.commons.collections4.CollectionUtils;
import org.odpi.openmetadata.accessservices.analyticsmodeling.contentmanager.OMEntityDao;
import org.odpi.openmetadata.accessservices.analyticsmodeling.converter.GlossaryTermConverter;
Expand All @@ -25,8 +13,20 @@
import org.odpi.openmetadata.accessservices.analyticsmodeling.metadata.Database;
import org.odpi.openmetadata.accessservices.analyticsmodeling.metadata.GlossaryTerm;
import org.odpi.openmetadata.accessservices.analyticsmodeling.metadata.Schema;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.*;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.module.*;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.ModuleTableFilter;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.ResponseContainerDatabase;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.ResponseContainerDatabaseSchema;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.ResponseContainerModule;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.ResponseContainerSchemaTables;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.module.BaseObjectType;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.module.Column;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.module.DataSource;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.module.ForeignColumn;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.module.ForeignKey;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.module.MetadataModule;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.module.PrimaryKey;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.module.Table;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.module.TableItem;
import org.odpi.openmetadata.accessservices.analyticsmodeling.model.response.Messages;
import org.odpi.openmetadata.accessservices.analyticsmodeling.utils.Constants;
import org.odpi.openmetadata.accessservices.analyticsmodeling.utils.ExecutionContext;
Expand All @@ -42,8 +42,20 @@
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.InstanceProperties;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.instances.Relationship;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* The class builds data content of the Analytics Modeling OMAS responses.<br>
Expand All @@ -64,6 +76,8 @@
*/
public class DatabaseContextHandler {

private static final ObjectWriter OBJECT_WRITER = new ObjectMapper().writer();

public static final String DATA_SOURCE_GUID = "dataSourceGUID";

private RelationalDataHandler<Database,
Expand Down Expand Up @@ -460,7 +474,7 @@ private String buildGlossaryTerm(GlossaryTerm term)
}

try {
return new ObjectMapper().writeValueAsString(json);
return OBJECT_WRITER.writeValueAsString(json);
} catch (JsonProcessingException e) {
// log warning in context
ctx.addMessage(AnalyticsModelingErrorCode.BUILD_GLOSSARY_TERM_EXCEPTION.getMessageDefinition(term.getName()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

package org.odpi.openmetadata.accessservices.analyticsmodeling.synchronization.converters;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.odpi.openmetadata.accessservices.analyticsmodeling.synchronization.model.AnalyticsAsset;
import org.odpi.openmetadata.accessservices.analyticsmodeling.synchronization.model.AssetReference;
import org.odpi.openmetadata.accessservices.analyticsmodeling.utils.Constants;
Expand All @@ -17,11 +15,14 @@
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.properties.typedefs.TypeDefCategory;
import org.odpi.openmetadata.repositoryservices.connectors.stores.metadatacollectionstore.repositoryconnector.OMRSRepositoryHelper;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.List;
import java.util.Map;

public class AssetConverter extends OpenMetadataAPIGenericConverter<AnalyticsAsset> {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

public AssetConverter(OMRSRepositoryHelper repositoryHelper, String serviceName, String serverName) {
super(repositoryHelper, serviceName, serverName);
}
Expand Down Expand Up @@ -63,7 +64,7 @@ public AnalyticsAsset getNewBean(Class<AnalyticsAsset> beanClass,
String jsonReference = props.get(Constants.REFERENCE);
if (jsonReference != null && !jsonReference.isEmpty()) {
try {
bean.setReference(new ObjectMapper()
bean.setReference(OBJECT_MAPPER
.readValue(jsonReference.getBytes(), new TypeReference<List<AssetReference>>(){}));
} catch (IOException e) {
// log warning into execution context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

package org.odpi.openmetadata.accessservices.analyticsmodeling.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.odpi.openmetadata.accessservices.analyticsmodeling.synchronization.model.AnalyticsAsset;
import org.odpi.openmetadata.accessservices.analyticsmodeling.synchronization.model.AssetReference;
import org.odpi.openmetadata.accessservices.analyticsmodeling.synchronization.model.MetadataContainer;
import org.odpi.openmetadata.accessservices.analyticsmodeling.synchronization.model.MetadataItem;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
* Class provides useful operations with bean class
Expand All @@ -22,6 +22,11 @@
*/
public class AnalyticsAssetUtils {

private static final ObjectWriter OBJECT_WRITER = new ObjectMapper().writer();

private AnalyticsAssetUtils() {
}

/**
* Add container to the asset.
* @param asset to add new container to.
Expand Down Expand Up @@ -129,7 +134,7 @@ public static Map<String, String> buildAdditionalProperties(AnalyticsAsset asset

if (asset.getReference() != null ) {
try {
String references = new ObjectMapper().writeValueAsString(asset.getReference());
String references = OBJECT_WRITER.writeValueAsString(asset.getReference());
additionalProperties.put(Constants.REFERENCE, references);
} catch (JsonProcessingException e) {
// log to execution context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.odpi.openmetadata.repositoryservices.connectors.openmetadatatopic.OpenMetadataTopicConnector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -15,7 +16,8 @@
*/
public class AssetCatalogSearchPublisher {

private static final Logger log = LoggerFactory.getLogger(AssetCatalogSearchPublisher.class);
private static final Logger LOG = LoggerFactory.getLogger(AssetCatalogSearchPublisher.class);
private static final ObjectWriter OBJECT_WRITER = new ObjectMapper().writer();

private final OpenMetadataTopicConnector topicConnector;

Expand All @@ -35,21 +37,20 @@ public void publishEvent(Serializable event)
{
if (topicConnector != null)
{
ObjectMapper objectMapper = new ObjectMapper();
topicConnector.sendEvent(objectMapper.writeValueAsString(event));
topicConnector.sendEvent(OBJECT_WRITER.writeValueAsString(event));
}
else
{
log.error("Cannot publish event: topic connector is null!");
LOG.error("Cannot publish event: topic connector is null!");
}
}
catch (JsonProcessingException e)
{
log.error("Unable to create json for publishing: " + event.toString(), e);
LOG.error("Unable to create json for publishing: " + event.toString(), e);
}
catch (Exception e)
{
log.error("Unable to publish new asset event", e);
LOG.error("Unable to publish new asset event", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@
package org.odpi.openmetadata.accessservices.assetconsumer.connectors.outtopic;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.odpi.openmetadata.accessservices.assetconsumer.events.AssetConsumerOutTopicEvent;
import org.odpi.openmetadata.accessservices.assetconsumer.ffdc.AssetConsumerAuditCode;
import org.odpi.openmetadata.accessservices.assetconsumer.ffdc.AssetConsumerErrorCode;
import org.odpi.openmetadata.frameworks.connectors.ffdc.ConnectorCheckedException;
import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;
import org.odpi.openmetadata.repositoryservices.connectors.openmetadatatopic.OpenMetadataTopicSenderConnectorBase;

import java.util.concurrent.CompletionException;


/**
* AssetConsumerOutTopicServerConnector is the java implementation of the
* the server side connector that send events to the Asset Consumer OMAS's OutTopic.
*/
public class AssetConsumerOutTopicServerConnector extends OpenMetadataTopicSenderConnectorBase
{

private static final ObjectWriter OBJECT_WRITER = new ObjectMapper().writer();

/**
* Send the request to the embedded event bus connector(s).
*
Expand All @@ -28,12 +34,11 @@ public class AssetConsumerOutTopicServerConnector extends OpenMetadataTopicSende
public void sendEvent(AssetConsumerOutTopicEvent event) throws InvalidParameterException, ConnectorCheckedException
{
final String methodName = "sendEvent";
ObjectMapper objectMapper = new ObjectMapper();

try
{
String eventString = objectMapper.writeValueAsString(event);
super.sendEvent(eventString);
String eventString = OBJECT_WRITER.writeValueAsString(event);
super.sendEvent(eventString).join();

if (super.auditLog != null)
{
Expand All @@ -42,6 +47,17 @@ public void sendEvent(AssetConsumerOutTopicEvent event) throws InvalidParameterE
eventString);
}
}
catch (CompletionException error)
{
if (error.getCause() instanceof ConnectorCheckedException)
{
throw (ConnectorCheckedException) error.getCause();
}
else if (error.getCause() instanceof InvalidParameterException)
{
throw (InvalidParameterException) error.getCause();
}
}
catch (InvalidParameterException | ConnectorCheckedException error)
{
throw error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import org.apache.commons.collections4.CollectionUtils;
Expand Down Expand Up @@ -54,6 +55,7 @@
public class AssetLineagePublisher {

private static final Logger log = LoggerFactory.getLogger(AssetLineagePublisher.class);
private static final ObjectWriter OBJECT_WRITER = new ObjectMapper().writer();
private static final AssetLineageInstanceHandler instanceHandler = new AssetLineageInstanceHandler();
private final OpenMetadataTopicConnector outTopicConnector;
private final String serverUserName;
Expand Down Expand Up @@ -314,8 +316,7 @@ public void publishEvent(AssetLineageEventHeader event) throws JsonProcessingExc
if (outTopicConnector == null)
return;

ObjectMapper objectMapper = new ObjectMapper();
outTopicConnector.sendEvent(objectMapper.writeValueAsString(event));
outTopicConnector.sendEvent(OBJECT_WRITER.writeValueAsString(event));

}

Expand Down
Loading

0 comments on commit 94823cc

Please sign in to comment.