Search in sources :

Example 1 with ISMPEndpoint

use of com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint 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 2 with ISMPEndpoint

use of com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint in project phoss-smp by phax.

the class AbstractPageSecureEndpoint method createViewToolbar.

@Override
@Nonnull
protected BootstrapButtonToolbar createViewToolbar(@Nonnull final WebPageExecutionContext aWPEC, final boolean bCanGoBack, @Nonnull final ISMPServiceInformation aSelectedObject) {
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final ISMPProcess aSelectedProcess = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_PROCESS);
    final ISMPEndpoint aSelectedEndpoint = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_ENDPOINT);
    final BootstrapButtonToolbar aToolbar = createNewViewToolbar(aWPEC);
    if (bCanGoBack) {
        // Back to list
        aToolbar.addButtonBack(aDisplayLocale);
    }
    if (isActionAllowed(aWPEC, EWebPageFormAction.EDIT, aSelectedObject)) {
        // Edit object
        aToolbar.addButtonEdit(aDisplayLocale, createEditURL(aWPEC, aSelectedObject).addAll(createParamMap(aSelectedObject, aSelectedProcess, aSelectedEndpoint)));
    }
    // Callback
    modifyViewToolbar(aWPEC, aSelectedObject, aToolbar);
    return aToolbar;
}
Also used : Locale(java.util.Locale) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) Nonnull(javax.annotation.Nonnull)

Example 3 with ISMPEndpoint

use of com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint in project phoss-smp by phax.

the class AbstractPageSecureEndpoint method showInputForm.

