Search in sources :

Example 11 with ISimpleURL

use of com.helger.commons.url.ISimpleURL in project phoss-smp by phax.

the class PageSecureServiceGroupMigrationOutbound method _createTable.

@Nonnull
private IHCNode _createTable(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final ICommonsIterable<ISMPParticipantMigration> aMigs, @Nonnull final EParticipantMigrationState eState) {
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final HCTable aTable = new HCTable(new DTCol("ID").setVisible(false), new DTCol("Participant ID").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Initiation").setDisplayType(EDTColType.DATETIME, aDisplayLocale), new DTCol("Migration Key"), new BootstrapDTColAction(aDisplayLocale)).setID(getID() + eState.getID());
    for (final ISMPParticipantMigration aCurObject : aMigs) {
        final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
        final String sParticipantID = aCurObject.getParticipantIdentifier().getURIEncoded();
        final HCRow aRow = aTable.addBodyRow();
        aRow.addCell(aCurObject.getID());
        aRow.addCell(a(aViewLink).addChild(sParticipantID));
        aRow.addCell(PDTToString.getAsString(aCurObject.getInitiationDateTime(), aDisplayLocale));
        aRow.addCell(code(aCurObject.getMigrationKey()));
        final IHCCell<?> aActionCell = aRow.addCell();
        aActionCell.addChild(eState.isInProgress() ? new HCA(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_FINALIZE_MIGRATION).add(CPageParam.PARAM_OBJECT, aCurObject.getID())).setTitle("Finalize Participant Migration of '" + sParticipantID + "'").addChild(EDefaultIcon.YES.getAsNode()) : createEmptyAction());
        aActionCell.addChild(" ");
        aActionCell.addChild(eState.isInProgress() ? new HCA(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_CANCEL_MIGRATION).add(CPageParam.PARAM_OBJECT, aCurObject.getID())).setTitle("Cancel Participant Migration of '" + sParticipantID + "'").addChild(EDefaultIcon.NO.getAsNode()) : createEmptyAction());
        aActionCell.addChild(" ");
        aActionCell.addChild(createDeleteLink(aWPEC, aCurObject, "Delete Participant Migration of '" + sParticipantID + "'"));
    }
    final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
    return new HCNodeList().addChild(aTable).addChild(aDataTables);
}
Also used : Locale(java.util.Locale) HCTable(com.helger.html.hc.html.tabular.HCTable) ISMPParticipantMigration(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration) HCNodeList(com.helger.html.hc.impl.HCNodeList) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISimpleURL(com.helger.commons.url.ISimpleURL) HCA(com.helger.html.hc.html.textlevel.HCA) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) HCRow(com.helger.html.hc.html.tabular.HCRow) PDTToString(com.helger.commons.datetime.PDTToString) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables) DataTables(com.helger.photon.uictrls.datatables.DataTables) Nonnull(javax.annotation.Nonnull)

Example 12 with ISimpleURL

use of com.helger.commons.url.ISimpleURL in project phoss-smp by phax.

the class SMPRendererSecure method _getNavbar.

@Nonnull
private static IHCNode _getNavbar(@Nonnull final ILayoutExecutionContext aLEC) {
    final Locale aDisplayLocale = aLEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
    final ISimpleURL aLinkToStartPage = aLEC.getLinkToMenuItem(aLEC.getMenuTree().getDefaultMenuItemID());
    final BootstrapNavbar aNavbar = new BootstrapNavbar();
    aNavbar.addBrand(SMPRendererPublic.createLogo(aLEC), aLinkToStartPage);
    aNavbar.addBrand(new HCSpan().addChild(CSMP.getApplicationSuffix() + " Administration"), aLinkToStartPage);
    aNavbar.addAndReturnText().addChild(" [" + SMPServerConfiguration.getSMLSMPID() + "]");
    final BootstrapNavbarToggleable aToggleable = aNavbar.addAndReturnToggleable();
    {
        aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MR_2).setOnClick(LinkHelper.getURLWithContext(AbstractPublicApplicationServlet.SERVLET_DEFAULT_PATH + "/")).addChild("Goto public view"));
        final IUser aUser = aLEC.getLoggedInUser();
        aToggleable.addAndReturnText().addClass(CBootstrapCSS.MX_2).addChild("Logged in as ").addChild(new HCStrong().addChild(SecurityHelper.getUserDisplayName(aUser, aDisplayLocale)));
        aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.MX_2).setOnClick(LinkHelper.getURLWithContext(aRequestScope, LogoutServlet.SERVLET_DEFAULT_PATH)).addChild(EPhotonCoreText.LOGIN_LOGOUT.getDisplayText(aDisplayLocale)));
    }
    return aNavbar;
}
Also used : Locale(java.util.Locale) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCSpan(com.helger.html.hc.html.textlevel.HCSpan) HCStrong(com.helger.html.hc.html.textlevel.HCStrong) BootstrapNavbar(com.helger.photon.bootstrap4.navbar.BootstrapNavbar) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapNavbarToggleable(com.helger.photon.bootstrap4.navbar.BootstrapNavbarToggleable) IUser(com.helger.photon.security.user.IUser) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) Nonnull(javax.annotation.Nonnull)

