Updated Branches: refs/heads/rbac c950651fe -> 01e6f47d4
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01e6f47d/services/iam/server/src/org/apache/cloudstack/iam/api/command/CreateAclGroupCmd.java ---------------------------------------------------------------------- diff --git a/services/iam/server/src/org/apache/cloudstack/iam/api/command/CreateAclGroupCmd.java b/services/iam/server/src/org/apache/cloudstack/iam/api/command/CreateAclGroupCmd.java deleted file mode 100644 index 3654d0d..0000000 --- a/services/iam/server/src/org/apache/cloudstack/iam/api/command/CreateAclGroupCmd.java +++ /dev/null @@ -1,162 +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 org.apache.cloudstack.iam.api.command; - -import org.apache.log4j.Logger; - -import org.apache.cloudstack.acl.AclGroup; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.ApiCommandJobType; -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCreateCmd; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.AclGroupResponse; -import org.apache.cloudstack.api.response.DomainResponse; -import org.apache.cloudstack.context.CallContext; - -import com.cloud.event.EventTypes; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.user.Account; - -@APICommand(name = "createAclGroup", responseObject = AclGroupResponse.class, description = "Creates an acl group") -public class CreateAclGroupCmd extends BaseAsyncCreateCmd { - public static final Logger s_logger = Logger.getLogger(CreateAclGroupCmd.class.getName()); - - private static final String s_name = "createaclgroupresponse"; - - // /////////////////////////////////////////////////// - // ////////////// API parameters ///////////////////// - // /////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an account for the acl group. Must be used with domainId.") - private String accountName; - - @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, description = "domainId of the account owning the acl group", entityType = DomainResponse.class) - private Long domainId; - - @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "optional description of the acl group") - private String description; - - @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the acl group") - private String name; - - - // /////////////////////////////////////////////////// - // ///////////////// Accessors /////////////////////// - // /////////////////////////////////////////////////// - - public String getAccountName() { - return accountName; - } - - public String getDescription() { - return description; - } - - public Long getDomainId() { - return domainId; - } - - public String getName() { - return name; - } - - - // /////////////////////////////////////////////////// - // ///////////// API Implementation/////////////////// - // /////////////////////////////////////////////////// - - - @Override - public String getCommandName() { - return s_name; - } - - @Override - public long getEntityOwnerId() { - Account account = CallContext.current().getCallingAccount(); - if ((account == null) || _accountService.isAdmin(account.getType())) { - if ((domainId != null) && (accountName != null)) { - Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId); - if (userAccount != null) { - return userAccount.getId(); - } - } - } - - if (account != null) { - return account.getId(); - } - - return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this - // command to SYSTEM so ERROR events - // are tracked - } - - @Override - public void execute() { - AclGroup grp = _entityMgr.findById(AclGroup.class, getEntityId()); - if (grp != null) { - AclGroupResponse response = _responseGenerator.createAclGroupResponse(grp); - response.setResponseName(getCommandName()); - setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create acl group:" + name); - } - } - - @Override - public void create() throws ResourceAllocationException { - Account account = CallContext.current().getCallingAccount(); - AclGroup result = _aclService.createAclGroup(account, name, description); - if (result != null) { - setEntityId(result.getId()); - setEntityUuid(result.getUuid()); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create acl group entity" + name); - } - - } - - @Override - public String getEventType() { - return EventTypes.EVENT_ACL_GROUP_CREATE; - } - - @Override - public String getEventDescription() { - return "creating Acl group"; - } - - @Override - public String getCreateEventType() { - return EventTypes.EVENT_ACL_GROUP_CREATE; - } - - @Override - public String getCreateEventDescription() { - return "creating acl group"; - } - - @Override - public ApiCommandJobType getInstanceType() { - return ApiCommandJobType.AclGroup; - } - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01e6f47d/services/iam/server/src/org/apache/cloudstack/iam/api/command/CreateAclPolicyCmd.java ---------------------------------------------------------------------- diff --git a/services/iam/server/src/org/apache/cloudstack/iam/api/command/CreateAclPolicyCmd.java b/services/iam/server/src/org/apache/cloudstack/iam/api/command/CreateAclPolicyCmd.java deleted file mode 100644 index 6628a82..0000000 --- a/services/iam/server/src/org/apache/cloudstack/iam/api/command/CreateAclPolicyCmd.java +++ /dev/null @@ -1,169 +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 org.apache.cloudstack.iam.api.command; - -import org.apache.log4j.Logger; - -import org.apache.cloudstack.acl.AclPolicy; -import org.apache.cloudstack.api.ACL; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.ApiCommandJobType; -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCreateCmd; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.AclPolicyResponse; -import org.apache.cloudstack.api.response.DomainResponse; -import org.apache.cloudstack.context.CallContext; - -import com.cloud.event.EventTypes; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.user.Account; - -@APICommand(name = "createAclPolicy", responseObject = AclPolicyResponse.class, description = "Creates an acl policy") -public class CreateAclPolicyCmd extends BaseAsyncCreateCmd { - public static final Logger s_logger = Logger.getLogger(CreateAclPolicyCmd.class.getName()); - - private static final String s_name = "createaclpolicyresponse"; - - // /////////////////////////////////////////////////// - // ////////////// API parameters ///////////////////// - // /////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "an account for the acl policy. Must be used with domainId.") - private String accountName; - - @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, description = "domainId of the account owning the acl policy", entityType = DomainResponse.class) - private Long domainId; - - @Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "optional description of the acl policy") - private String description; - - @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the acl policy") - private String name; - - @ACL - @Parameter(name = ApiConstants.ACL_PARENT_POLICY_ID, type = CommandType.UUID, description = "The ID of parent acl policy.", entityType = AclPolicyResponse.class) - private Long parentPolicyId; - - - // /////////////////////////////////////////////////// - // ///////////////// Accessors /////////////////////// - // /////////////////////////////////////////////////// - - public String getAccountName() { - return accountName; - } - - public String getDescription() { - return description; - } - - public Long getDomainId() { - return domainId; - } - - public String getName() { - return name; - } - - public Long getParentPolicyId() { - return parentPolicyId; - } - - // /////////////////////////////////////////////////// - // ///////////// API Implementation/////////////////// - // /////////////////////////////////////////////////// - - @Override - public String getCommandName() { - return s_name; - } - - @Override - public long getEntityOwnerId() { - Account account = CallContext.current().getCallingAccount(); - if ((account == null) || _accountService.isAdmin(account.getType())) { - if ((domainId != null) && (accountName != null)) { - Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId); - if (userAccount != null) { - return userAccount.getId(); - } - } - } - - if (account != null) { - return account.getId(); - } - - return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this - // command to SYSTEM so ERROR events - // are tracked - } - - @Override - public void execute() { - AclPolicy policy = _entityMgr.findById(AclPolicy.class, getEntityId()); - if (policy != null) { - AclPolicyResponse response = _responseGenerator.createAclPolicyResponse(policy); - response.setResponseName(getCommandName()); - setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create acl policy:" + name); - } - } - - @Override - public void create() throws ResourceAllocationException { - Account account = CallContext.current().getCallingAccount(); - AclPolicy result = _aclService.createAclPolicy(account, name, description, parentPolicyId); - if (result != null) { - setEntityId(result.getId()); - setEntityUuid(result.getUuid()); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create acl policy entity" + name); - } - - } - - @Override - public String getEventType() { - return EventTypes.EVENT_ACL_POLICY_CREATE; - } - - @Override - public String getEventDescription() { - return "creating Acl policy"; - } - - @Override - public String getCreateEventType() { - return EventTypes.EVENT_ACL_POLICY_CREATE; - } - - @Override - public String getCreateEventDescription() { - return "creating acl policy"; - } - - @Override - public ApiCommandJobType getInstanceType() { - return ApiCommandJobType.AclPolicy; - } - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01e6f47d/services/iam/server/src/org/apache/cloudstack/iam/api/command/DeleteAclGroupCmd.java ---------------------------------------------------------------------- diff --git a/services/iam/server/src/org/apache/cloudstack/iam/api/command/DeleteAclGroupCmd.java b/services/iam/server/src/org/apache/cloudstack/iam/api/command/DeleteAclGroupCmd.java deleted file mode 100644 index 110c1b5..0000000 --- a/services/iam/server/src/org/apache/cloudstack/iam/api/command/DeleteAclGroupCmd.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 org.apache.cloudstack.iam.api.command; - -import org.apache.log4j.Logger; - -import org.apache.cloudstack.api.ACL; -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.ServerApiException; -import org.apache.cloudstack.api.response.AclGroupResponse; -import org.apache.cloudstack.api.response.SuccessResponse; - -import com.cloud.event.EventTypes; -import com.cloud.user.Account; - -@APICommand(name = "deleteAclGroup", description = "Deletes acl group", responseObject = SuccessResponse.class) -public class DeleteAclGroupCmd extends BaseAsyncCmd { - public static final Logger s_logger = Logger.getLogger(DeleteAclGroupCmd.class.getName()); - private static final String s_name = "deleteaclgroupresponse"; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @ACL - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "The ID of the acl group.", required = true, entityType = AclGroupResponse.class) - private Long id; - - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public Long getId() { - return id; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public String getCommandName() { - return s_name; - } - - @Override - public long getEntityOwnerId() { - return Account.ACCOUNT_ID_SYSTEM; - } - - @Override - public void execute(){ - boolean result = _aclService.deleteAclGroup(id); - if (result) { - SuccessResponse response = new SuccessResponse(getCommandName()); - setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete acl group"); - } - } - - @Override - public String getEventType() { - return EventTypes.EVENT_ACL_GROUP_DELETE; - } - - @Override - public String getEventDescription() { - return "Deleting Acl group"; - } - - @Override - public ApiCommandJobType getInstanceType() { - return ApiCommandJobType.AclGroup; - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01e6f47d/services/iam/server/src/org/apache/cloudstack/iam/api/command/DeleteAclPolicyCmd.java ---------------------------------------------------------------------- diff --git a/services/iam/server/src/org/apache/cloudstack/iam/api/command/DeleteAclPolicyCmd.java b/services/iam/server/src/org/apache/cloudstack/iam/api/command/DeleteAclPolicyCmd.java deleted file mode 100644 index 06df62f..0000000 --- a/services/iam/server/src/org/apache/cloudstack/iam/api/command/DeleteAclPolicyCmd.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 org.apache.cloudstack.iam.api.command; - -import org.apache.log4j.Logger; - -import org.apache.cloudstack.api.ACL; -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.ServerApiException; -import org.apache.cloudstack.api.response.AclPolicyResponse; -import org.apache.cloudstack.api.response.SuccessResponse; - -import com.cloud.event.EventTypes; -import com.cloud.user.Account; - -@APICommand(name = "deleteAclPolicy", description = "Deletes acl policy", responseObject = SuccessResponse.class) -public class DeleteAclPolicyCmd extends BaseAsyncCmd { - public static final Logger s_logger = Logger.getLogger(DeleteAclPolicyCmd.class.getName()); - private static final String s_name = "deleteaclpolicyresponse"; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @ACL - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "The ID of the acl role.", required = true, entityType = AclPolicyResponse.class) - private Long id; - - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public Long getId() { - return id; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public String getCommandName() { - return s_name; - } - - @Override - public long getEntityOwnerId() { - return Account.ACCOUNT_ID_SYSTEM; - } - - @Override - public void execute(){ - boolean result = _aclService.deleteAclPolicy(id); - if (result) { - SuccessResponse response = new SuccessResponse(getCommandName()); - setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete acl policy"); - } - } - - @Override - public String getEventType() { - return EventTypes.EVENT_ACL_POLICY_DELETE; - } - - @Override - public String getEventDescription() { - return "Deleting Acl role"; - } - - @Override - public ApiCommandJobType getInstanceType() { - return ApiCommandJobType.AclPolicy; - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01e6f47d/services/iam/server/src/org/apache/cloudstack/iam/api/command/ListAclGroupsCmd.java ---------------------------------------------------------------------- diff --git a/services/iam/server/src/org/apache/cloudstack/iam/api/command/ListAclGroupsCmd.java b/services/iam/server/src/org/apache/cloudstack/iam/api/command/ListAclGroupsCmd.java deleted file mode 100644 index e6f732c..0000000 --- a/services/iam/server/src/org/apache/cloudstack/iam/api/command/ListAclGroupsCmd.java +++ /dev/null @@ -1,82 +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 org.apache.cloudstack.iam.api.command; - -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.BaseListDomainResourcesCmd; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.response.AclGroupResponse; -import org.apache.cloudstack.api.response.ListResponse; - - -@APICommand(name = "listAclGroups", description = "Lists acl groups", responseObject = AclGroupResponse.class) -public class ListAclGroupsCmd extends BaseListDomainResourcesCmd { - public static final Logger s_logger = Logger.getLogger(ListAclGroupsCmd.class.getName()); - - private static final String s_name = "listaclgroupsresponse"; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "lists acl groups by name") - private String aclGroupName; - - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "list the acl group by the id provided", entityType = AclGroupResponse.class) - private Long id; - - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - public String getAclGroupName() { - return aclGroupName; - } - - - public Long getId(){ - return id; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public String getCommandName() { - return s_name; - } - - @Override - public void execute(){ - - ListResponse<AclGroupResponse> response = _queryService.listAclGroups(id, aclGroupName, getDomainId(), - getStartIndex(), getPageSizeVal()); - response.setResponseName(getCommandName()); - setResponseObject(response); - - } - - @Override - public ApiCommandJobType getInstanceType() { - return ApiCommandJobType.AclGroup; - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01e6f47d/services/iam/server/src/org/apache/cloudstack/iam/api/command/ListAclPoliciesCmd.java ---------------------------------------------------------------------- diff --git a/services/iam/server/src/org/apache/cloudstack/iam/api/command/ListAclPoliciesCmd.java b/services/iam/server/src/org/apache/cloudstack/iam/api/command/ListAclPoliciesCmd.java deleted file mode 100644 index 5a99da0..0000000 --- a/services/iam/server/src/org/apache/cloudstack/iam/api/command/ListAclPoliciesCmd.java +++ /dev/null @@ -1,82 +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 org.apache.cloudstack.iam.api.command; - -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.BaseListDomainResourcesCmd; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.response.AclPolicyResponse; -import org.apache.cloudstack.api.response.ListResponse; - - -@APICommand(name = "listAclPolicies", description = "Lists acl policies", responseObject = AclPolicyResponse.class) -public class ListAclPoliciesCmd extends BaseListDomainResourcesCmd { - public static final Logger s_logger = Logger.getLogger(ListAclPoliciesCmd.class.getName()); - - private static final String s_name = "listaclpoliciesresponse"; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "lists acl policies by name") - private String aclPolicyName; - - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, description = "list the acl policy by the id provided", entityType = AclPolicyResponse.class) - private Long id; - - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - public String getAclPolicyName() { - return aclPolicyName; - } - - - public Long getId(){ - return id; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public String getCommandName() { - return s_name; - } - - @Override - public void execute(){ - - ListResponse<AclPolicyResponse> response = _queryService.listAclPolicies(id, aclPolicyName, getDomainId(), - getStartIndex(), getPageSizeVal()); - response.setResponseName(getCommandName()); - setResponseObject(response); - - } - - @Override - public ApiCommandJobType getInstanceType() { - return ApiCommandJobType.AclPolicy; - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01e6f47d/services/iam/server/src/org/apache/cloudstack/iam/api/command/RemoveAccountFromAclGroupCmd.java ---------------------------------------------------------------------- diff --git a/services/iam/server/src/org/apache/cloudstack/iam/api/command/RemoveAccountFromAclGroupCmd.java b/services/iam/server/src/org/apache/cloudstack/iam/api/command/RemoveAccountFromAclGroupCmd.java deleted file mode 100644 index 8d8d28a..0000000 --- a/services/iam/server/src/org/apache/cloudstack/iam/api/command/RemoveAccountFromAclGroupCmd.java +++ /dev/null @@ -1,121 +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 org.apache.cloudstack.iam.api.command; - -import java.util.List; - -import org.apache.log4j.Logger; - -import org.apache.cloudstack.acl.AclGroup; -import org.apache.cloudstack.api.ACL; -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.ServerApiException; -import org.apache.cloudstack.api.response.AccountResponse; -import org.apache.cloudstack.api.response.AclGroupResponse; -import org.apache.cloudstack.context.CallContext; - -import com.cloud.event.EventTypes; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.user.Account; - - -@APICommand(name = "removeAccountFromAclGroup", description = "remove accounts from an acl group", responseObject = AclGroupResponse.class) -public class RemoveAccountFromAclGroupCmd extends BaseAsyncCmd { - public static final Logger s_logger = Logger.getLogger(RemoveAccountFromAclGroupCmd.class.getName()); - private static final String s_name = "removeaccountfromaclgroupresponse"; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - - @ACL - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AclGroupResponse.class, - required = true, description = "The ID of the acl group") - private Long id; - - @ACL - @Parameter(name = ApiConstants.ACCOUNTS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = AccountResponse.class, description = "comma separated list of account id that are going to be assigned to the acl group.") - private List<Long> accountIdList; - - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - - public Long getId() { - return id; - } - - - public List<Long> getAccountIdList() { - return accountIdList; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - - @Override - public String getCommandName() { - return s_name; - } - - - @Override - public long getEntityOwnerId() { - return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked - } - - @Override - public void execute() throws ResourceUnavailableException, - InsufficientCapacityException, ServerApiException { - CallContext.current().setEventDetails("Acl group Id: " + getId()); - AclGroup result = _aclService.removeAccountsFromGroup(accountIdList, id); - if (result != null){ - AclGroupResponse response = _responseGenerator.createAclGroupResponse(result); - response.setResponseName(getCommandName()); - setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove accounts from acl group"); - } - } - - @Override - public String getEventType() { - return EventTypes.EVENT_ACL_GROUP_UPDATE; - } - - @Override - public String getEventDescription() { - return "removing accounts from acl group"; - } - - @Override - public ApiCommandJobType getInstanceType() { - return ApiCommandJobType.AclGroup; - } - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01e6f47d/services/iam/server/src/org/apache/cloudstack/iam/api/command/RemoveAclPermissionFromAclPolicyCmd.java ---------------------------------------------------------------------- diff --git a/services/iam/server/src/org/apache/cloudstack/iam/api/command/RemoveAclPermissionFromAclPolicyCmd.java b/services/iam/server/src/org/apache/cloudstack/iam/api/command/RemoveAclPermissionFromAclPolicyCmd.java deleted file mode 100644 index dc8ff33..0000000 --- a/services/iam/server/src/org/apache/cloudstack/iam/api/command/RemoveAclPermissionFromAclPolicyCmd.java +++ /dev/null @@ -1,141 +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 org.apache.cloudstack.iam.api.command; - -import org.apache.log4j.Logger; - -import org.apache.cloudstack.acl.AclPolicy; -import org.apache.cloudstack.acl.PermissionScope; -import org.apache.cloudstack.api.ACL; -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.ServerApiException; -import org.apache.cloudstack.api.response.AclPolicyResponse; -import org.apache.cloudstack.context.CallContext; - -import com.cloud.event.EventTypes; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.user.Account; - - -@APICommand(name = "removeAclPermissionFromAclPolicy", description = "Remove acl permission from an acl policy", responseObject = AclPolicyResponse.class) -public class RemoveAclPermissionFromAclPolicyCmd extends BaseAsyncCmd { - public static final Logger s_logger = Logger.getLogger(RemoveAclPermissionFromAclPolicyCmd.class.getName()); - private static final String s_name = "removeaclpermissionfromaclpolicyresponse"; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - - @ACL - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AclPolicyResponse.class, - required = true, description = "The ID of the acl policy") - private Long id; - - @Parameter(name = ApiConstants.ACL_ACTION, type = CommandType.STRING, required = true, description = "action api name.") - private String action; - - @Parameter(name = ApiConstants.ENTITY_TYPE, type = CommandType.STRING, required = false, description = "entity class simple name.") - private String entityType; - - @Parameter(name = ApiConstants.ACL_SCOPE, type = CommandType.STRING, - required = false, description = "acl permission scope") - private String scope; - - @Parameter(name = ApiConstants.ACL_SCOPE_ID, type = CommandType.UUID, required = false, description = "The ID of the permission scope id") - private Long scopeId; - - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - - public Long getId() { - return id; - } - - - public String getAction() { - return action; - } - - public String getEntityType() { - return entityType; - } - - public String getScope() { - return scope; - } - - public Long getScopeId() { - return scopeId; - } - - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - - @Override - public String getCommandName() { - return s_name; - } - - - @Override - public long getEntityOwnerId() { - return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked - } - - @Override - public void execute() throws ResourceUnavailableException, - InsufficientCapacityException, ServerApiException { - CallContext.current().setEventDetails("Acl policy Id: " + getId()); - AclPolicy result = _aclService.removeAclPermissionFromAclPolicy(id, entityType, PermissionScope.valueOf(scope), scopeId, action); - if (result != null) { - AclPolicyResponse response = _responseGenerator.createAclPolicyResponse(result); - response.setResponseName(getCommandName()); - setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to remove permission from acl policy " + getId()); - } - } - - @Override - public String getEventType() { - return EventTypes.EVENT_ACL_POLICY_REVOKE; - } - - @Override - public String getEventDescription() { - return "removing permission from acl policy"; - } - - @Override - public ApiCommandJobType getInstanceType() { - return ApiCommandJobType.AclPolicy; - } - -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/01e6f47d/services/iam/server/src/org/apache/cloudstack/iam/api/command/RemoveAclPolicyFromAclGroupCmd.java ---------------------------------------------------------------------- diff --git a/services/iam/server/src/org/apache/cloudstack/iam/api/command/RemoveAclPolicyFromAclGroupCmd.java b/services/iam/server/src/org/apache/cloudstack/iam/api/command/RemoveAclPolicyFromAclGroupCmd.java deleted file mode 100644 index 39958c0..0000000 --- a/services/iam/server/src/org/apache/cloudstack/iam/api/command/RemoveAclPolicyFromAclGroupCmd.java +++ /dev/null @@ -1,121 +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 org.apache.cloudstack.iam.api.command; - -import java.util.List; - -import org.apache.log4j.Logger; - -import org.apache.cloudstack.acl.AclGroup; -import org.apache.cloudstack.api.ACL; -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.ServerApiException; -import org.apache.cloudstack.api.response.AclGroupResponse; -import org.apache.cloudstack.api.response.AclPolicyResponse; -import org.apache.cloudstack.context.CallContext; - -import com.cloud.event.EventTypes; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.user.Account; - - -@APICommand(name = "removeAclPolicyFromAclGroup", description = "remove acl policy from an acl group", responseObject = AclGroupResponse.class) -public class RemoveAclPolicyFromAclGroupCmd extends BaseAsyncCmd { - public static final Logger s_logger = Logger.getLogger(RemoveAclPolicyFromAclGroupCmd.class.getName()); - private static final String s_name = "removeaclpolicyfromaclgroupresponse"; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - - @ACL - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = AclGroupResponse.class, - required = true, description = "The ID of the acl group") - private Long id; - - @ACL - @Parameter(name = ApiConstants.ACL_POLICIES, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = AclPolicyResponse.class, description = "comma separated list of acl policy id that are going to be applied to the acl group.") - private List<Long> policyIdList; - - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - - public Long getId() { - return id; - } - - - public List<Long> getRoleIdList() { - return policyIdList; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - - @Override - public String getCommandName() { - return s_name; - } - - - @Override - public long getEntityOwnerId() { - return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked - } - - @Override - public void execute() throws ResourceUnavailableException, - InsufficientCapacityException, ServerApiException { - CallContext.current().setEventDetails("Acl group Id: " + getId()); - AclGroup result = _aclService.removeAclPoliciesFromGroup(policyIdList, id); - if (result != null){ - AclGroupResponse response = _responseGenerator.createAclGroupResponse(result); - response.setResponseName(getCommandName()); - setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add roles to acl group"); - } - } - - @Override - public String getEventType() { - return EventTypes.EVENT_ACL_GROUP_UPDATE; - } - - @Override - public String getEventDescription() { - return "removing acl roles from acl group"; - } - - @Override - public ApiCommandJobType getInstanceType() { - return ApiCommandJobType.AclGroup; - } - -}
