http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/server/ManagementServerImpl.java
index 63d6a3d,a2a74c2..e9d2e23
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@@ -38,17 -39,9 +38,18 @@@ import java.util.concurrent.Executors
  import java.util.concurrent.ScheduledExecutorService;
  import java.util.concurrent.TimeUnit;
  
 +import javax.annotation.PostConstruct;
  import javax.crypto.Mac;
  import javax.crypto.spec.SecretKeySpec;
 +import javax.inject.Inject;
 +import javax.management.InstanceAlreadyExistsException;
 +import javax.management.MBeanRegistrationException;
 +import javax.management.MalformedObjectNameException;
 +import javax.management.NotCompliantMBeanException;
  
++import com.cloud.storage.dao.*;
 +import org.apache.cloudstack.acl.SecurityChecker.AccessType;
 +import org.apache.cloudstack.api.ApiConstants;
  import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
  import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;
  import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
@@@ -71,11 -54,8 +72,12 @@@ import org.apache.cloudstack.api.comman
  import org.apache.cloudstack.api.command.user.guest.ListGuestOsCmd;
  import org.apache.cloudstack.api.command.user.iso.ListIsosCmd;
  import org.apache.cloudstack.api.command.user.iso.UpdateIsoCmd;
 +import org.apache.cloudstack.api.command.user.offering.ListDiskOfferingsCmd;
 +import 
org.apache.cloudstack.api.command.user.offering.ListServiceOfferingsCmd;
 +import org.apache.cloudstack.api.command.user.ssh.CreateSSHKeyPairCmd;
+ import org.apache.cloudstack.api.command.user.ssh.ListSSHKeyPairsCmd;
  import org.apache.cloudstack.api.command.user.ssh.DeleteSSHKeyPairCmd;
 +import org.apache.cloudstack.api.command.user.ssh.ListSSHKeyPairsCmd;
  import org.apache.cloudstack.api.command.user.ssh.RegisterSSHKeyPairCmd;
  import org.apache.cloudstack.api.command.user.template.ListTemplatesCmd;
  import org.apache.cloudstack.api.command.user.template.UpdateTemplateCmd;
@@@ -193,13 -183,12 +193,6 @@@ import com.cloud.storage.UploadVO
  import com.cloud.storage.VMTemplateVO;
  import com.cloud.storage.Volume;
  import com.cloud.storage.VolumeVO;
- import com.cloud.storage.dao.DiskOfferingDao;
--import com.cloud.storage.dao.GuestOSCategoryDao;
--import com.cloud.storage.dao.GuestOSDao;
--import com.cloud.storage.dao.StoragePoolDao;
--import com.cloud.storage.dao.UploadDao;
--import com.cloud.storage.dao.VMTemplateDao;
--import com.cloud.storage.dao.VolumeDao;
  import com.cloud.storage.s3.S3Manager;
  import com.cloud.storage.secondary.SecondaryStorageVmManager;
  import com.cloud.storage.snapshot.SnapshotManager;
@@@ -565,121 -416,9 +558,7 @@@ public class ManagementServerImpl imple
          return PasswordGenerator.generateRandomPassword(6);
      }
  
 -
 -
      @Override
-     public List<DataCenterVO> listDataCenters(ListZonesByCmd cmd) {
-         Account account = UserContext.current().getCaller();
-         List<DataCenterVO> dcs = null;
-         Long domainId = cmd.getDomainId();
-         Long id = cmd.getId();
-         boolean removeDisabledZones = false;
-         String keyword = cmd.getKeyword();
-         if (domainId != null) {
-             // for domainId != null
-             // right now, we made the decision to only list zones associated
-             // with this domain
-             dcs = _dcDao.findZonesByDomainId(domainId, keyword); // private
-             // zones
-         } else if ((account == null || account.getType() == 
Account.ACCOUNT_TYPE_ADMIN)) {
-             if (keyword != null) {
-                 dcs = _dcDao.findByKeyword(keyword);
-             } else {
-                 dcs = _dcDao.listAll(); // all zones
-             }
-         } else if (account.getType() == Account.ACCOUNT_TYPE_NORMAL) {
-             // it was decided to return all zones for the user's domain, and
-             // everything above till root
-             // list all zones belonging to this domain, and all of its parents
-             // check the parent, if not null, add zones for that parent to 
list
-             dcs = new ArrayList<DataCenterVO>();
-             DomainVO domainRecord = 
_domainDao.findById(account.getDomainId());
-             if (domainRecord != null) {
-                 while (true) {
-                     
dcs.addAll(_dcDao.findZonesByDomainId(domainRecord.getId(), keyword));
-                     if (domainRecord.getParent() != null) {
-                         domainRecord = 
_domainDao.findById(domainRecord.getParent());
-                     } else {
-                         break;
-                     }
-                 }
-             }
-             // add all public zones too
-             dcs.addAll(_dcDao.listPublicZones(keyword));
-             removeDisabledZones = true;
-         } else if (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN || 
account.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
-             // it was decided to return all zones for the domain admin, and
-             // everything above till root
-             dcs = new ArrayList<DataCenterVO>();
-             DomainVO domainRecord = 
_domainDao.findById(account.getDomainId());
-             // this covers path till root
-             if (domainRecord != null) {
-                 DomainVO localRecord = domainRecord;
-                 while (true) {
-                     
dcs.addAll(_dcDao.findZonesByDomainId(localRecord.getId(), keyword));
-                     if (localRecord.getParent() != null) {
-                         localRecord = 
_domainDao.findById(localRecord.getParent());
-                     } else {
-                         break;
-                     }
-                 }
-             }
-             // this covers till leaf
-             if (domainRecord != null) {
-                 // find all children for this domain based on a like search by
-                 // path
-                 List<DomainVO> allChildDomains = 
_domainDao.findAllChildren(domainRecord.getPath(), domainRecord.getId());
-                 List<Long> allChildDomainIds = new ArrayList<Long>();
-                 // create list of domainIds for search
-                 for (DomainVO domain : allChildDomains) {
-                     allChildDomainIds.add(domain.getId());
-                 }
-                 // now make a search for zones based on this
-                 if (allChildDomainIds.size() > 0) {
-                     List<DataCenterVO> childZones = 
_dcDao.findChildZones((allChildDomainIds.toArray()), keyword);
-                     dcs.addAll(childZones);
-                 }
-             }
-             // add all public zones too
-             dcs.addAll(_dcDao.listPublicZones(keyword));
-             removeDisabledZones = true;
-         }
- 
-         if (removeDisabledZones) {
-             dcs.removeAll(_dcDao.listDisabledZones());
-         }
- 
-         Boolean available = cmd.isAvailable();
-         if (account != null) {
-             if ((available != null) && Boolean.FALSE.equals(available)) {
-                 List<DomainRouterVO> routers = 
_routerDao.listBy(account.getId());
-                 for (Iterator<DataCenterVO> iter = dcs.iterator(); 
iter.hasNext();) {
-                     DataCenterVO dc = iter.next();
-                     boolean found = false;
-                     for (DomainRouterVO router : routers) {
-                         if (dc.getId() == router.getDataCenterId()) {
-                             found = true;
-                             break;
-                         }
-                     }
-                     if (!found) {
-                         iter.remove();
-                     }
-                 }
-             }
-         }
- 
-         if (id != null) {
-             List<DataCenterVO> singleZone = new ArrayList<DataCenterVO>();
-             for (DataCenterVO zone : dcs) {
-                 if (zone.getId() == id) {
-                     singleZone.add(zone);
-                 }
-             }
-             return singleZone;
-         }
-         return dcs;
-     }
- 
-     @Override
      public HostVO getHostBy(long hostId) {
          return _hostDao.findById(hostId);
      }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/storage/dao/SnapshotPolicyDaoImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/storage/dao/SnapshotPolicyDaoImpl.java
