Skip to content

Commit

Permalink
fix: rename endpoint property of configuration (#458)
Browse files Browse the repository at this point in the history
* fix: rename endpoint property of configuration

* fix: rename property in ConfigurationView

Co-authored-by: Pampus, Julia <julia.pampus@isst.fraunhofer.de>
Co-authored-by: Julia Pampus <72392527+juliapampus@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 23, 2021
1 parent a5cfef1 commit 7162c5a
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@
*/
package io.dataspaceconnector.model.configuration;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.ElementCollection;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import java.net.URI;
import java.util.List;

import de.fraunhofer.iais.eis.ConnectorStatus;
import io.dataspaceconnector.model.keystore.Keystore;
import io.dataspaceconnector.model.named.NamedEntity;
Expand All @@ -43,6 +31,18 @@
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.ElementCollection;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import java.net.URI;
import java.util.List;

/**
* The configuration describes the configuration of a connector.
*/
Expand All @@ -65,7 +65,7 @@ public class Configuration extends NamedEntity {
* The access url of the connector.
*/
@Convert(converter = UriConverter.class)
private URI connectorEndpoint;
private URI defaultEndpoint;

/**
* The project version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/
package io.dataspaceconnector.model.configuration;

import java.net.URI;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.dataspaceconnector.model.keystore.KeystoreDesc;
import io.dataspaceconnector.model.named.NamedDescription;
Expand All @@ -26,6 +23,9 @@
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.net.URI;
import java.util.List;

/**
* Describing the configuration's properties.
*/
Expand All @@ -37,7 +37,7 @@ public class ConfigurationDesc extends NamedDescription {
* The access url of the connector.
*/
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private URI connectorEndpoint;
private URI defaultEndpoint;

/**
* The project version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/
package io.dataspaceconnector.model.configuration;

import java.net.URI;
import java.util.List;

import io.dataspaceconnector.model.keystore.KeystoreDesc;
import io.dataspaceconnector.model.keystore.KeystoreFactory;
import io.dataspaceconnector.model.named.AbstractNamedFactory;
Expand All @@ -30,6 +27,9 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.net.URI;
import java.util.List;

/**
* Creates and updates a configuration.
*/
Expand Down Expand Up @@ -114,8 +114,8 @@ protected Configuration initializeEntity(final ConfigurationDesc desc) {
*/
@Override
protected boolean updateInternal(final Configuration config, final ConfigurationDesc desc) {
final var hasUpdatedConnectorEndpoint = updateConnectorEndpoint(config,
desc.getConnectorEndpoint());
final var hasUpdatedDefaultEndpoint = updateDefaultEndpoint(config,
desc.getDefaultEndpoint());
final var hasUpdatedVersion = updateVersion(config, desc.getVersion());
final var hasUpdatedCurator = updateCurator(config, desc.getCurator());
final var hasUpdatedMaintainer = updateMaintainer(config, desc.getMaintainer());
Expand All @@ -131,7 +131,7 @@ protected boolean updateInternal(final Configuration config, final Configuration
final var hasUpdatedKeyStore = updateKeyStore(config, desc.getKeystoreSettings());
final var hasUpdatedProxy = updateProxy(config, desc.getProxySettings());

return hasUpdatedConnectorEndpoint
return hasUpdatedDefaultEndpoint
|| hasUpdatedVersion
|| hasUpdatedCurator
|| hasUpdatedMaintainer
Expand Down Expand Up @@ -185,7 +185,7 @@ private boolean updateInboundModelVersion(final Configuration config,
final List<String> inboundModelVersion) {
final var newInboundModelVersionList =
MetadataUtils.updateStringList(config.getInboundModelVersion(), inboundModelVersion,
DEFAULT_INBOUND_VERSION);
DEFAULT_INBOUND_VERSION);
newInboundModelVersionList.ifPresent(config::setInboundModelVersion);

return newInboundModelVersionList.isPresent();
Expand Down Expand Up @@ -234,16 +234,15 @@ private boolean updateVersion(final Configuration config,
}

/**
* @param config The configuration
* @param connectorEndpoint The new connector endpoint.
* @param config The configuration
* @param defaultEndpoint The new connector endpoint.
* @return True, if connector endpoint is updated.
*/
private boolean updateConnectorEndpoint(final Configuration config,
final URI connectorEndpoint) {
final var newUri =
MetadataUtils.updateUri(config.getConnectorEndpoint(), connectorEndpoint,
DEFAULT_CONNECTOR_ENDPOINT);
newUri.ifPresent(config::setConnectorEndpoint);
private boolean updateDefaultEndpoint(final Configuration config,
final URI defaultEndpoint) {
final var newUri = MetadataUtils.updateUri(config.getDefaultEndpoint(),
defaultEndpoint, DEFAULT_CONNECTOR_ENDPOINT);
newUri.ifPresent(config::setDefaultEndpoint);

return newUri.isPresent();
}
Expand Down
38 changes: 18 additions & 20 deletions src/main/java/io/dataspaceconnector/util/IdsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@
*/
package io.dataspaceconnector.util;

import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.net.URI;
import java.text.Normalizer;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.TimeZone;
import java.util.stream.Collectors;

import de.fraunhofer.iais.eis.Artifact;
import de.fraunhofer.iais.eis.BaseConnector;
import de.fraunhofer.iais.eis.BaseConnectorBuilder;
Expand Down Expand Up @@ -61,6 +46,21 @@
import io.dataspaceconnector.model.configuration.DeployMode;
import lombok.SneakyThrows;

import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import java.net.URI;
import java.text.Normalizer;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.TimeZone;
import java.util.stream.Collectors;

/**
*
*/
Expand Down Expand Up @@ -430,15 +430,13 @@ private static BasicAuthentication getBasicAuthHeader(final BasicAuth auth) {
*/
public static Connector getConnectorFromConfiguration(final Configuration config) {
return new BaseConnectorBuilder()
._title_(Util.asList(
new TypedLiteral(config.getTitle())))
._description_(Util.asList(
new TypedLiteral(config.getDescription())))
._title_(Util.asList(new TypedLiteral(config.getTitle())))
._description_(Util.asList(new TypedLiteral(config.getDescription())))
._curator_(config.getCurator())
._maintainer_(config.getMaintainer())
._securityProfile_(getSecurityProfile(config.getSecurityProfile()))
._hasDefaultEndpoint_(new ConnectorEndpointBuilder()
._accessURL_(config.getConnectorEndpoint())
._accessURL_(config.getDefaultEndpoint())
.build())
._outboundModelVersion_(config.getOutboundModelVersion())
._inboundModelVersion_(config.getInboundModelVersion())
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/dataspaceconnector/util/MappingUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ public static ConfigurationDesc fromIdsConfig(final ConfigurationModel configMod
}
description.setDeployMode(fromIdsDeployMode(configModel.getConnectorDeployMode()));
description.setCurator(configModel.getConnectorDescription().getCurator());
description.setConnectorEndpoint(
description.setDefaultEndpoint(
configModel.getConnectorDescription().getHasDefaultEndpoint().getAccessURL());
description.setInboundModelVersion(
configModel.getConnectorDescription().getInboundModelVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
*/
package io.dataspaceconnector.view.configuration;

import java.net.URI;
import java.time.ZonedDateTime;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.dataspaceconnector.model.configuration.DeployMode;
import io.dataspaceconnector.model.configuration.LogLevel;
Expand All @@ -33,6 +29,10 @@
import org.springframework.hateoas.RepresentationModel;
import org.springframework.hateoas.server.core.Relation;

import java.net.URI;
import java.time.ZonedDateTime;
import java.util.List;

/**
* A DTO for controlled exposing of configuration information in API responses.
*/
Expand Down Expand Up @@ -67,7 +67,7 @@ public class ConfigurationView extends RepresentationModel<ConfigurationView> {
/**
* The access url of the connector.
*/
private URI connectorEndpoint;
private URI defaultEndpoint;

/**
* The project version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/
package io.dataspaceconnector.model.configuration;

import java.net.URI;
import java.util.List;

import io.dataspaceconnector.model.keystore.KeystoreDesc;
import io.dataspaceconnector.model.keystore.KeystoreFactory;
import io.dataspaceconnector.model.proxy.ProxyDesc;
Expand All @@ -26,6 +23,9 @@
import io.dataspaceconnector.model.truststore.TruststoreFactory;
import org.junit.jupiter.api.Test;

import java.net.URI;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
Expand All @@ -50,7 +50,7 @@ void create_emptyDesc_returnNew() {
final var result = factory.create(new ConfigurationDesc());

/* ASSERT */
assertEquals(ConfigurationFactory.DEFAULT_CONNECTOR_ENDPOINT, result.getConnectorEndpoint());
assertEquals(ConfigurationFactory.DEFAULT_CONNECTOR_ENDPOINT, result.getDefaultEndpoint());
assertEquals(ConfigurationFactory.DEFAULT_DEPLOY_MODE, result.getDeployMode());
assertEquals(ConfigurationFactory.DEFAULT_VERSION, result.getVersion());
assertEquals(ConfigurationFactory.DEFAULT_CURATOR, result.getCurator());
Expand All @@ -63,7 +63,7 @@ void create_emptyDesc_returnNew() {
void create_validDesc_returnNew() {
/* ARRANGE */
final var desc = new ConfigurationDesc();
desc.setConnectorEndpoint(URI.create("https://endpoint"));
desc.setDefaultEndpoint(URI.create("https://endpoint"));
desc.setSecurityProfile(SecurityProfile.TRUST_PLUS_SECURITY);
desc.setOutboundModelVersion("fred");
desc.setInboundModelVersion(List.of("Model", "Version"));
Expand All @@ -77,7 +77,7 @@ void create_validDesc_returnNew() {
final var result = factory.create(desc);

/* ASSERT */
assertEquals(desc.getConnectorEndpoint(), result.getConnectorEndpoint());
assertEquals(desc.getDefaultEndpoint(), result.getDefaultEndpoint());
assertEquals(desc.getDeployMode(), result.getDeployMode());
assertEquals(desc.getVersion(), result.getVersion());
assertEquals(desc.getCurator(), result.getCurator());
Expand All @@ -91,14 +91,14 @@ void update_newConnectorEndpoint_willUpdate() {
/* ARRANGE */
final var config = factory.create(new ConfigurationDesc());
final var desc = new ConfigurationDesc();
desc.setConnectorEndpoint(URI.create("https://endpoint"));
desc.setDefaultEndpoint(URI.create("https://endpoint"));

/* ACT */
final var result = factory.update(config, desc);

/* ASSERT */
assertTrue(result);
assertEquals(desc.getConnectorEndpoint(), config.getConnectorEndpoint());
assertEquals(desc.getDefaultEndpoint(), config.getDefaultEndpoint());
}

@Test
Expand Down Expand Up @@ -261,15 +261,15 @@ void update_newTruststore_willUpdate() {
void update_sameConnectorEndpoint_willNotUpdate() {
/* ARRANGE */
final var desc = new ConfigurationDesc();
desc.setConnectorEndpoint(URI.create("https://endpoint"));
desc.setDefaultEndpoint(URI.create("https://endpoint"));
final var config = factory.create(desc);

/* ACT */
final var result = factory.update(config, desc);

/* ASSERT */
assertFalse(result);
assertEquals(desc.getConnectorEndpoint(), config.getConnectorEndpoint());
assertEquals(desc.getDefaultEndpoint(), config.getDefaultEndpoint());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void create_ValidBroker_returnBrokerView() {
assertEquals(after.getCurator(), shouldLookLike.getCurator());
assertEquals(after.getMaintainer(), shouldLookLike.getMaintainer());
assertEquals(after.getDeployMode(), shouldLookLike.getDeployMode());
assertEquals(after.getConnectorEndpoint(), shouldLookLike.getConnectorEndpoint());
assertEquals(after.getDefaultEndpoint(), shouldLookLike.getDefaultEndpoint());
assertEquals(after.getLogLevel(), shouldLookLike.getLogLevel());
assertTrue(after.getInboundModelVersion().isEmpty());
assertEquals(after.getOutboundModelVersion(), shouldLookLike.getOutboundModelVersion());
Expand Down Expand Up @@ -89,7 +89,7 @@ private ConfigurationDesc getConfigurationDesc(){
desc.setCurator(URI.create("https://ids.com"));
desc.setMaintainer(URI.create("https://ids.com"));
desc.setDeployMode(DeployMode.TEST);
desc.setConnectorEndpoint(URI.create("https://localhost:8080/api/ids/data"));
desc.setDefaultEndpoint(URI.create("https://localhost:8080/api/ids/data"));
desc.setLogLevel(LogLevel.OFF);
desc.setInboundModelVersion(new ArrayList<>());
desc.setOutboundModelVersion("4.1.0");
Expand Down

0 comments on commit 7162c5a

Please sign in to comment.