use of com.helger.smpclient.peppol.marshal.SMPMarshallerServiceGroupReferenceListType in project peppol-commons by phax.
the class SMPClientReadOnly method getServiceGroupReferenceList.
/**
* Gets a list of references to the CompleteServiceGroup's owned by the
* specified userId. This is a non-specification compliant method.
*
* @param sUserID
* The username for which to retrieve service groups.
* @param aCredentials
* The user name and password to use as credentials.
* @return A list of references to complete service groups and never
* <code>null</code>.
* @throws SMPClientException
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The username or password was not correct.
* @throws SMPClientNotFoundException
* The userId did not exist.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #getServiceGroupReferenceListOrNull(String,
* BasicAuthClientCredentials)
*/
@Nonnull
public ServiceGroupReferenceListType getServiceGroupReferenceList(@Nonnull final String sUserID, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
ValueEnforcer.notNull(sUserID, "UserID");
ValueEnforcer.notNull(aCredentials, "Credentials");
final String sURI = getSMPHostURI() + URL_PART_LIST + "/" + CIdentifier.createPercentEncoded(sUserID);
if (LOGGER.isDebugEnabled())
LOGGER.debug("SMPClient getServiceGroupReferenceList@" + sURI);
final HttpGet aRequest = new HttpGet(sURI);
aRequest.addHeader(CHttpHeader.AUTHORIZATION, aCredentials.getRequestValue());
final SMPMarshallerServiceGroupReferenceListType aMarshaller = new SMPMarshallerServiceGroupReferenceListType(isXMLSchemaValidation());
customizeMarshaller(aMarshaller);
return executeGenericRequest(aRequest, new SMPHttpResponseHandlerUnsigned<>(aMarshaller));
}
use of com.helger.smpclient.peppol.marshal.SMPMarshallerServiceGroupReferenceListType 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);
}
Aggregations