Search in sources :

Example 1 with SMPInternalErrorException

use of com.helger.phoss.smp.exception.SMPInternalErrorException in project phoss-smp by phax.

the class SMPServiceGroupManagerJDBC method createSMPServiceGroup.

@Nonnull
public SMPServiceGroup createSMPServiceGroup(@Nonnull @Nonempty final String sOwnerID, @Nonnull final IParticipantIdentifier aParticipantID, @Nullable final String sExtension, final boolean bCreateInSML) throws SMPServerException {
    ValueEnforcer.notEmpty(sOwnerID, "OwnerID");
    ValueEnforcer.notNull(aParticipantID, "ParticipantID");
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("createSMPServiceGroup (" + sOwnerID + ", " + aParticipantID.getURIEncoded() + ", " + (StringHelper.hasText(sExtension) ? "with extension" : "without extension") + ", " + bCreateInSML + ")");
    final MutableBoolean aCreatedSGHook = new MutableBoolean(false);
    final MutableBoolean aCreatedSGDB = new MutableBoolean(false);
    final IRegistrationHook aHook = RegistrationHookFactory.getInstance();
    final Wrapper<Exception> aCaughtException = new Wrapper<>();
    final DBExecutor aExecutor = newExecutor();
    final ESuccess eSuccess = aExecutor.performInTransaction(() -> {
        // Check if the passed service group ID is already in use
        final SMPServiceGroup aDBServiceGroup = getSMPServiceGroupOfID(aParticipantID);
        if (aDBServiceGroup != null)
            throw new IllegalStateException("The service group with ID " + aParticipantID.getURIEncoded() + " already exists!");
        if (bCreateInSML) {
            // It's a new service group - Create in SML and remember that
            // Throws exception in case of an error
            aHook.createServiceGroup(aParticipantID);
            aCreatedSGHook.set(true);
        }
        // Did not exist. Create it.
        if (aExecutor.insertOrUpdateOrDelete("INSERT INTO smp_service_group (businessIdentifierScheme, businessIdentifier, extension) VALUES (?, ?, ?)", new ConstantPreparedStatementDataProvider(aParticipantID.getScheme(), aParticipantID.getValue(), sExtension)) > 0) {
            aCreatedSGDB.set(true);
            aExecutor.insertOrUpdateOrDelete("INSERT INTO smp_ownership (businessIdentifierScheme, businessIdentifier, username) VALUES (?, ?, ?)", new ConstantPreparedStatementDataProvider(aParticipantID.getScheme(), aParticipantID.getValue(), sOwnerID));
        }
    }, aCaughtException::set);
    if (aCreatedSGHook.booleanValue() && !aCreatedSGDB.booleanValue()) {
        // Undo creation in SML again
        try {
            aHook.undoCreateServiceGroup(aParticipantID);
        } catch (final RegistrationHookException ex) {
            LOGGER.error("Failed to undoCreateServiceGroup (" + aParticipantID.getURIEncoded() + ")", ex);
        }
    }
    if (eSuccess.isFailure() || aCaughtException.isSet() || !aCreatedSGDB.booleanValue()) {
        AuditHelper.onAuditCreateFailure(SMPServiceGroup.OT, aParticipantID.getURIEncoded(), sOwnerID, sExtension, Boolean.valueOf(bCreateInSML));
        // Propagate contained exception
        final Exception ex = aCaughtException.get();
        if (ex instanceof SMPServerException)
            throw (SMPServerException) ex;
        if (ex instanceof RegistrationHookException)
            throw new SMPSMLException("Failed to create '" + aParticipantID.getURIEncoded() + "' in SML", ex);
        throw new SMPInternalErrorException("Error creating ServiceGroup '" + aParticipantID.getURIEncoded() + "'", ex);
    }
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("createSMPServiceGroup succeeded");
    AuditHelper.onAuditCreateSuccess(SMPServiceGroup.OT, aParticipantID.getURIEncoded(), sOwnerID, sExtension, Boolean.valueOf(bCreateInSML));
    final SMPServiceGroup aServiceGroup = new SMPServiceGroup(sOwnerID, aParticipantID, sExtension);
    if (m_aCache != null)
        m_aCache.put(aParticipantID.getURIEncoded(), aServiceGroup);
    m_aCBs.forEach(x -> x.onSMPServiceGroupCreated(aServiceGroup, bCreateInSML));
    return aServiceGroup;
}
Also used : ESuccess(com.helger.commons.state.ESuccess) Wrapper(com.helger.commons.wrapper.Wrapper) RegistrationHookException(com.helger.phoss.smp.smlhook.RegistrationHookException) MutableBoolean(com.helger.commons.mutable.MutableBoolean) SMPInternalErrorException(com.helger.phoss.smp.exception.SMPInternalErrorException) SMPSMLException(com.helger.phoss.smp.exception.SMPSMLException) SMPServerException(com.helger.phoss.smp.exception.SMPServerException) RegistrationHookException(com.helger.phoss.smp.smlhook.RegistrationHookException) SMPNotFoundException(com.helger.phoss.smp.exception.SMPNotFoundException) SMPSMLException(com.helger.phoss.smp.exception.SMPSMLException) IRegistrationHook(com.helger.phoss.smp.smlhook.IRegistrationHook) SMPInternalErrorException(com.helger.phoss.smp.exception.SMPInternalErrorException) DBExecutor(com.helger.db.jdbc.executor.DBExecutor) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) SMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup) ConstantPreparedStatementDataProvider(com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider) SMPServerException(com.helger.phoss.smp.exception.SMPServerException) Nonnull(javax.annotation.Nonnull)

