Search in sources :

Example 31 with TransactionLegacy

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;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) PrivateIpVO(com.cloud.network.vpc.PrivateIpVO) Date(java.util.Date)

Example 32 with TransactionLegacy

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;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) StaticRouteVO(com.cloud.network.vpc.StaticRouteVO) DB(com.cloud.utils.db.DB)

Example 33 with TransactionLegacy

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;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) VpcVO(com.cloud.network.vpc.VpcVO) DB(com.cloud.utils.db.DB)

Example 34 with TransactionLegacy

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;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) SecurityGroupRuleVO(com.cloud.network.security.SecurityGroupRuleVO) DB(com.cloud.utils.db.DB)

Example 35 with TransactionLegacy

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;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) ProjectVO(com.cloud.projects.ProjectVO) DB(com.cloud.utils.db.DB)

Aggregations

TransactionLegacy (com.cloud.utils.db.TransactionLegacy)368 PreparedStatement (java.sql.PreparedStatement)174 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)149 SQLException (java.sql.SQLException)133 ResultSet (java.sql.ResultSet)102 ArrayList (java.util.ArrayList)98 DB (com.cloud.utils.db.DB)95 ConfigurationException (javax.naming.ConfigurationException)54 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)35 Date (java.util.Date)34 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)31 HashMap (java.util.HashMap)29 URISyntaxException (java.net.URISyntaxException)28 AccountVO (com.cloud.user.AccountVO)21 CloudException (com.cloud.exception.CloudException)20 Account (com.cloud.user.Account)20 Field (java.lang.reflect.Field)19 MockVolumeVO (com.cloud.simulator.MockVolumeVO)18 AgentManager (com.cloud.agent.AgentManager)13 IPAddressDao (com.cloud.network.dao.IPAddressDao)13