Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AAS to v3.0.2_SSP-001 #455

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.6.0-RC1
## 0.6.0-RC2
### Added

- Update API to AAS to v3.0.2_SSP-001 (Breaking changes)
- Changed type of aasIdentifier and submodelIdentifier from `byte[]` to `String`
- Changed patterns to `^([\\x09\\x0a\\x0d\\x20-\\ud7ff\\ue000-\\ufffd]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\udbfe][\\udc00-\\udfff]|\\udbff[\\udc00-\\udfff])*$`
## fixed
- Update Spring Boot to version 3.3.4
- Update logback to version 1.5.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
import org.eclipse.tractusx.semantics.aas.registry.model.AssetAdministrationShellDescriptor;
import org.eclipse.tractusx.semantics.aas.registry.model.AssetKind;
import org.eclipse.tractusx.semantics.aas.registry.model.AssetLink;
import org.eclipse.tractusx.semantics.aas.registry.model.GetAllAssetAdministrationShellIdsByAssetLink200Response;
import org.eclipse.tractusx.semantics.aas.registry.model.GetAssetAdministrationShellDescriptorsResult;
import org.eclipse.tractusx.semantics.aas.registry.model.GetSubmodelDescriptorsResult;
import org.eclipse.tractusx.semantics.aas.registry.model.InlineResponse200;
import org.eclipse.tractusx.semantics.aas.registry.model.SearchAllShellsByAssetLink200Response;
import org.eclipse.tractusx.semantics.aas.registry.model.ServiceDescription;
import org.eclipse.tractusx.semantics.aas.registry.model.SpecificAssetId;
Expand Down Expand Up @@ -84,18 +84,17 @@ public ResponseEntity<ServiceDescription> getDescription() {
}

