-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
554 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package org.fiware.iam; | ||
|
||
import io.micronaut.context.annotation.Factory; | ||
import io.micronaut.runtime.Micronaut; | ||
|
||
@Factory | ||
public class Application { | ||
|
||
public static void main(String[] args) { | ||
Micronaut.run(Application.class, args); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.fiware.iam; | ||
|
||
import org.fiware.iam.tmforum.agreement.model.RelatedPartyTmfVO; | ||
import org.fiware.iam.tmforum.productorder.model.RelatedPartyVO; | ||
import org.mapstruct.Mapper; | ||
/** | ||
* Mapper for objects between TMForum APIs | ||
*/ | ||
@Mapper(componentModel = "jsr330") | ||
public interface TMFMapper { | ||
|
||
RelatedPartyTmfVO map(RelatedPartyVO relatedPartyVO); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.fiware.iam.dsp; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import io.micronaut.http.HttpResponse; | ||
import io.micronaut.http.HttpStatus; | ||
import jakarta.inject.Singleton; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.fiware.iam.exception.RainbowException; | ||
import org.fiware.rainbow.api.AgreementApiClient; | ||
import org.fiware.rainbow.model.AgreementCreateVO; | ||
import org.fiware.rainbow.model.AgreementVO; | ||
import reactor.core.publisher.Mono; | ||
|
||
|
||
/** | ||
* Adapter to handle communication with Rainbow. | ||
*/ | ||
@Singleton | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class RainbowAdapter { | ||
|
||
private final AgreementApiClient agreementApiClient; | ||
private final ObjectMapper objectMapper; | ||
|
||
/** | ||
* Create the agreement for the given organization and offer | ||
*/ | ||
public Mono<AgreementVO> createAgreement(String organizationId, String offeringId) { | ||
AgreementCreateVO agreementCreateVO = new AgreementCreateVO() | ||
.identity(organizationId) | ||
.dataServiceId(offeringId); | ||
|
||
return agreementApiClient | ||
.createAgreement(agreementCreateVO) | ||
.onErrorMap(t -> new RainbowException("Was not able to create agreement")) | ||
.map(HttpResponse::body) | ||
.map(body -> objectMapper.convertValue(body, AgreementVO.class)); | ||
} | ||
|
||
/** | ||
* Delete the agreement with the given id | ||
*/ | ||
public Mono<Boolean> deleteAgreement(String agreementId) { | ||
return agreementApiClient.deleteAgreementById(agreementId) | ||
.map(objectHttpResponse -> { | ||
if (objectHttpResponse.status().equals(HttpStatus.ACCEPTED)) { | ||
return true; | ||
} | ||
return false; | ||
}) | ||
.onErrorReturn(false); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/org/fiware/iam/exception/RainbowException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.fiware.iam.exception; | ||
|
||
/** | ||
* Exception to be thrown in case of problems with rainbow | ||
*/ | ||
public class RainbowException extends RuntimeException { | ||
|
||
public RainbowException(String message) { | ||
super(message); | ||
} | ||
|
||
public RainbowException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/org/fiware/iam/exception/TrustedIssuersException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.fiware.iam.exception; | ||
|
||
/** | ||
* Exception to be thrown in case of issues with the trusted-issuers-list | ||
*/ | ||
public class TrustedIssuersException extends RuntimeException { | ||
|
||
public TrustedIssuersException(String message) { | ||
super(message); | ||
} | ||
|
||
public TrustedIssuersException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.