You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2012/12/13 18:29:29 UTC

[2/3] Move all the DB view DAOs from cloud-server to cloud-api for future api-server package.

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/api/src/org/apache/cloudstack/api/view/dao/UserVmJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/view/dao/UserVmJoinDaoImpl.java b/api/src/org/apache/cloudstack/api/view/dao/UserVmJoinDaoImpl.java
new file mode 100644
index 0000000..b7821cc
--- /dev/null
+++ b/api/src/org/apache/cloudstack/api/view/dao/UserVmJoinDaoImpl.java
@@ -0,0 +1,331 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.api.view.dao;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.Hashtable;
+import java.util.List;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+//import com.cloud.api.ApiDBUtils;
+import org.apache.cloudstack.api.ApiConstants.VMDetails;
+import org.apache.cloudstack.api.response.NicResponse;
+import org.apache.cloudstack.api.response.SecurityGroupResponse;
+import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.api.view.DBViewUtils;
+import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
+import org.apache.cloudstack.api.view.vo.UserVmJoinVO;
+import com.cloud.user.Account;
+import com.cloud.uservm.UserVm;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.vm.VmStats;
+
+
+@Local(value={UserVmJoinDao.class})
+public class UserVmJoinDaoImpl extends GenericDaoBase<UserVmJoinVO, Long> implements UserVmJoinDao {
+    public static final Logger s_logger = Logger.getLogger(UserVmJoinDaoImpl.class);
+
+    private static final int VM_DETAILS_BATCH_SIZE=100;
+
+    private SearchBuilder<UserVmJoinVO> VmDetailSearch;
+
+    protected UserVmJoinDaoImpl() {
+
+        VmDetailSearch = createSearchBuilder();
+        VmDetailSearch.and("idIN", VmDetailSearch.entity().getId(), SearchCriteria.Op.IN);
+        VmDetailSearch.done();
+
+        this._count = "select count(distinct id) from user_vm_view WHERE ";
+    }
+
+    public UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm, EnumSet<VMDetails> details, Account caller) {
+        UserVmResponse userVmResponse = new UserVmResponse();
+
+        if (userVm.getHypervisorType() != null){
+            userVmResponse.setHypervisor(userVm.getHypervisorType().toString());
+        }
+        userVmResponse.setId(userVm.getUuid());
+        userVmResponse.setName(userVm.getName());
+
+        userVmResponse.setDisplayName(userVm.getDisplayName());
+
+        if (userVm.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
+            userVmResponse.setProjectId(userVm.getProjectUuid());
+            userVmResponse.setProjectName(userVm.getProjectName());
+        } else {
+            userVmResponse.setAccountName(userVm.getAccountName());
+        }
+
+        userVmResponse.setDomainId(userVm.getDomainUuid());
+        userVmResponse.setDomainName(userVm.getDomainName());
+
+        userVmResponse.setCreated(userVm.getCreated());
+
+        if (userVm.getState() != null) {
+            userVmResponse.setState(userVm.getState().toString());
+        }
+        userVmResponse.setHaEnable(userVm.isHaEnabled());
+        if (details.contains(VMDetails.all) || details.contains(VMDetails.group)) {
+            userVmResponse.setGroupId(userVm.getInstanceGroupUuid());
+            userVmResponse.setGroup(userVm.getInstanceGroupName());
+        }
+        userVmResponse.setZoneId(userVm.getDataCenterUuid());
+        userVmResponse.setZoneName(userVm.getDataCenterName());
+        if ((caller == null) || (caller.getType() == Account.ACCOUNT_TYPE_ADMIN)) {
+            userVmResponse.setInstanceName(userVm.getInstanceName());
+            userVmResponse.setHostId(userVm.getHostUuid());
+            userVmResponse.setHostName(userVm.getHostName());
+        }
+
+        if (details.contains(VMDetails.all) || details.contains(VMDetails.tmpl)) {
+            userVmResponse.setTemplateId(userVm.getTemplateUuid());
+            userVmResponse.setTemplateName(userVm.getTemplateName());
+            userVmResponse.setTemplateDisplayText(userVm.getTemplateDisplayText());
+            userVmResponse.setPasswordEnabled(userVm.isPasswordEnabled());
+        }
+        if (details.contains(VMDetails.all) || details.contains(VMDetails.iso)) {
+            userVmResponse.setIsoId(userVm.getIsoUuid());
+            userVmResponse.setIsoName(userVm.getIsoName());
+            userVmResponse.setIsoDisplayText(userVm.getIsoDisplayText());
+        }
+        if (details.contains(VMDetails.all) || details.contains(VMDetails.servoff)) {
+            userVmResponse.setServiceOfferingId(userVm.getServiceOfferingUuid());
+            userVmResponse.setServiceOfferingName(userVm.getServiceOfferingName());
+            userVmResponse.setCpuNumber(userVm.getCpu());
+            userVmResponse.setCpuSpeed(userVm.getSpeed());
+            userVmResponse.setMemory(userVm.getRamSize());
+        }
+        userVmResponse.setGuestOsId(userVm.getGuestOsUuid());
+        if (details.contains(VMDetails.all) || details.contains(VMDetails.volume)) {
+            userVmResponse.setRootDeviceId(userVm.getVolumeDeviceId());
+            if (userVm.getVolumeType() != null) {
+                userVmResponse.setRootDeviceType(userVm.getVolumeType().toString());
+            }
+        }
+        userVmResponse.setPassword(userVm.getPassword());
+        userVmResponse.setJobUuid(userVm.getJobUuid());
+        userVmResponse.setJobStatus(userVm.getJobStatus());
+        //userVmResponse.setForVirtualNetwork(userVm.getForVirtualNetwork());
+
+        userVmResponse.setPublicIpId(userVm.getPublicIpUuid());
+        userVmResponse.setPublicIp(userVm.getPublicIpAddress());
+        userVmResponse.setKeyPairName(userVm.getKeypairName());
+
+        /*TODO: we need to invoke cloud-engine API to get Vm statistics or StatsConnector needs
+         * to put them into DB tables
+        if (details.contains(VMDetails.all) || details.contains(VMDetails.stats)) {
+            DecimalFormat decimalFormat = new DecimalFormat("#.##");
+            // stats calculation
+            String cpuUsed = null;
+            VmStats vmStats = ApiDBUtils.getVmStatistics(userVm.getId());
+            if (vmStats != null) {
+                float cpuUtil = (float) vmStats.getCPUUtilization();
+                cpuUsed = decimalFormat.format(cpuUtil) + "%";
+                userVmResponse.setCpuUsed(cpuUsed);
+
+                Double networkKbRead = Double.valueOf(vmStats.getNetworkReadKBs());
+                userVmResponse.setNetworkKbsRead(networkKbRead.longValue());
+
+                Double networkKbWrite = Double.valueOf(vmStats.getNetworkWriteKBs());
+                userVmResponse.setNetworkKbsWrite(networkKbWrite.longValue());
+            }
+        }
+        */
+
+        if (details.contains(VMDetails.all) || details.contains(VMDetails.secgrp)) {
+            Long securityGroupId = userVm.getSecurityGroupId();
+            if (securityGroupId != null && securityGroupId.longValue() != 0) {
+                SecurityGroupResponse resp = new SecurityGroupResponse();
+                resp.setId(userVm.getSecurityGroupUuid());
+                resp.setName(userVm.getSecurityGroupName());
+                resp.setDescription(userVm.getSecurityGroupDescription());
+                resp.setObjectName("securitygroup");
+                if (userVm.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
+                    resp.setProjectId(userVm.getProjectUuid());
+                    resp.setProjectName(userVm.getProjectName());
+                } else {
+                    resp.setAccountName(userVm.getAccountName());
+                }
+                userVmResponse.addSecurityGroup(resp);
+            }
+        }
+
+        if (details.contains(VMDetails.all) || details.contains(VMDetails.nics)) {
+            long nic_id = userVm.getNicId();
+            if (nic_id > 0) {
+                NicResponse nicResponse = new NicResponse();
+                nicResponse.setId(userVm.getNicUuid());
+                nicResponse.setIpaddress(userVm.getIpAddress());
+                nicResponse.setGateway(userVm.getGateway());
+                nicResponse.setNetmask(userVm.getNetmask());
+                nicResponse.setNetworkid(userVm.getNetworkUuid());
+                nicResponse.setMacAddress(userVm.getMacAddress());
+                if (userVm.getBroadcastUri() != null) {
+                    nicResponse.setBroadcastUri(userVm.getBroadcastUri().toString());
+                }
+                if (userVm.getIsolationUri() != null) {
+                    nicResponse.setIsolationUri(userVm.getIsolationUri().toString());
+                }
+                if (userVm.getTrafficType() != null) {
+                    nicResponse.setTrafficType(userVm.getTrafficType().toString());
+                }
+                if (userVm.getGuestType() != null) {
+                    nicResponse.setType(userVm.getGuestType().toString());
+                }
+                nicResponse.setIsDefault(userVm.isDefaultNic());
+                nicResponse.setObjectName("nic");
+                userVmResponse.addNic(nicResponse);
+            }
+        }
+
+        // update tag information
+        long tag_id = userVm.getTagId();
+        if (tag_id > 0) {
+            ResourceTagJoinVO vtag = DBViewUtils.findResourceTagViewById(tag_id);
+            if ( vtag != null ){
+                userVmResponse.addTag(DBViewUtils.newResourceTagResponse(vtag, false));
+            }
+        }
+        userVmResponse.setObjectName(objectName);
+
+        return userVmResponse;
+       }
+
+    public UserVmResponse setUserVmResponse(UserVmResponse userVmData, UserVmJoinVO uvo) {
+        Long securityGroupId = uvo.getSecurityGroupId();
+        if (securityGroupId != null && securityGroupId.longValue() != 0) {
+            SecurityGroupResponse resp = new SecurityGroupResponse();
+            resp.setId(uvo.getSecurityGroupUuid());
+            resp.setName(uvo.getSecurityGroupName());
+            resp.setDescription(uvo.getSecurityGroupDescription());
+            resp.setObjectName("securitygroup");
+            if (uvo.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
+                resp.setProjectId(uvo.getProjectUuid());
+                resp.setProjectName(uvo.getProjectName());
+            } else {
+                resp.setAccountName(uvo.getAccountName());
+            }
+            userVmData.addSecurityGroup(resp);
+        }
+
+        long nic_id = uvo.getNicId();
+        if (nic_id > 0) {
+            NicResponse nicResponse = new NicResponse();
+            nicResponse.setId(uvo.getNicUuid());
+            nicResponse.setIpaddress(uvo.getIpAddress());
+            nicResponse.setGateway(uvo.getGateway());
+            nicResponse.setNetmask(uvo.getNetmask());
+            nicResponse.setNetworkid(uvo.getNetworkUuid());
+            nicResponse.setMacAddress(uvo.getMacAddress());
+            if (uvo.getBroadcastUri() != null) {
+                nicResponse.setBroadcastUri(uvo.getBroadcastUri().toString());
+            }
+            if (uvo.getIsolationUri() != null) {
+                nicResponse.setIsolationUri(uvo.getIsolationUri().toString());
+            }
+            if (uvo.getTrafficType() != null) {
+                nicResponse.setTrafficType(uvo.getTrafficType().toString());
+            }
+            if (uvo.getGuestType() != null) {
+                nicResponse.setType(uvo.getGuestType().toString());
+            }
+            nicResponse.setIsDefault(uvo.isDefaultNic());
+            nicResponse.setObjectName("nic");
+            userVmData.addNic(nicResponse);
+        }
+
+        long tag_id = uvo.getTagId();
+        if (tag_id > 0) {
+            ResourceTagJoinVO vtag = DBViewUtils.findResourceTagViewById(tag_id);
+            if ( vtag != null ){
+                userVmData.addTag(DBViewUtils.newResourceTagResponse(vtag, false));
+            }
+        }
+        return userVmData;
+    }
+
+
+    @Override
+    public List<UserVmJoinVO> searchByIds(Long... vmIds) {
+        SearchCriteria<UserVmJoinVO> sc = VmDetailSearch.create();
+        sc.setParameters("idIN", vmIds);
+        return searchIncludingRemoved(sc, null, null, false);
+    }
+
+    @Override
+    public List<UserVmJoinVO> newUserVmView(UserVm... userVms) {
+
+        int curr_index = 0;
+
+        Hashtable<Long, UserVm> userVmDataHash = new Hashtable<Long, UserVm>();
+        for (UserVm vm : userVms){
+            if ( !userVmDataHash.containsKey(vm.getId())){
+                userVmDataHash.put(vm.getId(), vm);
+            }
+        }
+
+        List<UserVmJoinVO> uvList = new ArrayList<UserVmJoinVO>();
+        List<Long> userVmIdList = new ArrayList(userVmDataHash.keySet());
+         if (userVmIdList.size() > VM_DETAILS_BATCH_SIZE) {
+            while ((curr_index + VM_DETAILS_BATCH_SIZE) <= userVmIdList.size()) {
+                // set current ids
+                Long[] vmIds = new Long[VM_DETAILS_BATCH_SIZE];
+                for (int k = 0, j = curr_index; j < curr_index + VM_DETAILS_BATCH_SIZE; j++, k++) {
+                    vmIds[k] = userVmIdList.get(j);
+                }
+                SearchCriteria<UserVmJoinVO> sc = VmDetailSearch.create();
+                sc.setParameters("idIN", vmIds);
+                List<UserVmJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+                if (vms != null) {
+                    for (UserVmJoinVO uvm : vms) {
+                        uvList.add(uvm);
+                    }
+                }
+                curr_index += VM_DETAILS_BATCH_SIZE;
+            }
+        }
+
+        if (curr_index < userVmIdList.size()) {
+            int batch_size = (userVmIdList.size() - curr_index);
+            // set the ids value
+            Long[] vmIds = new Long[batch_size];
+            for (int k = 0, j = curr_index; j < curr_index + batch_size; j++, k++) {
+                vmIds[k] = userVmIdList.get(j);
+            }
+            SearchCriteria<UserVmJoinVO> sc = VmDetailSearch.create();
+            sc.setParameters("idIN", vmIds);
+            List<UserVmJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
+            if (vms != null) {
+                for (UserVmJoinVO uvm : vms) {
+                    UserVm vm = userVmDataHash.get(uvm.getId());
+                    assert vm != null : "We should not find details of vm not in the passed UserVm list";
+                    uvList.add(uvm);
+                }
+            }
+        }
+        return uvList;
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index d5cce52..ae42609 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -33,6 +33,16 @@ import org.apache.cloudstack.api.response.ResourceTagResponse;
 import org.apache.cloudstack.api.response.SecurityGroupResponse;
 import org.apache.cloudstack.api.response.UserResponse;
 import org.apache.cloudstack.api.response.UserVmResponse;
+import org.apache.cloudstack.api.view.dao.DomainRouterJoinDao;
+import org.apache.cloudstack.api.view.dao.EventJoinDao;
+import org.apache.cloudstack.api.view.dao.InstanceGroupJoinDao;
+import org.apache.cloudstack.api.view.dao.ProjectAccountJoinDao;
+import org.apache.cloudstack.api.view.dao.ProjectInvitationJoinDao;
+import org.apache.cloudstack.api.view.dao.ProjectJoinDao;
+import org.apache.cloudstack.api.view.dao.ResourceTagJoinDao;
+import org.apache.cloudstack.api.view.dao.SecurityGroupJoinDao;
+import org.apache.cloudstack.api.view.dao.UserAccountJoinDao;
+import org.apache.cloudstack.api.view.dao.UserVmJoinDao;
 import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
 import org.apache.cloudstack.api.view.vo.EventJoinVO;
 import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
@@ -66,7 +76,6 @@ import com.cloud.dc.dao.VlanDao;
 import com.cloud.domain.DomainVO;
 import com.cloud.domain.dao.DomainDao;
 import com.cloud.event.Event;
-import com.cloud.event.dao.EventJoinDao;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.ha.HighAvailabilityManager;
 import com.cloud.host.Host;
@@ -112,7 +121,6 @@ import com.cloud.network.security.SecurityGroup;
 import com.cloud.network.security.SecurityGroupManager;
 import com.cloud.network.security.SecurityGroupVO;
 import com.cloud.network.security.dao.SecurityGroupDao;
-import com.cloud.network.security.dao.SecurityGroupJoinDao;
 import com.cloud.network.vpc.VpcManager;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.ServiceOffering;
@@ -122,9 +130,6 @@ import com.cloud.projects.Project;
 import com.cloud.projects.ProjectAccount;
 import com.cloud.projects.ProjectInvitation;
 import com.cloud.projects.ProjectService;
-import com.cloud.projects.dao.ProjectAccountJoinDao;
-import com.cloud.projects.dao.ProjectInvitationJoinDao;
-import com.cloud.projects.dao.ProjectJoinDao;
 import com.cloud.resource.ResourceManager;
 import com.cloud.server.Criteria;
 import com.cloud.server.ManagementServer;
@@ -162,7 +167,6 @@ import com.cloud.storage.dao.VMTemplateHostDao;
 import com.cloud.storage.dao.VMTemplateSwiftDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.dao.VolumeHostDao;
-import com.cloud.tags.dao.ResourceTagJoinDao;
 import com.cloud.user.Account;
 import com.cloud.user.AccountDetailsDao;
 import com.cloud.user.AccountVO;
@@ -174,7 +178,6 @@ import com.cloud.user.UserStatisticsVO;
 import com.cloud.user.UserVO;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.SSHKeyPairDao;
-import com.cloud.user.dao.UserAccountJoinDao;
 import com.cloud.user.dao.UserDao;
 import com.cloud.user.dao.UserStatisticsDao;
 import com.cloud.uservm.UserVm;
@@ -194,11 +197,8 @@ import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VmStats;
 import com.cloud.vm.dao.ConsoleProxyDao;
 import com.cloud.vm.dao.DomainRouterDao;
-import com.cloud.vm.dao.DomainRouterJoinDao;
-import com.cloud.vm.dao.InstanceGroupJoinDao;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.UserVmDetailsDao;
-import com.cloud.vm.dao.UserVmJoinDao;
 import com.cloud.vm.dao.VMInstanceDao;
 
 public class ApiDBUtils {
@@ -944,127 +944,6 @@ public class ApiDBUtils {
         return _counterDao.findById(counterId);
     }
 
-    ///////////////////////////////////////////////////////////////////////
-    //  Newly Added Utility Methods for List API refactoring             //
-    ///////////////////////////////////////////////////////////////////////
-
-    public static DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO vr, Account caller) {
-        return _domainRouterJoinDao.newDomainRouterResponse(vr, caller);
-    }
-
-    public static DomainRouterResponse fillRouterDetails(DomainRouterResponse vrData, DomainRouterJoinVO vr){
-         return _domainRouterJoinDao.setDomainRouterResponse(vrData, vr);
-    }
-
-    public static List<DomainRouterJoinVO> newDomainRouterView(VirtualRouter vr){
-        return _domainRouterJoinDao.newDomainRouterView(vr);
-    }
-
-    public static UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm, EnumSet<VMDetails> details, Account caller) {
-        return _userVmJoinDao.newUserVmResponse(objectName, userVm, details, caller);
-    }
-
-    public static UserVmResponse fillVmDetails(UserVmResponse vmData, UserVmJoinVO vm){
-         return _userVmJoinDao.setUserVmResponse(vmData, vm);
-    }
-
-    public static List<UserVmJoinVO> newUserVmView(UserVm... userVms){
-        return _userVmJoinDao.newUserVmView(userVms);
-    }
-
-    public static SecurityGroupResponse newSecurityGroupResponse(SecurityGroupJoinVO vsg, Account caller) {
-        return _securityGroupJoinDao.newSecurityGroupResponse(vsg, caller);
-    }
-
-    public static SecurityGroupResponse fillSecurityGroupDetails(SecurityGroupResponse vsgData, SecurityGroupJoinVO sg){
-         return _securityGroupJoinDao.setSecurityGroupResponse(vsgData, sg);
-    }
-
-    public static List<SecurityGroupJoinVO> newSecurityGroupView(SecurityGroup sg){
-        return _securityGroupJoinDao.newSecurityGroupView(sg);
-    }
-
-    public static List<SecurityGroupJoinVO> findSecurityGroupViewById(Long sgId){
-        return _securityGroupJoinDao.searchByIds(sgId);
-    }
-
-    public static ResourceTagResponse newResourceTagResponse(ResourceTagJoinVO vsg, boolean keyValueOnly) {
-        return _tagJoinDao.newResourceTagResponse(vsg, keyValueOnly);
-    }
-
-    public static ResourceTagJoinVO newResourceTagView(ResourceTag sg){
-        return _tagJoinDao.newResourceTagView(sg);
-    }
-
-    public static ResourceTagJoinVO findResourceTagViewById(Long tagId){
-        List<ResourceTagJoinVO> tags = _tagJoinDao.searchByIds(tagId);
-        if ( tags != null && tags.size() > 0 ){
-            return tags.get(0);
-        }
-        else{
-            return null;
-        }
-    }
-
-    public static EventResponse newEventResponse(EventJoinVO ve) {
-        return _eventJoinDao.newEventResponse(ve);
-    }
-
-    public static EventJoinVO newEventView(Event e){
-        return _eventJoinDao.newEventView(e);
-    }
-
-    public static InstanceGroupResponse newInstanceGroupResponse(InstanceGroupJoinVO ve) {
-        return _vmGroupJoinDao.newInstanceGroupResponse(ve);
-    }
-
-    public static InstanceGroupJoinVO newInstanceGroupView(InstanceGroup e){
-        return _vmGroupJoinDao.newInstanceGroupView(e);
-    }
-
-    public static UserResponse newUserResponse(UserAccountJoinVO usr) {
-        return _userAccountJoinDao.newUserResponse(usr);
-    }
-
-    public static UserAccountJoinVO newUserView(User usr){
-        return _userAccountJoinDao.newUserView(usr);
-    }
-
-    public static UserAccountJoinVO newUserView(UserAccount usr){
-        return _userAccountJoinDao.newUserView(usr);
-    }
-
-    public static ProjectResponse newProjectResponse(ProjectJoinVO proj) {
-        return _projectJoinDao.newProjectResponse(proj);
-    }
-
-    public static ProjectResponse fillProjectDetails(ProjectResponse rsp, ProjectJoinVO proj){
-         return _projectJoinDao.setProjectResponse(rsp,proj);
-    }
-
-    public static List<ProjectJoinVO> newProjectView(Project proj){
-        return _projectJoinDao.newProjectView(proj);
-    }
-
-    public static List<UserAccountJoinVO> findUserViewByAccountId(Long accountId){
-        return _userAccountJoinDao.searchByAccountId(accountId);
-    }
-
-    public static ProjectAccountResponse newProjectAccountResponse(ProjectAccountJoinVO proj) {
-        return _projectAccountJoinDao.newProjectAccountResponse(proj);
-    }
-
-    public static ProjectAccountJoinVO newProjectAccountView(ProjectAccount proj) {
-        return _projectAccountJoinDao.newProjectAccountView(proj);
-    }
-
-    public static ProjectInvitationResponse newProjectInvitationResponse(ProjectInvitationJoinVO proj) {
-        return _projectInvitationJoinDao.newProjectInvitationResponse(proj);
-    }
-
-    public static ProjectInvitationJoinVO newProjectInvitationView(ProjectInvitation proj) {
-        return _projectInvitationJoinDao.newProjectInvitationView(proj);
-    }
 
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 1e2b87d..72c3bc8 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -112,6 +112,7 @@ import org.apache.cloudstack.api.response.VpcOfferingResponse;
 import org.apache.cloudstack.api.response.VpcResponse;
 import org.apache.cloudstack.api.response.VpnUsersResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
