Search in sources :

Example 11 with IIdentifierFactory

use of com.helger.peppolid.factory.IIdentifierFactory in project peppol-commons by phax.

the class PeppolProcessIdentifierTest method testHasDefaultProcessIdentifierScheme.

@Test
public void testHasDefaultProcessIdentifierScheme() {
    final IIdentifierFactory aIF = PeppolIdentifierFactory.INSTANCE;
    assertTrue(aIF.createProcessIdentifierWithDefaultScheme("abc").hasScheme(PeppolIdentifierHelper.DEFAULT_PROCESS_SCHEME));
    assertFalse(new PeppolProcessIdentifier("proctype", "abc").hasDefaultScheme());
}
Also used : IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) Test(org.junit.Test)

Example 12 with IIdentifierFactory

use of com.helger.peppolid.factory.IIdentifierFactory in project phoss-smp by phax.

the class SMPRedirectManagerMongoDBTest method testConversion.

@Test
public void testConversion() throws SMPServerException {
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    final IDocumentTypeIdentifier aDocTypeID = aIdentifierFactory.createDocumentTypeIdentifier(PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS, "doctype4711");
    // Delete existing service group
    final IParticipantIdentifier aPI = aIdentifierFactory.createParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "0088:dummy");
    aServiceGroupMgr.deleteSMPServiceGroupNoEx(aPI, true);
    final ISMPServiceGroup aSG = aServiceGroupMgr.createSMPServiceGroup("blub", aPI, null, true);
    assertNotNull(aSG);
    try {
        _testConversion(new SMPRedirect(aSG, aDocTypeID, "target href", "what ever", null, null));
        _testConversion(new SMPRedirect(aSG, aDocTypeID, "target href", "what ever", null, "<ext/>"));
    } finally {
        aServiceGroupMgr.deleteSMPServiceGroup(aPI, true);
    }
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) SMPRedirect(com.helger.phoss.smp.domain.redirect.SMPRedirect) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 13 with IIdentifierFactory

use of com.helger.peppolid.factory.IIdentifierFactory in project phoss-smp by phax.

the class SMPRedirectManagerMongoDBTest method testRedirectUpperCaseSG.

@Test
public void testRedirectUpperCaseSG() throws SMPServerException {
    // Ensure the user is present
    final IUser aTestUser = PhotonSecurityManager.getUserMgr().getUserOfID(CSecurity.USER_ADMINISTRATOR_ID);
    assertNotNull(aTestUser);
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    assertFalse(aIdentifierFactory.isParticipantIdentifierCaseInsensitive("bla-sch-eme"));
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr();
    assertEquals(0, aRedirectMgr.getSMPRedirectCount());
    // Delete existing service group
    final IParticipantIdentifier aPI = aIdentifierFactory.createParticipantIdentifier("bla-sch-eme", "0088:UpperCase");
    assertNotNull(aPI);
    aServiceGroupMgr.deleteSMPServiceGroupNoEx(aPI, true);
    final ISMPServiceGroup aSG = aServiceGroupMgr.createSMPServiceGroup(aTestUser.getID(), aPI, null, true);
    assertNotNull(aSG);
    try {
        final IDocumentTypeIdentifier aDocTypeID = aIdentifierFactory.createDocumentTypeIdentifier(PeppolIdentifierHelper.DOCUMENT_TYPE_SCHEME_BUSDOX_DOCID_QNS, "DocType4711");
        final ISMPRedirect aRedirect = aRedirectMgr.createOrUpdateSMPRedirect(aSG, aDocTypeID, "bla", "foo", null, "<ext/>");
        assertNotNull(aRedirect);
        assertSame(aSG, aRedirect.getServiceGroup());
        assertEquals(aDocTypeID, aRedirect.getDocumentTypeIdentifier());
        assertEquals("bla", aRedirect.getTargetHref());
        assertEquals("foo", aRedirect.getSubjectUniqueIdentifier());
        assertNull(aRedirect.getCertificate());
        assertEquals("<ext />", aRedirect.getFirstExtensionXML().trim());
    } finally {
        aServiceGroupMgr.deleteSMPServiceGroup(aPI, true);
    }
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPRedirectManager(com.helger.phoss.smp.domain.redirect.ISMPRedirectManager) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) ISMPRedirect(com.helger.phoss.smp.domain.redirect.ISMPRedirect) IUser(com.helger.photon.security.user.IUser) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Test(org.junit.Test)

Example 14 with IIdentifierFactory

use of com.helger.peppolid.factory.IIdentifierFactory in project phoss-smp by phax.