Example 2 with SMPInternalErrorException

use of com.helger.phoss.smp.exception.SMPInternalErrorException in project phoss-smp by phax.

the class APIExecutorMigrationOutboundStartPut method invokeAPI.

public void invokeAPI(@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull @Nonempty final String sPath, @Nonnull final Map<String, String> aPathVariables, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception {
    final String sServiceGroupID = aPathVariables.get(SMPRestFilter.PARAM_SERVICE_GROUP_ID);
    final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider(aRequestScope, sServiceGroupID);
    // Is the writable API disabled?
    if (SMPMetaManager.getSettings().isRESTWritableAPIDisabled()) {
        throw new SMPPreconditionFailedException("The writable REST API is disabled. migrationOutboundStart will not be executed", aDataProvider.getCurrentURI());
    }
    final String sLogPrefix = "[REST API Migration-Outbound-Start] ";
    LOGGER.info(sLogPrefix + "Starting outbound migration for Service Group ID '" + sServiceGroupID + "'");
    // Only authenticated user may do so
    final BasicAuthClientCredentials aBasicAuth = getMandatoryAuth(aRequestScope.headers());
    SMPUserManagerPhoton.validateUserCredentials(aBasicAuth);
    final ISMPSettings aSettings = SMPMetaManager.getSettings();
    final ISMLInfo aSMLInfo = aSettings.getSMLInfo();
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPParticipantMigrationManager aParticipantMigrationMgr = SMPMetaManager.getParticipantMigrationMgr();
    if (aSMLInfo == null) {
        throw new SMPPreconditionFailedException("Currently no SML is available. Please select it in the UI at the 'SMP Settings' page", aDataProvider.getCurrentURI());
    }
    if (!aSettings.isSMLEnabled()) {
        throw new SMPPreconditionFailedException("SML Connection is not enabled hence no participant can be migrated", aDataProvider.getCurrentURI());
    }
    final IParticipantIdentifier aServiceGroupID = aIdentifierFactory.parseParticipantIdentifier(sServiceGroupID);
    if (aServiceGroupID == null) {
        // Invalid identifier
        throw SMPBadRequestException.failedToParseSG(sServiceGroupID, aDataProvider.getCurrentURI());
    }
    // Check that service group exists
    if (!aServiceGroupMgr.containsSMPServiceGroupWithID(aServiceGroupID)) {
        throw new SMPBadRequestException("The Service Group '" + sServiceGroupID + "' does not exist", aDataProvider.getCurrentURI());
    }
    // Ensure no existing migration is in process
    if (aParticipantMigrationMgr.containsOutboundMigrationInProgress(aServiceGroupID)) {
        throw new SMPBadRequestException("The outbound Participant Migration of the Service Group '" + sServiceGroupID + "' is already in progress", aDataProvider.getCurrentURI());
    }
    String sMigrationKey = null;
    try {
        final ManageParticipantIdentifierServiceCaller aCaller = new ManageParticipantIdentifierServiceCaller(aSMLInfo);
        aCaller.setSSLSocketFactory(SMPKeyManager.getInstance().createSSLContext().getSocketFactory());
        // Create a random migration key,
        // Than call SML
        sMigrationKey = aCaller.prepareToMigrate(aServiceGroupID, SMPServerConfiguration.getSMLSMPID());
        LOGGER.info(sLogPrefix + "Successfully called prepareToMigrate on SML. Created migration key is '" + sMigrationKey + "'");
    } catch (final BadRequestFault | InternalErrorFault | NotFoundFault | UnauthorizedFault | ClientTransportException ex) {
        throw new SMPSMLException("Failed to call prepareToMigrate on SML for Service Group '" + sServiceGroupID + "'", ex);
    }
    // Remember internally
    final ISMPParticipantMigration aMigration = aParticipantMigrationMgr.createOutboundParticipantMigration(aServiceGroupID, sMigrationKey);
    if (aMigration == null) {
        throw new SMPInternalErrorException("Failed to create outbound Participant Migration for '" + sServiceGroupID + "' internally");
    }
    LOGGER.info(sLogPrefix + "Successfully created outbound Participant Migration with ID '" + aMigration.getID() + "' internally.");
    // Build result
    final IMicroDocument aResponseDoc = new MicroDocument();
    final IMicroElement eRoot = aResponseDoc.appendElement("migrationOutboundResponse");
    eRoot.setAttribute("success", true);
    eRoot.appendElement(XML_ELEMENT_PARTICIPANT_ID).appendText(sServiceGroupID);
    eRoot.appendElement(XML_ELEMENT_MIGRATION_KEY).appendText(sMigrationKey);
    final XMLWriterSettings aXWS = new XMLWriterSettings().setIndent(EXMLSerializeIndent.INDENT_AND_ALIGN);
    aUnifiedResponse.setContentAndCharset(MicroWriter.getNodeAsString(aResponseDoc, aXWS), aXWS.getCharset()).setMimeType(new MimeType(CMimeType.APPLICATION_XML).addParameter(CMimeType.PARAMETER_NAME_CHARSET, aXWS.getCharset().name())).disableCaching();
}
Also used : ClientTransportException(com.sun.xml.ws.client.ClientTransportException) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) BadRequestFault(com.helger.peppol.smlclient.participant.BadRequestFault) ISMLInfo(com.helger.peppol.sml.ISMLInfo) NotFoundFault(com.helger.peppol.smlclient.participant.NotFoundFault) SMPSMLException(com.helger.phoss.smp.exception.SMPSMLException) CMimeType(com.helger.commons.mime.CMimeType) MimeType(com.helger.commons.mime.MimeType) IMicroDocument(com.helger.xml.microdom.IMicroDocument) MicroDocument(com.helger.xml.microdom.MicroDocument) ISMPParticipantMigration(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration) ISMPServerAPIDataProvider(com.helger.phoss.smp.restapi.ISMPServerAPIDataProvider) ISMPParticipantMigrationManager(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) SMPBadRequestException(com.helger.phoss.smp.exception.SMPBadRequestException) XMLWriterSettings(com.helger.xml.serialize.write.XMLWriterSettings) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) UnauthorizedFault(com.helger.peppol.smlclient.participant.UnauthorizedFault) SMPPreconditionFailedException(com.helger.phoss.smp.exception.SMPPreconditionFailedException) BasicAuthClientCredentials(com.helger.http.basicauth.BasicAuthClientCredentials) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) SMPInternalErrorException(com.helger.phoss.smp.exception.SMPInternalErrorException) IMicroElement(com.helger.xml.microdom.IMicroElement) IMicroDocument(com.helger.xml.microdom.IMicroDocument) InternalErrorFault(com.helger.peppol.smlclient.participant.InternalErrorFault) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 3 with SMPInternalErrorException

