Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feature/retrieve-fi…
Browse files Browse the repository at this point in the history
…ltered-models-in-auth
  • Loading branch information
mdanish98 committed Dec 23, 2024
2 parents 5c7836a + 8d13c0e commit 58cb7bb
Show file tree
Hide file tree
Showing 199 changed files with 5,447 additions and 1,171 deletions.
141 changes: 141 additions & 0 deletions .github/workflows/docker-snapshot-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Build and Push Docker Images on PR Merge

on:
push:
branches:
- main
paths-ignore:
- '.github/ISSUE_TEMPLATE/**'
- '.github/CODE_OF_CONDUCT.md'
- '.github/CODING_CONVENTIONS.md'
- '.github/CONTRIBUTING.md'
- '.github/dependabot.yml'
- '.github/pull_request_template.md'
- '.github/SECURITY.md'
- 'docs/**'
- 'examples/**'
- 'README.md'
- '.gitattributes'
- '.gitignore'
- 'LICENSE'
- 'NOTICE'

env:
DOCKER_NAMESPACE: eclipsebasyx

jobs:
build-and-push-prerelease:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: aas-environment
path: basyx.aasenvironment/basyx.aasenvironment.component
- name: aas-repository
path: basyx.aasrepository/basyx.aasrepository.component
- name: submodel-repository
path: basyx.submodelrepository/basyx.submodelrepository.component
- name: conceptdescription-repository
path: basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository.component
- name: aas-discovery
path: basyx.aasdiscoveryservice/basyx.aasdiscoveryservice.component
- name: aasxfileserver
path: basyx.aasxfileserver/basyx.aasxfileserver.component
- name: aas-registry-kafka-mem
path: basyx.aasregistry/basyx.aasregistry-service-release-kafka-mem/src/main/docker
- name: aas-registry-kafka-mongodb
path: basyx.aasregistry/basyx.aasregistry-service-release-kafka-mongodb/src/main/docker
- name: aas-registry-log-mem
path: basyx.aasregistry/basyx.aasregistry-service-release-log-mem/src/main/docker
- name: aas-registry-log-mongodb
path: basyx.aasregistry/basyx.aasregistry-service-release-log-mongodb/src/main/docker
- name: submodel-registry-kafka-mem
path: basyx.submodelregistry/basyx.submodelregistry-service-release-kafka-mem/src/main/docker
- name: submodel-registry-kafka-mongodb
path: basyx.submodelregistry/basyx.submodelregistry-service-release-kafka-mongodb/src/main/docker
- name: submodel-registry-log-mem
path: basyx.submodelregistry/basyx.submodelregistry-service-release-log-mem/src/main/docker
- name: submodel-registry-log-mongodb
path: basyx.submodelregistry/basyx.submodelregistry-service-release-log-mongodb/src/main/docker

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64,linux/arm/v7

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Build all modules first
run: mvn clean install -DskipTests

# Build the project
# For registry modules, we activate the dockerbuild profile and specify the module with --pl
- name: Build BaSyx
run: |
if [[ "${{ matrix.name }}" == *"registry"* ]]; then
# Derive the module's artifactId from the path
module_root=$(dirname "$(dirname "$(dirname "${{ matrix.path }}")")")
artifact_id=$(basename "$module_root")
# Run with dockerbuild profile and namespace
mvn clean install -DskipTests -Pdockerbuild "-Ddocker.namespace=${{ env.DOCKER_NAMESPACE }}" --pl "org.eclipse.digitaltwin.basyx:${artifact_id}"
else
echo "Non-registry module - already built in the previous step."
fi
- name: Prepare Registry JAR for Docker
if: contains(matrix.name, 'registry')
run: |
# Go three levels up from src/main/docker to get the module root
module_root=$(dirname "$(dirname "$(dirname "${{ matrix.path }}")")")
# Adjust the path to where the dockerbuild profile places the JAR
JAR_FILE=$(ls "$module_root/target/docker/${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}/2.0.0-SNAPSHOT/build/maven/"*.jar | head -n 1)
if [ -z "$JAR_FILE" ]; then
echo "No repackaged JAR found in $module_root/target/docker/${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}/2.0.0-SNAPSHOT/build/maven. Check your build."
exit 1
fi
# Create the maven directory inside the Docker context and copy the JAR there
mkdir -p "${{ matrix.path }}/maven"
cp "$JAR_FILE" "${{ matrix.path }}/maven/"
# Extract the final name without .jar extension
FINAL_NAME=$(basename "$JAR_FILE" .jar)
echo "FINAL_ARGS=FINAL_NAME=${FINAL_NAME}" >> $GITHUB_ENV
- name: No-Op for Non-Registry Modules
if: "!contains(matrix.name, 'registry')"
run: echo "FINAL_ARGS=" >> $GITHUB_ENV

- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.path }}
file: ${{ matrix.path }}/Dockerfile
push: true
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: |
${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}:2.0.0-SNAPSHOT
build-args: ${{ env.FINAL_ARGS }}

