From 64740d4747176e9a20286b79618a48b2cd876887 Mon Sep 17 00:00:00 2001 From: Philip Helger Date: Tue, 29 Oct 2024 15:30:02 +0100 Subject: [PATCH] Make sure to trim all path parameters --- .../rest/APIExecutorBusinessCardDelete.java | 3 +- .../smp/rest/APIExecutorBusinessCardGet.java | 7 +- .../smp/rest/APIExecutorBusinessCardPush.java | 3 +- .../smp/rest/APIExecutorBusinessCardPut.java | 3 +- .../rest/APIExecutorExportByOwnerXMLVer1.java | 3 +- .../APIExecutorExportSpecificXMLVer1.java | 3 +- ...APIExecutorMigrationOutboundCancelPut.java | 3 +- ...IExecutorMigrationOutboundFinalizePut.java | 3 +- .../APIExecutorMigrationOutboundStartPut.java | 3 +- .../rest/APIExecutorQueryGetBusinessCard.java | 3 +- .../smp/rest/APIExecutorQueryGetDocTypes.java | 3 +- .../APIExecutorQueryGetServiceMetadata.java | 107 +----------------- .../APIExecutorServiceGroupCompleteGet.java | 3 +- .../rest/APIExecutorServiceGroupDelete.java | 3 +- .../smp/rest/APIExecutorServiceGroupGet.java | 3 +- .../smp/rest/APIExecutorServiceGroupPut.java | 3 +- .../APIExecutorServiceMetadataDelete.java | 3 +- .../APIExecutorServiceMetadataDeleteAll.java | 3 +- .../rest/APIExecutorServiceMetadataGet.java | 5 +- .../rest/APIExecutorServiceMetadataPut.java | 3 +- .../smp/rest/APIExecutorUserListGet.java | 4 +- 21 files changed, 48 insertions(+), 126 deletions(-) diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardDelete.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardDelete.java index aa09a1b9f..12e7ddd82 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardDelete.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardDelete.java @@ -22,6 +22,7 @@ import com.helger.commons.annotation.Nonempty; import com.helger.commons.http.CHttp; +import com.helger.commons.string.StringHelper; import com.helger.phoss.smp.app.SMPWebAppConfiguration; import com.helger.phoss.smp.domain.SMPMetaManager; import com.helger.phoss.smp.exception.SMPPreconditionFailedException; @@ -40,7 +41,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sServiceGroupID); // Is the writable API disabled? diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardGet.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardGet.java index 1c0d61534..4f0f739d5 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardGet.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardGet.java @@ -22,6 +22,7 @@ import com.helger.commons.annotation.Nonempty; import com.helger.commons.mime.CMimeType; +import com.helger.commons.string.StringHelper; import com.helger.peppol.businesscard.v3.PD3BusinessCardMarshaller; import com.helger.peppol.businesscard.v3.PD3BusinessCardType; import com.helger.phoss.smp.app.SMPWebAppConfiguration; @@ -42,7 +43,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sServiceGroupID); if (!SMPMetaManager.getSettings ().isDirectoryIntegrationEnabled ()) @@ -58,6 +59,8 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, final PD3BusinessCardType ret = new BusinessCardServerAPI (aDataProvider).getBusinessCard (sServiceGroupID); final byte [] aBytes = new PD3BusinessCardMarshaller ().getAsBytes (ret); - aUnifiedResponse.setContent (aBytes).setMimeType (CMimeType.TEXT_XML).setCharset (XMLWriterSettings.DEFAULT_XML_CHARSET_OBJ); + aUnifiedResponse.setContent (aBytes) + .setMimeType (CMimeType.TEXT_XML) + .setCharset (XMLWriterSettings.DEFAULT_XML_CHARSET_OBJ); } } diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardPush.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardPush.java index 7d2840357..8a71ceafa 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardPush.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardPush.java @@ -25,6 +25,7 @@ import com.helger.commons.annotation.Nonempty; import com.helger.commons.http.CHttp; +import com.helger.commons.string.StringHelper; import com.helger.peppolid.IParticipantIdentifier; import com.helger.peppolid.factory.IIdentifierFactory; import com.helger.phoss.smp.app.PDClientProvider; @@ -106,7 +107,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sServiceGroupID); if (!SMPMetaManager.getSettings ().isDirectoryIntegrationEnabled ()) diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardPut.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardPut.java index 490af6dd1..360857463 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardPut.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorBusinessCardPut.java @@ -25,6 +25,7 @@ import com.helger.commons.http.CHttp; import com.helger.commons.io.stream.StreamHelper; import com.helger.commons.state.ESuccess; +import com.helger.commons.string.StringHelper; import com.helger.peppol.businesscard.generic.PDBusinessCard; import com.helger.peppol.businesscard.helper.PDBusinessCardHelper; import com.helger.phoss.smp.app.SMPWebAppConfiguration; @@ -46,7 +47,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sServiceGroupID); // Is the writable API disabled? diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorExportByOwnerXMLVer1.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorExportByOwnerXMLVer1.java index c25c742fc..1e5f36bba 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorExportByOwnerXMLVer1.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorExportByOwnerXMLVer1.java @@ -27,6 +27,7 @@ import com.helger.commons.collection.impl.ICommonsList; import com.helger.commons.mime.CMimeType; import com.helger.commons.mime.MimeType; +import com.helger.commons.string.StringHelper; import com.helger.phoss.smp.domain.SMPMetaManager; import com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup; import com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager; @@ -63,7 +64,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathUserLoginName = aPathVariables.get (SMPRestFilter.PARAM_USER_ID); + final String sPathUserLoginName = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_USER_ID)); final String sLogPrefix = "[REST API Export-ByOwner-XML-V1] "; LOGGER.info (sLogPrefix + "Starting Export for all of owner '" + sPathUserLoginName + "'"); diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorExportSpecificXMLVer1.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorExportSpecificXMLVer1.java index da6d2379e..8e351aa61 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorExportSpecificXMLVer1.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorExportSpecificXMLVer1.java @@ -27,6 +27,7 @@ import com.helger.commons.collection.impl.CommonsArrayList; import com.helger.commons.mime.CMimeType; import com.helger.commons.mime.MimeType; +import com.helger.commons.string.StringHelper; import com.helger.peppolid.IParticipantIdentifier; import com.helger.peppolid.factory.IIdentifierFactory; import com.helger.phoss.smp.domain.SMPMetaManager; @@ -65,7 +66,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sPathServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final String sLogPrefix = "[REST API Export-Specific-XML-V1] "; LOGGER.info (sLogPrefix + "Starting Export of '" + sPathServiceGroupID + "'"); diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorMigrationOutboundCancelPut.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorMigrationOutboundCancelPut.java index f1d119d9d..049df74bd 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorMigrationOutboundCancelPut.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorMigrationOutboundCancelPut.java @@ -25,6 +25,7 @@ import com.helger.commons.annotation.Nonempty; import com.helger.commons.http.CHttp; +import com.helger.commons.string.StringHelper; import com.helger.peppolid.IParticipantIdentifier; import com.helger.peppolid.factory.IIdentifierFactory; import com.helger.phoss.smp.domain.SMPMetaManager; @@ -57,7 +58,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sServiceGroupID); // Is the writable API disabled? diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorMigrationOutboundFinalizePut.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorMigrationOutboundFinalizePut.java index ecdf829dc..efd382853 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorMigrationOutboundFinalizePut.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorMigrationOutboundFinalizePut.java @@ -25,6 +25,7 @@ import com.helger.commons.annotation.Nonempty; import com.helger.commons.http.CHttp; +import com.helger.commons.string.StringHelper; import com.helger.peppolid.IParticipantIdentifier; import com.helger.peppolid.factory.IIdentifierFactory; import com.helger.phoss.smp.domain.SMPMetaManager; @@ -60,7 +61,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sServiceGroupID); // Is the writable API disabled? diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorMigrationOutboundStartPut.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorMigrationOutboundStartPut.java index 568f5085f..31cd938d0 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorMigrationOutboundStartPut.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorMigrationOutboundStartPut.java @@ -26,6 +26,7 @@ import com.helger.commons.annotation.Nonempty; import com.helger.commons.mime.CMimeType; import com.helger.commons.mime.MimeType; +import com.helger.commons.string.StringHelper; import com.helger.peppol.sml.ISMLInfo; import com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller; import com.helger.peppol.smlclient.participant.BadRequestFault; @@ -77,7 +78,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sServiceGroupID); // Is the writable API disabled? diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorQueryGetBusinessCard.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorQueryGetBusinessCard.java index bc548278a..8726255b7 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorQueryGetBusinessCard.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorQueryGetBusinessCard.java @@ -33,6 +33,7 @@ import com.helger.commons.datetime.PDTFactory; import com.helger.commons.http.CHttp; import com.helger.commons.mime.CMimeType; +import com.helger.commons.string.StringHelper; import com.helger.commons.timing.StopWatch; import com.helger.httpclient.HttpClientManager; import com.helger.httpclient.response.ResponseHandlerByteArray; @@ -68,7 +69,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sPathServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sPathServiceGroupID); // Is the remote query API disabled? diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorQueryGetDocTypes.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorQueryGetDocTypes.java index 61d5f0c35..9ad841a0a 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorQueryGetDocTypes.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorQueryGetDocTypes.java @@ -35,6 +35,7 @@ import com.helger.commons.datetime.PDTFactory; import com.helger.commons.http.CHttp; import com.helger.commons.mime.CMimeType; +import com.helger.commons.string.StringHelper; import com.helger.commons.timing.StopWatch; import com.helger.httpclient.HttpClientManager; import com.helger.httpclient.response.ResponseHandlerByteArray; @@ -71,7 +72,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sPathServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sPathServiceGroupID); // Is the remote query API disabled? diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorQueryGetServiceMetadata.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorQueryGetServiceMetadata.java index 961dd0f0b..d011bd44d 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorQueryGetServiceMetadata.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorQueryGetServiceMetadata.java @@ -28,7 +28,6 @@ import org.slf4j.LoggerFactory; import com.helger.commons.CGlobal; -import com.helger.commons.ValueEnforcer; import com.helger.commons.annotation.Nonempty; import com.helger.commons.base64.Base64; import com.helger.commons.datetime.OffsetDate; @@ -36,16 +35,15 @@ import com.helger.commons.datetime.XMLOffsetDate; import com.helger.commons.http.CHttp; import com.helger.commons.mime.CMimeType; +import com.helger.commons.string.StringHelper; import com.helger.commons.timing.StopWatch; import com.helger.json.IJsonArray; import com.helger.json.IJsonObject; import com.helger.json.JsonArray; import com.helger.json.JsonObject; -import com.helger.json.JsonValue; import com.helger.json.serialize.JsonWriter; import com.helger.json.serialize.JsonWriterSettings; import com.helger.peppol.sml.ESMPAPIType; -import com.helger.peppolid.CIdentifier; import com.helger.peppolid.IDocumentTypeIdentifier; import com.helger.peppolid.IParticipantIdentifier; import com.helger.peppolid.factory.IIdentifierFactory; @@ -63,8 +61,6 @@ import com.helger.smpclient.peppol.SMPClientReadOnly; import com.helger.web.scope.IRequestWebScopeWithoutResponse; import com.helger.xsds.bdxr.smp2.ac.CertificateType; -import com.helger.xsds.bdxr.smp2.ac.ProcessMetadataType; -import com.helger.xsds.bdxr.smp2.ac.ProcessType; public final class APIExecutorQueryGetServiceMetadata extends AbstractSMPAPIExecutorQuery { @@ -112,110 +108,13 @@ static IJsonObject convertEndpoint (@Nonnull final com.helger.xsds.bdxr.smp2.ac. return ret; } - // TODO use SMPJsonResponse version in peppol-commons>8.8.0 - @Nonnull - static IJsonObject convert (@Nonnull final IParticipantIdentifier aParticipantID, - @Nonnull final IDocumentTypeIdentifier aDocTypeID, - @Nonnull final com.helger.xsds.bdxr.smp2.ServiceMetadataType aSM) - { - ValueEnforcer.notNull (aParticipantID, "ParticipantID"); - ValueEnforcer.notNull (aDocTypeID, "DocTypeID"); - ValueEnforcer.notNull (aSM, "SM"); - - final IJsonObject ret = new JsonObject (); - ret.add (SMPJsonResponse.JSON_SMPTYPE, ESMPAPIType.OASIS_BDXR_V2.getID ()); - ret.add (SMPJsonResponse.JSON_PARTICIPANT_ID, aParticipantID.getURIEncoded ()); - ret.add (SMPJsonResponse.JSON_DOCUMENT_TYPE_ID, aDocTypeID.getURIEncoded ()); - - for (final ProcessMetadataType aPM : aSM.getProcessMetadata ()) - { - final IJsonObject aJsonProcessMetadata = new JsonObject (); - - { - final SMPExtensionList aExts = SMPExtensionList.ofBDXR2 (aPM.getSMPExtensions ()); - if (aExts != null) - aJsonProcessMetadata.addIfNotNull (SMPJsonResponse.JSON_EXTENSION, aExts.getExtensionsAsJsonString ()); - } - - { - // Convert all process IDs - final IJsonArray aJsonProcesses = new JsonArray (); - for (final ProcessType aProc : aPM.getProcess ()) - { - final IJsonObject aJsonProc = new JsonObject ().add ("id", - CIdentifier.getURIEncodedBDXR2 (aProc.getID () - .getSchemeID (), - aProc.getID () - .getValue ())); - if (aProc.hasRoleIDEntries ()) - { - aJsonProc.add ("roleids", - new JsonArray ().addAllMapped (aProc.getRoleID (), - x -> JsonValue.create (CIdentifier.getURIEncodedBDXR2 (x.getSchemeID (), - x.getValue ())))); - } - - final SMPExtensionList aExts = SMPExtensionList.ofBDXR2 (aProc.getSMPExtensions ()); - if (aExts != null) - aJsonProc.addIfNotNull (SMPJsonResponse.JSON_EXTENSION, aExts.getExtensionsAsJsonString ()); - - aJsonProcesses.add (aJsonProc); - } - aJsonProcessMetadata.add ("processes", aJsonProcesses); - } - - final com.helger.xsds.bdxr.smp2.ac.RedirectType aRedirect = aPM.getRedirect (); - if (aRedirect != null) - { - final IJsonObject aJsonRedirect = new JsonObject ().add (SMPJsonResponse.JSON_HREF, - aRedirect.getPublisherURIValue ()); - - // Add all certificates - final IJsonArray aJsonCerts = new JsonArray (); - for (final CertificateType aCert : aRedirect.getCertificate ()) - { - final IJsonObject aJsonCert = new JsonObject (); - SMPJsonResponse.convertCertificate (aJsonCert, Base64.encodeBytes (aCert.getContentBinaryObjectValue ())); - aJsonCerts.add (aJsonCert); - } - aJsonRedirect.addJson ("certificates", aJsonCerts); - - final SMPExtensionList aExts = SMPExtensionList.ofBDXR2 (aRedirect.getSMPExtensions ()); - if (aExts != null) - { - // It's okay to add as string - aJsonRedirect.addIfNotNull (SMPJsonResponse.JSON_EXTENSION, aExts.getExtensionsAsJsonString ()); - } - aJsonProcessMetadata.addJson (SMPJsonResponse.JSON_REDIRECT, aJsonRedirect); - } - else - { - final IJsonArray aJsonEPs = new JsonArray (); - // For all endpoints - for (final com.helger.xsds.bdxr.smp2.ac.EndpointType aEndpoint : aPM.getEndpoint ()) - { - aJsonEPs.add (convertEndpoint (aEndpoint)); - } - aJsonProcessMetadata.addJson (SMPJsonResponse.JSON_ENDPOINTS, aJsonEPs); - } - } - - final SMPExtensionList aExts = SMPExtensionList.ofBDXR2 (aSM.getSMPExtensions ()); - if (aExts != null) - { - // It's okay to add as string - ret.addIfNotNull (SMPJsonResponse.JSON_EXTENSION, aExts.getExtensionsAsJsonString ()); - } - return ret; - } - public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull @Nonempty final String sPath, @Nonnull final Map aPathVariables, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sPathServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sPathServiceGroupID); // Is the remote query API disabled? @@ -305,7 +204,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, aDocTypeID); if (aSM != null) { - aJson = convert (aParticipantID, aDocTypeID, aSM); + aJson = SMPJsonResponse.convert (aParticipantID, aDocTypeID, aSM); } break; } diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupCompleteGet.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupCompleteGet.java index 1bf3760b5..b6ae2b081 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupCompleteGet.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupCompleteGet.java @@ -22,6 +22,7 @@ import com.helger.commons.annotation.Nonempty; import com.helger.commons.mime.CMimeType; +import com.helger.commons.string.StringHelper; import com.helger.phoss.smp.config.SMPServerConfiguration; import com.helger.phoss.smp.exception.SMPInternalErrorException; import com.helger.phoss.smp.restapi.BDXR1ServerAPI; @@ -42,7 +43,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sPathServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sPathServiceGroupID); final byte [] aBytes; diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupDelete.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupDelete.java index 0363243d4..5a4f1bc5b 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupDelete.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupDelete.java @@ -22,6 +22,7 @@ import com.helger.commons.annotation.Nonempty; import com.helger.commons.http.CHttp; +import com.helger.commons.string.StringHelper; import com.helger.phoss.smp.config.SMPServerConfiguration; import com.helger.phoss.smp.domain.SMPMetaManager; import com.helger.phoss.smp.exception.SMPPreconditionFailedException; @@ -42,7 +43,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sPathServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sPathServiceGroupID); // Is the writable API disabled? diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupGet.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupGet.java index d6241ce43..9f0b97a1b 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupGet.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupGet.java @@ -22,6 +22,7 @@ import com.helger.commons.annotation.Nonempty; import com.helger.commons.mime.CMimeType; +import com.helger.commons.string.StringHelper; import com.helger.phoss.smp.config.SMPServerConfiguration; import com.helger.phoss.smp.exception.SMPInternalErrorException; import com.helger.phoss.smp.restapi.BDXR1ServerAPI; @@ -44,7 +45,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sPathServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sPathServiceGroupID); final byte [] aBytes; diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupPut.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupPut.java index 39221297f..423b68dac 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupPut.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceGroupPut.java @@ -26,6 +26,7 @@ import com.helger.commons.http.CHttp; import com.helger.commons.io.stream.StreamHelper; import com.helger.commons.state.ESuccess; +import com.helger.commons.string.StringHelper; import com.helger.phoss.smp.config.SMPServerConfiguration; import com.helger.phoss.smp.domain.SMPMetaManager; import com.helger.phoss.smp.exception.SMPBadRequestException; @@ -51,7 +52,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sPathServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sPathServiceGroupID); // Is the writable API disabled? diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataDelete.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataDelete.java index 5b6b723e9..6d423043a 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataDelete.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataDelete.java @@ -22,6 +22,7 @@ import com.helger.commons.annotation.Nonempty; import com.helger.commons.http.CHttp; +import com.helger.commons.string.StringHelper; import com.helger.phoss.smp.config.SMPServerConfiguration; import com.helger.phoss.smp.domain.SMPMetaManager; import com.helger.phoss.smp.exception.SMPPreconditionFailedException; @@ -42,7 +43,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sPathServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sPathServiceGroupID); // Is the writable API disabled? diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataDeleteAll.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataDeleteAll.java index bc518a31b..5bb0c19eb 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataDeleteAll.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataDeleteAll.java @@ -21,6 +21,7 @@ import javax.annotation.Nonnull; import com.helger.commons.annotation.Nonempty; +import com.helger.commons.string.StringHelper; import com.helger.phoss.smp.config.SMPServerConfiguration; import com.helger.phoss.smp.domain.SMPMetaManager; import com.helger.phoss.smp.exception.SMPPreconditionFailedException; @@ -43,7 +44,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sPathServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sPathServiceGroupID); // Is the writable API disabled? diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataGet.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataGet.java index 605232772..adae5c9b1 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataGet.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataGet.java @@ -31,6 +31,7 @@ import com.helger.commons.annotation.Nonempty; import com.helger.commons.io.stream.NonBlockingByteArrayOutputStream; import com.helger.commons.mime.CMimeType; +import com.helger.commons.string.StringHelper; import com.helger.phoss.smp.config.SMPServerConfiguration; import com.helger.phoss.smp.exception.SMPInternalErrorException; import com.helger.phoss.smp.restapi.BDXR1ServerAPI; @@ -59,8 +60,8 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); - final String sPathDocumentTypeID = aPathVariables.get (SMPRestFilter.PARAM_DOCUMENT_TYPE_ID); + final String sPathServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); + final String sPathDocumentTypeID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_DOCUMENT_TYPE_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sPathServiceGroupID); // Create the unsigned response document diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataPut.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataPut.java index 7d56fa193..defa758c5 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataPut.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorServiceMetadataPut.java @@ -26,6 +26,7 @@ import com.helger.commons.http.CHttp; import com.helger.commons.io.stream.StreamHelper; import com.helger.commons.state.ESuccess; +import com.helger.commons.string.StringHelper; import com.helger.phoss.smp.config.SMPServerConfiguration; import com.helger.phoss.smp.domain.SMPMetaManager; import com.helger.phoss.smp.exception.SMPBadRequestException; @@ -51,7 +52,7 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathServiceGroupID = aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID); + final String sPathServiceGroupID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_SERVICE_GROUP_ID)); final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, sPathServiceGroupID); // Is the writable API disabled? diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorUserListGet.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorUserListGet.java index c7c4c7f2f..e74bf8798 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorUserListGet.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/rest/APIExecutorUserListGet.java @@ -22,6 +22,7 @@ import com.helger.commons.annotation.Nonempty; import com.helger.commons.mime.CMimeType; +import com.helger.commons.string.StringHelper; import com.helger.phoss.smp.config.SMPServerConfiguration; import com.helger.phoss.smp.exception.SMPInternalErrorException; import com.helger.phoss.smp.restapi.BDXR1ServerAPI; @@ -42,7 +43,8 @@ public void invokeAPI (@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception { - final String sPathUserID = aPathVariables.get (SMPRestFilter.PARAM_USER_ID); + final String sPathUserID = StringHelper.trim (aPathVariables.get (SMPRestFilter.PARAM_USER_ID)); + // No service group available final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider (aRequestScope, null);