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