@Override
protected void showInputForm(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMPServiceInformation aSelectedObject, @Nonnull final BootstrapForm aForm, final boolean bFormSubmitted, @Nonnull final EWebPageFormAction eFormAction, @Nonnull final FormErrorList aFormErrors) {
    final boolean bEdit = eFormAction.isEdit();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final ISMPProcess aSelectedProcess = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_PROCESS);
    final ISMPEndpoint aSelectedEndpoint = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_ENDPOINT);
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    aForm.addChild(getUIHandler().createActionHeader(bEdit ? "Edit endpoint" : "Create new endpoint"));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Service group").setCtrl(new HCServiceGroupSelect(new RequestField(FIELD_SERVICE_GROUP_ID, aSelectedObject != null ? aSelectedObject.getServiceGroupID() : null), aDisplayLocale).setReadOnly(bEdit)).setErrorList(aFormErrors.getListOfField(FIELD_SERVICE_GROUP_ID)));
    {
        final BootstrapRow aRow = new BootstrapRow();
        aRow.createColumn(GS_IDENTIFIER_SCHEME).addChild(new HCEdit(new RequestField(FIELD_DOCTYPE_ID_SCHEME, aSelectedObject != null ? aSelectedObject.getDocumentTypeIdentifier().getScheme() : aIdentifierFactory.getDefaultDocumentTypeIdentifierScheme())).setPlaceholder("Identifier scheme").setReadOnly(bEdit));
        aRow.createColumn(GS_IDENTIFIER_VALUE).addChild(new HCEdit(new RequestField(FIELD_DOCTYPE_ID_VALUE, aSelectedObject != null ? aSelectedObject.getDocumentTypeIdentifier().getValue() : null)).setPlaceholder("Identifier value").setReadOnly(bEdit));
        aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Document type ID").setCtrl(aRow).setErrorList(aFormErrors.getListOfFields(FIELD_DOCTYPE_ID_SCHEME, FIELD_DOCTYPE_ID_VALUE)));
    }
    {
        final BootstrapRow aRow = new BootstrapRow();
        aRow.createColumn(GS_IDENTIFIER_SCHEME).addChild(new HCEdit(new RequestField(FIELD_PROCESS_ID_SCHEME, aSelectedProcess != null ? aSelectedProcess.getProcessIdentifier().getScheme() : aIdentifierFactory.getDefaultProcessIdentifierScheme())).setPlaceholder("Identifier scheme").setReadOnly(bEdit));
        aRow.createColumn(GS_IDENTIFIER_VALUE).addChild(new HCEdit(new RequestField(FIELD_PROCESS_ID_VALUE, aSelectedProcess != null ? aSelectedProcess.getProcessIdentifier().getValue() : null)).setPlaceholder("Identifier value").setReadOnly(bEdit));
        aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Process ID").setCtrl(aRow).setErrorList(aFormErrors.getListOfFields(FIELD_PROCESS_ID_SCHEME, FIELD_PROCESS_ID_VALUE)));
    }
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Transport Profile").setCtrl(new HCSMPTransportProfileSelect(new RequestField(FIELD_TRANSPORT_PROFILE, aSelectedEndpoint != null ? aSelectedEndpoint.getTransportProfile() : ESMPTransportProfile.TRANSPORT_PROFILE_AS2.getID())).setReadOnly(bEdit)).setErrorList(aFormErrors.getListOfField(FIELD_TRANSPORT_PROFILE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Endpoint Reference").setCtrl(new HCEdit(new RequestField(FIELD_ENDPOINT_REFERENCE, aSelectedEndpoint != null ? aSelectedEndpoint.getEndpointReference() : null))).setHelpText("The URL where messsages of this type should be targeted to.").setErrorList(aFormErrors.getListOfField(FIELD_ENDPOINT_REFERENCE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Requires Business Level Signature").setCtrl(new HCCheckBox(new RequestFieldBoolean(FIELD_REQUIRES_BUSINESS_LEVEL_SIGNATURE, aSelectedEndpoint != null ? aSelectedEndpoint.isRequireBusinessLevelSignature() : SMPEndpoint.DEFAULT_REQUIRES_BUSINESS_LEVEL_SIGNATURE))).setHelpText("Check the box if the recipient requires business-level signatures for " + "the message, meaning a signature applied to the business message " + "before the message is put on the transport. This is independent of " + "the transport-level signatures that a specific transport profile, such " + "as the START profile, might mandate. This flag does not indicate " + "which type of business-level signature might be required. Setting or " + "consuming business-level signatures would typically be the " + "responsibility of the final senders and receivers of messages, rather " + "than a set of APs.").setErrorList(aFormErrors.getListOfField(FIELD_REQUIRES_BUSINESS_LEVEL_SIGNATURE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Minimum Authentication Level").setCtrl(new HCEdit(new RequestField(FIELD_MINIMUM_AUTHENTICATION_LEVEL, aSelectedEndpoint != null ? aSelectedEndpoint.getMinimumAuthenticationLevel() : null))).setHelpText("Indicates the minimum authentication level that recipient requires. " + "The specific semantics of this field is defined in a specific instance " + "of the BUSDOX infrastructure. It could for example reflect the " + "value of the \"urn:eu:busdox:attribute:assurance-level\" SAML " + "attribute defined in the START specification.").setErrorList(aFormErrors.getListOfField(FIELD_MINIMUM_AUTHENTICATION_LEVEL)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Not before").setCtrl(BootstrapDateTimePicker.create(FIELD_NOT_BEFORE, aSelectedEndpoint != null ? aSelectedEndpoint.getServiceActivationDate() : null, aDisplayLocale)).setHelpText("Activation date of the service. Senders should ignore services that " + "are not yet activated.").setErrorList(aFormErrors.getListOfField(FIELD_NOT_BEFORE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Not after").setCtrl(BootstrapDateTimePicker.create(FIELD_NOT_AFTER, aSelectedEndpoint != null ? aSelectedEndpoint.getServiceExpirationDate() : null, aDisplayLocale)).setHelpText("Expiration date of the service. Senders should ignore services that " + "are expired.").setErrorList(aFormErrors.getListOfField(FIELD_NOT_AFTER)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Certificate").setCtrl(new HCTextArea(new RequestField(FIELD_CERTIFICATE, aSelectedEndpoint != null ? aSelectedEndpoint.getCertificate() : null))).setHelpText("Holds the complete signing certificate of the recipient AP, as a " + "PEM base 64 encoded X509 DER formatted value.").setErrorList(aFormErrors.getListOfField(FIELD_CERTIFICATE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Service Description").setCtrl(new HCEdit(new RequestField(FIELD_SERVICE_DESCRIPTION, aSelectedEndpoint != null ? aSelectedEndpoint.getServiceDescription() : null))).setHelpText("A human readable description of the service.").setErrorList(aFormErrors.getListOfField(FIELD_SERVICE_DESCRIPTION)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Technical Contact").setCtrl(new HCEdit(new RequestField(FIELD_TECHNICAL_CONTACT, aSelectedEndpoint != null ? aSelectedEndpoint.getTechnicalContactUrl() : null))).setHelpText("Represents a link to human readable contact information. This " + "might also be an email address.").setErrorList(aFormErrors.getListOfField(FIELD_TECHNICAL_CONTACT)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Technical Information").setCtrl(new HCEdit(new RequestField(FIELD_TECHNICAL_INFORMATION, aSelectedEndpoint != null ? aSelectedEndpoint.getTechnicalInformationUrl() : null))).setHelpText("A URL to human readable documentation of the service format. " + "This could for example be a web site containing links to XML " + "Schemas, WSDLs, Schematrons and other relevant resources.").setErrorList(aFormErrors.getListOfField(FIELD_TECHNICAL_INFORMATION)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Extension").setCtrl(new HCTextArea(new RequestField(FIELD_EXTENSION, aSelectedEndpoint != null ? aSelectedEndpoint.getFirstExtensionXML() : null))).setHelpText("Optional extension to the endpoint. If present it must be valid XML content!").setErrorList(aFormErrors.getListOfField(FIELD_EXTENSION)));
}
Also used : Locale(java.util.Locale) HCTextArea(com.helger.html.hc.html.forms.HCTextArea) RequestFieldBoolean(com.helger.photon.core.form.RequestFieldBoolean) HCEdit(com.helger.html.hc.html.forms.HCEdit) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) HCSMPTransportProfileSelect(com.helger.phoss.smp.ui.secure.hc.HCSMPTransportProfileSelect) HCServiceGroupSelect(com.helger.phoss.smp.ui.secure.hc.HCServiceGroupSelect) BootstrapRow(com.helger.photon.bootstrap4.grid.BootstrapRow) HCCheckBox(com.helger.html.hc.html.forms.HCCheckBox) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) RequestField(com.helger.photon.core.form.RequestField)

