bug 9651: we're saving the tags twice.

This commit is contained in:
Alex Huang 2011-06-08 15:55:27 -07:00
parent 404e09f6ee
commit b1de7ece25
4 changed files with 16 additions and 17 deletions

View File

@ -1599,7 +1599,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
domainId = cmd.getDomainId();
}
Network network = createNetwork(networkOfferingId, name, displayText, isShared, isDefault, zoneId, gateway, cidr, vlanId, networkDomain, owner, false, domainId, null);
Network network = createNetwork(networkOfferingId, name, displayText, isShared, isDefault, zoneId, gateway, cidr, vlanId, networkDomain, owner, false, domainId, tags);
// Don't pass owner to create vlan when network offering is of type Direct - done to prevent accountVlanMap entry
// creation when vlan is mapped to network
@ -2926,6 +2926,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
Random _rand = new Random(System.currentTimeMillis());
@Override
@DB
public String acquireGuestIpAddress(Network network) {
List<String> ips = _nicDao.listIpAddressInNetwork(network.getId());

View File

@ -55,7 +55,6 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
NetworkAccountDaoImpl _accountsDao = ComponentLocator.inject(NetworkAccountDaoImpl.class);
NetworkDomainDaoImpl _domainsDao = ComponentLocator.inject(NetworkDomainDaoImpl.class);
NetworkOpDaoImpl _opDao = ComponentLocator.inject(NetworkOpDaoImpl.class);
NetworkTagDaoImpl _tagDao = ComponentLocator.inject(NetworkTagDaoImpl.class);
final TableGenerator _tgMacAddress;
Random _rand = new Random(System.currentTimeMillis());
@ -180,9 +179,6 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
addAccountToNetwork(network.getId(), network.getAccountId(), true);
NetworkOpVO op = new NetworkOpVO(network.getId(), gc);
_opDao.persist(op);
for (String tag : network.getTags()) {
_tagDao.persist(new NetworkTagVO(network.getId(), tag));
}
txn.commit();
newNetwork.setTags(network.getTags());
return newNetwork;

View File

@ -44,7 +44,6 @@ public class NetworkDaoTest extends TestCase {
retrievedTags = retrieved.getTags();
assert(retrievedTags.size() == 2 && retrievedTags.contains("e") && retrievedTags.contains("f"));
dao.expunge(1001l);
}

View File

@ -1218,6 +1218,8 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
}
}
}
if (_ecAttributes != null && _ecAttributes.size() > 0) {
HashMap<Attribute, Object> ecAttributes = new HashMap<Attribute, Object>();
for (Attribute attr : _ecAttributes) {
Object ec = attr.field.get(entity);
@ -1227,6 +1229,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
}
insertElementCollection(entity, _idAttributes.get(_table)[0], id, ecAttributes);
}
txn.commit();
} catch (final SQLException e) {
if (e.getSQLState().equals("23000") && e.getErrorCode() == 1062) {