use of com.helger.html.hc.impl.HCNodeList in project phoss-smp by phax.
the class PageSecureCertificateInformation method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final ZonedDateTime aNowZDT = PDTFactory.getCurrentZonedDateTime();
final LocalDateTime aNowLDT = aNowZDT.toLocalDateTime();
final String sDirectoryName = SMPWebAppConfiguration.getDirectoryName();
if (aWPEC.hasAction(ACTION_RELOAD_KEYSTORE)) {
SMPKeyManager.reloadFromConfiguration();
aWPEC.postRedirectGetInternal(info("The keystore was updated from the configuration at " + DateTimeFormatter.ISO_DATE_TIME.format(aNowZDT) + ". The changes are reflected below."));
} else if (aWPEC.hasAction(ACTION_RELOAD_TRUSTSTORE)) {
SMPTrustManager.reloadFromConfiguration();
aWPEC.postRedirectGetInternal(info("The truststore was updated from the configuration at " + DateTimeFormatter.ISO_DATE_TIME.format(aNowZDT) + ". The changes are reflected below."));
} else if (aWPEC.hasAction(ACTION_RELOAD_DIRECTORY_CONFIGURATION)) {
PDClientConfiguration.reloadConfiguration();
aWPEC.postRedirectGetInternal(info("The " + sDirectoryName + " configuration was reloaded at " + DateTimeFormatter.ISO_DATE_TIME.format(aNowZDT) + ". The changes are reflected below."));
}
{
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addChild(new BootstrapButton().addChild("Reload keystore").setIcon(EDefaultIcon.REFRESH).setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_RELOAD_KEYSTORE)));
aToolbar.addChild(new BootstrapButton().addChild("Reload truststore").setIcon(EDefaultIcon.REFRESH).setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_RELOAD_TRUSTSTORE)));
if (SMPMetaManager.getSettings().isDirectoryIntegrationEnabled()) {
aToolbar.addChild(new BootstrapButton().addChild("Reload " + sDirectoryName + " configuration").setIcon(EDefaultIcon.REFRESH).setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_RELOAD_DIRECTORY_CONFIGURATION)));
}
aNodeList.addChild(aToolbar);
}
final BootstrapTabBox aTabBox = aNodeList.addAndReturnChild(new BootstrapTabBox());
// SMP Key store
{
final HCNodeList aTab = new HCNodeList();
if (!SMPKeyManager.isKeyStoreValid()) {
aTab.addChild(error(SMPKeyManager.getInitializationError()));
} else {
// Successfully loaded private key
final SMPKeyManager aKeyMgr = SMPKeyManager.getInstance();
final KeyStore aKeyStore = aKeyMgr.getKeyStore();
if (aKeyStore != null) {
try {
int nKeyEntries = 0;
for (final String sAlias : CollectionHelper.newList(aKeyStore.aliases())) {
if (aKeyStore.isKeyEntry(sAlias))
nKeyEntries++;
}
if (nKeyEntries == 0)
aTab.addChild(error("Found no private key entry in the configured key store."));
else if (nKeyEntries > 1)
aTab.addChild(warn("The configured key store contains " + nKeyEntries + " key entries. It is highly recommended to have only the SMP key in the key store to avoid issues with the SML communication."));
} catch (final GeneralSecurityException ex) {
aTab.addChild(error("Error iterating key store.").addChild(SMPCommonUI.getTechnicalDetailsUI(ex)));
}
}
final PrivateKeyEntry aKeyEntry = aKeyMgr.getPrivateKeyEntry();
if (aKeyEntry != null) {
final Certificate[] aChain = aKeyEntry.getCertificateChain();
// Key store path and password are fine
aTab.addChild(success(div("Keystore is located at '" + SMPServerConfiguration.getKeyStorePath() + "' and was successfully loaded.")).addChild(div("The private key with the alias '" + SMPServerConfiguration.getKeyStoreKeyAlias() + "' was successfully loaded.")));
if (aChain.length > 0 && aChain[0] instanceof X509Certificate) {
final X509Certificate aHead = (X509Certificate) aChain[0];
final String sIssuer = aHead.getIssuerX500Principal().getName();
final EPredefinedCert eCert = EPredefinedCert.getFromIssuerOrNull(sIssuer);
if (eCert != null) {
if (eCert.isDeprecated())
aTab.addChild(warn("You are currently using a ").addChild(strong("deprecated")).addChild(" " + eCert.getName() + " certificate!"));
else
aTab.addChild(info("You are currently using a " + eCert.getName() + " certificate!"));
if (aChain.length != eCert.getCertificateTreeLength())
aTab.addChild(error("The private key should be a chain of " + eCert.getCertificateTreeLength() + " certificates but it has " + aChain.length + " certificates. Please ensure that the respective root certificates are contained correctly!"));
}
// else: we don't care
}
final String sAlias = SMPServerConfiguration.getKeyStoreKeyAlias();
final HCOL aOL = new HCOL();
for (final Certificate aCert : aChain) {
if (aCert instanceof X509Certificate) {
final X509Certificate aX509Cert = (X509Certificate) aCert;
final BootstrapTable aCertDetails = SMPCommonUI.createCertificateDetailsTable(sAlias, aX509Cert, aNowLDT, aDisplayLocale);
aOL.addItem(aCertDetails);
} else
aOL.addItem("The certificate is not an X.509 certificate! It is internally a " + ClassHelper.getClassName(aCert));
}
aTab.addChild(aOL);
}
}
aTabBox.addTab("keystore", "Keystore", aTab);
}
// SMP Trust store
{
final HCNodeList aTab = new HCNodeList();
if (!SMPTrustManager.isTrustStoreValid()) {
aTab.addChild(warn(SMPTrustManager.getInitializationError()));
} else {
// Successfully loaded trust store
final SMPTrustManager aTrustMgr = SMPTrustManager.getInstance();
final KeyStore aTrustStore = aTrustMgr.getTrustStore();
// Trust store path and password are fine
aTab.addChild(success(div("Truststore is located at '" + SMPServerConfiguration.getTrustStorePath() + "' and was successfully loaded.")));
final HCOL aOL = new HCOL();
try {
for (final String sAlias : CollectionHelper.newList(aTrustStore.aliases())) {
final Certificate aCert = aTrustStore.getCertificate(sAlias);
if (aCert instanceof X509Certificate) {
final X509Certificate aX509Cert = (X509Certificate) aCert;
final BootstrapTable aCertDetails = SMPCommonUI.createCertificateDetailsTable(sAlias, aX509Cert, aNowLDT, aDisplayLocale);
aOL.addItem(aCertDetails);
} else
aOL.addItem("The certificate is not an X.509 certificate! It is internally a " + ClassHelper.getClassName(aCert));
}
} catch (final GeneralSecurityException ex) {
aOL.addItem(error("Error iterating trust store.").addChild(SMPCommonUI.getTechnicalDetailsUI(ex)));
}
aTab.addChild(aOL);
}
aTabBox.addTab("truststore", "Truststore", aTab);
}
// Peppol Directory client certificate
if (SMPMetaManager.getSettings().isDirectoryIntegrationEnabled()) {
// Directory client keystore
{
final HCNodeList aTab = new HCNodeList();
final LoadedKeyStore aKeyStoreLR = PDClientConfiguration.loadKeyStore();
if (aKeyStoreLR.isFailure()) {
aTab.addChild(error(PeppolKeyStoreHelper.getLoadError(aKeyStoreLR)));
} else {
final String sKeyStorePath = PDClientConfiguration.getKeyStorePath();
final LoadedKey<KeyStore.PrivateKeyEntry> aKeyLoading = PDClientConfiguration.loadPrivateKey(aKeyStoreLR.getKeyStore());
if (aKeyLoading.isFailure()) {
aTab.addChild(success(div("Keystore is located at '" + sKeyStorePath + "' and was successfully loaded.")));
aTab.addChild(error(PeppolKeyStoreHelper.getLoadError(aKeyLoading)));
} else {
// Successfully loaded private key
final String sAlias = PDClientConfiguration.getKeyStoreKeyAlias();
final PrivateKeyEntry aKeyEntry = aKeyLoading.getKeyEntry();
final Certificate[] aChain = aKeyEntry.getCertificateChain();
// Key store path and password are fine
aTab.addChild(success(div("Keystore is located at '" + sKeyStorePath + "' and was successfully loaded.")).addChild(div("The private key with the alias '" + sAlias + "' was successfully loaded.")));
if (aChain.length > 0 && aChain[0] instanceof X509Certificate) {
final X509Certificate aHead = (X509Certificate) aChain[0];
final String sIssuer = aHead.getIssuerX500Principal().getName();
final EPredefinedCert eCert = EPredefinedCert.getFromIssuerOrNull(sIssuer);
if (eCert != null) {
if (eCert.isDeprecated()) {
aTab.addChild(warn("You are currently using a ").addChild(strong("deprecated")).addChild(" " + eCert.getName() + " certificate!"));
} else
aTab.addChild(info("You are currently using a " + eCert.getName() + " certificate!"));
if (aChain.length != eCert.getCertificateTreeLength())
aTab.addChild(error("The private key should be a chain of " + eCert.getCertificateTreeLength() + " certificates but it has " + aChain.length + " certificates. Please ensure that the respective root certificates are contained!"));
}
// else: we don't care
}
final HCOL aUL = new HCOL();
for (final Certificate aCert : aChain) {
if (aCert instanceof X509Certificate) {
final X509Certificate aX509Cert = (X509Certificate) aCert;
final BootstrapTable aCertDetails = SMPCommonUI.createCertificateDetailsTable(sAlias, aX509Cert, aNowLDT, aDisplayLocale);
aUL.addItem(aCertDetails);
} else
aUL.addItem("The certificate is not an X.509 certificate! It is internally a " + ClassHelper.getClassName(aCert));
}
aTab.addChild(aUL);
}
}
aTabBox.addTab("pdkeystore", sDirectoryName + " Keystore", aTab);
}
// Directory client truststore
{
final HCNodeList aTab = new HCNodeList();
final LoadedKeyStore aTrustStoreLR = PDClientConfiguration.loadTrustStore();
if (aTrustStoreLR.isFailure()) {
aTab.addChild(error(PeppolKeyStoreHelper.getLoadError(aTrustStoreLR)));
} else {
// Successfully loaded trust store
final String sTrustStorePath = PDClientConfiguration.getTrustStorePath();
final KeyStore aTrustStore = aTrustStoreLR.getKeyStore();
// Trust store path and password are fine
aTab.addChild(success(div("Truststore is located at '" + sTrustStorePath + "' and was successfully loaded.")));
final HCOL aOL = new HCOL();
try {
for (final String sAlias : CollectionHelper.newList(aTrustStore.aliases())) {
final Certificate aCert = aTrustStore.getCertificate(sAlias);
if (aCert instanceof X509Certificate) {
final X509Certificate aX509Cert = (X509Certificate) aCert;
final BootstrapTable aCertDetails = SMPCommonUI.createCertificateDetailsTable(sAlias, aX509Cert, aNowLDT, aDisplayLocale);
aOL.addItem(aCertDetails);
} else
aOL.addItem("The certificate is not an X.509 certificate! It is internally a " + ClassHelper.getClassName(aCert));
}
} catch (final GeneralSecurityException ex) {
aOL.addItem(error("Error iterating trust store.").addChild(SMPCommonUI.getTechnicalDetailsUI(ex)));
}
aTab.addChild(aOL);
}
aTabBox.addTab("pdtruststore", sDirectoryName + " Truststore", aTab);
}
}
}
use of com.helger.html.hc.impl.HCNodeList in project phoss-smp by phax.
the class PageSecureEndpointChangeCertificate method _getCertificateDisplay.
@Nonnull
private static IHCNode _getCertificateDisplay(@Nullable final String sCert, @Nonnull final Locale aDisplayLocale) {
X509Certificate aEndpointCert = null;
try {
aEndpointCert = CertificateHelper.convertStringToCertficate(sCert);
} catch (final Exception ex) {
// Ignore
}
if (aEndpointCert == null) {
final int nDisplayLen = 20;
final String sCertPart = (sCert.length() > nDisplayLen ? sCert.substring(0, 20) + "..." : sCert);
final HCDiv ret = new HCDiv().addChild("Invalid certificate").addChild(sCert.length() > nDisplayLen ? " starting with: " : ": ");
if (sCertPart.length() > 0)
ret.addChild(new HCCode().addChild(sCertPart));
else
ret.addChild(new HCEM().addChild("empty"));
return ret;
}
final HCNodeList ret = new HCNodeList();
ret.addChild(new HCDiv().addChild("Issuer: " + aEndpointCert.getIssuerX500Principal().toString()));
ret.addChild(new HCDiv().addChild("Subject: " + aEndpointCert.getSubjectX500Principal().toString()));
final LocalDateTime aNotBefore = PDTFactory.createLocalDateTime(aEndpointCert.getNotBefore());
ret.addChild(new HCDiv().addChild("Not before: " + PDTToString.getAsString(aNotBefore, aDisplayLocale)));
final LocalDateTime aNotAfter = PDTFactory.createLocalDateTime(aEndpointCert.getNotAfter());
ret.addChild(new HCDiv().addChild("Not after: " + PDTToString.getAsString(aNotAfter, aDisplayLocale)));
return ret;
}
use of com.helger.html.hc.impl.HCNodeList in project phoss-smp by phax.
the class PageSecureEndpointChangeURL method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
boolean bShowList = true;
final ICommonsMap<String, ICommonsList<ISMPEndpoint>> aEndpointsGroupedPerURL = new CommonsHashMap<>();
final ICommonsMap<String, ICommonsSet<ISMPServiceGroup>> aServiceGroupsGroupedPerURL = new CommonsHashMap<>();
final ICommonsList<ISMPServiceInformation> aAllSIs = aServiceInfoMgr.getAllSMPServiceInformation();
int nTotalEndpointCount = 0;
int nTotalEndpointCountWithURL = 0;
for (final ISMPServiceInformation aSI : aAllSIs) {
final ISMPServiceGroup aSG = aSI.getServiceGroup();
for (final ISMPProcess aProcess : aSI.getAllProcesses()) for (final ISMPEndpoint aEndpoint : aProcess.getAllEndpoints()) {
++nTotalEndpointCount;
if (aEndpoint.hasEndpointReference()) {
aEndpointsGroupedPerURL.computeIfAbsent(aEndpoint.getEndpointReference(), k -> new CommonsArrayList<>()).add(aEndpoint);
aServiceGroupsGroupedPerURL.computeIfAbsent(aEndpoint.getEndpointReference(), k -> new CommonsHashSet<>()).add(aSG);
++nTotalEndpointCountWithURL;
}
}
}
{
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
aNodeList.addChild(aToolbar);
final int nCount = BulkChangeEndpointURL.getRunningJobCount();
if (nCount > 0) {
aNodeList.addChild(warn((nCount == 1 ? "1 bulk change is" : nCount + " bulk changes are") + " currently running in the background"));
}
}
if (aWPEC.hasAction(CPageParam.ACTION_EDIT)) {
bShowList = false;
final FormErrorList aFormErrors = new FormErrorList();
final String sOldURL = aWPEC.params().getAsString(FIELD_OLD_URL);
if (aWPEC.hasSubAction(CPageParam.ACTION_SAVE)) {
// Find selected service group (if any)
final String sServiceGroupID = aWPEC.params().getAsString(FIELD_SERVICE_GROUP);
ISMPServiceGroup aServiceGroup = null;
if (StringHelper.hasText(sServiceGroupID)) {
final IParticipantIdentifier aParticipantID = aIdentifierFactory.parseParticipantIdentifier(sServiceGroupID);
if (aParticipantID != null)
aServiceGroup = aServiceGroupMgr.getSMPServiceGroupOfID(aParticipantID);
}
final String sNewURL = aWPEC.params().getAsString(FIELD_NEW_URL);
if (StringHelper.hasNoText(sOldURL))
aFormErrors.addFieldInfo(FIELD_OLD_URL, "An old URL must be provided");
else if (!URLValidator.isValid(sOldURL))
aFormErrors.addFieldInfo(FIELD_OLD_URL, "The old URL is invalid");
if (StringHelper.hasNoText(sNewURL))
aFormErrors.addFieldInfo(FIELD_NEW_URL, "A new URL must be provided");
else if (!URLValidator.isValid(sNewURL))
aFormErrors.addFieldInfo(FIELD_NEW_URL, "The new URL is invalid");
else if (sNewURL.equals(sOldURL))
aFormErrors.addFieldInfo(FIELD_NEW_URL, "The new URL is identical to the old URL");
// Validate parameters
if (aFormErrors.isEmpty()) {
PhotonWorkerPool.getInstance().run("BulkChangeEndpointURL", new BulkChangeEndpointURL(aAllSIs, aServiceGroup, sOldURL, sNewURL));
aWPEC.postRedirectGetInternal(success("The bulk change of the endpoint URL from '" + sOldURL + "' to '" + sNewURL + "' is now running in the background. Please manually refresh the page to see the update."));
}
}
final ICommonsSet<ISMPServiceGroup> aServiceGroups = aServiceGroupsGroupedPerURL.get(sOldURL);
final int nSGCount = CollectionHelper.getSize(aServiceGroups);
final int nEPCount = CollectionHelper.getSize(aEndpointsGroupedPerURL.get(sOldURL));
aNodeList.addChild(info("The selected old URL '" + sOldURL + "' is currently used in " + nEPCount + " " + (nEPCount == 1 ? "endpoint" : "endpoints") + " of " + nSGCount + " " + (nSGCount == 1 ? "service group" : "service groups") + "."));
// Show edit screen
final BootstrapForm aForm = aNodeList.addAndReturnChild(getUIHandler().createFormSelf(aWPEC));
aForm.addChild(new HCHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_EDIT));
aForm.addChild(new HCHiddenField(CPageParam.PARAM_SUBACTION, CPageParam.ACTION_SAVE));
if (nSGCount > 1) {
// Select the affected service groups if more than one is available
final HCSelect aSGSelect = new HCSelect(new RequestField(FIELD_SERVICE_GROUP));
aSGSelect.addOption(SERVICE_GROUP_ALL, "All affected Service Groups");
if (aServiceGroups != null)
for (final ISMPServiceGroup aSG : aServiceGroups.getSorted(ISMPServiceGroup.comparator())) aSGSelect.addOption(aSG.getID(), aSG.getParticipantIdentifier().getURIEncoded());
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Service group").setCtrl(aSGSelect).setHelpText("If a specific service group is selected, the URL change will only happen in the endpoints of the selected service group. Othwerwise the endpoint is changed in ALL service groups with matching endpoints.").setErrorList(aFormErrors.getListOfField(FIELD_OLD_URL)));
} else {
// If less than 2 service groups are affected, use the 0/1
// automatically.
aForm.addChild(new HCHiddenField(FIELD_SERVICE_GROUP, SERVICE_GROUP_ALL));
}
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Old endpoint URL").setCtrl(new HCEdit(new RequestField(FIELD_OLD_URL, sOldURL))).setHelpText("The old URL that is to be changed in all matching endpoints").setErrorList(aFormErrors.getListOfField(FIELD_OLD_URL)));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("New endpoint URL").setCtrl(new HCEdit(new RequestField(FIELD_NEW_URL, sOldURL))).setHelpText("The new URL that is used instead").setErrorList(aFormErrors.getListOfField(FIELD_NEW_URL)));
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(getUIHandler().createToolbar(aWPEC));
aToolbar.addSubmitButton("Save changes", EDefaultIcon.SAVE);
aToolbar.addButtonCancel(aDisplayLocale);
}
if (bShowList) {
aNodeList.addChild(info().addChildren(div("This page lets you change the URLs of multiple endpoints at once. This is e.g. helpful when the underlying server got a new URL."), div("Currently " + (nTotalEndpointCount == 1 ? "1 endpoint is" : nTotalEndpointCount + " endpoints are") + " registered" + (nTotalEndpointCountWithURL < nTotalEndpointCount ? " of which " + nTotalEndpointCountWithURL + " have an endpoint reference" : "") + ".")));
final HCTable aTable = new HCTable(new DTCol("Endpoint URL").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Service Group Count").setDisplayType(EDTColType.INT, aDisplayLocale), new DTCol("Endpoint Count").setDisplayType(EDTColType.INT, aDisplayLocale), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
aEndpointsGroupedPerURL.forEach((sURL, aEndpoints) -> {
final HCRow aRow = aTable.addBodyRow();
aRow.addCell(sURL);
final int nSGCount = CollectionHelper.getSize(aServiceGroupsGroupedPerURL.get(sURL));
aRow.addCell(Integer.toString(nSGCount));
aRow.addCell(Integer.toString(aEndpoints.size()));
final ISimpleURL aEditURL = aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, CPageParam.ACTION_EDIT).add(FIELD_OLD_URL, sURL);
aRow.addCell(new HCA(aEditURL).setTitle("Change all endpoints pointing to " + sURL).addChild(EDefaultIcon.EDIT.getAsNode()));
});
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
}
use of com.helger.html.hc.impl.HCNodeList in project phoss-smp by phax.
the class PageSecureEndpointList method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
final ICommonsList<ISMPServiceInformation> aAllServiceInfos = aServiceInfoMgr.getAllSMPServiceInformation();
// Count unique service groups
final ICommonsSet<String> aServiceGroupIDs = new CommonsHashSet<>();
aAllServiceInfos.findAllMapped(ISMPServiceInformation::getServiceGroupID, aServiceGroupIDs::add);
final boolean bHideDetails = aServiceGroupIDs.size() > 1000;
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Create new Endpoint", createCreateURL(aWPEC), EDefaultIcon.NEW);
aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
if (!bHideDetails)
aToolbar.addButton("Tree view", aWPEC.getLinkToMenuItem(CMenuSecure.MENU_ENDPOINT_TREE), EDefaultIcon.MAGNIFIER);
aNodeList.addChild(aToolbar);
final HCTable aTable = new HCTable(new DTCol("Service group").setInitialSorting(ESortOrder.ASCENDING).setDataSort(0, 1, 2, 3), new DTCol("Document type ID").setDataSort(1, 0, 2, 3), new DTCol("Process ID").setDataSort(2, 0, 1, 3), new DTCol("Transport profile").setDataSort(3, 0, 1, 2), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
for (final ISMPServiceInformation aServiceInfo : aAllServiceInfos) {
final ISMPServiceGroup aServiceGroup = aServiceInfo.getServiceGroup();
final IParticipantIdentifier aParticipantID = aServiceGroup.getParticipantIdentifier();
final IDocumentTypeIdentifier aDocTypeID = aServiceInfo.getDocumentTypeIdentifier();
for (final ISMPProcess aProcess : aServiceInfo.getAllProcesses()) {
final IProcessIdentifier aProcessID = aProcess.getProcessIdentifier();
for (final ISMPEndpoint aEndpoint : aProcess.getAllEndpoints()) {
final StringMap aParams = createParamMap(aServiceInfo, aProcess, aEndpoint);
final HCRow aRow = aTable.addBodyRow();
final ISimpleURL aViewURL = createViewURL(aWPEC, aServiceInfo, aParams);
aRow.addCell(new HCA(aViewURL).addChild(aServiceGroup.getID()));
aRow.addCell(NiceNameUI.getDocumentTypeID(aDocTypeID, false));
aRow.addCell(NiceNameUI.getProcessID(aDocTypeID, aProcessID, false));
final String sTransportProfile = aEndpoint.getTransportProfile();
aRow.addCell(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_TRANSPORT_PROFILES, sTransportProfile)).addChild(NiceNameUI.getTransportProfile(sTransportProfile, false)));
final ISimpleURL aEditURL = createEditURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aCopyURL = createCopyURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aDeleteURL = createDeleteURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aPreviewURL = LinkHelper.getURLWithServerAndContext(aParticipantID.getURIPercentEncoded() + SMPRestFilter.PATH_SERVICES + aDocTypeID.getURIPercentEncoded());
aRow.addCell(new HCA(aViewURL).setTitle("View endpoint").addChild(EDefaultIcon.MAGNIFIER.getAsNode()), new HCTextNode(" "), new HCA(aEditURL).setTitle("Edit endpoint").addChild(EDefaultIcon.EDIT.getAsNode()), new HCTextNode(" "), new HCA(aCopyURL).setTitle("Copy endpoint").addChild(EDefaultIcon.COPY.getAsNode()), new HCTextNode(" "), new HCA(aDeleteURL).setTitle("Delete endpoint").addChild(EDefaultIcon.DELETE.getAsNode()), new HCTextNode(" "), new HCA(aPreviewURL).setTitle("Perform SMP query on endpoint").setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode()));
}
}
}
final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
aNodeList.addChild(aTable).addChild(aDataTables);
}
use of com.helger.html.hc.impl.HCNodeList in project phoss-smp by phax.
the class PageSecureEndpointTree method showListOfExistingObjects.
@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
aToolbar.addButton("Create new Endpoint", createCreateURL(aWPEC), EDefaultIcon.NEW);
aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
aToolbar.addButton("List view", aWPEC.getLinkToMenuItem(CMenuSecure.MENU_ENDPOINT_LIST), EDefaultIcon.MAGNIFIER);
aNodeList.addChild(aToolbar);
// Create list of service groups
final ICommonsMap<ISMPServiceGroup, ICommonsList<ISMPServiceInformation>> aMap = new CommonsHashMap<>();
aServiceInfoMgr.getAllSMPServiceInformation().forEach(x -> aMap.computeIfAbsent(x.getServiceGroup(), k -> new CommonsArrayList<>()).add(x));
final HCUL aULSG = new HCUL();
final ICommonsList<ISMPServiceGroup> aServiceGroups = aServiceGroupMgr.getAllSMPServiceGroups().getSortedInline(ISMPServiceGroup.comparator());
for (final ISMPServiceGroup aServiceGroup : aServiceGroups) {
// Print service group
final IParticipantIdentifier aParticipantID = aServiceGroup.getParticipantIdentifier();
final HCLI aLISG = aULSG.addAndReturnItem(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_SERVICE_GROUPS, aServiceGroup)).addChild(aParticipantID.getURIEncoded()));
final HCUL aULDT = new HCUL();
final ICommonsList<ISMPServiceInformation> aServiceInfos = aMap.get(aServiceGroup);
if (aServiceInfos != null) {
for (final ISMPServiceInformation aServiceInfo : aServiceInfos.getSortedInline(ISMPServiceInformation.comparator())) {
final HCUL aULP = new HCUL();
final IDocumentTypeIdentifier aDocTypeID = aServiceInfo.getDocumentTypeIdentifier();
final ICommonsList<ISMPProcess> aProcesses = aServiceInfo.getAllProcesses().getSortedInline(ISMPProcess.comparator());
for (final ISMPProcess aProcess : aProcesses) {
final BootstrapTable aEPTable = new BootstrapTable(HCCol.perc(40), HCCol.perc(40), HCCol.perc(20)).setBordered(true);
final ICommonsList<ISMPEndpoint> aEndpoints = aProcess.getAllEndpoints().getSortedInline(ISMPEndpoint.comparator());
for (final ISMPEndpoint aEndpoint : aEndpoints) {
final StringMap aParams = createParamMap(aServiceInfo, aProcess, aEndpoint);
final HCRow aBodyRow = aEPTable.addBodyRow();
final String sTransportProfile = aEndpoint.getTransportProfile();
final ISimpleURL aViewURL = createViewURL(aWPEC, aServiceInfo, aParams);
aBodyRow.addCell(new HCA(aViewURL).addChild(NiceNameUI.getTransportProfile(sTransportProfile, false)));
aBodyRow.addCell(aEndpoint.getEndpointReference());
final ISimpleURL aEditURL = createEditURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aCopyURL = createCopyURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aDeleteURL = createDeleteURL(aWPEC, aServiceInfo).addAll(aParams);
final ISimpleURL aPreviewURL = LinkHelper.getURLWithServerAndContext(aParticipantID.getURIPercentEncoded() + SMPRestFilter.PATH_SERVICES + aDocTypeID.getURIPercentEncoded());
aBodyRow.addAndReturnCell(new HCA(aViewURL).setTitle("View endpoint").addChild(EDefaultIcon.MAGNIFIER.getAsNode()), new HCTextNode(" "), new HCA(aEditURL).setTitle("Edit endpoint").addChild(EDefaultIcon.EDIT.getAsNode()), new HCTextNode(" "), new HCA(aCopyURL).setTitle("Copy endpoint").addChild(EDefaultIcon.COPY.getAsNode()), new HCTextNode(" "), new HCA(aDeleteURL).setTitle("Delete endpoint").addChild(EDefaultIcon.DELETE.getAsNode()), new HCTextNode(" "), new HCA(aPreviewURL).setTitle("Perform SMP query on endpoint").setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode())).addClass(CSS_CLASS_RIGHT);
}
// Show process + endpoints
final HCLI aLI = aULP.addItem();
final HCDiv aDiv = div(NiceNameUI.getProcessID(aDocTypeID, aProcess.getProcessIdentifier(), false));
aLI.addChild(aDiv);
if (aEndpoints.isEmpty()) {
aDiv.addChild(" ").addChild(new HCA(aWPEC.getSelfHref().addAll(createParamMap(aServiceInfo, aProcess, (ISMPEndpoint) null)).add(CPageParam.PARAM_ACTION, ACTION_DELETE_PROCESS)).setTitle("Delete process").addChild(EDefaultIcon.DELETE.getAsNode()));
} else
aLI.addChild(aEPTable);
}
// Show document types + children
final HCLI aLI = aULDT.addItem();
final HCDiv aDiv = div().addChild(NiceNameUI.getDocumentTypeID(aServiceInfo.getDocumentTypeIdentifier(), false)).addChild(" ").addChild(new HCA(LinkHelper.getURLWithServerAndContext(aParticipantID.getURIPercentEncoded() + SMPRestFilter.PATH_SERVICES + aDocTypeID.getURIPercentEncoded())).setTitle("Perform SMP query on document type ").setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode()));
aLI.addChild(aDiv);
if (aProcesses.isEmpty()) {
aDiv.addChild(" ").addChild(new HCA(aWPEC.getSelfHref().addAll(createParamMap(aServiceInfo, (ISMPProcess) null, (ISMPEndpoint) null)).add(CPageParam.PARAM_ACTION, ACTION_DELETE_DOCUMENT_TYPE)).setTitle("Delete document type").addChild(EDefaultIcon.DELETE.getAsNode()));
} else
aLI.addChild(aULP);
}
}
if (aServiceInfos == null || aServiceInfos.isEmpty() || aULDT.hasNoChildren())
aLISG.addChild(" ").addChild(badgeInfo("This service group has no assigned endpoints!"));
else
aLISG.addChild(aULDT);
}
aNodeList.addChild(aULSG);
}
Aggregations