Search in sources :

Example 46 with EChange

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

the class MapBasedXPathVariableResolverQName method addAllFrom.

/**
 * Add all variables from the other variable resolver into this resolver. This
 * methods creates a QName with an empty namespace URI.
 *
 * @param aOther
 *        The variable resolver to import the variable from. May not be
 *        <code>null</code>.
 * @param bOverwrite
 *        if <code>true</code> existing variables will be overwritten with the
 *        new variables, otherwise the old variables are kept.
 * @return {@link EChange}
 */
@Nonnull
public EChange addAllFrom(@Nonnull final MapBasedXPathVariableResolver aOther, final boolean bOverwrite) {
    ValueEnforcer.notNull(aOther, "Other");
    EChange eChange = EChange.UNCHANGED;
    for (final Map.Entry<String, ?> aEntry : aOther.getAllVariables().entrySet()) {
        // Local part only to QName
        final QName aKey = new QName(aEntry.getKey());
        if (bOverwrite || !m_aMap.containsKey(aKey)) {
            m_aMap.put(aKey, aEntry.getValue());
            eChange = EChange.CHANGED;
        }
    }
    return eChange;
}
Also used : QName(javax.xml.namespace.QName) EChange(com.helger.commons.state.EChange) CommonsHashMap(com.helger.commons.collection.impl.CommonsHashMap) Map(java.util.Map) ICommonsMap(com.helger.commons.collection.impl.ICommonsMap) Nonnull(javax.annotation.Nonnull)

Example 47 with EChange

use of com.helger.commons.state.EChange in project peppol-practical by phax.

the class TestEndpointManager method updateTestEndpoint.

@Nonnull
public EChange updateTestEndpoint(@Nullable final String sTestEndpointID, @Nonnull @Nonempty final String sCompanyName, @Nullable final String sContactPerson, @Nonnull @Nonempty final String sParticipantIDScheme, @Nonnull @Nonempty final String sParticipantIDValue, @Nonnull final ISMPTransportProfile aTransportProfile, @Nonnull final ISMLConfiguration aSML) {
    m_aRWLock.writeLock().lock();
    try {
        final TestEndpoint aTestEndpoint = m_aMap.get(sTestEndpointID);
        if (aTestEndpoint == null) {
            AuditHelper.onAuditModifyFailure(TestEndpoint.OT, sTestEndpointID, "no-such-id");
            return EChange.UNCHANGED;
        }
        EChange eChange = EChange.UNCHANGED;
        // client ID cannot be changed!
        eChange = eChange.or(aTestEndpoint.setCompanyName(sCompanyName));
        eChange = eChange.or(aTestEndpoint.setContactPerson(sContactPerson));
        eChange = eChange.or(aTestEndpoint.setParticipantIDIssuer(sParticipantIDScheme));
        eChange = eChange.or(aTestEndpoint.setParticipantIDValue(sParticipantIDValue));
        eChange = eChange.or(aTestEndpoint.setTransportProfile(aTransportProfile));
        eChange = eChange.or(aTestEndpoint.setSML(aSML));
        if (eChange.isUnchanged())
            return EChange.UNCHANGED;
        BusinessObjectHelper.setLastModificationNow(aTestEndpoint);
        markAsChanged();
    } finally {
        m_aRWLock.writeLock().unlock();
    }
    AuditHelper.onAuditModifySuccess(TestEndpoint.OT, sTestEndpointID, sCompanyName, sContactPerson, sParticipantIDScheme, sParticipantIDValue, aTransportProfile, aSML);
    return EChange.CHANGED;
}
Also used : EChange(com.helger.commons.state.EChange) Nonnull(javax.annotation.Nonnull)

Example 48 with EChange

use of com.helger.commons.state.EChange in project peppol-practical by phax.

the class CRMGroupManager method updateCRMGroup.

@Nonnull
public EChange updateCRMGroup(@Nullable final String sCRMGroupID, @Nonnull @Nonempty final String sDisplayName, @Nonnull @Nonempty final String sSenderEmailAddress) {
    final CRMGroup aCRMGroup = getOfID(sCRMGroupID);
    if (aCRMGroup == null) {
        AuditHelper.onAuditModifyFailure(CRMGroup.OT_CRM_GROUP, sCRMGroupID, "no-such-id");
        return EChange.UNCHANGED;
    }
    m_aRWLock.writeLock().lock();
    try {
        EChange eChange = EChange.UNCHANGED;
        // ID cannot be changed!
        eChange = eChange.or(aCRMGroup.setDisplayName(sDisplayName));
        eChange = eChange.or(aCRMGroup.setSenderEmailAddress(sSenderEmailAddress));
        if (eChange.isUnchanged())
            return EChange.UNCHANGED;
        BusinessObjectHelper.setLastModificationNow(aCRMGroup);
        internalUpdateItem(aCRMGroup);
    } finally {
        m_aRWLock.writeLock().unlock();
    }
    AuditHelper.onAuditModifySuccess(CRMGroup.OT_CRM_GROUP, "all", sCRMGroupID, sDisplayName, sSenderEmailAddress);
    return EChange.CHANGED;
}
Also used : EChange(com.helger.commons.state.EChange) Nonnull(javax.annotation.Nonnull)

