use of org.osate.aadl2.ProcessType in project peppol-commons by phax.
the class MainSMPServiceRegistrationCreate method main.
public static void main(final String[] args) throws Exception {
final URI SMP_URI = MockSMPClientConfig.getSMPURI();
final BasicAuthClientCredentials SMP_CREDENTIALS = MockSMPClientConfig.getSMPCredentials();
final IParticipantIdentifier PARTICIPANT_ID = MockSMPClientConfig.getParticipantID();
final IDocumentTypeIdentifier DOCUMENT_ID = MockSMPClientConfig.getDocumentTypeID();
final IProcessIdentifier PROCESS_ID = MockSMPClientConfig.getProcessTypeID();
final W3CEndpointReference START_AP_ENDPOINTREF = MockSMPClientConfig.getAPEndpointRef();
final String AP_CERT_STRING = MockSMPClientConfig.getAPCert();
final String AP_SERVICE_DESCRIPTION = MockSMPClientConfig.getAPServiceDescription();
final String AP_CONTACT_URL = MockSMPClientConfig.getAPContact();
final String AP_INFO_URL = MockSMPClientConfig.getAPInfo();
// The main SMP client
final SMPClient aClient = new SMPClient(SMP_URI);
// Create the service registration
final ServiceInformationType aServiceInformation = new ServiceInformationType();
{
final ProcessListType aProcessList = new ProcessListType();
{
final ProcessType aProcess = new ProcessType();
{
final ServiceEndpointList aServiceEndpointList = new ServiceEndpointList();
{
final EndpointType aEndpoint = new EndpointType();
aEndpoint.setEndpointReference(START_AP_ENDPOINTREF);
aEndpoint.setTransportProfile(ESMPTransportProfile.TRANSPORT_PROFILE_AS2.getID());
aEndpoint.setCertificate(AP_CERT_STRING);
aEndpoint.setServiceActivationDate(PDTFactory.createXMLOffsetDateTime(2011, Month.JANUARY, 1));
aEndpoint.setServiceExpirationDate(PDTFactory.createXMLOffsetDateTime(2020, Month.DECEMBER, 31));
aEndpoint.setServiceDescription(AP_SERVICE_DESCRIPTION);
aEndpoint.setTechnicalContactUrl(AP_CONTACT_URL);
aEndpoint.setTechnicalInformationUrl(AP_INFO_URL);
aEndpoint.setMinimumAuthenticationLevel("1");
aEndpoint.setRequireBusinessLevelSignature(false);
aServiceEndpointList.getEndpoint().add(aEndpoint);
}
aProcess.setProcessIdentifier(new SimpleProcessIdentifier(PROCESS_ID));
aProcess.setServiceEndpointList(aServiceEndpointList);
}
aProcessList.getProcess().add(aProcess);
}
aServiceInformation.setDocumentIdentifier(new SimpleDocumentTypeIdentifier(DOCUMENT_ID));
aServiceInformation.setParticipantIdentifier(new SimpleParticipantIdentifier(PARTICIPANT_ID));
aServiceInformation.setProcessList(aProcessList);
}
aClient.saveServiceInformation(aServiceInformation, SMP_CREDENTIALS);
LOGGER.info("Done");
}
use of org.osate.aadl2.ProcessType in project peppol-commons by phax.
the class BDXRClientReadOnly method getEndpoint.
/**
* Extract the Endpoint from the ServiceMetadata that matches the passed
* process ID and the optional required transport profile.
*
* @param aServiceMetadata
* The unsigned service meta data object. May not be <code>null</code>.
* @param aProcessID
* The process identifier to be looked up. May not be <code>null</code>
* .
* @param aTransportProfile
* The required transport profile to be used. May not be
* <code>null</code>.
* @return <code>null</code> if no matching endpoint was found
* @since 8.2.6
*/
@Nullable
public static EndpointType getEndpoint(@Nonnull final ServiceMetadataType aServiceMetadata, @Nonnull final IProcessIdentifier aProcessID, @Nonnull final ISMPTransportProfile aTransportProfile) {
ValueEnforcer.notNull(aServiceMetadata, "ServiceMetadata");
final ServiceInformationType aServiceInformation = aServiceMetadata.getServiceInformation();
if (aServiceInformation == null) {
// It seems to be a redirect and not service information
return null;
}
ValueEnforcer.notNull(aServiceInformation.getProcessList(), "ServiceMetadata.ServiceInformation.ProcessList");
ValueEnforcer.notNull(aProcessID, "ProcessID");
ValueEnforcer.notNull(aTransportProfile, "TransportProfile");
// Iterate all processes
for (final ProcessType aProcessType : aServiceInformation.getProcessList().getProcess()) {
// Matches the requested one?
if (SimpleProcessIdentifier.wrap(aProcessType.getProcessIdentifier()).hasSameContent(aProcessID)) {
// Filter endpoints by required transport profile
final ICommonsList<EndpointType> aRelevantEndpoints = new CommonsArrayList<>();
for (final EndpointType aEndpoint : aProcessType.getServiceEndpointList().getEndpoint()) if (aTransportProfile.getID().equals(aEndpoint.getTransportProfile()))
aRelevantEndpoints.add(aEndpoint);
if (aRelevantEndpoints.size() != 1) {
if (LOGGER.isWarnEnabled())
LOGGER.warn("Found " + aRelevantEndpoints.size() + " endpoints for process " + aProcessID + " and transport profile " + aTransportProfile.getID() + (aRelevantEndpoints.isEmpty() ? "" : ": " + aRelevantEndpoints.toString() + " - using the first one"));
}
// Use the first endpoint or null
final EndpointType ret = aRelevantEndpoints.getFirst();
if (LOGGER.isDebugEnabled())
LOGGER.debug("Found matching endpoint: " + ret);
return ret;
}
}
if (LOGGER.isDebugEnabled())
LOGGER.debug("Found no matching SMP endpoint");
return null;
}
use of org.osate.aadl2.ProcessType in project geotoolkit by Geomatys.
the class ObservationTemplate method setProcedure.
@Override
public void setProcedure(final Process id) {
if (id != null && observation != null) {
ProcessType proc;
if (id instanceof ProcessType) {
proc = (ProcessType) id;
} else {
proc = new ProcessType((org.geotoolkit.observation.xml.Process) id);
}
observation.setProcedure(proc);
}
}
Aggregations