@Override public AccountResponse newAccountResponse(ResponseView view, AccountJoinVO account) { AccountResponse accountResponse = new AccountResponse(); accountResponse.setId(account.getUuid()); accountResponse.setName(account.getAccountName()); accountResponse.setAccountType(account.getType()); accountResponse.setDomainId(account.getDomainUuid()); accountResponse.setDomainName(account.getDomainName()); accountResponse.setState(account.getState().toString()); accountResponse.setNetworkDomain(account.getNetworkDomain()); accountResponse.setDefaultZone(account.getDataCenterUuid()); accountResponse.setIsDefault(account.isDefault()); accountResponse.setBytesReceived(account.getBytesReceived()); accountResponse.setBytesSent(account.getBytesSent()); long projectTotal = (account.getProjectTotal() == null) ? 0 : account.getProjectTotal(); String projectAvail = (fullView || projectLimit == -1) ? "Unlimited" : String.valueOf(projectLimit - projectTotal); accountResponse.setProjectLimit(projectLimitDisplay); accountResponse.setProjectTotal(projectTotal); accountResponse.setProjectAvailable(projectAvail); accountResponse.setJobId(account.getJobUuid()); accountResponse.setJobStatus(account.getJobStatus()); accountResponse.setUsers(userResponses); accountResponse.setDetails(ApiDBUtils.getAccountDetails(account.getId())); accountResponse.setObjectName("account");
@Override public void execute() { Account result = _regionService.enableAccount(this); if (result != null){ AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable account"); } } }
import javax.xml.bind.*; public class Demo { public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(AccountResponse.class); AccountResponse ar = new AccountResponse(); ar.setAccountNumber(1234); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(ar, System.out); } }
@Override public void execute() { Account result = _regionService.updateAccount(this); if (result != null){ AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update account"); } } }
@Override public void execute() { Account result = _configService.markDefaultZone(getAccountName(), getDomainId(), getDefaultZoneId()); if (result != null) { AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to mark the account with the default zone"); } } }
@Override public void execute() throws ConcurrentOperationException, ResourceUnavailableException { CallContext.current().setEventDetails("Account Name: " + getAccountName() + ", Domain Id:" + getDomainId()); Account result = _regionService.disableAccount(this); if (result != null){ AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, lockRequested == true ? "Failed to lock account" : "Failed to disable account"); } }
@Override public void execute() throws ServerApiException { if (getAccountType() == null && getRoleId() == null) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Both account type and role ID are not provided"); } final CallContext callContext = getCurrentContext(); String finalAccountName = getAccountName(); Long finalDomainId = getDomainId(); callContext.setEventDetails("Account Name: " + finalAccountName + ", Domain Id:" + finalDomainId); try { final LdapUser user = _ldapManager.getUser(username, domainId); validateUser(user); final UserAccount userAccount = createCloudstackUserAccount(user, finalAccountName, finalDomainId); if (userAccount != null) { final AccountResponse response = _responseGenerator.createUserAccountResponse(ResponseView.Full, userAccount); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a user account"); } } catch (NoLdapUserMatchingQueryException e) { throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, "No LDAP user exists with the username of " + username); } }
@Override public void execute() { validateParams(); CallContext.current().setEventDetails("Account Name: " + getUsername() + ", Domain Id:" + getDomainId()); UserAccount userAccount = _accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(), getRoleId(), getDomainId(), getNetworkDomain(), getDetails(), getAccountUUID(), getUserUUID()); if (userAccount != null) { AccountResponse response = _responseGenerator.createUserAccountResponse(ResponseView.Full, userAccount); response.setResponseName(getCommandName()); setResponseObject(response); } else { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a user account"); } }