You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ml...@apache.org on 2013/01/10 01:59:35 UTC

[5/50] [abbrv] git commit: api: Move base template*cmd class to org.apache.cloudstack.api, fix names and annotations

api: Move base template*cmd class to org.apache.cloudstack.api, fix names and annotations


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

Branch: refs/heads/resizevolume
Commit: 8b085d3308cd1a4bc35d3b1439660e2167f7d9e2
Parents: 0df94a8
Author: Rohit Yadav <bh...@apache.org>
Authored: Sun Jan 6 14:46:02 2013 -0800
Committer: Rohit Yadav <bh...@apache.org>
Committed: Sun Jan 6 14:46:02 2013 -0800

----------------------------------------------------------------------
 .../commands/ListTemplateOrIsoPermissionsCmd.java  |   94 -----------
 .../cloud/api/commands/UpdateTemplateOrIsoCmd.java |   96 -----------
 .../UpdateTemplateOrIsoPermissionsCmd.java         |  129 ---------------
 api/src/com/cloud/template/TemplateService.java    |    8 +-
 .../api/BaseListTemplateOrIsoPermissionsCmd.java   |   89 ++++++++++
 .../cloudstack/api/BaseUpdateTemplateOrIsoCmd.java |   96 +++++++++++
 .../api/BaseUpdateTemplateOrIsoPermissionsCmd.java |  125 ++++++++++++++
 .../command/user/autoscale/CreateConditionCmd.java |    2 +-
 .../command/user/iso/ListIsoPermissionsCmd.java    |    7 +-
 .../api/command/user/iso/UpdateIsoCmd.java         |    4 +-
 .../command/user/iso/UpdateIsoPermissionsCmd.java  |    4 +-
 .../user/template/ListTemplatePermissionsCmd.java  |    7 +-
 .../command/user/template/UpdateTemplateCmd.java   |    4 +-
 .../template/UpdateTemplatePermissionsCmd.java     |    4 +-
 14 files changed, 333 insertions(+), 336 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/api/src/com/cloud/api/commands/ListTemplateOrIsoPermissionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListTemplateOrIsoPermissionsCmd.java b/api/src/com/cloud/api/commands/ListTemplateOrIsoPermissionsCmd.java
