use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class HostDetailsDaoImpl method persist.
@Override
public void persist(long hostId, Map<String, String> details) {
final String InsertOrUpdateSql = "INSERT INTO `cloud`.`host_details` (host_id, name, value) VALUES (?,?,?) ON DUPLICATE KEY UPDATE value=?";
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
for (Map.Entry<String, String> detail : details.entrySet()) {
String value = detail.getValue();
if ("password".equals(detail.getKey())) {
value = DBEncryptionUtil.encrypt(value);
}
try {
PreparedStatement pstmt = txn.prepareAutoCloseStatement(InsertOrUpdateSql);
pstmt.setLong(1, hostId);
pstmt.setString(2, detail.getKey());
pstmt.setString(3, value);
pstmt.setString(4, value);
pstmt.executeUpdate();
} catch (SQLException e) {
throw new CloudRuntimeException("Unable to persist the host_details key: " + detail.getKey() + " for host id: " + hostId, e);
}
}
txn.commit();
}
use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class EngineDataCenterDaoImpl method remove.
@Override
public boolean remove(Long id) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
EngineDataCenterVO zone = createForUpdate();
zone.setName(null);
update(id, zone);
boolean result = super.remove(id);
txn.commit();
return result;
}
use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class EngineHostPodDaoImpl method remove.
@Override
public boolean remove(Long id) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
EngineHostPodVO pod = createForUpdate();
pod.setName(null);
update(id, pod);
boolean result = super.remove(id);
txn.commit();
return result;
}
use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class TestNGAop method intercept.
@Override
public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) {
for (IMethodInstance methodIns : methods) {
ITestNGMethod method = methodIns.getMethod();
ConstructorOrMethod meth = method.getConstructorOrMethod();
Method m = meth.getMethod();
if (m != null) {
DB db = m.getAnnotation(DB.class);
if (db != null) {
TransactionLegacy txn = TransactionLegacy.open(m.getName());
}
}
}
// TODO Auto-generated method stub
return methods;
}
use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class SAMLTokenDaoImpl method expireTokens.
@Override
public void expireTokens() {
TransactionLegacy txn = TransactionLegacy.currentTxn();
try {
txn.start();
String sql = "DELETE FROM `saml_token` WHERE `created` < (NOW() - INTERVAL 1 HOUR)";
PreparedStatement pstmt = txn.prepareAutoCloseStatement(sql);
pstmt.executeUpdate();
txn.commit();
} catch (Exception e) {
txn.rollback();
throw new CloudRuntimeException("Unable to flush old SAML tokens due to exception", e);
}
}
Aggregations