+import org.apache.cloudstack.api.view.DBViewUtils;
 import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
 import org.apache.cloudstack.api.view.vo.ControlledViewEntity;
 import org.apache.cloudstack.api.view.vo.EventJoinVO;
@@ -242,8 +243,8 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     @Override
     public UserResponse createUserResponse(User user) {
-        UserAccountJoinVO vUser = ApiDBUtils.newUserView(user);
-        return ApiDBUtils.newUserResponse(vUser);
+        UserAccountJoinVO vUser = DBViewUtils.newUserView(user);
+        return DBViewUtils.newUserResponse(vUser);
     }
 
 
@@ -251,7 +252,7 @@ public class ApiResponseHelper implements ResponseGenerator {
     public List<UserResponse> createUserResponse(UserAccountJoinVO... users) {
         List<UserResponse> respList = new ArrayList<UserResponse>();
         for (UserAccountJoinVO vt : users){
-            respList.add(ApiDBUtils.newUserResponse(vt));
+            respList.add(DBViewUtils.newUserResponse(vt));
         }
         return respList;
     }
@@ -415,8 +416,8 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     @Override
     public UserResponse createUserResponse(UserAccount user) {
-        UserAccountJoinVO vUser = ApiDBUtils.newUserView(user);
-        return ApiDBUtils.newUserResponse(vUser);
+        UserAccountJoinVO vUser = DBViewUtils.newUserView(user);
+        return DBViewUtils.newUserResponse(vUser);
     }
 
     @Override
@@ -1170,8 +1171,8 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     @Override
     public InstanceGroupResponse createInstanceGroupResponse(InstanceGroup group) {
-        InstanceGroupJoinVO vgroup = ApiDBUtils.newInstanceGroupView(group);
-        return ApiDBUtils.newInstanceGroupResponse(vgroup);
+        InstanceGroupJoinVO vgroup = DBViewUtils.newInstanceGroupView(group);
+        return DBViewUtils.newInstanceGroupResponse(vgroup);
 
     }
 
@@ -1181,7 +1182,7 @@ public class ApiResponseHelper implements ResponseGenerator {
     public List<InstanceGroupResponse> createInstanceGroupResponse(InstanceGroupJoinVO... groups) {
         List<InstanceGroupResponse> respList = new ArrayList<InstanceGroupResponse>();
         for (InstanceGroupJoinVO vt : groups){
-            respList.add(ApiDBUtils.newInstanceGroupResponse(vt));
+            respList.add(DBViewUtils.newInstanceGroupResponse(vt));
         }
         return respList;
     }
@@ -1368,14 +1369,14 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     @Override
     public List<UserVmResponse> createUserVmResponse(String objectName, EnumSet<VMDetails> details, UserVm... userVms) {
-        List<UserVmJoinVO> viewVms = ApiDBUtils.newUserVmView(userVms);
+        List<UserVmJoinVO> viewVms = DBViewUtils.newUserVmView(userVms);
         return createUserVmResponse(objectName, details, viewVms.toArray(new UserVmJoinVO[viewVms.size()]));
 
     }
 
     @Override
     public List<UserVmResponse> createUserVmResponse(String objectName, UserVm... userVms) {
-        List<UserVmJoinVO> viewVms = ApiDBUtils.newUserVmView(userVms);
+        List<UserVmJoinVO> viewVms = DBViewUtils.newUserVmView(userVms);
         return createUserVmResponse(objectName, viewVms.toArray(new UserVmJoinVO[viewVms.size()]));
     }
 
@@ -1397,10 +1398,10 @@ public class ApiResponseHelper implements ResponseGenerator {
             UserVmResponse userVmData = vmDataList.get(userVm.getId());
             if ( userVmData == null ){
                 // first time encountering this vm
-                userVmData = ApiDBUtils.newUserVmResponse(objectName, userVm, details, caller);
+                userVmData = DBViewUtils.newUserVmResponse(objectName, userVm, details, caller);
             } else{
                 // update nics, securitygroups, tags for 1 to many mapping fields
-                userVmData = ApiDBUtils.fillVmDetails(userVmData, userVm);
+                userVmData = DBViewUtils.fillVmDetails(userVmData, userVm);
             }
             vmDataList.put(userVm.getId(), userVmData);
         }
@@ -1410,7 +1411,7 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     @Override
     public DomainRouterResponse createDomainRouterResponse(VirtualRouter router) {
-        List<DomainRouterJoinVO> viewVrs = ApiDBUtils.newDomainRouterView(router);
+        List<DomainRouterJoinVO> viewVrs = DBViewUtils.newDomainRouterView(router);
         List<DomainRouterResponse> listVrs = createDomainRouterResponse(viewVrs.toArray(new DomainRouterJoinVO[viewVrs.size()]));
         assert listVrs != null && listVrs.size() == 1 : "There should be one virtual router returned";
         return listVrs.get(0);
@@ -1425,11 +1426,11 @@ public class ApiResponseHelper implements ResponseGenerator {
             DomainRouterResponse vrData = vrDataList.get(vr.getId());
             if ( vrData == null ){
                 // first time encountering this vm
-                vrData = ApiDBUtils.newDomainRouterResponse(vr, caller);
+                vrData = DBViewUtils.newDomainRouterResponse(vr, caller);
             }
             else{
                 // update nics for 1 to many mapping fields
-                vrData = ApiDBUtils.fillRouterDetails(vrData, vr);
+                vrData = DBViewUtils.fillRouterDetails(vrData, vr);
             }
             vrDataList.put(vr.getId(), vrData);
         }
@@ -2015,11 +2016,11 @@ public class ApiResponseHelper implements ResponseGenerator {
             SecurityGroupResponse vrData = vrDataList.get(vr.getId());
             if ( vrData == null ) {
                 // first time encountering this sg
-                vrData = ApiDBUtils.newSecurityGroupResponse(vr, caller);
+                vrData = DBViewUtils.newSecurityGroupResponse(vr, caller);
 
             } else {
                 // update rules for 1 to many mapping fields
-                vrData = ApiDBUtils.fillSecurityGroupDetails(vrData, vr);
+                vrData = DBViewUtils.fillSecurityGroupDetails(vrData, vr);
             }
             vrDataList.put(vr.getId(), vrData);
         }
@@ -2028,7 +2029,7 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     @Override
     public SecurityGroupResponse createSecurityGroupResponse(SecurityGroup group) {
-        List<SecurityGroupJoinVO> viewSgs = ApiDBUtils.newSecurityGroupView(group);
+        List<SecurityGroupJoinVO> viewSgs = DBViewUtils.newSecurityGroupView(group);
         List<SecurityGroupResponse> listSgs = createSecurityGroupResponses(viewSgs);
         assert listSgs != null && listSgs.size() == 1 : "There should be one security group returned";
         return listSgs.get(0);
@@ -2121,15 +2122,15 @@ public class ApiResponseHelper implements ResponseGenerator {
     public List<EventResponse> createEventResponse(EventJoinVO... events) {
         List<EventResponse> respList = new ArrayList<EventResponse>();
         for (EventJoinVO vt : events){
-            respList.add(ApiDBUtils.newEventResponse(vt));
+            respList.add(DBViewUtils.newEventResponse(vt));
         }
         return respList;
     }
 
     @Override
     public EventResponse createEventResponse(Event event) {
-        EventJoinVO vEvent = ApiDBUtils.newEventView(event);
-        return ApiDBUtils.newEventResponse(vEvent);
+        EventJoinVO vEvent = DBViewUtils.newEventView(event);
+        return DBViewUtils.newEventResponse(vEvent);
     }
 
     private List<CapacityVO> sumCapacities(List<? extends Capacity> hostCapacities) {
@@ -2383,7 +2384,7 @@ public class ApiResponseHelper implements ResponseGenerator {
         Map<Long, Account> allowedSecuriytGroupAccounts = new HashMap<Long, Account>();
 
         if ((securityRules != null) && !securityRules.isEmpty()) {
-            SecurityGroupJoinVO securityGroup = ApiDBUtils.findSecurityGroupViewById(securityRules.get(0).getSecurityGroupId()).get(0);
+            SecurityGroupJoinVO securityGroup = DBViewUtils.findSecurityGroupViewById(securityRules.get(0).getSecurityGroupId()).get(0);
             response.setId(securityGroup.getUuid());
             response.setName(securityGroup.getName());
             response.setDescription(securityGroup.getDescription());
@@ -2415,7 +2416,7 @@ public class ApiResponseHelper implements ResponseGenerator {
 
                 Long allowedSecurityGroupId = securityRule.getAllowedNetworkId();
                 if (allowedSecurityGroupId != null) {
-                    List<SecurityGroupJoinVO> sgs = ApiDBUtils.findSecurityGroupViewById(allowedSecurityGroupId);
+                    List<SecurityGroupJoinVO> sgs = DBViewUtils.findSecurityGroupViewById(allowedSecurityGroupId);
                     if (sgs != null && sgs.size() > 0) {
                         SecurityGroupJoinVO sg = sgs.get(0);
                         securityGroupData.setSecurityGroupName(sg.getName());
@@ -2674,7 +2675,7 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     @Override
     public ProjectResponse createProjectResponse(Project project) {
-        List<ProjectJoinVO> viewPrjs = ApiDBUtils.newProjectView(project);
+        List<ProjectJoinVO> viewPrjs = DBViewUtils.newProjectView(project);
         List<ProjectResponse> listPrjs = createProjectResponse(viewPrjs.toArray(new ProjectJoinVO[viewPrjs.size()]));
         assert listPrjs != null && listPrjs.size() == 1 : "There should be one project  returned";
         return listPrjs.get(0);
@@ -2689,11 +2690,11 @@ public class ApiResponseHelper implements ResponseGenerator {
             ProjectResponse pData = prjDataList.get(p.getId());
             if ( pData == null ){
                 // first time encountering this vm
-                pData = ApiDBUtils.newProjectResponse(p);
+                pData = DBViewUtils.newProjectResponse(p);
             }
             else{
                 // update those  1 to many mapping fields
-                pData = ApiDBUtils.fillProjectDetails(pData, p);
+                pData = DBViewUtils.fillProjectDetails(pData, p);
             }
             prjDataList.put(p.getId(), pData);
         }
@@ -2852,7 +2853,7 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     @Override
     public ProjectAccountResponse createProjectAccountResponse(ProjectAccount projectAccount) {
-        ProjectAccountJoinVO vProj = ApiDBUtils.newProjectAccountView(projectAccount);
+        ProjectAccountJoinVO vProj = DBViewUtils.newProjectAccountView(projectAccount);
         List<ProjectAccountResponse> listProjs = createProjectAccountResponse(vProj);
         assert listProjs != null && listProjs.size() == 1 : "There should be one project account returned";
         return listProjs.get(0);
@@ -2863,9 +2864,9 @@ public class ApiResponseHelper implements ResponseGenerator {
     public List<ProjectAccountResponse> createProjectAccountResponse(ProjectAccountJoinVO... projectAccounts) {
         List<ProjectAccountResponse> responseList = new ArrayList<ProjectAccountResponse>();
         for (ProjectAccountJoinVO proj : projectAccounts){
-            ProjectAccountResponse resp = ApiDBUtils.newProjectAccountResponse(proj);
+            ProjectAccountResponse resp = DBViewUtils.newProjectAccountResponse(proj);
             // update user list
-            List<UserAccountJoinVO> users = ApiDBUtils.findUserViewByAccountId(proj.getAccountId());
+            List<UserAccountJoinVO> users = DBViewUtils.findUserViewByAccountId(proj.getAccountId());
             resp.setUsers(createUserResponse(users.toArray(new UserAccountJoinVO[users.size()])));
             responseList.add(resp);
         }
@@ -2874,8 +2875,8 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     @Override
     public ProjectInvitationResponse createProjectInvitationResponse(ProjectInvitation invite) {
-        ProjectInvitationJoinVO vInvite = ApiDBUtils.newProjectInvitationView(invite);
-        return ApiDBUtils.newProjectInvitationResponse(vInvite);
+        ProjectInvitationJoinVO vInvite = DBViewUtils.newProjectInvitationView(invite);
+        return DBViewUtils.newProjectInvitationResponse(vInvite);
     }
 
 
@@ -2884,7 +2885,7 @@ public class ApiResponseHelper implements ResponseGenerator {
     public List<ProjectInvitationResponse> createProjectInvitationResponse(ProjectInvitationJoinVO... invites) {
         List<ProjectInvitationResponse> respList = new ArrayList<ProjectInvitationResponse>();
         for (ProjectInvitationJoinVO v : invites){
-            respList.add(ApiDBUtils.newProjectInvitationResponse(v));
+            respList.add(DBViewUtils.newProjectInvitationResponse(v));
         }
         return respList;
     }
@@ -3121,8 +3122,8 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     @Override
     public ResourceTagResponse createResourceTagResponse(ResourceTag resourceTag, boolean keyValueOnly) {
-        ResourceTagJoinVO rto = ApiDBUtils.newResourceTagView(resourceTag);
-        return ApiDBUtils.newResourceTagResponse(rto, keyValueOnly);
+        ResourceTagJoinVO rto = DBViewUtils.newResourceTagView(resourceTag);
+        return DBViewUtils.newResourceTagResponse(rto, keyValueOnly);
     }
 
 
@@ -3130,7 +3131,7 @@ public class ApiResponseHelper implements ResponseGenerator {
     public List<ResourceTagResponse> createResourceTagResponse(boolean keyValueOnly, ResourceTagJoinVO... tags) {
         List<ResourceTagResponse> respList = new ArrayList<ResourceTagResponse>();
         for (ResourceTagJoinVO vt : tags){
-            respList.add(ApiDBUtils.newResourceTagResponse(vt, keyValueOnly));
+            respList.add(DBViewUtils.newResourceTagResponse(vt, keyValueOnly));
         }
         return respList;
     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/server/src/com/cloud/configuration/DefaultComponentLibrary.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
index 2dd46fd..e49425e 100755
--- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java
+++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java
@@ -21,6 +21,17 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.cloudstack.api.view.dao.DomainRouterJoinDaoImpl;
+import org.apache.cloudstack.api.view.dao.EventJoinDaoImpl;
+import org.apache.cloudstack.api.view.dao.InstanceGroupJoinDaoImpl;
+import org.apache.cloudstack.api.view.dao.ProjectAccountJoinDaoImpl;
+import org.apache.cloudstack.api.view.dao.ProjectInvitationJoinDaoImpl;
+import org.apache.cloudstack.api.view.dao.ProjectJoinDaoImpl;
+import org.apache.cloudstack.api.view.dao.ResourceTagJoinDaoImpl;
+import org.apache.cloudstack.api.view.dao.SecurityGroupJoinDaoImpl;
+import org.apache.cloudstack.api.view.dao.UserAccountJoinDaoImpl;
+import org.apache.cloudstack.api.view.dao.UserVmJoinDaoImpl;
+
 import com.cloud.agent.manager.ClusteredAgentManagerImpl;
 import com.cloud.alert.AlertManagerImpl;
 import com.cloud.alert.dao.AlertDaoImpl;
@@ -117,7 +128,6 @@ import com.cloud.network.rules.RulesManagerImpl;
 import com.cloud.network.rules.dao.PortForwardingRulesDaoImpl;
 import com.cloud.network.security.SecurityGroupManagerImpl2;
 import com.cloud.network.security.dao.SecurityGroupDaoImpl;
-import com.cloud.network.security.dao.SecurityGroupJoinDaoImpl;
 import com.cloud.network.security.dao.SecurityGroupRuleDaoImpl;
 import com.cloud.network.security.dao.SecurityGroupRulesDaoImpl;
 import com.cloud.network.security.dao.SecurityGroupVMMapDaoImpl;
@@ -139,8 +149,6 @@ import com.cloud.projects.ProjectManagerImpl;
 import com.cloud.projects.dao.ProjectAccountDaoImpl;
 import com.cloud.projects.dao.ProjectDaoImpl;
 import com.cloud.projects.dao.ProjectInvitationDaoImpl;
-import com.cloud.projects.dao.ProjectInvitationJoinDaoImpl;
-import com.cloud.projects.dao.ProjectJoinDaoImpl;
 import com.cloud.resource.ResourceManagerImpl;
 import com.cloud.resourcelimit.ResourceLimitManagerImpl;
 import com.cloud.service.dao.ServiceOfferingDaoImpl;
@@ -173,7 +181,6 @@ import com.cloud.storage.snapshot.SnapshotSchedulerImpl;
 import com.cloud.storage.swift.SwiftManagerImpl;
 import com.cloud.storage.upload.UploadMonitorImpl;
 import com.cloud.tags.TaggedResourceManagerImpl;
-import com.cloud.tags.dao.ResourceTagJoinDaoImpl;
 import com.cloud.tags.dao.ResourceTagsDaoImpl;
 import com.cloud.template.HyervisorTemplateAdapter;
 import com.cloud.template.TemplateAdapter;
@@ -185,7 +192,6 @@ import com.cloud.user.DomainManagerImpl;
 import com.cloud.user.dao.AccountDaoImpl;
 import com.cloud.user.dao.SSHKeyPairDaoImpl;
 import com.cloud.user.dao.UserAccountDaoImpl;
-import com.cloud.user.dao.UserAccountJoinDaoImpl;
 import com.cloud.user.dao.UserDaoImpl;
 import com.cloud.user.dao.UserStatisticsDaoImpl;
 import com.cloud.user.dao.UserStatsLogDaoImpl;
@@ -203,18 +209,13 @@ import com.cloud.vm.ItWorkDaoImpl;
 import com.cloud.vm.UserVmManagerImpl;
 import com.cloud.vm.dao.ConsoleProxyDaoImpl;
 import com.cloud.vm.dao.DomainRouterDaoImpl;
-import com.cloud.vm.dao.DomainRouterJoinDaoImpl;
 import com.cloud.vm.dao.InstanceGroupDaoImpl;
-import com.cloud.vm.dao.InstanceGroupJoinDaoImpl;
 import com.cloud.vm.dao.InstanceGroupVMMapDaoImpl;
 import com.cloud.vm.dao.NicDaoImpl;
 import com.cloud.vm.dao.SecondaryStorageVmDaoImpl;
 import com.cloud.vm.dao.UserVmDaoImpl;
-import com.cloud.vm.dao.UserVmJoinDaoImpl;
 import com.cloud.vm.dao.UserVmDetailsDaoImpl;
 import com.cloud.vm.dao.VMInstanceDaoImpl;
-import com.cloud.event.dao.EventJoinDaoImpl;
-import com.cloud.projects.dao.ProjectAccountJoinDaoImpl;
 
 
 public class DefaultComponentLibrary extends ComponentLibraryBase implements ComponentLibrary {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/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
deleted file mode 100644
index d67653d..0000000
--- a/server/src/com/cloud/event/dao/EventJoinDao.java
+++ /dev/null
@@ -1,39 +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.event.dao;
-
-import java.util.List;
-
-import org.apache.cloudstack.api.response.EventResponse;
-import org.apache.cloudstack.api.view.vo.EventJoinVO;
-import com.cloud.event.Event;
-import com.cloud.utils.db.Filter;
-import com.cloud.utils.db.GenericDao;
-import com.cloud.utils.db.SearchCriteria;
-
-public interface EventJoinDao extends GenericDao<EventJoinVO, Long> {
-
-    EventResponse newEventResponse(EventJoinVO uvo);
-
-    EventJoinVO newEventView(Event vr);
-
-    List<EventJoinVO> searchByIds(Long... ids);
-
-    List<EventJoinVO> searchAllEvents(SearchCriteria<EventJoinVO> sc, Filter filter);
-
-    EventJoinVO findCompletedEvent(long startId);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/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
deleted file mode 100644
index be2a6dc..0000000
--- a/server/src/com/cloud/event/dao/EventJoinDaoImpl.java
+++ /dev/null
@@ -1,123 +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.event.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.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;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-
-
-@Local(value={EventJoinDao.class})
-public class EventJoinDaoImpl extends GenericDaoBase<EventJoinVO, Long> implements EventJoinDao {
-    public static final Logger s_logger = Logger.getLogger(EventJoinDaoImpl.class);
-
-    private SearchBuilder<EventJoinVO> vrSearch;
-
-    private SearchBuilder<EventJoinVO> vrIdSearch;
-
-    private SearchBuilder<EventJoinVO> CompletedEventSearch;
-
-    protected EventJoinDaoImpl() {
-
-        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();
-
-        CompletedEventSearch = createSearchBuilder();
-        CompletedEventSearch.and("state",CompletedEventSearch.entity().getState(),SearchCriteria.Op.EQ);
-        CompletedEventSearch.and("startId", CompletedEventSearch.entity().getStartId(), SearchCriteria.Op.EQ);
-        CompletedEventSearch.done();
-
-
-        this._count = "select count(distinct id) from event_view WHERE ";
-    }
-
-
-
-    @Override
-    public List<EventJoinVO> searchAllEvents(SearchCriteria<EventJoinVO> sc, Filter filter) {
-        return listIncludingRemovedBy(sc, filter);
-    }
-
-
-
-    @Override
-    public EventJoinVO findCompletedEvent(long startId) {
-        SearchCriteria<EventJoinVO> sc = CompletedEventSearch.create();
-        sc.setParameters("state", State.Completed);
-        sc.setParameters("startId", startId);
-        return findOneIncludingRemovedBy(sc);
-    }
-
-
-
-    @Override
-    public EventResponse newEventResponse(EventJoinVO event) {
-        EventResponse responseEvent = new EventResponse();
-        responseEvent.setCreated(event.getCreateDate());
-        responseEvent.setDescription(event.getDescription());
-        responseEvent.setEventType(event.getType());
-        responseEvent.setId(event.getUuid());
-        responseEvent.setLevel(event.getLevel());
-        responseEvent.setParentId(event.getStartUuid());
-        responseEvent.setState(event.getState());
-        responseEvent.setUsername(event.getUserName());
-
-        ApiResponseHelper.populateOwner(responseEvent, event);
-        responseEvent.setObjectName("event");
-        return responseEvent;
-    }
-
-
-
-    @Override
-    public List<EventJoinVO> searchByIds(Long... ids) {
-        SearchCriteria<EventJoinVO> sc = vrSearch.create();
-        sc.setParameters("idIN", ids);
-        return searchIncludingRemoved(sc, null, null, false);
-    }
-
-
-    @Override
-    public EventJoinVO newEventView(Event vr) {
-
-        SearchCriteria<EventJoinVO> sc = vrIdSearch.create();
-        sc.setParameters("id", vr.getId());
-        List<EventJoinVO> vms = searchIncludingRemoved(sc, null, null, false);
-        assert vms != null && vms.size() == 1 : "No event found for event id " + vr.getId();
-        return vms.get(0);
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/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..a017f53 100755
--- a/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
+++ b/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
@@ -46,6 +46,7 @@ import com.cloud.agent.api.SecurityGroupRulesCmd;
 import com.cloud.agent.api.SecurityGroupRulesCmd.IpPortAndProto;
 import com.cloud.agent.manager.Commands;
 import org.apache.cloudstack.api.command.user.securitygroup.RevokeSecurityGroupEgressCmd;
+import org.apache.cloudstack.api.view.dao.SecurityGroupJoinDao;
 import org.apache.cloudstack.api.view.vo.SecurityGroupJoinVO;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.dao.ConfigurationDao;
@@ -65,7 +66,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;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/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/7597a38f/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/7597a38f/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..51a98ae 100755
--- a/server/src/com/cloud/projects/ProjectManagerImpl.java
+++ b/server/src/com/cloud/projects/ProjectManagerImpl.java
@@ -38,6 +38,9 @@ import javax.mail.URLName;
 import javax.mail.internet.InternetAddress;
 import javax.naming.ConfigurationException;
 
+import org.apache.cloudstack.api.view.dao.ProjectAccountJoinDao;
+import org.apache.cloudstack.api.view.dao.ProjectInvitationJoinDao;
+import org.apache.cloudstack.api.view.dao.ProjectJoinDao;
 import org.apache.cloudstack.api.view.vo.ProjectAccountJoinVO;
 import org.apache.cloudstack.api.view.vo.ProjectInvitationJoinVO;
 import org.apache.cloudstack.api.view.vo.ProjectJoinVO;
@@ -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;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/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/7597a38f/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/7597a38f/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/7597a38f/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/7597a38f/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/7597a38f/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/7597a38f/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..a608a79 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -98,6 +98,9 @@ import com.cloud.api.commands.UpdateTemplateOrIsoCmd;
 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.dao.DomainRouterJoinDao;
+import org.apache.cloudstack.api.view.dao.EventJoinDao;
+import org.apache.cloudstack.api.view.dao.InstanceGroupJoinDao;
 import org.apache.cloudstack.api.view.vo.DomainRouterJoinVO;
 import org.apache.cloudstack.api.view.vo.EventJoinVO;
 import org.apache.cloudstack.api.view.vo.InstanceGroupJoinVO;
@@ -144,7 +147,6 @@ import com.cloud.event.EventTypes;
 import com.cloud.event.EventUtils;
 import com.cloud.event.EventVO;
 import com.cloud.event.dao.EventDao;
-import com.cloud.event.dao.EventJoinDao;
 import com.cloud.exception.CloudAuthenticationException;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.InvalidParameterValueException;
@@ -262,9 +264,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;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/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..6e69bd4 100644
--- a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
+++ b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
@@ -27,6 +27,7 @@ import javax.naming.ConfigurationException;
 import org.apache.cloudstack.api.command.user.tag.ListTagsCmd;
 import org.apache.log4j.Logger;
 
+import org.apache.cloudstack.api.view.dao.ResourceTagJoinDao;
 import org.apache.cloudstack.api.view.vo.ResourceTagJoinVO;
 import com.cloud.domain.Domain;
 import com.cloud.event.ActionEvent;
@@ -51,7 +52,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;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/7597a38f/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/7597a38f/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);
-
-    }
-
-}