cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [19/27] git commit: updated refs/heads/ui-restyle to 205f22b
Date Mon, 07 Oct 2013 18:30:44 GMT
CLOUDSTACK-3101:
fix listDiskOffering to not display offerings to the normal users with forDisplay=false. But
display them to ROOT Admin irrespective of the flag.
Added display flag in the updateVolume/offeirng commands
Signed off by : nitin mehta<nitin.mehta@citrix.com>


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

Branch: refs/heads/ui-restyle
Commit: a6852a340d08845ae41833814d07771ec75cbf36
Parents: b3c1784
Author: Nitin Mehta <nitin.mehta@citrix.com>
Authored: Fri Oct 4 18:19:07 2013 -0700
Committer: Nitin Mehta <nitin.mehta@citrix.com>
Committed: Fri Oct 4 18:19:07 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/storage/VolumeApiService.java         |  2 +-
 .../command/admin/offering/UpdateDiskOfferingCmd.java   |  8 +++++++-
 .../api/command/user/volume/UpdateVolumeCmd.java        | 12 +++++++++---
 server/src/com/cloud/api/query/QueryManagerImpl.java    |  5 +++++
 .../cloud/configuration/ConfigurationManagerImpl.java   |  7 ++++++-
 server/src/com/cloud/storage/VolumeApiServiceImpl.java  |  6 +++++-
 6 files changed, 33 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a6852a34/api/src/com/cloud/storage/VolumeApiService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/VolumeApiService.java b/api/src/com/cloud/storage/VolumeApiService.java
