use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class PrivateIpDaoImpl method allocateIpAddress.
@Override
public PrivateIpVO allocateIpAddress(long dcId, long networkId, String requestedIp) {
SearchCriteria<PrivateIpVO> sc = AllFieldsSearch.create();
sc.setParameters("networkId", networkId);
sc.setParameters("taken", (Date) null);
if (requestedIp != null) {
sc.setParameters("ipAddress", requestedIp);
}
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
PrivateIpVO vo = lockOneRandomRow(sc, true);
if (vo == null) {
txn.rollback();
return null;
}
vo.setTakenAt(new Date());
update(vo.getId(), vo);
txn.commit();
return vo;
}
use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class StaticRouteDaoImpl method remove.
@Override
@DB
public boolean remove(Long id) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
StaticRouteVO entry = findById(id);
if (entry != null) {
_tagsDao.removeByIdAndType(id, ResourceObjectType.StaticRoute);
}
boolean result = super.remove(id);
txn.commit();
return result;
}
use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class VpcDaoImpl method remove.
@Override
@DB
public boolean remove(Long id) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
VpcVO entry = findById(id);
if (entry != null) {
_tagsDao.removeByIdAndType(id, ResourceObjectType.Vpc);
}
boolean result = super.remove(id);
txn.commit();
return result;
}
use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class SecurityGroupRuleDaoImpl method remove.
@Override
@DB
public boolean remove(Long id) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
SecurityGroupRuleVO entry = findById(id);
if (entry != null) {
_tagsDao.removeByIdAndType(id, ResourceObjectType.SecurityGroupRule);
}
boolean result = super.remove(id);
txn.commit();
return result;
}
use of com.cloud.utils.db.TransactionLegacy in project cloudstack by apache.
the class ProjectDaoImpl method remove.
@Override
@DB
public boolean remove(Long projectId) {
boolean result = false;
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
ProjectVO projectToRemove = findById(projectId);
projectToRemove.setName(null);
if (!update(projectId, projectToRemove)) {
s_logger.warn("Failed to reset name for the project id=" + projectId + " as a part of project remove");
return false;
}
_tagsDao.removeByIdAndType(projectId, ResourceObjectType.Project);
result = super.remove(projectId);
txn.commit();
return result;
}
Aggregations