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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations