cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject git commit: updated refs/heads/rbac to 015d06e
Date Sat, 23 Nov 2013 02:48:49 GMT
Updated Branches:
  refs/heads/rbac f3ef86d29 -> 015d06e7f


Separate all volume related APIs to two Cmd classes based on two
response views.

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

Branch: refs/heads/rbac
Commit: 015d06e7fcc5b42b5df934bb532c80e197c091de
Parents: f3ef86d
Author: Min Chen <min.chen@citrix.com>
Authored: Fri Nov 22 18:48:20 2013 -0800
Committer: Min Chen <min.chen@citrix.com>
Committed: Fri Nov 22 18:48:20 2013 -0800

----------------------------------------------------------------------
 api/src/com/cloud/storage/VolumeApiService.java |  2 +-
 .../apache/cloudstack/acl/AclEntityType.java    |  3 +-
 .../cloudstack/api/ResponseGenerator.java       |  2 +-
 .../admin/volume/AttachVolumeCmdByAdmin.java    | 47 +++++++++++++++
 .../admin/volume/CreateVolumeCmdByAdmin.java    | 61 +++++++++++++++++++
 .../admin/volume/DetachVolumeCmdByAdmin.java    | 48 +++++++++++++++
 .../admin/volume/ListVolumesCmdByAdmin.java     | 63 ++++++++++++++++++++
 .../admin/volume/MigrateVolumeCmdByAdmin.java   | 47 +++++++++++++++
 .../admin/volume/ResizeVolumeCmdByAdmin.java    | 47 +++++++++++++++
 .../admin/volume/UpdateVolumeCmdByAdmin.java    | 44 ++++++++++++++
 .../admin/volume/UploadVolumeCmdByAdmin.java    | 57 ++++++++++++++++++
 .../command/user/volume/AttachVolumeCmd.java    | 13 ++--
 .../command/user/volume/CreateVolumeCmd.java    | 17 +++---
 .../command/user/volume/DetachVolumeCmd.java    | 13 ++--
 .../api/command/user/volume/ListVolumesCmd.java |  8 ++-
 .../command/user/volume/MigrateVolumeCmd.java   |  8 +--
 .../command/user/volume/ResizeVolumeCmd.java    | 11 ++--
 .../command/user/volume/UpdateVolumeCmd.java    | 14 +++--
 .../command/user/volume/UploadVolumeCmd.java    | 16 ++---
 server/src/com/cloud/api/ApiDBUtils.java        |  8 +--
 server/src/com/cloud/api/ApiResponseHelper.java |  4 +-
 .../com/cloud/api/query/QueryManagerImpl.java   | 35 ++++++-----
 .../com/cloud/api/query/ViewResponseHelper.java |  6 +-
 .../com/cloud/api/query/dao/VolumeJoinDao.java  |  6 +-
 .../cloud/api/query/dao/VolumeJoinDaoImpl.java  | 26 ++++----
 25 files changed, 522 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/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 4806ae7..351e2bf 100644
