Search in sources :

Example 1 with EPredefinedParticipantIdentifierScheme

use of com.helger.peppolid.peppol.pidscheme.EPredefinedParticipantIdentifierScheme in project peppol-commons by phax.

the class EPredefinedParticipantIdentifierSchemeTest method testAll.

@SuppressWarnings("deprecation")
@Test
public void testAll() {
    for (final EPredefinedParticipantIdentifierScheme e : EPredefinedParticipantIdentifierScheme.values()) {
        assertTrue(StringHelper.hasText(e.getSchemeID()));
        // May be null but not empty
        final String sAgency = e.getSchemeAgency();
        if (sAgency != null)
            assertTrue(StringHelper.hasText(sAgency));
        assertTrue(StringHelper.hasText(e.getISO6523Code()));
        assertSame(e, EPredefinedParticipantIdentifierScheme.valueOf(e.name()));
        assertTrue(e.createIdentifierValue("abc").endsWith(":abc"));
        assertTrue(e.createParticipantIdentifier("def").getURIEncoded().endsWith(":def"));
        assertNotNull(e.getSince());
        assertNotNull(e.getInitialRelease());
    }
}
Also used : EPredefinedParticipantIdentifierScheme(com.helger.peppolid.peppol.pidscheme.EPredefinedParticipantIdentifierScheme) Test(org.junit.Test)

Example 2 with EPredefinedParticipantIdentifierScheme

use of com.helger.peppolid.peppol.pidscheme.EPredefinedParticipantIdentifierScheme 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));
        }
    }
}
Also used : TestEndpoint(com.helger.peppol.testendpoint.TestEndpoint) ISMLConfigurationManager(com.helger.peppol.app.mgr.ISMLConfigurationManager) ESMPTransportProfile(com.helger.peppol.smp.ESMPTransportProfile) TestEndpointManager(com.helger.peppol.testendpoint.TestEndpointManager) ISMLConfiguration(com.helger.peppol.domain.ISMLConfiguration) EPredefinedParticipantIdentifierScheme(com.helger.peppolid.peppol.pidscheme.EPredefinedParticipantIdentifierScheme)

Aggregations

EPredefinedParticipantIdentifierScheme (com.helger.peppolid.peppol.pidscheme.EPredefinedParticipantIdentifierScheme)2 ISMLConfigurationManager (com.helger.peppol.app.mgr.ISMLConfigurationManager)1 ISMLConfiguration (com.helger.peppol.domain.ISMLConfiguration)1 ESMPTransportProfile (com.helger.peppol.smp.ESMPTransportProfile)1 TestEndpoint (com.helger.peppol.testendpoint.TestEndpoint)1 TestEndpointManager (com.helger.peppol.testendpoint.TestEndpointManager)1 Test (org.junit.Test)1