You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mc...@apache.org on 2012/12/14 19:48:30 UTC
[6/7] Move view based VO and Dao classes to cloud-server module to
hide the details from API client,
also extract query related methods into QueryService interface.
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/event/dao/EventJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/event/dao/EventJoinDao.java b/server/src/com/cloud/event/dao/EventJoinDao.java
index d67653d..cd37d78 100644
--- a/server/src/com/cloud/event/dao/EventJoinDao.java
+++ b/server/src/com/cloud/event/dao/EventJoinDao.java
@@ -19,7 +19,8 @@ package com.cloud.event.dao;
import java.util.List;
import org.apache.cloudstack.api.response.EventResponse;
-import org.apache.cloudstack.api.view.vo.EventJoinVO;
+
+import com.cloud.api.query.vo.EventJoinVO;
import com.cloud.event.Event;
import com.cloud.utils.db.Filter;
import com.cloud.utils.db.GenericDao;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/event/dao/EventJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/event/dao/EventJoinDaoImpl.java b/server/src/com/cloud/event/dao/EventJoinDaoImpl.java
index be2a6dc..764df99 100644
--- a/server/src/com/cloud/event/dao/EventJoinDaoImpl.java
+++ b/server/src/com/cloud/event/dao/EventJoinDaoImpl.java
@@ -24,8 +24,9 @@ import javax.ejb.Local;
import org.apache.log4j.Logger;
import com.cloud.api.ApiResponseHelper;
+import com.cloud.api.query.vo.EventJoinVO;
+
import org.apache.cloudstack.api.response.EventResponse;
-import org.apache.cloudstack.api.view.vo.EventJoinVO;
import com.cloud.event.Event;
import com.cloud.event.Event.State;
import com.cloud.utils.db.Filter;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java b/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
index a9d1f0b..8e45899 100755
--- a/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
+++ b/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
@@ -45,8 +45,10 @@ import com.cloud.agent.api.NetworkRulesSystemVmCommand;
import com.cloud.agent.api.SecurityGroupRulesCmd;
import com.cloud.agent.api.SecurityGroupRulesCmd.IpPortAndProto;
import com.cloud.agent.manager.Commands;
+import com.cloud.api.query.dao.SecurityGroupJoinDao;
+import com.cloud.api.query.vo.SecurityGroupJoinVO;
+
import org.apache.cloudstack.api.command.user.securitygroup.RevokeSecurityGroupEgressCmd;
-import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
import com.cloud.configuration.Config;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.domain.dao.DomainDao;
@@ -65,7 +67,6 @@ import com.cloud.network.NetworkManager;
import com.cloud.network.security.SecurityGroupWork.Step;
import com.cloud.network.security.SecurityRule.SecurityRuleType;
import com.cloud.network.security.dao.SecurityGroupDao;
-import com.cloud.network.security.dao.SecurityGroupJoinDao;
import com.cloud.network.security.dao.SecurityGroupRuleDao;
import com.cloud.network.security.dao.SecurityGroupRulesDao;
import com.cloud.network.security.dao.SecurityGroupVMMapDao;
@@ -158,7 +159,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
UsageEventDao _usageEventDao;
@Inject
ResourceTagDao _resourceTagDao;
-
+
ScheduledExecutorService _executorPool;
ScheduledExecutorService _cleanupExecutor;
@@ -396,7 +397,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
if (s_logger.isTraceEnabled()) {
s_logger.trace("Security Group Mgr: scheduling ruleset updates for " + affectedVms.size() + " vms");
}
- boolean locked = _workLock.lock(_globalWorkLockTimeout);
+ boolean locked = _workLock.lock(_globalWorkLockTimeout);
if (!locked) {
s_logger.warn("Security Group Mgr: failed to acquire global work lock");
return;
@@ -575,11 +576,11 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
Map groupList = cmd.getUserSecurityGroupList();
return authorizeSecurityGroupRule(securityGroupId,protocol,startPort,endPort,icmpType,icmpCode,cidrList,groupList,SecurityRuleType.IngressRule);
}
-
+
private List<SecurityGroupRuleVO> authorizeSecurityGroupRule(Long securityGroupId,String protocol,Integer startPort,Integer endPort,Integer icmpType,Integer icmpCode,List<String> cidrList,Map groupList,SecurityRuleType ruleType) {
Integer startPortOrType = null;
Integer endPortOrCode = null;
-
+
// Validate parameters
SecurityGroup securityGroup = _securityGroupDao.findById(securityGroupId);
if (securityGroup == null) {
@@ -747,7 +748,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
}
}
}
-
+
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_SECURITY_GROUP_REVOKE_EGRESS, eventDescription = "Revoking Egress Rule ", async = true)
@@ -755,7 +756,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
Long id = cmd.getId();
return revokeSecurityGroupRule(id, SecurityRuleType.EgressRule);
}
-
+
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_SECURITY_GROUP_REVOKE_INGRESS, eventDescription = "Revoking Ingress Rule ", async = true)
@@ -764,11 +765,11 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
Long id = cmd.getId();
return revokeSecurityGroupRule(id, SecurityRuleType.IngressRule);
}
-
+
private boolean revokeSecurityGroupRule(Long id, SecurityRuleType type) {
// input validation
Account caller = UserContext.current().getCaller();
-
+
SecurityGroupRuleVO rule = _securityGroupRuleDao.findById(id);
if (rule == null) {
s_logger.debug("Unable to find security rule with id " + id);
@@ -780,7 +781,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
s_logger.debug("Mismatch in rule type for security rule with id " + id );
throw new InvalidParameterValueException("Mismatch in rule type for security rule with id " + id);
}
-
+
// Check permissions
SecurityGroup securityGroup = _securityGroupDao.findById(rule.getSecurityGroupId());
_accountMgr.checkAccess(caller, null, true, securityGroup);
@@ -861,13 +862,13 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
_serverId = ((ManagementServer) ComponentLocator.getComponent(ManagementServer.Name)).getId();
- s_logger.info("SecurityGroupManager: num worker threads=" + _numWorkerThreads +
+ s_logger.info("SecurityGroupManager: num worker threads=" + _numWorkerThreads +
", time between cleanups=" + _timeBetweenCleanups + " global lock timeout=" + _globalWorkLockTimeout);
createThreadPools();
return true;
}
-
+
protected void createThreadPools() {
_executorPool = Executors.newScheduledThreadPool(_numWorkerThreads, new NamedThreadFactory("NWGRP"));
_cleanupExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("NWGRP-Cleanup"));
@@ -964,7 +965,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
s_logger.debug("Unable to send ingress rules updates for vm: " + userVmId + "(agentid=" + agentId + ")");
_workDao.updateStep(work.getInstanceId(), seqnum, Step.Done);
}
-
+
}
}
} finally {
@@ -1088,91 +1089,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
return true;
}
- @Override
- public Pair<List<SecurityGroupJoinVO>, Integer> searchForSecurityGroupRules(ListSecurityGroupsCmd cmd) throws PermissionDeniedException, InvalidParameterValueException {
- Account caller = UserContext.current().getCaller();
- Long instanceId = cmd.getVirtualMachineId();
- String securityGroup = cmd.getSecurityGroupName();
- Long id = cmd.getId();
- Object keyword = cmd.getKeyword();
- List<Long> permittedAccounts = new ArrayList<Long>();
- Map<String, String> tags = cmd.getTags();
-
- if (instanceId != null) {
- UserVmVO userVM = _userVMDao.findById(instanceId);
- if (userVM == null) {
- throw new InvalidParameterValueException("Unable to list network groups for virtual machine instance " + instanceId + "; instance not found.");
- }
- _accountMgr.checkAccess(caller, null, true, userVM);
- return listSecurityGroupRulesByVM(instanceId.longValue(), cmd.getStartIndex(), cmd.getPageSizeVal());
- }
-
- Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
- _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false);
- Long domainId = domainIdRecursiveListProject.first();
- Boolean isRecursive = domainIdRecursiveListProject.second();
- ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
-
- Filter searchFilter = new Filter(SecurityGroupJoinVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
- SearchBuilder<SecurityGroupJoinVO> sb = _securityGroupJoinDao.createSearchBuilder();
- sb.select(null, Func.DISTINCT, sb.entity().getId()); // select distinct ids
- _accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
-
- sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
- sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ);
-
- if (tags != null && !tags.isEmpty()) {
- for (int count=0; count < tags.size(); count++) {
- sb.or().op("key" + String.valueOf(count), sb.entity().getTagKey(), SearchCriteria.Op.EQ);
- sb.and("value" + String.valueOf(count), sb.entity().getTagValue(), SearchCriteria.Op.EQ);
- sb.cp();
- }
- }
- SearchCriteria<SecurityGroupJoinVO> sc = sb.create();
- _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
-
- if (id != null) {
- sc.setParameters("id", id);
- }
-
- if (tags != null && !tags.isEmpty()) {
- int count = 0;
- for (String key : tags.keySet()) {
- sc.setParameters("key" + String.valueOf(count), key);
- sc.setParameters("value" + String.valueOf(count), tags.get(key));
- count++;
- }
- }
-
- if (securityGroup != null) {
- sc.setParameters("name", securityGroup);
- }
-
- if (keyword != null) {
- SearchCriteria<SecurityGroupJoinVO> ssc = _securityGroupJoinDao.createSearchCriteria();
- ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- sc.addAnd("name", SearchCriteria.Op.SC, ssc);
- }
-
- // search security group together with rules
- Pair<List<SecurityGroupJoinVO>, Integer> uniqueSgPair = _securityGroupJoinDao.searchAndCount(sc, searchFilter);
- Integer count = uniqueSgPair.second();
- if ( count.intValue() == 0 ){
- // handle empty result cases
- return uniqueSgPair;
- }
-
- List<SecurityGroupJoinVO> uniqueSgs = uniqueSgPair.first();
- Long[] sgIds = new Long[uniqueSgs.size()];
- int i = 0;
- for (SecurityGroupJoinVO v : uniqueSgs ){
- sgIds[i++] = v.getId();
- }
- List<SecurityGroupJoinVO> sgs = _securityGroupJoinDao.searchByIds(sgIds);
- return new Pair<List<SecurityGroupJoinVO>, Integer>(sgs, count);
- }
private Pair<List<SecurityGroupJoinVO>, Integer> listSecurityGroupRulesByVM(long vmId, long pageInd, long pageSize) {
Filter sf = new Filter(SecurityGroupVMMapVO.class, null, true, pageInd, pageSize);
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/network/security/dao/SecurityGroupJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupJoinDao.java b/server/src/com/cloud/network/security/dao/SecurityGroupJoinDao.java
deleted file mode 100644
index 30c0897..0000000
--- a/server/src/com/cloud/network/security/dao/SecurityGroupJoinDao.java
+++ /dev/null
@@ -1,37 +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 com.cloud.network.security.dao;
-
-import java.util.List;
-
-import org.apache.cloudstack.api.response.SecurityGroupResponse;
-import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
-import com.cloud.network.security.SecurityGroup;
-import com.cloud.user.Account;
-import com.cloud.utils.db.GenericDao;
-
-public interface SecurityGroupJoinDao extends GenericDao<SecurityGroupJoinVO, Long> {
-
- SecurityGroupResponse newSecurityGroupResponse(SecurityGroupJoinVO vsg, Account caller);
-
- SecurityGroupResponse setSecurityGroupResponse(SecurityGroupResponse vsgData, SecurityGroupJoinVO vsg);
-
- List<SecurityGroupJoinVO> newSecurityGroupView(SecurityGroup sg);
-
- List<SecurityGroupJoinVO> searchByIds(Long... ids);
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/network/security/dao/SecurityGroupJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/dao/SecurityGroupJoinDaoImpl.java b/server/src/com/cloud/network/security/dao/SecurityGroupJoinDaoImpl.java
deleted file mode 100644
index 6ecb258..0000000
--- a/server/src/com/cloud/network/security/dao/SecurityGroupJoinDaoImpl.java
+++ /dev/null
@@ -1,177 +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 com.cloud.network.security.dao;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiDBUtils;
-import com.cloud.api.ApiResponseHelper;
-import org.apache.cloudstack.api.response.SecurityGroupResponse;
-import org.apache.cloudstack.api.response.SecurityGroupRuleResponse;
-import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
-import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
-import com.cloud.network.security.SecurityGroup;
-import com.cloud.network.security.SecurityRule.SecurityRuleType;
-import com.cloud.user.Account;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-
-@Local(value={SecurityGroupJoinDao.class})
-public class SecurityGroupJoinDaoImpl extends GenericDaoBase<SecurityGroupJoinVO, Long> implements SecurityGroupJoinDao {
- public static final Logger s_logger = Logger.getLogger(SecurityGroupJoinDaoImpl.class);
-
- private SearchBuilder<SecurityGroupJoinVO> sgSearch;
-
- private SearchBuilder<SecurityGroupJoinVO> sgIdSearch;
-
- protected SecurityGroupJoinDaoImpl() {
-
- sgSearch = createSearchBuilder();
- sgSearch.and("idIN", sgSearch.entity().getId(), SearchCriteria.Op.IN);
- sgSearch.done();
-
- sgIdSearch = createSearchBuilder();
- sgIdSearch.and("id", sgIdSearch.entity().getId(), SearchCriteria.Op.EQ);
- sgIdSearch.done();
-
- this._count = "select count(distinct id) from security_group_view WHERE ";
- }
-
- @Override
- public SecurityGroupResponse newSecurityGroupResponse(SecurityGroupJoinVO vsg, Account caller) {
- SecurityGroupResponse sgResponse = new SecurityGroupResponse();
- sgResponse.setId(vsg.getUuid());
- sgResponse.setName(vsg.getName());
- sgResponse.setDescription(vsg.getDescription());
-
- ApiResponseHelper.populateOwner(sgResponse, vsg);
-
- Long rule_id = vsg.getRuleId();
- if (rule_id != null && rule_id.longValue() > 0) {
- SecurityGroupRuleResponse ruleData = new SecurityGroupRuleResponse();
- ruleData.setRuleId(vsg.getRuleUuid());
- ruleData.setProtocol(vsg.getRuleProtocol());
-
- if ("icmp".equalsIgnoreCase(vsg.getRuleProtocol())) {
- ruleData.setIcmpType(vsg.getRuleStartPort());
- ruleData.setIcmpCode(vsg.getRuleEndPort());
- } else {
- ruleData.setStartPort(vsg.getRuleStartPort());
- ruleData.setEndPort(vsg.getRuleEndPort());
- }
-
- if (vsg.getRuleAllowedNetworkId() != null) {
- List<SecurityGroupJoinVO> sgs = this.searchByIds(vsg.getRuleAllowedNetworkId());
- if (sgs != null && sgs.size() > 0) {
- SecurityGroupJoinVO sg = sgs.get(0);
- ruleData.setSecurityGroupName(sg.getName());
- ruleData.setAccountName(sg.getAccountName());
- }
- } else {
- ruleData.setCidr(vsg.getRuleAllowedSourceIpCidr());
- }
-
- if (vsg.getRuleType() == SecurityRuleType.IngressRule) {
- ruleData.setObjectName("ingressrule");
- sgResponse.addSecurityGroupIngressRule(ruleData);
- } else {
- ruleData.setObjectName("egressrule");
- sgResponse.addSecurityGroupEgressRule(ruleData);
- }
- }
-
- // update tag information
- Long tag_id = vsg.getTagId();
- if (tag_id != null && tag_id.longValue() > 0) {
- ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
- if ( vtag != null ){
- sgResponse.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
- }
- }
- sgResponse.setObjectName("securitygroup");
-
- return sgResponse;
- }
-
- @Override
- public SecurityGroupResponse setSecurityGroupResponse(SecurityGroupResponse vsgData, SecurityGroupJoinVO vsg) {
- Long rule_id = vsg.getRuleId();
- if (rule_id != null && rule_id.longValue() > 0) {
- SecurityGroupRuleResponse ruleData = new SecurityGroupRuleResponse();
- ruleData.setRuleId(vsg.getRuleUuid());
- ruleData.setProtocol(vsg.getRuleProtocol());
-
- if ("icmp".equalsIgnoreCase(vsg.getRuleProtocol())) {
- ruleData.setIcmpType(vsg.getRuleStartPort());
- ruleData.setIcmpCode(vsg.getRuleEndPort());
- } else {
- ruleData.setStartPort(vsg.getRuleStartPort());
- ruleData.setEndPort(vsg.getRuleEndPort());
- }
-
- if (vsg.getRuleAllowedNetworkId() != null) {
- List<SecurityGroupJoinVO> sgs = this.searchByIds(vsg.getRuleAllowedNetworkId());
- if (sgs != null && sgs.size() > 0) {
- SecurityGroupJoinVO sg = sgs.get(0);
- ruleData.setSecurityGroupName(sg.getName());
- ruleData.setAccountName(sg.getAccountName());
- }
- } else {
- ruleData.setCidr(vsg.getRuleAllowedSourceIpCidr());
- }
-
- if (vsg.getRuleType() == SecurityRuleType.IngressRule) {
- ruleData.setObjectName("ingressrule");
- vsgData.addSecurityGroupIngressRule(ruleData);
- } else {
- ruleData.setObjectName("egressrule");
- vsgData.addSecurityGroupEgressRule(ruleData);
- }
- }
-
- // update tag information
- Long tag_id = vsg.getTagId();
- if (tag_id != null && tag_id.longValue() > 0 ) {
- ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
- if ( vtag != null ){
- vsgData.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
- }
- }
- return vsgData;
- }
-
- @Override
- public List<SecurityGroupJoinVO> newSecurityGroupView(SecurityGroup sg) {
-
- SearchCriteria<SecurityGroupJoinVO> sc = sgIdSearch.create();
- sc.setParameters("id", sg.getId());
- return searchIncludingRemoved(sc, null, null, false);
- }
-
- @Override
- public List<SecurityGroupJoinVO> searchByIds(Long... ids) {
- SearchCriteria<SecurityGroupJoinVO> sc = sgSearch.create();
- sc.setParameters("idIN", ids);
- return searchIncludingRemoved(sc, null, null, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/projects/ProjectManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/ProjectManager.java b/server/src/com/cloud/projects/ProjectManager.java
index a243d2d..f568146 100644
--- a/server/src/com/cloud/projects/ProjectManager.java
+++ b/server/src/com/cloud/projects/ProjectManager.java
@@ -35,4 +35,6 @@ public interface ProjectManager extends ProjectService {
boolean deleteProject(Account caller, long callerUserId, ProjectVO project);
+ long getInvitationTimeout();
+
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/projects/ProjectManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/ProjectManagerImpl.java b/server/src/com/cloud/projects/ProjectManagerImpl.java
index 7c97af2..4fbbc7d 100755
--- a/server/src/com/cloud/projects/ProjectManagerImpl.java
+++ b/server/src/com/cloud/projects/ProjectManagerImpl.java
@@ -38,13 +38,16 @@ import javax.mail.URLName;
import javax.mail.internet.InternetAddress;
import javax.naming.ConfigurationException;
-import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
-import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
-import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
-import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
import org.apache.log4j.Logger;
import com.cloud.acl.SecurityChecker.AccessType;
+import com.cloud.api.query.dao.ProjectAccountJoinDao;
+import com.cloud.api.query.dao.ProjectInvitationJoinDao;
+import com.cloud.api.query.dao.ProjectJoinDao;
+import com.cloud.api.query.vo.ProjectAccountJoinVO;
+import com.cloud.api.query.vo.ProjectInvitationJoinVO;
+import com.cloud.api.query.vo.ProjectJoinVO;
+import com.cloud.api.query.vo.UserVmJoinVO;
import com.cloud.configuration.Config;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.Resource.ResourceType;
@@ -62,11 +65,8 @@ import com.cloud.projects.Project.ListProjectResourcesCriteria;
import com.cloud.projects.Project.State;
import com.cloud.projects.ProjectAccount.Role;
import com.cloud.projects.dao.ProjectAccountDao;
-import com.cloud.projects.dao.ProjectAccountJoinDao;
import com.cloud.projects.dao.ProjectDao;
import com.cloud.projects.dao.ProjectInvitationDao;
-import com.cloud.projects.dao.ProjectInvitationJoinDao;
-import com.cloud.projects.dao.ProjectJoinDao;
import com.cloud.server.ResourceTag.TaggedResourceType;
import com.cloud.tags.ResourceTagVO;
import com.cloud.tags.dao.ResourceTagDao;
@@ -368,140 +368,13 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
return _projectDao.findById(projectId);
}
- @Override
- public Pair<List<ProjectJoinVO>, Integer> listProjects(Long id, String name, String displayText, String state,
- String accountName, Long domainId, String keyword, Long startIndex, Long pageSize, boolean listAll,
- boolean isRecursive, Map<String, String> tags) {
- Account caller = UserContext.current().getCaller();
- Long accountId = null;
- String path = null;
-
- Filter searchFilter = new Filter(ProjectJoinVO.class, "id", false, startIndex, pageSize);
- SearchBuilder<ProjectJoinVO> sb = _projectJoinDao.createSearchBuilder();
- sb.select(null, Func.DISTINCT, sb.entity().getId()); // select distinct ids
-
- if (_accountMgr.isAdmin(caller.getType())) {
- if (domainId != null) {
- DomainVO domain = _domainDao.findById(domainId);
- if (domain == null) {
- throw new InvalidParameterValueException("Domain id=" + domainId + " doesn't exist in the system");
- }
-
- _accountMgr.checkAccess(caller, domain);
-
- if (accountName != null) {
- Account owner = _accountMgr.getActiveAccountByName(accountName, domainId);
- if (owner == null) {
- throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
- }
- accountId = owner.getId();
- }
- }
- else { //domainId == null
- if (accountName != null) {
- throw new InvalidParameterValueException("could not find account " + accountName + " because domain is not specified");
- }
-
- }
- } else {
- if (accountName != null && !accountName.equals(caller.getAccountName())) {
- throw new PermissionDeniedException("Can't list account " + accountName + " projects; unauthorized");
- }
-
- if (domainId != null && domainId.equals(caller.getDomainId())) {
- throw new PermissionDeniedException("Can't list domain id= " + domainId + " projects; unauthorized");
- }
-
- accountId = caller.getId();
- }
-
- if (domainId == null && accountId == null && (caller.getType() == Account.ACCOUNT_TYPE_NORMAL || !listAll)) {
- accountId = caller.getId();
- } else if (caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN || (isRecursive && !listAll)) {
- DomainVO domain = _domainDao.findById(caller.getDomainId());
- path = domain.getPath();
- }
-
- if (path != null) {
- sb.and("domainPath", sb.entity().getDomainPath(), SearchCriteria.Op.LIKE);
- }
-
- if (accountId != null) {
- sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ);
- }
-
- if (tags != null && !tags.isEmpty()) {
- for (int count=0; count < tags.size(); count++) {
- sb.or().op("key" + String.valueOf(count), sb.entity().getTagKey(), SearchCriteria.Op.EQ);
- sb.and("value" + String.valueOf(count), sb.entity().getTagValue(), SearchCriteria.Op.EQ);
- sb.cp();
- }
- }
-
-
- SearchCriteria<ProjectJoinVO> sc = sb.create();
-
- if (id != null) {
- sc.addAnd("id", Op.EQ, id);
- }
-
- if (domainId != null && !isRecursive) {
- sc.addAnd("domainId", Op.EQ, domainId);
- }
-
- if (name != null) {
- sc.addAnd("name", Op.EQ, name);
- }
-
- if (displayText != null) {
- sc.addAnd("displayText", Op.EQ, displayText);
- }
-
- if (accountId != null) {
- sc.setParameters("accountId", accountId);
- }
-
- if (state != null) {
- sc.addAnd("state", Op.EQ, state);
- }
-
- if (keyword != null) {
- SearchCriteria<ProjectJoinVO> ssc = _projectJoinDao.createSearchCriteria();
- ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("displayText", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- sc.addAnd("name", SearchCriteria.Op.SC, ssc);
- }
-
- if (path != null) {
- sc.setParameters("domainPath", path);
- }
- if (tags != null && !tags.isEmpty()) {
- int count = 0;
- for (String key : tags.keySet()) {
- sc.setParameters("key" + String.valueOf(count), key);
- sc.setParameters("value" + String.valueOf(count), tags.get(key));
- count++;
- }
- }
-
- // search distinct projects to get count
- Pair<List<ProjectJoinVO>, Integer> uniquePrjPair = _projectJoinDao.searchAndCount(sc, searchFilter);
- Integer count = uniquePrjPair.second();
- if ( count.intValue() == 0 ){
- // handle empty result cases
- return uniquePrjPair;
- }
- List<ProjectJoinVO> uniquePrjs = uniquePrjPair.first();
- Long[] prjIds = new Long[uniquePrjs.size()];
- int i = 0;
- for (ProjectJoinVO v : uniquePrjs ){
- prjIds[i++] = v.getId();
- }
- List<ProjectJoinVO> prjs = _projectJoinDao.searchByIds(prjIds);
- return new Pair<List<ProjectJoinVO>, Integer>(prjs, count);
+ @Override
+ public long getInvitationTimeout() {
+ return _invitationTimeOut;
}
+
@Override
public ProjectAccount assignAccountToProject(Project project, long accountId, ProjectAccount.Role accountRole) {
return _projectAccountDao.persist(new ProjectAccountVO(project, accountId, accountRole));
@@ -769,46 +642,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
}
- @Override
- public Pair<List<ProjectAccountJoinVO>, Integer> listProjectAccounts(long projectId, String accountName, String role, Long startIndex, Long pageSizeVal) {
- Account caller = UserContext.current().getCaller();
-
- //check that the project exists
- Project project = getProject(projectId);
-
- if (project == null) {
- throw new InvalidParameterValueException("Unable to find the project id=" + projectId);
- }
-
- //verify permissions - only accounts belonging to the project can list project's account
- if (!_accountMgr.isAdmin(caller.getType()) && _projectAccountDao.findByProjectIdAccountId(projectId, caller.getAccountId()) == null) {
- throw new PermissionDeniedException("Account " + caller + " is not authorized to list users of the project id=" + projectId);
- }
-
- Filter searchFilter = new Filter(ProjectAccountJoinVO.class, "id", false, startIndex, pageSizeVal);
- SearchBuilder<ProjectAccountJoinVO> sb = _projectAccountJoinDao.createSearchBuilder();
- sb.and("accountRole", sb.entity().getAccountRole(), Op.EQ);
- sb.and("projectId", sb.entity().getProjectId(), Op.EQ);
-
- SearchBuilder<AccountVO> accountSearch;
- if (accountName != null) {
- sb.and("accountName", sb.entity().getAccountName(), Op.EQ);
- }
-
- SearchCriteria<ProjectAccountJoinVO> sc = sb.create();
- sc.setParameters("projectId", projectId);
-
- if (role != null) {
- sc.setParameters("accountRole", role);
- }
-
- if (accountName != null) {
- sc.setParameters("accountName", accountName);
- }
-
- return _projectAccountJoinDao.searchAndCount(sc, searchFilter);
- }
public ProjectInvitation createAccountInvitation(Project project, Long accountId) {
if (activeInviteExists(project, accountId, null)) {
@@ -878,52 +712,8 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
return _projectInvitationDao.update(invite.getId(), invite);
}
- @Override
- public Pair<List<ProjectInvitationJoinVO>, Integer> listProjectInvitations(Long id, Long projectId,
- String accountName, Long domainId, String state, boolean activeOnly, Long startIndex, Long pageSizeVal, boolean isRecursive, boolean listAll) {
- Account caller = UserContext.current().getCaller();
- List<Long> permittedAccounts = new ArrayList<Long>();
-
- Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(domainId, isRecursive, null);
- _accountMgr.buildACLSearchParameters(caller, id, accountName, projectId, permittedAccounts, domainIdRecursiveListProject, listAll, true);
- domainId = domainIdRecursiveListProject.first();
- isRecursive = domainIdRecursiveListProject.second();
- ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
-
- Filter searchFilter = new Filter(ProjectInvitationJoinVO.class, "id", true, startIndex, pageSizeVal);
- SearchBuilder<ProjectInvitationJoinVO> sb = _projectInvitationJoinDao.createSearchBuilder();
- _accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
-
- sb.and("projectId", sb.entity().getProjectId(), SearchCriteria.Op.EQ);
- sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
- sb.and("created", sb.entity().getCreated(), SearchCriteria.Op.GT);
- sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
-
- SearchCriteria<ProjectInvitationJoinVO> sc = sb.create();
- _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
- if (projectId != null){
- sc.setParameters("projectId", projectId);
- }
-
- if (state != null) {
- sc.setParameters("state", state);
- }
-
- if (id != null) {
- sc.setParameters("id", id);
- }
-
- if (activeOnly) {
- sc.setParameters("state", ProjectInvitation.State.Pending);
- sc.setParameters("created", new Date((DateUtil.currentGMTTime().getTime()) - _invitationTimeOut));
- }
-
- return _projectInvitationJoinDao.searchAndCount(sc, searchFilter);
-
- }
-
@Override @DB
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_INVITATION_UPDATE, eventDescription = "updating project invitation", async=true)
public boolean updateInvitation(long projectId, String accountName, String token, boolean accept) {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/projects/dao/ProjectAccountJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/dao/ProjectAccountJoinDao.java b/server/src/com/cloud/projects/dao/ProjectAccountJoinDao.java
deleted file mode 100644
index bdee7aa..0000000
--- a/server/src/com/cloud/projects/dao/ProjectAccountJoinDao.java
+++ /dev/null
@@ -1,33 +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 com.cloud.projects.dao;
-
-import java.util.List;
-
-import org.apache.cloudstack.api.response.ProjectAccountResponse;
-import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
-import com.cloud.projects.ProjectAccount;
-import com.cloud.utils.db.GenericDao;
-
-public interface ProjectAccountJoinDao extends GenericDao<ProjectAccountJoinVO, Long> {
-
- ProjectAccountResponse newProjectAccountResponse(ProjectAccountJoinVO proj);
-
- ProjectAccountJoinVO newProjectAccountView(ProjectAccount proj);
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/projects/dao/ProjectAccountJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/dao/ProjectAccountJoinDaoImpl.java b/server/src/com/cloud/projects/dao/ProjectAccountJoinDaoImpl.java
deleted file mode 100644
index afea1cb..0000000
--- a/server/src/com/cloud/projects/dao/ProjectAccountJoinDaoImpl.java
+++ /dev/null
@@ -1,85 +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 com.cloud.projects.dao;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.response.ProjectAccountResponse;
-import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
-import com.cloud.projects.ProjectAccount;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-
-@Local(value={ProjectAccountJoinDao.class})
-public class ProjectAccountJoinDaoImpl extends GenericDaoBase<ProjectAccountJoinVO, Long> implements ProjectAccountJoinDao {
- public static final Logger s_logger = Logger.getLogger(ProjectAccountJoinDaoImpl.class);
-
-
- private SearchBuilder<ProjectAccountJoinVO> vrIdSearch;
-
- protected ProjectAccountJoinDaoImpl() {
-
- vrIdSearch = createSearchBuilder();
- vrIdSearch.and("accountId", vrIdSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
- vrIdSearch.and("projectId", vrIdSearch.entity().getProjectId(), SearchCriteria.Op.EQ);
- vrIdSearch.done();
-
- this._count = "select count(distinct id) from project_account_view WHERE ";
- }
-
-
-
-
- @Override
- public ProjectAccountResponse newProjectAccountResponse(ProjectAccountJoinVO proj) {
- ProjectAccountResponse projectAccountResponse = new ProjectAccountResponse();
-
- projectAccountResponse.setProjectId(proj.getProjectUuid());
- projectAccountResponse.setProjectName(proj.getProjectName());
-
- projectAccountResponse.setAccountId(proj.getAccountUuid());
- projectAccountResponse.setAccountName(proj.getAccountName());
- projectAccountResponse.setAccountType(proj.getAccountType());
- projectAccountResponse.setRole(proj.getAccountRole().toString());
- projectAccountResponse.setDomainId(proj.getDomainUuid());
- projectAccountResponse.setDomainName(proj.getDomainName());
-
- projectAccountResponse.setObjectName("projectaccount");
-
- return projectAccountResponse;
- }
-
-
-
-
- @Override
- public ProjectAccountJoinVO newProjectAccountView(ProjectAccount proj) {
- SearchCriteria<ProjectAccountJoinVO> sc = vrIdSearch.create();
- sc.setParameters("accountId", proj.getAccountId());
- sc.setParameters("projectId", proj.getProjectId());
- List<ProjectAccountJoinVO> grps = searchIncludingRemoved(sc, null, null, false);
- assert grps != null && grps.size() == 1 : "No project account found for account id = " + proj.getAccountId() + " and project id = " + proj.getProjectId();
- return grps.get(0);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/projects/dao/ProjectInvitationJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/dao/ProjectInvitationJoinDao.java b/server/src/com/cloud/projects/dao/ProjectInvitationJoinDao.java
deleted file mode 100644
index 2ee7de0..0000000
--- a/server/src/com/cloud/projects/dao/ProjectInvitationJoinDao.java
+++ /dev/null
@@ -1,29 +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 com.cloud.projects.dao;
-
-import org.apache.cloudstack.api.response.ProjectInvitationResponse;
-import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
-import com.cloud.projects.ProjectInvitation;
-import com.cloud.utils.db.GenericDao;
-
-public interface ProjectInvitationJoinDao extends GenericDao<ProjectInvitationJoinVO, Long> {
-
- ProjectInvitationResponse newProjectInvitationResponse(ProjectInvitationJoinVO proj);
-
- ProjectInvitationJoinVO newProjectInvitationView(ProjectInvitation proj);
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/projects/dao/ProjectInvitationJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/dao/ProjectInvitationJoinDaoImpl.java b/server/src/com/cloud/projects/dao/ProjectInvitationJoinDaoImpl.java
deleted file mode 100644
index 0ee0ef8..0000000
--- a/server/src/com/cloud/projects/dao/ProjectInvitationJoinDaoImpl.java
+++ /dev/null
@@ -1,86 +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 com.cloud.projects.dao;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.api.response.ProjectInvitationResponse;
-import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
-
-import com.cloud.api.ApiDBUtils;
-import com.cloud.projects.ProjectInvitation;
-import com.cloud.user.Account;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-
-@Local(value={ProjectInvitationJoinDao.class})
-public class ProjectInvitationJoinDaoImpl extends GenericDaoBase<ProjectInvitationJoinVO, Long> implements ProjectInvitationJoinDao {
- public static final Logger s_logger = Logger.getLogger(ProjectInvitationJoinDaoImpl.class);
-
-
- private SearchBuilder<ProjectInvitationJoinVO> vrIdSearch;
-
- protected ProjectInvitationJoinDaoImpl() {
-
- vrIdSearch = createSearchBuilder();
- vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
- vrIdSearch.done();
-
- this._count = "select count(distinct id) from project_invitation_view WHERE ";
- }
-
-
-
- @Override
- public ProjectInvitationResponse newProjectInvitationResponse(ProjectInvitationJoinVO invite) {
- ProjectInvitationResponse response = new ProjectInvitationResponse();
- response.setId(invite.getUuid());
- response.setProjectId(invite.getProjectUuid());
- response.setProjectName(invite.getProjectName());
- response.setInvitationState(invite.getState().toString());
-
- if (invite.getAccountName() != null) {
- response.setAccountName(invite.getAccountName());
- } else {
- response.setEmail(invite.getEmail());
- }
-
- response.setDomainId(invite.getDomainUuid());
- response.setDomainName(invite.getDomainName());
-
- response.setObjectName("projectinvitation");
- return response;
- }
-
-
-
- @Override
- public ProjectInvitationJoinVO newProjectInvitationView(ProjectInvitation proj) {
- SearchCriteria<ProjectInvitationJoinVO> sc = vrIdSearch.create();
- sc.setParameters("id", proj.getId());
- List<ProjectInvitationJoinVO> grps = searchIncludingRemoved(sc, null, null, false);
- assert grps != null && grps.size() == 1 : "No project invitation found for id " + proj.getId();
- return grps.get(0);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/projects/dao/ProjectJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/dao/ProjectJoinDao.java b/server/src/com/cloud/projects/dao/ProjectJoinDao.java
deleted file mode 100644
index c5cc422..0000000
--- a/server/src/com/cloud/projects/dao/ProjectJoinDao.java
+++ /dev/null
@@ -1,36 +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 com.cloud.projects.dao;
-
-import java.util.List;
-
-import org.apache.cloudstack.api.response.ProjectResponse;
-import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
-import com.cloud.projects.Project;
-import com.cloud.utils.db.GenericDao;
-
-public interface ProjectJoinDao extends GenericDao<ProjectJoinVO, Long> {
-
- ProjectResponse newProjectResponse(ProjectJoinVO proj);
-
- ProjectResponse setProjectResponse(ProjectResponse rsp, ProjectJoinVO proj);
-
- List<ProjectJoinVO> newProjectView(Project proj);
-
- List<ProjectJoinVO> searchByIds(Long... ids);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/projects/dao/ProjectJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/projects/dao/ProjectJoinDaoImpl.java b/server/src/com/cloud/projects/dao/ProjectJoinDaoImpl.java
deleted file mode 100644
index 81ccb7f..0000000
--- a/server/src/com/cloud/projects/dao/ProjectJoinDaoImpl.java
+++ /dev/null
@@ -1,108 +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 com.cloud.projects.dao;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiDBUtils;
-import org.apache.cloudstack.api.response.ProjectResponse;
-import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
-import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
-import com.cloud.projects.Project;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-
-@Local(value={ProjectJoinDao.class})
-public class ProjectJoinDaoImpl extends GenericDaoBase<ProjectJoinVO, Long> implements ProjectJoinDao {
- public static final Logger s_logger = Logger.getLogger(ProjectJoinDaoImpl.class);
-
- private SearchBuilder<ProjectJoinVO> vrSearch;
-
- private SearchBuilder<ProjectJoinVO> vrIdSearch;
-
- protected ProjectJoinDaoImpl() {
-
- vrSearch = createSearchBuilder();
- vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
- vrSearch.done();
-
- vrIdSearch = createSearchBuilder();
- vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
- vrIdSearch.done();
-
- this._count = "select count(distinct id) from project_view WHERE ";
- }
-
- @Override
- public ProjectResponse newProjectResponse(ProjectJoinVO proj) {
- ProjectResponse response = new ProjectResponse();
- response.setId(proj.getUuid());
- response.setName(proj.getName());
- response.setDisplaytext(proj.getDisplayText());
- response.setState(proj.getState().toString());
-
- response.setDomainId(proj.getDomainUuid());
- response.setDomain(proj.getDomainName());
-
- response.setOwner(proj.getOwner());
-
- // update tag information
- Long tag_id = proj.getTagId();
- if (tag_id != null && tag_id.longValue() > 0) {
- ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
- if ( vtag != null ){
- response.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
- }
- }
-
- response.setObjectName("project");
- return response;
- }
-
- @Override
- public ProjectResponse setProjectResponse(ProjectResponse rsp, ProjectJoinVO proj) {
- // update tag information
- Long tag_id = proj.getTagId();
- if (tag_id != null && tag_id.longValue() > 0) {
- ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
- if ( vtag != null ){
- rsp.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
- }
- }
- return rsp;
- }
-
- @Override
- public List<ProjectJoinVO> newProjectView(Project proj) {
- SearchCriteria<ProjectJoinVO> sc = vrIdSearch.create();
- sc.setParameters("id", proj.getId());
- return searchIncludingRemoved(sc, null, null, false);
- }
-
- @Override
- public List<ProjectJoinVO> searchByIds(Long... ids) {
- SearchCriteria<ProjectJoinVO> sc = vrSearch.create();
- sc.setParameters("idIN", ids);
- return searchIncludingRemoved(sc, null, null, false);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index a196cd3..ddf91dc 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -95,12 +95,15 @@ import org.apache.cloudstack.api.command.admin.systemvm.StopSystemVmCmd;
import org.apache.cloudstack.api.command.admin.domain.UpdateDomainCmd;
import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
import com.cloud.api.commands.UpdateTemplateOrIsoCmd;
+import com.cloud.api.query.dao.DomainRouterJoinDao;
+import com.cloud.api.query.dao.InstanceGroupJoinDao;
+import com.cloud.api.query.vo.DomainRouterJoinVO;
+import com.cloud.api.query.vo.EventJoinVO;
+import com.cloud.api.query.vo.InstanceGroupJoinVO;
+
import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
import org.apache.cloudstack.api.command.admin.resource.UploadCustomCertificateCmd;
import org.apache.cloudstack.api.response.ExtractResponse;
-import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
-import org.apache.cloudstack.api.view.vo.EventJoinVO;
-import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
import com.cloud.async.AsyncJob;
import com.cloud.async.AsyncJobExecutor;
@@ -262,9 +265,7 @@ import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.VirtualMachineProfileImpl;
import com.cloud.vm.dao.ConsoleProxyDao;
import com.cloud.vm.dao.DomainRouterDao;
-import com.cloud.vm.dao.DomainRouterJoinDao;
import com.cloud.vm.dao.InstanceGroupDao;
-import com.cloud.vm.dao.InstanceGroupJoinDao;
import com.cloud.vm.dao.NicDao;
import com.cloud.vm.dao.SecondaryStorageVmDao;
import com.cloud.vm.dao.UserVmDao;
@@ -1548,221 +1549,8 @@ public class ManagementServerImpl implements ManagementServer {
return _templateDao.findById(id);
}
- @Override
- public Pair<List<EventJoinVO>, Integer> searchForEvents(ListEventsCmd cmd) {
- Account caller = UserContext.current().getCaller();
- List<Long> permittedAccounts = new ArrayList<Long>();
-
- Long id = cmd.getId();
- String type = cmd.getType();
- String level = cmd.getLevel();
- Date startDate = cmd.getStartDate();
- Date endDate = cmd.getEndDate();
- String keyword = cmd.getKeyword();
- Integer entryTime = cmd.getEntryTime();
- Integer duration = cmd.getDuration();
-
- Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
- cmd.getDomainId(), cmd.isRecursive(), null);
- _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject,
- cmd.listAll(), false);
- Long domainId = domainIdRecursiveListProject.first();
- Boolean isRecursive = domainIdRecursiveListProject.second();
- ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
-
- Filter searchFilter = new Filter(EventJoinVO.class, "createDate", false, cmd.getStartIndex(), cmd.getPageSizeVal());
- SearchBuilder<EventJoinVO> sb = _eventJoinDao.createSearchBuilder();
- _accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
-
- sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
- sb.and("levelL", sb.entity().getLevel(), SearchCriteria.Op.LIKE);
- sb.and("levelEQ", sb.entity().getLevel(), SearchCriteria.Op.EQ);
- sb.and("type", sb.entity().getType(), SearchCriteria.Op.EQ);
- sb.and("createDateB", sb.entity().getCreateDate(), SearchCriteria.Op.BETWEEN);
- sb.and("createDateG", sb.entity().getCreateDate(), SearchCriteria.Op.GTEQ);
- sb.and("createDateL", sb.entity().getCreateDate(), SearchCriteria.Op.LTEQ);
- sb.and("state", sb.entity().getState(), SearchCriteria.Op.NEQ);
- sb.and("startId", sb.entity().getStartId(), SearchCriteria.Op.EQ);
- sb.and("createDate", sb.entity().getCreateDate(), SearchCriteria.Op.BETWEEN);
-
- SearchCriteria<EventJoinVO> sc = sb.create();
- // building ACL condition
- _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
-
- if (id != null) {
- sc.setParameters("id", id);
- }
-
- if (keyword != null) {
- SearchCriteria<EventJoinVO> ssc = _eventJoinDao.createSearchCriteria();
- ssc.addOr("type", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("description", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("level", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- sc.addAnd("level", SearchCriteria.Op.SC, ssc);
- }
-
- if (level != null) {
- sc.setParameters("levelEQ", level);
- }
-
- if (type != null) {
- sc.setParameters("type", type);
- }
-
- if (startDate != null && endDate != null) {
- sc.setParameters("createDateB", startDate, endDate);
- } else if (startDate != null) {
- sc.setParameters("createDateG", startDate);
- } else if (endDate != null) {
- sc.setParameters("createDateL", endDate);
- }
-
- Pair<List<EventJoinVO>, Integer> eventPair = null;
- // event_view will not have duplicate rows for each event, so searchAndCount should be good enough.
- if ((entryTime != null) && (duration != null)) {
- // TODO: waiting for response from dev list, logic is mystery to
- // me!!
- /*
- * if (entryTime <= duration) { throw new
- * InvalidParameterValueException
- * ("Entry time must be greater than duration"); } Calendar calMin =
- * Calendar.getInstance(); Calendar calMax = Calendar.getInstance();
- * calMin.add(Calendar.SECOND, -entryTime);
- * calMax.add(Calendar.SECOND, -duration); Date minTime =
- * calMin.getTime(); Date maxTime = calMax.getTime();
- *
- * sc.setParameters("state", com.cloud.event.Event.State.Completed);
- * sc.setParameters("startId", 0); sc.setParameters("createDate",
- * minTime, maxTime); List<EventJoinVO> startedEvents =
- * _eventJoinDao.searchAllEvents(sc, searchFilter);
- * List<EventJoinVO> pendingEvents = new ArrayList<EventJoinVO>();
- * for (EventVO event : startedEvents) { EventVO completedEvent =
- * _eventDao.findCompletedEvent(event.getId()); if (completedEvent
- * == null) { pendingEvents.add(event); } } return pendingEvents;
- */
- } else {
- eventPair = _eventJoinDao.searchAndCount(sc, searchFilter);
- }
- return eventPair;
-
- }
-
- @Override
- public Pair<List<DomainRouterJoinVO>, Integer> searchForRouters(ListRoutersCmd cmd) {
- Long id = cmd.getId();
- String name = cmd.getRouterName();
- String state = cmd.getState();
- Long zone = cmd.getZoneId();
- Long pod = cmd.getPodId();
- Long hostId = cmd.getHostId();
- String keyword = cmd.getKeyword();
- Long networkId = cmd.getNetworkId();
- Long vpcId = cmd.getVpcId();
- Boolean forVpc = cmd.getForVpc();
-
- Account caller = UserContext.current().getCaller();
- List<Long> permittedAccounts = new ArrayList<Long>();
-
- Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
- cmd.getDomainId(), cmd.isRecursive(), null);
- _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject,
- cmd.listAll(), false);
- Long domainId = domainIdRecursiveListProject.first();
- Boolean isRecursive = domainIdRecursiveListProject.second();
- ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
- // no default orderBy
- // Filter searchFilter = new Filter(DomainRouterJoinVO.class, "id",
- // true, cmd.getStartIndex(), cmd.getPageSizeVal());
- Filter searchFilter = new Filter(DomainRouterJoinVO.class, null, true, cmd.getStartIndex(), cmd.getPageSizeVal());
- SearchBuilder<DomainRouterJoinVO> sb = _routerJoinDao.createSearchBuilder();
- sb.select(null, Func.DISTINCT, sb.entity().getId()); // select distinct
- // ids to get
- // number of
- // records with
- // pagination
- _accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
-
- sb.and("name", sb.entity().getHostName(), SearchCriteria.Op.LIKE);
- sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
- sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.IN);
- sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
- sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
- sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ);
- sb.and("hostId", sb.entity().getHostId(), SearchCriteria.Op.EQ);
- sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ);
-
- if (forVpc != null) {
- if (forVpc) {
- sb.and("forVpc", sb.entity().getVpcId(), SearchCriteria.Op.NNULL);
- } else {
- sb.and("forVpc", sb.entity().getVpcId(), SearchCriteria.Op.NULL);
- }
- }
-
- if (networkId != null) {
- sb.and("networkId", sb.entity().getNetworkId(), SearchCriteria.Op.EQ);
- }
-
- SearchCriteria<DomainRouterJoinVO> sc = sb.create();
- _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
- if (keyword != null) {
- SearchCriteria<DomainRouterJoinVO> ssc = _routerJoinDao.createSearchCriteria();
- ssc.addOr("hostName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("instanceName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("state", SearchCriteria.Op.LIKE, "%" + keyword + "%");
-
- sc.addAnd("hostName", SearchCriteria.Op.SC, ssc);
- }
-
- if (name != null) {
- sc.setParameters("name", "%" + name + "%");
- }
-
- if (id != null) {
- sc.setParameters("id", id);
- }
-
- if (state != null) {
- sc.setParameters("state", state);
- }
-
- if (zone != null) {
- sc.setParameters("dataCenterId", zone);
- }
-
- if (pod != null) {
- sc.setParameters("podId", pod);
- }
- if (hostId != null) {
- sc.setParameters("hostId", hostId);
- }
-
- if (networkId != null) {
- sc.setJoinParameters("nicSearch", "networkId", networkId);
- }
-
- if (vpcId != null) {
- sc.setParameters("vpcId", vpcId);
- }
-
- // search VR details by ids
- Pair<List<DomainRouterJoinVO>, Integer> uniqueVrPair = _routerJoinDao.searchAndCount(sc, searchFilter);
- Integer count = uniqueVrPair.second();
- if (count.intValue() == 0) {
- // empty result
- return uniqueVrPair;
- }
- List<DomainRouterJoinVO> uniqueVrs = uniqueVrPair.first();
- Long[] vrIds = new Long[uniqueVrs.size()];
- int i = 0;
- for (DomainRouterJoinVO v : uniqueVrs) {
- vrIds[i++] = v.getId();
- }
- List<DomainRouterJoinVO> vrs = _routerJoinDao.searchByIds(vrIds);
- return new Pair<List<DomainRouterJoinVO>, Integer>(vrs, count);
- }
@Override
public Pair<List<? extends IpAddress>, Integer> searchForIPAddresses(ListPublicIpAddressesCmd cmd) {
@@ -3209,53 +2997,7 @@ public class ManagementServerImpl implements ManagementServer {
return _vmGroupDao.findById(groupId);
}
- @Override
- public Pair<List<InstanceGroupJoinVO>, Integer> searchForVmGroups(ListVMGroupsCmd cmd) {
- Long id = cmd.getId();
- String name = cmd.getGroupName();
- String keyword = cmd.getKeyword();
-
- Account caller = UserContext.current().getCaller();
- List<Long> permittedAccounts = new ArrayList<Long>();
- Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(
- cmd.getDomainId(), cmd.isRecursive(), null);
- _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject,
- cmd.listAll(), false);
- Long domainId = domainIdRecursiveListProject.first();
- Boolean isRecursive = domainIdRecursiveListProject.second();
- ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
-
- Filter searchFilter = new Filter(InstanceGroupJoinVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
-
- SearchBuilder<InstanceGroupJoinVO> sb = _vmGroupJoinDao.createSearchBuilder();
- _accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
-
-
- sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
- sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
-
-
- SearchCriteria<InstanceGroupJoinVO> sc = sb.create();
- _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
-
- if (keyword != null) {
- SearchCriteria<InstanceGroupJoinVO> ssc = _vmGroupJoinDao.createSearchCriteria();
- ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- sc.addAnd("name", SearchCriteria.Op.SC, ssc);
- }
-
-
- if (id != null) {
- sc.setParameters("id", id);
- }
-
- if (name != null) {
- sc.setParameters("name", "%" + name + "%");
- }
-
- return _vmGroupJoinDao.searchAndCount(sc, searchFilter);
- }
@Override
public String getVersion() {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
index 0f82142..42d3c83 100644
--- a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
+++ b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
@@ -27,7 +27,9 @@ import javax.naming.ConfigurationException;
import org.apache.cloudstack.api.command.user.tag.ListTagsCmd;
import org.apache.log4j.Logger;
-import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
+
+import com.cloud.api.query.dao.ResourceTagJoinDao;
+import com.cloud.api.query.vo.ResourceTagJoinVO;
import com.cloud.domain.Domain;
import com.cloud.event.ActionEvent;
import com.cloud.event.EventTypes;
@@ -51,7 +53,6 @@ import com.cloud.storage.dao.SnapshotDao;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.tags.dao.ResourceTagDao;
-import com.cloud.tags.dao.ResourceTagJoinDao;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.DomainManager;
@@ -326,71 +327,6 @@ public class TaggedResourceManagerImpl implements TaggedResourceService, Manager
}
@Override
- public Pair<List<ResourceTagJoinVO>, Integer> listTags(ListTagsCmd cmd) {
- Account caller = UserContext.current().getCaller();
- List<Long> permittedAccounts = new ArrayList<Long>();
- String key = cmd.getKey();
- String value = cmd.getValue();
- String resourceId = cmd.getResourceId();
- String resourceType = cmd.getResourceType();
- String customerName = cmd.getCustomer();
- boolean listAll = cmd.listAll();
-
- Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject =
- new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
-
- _accountMgr.buildACLSearchParameters(caller, null, cmd.getAccountName(),
- cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, listAll, false);
- Long domainId = domainIdRecursiveListProject.first();
- Boolean isRecursive = domainIdRecursiveListProject.second();
- ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
- Filter searchFilter = new Filter(ResourceTagJoinVO.class, "resourceType", false, cmd.getStartIndex(), cmd.getPageSizeVal());
-
- SearchBuilder<ResourceTagJoinVO> sb = _resourceTagJoinDao.createSearchBuilder();
- _accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
-
- sb.and("key", sb.entity().getKey(), SearchCriteria.Op.EQ);
- sb.and("value", sb.entity().getValue(), SearchCriteria.Op.EQ);
-
- if (resourceId != null) {
- sb.and().op("resourceId", sb.entity().getResourceId(), SearchCriteria.Op.EQ);
- sb.or("resourceUuid", sb.entity().getResourceUuid(), SearchCriteria.Op.EQ);
- sb.cp();
- }
-
- sb.and("resourceType", sb.entity().getResourceType(), SearchCriteria.Op.EQ);
- sb.and("customer", sb.entity().getCustomer(), SearchCriteria.Op.EQ);
-
- // now set the SC criteria...
- SearchCriteria<ResourceTagJoinVO> sc = sb.create();
- _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
-
- if (key != null) {
- sc.setParameters("key", key);
- }
-
- if (value != null) {
- sc.setParameters("value", value);
- }
-
- if (resourceId != null) {
- sc.setParameters("resourceId", resourceId);
- sc.setParameters("resourceUuid", resourceId);
- }
-
- if (resourceType != null) {
- sc.setParameters("resourceType", resourceType);
- }
-
- if (customerName != null) {
- sc.setParameters("customer", customerName);
- }
-
- Pair<List<ResourceTagJoinVO>, Integer> result = _resourceTagJoinDao.searchAndCount(sc, searchFilter);
- return result;
- }
-
- @Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_TAGS_DELETE, eventDescription = "deleting resource tags")
public boolean deleteTags(List<String> resourceIds, TaggedResourceType resourceType, Map<String, String> tags) {
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/tags/dao/ResourceTagJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/tags/dao/ResourceTagJoinDao.java b/server/src/com/cloud/tags/dao/ResourceTagJoinDao.java
deleted file mode 100644
index 8dd3d82..0000000
--- a/server/src/com/cloud/tags/dao/ResourceTagJoinDao.java
+++ /dev/null
@@ -1,33 +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 com.cloud.tags.dao;
-
-import java.util.List;
-
-import org.apache.cloudstack.api.response.ResourceTagResponse;
-import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
-import com.cloud.server.ResourceTag;
-import com.cloud.utils.db.GenericDao;
-
-public interface ResourceTagJoinDao extends GenericDao<ResourceTagJoinVO, Long> {
-
- ResourceTagResponse newResourceTagResponse(ResourceTagJoinVO uvo, boolean keyValueOnly );
-
- ResourceTagJoinVO newResourceTagView(ResourceTag vr);
-
- List<ResourceTagJoinVO> searchByIds(Long... ids);
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/tags/dao/ResourceTagJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/tags/dao/ResourceTagJoinDaoImpl.java b/server/src/com/cloud/tags/dao/ResourceTagJoinDaoImpl.java
deleted file mode 100644
index 3c2dafa..0000000
--- a/server/src/com/cloud/tags/dao/ResourceTagJoinDaoImpl.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 com.cloud.tags.dao;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ejb.Local;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.api.ApiResponseHelper;
-import org.apache.cloudstack.api.response.ResourceTagResponse;
-import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
-import com.cloud.server.ResourceTag;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-
-
-@Local(value={ResourceTagJoinDao.class})
-public class ResourceTagJoinDaoImpl extends GenericDaoBase<ResourceTagJoinVO, Long> implements ResourceTagJoinDao {
- public static final Logger s_logger = Logger.getLogger(ResourceTagJoinDaoImpl.class);
-
- private SearchBuilder<ResourceTagJoinVO> vrSearch;
-
- private SearchBuilder<ResourceTagJoinVO> vrIdSearch;
-
- protected ResourceTagJoinDaoImpl() {
-
- vrSearch = createSearchBuilder();
- vrSearch.and("idIN", vrSearch.entity().getId(), SearchCriteria.Op.IN);
- vrSearch.done();
-
- vrIdSearch = createSearchBuilder();
- vrIdSearch.and("id", vrIdSearch.entity().getId(), SearchCriteria.Op.EQ);
- vrIdSearch.done();
-
- this._count = "select count(distinct id) from resource_tag_view WHERE ";
- }
-
-
-
-
-
- @Override
- public ResourceTagResponse newResourceTagResponse(ResourceTagJoinVO resourceTag, boolean keyValueOnly) {
- ResourceTagResponse response = new ResourceTagResponse();
- response.setKey(resourceTag.getKey());
- response.setValue(resourceTag.getValue());
-
- if (!keyValueOnly) {
- response.setResourceType(resourceTag.getResourceType().toString());
- response.setResourceId(resourceTag.getResourceUuid());
-
- ApiResponseHelper.populateOwner(response, resourceTag);
-
- response.setDomainId(resourceTag.getDomainUuid());
- response.setDomainName(resourceTag.getDomainName());
-
- response.setCustomer(resourceTag.getCustomer());
- }
-
- response.setObjectName("tag");
-
- return response;
- }
-
-
- @Override
- public List<ResourceTagJoinVO> searchByIds(Long... ids) {
- SearchCriteria<ResourceTagJoinVO> sc = vrSearch.create();
- sc.setParameters("idIN", ids);
- return searchIncludingRemoved(sc, null, null, false);
- }
-
-
- @Override
- public ResourceTagJoinVO newResourceTagView(ResourceTag vr) {
-
- SearchCriteria<ResourceTagJoinVO> sc = vrIdSearch.create();
- sc.setParameters("id", vr.getId());
- List<ResourceTagJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
- assert vms != null && vms.size() == 1 : "No tag found for tag id " + vr.getId();
- return vms.get(0);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/user/AccountManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManager.java b/server/src/com/cloud/user/AccountManager.java
index 56a2394..3e5e176 100755
--- a/server/src/com/cloud/user/AccountManager.java
+++ b/server/src/com/cloud/user/AccountManager.java
@@ -20,7 +20,7 @@ import java.util.List;
import java.util.Map;
import com.cloud.acl.ControlledEntity;
-import org.apache.cloudstack.api.view.vo.ControlledViewEntity;
+import com.cloud.api.query.vo.ControlledViewEntity;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.projects.Project.ListProjectResourcesCriteria;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/user/AccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java
index e1b806d..593d295 100755
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java
@@ -36,19 +36,19 @@ import javax.crypto.spec.SecretKeySpec;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
-import org.apache.cloudstack.api.command.admin.user.*;
import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
import com.cloud.acl.ControlledEntity;
-import org.apache.cloudstack.api.view.vo.ControlledViewEntity;
-import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
import com.cloud.acl.SecurityChecker;
import com.cloud.acl.SecurityChecker.AccessType;
import com.cloud.api.ApiDBUtils;
+import com.cloud.api.query.vo.ControlledViewEntity;
+
+
import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
import org.apache.cloudstack.api.command.user.account.ListAccountsCmd;
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
@@ -763,6 +763,7 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
// ////////////// API commands /////////////////////
// ///////////////////////////////////////////////////
+
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_ACCOUNT_CREATE, eventDescription = "creating Account")
@@ -2140,101 +2141,6 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
return new Pair<List<? extends Account>, Integer>(result.first(), result.second());
}
- @Override
- public Pair<List<UserAccountJoinVO>, Integer> searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException {
- Account caller = UserContext.current().getCaller();
-
- //TODO: Integrate with ACL checkAccess refactoring
- Long domainId = cmd.getDomainId();
- if (domainId != null) {
- Domain domain = _domainDao.findById(domainId);
- if (domain == null) {
- throw new InvalidParameterValueException("Unable to find domain by id=" + domainId);
- }
-
- checkAccess(caller, domain);
- } else {
- // default domainId to the caller's domain
- domainId = caller.getDomainId();
- }
-
- Filter searchFilter = new Filter(UserAccountJoinVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
-
- Long id = cmd.getId();
- Object username = cmd.getUsername();
- Object type = cmd.getAccountType();
- Object accountName = cmd.getAccountName();
- Object state = cmd.getState();
- Object keyword = cmd.getKeyword();
-
- SearchBuilder<UserAccountJoinVO> sb = _userAccountJoinDao.createSearchBuilder();
- sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.LIKE);
- if (id != null && id == 1) {
- // system user should NOT be searchable
- List<UserAccountJoinVO> emptyList = new ArrayList<UserAccountJoinVO>();
- return new Pair<List<UserAccountJoinVO>, Integer>(emptyList, 0);
- } else if (id != null) {
- sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
- } else {
- // this condition is used to exclude system user from the search results
- sb.and("id", sb.entity().getId(), SearchCriteria.Op.NEQ);
- }
-
- sb.and("type", sb.entity().getAccountType(), SearchCriteria.Op.EQ);
- sb.and("domainId", sb.entity().getDomainId(), SearchCriteria.Op.EQ);
- sb.and("accountName", sb.entity().getAccountName(), SearchCriteria.Op.EQ);
- sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
-
- if ((accountName == null) && (domainId != null)) {
- sb.and("domainPath", sb.entity().getDomainPath(), SearchCriteria.Op.LIKE);
- }
-
- SearchCriteria<UserAccountJoinVO> sc = sb.create();
- if (keyword != null) {
- SearchCriteria<UserAccountJoinVO> ssc = _userAccountJoinDao.createSearchCriteria();
- ssc.addOr("username", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("firstname", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("lastname", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("email", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("state", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("accountName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("type", SearchCriteria.Op.LIKE, "%" + keyword + "%");
- ssc.addOr("accountState", SearchCriteria.Op.LIKE, "%" + keyword + "%");
-
- sc.addAnd("username", SearchCriteria.Op.SC, ssc);
- }
-
- if (username != null) {
- sc.setParameters("username", username);
- }
-
- if (id != null) {
- sc.setParameters("id", id);
- } else {
- // Don't return system user, search builder with NEQ
- sc.setParameters("id", 1);
- }
-
- if (type != null) {
- sc.setParameters("type", type);
- }
-
- if (accountName != null) {
- sc.setParameters("accountName", accountName);
- if (domainId != null) {
- sc.setParameters("domainId", domainId);
- }
- } else if (domainId != null) {
- DomainVO domainVO = _domainDao.findById(domainId);
- sc.setParameters("domainPath", domainVO.getPath() + "%");
- }
-
- if (state != null) {
- sc.setParameters("state", state);
- }
-
- return _userAccountJoinDao.searchAndCount(sc, searchFilter);
- }
@Override
public void buildACLSearchBuilder(SearchBuilder<? extends ControlledEntity> sb,
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/user/dao/UserAccountJoinDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/dao/UserAccountJoinDao.java b/server/src/com/cloud/user/dao/UserAccountJoinDao.java
index 39a82d0..0072d33 100644
--- a/server/src/com/cloud/user/dao/UserAccountJoinDao.java
+++ b/server/src/com/cloud/user/dao/UserAccountJoinDao.java
@@ -19,8 +19,8 @@ package com.cloud.user.dao;
import java.util.List;
import org.apache.cloudstack.api.response.UserResponse;
-import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
+import com.cloud.api.query.vo.UserAccountJoinVO;
import com.cloud.user.User;
import com.cloud.user.UserAccount;
import com.cloud.utils.db.GenericDao;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/user/dao/UserAccountJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/dao/UserAccountJoinDaoImpl.java b/server/src/com/cloud/user/dao/UserAccountJoinDaoImpl.java
index e854ae5..4cad00b 100644
--- a/server/src/com/cloud/user/dao/UserAccountJoinDaoImpl.java
+++ b/server/src/com/cloud/user/dao/UserAccountJoinDaoImpl.java
@@ -24,10 +24,11 @@ import org.apache.log4j.Logger;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.ApiResponseHelper;
+import com.cloud.api.query.vo.InstanceGroupJoinVO;
+import com.cloud.api.query.vo.UserAccountJoinVO;
+
import org.apache.cloudstack.api.response.InstanceGroupResponse;
import org.apache.cloudstack.api.response.UserResponse;
-import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
-import org.apache.cloudstack.api.view.vo.UserAccountJoinVO;
import com.cloud.user.Account;
import com.cloud.user.User;
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c167ad45/server/src/com/cloud/vm/UserVmManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManager.java b/server/src/com/cloud/vm/UserVmManager.java
index f58b10e..3e4a2db 100755
--- a/server/src/com/cloud/vm/UserVmManager.java
+++ b/server/src/com/cloud/vm/UserVmManager.java
@@ -21,7 +21,7 @@ import java.util.List;
import java.util.Map;
import com.cloud.agent.api.VmStatsEntry;
-import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
+import com.cloud.api.query.vo.UserVmJoinVO;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceUnavailableException;