Search in sources :

Example 11 with EChange

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

the class AS4ProfileManager method setDefaultProfile.

public void setDefaultProfile(@Nullable final IAS4Profile aAS4Profile) {
    final EChange eChanged = m_aRWLock.writeLockedGet(() -> {
        if (EqualsHelper.equals(aAS4Profile, m_aDefaultProfile))
            return EChange.UNCHANGED;
        m_aDefaultProfile = aAS4Profile;
        return EChange.CHANGED;
    });
    if (eChanged.isChanged())
        if (aAS4Profile == null)
            LOGGER.info("Removed the default AS4 profile");
        else
            LOGGER.info("Set the default AS4 profile to '" + aAS4Profile.getID() + "'" + (aAS4Profile.isDeprecated() ? " which is deprecated" : ""));
}
Also used : EChange(com.helger.commons.state.EChange)

Example 12 with EChange

use of com.helger.commons.state.EChange in project ph-web by phax.

the class RequestWebScopeMultipart method addSpecialRequestParams.

@Override
@OverrideOnDemand
protected EChange addSpecialRequestParams() {
    // Parse as multipart if the Content-Type matches, and add each item into
    // params()
    final EChange ret = RequestMultipartHelper.handleMultipartFormData(m_aHttpRequest, params()::putIn);
    m_bParsedMultipart = ret.isChanged();
    return ret;
}
Also used : EChange(com.helger.commons.state.EChange) OverrideOnDemand(com.helger.commons.annotation.OverrideOnDemand)

Example 13 with EChange

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

the class SMLInfoManager method updateSMLInfo.

@Nonnull
public EChange updateSMLInfo(@Nullable final String sSMLInfoID, @Nonnull @Nonempty final String sDisplayName, @Nonnull @Nonempty final String sDNSZone, @Nonnull @Nonempty final String sManagementServiceURL, final boolean bClientCertificateRequired) {
    final SMLInfo aSMLInfo = getOfID(sSMLInfoID);
    if (aSMLInfo == null) {
        AuditHelper.onAuditModifyFailure(SMLInfo.OT, sSMLInfoID, "no-such-id");
        return EChange.UNCHANGED;
    }
    m_aRWLock.writeLock().lock();
    try {
        EChange eChange = EChange.UNCHANGED;
        eChange = eChange.or(aSMLInfo.setDisplayName(sDisplayName));
        eChange = eChange.or(aSMLInfo.setDNSZone(sDNSZone));
        eChange = eChange.or(aSMLInfo.setManagementServiceURL(sManagementServiceURL));
        eChange = eChange.or(aSMLInfo.setClientCertificateRequired(bClientCertificateRequired));
        if (eChange.isUnchanged())
            return EChange.UNCHANGED;
        internalUpdateItem(aSMLInfo);
    } finally {
        m_aRWLock.writeLock().unlock();
    }
    AuditHelper.onAuditModifySuccess(SMLInfo.OT, "all", sSMLInfoID, sDisplayName, sDNSZone, sManagementServiceURL, Boolean.valueOf(bClientCertificateRequired));
    return EChange.CHANGED;
}
Also used : SMLInfo(com.helger.peppol.sml.SMLInfo) ISMLInfo(com.helger.peppol.sml.ISMLInfo) EChange(com.helger.commons.state.EChange) Nonnull(javax.annotation.Nonnull)

Example 14 with EChange

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

the class ValidationExecutorSetRegistry method removeAll.

/**
 * This is a cleanup method that frees all resources when they are no longer
 * needed. This removes all registered validators.
 *
 * @param bCleanVES
 *        This may be helpful because some {@link IValidationExecutor}
 *        implementations contained in the {@link IValidationExecutorSet}
 *        contained in this registry might have strong references to
 *        {@link ClassLoader} instances. By passing <code>true</code>,
 *        {@link ValidationExecutorSet#removeAllExecutors()} is invoked on all
 *        matching validation executor sets.
 * @return {@link EChange}
 * @since 6.0.1
 */
@Nonnull
public EChange removeAll(final boolean bCleanVES) {
    EChange ret = EChange.UNCHANGED;
    m_aRWLock.writeLock().lock();
    try {
        if (m_aMap.isNotEmpty()) {
            ret = EChange.CHANGED;
            if (bCleanVES)
                for (final IValidationExecutorSet<?> aVES : m_aMap.values()) if (aVES instanceof ValidationExecutorSet)
                    ((ValidationExecutorSet<?>) aVES).removeAllExecutors();
            m_aMap.clear();
        }
    } finally {
        m_aRWLock.writeLock().unlock();
    }
    if (ret.isChanged())
        if (LOGGER.isDebugEnabled())
            LOGGER.debug("Successfully removed all validatione executor sets" + (bCleanVES ? " and cleaned all VES." : "."));
    return ret;
}
Also used : EChange(com.helger.commons.state.EChange) Nonnull(javax.annotation.Nonnull)

Example 15 with EChange

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

the class PModeManagerInMemory method updatePMode.

@Nonnull
public EChange updatePMode(@Nonnull final IPMode aNewPMode) {
    ValueEnforcer.notNull(aNewPMode, "PMode");
    _validatePMode(aNewPMode);
    final PMode aExistingPMode = getOfID(aNewPMode.getID());
    if (aExistingPMode == null || aExistingPMode.isDeleted())
        return EChange.UNCHANGED;
    m_aRWLock.writeLock().lock();
    try {
        EChange eChange = EChange.UNCHANGED;
        eChange = eChange.or(aExistingPMode.setInitiator(aNewPMode.getInitiator()));
        eChange = eChange.or(aExistingPMode.setResponder(aNewPMode.getResponder()));
        eChange = eChange.or(aExistingPMode.setAgreement(aNewPMode.getAgreement()));
        eChange = eChange.or(aExistingPMode.setMEP(aNewPMode.getMEP()));
        eChange = eChange.or(aExistingPMode.setMEPBinding(aNewPMode.getMEPBinding()));
        eChange = eChange.or(aExistingPMode.setLeg1(aNewPMode.getLeg1()));
        eChange = eChange.or(aExistingPMode.setLeg2(aNewPMode.getLeg2()));
        eChange = eChange.or(aExistingPMode.setPayloadService(aNewPMode.getPayloadService()));
        eChange = eChange.or(aExistingPMode.setReceptionAwareness(aNewPMode.getReceptionAwareness()));
        if (eChange.isUnchanged())
            return EChange.UNCHANGED;
        BusinessObjectHelper.setLastModificationNow(aExistingPMode);
    } finally {
        m_aRWLock.writeLock().unlock();
    }
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("Updated PMode with ID '" + aNewPMode.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