Skip to content

Commit

Permalink
Merge pull request #25 from carlos-schmidt/main
Browse files Browse the repository at this point in the history
Code cleanup / Performance improvement
  • Loading branch information
carlos-schmidt authored Apr 13, 2023
2 parents e0fb5eb + 2a7e4c6 commit 1d64e85
Show file tree
Hide file tree
Showing 35 changed files with 1,960 additions and 659 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ Provide digital twin (AAS) data to business partners in Data Spaces like Catena-
| POST | negotiateContract (a) | Query Parameter "providerUrl": URL (r), request body: contractOffer (r) | Using a contractOffer and a providerUrl, negotiate a contract. Returns an agreementId on success.
| GET | transfer (a) | Query Parameter "providerUrl": URL (r), Query Parameter "agreementId": String (r), Query Parameter "assetId": String (r), Query Parameter "dataDestinationUrl" | Submits a data transfer request to the providerUrl. On success, returns the data behind the specified asset. Optionally, a data destination URL can be specified where the data is then sent to.
| POST | contractOffers (a) | request body: List of ContractOffers (JSON) (r) | Adds the given ContractOffers to the accepted ContractOffers list: On fully automated negotiation, the provider's ContractOffer is matched against the consumer's accepted ContractOffer list. If any ContractOffer's policies fit the provider's, the negotiation continues.
| GET | agreements (a) | Query Parameter "providerUrl": URL, Query Parameter "assetId": String | Get agreements for already negotiated contracts. These agreements are stored within the extension.
| DELETE | agreements (a) | Query Parameter "agreementId": String (r) | Remove an agremeent of an already negotiated contract.

### Dependencies

Expand Down Expand Up @@ -86,6 +84,7 @@ Provide digital twin (AAS) data to business partners in Data Spaces like Catena-
|edc.aas.exposeSelfDescription| True/False| Whether the Self Description should be exposed on {edc}/api/selfDescription. When set to False, the selfDescription is still available for authenticated requests.|
|edc.aas.defaultAccessPolicyPath|path |Path to an access policy file (JSON). This policy will be used as the default access policy for all assets created after the configuration value has been set.|
|edc.aas.defaultContractPolicyPath|path |Path to a contract policy file (JSON). This policy will be used as the default contract policy for all assets created after the configuration value has been set.|
|edc.aas.defaultContractValidity|long value in seconds| "Number of seconds during which contract is valid starting from startDate." |

#### **Client Configurations**

Expand Down
2 changes: 1 addition & 1 deletion edc-extension4aas/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ tasks.jacocoTestReport {
configurations.all {
resolutionStrategy.eachDependency {
if (requested.module.toString() == "com.google.inject:guice") {
artifactSelection{
artifactSelection {
selectArtifact(DependencyArtifact.DEFAULT_TYPE, null, null)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
Expand All @@ -29,6 +28,7 @@
import org.eclipse.edc.api.auth.spi.AuthenticationService;
import org.eclipse.edc.connector.contract.spi.negotiation.ConsumerContractNegotiationManager;
import org.eclipse.edc.connector.contract.spi.negotiation.observe.ContractNegotiationObservable;
import org.eclipse.edc.connector.contract.spi.negotiation.store.ContractNegotiationStore;
import org.eclipse.edc.connector.contract.spi.offer.store.ContractDefinitionStore;
import org.eclipse.edc.connector.policy.spi.store.PolicyDefinitionStore;
import org.eclipse.edc.connector.spi.catalog.CatalogService;
Expand All @@ -53,11 +53,12 @@
import de.fraunhofer.iosb.app.controller.ConfigurationController;
import de.fraunhofer.iosb.app.controller.ResourceController;
import de.fraunhofer.iosb.app.model.configuration.Configuration;
import de.fraunhofer.iosb.app.model.ids.SelfDescription;
import de.fraunhofer.iosb.app.model.ids.SelfDescriptionRepository;
import de.fraunhofer.iosb.app.sync.Synchronizer;
import okhttp3.OkHttpClient;

/**
* Extension providing/connecting EDC logic to the EDC-AAS-Application.
* EDC Extension supporting usage of Asset Administration Shells.
*/
public class AasExtension implements ServiceExtension {

Expand All @@ -74,6 +75,8 @@ public class AasExtension implements ServiceExtension {
@Inject
private ContractNegotiationObservable contractNegotiationObservable;
@Inject
private ContractNegotiationStore contractNegotiationStore;
@Inject
private OkHttpClient okHttpClient;
@Inject
private PolicyDefinitionStore policyStore;
Expand All @@ -92,11 +95,12 @@ public void initialize(ServiceExtensionContext context) {
logger.setMonitor(context.getMonitor());

// Distribute controllers, repositories
var selfDescriptionRepository = new ConcurrentHashMap<URL, SelfDescription>();
var selfDescriptionRepository = new SelfDescriptionRepository();
aasController = new AasController(okHttpClient);

var endpoint = new Endpoint(selfDescriptionRepository, aasController,
var endpoint = new Endpoint(selfDescriptionRepository, aasController);
var synchronizer = new Synchronizer(selfDescriptionRepository, aasController,
new ResourceController(assetIndex, contractStore, policyStore));
selfDescriptionRepository.registerListener(synchronizer);

loadConfig(context);
var configInstance = Configuration.getInstance();
Expand All @@ -114,15 +118,14 @@ public void initialize(ServiceExtensionContext context) {

// Task: get all AAS service URLs, synchronize EDC and AAS
syncExecutor.scheduleAtFixedRate(
() -> selfDescriptionRepository.keys().asIterator()
.forEachRemaining(url -> endpoint.syncAasWithEdc(url)),
configInstance.getSyncPeriod(),
() -> synchronizer.synchronize(),
1,
configInstance.getSyncPeriod(), TimeUnit.SECONDS);

webService.registerResource(endpoint);

var authenticationRequestFilter = new CustomAuthenticationRequestFilter(authenticationService,
configInstance.isExposeSelfDescription() ? Endpoint.SELF_DESCRIPTION_PATH : null);

webService.registerResource(authenticationRequestFilter);

initializeClient(context, authenticationRequestFilter);
Expand All @@ -141,7 +144,7 @@ private void initializeClient(ServiceExtensionContext context,
var observable = new DataTransferObservable();
var dataTransferEndpoint = new DataTransferEndpoint(observable);
webService.registerResource(
new ClientEndpoint(ownUri, catalogService, consumerNegotiationManager,
new ClientEndpoint(ownUri, catalogService, consumerNegotiationManager, contractNegotiationStore,
contractNegotiationObservable, transferProcessManager, observable,
authenticationRequestFilter));
webService.registerResource(dataTransferEndpoint);
Expand Down
Loading

0 comments on commit 1d64e85

Please sign in to comment.