Search in sources :

Example 1 with TestEndpoint

use of com.helger.peppol.testendpoint.TestEndpoint in project peppol-practical by phax.

the class PagePublicToolsTestEndpoints method validateAndSaveInputParameters.

@Override
protected void validateAndSaveInputParameters(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final TestEndpoint aSelectedObject, @Nonnull final FormErrorList aFormErrors, @Nonnull final EWebPageFormAction eFormAction) {
    final TestEndpointManager aTestEndpointMgr = PPMetaManager.getTestEndpointMgr();
    final ISMLConfigurationManager aSMLConfigurationMgr = PPMetaManager.getSMLConfigurationMgr();
    final String sCompanyName = aWPEC.params().getAsString(FIELD_COMPANY_NAME);
    final String sContactPerson = aWPEC.params().getAsString(FIELD_CONTACT_PERSON);
    final String sParticipantIDIssuer = aWPEC.params().getAsString(FIELD_PARTICIPANT_ID_ISSUER);
    final EPredefinedParticipantIdentifierScheme eScheme = AppHelper.getParticipantIdentifierSchemeOfID(sParticipantIDIssuer);
    final String sParticipantIDValue = aWPEC.params().getAsString(FIELD_PARTICIPANT_ID_VALUE);
    final String sTransportProfile = aWPEC.params().getAsString(FIELD_TRANSPORT_PROFILE);
    final ESMPTransportProfile eTransportProfile = ESMPTransportProfile.getFromIDOrNull(sTransportProfile);
    final String sTransportProfileName = AppHelper.getSMPTransportProfileShortName(eTransportProfile);
    final String sSMLID = aWPEC.params().getAsString(FIELD_SML);
    final ISMLConfiguration aSML = aSMLConfigurationMgr.getSMLInfoOfID(sSMLID);
    if (StringHelper.hasNoText(sCompanyName))
        aFormErrors.addFieldError(FIELD_COMPANY_NAME, "Please provide the company name");
    if (StringHelper.hasNoText(sParticipantIDIssuer))
        aFormErrors.addFieldError(FIELD_PARTICIPANT_ID_ISSUER, "Please select a participant identifier issuing agency");
    else if (eScheme == null)
        aFormErrors.addFieldError(FIELD_PARTICIPANT_ID_ISSUER, "Please select a valid participant identifier issuing agency");
    if (StringHelper.hasNoText(sParticipantIDValue))
        aFormErrors.addFieldError(FIELD_PARTICIPANT_ID_VALUE, "Please provide a participant identifier value");
    if (eTransportProfile == null)
        aFormErrors.addFieldError(FIELD_TRANSPORT_PROFILE, "Please select a transport profile");
    if (aSML == null)
        aFormErrors.addFieldError(FIELD_SML, "Please select an SML where the participant is registered");
    if (aFormErrors.isEmpty()) {
        // Check if participant ID and transport profile are already registered
        final TestEndpoint aSameIDTestEndpoint = aTestEndpointMgr.getTestEndpoint(sParticipantIDIssuer, sParticipantIDValue, eTransportProfile);
        if (aSameIDTestEndpoint != null && !aSameIDTestEndpoint.equals(aSelectedObject))
            aFormErrors.addFieldError(FIELD_TRANSPORT_PROFILE, "Another test endpoint for " + sParticipantIDIssuer + ":" + sParticipantIDValue + " and transport profile " + sTransportProfileName + " is already registered!");
    }
    if (aFormErrors.isEmpty()) {
        if (eFormAction.isEdit()) {
            aTestEndpointMgr.updateTestEndpoint(aSelectedObject.getID(), sCompanyName, sContactPerson, sParticipantIDIssuer, sParticipantIDValue, eTransportProfile, aSML);
            aWPEC.postRedirectGetInternal(success("Successfully edited the test endpoint for " + sParticipantIDIssuer + ":" + sParticipantIDValue + " with transport profile " + sTransportProfileName));
        } else {
            aTestEndpointMgr.createTestEndpoint(sCompanyName, sContactPerson, sParticipantIDIssuer, sParticipantIDValue, eTransportProfile, aSML);
            aWPEC.postRedirectGetInternal(success("Successfully added the new test endpoint for " + sParticipantIDIssuer + ":" + sParticipantIDValue + " with transport profile " + sTransportProfileName));
        }
    }
}
Also used : TestEndpoint(com.helger.peppol.testendpoint.TestEndpoint) ISMLConfigurationManager(com.helger.peppol.app.mgr.ISMLConfigurationManager) ESMPTransportProfile(com.helger.peppol.smp.ESMPTransportProfile) TestEndpointManager(com.helger.peppol.testendpoint.TestEndpointManager) ISMLConfiguration(com.helger.peppol.domain.ISMLConfiguration) EPredefinedParticipantIdentifierScheme(com.helger.peppolid.peppol.pidscheme.EPredefinedParticipantIdentifierScheme)

