-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
d1209ad
commit 9e865c4
Showing
5 changed files
with
193 additions
and
23 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
71 changes: 71 additions & 0 deletions
71
...a-client/src/main/java/com/oviva/epa/client/internal/ExceptionMappedKonnektorService.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,71 @@ | ||
package com.oviva.epa.client.internal; | ||
|
||
import com.oviva.epa.client.KonnektorService; | ||
import com.oviva.epa.client.model.*; | ||
import de.gematik.epa.ihe.model.document.Document; | ||
import de.gematik.epa.ihe.model.simple.AuthorInstitution; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import telematik.ws.conn.exception.FaultMessageException; | ||
|
||
/** | ||
* Simple decorator for a KonnektorService to wrap underlying {@link | ||
* telematik.ws.conn.exception.FaultMessageException} into {@link KonnektorException} | ||
*/ | ||
public class ExceptionMappedKonnektorService implements KonnektorService { | ||
|
||
private final KonnektorService delegate; | ||
|
||
public ExceptionMappedKonnektorService(KonnektorService delegate) { | ||
this.delegate = delegate; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public List<AuthorInstitution> getAuthorInstitutions() { | ||
return wrap(delegate::getAuthorInstitutions); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public List<Card> getCardsInfo() { | ||
return wrap(delegate::getCardsInfo); | ||
} | ||
|
||
@Override | ||
public @NonNull PinStatus verifySmcPin(@NonNull String cardHandle) { | ||
return wrap(() -> delegate.verifySmcPin(cardHandle)); | ||
} | ||
|
||
@Override | ||
public @NonNull WriteDocumentResponse writeDocument( | ||
@NonNull RecordIdentifier recordIdentifier, @NonNull Document document) { | ||
return wrap(() -> delegate.writeDocument(recordIdentifier, document)); | ||
} | ||
|
||
@Override | ||
public @NonNull WriteDocumentResponse replaceDocument( | ||
@NonNull RecordIdentifier recordIdentifier, | ||
@NonNull Document document, | ||
@NonNull UUID documentToReplaceId) { | ||
return wrap(() -> delegate.replaceDocument(recordIdentifier, document, documentToReplaceId)); | ||
} | ||
|
||
@Override | ||
public @NonNull String getHomeCommunityID(@NonNull String kvnr) { | ||
return wrap(() -> delegate.getHomeCommunityID(kvnr)); | ||
} | ||
|
||
private static <T> T wrap(WebServiceExecutor<T> requestor) { | ||
try { | ||
return requestor.execute(); | ||
} catch (FaultMessageException e) { | ||
throw new KonnektorException("request failed: " + e.getMessage(), e); | ||
} | ||
} | ||
|
||
interface WebServiceExecutor<T> { | ||
T execute() throws FaultMessageException; | ||
} | ||
} |
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