index 9beed67,100d53b..3f894a2
--- a/server/src/com/cloud/storage/dao/SnapshotPolicyDaoImpl.java
+++ b/server/src/com/cloud/storage/dao/SnapshotPolicyDaoImpl.java
@@@ -21,10 -21,9 +21,11 @@@ import java.util.List
  
  import javax.ejb.Local;
  
 +import org.springframework.stereotype.Component;
 +
  import com.cloud.storage.SnapshotPolicyVO;
  import com.cloud.utils.DateUtil.IntervalType;
+ import com.cloud.utils.Pair;
  import com.cloud.utils.db.Filter;
  import com.cloud.utils.db.GenericDaoBase;
  import com.cloud.utils.db.SearchBuilder;
@@@ -65,7 -63,20 +66,20 @@@ public class SnapshotPolicyDaoImpl exte
          sc.setParameters("active", true);
          return listBy(sc, filter);
      }
 -
 +      
+     @Override
+     public Pair<List<SnapshotPolicyVO>, Integer> listAndCountByVolumeId(long 
volumeId) {
+         return listAndCountByVolumeId(volumeId, null);
+     }
+ 
+     @Override
+     public Pair<List<SnapshotPolicyVO>, Integer> listAndCountByVolumeId(long 
volumeId, Filter filter) {
+         SearchCriteria<SnapshotPolicyVO> sc = VolumeIdSearch.create();
+         sc.setParameters("volumeId", volumeId);
+         sc.setParameters("active", true);
+         return searchAndCount(sc, filter);
+     }
+ 
      protected SnapshotPolicyDaoImpl() {
          VolumeIdSearch = createSearchBuilder();
          VolumeIdSearch.and("volumeId", VolumeIdSearch.entity().getVolumeId(), 
SearchCriteria.Op.EQ);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/server/src/com/cloud/storage/swift/SwiftManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/storage/swift/SwiftManagerImpl.java
index ef3deed,d62dd63..01e2955
--- a/server/src/com/cloud/storage/swift/SwiftManagerImpl.java
+++ b/server/src/com/cloud/storage/swift/SwiftManagerImpl.java
@@@ -52,6 -50,8 +52,7 @@@ import com.cloud.storage.dao.SwiftDao
  import com.cloud.storage.dao.VMTemplateHostDao;
  import com.cloud.storage.dao.VMTemplateSwiftDao;
  import com.cloud.storage.dao.VMTemplateZoneDao;
+ import com.cloud.utils.Pair;
 -import com.cloud.utils.component.Inject;
  import com.cloud.utils.db.Filter;
  import com.cloud.utils.db.SearchCriteria;
  import com.cloud.utils.db.SearchCriteria.Op;
@@@ -59,15 -59,14 +60,11 @@@ import com.cloud.utils.db.SearchCriteri
  import com.cloud.utils.db.SearchCriteriaService;
  import com.cloud.utils.exception.CloudRuntimeException;
  
--
--
 +@Component
  @Local(value = { SwiftManager.class })
  public class SwiftManagerImpl implements SwiftManager {
      private static final Logger s_logger = 
Logger.getLogger(SwiftManagerImpl.class);
  
--
--
      private String _name;
      @Inject
      private SwiftDao _swiftDao;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/356866c7/utils/src/com/cloud/utils/db/GenericDaoBase.java
----------------------------------------------------------------------

Reply via email to