Search in sources :

Example 1 with ISMLInfoManager

use of com.helger.pd.publisher.app.ISMLInfoManager in project phoss-directory by phax.

the class PageSecureAdminSMLConfiguration method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final ISMLInfoManager aSMLInfoMgr = PDPMetaManager.getSMLInfoMgr();
    aNodeList.addChild(info("This page lets you create custom SML configurations that can be used for registration."));
    final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
    aToolbar.addButton("Create new SML configuration", createCreateURL(aWPEC), EDefaultIcon.NEW);
    aNodeList.addChild(aToolbar);
    final HCTable aTable = new HCTable(new DTCol("Name").setInitialSorting(ESortOrder.ASCENDING), new DTCol("DNS Zone"), new DTCol("Management Service URL"), new DTCol("Client Cert?"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
    for (final ISMLInfo aCurObject : aSMLInfoMgr.getAll()) {
        final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
        final HCRow aRow = aTable.addBodyRow();
        aRow.addCell(new HCA(aViewLink).addChild(aCurObject.getDisplayName()));
        aRow.addCell(aCurObject.getDNSZone());
        aRow.addCell(aCurObject.getManagementServiceURL());
        aRow.addCell(EPhotonCoreText.getYesOrNo(aCurObject.isClientCertificateRequired(), aDisplayLocale));
        aRow.addCell(createEditLink(aWPEC, aCurObject, "Edit " + aCurObject.getID()), new HCTextNode(" "), createCopyLink(aWPEC, aCurObject, "Copy " + aCurObject.getID()), new HCTextNode(" "), isActionAllowed(aWPEC, EWebPageFormAction.DELETE, aCurObject) ? createDeleteLink(aWPEC, aCurObject, "Delete " + aCurObject.getDisplayName()) : createEmptyAction());
    }
    final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
    aNodeList.addChild(aTable).addChild(aDataTables);
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMLInfo(com.helger.peppol.sml.ISMLInfo) HCA(com.helger.html.hc.html.textlevel.HCA) 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) ISMLInfoManager(com.helger.pd.publisher.app.ISMLInfoManager) 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)

Example 2 with ISMLInfoManager

use of com.helger.pd.publisher.app.ISMLInfoManager in project phoss-directory by phax.

the class PageSecureAdminSMLConfiguration method validateAndSaveInputParameters.

@Override
protected void validateAndSaveInputParameters(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMLInfo aSelectedObject, @Nonnull final FormErrorList aFormErrors, @Nonnull final EWebPageFormAction eFormAction) {
    final boolean bEdit = eFormAction.isEdit();
    final ISMLInfoManager aSMLInfoMgr = PDPMetaManager.getSMLInfoMgr();
    final String sDisplayName = aWPEC.params().getAsString(FIELD_DISPLAY_NAME);
    final String sDNSZone = aWPEC.params().getAsString(FIELD_DNS_ZONE);
    final String sManagementAddressURL = aWPEC.params().getAsString(FIELD_MANAGEMENT_ADDRESS_URL);
    final boolean bClientCertificateRequired = aWPEC.params().isCheckBoxChecked(FIELD_CLIENT_CERTIFICATE_REQUIRED, true);
    // validations
    if (StringHelper.hasNoText(sDisplayName))
        aFormErrors.addFieldError(FIELD_DISPLAY_NAME, "The SML configuration name must not be empty!");
    if (StringHelper.hasNoText(sDNSZone))
        aFormErrors.addFieldError(FIELD_DNS_ZONE, "The DNS Zone must not be empty!");
    if (StringHelper.hasNoText(sManagementAddressURL))
        aFormErrors.addFieldError(FIELD_MANAGEMENT_ADDRESS_URL, "The Management Address URL must not be empty!");
    else {
        final URL aURL = URLHelper.getAsURL(sManagementAddressURL);
        if (aURL == null)
            aFormErrors.addFieldError(FIELD_MANAGEMENT_ADDRESS_URL, "The Management Address URL is not a valid URL!");
        else if (!"https".equals(aURL.getProtocol()) && !"http".equals(aURL.getProtocol()))
            aFormErrors.addFieldError(FIELD_MANAGEMENT_ADDRESS_URL, "The Management Address URL should only be use the 'http' or the 'https' protocol!");
    }
    if (aFormErrors.isEmpty()) {
        // Lowercase with the US locale - not display locale specific
        final String sDNSZoneLC = sDNSZone.toLowerCase(Locale.US);
        if (bEdit) {
            aSMLInfoMgr.updateSMLInfo(aSelectedObject.getID(), sDisplayName, sDNSZoneLC, sManagementAddressURL, bClientCertificateRequired);
            aWPEC.postRedirectGetInternal(success("The SML configuration '" + sDisplayName + "' was successfully edited."));
        } else {
            aSMLInfoMgr.createSMLInfo(sDisplayName, sDNSZoneLC, sManagementAddressURL, bClientCertificateRequired);
            aWPEC.postRedirectGetInternal(success("The new SML configuration '" + sDisplayName + "' was successfully created."));
        }
    }
}
Also used : ISMLInfoManager(com.helger.pd.publisher.app.ISMLInfoManager) URL(java.net.URL) ISimpleURL(com.helger.commons.url.ISimpleURL)

Aggregations

ISimpleURL (com.helger.commons.url.ISimpleURL)2 ISMLInfoManager (com.helger.pd.publisher.app.ISMLInfoManager)2 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 ISMLInfo (com.helger.peppol.sml.ISMLInfo)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 URL (java.net.URL)1 Locale (java.util.Locale)1