--- a/api/src/com/cloud/storage/VolumeApiService.java
+++ b/api/src/com/cloud/storage/VolumeApiService.java
@@ -67,7 +67,7 @@ public interface VolumeApiService {
     /**
      * Uploads the volume to secondary storage
      *
-     * @param UploadVolumeCmd cmd
+     * @param UploadVolumeCmdByAdmin cmd
      *
      * @return Volume object
      */

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/acl/AclEntityType.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/acl/AclEntityType.java b/api/src/org/apache/cloudstack/acl/AclEntityType.java
index 1ce3a70..109c7dc 100644
--- a/api/src/org/apache/cloudstack/acl/AclEntityType.java
+++ b/api/src/org/apache/cloudstack/acl/AclEntityType.java
@@ -2,5 +2,6 @@ package org.apache.cloudstack.acl;
 
 public enum AclEntityType {
     // currently supported entity, to be added one by one after we support acl on the entity
-    VM;
+    VM,
+    VOLUME;
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/ResponseGenerator.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
index aeb7521..f70f6ca 100644
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@ -259,7 +259,7 @@ public interface ResponseGenerator {
 
     ZoneResponse createZoneResponse(DataCenter dataCenter, Boolean showCapacities);
 
-    VolumeResponse createVolumeResponse(Volume volume);
+    VolumeResponse createVolumeResponse(ResponseView view, Volume volume);
 
     InstanceGroupResponse createInstanceGroupResponse(InstanceGroup group);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/admin/volume/AttachVolumeCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/AttachVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/AttachVolumeCmdByAdmin.java
new file mode 100644
index 0000000..3634a97
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/volume/AttachVolumeCmdByAdmin.java
@@ -0,0 +1,47 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.volume;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
+import org.apache.cloudstack.api.response.VolumeResponse;
+import org.apache.cloudstack.context.CallContext;
+
+import com.cloud.storage.Volume;
+
+@APICommand(name = "attachVolume", description = "Attaches a disk volume to a virtual machine.", responseObject = VolumeResponse.class, responseView = ResponseView.Full)
+public class AttachVolumeCmdByAdmin extends AttachVolumeCmd {
+    public static final Logger s_logger = Logger.getLogger(AttachVolumeCmdByAdmin.class.getName());
+
+    @Override
+    public void execute(){
+        CallContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId());
+        Volume result = _volumeService.attachVolumeToVM(this);
+        if (result != null) {
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, result);
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to attach volume");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/admin/volume/CreateVolumeCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/CreateVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/CreateVolumeCmdByAdmin.java
new file mode 100644
index 0000000..5df7481
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/volume/CreateVolumeCmdByAdmin.java
@@ -0,0 +1,61 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.volume;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
+import org.apache.cloudstack.api.response.VolumeResponse;
+import org.apache.cloudstack.context.CallContext;
+
+import com.cloud.storage.Snapshot;
+import com.cloud.storage.Volume;
+
+@APICommand(name = "createVolume", responseObject = VolumeResponse.class, description = "Creates a disk volume from a disk offering. This disk volume must still be attached to a virtual machine to make use of it.", responseView = ResponseView.Full)
+public class CreateVolumeCmdByAdmin extends CreateVolumeCmd {
+    public static final Logger s_logger = Logger.getLogger(CreateVolumeCmdByAdmin.class.getName());
+
+    @Override
+    public void execute(){
+        CallContext.current().setEventDetails("Volume Id: "+getEntityId()+((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId()));
+        Volume volume = _volumeService.createVolume(this);
+        if (volume != null) {
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume);
+            //FIXME - have to be moved to ApiResponseHelper
+            if (getSnapshotId() != null) {
+                Snapshot snap = _entityMgr.findById(Snapshot.class, getSnapshotId());
+                if (snap != null) {
+                    response.setSnapshotId(snap.getUuid()); // if the volume was
+                    // created from a
+                    // snapshot,
+                    // snapshotId will
+                    // be set so we pass
+                    // it back in the
+                    // response
+                }
+            }
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a volume");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/admin/volume/DetachVolumeCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/DetachVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/DetachVolumeCmdByAdmin.java
new file mode 100644
index 0000000..ab07a78
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/volume/DetachVolumeCmdByAdmin.java
@@ -0,0 +1,48 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.volume;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
+import org.apache.cloudstack.api.response.VolumeResponse;
+import org.apache.cloudstack.context.CallContext;
+
+import com.cloud.storage.Volume;
+
+@APICommand(name = "detachVolume", description = "Detaches a disk volume from a virtual machine.", responseObject = VolumeResponse.class, responseView = ResponseView.Full)
+public class DetachVolumeCmdByAdmin extends DetachVolumeCmd {
+    public static final Logger s_logger = Logger.getLogger(DetachVolumeCmdByAdmin.class.getName());
+
+
+    @Override
+    public void execute(){
+        CallContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId());
+        Volume result = _volumeService.detachVolumeFromVM(this);
+        if (result != null){
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, result);
+            response.setResponseName("volume");
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to detach volume");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/admin/volume/ListVolumesCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/ListVolumesCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/ListVolumesCmdByAdmin.java
new file mode 100644
index 0000000..a8741fd
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/volume/ListVolumesCmdByAdmin.java
@@ -0,0 +1,63 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.volume;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
+import org.apache.cloudstack.api.response.PodResponse;
+import org.apache.cloudstack.api.response.StoragePoolResponse;
+import org.apache.cloudstack.api.response.VolumeResponse;
+
+
+
+@APICommand(name = "listVolumes", description = "Lists all volumes.", responseObject = VolumeResponse.class, responseView = ResponseView.Full)
+public class ListVolumesCmdByAdmin extends ListVolumesCmd {
+    public static final Logger s_logger = Logger.getLogger(ListVolumesCmdByAdmin.class.getName());
+
+    @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class,
+            description="the pod id the disk volume belongs to")
+    private Long podId;
+
+
+    @Parameter(name=ApiConstants.STORAGE_ID, type=CommandType.UUID, entityType=StoragePoolResponse.class,
+            description="the ID of the storage pool, available to ROOT admin only", since="4.3", authorized = { RoleType.Admin })
+    private Long storageId;
+
+    
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+
+    @Override
+    public Long getPodId() {
+        return podId;
+    }
+
+
+    @Override
+    public Long getStorageId() {
+        return storageId;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/admin/volume/MigrateVolumeCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/MigrateVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/MigrateVolumeCmdByAdmin.java
new file mode 100644
index 0000000..c58a233
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/volume/MigrateVolumeCmdByAdmin.java
@@ -0,0 +1,47 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.volume;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd;
+import org.apache.cloudstack.api.response.VolumeResponse;
+
+import com.cloud.storage.Volume;
+
+
+@APICommand(name = "migrateVolume", description = "Migrate volume", responseObject = VolumeResponse.class, since = "3.0.0", responseView = ResponseView.Full)
+public class MigrateVolumeCmdByAdmin extends MigrateVolumeCmd {
+
+
+    @Override
+    public void execute(){
+    	Volume result;
+
+    	result = _volumeService.migrateVolume(this);
+    	if (result != null) {
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, result);
+    		response.setResponseName(getCommandName());
+    		setResponseObject(response);
+    	} else {
+    		throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate volume");
+    	}
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java
new file mode 100644
index 0000000..21bbdbb
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/volume/ResizeVolumeCmdByAdmin.java
@@ -0,0 +1,47 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.volume;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
+import org.apache.cloudstack.api.response.VolumeResponse;
+import org.apache.cloudstack.context.CallContext;
+
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.storage.Volume;
+
+
+@APICommand(name = "resizeVolume", description = "Resizes a volume", responseObject = VolumeResponse.class, responseView = ResponseView.Full)
+public class ResizeVolumeCmdByAdmin extends ResizeVolumeCmd {
+
+    @Override
+    public void execute() throws ResourceAllocationException{
+        CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
+    	Volume volume = _volumeService.resizeVolume(this);
+    	if (volume != null) {
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume);
+            //FIXME - have to be moved to ApiResponseHelper
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to resize volume");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/admin/volume/UpdateVolumeCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/UpdateVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/UpdateVolumeCmdByAdmin.java
new file mode 100644
index 0000000..f1afc3f
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/volume/UpdateVolumeCmdByAdmin.java
@@ -0,0 +1,44 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.volume;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.command.user.volume.UpdateVolumeCmd;
+import org.apache.cloudstack.api.response.VolumeResponse;
+import org.apache.cloudstack.context.CallContext;
+
+import com.cloud.storage.Volume;
+
+@APICommand(name = "updateVolume", description = "Updates the volume.", responseObject = VolumeResponse.class, responseView = ResponseView.Full)
+public class UpdateVolumeCmdByAdmin extends UpdateVolumeCmd {
+
+    @Override
+    public void execute(){
+        CallContext.current().setEventDetails("Volume Id: "+getId());
+        Volume result = _volumeService.updateVolume(getId(), getPath(), getState(), getStorageId(), getDisplayVolume());
+        if (result != null) {
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, result);
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update volume");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/admin/volume/UploadVolumeCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/volume/UploadVolumeCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/volume/UploadVolumeCmdByAdmin.java
new file mode 100644
index 0000000..e3e0c9b
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/volume/UploadVolumeCmdByAdmin.java
@@ -0,0 +1,57 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.command.admin.volume;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ApiErrorCode;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.ServerApiException;
+import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
+import org.apache.cloudstack.api.response.VolumeResponse;
+
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.storage.Volume;
+
+@APICommand(name = "uploadVolume", description = "Uploads a data disk.", responseObject = VolumeResponse.class, responseView = ResponseView.Full)
+public class UploadVolumeCmdByAdmin extends UploadVolumeCmd {
+    public static final Logger s_logger = Logger.getLogger(UploadVolumeCmdByAdmin.class.getName());
+
+
+    @Override
+    public void execute() throws ResourceUnavailableException,
+            InsufficientCapacityException, ServerApiException,
+            ConcurrentOperationException, ResourceAllocationException,
+            NetworkRuleConflictException {
+
+            Volume volume = _volumeService.uploadVolume(this);
+            if (volume != null){
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Full, volume);
+                response.setResponseName(getCommandName());
+                setResponseObject(response);
+            } else {
+                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upload volume");
+            }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java
index baec44f..eb864ba 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/AttachVolumeCmd.java
@@ -16,24 +16,25 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.event.EventTypes;
 import com.cloud.storage.Volume;
 import com.cloud.user.Account;
 
-@APICommand(name = "attachVolume", description="Attaches a disk volume to a virtual machine.", responseObject=VolumeResponse.class)
+@APICommand(name = "attachVolume", description = "Attaches a disk volume to a virtual machine.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted)
 public class AttachVolumeCmd extends BaseAsyncCmd {
     public static final Logger s_logger = Logger.getLogger(AttachVolumeCmd.class.getName());
     private static final String s_name = "attachvolumeresponse";
@@ -90,10 +91,12 @@ public class AttachVolumeCmd extends BaseAsyncCmd {
         return s_name;
     }
 
+    @Override
     public ApiCommandJobType getInstanceType() {
         return ApiCommandJobType.Volume;
     }
 
+    @Override
     public Long getInstanceId() {
         return getId();
     }
@@ -122,9 +125,9 @@ public class AttachVolumeCmd extends BaseAsyncCmd {
         CallContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId());
         Volume result = _volumeService.attachVolumeToVM(this);
         if (result != null) {
-            VolumeResponse response = _responseGenerator.createVolumeResponse(result);
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, result);
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to attach volume");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
index e5c7a51..cd8232e 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/CreateVolumeCmd.java
@@ -16,12 +16,15 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCreateCmd;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DiskOfferingResponse;
 import org.apache.cloudstack.api.response.DomainResponse;
@@ -31,14 +34,12 @@ import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.storage.Snapshot;
 import com.cloud.storage.Volume;
 
-@APICommand(name = "createVolume", responseObject=VolumeResponse.class, description="Creates a disk volume from a disk offering. This disk volume must still be attached to a virtual machine to make use of it.")
+@APICommand(name = "createVolume", responseObject = VolumeResponse.class, description = "Creates a disk volume from a disk offering. This disk volume must still be attached to a virtual machine to make use of it.", responseView = ResponseView.Restricted)
 public class CreateVolumeCmd extends BaseAsyncCreateCmd {
     public static final Logger s_logger = Logger.getLogger(CreateVolumeCmd.class.getName());
     private static final String s_name = "createvolumeresponse";
@@ -175,10 +176,10 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
     @Override
     public void create() throws ResourceAllocationException{
 
-        Volume volume = this._volumeService.allocVolume(this);
+        Volume volume = _volumeService.allocVolume(this);
         if (volume != null) {
-            this.setEntityId(volume.getId());
-            this.setEntityUuid(volume.getUuid());
+            setEntityId(volume.getId());
+            setEntityUuid(volume.getUuid());
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create volume");
         }
@@ -189,7 +190,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
         CallContext.current().setEventDetails("Volume Id: "+getEntityId()+((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId()));
         Volume volume = _volumeService.createVolume(this);
         if (volume != null) {
-            VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, volume);
             //FIXME - have to be moved to ApiResponseHelper
             if (getSnapshotId() != null) {
                 Snapshot snap = _entityMgr.findById(Snapshot.class, getSnapshotId());
@@ -204,7 +205,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
                 }
             }
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a volume");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java
index f2fe0cd..fc68fe1 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/DetachVolumeCmd.java
@@ -16,25 +16,26 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.event.EventTypes;
 import com.cloud.storage.Volume;
 import com.cloud.user.Account;
 import com.cloud.uservm.UserVm;
 
-@APICommand(name = "detachVolume", description="Detaches a disk volume from a virtual machine.", responseObject=VolumeResponse.class)
+@APICommand(name = "detachVolume", description = "Detaches a disk volume from a virtual machine.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted)
 public class DetachVolumeCmd extends BaseAsyncCmd {
     public static final Logger s_logger = Logger.getLogger(DetachVolumeCmd.class.getName());
     private static final String s_name = "detachvolumeresponse";
@@ -83,10 +84,12 @@ public class DetachVolumeCmd extends BaseAsyncCmd {
         return "volume";
     }
 
+    @Override
     public ApiCommandJobType getInstanceType() {
         return ApiCommandJobType.Volume;
     }
 
+    @Override
     public Long getInstanceId() {
         return getId();
     }
@@ -133,9 +136,9 @@ public class DetachVolumeCmd extends BaseAsyncCmd {
         CallContext.current().setEventDetails("Volume Id: "+getId()+" VmId: "+getVirtualMachineId());
         Volume result = _volumeService.detachVolumeFromVM(this);
         if (result != null){
-            VolumeResponse response = _responseGenerator.createVolumeResponse(result);
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, result);
             response.setResponseName("volume");
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to detach volume");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java
index f6bdb3c..900cd75 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/ListVolumesCmd.java
@@ -16,12 +16,15 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.acl.RoleType;
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.response.HostResponse;
 import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.PodResponse;
@@ -29,11 +32,10 @@ import org.apache.cloudstack.api.response.StoragePoolResponse;
 import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
-import org.apache.log4j.Logger;
 
 
 
-@APICommand(name = "listVolumes", description="Lists all volumes.", responseObject=VolumeResponse.class)
+@APICommand(name = "listVolumes", description = "Lists all volumes.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted)
 public class ListVolumesCmd extends BaseListTaggedResourcesCmd {
     public static final Logger s_logger = Logger.getLogger(ListVolumesCmd.class.getName());
 
@@ -129,6 +131,6 @@ public class ListVolumesCmd extends BaseListTaggedResourcesCmd {
     public void execute(){
         ListResponse<VolumeResponse> response = _queryService.searchForVolumes(this);
         response.setResponseName(getCommandName());
-        this.setResponseObject(response);
+        setResponseObject(response);
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
index 6186397..de5a555 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/MigrateVolumeCmd.java
@@ -21,17 +21,17 @@ import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.StoragePoolResponse;
 import org.apache.cloudstack.api.response.VolumeResponse;
 
 import com.cloud.event.EventTypes;
-import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.storage.Volume;
 import com.cloud.user.Account;
 
 
-@APICommand(name = "migrateVolume", description="Migrate volume", responseObject=VolumeResponse.class, since="3.0.0")
+@APICommand(name = "migrateVolume", description = "Migrate volume", responseObject = VolumeResponse.class, since = "3.0.0", responseView = ResponseView.Restricted)
 public class MigrateVolumeCmd extends BaseAsyncCmd {
     private static final String s_name = "migratevolumeresponse";
 
@@ -102,9 +102,9 @@ public class MigrateVolumeCmd extends BaseAsyncCmd {
 
     	result = _volumeService.migrateVolume(this);
     	if (result != null) {
-    		VolumeResponse response = _responseGenerator.createVolumeResponse(result);
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, result);
     		response.setResponseName(getCommandName());
-    		this.setResponseObject(response);
+    		setResponseObject(response);
     	} else {
     		throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate volume");
     	}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
index 811440d..85bf433 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
@@ -16,19 +16,20 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.DiskOfferingResponse;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.PermissionDeniedException;
@@ -38,7 +39,7 @@ import com.cloud.storage.Volume;
 import com.cloud.user.Account;
 
 
-@APICommand(name="resizeVolume", description="Resizes a volume", responseObject=VolumeResponse.class)
+@APICommand(name = "resizeVolume", description = "Resizes a volume", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted)
 public class ResizeVolumeCmd extends BaseAsyncCmd {
     public static final Logger s_logger = Logger.getLogger(ResizeVolumeCmd.class.getName());
 
@@ -137,10 +138,10 @@ public class ResizeVolumeCmd extends BaseAsyncCmd {
         CallContext.current().setEventDetails("Volume Id: " + getEntityId() + " to size " + getSize() + "G");
     	Volume volume = _volumeService.resizeVolume(this);
     	if (volume != null) {
-            VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, volume);
             //FIXME - have to be moved to ApiResponseHelper
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to resize volume");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/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 d4e3a6c..859ad8a 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
@@ -16,23 +16,25 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.StoragePoolResponse;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.context.CallContext;
-import org.apache.log4j.Logger;
 
 import com.cloud.event.EventTypes;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.storage.Volume;
 
-@APICommand(name = "updateVolume", description="Updates the volume.", responseObject=VolumeResponse.class)
+@APICommand(name = "updateVolume", description = "Updates the volume.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted)
 public class UpdateVolumeCmd extends BaseAsyncCmd {
     public static final Logger s_logger = Logger.getLogger(UpdateVolumeCmd.class.getName());
     private static final String s_name = "updatevolumeresponse";
@@ -90,10 +92,12 @@ public class UpdateVolumeCmd extends BaseAsyncCmd {
         return s_name;
     }
 
+    @Override
     public ApiCommandJobType getInstanceType() {
         return ApiCommandJobType.Volume;
     }
 
+    @Override
     public Long getInstanceId() {
         return getId();
     }
@@ -117,7 +121,7 @@ public class UpdateVolumeCmd extends BaseAsyncCmd {
         StringBuilder desc = new StringBuilder("Updating volume: ");
         desc.append(getId()).append(" with");
         if (getPath() != null) {
-            desc.append(" path " + getPath());            
+            desc.append(" path " + getPath());
         }
         if (getStorageId() != null) {
             desc.append(", storage id " + getStorageId());
@@ -134,9 +138,9 @@ public class UpdateVolumeCmd extends BaseAsyncCmd {
         CallContext.current().setEventDetails("Volume Id: "+getId());
         Volume result = _volumeService.updateVolume(getId(), getPath(), getState(), getStorageId(), getDisplayVolume());
         if (result != null) {
-            VolumeResponse response = _responseGenerator.createVolumeResponse(result);
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, result);
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update volume");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java b/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java
index f9104f7..11eab5f 100644
--- a/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/volume/UploadVolumeCmd.java
@@ -16,21 +16,21 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.volume;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.BaseCmd.CommandType;
 import org.apache.cloudstack.api.response.DomainResponse;
 import org.apache.cloudstack.api.response.ProjectResponse;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.event.EventTypes;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InsufficientCapacityException;
@@ -39,7 +39,7 @@ import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.storage.Volume;
 
-@APICommand(name = "uploadVolume", description="Uploads a data disk.", responseObject=VolumeResponse.class)
+@APICommand(name = "uploadVolume", description = "Uploads a data disk.", responseObject = VolumeResponse.class, responseView = ResponseView.Restricted)
 public class UploadVolumeCmd extends BaseAsyncCmd {
     public static final Logger s_logger = Logger.getLogger(UploadVolumeCmd.class.getName());
     private static final String s_name = "uploadvolumeresponse";
@@ -77,7 +77,7 @@ public class UploadVolumeCmd extends BaseAsyncCmd {
 
     @Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.UUID, entityType = ProjectResponse.class,
             description="Upload volume for the project")
-    private Long projectId;    
+    private Long projectId;
 
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
@@ -112,7 +112,7 @@ public class UploadVolumeCmd extends BaseAsyncCmd {
     }
     
     public String getImageStoreUuid() {
-        return this.imageStoreUuid;
+        return imageStoreUuid;
     }
 
     /////////////////////////////////////////////////////
@@ -127,9 +127,9 @@ public class UploadVolumeCmd extends BaseAsyncCmd {
 
             Volume volume = _volumeService.uploadVolume(this);
             if (volume != null){
-                VolumeResponse response = _responseGenerator.createVolumeResponse(volume);
+            VolumeResponse response = _responseGenerator.createVolumeResponse(ResponseView.Restricted, volume);
                 response.setResponseName(getCommandName());
-                this.setResponseObject(response);
+                setResponseObject(response);
             } else {
                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upload volume");
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index c0cb104..3ae7142 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -1560,13 +1560,13 @@ public class ApiDBUtils {
         return _hostJoinDao.newHostView(vr);
     }
 
-    public static VolumeResponse newVolumeResponse(VolumeJoinVO vr) {
-        return _volJoinDao.newVolumeResponse(vr);
+    public static VolumeResponse newVolumeResponse(ResponseView view, VolumeJoinVO vr) {
+        return _volJoinDao.newVolumeResponse(view, vr);
     }
 
 
-    public static VolumeResponse fillVolumeDetails(VolumeResponse vrData, VolumeJoinVO vr){
-        return _volJoinDao.setVolumeResponse(vrData, vr);
+    public static VolumeResponse fillVolumeDetails(ResponseView view, VolumeResponse vrData, VolumeJoinVO vr) {
+        return _volJoinDao.setVolumeResponse(view, vrData, vr);
     }
 
     public static List<VolumeJoinVO> newVolumeView(Volume vr){

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 6851473..16f3c65 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -920,9 +920,9 @@ public class ApiResponseHelper implements ResponseGenerator {
     }
 
     @Override
-    public VolumeResponse createVolumeResponse(Volume volume) {
+    public VolumeResponse createVolumeResponse(ResponseView view, Volume volume) {
         List<VolumeJoinVO> viewVrs = ApiDBUtils.newVolumeView(volume);
-        List<VolumeResponse> listVrs = ViewResponseHelper.createVolumeResponse(viewVrs.toArray(new VolumeJoinVO[viewVrs.size()]));
+        List<VolumeResponse> listVrs = ViewResponseHelper.createVolumeResponse(view, viewVrs.toArray(new VolumeJoinVO[viewVrs.size()]));
         assert listVrs != null && listVrs.size() == 1 : "There should be one volume returned";
         return listVrs.get(0);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/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 37f4632..d436453 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -51,6 +51,7 @@ import org.apache.cloudstack.api.command.admin.storage.ListSecondaryStagingStore
 import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
 import org.apache.cloudstack.api.command.admin.user.ListUsersCmd;
 import org.apache.cloudstack.api.command.admin.vm.ListVMsCmdByAdmin;
+import org.apache.cloudstack.api.command.admin.volume.ListVolumesCmdByAdmin;
 import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
 import org.apache.cloudstack.api.command.user.account.ListProjectAccountsCmd;
 import org.apache.cloudstack.api.command.user.event.ListEventsCmd;
@@ -1614,7 +1615,12 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         Pair<List<VolumeJoinVO>, Integer> result = searchForVolumesInternal(cmd);
         ListResponse<VolumeResponse> response = new ListResponse<VolumeResponse>();
 
-        List<VolumeResponse> volumeResponses = ViewResponseHelper.createVolumeResponse(result.first().toArray(
+        ResponseView respView = ResponseView.Restricted;
+        if (cmd instanceof ListVolumesCmdByAdmin) {
+            respView = ResponseView.Full;
+        }
+
+        List<VolumeResponse> volumeResponses = ViewResponseHelper.createVolumeResponse(respView, result.first().toArray(
                 new VolumeJoinVO[result.first().size()]));
         response.setResponses(volumeResponses, result.second());
         return response;
@@ -1623,7 +1629,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
     private Pair<List<VolumeJoinVO>, Integer> searchForVolumesInternal(ListVolumesCmd cmd) {
 
         Account caller = CallContext.current().getCallingAccount();
+        List<Long> permittedDomains = new ArrayList<Long>();
         List<Long> permittedAccounts = new ArrayList<Long>();
+        List<Long> permittedResources = new ArrayList<Long>();
 
         Long id = cmd.getId();
         Long vmInstanceId = cmd.getVirtualMachineId();
@@ -1631,20 +1639,16 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         String keyword = cmd.getKeyword();
         String type = cmd.getType();
         Map<String, String> tags = cmd.getTags();
-        boolean isRootAdmin = _accountMgr.isRootAdmin(caller.getType());
         Long storageId = cmd.getStorageId();
 
         Long zoneId = cmd.getZoneId();
-        Long podId = null;
-        if (_accountMgr.isAdmin(caller.getType())) {
-            podId = cmd.getPodId();
-        }
+        Long podId = cmd.getPodId();
 
         Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
                 cmd.getDomainId(), cmd.isRecursive(), null);
-        _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts,
-                domainIdRecursiveListProject, cmd.listAll(), false);
-        Long domainId = domainIdRecursiveListProject.first();
+        _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedDomains, permittedAccounts, permittedResources,
+                domainIdRecursiveListProject, cmd.listAll(), false, "listVolumes");
+//        Long domainId = domainIdRecursiveListProject.first();
         Boolean isRecursive = domainIdRecursiveListProject.second();
         ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
         Filter searchFilter = new Filter(VolumeJoinVO.class, "created", false, cmd.getStartIndex(),
@@ -1659,8 +1663,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         // number of
         // records with
         // pagination
-        _accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts,
-                listProjectResourcesCriteria);
+
 
         sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ);
         sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
@@ -1675,7 +1678,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         // display UserVM volumes only
         sb.and().op("type", sb.entity().getVmType(), SearchCriteria.Op.NIN);
         sb.or("nulltype", sb.entity().getVmType(), SearchCriteria.Op.NULL);
-        if(!isRootAdmin){
+        if (!(cmd instanceof ListVolumesCmdByAdmin)) {
             sb.and("displayVolume", sb.entity().isDisplayVolume(), SearchCriteria.Op.EQ);
         }
         sb.cp();
@@ -1683,8 +1686,10 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
 
         // now set the SC criteria...
         SearchCriteria<VolumeJoinVO> sc = sb.create();
-        _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts,
-                listProjectResourcesCriteria);
+        SearchCriteria<VolumeJoinVO> aclSc = _volumeJoinDao.createSearchCriteria();
+
+        // building ACL search criteria
+        _accountMgr.buildACLViewSearchCriteria(sc, aclSc, isRecursive, permittedDomains, permittedAccounts, permittedResources, listProjectResourcesCriteria);
 
         if (keyword != null) {
             SearchCriteria<VolumeJoinVO> ssc = _volumeJoinDao.createSearchCriteria();
@@ -1732,7 +1737,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
             sc.setParameters("storageId", storageId);
         }
 
-        if(!isRootAdmin){
+        if (!(cmd instanceof ListVolumesCmdByAdmin)) {
             sc.setParameters("displayVolume", 1);
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/server/src/com/cloud/api/query/ViewResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/ViewResponseHelper.java b/server/src/com/cloud/api/query/ViewResponseHelper.java
index 0cf8e16..7f5168c 100644
--- a/server/src/com/cloud/api/query/ViewResponseHelper.java
+++ b/server/src/com/cloud/api/query/ViewResponseHelper.java
@@ -266,17 +266,17 @@ public class ViewResponseHelper {
         return new ArrayList<HostForMigrationResponse>(vrDataList.values());
     }
 
-    public static List<VolumeResponse> createVolumeResponse(VolumeJoinVO... volumes) {
+    public static List<VolumeResponse> createVolumeResponse(ResponseView view, VolumeJoinVO... volumes) {
         Hashtable<Long, VolumeResponse> vrDataList = new Hashtable<Long, VolumeResponse>();
         for (VolumeJoinVO vr : volumes) {
             VolumeResponse vrData = vrDataList.get(vr.getId());
             if ( vrData == null ){
                 // first time encountering this volume
-                vrData = ApiDBUtils.newVolumeResponse(vr);
+                vrData = ApiDBUtils.newVolumeResponse(view, vr);
             }
             else{
                 // update tags
-                vrData = ApiDBUtils.fillVolumeDetails(vrData, vr);
+                vrData = ApiDBUtils.fillVolumeDetails(view, vrData, vr);
             }
             vrDataList.put(vr.getId(), vrData);
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/server/src/com/cloud/api/query/dao/VolumeJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/VolumeJoinDao.java b/server/src/com/cloud/api/query/dao/VolumeJoinDao.java
index 67509cf..ebcf0bc 100644
--- a/server/src/com/cloud/api/query/dao/VolumeJoinDao.java
+++ b/server/src/com/cloud/api/query/dao/VolumeJoinDao.java
@@ -18,18 +18,18 @@ package com.cloud.api.query.dao;
 
 import java.util.List;
 
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.response.VolumeResponse;
 
-
 import com.cloud.api.query.vo.VolumeJoinVO;
 import com.cloud.storage.Volume;
 import com.cloud.utils.db.GenericDao;
 
 public interface VolumeJoinDao extends GenericDao<VolumeJoinVO, Long> {
 
-    VolumeResponse newVolumeResponse(VolumeJoinVO vol);
+    VolumeResponse newVolumeResponse(ResponseView view, VolumeJoinVO vol);
 
-    VolumeResponse setVolumeResponse(VolumeResponse volData, VolumeJoinVO vol);
+    VolumeResponse setVolumeResponse(ResponseView view, VolumeResponse volData, VolumeJoinVO vol);
 
     List<VolumeJoinVO> newVolumeView(Volume vol);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/015d06e7/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
index fdee690..dfcf028 100644
--- a/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/VolumeJoinDaoImpl.java
@@ -22,13 +22,14 @@ import java.util.List;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.response.VolumeResponse;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
 import com.cloud.api.ApiDBUtils;
 import com.cloud.api.ApiResponseHelper;
 import com.cloud.api.query.vo.ResourceTagJoinVO;
@@ -40,7 +41,6 @@ import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
 import com.cloud.storage.Volume;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
-import com.cloud.user.AccountService;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -70,14 +70,14 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
         volIdSearch.and("id", volIdSearch.entity().getId(), SearchCriteria.Op.EQ);
         volIdSearch.done();
 
-        this._count = "select count(distinct id) from volume_view WHERE ";
+        _count = "select count(distinct id) from volume_view WHERE ";
     }
 
 
 
 
     @Override
-    public VolumeResponse newVolumeResponse(VolumeJoinVO volume) {
+    public VolumeResponse newVolumeResponse(ResponseView view, VolumeJoinVO volume) {
         Account caller = CallContext.current().getCallingAccount();
 
         VolumeResponse volResponse = new VolumeResponse();
@@ -118,9 +118,11 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
             volResponse.setSize(volume.getVolumeStoreSize());
             volResponse.setCreated(volume.getCreatedOnStore());
 
-            if (_accountMgr.isRootAdmin(caller.getId())
-                    || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN)
+            // if (_accountMgr.isRootAdmin(caller.getId())
+            //         || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN)
+            if (view == ResponseView.Full) {
                 volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getFormat()).toString());
+            }
             if (volume.getDownloadState() != Status.DOWNLOADED) {
                 String volumeStatus = "Processing";
                 if (volume.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
@@ -147,7 +149,8 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
             }
         }
 
-        if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN){
+        // if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN){
+        if (view == ResponseView.Full) {
             volResponse.setPath(volume.getPath());
         }
 
@@ -180,7 +183,8 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
         }
         
         // return hypervisor and storage pool info for ROOT and Resource domain only
-        if (_accountMgr.isRootAdmin(caller.getId()) || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
+        // if (_accountMgr.isRootAdmin(caller.getId()) || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
+        if (view == ResponseView.Full) {
             if (volume.getState() != Volume.State.UploadOp && volume.getHypervisorType() != null) {
                 volResponse.setHypervisor(volume.getHypervisorType().toString());
             }
@@ -229,7 +233,7 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
 
 
     @Override
-    public VolumeResponse setVolumeResponse(VolumeResponse volData, VolumeJoinVO vol) {
+    public VolumeResponse setVolumeResponse(ResponseView view, VolumeResponse volData, VolumeJoinVO vol) {
         long tag_id = vol.getTagId();
         if (tag_id > 0) {
             ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);


Mime
View raw message