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));
}
}
}
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);
}
Aggregations