Search in sources :

Example 1 with BDXR1MarshallerServiceGroupReferenceListType

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

the class APIExecutorUserListGet 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 sPathUserID = aPathVariables.get(SMPRestFilter.PARAM_USER_ID);
    // No service group available
    final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider(aRequestScope, null);
    final BasicAuthClientCredentials aCredentials = getMandatoryAuth(aRequestScope.headers());
    final byte[] aBytes;
    switch(SMPServerConfiguration.getRESTType()) {
        case PEPPOL:
            {
                // Unspecified extension
                final com.helger.xsds.peppol.smp1.ServiceGroupReferenceListType ret = new SMPServerAPI(aDataProvider).getServiceGroupReferenceList(sPathUserID, aCredentials);
                aBytes = new SMPMarshallerServiceGroupReferenceListType(XML_SCHEMA_VALIDATION).getAsBytes(ret);
                break;
            }
        case OASIS_BDXR_V1:
            {
                // Unspecified extension
                final com.helger.xsds.bdxr.smp1.ServiceGroupReferenceListType ret = new BDXR1ServerAPI(aDataProvider).getServiceGroupReferenceList(sPathUserID, aCredentials);
                aBytes = new BDXR1MarshallerServiceGroupReferenceListType(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);
}
Also used : SMPServerAPI(com.helger.phoss.smp.restapi.SMPServerAPI) SMPMarshallerServiceGroupReferenceListType(com.helger.smpclient.peppol.marshal.SMPMarshallerServiceGroupReferenceListType) BDXR1MarshallerServiceGroupReferenceListType(com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerServiceGroupReferenceListType) SMPMarshallerServiceGroupReferenceListType(com.helger.smpclient.peppol.marshal.SMPMarshallerServiceGroupReferenceListType) BDXR1ServerAPI(com.helger.phoss.smp.restapi.BDXR1ServerAPI) BasicAuthClientCredentials(com.helger.http.basicauth.BasicAuthClientCredentials) SMPInternalErrorException(com.helger.phoss.smp.exception.SMPInternalErrorException) ISMPServerAPIDataProvider(com.helger.phoss.smp.restapi.ISMPServerAPIDataProvider) BDXR1MarshallerServiceGroupReferenceListType(com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerServiceGroupReferenceListType)

Aggregations

BasicAuthClientCredentials (com.helger.http.basicauth.BasicAuthClientCredentials)1 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 BDXR1MarshallerServiceGroupReferenceListType (com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerServiceGroupReferenceListType)1 SMPMarshallerServiceGroupReferenceListType (com.helger.smpclient.peppol.marshal.SMPMarshallerServiceGroupReferenceListType)1