Search in sources :

Example 6 with EChange

use of com.helger.commons.state.EChange in project phoss-smp by phax.

the class SMPParticipantMigrationManagerXML method deleteAllParticipantMigrationsOfParticipant.

@Nonnull
public EChange deleteAllParticipantMigrationsOfParticipant(@Nonnull final IParticipantIdentifier aParticipantID) {
    ValueEnforcer.notNull(aParticipantID, "ParticipantID");
    final ICommonsList<SMPParticipantMigration> aAllMatching = internalGetAll(x -> x.getParticipantIdentifier().hasSameContent(aParticipantID));
    EChange ret = EChange.UNCHANGED;
    for (final SMPParticipantMigration aItem : aAllMatching) ret = ret.or(deleteParticipantMigrationOfID(aItem.getID()));
    return ret;
}
Also used : EChange(com.helger.commons.state.EChange) Nonnull(javax.annotation.Nonnull)

Example 7 with EChange

use of com.helger.commons.state.EChange in project phoss-smp by phax.

the class BDXR1ServerAPI method deleteServiceGroup.

@Nonnull
public EChange deleteServiceGroup(@Nonnull final String sPathServiceGroupID, final boolean bDeleteInSML, @Nonnull final BasicAuthClientCredentials aCredentials) throws SMPServerException {
    final String sLog = LOG_PREFIX + "DELETE /" + sPathServiceGroupID + (bDeleteInSML ? "" : CSMPServer.LOG_SUFFIX_NO_SML_INTERACTION);
    final String sAction = "deleteServiceGroup";
    if (LOGGER.isInfoEnabled())
        LOGGER.info(sLog);
    STATS_COUNTER_INVOCATION.increment(sAction);
    try {
        final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
        final IParticipantIdentifier aPathServiceGroupID = aIdentifierFactory.parseParticipantIdentifier(sPathServiceGroupID);
        if (aPathServiceGroupID == null) {
            // Invalid identifier
            throw SMPBadRequestException.failedToParseSG(sPathServiceGroupID, m_aAPIDataProvider.getCurrentURI());
        }
        final IUser aSMPUser = SMPUserManagerPhoton.validateUserCredentials(aCredentials);
        SMPUserManagerPhoton.verifyOwnership(aPathServiceGroupID, aSMPUser);
        final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
        final EChange eDeleted = aServiceGroupMgr.deleteSMPServiceGroup(aPathServiceGroupID, bDeleteInSML);
        if (LOGGER.isInfoEnabled())
            LOGGER.info(sLog + " SUCCESS");
        STATS_COUNTER_SUCCESS.increment(sAction);
        return eDeleted;
    } catch (final SMPServerException ex) {
        if (LOGGER.isWarnEnabled())
            LOGGER.warn(sLog + " ERROR - " + ex.getMessage());
        STATS_COUNTER_ERROR.increment(sAction);
        throw ex;
    }
}
Also used : ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) IUser(com.helger.photon.security.user.IUser) EChange(com.helger.commons.state.EChange) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) SMPServerException(com.helger.phoss.smp.exception.SMPServerException) Nonnull(javax.annotation.Nonnull)

Example 8 with EChange

use of com.helger.commons.state.EChange in project phoss-smp by phax.

the class SMPSettingsManagerXML method updateSettings.

@Nonnull
public EChange updateSettings(final boolean bRESTWritableAPIDisabled, final boolean bDirectoryIntegrationEnabled, final boolean bDirectoryIntegrationRequired, final boolean bDirectoryIntegrationAutoUpdate, @Nullable final String sDirectoryHostName, final boolean bSMLActive, final boolean bSMLRequired, @Nullable final String sSMLInfoID) {
    EChange eChange = EChange.UNCHANGED;
    m_aRWLock.writeLock().lock();
    try {
        eChange = eChange.or(m_aSettings.setRESTWritableAPIDisabled(bRESTWritableAPIDisabled));
        eChange = eChange.or(m_aSettings.setDirectoryIntegrationRequired(bDirectoryIntegrationRequired));
        eChange = eChange.or(m_aSettings.setDirectoryIntegrationEnabled(bDirectoryIntegrationEnabled));
        eChange = eChange.or(m_aSettings.setDirectoryIntegrationAutoUpdate(bDirectoryIntegrationAutoUpdate));
        eChange = eChange.or(m_aSettings.setDirectoryHostName(sDirectoryHostName));
        eChange = eChange.or(m_aSettings.setSMLRequired(bSMLRequired));
        eChange = eChange.or(m_aSettings.setSMLEnabled(bSMLActive));
        eChange = eChange.or(m_aSettings.setSMLInfoID(sSMLInfoID));
        if (eChange.isChanged())
            markAsChanged();
    } finally {
        m_aRWLock.writeLock().unlock();
    }
    // Invoke callbacks
    if (eChange.isChanged())
        m_aCallbacks.forEach(x -> x.onSMPSettingsChanged(m_aSettings));
    return eChange;
}
Also used : DAOException(com.helger.dao.DAOException) IMicroDocument(com.helger.xml.microdom.IMicroDocument) ThreadSafe(javax.annotation.concurrent.ThreadSafe) EChange(com.helger.commons.state.EChange) ISettings(com.helger.settings.ISettings) AbstractPhotonSimpleDAO(com.helger.photon.app.dao.AbstractPhotonSimpleDAO) MicroDocument(com.helger.xml.microdom.MicroDocument) CallbackList(com.helger.commons.callback.CallbackList) SettingsMicroDocumentConverter(com.helger.settings.exchange.xml.SettingsMicroDocumentConverter) ReturnsMutableObject(com.helger.commons.annotation.ReturnsMutableObject) Nonnull(javax.annotation.Nonnull) Settings(com.helger.settings.Settings) Nullable(javax.annotation.Nullable) ISettingsFactory(com.helger.settings.factory.ISettingsFactory) EChange(com.helger.commons.state.EChange) Nonnull(javax.annotation.Nonnull)

