cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [11/44] git commit: updated refs/heads/vpc-toolkit-hugo to 1ad1883
Date Mon, 14 Jul 2014 13:37:15 GMT
CLOUDSTACK-7073: Added domainId field to the user table in order to restrict duplicated users
creation on the db level


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5a96d8ef
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5a96d8ef
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5a96d8ef

Branch: refs/heads/vpc-toolkit-hugo
Commit: 5a96d8ef5cbc88df366016ae9dd7ee46e4ca417a
Parents: b87a5ce
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Jul 7 15:12:36 2014 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Jul 7 16:21:38 2014 -0700

----------------------------------------------------------------------
 engine/schema/src/com/cloud/user/UserVO.java          |  6 ++++++
 engine/schema/src/com/cloud/user/dao/UserDaoImpl.java | 13 +++++++++++++
 setup/db/db/schema-440to450.sql                       |  6 ++++++
 3 files changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a96d8ef/engine/schema/src/com/cloud/user/UserVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/user/UserVO.java b/engine/schema/src/com/cloud/user/UserVO.java
index 68879f6..8ab450d 100644
--- a/engine/schema/src/com/cloud/user/UserVO.java
+++ b/engine/schema/src/com/cloud/user/UserVO.java
@@ -97,6 +97,9 @@ public class UserVO implements User, Identity, InternalIdentity {
     @Column(name = "default")
     boolean isDefault;
 
+    @Column(name = "domain_id")
+    private long domainId;
+
     public UserVO() {
         this.uuid = UUID.randomUUID().toString();
     }
@@ -270,4 +273,7 @@ public class UserVO implements User, Identity, InternalIdentity {
         return isDefault;
     }
 
+    public void setDomainId(long domainId) {
+        this.domainId = domainId;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a96d8ef/engine/schema/src/com/cloud/user/dao/UserDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/user/dao/UserDaoImpl.java b/engine/schema/src/com/cloud/user/dao/UserDaoImpl.java
index 6ac398d..d39177e 100644
--- a/engine/schema/src/com/cloud/user/dao/UserDaoImpl.java
+++ b/engine/schema/src/com/cloud/user/dao/UserDaoImpl.java
@@ -19,9 +19,11 @@ package com.cloud.user.dao;
 import java.util.List;
 
 import javax.ejb.Local;
+import javax.inject.Inject;
 
 import org.springframework.stereotype.Component;
 
+import com.cloud.user.Account;
 import com.cloud.user.UserVO;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GenericDaoBase;
@@ -40,6 +42,9 @@ public class UserDaoImpl extends GenericDaoBase<UserVO, Long> implements
UserDao
     protected SearchBuilder<UserVO> SecretKeySearch;
     protected SearchBuilder<UserVO> RegistrationTokenSearch;
 
+    @Inject
+    AccountDao _accountDao;
+
     protected UserDaoImpl() {
         UsernameSearch = createSearchBuilder();
         UsernameSearch.and("username", UsernameSearch.entity().getUsername(), SearchCriteria.Op.EQ);
@@ -128,4 +133,12 @@ public class UserDaoImpl extends GenericDaoBase<UserVO, Long> implements
UserDao
         return listBy(sc);
     }
 
+    @Override
+    @DB
+    public UserVO persist(UserVO user) {
+        Account account = _accountDao.findById(user.getAccountId());
+        user.setDomainId(account.getDomainId());
+        return super.persist(user);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5a96d8ef/setup/db/db/schema-440to450.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-440to450.sql b/setup/db/db/schema-440to450.sql
index 1a019dd..5fd6200 100644
--- a/setup/db/db/schema-440to450.sql
+++ b/setup/db/db/schema-440to450.sql
@@ -234,3 +234,9 @@ CREATE VIEW `cloud`.`volume_view` AS
 
 /* As part of the separation of Xen and XenServer, update the column for the network labels
*/
 ALTER TABLE `cloud`.`physical_network_traffic_types` CHANGE `xen_network_label` `xenserver_network_label`
varchar(255) COMMENT 'The network name label of the physical device dedicated to this traffic
on a XenServer host';
+
+/*Adding domainId field to the user table in order to restrict duplicated users creation
on the db level*/
+ALTER TABLE `cloud`.`user` ADD COLUMN domain_id bigint(20) unsigned DEFAULT NULL;
+ALTER TABLE `cloud`.`user` ADD CONSTRAINT `fk_user__domain_id` FOREIGN KEY `fk_user__domain_id`(`domain_id`)
REFERENCES `domain`(`id`) ON DELETE CASCADE;
+UPDATE `cloud`.`user` SET `cloud`.`user`.domain_id=(SELECT `cloud`.`account`.domain_id  
FROM `cloud`.`account`   WHERE `cloud`.`account`.id=`cloud`.`user`.account_id) where id >
0;
+ALTER TABLE `cloud`.`user` ADD UNIQUE KEY `username_domain_id` (`username`,`domain_id`);


Mime
View raw message