Search in sources :

Example 21 with ISMPRedirectManager

use of com.helger.phoss.smp.domain.redirect.ISMPRedirectManager in project phoss-smp by phax.

the class SMPRedirectManagerXMLTest method testRedirectBasic.

@Test
public void testRedirectBasic() throws SMPServerException {
    // Ensure the user is present
    final IUser aTestUser = PhotonSecurityManager.getUserMgr().getUserOfID(CSecurity.USER_ADMINISTRATOR_ID);
    assertNotNull(aTestUser);
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr();
    assertEquals(0, aRedirectMgr.getSMPRedirectCount());
    // Delete existing service group
    final IParticipantIdentifier aPI = aIdentifierFactory.createParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "0088:dummy");
    aServiceGroupMgr.deleteSMPServiceGroupNoEx(aPI, true);
    final ISMPServiceGroup aSG = aServiceGroupMgr.createSMPServiceGroup(aTestUser.getID(), aPI, null, true);
    assertNotNull(aSG);
    try {
        final IDocumentTypeIdentifier aDocTypeID = aIdentifierFactory.createDocumentTypeIdentifier(PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS, "doctype4711");
        final ISMPRedirect aRedirect = aRedirectMgr.createOrUpdateSMPRedirect(aSG, aDocTypeID, "bla", "foo", null, "<ext/>");
        assertNotNull(aRedirect);
        assertSame(aSG, aRedirect.getServiceGroup());
        assertEquals(aDocTypeID, aRedirect.getDocumentTypeIdentifier());
        assertEquals("bla", aRedirect.getTargetHref());
        assertEquals("foo", aRedirect.getSubjectUniqueIdentifier());
        assertNull(aRedirect.getCertificate());
        assertEquals("<ext />", aRedirect.getFirstExtensionXML().trim());
        XMLTestHelper.testMicroTypeConversion(aRedirect);
    } finally {
        aServiceGroupMgr.deleteSMPServiceGroup(aPI, true);
    }
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPRedirectManager(com.helger.phoss.smp.domain.redirect.ISMPRedirectManager) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) IUser(com.helger.photon.security.user.IUser) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 22 with ISMPRedirectManager

use of com.helger.phoss.smp.domain.redirect.ISMPRedirectManager in project phoss-smp by phax.

the class SMPRedirectManagerXMLTest method testRedirectUpperCaseSG.

@Test
public void testRedirectUpperCaseSG() throws SMPServerException {
    // Ensure the user is present
    final IUser aTestUser = PhotonSecurityManager.getUserMgr().getUserOfID(CSecurity.USER_ADMINISTRATOR_ID);
    assertNotNull(aTestUser);
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    assertFalse(aIdentifierFactory.isParticipantIdentifierCaseInsensitive("bla-sch-eme"));
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr();
    assertEquals(0, aRedirectMgr.getSMPRedirectCount());
    // Delete existing service group
    final IParticipantIdentifier aPI = aIdentifierFactory.createParticipantIdentifier("bla-sch-eme", "0088:UpperCase");
    assertNotNull(aPI);
    aServiceGroupMgr.deleteSMPServiceGroupNoEx(aPI, true);
    final ISMPServiceGroup aSG = aServiceGroupMgr.createSMPServiceGroup(aTestUser.getID(), aPI, null, true);
    assertNotNull(aSG);
    try {
        final IDocumentTypeIdentifier aDocTypeID = aIdentifierFactory.createDocumentTypeIdentifier(PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS, "DocType4711");
        final ISMPRedirect aRedirect = aRedirectMgr.createOrUpdateSMPRedirect(aSG, aDocTypeID, "bla", "foo", null, "<ext/>");
        assertNotNull(aRedirect);
        assertSame(aSG, aRedirect.getServiceGroup());
        assertEquals(aDocTypeID, aRedirect.getDocumentTypeIdentifier());
        assertEquals("bla", aRedirect.getTargetHref());
        assertEquals("foo", aRedirect.getSubjectUniqueIdentifier());
        assertNull(aRedirect.getCertificate());
        assertEquals("<ext />", aRedirect.getFirstExtensionXML().trim());
        XMLTestHelper.testMicroTypeConversion(aRedirect);
    } finally {
        aServiceGroupMgr.deleteSMPServiceGroup(aPI, true);
    }
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPRedirectManager(com.helger.phoss.smp.domain.redirect.ISMPRedirectManager) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) IUser(com.helger.photon.security.user.IUser) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 23 with ISMPRedirectManager

