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