Skip to content

Commit 8b1a5b1

Browse files
author
Kishan Kavala
committed
- Separated RegionServiceImpl and RegionManagerImpl
- Added comments - Changed package name to org.apache.cloudstack.region
1 parent e848a93 commit 8b1a5b1

49 files changed

Lines changed: 1245 additions & 552 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/src/com/cloud/region/RegionService.java

Lines changed: 0 additions & 49 deletions
This file was deleted.

api/src/com/cloud/user/AccountService.java

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,10 @@
2323
import org.apache.cloudstack.acl.RoleType;
2424
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
2525

26-
import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
2726
import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
28-
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
29-
import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
3027

3128
import com.cloud.domain.Domain;
32-
import com.cloud.exception.ConcurrentOperationException;
3329
import com.cloud.exception.PermissionDeniedException;
34-
import com.cloud.exception.ResourceUnavailableException;
3530
import com.cloud.utils.Pair;
3631

3732
public interface AccountService {
@@ -65,34 +60,6 @@ public interface AccountService {
6560
UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain,
6661
Map<String, String> details, String accountUUID, String userUUID, Integer regionId);
6762

68-
/**
69-
* Deletes a user by userId
70-
*
71-
* @param accountId
72-
* - id of the account do delete
73-
*
74-
* @return true if delete was successful, false otherwise
75-
*/
76-
boolean deleteUserAccount(long accountId);
77-
78-
/**
79-
* Disables a user by userId
80-
*
81-
* @param userId
82-
* - the userId
83-
* @return UserAccount object
84-
*/
85-
UserAccount disableUser(long userId);
86-
87-
/**
88-
* Enables a user
89-
*
90-
* @param userId
91-
* - the userId
92-
* @return UserAccount object
93-
*/
94-
UserAccount enableUser(long userId);
95-
9663
/**
9764
* Locks a user by userId. A locked user cannot access the API, but will still have running VMs/IP addresses
9865
* allocated/etc.
@@ -102,72 +69,12 @@ UserAccount createUserAccount(String userName, String password, String firstName
10269
*/
10370
UserAccount lockUser(long userId);
10471

105-
/**
106-
* Update a user by userId
107-
*
108-
* @param userId
109-
* @return UserAccount object
110-
*/
111-
UserAccount updateUser(UpdateUserCmd cmd);
112-
113-
/**
114-
* Disables an account by accountName and domainId
115-
*
116-
* @param accountName
117-
* TODO
118-
* @param domainId
119-
* TODO
120-
* @param accountId
121-
* @param disabled
122-
* account if success
123-
* @return true if disable was successful, false otherwise
124-
*/
125-
Account disableAccount(String accountName, Long domainId, Long accountId) throws ConcurrentOperationException, ResourceUnavailableException;
126-
127-
/**
128-
* Enables an account by accountId
129-
*
130-
* @param accountName
131-
* - the enableAccount command defining the accountId to be deleted.
132-
* @param domainId
133-
* TODO
134-
* @param accountId
135-
* @return account object
136-
*/
137-
Account enableAccount(String accountName, Long domainId, Long accountId);
138-
139-
/**
140-
* Locks an account by accountId. A locked account cannot access the API, but will still have running VMs/IP
141-
* addresses
142-
* allocated/etc.
143-
*
144-
* @param accountName
145-
* - the LockAccount command defining the accountId to be locked.
146-
* @param domainId
147-
* TODO
148-
* @param accountId
149-
* @return account object
150-
*/
151-
Account lockAccount(String accountName, Long domainId, Long accountId);
152-
153-
/**
154-
* Updates an account name
155-
*
156-
* @param cmd
157-
* - the parameter containing accountId
158-
* @return updated account object
159-
*/
160-
161-
Account updateAccount(UpdateAccountCmd cmd);
162-
16372
Account getSystemAccount();
16473

16574
User getSystemUser();
16675

16776
User createUser(String userName, String password, String firstName, String lastName, String email, String timeZone, String accountName, Long domainId, String userUUID, Integer regionId);
16877

169-
boolean deleteUser(DeleteUserCmd deleteUserCmd);
170-
17178
boolean isAdmin(short accountType);
17279

17380
Account finalizeOwner(Account caller, String accountName, Long domainId, Long projectId);

api/src/com/cloud/user/DomainService.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import org.apache.cloudstack.api.command.admin.domain.ListDomainChildrenCmd;
2222
import org.apache.cloudstack.api.command.admin.domain.ListDomainsCmd;
23-
import org.apache.cloudstack.api.command.admin.domain.UpdateDomainCmd;
2423

2524
import com.cloud.domain.Domain;
2625
import com.cloud.exception.PermissionDeniedException;
@@ -42,21 +41,11 @@ public interface DomainService {
4241
*/
4342
boolean isChildDomain(Long parentId, Long childId);
4443

45-
boolean deleteDomain(long domainId, Boolean cleanup);
46-
4744
Pair<List<? extends Domain>, Integer> searchForDomains(ListDomainsCmd cmd)
4845
throws PermissionDeniedException;
4946

5047
Pair<List<? extends Domain>, Integer> searchForDomainChildren(ListDomainChildrenCmd cmd)
5148
throws PermissionDeniedException;
52-
/**
53-
* update an existing domain
54-
*
55-
* @param cmd
56-
* - the command containing domainId and new domainName
57-
* @return Domain object if the command succeeded
58-
*/
59-
Domain updateDomain(UpdateDomainCmd cmd);
6049

6150
/**
6251
* find the domain by its path

api/src/org/apache/cloudstack/api/BaseCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.regex.Pattern;
2727

2828
import org.apache.cloudstack.query.QueryService;
29+
import org.apache.cloudstack.region.RegionService;
2930
import org.apache.log4j.Logger;
3031

3132
import com.cloud.configuration.ConfigurationService;
@@ -53,7 +54,6 @@
5354
import com.cloud.network.vpn.Site2SiteVpnService;
5455
import com.cloud.projects.Project;
5556
import com.cloud.projects.ProjectService;
56-
import com.cloud.region.RegionService;
5757
import com.cloud.resource.ResourceService;
5858
import com.cloud.server.ManagementService;
5959
import com.cloud.server.TaggedResourceService;

api/src/org/apache/cloudstack/api/ResponseGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
import org.apache.cloudstack.api.response.VpcResponse;
9494
import org.apache.cloudstack.api.response.VpnUsersResponse;
9595
import org.apache.cloudstack.api.response.ZoneResponse;
96+
import org.apache.cloudstack.region.Region;
9697

9798
import com.cloud.async.AsyncJob;
9899
import com.cloud.capacity.Capacity;
@@ -143,7 +144,6 @@
143144
import com.cloud.projects.Project;
144145
import com.cloud.projects.ProjectAccount;
145146
import com.cloud.projects.ProjectInvitation;
146-
import com.cloud.region.Region;
147147
import com.cloud.server.ResourceTag;
148148
import com.cloud.storage.GuestOS;
149149
import com.cloud.storage.S3;

api/src/org/apache/cloudstack/api/command/admin/account/DeleteAccountCmd.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,8 @@ public String getEventDescription() {
9494
@Override
9595
public void execute(){
9696
UserContext.current().setEventDetails("Account Id: "+getId());
97-
boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
98-
boolean result = false;
99-
if(isPopagate){
100-
result = _accountService.deleteUserAccount(getId());
101-
} else {
102-
result = _regionService.deleteUserAccount(getId());
103-
}
97+
98+
boolean result = _regionService.deleteUserAccount(this);
10499
if (result) {
105100
SuccessResponse response = new SuccessResponse(getCommandName());
106101
this.setResponseObject(response);

api/src/org/apache/cloudstack/api/command/admin/account/DisableAccountCmd.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,16 @@ public Long getDomainId() {
7474
public Boolean getIsPropagate() {
7575
return isPropagate;
7676
}
77-
77+
78+
public Boolean getLockRequested() {
79+
return lockRequested;
80+
}
81+
7882
/////////////////////////////////////////////////////
7983
/////////////// API Implementation///////////////////
8084
/////////////////////////////////////////////////////
8185

82-
@Override
86+
@Override
8387
public String getCommandName() {
8488
return s_name;
8589
}
@@ -112,16 +116,7 @@ public String getEventDescription() {
112116
@Override
113117
public void execute() throws ConcurrentOperationException, ResourceUnavailableException{
114118
UserContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
115-
Account result = null;
116-
boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
117-
if(isPopagate){
118-
if(lockRequested)
119-
result = _accountService.lockAccount(getAccountName(), getDomainId(), getId());
120-
else
121-
result = _accountService.disableAccount(getAccountName(), getDomainId(), getId());
122-
} else {
123-
result = _regionService.disableAccount(getAccountName(), getDomainId(), getId(), lockRequested);
124-
}
119+
Account result = _regionService.disableAccount(this);
125120
if (result != null){
126121
AccountResponse response = _responseGenerator.createAccountResponse(result);
127122
response.setResponseName(getCommandName());

api/src/org/apache/cloudstack/api/command/admin/account/EnableAccountCmd.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,7 @@ public long getEntityOwnerId() {
9797

9898
@Override
9999
public void execute(){
100-
boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
101-
Account result = null;
102-
if(isPopagate){
103-
result = _accountService.enableAccount(getAccountName(), getDomainId(), getId());
104-
} else {
105-
result = _regionService.enableAccount(getAccountName(), getDomainId(), getId());
106-
}
100+
Account result = _regionService.enableAccount(this);
107101
if (result != null){
108102
AccountResponse response = _responseGenerator.createAccountResponse(result);
109103
response.setResponseName(getCommandName());

api/src/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,7 @@ public long getEntityOwnerId() {
127127

128128
@Override
129129
public void execute(){
130-
boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
131-
Account result = null;
132-
if(isPopagate){
133-
result = _accountService.updateAccount(this);
134-
} else {
135-
result = _regionService.updateAccount(this);
136-
}
130+
Account result = _regionService.updateAccount(this);
137131
if (result != null){
138132
AccountResponse response = _responseGenerator.createAccountResponse(result);
139133
response.setResponseName(getCommandName());

api/src/org/apache/cloudstack/api/command/admin/domain/DeleteDomainCmd.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,7 @@ public String getEventDescription() {
9595
public void execute(){
9696
UserContext.current().setEventDetails("Domain Id: "+getId());
9797
boolean isPopagate = (getIsPropagate() != null ) ? getIsPropagate() : false;
98-
boolean result = false;
99-
if(isPopagate){
100-
result = _domainService.deleteDomain(id, cleanup);
101-
} else {
102-
result = _regionService.deleteDomain(id, cleanup);
103-
}
98+
boolean result = _regionService.deleteDomain(this);
10499
if (result) {
105100
SuccessResponse response = new SuccessResponse(getCommandName());
106101
this.setResponseObject(response);

0 commit comments

Comments
 (0)