cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [03/50] [abbrv] Made all resource details DAOs (nic_details, user_vm_details, template_details, volume_details, service_offering_details) extend from the same base class as although details are being stored in diff tables, those tables have the same stru
Date Tue, 29 Oct 2013 03:52:53 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0fb4d9d5/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index fb1bb27..7a1b5aa 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -30,7 +30,6 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import org.apache.log4j.Logger;
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
 import org.apache.cloudstack.api.BaseListTemplateOrIsoPermissionsCmd;
 import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
@@ -82,6 +81,7 @@ import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
 import org.apache.cloudstack.storage.image.datastore.ImageStoreEntity;
+import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
@@ -135,6 +135,7 @@ import com.cloud.storage.StoragePoolHostVO;
 import com.cloud.storage.StoragePoolStatus;
 import com.cloud.storage.TemplateProfile;
 import com.cloud.storage.Upload;
+import com.cloud.storage.VMTemplateDetailVO;
 import com.cloud.storage.VMTemplateHostVO;
 import com.cloud.storage.VMTemplateStoragePoolVO;
 import com.cloud.storage.VMTemplateStorageResourceAssoc;
@@ -176,7 +177,6 @@ import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.concurrency.NamedThreadFactory;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.Transaction;
-import com.cloud.utils.db.TransactionCallback;
 import com.cloud.utils.db.TransactionCallbackNoReturn;
 import com.cloud.utils.db.TransactionStatus;
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -1627,8 +1627,13 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
         VMTemplateVO template = _tmpltDao.persist(privateTemplate);
         // Increment the number of templates
         if (template != null) {
-            if (cmd.getDetails() != null) {
-                _templateDetailsDao.persist(template.getId(), cmd.getDetails());
+            Map<String, String> detailsStr = cmd.getDetails();
+            if (detailsStr != null) {
+                List<VMTemplateDetailVO> details = new ArrayList<VMTemplateDetailVO>();
+                for (String key : detailsStr.keySet()) {
+                    details.add(new VMTemplateDetailVO(template.getId(), key, detailsStr.get(key)));
+                }
+                _templateDetailsDao.addDetails(details);
             }
 
             _resourceLimitMgr.incrementResourceCount(templateOwner.getId(), ResourceType.template);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0fb4d9d5/server/test/com/cloud/metadata/ResourceMetaDataManagerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/metadata/ResourceMetaDataManagerTest.java b/server/test/com/cloud/metadata/ResourceMetaDataManagerTest.java
index b071955..ae3cae4 100644
--- a/server/test/com/cloud/metadata/ResourceMetaDataManagerTest.java
+++ b/server/test/com/cloud/metadata/ResourceMetaDataManagerTest.java
@@ -76,8 +76,8 @@ public class ResourceMetaDataManagerTest {
         doReturn(1L).when(_taggedResourceMgr).getResourceId(anyString(), eq(ResourceTag.ResourceObjectType.Volume));
         //           _volumeDetailDao.removeDetails(id, key);
 
-        doNothing().when(_volumeDetailDao).removeDetails(anyLong(), anyString());
-        doNothing().when(_nicDetailDao).removeDetails(anyLong(), anyString());
+        doNothing().when(_volumeDetailDao).removeDetail(anyLong(), anyString());
+        doNothing().when(_nicDetailDao).removeDetail(anyLong(), anyString());
         _resourceMetaDataMgr.deleteResourceMetaData(anyString(), eq(ResourceTag.ResourceObjectType.Volume),
anyString());
 
     }
@@ -91,8 +91,8 @@ public class ResourceMetaDataManagerTest {
         doReturn(1L).when(_taggedResourceMgr).getResourceId("1", ResourceTag.ResourceObjectType.Volume);
         //           _volumeDetailDao.removeDetails(id, key);
 
-        doNothing().when(_volumeDetailDao).removeDetails(anyLong(), anyString());
-        doNothing().when(_nicDetailDao).removeDetails(anyLong(), anyString());
+        doNothing().when(_volumeDetailDao).removeDetail(anyLong(), anyString());
+        doNothing().when(_nicDetailDao).removeDetail(anyLong(), anyString());
         Map<String, String> map = new HashedMap();
         map.put("key","value");
         _resourceMetaDataMgr.addResourceMetaData("1", ResourceTag.ResourceObjectType.Volume,
map);


Mime
View raw message