| // 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.account; |
| |
| import java.util.logging.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.response.AccountResponse; |
| import org.apache.cloudstack.api.response.DomainResponse; |
| |
| import com.cloud.user.Account; |
| import com.cloud.utils.exception.CloudRuntimeException; |
| |
| @APICommand(name = "lockAccount", |
| description = "This deprecated function used to locks an account. Look for the API DisableAccount instead", |
| responseObject = AccountResponse.class, |
| entityType = {Account.class}, |
| requestHasSensitiveInfo = false, |
| responseHasSensitiveInfo = true) |
| public class LockAccountCmd extends BaseCmd { |
| public static final Logger s_logger = Logger.getLogger(LockAccountCmd.class.getName()); |
| |
| private static final String s_name = "lockaccountresponse"; |
| |
| ///////////////////////////////////////////////////// |
| //////////////// API parameters ///////////////////// |
| ///////////////////////////////////////////////////// |
| |
| @Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, required = true, description = "Locks the specified account.") |
| private String accountName; |
| |
| @Parameter(name = ApiConstants.DOMAIN_ID, |
| type = CommandType.UUID, |
| entityType = DomainResponse.class, |
| required = true, |
| description = "Locks the specified account on this domain.") |
| private Long domainId; |
| |
| ///////////////////////////////////////////////////// |
| /////////////////// Accessors /////////////////////// |
| ///////////////////////////////////////////////////// |
| |
| public String getAccountName() { |
| return accountName; |
| } |
| |
| public Long getDomainId() { |
| return domainId; |
| } |
| |
| ///////////////////////////////////////////////////// |
| /////////////// API Implementation/////////////////// |
| ///////////////////////////////////////////////////// |
| |
| @Override |
| public String getCommandName() { |
| return s_name; |
| } |
| |
| @Override |
| public long getEntityOwnerId() { |
| final Account account = _accountService.getActiveAccountByName(getAccountName(), getDomainId()); |
| if (account != null) { |
| return account.getAccountId(); |
| } |
| |
| return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked |
| } |
| |
| @Override |
| public void execute() { |
| throw new CloudRuntimeException("LockAccount does not lock accounts. Its implementation is disabled. Use DisableAccount instead"); |
| } |
| } |