index e8fb8de..4806ae7 100644
--- a/api/src/com/cloud/storage/VolumeApiService.java
+++ b/api/src/com/cloud/storage/VolumeApiService.java
@@ -84,7 +84,7 @@ public interface VolumeApiService {
 
 	Snapshot allocSnapshot(Long volumeId, Long policyId)
             throws ResourceAllocationException;
-    Volume updateVolume(long volumeId, String path, String state, Long storageId);
+    Volume updateVolume(long volumeId, String path, String state, Long storageId, Boolean
displayVolume);
 
     /**
      * Extracts the volume to a particular location.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a6852a34/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateDiskOfferingCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateDiskOfferingCmd.java
b/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateDiskOfferingCmd.java
index 1e421a1..a7b8dcd 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateDiskOfferingCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/offering/UpdateDiskOfferingCmd.java
@@ -49,6 +49,9 @@ public class UpdateDiskOfferingCmd extends BaseCmd{
     @Parameter(name=ApiConstants.SORT_KEY, type=CommandType.INTEGER, description="sort key
of the disk offering, integer")
     private Integer sortKey;
 
+    @Parameter(name=ApiConstants.DISPLAY_OFFERING, type=CommandType.BOOLEAN, description="an
optional field, whether to display the offering to the end user or not.")
+    private Boolean displayOffering;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -69,8 +72,11 @@ public class UpdateDiskOfferingCmd extends BaseCmd{
         return sortKey;
     }
 
+    public Boolean getDisplayOffering() {
+        return displayOffering;
+    }
 
-    /////////////////////////////////////////////////////
+/////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a6852a34/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java
index 929996e..b247e0f 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/UpdateVolumeCmd.java
@@ -54,6 +54,9 @@ public class UpdateVolumeCmd extends BaseAsyncCmd {
     @Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="The state of
the volume", since="4.3")
     private String state;
 
+    @Parameter(name=ApiConstants.DISPLAY_VOLUME, type=CommandType.BOOLEAN, description="an
optional field, whether to the display the volume to the end user or not.")
+    private Boolean displayVolume;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -73,9 +76,12 @@ public class UpdateVolumeCmd extends BaseAsyncCmd {
     public String getState() {
         return state;
     }
-    
 
-    /////////////////////////////////////////////////////
+    public Boolean getDisplayVolume() {
+        return displayVolume;
+    }
+
+/////////////////////////////////////////////////////
     /////////////// API Implementation///////////////////
     /////////////////////////////////////////////////////
 
@@ -126,7 +132,7 @@ public class UpdateVolumeCmd extends BaseAsyncCmd {
     @Override
     public void execute(){
         CallContext.current().setEventDetails("Volume Id: "+getId());
-        Volume result = _volumeService.updateVolume(getId(), getPath(), getState(), getStorageId());
+        Volume result = _volumeService.updateVolume(getId(), getPath(), getState(), getStorageId(),
getDisplayVolume());
         if (result != null) {
             VolumeResponse response = _responseGenerator.createVolumeResponse(result);
             response.setResponseName(getCommandName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a6852a34/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index 5580c31..bd4f158 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -2252,6 +2252,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
         Object id = cmd.getId();
         Object keyword = cmd.getKeyword();
         Long domainId = cmd.getDomainId();
+        Boolean isRootAdmin = _accountMgr.isRootAdmin(account.getType());
         // Keeping this logic consistent with domain specific zones
         // if a domainId is provided, we just return the disk offering
         // associated with this domain
@@ -2260,6 +2261,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
                 // check if the user's domain == do's domain || user's domain is
                 // a child of so's domain for non-root users
                 sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId);
+                if(!isRootAdmin){
+                    sc.addAnd("displayOffering", SearchCriteria.Op.EQ, 1);
+                }
                 return _diskOfferingJoinDao.searchAndCount(sc, searchFilter);
             } else {
                 throw new PermissionDeniedException("The account:" + account.getAccountName()
@@ -2292,6 +2296,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
             spc.addOr("domainId", SearchCriteria.Op.NULL); // include public
             // offering as where
             sc.addAnd("domainId", SearchCriteria.Op.SC, spc);
+            sc.addAnd("displayOffering", SearchCriteria.Op.EQ, 1);
             sc.addAnd("systemUse", SearchCriteria.Op.EQ, false); // non-root
             // users should
             // not see

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a6852a34/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 2b86bf5..4fda3b1 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -2310,6 +2310,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
         String name = cmd.getDiskOfferingName();
         String displayText = cmd.getDisplayText();
         Integer sortKey = cmd.getSortKey();
+        Boolean displayDiskOffering = cmd.getDisplayOffering();
 
         // Check if diskOffering exists
         DiskOffering diskOfferingHandle = _entityMgr.findById(DiskOffering.class, diskOfferingId);
@@ -2318,7 +2319,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
             throw new InvalidParameterValueException("Unable to find disk offering by id
" + diskOfferingId);
         }
 
-        boolean updateNeeded = (name != null || displayText != null || sortKey != null);
+        boolean updateNeeded = (name != null || displayText != null || sortKey != null ||
displayDiskOffering != null);
         if (!updateNeeded) {
             return _diskOfferingDao.findById(diskOfferingId);
         }
@@ -2337,6 +2338,10 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
             diskOffering.setSortKey(sortKey);
         }
 
+        if(displayDiskOffering != null){
+            diskOffering.setDisplayOffering(displayDiskOffering);
+        }
+
         // Note: tag editing commented out for now;keeping the code intact,
         // might need to re-enable in next releases
         // if (tags != null)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a6852a34/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 5161ca5..079f90c 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -1115,12 +1115,16 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPDATE, eventDescription = "updating
volume", async = true)
-    public Volume updateVolume(long volumeId, String path, String state, Long storageId)
{
+    public Volume updateVolume(long volumeId, String path, String state, Long storageId,
Boolean displayVolume) {
         VolumeVO volume = _volumeDao.findById(volumeId);
         
         if (path != null) {
             volume.setPath(path);
         }
+
+        if (displayVolume != null) {
+            volume.setDisplayVolume(displayVolume);
+        }
         
         if (state != null) {
             try {


Mime
View raw message