diff --git a/api/src/com/cloud/region/Region.java b/api/src/com/cloud/region/Region.java index 3096af59317..96d7dff5e10 100644 --- a/api/src/com/cloud/region/Region.java +++ b/api/src/com/cloud/region/Region.java @@ -16,8 +16,6 @@ // under the License. package com.cloud.region; -import java.util.Date; - /** * */ @@ -29,8 +27,6 @@ public interface Region { public void setName(String name); - public Date getRemoved(); - public String getEndPoint(); public String getApiKey(); diff --git a/api/src/com/cloud/user/AccountService.java b/api/src/com/cloud/user/AccountService.java index 288d845f1ed..553c84ae100 100755 --- a/api/src/com/cloud/user/AccountService.java +++ b/api/src/com/cloud/user/AccountService.java @@ -200,7 +200,4 @@ public interface AccountService { void checkAccess(Account account, AccessType accessType, boolean sameOwner, ControlledEntity... entities) throws PermissionDeniedException; - User findUser(String username, Long domainId); - - Account findAccount(Long id); } diff --git a/api/src/org/apache/cloudstack/api/ResponseGenerator.java b/api/src/org/apache/cloudstack/api/ResponseGenerator.java index e380642a937..d6780fd66a0 100644 --- a/api/src/org/apache/cloudstack/api/ResponseGenerator.java +++ b/api/src/org/apache/cloudstack/api/ResponseGenerator.java @@ -39,9 +39,6 @@ import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.DomainRouterResponse; import org.apache.cloudstack.api.response.EventResponse; import org.apache.cloudstack.api.response.ExtractResponse; -import org.apache.cloudstack.api.response.FindAccountResponse; -import org.apache.cloudstack.api.response.FindDomainResponse; -import org.apache.cloudstack.api.response.FindUserResponse; import org.apache.cloudstack.api.response.FirewallResponse; import org.apache.cloudstack.api.response.FirewallRuleResponse; import org.apache.cloudstack.api.response.GuestOSResponse; @@ -365,11 +362,6 @@ public interface ResponseGenerator { Site2SiteVpnConnectionResponse createSite2SiteVpnConnectionResponse(Site2SiteVpnConnection result); - FindUserResponse createFindUserResponse(User user); - - FindAccountResponse createFindAccountResponse(Account account); - - FindDomainResponse createFindDomainResponse(Domain domain); CounterResponse createCounterResponse(Counter ctr); ConditionResponse createConditionResponse(Condition cndn); diff --git a/api/src/org/apache/cloudstack/api/command/admin/account/FindAccountCmd.java b/api/src/org/apache/cloudstack/api/command/admin/account/FindAccountCmd.java deleted file mode 100644 index 9cfe548d5ff..00000000000 --- a/api/src/org/apache/cloudstack/api/command/admin/account/FindAccountCmd.java +++ /dev/null @@ -1,76 +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.api.command.admin.account; - -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.FindAccountResponse; -import org.apache.log4j.Logger; - -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.user.Account; - -@APICommand(name = "findAccount", description="Find account by ID", responseObject=FindAccountResponse.class) -public class FindAccountCmd extends BaseCmd { - public static final Logger s_logger = Logger.getLogger(FindAccountCmd.class.getName()); - - private static final String s_name = "findaccountresponse"; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.ID, type=CommandType.UUID, entityType=AccountResponse.class, required=true, description = "Id of the account") - private Long id; - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public Long getId() { - return id; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public String getCommandName() { - return s_name; - } - - @Override - public long getEntityOwnerId() { - return 0; - } - - @Override - public void execute(){ - Account result = _accountService.findAccount(getId()); - if(result != null){ - FindAccountResponse response = _responseGenerator.createFindAccountResponse(result); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } else { - throw new InvalidParameterValueException("Account with specified Id does not exist"); - } - } -} diff --git a/api/src/org/apache/cloudstack/api/command/admin/domain/FindDomainCmd.java b/api/src/org/apache/cloudstack/api/command/admin/domain/FindDomainCmd.java deleted file mode 100644 index ff9bdc1005d..00000000000 --- a/api/src/org/apache/cloudstack/api/command/admin/domain/FindDomainCmd.java +++ /dev/null @@ -1,89 +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.api.command.admin.domain; - -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.DomainResponse; -import org.apache.cloudstack.api.response.FindDomainResponse; -import org.apache.log4j.Logger; - -import com.cloud.domain.Domain; -import com.cloud.exception.InvalidParameterValueException; - -@APICommand(name = "findDomain", description="Find account by ID", responseObject=FindDomainResponse.class) -public class FindDomainCmd extends BaseCmd { - public static final Logger s_logger = Logger.getLogger(FindDomainCmd.class.getName()); - - private static final String s_name = "finddomainresponse"; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.ID, type=CommandType.UUID, entityType=DomainResponse.class, description = "Id of the domain") - private Long id; - - @Parameter(name = ApiConstants.DOMAIN, type = CommandType.STRING, description = "Path of the domain") - private String domain; - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public Long getId() { - return id; - } - - public String getDomain() { - return domain; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public String getCommandName() { - return s_name; - } - - @Override - public long getEntityOwnerId() { - return 0; - } - - @Override - public void execute(){ - Domain result = null; - if(getId() != null){ - result = _domainService.getDomain(getId()); - } else if (getDomain() != null){ - result = _domainService.findDomainByPath(getDomain()); - } - - if(result != null){ - FindDomainResponse response = _responseGenerator.createFindDomainResponse(result); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } else { - throw new InvalidParameterValueException("Domain with specified Id does not exist"); - } - } -} diff --git a/api/src/org/apache/cloudstack/api/command/admin/user/FindUserCmd.java b/api/src/org/apache/cloudstack/api/command/admin/user/FindUserCmd.java deleted file mode 100644 index ffd548765cb..00000000000 --- a/api/src/org/apache/cloudstack/api/command/admin/user/FindUserCmd.java +++ /dev/null @@ -1,83 +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.api.command.admin.user; - -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.DomainResponse; -import org.apache.cloudstack.api.response.FindUserResponse; -import org.apache.log4j.Logger; - -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.user.User; - -@APICommand(name = "findUser", description="Find user by name and domain", responseObject=FindUserResponse.class) -public class FindUserCmd extends BaseCmd { - public static final Logger s_logger = Logger.getLogger(FindUserCmd.class.getName()); - - private static final String s_name = "finduserresponse"; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="find user with specified username") - private String username; - - @Parameter(name = ApiConstants.DOMAIN_ID, type=CommandType.UUID, entityType=DomainResponse.class, required=true, description = "Domain the user belongs to") - private Long domainId; - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public String getUserName() { - return username; - } - - public Long getDomainId() { - return domainId; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public String getCommandName() { - return s_name; - } - - @Override - public long getEntityOwnerId() { - return 0; - } - - @Override - public void execute(){ - User result = _accountService.findUser(getUserName(), getDomainId()); - if(result != null){ - FindUserResponse response = _responseGenerator.createFindUserResponse(result); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } else { - throw new InvalidParameterValueException("User with specified name and domainId does not exist"); - } - } -} diff --git a/api/src/org/apache/cloudstack/api/response/FindAccountResponse.java b/api/src/org/apache/cloudstack/api/response/FindAccountResponse.java deleted file mode 100755 index 6cff618057c..00000000000 --- a/api/src/org/apache/cloudstack/api/response/FindAccountResponse.java +++ /dev/null @@ -1,106 +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.api.response; - -import java.util.Map; - -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.BaseResponse; -import org.apache.cloudstack.api.EntityReference; - -import com.cloud.serializer.Param; -import com.cloud.user.Account; -import com.google.gson.annotations.SerializedName; - -@SuppressWarnings("unused") -@EntityReference(value = Account.class) -public class FindAccountResponse extends BaseResponse { - @SerializedName(ApiConstants.ID) @Param(description="the id of the account") - private String id; - - @SerializedName(ApiConstants.NAME) @Param(description="the name of the account") - private String name; - - @SerializedName(ApiConstants.ACCOUNT_TYPE) @Param(description="account type (admin, domain-admin, user)") - private Short accountType; - - @SerializedName(ApiConstants.DOMAIN_ID) @Param(description="id of the Domain the account belongs too") - private String domainId; - - @SerializedName(ApiConstants.DEFAULT_ZONE_ID) @Param(description="the default zone of the account") - private String defaultZoneId; - - @SerializedName(ApiConstants.STATE) @Param(description="the state of the account") - private String state; - - @SerializedName(ApiConstants.NETWORK_DOMAIN) @Param(description="the network domain") - private String networkDomain; - - @SerializedName(ApiConstants.ACCOUNT_DETAILS) @Param(description="details for the account") - private Map details; - - @SerializedName("regionId") @Param(description="source region id of the user") - private int regionId; - - public void setName(String name) { - this.name = name; - } - - public void setAccountType(Short accountType) { - this.accountType = accountType; - } - - public void setState(String state) { - this.state = state; - } - - public void setNetworkDomain(String networkDomain) { - this.networkDomain = networkDomain; - } - - public void setDetails(Map details) { - this.details = details; - } - - public void setRegionId(int regionId) { - this.regionId = regionId; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getDomainId() { - return domainId; - } - - public void setDomainId(String domainId) { - this.domainId = domainId; - } - - public String getDefaultZoneId() { - return defaultZoneId; - } - - public void setDefaultZoneId(String defaultZoneId) { - this.defaultZoneId = defaultZoneId; - } -} diff --git a/api/src/org/apache/cloudstack/api/response/FindDomainResponse.java b/api/src/org/apache/cloudstack/api/response/FindDomainResponse.java deleted file mode 100644 index 055e4a2b78c..00000000000 --- a/api/src/org/apache/cloudstack/api/response/FindDomainResponse.java +++ /dev/null @@ -1,103 +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.api.response; - -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.BaseResponse; -import org.apache.cloudstack.api.EntityReference; - -import com.cloud.domain.Domain; -import com.cloud.serializer.Param; -import com.google.gson.annotations.SerializedName; - -@EntityReference(value = Domain.class) -public class FindDomainResponse extends BaseResponse { - @SerializedName(ApiConstants.ID) @Param(description="the ID of the domain") - private String id; - - @SerializedName(ApiConstants.NAME) @Param(description="the name of the domain") - private String domainName; - - @SerializedName(ApiConstants.LEVEL) @Param(description="the level of the domain") - private Integer level; - - @SerializedName("parentdomainid") @Param(description="the domain ID of the parent domain") - private String parent; - - @SerializedName("haschild") @Param(description="whether the domain has one or more sub-domains") - private boolean hasChild; - - @SerializedName(ApiConstants.NETWORK_DOMAIN) @Param(description="the network domain") - private String networkDomain; - - @SerializedName(ApiConstants.PATH) @Param(description="the path of the domain") - private String path; - - @SerializedName(ApiConstants.STATE) @Param(description="the state of the domain") - private String state; - - @SerializedName("regionId") @Param(description="source region id of the user") - private int regionId; - - public void setDomainName(String domainName) { - this.domainName = domainName; - } - - public void setLevel(Integer level) { - this.level = level; - } - - public void setHasChild(boolean hasChild) { - this.hasChild = hasChild; - } - - public void setNetworkDomain(String networkDomain) { - this.networkDomain = networkDomain; - } - - public void setPath(String path) { - this.path = path; - } - - public void setRegionId(int regionId) { - this.regionId = regionId; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getParent() { - return parent; - } - - public void setParent(String parent) { - this.parent = parent; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } -} diff --git a/api/src/org/apache/cloudstack/api/response/FindUserResponse.java b/api/src/org/apache/cloudstack/api/response/FindUserResponse.java deleted file mode 100644 index c60caabd596..00000000000 --- a/api/src/org/apache/cloudstack/api/response/FindUserResponse.java +++ /dev/null @@ -1,193 +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.api.response; - -import java.util.Date; - -import org.apache.cloudstack.api.BaseResponse; -import org.apache.cloudstack.api.EntityReference; - -import com.cloud.serializer.Param; -import com.cloud.user.User; -import com.google.gson.annotations.SerializedName; - -@EntityReference(value = User.class) -public class FindUserResponse extends BaseResponse { - @SerializedName("id") @Param(description="the user ID") - private String id ; - - @SerializedName("username") @Param(description="the user name") - private String username; - - @SerializedName("password") @Param(description="the password of the user") - private String password; - - @SerializedName("firstname") @Param(description="the user firstname") - private String firstname; - - @SerializedName("lastname") @Param(description="the user lastname") - private String lastname; - - @SerializedName("accountId") @Param(description="the account ID of the user") - private String accountId; - - @SerializedName("email") @Param(description="the user email address") - private String email; - - @SerializedName("state") @Param(description="the user state") - private String state; - - @SerializedName("apikey") @Param(description="the api key of the user") - private String apiKey; - - @SerializedName("secretkey") @Param(description="the secret key of the user") - private String secretKey; - - @SerializedName("created") @Param(description="the date and time the user account was created") - private Date created; - - @SerializedName("timezone") @Param(description="the timezone user was created in") - private String timezone; - - @SerializedName("registrationtoken") @Param(description="the registration token") - private String registrationToken; - - @SerializedName("registered") @Param(description="registration flag") - boolean registered; - - @SerializedName("regionId") @Param(description="source region id of the user") - private int regionId; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getFirstname() { - return firstname; - } - - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - public String getLastname() { - return lastname; - } - - public void setLastname(String lastname) { - this.lastname = lastname; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public Date getCreated() { - return created; - } - - public void setCreated(Date created) { - this.created = created; - } - - public String getState() { - return state; - } - - public void setState(String state) { - this.state = state; - } - - public String getTimezone() { - return timezone; - } - - public void setTimezone(String timezone) { - this.timezone = timezone; - } - - public String getApiKey() { - return apiKey; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } - - public String getSecretKey() { - return secretKey; - } - - public void setSecretKey(String secretKey) { - this.secretKey = secretKey; - } - public String getAccountId() { - return accountId; - } - - public void setAccountId(String accountId) { - this.accountId = accountId; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getRegistrationToken() { - return registrationToken; - } - - public void setRegistrationToken(String registrationToken) { - this.registrationToken = registrationToken; - } - - public boolean isRegistered() { - return registered; - } - - public void setRegistered(boolean registered) { - this.registered = registered; - } - - public int getRegionId() { - return regionId; - } - - public void setRegionId(int regionId) { - this.regionId = regionId; - } -} diff --git a/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java b/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java index 4417a97590c..b0cf0b03cd6 100644 --- a/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java +++ b/plugins/user-authenticators/md5/src/com/cloud/server/auth/MD5UserAuthenticator.java @@ -25,9 +25,9 @@ import javax.naming.ConfigurationException; import org.apache.log4j.Logger; -import com.cloud.region.RegionManager; import com.cloud.server.ManagementServer; import com.cloud.user.UserAccount; +import com.cloud.user.dao.UserAccountDao; import com.cloud.utils.component.ComponentLocator; import com.cloud.utils.exception.CloudRuntimeException; @@ -40,14 +40,14 @@ import com.cloud.utils.exception.CloudRuntimeException; public class MD5UserAuthenticator extends DefaultUserAuthenticator { public static final Logger s_logger = Logger.getLogger(MD5UserAuthenticator.class); - private RegionManager _regionMgr; + private UserAccountDao _userAccountDao; @Override public boolean authenticate(String username, String password, Long domainId, Map requestParameters ) { if (s_logger.isDebugEnabled()) { s_logger.debug("Retrieving user: " + username); } - UserAccount user = _regionMgr.getUserAccount(username, domainId); + UserAccount user = _userAccountDao.getUserAccount(username, domainId); if (user == null) { s_logger.debug("Unable to find user with " + username + " in domain " + domainId); return false; @@ -64,7 +64,7 @@ public class MD5UserAuthenticator extends DefaultUserAuthenticator { throws ConfigurationException { super.configure(name, params); ComponentLocator locator = ComponentLocator.getLocator(ManagementServer.Name); - _regionMgr = locator.getManager(RegionManager.class); + _userAccountDao = locator.getDao(UserAccountDao.class); return true; } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index cef780d121b..86f0ea3a7c1 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -78,9 +78,6 @@ import org.apache.cloudstack.api.response.DomainResponse; import org.apache.cloudstack.api.response.DomainRouterResponse; import org.apache.cloudstack.api.response.EventResponse; import org.apache.cloudstack.api.response.ExtractResponse; -import org.apache.cloudstack.api.response.FindAccountResponse; -import org.apache.cloudstack.api.response.FindDomainResponse; -import org.apache.cloudstack.api.response.FindUserResponse; import org.apache.cloudstack.api.response.FirewallResponse; import org.apache.cloudstack.api.response.FirewallRuleResponse; import org.apache.cloudstack.api.response.GuestOSResponse; @@ -3113,69 +3110,6 @@ public class ApiResponseHelper implements ResponseGenerator { return response; } - @Override - public FindUserResponse createFindUserResponse(User user) { - FindUserResponse userResponse = new FindUserResponse(); - userResponse.setId(user.getUuid()); - userResponse.setUsername(user.getUsername()); - userResponse.setPassword(user.getPassword()); - userResponse.setFirstname(user.getFirstname()); - userResponse.setLastname(user.getLastname()); - Account account = ApiDBUtils.findAccountById(user.getAccountId()); - if(account != null){ - userResponse.setAccountId(account.getUuid()); - } - userResponse.setEmail(user.getEmail()); - userResponse.setState(user.getState().toString()); - userResponse.setApiKey(user.getApiKey()); - userResponse.setSecretKey(user.getSecretKey()); - userResponse.setCreated(user.getCreated()); - userResponse.setTimezone(user.getTimezone()); - userResponse.setRegistrationToken(user.getRegistrationToken()); - userResponse.setRegistered(user.isRegistered()); - userResponse.setRegionId(user.getRegionId()); - userResponse.setObjectName("user"); - - return userResponse; - } - - @Override - public FindAccountResponse createFindAccountResponse(Account account) { - FindAccountResponse accountResponse = new FindAccountResponse(); - accountResponse.setId(account.getUuid()); - accountResponse.setName(account.getAccountName()); - accountResponse.setAccountType(account.getType()); - DataCenterVO zone = ApiDBUtils.findZoneById(account.getDefaultZoneId()); - if(zone != null){ - accountResponse.setDefaultZoneId(zone.getUuid()); - } - Domain domain = ApiDBUtils.findDomainById(account.getDomainId()); - if(domain != null){ - accountResponse.setDomainId(domain.getUuid()); - } - accountResponse.setRegionId(account.getRegionId()); - accountResponse.setState(account.getState().toString()); - accountResponse.setObjectName("account"); - return accountResponse; - } - - @Override - public FindDomainResponse createFindDomainResponse(Domain domain) { - FindDomainResponse domainResponse = new FindDomainResponse(); - domainResponse.setDomainName(domain.getName()); - domainResponse.setId(domain.getUuid()); - domainResponse.setLevel(domain.getLevel()); - domainResponse.setNetworkDomain(domain.getNetworkDomain()); - Domain parentDomain = ApiDBUtils.findDomainById(domain.getParent()); - if (parentDomain != null) { - domainResponse.setParent(parentDomain.getUuid()); - } - domainResponse.setPath(domain.getPath()); - domainResponse.setObjectName("domain"); - domainResponse.setRegionId(domain.getRegionId()); - return domainResponse; - } - @Override public GuestOSResponse createGuestOSResponse(GuestOS guestOS) { GuestOSResponse response = new GuestOSResponse(); diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index 0b160f1018e..d2d07125acb 100755 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -754,7 +754,7 @@ public class ApiServer implements HttpRequestHandler { if (domainPath == null || domainPath.trim().length() == 0) { domainId = DomainVO.ROOT_DOMAIN; } else { - Domain domainObj = _regionMgr.findDomainByPath(domainPath); + Domain domainObj = _domainMgr.findDomainByPath(domainPath); if (domainObj != null) { domainId = domainObj.getId(); } else { // if an unknown path is passed in, fail the login call diff --git a/server/src/com/cloud/region/RegionManager.java b/server/src/com/cloud/region/RegionManager.java index 453a9779411..437e02d334d 100644 --- a/server/src/com/cloud/region/RegionManager.java +++ b/server/src/com/cloud/region/RegionManager.java @@ -18,10 +18,6 @@ package com.cloud.region; import java.util.Map; -import com.cloud.domain.Domain; -import com.cloud.user.UserAccount; - - public interface RegionManager { public boolean propogateAddAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain, Map details, String accountUUID, String userUUID); @@ -31,6 +27,4 @@ public interface RegionManager { String firstName, String lastName, String email, String timeZone, String accountName, String domainUUId, String userUUID); public void propogateAddDomain(String name, Long parentId, String networkDomain, String uuid); - UserAccount getUserAccount(String username, Long domainId); - Domain findDomainByPath(String domainPath); } diff --git a/server/src/com/cloud/region/RegionManagerImpl.java b/server/src/com/cloud/region/RegionManagerImpl.java index 193c16ab2a2..a2a79e444c7 100755 --- a/server/src/com/cloud/region/RegionManagerImpl.java +++ b/server/src/com/cloud/region/RegionManagerImpl.java @@ -99,6 +99,72 @@ public class RegionManagerImpl implements RegionManager, RegionService, Manager{ return _name; } + @Override + public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey) { + if( _regionDao.findById(id) == null ){ + RegionVO region = new RegionVO(id, name, endPoint, apiKey, secretKey); + return _regionDao.persist(region); + } else { + throw new InvalidParameterValueException("Region with id: "+id+" already exists"); + } + } + + @Override + public Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey) { + RegionVO region = _regionDao.findById(id); + + if(region == null){ + throw new InvalidParameterValueException("Region with id: "+id+" does not exist"); + } + + if(name != null){ + region.setName(name); + } + + if(endPoint != null){ + region.setEndPoint(endPoint); + } + + if(apiKey != null){ + region.setApiKey(apiKey); + } + + if(secretKey != null){ + region.setSecretKey(secretKey); + } + + _regionDao.update(id, region); + return _regionDao.findById(id); + } + + @Override + public boolean removeRegion(int id) { + RegionVO region = _regionDao.findById(id); + if(region != null){ + return _regionDao.remove(id); + } else { + throw new InvalidParameterValueException("Failed to delete Region: " + id + ", Region not found"); + } + } + + @Override + public List listRegions(ListRegionsCmd cmd) { + if(cmd.getId() != null){ + List regions = new ArrayList(); + regions.add(_regionDao.findById(cmd.getId())); + return regions; + } + return _regionDao.listAll(); + } + + public int getId() { + return _id; + } + + public void setId(int _id) { + this._id = _id; + } + @Override public boolean propogateAddAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain, Map details, String accountUUID, String userUUID) { @@ -249,73 +315,6 @@ public class RegionManagerImpl implements RegionManager, RegionService, Manager{ } } - @Override - public Region addRegion(int id, String name, String endPoint, String apiKey, String secretKey) { - if( _regionDao.findById(id) == null ){ - RegionVO region = new RegionVO(id, name, endPoint, apiKey, secretKey); - return _regionDao.persist(region); - } else { - throw new InvalidParameterValueException("Region with id: "+id+" already exists"); - } - } - - @Override - public Region updateRegion(int id, String name, String endPoint, String apiKey, String secretKey) { - RegionVO region = _regionDao.findById(id); - - if(region == null){ - throw new InvalidParameterValueException("Region with id: "+id+" does not exist"); - } - - if(name != null){ - region.setName(name); - } - - if(endPoint != null){ - region.setEndPoint(endPoint); - } - - if(apiKey != null){ - region.setApiKey(apiKey); - } - - if(secretKey != null){ - region.setSecretKey(secretKey); - } - - _regionDao.update(id, region); - return _regionDao.findById(id); - } - - @Override - public boolean removeRegion(int id) { - //Remove complete row, instead of soft delete - RegionVO region = _regionDao.findById(id); - if(region != null){ - return _regionDao.remove(id); - } else { - throw new InvalidParameterValueException("Failed to delete Region: " + id + ", Region not found"); - } - } - - public int getId() { - return _id; - } - - public void setId(int _id) { - this._id = _id; - } - - @Override - public List listRegions(ListRegionsCmd cmd) { - if(cmd.getId() != null){ - List regions = new ArrayList(); - regions.add(_regionDao.findById(cmd.getId())); - return regions; - } - return _regionDao.listAll(); - } - @Override public Account disableAccount(String accountName, Long domainId, Long accountId, Boolean lockRequested) throws ConcurrentOperationException, ResourceUnavailableException { Account account = null; @@ -774,149 +773,5 @@ public class RegionManagerImpl implements RegionManager, RegionService, Manager{ } return; } - - @Override - public UserAccount getUserAccount(String username, Long domainId) { - UserAccount user = _userAccountDao.getUserAccount(username, domainId); - if(user != null){ - return user; - } else { - DomainVO domain = _domainDao.findById(domainId); - if(domain == null){ - //Lookup Domain - s_logger.debug("Domain with Id :"+domainId+" doesn't exist"); - } - String command = "findUser"; - List params = new ArrayList(); - params.add(new NameValuePair(ApiConstants.USERNAME, username)); - params.add(new NameValuePair(ApiConstants.DOMAIN_ID, domain.getUuid())); - RegionUser regionuser = null; - List regions = _regionDao.listAll(); - boolean sourceCheck = false; - for (Region region : regions){ - if(region.getId() == getId()){ - continue; - } - s_logger.debug("Looking up user :"+username+" in Region: "+region.getId()); - regionuser = RegionsApiUtil.makeUserAPICall(region, command, params); - if(regionuser != null){ - s_logger.debug("Found user :"+username+" in Region: "+region.getId()); - if(regionuser.getRegionId() != region.getId()){ - sourceCheck = true; - } - break; - } - } - if(regionuser == null){ - s_logger.debug("User :"+username+" not found in any Region"); - return null; - } - - if(sourceCheck){ - if(regionuser.getRegionId() == getId()){ - s_logger.debug("Current Region is the source Region for found user: " +username+ ". Ignoring.."); - return null; - } - - s_logger.debug("Verifying user: " +username+ " in source Region: "+regionuser.getRegionId()); - - //Verify user in source Region - Region sourceRegion = _regionDao.findById(regionuser.getRegionId()); - if(sourceRegion != null){ - regionuser = RegionsApiUtil.makeUserAPICall(sourceRegion, command, params); - if(regionuser != null && sourceRegion.getId() == regionuser.getRegionId()){ - s_logger.debug("Found User :"+username+" in Source Region: "+sourceRegion.getId()+" Add to local Region"); - } else { - s_logger.debug("User :"+username+" not found in Source Region: "+sourceRegion.getId()); - return null; - } - } else { - s_logger.debug("Source Region :"+regionuser.getRegionId()+" not found"); - return null; - } - } - - if(regionuser != null){ - Long accountId = _identityDao.getIdentityId("account", regionuser.getAccountuuid()); - if(accountId == null){ - //Lookup Account - } - regionuser.setAccountId(accountId); - UserVO newuser = (UserVO)regionuser; - _userDao.persist(newuser); - return _userAccountDao.getUserAccount(username, domainId); - } - return null; - } - } - - @Override - public DomainVO findDomainByPath(String domainPath) { - DomainVO domain = (DomainVO)_domainMgr.findDomainByPath(domainPath); - if(domain != null){ - return domain; - } else { - String command = "findDomain"; - List params = new ArrayList(); - params.add(new NameValuePair(ApiConstants.DOMAIN, domainPath)); - boolean sourceCheck = false; - RegionDomain regiondomain = null; - List regions = _regionDao.listAll(); - for (Region region : regions){ - if(region.getId() == getId()){ - continue; - } - s_logger.debug("Looking up domain :"+domainPath+" in Region: "+region.getId()); - regiondomain = RegionsApiUtil.makeDomainAPICall(region, command, params); - if(regiondomain != null){ - s_logger.debug("Found domain :"+domainPath+" in Region: "+region.getId()); - if(regiondomain.getRegionId() != region.getId()){ - sourceCheck = true; - } - break; - } - } - - if(regiondomain == null){ - s_logger.debug("Domain :"+domainPath+" not found in any Region"); - return null; - } - - if(sourceCheck){ - if(regiondomain.getRegionId() == getId()){ - s_logger.debug("Current Region is the source Region for found domain: " +domainPath+ ". Ignoring.."); - return null; - } - - s_logger.debug("Verifying domain: " +domainPath+ " in source Region: "+regiondomain.getRegionId()); - - //Verify user in source Region - Region sourceRegion = _regionDao.findById(regiondomain.getRegionId()); - if(sourceRegion != null){ - DomainVO sourceDomain = RegionsApiUtil.makeDomainAPICall(sourceRegion, command, params); - if(sourceDomain != null && sourceRegion.getId() == sourceDomain.getRegionId()){ - s_logger.debug("Found Domain :"+domainPath+" in Source Region: "+sourceRegion.getId()+" Add to local Region"); - } else { - s_logger.debug("Domain :"+domainPath+" not found in Source Region: "+sourceRegion.getId()); - return null; - } - } else { - s_logger.debug("Source Region :"+regiondomain.getRegionId()+" not found"); - return null; - } - } - - if(regiondomain != null){ - Long parentId = _identityDao.getIdentityId("domain", regiondomain.getParentUuid()); - if(parentId == null){ - //lookup ParentDomain - } - regiondomain.setParent(parentId); - regiondomain.setState(Domain.State.Active); - _domainDao.persist((DomainVO)regiondomain); - } - return (DomainVO)_domainMgr.findDomainByPath(domainPath); - } - } } diff --git a/server/src/com/cloud/region/RegionVO.java b/server/src/com/cloud/region/RegionVO.java index c54dea23154..a168f395aa6 100644 --- a/server/src/com/cloud/region/RegionVO.java +++ b/server/src/com/cloud/region/RegionVO.java @@ -16,14 +16,11 @@ // under the License. package com.cloud.region; -import java.util.Date; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; -import com.cloud.utils.db.GenericDao; @Entity @Table(name="region") @@ -45,9 +42,6 @@ public class RegionVO implements Region{ @Column(name="secret_key") private String secretKey; - @Column(name=GenericDao.REMOVED_COLUMN) - private Date removed; - public RegionVO() { } @@ -71,10 +65,6 @@ public class RegionVO implements Region{ this.name = name; } - public Date getRemoved() { - return removed; - } - public String getEndPoint() { return endPoint; } diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java index dcd6da30e72..c5c53e898dc 100755 --- a/server/src/com/cloud/user/AccountManagerImpl.java +++ b/server/src/com/cloud/user/AccountManagerImpl.java @@ -2240,24 +2240,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag } } - @Override - public User findUser(String username, Long domainId) { - UserAccount userAccount = _userAccountDao.getUserAccount(username, domainId); - if(userAccount == null){ - throw new InvalidParameterValueException("Unable to find user account by name: "+username); - } - User user = _userDao.findById(userAccount.getId()); - if(user == null){ - throw new InvalidParameterValueException("Unable to find user by name: "+username); - } - return user; - } - - @Override - public Account findAccount(Long id) { - return _accountDao.findById(id); - } - @Override public void buildACLViewSearchBuilder(SearchBuilder sb, Long domainId, boolean isRecursive, List permittedAccounts, ListProjectResourcesCriteria listProjectResourcesCriteria) { diff --git a/server/test/com/cloud/user/MockAccountManagerImpl.java b/server/test/com/cloud/user/MockAccountManagerImpl.java index 7e204916d71..2b22e7bc98a 100644 --- a/server/test/com/cloud/user/MockAccountManagerImpl.java +++ b/server/test/com/cloud/user/MockAccountManagerImpl.java @@ -28,11 +28,9 @@ import org.apache.cloudstack.acl.SecurityChecker.AccessType; import com.cloud.api.query.vo.ControlledViewEntity; import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd; -import org.apache.cloudstack.api.command.admin.user.ListUsersCmd; import org.apache.cloudstack.api.command.admin.user.RegisterCmd; import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd; import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd; -import org.apache.cloudstack.api.command.user.account.ListAccountsCmd; import com.cloud.domain.Domain; import com.cloud.exception.ConcurrentOperationException; @@ -342,18 +340,6 @@ public class MockAccountManagerImpl implements Manager, AccountManager, AccountS return null; } - @Override - public User findUser(String username, Long domainId) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Account findAccount(Long id) { - // TODO Auto-generated method stub - return null; - } - @Override public Account createAccount(String accountName, short accountType, Long domainId, String networkDomain, Map details, String uuid, diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 62b95af7ec7..31f6d781557 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -2262,7 +2262,6 @@ CREATE TABLE `cloud`.`region` ( `end_point` varchar(255) NOT NULL, `api_key` varchar(255), `secret_key` varchar(255), - `removed` datetime COMMENT 'date removed if not null', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;