use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phase4 by phax.
the class MainPhase4CEFSenderToop method main.
public static void main(final String[] args) {
WebScopeManager.onGlobalBegin(MockServletContext.create());
// Dump (for debugging purpose only)
AS4DumpManager.setIncomingDumper(new AS4IncomingDumperFileBased());
AS4DumpManager.setOutgoingDumper(new AS4OutgoingDumperFileBased());
try (final WebScoped w = new WebScoped()) {
final byte[] aPayloadBytes = SimpleFileIO.getAllFileBytes(new File("src/test/resources/examples/base-example.xml"));
if (aPayloadBytes == null)
throw new IllegalStateException();
// Start configuring here
final IParticipantIdentifier aReceiverID = Phase4CEFSender.IF.createParticipantIdentifier("iso6523-actorid-upis", "9915:tooptest");
final IAS4ClientBuildMessageCallback aBuildMessageCallback = new IAS4ClientBuildMessageCallback() {
public void onAS4Message(final AbstractAS4Message<?> aMsg) {
final AS4UserMessage aUserMsg = (AS4UserMessage) aMsg;
LOGGER.info("Sending out AS4 message with message ID '" + aUserMsg.getEbms3UserMessage().getMessageInfo().getMessageId() + "'");
LOGGER.info("Sending out AS4 message with conversation ID '" + aUserMsg.getEbms3UserMessage().getCollaborationInfo().getConversationId() + "'");
}
};
if (Phase4CEFSender.builder().documentTypeID(Phase4CEFSender.IF.createDocumentTypeIdentifier("toop-doctypeid-qns", "urn:eu:toop:ns:dataexchange-1p40::Response##urn:eu.toop.response.registeredorganization::1.40")).processID(Phase4CEFSender.IF.createProcessIdentifier("toop-procid-agreement", "urn:eu.toop.process.datarequestresponse")).senderParticipantID(Phase4CEFSender.IF.createParticipantIdentifier("iso6523-actorid-upis", "9914:phase4-test-sender")).receiverParticipantID(aReceiverID).fromPartyID(new SimpleParticipantIdentifier("type", "POP000306")).fromRole("http://www.toop.eu/edelivery/gateway").toPartyID(new SimpleParticipantIdentifier("type", "POP000306")).toRole("http://www.toop.eu/edelivery/gateway").payload(Phase4OutgoingAttachment.builder().data(aPayloadBytes).mimeTypeXML()).smpClient(new BDXRClientReadOnly(Phase4CEFSender.URL_PROVIDER, aReceiverID, SML_TOOP)).rawResponseConsumer(new AS4RawResponseConsumerWriteToFile()).buildMessageCallback(aBuildMessageCallback).sendMessage().isSuccess()) {
LOGGER.info("Successfully sent CEF message via AS4");
} else {
LOGGER.error("Failed to send CEF message via AS4");
}
} catch (final Exception ex) {
LOGGER.error("Error sending CEF message via AS4", ex);
} finally {
WebScopeManager.onGlobalEnd();
}
}
use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phoss-smp by phax.
the class SMPServiceGroupManagerJDBC method getAllSMPServiceGroups.
@Nonnull
@ReturnsMutableCopy
public ICommonsList<ISMPServiceGroup> getAllSMPServiceGroups() {
if (LOGGER.isDebugEnabled())
LOGGER.debug("getAllSMPServiceGroups()");
final ICommonsList<DBResultRow> aDBResult = newExecutor().queryAll("SELECT sg.businessIdentifierScheme, sg.businessIdentifier, sg.extension, so.username" + " FROM smp_service_group sg, smp_ownership so" + " WHERE so.businessIdentifierScheme=sg.businessIdentifierScheme AND so.businessIdentifier=sg.businessIdentifier");
final ICommonsList<ISMPServiceGroup> ret = new CommonsArrayList<>();
if (aDBResult != null)
for (final DBResultRow aRow : aDBResult) ret.add(new SMPServiceGroup(aRow.getAsString(3), new SimpleParticipantIdentifier(aRow.getAsString(0), aRow.getAsString(1)), aRow.getAsString(2)));
return ret;
}
use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phoss-smp by phax.
the class ServiceGroupInterfaceTest method testCreateAndDeleteServiceGroupSMPClient.
@Test
public void testCreateAndDeleteServiceGroupSMPClient() throws SMPClientException {
// Lower case version
final IParticipantIdentifier aPI_LC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9930:de203827312");
// Upper case version
final IParticipantIdentifier aPI_UC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9930:DE203827312");
final ServiceGroupType aSG = new ServiceGroupType();
aSG.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI_LC));
aSG.setServiceMetadataReferenceCollection(new ServiceMetadataReferenceCollectionType());
final ISMPServiceGroupManager aSGMgr = SMPMetaManager.getServiceGroupMgr();
final SMPClient aSMPClient = new MockSMPClient();
// GET
assertNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
try {
// PUT 1 - create
aSMPClient.saveServiceGroup(aSG, CREDENTIALS);
// Both regular and upper case must work
assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
// PUT 2 - overwrite
aSMPClient.saveServiceGroup(aSG, CREDENTIALS);
// Both regular and upper case must work
assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
// DELETE 1
aSMPClient.deleteServiceGroup(aPI_LC, CREDENTIALS);
// Both must be deleted
assertNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
} finally {
// DELETE 2
try {
aSMPClient.deleteServiceGroup(aPI_LC, CREDENTIALS);
} catch (final SMPClientNotFoundException ex) {
// Expected
}
// Both must be deleted
assertNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
}
}
use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phoss-smp by phax.
the class ServiceGroupInterfaceTest method testCreateAndDeleteServiceGroupJerseyClient.
@Test
public void testCreateAndDeleteServiceGroupJerseyClient() {
// Lower case version
final IParticipantIdentifier aPI_LC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9930:de203827312");
final String sPI_LC = aPI_LC.getURIEncoded();
// Upper case version
final IParticipantIdentifier aPI_UC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9930:DE203827312");
final String sPI_UC = aPI_UC.getURIEncoded();
final ServiceGroupType aSG_LC = new ServiceGroupType();
aSG_LC.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI_LC));
aSG_LC.setServiceMetadataReferenceCollection(new ServiceMetadataReferenceCollectionType());
final ServiceGroupType aSG_UC = new ServiceGroupType();
aSG_UC.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI_UC));
aSG_UC.setServiceMetadataReferenceCollection(new ServiceMetadataReferenceCollectionType());
final ISMPServiceGroupManager aSGMgr = SMPMetaManager.getServiceGroupMgr();
final WebTarget aTarget = ClientBuilder.newClient().target(m_aRule.getFullURL());
Response aResponseMsg;
// GET
_testResponseJerseyClient(aTarget.path(sPI_LC).request().get(), 404);
_testResponseJerseyClient(aTarget.path(sPI_UC).request().get(), 404);
try {
// PUT 1 - create
aResponseMsg = _addCredentials(aTarget.path(sPI_LC).request()).put(Entity.xml(m_aObjFactory.createServiceGroup(aSG_LC)));
_testResponseJerseyClient(aResponseMsg, 200);
// PUT 2 - upper case - already present
aResponseMsg = _addCredentials(aTarget.path(sPI_UC).request()).put(Entity.xml(m_aObjFactory.createServiceGroup(aSG_UC)));
_testResponseJerseyClient(aResponseMsg, 200);
// Both regular and upper case must work
assertNotNull(aTarget.path(sPI_LC).request().get(ServiceGroupType.class));
assertNotNull(aTarget.path(sPI_UC).request().get(ServiceGroupType.class));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
// PUT 2 - overwrite
aResponseMsg = _addCredentials(aTarget.path(sPI_LC).request()).put(Entity.xml(m_aObjFactory.createServiceGroup(aSG_LC)));
_testResponseJerseyClient(aResponseMsg, 200);
aResponseMsg = _addCredentials(aTarget.path(sPI_UC).request()).put(Entity.xml(m_aObjFactory.createServiceGroup(aSG_UC)));
_testResponseJerseyClient(aResponseMsg, 200);
// Both regular and upper case must work
assertNotNull(aTarget.path(sPI_LC).request().get(ServiceGroupType.class));
assertNotNull(aTarget.path(sPI_UC).request().get(ServiceGroupType.class));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
// DELETE 1
aResponseMsg = _addCredentials(aTarget.path(sPI_LC).request()).delete();
_testResponseJerseyClient(aResponseMsg, 200);
// Both must be deleted
_testResponseJerseyClient(aTarget.path(sPI_LC).request().get(), 404);
_testResponseJerseyClient(aTarget.path(sPI_UC).request().get(), 404);
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
} finally {
// DELETE 2
aResponseMsg = _addCredentials(aTarget.path(sPI_LC).request()).delete();
_testResponseJerseyClient(aResponseMsg, 200, 404);
// Both must be deleted
_testResponseJerseyClient(aTarget.path(sPI_LC).request().get(), 404);
_testResponseJerseyClient(aTarget.path(sPI_UC).request().get(), 404);
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
}
}
use of com.helger.peppolid.simple.participant.SimpleParticipantIdentifier in project phoss-smp by phax.
the class ServiceMetadataInterfaceTest method testCreateAndDeleteRedirectSMPClient.
@Test
public void testCreateAndDeleteRedirectSMPClient() throws SMPClientException {
// Lower case
final IParticipantIdentifier aPI_LC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9915:xxx");
// Upper case
final IParticipantIdentifier aPI_UC = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9915:XXX");
final IDocumentTypeIdentifier aDT = EPredefinedDocumentTypeIdentifier.INVOICE_EN16931_PEPPOL_V30.getAsDocumentTypeIdentifier();
final ServiceGroupType aSG = new ServiceGroupType();
aSG.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI_LC));
aSG.setServiceMetadataReferenceCollection(new ServiceMetadataReferenceCollectionType());
final RedirectType aRedir = _createRedirect();
final ISMPServiceGroupManager aSGMgr = SMPMetaManager.getServiceGroupMgr();
final ISMPRedirectManager aSRMgr = SMPMetaManager.getRedirectMgr();
final SMPClient aSMPClient = new MockSMPClient();
assertNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
try {
// PUT ServiceGroup
aSMPClient.saveServiceGroup(aSG, CREDENTIALS);
assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNotNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertTrue(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
final ISMPServiceGroup aServiceGroup = aSGMgr.getSMPServiceGroupOfID(aPI_LC);
assertNotNull(aServiceGroup);
final ISMPServiceGroup aServiceGroup_UC = aSGMgr.getSMPServiceGroupOfID(aPI_UC);
assertEquals(aServiceGroup, aServiceGroup_UC);
try {
// PUT 1 ServiceInformation
aSMPClient.saveServiceRedirect(aPI_LC, aDT, aRedir, CREDENTIALS);
assertNotNull(aSRMgr.getSMPRedirectOfServiceGroupAndDocumentType(aServiceGroup, aDT));
// PUT 2 ServiceInformation
aSMPClient.saveServiceRedirect(aPI_LC, aDT, aRedir, CREDENTIALS);
assertNotNull(aSRMgr.getSMPRedirectOfServiceGroupAndDocumentType(aServiceGroup, aDT));
// DELETE 1 Redirect
aSMPClient.deleteServiceRegistration(aPI_LC, aDT, CREDENTIALS);
assertNull(aSRMgr.getSMPRedirectOfServiceGroupAndDocumentType(aServiceGroup, aDT));
} finally {
// DELETE 2 Redirect
try {
aSMPClient.deleteServiceRegistration(aPI_LC, aDT, CREDENTIALS);
} catch (final SMPClientNotFoundException ex) {
// Expected
}
assertNull(aSRMgr.getSMPRedirectOfServiceGroupAndDocumentType(aServiceGroup, aDT));
}
assertNotNull(aSGMgr.getSMPServiceGroupOfID(aPI_LC));
} finally {
// DELETE ServiceGroup
try {
aSMPClient.deleteServiceGroup(aPI_LC, CREDENTIALS);
} catch (final SMPClientNotFoundException ex) {
// Expected
}
assertNull(aSMPClient.getServiceGroupOrNull(aPI_LC));
assertNull(aSMPClient.getServiceGroupOrNull(aPI_UC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_LC));
assertFalse(aSGMgr.containsSMPServiceGroupWithID(aPI_UC));
}
}
Aggregations