5050import org .apache .log4j .Logger ;
5151
5252import com .cloud .api .ApiDBUtils ;
53- import com .cloud .api .query .dao .UserAccountJoinDao ;
5453import com .cloud .api .query .vo .ControlledViewEntity ;
5554import com .cloud .configuration .Config ;
5655import com .cloud .configuration .ConfigurationManager ;
105104import com .cloud .projects .dao .ProjectAccountDao ;
106105import com .cloud .projects .dao .ProjectDao ;
107106import com .cloud .server .auth .UserAuthenticator ;
108- import com .cloud .storage .StorageManager ;
109107import com .cloud .storage .VMTemplateVO ;
110108import com .cloud .storage .Volume ;
111109import com .cloud .storage .VolumeManager ;
@@ -164,8 +162,6 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
164162 @ Inject
165163 private UserAccountDao _userAccountDao ;
166164 @ Inject
167- private UserAccountJoinDao _userAccountJoinDao ;
168- @ Inject
169165 private VolumeDao _volumeDao ;
170166 @ Inject
171167 private UserVmDao _userVmDao ;
@@ -190,8 +186,6 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
190186 @ Inject
191187 private UserVmManager _vmMgr ;
192188 @ Inject
193- private StorageManager _storageMgr ;
194- @ Inject
195189 private TemplateManager _tmpltMgr ;
196190 @ Inject
197191 private ConfigurationManager _configMgr ;
@@ -505,8 +499,8 @@ public boolean enableAccount(long accountId) {
505499 return success ;
506500 }
507501
508- @ Override
509- public boolean lockAccount (long accountId ) {
502+
503+ protected boolean lockAccount (long accountId ) {
510504 boolean success = false ;
511505 Account account = _accountDao .findById (accountId );
512506 if (account != null ) {
@@ -544,8 +538,8 @@ public boolean deleteAccount(AccountVO account, long callerUserId, Account calle
544538 return cleanupAccount (account , callerUserId , caller );
545539 }
546540
547- @ Override
548- public boolean cleanupAccount (AccountVO account , long callerUserId , Account caller ) {
541+
542+ protected boolean cleanupAccount (AccountVO account , long callerUserId , Account caller ) {
549543 long accountId = account .getId ();
550544 boolean accountCleanupNeeded = false ;
551545
@@ -1617,21 +1611,13 @@ public Account getActiveAccountByName(String accountName, Long domainId) {
16171611 }
16181612
16191613 @ Override
1620- public Account getActiveAccountById (Long accountId ) {
1621- if (accountId == null ) {
1622- throw new InvalidParameterValueException ("AccountId is required by account search" );
1623- } else {
1624- return _accountDao .findById (accountId );
1625- }
1614+ public Account getActiveAccountById (long accountId ) {
1615+ return _accountDao .findById (accountId );
16261616 }
16271617
16281618 @ Override
1629- public Account getAccount (Long accountId ) {
1630- if (accountId == null ) {
1631- throw new InvalidParameterValueException ("AccountId is required by account search" );
1632- } else {
1633- return _accountDao .findByIdIncludingRemoved (accountId );
1634- }
1619+ public Account getAccount (long accountId ) {
1620+ return _accountDao .findByIdIncludingRemoved (accountId );
16351621 }
16361622
16371623 @ Override
@@ -1669,62 +1655,6 @@ public User getUserIncludingRemoved(long userId) {
16691655 return _userDao .findByIdIncludingRemoved (userId );
16701656 }
16711657
1672- @ Override
1673- public Pair <List <Long >, Long > finalizeAccountDomainForList (Account caller , String accountName , Long domainId , Long projectId ) {
1674- List <Long > permittedAccounts = new ArrayList <Long >();
1675-
1676- if (isAdmin (caller .getType ())) {
1677- if (domainId == null && accountName != null ) {
1678- throw new InvalidParameterValueException ("accountName and domainId might be specified together" );
1679- } else if (domainId != null ) {
1680- Domain domain = _domainMgr .getDomain (domainId );
1681- if (domain == null ) {
1682- throw new InvalidParameterValueException ("Unable to find the domain by id=" + domainId );
1683- }
1684-
1685- checkAccess (caller , domain );
1686-
1687- if (accountName != null ) {
1688- Account owner = getActiveAccountByName (accountName , domainId );
1689- if (owner == null ) {
1690- throw new InvalidParameterValueException ("Unable to find account with name " + accountName + " in domain id=" + domainId );
1691- }
1692-
1693- permittedAccounts .add (owner .getId ());
1694- }
1695- }
1696- } else if (accountName != null && domainId != null ) {
1697- if (!accountName .equals (caller .getAccountName ()) || domainId .longValue () != caller .getDomainId ()) {
1698- throw new PermissionDeniedException ("Can't list port forwarding rules for account " + accountName + " in domain " + domainId + ", permission denied" );
1699- }
1700- permittedAccounts .add (getActiveAccountByName (accountName , domainId ).getId ());
1701- } else {
1702- permittedAccounts .add (caller .getAccountId ());
1703- }
1704-
1705- if (domainId == null && caller .getType () == Account .ACCOUNT_TYPE_DOMAIN_ADMIN ) {
1706- domainId = caller .getDomainId ();
1707- }
1708-
1709- // set project information
1710- if (projectId != null ) {
1711- if (projectId .longValue () == -1 ) {
1712- permittedAccounts .addAll (_projectMgr .listPermittedProjectAccounts (caller .getId ()));
1713- } else {
1714- permittedAccounts .clear ();
1715- Project project = _projectMgr .getProject (projectId );
1716- if (project == null ) {
1717- throw new InvalidParameterValueException ("Unable to find project by id " + projectId );
1718- }
1719- if (!_projectMgr .canAccessProjectAccount (caller , project .getProjectAccountId ())) {
1720- throw new InvalidParameterValueException ("Account " + caller + " can't access project id=" + projectId );
1721- }
1722- permittedAccounts .add (project .getProjectAccountId ());
1723- }
1724- }
1725-
1726- return new Pair <List <Long >, Long >(permittedAccounts , domainId );
1727- }
17281658
17291659 @ Override
17301660 public User getActiveUserByRegistrationToken (String registrationToken ) {
@@ -1806,9 +1736,8 @@ public AccountVO createAccount(String accountName, short accountType, Long domai
18061736 return account ;
18071737 }
18081738
1809- @ Override
18101739 @ ActionEvent (eventType = EventTypes .EVENT_USER_CREATE , eventDescription = "creating User" )
1811- public UserVO createUser (long accountId , String userName , String password , String firstName , String lastName , String email , String timezone , String userUUID ) {
1740+ protected UserVO createUser (long accountId , String userName , String password , String firstName , String lastName , String email , String timezone , String userUUID ) {
18121741 if (s_logger .isDebugEnabled ()) {
18131742 s_logger .debug ("Creating user: " + userName + ", accountId: " + accountId + " timezone:" + timezone );
18141743 }
@@ -1833,29 +1762,13 @@ public UserVO createUser(long accountId, String userName, String password, Strin
18331762 }
18341763
18351764 @ Override
1836- public void logoutUser (Long userId ) {
1765+ public void logoutUser (long userId ) {
18371766 UserAccount userAcct = _userAccountDao .findById (userId );
18381767 if (userAcct != null ) {
18391768 ActionEventUtils .onActionEvent (userId , userAcct .getAccountId (), userAcct .getDomainId (), EventTypes .EVENT_USER_LOGOUT , "user has logged out" );
18401769 } // else log some kind of error event? This likely means the user doesn't exist, or has been deleted...
18411770 }
18421771
1843- @ Override
1844- public UserAccount getUserAccount (String username , Long domainId ) {
1845- if (s_logger .isDebugEnabled ()) {
1846- s_logger .debug ("Retrieiving user: " + username + " in domain " + domainId );
1847- }
1848-
1849- UserAccount userAccount = _userAccountDao .getUserAccount (username , domainId );
1850- if (userAccount == null ) {
1851- if (s_logger .isDebugEnabled ()) {
1852- s_logger .debug ("Unable to find user with name " + username + " in domain " + domainId );
1853- }
1854- return null ;
1855- }
1856-
1857- return userAccount ;
1858- }
18591772
18601773 @ Override
18611774 public UserAccount authenticateUser (String username , String password , Long domainId , String loginIpAddress , Map <String , Object []> requestParameters ) {
0 commit comments