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 8f21eca
Date Tue, 10 Dec 2013 20:24:00 GMT
Updated Branches:
  refs/heads/rbac e66b58b65 -> 8f21eca92


Separate Template/ISO related APIs to use two different views.

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

Branch: refs/heads/rbac
Commit: 8f21eca922d80111d480987b4f56d5ff8357f42c
Parents: e66b58b
Author: Min Chen <min.chen@citrix.com>
Authored: Tue Dec 10 12:23:39 2013 -0800
Committer: Min Chen <min.chen@citrix.com>
Committed: Tue Dec 10 12:23:39 2013 -0800

----------------------------------------------------------------------
 .../cloudstack/api/ResponseGenerator.java       | 27 ++-------
 .../command/admin/iso/ListIsosCmdByAdmin.java   | 27 +++++++++
 .../admin/iso/RegisterIsoCmdByAdmin.java        | 53 ++++++++++++++++
 .../command/admin/iso/UpdateIsoCmdByAdmin.java  | 45 ++++++++++++++
 .../admin/template/CopyTemplateCmdByAdmin.java  | 63 ++++++++++++++++++++
 .../template/CreateTemplateCmdByAdmin.java      | 62 +++++++++++++++++++
 .../admin/template/ListTemplatesCmdByAdmin.java | 27 +++++++++
 .../admin/template/PrepareTemplateCmd.java      |  8 ++-
 .../template/RegisterTemplateCmdByAdmin.java    | 57 ++++++++++++++++++
 .../template/UpdateTemplateCmdByAdmin.java      | 47 +++++++++++++++
 .../api/command/user/iso/ListIsosCmd.java       | 10 ++--
 .../api/command/user/iso/RegisterIsoCmd.java    | 15 ++---
 .../api/command/user/iso/UpdateIsoCmd.java      | 10 ++--
 .../command/user/template/CopyTemplateCmd.java  | 14 +++--
 .../user/template/CreateTemplateCmd.java        | 55 ++++++++---------
 .../command/user/template/ListTemplatesCmd.java | 10 ++--
 .../user/template/RegisterTemplateCmd.java      | 13 ++--
 .../user/template/UpdateTemplateCmd.java        | 10 ++--
 server/src/com/cloud/api/ApiDBUtils.java        |  8 +--
 server/src/com/cloud/api/ApiResponseHelper.java | 24 ++++----
 .../com/cloud/api/query/QueryManagerImpl.java   | 16 ++++-
 .../com/cloud/api/query/ViewResponseHelper.java | 14 ++---
 .../cloud/api/query/dao/TemplateJoinDao.java    |  5 +-
 .../api/query/dao/TemplateJoinDaoImpl.java      | 56 ++++++++---------
 .../cloud/api/query/dao/UserVmJoinDaoImpl.java  |  2 +-
 25 files changed, 532 insertions(+), 146 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/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 77ba4ce..730f6fd 100644
--- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java
+++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java
@@ -216,10 +216,6 @@ public interface ResponseGenerator {
 
     SnapshotPolicyResponse createSnapshotPolicyResponse(SnapshotPolicy policy);
 
-    //List<UserVmResponse> createUserVmResponse(String objectName, UserVm... userVms);
-
-    //List<UserVmResponse> createUserVmResponse(String objectName, EnumSet<VMDetails> details, UserVm... userVms);
-
     List<UserVmResponse> createUserVmResponse(ResponseView view, String objectName, UserVm... userVms);
 
     List<UserVmResponse> createUserVmResponse(ResponseView view, String objectName, EnumSet<VMDetails> details, UserVm... userVms);
@@ -285,17 +281,13 @@ public interface ResponseGenerator {
 
     Host findHostById(Long hostId);
 
-    //List<TemplateResponse> createTemplateResponses(long templateId, long zoneId, boolean readyOnly);
-
     VpnUsersResponse createVpnUserResponse(VpnUser user);
 
     RemoteAccessVpnResponse createRemoteAccessVpnResponse(RemoteAccessVpn vpn);
 
-    List<TemplateResponse> createTemplateResponses(long templateId, Long zoneId, boolean readyOnly);
-
-    List<TemplateResponse> createTemplateResponses(long templateId, Long snapshotId, Long volumeId, boolean readyOnly);
+    List<TemplateResponse> createTemplateResponses(ResponseView view, long templateId, Long zoneId, boolean readyOnly);
 
-    //ListResponse<SecurityGroupResponse> createSecurityGroupResponses(List<? extends SecurityGroupRules> networkGroups);
+    List<TemplateResponse> createTemplateResponses(ResponseView view, long templateId, Long snapshotId, Long volumeId, boolean readyOnly);
 
     SecurityGroupResponse createSecurityGroupResponseFromSecurityGroupRule(List<? extends SecurityRule> SecurityRules);
 
@@ -309,11 +301,9 @@ public interface ResponseGenerator {
 
     EventResponse createEventResponse(Event event);
 
-    //List<EventResponse> createEventResponse(EventJoinVO... events);
+    TemplateResponse createTemplateUpdateResponse(ResponseView view, VirtualMachineTemplate result);
 
-    TemplateResponse createTemplateUpdateResponse(VirtualMachineTemplate result);
-
-    List<TemplateResponse> createTemplateResponses(VirtualMachineTemplate result, Long zoneId, boolean readyOnly);
+    List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachineTemplate result, Long zoneId, boolean readyOnly);
 
     List<CapacityResponse> createCapacityResponse(List<? extends Capacity> result, DecimalFormat format);
 
@@ -327,20 +317,15 @@ public interface ResponseGenerator {
 
     UserResponse createUserResponse(User user);
 
-    //List<UserResponse> createUserResponse(UserAccountJoinVO... users);
-
     AccountResponse createUserAccountResponse(UserAccount user);
 
     Long getSecurityGroupId(String groupName, long accountId);
 
-    List<TemplateResponse> createIsoResponses(VirtualMachineTemplate iso, Long zoneId, boolean readyOnly);
-
-    // List<TemplateResponse> createIsoResponses(long isoId, Long zoneId, boolean readyOnly);
-    //List<TemplateResponse> createIsoResponses(VirtualMachineTemplate iso, long zoneId, boolean readyOnly);
+    List<TemplateResponse> createIsoResponses(ResponseView view, VirtualMachineTemplate iso, Long zoneId, boolean readyOnly);
 
     ProjectResponse createProjectResponse(Project project);
 
-    List<TemplateResponse> createTemplateResponses(long templateId, Long vmId);
+    List<TemplateResponse> createTemplateResponses(ResponseView view, long templateId, Long vmId);
 
     FirewallResponse createFirewallResponse(FirewallRule fwRule);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/admin/iso/ListIsosCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/iso/ListIsosCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/iso/ListIsosCmdByAdmin.java
new file mode 100644
index 0000000..660084a
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/iso/ListIsosCmdByAdmin.java
@@ -0,0 +1,27 @@
+// 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.iso;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.command.user.iso.ListIsosCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+
+@APICommand(name = "listIsos", description = "Lists all available ISO files.", responseObject = TemplateResponse.class, responseView = ResponseView.Full)
+public class ListIsosCmdByAdmin extends ListIsosCmd {
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/admin/iso/RegisterIsoCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/iso/RegisterIsoCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/iso/RegisterIsoCmdByAdmin.java
new file mode 100644
index 0000000..79687f1
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/iso/RegisterIsoCmdByAdmin.java
@@ -0,0 +1,53 @@
+// 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.iso;
+
+import java.util.List;
+
+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.iso.RegisterIsoCmd;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.TemplateResponse;
+
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.template.VirtualMachineTemplate;
+
+@APICommand(name = "registerIso", responseObject = TemplateResponse.class, description = "Registers an existing ISO into the CloudStack Cloud.", responseView = ResponseView.Full)
+public class RegisterIsoCmdByAdmin extends RegisterIsoCmd {
+    public static final Logger s_logger = Logger.getLogger(RegisterIsoCmdByAdmin.class.getName());
+
+
+    @Override
+    public void execute() throws ResourceAllocationException{
+        VirtualMachineTemplate template = _templateService.registerIso(this);
+        if (template != null) {
+            ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
+            List<TemplateResponse> templateResponses = _responseGenerator.createIsoResponses(ResponseView.Full, template, zoneId, false);
+            response.setResponses(templateResponses);
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register iso");
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/admin/iso/UpdateIsoCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/iso/UpdateIsoCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/iso/UpdateIsoCmdByAdmin.java
new file mode 100644
index 0000000..1caf398
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/iso/UpdateIsoCmdByAdmin.java
@@ -0,0 +1,45 @@
+// 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.iso;
+
+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.iso.UpdateIsoCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+
+import com.cloud.template.VirtualMachineTemplate;
+
+@APICommand(name = "updateIso", description = "Updates an ISO file.", responseObject = TemplateResponse.class, responseView = ResponseView.Full)
+public class UpdateIsoCmdByAdmin extends UpdateIsoCmd {
+    public static final Logger s_logger = Logger.getLogger(UpdateIsoCmdByAdmin.class.getName());
+
+    @Override
+    public void execute(){
+        VirtualMachineTemplate result = _templateService.updateTemplate(this);
+        if (result != null) {
+            TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(ResponseView.Full, result);
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update iso");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/admin/template/CopyTemplateCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/template/CopyTemplateCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/template/CopyTemplateCmdByAdmin.java
new file mode 100644
index 0000000..c6a5ee7
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/template/CopyTemplateCmdByAdmin.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.template;
+
+import java.util.List;
+
+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.template.CopyTemplateCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+import org.apache.cloudstack.context.CallContext;
+
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.StorageUnavailableException;
+import com.cloud.template.VirtualMachineTemplate;
+
+@APICommand(name = "copyTemplate", description = "Copies a template from one zone to another.", responseObject = TemplateResponse.class, responseView = ResponseView.Full)
+public class CopyTemplateCmdByAdmin extends CopyTemplateCmd {
+    public static final Logger s_logger = Logger.getLogger(CopyTemplateCmdByAdmin.class.getName());
+
+    @Override
+    public void execute() throws ResourceAllocationException{
+        try {
+            CallContext.current().setEventDetails(getEventDescription());
+            VirtualMachineTemplate template = _templateService.copyTemplate(this);
+
+            if (template != null){
+                List<TemplateResponse> listResponse = _responseGenerator.createTemplateResponses(ResponseView.Full, template, getDestinationZoneId(), false);
+                TemplateResponse response = new TemplateResponse();
+                if (listResponse != null && !listResponse.isEmpty()) {
+                    response = listResponse.get(0);
+                }
+
+                response.setResponseName(getCommandName());
+                setResponseObject(response);
+            } else {
+                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to copy template");
+            }
+        } catch (StorageUnavailableException ex) {
+            s_logger.warn("Exception: ", ex);
+            throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/admin/template/CreateTemplateCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/template/CreateTemplateCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/template/CreateTemplateCmdByAdmin.java
new file mode 100644
index 0000000..d316278
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/template/CreateTemplateCmdByAdmin.java
@@ -0,0 +1,62 @@
+// 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.template;
+
+import java.util.List;
+
+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.template.CreateTemplateCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+import org.apache.cloudstack.context.CallContext;
+
+import com.cloud.template.VirtualMachineTemplate;
+
+@APICommand(name = "createTemplate", responseObject = TemplateResponse.class, description = "Creates a template of a virtual machine. " + "The virtual machine must be in a STOPPED state. "
+        + "A template created from this command is automatically designated as a private template visible to the account that created it.", responseView = ResponseView.Full)
+public class CreateTemplateCmdByAdmin extends CreateTemplateCmd {
+    public static final Logger s_logger = Logger.getLogger(CreateTemplateCmdByAdmin.class.getName());
+
+    @Override
+    public void execute() {
+        CallContext.current().setEventDetails("Template Id: "+getEntityId()+((getSnapshotId() == null) ? " from volume Id: " + getVolumeId() : " from snapshot Id: " + getSnapshotId()));
+        VirtualMachineTemplate template = null;
+        template = _templateService.createPrivateTemplate(this);
+
+        if (template != null){
+            List<TemplateResponse> templateResponses;
+            if (isBareMetal()) {
+                templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Full, template.getId(), vmId);
+            } else {
+                templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Full, template.getId(), snapshotId, volumeId, false);
+            }
+            TemplateResponse response = new TemplateResponse();
+            if (templateResponses != null && !templateResponses.isEmpty()) {
+                response = templateResponses.get(0);
+            }
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private template");
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/admin/template/ListTemplatesCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/template/ListTemplatesCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/template/ListTemplatesCmdByAdmin.java
new file mode 100644
index 0000000..bc74288
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/template/ListTemplatesCmdByAdmin.java
@@ -0,0 +1,27 @@
+// 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.template;
+
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
+import org.apache.cloudstack.api.command.user.template.ListTemplatesCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+
+@APICommand(name = "listTemplates", description = "List all public, private, and privileged templates.", responseObject = TemplateResponse.class, responseView = ResponseView.Full)
+public class ListTemplatesCmdByAdmin extends ListTemplatesCmd {
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/admin/template/PrepareTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/template/PrepareTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/admin/template/PrepareTemplateCmd.java
index aee35ad..06cc6e0 100644
--- a/api/src/org/apache/cloudstack/api/command/admin/template/PrepareTemplateCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/admin/template/PrepareTemplateCmd.java
@@ -18,14 +18,16 @@ package org.apache.cloudstack.api.command.admin.template;
 
 import java.util.List;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
-import org.apache.log4j.Logger;
 
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
@@ -80,10 +82,10 @@ public class PrepareTemplateCmd extends BaseCmd {
         ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
 
         VirtualMachineTemplate vmTemplate = _templateService.prepareTemplate(templateId, zoneId);
-        List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(vmTemplate, zoneId, true);
+        List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Full, vmTemplate, zoneId, true);
         response.setResponses(templateResponses);
         response.setResponseName(getCommandName());
-        this.setResponseObject(response);
+        setResponseObject(response);
     }
 }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/admin/template/RegisterTemplateCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/template/RegisterTemplateCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/template/RegisterTemplateCmdByAdmin.java
new file mode 100644
index 0000000..c623938
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/template/RegisterTemplateCmdByAdmin.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.template;
+
+import java.net.URISyntaxException;
+import java.util.List;
+
+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.template.RegisterTemplateCmd;
+import org.apache.cloudstack.api.response.ListResponse;
+import org.apache.cloudstack.api.response.TemplateResponse;
+
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.template.VirtualMachineTemplate;
+
+@APICommand(name = "registerTemplate", description = "Registers an existing template into the CloudStack cloud. ", responseObject = TemplateResponse.class, responseView = ResponseView.Full)
+public class RegisterTemplateCmdByAdmin extends RegisterTemplateCmd {
+    public static final Logger s_logger = Logger.getLogger(RegisterTemplateCmdByAdmin.class.getName());
+
+    @Override
+    public void execute() throws ResourceAllocationException{
+        try {
+            VirtualMachineTemplate template = _templateService.registerTemplate(this);
+            if (template != null){
+                ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
+                List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Full, template, zoneId, false);
+                response.setResponses(templateResponses);
+                response.setResponseName(getCommandName());
+                setResponseObject(response);
+            } else {
+                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register template");
+            }
+        } catch (URISyntaxException ex1) {
+            s_logger.info(ex1);
+            throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ex1.getMessage());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/admin/template/UpdateTemplateCmdByAdmin.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/admin/template/UpdateTemplateCmdByAdmin.java b/api/src/org/apache/cloudstack/api/command/admin/template/UpdateTemplateCmdByAdmin.java
new file mode 100644
index 0000000..6587020
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/command/admin/template/UpdateTemplateCmdByAdmin.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.template;
+
+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.template.UpdateTemplateCmd;
+import org.apache.cloudstack.api.response.TemplateResponse;
+
+import com.cloud.template.VirtualMachineTemplate;
+
+@APICommand(name = "updateTemplate", description = "Updates attributes of a template.", responseObject = TemplateResponse.class, responseView = ResponseView.Full)
+public class UpdateTemplateCmdByAdmin extends UpdateTemplateCmd {
+    public static final Logger s_logger = Logger.getLogger(UpdateTemplateCmdByAdmin.class.getName());
+
+    @Override
+    public void execute(){
+        VirtualMachineTemplate result = _templateService.updateTemplate(this);
+        if (result != null) {
+            TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(ResponseView.Full, result);
+            response.setObjectName("template");
+            response.setTemplateType(result.getTemplateType().toString());//Template can be either USER or ROUTING type
+            response.setResponseName(getCommandName());
+            setResponseObject(response);
+        } else {
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update template");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
index a1fece5..01b7669 100644
--- a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
@@ -16,22 +16,23 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.iso;
 
+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.BaseListTaggedResourcesCmd;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
 import com.cloud.user.Account;
 
-@APICommand(name = "listIsos", description="Lists all available ISO files.", responseObject=TemplateResponse.class)
+@APICommand(name = "listIsos", description = "Lists all available ISO files.", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted)
 public class ListIsosCmd extends BaseListTaggedResourcesCmd {
     public static final Logger s_logger = Logger.getLogger(ListIsosCmd.class.getName());
 
@@ -139,6 +140,7 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
         return s_name;
     }
 
+    @Override
     public ApiCommandJobType getInstanceType() {
         return ApiCommandJobType.Iso;
     }
@@ -147,6 +149,6 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
     public void execute(){
         ListResponse<TemplateResponse> response = _queryService.listIsos(this);
         response.setResponseName(getCommandName());
-        this.setResponseObject(response);
+        setResponseObject(response);
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
index 84f6980..9d39ee2 100644
--- a/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/iso/RegisterIsoCmd.java
@@ -18,11 +18,14 @@ package org.apache.cloudstack.api.command.user.iso;
 
 import java.util.List;
 
+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.BaseCmd;
 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.DomainResponse;
 import org.apache.cloudstack.api.response.GuestOSResponse;
@@ -32,12 +35,10 @@ import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.template.VirtualMachineTemplate;
 
-@APICommand(name = "registerIso", responseObject=TemplateResponse.class, description="Registers an existing ISO into the CloudStack Cloud.")
+@APICommand(name = "registerIso", responseObject = TemplateResponse.class, description = "Registers an existing ISO into the CloudStack Cloud.", responseView = ResponseView.Restricted)
 public class RegisterIsoCmd extends BaseCmd {
     public static final Logger s_logger = Logger.getLogger(RegisterIsoCmd.class.getName());
 
@@ -74,7 +75,7 @@ public class RegisterIsoCmd extends BaseCmd {
 
     @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
             required=true, description="the ID of the zone you wish to register the ISO to.")
-    private Long zoneId;
+    protected Long zoneId;
 
     @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType = DomainResponse.class,
             description="an optional domainId. If the account parameter is used, domainId must also be used.")
@@ -150,7 +151,7 @@ public class RegisterIsoCmd extends BaseCmd {
     }
 
     public String getImageStoreUuid() {
-        return this.imageStoreUuid;
+        return imageStoreUuid;
     }
 
     public Boolean isDynamicallyScalable() {
@@ -181,10 +182,10 @@ public class RegisterIsoCmd extends BaseCmd {
         VirtualMachineTemplate template = _templateService.registerIso(this);
         if (template != null) {
             ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
-            List<TemplateResponse> templateResponses = _responseGenerator.createIsoResponses(template, zoneId, false);
+            List<TemplateResponse> templateResponses = _responseGenerator.createIsoResponses(ResponseView.Restricted, template, zoneId, false);
             response.setResponses(templateResponses);
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register iso");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java
index 1d84847..69e95a0 100644
--- a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoCmd.java
@@ -16,17 +16,19 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.iso;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.TemplateResponse;
-import org.apache.log4j.Logger;
 
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
 
-@APICommand(name = "updateIso", description="Updates an ISO file.", responseObject=TemplateResponse.class)
+@APICommand(name = "updateIso", description = "Updates an ISO file.", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted)
 public class UpdateIsoCmd extends BaseUpdateTemplateOrIsoCmd {
     public static final Logger s_logger = Logger.getLogger(UpdateIsoCmd.class.getName());
     private static final String s_name = "updateisoresponse";
@@ -68,9 +70,9 @@ public class UpdateIsoCmd extends BaseUpdateTemplateOrIsoCmd {
     public void execute(){
         VirtualMachineTemplate result = _templateService.updateTemplate(this);
         if (result != null) {
-            TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(result);
+            TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(ResponseView.Restricted, result);
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update iso");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/user/template/CopyTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/CopyTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/CopyTemplateCmd.java
index a25bd65..396d618 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/CopyTemplateCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/CopyTemplateCmd.java
@@ -18,27 +18,27 @@ package org.apache.cloudstack.api.command.user.template;
 
 import java.util.List;
 
+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.TemplateResponse;
-import org.apache.cloudstack.api.response.UserVmResponse;
 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.exception.StorageUnavailableException;
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
 
-@APICommand(name = "copyTemplate", description="Copies a template from one zone to another.", responseObject=TemplateResponse.class)
+@APICommand(name = "copyTemplate", description = "Copies a template from one zone to another.", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted)
 public class CopyTemplateCmd extends BaseAsyncCmd {
     public static final Logger s_logger = Logger.getLogger(CopyTemplateCmd.class.getName());
     private static final String s_name = "copytemplateresponse";
@@ -110,10 +110,12 @@ public class CopyTemplateCmd extends BaseAsyncCmd {
         return  "copying template: " + getId() + " from zone: " + getSourceZoneId() + " to zone: " + getDestinationZoneId();
     }
 
+    @Override
     public ApiCommandJobType getInstanceType() {
         return ApiCommandJobType.Template;
     }
 
+    @Override
     public Long getInstanceId() {
         return getId();
     }
@@ -125,14 +127,14 @@ public class CopyTemplateCmd extends BaseAsyncCmd {
             VirtualMachineTemplate template = _templateService.copyTemplate(this);
 
             if (template != null){
-                List<TemplateResponse> listResponse = _responseGenerator.createTemplateResponses(template, getDestinationZoneId(), false);
+                List<TemplateResponse> listResponse = _responseGenerator.createTemplateResponses(ResponseView.Restricted, template, getDestinationZoneId(), false);
                 TemplateResponse response = new TemplateResponse();
                 if (listResponse != null && !listResponse.isEmpty()) {
                     response = listResponse.get(0);
                 }
 
                 response.setResponseName(getCommandName());
-                this.setResponseObject(response);
+                setResponseObject(response);
             } else {
                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to copy template");
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java
index 6116a4e..d21754c 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java
@@ -16,15 +16,11 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.template;
 
-import com.cloud.event.EventTypes;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.PermissionDeniedException;
-import com.cloud.exception.ResourceAllocationException;
-import com.cloud.projects.Project;
-import com.cloud.storage.Snapshot;
-import com.cloud.storage.Volume;
-import com.cloud.template.VirtualMachineTemplate;
-import com.cloud.user.Account;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiCommandJobType;
@@ -32,6 +28,7 @@ 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.GuestOSResponse;
 import org.apache.cloudstack.api.response.SnapshotResponse;
@@ -40,14 +37,18 @@ 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 java.util.Collection;
-import java.util.List;
-import java.util.Map;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.PermissionDeniedException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.projects.Project;
+import com.cloud.storage.Snapshot;
+import com.cloud.storage.Volume;
+import com.cloud.template.VirtualMachineTemplate;
+import com.cloud.user.Account;
 
 @APICommand(name = "createTemplate", responseObject = TemplateResponse.class, description = "Creates a template of a virtual machine. " + "The virtual machine must be in a STOPPED state. "
-        + "A template created from this command is automatically designated as a private template visible to the account that created it.")
+        + "A template created from this command is automatically designated as a private template visible to the account that created it.", responseView = ResponseView.Restricted)
         public class CreateTemplateCmd extends BaseAsyncCreateCmd {
     public static final Logger s_logger = Logger.getLogger(CreateTemplateCmd.class.getName());
     private static final String s_name = "createtemplateresponse";
@@ -83,15 +84,15 @@ import java.util.Map;
 
     @Parameter(name = ApiConstants.SNAPSHOT_ID, type = CommandType.UUID, entityType = SnapshotResponse.class,
             description = "the ID of the snapshot the template is being created from. Either this parameter, or volumeId has to be passed in")
-    private Long snapshotId;
+    protected Long snapshotId;
 
     @Parameter(name = ApiConstants.VOLUME_ID, type = CommandType.UUID, entityType = VolumeResponse.class,
             description = "the ID of the disk volume the template is being created from. Either this parameter, or snapshotId has to be passed in")
-    private Long volumeId;
+    protected Long volumeId;
 
     @Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.UUID, entityType = UserVmResponse.class,
             description="Optional, VM ID. If this presents, it is going to create a baremetal template for VM this ID refers to. This is only for VM whose hypervisor type is BareMetal")
-    private Long vmId;
+    protected Long vmId;
 
     @Parameter(name=ApiConstants.URL, type=CommandType.STRING, description="Optional, only for baremetal hypervisor. The directory name where template stored on CIFS server")
     private String url;
@@ -240,17 +241,17 @@ import java.util.Map;
         return ApiCommandJobType.Template;
     }
 
-    private boolean isBareMetal() {
-        return (this.getVmId() != null && this.getUrl() != null);
+    protected boolean isBareMetal() {
+        return (getVmId() != null && getUrl() != null);
     }
 
     @Override
     public void create() throws ResourceAllocationException {
         VirtualMachineTemplate template = null;
-        template = this._templateService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
+        template = _templateService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
         if (template != null) {
-            this.setEntityId(template.getId());
-            this.setEntityUuid(template.getUuid());
+            setEntityId(template.getId());
+            setEntityUuid(template.getUuid());
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
             "Failed to create a template");
@@ -262,21 +263,21 @@ import java.util.Map;
     public void execute() {
         CallContext.current().setEventDetails("Template Id: "+getEntityId()+((getSnapshotId() == null) ? " from volume Id: " + getVolumeId() : " from snapshot Id: " + getSnapshotId()));
         VirtualMachineTemplate template = null;
-        template = this._templateService.createPrivateTemplate(this);
+        template = _templateService.createPrivateTemplate(this);
 
         if (template != null){
             List<TemplateResponse> templateResponses;
             if (isBareMetal()) {
-                templateResponses = _responseGenerator.createTemplateResponses(template.getId(), vmId);
+                templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Restricted, template.getId(), vmId);
             } else {
-                templateResponses = _responseGenerator.createTemplateResponses(template.getId(), snapshotId, volumeId, false);
+                templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Restricted, template.getId(), snapshotId, volumeId, false);
             }
             TemplateResponse response = new TemplateResponse();
             if (templateResponses != null && !templateResponses.isEmpty()) {
                 response = templateResponses.get(0);
             }
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private template");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
index 30960f1..95c482e 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
@@ -16,22 +16,23 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.template;
 
+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.BaseListTaggedResourcesCmd;
 import org.apache.cloudstack.api.Parameter;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.response.ListResponse;
 import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.template.VirtualMachineTemplate.TemplateFilter;
 import com.cloud.user.Account;
 
-@APICommand(name = "listTemplates", description="List all public, private, and privileged templates.", responseObject=TemplateResponse.class)
+@APICommand(name = "listTemplates", description = "List all public, private, and privileged templates.", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted)
 public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
     public static final Logger s_logger = Logger.getLogger(ListTemplatesCmd.class.getName());
 
@@ -110,6 +111,7 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
         return s_name;
     }
 
+    @Override
     public ApiCommandJobType getInstanceType() {
         return ApiCommandJobType.Template;
     }
@@ -118,6 +120,6 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
     public void execute(){
         ListResponse<TemplateResponse> response = _queryService.listTemplates(this);
         response.setResponseName(getCommandName());
-        this.setResponseObject(response);
+        setResponseObject(response);
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
index bba90bf..9575587 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/RegisterTemplateCmd.java
@@ -21,12 +21,15 @@ import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+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.BaseCmd;
 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.DomainResponse;
 import org.apache.cloudstack.api.response.GuestOSResponse;
@@ -36,12 +39,10 @@ import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.context.CallContext;
 
-import org.apache.log4j.Logger;
-
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.template.VirtualMachineTemplate;
 
-@APICommand(name = "registerTemplate", description="Registers an existing template into the CloudStack cloud. ", responseObject=TemplateResponse.class)
+@APICommand(name = "registerTemplate", description = "Registers an existing template into the CloudStack cloud. ", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted)
 public class RegisterTemplateCmd extends BaseCmd {
     public static final Logger s_logger = Logger.getLogger(RegisterTemplateCmd.class.getName());
 
@@ -93,7 +94,7 @@ public class RegisterTemplateCmd extends BaseCmd {
 
     @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
             required=true, description="the ID of the zone the template is to be hosted on")
-    private Long zoneId;
+    protected Long zoneId;
 
     @Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType = DomainResponse.class,
             description="an optional domainId. If the account parameter is used, domainId must also be used.")
@@ -245,10 +246,10 @@ public class RegisterTemplateCmd extends BaseCmd {
             VirtualMachineTemplate template = _templateService.registerTemplate(this);
             if (template != null){
                 ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
-                List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(template, zoneId, false);
+                List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(ResponseView.Restricted, template, zoneId, false);
                 response.setResponses(templateResponses);
                 response.setResponseName(getCommandName());
-                this.setResponseObject(response);
+                setResponseObject(response);
             } else {
                 throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to register template");
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java
index b4149c0..f294b29 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplateCmd.java
@@ -16,17 +16,19 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.template;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.APICommand;
 import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.cloudstack.api.response.TemplateResponse;
-import org.apache.log4j.Logger;
 
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
 
-@APICommand(name = "updateTemplate", description="Updates attributes of a template.", responseObject=TemplateResponse.class)
+@APICommand(name = "updateTemplate", description = "Updates attributes of a template.", responseObject = TemplateResponse.class, responseView = ResponseView.Restricted)
 public class UpdateTemplateCmd extends BaseUpdateTemplateOrIsoCmd {
     public static final Logger s_logger = Logger.getLogger(UpdateTemplateCmd.class.getName());
     private static final String s_name = "updatetemplateresponse";
@@ -68,11 +70,11 @@ public class UpdateTemplateCmd extends BaseUpdateTemplateOrIsoCmd {
     public void execute(){
         VirtualMachineTemplate result = _templateService.updateTemplate(this);
         if (result != null) {
-            TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(result);
+            TemplateResponse response = _responseGenerator.createTemplateUpdateResponse(ResponseView.Restricted, result);
             response.setObjectName("template");
             response.setTemplateType(result.getTemplateType().toString());//Template can be either USER or ROUTING type
             response.setResponseName(getCommandName());
-            this.setResponseObject(response);
+            setResponseObject(response);
         } else {
             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update template");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/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 f6e7cd8..129f0ff 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -1664,8 +1664,8 @@ public class ApiDBUtils {
     }
 
 
-    public static TemplateResponse newTemplateResponse(TemplateJoinVO vr) {
-        return _templateJoinDao.newTemplateResponse(vr);
+    public static TemplateResponse newTemplateResponse(ResponseView view, TemplateJoinVO vr) {
+        return _templateJoinDao.newTemplateResponse(view, vr);
     }
 
 
@@ -1673,8 +1673,8 @@ public class ApiDBUtils {
         return _templateJoinDao.newIsoResponse(vr);
     }
 
-    public static TemplateResponse fillTemplateDetails(TemplateResponse vrData, TemplateJoinVO vr){
-        return _templateJoinDao.setTemplateResponse(vrData, vr);
+    public static TemplateResponse fillTemplateDetails(ResponseView view, TemplateResponse vrData, TemplateJoinVO vr) {
+        return _templateJoinDao.setTemplateResponse(view, vrData, vr);
     }
 
     public static List<TemplateJoinVO> newTemplateView(VirtualMachineTemplate vr){

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/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 4cbe6f9..bd4598c 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -1279,15 +1279,15 @@ public class ApiResponseHelper implements ResponseGenerator {
     }
 
     @Override
-    public TemplateResponse createTemplateUpdateResponse(VirtualMachineTemplate result) {
+    public TemplateResponse createTemplateUpdateResponse(ResponseView view, VirtualMachineTemplate result) {
         List<TemplateJoinVO> tvo = ApiDBUtils.newTemplateView(result);
-        List<TemplateResponse> listVrs = ViewResponseHelper.createTemplateUpdateResponse(tvo.toArray(new TemplateJoinVO[tvo.size()]));
+        List<TemplateResponse> listVrs = ViewResponseHelper.createTemplateUpdateResponse(view, tvo.toArray(new TemplateJoinVO[tvo.size()]));
         assert listVrs != null && listVrs.size() == 1 : "There should be one template returned";
         return listVrs.get(0);
     }
 
     @Override
-    public List<TemplateResponse> createTemplateResponses(VirtualMachineTemplate result, Long zoneId, boolean readyOnly) {
+    public List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachineTemplate result, Long zoneId, boolean readyOnly) {
         List<TemplateJoinVO> tvo = null;
         if (zoneId == null || zoneId == -1) {
             tvo = ApiDBUtils.newTemplateView(result);
@@ -1295,18 +1295,18 @@ public class ApiResponseHelper implements ResponseGenerator {
             tvo = ApiDBUtils.newTemplateView(result, zoneId, readyOnly);
 
         }
-        return ViewResponseHelper.createTemplateResponse(tvo.toArray(new TemplateJoinVO[tvo.size()]));
+        return ViewResponseHelper.createTemplateResponse(view, tvo.toArray(new TemplateJoinVO[tvo.size()]));
     }
 
     @Override
-    public List<TemplateResponse> createTemplateResponses(long templateId, Long zoneId, boolean readyOnly) {
+    public List<TemplateResponse> createTemplateResponses(ResponseView view, long templateId, Long zoneId, boolean readyOnly) {
         VirtualMachineTemplate template = findTemplateById(templateId);
-        return createTemplateResponses(template, zoneId, readyOnly);
+        return createTemplateResponses(view, template, zoneId, readyOnly);
     }
 
 
     @Override
-    public List<TemplateResponse> createIsoResponses(VirtualMachineTemplate result, Long zoneId, boolean readyOnly) {
+    public List<TemplateResponse> createIsoResponses(ResponseView view, VirtualMachineTemplate result, Long zoneId, boolean readyOnly) {
         List<TemplateJoinVO> tvo = null;
         if (zoneId == null || zoneId == -1) {
             tvo = ApiDBUtils.newTemplateView(result);
@@ -1314,7 +1314,7 @@ public class ApiResponseHelper implements ResponseGenerator {
             tvo = ApiDBUtils.newTemplateView(result, zoneId, readyOnly);
         }
 
-        return ViewResponseHelper.createIsoResponse(tvo.toArray(new TemplateJoinVO[tvo.size()]));
+        return ViewResponseHelper.createIsoResponse(view, tvo.toArray(new TemplateJoinVO[tvo.size()]));
     }
 
     /*
@@ -1653,7 +1653,7 @@ public class ApiResponseHelper implements ResponseGenerator {
     }
 
     @Override
-    public List<TemplateResponse> createTemplateResponses(long templateId, Long snapshotId, Long volumeId, boolean readyOnly) {
+    public List<TemplateResponse> createTemplateResponses(ResponseView view, long templateId, Long snapshotId, Long volumeId, boolean readyOnly) {
         VolumeVO volume = null;
         if (snapshotId != null) {
             Snapshot snapshot = ApiDBUtils.findSnapshotById(snapshotId);
@@ -1661,15 +1661,15 @@ public class ApiResponseHelper implements ResponseGenerator {
         } else {
             volume = findVolumeById(volumeId);
         }
-        return createTemplateResponses(templateId, volume.getDataCenterId(), readyOnly);
+        return createTemplateResponses(view, templateId, volume.getDataCenterId(), readyOnly);
     }
 
     @Override
-    public List<TemplateResponse> createTemplateResponses(long templateId, Long vmId) {
+    public List<TemplateResponse> createTemplateResponses(ResponseView view, long templateId, Long vmId) {
         UserVm vm = findUserVmById(vmId);
         Long hostId = (vm.getHostId() == null ? vm.getLastHostId() : vm.getHostId());
         Host host = findHostById(hostId);
-        return createTemplateResponses(templateId, host.getDataCenterId(), true);
+        return createTemplateResponses(view, templateId, host.getDataCenterId(), true);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/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 4a3e882..a304d22 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -45,10 +45,12 @@ import org.apache.cloudstack.api.ResourceDetail;
 import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
 import org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd;
+import org.apache.cloudstack.api.command.admin.iso.ListIsosCmdByAdmin;
 import org.apache.cloudstack.api.command.admin.router.ListRoutersCmd;
 import org.apache.cloudstack.api.command.admin.storage.ListImageStoresCmd;
 import org.apache.cloudstack.api.command.admin.storage.ListSecondaryStagingStoresCmd;
 import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
+import org.apache.cloudstack.api.command.admin.template.ListTemplatesCmdByAdmin;
 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;
@@ -2748,7 +2750,12 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         Pair<List<TemplateJoinVO>, Integer> result = searchForTemplatesInternal(cmd);
         ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
 
-        List<TemplateResponse> templateResponses = ViewResponseHelper.createTemplateResponse(result.first().toArray(
+        ResponseView respView = ResponseView.Restricted;
+        if (cmd instanceof ListTemplatesCmdByAdmin) {
+            respView = ResponseView.Full;
+        }
+
+        List<TemplateResponse> templateResponses = ViewResponseHelper.createTemplateResponse(respView, result.first().toArray(
                 new TemplateJoinVO[result.first().size()]));
         response.setResponses(templateResponses, result.second());
         return response;
@@ -3045,7 +3052,12 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
         Pair<List<TemplateJoinVO>, Integer> result = searchForIsosInternal(cmd);
         ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
 
-        List<TemplateResponse> templateResponses = ViewResponseHelper.createIsoResponse(result.first().toArray(
+        ResponseView respView = ResponseView.Restricted;
+        if (cmd instanceof ListIsosCmdByAdmin) {
+            respView = ResponseView.Full;
+        }
+
+        List<TemplateResponse> templateResponses = ViewResponseHelper.createIsoResponse(respView, result.first().toArray(
                 new TemplateJoinVO[result.first().size()]));
         response.setResponses(templateResponses, result.second());
         return response;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/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 cfb097e..7e438f2 100644
--- a/server/src/com/cloud/api/query/ViewResponseHelper.java
+++ b/server/src/com/cloud/api/query/ViewResponseHelper.java
@@ -378,24 +378,24 @@ public class ViewResponseHelper {
         return respList;
     }
 
-    public static List<TemplateResponse> createTemplateResponse(TemplateJoinVO... templates) {
+    public static List<TemplateResponse> createTemplateResponse(ResponseView view, TemplateJoinVO... templates) {
         Hashtable<String, TemplateResponse> vrDataList = new Hashtable<String, TemplateResponse>();
         for (TemplateJoinVO vr : templates) {
             TemplateResponse vrData = vrDataList.get(vr.getTempZonePair());
             if ( vrData == null ){
                 // first time encountering this volume
-                vrData = ApiDBUtils.newTemplateResponse(vr);
+                vrData = ApiDBUtils.newTemplateResponse(view, vr);
             }
             else{
                 // update tags
-                vrData = ApiDBUtils.fillTemplateDetails(vrData, vr);
+                vrData = ApiDBUtils.fillTemplateDetails(view, vrData, vr);
             }
             vrDataList.put(vr.getTempZonePair(), vrData);
         }
         return new ArrayList<TemplateResponse>(vrDataList.values());
     }
 
-    public static List<TemplateResponse> createTemplateUpdateResponse(TemplateJoinVO... templates) {
+    public static List<TemplateResponse> createTemplateUpdateResponse(ResponseView view, TemplateJoinVO... templates) {
         Hashtable<Long, TemplateResponse> vrDataList = new Hashtable<Long, TemplateResponse>();
         for (TemplateJoinVO vr : templates) {
             TemplateResponse vrData = vrDataList.get(vr.getId());
@@ -405,14 +405,14 @@ public class ViewResponseHelper {
             }
             else{
                 // update tags
-                vrData = ApiDBUtils.fillTemplateDetails(vrData, vr);
+                vrData = ApiDBUtils.fillTemplateDetails(view, vrData, vr);
             }
             vrDataList.put(vr.getId(), vrData);
         }
         return new ArrayList<TemplateResponse>(vrDataList.values());
     }
 
-    public static List<TemplateResponse> createIsoResponse(TemplateJoinVO... templates) {
+    public static List<TemplateResponse> createIsoResponse(ResponseView view, TemplateJoinVO... templates) {
         Hashtable<String, TemplateResponse> vrDataList = new Hashtable<String, TemplateResponse>();
         for (TemplateJoinVO vr : templates) {
             TemplateResponse vrData = vrDataList.get(vr.getTempZonePair());
@@ -422,7 +422,7 @@ public class ViewResponseHelper {
             }
             else{
                 // update tags
-                vrData = ApiDBUtils.fillTemplateDetails(vrData, vr);
+                vrData = ApiDBUtils.fillTemplateDetails(view, vrData, vr);
             }
             vrDataList.put(vr.getTempZonePair(), vrData);
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/server/src/com/cloud/api/query/dao/TemplateJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/TemplateJoinDao.java b/server/src/com/cloud/api/query/dao/TemplateJoinDao.java
index f73f5bd..afd399c 100644
--- a/server/src/com/cloud/api/query/dao/TemplateJoinDao.java
+++ b/server/src/com/cloud/api/query/dao/TemplateJoinDao.java
@@ -18,6 +18,7 @@ package com.cloud.api.query.dao;
 
 import java.util.List;
 
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.response.TemplateResponse;
 
 import com.cloud.api.query.vo.TemplateJoinVO;
@@ -26,13 +27,13 @@ import com.cloud.utils.db.GenericDao;
 
 public interface TemplateJoinDao extends GenericDao<TemplateJoinVO, Long> {
 
-    TemplateResponse newTemplateResponse(TemplateJoinVO tmpl);
+    TemplateResponse newTemplateResponse(ResponseView view, TemplateJoinVO tmpl);
 
     TemplateResponse newIsoResponse(TemplateJoinVO tmpl);
 
     TemplateResponse newUpdateResponse(TemplateJoinVO tmpl);
 
-    TemplateResponse setTemplateResponse(TemplateResponse tmplData, TemplateJoinVO tmpl);
+    TemplateResponse setTemplateResponse(ResponseView view, TemplateResponse tmplData, TemplateJoinVO tmpl);
 
     List<TemplateJoinVO> newTemplateView(VirtualMachineTemplate tmpl);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
index 3511613..8840da2 100644
--- a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
@@ -24,16 +24,16 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import org.apache.cloudstack.api.BaseCmd;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import org.apache.cloudstack.api.ResponseObject.ResponseView;
 import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
 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;
@@ -94,44 +94,34 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
         activeTmpltSearch.done();
 
         // select distinct pair (template_id, zone_id)
-        this._count = "select count(distinct temp_zone_pair) from template_view WHERE ";
+        _count = "select count(distinct temp_zone_pair) from template_view WHERE ";
     }
 
 
 
-    private String getTemplateStatus(TemplateJoinVO template){
-        boolean isAdmin = false;
-        Account caller = CallContext.current().getCallingAccount();
-        if ((caller == null) || _accountService.isAdmin(caller.getType())) {
-            isAdmin = true;
-        }
-
-        // If the user is an Admin, add the template download status
+    private String getTemplateStatus(TemplateJoinVO template) {
         String templateStatus = null;
-        if (isAdmin || caller.getId() == template.getAccountId()) {
-            // add download status
-            if (template.getDownloadState() != Status.DOWNLOADED) {
-                templateStatus = "Processing";
-                if (template.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
-                    if (template.getDownloadPercent() == 100) {
-                        templateStatus = "Installing Template";
-                    } else {
-                        templateStatus = template.getDownloadPercent() + "% Downloaded";
-                    }
+        if (template.getDownloadState() != Status.DOWNLOADED) {
+            templateStatus = "Processing";
+            if (template.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
+                if (template.getDownloadPercent() == 100) {
+                    templateStatus = "Installing Template";
                 } else {
-                    templateStatus = template.getErrorString();
+                    templateStatus = template.getDownloadPercent() + "% Downloaded";
                 }
-            } else if (template.getDownloadState() == VMTemplateHostVO.Status.DOWNLOADED) {
-                templateStatus = "Download Complete";
             } else {
-                templateStatus = "Successfully Installed";
+                templateStatus = template.getErrorString();
             }
+        } else if (template.getDownloadState() == VMTemplateHostVO.Status.DOWNLOADED) {
+            templateStatus = "Download Complete";
+        } else {
+            templateStatus = "Successfully Installed";
         }
         return templateStatus;
     }
 
     @Override
-    public TemplateResponse newTemplateResponse(TemplateJoinVO template) {
+    public TemplateResponse newTemplateResponse(ResponseView view, TemplateJoinVO template) {
         TemplateResponse templateResponse = new TemplateResponse();
         templateResponse.setId(template.getUuid());
         templateResponse.setName(template.getName());
@@ -171,9 +161,11 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
 
 
         // If the user is an Admin, add the template download status
-        String templateStatus = getTemplateStatus(template);
-        if ( templateStatus != null ){
-            templateResponse.setStatus(templateStatus);
+        if (view == ResponseView.Full) {
+            String templateStatus = getTemplateStatus(template);
+            if (templateStatus != null) {
+                templateResponse.setStatus(templateStatus);
+            }
         }
 
         if ( template.getDataCenterId() > 0 ){
@@ -261,7 +253,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
 
 
     @Override
-    public TemplateResponse setTemplateResponse(TemplateResponse templateResponse, TemplateJoinVO template) {
+    public TemplateResponse setTemplateResponse(ResponseView view, TemplateResponse templateResponse, TemplateJoinVO template) {
 
         // update details map
         if (template.getDetailName() != null){

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f21eca9/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
index 7371665..76966e6 100644
--- a/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java
@@ -127,7 +127,7 @@ public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implem
         }
         userVmResponse.setZoneId(userVm.getDataCenterUuid());
         userVmResponse.setZoneName(userVm.getDataCenterName());
-        if (view == ResponseView.Full || ((view == null) && ((caller == null) || (_accountMgr.isRootAdmin(caller.getId()))))) {
+        if (view == ResponseView.Full) {
             userVmResponse.setInstanceName(userVm.getInstanceName());
             userVmResponse.setHostId(userVm.getHostUuid());
             userVmResponse.setHostName(userVm.getHostName());


Mime
View raw message