Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-schmidt committed Feb 24, 2024
1 parent 5cd32f6 commit bb10cb6
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class DataTransferController {

private final Config config;

private final DataTransferEndpoint dataTransferEndpoint;
private final DataTransferObservable dataTransferObservable;
private final TransferInitiator transferInitiator;

Expand All @@ -56,7 +55,7 @@ public class DataTransferController {
* @param config Read config value transfer timeout and
* own URI
* @param webService Register data transfer endpoint.
* @param dataEndpointAuthRequestFilter Creating and passing through custom api
* @param authenticationService Creating and passing through custom api
* keys for each data transfer.
* @param transferProcessManager Initiating a transfer process as a
* consumer.
Expand All @@ -69,7 +68,7 @@ public DataTransferController(Monitor monitor, Config config, WebService webServ
authenticationService);

this.dataTransferObservable = new DataTransferObservable(monitor);
this.dataTransferEndpoint = new DataTransferEndpoint(monitor, dataTransferObservable);
var dataTransferEndpoint = new DataTransferEndpoint(monitor, dataTransferObservable);
webService.registerResource(dataTransferEndpoint);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public Negotiator(ConsumerContractNegotiationManager consumerNegotiationManager,
* aborted by throwing an exception. This exception can be inspected using the
* getCause() method.
*/
StatusResult<ContractNegotiation> negotiate(ContractRequest contractRequest)
throws InterruptedException, ExecutionException {
StatusResult<ContractNegotiation> negotiate(ContractRequest contractRequest) {
var previousAgreements = contractNegotiationStore.queryAgreements(QuerySpec.max());
var relevantAgreements = previousAgreements
.filter(agreement -> agreement.getAssetId().equals(contractRequest.getContractOffer().getAssetId()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,15 @@
public class PolicyController {


private final PolicyServiceConfig config;

private final PolicyDefinitionStore policyDefinitionStore;
private final PolicyService policyService;

public PolicyController(Monitor monitor, CatalogService catalogService,
TypeTransformerRegistry typeTransformerRegistry, Config systemConfig) {
this.config = new PolicyServiceConfig(systemConfig);
var config = new PolicyServiceConfig(systemConfig);

this.policyDefinitionStore = new PolicyDefinitionStore(monitor, this.config.getAcceptedPolicyDefinitionsPath());
this.policyService = new PolicyService(catalogService, typeTransformerRegistry, this.config,
this.policyDefinitionStore = new PolicyDefinitionStore(monitor, config.getAcceptedPolicyDefinitionsPath());
this.policyService = new PolicyService(catalogService, typeTransformerRegistry, config,
this.policyDefinitionStore, monitor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@
public class TransferInitiatorTest {

private final TransferProcessManager mockTransferProcessManager = mock(TransferProcessManager.class);
private Config configMock;

private TransferInitiator transferInitiator;
private StatusResult<TransferProcess> mockStatusResult;

@BeforeEach
@SuppressWarnings("unchecked")
void initializeContractOfferService() throws URISyntaxException {
configMock = ConfigFactory.fromMap(Map.of("edc.dsp.callback.address", "http://localhost:4321/dsp",
void initializeContractOfferService() {
var configMock = ConfigFactory.fromMap(Map.of("edc.dsp.callback.address", "http://localhost:4321/dsp",
"web.http.port", "8080", "web.http.path", "/api"));

transferInitiator = new TransferInitiator(configMock, mock(Monitor.class), mockTransferProcessManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,15 @@ public class AasExtension implements ServiceExtension {
private static final Logger logger = Logger.getInstance();
private final ScheduledExecutorService syncExecutor = new ScheduledThreadPoolExecutor(1);
private AasController aasController;
private ConfigurationController configurationController;

@Override
public void initialize(ServiceExtensionContext context) {
this.configurationController = new ConfigurationController(context.getConfig(SETTINGS_PREFIX));
var configurationController = new ConfigurationController(context.getConfig(SETTINGS_PREFIX));

// Distribute controllers, repository
var selfDescriptionRepository = new SelfDescriptionRepository();
this.aasController = new AasController(okHttpClient);
var endpoint = new Endpoint(selfDescriptionRepository, this.aasController, this.configurationController);
var endpoint = new Endpoint(selfDescriptionRepository, this.aasController, configurationController);

// Initialize/Start synchronizer, start AAS services defined in configuration
initializeSynchronizer(selfDescriptionRepository);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,7 @@ public boolean equals(Object obj) {
return false;
}

if (!this.getIdShort().equals(other.getIdShort())) {
return false;
}

return true;
return this.getIdShort().equals(other.getIdShort());
}

}
12 changes: 6 additions & 6 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ java "-Dedc.fs.config=./example/configurations/provider.properties" -jar ./examp

After building the extension as seen above, a docker image can be built with

0. `cd ./example`
1. `docker build -t edc-aas-extension:latest .`
2. `mkdir workdir`
2. Create configuration under `./workdir/config.properties`
3. Add additional files under `./workdir` (Fitting to your paths in config.properties)
4. Run with `docker run -i -v $PWD/workdir:/workdir/ -e EDC_FS_CONFIG=/workdir/config.properties edc-extension4aas:latest`
1. `cd ./example`
2. `docker build -t edc-aas-extension:latest .`
3. `mkdir workdir`
4. Create configuration under `./workdir/config.properties`
5. Add additional files under `./workdir` (Fitting to your paths in config.properties)
6. Run with `docker run -i -v $PWD/workdir:/workdir/ -e EDC_FS_CONFIG=/workdir/config.properties edc-extension4aas:latest`

This docker image can be run individually or **inside a docker-compose file**:

Expand Down

0 comments on commit bb10cb6

Please sign in to comment.