Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Commit

Permalink
fix: add null checking for object mappers (#524)
Browse files Browse the repository at this point in the history
* fix: add null checking for object mappers

* release: increase version from v6.1.1 to v6.1.2

* docs: update openapi.yaml
  • Loading branch information
juliapampus authored Aug 19, 2021
1 parent f657a40 commit 2c9df0c
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 60 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

## [6.1.2] - 2021-08-19

### Fixed
- Add null checking to object mappers.

## [6.1.1] - 2021-08-19

### Added
Expand Down
4 changes: 2 additions & 2 deletions charts/dataspace-connector/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.8
version: 0.1.9

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "6.1.1"
appVersion: "6.1.2"

dependencies:
- name: postgresql
Expand Down
102 changes: 55 additions & 47 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ info:
license:
name: "Apache License, Version 2.0"
url: https://www.apache.org/licenses/LICENSE-2.0.txt
version: 6.1.1
version: 6.1.2
servers:
- url: https://localhost:8080
description: Generated server url
Expand Down Expand Up @@ -5633,6 +5633,10 @@ components:
modificationDate:
type: string
format: date-time
title:
type: string
description:
type: string
target:
type: string
format: uri
Expand Down Expand Up @@ -5786,12 +5790,6 @@ components:
endpointDocumentation:
type: string
format: uri
paymentMethod:
type: string
enum:
- fixedPrice
- free
- negotiationBasis
samples:
type: array
items:
Expand All @@ -5801,6 +5799,13 @@ components:
type: string
format: uri
readOnly: true
paymentMethod:
type: string
enum:
- undefined
- fixedPrice
- free
- negotiationBasis
RequestedResourceView:
type: object
properties:
Expand Down Expand Up @@ -5841,6 +5846,7 @@ components:
paymentModality:
type: string
enum:
- undefined
- fixedPrice
- free
- negotiationBasis
Expand Down Expand Up @@ -5923,17 +5929,18 @@ components:
endpointDocumentation:
type: string
format: uri
samples:
type: array
items:
type: string
format: uri
paymentMethod:
type: string
enum:
- undefined
- fixedPrice
- free
- negotiationBasis
samples:
type: array
items:
type: string
format: uri
OfferedResourceView:
type: object
properties:
Expand Down Expand Up @@ -5971,6 +5978,7 @@ components:
paymentModality:
type: string
enum:
- undefined
- fixedPrice
- free
- negotiationBasis
Expand Down Expand Up @@ -6565,32 +6573,10 @@ components:
- $ref: '#/components/schemas/AbstractConstraint'
- type: object
properties:
ids:leftOperand:
type: string
enum:
- https://w3id.org/idsa/code/ABSOLUTE_SPATIAL_POSITION
- https://w3id.org/idsa/code/COUNT
- https://w3id.org/idsa/code/DELAY
- https://w3id.org/idsa/code/ELAPSED_TIME
- https://w3id.org/idsa/code/ENDPOINT
- https://w3id.org/idsa/code/EVENT
- https://w3id.org/idsa/code/PATH
- https://w3id.org/idsa/code/PAYMENT
- https://w3id.org/idsa/code/PAY_AMOUNT
- https://w3id.org/idsa/code/POLICY_EVALUATION_TIME
- https://w3id.org/idsa/code/PURPOSE
- https://w3id.org/idsa/code/QUANTITY
- https://w3id.org/idsa/code/RECURRENCE_RATE
- https://w3id.org/idsa/code/SECURITY_LEVEL
- https://w3id.org/idsa/code/STATE
- https://w3id.org/idsa/code/SYSTEM
- https://w3id.org/idsa/code/USER
ids:unit:
ids:rightOperandReference:
type: string
format: uri
ids:rightOperand:
$ref: '#/components/schemas/RdfResource'
ids:pipEndpoint:
ids:unit:
type: string
format: uri
ids:operator:
Expand Down Expand Up @@ -6642,7 +6628,29 @@ components:
- https://w3id.org/idsa/code/STRING_IS_CONTAINED
- https://w3id.org/idsa/code/TEMPORAL_DISJOINT
- https://w3id.org/idsa/code/TEMPORAL_EQUALS
ids:rightOperandReference:
ids:leftOperand:
type: string
enum:
- https://w3id.org/idsa/code/ABSOLUTE_SPATIAL_POSITION
- https://w3id.org/idsa/code/COUNT
- https://w3id.org/idsa/code/DELAY
- https://w3id.org/idsa/code/ELAPSED_TIME
- https://w3id.org/idsa/code/ENDPOINT
- https://w3id.org/idsa/code/EVENT
- https://w3id.org/idsa/code/PATH
- https://w3id.org/idsa/code/PAYMENT
- https://w3id.org/idsa/code/PAY_AMOUNT
- https://w3id.org/idsa/code/POLICY_EVALUATION_TIME
- https://w3id.org/idsa/code/PURPOSE
- https://w3id.org/idsa/code/QUANTITY
- https://w3id.org/idsa/code/RECURRENCE_RATE
- https://w3id.org/idsa/code/SECURITY_LEVEL
- https://w3id.org/idsa/code/STATE
- https://w3id.org/idsa/code/SYSTEM
- https://w3id.org/idsa/code/USER
ids:rightOperand:
$ref: '#/components/schemas/RdfResource'
ids:pipEndpoint:
type: string
format: uri
'@type':
Expand Down Expand Up @@ -6748,12 +6756,20 @@ components:
type: array
items:
$ref: '#/components/schemas/TypedLiteral'
ids:assignee:
ids:target:
type: string
format: uri
ids:constraint:
type: array
items:
oneOf:
- $ref: '#/components/schemas/LogicalConstraint'
ids:assigner:
type: array
items:
type: string
format: uri
ids:assigner:
ids:assignee:
type: array
items:
type: string
Expand All @@ -6779,18 +6795,10 @@ components:
- https://w3id.org/idsa/code/TRACK_PROVENANCE
- https://w3id.org/idsa/code/USE
- https://w3id.org/idsa/code/WRITE
ids:constraint:
type: array
items:
oneOf:
- $ref: '#/components/schemas/LogicalConstraint'
ids:assetRefinement:
oneOf:
- $ref: '#/components/schemas/Constraint'
- $ref: '#/components/schemas/LogicalConstraint'
ids:target:
type: string
format: uri
ids:description:
type: array
items:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

<properties>
<!-- General -->
<revision>6.1.1</revision>
<revision>6.1.2</revision>
<email>[email protected]</email>

<!-- Build info -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@ public static ConfigurationDesc fromIdsConfig(final ConfigurationModel configMod
* @return The internal log level.
*/
private static LogLevel fromIdsLogLevel(final de.fraunhofer.iais.eis.LogLevel logLevel) {
if (logLevel == null) {
return LogLevel.OFF;
}

switch (logLevel) {
// TODO infomodel has less log levels than DSC, info will get lost
case MINIMAL_LOGGING:
Expand All @@ -615,6 +619,10 @@ private static LogLevel fromIdsLogLevel(final de.fraunhofer.iais.eis.LogLevel lo
*/
private static SecurityProfile fromIdsSecurityProfile(
final de.fraunhofer.iais.eis.SecurityProfile securityProfile) {
if (securityProfile == null) {
return SecurityProfile.BASE_SECURITY;
}

switch (securityProfile) {
case TRUST_SECURITY_PROFILE:
return SecurityProfile.TRUST_SECURITY;
Expand All @@ -627,11 +635,16 @@ private static SecurityProfile fromIdsSecurityProfile(

/**
* Get dsc connector status from ids connector status.
*
* @param status The ids connector status.
* @return The internal connector status.
*/
public static ConnectorStatus fromIdsConnectorStatus(
final de.fraunhofer.iais.eis.ConnectorStatus status) {
if (status == null) {
return ConnectorStatus.FAULTY;
}

switch (status) {
case CONNECTOR_ONLINE:
return ConnectorStatus.ONLINE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public static LogLevel getLogLevel(

/**
* Get the ids connector status from dsc connector status.
*
* @param status The internal connector status.
* @return The ids connector status.
*/
Expand Down Expand Up @@ -226,7 +227,9 @@ public static Connector getConnectorFromConfiguration(final Configuration config
._description_(Util.asList(new TypedLiteral(config.getDescription())))
._curator_(config.getCurator())
._maintainer_(config.getMaintainer())
._securityProfile_(getSecurityProfile(config.getSecurityProfile()))
._securityProfile_(config.getSecurityProfile() == null
? SecurityProfile.BASE_SECURITY_PROFILE
: getSecurityProfile(config.getSecurityProfile()))
._hasDefaultEndpoint_(new ConnectorEndpointBuilder()
._accessURL_(config.getDefaultEndpoint())
.build())
Expand Down Expand Up @@ -261,10 +264,6 @@ private static SecurityProfile getSecurityProfile(
* @return The ids payment modality.
*/
public static PaymentModality getPaymentModality(final PaymentMethod paymentMethod) {
if (paymentMethod == null) {
return null;
}

switch (paymentMethod) {
case FREE:
return PaymentModality.FREE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ protected ConfigurationModel createInternal(final Configuration config,
throws ConstraintViolationException {
// Prepare configuration attributes.
final var deployMode = ToIdsObjectMapper.getConnectorDeployMode(config.getDeployMode());
final var logLevel = ToIdsObjectMapper.getLogLevel(config.getLogLevel());
final var logLevel = config.getLogLevel() == null
? null : ToIdsObjectMapper.getLogLevel(config.getLogLevel());
final var connector = ToIdsObjectMapper.getConnectorFromConfiguration(config);
final var status = ToIdsObjectMapper.getConnectorStatus(config.getStatus());
final var status = config.getStatus() == null
? null : ToIdsObjectMapper.getConnectorStatus(config.getStatus());

final var configBuilder = new ConfigurationModelBuilder()
._connectorDeployMode_(deployMode)
Expand All @@ -58,7 +60,8 @@ protected ConfigurationModel createInternal(final Configuration config,
._connectorDescription_(connector);

if (config.getProxy() != null) {
configBuilder._connectorProxy_(List.of(ToIdsObjectMapper.getProxy(config.getProxy())));
configBuilder._connectorProxy_(config.getProxy() == null
? null : List.of(ToIdsObjectMapper.getProxy(config.getProxy())));
}

return configBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ protected de.fraunhofer.iais.eis.Resource createInternal(final Resource resource
final var keywords = ToIdsObjectMapper.getKeywordsAsTypedLiteral(resource.getKeywords(),
language);
final var license = resource.getLicense();
final var paymentModality
= ToIdsObjectMapper.getPaymentModality(resource.getPaymentModality());
final var paymentModality = resource.getPaymentModality() == null
? null : ToIdsObjectMapper.getPaymentModality(resource.getPaymentModality());
final var publisher = resource.getPublisher();
final var sovereign = resource.getSovereign();
final var title = resource.getTitle();
Expand Down

0 comments on commit 2c9df0c

Please sign in to comment.