Skip to content

Commit

Permalink
Merge pull request #243 from bci-oss/feature/prepare-ASS-V3.0.1
Browse files Browse the repository at this point in the history
Feat: Changes done for AAS updates v3.0.1
  • Loading branch information
tunacicek authored Dec 1, 2023
2 parents 097018a + dd325b7 commit 75426da
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 59 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Length for Column "SUB_PROTOCOL_BODY" has been extended to 2048.
## fixed

- Fix done for encoding input parameter to get shell look up api.
- Fixed response for GetDescription api.

## 0.3.20
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
********************************************************************************/
package org.eclipse.tractusx.semantics.registry.controller;

import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;

import org.eclipse.tractusx.semantics.aas.registry.api.DescriptionApiDelegate;
import org.eclipse.tractusx.semantics.aas.registry.api.LookupApiDelegate;
Expand All @@ -39,6 +41,9 @@
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.context.request.NativeWebRequest;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;

@Service
public class AssetAdministrationShellApiDelegate implements DescriptionApiDelegate, ShellDescriptorsApiDelegate, LookupApiDelegate {

Expand All @@ -62,8 +67,7 @@ public Optional<NativeWebRequest> getRequest() {
@Override
public ResponseEntity<ServiceDescription> getDescription() {
ServiceDescription serviceDescription = new ServiceDescription();
serviceDescription.setProfiles( List.of( ServiceDescription.ProfilesEnum.ASSETADMINISTRATIONSHELLREPOSITORYSERVICESPECIFICATION_V3_0_MINIMALPROFILE,
ServiceDescription.ProfilesEnum.REGISTRYSERVICESPECIFICATION_V3_0) );
serviceDescription.setProfiles( List.of( ServiceDescription.ProfilesEnum.ASSETADMINISTRATIONSHELLREGISTRYSERVICESPECIFICATION_SSP_001, ServiceDescription.ProfilesEnum.DISCOVERYSERVICESPECIFICATION_SSP_001) );
return new ResponseEntity<>( serviceDescription, HttpStatus.OK );
}

Expand Down Expand Up @@ -149,16 +153,29 @@ public ResponseEntity<Void> putSubmodelDescriptorByIdThroughSuperpath( byte[] aa
}

@Override
public ResponseEntity<GetAllAssetAdministrationShellIdsByAssetLink200Response> getAllAssetAdministrationShellIdsByAssetLink(List<SpecificAssetId> assetIds,
public ResponseEntity<GetAllAssetAdministrationShellIdsByAssetLink200Response> getAllAssetAdministrationShellIdsByAssetLink(List<byte[]> assetIds,
Integer limit, String cursor, @RequestHeader String externalSubjectId) {
if (assetIds == null || assetIds.isEmpty()) {
return new ResponseEntity<>(new GetAllAssetAdministrationShellIdsByAssetLink200Response(), HttpStatus.OK);
}

List<SpecificAssetId> listSpecificAssetId =assetIds.stream().map( this::decodeSAID).collect( Collectors.toList());
GetAllAssetAdministrationShellIdsByAssetLink200Response result =
shellService.findExternalShellIdsByIdentifiersByExactMatch(shellMapper.fromApiDto(assetIds), limit, cursor,getExternalSubjectIdOrEmpty(externalSubjectId));
shellService.findExternalShellIdsByIdentifiersByExactMatch(shellMapper.fromApiDto(listSpecificAssetId), limit, cursor,getExternalSubjectIdOrEmpty(externalSubjectId));
return new ResponseEntity<>(result, HttpStatus.OK);
}

private SpecificAssetId decodeSAID(byte[] encodedId){
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion( JsonInclude.Include.NON_NULL);
try {
byte[] decodedBytes = Base64.getUrlDecoder().decode( encodedId );
return mapper.readValue(decodedBytes, SpecificAssetId.class );
} catch (Exception e ) {
throw new IllegalArgumentException("Incorrect Base64 encoded value provided as parameter");
}
}

@Override
public ResponseEntity<List<SpecificAssetId>> getAllAssetLinksById(byte[] aasIdentifier,@RequestHeader String externalSubjectId) {
Set<ShellIdentifier> identifiers = shellService.findShellIdentifiersByExternalShellId(getDecodedId( aasIdentifier ),getExternalSubjectIdOrEmpty(externalSubjectId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ protected SecurityFilterChain configure(HttpSecurity http) throws Exception {
.requestMatchers( HttpMethod.POST, "/**/lookup/**" ).access( "@authorizationEvaluator.hasRoleAddDigitalTwin()" )
.requestMatchers( HttpMethod.PUT, "/**/lookup/**" ).access( "@authorizationEvaluator.hasRoleUpdateDigitalTwin()" )
.requestMatchers( HttpMethod.DELETE, "/**/lookup/**" ).access( "@authorizationEvaluator.hasRoleDeleteDigitalTwin()" )

//getDescription allowed for reader
.requestMatchers( HttpMethod.GET, "/**/description" ).access( "@authorizationEvaluator.hasRoleViewDigitalTwin()" )
)
.csrf(CsrfConfigurer::disable)
.sessionManagement(sessionManagement -> sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
Expand Down
53 changes: 25 additions & 28 deletions backend/src/main/resources/static/aas-registry-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -703,16 +703,12 @@ paths:
# the "content" is the correct way to accept json encoded query parameters
# style: form
# explode: true
content:
application/json:
schema:
type: array
maxItems: 10000
items:
$ref: '#/components/schemas/SpecificAssetId'
examples:
complete:
$ref: '#/components/examples/lookup-shells-by-aas-identifier-query'
schema:
type: array
items:
type: string
format: byte
example: '?assetIds=eyAibmFtZSI6ICJzb21lLWFzc2V0LWlkIiwgInZhbHVlIjogImh0dHA6Ly9leGFtcGxlLWNvbXBhbnkuY29tL215QXNzZXQiLCAiZXh0ZXJuYWxTdWJqZWN0SWQiOiB7ICJrZXlzIjogWyB7ICJ0eXBlIjogIkdsb2JhbFJlZmVyZW5jZSIsICJ2YWx1ZSI6ICJodHRwOi8vZXhhbXBsZS1jb21wYW55LmNvbS9leGFtcGxlLWNvbXBhbnlzLWFzc2V0LWtleXMiIH0gXSwgInR5cGUiOiAiR2xvYmFsUmVmZXJlbmNlIiB9IH0&assetIds=eyAibmFtZSI6ICJzb21lLW90aGVyLWFzc2V0LWlkIiwgInZhbHVlIjogIjEyMzQ1QUJDIiwgImV4dGVybmFsU3ViamVjdElkIjogeyAia2V5cyI6IFsgeyAidHlwZSI6ICJHbG9iYWxSZWZlcmVuY2UiLCAidmFsdWUiOiAiaHR0cDovL215LW93bi1jb21wYW55LmNvbS9rZXlzIiB9IF0sICJ0eXBlIjogIkdsb2JhbFJlZmVyZW5jZSIgfSB9'
- name: limit
in: query
description: The maximum number of elements in the response array
Expand Down Expand Up @@ -1505,29 +1501,30 @@ components:
properties:
profiles:
minItems: 1
maxItems: 10000
type: array

Check warning on line 1504 in backend/src/main/resources/static/aas-registry-openapi.yaml

View workflow job for this annotation

GitHub Actions / Analyze

[HIGH] Array Without Maximum Number of Items (v3)

Array schema should have the field 'maxItems' set
items:
type: string
enum:
- AssetAdministrationShellServiceSpecification/V3.0
- AssetAdministrationShellServiceSpecification/V3.0-MinimalProfile
- SubmodelServiceSpecification/V3.0
- SubmodelServiceSpecification/V3.0-ValueProfile
- SubmodelServiceSpecification/V3.0-MinimalProfile
- AasxFileServerServiceSpecification/V3.0
- RegistryServiceSpecification/V3.0
- RegistryServiceSpecification/V3.0- AssetAdministrationShellRegistry
- RegistryServiceSpecification/V3.0-SubmodelRegistry
- RepositoryServiceSpecification/V3.0
- RepositoryServiceSpecification/V3.0-MinimalProfile
- AssetAdministrationShellRepositoryServiceSpecification/V3.0
- AssetAdministrationShellRepositoryServiceSpecification/V3.0-MinimalProfile
- SubmodelRepositoryServiceSpecification/V3.0
- SubmodelRepositoryServiceSpecification/V3.0-MinimalProfile
- RegistryAndDiscoveryServiceSpecification/V3.0
- https://admin-shell.io/aas/API/3/0/AssetAdministrationShellServiceSpecification/SSP-001
- https://admin-shell.io/aas/API/3/0/AssetAdministrationShellServiceSpecification/SSP-002
- https://admin-shell.io/aas/API/3/0/SubmodelServiceSpecification/SSP-001
- https://admin-shell.io/aas/API/3/0/SubmodelServiceSpecification/SSP-002
- https://admin-shell.io/aas/API/3/0/SubmodelServiceSpecification/SSP-003
- https://admin-shell.io/aas/API/3/0/AasxFileServerServiceSpecification/SSP-001
- https://admin-shell.io/aas/API/3/0/AssetAdministrationShellRegistryServiceSpecification/SSP-001
- https://admin-shell.io/aas/API/3/0/AssetAdministrationShellRegistryServiceSpecification/SSP-002
- https://admin-shell.io/aas/API/3/0/SubmodelRegistryServiceSpecification/SSP-001
- https://admin-shell.io/aas/API/3/0/SubmodelRegistryServiceSpecification/SSP-002
- https://admin-shell.io/aas/API/3/0/DiscoveryServiceSpecification/SSP-001
- https://admin-shell.io/aas/API/3/0/AssetAdministrationShellRepositoryServiceSpecification/SSP-001
- https://admin-shell.io/aas/API/3/0/AssetAdministrationShellRepositoryServiceSpecification/SSP-002
- https://admin-shell.io/aas/API/3/0/SubmodelRepositoryServiceSpecification/SSP-001
- https://admin-shell.io/aas/API/3/0/SubmodelRepositoryServiceSpecification/SSP-002
- https://admin-shell.io/aas/API/3/0/SubmodelRepositoryServiceSpecification/SSP-003
- https://admin-shell.io/aas/API/3/0/SubmodelRepositoryServiceSpecification/SSP-004
- https://admin-shell.io/aas/API/3/0/ConceptDescriptionServiceSpecification/SSP-001
description: "The Description object enables servers to present their capabilities to the clients, in particular which profiles they implement. At least one defined profile is required. Additional, proprietary attributes might be included. Nevertheless, the server must not expect that a regular client understands them."
example: { "profiles": [ "RepositoryServiceSpecification/V3.0-MinimalProfile", "RegistryServiceSpecification/V3.0" ] }
example: { "profiles": ["https://admin-shell.io/aas/API/3/0/AssetAdministrationShellRegistryServiceSpecification/SSP-002", "https://admin-shell.io/aas/API/3/0/SubmodelRegistryServiceSpecification/SSP-002"] }
PagedResult_paging_metadata:
type: object
properties:
Expand Down
Loading

0 comments on commit 75426da

Please sign in to comment.