Example 49 with EChange

use of com.helger.commons.state.EChange in project peppol-practical by phax.

the class CRMSubscriberManager method updateCRMSubscriber.

@Nonnull
public EChange updateCRMSubscriber(@Nullable final String sCRMSubscriberID, @Nullable final ESalutation eSalutation, @Nonnull @Nonempty final String sName, @Nonnull @Nonempty final String sEmailAddress, @Nullable final Set<ICRMGroup> aAssignedGroups) {
    final CRMSubscriber aCRMSubscriber = getOfID(sCRMSubscriberID);
    if (aCRMSubscriber == null) {
        AuditHelper.onAuditModifyFailure(CRMSubscriber.OT_CRM_SUBSCRIBER, sCRMSubscriberID, "no-such-id");
        return EChange.UNCHANGED;
    }
    m_aRWLock.writeLock().lock();
    try {
        EChange eChange = EChange.UNCHANGED;
        // ID cannot be changed!
        eChange = eChange.or(aCRMSubscriber.setSalutation(eSalutation));
        eChange = eChange.or(aCRMSubscriber.setName(sName));
        eChange = eChange.or(aCRMSubscriber.setEmailAddress(sEmailAddress));
        eChange = eChange.or(aCRMSubscriber.setAssignedGroups(aAssignedGroups));
        if (eChange.isUnchanged())
            return EChange.UNCHANGED;
        BusinessObjectHelper.setLastModificationNow(aCRMSubscriber);
        internalUpdateItem(aCRMSubscriber);
    } finally {
        m_aRWLock.writeLock().unlock();
    }
    AuditHelper.onAuditModifySuccess(CRMSubscriber.OT_CRM_SUBSCRIBER, "all", sCRMSubscriberID, eSalutation, sName, sEmailAddress, aAssignedGroups);
    return EChange.CHANGED;
}
Also used : EChange(com.helger.commons.state.EChange) Nonnull(javax.annotation.Nonnull)

Example 50 with EChange

use of com.helger.commons.state.EChange in project peppol-practical by phax.

the class CRMSubscriberManager method updateCRMSubscriberGroupAssignments.

@Nonnull
public EChange updateCRMSubscriberGroupAssignments(@Nullable final String sCRMSubscriberID, @Nullable final Set<ICRMGroup> aAssignedGroups) {
    final CRMSubscriber aCRMSubscriber = getOfID(sCRMSubscriberID);
    if (aCRMSubscriber == null) {
        AuditHelper.onAuditModifyFailure(CRMSubscriber.OT_CRM_SUBSCRIBER, sCRMSubscriberID, "no-such-id");
        return EChange.UNCHANGED;
    }
    m_aRWLock.writeLock().lock();
    try {
        EChange eChange = EChange.UNCHANGED;
        eChange = eChange.or(aCRMSubscriber.setAssignedGroups(aAssignedGroups));
        if (eChange.isUnchanged())
            return EChange.UNCHANGED;
        BusinessObjectHelper.setLastModificationNow(aCRMSubscriber);
        internalUpdateItem(aCRMSubscriber);
    } finally {
        m_aRWLock.writeLock().unlock();
    }
    AuditHelper.onAuditModifySuccess(CRMSubscriber.OT_CRM_SUBSCRIBER, "assigned-groups", sCRMSubscriberID, aAssignedGroups);
    return EChange.CHANGED;
}
Also used : EChange(com.helger.commons.state.EChange) Nonnull(javax.annotation.Nonnull)

Aggregations

EChange (com.helger.commons.state.EChange)50 Nonnull (javax.annotation.Nonnull)42 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)9 ISMPServiceGroup (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup)9 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)9 SMPServerException (com.helger.phoss.smp.exception.SMPServerException)7 CommonsHashMap (com.helger.commons.collection.impl.CommonsHashMap)6 ICommonsMap (com.helger.commons.collection.impl.ICommonsMap)6 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)6 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 Map (java.util.Map)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