use of com.helger.peppol.smp.SMPTransportProfile in project phoss-smp by phax.
the class SMPTransportProfileManagerJDBC method getSMPTransportProfileOfID.
@Nullable
public ISMPTransportProfile getSMPTransportProfileOfID(@Nullable final String sID) {
if (StringHelper.hasNoText(sID))
return null;
final Wrapper<DBResultRow> aDBResult = new Wrapper<>();
newExecutor().querySingle("SELECT name, deprecated FROM smp_tprofile WHERE id=?", new ConstantPreparedStatementDataProvider(sID), aDBResult::set);
if (aDBResult.isNotSet())
return null;
final DBResultRow aRow = aDBResult.get();
return new SMPTransportProfile(sID, aRow.getAsString(0), aRow.getAsBoolean(1, SMPTransportProfile.DEFAULT_DEPRECATED));
}
use of com.helger.peppol.smp.SMPTransportProfile in project phoss-smp by phax.
the class SMPTransportProfileManagerXML method createSMPTransportProfile.
@Nullable
public ISMPTransportProfile createSMPTransportProfile(@Nonnull @Nonempty final String sID, @Nonnull @Nonempty final String sName, final boolean bIsDeprecated) {
// Double ID needs to be taken care of
if (containsWithID(sID))
return null;
final SMPTransportProfile aSMPTransportProfile = new SMPTransportProfile(sID, sName, bIsDeprecated);
m_aRWLock.writeLocked(() -> {
internalCreateItem(aSMPTransportProfile);
});
AuditHelper.onAuditCreateSuccess(SMPTransportProfile.OT, sID, sName, Boolean.valueOf(bIsDeprecated));
return aSMPTransportProfile;
}
use of com.helger.peppol.smp.SMPTransportProfile in project phoss-smp by phax.
the class SMPTransportProfileManagerMongoDB method createSMPTransportProfile.
@Nullable
public ISMPTransportProfile createSMPTransportProfile(@Nonnull @Nonempty final String sID, @Nonnull @Nonempty final String sName, final boolean bIsDeprecated) {
// Double ID needs to be taken care of
if (containsSMPTransportProfileWithID(sID))
return null;
final SMPTransportProfile aSMPTransportProfile = new SMPTransportProfile(sID, sName, bIsDeprecated);
if (!getCollection().insertOne(toBson(aSMPTransportProfile)).wasAcknowledged())
throw new IllegalStateException("Failed to insert into MongoDB Collection");
AuditHelper.onAuditCreateSuccess(SMPTransportProfile.OT, sID, sName, Boolean.valueOf(bIsDeprecated));
return aSMPTransportProfile;
}
use of com.helger.peppol.smp.SMPTransportProfile in project phoss-smp by phax.
the class SMPTransportProfileManagerJDBC method createSMPTransportProfile.
@Nullable
public ISMPTransportProfile createSMPTransportProfile(@Nonnull @Nonempty final String sID, @Nonnull @Nonempty final String sName, final boolean bIsDeprecated) {
final ISMPTransportProfile ret = new SMPTransportProfile(sID, sName, bIsDeprecated);
final DBExecutor aExecutor = newExecutor();
final ESuccess eSuccess = aExecutor.performInTransaction(() -> {
// Create new
final long nCreated = aExecutor.insertOrUpdateOrDelete("INSERT INTO smp_tprofile (id, name, deprecated) VALUES (?, ?, ?)", new ConstantPreparedStatementDataProvider(DBValueHelper.getTrimmedToLength(ret.getID(), 45), ret.getName(), Boolean.valueOf(ret.isDeprecated())));
if (nCreated != 1)
throw new IllegalStateException("Failed to create new DB entry (" + nCreated + ")");
});
if (eSuccess.isFailure()) {
AuditHelper.onAuditCreateFailure(SMPTransportProfile.OT, sID, sName, Boolean.valueOf(bIsDeprecated), "database-error");
return null;
}
AuditHelper.onAuditCreateSuccess(SMPTransportProfile.OT, sID, sName, Boolean.valueOf(bIsDeprecated));
return ret;
}
use of com.helger.peppol.smp.SMPTransportProfile in project phoss-smp by phax.
the class SMPTransportProfileManagerXML method updateSMPTransportProfile.
@Nonnull
public EChange updateSMPTransportProfile(@Nullable final String sSMPTransportProfileID, @Nonnull @Nonempty final String sName, final boolean bIsDeprecated) {
final SMPTransportProfile aSMPTransportProfile = getOfID(sSMPTransportProfileID);
if (aSMPTransportProfile == null) {
AuditHelper.onAuditModifyFailure(SMPTransportProfile.OT, "set-all", sSMPTransportProfileID, "no-such-id");
return EChange.UNCHANGED;
}
m_aRWLock.writeLock().lock();
try {
EChange eChange = EChange.UNCHANGED;
eChange = eChange.or(aSMPTransportProfile.setName(sName));
eChange = eChange.or(aSMPTransportProfile.setDeprecated(bIsDeprecated));
if (eChange.isUnchanged())
return EChange.UNCHANGED;
internalUpdateItem(aSMPTransportProfile);
} finally {
m_aRWLock.writeLock().unlock();
}
AuditHelper.onAuditModifySuccess(SMPTransportProfile.OT, "set-all", sSMPTransportProfileID, sName, Boolean.valueOf(bIsDeprecated));
return EChange.CHANGED;
}
Aggregations