mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Events for adding/removing project users
This commit is contained in:
		
							parent
							
								
									a623b2824b
								
							
						
					
					
						commit
						eda1b53c76
					
				| @ -26,7 +26,10 @@ import com.cloud.api.Implementation; | |||||||
| import com.cloud.api.Parameter; | import com.cloud.api.Parameter; | ||||||
| import com.cloud.api.ServerApiException; | import com.cloud.api.ServerApiException; | ||||||
| import com.cloud.api.response.SuccessResponse; | import com.cloud.api.response.SuccessResponse; | ||||||
|  | import com.cloud.exception.InvalidParameterValueException; | ||||||
|  | import com.cloud.projects.Project; | ||||||
| import com.cloud.user.Account; | import com.cloud.user.Account; | ||||||
|  | import com.cloud.user.UserContext; | ||||||
| 
 | 
 | ||||||
| @Implementation(description="Adds acoount to a project", responseObject=SuccessResponse.class) | @Implementation(description="Adds acoount to a project", responseObject=SuccessResponse.class) | ||||||
| public class AddAccountToProjectCmd extends BaseCmd { | public class AddAccountToProjectCmd extends BaseCmd { | ||||||
| @ -72,6 +75,7 @@ public class AddAccountToProjectCmd extends BaseCmd { | |||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public void execute(){ |     public void execute(){ | ||||||
|  |         UserContext.current().setEventDetails("Project id: "+ projectId + "; accountName " + accountName); | ||||||
|         boolean result = _projectService.addAccountToProject(getProjectId(), getAccountName()); |         boolean result = _projectService.addAccountToProject(getProjectId(), getAccountName()); | ||||||
|         if (result) { |         if (result) { | ||||||
|             SuccessResponse response = new SuccessResponse(getCommandName()); |             SuccessResponse response = new SuccessResponse(getCommandName()); | ||||||
| @ -83,7 +87,12 @@ public class AddAccountToProjectCmd extends BaseCmd { | |||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     public long getEntityOwnerId() { |     public long getEntityOwnerId() { | ||||||
|         //TODO - return project entity ownerId |         Project project= _projectService.getProject(projectId); | ||||||
|         return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked |         //verify input parameters | ||||||
|  |         if (project == null) { | ||||||
|  |             throw new InvalidParameterValueException("Unable to find project by id " + projectId); | ||||||
|  |         }  | ||||||
|  |          | ||||||
|  |         return _projectService.getProjectOwner(projectId).getId();  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -26,6 +26,7 @@ import com.cloud.api.Implementation; | |||||||
| import com.cloud.api.Parameter; | import com.cloud.api.Parameter; | ||||||
| import com.cloud.api.ServerApiException; | import com.cloud.api.ServerApiException; | ||||||
| import com.cloud.api.response.ProjectResponse; | import com.cloud.api.response.ProjectResponse; | ||||||
|  | import com.cloud.exception.InvalidParameterValueException; | ||||||
| import com.cloud.exception.ResourceAllocationException; | import com.cloud.exception.ResourceAllocationException; | ||||||
| import com.cloud.projects.Project; | import com.cloud.projects.Project; | ||||||
| import com.cloud.user.Account; | import com.cloud.user.Account; | ||||||
| @ -80,8 +81,17 @@ public class CreateProjectCmd extends BaseCmd { | |||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     public long getEntityOwnerId() { |     public long getEntityOwnerId() { | ||||||
|         //TODO - return project entity ownerId |         Account caller = UserContext.current().getCaller(); | ||||||
|         return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked |          | ||||||
|  |         if ((accountName != null && domainId == null) || (domainId != null && accountName == null)) { | ||||||
|  |             throw new InvalidParameterValueException("Account name and domain id must be specified together"); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         if (accountName != null) { | ||||||
|  |             return _accountService.finalizeOwner(caller, accountName, domainId).getId(); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         return caller.getId(); | ||||||
|     } |     } | ||||||
|   |   | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -26,7 +26,9 @@ import com.cloud.api.Implementation; | |||||||
| import com.cloud.api.Parameter; | import com.cloud.api.Parameter; | ||||||
| import com.cloud.api.ServerApiException; | import com.cloud.api.ServerApiException; | ||||||
| import com.cloud.api.response.SuccessResponse; | import com.cloud.api.response.SuccessResponse; | ||||||
| import com.cloud.user.Account; | import com.cloud.exception.InvalidParameterValueException; | ||||||
|  | import com.cloud.projects.Project; | ||||||
|  | import com.cloud.user.UserContext; | ||||||
| 
 | 
 | ||||||
| @Implementation(description="Deletes account from the project", responseObject=SuccessResponse.class) | @Implementation(description="Deletes account from the project", responseObject=SuccessResponse.class) | ||||||
| public class DeleteAccountFromProjectCmd extends BaseCmd { | public class DeleteAccountFromProjectCmd extends BaseCmd { | ||||||
| @ -69,6 +71,7 @@ public class DeleteAccountFromProjectCmd extends BaseCmd { | |||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public void execute(){ |     public void execute(){ | ||||||
|  |         UserContext.current().setEventDetails("Project id: "+ projectId + "; accountName " + accountName); | ||||||
|         boolean result = _projectService.deleteAccountFromProject(projectId, accountName); |         boolean result = _projectService.deleteAccountFromProject(projectId, accountName); | ||||||
|         if (result) { |         if (result) { | ||||||
|             SuccessResponse response = new SuccessResponse(getCommandName()); |             SuccessResponse response = new SuccessResponse(getCommandName()); | ||||||
| @ -81,7 +84,12 @@ public class DeleteAccountFromProjectCmd extends BaseCmd { | |||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     public long getEntityOwnerId() { |     public long getEntityOwnerId() { | ||||||
|         //TODO - return project entity ownerId |         Project project= _projectService.getProject(projectId); | ||||||
|         return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked |         //verify input parameters | ||||||
|  |         if (project == null) { | ||||||
|  |             throw new InvalidParameterValueException("Unable to find project by id " + projectId); | ||||||
|  |         }  | ||||||
|  |          | ||||||
|  |         return _projectService.getProjectOwner(projectId).getId();  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -28,7 +28,8 @@ import com.cloud.api.Parameter; | |||||||
| import com.cloud.api.ServerApiException; | import com.cloud.api.ServerApiException; | ||||||
| import com.cloud.api.response.SuccessResponse; | import com.cloud.api.response.SuccessResponse; | ||||||
| import com.cloud.event.EventTypes; | import com.cloud.event.EventTypes; | ||||||
| import com.cloud.user.Account; | import com.cloud.exception.InvalidParameterValueException; | ||||||
|  | import com.cloud.projects.Project; | ||||||
| import com.cloud.user.UserContext; | import com.cloud.user.UserContext; | ||||||
| 
 | 
 | ||||||
| @Implementation(description="Deletes a project", responseObject=SuccessResponse.class) | @Implementation(description="Deletes a project", responseObject=SuccessResponse.class) | ||||||
| @ -86,7 +87,13 @@ public class DeleteProjectCmd extends BaseAsyncCmd { | |||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     public long getEntityOwnerId() { |     public long getEntityOwnerId() { | ||||||
|         //TODO - return project entity ownerId |         Project project= _projectService.getProject(id); | ||||||
|         return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked |         //verify input parameters | ||||||
|  |         if (project == null) { | ||||||
|  |             throw new InvalidParameterValueException("Unable to find project by id " + id); | ||||||
|         }  |         }  | ||||||
|  |          | ||||||
|  |         return _projectService.getProjectOwner(id).getId();  | ||||||
|  |     } | ||||||
|  |      | ||||||
| } | } | ||||||
| @ -26,6 +26,7 @@ import com.cloud.api.Parameter; | |||||||
| import com.cloud.api.ServerApiException; | import com.cloud.api.ServerApiException; | ||||||
| import com.cloud.api.response.SuccessResponse; | import com.cloud.api.response.SuccessResponse; | ||||||
| import com.cloud.user.Account; | import com.cloud.user.Account; | ||||||
|  | import com.cloud.user.UserContext; | ||||||
| 
 | 
 | ||||||
| @Implementation(description="Makes account to join the project", responseObject=SuccessResponse.class) | @Implementation(description="Makes account to join the project", responseObject=SuccessResponse.class) | ||||||
| public class JoinProjectCmd extends BaseCmd { | public class JoinProjectCmd extends BaseCmd { | ||||||
| @ -71,6 +72,7 @@ public class JoinProjectCmd extends BaseCmd { | |||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public void execute(){ |     public void execute(){ | ||||||
|  |         UserContext.current().setEventDetails("Project id: "+ projectId + "; accountName " + accountName); | ||||||
|         boolean result = _projectService.joinProject(projectId, accountName); |         boolean result = _projectService.joinProject(projectId, accountName); | ||||||
|         if (result) { |         if (result) { | ||||||
|             SuccessResponse response = new SuccessResponse(getCommandName()); |             SuccessResponse response = new SuccessResponse(getCommandName()); | ||||||
|  | |||||||
| @ -26,8 +26,8 @@ import com.cloud.api.Implementation; | |||||||
| import com.cloud.api.Parameter; | import com.cloud.api.Parameter; | ||||||
| import com.cloud.api.ServerApiException; | import com.cloud.api.ServerApiException; | ||||||
| import com.cloud.api.response.ProjectResponse; | import com.cloud.api.response.ProjectResponse; | ||||||
|  | import com.cloud.exception.InvalidParameterValueException; | ||||||
| import com.cloud.projects.Project; | import com.cloud.projects.Project; | ||||||
| import com.cloud.user.Account; |  | ||||||
| import com.cloud.user.UserContext; | import com.cloud.user.UserContext; | ||||||
| 
 | 
 | ||||||
| @Implementation(description="Updates a project", responseObject=ProjectResponse.class) | @Implementation(description="Updates a project", responseObject=ProjectResponse.class) | ||||||
| @ -72,9 +72,13 @@ public class UpdateProjectCmd extends BaseCmd { | |||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     public long getEntityOwnerId() { |     public long getEntityOwnerId() { | ||||||
|        //TODO - return project entity ownerId |         Project project= _projectService.getProject(id); | ||||||
|  |         //verify input parameters | ||||||
|  |         if (project == null) { | ||||||
|  |             throw new InvalidParameterValueException("Unable to find project by id " + id); | ||||||
|  |         }  | ||||||
|          |          | ||||||
|         return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked |         return _projectService.getProjectOwner(id).getId();  | ||||||
|     } |     } | ||||||
|   |   | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -205,6 +205,8 @@ public class EventTypes { | |||||||
| 	 | 	 | ||||||
| 	//Projects | 	//Projects | ||||||
| 	public static final String EVENT_PROJECT_CREATE = "PROJECT.CREATE"; | 	public static final String EVENT_PROJECT_CREATE = "PROJECT.CREATE"; | ||||||
|  | 	public static final String EVENT_PROJECT_UPDATE = "PROJECT.UPDATE"; | ||||||
| 	public static final String EVENT_PROJECT_DELETE = "PROJECT.DELETE"; | 	public static final String EVENT_PROJECT_DELETE = "PROJECT.DELETE"; | ||||||
| 	 | 	public static final String EVENT_PROJECT_ACCOUNT_ADD = "PROJECT.ACCOUNT.ADD"; | ||||||
|  | 	public static final String EVENT_PROJECT_ACCOUNT_REMOVE = "PROJECT.ACCOUNT.REMOVE"; | ||||||
| } | } | ||||||
|  | |||||||
| @ -648,4 +648,8 @@ public class ApiDBUtils { | |||||||
|     public static Project findProjectById(long projectId) { |     public static Project findProjectById(long projectId) { | ||||||
|         return _projectMgr.getProject(projectId); |         return _projectMgr.getProject(projectId); | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  |     public static long getProjectOwnwerId(long projectId) { | ||||||
|  |         return _projectMgr.getProjectOwner(projectId).getId(); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -138,8 +138,6 @@ public class ProjectManagerImpl implements ProjectManager, Manager{ | |||||||
|             throw new InvalidParameterValueException("Project with name " + name + " already exists in domain id=" + owner.getDomainId()); |             throw new InvalidParameterValueException("Project with name " + name + " already exists in domain id=" + owner.getDomainId()); | ||||||
|         } |         } | ||||||
|          |          | ||||||
|         Domain ownerDomain = _domainDao.findById(owner.getDomainId()); |  | ||||||
|          |  | ||||||
|         //do resource limit check |         //do resource limit check | ||||||
|         _resourceLimitMgr.checkResourceLimit(owner, ResourceType.project); |         _resourceLimitMgr.checkResourceLimit(owner, ResourceType.project); | ||||||
|          |          | ||||||
| @ -227,7 +225,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{ | |||||||
|          |          | ||||||
|         //Delete project's domain |         //Delete project's domain | ||||||
|         s_logger.debug("Deleting projects " + project + " internal domain id=" + project.getProjectDomainId() + " as a part of project cleanup..."); |         s_logger.debug("Deleting projects " + project + " internal domain id=" + project.getProjectDomainId() + " as a part of project cleanup..."); | ||||||
|         result = result && _domainMgr.deleteDomain(project.getProjectDomainId(), true); |         result = result && _domainMgr.deleteDomain(_domainDao.findById(project.getProjectDomainId()), true); | ||||||
|          |          | ||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
| @ -335,6 +333,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{ | |||||||
|     } |     } | ||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|  |     @ActionEvent(eventType = EventTypes.EVENT_PROJECT_ACCOUNT_ADD, eventDescription = "adding account to project") | ||||||
|     public ProjectAccount assignAccountToProject(Project project, long accountId, ProjectAccount.Role accountRole) { |     public ProjectAccount assignAccountToProject(Project project, long accountId, ProjectAccount.Role accountRole) { | ||||||
|         return _projectAccountDao.persist(new ProjectAccountVO(project, accountId, accountRole)); |         return _projectAccountDao.persist(new ProjectAccountVO(project, accountId, accountRole)); | ||||||
|     } |     } | ||||||
| @ -386,6 +385,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{ | |||||||
|     } |     } | ||||||
|      |      | ||||||
|     @Override @DB |     @Override @DB | ||||||
|  |     @ActionEvent(eventType = EventTypes.EVENT_PROJECT_UPDATE, eventDescription = "updating project") | ||||||
|     public Project updateProject(long projectId, String displayText, String newOwnerName) { |     public Project updateProject(long projectId, String displayText, String newOwnerName) { | ||||||
|         Account caller = UserContext.current().getCaller(); |         Account caller = UserContext.current().getCaller(); | ||||||
|          |          | ||||||
| @ -486,6 +486,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{ | |||||||
|     } |     } | ||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|  |     @ActionEvent(eventType = EventTypes.EVENT_PROJECT_ACCOUNT_REMOVE, eventDescription = "removing account from project") | ||||||
|     public boolean deleteAccountFromProject(long projectId, String accountName) { |     public boolean deleteAccountFromProject(long projectId, String accountName) { | ||||||
|         Account caller = UserContext.current().getCaller(); |         Account caller = UserContext.current().getCaller(); | ||||||
|          |          | ||||||
|  | |||||||
| @ -595,6 +595,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag | |||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     @DB |     @DB | ||||||
|  |     @ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_CREATE, eventDescription = "creating Account") | ||||||
|     public UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain) { |     public UserAccount createUserAccount(String userName, String password, String firstName, String lastName, String email, String timezone, String accountName, short accountType, Long domainId, String networkDomain) { | ||||||
|          |          | ||||||
|         if (accountName == null) { |         if (accountName == null) { | ||||||
| @ -1277,7 +1278,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag | |||||||
| 	} | 	} | ||||||
|      |      | ||||||
|     @Override @DB |     @Override @DB | ||||||
|     @ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_CREATE, eventDescription = "creating Account") |  | ||||||
|     public Account createAccount(String accountName, short accountType, Long domainId, String networkDomain) { |     public Account createAccount(String accountName, short accountType, Long domainId, String networkDomain) { | ||||||
|         //Validate domain |         //Validate domain | ||||||
|         Domain domain = _domainMgr.getDomain(domainId); |         Domain domain = _domainMgr.getDomain(domainId); | ||||||
|  | |||||||
| @ -21,12 +21,13 @@ import java.util.List; | |||||||
| import java.util.Set; | import java.util.Set; | ||||||
| 
 | 
 | ||||||
| import com.cloud.domain.Domain; | import com.cloud.domain.Domain; | ||||||
|  | import com.cloud.domain.Domain.Type; | ||||||
| import com.cloud.domain.DomainVO; | import com.cloud.domain.DomainVO; | ||||||
| 
 | 
 | ||||||
| public interface DomainManager extends DomainService{ | public interface DomainManager extends DomainService{ | ||||||
|     Set<Long> getDomainChildrenIds(String parentDomainPath); |     Set<Long> getDomainChildrenIds(String parentDomainPath); | ||||||
| 
 | 
 | ||||||
|     Domain createDomain(String name, Long parentId, Long ownerId, String networkDomain, Domain.Type domainType); |     Domain createDomain(String name, Long parentId, Long ownerId, String networkDomain, Type domainType); | ||||||
|      |      | ||||||
|     /** |     /** | ||||||
|      * find the domain by its path |      * find the domain by its path | ||||||
| @ -42,4 +43,7 @@ public interface DomainManager extends DomainService{ | |||||||
|     boolean removeDomain(long domainId); |     boolean removeDomain(long domainId); | ||||||
|      |      | ||||||
|     List<? extends Domain> findInactiveDomains(); |     List<? extends Domain> findInactiveDomains(); | ||||||
|  | 
 | ||||||
|  |     boolean deleteDomain(DomainVO domain, Boolean cleanup); | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | |||||||
| @ -31,6 +31,7 @@ import org.apache.log4j.Logger; | |||||||
| import com.cloud.configuration.ResourceLimit; | import com.cloud.configuration.ResourceLimit; | ||||||
| import com.cloud.configuration.dao.ResourceCountDao; | import com.cloud.configuration.dao.ResourceCountDao; | ||||||
| import com.cloud.domain.Domain; | import com.cloud.domain.Domain; | ||||||
|  | import com.cloud.domain.Domain.Type; | ||||||
| import com.cloud.domain.DomainVO; | import com.cloud.domain.DomainVO; | ||||||
| import com.cloud.domain.dao.DomainDao; | import com.cloud.domain.dao.DomainDao; | ||||||
| import com.cloud.event.ActionEvent; | import com.cloud.event.ActionEvent; | ||||||
| @ -118,7 +119,7 @@ public class DomainManagerImpl implements DomainManager, DomainService, Manager{ | |||||||
|     } |     } | ||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     @DB |     @ActionEvent(eventType = EventTypes.EVENT_DOMAIN_CREATE, eventDescription = "creating Domain") | ||||||
|     public Domain createDomain(String name, Long parentId, String networkDomain) { |     public Domain createDomain(String name, Long parentId, String networkDomain) { | ||||||
|         Account caller = UserContext.current().getCaller(); |         Account caller = UserContext.current().getCaller(); | ||||||
| 
 | 
 | ||||||
| @ -143,9 +144,8 @@ public class DomainManagerImpl implements DomainManager, DomainService, Manager{ | |||||||
|     } |     } | ||||||
|      |      | ||||||
|     @Override |     @Override | ||||||
|     @ActionEvent(eventType = EventTypes.EVENT_DOMAIN_CREATE, eventDescription = "creating Domain") |  | ||||||
|     @DB |     @DB | ||||||
|     public Domain createDomain(String name, Long parentId, Long ownerId, String networkDomain, Domain.Type domainType) { |     public Domain createDomain(String name, Long parentId, Long ownerId, String networkDomain, Type domainType) { | ||||||
|         //Verify network domain |         //Verify network domain | ||||||
|         if (networkDomain != null) { |         if (networkDomain != null) { | ||||||
|             if (!NetUtils.verifyDomainName(networkDomain)) { |             if (!NetUtils.verifyDomainName(networkDomain)) { | ||||||
| @ -155,6 +155,7 @@ public class DomainManagerImpl implements DomainManager, DomainService, Manager{ | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|       |       | ||||||
|  |          | ||||||
|         //verify domainType |         //verify domainType | ||||||
|         if (domainType != null && !(domainType == Domain.Type.Project || domainType == Domain.Type.Normal)) { |         if (domainType != null && !(domainType == Domain.Type.Project || domainType == Domain.Type.Normal)) { | ||||||
|             throw new InvalidParameterValueException("Invalid domain type; following values are supported: " + Domain.Type.Normal + ", " + Domain.Type.Project); |             throw new InvalidParameterValueException("Invalid domain type; following values are supported: " + Domain.Type.Normal + ", " + Domain.Type.Project); | ||||||
| @ -180,6 +181,7 @@ public class DomainManagerImpl implements DomainManager, DomainService, Manager{ | |||||||
|         return domain; |         return domain; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |      | ||||||
|     @Override |     @Override | ||||||
|     public DomainVO findDomainByPath(String domainPath) { |     public DomainVO findDomainByPath(String domainPath) { | ||||||
|         return _domainDao.findDomainByPath(domainPath); |         return _domainDao.findDomainByPath(domainPath); | ||||||
| @ -215,23 +217,28 @@ public class DomainManagerImpl implements DomainManager, DomainService, Manager{ | |||||||
|          |          | ||||||
|         _accountMgr.checkAccess(caller, domain, null); |         _accountMgr.checkAccess(caller, domain, null); | ||||||
|          |          | ||||||
|  |        return deleteDomain(domain, cleanup); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     @Override | ||||||
|  |     public boolean deleteDomain(DomainVO domain, Boolean cleanup) { | ||||||
|         //mark domain as inactive |         //mark domain as inactive | ||||||
|         s_logger.debug("Marking domain id=" + domainId + " as " + Domain.State.Inactive + " before actually deleting it"); |         s_logger.debug("Marking domain id=" + domain.getId() + " as " + Domain.State.Inactive + " before actually deleting it"); | ||||||
|         domain.setState(Domain.State.Inactive); |         domain.setState(Domain.State.Inactive); | ||||||
|         _domainDao.update(domainId, domain); |         _domainDao.update(domain.getId(), domain); | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|             long ownerId = domain.getAccountId(); |             long ownerId = domain.getAccountId(); | ||||||
|             if ((cleanup != null) && cleanup.booleanValue()) { |             if ((cleanup != null) && cleanup.booleanValue()) { | ||||||
|                 if (!cleanupDomain(domainId, ownerId)) { |                 if (!cleanupDomain(domain.getId(), ownerId)) { | ||||||
|                     s_logger.error("Failed to clean up domain resources and sub domains, delete failed on domain " + domain.getName() + " (id: " + domainId + ")."); |                     s_logger.error("Failed to clean up domain resources and sub domains, delete failed on domain " + domain.getName() + " (id: " + domain.getId() + ")."); | ||||||
|                     return false; |                     return false; | ||||||
|                 } |                 } | ||||||
|             } else {  |             } else {  | ||||||
|                 List<AccountVO> accountsForCleanup = _accountDao.findCleanupsForRemovedAccounts(domainId); |                 List<AccountVO> accountsForCleanup = _accountDao.findCleanupsForRemovedAccounts(domain.getId()); | ||||||
|                 if (accountsForCleanup.isEmpty()) { |                 if (accountsForCleanup.isEmpty()) { | ||||||
|                     if (!_domainDao.remove(domainId)) { |                     if (!_domainDao.remove(domain.getId())) { | ||||||
|                         s_logger.error("Delete failed on domain " + domain.getName() + " (id: " + domainId |                         s_logger.error("Delete failed on domain " + domain.getName() + " (id: " + domain.getId() | ||||||
|                                 + "); please make sure all users and sub domains have been removed from the domain before deleting"); |                                 + "); please make sure all users and sub domains have been removed from the domain before deleting"); | ||||||
|                         return false; |                         return false; | ||||||
|                     }  |                     }  | ||||||
| @ -241,10 +248,10 @@ public class DomainManagerImpl implements DomainManager, DomainService, Manager{ | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|              |              | ||||||
|             cleanupDomainOfferings(domainId); |             cleanupDomainOfferings(domain.getId()); | ||||||
|             return true; |             return true; | ||||||
|         } catch (Exception ex) { |         } catch (Exception ex) { | ||||||
|             s_logger.error("Exception deleting domain with id " + domainId, ex); |             s_logger.error("Exception deleting domain with id " + domain.getId(), ex); | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user