Example 13 with ISimpleURL

use of com.helger.commons.url.ISimpleURL in project ph-web by phax.

the class RequestHelperTest method testGetWithoutSessionID.

@Test
public void testGetWithoutSessionID() {
    final String sURL = "http://127.0.0.1:8080/erb/;jsessionid=1n3dlmrbng6ieckg4lahc7kpf?p=einvoice_precond_usp#top";
    final ISimpleURL aBaseURL = new SimpleURL(sURL);
    // Just a sanity check that parsing works :)
    assertEquals(sURL, aBaseURL.getAsStringWithEncodedParameters());
    final ISimpleURL aStrippedURL = RequestHelper.getWithoutSessionID(aBaseURL);
    assertEquals("http://127.0.0.1:8080/erb/?p=einvoice_precond_usp#top", aStrippedURL.getAsStringWithEncodedParameters());
}
Also used : ISimpleURL(com.helger.commons.url.ISimpleURL) SimpleURL(com.helger.commons.url.SimpleURL) ISimpleURL(com.helger.commons.url.ISimpleURL) Test(org.junit.Test)

Example 14 with ISimpleURL

use of com.helger.commons.url.ISimpleURL in project phoss-directory by phax.

the class PageSecureParticipantList method fillContent.

@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
    if (aWPEC.hasAction(CPageParam.ACTION_DELETE)) {
        final String sParticipantID = aRequestScope.params().getAsString(FIELD_PARTICIPANT_ID);
        final IIdentifierFactory aIdentifierFactory = PDMetaManager.getIdentifierFactory();
        final IParticipantIdentifier aParticipantID = aIdentifierFactory.parseParticipantIdentifier(sParticipantID);
        if (aParticipantID != null) {
            boolean bSuccess = false;
            try {
                bSuccess = PDMetaManager.getStorageMgr().deleteEntry(aParticipantID, null, false) > 0;
            } catch (final IOException ex) {
            // ignore
            }
            if (bSuccess)
                aNodeList.addChild(info("The participant ID '" + aParticipantID.getURIEncoded() + "' was deleted"));
            else
                aNodeList.addChild(error("Error deleting participant ID '" + aParticipantID.getURIEncoded() + "'"));
        }
    }
    final ICommonsSortedMap<IParticipantIdentifier, MutableInt> aAllIDs = PDMetaManager.getStorageMgr().getAllContainedParticipantIDs(EQueryMode.NON_DELETED_ONLY);
    aNodeList.addChild(h3(aAllIDs.size() + " participants (=Business Cards) are contained"));
    int nMaxEntries;
    if (aWPEC.params().containsKey(PARAM_SHOW_ALL))
        nMaxEntries = Integer.MAX_VALUE;
    else {
        nMaxEntries = aWPEC.params().getAsInt(PARAM_MAX_ENTRIES, -1);
        if (nMaxEntries <= 0) {
            // Avoid negative entry count
            nMaxEntries = 500;
        }
        if (aAllIDs.size() > nMaxEntries) {
            aNodeList.addChild(info("Showing only the first " + nMaxEntries + " participant(s), to avoid too much load on the server. Use the parameter '" + PARAM_SHOW_ALL + "' to show all participants, or '" + PARAM_MAX_ENTRIES + "' to specify a maximum number of entries."));
        }
    }
    final HCTable aTable = new HCTable(new DTCol("ID").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Entities").setDisplayType(EDTColType.INT, aDisplayLocale), new BootstrapDTColAction()).setID(getID());
    for (final Map.Entry<IParticipantIdentifier, MutableInt> aEntry : aAllIDs.entrySet()) {
        final String sParticipantID = aEntry.getKey().getURIEncoded();
        final HCRow aRow = aTable.addBodyRow();
        aRow.addCell(sParticipantID);
        aRow.addCell(Integer.toString(aEntry.getValue().intValue()));
        final IHCCell<?> aActionCell = aRow.addCell();
        final ISimpleURL aShowDetails = aWPEC.getLinkToMenuItem(CApplicationID.APP_ID_PUBLIC, CMenuPublic.MENU_SEARCH_SIMPLE).add(PagePublicSearchSimple.FIELD_QUERY, sParticipantID).add(CPageParam.PARAM_ACTION, CPageParam.ACTION_VIEW).add(PagePublicSearchSimple.FIELD_PARTICIPANT_ID, sParticipantID);
        aActionCell.addChild(new HCA(aShowDetails).addChild("Search"));
        aActionCell.addChild(" ");
        final ISimpleURL aReIndex = aWPEC.getLinkToMenuItem(CMenuSecure.MENU_INDEX_MANUALLY).add(PageSecureIndexManually.FIELD_PARTICIPANT_ID, sParticipantID).add(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM);
        aActionCell.addChild(new HCA(aReIndex).addChild("Reindex"));
        aActionCell.addChild(" ");
        final ISimpleURL aDelete = aWPEC.getSelfHref().add(FIELD_PARTICIPANT_ID, sParticipantID).add(CPageParam.PARAM_ACTION, CPageParam.ACTION_DELETE);
        aActionCell.addChild(new HCA(aDelete).addChild("Delete"));
        if (aTable.getBodyRowCount() >= nMaxEntries) {
            LOGGER.info("Stopping rendering after " + nMaxEntries + " entries");
            break;
        }
    }
    aNodeList.addChild(aTable).addChild(BootstrapDataTables.createDefaultDataTables(aWPEC, aTable));
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) IOException(java.io.IOException) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCTable(com.helger.html.hc.html.tabular.HCTable) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) MutableInt(com.helger.commons.mutable.MutableInt) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) Map(java.util.Map) ICommonsSortedMap(com.helger.commons.collection.impl.ICommonsSortedMap) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 15 with ISimpleURL