use of com.helger.phoss.smp.exception.SMPInternalErrorException in project phoss-smp by phax.

the class APIExecutorServiceGroupCompleteGet method invokeAPI.

public void invokeAPI(@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull @Nonempty final String sPath, @Nonnull final Map<String, String> aPathVariables, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception {
    final String sPathServiceGroupID = aPathVariables.get(SMPRestFilter.PARAM_SERVICE_GROUP_ID);
    final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider(aRequestScope, sPathServiceGroupID);
    final byte[] aBytes;
    switch(SMPServerConfiguration.getRESTType()) {
        case PEPPOL:
            {
                // Unspecified extension
                final com.helger.xsds.peppol.smp1.CompleteServiceGroupType ret = new SMPServerAPI(aDataProvider).getCompleteServiceGroup(sPathServiceGroupID);
                aBytes = new SMPMarshallerCompleteServiceGroupType(XML_SCHEMA_VALIDATION).getAsBytes(ret);
                break;
            }
        case OASIS_BDXR_V1:
            {
                // Unspecified extension
                final com.helger.xsds.bdxr.smp1.CompleteServiceGroupType ret = new BDXR1ServerAPI(aDataProvider).getCompleteServiceGroup(sPathServiceGroupID);
                aBytes = new BDXR1MarshallerCompleteServiceGroupType(XML_SCHEMA_VALIDATION).getAsBytes(ret);
                break;
            }
        default:
            throw new UnsupportedOperationException("Unsupported REST type specified!");
    }
    if (aBytes == null) {
        // Internal error serializing the payload
        throw new SMPInternalErrorException("Failed to convert the returned CompleteServiceGroup to XML");
    }
    aUnifiedResponse.setContent(aBytes).setMimeType(CMimeType.TEXT_XML).setCharset(XMLWriterSettings.DEFAULT_XML_CHARSET_OBJ);
}
Also used : SMPMarshallerCompleteServiceGroupType(com.helger.smpclient.peppol.marshal.SMPMarshallerCompleteServiceGroupType) BDXR1MarshallerCompleteServiceGroupType(com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerCompleteServiceGroupType) SMPMarshallerCompleteServiceGroupType(com.helger.smpclient.peppol.marshal.SMPMarshallerCompleteServiceGroupType) SMPServerAPI(com.helger.phoss.smp.restapi.SMPServerAPI) BDXR1MarshallerCompleteServiceGroupType(com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerCompleteServiceGroupType) BDXR1ServerAPI(com.helger.phoss.smp.restapi.BDXR1ServerAPI) SMPInternalErrorException(com.helger.phoss.smp.exception.SMPInternalErrorException) ISMPServerAPIDataProvider(com.helger.phoss.smp.restapi.ISMPServerAPIDataProvider)

Example 4 with SMPInternalErrorException

use of com.helger.phoss.smp.exception.SMPInternalErrorException in project phoss-smp by phax.

the class APIExecutorServiceMetadataGet method invokeAPI.

public void invokeAPI(@Nonnull final IAPIDescriptor aAPIDescriptor, @Nonnull @Nonempty final String sPath, @Nonnull final Map<String, String> aPathVariables, @Nonnull final IRequestWebScopeWithoutResponse aRequestScope, @Nonnull final UnifiedResponse aUnifiedResponse) throws Exception {
    final String sPathServiceGroupID = aPathVariables.get(SMPRestFilter.PARAM_SERVICE_GROUP_ID);
    final String sPathDocumentTypeID = aPathVariables.get(SMPRestFilter.PARAM_DOCUMENT_TYPE_ID);
    final ISMPServerAPIDataProvider aDataProvider = new SMPRestDataProvider(aRequestScope, sPathServiceGroupID);
    // Create the unsigned response document
    final Document aDoc;
    switch(SMPServerConfiguration.getRESTType()) {
        case PEPPOL:
            {
                final com.helger.xsds.peppol.smp1.SignedServiceMetadataType ret = new SMPServerAPI(aDataProvider).getServiceRegistration(sPathServiceGroupID, sPathDocumentTypeID);
                // Convert to DOM document
                // Disable XSD check, because Signature is added later
                final SMPMarshallerSignedServiceMetadataType aMarshaller = new SMPMarshallerSignedServiceMetadataType(false);
                aDoc = aMarshaller.getAsDocument(ret);
                break;
            }
        case OASIS_BDXR_V1:
            {
                final com.helger.xsds.bdxr.smp1.SignedServiceMetadataType ret = new BDXR1ServerAPI(aDataProvider).getServiceRegistration(sPathServiceGroupID, sPathDocumentTypeID);
                // Convert to DOM document
                // Disable XSD check, because Signature is added later
                final BDXR1MarshallerSignedServiceMetadataType aMarshaller = new BDXR1MarshallerSignedServiceMetadataType(false);
                aDoc = aMarshaller.getAsDocument(ret);
                break;
            }
        default:
            throw new UnsupportedOperationException("Unsupported REST type specified!");
    }
    if (aDoc == null)
        throw new IllegalStateException("Failed to serialize unsigned node!");
    // Sign the document
    try {
        SMPKeyManager.getInstance().signXML(aDoc.getDocumentElement(), SMPServerConfiguration.getRESTType().isBDXR());
        LOGGER.info("Successfully signed response XML");
    } catch (final Exception ex) {
        throw new SMPInternalErrorException("Error in signing the response XML", ex);
    }
    // Serialize the signed document
    try (final NonBlockingByteArrayOutputStream aBAOS = new NonBlockingByteArrayOutputStream()) {
        if (false) {
            // IMPORTANT: no indent and no align!
            final IXMLWriterSettings aSettings = XMLWriterSettings.createForCanonicalization();
            // Write the result to a byte array
            if (XMLWriter.writeToStream(aDoc, aBAOS, aSettings).isFailure())
                throw new IllegalStateException("Failed to serialize signed node!");
        } else {
            // for validating the signature!
            try {
                final Transformer aTransformer = XMLTransformerFactory.newTransformer();
                aTransformer.transform(new DOMSource(aDoc), new StreamResult(aBAOS));
            } catch (final TransformerException ex) {
                throw new IllegalStateException("Failed to serialized signed node", ex);
            }
        }
        aUnifiedResponse.setContent(aBAOS.toByteArray()).setMimeType(CMimeType.TEXT_XML).setCharset(XMLWriterSettings.DEFAULT_XML_CHARSET_OBJ);
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) SMPServerAPI(com.helger.phoss.smp.restapi.SMPServerAPI) IXMLWriterSettings(com.helger.xml.serialize.write.IXMLWriterSettings) Transformer(javax.xml.transform.Transformer) StreamResult(javax.xml.transform.stream.StreamResult) NonBlockingByteArrayOutputStream(com.helger.commons.io.stream.NonBlockingByteArrayOutputStream) SMPMarshallerSignedServiceMetadataType(com.helger.smpclient.peppol.marshal.SMPMarshallerSignedServiceMetadataType) BDXR1MarshallerSignedServiceMetadataType(com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerSignedServiceMetadataType) BDXR1ServerAPI(com.helger.phoss.smp.restapi.BDXR1ServerAPI) Document(org.w3c.dom.Document) SMPInternalErrorException(com.helger.phoss.smp.exception.SMPInternalErrorException) TransformerException(javax.xml.transform.TransformerException) SMPInternalErrorException(com.helger.phoss.smp.exception.SMPInternalErrorException) BDXR1MarshallerSignedServiceMetadataType(com.helger.smpclient.bdxr1.marshal.BDXR1MarshallerSignedServiceMetadataType) ISMPServerAPIDataProvider(com.helger.phoss.smp.restapi.ISMPServerAPIDataProvider) TransformerException(javax.xml.transform.TransformerException) SMPMarshallerSignedServiceMetadataType(com.helger.smpclient.peppol.marshal.SMPMarshallerSignedServiceMetadataType)

Example 5 with SMPInternalErrorException

use of com.helger.phoss.smp.exception.SMPInternalErrorException in project phoss-smp by phax.

the class SMPServiceGroupManagerJDBC method updateSMPServiceGroup.

@Nonnull
public EChange updateSMPServiceGroup(@Nonnull final IParticipantIdentifier aParticipantID, @Nonnull @Nonempty final String sNewOwnerID, @Nullable final String sNewExtension) throws SMPServerException {
    ValueEnforcer.notNull(aParticipantID, "ParticipantID");
    ValueEnforcer.notEmpty(sNewOwnerID, "NewOwnerID");
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("updateSMPServiceGroup (" + aParticipantID.getURIEncoded() + ", " + sNewOwnerID + ", " + (StringHelper.hasText(sNewExtension) ? "with extension" : "without extension") + ")");
    final Wrapper<EChange> aWrappedChange = new Wrapper<>(EChange.UNCHANGED);
    final Wrapper<Exception> aCaughtException = new Wrapper<>();
    final DBExecutor aExecutor = newExecutor();
    final ESuccess eSuccess = aExecutor.performInTransaction(() -> {
        // Check if the passed service group ID is already in use
        final SMPServiceGroup aDBServiceGroup = getSMPServiceGroupOfID(aParticipantID);
        if (aDBServiceGroup == null)
            throw new SMPNotFoundException("The service group with ID " + aParticipantID.getURIEncoded() + " does not exist!");
        if (!EqualsHelper.equals(sNewOwnerID, aDBServiceGroup.getOwnerID())) {
            // Update ownership
            final long nCount = aExecutor.insertOrUpdateOrDelete("UPDATE smp_ownership SET username=? WHERE businessIdentifierScheme=? AND businessIdentifier=?", new ConstantPreparedStatementDataProvider(sNewOwnerID, aDBServiceGroup.getParticipantIdentifier().getScheme(), aDBServiceGroup.getParticipantIdentifier().getValue()));
            if (nCount != 1)
                throw new IllegalStateException("Failed to update the ownership username to '" + sNewOwnerID + "'");
            aWrappedChange.set(EChange.CHANGED);
        }
        if (!EqualsHelper.equals(sNewExtension, aDBServiceGroup.getExtensionsAsString())) {
            // Update extension
            final long nCount = aExecutor.insertOrUpdateOrDelete("UPDATE smp_service_group SET extension=? WHERE businessIdentifierScheme=? AND businessIdentifier=?", new ConstantPreparedStatementDataProvider(sNewExtension, aDBServiceGroup.getParticipantIdentifier().getScheme(), aDBServiceGroup.getParticipantIdentifier().getValue()));
            if (nCount != 1)
                throw new IllegalStateException("Failed to update the service_group extension to '" + sNewExtension + "'");
            aWrappedChange.set(EChange.CHANGED);
        }
    }, aCaughtException::set);
    if (eSuccess.isFailure() || aCaughtException.isSet()) {
        AuditHelper.onAuditModifyFailure(SMPServiceGroup.OT, "set-all", aParticipantID.getURIEncoded(), sNewOwnerID, sNewExtension);
        final Exception ex = aCaughtException.get();
        if (ex instanceof SMPServerException)
            throw (SMPServerException) ex;
        throw new SMPInternalErrorException("Failed to update ServiceGroup '" + aParticipantID.getURIEncoded() + "'", ex);
    }
    final EChange eChange = aWrappedChange.get();
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("updateSMPServiceGroup succeeded. Change=" + eChange.isChanged());
    AuditHelper.onAuditModifySuccess(SMPServiceGroup.OT, "set-all", aParticipantID.getURIEncoded(), sNewOwnerID, sNewExtension);
    // Callback only if something changed
    if (eChange.isChanged())
        m_aCBs.forEach(x -> x.onSMPServiceGroupUpdated(aParticipantID));
    return eChange;
}
Also used : ESuccess(com.helger.commons.state.ESuccess) ESuccess(com.helger.commons.state.ESuccess) SMPInternalErrorException(com.helger.phoss.smp.exception.SMPInternalErrorException) Nonnegative(javax.annotation.Nonnegative) ICommonsSet(com.helger.commons.collection.impl.ICommonsSet) CIdentifier(com.helger.peppolid.CIdentifier) LoggerFactory(org.slf4j.LoggerFactory) SMPSMLException(com.helger.phoss.smp.exception.SMPSMLException) EChange(com.helger.commons.state.EChange) CheckForSigned(javax.annotation.CheckForSigned) Supplier(java.util.function.Supplier) CallbackList(com.helger.commons.callback.CallbackList) AbstractJDBCEnabledManager(com.helger.db.jdbc.mgr.AbstractJDBCEnabledManager) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) MutableBoolean(com.helger.commons.mutable.MutableBoolean) SMPServerException(com.helger.phoss.smp.exception.SMPServerException) Nonempty(com.helger.commons.annotation.Nonempty) RegistrationHookException(com.helger.phoss.smp.smlhook.RegistrationHookException) DBExecutor(com.helger.db.jdbc.executor.DBExecutor) ReturnsMutableCopy(com.helger.commons.annotation.ReturnsMutableCopy) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) RegistrationHookFactory(com.helger.phoss.smp.smlhook.RegistrationHookFactory) Logger(org.slf4j.Logger) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) ConstantPreparedStatementDataProvider(com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider) StringHelper(com.helger.commons.string.StringHelper) SimpleParticipantIdentifier(com.helger.peppolid.simple.participant.SimpleParticipantIdentifier) ISMPServiceGroupCallback(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupCallback) ExpiringMap(net.jodah.expiringmap.ExpiringMap) EqualsHelper(com.helger.commons.equals.EqualsHelper) ValueEnforcer(com.helger.commons.ValueEnforcer) DBResultRow(com.helger.db.jdbc.executor.DBResultRow) TimeUnit(java.util.concurrent.TimeUnit) SMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup) IRegistrationHook(com.helger.phoss.smp.smlhook.IRegistrationHook) AuditHelper(com.helger.photon.audit.AuditHelper) SMPNotFoundException(com.helger.phoss.smp.exception.SMPNotFoundException) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) ICommonsList(com.helger.commons.collection.impl.ICommonsList) Wrapper(com.helger.commons.wrapper.Wrapper) ReturnsMutableObject(com.helger.commons.annotation.ReturnsMutableObject) ExpirationPolicy(net.jodah.expiringmap.ExpirationPolicy) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) Wrapper(com.helger.commons.wrapper.Wrapper) SMPInternalErrorException(com.helger.phoss.smp.exception.SMPInternalErrorException) SMPSMLException(com.helger.phoss.smp.exception.SMPSMLException) SMPServerException(com.helger.phoss.smp.exception.SMPServerException) RegistrationHookException(com.helger.phoss.smp.smlhook.RegistrationHookException) SMPNotFoundException(com.helger.phoss.smp.exception.SMPNotFoundException) SMPNotFoundException(com.helger.phoss.smp.exception.SMPNotFoundException) SMPInternalErrorException(com.helger.phoss.smp.exception.SMPInternalErrorException) DBExecutor(com.helger.db.jdbc.executor.DBExecutor) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) SMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup) ConstantPreparedStatementDataProvider(com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider) EChange(com.helger.commons.state.EChange) SMPServerException(com.helger.phoss.smp.exception.SMPServerException) Nonnull(javax.annotation.Nonnull)