deleted file mode 100644
index 54bbace..0000000
--- a/api/src/com/cloud/api/commands/ListTemplateOrIsoPermissionsCmd.java
+++ /dev/null
@@ -1,94 +0,0 @@
-// 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 com.cloud.api.commands;
-
-import java.util.List;
-
-import org.apache.cloudstack.api.APICommand;
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
-import com.cloud.template.VirtualMachineTemplate;
-import com.cloud.user.Account;
-import com.cloud.user.UserContext;
-
-@APICommand(description="List template visibility and all accounts that have permissions to view this template.", responseObject=TemplatePermissionsResponse.class)
-public class ListTemplateOrIsoPermissionsCmd extends BaseCmd {
-    public Logger s_logger = getLogger();
-    protected String s_name = "listtemplatepermissionsresponse";
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = TemplatePermissionsResponse.class,
-            required=true, description="the template ID")
-    private Long id;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Long getId() {
-        return id;
-    }
-
-    /////////////////////////////////////////////////////
-    /////////////// API Implementation///////////////////
-    /////////////////////////////////////////////////////
-    @Override
-    public long getEntityOwnerId() {
-        VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, getId());
-        if (template != null) {
-            return template.getAccountId();
-        }
-
-        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
-    }
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    protected boolean templateIsCorrectType(VirtualMachineTemplate template) {
-        return true;
-    }
-
-    public String getMediaType() {
-        return "templateOrIso";
-    }
-
-    protected Logger getLogger() {
-        return Logger.getLogger(UpdateTemplateOrIsoPermissionsCmd.class.getName());
-    }
-
-    @Override
-    public void execute(){
-        List<String> accountNames = _templateService.listTemplatePermissions(this);
-
-        Account account = UserContext.current().getCaller();
-        boolean isAdmin = (isAdmin(account.getType()));
-
-        TemplatePermissionsResponse response = _responseGenerator.createTemplatePermissionsResponse(accountNames, id, isAdmin);
-        response.setResponseName(getCommandName());
-        this.setResponseObject(response);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/api/src/com/cloud/api/commands/UpdateTemplateOrIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdateTemplateOrIsoCmd.java b/api/src/com/cloud/api/commands/UpdateTemplateOrIsoCmd.java
deleted file mode 100755
index 57e8e55..0000000
--- a/api/src/com/cloud/api/commands/UpdateTemplateOrIsoCmd.java
+++ /dev/null
@@ -1,96 +0,0 @@
-// 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 com.cloud.api.commands;
-
-import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd;
-import org.apache.cloudstack.api.response.GuestOSResponse;
-import org.apache.cloudstack.api.response.TemplateResponse;
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.Parameter;
-
-public abstract class UpdateTemplateOrIsoCmd extends BaseCmd {
-    public static final Logger s_logger = Logger.getLogger(UpdateIsoCmd.class.getName());
-
-    /////////////////////////////////////////////////////
-    //////////////// API parameters /////////////////////
-    /////////////////////////////////////////////////////
-
-    @Parameter(name=ApiConstants.BOOTABLE, type=CommandType.BOOLEAN, description="true if image is bootable, false otherwise")
-    private Boolean bootable;
-
-    @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the image", length=4096)
-    private String displayText;
-
-    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = TemplateResponse.class,
-            required=true, description="the ID of the image file")
-    private Long id;
-
-    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the image file")
-    private String templateName;
-
-    @Parameter(name=ApiConstants.OS_TYPE_ID, type=CommandType.UUID, entityType = GuestOSResponse.class,
-            description="the ID of the OS type that best represents the OS of this image.")
-    private Long osTypeId;
-
-    @Parameter(name=ApiConstants.FORMAT, type=CommandType.STRING, description="the format for the image")
-    private String format;
-
-    @Parameter(name=ApiConstants.PASSWORD_ENABLED, type=CommandType.BOOLEAN, description="true if the image supports the password reset feature; default is false")
-    private Boolean passwordEnabled;
-
-    @Parameter(name=ApiConstants.SORT_KEY, type=CommandType.INTEGER, description="sort key of the template, integer")
-    private Integer sortKey;
-
-    /////////////////////////////////////////////////////
-    /////////////////// Accessors ///////////////////////
-    /////////////////////////////////////////////////////
-
-    public Boolean isBootable() {
-        return bootable;
-    }
-
-    public String getDisplayText() {
-        return displayText;
-    }
-
-    public Long getId() {
-        return id;
-    }
-
-    public String getTemplateName() {
-        return templateName;
-    }
-
-    public Long getOsTypeId() {
-        return osTypeId;
-    }
-
-    public Boolean isPasswordEnabled() {
-        return passwordEnabled;
-    }
-
-    public String getFormat() {
-        return format;
-    }
-
-    public Integer getSortKey() {
-        return sortKey;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/api/src/com/cloud/api/commands/UpdateTemplateOrIsoPermissionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/UpdateTemplateOrIsoPermissionsCmd.java b/api/src/com/cloud/api/commands/UpdateTemplateOrIsoPermissionsCmd.java
deleted file mode 100755
index 5208e1d..0000000
--- a/api/src/com/cloud/api/commands/UpdateTemplateOrIsoPermissionsCmd.java
+++ /dev/null
@@ -1,129 +0,0 @@
-// 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 com.cloud.api.commands;
-
-import java.util.List;
-
-import org.apache.cloudstack.api.response.ProjectResponse;
-import org.apache.cloudstack.api.response.TemplateResponse;
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.BaseCmd;
-import org.apache.cloudstack.api.Parameter;
-import org.apache.cloudstack.api.ServerApiException;
-import org.apache.cloudstack.api.response.SuccessResponse;
-import com.cloud.exception.InvalidParameterValueException;
-
-public abstract class UpdateTemplateOrIsoPermissionsCmd extends BaseCmd {
-    public Logger s_logger = getLogger();
-    protected String s_name = getResponseName();
-
-    // ///////////////////////////////////////////////////
-    // ////////////// API parameters /////////////////////
-    // ///////////////////////////////////////////////////
-
-    @Parameter(name = ApiConstants.ACCOUNTS, type = CommandType.LIST, collectionType = CommandType.STRING, description = "a comma delimited list of accounts. If specified, \"op\" parameter has to be passed in.")
-    private List<String> accountNames;
-
-    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = TemplateResponse.class,
-            required = true, description = "the template ID")
-    private Long id;
-
-    @Parameter(name = ApiConstants.IS_FEATURED, type = CommandType.BOOLEAN, description = "true for featured template/iso, false otherwise")
-    private Boolean featured;
-
-    @Parameter(name = ApiConstants.IS_PUBLIC, type = CommandType.BOOLEAN, description = "true for public template/iso, false for private templates/isos")
-    private Boolean isPublic;
-
-    @Parameter(name = ApiConstants.IS_EXTRACTABLE, type = CommandType.BOOLEAN, description = "true if the template/iso is extractable, false other wise. Can be set only by root admin")
-    private Boolean isExtractable;
-
-    @Parameter(name = ApiConstants.OP, type = CommandType.STRING, description = "permission operator (add, remove, reset)")
-    private String operation;
-
-    @Parameter(name = ApiConstants.PROJECT_IDS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = ProjectResponse.class,
-            description = "a comma delimited list of projects. If specified, \"op\" parameter has to be passed in.")
-    private List<Long> projectIds;
-
-    // ///////////////////////////////////////////////////
-    // ///////////////// Accessors ///////////////////////
-    // ///////////////////////////////////////////////////
-
-    public List<String> getAccountNames() {
-        if (accountNames != null && projectIds != null) {
-            throw new InvalidParameterValueException("Accounts and projectIds can't be specified together");
-        }
-
-        return accountNames;
-    }
-
-    public Long getId() {
-        return id;
-    }
-
-    public Boolean isFeatured() {
-        return featured;
-    }
-
-    public Boolean isPublic() {
-        return isPublic;
-    }
-
-    public Boolean isExtractable() {
-        return isExtractable;
-    }
-
-    public String getOperation() {
-        return operation;
-    }
-
-    public List<Long> getProjectIds() {
-        if (accountNames != null && projectIds != null) {
-            throw new InvalidParameterValueException("Accounts and projectIds can't be specified together");
-        }
-        return projectIds;
-    }
-
-    // ///////////////////////////////////////////////////
-    // ///////////// API Implementation///////////////////
-    // ///////////////////////////////////////////////////
-
-    @Override
-    public String getCommandName() {
-        return s_name;
-    }
-
-    protected String getResponseName() {
-        return "updatetemplateorisopermissionsresponse";
-    }
-
-    protected Logger getLogger() {
-        return Logger.getLogger(UpdateTemplateOrIsoPermissionsCmd.class.getName());
-    }
-
-    @Override
-    public void execute(){
-        boolean result = _templateService.updateTemplateOrIsoPermissions(this);
-        if (result) {
-            SuccessResponse response = new SuccessResponse(getCommandName());
-            this.setResponseObject(response);
-        } else {
-            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update template/iso permissions");
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/api/src/com/cloud/template/TemplateService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/template/TemplateService.java b/api/src/com/cloud/template/TemplateService.java
index 6fbc840..93e8a25 100755
--- a/api/src/com/cloud/template/TemplateService.java
+++ b/api/src/com/cloud/template/TemplateService.java
@@ -19,15 +19,15 @@ package com.cloud.template;
 import java.net.URISyntaxException;
 import java.util.List;
 
+import org.apache.cloudstack.api.BaseListTemplateOrIsoPermissionsCmd;
+import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoPermissionsCmd;
 import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
 import org.apache.cloudstack.api.command.user.iso.ExtractIsoCmd;
 import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
 import org.apache.cloudstack.api.command.user.template.*;
 import org.apache.cloudstack.api.command.user.template.CopyTemplateCmd;
 import org.apache.cloudstack.api.command.user.template.ExtractTemplateCmd;
-import com.cloud.api.commands.ListTemplateOrIsoPermissionsCmd;
 import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
-import com.cloud.api.commands.UpdateTemplateOrIsoPermissionsCmd;
 import com.cloud.exception.InternalErrorException;
 import com.cloud.exception.ResourceAllocationException;
 import com.cloud.exception.StorageUnavailableException;
@@ -83,7 +83,7 @@ public interface TemplateService {
 
     VirtualMachineTemplate getTemplate(long templateId);
 
-    List<String> listTemplatePermissions(ListTemplateOrIsoPermissionsCmd cmd);
+    List<String> listTemplatePermissions(BaseListTemplateOrIsoPermissionsCmd cmd);
 
-    boolean updateTemplateOrIsoPermissions(UpdateTemplateOrIsoPermissionsCmd cmd);
+    boolean updateTemplateOrIsoPermissions(BaseUpdateTemplateOrIsoPermissionsCmd cmd);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java b/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java
new file mode 100644
index 0000000..cde2d94
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/BaseListTemplateOrIsoPermissionsCmd.java
@@ -0,0 +1,89 @@
+// 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;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
+import com.cloud.template.VirtualMachineTemplate;
+import com.cloud.user.Account;
+import com.cloud.user.UserContext;
+
+public class BaseListTemplateOrIsoPermissionsCmd extends BaseCmd {
+    public Logger s_logger = getLogger();
+    protected String s_name = "listtemplatepermissionsresponse";
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = TemplatePermissionsResponse.class,
+            required=true, description="the template ID")
+    private Long id;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Long getId() {
+        return id;
+    }
+
+    /////////////////////////////////////////////////////
+    /////////////// API Implementation///////////////////
+    /////////////////////////////////////////////////////
+    @Override
+    public long getEntityOwnerId() {
+        VirtualMachineTemplate template = _entityMgr.findById(VirtualMachineTemplate.class, getId());
+        if (template != null) {
+            return template.getAccountId();
+        }
+
+        return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    protected boolean templateIsCorrectType(VirtualMachineTemplate template) {
+        return true;
+    }
+
+    public String getMediaType() {
+        return "templateOrIso";
+    }
+
+    protected Logger getLogger() {
+        return Logger.getLogger(BaseUpdateTemplateOrIsoPermissionsCmd.class.getName());
+    }
+
+    @Override
+    public void execute(){
+        List<String> accountNames = _templateService.listTemplatePermissions(this);
+
+        Account account = UserContext.current().getCaller();
+        boolean isAdmin = (isAdmin(account.getType()));
+
+        TemplatePermissionsResponse response = _responseGenerator.createTemplatePermissionsResponse(accountNames, id, isAdmin);
+        response.setResponseName(getCommandName());
+        this.setResponseObject(response);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java b/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
new file mode 100755
index 0000000..dd6ae00
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java
@@ -0,0 +1,96 @@
+// 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;
+
+import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd;
+import org.apache.cloudstack.api.response.GuestOSResponse;
+import org.apache.cloudstack.api.response.TemplateResponse;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.api.BaseCmd;
+import org.apache.cloudstack.api.Parameter;
+
+public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
+    public static final Logger s_logger = Logger.getLogger(UpdateIsoCmd.class.getName());
+
+    /////////////////////////////////////////////////////
+    //////////////// API parameters /////////////////////
+    /////////////////////////////////////////////////////
+
+    @Parameter(name=ApiConstants.BOOTABLE, type=CommandType.BOOLEAN, description="true if image is bootable, false otherwise")
+    private Boolean bootable;
+
+    @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the image", length=4096)
+    private String displayText;
+
+    @Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType = TemplateResponse.class,
+            required=true, description="the ID of the image file")
+    private Long id;
+
+    @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the image file")
+    private String templateName;
+
+    @Parameter(name=ApiConstants.OS_TYPE_ID, type=CommandType.UUID, entityType = GuestOSResponse.class,
+            description="the ID of the OS type that best represents the OS of this image.")
+    private Long osTypeId;
+
+    @Parameter(name=ApiConstants.FORMAT, type=CommandType.STRING, description="the format for the image")
+    private String format;
+
+    @Parameter(name=ApiConstants.PASSWORD_ENABLED, type=CommandType.BOOLEAN, description="true if the image supports the password reset feature; default is false")
+    private Boolean passwordEnabled;
+
+    @Parameter(name=ApiConstants.SORT_KEY, type=CommandType.INTEGER, description="sort key of the template, integer")
+    private Integer sortKey;
+
+    /////////////////////////////////////////////////////
+    /////////////////// Accessors ///////////////////////
+    /////////////////////////////////////////////////////
+
+    public Boolean isBootable() {
+        return bootable;
+    }
+
+    public String getDisplayText() {
+        return displayText;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getTemplateName() {
+        return templateName;
+    }
+
+    public Long getOsTypeId() {
+        return osTypeId;
+    }
+
+    public Boolean isPasswordEnabled() {
+        return passwordEnabled;
+    }
+
+    public String getFormat() {
+        return format;
+    }
+
+    public Integer getSortKey() {
+        return sortKey;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoPermissionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoPermissionsCmd.java b/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoPermissionsCmd.java
new file mode 100755
index 0000000..aacc6ef
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/BaseUpdateTemplateOrIsoPermissionsCmd.java
@@ -0,0 +1,125 @@
+// 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;
+
+import java.util.List;
+
+import org.apache.cloudstack.api.response.ProjectResponse;
+import org.apache.cloudstack.api.response.TemplateResponse;
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.response.SuccessResponse;
+import com.cloud.exception.InvalidParameterValueException;
+
+public abstract class BaseUpdateTemplateOrIsoPermissionsCmd extends BaseCmd {
+    public Logger s_logger = getLogger();
+    protected String s_name = getResponseName();
+
+    // ///////////////////////////////////////////////////
+    // ////////////// API parameters /////////////////////
+    // ///////////////////////////////////////////////////
+
+    @Parameter(name = ApiConstants.ACCOUNTS, type = CommandType.LIST, collectionType = CommandType.STRING, description = "a comma delimited list of accounts. If specified, \"op\" parameter has to be passed in.")
+    private List<String> accountNames;
+
+    @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = TemplateResponse.class,
+            required = true, description = "the template ID")
+    private Long id;
+
+    @Parameter(name = ApiConstants.IS_FEATURED, type = CommandType.BOOLEAN, description = "true for featured template/iso, false otherwise")
+    private Boolean featured;
+
+    @Parameter(name = ApiConstants.IS_PUBLIC, type = CommandType.BOOLEAN, description = "true for public template/iso, false for private templates/isos")
+    private Boolean isPublic;
+
+    @Parameter(name = ApiConstants.IS_EXTRACTABLE, type = CommandType.BOOLEAN, description = "true if the template/iso is extractable, false other wise. Can be set only by root admin")
+    private Boolean isExtractable;
+
+    @Parameter(name = ApiConstants.OP, type = CommandType.STRING, description = "permission operator (add, remove, reset)")
+    private String operation;
+
+    @Parameter(name = ApiConstants.PROJECT_IDS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = ProjectResponse.class,
+            description = "a comma delimited list of projects. If specified, \"op\" parameter has to be passed in.")
+    private List<Long> projectIds;
+
+    // ///////////////////////////////////////////////////
+    // ///////////////// Accessors ///////////////////////
+    // ///////////////////////////////////////////////////
+
+    public List<String> getAccountNames() {
+        if (accountNames != null && projectIds != null) {
+            throw new InvalidParameterValueException("Accounts and projectIds can't be specified together");
+        }
+
+        return accountNames;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public Boolean isFeatured() {
+        return featured;
+    }
+
+    public Boolean isPublic() {
+        return isPublic;
+    }
+
+    public Boolean isExtractable() {
+        return isExtractable;
+    }
+
+    public String getOperation() {
+        return operation;
+    }
+
+    public List<Long> getProjectIds() {
+        if (accountNames != null && projectIds != null) {
+            throw new InvalidParameterValueException("Accounts and projectIds can't be specified together");
+        }
+        return projectIds;
+    }
+
+    // ///////////////////////////////////////////////////
+    // ///////////// API Implementation///////////////////
+    // ///////////////////////////////////////////////////
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    protected String getResponseName() {
+        return "updatetemplateorisopermissionsresponse";
+    }
+
+    protected Logger getLogger() {
+        return Logger.getLogger(BaseUpdateTemplateOrIsoPermissionsCmd.class.getName());
+    }
+
+    @Override
+    public void execute(){
+        boolean result = _templateService.updateTemplateOrIsoPermissions(this);
+        if (result) {
+            SuccessResponse response = new SuccessResponse(getCommandName());
+            this.setResponseObject(response);
+        } else {
+            throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update template/iso permissions");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
index 7ef9ef5..a952471 100644
--- a/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/autoscale/CreateConditionCmd.java
@@ -34,7 +34,7 @@ import com.cloud.exception.ResourceAllocationException;
 import com.cloud.network.as.Condition;
 import com.cloud.user.UserContext;
 
-@APICommand(name = "createCondition ", description = "Creates a condition", responseObject = ConditionResponse.class)
+@APICommand(name = "createCondition", description = "Creates a condition", responseObject = ConditionResponse.class)
 public class CreateConditionCmd extends BaseAsyncCreateCmd {
     public static final Logger s_logger = Logger.getLogger(CreateConditionCmd.class.getName());
     private static final String s_name = "conditionresponse";

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/api/src/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java
index 4ab7061..0ca711f 100644
--- a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsoPermissionsCmd.java
@@ -16,13 +16,16 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.iso;
 
-import com.cloud.api.commands.ListTemplateOrIsoPermissionsCmd;
+import org.apache.cloudstack.api.BaseListTemplateOrIsoPermissionsCmd;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
 import org.apache.log4j.Logger;
 
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.template.VirtualMachineTemplate;
 
-public class ListIsoPermissionsCmd extends ListTemplateOrIsoPermissionsCmd {
+@APICommand(name="listIsoPermissions", description="List iso visibility and all accounts that have permissions to view this iso.", responseObject=TemplatePermissionsResponse.class)
+public class ListIsoPermissionsCmd extends BaseListTemplateOrIsoPermissionsCmd {
     protected String getResponseName() {
         return "listisopermissionsresponse";
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/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 eb368df..f54f8a6 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,7 +16,7 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.iso;
 
-import com.cloud.api.commands.UpdateTemplateOrIsoCmd;
+import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.BaseCmd;
@@ -27,7 +27,7 @@ import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
 
 @APICommand(name = "updateIso", description="Updates an ISO file.", responseObject=TemplateResponse.class)
-public class UpdateIsoCmd extends UpdateTemplateOrIsoCmd {
+public class UpdateIsoCmd extends BaseUpdateTemplateOrIsoCmd {
     public static final Logger s_logger = Logger.getLogger(UpdateIsoCmd.class.getName());
     private static final String s_name = "updateisoresponse";
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoPermissionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoPermissionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoPermissionsCmd.java
index 4f15659..b7a2c56 100644
--- a/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoPermissionsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/iso/UpdateIsoPermissionsCmd.java
@@ -16,7 +16,7 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.iso;
 
-import com.cloud.api.commands.UpdateTemplateOrIsoPermissionsCmd;
+import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoPermissionsCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
@@ -25,7 +25,7 @@ import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
 
 @APICommand(name = "updateIsoPermissions", description="Updates iso permissions", responseObject=SuccessResponse.class)
-public class UpdateIsoPermissionsCmd extends UpdateTemplateOrIsoPermissionsCmd {
+public class UpdateIsoPermissionsCmd extends BaseUpdateTemplateOrIsoPermissionsCmd {
     protected String getResponseName() {
         return "updateisopermissionsresponse";
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatePermissionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatePermissionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatePermissionsCmd.java
index 7c489b2..7446195 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatePermissionsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatePermissionsCmd.java
@@ -16,13 +16,16 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.template;
 
-import com.cloud.api.commands.ListTemplateOrIsoPermissionsCmd;
+import org.apache.cloudstack.api.BaseListTemplateOrIsoPermissionsCmd;
+import org.apache.cloudstack.api.APICommand;
+import org.apache.cloudstack.api.response.TemplatePermissionsResponse;
 import org.apache.log4j.Logger;
 
 import com.cloud.storage.Storage.ImageFormat;
 import com.cloud.template.VirtualMachineTemplate;
 
-public class ListTemplatePermissionsCmd extends ListTemplateOrIsoPermissionsCmd {
+@APICommand(name = "listTemplatePermissions", description="List template visibility and all accounts that have permissions to view this template.", responseObject=TemplatePermissionsResponse.class)
+public class ListTemplatePermissionsCmd extends BaseListTemplateOrIsoPermissionsCmd {
     protected String getResponseName() {
         return "listtemplatepermissionsresponse";
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/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 31f375b..01ea200 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,7 +16,7 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.template;
 
-import com.cloud.api.commands.UpdateTemplateOrIsoCmd;
+import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.BaseCmd;
@@ -27,7 +27,7 @@ import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.user.Account;
 
 @APICommand(name = "updateTemplate", description="Updates attributes of a template.", responseObject=TemplateResponse.class)
-public class UpdateTemplateCmd extends UpdateTemplateOrIsoCmd {
+public class UpdateTemplateCmd extends BaseUpdateTemplateOrIsoCmd {
     public static final Logger s_logger = Logger.getLogger(UpdateTemplateCmd.class.getName());
     private static final String s_name = "updatetemplateresponse";
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8b085d33/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplatePermissionsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplatePermissionsCmd.java b/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplatePermissionsCmd.java
index 184cabe..8f3e660 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplatePermissionsCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/UpdateTemplatePermissionsCmd.java
@@ -16,7 +16,7 @@
 // under the License.
 package org.apache.cloudstack.api.command.user.template;
 
-import com.cloud.api.commands.UpdateTemplateOrIsoPermissionsCmd;
+import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoPermissionsCmd;
 import org.apache.log4j.Logger;
 
 import org.apache.cloudstack.api.APICommand;
@@ -29,7 +29,7 @@ import com.cloud.user.Account;
                                                                                         "A private template is visible only to the owner of the template. " +
                                                                                         "A priviledged template is a private template with account permissions added. " +
                                                                                         "Only accounts specified under the template permissions are visible to them.")
-public class UpdateTemplatePermissionsCmd extends UpdateTemplateOrIsoPermissionsCmd {
+public class UpdateTemplatePermissionsCmd extends BaseUpdateTemplateOrIsoPermissionsCmd {
     protected String getResponseName() {
         return "updatetemplatepermissionsresponse";
     }