diff --git a/phoss-smp-backend-mongodb/src/main/java/com/helger/phoss/smp/backend/mongodb/mgr/SMPServiceInformationManagerMongoDB.java b/phoss-smp-backend-mongodb/src/main/java/com/helger/phoss/smp/backend/mongodb/mgr/SMPServiceInformationManagerMongoDB.java index f3f3edda4..5ccef943c 100644 --- a/phoss-smp-backend-mongodb/src/main/java/com/helger/phoss/smp/backend/mongodb/mgr/SMPServiceInformationManagerMongoDB.java +++ b/phoss-smp-backend-mongodb/src/main/java/com/helger/phoss/smp/backend/mongodb/mgr/SMPServiceInformationManagerMongoDB.java @@ -432,10 +432,15 @@ public EChange deleteSMPProcess (@Nullable final ISMPServiceInformation aSMPServ public ICommonsList getAllSMPServiceInformation () { final ICommonsList ret = new CommonsArrayList <> (); - getCollection ().find ().forEach ((Consumer ) x -> ret.add (toServiceInformation (x, true))); + forEachSMPServiceInformation (ret::add); return ret; } + public void forEachSMPServiceInformation (@Nonnull final Consumer aConsumer) + { + getCollection ().find ().forEach (x -> aConsumer.accept (toServiceInformation (x, true))); + } + @Nonnegative public long getSMPServiceInformationCount () { @@ -461,8 +466,8 @@ public ICommonsList getAllSMPDocumentTypesOfServiceGro if (aServiceGroup != null) { getCollection ().find (new Document (BSON_SERVICE_GROUP_ID, aServiceGroup.getID ())) - .forEach ((Consumer ) x -> ret.add (toServiceInformation (x, - false).getDocumentTypeIdentifier ())); + .forEach ((Consumer ) x -> ret.add (toServiceInformation (x, false) + .getDocumentTypeIdentifier ())); } return ret; } @@ -499,8 +504,6 @@ public boolean containsAnyEndpointWithTransportProfile (@Nullable final String s // As simple as it can be return getCollection ().find (new Document (BSON_PROCESSES + "." + BSON_ENDPOINTS + "." + BSON_TRANSPORT_PROFILE, - sTransportProfileID)) - .iterator () - .hasNext (); + sTransportProfileID)).iterator ().hasNext (); } } diff --git a/phoss-smp-backend-sql/src/main/java/com/helger/phoss/smp/backend/sql/mgr/SMPServiceInformationManagerJDBC.java b/phoss-smp-backend-sql/src/main/java/com/helger/phoss/smp/backend/sql/mgr/SMPServiceInformationManagerJDBC.java index ab913acef..0d65197e0 100644 --- a/phoss-smp-backend-sql/src/main/java/com/helger/phoss/smp/backend/sql/mgr/SMPServiceInformationManagerJDBC.java +++ b/phoss-smp-backend-sql/src/main/java/com/helger/phoss/smp/backend/sql/mgr/SMPServiceInformationManagerJDBC.java @@ -17,6 +17,7 @@ package com.helger.phoss.smp.backend.sql.mgr; import java.util.Map; +import java.util.function.Consumer; import java.util.function.Supplier; import javax.annotation.Nonnegative; @@ -385,6 +386,12 @@ public EChange deleteSMPProcess (@Nullable final ISMPServiceInformation aSMPServ public ICommonsList getAllSMPServiceInformation () { final ICommonsList ret = new CommonsArrayList <> (); + forEachSMPServiceInformation (ret::add); + return ret; + } + + public void forEachSMPServiceInformation (@Nonnull final Consumer aConsumer) + { final ICommonsList aDBResult = newExecutor ().queryAll ("SELECT sm.businessIdentifierScheme, sm.businessIdentifier, sm.documentIdentifierScheme, sm.documentIdentifier, sm.extension," + " sp.processIdentifierType, sp.processIdentifier, sp.extension," + " se.transportProfile, se.endpointReference, se.requireBusinessLevelSignature, se.minimumAuthenticationLevel," + @@ -459,11 +466,9 @@ public ICommonsList getAllSMPServiceInformation () } final DocTypeAndExtension aDE = aEntry2.getKey (); - ret.add (new SMPServiceInformation (aServiceGroup, aDE.m_aDocTypeID, aProcesses, aDE.m_sExt)); + aConsumer.accept (new SMPServiceInformation (aServiceGroup, aDE.m_aDocTypeID, aProcesses, aDE.m_sExt)); } } - - return ret; } @Nonnegative diff --git a/phoss-smp-backend-xml/src/main/java/com/helger/phoss/smp/backend/xml/mgr/SMPServiceInformationManagerXML.java b/phoss-smp-backend-xml/src/main/java/com/helger/phoss/smp/backend/xml/mgr/SMPServiceInformationManagerXML.java index 27bd8747f..75c598acc 100644 --- a/phoss-smp-backend-xml/src/main/java/com/helger/phoss/smp/backend/xml/mgr/SMPServiceInformationManagerXML.java +++ b/phoss-smp-backend-xml/src/main/java/com/helger/phoss/smp/backend/xml/mgr/SMPServiceInformationManagerXML.java @@ -16,6 +16,8 @@ */ package com.helger.phoss.smp.backend.xml.mgr; +import java.util.function.Consumer; + import javax.annotation.Nonnegative; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -119,9 +121,7 @@ public ESuccess mergeSMPServiceInformation (@Nonnull final ISMPServiceInformatio if (bChangeExisting) { // Edit existing - m_aRWLock.writeLocked ( () -> { - internalUpdateItem (aOldInformation); - }); + m_aRWLock.writeLocked ( () -> { internalUpdateItem (aOldInformation); }); AuditHelper.onAuditModifySuccess (SMPServiceInformation.OT, "set-all", @@ -302,6 +302,11 @@ public ICommonsList getAllSMPServiceInformation () return getAll (); } + public void forEachSMPServiceInformation (@Nonnull final Consumer aConsumer) + { + forEachValue (aConsumer); + } + @Nonnegative public long getSMPServiceInformationCount () { diff --git a/phoss-smp-backend/src/main/java/com/helger/phoss/smp/ChangeSMPV8.java b/phoss-smp-backend/src/main/java/com/helger/phoss/smp/ChangeSMPV8.java new file mode 100644 index 000000000..ae4aac983 --- /dev/null +++ b/phoss-smp-backend/src/main/java/com/helger/phoss/smp/ChangeSMPV8.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2015-2024 Philip Helger (www.helger.com) + * philip[at]helger[dot]com + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.helger.phoss.smp; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Internal interface to act as a marker for future SMP V8 changes. + * + * @author Philip Helger + */ +@Retention (RetentionPolicy.SOURCE) +@Target ({ ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR }) +public @interface ChangeSMPV8 +{ + String value() default ""; +} diff --git a/phoss-smp-backend/src/main/java/com/helger/phoss/smp/domain/serviceinfo/ISMPServiceInformationManager.java b/phoss-smp-backend/src/main/java/com/helger/phoss/smp/domain/serviceinfo/ISMPServiceInformationManager.java index 7ab7b8c42..c03dacc96 100644 --- a/phoss-smp-backend/src/main/java/com/helger/phoss/smp/domain/serviceinfo/ISMPServiceInformationManager.java +++ b/phoss-smp-backend/src/main/java/com/helger/phoss/smp/domain/serviceinfo/ISMPServiceInformationManager.java @@ -10,6 +10,8 @@ */ package com.helger.phoss.smp.domain.serviceinfo; +import java.util.function.Consumer; + import javax.annotation.Nonnegative; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -23,6 +25,7 @@ import com.helger.peppol.smp.ISMPTransportProfile; import com.helger.peppolid.IDocumentTypeIdentifier; import com.helger.peppolid.IProcessIdentifier; +import com.helger.phoss.smp.ChangeSMPV8; import com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup; /** @@ -74,6 +77,7 @@ public interface ISMPServiceInformationManager * @see #getSMPServiceInformationOfServiceGroupAndDocumentType(ISMPServiceGroup, * IDocumentTypeIdentifier) */ + @ChangeSMPV8 ("Rename to findSMPServiceInformation") @Nullable ISMPServiceInformation findServiceInformation (@Nullable ISMPServiceGroup aServiceGroup, @Nullable IDocumentTypeIdentifier aDocTypeID, @@ -131,6 +135,16 @@ ISMPServiceInformation findServiceInformation (@Nullable ISMPServiceGroup aServi @ReturnsMutableCopy ICommonsList getAllSMPServiceInformation (); + /** + * Iterate each Service Information element and invoke the provided consumer + * for it. + * + * @param aConsumer + * The consumer to invoke. May not be null. + * @since 7.1.5 + */ + void forEachSMPServiceInformation (@Nonnull Consumer aConsumer); + /** * @return The count of all service information objects. Always ≥ 0. */ @@ -189,7 +203,7 @@ ISMPServiceInformation getSMPServiceInformationOfServiceGroupAndDocumentType (@N /** * Check if the passed transport profile is used or not. - * + * * @param sTransportProfileID * The transport profile ID to be checked. May be null. * @return true if at least one endpoint uses the provided diff --git a/phoss-smp-backend/src/test/java/com/helger/phoss/smp/mock/MockSMPServiceInformationManager.java b/phoss-smp-backend/src/test/java/com/helger/phoss/smp/mock/MockSMPServiceInformationManager.java index 8c64fd2e4..30c5f66a9 100644 --- a/phoss-smp-backend/src/test/java/com/helger/phoss/smp/mock/MockSMPServiceInformationManager.java +++ b/phoss-smp-backend/src/test/java/com/helger/phoss/smp/mock/MockSMPServiceInformationManager.java @@ -10,6 +10,8 @@ */ package com.helger.phoss.smp.mock; +import java.util.function.Consumer; + import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -66,6 +68,11 @@ public ICommonsList getAllSMPServiceInformationOfServic throw new UnsupportedOperationException (); } + public void forEachSMPServiceInformation (@Nonnull final Consumer aConsumer) + { + throw new UnsupportedOperationException (); + } + @Nonnull public ICommonsList getAllSMPServiceInformation () { diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointChangeCertificate.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointChangeCertificate.java index 04817b986..4c5e4c367 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointChangeCertificate.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointChangeCertificate.java @@ -37,6 +37,7 @@ import com.helger.commons.collection.impl.ICommonsSortedSet; import com.helger.commons.compare.ESortOrder; import com.helger.commons.datetime.PDTFactory; +import com.helger.commons.mutable.MutableInt; import com.helger.commons.state.EValidity; import com.helger.commons.state.IValidityIndicator; import com.helger.commons.string.StringHelper; @@ -59,7 +60,6 @@ import com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager; import com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint; import com.helger.phoss.smp.domain.serviceinfo.ISMPProcess; -import com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation; import com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager; import com.helger.phoss.smp.domain.serviceinfo.SMPEndpoint; import com.helger.phoss.smp.ui.AbstractSMPWebPage; @@ -97,19 +97,16 @@ private static final class BulkChangeCertificate extends AbstractLongRunningJobR { private static final AtomicInteger RUNNING_JOBS = new AtomicInteger (0); - private final ICommonsList m_aAllSIs; private final Locale m_aDisplayLocale; private final String m_sOldUnifiedCert; private final String m_sNewCert; - public BulkChangeCertificate (@Nonnull final ICommonsList aAllSIs, - @Nonnull final Locale aDisplayLocale, + public BulkChangeCertificate (@Nonnull final Locale aDisplayLocale, @Nonnull final String sOldUnifiedCert, @Nonnull final String sNewCert) { super ("BulkChangeCertificate", new ReadOnlyMultilingualText (CSMPServer.DEFAULT_LOCALE, "Bulk change certificate")); - m_aAllSIs = aAllSIs; m_aDisplayLocale = aDisplayLocale; m_sOldUnifiedCert = sOldUnifiedCert; m_sNewCert = sNewCert; @@ -124,11 +121,10 @@ public LongRunningJobResult createLongRunningJobResult () final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr (); // Modify all endpoints - int nChangedEndpoints = 0; - int nSaveErrors = 0; + final MutableInt aChangedEndpoints = new MutableInt (0); + final MutableInt aSaveErrors = new MutableInt (0); final ICommonsSortedSet aChangedServiceGroup = new CommonsTreeSet <> (); - for (final ISMPServiceInformation aSI : m_aAllSIs) - { + aServiceInfoMgr.forEachSMPServiceInformation (aSI -> { boolean bChanged = false; for (final ISMPProcess aProcess : aSI.getAllProcesses ()) for (final ISMPEndpoint aEndpoint : aProcess.getAllEndpoints ()) @@ -136,31 +132,31 @@ public LongRunningJobResult createLongRunningJobResult () { bChanged = true; ((SMPEndpoint) aEndpoint).setCertificate (m_sNewCert); - ++nChangedEndpoints; + aChangedEndpoints.inc (); } if (bChanged) { if (aServiceInfoMgr.mergeSMPServiceInformation (aSI).isFailure ()) - nSaveErrors++; + aSaveErrors.inc (); aChangedServiceGroup.add (aSI.getServiceGroupID ()); } - } + }); final IHCNode aRes; - if (nChangedEndpoints > 0) + if (aChangedEndpoints.isGT0 ()) { final HCUL aUL = new HCUL (); for (final String sChangedServiceGroupID : aChangedServiceGroup) aUL.addItem (sChangedServiceGroupID); final HCNodeList aNodes = new HCNodeList ().addChildren (div ("The old certificate was changed in " + - nChangedEndpoints + + aChangedEndpoints.intValue () + " endpoints to the new certificate:"), _getCertificateDisplay (m_sNewCert, m_aDisplayLocale), div ("Effected service groups are:"), aUL); - if (nSaveErrors == 0) + if (aSaveErrors.is0 ()) aRes = success (aNodes); else { @@ -288,10 +284,8 @@ protected void fillContent (@Nonnull final WebPageExecutionContext aWPEC) final ICommonsMap > aEndpointsGroupedPerURL = new CommonsHashMap <> (); final ICommonsMap > aServiceGroupsGroupedPerURL = new CommonsHashMap <> (); - final ICommonsList aAllSIs = aServiceInfoMgr.getAllSMPServiceInformation (); - int nTotalEndpointCount = 0; - for (final ISMPServiceInformation aSI : aAllSIs) - { + final MutableInt aTotalEndpointCount = new MutableInt (0); + aServiceInfoMgr.forEachSMPServiceInformation (aSI -> { final ISMPServiceGroup aSG = aSI.getServiceGroup (); for (final ISMPProcess aProcess : aSI.getAllProcesses ()) for (final ISMPEndpoint aEndpoint : aProcess.getAllEndpoints ()) @@ -300,9 +294,9 @@ protected void fillContent (@Nonnull final WebPageExecutionContext aWPEC) aEndpointsGroupedPerURL.computeIfAbsent (sUnifiedCertificate, k -> new CommonsArrayList <> ()) .add (aEndpoint); aServiceGroupsGroupedPerURL.computeIfAbsent (sUnifiedCertificate, k -> new CommonsHashSet <> ()).add (aSG); - ++nTotalEndpointCount; + aTotalEndpointCount.inc (); } - } + }); { final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar (aWPEC); @@ -356,7 +350,7 @@ protected void fillContent (@Nonnull final WebPageExecutionContext aWPEC) { PhotonWorkerPool.getInstance () .run ("BulkChangeCertificate", - new BulkChangeCertificate (aAllSIs, aDisplayLocale, sOldUnifiedCert, sNewCert)); + new BulkChangeCertificate (aDisplayLocale, sOldUnifiedCert, sNewCert)); aWPEC.postRedirectGetInternal (success ().addChildren (div ("The bulk change of the endpoint certificate to"), _getCertificateDisplay (sNewUnifiedCert, @@ -404,9 +398,9 @@ protected void fillContent (@Nonnull final WebPageExecutionContext aWPEC) { aNodeList.addChild (info ().addChildren (div ("This page lets you change the certificates of multiple endpoints at once. This is e.g. helpful when the old certificate expired."), div ("Currently " + - (nTotalEndpointCount == 1 ? "1 endpoint is" - : nTotalEndpointCount + - " endpoints are") + + (aTotalEndpointCount.intValue () == 1 ? "1 endpoint is" + : aTotalEndpointCount.intValue () + + " endpoints are") + " registered."))); final HCTable aTable = new HCTable (new DTCol ("Certificate").setInitialSorting (ESortOrder.ASCENDING), diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointChangeURL.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointChangeURL.java index ed09d39ce..fc6523f04 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointChangeURL.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointChangeURL.java @@ -21,6 +21,7 @@ import javax.annotation.Nonnegative; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import com.helger.commons.annotation.Nonempty; import com.helger.commons.collection.CollectionHelper; @@ -33,6 +34,7 @@ import com.helger.commons.collection.impl.ICommonsSet; import com.helger.commons.collection.impl.ICommonsSortedSet; import com.helger.commons.compare.ESortOrder; +import com.helger.commons.mutable.MutableInt; import com.helger.commons.state.EValidity; import com.helger.commons.state.IValidityIndicator; import com.helger.commons.string.StringHelper; @@ -56,7 +58,6 @@ import com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager; import com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint; import com.helger.phoss.smp.domain.serviceinfo.ISMPProcess; -import com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation; import com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager; import com.helger.phoss.smp.domain.serviceinfo.SMPEndpoint; import com.helger.phoss.smp.ui.AbstractSMPWebPage; @@ -92,18 +93,16 @@ private static final class BulkChangeEndpointURL extends AbstractLongRunningJobR { private static final AtomicInteger RUNNING_JOBS = new AtomicInteger (0); - private final ICommonsList m_aAllSIs; private final ISMPServiceGroup m_aServiceGroup; private final String m_sOldURL; private final String m_sNewURL; - public BulkChangeEndpointURL (final ICommonsList aAllSIs, - final ISMPServiceGroup aServiceGroup, - final String sOldURL, - final String sNewURL) + public BulkChangeEndpointURL (@Nullable final ISMPServiceGroup aServiceGroup, + @Nonnull @Nonempty final String sOldURL, + @Nonnull @Nonempty final String sNewURL) { - super ("BulkChangeEndpointURL", new ReadOnlyMultilingualText (CSMPServer.DEFAULT_LOCALE, "Bulk change endpoint URL")); - m_aAllSIs = aAllSIs; + super ("BulkChangeEndpointURL", + new ReadOnlyMultilingualText (CSMPServer.DEFAULT_LOCALE, "Bulk change endpoint URL")); m_aServiceGroup = aServiceGroup; m_sOldURL = sOldURL; m_sNewURL = sNewURL; @@ -118,15 +117,14 @@ public LongRunningJobResult createLongRunningJobResult () final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr (); // Modify all endpoints - int nChangedEndpoints = 0; - int nSaveErrors = 0; + final MutableInt aChangedEndpoints = new MutableInt (0); + final MutableInt aSaveErrors = new MutableInt (0); final ICommonsSortedSet aChangedServiceGroup = new CommonsTreeSet <> (); - for (final ISMPServiceInformation aSI : m_aAllSIs) - { + aServiceInfoMgr.forEachSMPServiceInformation (aSI -> { if (m_aServiceGroup != null && !aSI.getServiceGroup ().equals (m_aServiceGroup)) { // Wrong service group - continue; + return; } boolean bChanged = false; @@ -136,18 +134,18 @@ public LongRunningJobResult createLongRunningJobResult () { ((SMPEndpoint) aEndpoint).setEndpointReference (m_sNewURL); bChanged = true; - ++nChangedEndpoints; + aChangedEndpoints.inc (); } if (bChanged) { if (aServiceInfoMgr.mergeSMPServiceInformation (aSI).isFailure ()) - nSaveErrors++; + aSaveErrors.inc (); aChangedServiceGroup.add (aSI.getServiceGroupID ()); } - } + }); final IHCNode aRes; - if (nChangedEndpoints > 0) + if (aChangedEndpoints.isGT0 ()) { final HCUL aUL = new HCUL (); for (final String sChangedServiceGroupID : aChangedServiceGroup) @@ -156,10 +154,10 @@ public LongRunningJobResult createLongRunningJobResult () final HCNodeList aNodes = new HCNodeList ().addChildren (div ("The old URL '" + m_sOldURL + "' was changed in " + - nChangedEndpoints + + aChangedEndpoints.intValue () + " endpoints. Effected service groups are:"), aUL); - if (nSaveErrors == 0) + if (aSaveErrors.is0 ()) aRes = success (aNodes); else { @@ -205,7 +203,8 @@ protected IValidityIndicator isValidToDisplayPage (@Nonnull final WebPageExecuti { aNodeList.addChild (warn ("No service group is present! At least one service group must be present to change endpoints.")); aNodeList.addChild (new BootstrapButton ().addChild ("Create new service group") - .setOnClick (AbstractWebPageForm.createCreateURL (aWPEC, CMenuSecure.MENU_SERVICE_GROUPS)) + .setOnClick (AbstractWebPageForm.createCreateURL (aWPEC, + CMenuSecure.MENU_SERVICE_GROUPS)) .setIcon (EDefaultIcon.YES)); return EValidity.INVALID; } @@ -224,24 +223,24 @@ protected void fillContent (@Nonnull final WebPageExecutionContext aWPEC) final ICommonsMap > aEndpointsGroupedPerURL = new CommonsHashMap <> (); final ICommonsMap > aServiceGroupsGroupedPerURL = new CommonsHashMap <> (); - final ICommonsList aAllSIs = aServiceInfoMgr.getAllSMPServiceInformation (); - int nTotalEndpointCount = 0; - int nTotalEndpointCountWithURL = 0; - for (final ISMPServiceInformation aSI : aAllSIs) - { + final MutableInt aTotalEndpointCount = new MutableInt (0); + final MutableInt aTotalEndpointCountWithURL = new MutableInt (0); + aServiceInfoMgr.forEachSMPServiceInformation (aSI -> { final ISMPServiceGroup aSG = aSI.getServiceGroup (); for (final ISMPProcess aProcess : aSI.getAllProcesses ()) for (final ISMPEndpoint aEndpoint : aProcess.getAllEndpoints ()) { - ++nTotalEndpointCount; + aTotalEndpointCount.inc (); if (aEndpoint.hasEndpointReference ()) { - aEndpointsGroupedPerURL.computeIfAbsent (aEndpoint.getEndpointReference (), k -> new CommonsArrayList <> ()).add (aEndpoint); - aServiceGroupsGroupedPerURL.computeIfAbsent (aEndpoint.getEndpointReference (), k -> new CommonsHashSet <> ()).add (aSG); - ++nTotalEndpointCountWithURL; + aEndpointsGroupedPerURL.computeIfAbsent (aEndpoint.getEndpointReference (), k -> new CommonsArrayList <> ()) + .add (aEndpoint); + aServiceGroupsGroupedPerURL.computeIfAbsent (aEndpoint.getEndpointReference (), + k -> new CommonsHashSet <> ()).add (aSG); + aTotalEndpointCountWithURL.inc (); } } - } + }); { final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar (aWPEC); @@ -267,12 +266,12 @@ protected void fillContent (@Nonnull final WebPageExecutionContext aWPEC) { // Find selected service group (if any) final String sServiceGroupID = aWPEC.params ().getAsString (FIELD_SERVICE_GROUP); - ISMPServiceGroup aServiceGroup = null; + ISMPServiceGroup aSelectedServiceGroup = null; if (StringHelper.hasText (sServiceGroupID)) { final IParticipantIdentifier aParticipantID = aIdentifierFactory.parseParticipantIdentifier (sServiceGroupID); if (aParticipantID != null) - aServiceGroup = aServiceGroupMgr.getSMPServiceGroupOfID (aParticipantID); + aSelectedServiceGroup = aServiceGroupMgr.getSMPServiceGroupOfID (aParticipantID); } final String sNewURL = aWPEC.params ().getAsString (FIELD_NEW_URL); @@ -296,7 +295,8 @@ protected void fillContent (@Nonnull final WebPageExecutionContext aWPEC) if (aFormErrors.isEmpty ()) { PhotonWorkerPool.getInstance () - .run ("BulkChangeEndpointURL", new BulkChangeEndpointURL (aAllSIs, aServiceGroup, sOldURL, sNewURL)); + .run ("BulkChangeEndpointURL", + new BulkChangeEndpointURL (aSelectedServiceGroup, sOldURL, sNewURL)); aWPEC.postRedirectGetInternal (success ("The bulk change of the endpoint URL from '" + sOldURL + @@ -365,16 +365,20 @@ protected void fillContent (@Nonnull final WebPageExecutionContext aWPEC) { 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") + + (aTotalEndpointCount.intValue () == 1 ? "1 endpoint is" + : aTotalEndpointCount.intValue () + + " endpoints are") + " registered" + - (nTotalEndpointCountWithURL < nTotalEndpointCount ? " of which " + - nTotalEndpointCountWithURL + - " have an endpoint reference" - : "") + + (aTotalEndpointCountWithURL.intValue () < + aTotalEndpointCount.intValue () ? " of which " + + aTotalEndpointCountWithURL.intValue () + + " 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 ("Service Group Count").setDisplayType (EDTColType.INT, + aDisplayLocale), new DTCol ("Endpoint Count").setDisplayType (EDTColType.INT, aDisplayLocale), new BootstrapDTColAction (aDisplayLocale)).setID (getID ()); aEndpointsGroupedPerURL.forEach ( (sURL, aEndpoints) -> { @@ -386,8 +390,11 @@ protected void fillContent (@Nonnull final WebPageExecutionContext aWPEC) 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 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); diff --git a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointTree.java b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointTree.java index dd2f2814e..24b3f326c 100644 --- a/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointTree.java +++ b/phoss-smp-webapp/src/main/java/com/helger/phoss/smp/ui/secure/PageSecureEndpointTree.java @@ -80,8 +80,8 @@ protected void showListOfExistingObjects (@Nonnull final WebPageExecutionContext // Create list of service groups final ICommonsMap > aMap = new CommonsHashMap <> (); - aServiceInfoMgr.getAllSMPServiceInformation () - .forEach (x -> aMap.computeIfAbsent (x.getServiceGroup (), k -> new CommonsArrayList <> ()).add (x)); + aServiceInfoMgr.forEachSMPServiceInformation (x -> aMap.computeIfAbsent (x.getServiceGroup (), + k -> new CommonsArrayList <> ()).add (x)); final HCUL aULSG = new HCUL (); final ICommonsList aServiceGroups = aServiceGroupMgr.getAllSMPServiceGroups () @@ -107,9 +107,8 @@ protected void showListOfExistingObjects (@Nonnull final WebPageExecutionContext .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 BootstrapTable aEPTable = new BootstrapTable (HCCol.perc (40), HCCol.perc (40), HCCol.perc (20)) + .setBordered (true); final ICommonsList aEndpoints = aProcess.getAllEndpoints () .getSortedInline (ISMPEndpoint.comparator ()); for (final ISMPEndpoint aEndpoint : aEndpoints) @@ -158,8 +157,8 @@ protected void showListOfExistingObjects (@Nonnull final WebPageExecutionContext aDiv.addChild (" ") .addChild (new HCA (aWPEC.getSelfHref () .addAll (createParamMap (aServiceInfo, aProcess, (ISMPEndpoint) null)) - .add (CPageParam.PARAM_ACTION, ACTION_DELETE_PROCESS)) - .setTitle ("Delete process") + .add (CPageParam.PARAM_ACTION, ACTION_DELETE_PROCESS)).setTitle ( + "Delete process") .addChild (EDefaultIcon.DELETE.getAsNode ())); } else @@ -184,8 +183,8 @@ protected void showListOfExistingObjects (@Nonnull final WebPageExecutionContext .addAll (createParamMap (aServiceInfo, (ISMPProcess) null, (ISMPEndpoint) null)) - .add (CPageParam.PARAM_ACTION, ACTION_DELETE_DOCUMENT_TYPE)) - .setTitle ("Delete document type") + .add (CPageParam.PARAM_ACTION, ACTION_DELETE_DOCUMENT_TYPE)).setTitle ( + "Delete document type") .addChild (EDefaultIcon.DELETE.getAsNode ())); } else