use of com.helger.phoss.smp.domain.redirect.ISMPRedirectManager in project phoss-smp by phax.

the class PageSecureRedirect method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr();
    final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
    aToolbar.addButton("Create new Redirect", createCreateURL(aWPEC), EDefaultIcon.NEW);
    aNodeList.addChild(aToolbar);
    final HCTable aTable = new HCTable(new DTCol("Service Group").setDataSort(0, 1).setInitialSorting(ESortOrder.ASCENDING), new DTCol("Document type ID").setDataSort(1, 0), new DTCol("Target URL"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
    for (final ISMPRedirect aCurObject : aRedirectMgr.getAllSMPRedirects()) {
        final StringMap aParams = new StringMap();
        aParams.putIn(FIELD_SERVICE_GROUP_ID, aCurObject.getServiceGroupID());
        aParams.putIn(FIELD_DOCTYPE_ID, aCurObject.getDocumentTypeIdentifier().getURIEncoded());
        final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject, aParams);
        final String sDisplayName = aCurObject.getServiceGroupID();
        final HCRow aRow = aTable.addBodyRow();
        aRow.addCell(new HCA(aViewLink).addChild(sDisplayName));
        aRow.addCell(NiceNameUI.getDocumentTypeID(aCurObject.getDocumentTypeIdentifier(), false));
        aRow.addCell(aCurObject.getTargetHref());
        final ISimpleURL aEditURL = createEditURL(aWPEC, aCurObject).addAll(aParams);
        final ISimpleURL aCopyURL = createCopyURL(aWPEC, aCurObject).addAll(aParams);
        final ISimpleURL aDeleteURL = createDeleteURL(aWPEC, aCurObject).addAll(aParams);
        final ISimpleURL aPreviewURL = LinkHelper.getURLWithServerAndContext(aCurObject.getServiceGroup().getParticipantIdentifier().getURIPercentEncoded() + SMPRestFilter.PATH_SERVICES + aCurObject.getDocumentTypeIdentifier().getURIPercentEncoded());
        aRow.addCell(new HCA(aEditURL).setTitle("Edit " + sDisplayName).addChild(EDefaultIcon.EDIT.getAsNode()), new HCTextNode(" "), new HCA(aCopyURL).setTitle("Create a copy of " + sDisplayName).addChild(EDefaultIcon.COPY.getAsNode()), new HCTextNode(" "), new HCA(aDeleteURL).setTitle("Delete " + sDisplayName).addChild(EDefaultIcon.DELETE.getAsNode()), new HCTextNode(" "), new HCA(aPreviewURL).setTitle("Perform SMP query on " + sDisplayName).setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode()));
    }
    final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
    aNodeList.addChild(aTable).addChild(aDataTables);
}
Also used : Locale(java.util.Locale) StringMap(com.helger.commons.collection.attr.StringMap) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) ISMPRedirectManager(com.helger.phoss.smp.domain.redirect.ISMPRedirectManager) HCTable(com.helger.html.hc.html.tabular.HCTable) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) HCTextNode(com.helger.html.hc.impl.HCTextNode) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables) DataTables(com.helger.photon.uictrls.datatables.DataTables)

Aggregations

ISMPRedirectManager (com.helger.phoss.smp.domain.redirect.ISMPRedirectManager)23 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)22 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)17 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)16 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)16 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)15 ISMPServiceInformationManager (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager)14 ISMPRedirect (com.helger.phoss.smp.domain.redirect.ISMPRedirect)12 IUser (com.helger.photon.security.user.IUser)11 ISMPServiceInformation (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation)10 SMPNotFoundException (com.helger.phoss.smp.exception.SMPNotFoundException)10 SMPServerException (com.helger.phoss.smp.exception.SMPServerException)9 Nonnull (javax.annotation.Nonnull)8 Test (org.junit.Test)7 EChange (com.helger.commons.state.EChange)4 X509Certificate (java.security.cert.X509Certificate)4 ICommonsList (com.helger.commons.collection.impl.ICommonsList)3 SimpleParticipantIdentifier (com.helger.peppolid.simple.participant.SimpleParticipantIdentifier)3 IMicroDocument (com.helger.xml.microdom.IMicroDocument)3 ISMPBusinessCard (com.helger.phoss.smp.domain.businesscard.ISMPBusinessCard)2