Skip to content

Commit

Permalink
attempt to use custom JacksonJsonProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
akphi committed Apr 6, 2023
1 parent 2f99475 commit 5e86942
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 11 deletions.
4 changes: 4 additions & 0 deletions legend-sdlc-server-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>

<!-- TEST -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void run(C configuration, Environment environment)
environment.jersey().register(new CatchAllExceptionMapper(includeStackTraces));

// Serialization
environment.jersey().register(new BaseServerJacksonJsonProvider());
environment.jersey().register(BaseServerJacksonJsonProvider.class);
}

public ServerInfo getServerInfo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;

import javax.ws.rs.ext.ContextResolver;
Expand All @@ -27,6 +28,7 @@ public class BaseServerJacksonJsonProvider extends JacksonJsonProvider implement
public BaseServerJacksonJsonProvider()
{
objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
}

Expand Down
4 changes: 4 additions & 0 deletions legend-sdlc-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
Expand Down
3 changes: 0 additions & 3 deletions legend-sdlc-server/src/main/Pipeline.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package org.finos.legend.sdlc.server;

import io.dropwizard.setup.Environment;
import org.finos.legend.sdlc.server.config.LegendSDLCServerConfiguration;

public class LegendSDLCServer extends BaseLegendSDLCServer<LegendSDLCServerConfiguration>
Expand All @@ -24,12 +23,6 @@ public LegendSDLCServer(String mode)
super(mode);
}

@Override
public void run(LegendSDLCServerConfiguration configuration, Environment environment)
{
super.run(configuration, environment);
}

@Override
protected ServerPlatformInfo newServerPlatformInfo()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
package org.finos.legend.sdlc.server;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import org.finos.legend.sdlc.domain.model.entity.Entity;
import org.finos.legend.sdlc.domain.model.project.Project;
Expand All @@ -36,6 +38,8 @@ public class LegendSDLCServerForTestJacksonJsonProvider extends JacksonJsonProvi
public LegendSDLCServerForTestJacksonJsonProvider()
{
objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.addMixIn(Project.class, InMemoryMixins.Project.class);
objectMapper.addMixIn(Workspace.class, InMemoryMixins.Workspace.class);
objectMapper.addMixIn(Entity.class, InMemoryMixins.Entity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import org.finos.legend.sdlc.domain.model.entity.Entity;
import org.finos.legend.sdlc.domain.model.project.Project;
Expand Down Expand Up @@ -78,6 +79,7 @@ static class SDLCServerClientRuleJacksonJsonProvider extends JacksonJsonProvider
public SDLCServerClientRuleJacksonJsonProvider()
{
objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
this.objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
this.objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
this.objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
Expand Down
119 changes: 119 additions & 0 deletions legend-sdlc-server/src/test/resources/config-local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Copyright 2020 Goldman Sachs
#
# 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.

applicationName: Legend SDLC

sessionCookie: LEGEND_SDLC_JSESSIONID

server:
applicationConnectors:
- type: http
port: 6100
maxRequestHeaderSize: 128KiB
adminConnectors:
- type: http
port: 6101
gzip:
includedMethods:
- GET
- POST
requestLog:
type: classic
appenders:
- type: file
currentLogFilename: ./logs/access.log
threshold: ALL
archive: true
archivedLogFilenamePattern: ./logs/access-%d.log
archivedFileCount: 5
timeZone: UTC
rootPath: /api

features:
canCreateProject: true
canCreateVersion: true

filterPriorities:
GitLab: 1
org.pac4j.j2e.filter.CallbackFilter: 2
org.pac4j.j2e.filter.SecurityFilter: 3
CORS: 4

pac4j:
callbackPrefix: /api/pac4j/login
clients:
- org.finos.legend.server.pac4j.gitlab.GitlabClient:
name: gitlab
clientId: 6259b5d9b6ddb85d3a0224d7bec3ffb41fb48f751150152c1eb142fe8c455ab5
secret: 8c4afdc49d41126408819a703e8a8ee130313c379035dbb696d5f435728b990d
discoveryUri: https://gitlab.com/.well-known/openid-configuration
scope: openid profile api
bypassPaths:
- /api/info
mongoUri: mongodb://localhost:27017
mongoDb: legend
mongoSession:
enabled: true
collection: userSessions


gitLab:
newProjectVisibility: public
projectTag: legend
prod:
server:
scheme: https
host: gitlab.com
app:
id: 6259b5d9b6ddb85d3a0224d7bec3ffb41fb48f751150152c1eb142fe8c455ab5
secret: 8c4afdc49d41126408819a703e8a8ee130313c379035dbb696d5f435728b990d
redirectURI: http://localhost:6100/api/auth/callback

projectStructure:
extensionProvider:
org.finos.legend.sdlc.server.gitlab.finos.FinosGitlabProjectStructureExtensionProvider: {}
platforms:
legend-engine:
groupId: org.finos.legend.engine
platformVersion:
version: 4.4.2
fromPackage: legend-engine-protocol-pure
legend-sdlc:
groupId: org.finos.legend.sdlc
platformVersion:
version: 0.120.2
fromPackage: legend-sdlc-server

logging:
# Change this to affect library class logging
level: INFO
loggers:
# Change this to affect application class logging
org.finos.legend.sdlc: INFO
appenders:
- type: file
logFormat: "%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p [%thread] %c - %m%n"
currentLogFilename: ./logs/service.log
threshold: ALL
archive: true
archivedLogFilenamePattern: ./logs/service-%d.log
archivedFileCount: 5
timeZone: UTC
- type: console
logFormat: "%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p [%thread] %c - %m%n"

swagger:
resourcePackage: org.finos.legend.sdlc.server.resources
title: Legend SDLC
schemes: []
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,11 @@
<version>${legend.engine.version}</version>
</dependency>
<!-- External dependencies -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
Expand Down

0 comments on commit 5e86942

Please sign in to comment.