use of com.helger.commons.url.ISimpleURL in project phoss-directory by phax.

the class AbstractPageSecureReIndex method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    // Add toolbar
    {
        final BootstrapButtonToolbar aToolbar = aNodeList.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
        aToolbar.addChild(new BootstrapButton().addChild("Refresh").setIcon(EDefaultIcon.REFRESH).setOnClick(aWPEC.getSelfHref()));
        aToolbar.addChild(new BootstrapButton().addChild("Delete all entries").setIcon(EDefaultIcon.DELETE).setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_DELETE_ALL)));
        aToolbar.addChild(span("Current server time: " + PDTToString.getAsString(PDTFactory.getCurrentLocalTime(), aDisplayLocale)).addClass(PDCommonUI.CSS_CLASS_VERTICAL_PADDED_TEXT));
    }
    final HCTable aTable = new HCTable(new DTCol("Reg date").setDisplayType(EDTColType.DATETIME, aDisplayLocale).setInitialSorting(ESortOrder.DESCENDING), new DTCol("Participant"), new DTCol("Action"), new DTCol("Retries").setDisplayType(EDTColType.INT, aDisplayLocale), m_bDeadIndex ? null : new DTCol("Next retry").setDisplayType(EDTColType.DATETIME, aDisplayLocale), new DTCol("Last retry").setDisplayType(EDTColType.DATETIME, aDisplayLocale), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
    for (final IReIndexWorkItem aItem : getReIndexWorkItemList().getAllItems()) {
        final ISimpleURL aViewLink = createViewURL(aWPEC, aItem);
        final IIndexerWorkItem aWorkItem = aItem.getWorkItem();
        final HCRow aRow = aTable.addBodyRow();
        aRow.addCell(new HCA(aViewLink).addChild(PDTToString.getAsString(aWorkItem.getCreationDateTime(), aDisplayLocale)));
        aRow.addCell(aWorkItem.getParticipantID().getURIEncoded());
        aRow.addCell(aWorkItem.getType().getDisplayName());
        aRow.addCell(Integer.toString(aItem.getRetryCount()));
        if (!m_bDeadIndex)
            aRow.addCell(PDTToString.getAsString(aItem.getNextRetryDT(), aDisplayLocale));
        aRow.addCell(PDTToString.getAsString(aItem.getMaxRetryDT(), aDisplayLocale));
        final IHCCell<?> aActionCell = aRow.addCell();
        if (m_bDeadIndex) {
            aActionCell.addChild(new HCA(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_REINDEX_NOW).add(CPageParam.PARAM_OBJECT, aItem.getID())).setTitle("Re-index the entry now").addChild(EDefaultIcon.NEXT.getAsNode()));
            aActionCell.addChild(" ");
        }
        aActionCell.addChild(createDeleteLink(aWPEC, aItem));
    }
    aNodeList.addChild(aTable);
    aNodeList.addChild(BootstrapDataTables.createDefaultDataTables(aWPEC, aTable));
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) IReIndexWorkItem(com.helger.pd.indexer.reindex.IReIndexWorkItem) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) HCTable(com.helger.html.hc.html.tabular.HCTable) IIndexerWorkItem(com.helger.pd.indexer.index.IIndexerWorkItem) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)

Aggregations

ISimpleURL (com.helger.commons.url.ISimpleURL)20 HCNodeList (com.helger.html.hc.impl.HCNodeList)15 Locale (java.util.Locale)15 HCRow (com.helger.html.hc.html.tabular.HCRow)14 HCA (com.helger.html.hc.html.textlevel.HCA)14 HCTable (com.helger.html.hc.html.tabular.HCTable)13 BootstrapDTColAction (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction)13 DTCol (com.helger.photon.uictrls.datatables.column.DTCol)13 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)11 BootstrapDataTables (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)11 DataTables (com.helger.photon.uictrls.datatables.DataTables)11 HCTextNode (com.helger.html.hc.impl.HCTextNode)7 Nonnull (javax.annotation.Nonnull)6 HCSpan (com.helger.html.hc.html.textlevel.HCSpan)5 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)5 ISMPServiceInformation (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation)5 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)5 PDTToString (com.helger.commons.datetime.PDTToString)4 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)4 ISMPEndpoint (com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint)4