use of com.helger.xsds.peppol.smp1.ServiceGroupReferenceListType in project peppol-commons by phax.
the class SMPClientTest method testGetServiceGroupReferenceList.
@Test
public void testGetServiceGroupReferenceList() throws SMPClientException {
final SMPClient aSMPClient = new SMPClient(SMP_URI);
final ServiceGroupReferenceListType aServiceGroupReferenceList = aSMPClient.getServiceGroupReferenceList(SMP_USERNAME, SMP_CREDENTIALS);
assertNotNull(aServiceGroupReferenceList);
for (final ServiceGroupReferenceType aServiceGroupReference : aServiceGroupReferenceList.getServiceGroupReference()) {
final CompleteServiceGroupType aCSG = aSMPClient.getCompleteServiceGroup(aServiceGroupReference.getHref());
assertNotNull(aCSG);
}
}
use of com.helger.xsds.peppol.smp1.ServiceGroupReferenceListType in project peppol-commons by phax.
the class MainSMPServiceGroupReferenceList method main.
public static void main(final String[] args) throws Exception {
final URI SMP_URI = MockSMPClientConfig.getSMPURI();
final BasicAuthClientCredentials SMP_CREDENTIALS = MockSMPClientConfig.getSMPCredentials();
final String SMP_USERNAME = MockSMPClientConfig.getSMPUserName();
// The main SMP client
final SMPClient aClient = new SMPClient(SMP_URI);
// Get the service group reference list
final ServiceGroupReferenceListType aServiceGroupReferenceList = aClient.getServiceGroupReferenceListOrNull(SMP_USERNAME, SMP_CREDENTIALS);
if (aServiceGroupReferenceList == null)
LOGGER.error("Failed to get complete service group for " + SMP_USERNAME);
else {
LOGGER.info("All service groups owned by " + SMP_USERNAME + ":");
for (final ServiceGroupReferenceType aServiceGroupReference : aServiceGroupReferenceList.getServiceGroupReference()) LOGGER.info(" " + aServiceGroupReference.getHref());
}
LOGGER.info("Done");
}
use of com.helger.xsds.peppol.smp1.ServiceGroupReferenceListType in project phoss-smp by phax.
the class SMPServerAPI method getServiceGroupReferenceList.
@Nonnull
public ServiceGroupReferenceListType getServiceGroupReferenceList(@Nonnull final String sPathUserID, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPServerException {
final String sLog = LOG_PREFIX + "GET /list/" + sPathUserID;
final String sAction = "getServiceGroupReferenceList";
if (LOGGER.isInfoEnabled())
LOGGER.info(sLog);
STATS_COUNTER_INVOCATION.increment(sAction);
try {
if (!aCredentials.getUserName().equals(sPathUserID)) {
throw new SMPUnauthorizedException("URL user name '" + sPathUserID + "' does not match HTTP Basic Auth user name '" + aCredentials.getUserName() + "'", m_aAPIDataProvider.getCurrentURI());
}
final IUser aSMPUser = SMPUserManagerPhoton.validateUserCredentials(aCredentials);
final ISMPServiceGroupManager aSGMgr = SMPMetaManager.getServiceGroupMgr();
final ICommonsList<ISMPServiceGroup> aServiceGroups = aSGMgr.getAllSMPServiceGroupsOfOwner(aSMPUser.getID());
final ServiceGroupReferenceListType aRefList = new ServiceGroupReferenceListType();
for (final ISMPServiceGroup aServiceGroup : aServiceGroups) {
final String sHref = m_aAPIDataProvider.getServiceGroupHref(aServiceGroup.getParticipantIdentifier());
final ServiceGroupReferenceType aServGroupRefType = new ServiceGroupReferenceType();
aServGroupRefType.setHref(sHref);
aRefList.addServiceGroupReference(aServGroupRefType);
}
if (LOGGER.isInfoEnabled())
LOGGER.info(sLog + " SUCCESS");
STATS_COUNTER_SUCCESS.increment(sAction);
return aRefList;
} catch (final SMPServerException ex) {
if (LOGGER.isWarnEnabled())
LOGGER.warn(sLog + " ERROR - " + ex.getMessage());
STATS_COUNTER_ERROR.increment(sAction);
throw ex;
}
}
use of com.helger.xsds.peppol.smp1.ServiceGroupReferenceListType in project phoss-smp by phax.
the class BDXR1ServerAPI method getServiceGroupReferenceList.
@Nonnull
public ServiceGroupReferenceListType getServiceGroupReferenceList(@Nonnull final String sPathUserID, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPServerException {
final String sLog = LOG_PREFIX + "GET /list/" + sPathUserID;
final String sAction = "getServiceGroupReferenceList";
if (LOGGER.isInfoEnabled())
LOGGER.info(sLog);
STATS_COUNTER_INVOCATION.increment(sAction);
try {
if (!aCredentials.getUserName().equals(sPathUserID)) {
throw new SMPUnauthorizedException("URL user name '" + sPathUserID + "' does not match HTTP Basic Auth user name '" + aCredentials.getUserName() + "'", m_aAPIDataProvider.getCurrentURI());
}
final IUser aSMPUser = SMPUserManagerPhoton.validateUserCredentials(aCredentials);
final ISMPServiceGroupManager aSGMgr = SMPMetaManager.getServiceGroupMgr();
final ICommonsList<ISMPServiceGroup> aServiceGroups = aSGMgr.getAllSMPServiceGroupsOfOwner(aSMPUser.getID());
final ServiceGroupReferenceListType aRefList = new ServiceGroupReferenceListType();
for (final ISMPServiceGroup aServiceGroup : aServiceGroups) {
final String sHref = m_aAPIDataProvider.getServiceGroupHref(aServiceGroup.getParticipantIdentifier());
final ServiceGroupReferenceType aServGroupRefType = new ServiceGroupReferenceType();
aServGroupRefType.setHref(sHref);
aRefList.addServiceGroupReference(aServGroupRefType);
}
if (LOGGER.isInfoEnabled())
LOGGER.info(sLog + " SUCCESS");
STATS_COUNTER_SUCCESS.increment(sAction);
return aRefList;
} catch (final SMPServerException ex) {
if (LOGGER.isWarnEnabled())
LOGGER.warn(sLog + " ERROR - " + ex.getMessage());
STATS_COUNTER_ERROR.increment(sAction);
throw ex;
}
}
Aggregations