Search in sources :

Example 1 with BDXR1MarshallerCompleteServiceGroupType

use of com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerCompleteServiceGroupType in project phoss-smp by phax.

the class APIExecutorServiceGroupCompleteGet method invokeAPI.

public void invokeAPI(@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull @Nonempty final String sPath, @Nonnull final Map<String, String> aPathVariables, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception {
    final String sPathServiceGroupID = aPathVariables.get(SMPRestFilter.PARAM_SERVICE_GROUP_ID);
    final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider(aRequestScope, sPathServiceGroupID);
    final byte[] aBytes;
    switch(SMPServerConfiguration.getRESTType()) {
        case PEPPOL:
            {
                // Unspecified extension
                final com.helger.xsds.peppol.smp1.CompleteServiceGroupType ret = new SMPServerAPI(aDataProvider).getCompleteServiceGroup(sPathServiceGroupID);
                aBytes = new SMPMarshallerCompleteServiceGroupType(XML_SCHEMA_VALIDATION).getAsBytes(ret);
                break;
            }
        case OASIS_BDXR_V1:
            {
                // Unspecified extension
                final com.helger.xsds.bdxr.smp1.CompleteServiceGroupType ret = new BDXR1ServerAPI(aDataProvider).getCompleteServiceGroup(sPathServiceGroupID);
                aBytes = new BDXR1MarshallerCompleteServiceGroupType(XML_SCHEMA_VALIDATION).getAsBytes(ret);
                break;
            }
        default:
            throw new UnsupportedOperationException("Unsupported REST type specified!");
    }
    if (aBytes == null) {
        // Internal error serializing the payload
        throw new SMPInternalErrorException("Failed to convert the returned CompleteServiceGroup to XML");
    }
    aUnifiedResponse.setContent(aBytes).setMimeType(CMimeType.TEXT_XML).setCharset(XMLWriterSettings.DEFAULT_XML_CHARSET_OBJ);
}
Also used : SMPMarshallerCompleteServiceGroupType(com.helger.smpclient.peppol.marshal.SMPMarshallerCompleteServiceGroupType) BDXR1MarshallerCompleteServiceGroupType(com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerCompleteServiceGroupType) SMPMarshallerCompleteServiceGroupType(com.helger.smpclient.peppol.marshal.SMPMarshallerCompleteServiceGroupType) SMPServerAPI(com.helger.phoss.smp.restapi.SMPServerAPI) BDXR1MarshallerCompleteServiceGroupType(com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerCompleteServiceGroupType) BDXR1ServerAPI(com.helger.phoss.smp.restapi.BDXR1ServerAPI) SMPInternalErrorException(com.helger.phoss.smp.exception.SMPInternalErrorException) ISMPServerAPIDataProvider(com.helger.phoss.smp.restapi.ISMPServerAPIDataProvider)

Aggregations

SMPInternalErrorException (com.helger.phoss.smp.exception.SMPInternalErrorException)1 BDXR1ServerAPI (com.helger.phoss.smp.restapi.BDXR1ServerAPI)1 ISMPServerAPIDataProvider (com.helger.phoss.smp.restapi.ISMPServerAPIDataProvider)1 SMPServerAPI (com.helger.phoss.smp.restapi.SMPServerAPI)1 BDXR1MarshallerCompleteServiceGroupType (com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerCompleteServiceGroupType)1 SMPMarshallerCompleteServiceGroupType (com.helger.smpclient.peppol.marshal.SMPMarshallerCompleteServiceGroupType)1