Aggregations

SMPInternalErrorException (com.helger.phoss.smp.exception.SMPInternalErrorException)8 ISMPServerAPIDataProvider (com.helger.phoss.smp.restapi.ISMPServerAPIDataProvider)5 SMPSMLException (com.helger.phoss.smp.exception.SMPSMLException)4 BDXR1ServerAPI (com.helger.phoss.smp.restapi.BDXR1ServerAPI)4 SMPServerAPI (com.helger.phoss.smp.restapi.SMPServerAPI)4 MutableBoolean (com.helger.commons.mutable.MutableBoolean)3 ESuccess (com.helger.commons.state.ESuccess)3 Wrapper (com.helger.commons.wrapper.Wrapper)3 ConstantPreparedStatementDataProvider (com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider)3 DBExecutor (com.helger.db.jdbc.executor.DBExecutor)3 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)3 SMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.SMPServiceGroup)3 SMPNotFoundException (com.helger.phoss.smp.exception.SMPNotFoundException)3 SMPServerException (com.helger.phoss.smp.exception.SMPServerException)3 IRegistrationHook (com.helger.phoss.smp.smlhook.IRegistrationHook)3 RegistrationHookException (com.helger.phoss.smp.smlhook.RegistrationHookException)3 EChange (com.helger.commons.state.EChange)2 BasicAuthClientCredentials (com.helger.http.basicauth.BasicAuthClientCredentials)2 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)2 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)2