Example 2 with TestEndpoint

use of com.helger.peppol.testendpoint.TestEndpoint in project peppol-practical by phax.

the class PagePublicToolsTestEndpoints method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final TestEndpointManager aTestEndpointMgr = PPMetaManager.getTestEndpointMgr();
    final boolean bUserIsLoggedIn = LoggedInUserManager.getInstance().isUserLoggedInInCurrentSession();
    // Toolbar on top
    final BootstrapButtonToolbar aToolbar = aNodeList.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
    if (bUserIsLoggedIn)
        aToolbar.addButtonNew("Create new test endpoint", createCreateURL(aWPEC));
    else
        aToolbar.addChild(badgeInfo("You need to be logged in to create test endpoints."));
    aNodeList.addChild(info("Test endpoints are special Peppol participant identifiers whose sole purpose is the usage for testing. So if you are a Peppol AccessPoint provider and want to test your implementation you may use the below listed participant identifiers as test recipients."));
    // List existing
    final HCTable aTable = new HCTable(new DTCol("Participant ID"), new DTCol("Company").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Transport profile"), new DTCol("SML"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
    for (final TestEndpoint aCurObject : aTestEndpointMgr.getAllActiveTestEndpoints()) {
        final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
        final HCRow aRow = aTable.addBodyRow();
        aRow.addCell(new HCA(aViewLink).addChild(aCurObject.getDisplayName()));
        aRow.addCell(aCurObject.getCompanyName());
        aRow.addCell(AppHelper.getSMPTransportProfileShortName(aCurObject.getTransportProfile()));
        aRow.addCell(aCurObject.getSML().getDisplayName());
        final IHCCell<?> aActionCell = aRow.addCell();
        if (isActionAllowed(aWPEC, EWebPageFormAction.EDIT, aCurObject))
            aActionCell.addChild(createEditLink(aWPEC, aCurObject));
        else
            aActionCell.addChild(createEmptyAction());
        aActionCell.addChild(new HCTextNode(" "));
        if (isActionAllowed(aWPEC, EWebPageFormAction.DELETE, aCurObject))
            aActionCell.addChild(createDeleteLink(aWPEC, aCurObject));
        else
            aActionCell.addChild(createEmptyAction());
        aActionCell.addChild(new HCTextNode(" "));
        if (bUserIsLoggedIn)
            aActionCell.addChild(createCopyLink(aWPEC, aCurObject));
        else
            aActionCell.addChild(createEmptyAction());
        aActionCell.addChild(new HCTextNode(" "));
        // Visible for all
        aActionCell.addChild(new HCA(_createParticipantInfoURL(aWPEC, aCurObject)).setTitle("Show participant information").addChild(EDefaultIcon.MAGNIFIER.getAsNode()));
    }
    aNodeList.addChild(aTable);
    final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
    aNodeList.addChild(aDataTables);
}
Also used : Locale(java.util.Locale) TestEndpoint(com.helger.peppol.testendpoint.TestEndpoint) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCA(com.helger.html.hc.html.textlevel.HCA) TestEndpointManager(com.helger.peppol.testendpoint.TestEndpointManager) HCRow(com.helger.html.hc.html.tabular.HCRow) HCTable(com.helger.html.hc.html.tabular.HCTable) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) 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) DataTables(com.helger.photon.uictrls.datatables.DataTables) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)

Aggregations

TestEndpoint (com.helger.peppol.testendpoint.TestEndpoint)2 TestEndpointManager (com.helger.peppol.testendpoint.TestEndpointManager)2 ISimpleURL (com.helger.commons.url.ISimpleURL)1 HCRow (com.helger.html.hc.html.tabular.HCRow)1 HCTable (com.helger.html.hc.html.tabular.HCTable)1 HCA (com.helger.html.hc.html.textlevel.HCA)1 HCNodeList (com.helger.html.hc.impl.HCNodeList)1 HCTextNode (com.helger.html.hc.impl.HCTextNode)1 ISMLConfigurationManager (com.helger.peppol.app.mgr.ISMLConfigurationManager)1 ISMLConfiguration (com.helger.peppol.domain.ISMLConfiguration)1 ESMPTransportProfile (com.helger.peppol.smp.ESMPTransportProfile)1 EPredefinedParticipantIdentifierScheme (com.helger.peppolid.peppol.pidscheme.EPredefinedParticipantIdentifierScheme)1 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)1 BootstrapDTColAction (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction)1 BootstrapDataTables (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)1 DataTables (com.helger.photon.uictrls.datatables.DataTables)1 DTCol (com.helger.photon.uictrls.datatables.column.DTCol)1 Locale (java.util.Locale)1