Skip to content
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
74 changes: 74 additions & 0 deletions basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice</artifactId>
<version>${revision}</version>
</parent>

<artifactId>basyx.aasdiscoveryservice-client</artifactId>
<name>AAS Discovery Service Client</name>

<dependencies>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice-core</artifactId>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice-backend-h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice-backend</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice-http</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.aasdiscoveryservice-feature-authorization</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.http</artifactId>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.digitaltwin.basyx</groupId>
<artifactId>basyx.authorization</artifactId>
<scope>test</scope>
<classifier>tests</classifier>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (C) 2025 the Eclipse BaSyx Authors
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* SPDX-License-Identifier: MIT
******************************************************************************/

package org.eclipse.digitaltwin.basyx.aasdiscoveryservice.client;

import org.eclipse.digitaltwin.basyx.client.internal.authorization.TokenManager;

/**
* Provides access to an Authorized Aas Repository on a remote server
*
* @author fried
*/
public class AuthorizedConnectedAasDiscoveryService extends ConnectedAasDiscoveryService {

private TokenManager tokenManager;

public AuthorizedConnectedAasDiscoveryService(String baseURL, TokenManager tokenManager) {
super(baseURL, tokenManager);
this.tokenManager = tokenManager;
}

public TokenManager getTokenManager() {
return tokenManager;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*******************************************************************************
* Copyright (C) 2025 the Eclipse BaSyx Authors
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* SPDX-License-Identifier: MIT
******************************************************************************/

package org.eclipse.digitaltwin.basyx.aasdiscoveryservice.client;

import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.client.internal.AssetAdministrationShellDiscoveryApi;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryService;
import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.model.AssetLink;
import org.eclipse.digitaltwin.basyx.client.internal.ApiException;
import org.eclipse.digitaltwin.basyx.client.internal.authorization.TokenManager;
import org.eclipse.digitaltwin.basyx.core.exceptions.*;
import org.eclipse.digitaltwin.basyx.core.pagination.CursorResult;
import org.eclipse.digitaltwin.basyx.core.pagination.PaginationInfo;
import org.springframework.http.HttpStatus;

import java.util.List;

/**
* Provides access to an AAS Discovery Service on a remote server
*
* @author fried
*/
public class ConnectedAasDiscoveryService implements AasDiscoveryService {

private final AssetAdministrationShellDiscoveryApi discoveryApi;

public ConnectedAasDiscoveryService(String baseURL){
this.discoveryApi = new AssetAdministrationShellDiscoveryApi(baseURL);
}

public ConnectedAasDiscoveryService(String baseURL, TokenManager tokenManager){
this.discoveryApi = new AssetAdministrationShellDiscoveryApi(baseURL, tokenManager);
}

@Override
public CursorResult<List<String>> getAllAssetAdministrationShellIdsByAssetLink(PaginationInfo pInfo, List<AssetLink> assetIds) {
try{
return discoveryApi.getAllAssetAdministrationShellIdsByAssetLink(assetIds, pInfo.getLimit(), pInfo.getCursor());
} catch (ApiException e) {
if(e.getCode() == HttpStatus.NOT_FOUND.value()){
throw new AssetLinkDoesNotExistException("No matching element for given assetIds");
} else {
throw new RuntimeException("Error while getting all Asset Administration Shell IDs by Asset Link", e);
}
}
}

@Override
public List<SpecificAssetId> getAllAssetLinksById(String shellIdentifier) {
try{
return discoveryApi.getAllAssetLinksById(shellIdentifier);
} catch (ApiException e) {
if(e.getCode() == HttpStatus.NOT_FOUND.value()){
throw new AssetLinkDoesNotExistException("Element with id "+shellIdentifier+" does not exist");
} else {
throw new RuntimeException("Error while getting all Asset Links by ID", e);
}
}
}

@Override
public List<SpecificAssetId> createAllAssetLinksById(String shellIdentifier, List<SpecificAssetId> assetIds) {
try{
return discoveryApi.postAllAssetLinksById(shellIdentifier, assetIds);
} catch (ApiException e) {
if(e.getCode() == HttpStatus.CONFLICT.value()){
throw new CollidingAssetLinkException("Asset Links for shell "+shellIdentifier+" already exists");
} else {
throw new RuntimeException("Error while creating all Asset Links by ID", e);
}
}
}

@Override
public void deleteAllAssetLinksById(String shellIdentifier) {
try{
discoveryApi.deleteAllAssetLinksById(shellIdentifier);
} catch (ApiException e) {
if(e.getCode() == HttpStatus.NOT_FOUND.value()){
throw new AssetLinkDoesNotExistException("Element with id "+shellIdentifier+" does not exist");
} else {
throw new RuntimeException("Error while deleting all Asset Links by ID", e);
}
}
}
}
Loading