-
Notifications
You must be signed in to change notification settings - Fork 23
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
Chore/upstream contribution #1383
base: main
Are you sure you want to change the base?
Changes from all commits
1f7dcd3
1588186
2d346b6
763c2a2
9a14191
e20c5c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
|
||
import { _environment } from './_environment.base'; | ||
|
||
export const environment = { | ||
..._environment, | ||
mockService: false, | ||
authDisabled: false, | ||
apiUrl: 'https://traceability-test.dev.demo.catena-x.net/api', | ||
keycloakUrl: 'https://centralidp.dev.demo.catena-x.net/auth', | ||
clientId: 'Cl17-CX-Part', | ||
api: '', | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,9 +29,9 @@ | |
import org.eclipse.tractusx.irs.edc.client.policy.model.exception.CreateEdcPolicyDefinitionException; | ||
import org.eclipse.tractusx.irs.edc.client.policy.model.exception.EdcPolicyDefinitionAlreadyExists; | ||
import org.eclipse.tractusx.irs.edc.client.policy.service.EdcPolicyDefinitionService; | ||
import org.eclipse.tractusx.traceability.common.properties.TraceabilityProperties; | ||
import org.eclipse.tractusx.traceability.common.properties.RegistryProperties; | ||
import org.eclipse.tractusx.traceability.common.properties.SubmodelProperties; | ||
import org.eclipse.tractusx.traceability.policies.application.service.PolicyService; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
import policies.response.PolicyResponse; | ||
|
||
|
@@ -43,65 +43,71 @@ | |
@Service | ||
@RequiredArgsConstructor | ||
public class EdcAssetCreationService { | ||
private static final String REGISTRY_ASSET_ID = "registry-asset"; | ||
private final EdcAssetService edcAssetService; | ||
private final EdcPolicyDefinitionService edcPolicyDefinitionService; | ||
private final EdcContractDefinitionService edcContractDefinitionService; | ||
private final TraceabilityProperties traceabilityProperties; | ||
private final RegistryProperties registryProperties; | ||
private final SubmodelProperties submodelProperties; | ||
private final PolicyService policyService; | ||
@Value("${registry.urlWithPath}") | ||
String registryUrlWithPath = null; | ||
|
||
|
||
public String createEdcContractDefinitionsForDtrAndSubmodel(String policyId) throws CreateEdcPolicyDefinitionException, CreateEdcAssetException, CreateEdcContractDefinitionException { | ||
PolicyResponse policy = policyService.getPolicy(policyId); | ||
String createdPolicyId; | ||
try { | ||
boolean exists = edcPolicyDefinitionService.policyDefinitionExists(policyId); | ||
if (exists) { | ||
log.info("Policy with id " + policyId + " already exists and contains necessary application constraints. Reusing for edc asset contract definition."); | ||
createdPolicyId =policyId; | ||
} else{ | ||
log.info("EDC Policy (DTR) already exists with id: {} reusing it", policyId); | ||
createdPolicyId = policyId; | ||
} else { | ||
createdPolicyId = edcPolicyDefinitionService.createAccessPolicy(mapToEdcPolicyRequest(policy)); | ||
log.info("DTR Policy Id created :{}", createdPolicyId); | ||
log.info("EDC Policy (DTR) created with id :{}", createdPolicyId); | ||
} | ||
} catch (EdcPolicyDefinitionAlreadyExists e) { | ||
createdPolicyId = policyId; | ||
} catch (Exception exception) { | ||
log.warn("EDC Policy (DTR) could not be created: {}", exception.getMessage()); | ||
throw new CreateEdcPolicyDefinitionException(exception); | ||
} | ||
|
||
String dtrAssetId; | ||
try { | ||
dtrAssetId = edcAssetService.createDtrAsset(registryUrlWithPath, REGISTRY_ASSET_ID); | ||
log.info("DTR Asset Id created :{}", dtrAssetId); | ||
dtrAssetId = edcAssetService.createDtrAsset(registryProperties.getUrlWithPathInternal(), registryProperties.getEdcAssetId()); | ||
log.info("EDC Asset (DTR) created with id :{}", dtrAssetId); | ||
} catch (EdcAssetAlreadyExistsException e) { | ||
dtrAssetId = REGISTRY_ASSET_ID; | ||
log.info("EDC Asset (DTR) already exists with id: {} reusing it", registryProperties.getEdcAssetId()); | ||
dtrAssetId = registryProperties.getEdcAssetId(); | ||
} catch (Exception exception) { | ||
log.warn("EDC Asset (DTR) could not be created: {}", exception.getMessage()); | ||
throw new CreateEdcAssetException(exception); | ||
} | ||
|
||
try { | ||
String dtrContractId = edcContractDefinitionService.createContractDefinition(dtrAssetId, createdPolicyId); | ||
log.info("DTR Contract Id created :{}", dtrContractId); | ||
log.info("EDC ContractDefinition (DTR) created with id :{}", dtrContractId); | ||
} catch (Exception e) { | ||
log.warn("EDC ContractDefinition (DTR) could not be created: {}", e.getMessage()); | ||
throw new CreateEdcContractDefinitionException(e); | ||
} | ||
|
||
String submodelAssetId; | ||
String submodelAssetIdToCreate = "urn:uuid:" + UUID.randomUUID(); | ||
try { | ||
submodelAssetId = edcAssetService.createSubmodelAsset(traceabilityProperties.getSubmodelBase(), submodelAssetIdToCreate); | ||
log.info("Submodel Asset Id created :{}", submodelAssetId); | ||
submodelAssetId = edcAssetService.createSubmodelAsset(submodelProperties.getBaseInternal(), submodelAssetIdToCreate); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you set the public url for the submodel, this is the case in the open source variant. Please check |
||
log.info("EDC Asset (Submodel) created with id :{}", submodelAssetId); | ||
} catch (EdcAssetAlreadyExistsException e) { | ||
submodelAssetId = submodelAssetIdToCreate; | ||
log.info("EDC Asset (Submodel) already exists with id: {} reusing it", submodelAssetId); | ||
} catch (Exception exception) { | ||
log.warn("EDC Asset (Submodel) could not be created: {}", exception.getMessage()); | ||
throw new CreateEdcAssetException(exception); | ||
} | ||
|
||
try { | ||
String submodelContractId = edcContractDefinitionService.createContractDefinition(submodelAssetId, createdPolicyId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if the submodel server is returning the id on open source variant. |
||
log.info("Submodel Contract Id created :{}", submodelContractId); | ||
log.info("EDC ContractDefinition (Submodel) created with id :{}", submodelContractId); | ||
} catch (Exception e) { | ||
log.warn("EDC ContractDefinition (Submodel) could not be created: {}", e.getMessage()); | ||
throw new CreateEdcContractDefinitionException(e); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please recheck if this exists open source