use of com.helger.xsds.bdxr.smp2.ServiceMetadataType in project phoss-smp by phax.
the class SMPServerAPI method getServiceRegistration.
@Nonnull
public SignedServiceMetadataType getServiceRegistration(@Nonnull final String sPathServiceGroupID, @Nonnull final String sPathDocTypeID) throws SMPServerException {
final String sLog = LOG_PREFIX + "GET /" + sPathServiceGroupID + "/services/" + sPathDocTypeID;
final String sAction = "getServiceRegistration";
if (LOGGER.isInfoEnabled())
LOGGER.info(sLog);
STATS_COUNTER_INVOCATION.increment(sAction);
try {
final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
final IParticipantIdentifier aPathServiceGroupID = aIdentifierFactory.parseParticipantIdentifier(sPathServiceGroupID);
if (aPathServiceGroupID == null) {
// Invalid identifier
throw SMPBadRequestException.failedToParseSG(sPathServiceGroupID, m_aAPIDataProvider.getCurrentURI());
}
final ISMPServiceGroup aPathServiceGroup = SMPMetaManager.getServiceGroupMgr().getSMPServiceGroupOfID(aPathServiceGroupID);
if (aPathServiceGroup == null) {
throw new SMPNotFoundException("No such Service Group '" + sPathServiceGroupID + "'", m_aAPIDataProvider.getCurrentURI());
}
final IDocumentTypeIdentifier aPathDocTypeID = aIdentifierFactory.parseDocumentTypeIdentifier(sPathDocTypeID);
if (aPathDocTypeID == null) {
throw SMPBadRequestException.failedToParseDocType(sPathDocTypeID, m_aAPIDataProvider.getCurrentURI());
}
// First check for redirection, then for actual service
final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr();
final ISMPRedirect aRedirect = aRedirectMgr.getSMPRedirectOfServiceGroupAndDocumentType(aPathServiceGroup, aPathDocTypeID);
final SignedServiceMetadataType aSignedServiceMetadata = new SignedServiceMetadataType();
if (aRedirect != null) {
aSignedServiceMetadata.setServiceMetadata(aRedirect.getAsJAXBObjectPeppol());
} else {
// Get as regular service information
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
final ISMPServiceInformation aServiceInfo = aServiceInfoMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aPathServiceGroup, aPathDocTypeID);
final ServiceMetadataType aSM = aServiceInfo == null ? null : aServiceInfo.getAsJAXBObjectPeppol();
if (aSM != null) {
aSignedServiceMetadata.setServiceMetadata(aSM);
} else {
// Neither nor is present, or no endpoint is available
throw new SMPNotFoundException("service(" + sPathServiceGroupID + "," + sPathDocTypeID + ")", m_aAPIDataProvider.getCurrentURI());
}
}
if (LOGGER.isInfoEnabled())
LOGGER.info(sLog + " SUCCESS");
STATS_COUNTER_SUCCESS.increment(sAction);
return aSignedServiceMetadata;
} 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.bdxr.smp2.ServiceMetadataType in project peppol-commons by phax.
the class SMPClient method saveServiceRedirect.
/**
* Saves a redirect data object.
*
* @param aServiceGroupID
* The service group ID to use. May not be <code>null</code>.
* @param aDocumentTypeID
* The document type ID to use. May not be <code>null</code>.
* @param aRedirect
* The redirect to be saved. May not be <code>null</code>.
* @param aCredentials
* The user name and password to use as credentials. May not be
* <code>null</code>.
* @throws SMPClientException
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientNotFoundException
* A HTTP Not Found was received. This can happen if the service was
* not found.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #saveServiceInformation(ServiceInformationType,
* BasicAuthClientCredentials)
*/
public void saveServiceRedirect(@Nonnull final IParticipantIdentifier aServiceGroupID, @Nonnull final IDocumentTypeIdentifier aDocumentTypeID, @Nonnull final RedirectType aRedirect, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
ValueEnforcer.notNull(aServiceGroupID, "ServiceGroupID");
ValueEnforcer.notNull(aDocumentTypeID, "DocumentTypeID");
ValueEnforcer.notNull(aRedirect, "Redirect");
ValueEnforcer.notNull(aCredentials, "Credentials");
final ServiceMetadataType aServiceMetadata = new ServiceMetadataType();
aServiceMetadata.setRedirect(aRedirect);
_saveServiceInformation(aServiceGroupID, aDocumentTypeID, aServiceMetadata, aCredentials);
}
use of com.helger.xsds.bdxr.smp2.ServiceMetadataType in project peppol-commons by phax.
the class SMPClient method saveServiceInformation.
/**
* Saves a service information data object.
*
* @param aServiceInformation
* The service information object to save. May not be
* <code>null</code>.
* @param aCredentials
* The user name and password to use as credentials. May not be
* <code>null</code>.
* @throws SMPClientException
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientNotFoundException
* A HTTP Not Found was received. This can happen if the service was
* not found.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #saveServiceRedirect(IParticipantIdentifier, IDocumentTypeIdentifier,
* RedirectType, BasicAuthClientCredentials)
*/
public void saveServiceInformation(@Nonnull final ServiceInformationType aServiceInformation, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
ValueEnforcer.notNull(aServiceInformation, "ServiceMetadata.ServiceInformation");
ValueEnforcer.notNull(aServiceInformation.getParticipantIdentifier(), "ServiceMetadata.ServiceInformation.ParticipantIdentifier");
ValueEnforcer.notNull(aServiceInformation.getDocumentIdentifier(), "ServiceMetadata.ServiceInformation.DocumentIdentifier");
ValueEnforcer.notNull(aCredentials, "Credentials");
final ServiceMetadataType aServiceMetadata = new ServiceMetadataType();
aServiceMetadata.setServiceInformation(aServiceInformation);
_saveServiceInformation(SimpleParticipantIdentifier.wrap(aServiceInformation.getParticipantIdentifier()), SimpleDocumentTypeIdentifier.wrap(aServiceInformation.getDocumentIdentifier()), aServiceMetadata, aCredentials);
}
use of com.helger.xsds.bdxr.smp2.ServiceMetadataType in project peppol-commons by phax.
the class BDXRClient method saveServiceInformation.
/**
* Saves a service information data object.
*
* @param aServiceInformation
* The service information object to save. May not be
* <code>null</code>.
* @param aCredentials
* The user name and password to use as credentials. May not be
* <code>null</code>.
* @throws SMPClientException
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientNotFoundException
* A HTTP Not Found was received. This can happen if the service was
* not found.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #saveServiceRedirect(ParticipantIdentifierType,
* DocumentIdentifierType, RedirectType, BasicAuthClientCredentials)
*/
public void saveServiceInformation(@Nonnull final ServiceInformationType aServiceInformation, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
ValueEnforcer.notNull(aServiceInformation, "ServiceMetadata.ServiceInformation");
ValueEnforcer.notNull(aServiceInformation.getParticipantIdentifier(), "ServiceMetadata.ServiceInformation.ParticipantIdentifier");
ValueEnforcer.notNull(aServiceInformation.getDocumentIdentifier(), "ServiceMetadata.ServiceInformation.DocumentIdentifier");
ValueEnforcer.notNull(aCredentials, "Credentials");
final ServiceMetadataType aServiceMetadata = new ServiceMetadataType();
aServiceMetadata.setServiceInformation(aServiceInformation);
_saveServiceInformation(aServiceInformation.getParticipantIdentifier(), aServiceInformation.getDocumentIdentifier(), aServiceMetadata, aCredentials);
}
use of com.helger.xsds.bdxr.smp2.ServiceMetadataType in project peppol-commons by phax.
the class BDXRClient method saveServiceRedirect.
/**
* Saves a redirect data object.
*
* @param aServiceGroupID
* The service group ID to use. May not be <code>null</code>.
* @param aDocumentTypeID
* The document type ID to use. May not be <code>null</code>.
* @param aRedirect
* The redirect to be saved. May not be <code>null</code>.
* @param aCredentials
* The user name and password to use as credentials. May not be
* <code>null</code>.
* @throws SMPClientException
* in case something goes wrong
* @throws SMPClientUnauthorizedException
* The user name or password was not correct.
* @throws SMPClientNotFoundException
* A HTTP Not Found was received. This can happen if the service was
* not found.
* @throws SMPClientBadRequestException
* The request was not well formed.
* @see #saveServiceInformation(ServiceInformationType,
* BasicAuthClientCredentials)
*/
public void saveServiceRedirect(@Nonnull final ParticipantIdentifierType aServiceGroupID, @Nonnull final DocumentIdentifierType aDocumentTypeID, @Nonnull final RedirectType aRedirect, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPClientException {
ValueEnforcer.notNull(aServiceGroupID, "ServiceGroupID");
ValueEnforcer.notNull(aDocumentTypeID, "DocumentTypeID");
ValueEnforcer.notNull(aRedirect, "Redirect");
ValueEnforcer.notNull(aCredentials, "Credentials");
final ServiceMetadataType aServiceMetadata = new ServiceMetadataType();
aServiceMetadata.setRedirect(aRedirect);
_saveServiceInformation(aServiceGroupID, aDocumentTypeID, aServiceMetadata, aCredentials);
}
Aggregations