Example 4 with ISMPEndpoint

use of com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint in project phoss-smp by phax.

the class AbstractPageSecureEndpoint method validateAndSaveInputParameters.

@Override
protected void validateAndSaveInputParameters(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMPServiceInformation aSelectedObject, @Nonnull final FormErrorList aFormErrors, @Nonnull final EWebPageFormAction eFormAction) {
    final boolean bEdit = eFormAction.isEdit();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final ISMPProcess aSelectedProcess = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_PROCESS);
    final ISMPEndpoint aSelectedEndpoint = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_ENDPOINT);
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
    final ISMPRedirectManager aRedirectMgr = SMPMetaManager.getRedirectMgr();
    final ISMPTransportProfileManager aTransportProfileMgr = SMPMetaManager.getTransportProfileMgr();
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    final String sServiceGroupID = bEdit ? aSelectedObject.getServiceGroupID() : aWPEC.params().getAsStringTrimmed(FIELD_SERVICE_GROUP_ID);
    ISMPServiceGroup aServiceGroup = null;
    final String sDocTypeIDScheme = bEdit ? aSelectedObject.getDocumentTypeIdentifier().getScheme() : aWPEC.params().getAsStringTrimmed(FIELD_DOCTYPE_ID_SCHEME);
    final String sDocTypeIDValue = bEdit ? aSelectedObject.getDocumentTypeIdentifier().getValue() : aWPEC.params().getAsStringTrimmed(FIELD_DOCTYPE_ID_VALUE);
    IDocumentTypeIdentifier aDocTypeID = null;
    final String sProcessIDScheme = bEdit ? aSelectedProcess.getProcessIdentifier().getScheme() : aWPEC.params().getAsStringTrimmed(FIELD_PROCESS_ID_SCHEME);
    final String sProcessIDValue = bEdit ? aSelectedProcess.getProcessIdentifier().getValue() : aWPEC.params().getAsStringTrimmed(FIELD_PROCESS_ID_VALUE);
    IProcessIdentifier aProcessID = null;
    final String sTransportProfileID = bEdit ? aSelectedEndpoint.getTransportProfile() : aWPEC.params().getAsStringTrimmed(FIELD_TRANSPORT_PROFILE);
    final ISMPTransportProfile aTransportProfile = aTransportProfileMgr.getSMPTransportProfileOfID(sTransportProfileID);
    final String sEndpointReference = aWPEC.params().getAsStringTrimmed(FIELD_ENDPOINT_REFERENCE);
    final boolean bRequireBusinessLevelSignature = aWPEC.params().getAsBoolean(FIELD_REQUIRES_BUSINESS_LEVEL_SIGNATURE);
    final String sMinimumAuthenticationLevel = aWPEC.params().getAsStringTrimmed(FIELD_MINIMUM_AUTHENTICATION_LEVEL);
    final String sNotBefore = aWPEC.params().getAsStringTrimmed(FIELD_NOT_BEFORE);
    final LocalDate aNotBeforeDate = PDTFromString.getLocalDateFromString(sNotBefore, aDisplayLocale);
    final String sNotAfter = aWPEC.params().getAsStringTrimmed(FIELD_NOT_AFTER);
    final LocalDate aNotAfterDate = PDTFromString.getLocalDateFromString(sNotAfter, aDisplayLocale);
    final String sCertificate = aWPEC.params().getAsStringTrimmed(FIELD_CERTIFICATE);
    final String sServiceDescription = aWPEC.params().getAsStringTrimmed(FIELD_SERVICE_DESCRIPTION);
    final String sTechnicalContact = aWPEC.params().getAsStringTrimmed(FIELD_TECHNICAL_CONTACT);
    final String sTechnicalInformation = aWPEC.params().getAsStringTrimmed(FIELD_TECHNICAL_INFORMATION);
    final String sExtension = aWPEC.params().getAsStringTrimmed(FIELD_EXTENSION);
    // validations
    if (StringHelper.hasNoText(sServiceGroupID))
        aFormErrors.addFieldError(FIELD_SERVICE_GROUP_ID, "A service group must be selected!");
    else {
        aServiceGroup = aServiceGroupMgr.getSMPServiceGroupOfID(aIdentifierFactory.parseParticipantIdentifier(sServiceGroupID));
        if (aServiceGroup == null)
            aFormErrors.addFieldError(FIELD_SERVICE_GROUP_ID, "The provided service group does not exist!");
    }
    if (aIdentifierFactory.isDocumentTypeIdentifierSchemeMandatory() && StringHelper.hasNoText(sDocTypeIDScheme))
        aFormErrors.addFieldError(FIELD_DOCTYPE_ID_SCHEME, "Document type ID scheme must not be empty!");
    else if (StringHelper.hasNoText(sDocTypeIDValue))
        aFormErrors.addFieldError(FIELD_DOCTYPE_ID_VALUE, "Document type ID value must not be empty!");
    else {
        aDocTypeID = aIdentifierFactory.createDocumentTypeIdentifier(sDocTypeIDScheme, sDocTypeIDValue);
        if (aDocTypeID == null)
            aFormErrors.addFieldError(FIELD_DOCTYPE_ID_VALUE, "The provided document type ID has an invalid syntax!");
        else {
            if (aServiceGroup != null)
                if (aRedirectMgr.getSMPRedirectOfServiceGroupAndDocumentType(aServiceGroup, aDocTypeID) != null)
                    aFormErrors.addFieldError(FIELD_DOCTYPE_ID_VALUE, "At least one redirect is registered for this document type. Delete the redirect before you can create an endpoint.");
        }
    }
    if (aIdentifierFactory.isProcessIdentifierSchemeMandatory() && StringHelper.hasNoText(sProcessIDScheme))
        aFormErrors.addFieldError(FIELD_PROCESS_ID_SCHEME, "Process ID scheme must not be empty!");
    else if (StringHelper.hasNoText(sProcessIDValue))
        aFormErrors.addFieldError(FIELD_PROCESS_ID_SCHEME, "Process ID value must not be empty!");
    else {
        aProcessID = aIdentifierFactory.createProcessIdentifier(sProcessIDScheme, sProcessIDValue);
        if (aProcessID == null)
            aFormErrors.addFieldError(FIELD_PROCESS_ID_VALUE, "The provided process ID has an invalid syntax!");
    }
    if (StringHelper.hasNoText(sTransportProfileID))
        aFormErrors.addFieldError(FIELD_TRANSPORT_PROFILE, "Transport Profile must not be empty!");
    else if (aTransportProfile == null)
        aFormErrors.addFieldError(FIELD_TRANSPORT_PROFILE, "Transport Profile of type '" + sTransportProfileID + "' does not exist!");
    if (!bEdit && aServiceGroup != null && aDocTypeID != null && aProcessID != null && aTransportProfile != null && aServiceInfoMgr.findServiceInformation(aServiceGroup, aDocTypeID, aProcessID, aTransportProfile) != null) {
        final String sMsg = "Another endpoint for the provided service group, document type, process and transport profile is already present. Some of the identifiers may be treated case insensitive!";
        aFormErrors.addFieldError(FIELD_DOCTYPE_ID_VALUE, sMsg);
        aFormErrors.addFieldError(FIELD_PROCESS_ID_VALUE, sMsg);
        aFormErrors.addFieldError(FIELD_TRANSPORT_PROFILE, sMsg);
    }
    if (StringHelper.hasNoText(sEndpointReference)) {
        if (false)
            aFormErrors.addFieldError(FIELD_ENDPOINT_REFERENCE, "Endpoint Reference must not be empty!");
    } else if (URLHelper.getAsURL(sEndpointReference) == null)
        aFormErrors.addFieldError(FIELD_ENDPOINT_REFERENCE, "The Endpoint Reference is not a valid URL!");
    if (aNotBeforeDate != null && aNotAfterDate != null)
        if (aNotBeforeDate.isAfter(aNotAfterDate))
            aFormErrors.addFieldError(FIELD_NOT_BEFORE, "Not Before Date must not be after Not After Date!");
    if (StringHelper.hasNoText(sCertificate))
        aFormErrors.addFieldError(FIELD_CERTIFICATE, "Certificate must not be empty!");
    else {
        X509Certificate aCert = null;
        try {
            aCert = CertificateHelper.convertStringToCertficate(sCertificate);
        } catch (final CertificateException ex) {
        // Fall through
        }
        if (aCert == null)
            aFormErrors.addFieldError(FIELD_CERTIFICATE, "The provided certificate string is not a valid X509 certificate!");
    }
    if (StringHelper.hasNoText(sServiceDescription))
        aFormErrors.addFieldError(FIELD_SERVICE_DESCRIPTION, "Service Description must not be empty!");
    if (StringHelper.hasNoText(sTechnicalContact))
        aFormErrors.addFieldError(FIELD_TECHNICAL_CONTACT, "Technical Contact must not be empty!");
    if (StringHelper.hasText(sExtension)) {
        final IMicroDocument aDoc = MicroReader.readMicroXML(sExtension);
        if (aDoc == null)
            aFormErrors.addFieldError(FIELD_EXTENSION, "The extension must be XML content.");
    }
    if (aFormErrors.isEmpty()) {
        ISMPServiceInformation aServiceInfo = aServiceInfoMgr.getSMPServiceInformationOfServiceGroupAndDocumentType(aServiceGroup, aDocTypeID);
        if (aServiceInfo == null)
            aServiceInfo = new SMPServiceInformation(aServiceGroup, aDocTypeID, null, null);
        ISMPProcess aProcess = aServiceInfo.getProcessOfID(aProcessID);
        if (aProcess == null) {
            aProcess = new SMPProcess(aProcessID, null, null);
            aServiceInfo.addProcess((SMPProcess) aProcess);
        }
        aProcess.setEndpoint(new SMPEndpoint(sTransportProfileID, sEndpointReference, bRequireBusinessLevelSignature, sMinimumAuthenticationLevel, PDTFactory.createXMLOffsetDateTime(aNotBeforeDate), PDTFactory.createXMLOffsetDateTime(aNotAfterDate), sCertificate, sServiceDescription, sTechnicalContact, sTechnicalInformation, sExtension));
        if (aServiceInfoMgr.mergeSMPServiceInformation(aServiceInfo).isSuccess()) {
            if (bEdit) {
                aWPEC.postRedirectGetInternal(success("Successfully edited the endpoint for service group '" + aServiceGroup.getParticipantIdentifier().getURIEncoded() + "'."));
            } else {
                aWPEC.postRedirectGetInternal(success("Successfully created a new endpoint for service group '" + aServiceGroup.getParticipantIdentifier().getURIEncoded() + "'."));
            }
        } else {
            if (bEdit) {
                aWPEC.postRedirectGetInternal(error("Error editing the endpoint for service group '" + aServiceGroup.getParticipantIdentifier().getURIEncoded() + "'."));
            } else {
                aWPEC.postRedirectGetInternal(error("Error creating a new endpoint for service group '" + aServiceGroup.getParticipantIdentifier().getURIEncoded() + "'."));
            }
        }
    }
}
Also used : Locale(java.util.Locale) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ISMPServiceInformationManager(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) SMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.SMPServiceInformation) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) CertificateException(java.security.cert.CertificateException) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) SMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.SMPEndpoint) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) PDTToString(com.helger.commons.datetime.PDTToString) PDTFromString(com.helger.commons.datetime.PDTFromString) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) LocalDate(java.time.LocalDate) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) X509Certificate(java.security.cert.X509Certificate) ISMPRedirectManager(com.helger.phoss.smp.domain.redirect.ISMPRedirectManager) SMPProcess(com.helger.phoss.smp.domain.serviceinfo.SMPProcess) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) ISMPTransportProfileManager(com.helger.phoss.smp.domain.transportprofile.ISMPTransportProfileManager) ISMPTransportProfile(com.helger.peppol.smp.ISMPTransportProfile) IMicroDocument(com.helger.xml.microdom.IMicroDocument) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory)

