Skip to content

Commit

Permalink
Merge pull request #111 from de4a-wp5/iteration2-dev
Browse files Browse the repository at this point in the history
Iteration2 dev
  • Loading branch information
phax authored Dec 15, 2022
2 parents 44e83e0 + 0a120af commit 38f7861
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 67 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Checkout the technical documentation on [the Wiki page](https://wiki.de4a.eu/ind
* Optional query parameter **`environment`** - The runtime environment for which the Connector will filter the result entries from IAL. See above for details.
* **`/service/reload-addresses`** - Reload the internal address list for forwarding to DE and DO from the backend file.

*Note*: the MOR data cannot be queried via the Connector. Please query the [IAL](https://github.com/de4a-wp5/ial-service) directly. Example URL: `https://de4a.simplegob.com/ial/mor/en.json`

### Configuration

#### Application properties
Expand Down Expand Up @@ -268,6 +270,10 @@ Once you have deployed the `war` file, there are several **checks to ensure that

# News and Noteworthy

* v0.3.2 - 2022-12-15
* Fixed an error in `/response/subscription` that Data Evaluator and Data Owner were not swapped correctly
* Fixed `NullPointerException` in the DBA legacy layer, if error messages are returned
* Fixed the missing "Error handling" part in the DBA legacy layer for all kind of responses
* v0.3.1 - 2022-11-16
* Updated default application.properties for easier Tracker usage
* v0.3.0 - 2022-10-21
Expand Down
2 changes: 1 addition & 1 deletion build-and-push-docker-release.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@echo off

:: The version to release
set VER=0.2.6
set VER=0.3.2

cd de4a-connector
docker build --pull -t de4a/connector:%VER% .
Expand Down
6 changes: 3 additions & 3 deletions de4a-connector/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ RUN apt-get update \

COPY target/de4a-connector.war ./connector.war

RUN unzip connector.war -d /smp && \
rm -f /smp/WEB-INF/classes/*.p12
RUN unzip connector.war -d /de4a && \
rm -f /de4a/WEB-INF/classes/*.p12

# Part 2:

Expand All @@ -22,4 +22,4 @@ ENV CATALINA_OPTS="$CATALINA_OPTS -Djava.security.egd=file:/dev/urandom"
WORKDIR $CATALINA_HOME/webapps
RUN rm -rf manager host-manager docs examples ROOT

COPY --from=build /smp $CATALINA_HOME/webapps/ROOT
COPY --from=build /de4a $CATALINA_HOME/webapps/ROOT
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public class ResponseController
redirectUserMsg.getCanonicalEvidenceTypeId (),
DE4AConstants.PROCESS_ID_RESPONSE);

String responseMetadata = MessageUtils.getRedirectResponseMetadata(redirectUserMsg);
this.apiManager.processIncomingMessage (ELogMessage.LOG_RES_REDIRECT_DO_DT,
final String responseMetadata = MessageUtils.getRedirectResponseMetadata(redirectUserMsg);
this.apiManager.processIncomingMessage (ELogMessage.LOG_RES_REDIRECT_DO_DT,
redirectUserMsg, messageDTO, marshaller, redirectUserMsg.getRequestId(), responseMetadata);

return ResponseEntity.status (HttpStatus.OK).body (ConnectorExceptionHandler.getSuccessResponseBytes ());
Expand All @@ -77,7 +77,7 @@ public class ResponseController
final ResponseExtractMultiEvidenceType responseObj = APIRestUtils.conversionBytesWithCatching (request,
marshaller,
new ConnectorException ().withModule (EExternalModule.CONNECTOR_DT));

if (responseObj.hasNoResponseExtractEvidenceItemEntries ())
throw new IllegalStateException ("Provided payload has no ResponseExtractEvidenceItem entries");

Expand All @@ -97,8 +97,8 @@ public class ResponseController
docTypeID,
DE4AConstants.PROCESS_ID_RESPONSE);

String responseMetadata = MessageUtils.getEvidenceResponseMetadata(responseObj.getResponseExtractEvidenceItem());
this.apiManager.processIncomingMessage (ELogMessage.LOG_RES_EVIDENCE_DO_DT,
final String responseMetadata = MessageUtils.getEvidenceResponseMetadata(responseObj.getResponseExtractEvidenceItem());
this.apiManager.processIncomingMessage (ELogMessage.LOG_RES_EVIDENCE_DO_DT,
responseObj, messageDTO, marshaller, responseObj.getRequestId(), responseMetadata);

return ResponseEntity.status (HttpStatus.OK).body (ConnectorExceptionHandler.getSuccessResponseBytes ());
Expand Down Expand Up @@ -128,14 +128,14 @@ public class ResponseController
docTypeID = responseObj.getResponseEventSubscriptionItemAtIndex (0).getCanonicalEventCatalogUri ();
}

final AS4MessageDTO messageDTO = new AS4MessageDTO (responseObj.getDataEvaluator ().getAgentUrn (),
responseObj.getDataOwner ().getAgentUrn (),
final AS4MessageDTO messageDTO = new AS4MessageDTO (responseObj.getDataOwner ().getAgentUrn (),
responseObj.getDataEvaluator ().getAgentUrn (),
docTypeID,
DE4AConstants.PROCESS_ID_RESPONSE);

responseObj.getResponseEventSubscriptionItemAtIndex(0).getError();
String responseMetadata = MessageUtils.getEventSubscriptionResponseMetadata(responseObj.getResponseEventSubscriptionItem());
this.apiManager.processIncomingMessage (ELogMessage.LOG_RES_SUBSC_DO_DT,
final String responseMetadata = MessageUtils.getEventSubscriptionResponseMetadata(responseObj.getResponseEventSubscriptionItem());
this.apiManager.processIncomingMessage (ELogMessage.LOG_RES_SUBSC_DO_DT,
responseObj, messageDTO, marshaller, responseObj.getRequestId(), responseMetadata);

return ResponseEntity.status (HttpStatus.OK).body (ConnectorExceptionHandler.getSuccessResponseBytes ());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package eu.de4a.connector.api.legacy;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.function.Function;

Expand All @@ -26,6 +24,8 @@
import eu.de4a.iem.core.jaxb.common.ResponseExtractMultiEvidenceType;
import eu.de4a.iem.jaxb.common.types.CanonicalEvidenceType;
import eu.de4a.iem.jaxb.common.types.DomesticsEvidencesType;
import eu.de4a.iem.jaxb.common.types.ErrorListType;
import eu.de4a.iem.jaxb.common.types.ErrorType;
import eu.de4a.iem.jaxb.common.types.RequestExtractEvidenceIMType;
import eu.de4a.iem.jaxb.common.types.RequestTransferEvidenceUSIIMDRType;
import eu.de4a.iem.jaxb.common.types.ResponseExtractEvidenceType;
Expand Down Expand Up @@ -139,11 +139,12 @@ public static ResponseTransferEvidenceType convertNewToOldResponse_DR (@Nonnull
final ResponseTransferEvidenceType aOldResponse = DE4AResponseDocumentHelper.createResponseTransferEvidence (aOldRequest);
// Only canonical evidence and domestic evidence is missing
final ResponseExtractEvidenceItemType aNewItem = aNewResponse.getResponseExtractEvidenceItemAtIndex (0);

// Canonical Evidences
if (aNewItem.getCanonicalEvidence ().getAny () != null)
if (aNewItem.getCanonicalEvidence () != null && aNewItem.getCanonicalEvidence ().getAny () != null)
{
final CanonicalEvidenceType aOldCE = new CanonicalEvidenceType ();
// TODO Do we need to clone???
// No need to clone here
aOldCE.setAny (aNewItem.getCanonicalEvidence ().getAny ());
aOldResponse.setCanonicalEvidence (aOldCE);
}
Expand Down Expand Up @@ -178,6 +179,32 @@ public static ResponseTransferEvidenceType convertNewToOldResponse_DR (@Nonnull
aOldDEs.addDomesticEvidence (aDEConverter.apply (aNewDE));
aOldResponse.setDomesticEvidenceList (aOldDEs);
}

// Error messages
if (aNewItem.hasErrorEntries ())
{
final ErrorListType aOldErrorList = new ErrorListType ();
for (final eu.de4a.iem.core.jaxb.common.ErrorType aNewError : aNewItem.getError ())
{
final ErrorType aOldError = new ErrorType ();
aOldError.setCode (aNewError.getCode ());
aOldError.setText (aNewError.getText ());
aOldErrorList.addError (aOldError);
}
aOldResponse.setErrorList (aOldErrorList);
}

if (aOldResponse.getCanonicalEvidence () == null && aOldResponse.getErrorList () == null)
{
// Fallback to avoid illegal content
final ErrorListType aOldErrorList = new ErrorListType ();
final ErrorType aOldError = new ErrorType ();
aOldError.setCode ("FALLBACK");
aOldError.setText ("Error converting new response to old response");
aOldErrorList.addError (aOldError);
aOldResponse.setErrorList (aOldErrorList);
}

return aOldResponse;
}

Expand Down Expand Up @@ -337,22 +364,45 @@ public static ResponseExtractMultiEvidenceType convertOldToNewResponse (@Nonnull
aNewResponse.setDataEvaluator (aNewRequest.getDataEvaluator ());
aNewResponse.setDataOwner (aNewRequest.getDataOwner ());

final ResponseExtractEvidenceItemType item = new ResponseExtractEvidenceItemType ();
item.setRequestItemId (aNewRequest.getRequestId ());
item.setDataRequestSubject (aNewRequest.getRequestEvidenceIMItemAtIndex (0).getDataRequestSubject ());
item.setCanonicalEvidenceTypeId (aNewRequest.getRequestEvidenceIMItemAtIndex (0).getCanonicalEvidenceTypeId ());
final ResponseExtractEvidenceItemType aNewItem = new ResponseExtractEvidenceItemType ();
aNewItem.setRequestItemId (aNewRequest.getRequestId ());
aNewItem.setDataRequestSubject (aNewRequest.getRequestEvidenceIMItemAtIndex (0).getDataRequestSubject ());
aNewItem.setCanonicalEvidenceTypeId (aNewRequest.getRequestEvidenceIMItemAtIndex (0).getCanonicalEvidenceTypeId ());

if (aOldResponse.getCanonicalEvidence ().getAny () != null)
if (aOldResponse.getCanonicalEvidence () != null && aOldResponse.getCanonicalEvidence ().getAny () != null)
{
final eu.de4a.iem.core.jaxb.common.CanonicalEvidenceType aNewCE = new eu.de4a.iem.core.jaxb.common.CanonicalEvidenceType ();

aNewCE.setAny (aOldResponse.getCanonicalEvidence ().getAny ());
item.setCanonicalEvidence (aNewCE);
aNewItem.setCanonicalEvidence (aNewCE);
}

// Error messages
if (aOldResponse.getErrorList () != null && aOldResponse.getErrorList ().hasErrorEntries ())
{
final ErrorListType aOldErrorList = new ErrorListType ();
for (final eu.de4a.iem.core.jaxb.common.ErrorType aNewError : aNewItem.getError ())
{
final ErrorType aOldError = new ErrorType ();
aOldError.setCode (aNewError.getCode ());
aOldError.setText (aNewError.getText ());
aOldErrorList.addError (aOldError);
}
aOldResponse.setErrorList (aOldErrorList);
}

final List <ResponseExtractEvidenceItemType> aList = new ArrayList <> ();
aList.add (item);
aNewResponse.setResponseExtractEvidenceItem (aList);
if (aNewItem.getCanonicalEvidence () == null && aNewItem.hasNoErrorEntries ())
{
// Fallback to avoid illegal content
final ErrorListType aOldErrorList = new ErrorListType ();
final ErrorType aOldError = new ErrorType ();
aOldError.setCode ("FALLBACK");
aOldError.setText ("Error converting new response to old response");
aOldErrorList.addError (aOldError);
aOldResponse.setErrorList (aOldErrorList);
}


aNewResponse.addResponseExtractEvidenceItem (aNewItem);

return aNewResponse;
}
Expand All @@ -372,21 +422,44 @@ public static ResponseExtractMultiEvidenceType convertOldToNewResponse (@Nonnull
aNewResponse.setDataEvaluator (aNewRequest.getDataEvaluator ());
aNewResponse.setDataOwner (aNewRequest.getDataOwner ());

final ResponseExtractEvidenceItemType item = new ResponseExtractEvidenceItemType ();
item.setRequestItemId (aNewRequest.getRequestId ());
item.setDataRequestSubject (aNewRequest.getRequestEvidenceIMItemAtIndex (0).getDataRequestSubject ());
item.setCanonicalEvidenceTypeId (aNewRequest.getRequestEvidenceIMItemAtIndex (0).getCanonicalEvidenceTypeId ());
final ResponseExtractEvidenceItemType aNewItem = new ResponseExtractEvidenceItemType ();
aNewItem.setRequestItemId (aNewRequest.getRequestId ());
aNewItem.setDataRequestSubject (aNewRequest.getRequestEvidenceIMItemAtIndex (0).getDataRequestSubject ());
aNewItem.setCanonicalEvidenceTypeId (aNewRequest.getRequestEvidenceIMItemAtIndex (0).getCanonicalEvidenceTypeId ());

if (aOldResponse.getCanonicalEvidence ().getAny () != null)
if (aOldResponse.getCanonicalEvidence () != null && aOldResponse.getCanonicalEvidence ().getAny () != null)
{
final eu.de4a.iem.core.jaxb.common.CanonicalEvidenceType aNewCE = new eu.de4a.iem.core.jaxb.common.CanonicalEvidenceType ();
aNewCE.setAny (aOldResponse.getCanonicalEvidence ().getAny ());
item.setCanonicalEvidence (aNewCE);
aNewItem.setCanonicalEvidence (aNewCE);
}

// Error messages
if (aOldResponse.getErrorList () != null && aOldResponse.getErrorList ().hasErrorEntries ())
{
final ErrorListType aOldErrorList = new ErrorListType ();
for (final eu.de4a.iem.core.jaxb.common.ErrorType aNewError : aNewItem.getError ())
{
final ErrorType aOldError = new ErrorType ();
aOldError.setCode (aNewError.getCode ());
aOldError.setText (aNewError.getText ());
aOldErrorList.addError (aOldError);
}
aOldResponse.setErrorList (aOldErrorList);
}

if (aNewItem.getCanonicalEvidence () == null && aNewItem.hasNoErrorEntries ())
{
// Fallback to avoid illegal content
final ErrorListType aOldErrorList = new ErrorListType ();
final ErrorType aOldError = new ErrorType ();
aOldError.setCode ("FALLBACK");
aOldError.setText ("Error converting new response to old response");
aOldErrorList.addError (aOldError);
aOldResponse.setErrorList (aOldErrorList);
}

final List <ResponseExtractEvidenceItemType> aList = new ArrayList <> ();
aList.add (item);
aNewResponse.setResponseExtractEvidenceItem (aList);
aNewResponse.addResponseExtractEvidenceItem (aNewItem);

return aNewResponse;
}
Expand Down
Loading

0 comments on commit 38f7861

Please sign in to comment.