- name: Verify Docker Image
run: |
docker pull ${{ env.DOCKER_NAMESPACE }}/${{ matrix.name }}:2.0.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice-backend</artifactId>
</dependency>

</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.backend.inmemory.core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.AasDiscoveryBackendProvider;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.AasDiscoveryDocument;
import org.eclipse.digitaltwin.basyx.common.backend.inmemory.core.InMemoryCrudRepository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;
Expand All @@ -41,7 +42,7 @@
@Component
public class AasDiscoveryInMemoryBackendProvider implements AasDiscoveryBackendProvider {

private AasDiscoveryInMemoryCrudRepository repository = new AasDiscoveryInMemoryCrudRepository();
private CrudRepository<AasDiscoveryDocument, String> repository = new InMemoryCrudRepository<AasDiscoveryDocument>(AasDiscoveryDocument::getShellIdentifier);

@Override
public CrudRepository<AasDiscoveryDocument, String> getCrudRepository() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public abstract class AasDiscoveryServiceSuite {

protected abstract AasDiscoveryService getAasDiscoveryService();

private final PaginationInfo noLimitPaginationInfo = new PaginationInfo(0, "");

@Test
public void getAllAssetAdministrationShellIdsByAssetLink() {
AasDiscoveryService discoveryService = getAasDiscoveryService();
Expand All @@ -74,7 +72,7 @@ public void getAllAssetAdministrationShellIdsByAssetLink() {
new AssetLink("DummyAssetName2", "DummyAsset_2_Value")
));

List<String> actualResult = discoveryService.getAllAssetAdministrationShellIdsByAssetLink(noLimitPaginationInfo, assetIds)
List<String> actualResult = discoveryService.getAllAssetAdministrationShellIdsByAssetLink(PaginationInfo.NO_LIMIT, assetIds)
.getResult();

assertEquals(expectedResult.size(), actualResult.size());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.eclipse.digitaltwin.basyx.aasdiscoveryservice.http;

import java.util.List;
import java.util.TreeSet;

import org.eclipse.digitaltwin.basyx.http.description.Profile;
import org.eclipse.digitaltwin.basyx.http.description.ProfileDeclaration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AasDiscoveryServiceDescriptionConfiguration {
@Bean
public ProfileDeclaration aasDiscoveryProfiles() {
return () -> new TreeSet<>(List.of(Profile.DISCOVERYSERVICESPECIFICATION_SSP_001));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM amazoncorretto:17
FROM eclipse-temurin:17
ARG HTTP_PROXY
ARG HTTPS_PROXY
USER nobody
WORKDIR /application
ARG JAR_FILE=target/*-exec.jar
Expand Down
13 changes: 11 additions & 2 deletions basyx.aasenvironment/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Eclipse BaSyx provides the AAS Environment as off-the-shelf component:
It aggregates the AAS Repository, Submodel Repository and ConceptDescription Repository into a single component. For its features and configuration, see the documentation of the respective components.

In addition, it supports the following endpoint defined in DotAAS Part 2 V3 - Serialization Interface:
- GenerateSerializationByIds
- GenerateSerializationByIds. For more information about this endpoint please refer to [Swagger API](https://app.swaggerhub.com/apis/Plattform_i40/Entire-API-Collection/V3.0.1#/Serialization%20API/GenerateSerializationByIds)

The Aggregated API endpoint documentation is available at:

Expand Down Expand Up @@ -40,10 +40,19 @@ For examples, see [application.properties](./basyx.aasenvironment.component/src/

## AAS Environment Upload Endpoint

AAS environments (e.g. XML, JSON, AASX) can be uploaded by a multipart/form-data POST on the `/upload` endpoint. Please note that the following MIME types are expected for the respective file uploads:
AAS environments (e.g. XML, JSON, AASX) can be uploaded by a multipart/form-data POST on the `/upload` endpoint. Please note that the following MIME types as **Accept Header** are expected for the respective file uploads:
* AASX: application/asset-administration-shell-package
* JSON: application/json
* XML: application/xml

Below is an example curl request:

```
curl --location 'http://localhost:8081/upload' \
--header 'Accept: application/asset-administration-shell-package' \
--form 'file=@"Sample.aasx"'
```

The upload follows the same rules as the preconfiguration in terms of handling existing AAS, submodels and concept descriptions. In order for the file to be recognized correctly, please make sure that its MIME type is properly configured.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,7 @@ public void createSubmodelInAas(String aasIdentifier, Submodel submodel) {
throw new RegistryHttpRequestException(aasIdentifier, e);
}

Reference smRef = AasUtils.toReference(AasUtils.toReference(shell), submodel);

// TODO See https://github.com/eclipse-aas4j/aas4j/issues/308
smRef.setReferredSemanticId(submodel.getSemanticId());
Reference smRef = AasUtils.toReference(AasUtils.toReference(shell), submodel, true);

aasRepository.addSubmodelReference(aasIdentifier, smRef);
}
Expand Down
Loading

0 comments on commit 58cb7bb

Please sign in to comment.