@Override
public ResponseEntity<Void> deleteAssetAdministrationShellDescriptorById( byte[] aasIdentifier ) {
public ResponseEntity<Void> deleteAssetAdministrationShellDescriptorById( String aasIdentifier ) {
shellService.deleteShell( getDecodedId(aasIdentifier) );
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Override
public ResponseEntity<Void> deleteAllAssetLinksById(byte[] aasIdentifier) {

public ResponseEntity<Void> deleteAllAssetLinksById(String aasIdentifier) {
shellService.deleteAllIdentifiers(getDecodedId(aasIdentifier));
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Override
public ResponseEntity<Void> deleteSubmodelDescriptorByIdThroughSuperpath( byte[] aasIdentifier, byte[] submodelIdentifier, @RequestHeader String externalSubjectId ) {
public ResponseEntity<Void> deleteSubmodelDescriptorByIdThroughSuperpath( String aasIdentifier, String submodelIdentifier, @RequestHeader String externalSubjectId ) {
shellService.deleteSubmodel(getDecodedId( aasIdentifier ), getDecodedId( submodelIdentifier ),getExternalSubjectIdOrEmpty( externalSubjectId ));
return new ResponseEntity<>(HttpStatus.NO_CONTENT);

Expand All @@ -110,22 +109,22 @@ public ResponseEntity<GetAssetAdministrationShellDescriptorsResult> getAllAssetA
}

@Override
public ResponseEntity<GetSubmodelDescriptorsResult> getAllSubmodelDescriptorsThroughSuperpath( byte[] aasIdentifier, Integer limit, String cursor, @RequestHeader String externalSubjectId ) {
public ResponseEntity<GetSubmodelDescriptorsResult> getAllSubmodelDescriptorsThroughSuperpath( String aasIdentifier, Integer limit, String cursor, @RequestHeader String externalSubjectId ) {
Shell savedShell = shellService.findShellByExternalIdAndExternalSubjectId(getDecodedId( aasIdentifier ),getExternalSubjectIdOrEmpty(externalSubjectId));
SubmodelCollectionDto dto = shellService.findAllSubmodel( limit,cursor, savedShell);
GetSubmodelDescriptorsResult result= submodelMapper.toApiDto( dto );
return new ResponseEntity<>(result, HttpStatus.OK);
}

@Override
public ResponseEntity<AssetAdministrationShellDescriptor> getAssetAdministrationShellDescriptorById( byte[] aasIdentifier, @RequestHeader String externalSubjectId ) {
public ResponseEntity<AssetAdministrationShellDescriptor> getAssetAdministrationShellDescriptorById( String aasIdentifier, @RequestHeader String externalSubjectId ) {
String decodedAasIdentifier = getDecodedId( aasIdentifier );
Shell saved = shellService.findShellByExternalIdAndExternalSubjectId(decodedAasIdentifier, getExternalSubjectIdOrEmpty(externalSubjectId));
return new ResponseEntity<>(shellMapper.toApiDto(saved), HttpStatus.OK);
}

@Override
public ResponseEntity<SubmodelDescriptor> getSubmodelDescriptorByIdThroughSuperpath( byte[] aasIdentifier, byte[] submodelIdentifier, @RequestHeader String externalSubjectId ) {
public ResponseEntity<SubmodelDescriptor> getSubmodelDescriptorByIdThroughSuperpath( String aasIdentifier, String submodelIdentifier, @RequestHeader String externalSubjectId ) {
Submodel submodel = shellService.findSubmodelByExternalId(getDecodedId( aasIdentifier ), getDecodedId( submodelIdentifier ),getExternalSubjectIdOrEmpty( externalSubjectId ));
return new ResponseEntity<>(submodelMapper.toApiDto(submodel), HttpStatus.OK);
}
Expand All @@ -140,7 +139,7 @@ public ResponseEntity<AssetAdministrationShellDescriptor> postAssetAdministratio
}

@Override
public ResponseEntity<SubmodelDescriptor> postSubmodelDescriptorThroughSuperpath( byte[] aasIdentifier, @RequestHeader String externalSubjectId, SubmodelDescriptor submodelDescriptor ) {
public ResponseEntity<SubmodelDescriptor> postSubmodelDescriptorThroughSuperpath( String aasIdentifier, SubmodelDescriptor submodelDescriptor, @RequestHeader String externalSubjectId ) {
Submodel toBeSaved = submodelMapper.fromApiDto(submodelDescriptor);
toBeSaved.setIdExternal( submodelDescriptor.getId() );
shellService.mapSubmodel( Set.of(toBeSaved) );
Expand All @@ -149,26 +148,26 @@ public ResponseEntity<SubmodelDescriptor> postSubmodelDescriptorThroughSuperpath
}

@Override
public ResponseEntity<Void> putAssetAdministrationShellDescriptorById( byte[] aasIdentifier, AssetAdministrationShellDescriptor assetAdministrationShellDescriptor, @RequestHeader String externalSubjectId ) {
public ResponseEntity<Void> putAssetAdministrationShellDescriptorById( String aasIdentifier, AssetAdministrationShellDescriptor assetAdministrationShellDescriptor, @RequestHeader String externalSubjectId ) {
Shell shell = shellMapper.fromApiDto( assetAdministrationShellDescriptor );
Shell shellFromDb = shellService.findShellByExternalIdWithoutFiltering( getDecodedId( aasIdentifier ) );
shellService.update( shell.withId( shellFromDb.getId() ).withIdExternal( getDecodedId( aasIdentifier ) ), getDecodedId( aasIdentifier ) );
return new ResponseEntity<>( HttpStatus.NO_CONTENT );
}

@Override
public ResponseEntity<Void> putSubmodelDescriptorByIdThroughSuperpath( byte[] aasIdentifier, byte[] submodelIdentifier, @RequestHeader String externalSubjectId, SubmodelDescriptor submodelDescriptor ) {
public ResponseEntity<Void> putSubmodelDescriptorByIdThroughSuperpath( String aasIdentifier, String submodelIdentifier, SubmodelDescriptor submodelDescriptor, @RequestHeader String externalSubjectId ) {
shellService.deleteSubmodel(getDecodedId( aasIdentifier ), getDecodedId( submodelIdentifier ),getExternalSubjectIdOrEmpty( externalSubjectId ));
submodelDescriptor.setId( getDecodedId( submodelIdentifier ));
postSubmodelDescriptorThroughSuperpath(aasIdentifier,externalSubjectId,submodelDescriptor);
postSubmodelDescriptorThroughSuperpath(aasIdentifier,submodelDescriptor,externalSubjectId );
return new ResponseEntity<>( HttpStatus.NO_CONTENT );
}

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

List<SpecificAssetId> listSpecificAssetId = assetIds.stream().map( this::decodeSAID).collect( Collectors.toList());
Expand All @@ -190,25 +189,25 @@ public ResponseEntity<SearchAllShellsByAssetLink200Response> searchAllShellsByAs
return new ResponseEntity<>( result, HttpStatus.OK );
}

private SpecificAssetId decodeSAID(byte[] encodedId){
private SpecificAssetId decodeSAID(String encodedId){
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion( JsonInclude.Include.NON_NULL);
try {
byte[] decodedBytes = Base64.getUrlDecoder().decode( encodedId );
return mapper.readValue(decodedBytes, SpecificAssetId.class );
String decodeString = new String(Base64.getUrlDecoder().decode( encodedId ));
return mapper.readValue(decodeString, 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) {
public ResponseEntity<List<SpecificAssetId>> getAllAssetLinksById(String aasIdentifier,@RequestHeader String externalSubjectId) {
Set<ShellIdentifier> identifiers = shellService.findShellIdentifiersByExternalShellId(getDecodedId( aasIdentifier ),getExternalSubjectIdOrEmpty(externalSubjectId));
return new ResponseEntity<>(shellMapper.toApiDto(identifiers), HttpStatus.OK);
}

@Override
public ResponseEntity<List<SpecificAssetId>> postAllAssetLinksById(byte[] aasIdentifier, List<SpecificAssetId> specificAssetId, @RequestHeader String externalSubjectId ) {
public ResponseEntity<List<SpecificAssetId>> postAllAssetLinksById(String aasIdentifier, List<SpecificAssetId> specificAssetId, @RequestHeader String externalSubjectId ) {
Set<ShellIdentifier> shellIdentifiers = shellService.save(getDecodedId( aasIdentifier ), shellMapper.fromApiDto(specificAssetId),getExternalSubjectIdOrEmpty( externalSubjectId ));
List<SpecificAssetId> list = shellMapper.toApiDto(shellIdentifiers);
return new ResponseEntity<>(list, HttpStatus.CREATED);
Expand All @@ -218,7 +217,7 @@ private String getExternalSubjectIdOrEmpty(String externalSubjectId) {
return (null ==externalSubjectId) ? "" : externalSubjectId;
}

private String getDecodedId( byte[] aasIdentifier ) {
private String getDecodedId( String aasIdentifier ) {
try {
byte[] decodedBytes = Base64.getUrlDecoder().decode( aasIdentifier );
return new String( decodedBytes );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.tractusx.semantics.RegistryProperties;
import org.eclipse.tractusx.semantics.aas.registry.model.GetAllAssetAdministrationShellIdsByAssetLink200Response;
import org.eclipse.tractusx.semantics.aas.registry.model.InlineResponse200;
import org.eclipse.tractusx.semantics.aas.registry.model.PagedResultPagingMetadata;
import org.eclipse.tractusx.semantics.aas.registry.model.SearchAllShellsByAssetLink200Response;
import org.eclipse.tractusx.semantics.accesscontrol.api.exception.DenyAccessException;
Expand Down Expand Up @@ -271,7 +271,7 @@ private Specification<Submodel> hasShellFkId( Shell shellId ) {
}

@Transactional( readOnly = true )
public GetAllAssetAdministrationShellIdsByAssetLink200Response findExternalShellIdsByIdentifiersByExactMatch( Set<ShellIdentifier> shellIdentifiers,
public InlineResponse200 findExternalShellIdsByIdentifiersByExactMatch( Set<ShellIdentifier> shellIdentifiers,
Integer pageSize, String cursor, String externalSubjectId ) {

pageSize = getPageSize( pageSize );
Expand All @@ -286,12 +286,12 @@ public GetAllAssetAdministrationShellIdsByAssetLink200Response findExternalShell

final var assetIdList = visibleAssetIds.stream().limit( pageSize ).toList();
final String nextCursor = getCursorEncoded( visibleAssetIds, assetIdList );
final var response = new GetAllAssetAdministrationShellIdsByAssetLink200Response();
final var response = new InlineResponse200();
response.setResult( assetIdList );
response.setPagingMetadata( new PagedResultPagingMetadata().cursor( nextCursor ) );
return response;
} catch ( DenyAccessException e ) {
final var response = new GetAllAssetAdministrationShellIdsByAssetLink200Response();
final var response = new InlineResponse200();
response.setResult( Collections.emptyList() );
return response;
}
Expand Down
Loading
Loading