the class AbstractPageSecureEndpoint method isActionAllowed.

@Override
protected boolean isActionAllowed(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final EWebPageFormAction eFormAction, @Nullable final ISMPServiceInformation aSelectedObject) {
    if (eFormAction == EWebPageFormAction.VIEW || eFormAction == EWebPageFormAction.COPY || eFormAction == EWebPageFormAction.EDIT || eFormAction == EWebPageFormAction.DELETE) {
        final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
        final String sProcessIDScheme = aWPEC.params().getAsString(FIELD_PROCESS_ID_SCHEME);
        final String sProcessIDValue = aWPEC.params().getAsString(FIELD_PROCESS_ID_VALUE);
        final IProcessIdentifier aProcessID = aIdentifierFactory.createProcessIdentifier(sProcessIDScheme, sProcessIDValue);
        final ISMPProcess aProcess = aSelectedObject.getProcessOfID(aProcessID);
        if (aProcess != null) {
            final String sTransportProfile = aWPEC.params().getAsString(FIELD_TRANSPORT_PROFILE);
            final ISMPEndpoint aEndpoint = aProcess.getEndpointOfTransportProfile(sTransportProfile);
            if (aEndpoint != null) {
                aWPEC.getRequestScope().attrs().putIn(REQUEST_ATTR_PROCESS, aProcess);
                aWPEC.getRequestScope().attrs().putIn(REQUEST_ATTR_ENDPOINT, aEndpoint);
                return true;
            }
            if (LOGGER.isWarnEnabled())
                LOGGER.warn("Action " + eFormAction.getID() + " is not allowed, because endpoint with transport profile is missing ('" + sTransportProfile + "')");
        } else {
            if (LOGGER.isWarnEnabled())
                LOGGER.warn("Action " + eFormAction.getID() + " is not allowed, because process ID fields are missing ('" + sProcessIDScheme + "', '" + sProcessIDValue + "')");
        }
        return false;
    }
    return super.isActionAllowed(aWPEC, eFormAction, aSelectedObject);
}
Also used : PDTToString(com.helger.commons.datetime.PDTToString) PDTFromString(com.helger.commons.datetime.PDTFromString) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier)

Example 15 with IIdentifierFactory

use of com.helger.peppolid.factory.IIdentifierFactory in project phoss-smp by phax.

the class AbstractPageSecureEndpoint method getSelectedObject.

@Override
@Nullable
protected ISMPServiceInformation getSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final String sID) {
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
    final String sServiceGroupID = aWPEC.params().getAsString(FIELD_SERVICE_GROUP_ID);
    final IParticipantIdentifier aServiceGroupID = aIdentifierFactory.parseParticipantIdentifier(sServiceGroupID);
    final ISMPServiceGroup aServiceGroup = aServiceGroupMgr.getSMPServiceGroupOfID(aServiceGroupID);
    final String sDocTypeIDScheme = aWPEC.params().getAsString(FIELD_DOCTYPE_ID_SCHEME);
    final String sDocTypeIDValue = aWPEC.params().getAsString(FIELD_DOCTYPE_ID_VALUE);
    final IDocumentTypeIdentifier aDocTypeID = aIdentifierFactory.createDocumentTypeIdentifier(sDocTypeIDScheme, sDocTypeIDValue);
    return aServiceInfoMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDocTypeID);
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPServiceInformationManager(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) PDTToString(com.helger.commons.datetime.PDTToString) PDTFromString(com.helger.commons.datetime.PDTFromString) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nullable(javax.annotation.Nullable)

Aggregations

IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)84 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)57 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)34 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)33 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)30 SMPServerException (com.helger.phoss.smp.exception.SMPServerException)22 IUser (com.helger.photon.security.user.IUser)20 Nonnull (javax.annotation.Nonnull)19 Test (org.junit.Test)19 ISMPServiceInformationManager (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager)17 SMPNotFoundException (com.helger.phoss.smp.exception.SMPNotFoundException)16 ISMPRedirectManager (com.helger.phoss.smp.domain.redirect.ISMPRedirectManager)15 ISMPServiceInformation (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation)13 SMPBadRequestException (com.helger.phoss.smp.exception.SMPBadRequestException)13 HCNodeList (com.helger.html.hc.impl.HCNodeList)11 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)11 Locale (java.util.Locale)11 Nullable (javax.annotation.Nullable)11 HCEdit (com.helger.html.hc.html.forms.HCEdit)10 RequestField (com.helger.photon.core.form.RequestField)10