Example 9 with EChange

use of com.helger.commons.state.EChange in project phoss-smp by phax.

the class SMPSettings method initFromSettings.

@Nonnull
EChange initFromSettings(@Nonnull final ISettings aSettings) {
    ValueEnforcer.notNull(aSettings, "settings");
    final EChange ret = m_aSettings.setAll(aSettings);
    // Soft migration 5.0.7
    if (!m_aSettings.containsKey(KEY_SML_INFO_ID)) {
        // Get old String (includes "/manageparticipantidentifier")
        final String sOldSMLURL = m_aSettings.getAsString("sml.url");
        if (StringHelper.hasText(sOldSMLURL)) {
            // Check if any SML item matches
            final ISMLInfo aSMLInfo = SMPMetaManager.getSMLInfoMgr().findFirstWithManageParticipantIdentifierEndpointAddress(sOldSMLURL);
            if (aSMLInfo != null)
                m_aSettings.put(KEY_SML_INFO_ID, aSMLInfo.getID());
        }
    }
    return ret;
}
Also used : ISMLInfo(com.helger.peppol.sml.ISMLInfo) EChange(com.helger.commons.state.EChange) Nonnull(javax.annotation.Nonnull)

Example 10 with EChange

use of com.helger.commons.state.EChange in project phase4 by phax.

the class PModeManager method updatePMode.

@Nonnull
public EChange updatePMode(@Nonnull final IPMode aPMode) {
    ValueEnforcer.notNull(aPMode, "PMode");
    _validatePMode(aPMode);
    final PMode aExistingPMode = getOfID(aPMode.getID());
    if (aExistingPMode == null) {
        AuditHelper.onAuditModifyFailure(PMode.OT, aPMode.getID(), "no-such-id");
        return EChange.UNCHANGED;
    }
    if (aExistingPMode.isDeleted()) {
        AuditHelper.onAuditModifyFailure(PMode.OT, aPMode.getID(), "already-deleted");
        return EChange.UNCHANGED;
    }
    m_aRWLock.writeLock().lock();
    try {
        EChange eChange = EChange.UNCHANGED;
        eChange = eChange.or(aExistingPMode.setInitiator(aPMode.getInitiator()));
        eChange = eChange.or(aExistingPMode.setResponder(aPMode.getResponder()));
        eChange = eChange.or(aExistingPMode.setAgreement(aPMode.getAgreement()));
        eChange = eChange.or(aExistingPMode.setMEP(aPMode.getMEP()));
        eChange = eChange.or(aExistingPMode.setMEPBinding(aPMode.getMEPBinding()));
        eChange = eChange.or(aExistingPMode.setLeg1(aPMode.getLeg1()));
        eChange = eChange.or(aExistingPMode.setLeg2(aPMode.getLeg2()));
        eChange = eChange.or(aExistingPMode.setPayloadService(aPMode.getPayloadService()));
        eChange = eChange.or(aExistingPMode.setReceptionAwareness(aPMode.getReceptionAwareness()));
        if (eChange.isUnchanged())
            return EChange.UNCHANGED;
        BusinessObjectHelper.setLastModificationNow(aExistingPMode);
        internalUpdateItem(aExistingPMode);
    } finally {
        m_aRWLock.writeLock().unlock();
    }
    AuditHelper.onAuditModifySuccess(PMode.OT, "all", aExistingPMode.getID());
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("Updated PMode with ID '" + aPMode.getID() + "'");
    return EChange.CHANGED;
}
Also used : EChange(com.helger.commons.state.EChange) Nonnull(javax.annotation.Nonnull)

Aggregations

EChange (com.helger.commons.state.EChange)27 Nonnull (javax.annotation.Nonnull)21 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)9 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)9 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)9 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)7 SMPServerException (com.helger.phoss.smp.exception.SMPServerException)7 SMPNotFoundException (com.helger.phoss.smp.exception.SMPNotFoundException)6 ESuccess (com.helger.commons.state.ESuccess)5 IDocumentTypeIdentifier (com.helger.peppolid.IDocumentTypeIdentifier)5 ISMPServiceInformationManager (com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager)5 IUser (com.helger.photon.security.user.IUser)5 ReturnsMutableObject (com.helger.commons.annotation.ReturnsMutableObject)4 CallbackList (com.helger.commons.callback.CallbackList)4 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)4 ICommonsList (com.helger.commons.collection.impl.ICommonsList)4 MutableBoolean (com.helger.commons.mutable.MutableBoolean)4 ConstantPreparedStatementDataProvider (com.helger.db.jdbc.callback.ConstantPreparedStatementDataProvider)4 DBExecutor (com.helger.db.jdbc.executor.DBExecutor)4 ISMPRedirectManager (com.helger.phoss.smp.domain.redirect.ISMPRedirectManager)4