Search in sources :

Example 1 with PD3BusinessCardMarshaller

use of com.helger.pd.businesscard.v3.PD3BusinessCardMarshaller in project phoss-smp by phax.

the class APIExecutorBusinessCardGet 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 sServiceGroupID = aPathVariables.get(SMPRestFilter.PARAM_SERVICE_GROUP_ID);
    final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider(aRequestScope, sServiceGroupID);
    if (!SMPMetaManager.getSettings().isDirectoryIntegrationEnabled()) {
        // PD integration is disabled
        throw new SMPPreconditionFailedException("The " + SMPWebAppConfiguration.getDirectoryName() + " integration is disabled. getBusinessCard will not be executed", aDataProvider.getCurrentURI());
    }
    // getBusinessCard throws an exception if non is found
    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);
}
Also used : SMPPreconditionFailedException(com.helger.phoss.smp.exception.SMPPreconditionFailedException) PD3BusinessCardType(com.helger.pd.businesscard.v3.PD3BusinessCardType) BusinessCardServerAPI(com.helger.phoss.smp.restapi.BusinessCardServerAPI) ISMPServerAPIDataProvider(com.helger.phoss.smp.restapi.ISMPServerAPIDataProvider) PD3BusinessCardMarshaller(com.helger.pd.businesscard.v3.PD3BusinessCardMarshaller)

Aggregations

PD3BusinessCardMarshaller (com.helger.pd.businesscard.v3.PD3BusinessCardMarshaller)1 PD3BusinessCardType (com.helger.pd.businesscard.v3.PD3BusinessCardType)1 SMPPreconditionFailedException (com.helger.phoss.smp.exception.SMPPreconditionFailedException)1 BusinessCardServerAPI (com.helger.phoss.smp.restapi.BusinessCardServerAPI)1 ISMPServerAPIDataProvider (com.helger.phoss.smp.restapi.ISMPServerAPIDataProvider)1