Example 5 with ISMPEndpoint

use of com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint in project phoss-smp by phax.

the class SMPMetaManager method _performMigrations.

private void _performMigrations() {
    // Required for SQL version
    try (final WebScoped aWS = new WebScoped()) {
        // See issue #128
        PhotonBasicManager.getSystemMigrationMgr().performMigrationIfNecessary("ensure-transport-profiles-128", () -> {
            LOGGER.info("Started running migration to ensure all used transport profiles are automatically created");
            for (final ISMPServiceInformation aSI : m_aServiceInformationMgr.getAllSMPServiceInformation()) for (final ISMPProcess aProc : aSI.getAllProcesses()) for (final ISMPEndpoint aEP : aProc.getAllEndpoints()) {
                final String sTransportProfile = aEP.getTransportProfile();
                if (!m_aTransportProfileMgr.containsSMPTransportProfileWithID(sTransportProfile)) {
                    m_aTransportProfileMgr.createSMPTransportProfile(sTransportProfile, sTransportProfile + " (automatically created)", false);
                    LOGGER.info("Created missing transport profile '" + sTransportProfile + "'");
                }
            }
        });
    }
}
Also used : WebScoped(com.helger.web.scope.mgr.WebScoped) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess)

Aggregations

ISMPEndpoint (com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint)12 ISMPProcess (com.helger.phoss.smp.domain.serviceinfo.ISMPProcess)12 Locale (java.util.Locale)8 ISMPServiceInformation (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation)7 HCNodeList (com.helger.html.hc.impl.HCNodeList)6 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)6 ISMPServiceInformationManager (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager)6 HCA (com.helger.html.hc.html.textlevel.HCA)5 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)5 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)5 ICommonsList (com.helger.commons.collection.impl.ICommonsList)4 ISimpleURL (com.helger.commons.url.ISimpleURL)4 HCRow (com.helger.html.hc.html.tabular.HCRow)4 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)4 IProcessIdentifier (com.helger.peppolid.IProcessIdentifier)4 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)4 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)4 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)4 CommonsHashMap (com.helger.commons.collection.impl.CommonsHashMap)3 PDTToString (com.helger.commons.datetime.PDTToString)3