mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-17 11:04:00 +01:00
Merge pull request #1349 from DaanHoogland/CLOUDSTACK-9239
CLOUDSTACK-9239 throw exception on deprecated commandan API call to LockAccount fails silently with a 200 return and no contents. client are responsible to check and will find that no locking has actually occured. This way they may be lured to a sense of false security. Throwing an exption makes the failure explicit. cloudmonkey lock account name=<name> domainid=<id> now errors out with an http result of 530 * pr/1349: CLOUDSTACK-9239 throw exception on deprecated command Signed-off-by: Remi Bergsma <github@remi.nl>
This commit is contained in:
commit
d9ce59f11c
@ -16,7 +16,7 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package org.apache.cloudstack.api.command.admin.account;
|
package org.apache.cloudstack.api.command.admin.account;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
import org.apache.cloudstack.api.APICommand;
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
import org.apache.cloudstack.api.ApiConstants;
|
||||||
@ -26,9 +26,14 @@ import org.apache.cloudstack.api.response.AccountResponse;
|
|||||||
import org.apache.cloudstack.api.response.DomainResponse;
|
import org.apache.cloudstack.api.response.DomainResponse;
|
||||||
|
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
@APICommand(name = "lockAccount", description = "Locks an account", responseObject = AccountResponse.class, entityType = {Account.class},
|
@APICommand(name = "lockAccount",
|
||||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
|
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 class LockAccountCmd extends BaseCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(LockAccountCmd.class.getName());
|
public static final Logger s_logger = Logger.getLogger(LockAccountCmd.class.getName());
|
||||||
|
|
||||||
@ -71,7 +76,7 @@ public class LockAccountCmd extends BaseCmd {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getEntityOwnerId() {
|
public long getEntityOwnerId() {
|
||||||
Account account = _accountService.getActiveAccountByName(getAccountName(), getDomainId());
|
final Account account = _accountService.getActiveAccountByName(getAccountName(), getDomainId());
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
return account.getAccountId();
|
return account.getAccountId();
|
||||||
}
|
}
|
||||||
@ -81,14 +86,6 @@ public class LockAccountCmd extends BaseCmd {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
// Account result = null;
|
throw new CloudRuntimeException("LockAccount does not lock accounts. Its implementation is disabled. Use DisableAccount instead");
|
||||||
//result = _accountService.lockAccount(this);
|
|
||||||
// if (result != null){
|
|
||||||
// AccountResponse response = _responseGenerator.createAccountResponse(result);
|
|
||||||
// response.setResponseName(getCommandName());
|
|
||||||
// this.setResponseObject(response);
|
|
||||||
// } else {
|
|
||||||
// throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to lock account");
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user