DaanHoogland commented on code in PR #7446:
URL: https://github.com/apache/cloudstack/pull/7446#discussion_r1409698229


##########
server/src/main/java/com/cloud/dc/dao/DedicatedResourceDaoImpl.java:
##########
@@ -428,4 +447,35 @@ public List<Long> findHostsByZone(Long zoneId) {
         }
         return hosts;
     }
+
+
+    @Override
+    public Map<Long, List<String>> 
listDomainsOfDedicatedResourcesUsedByDomainPath(String domainPath) {
+        LOGGER.debug(String.format("Retrieving the domains of the dedicated 
resources used by domain with path [%s].", domainPath));
+
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        try (PreparedStatement pstmt = 
txn.prepareStatement(LIST_DOMAINS_OF_DEDICATED_RESOURCES_USED_BY_DOMAIN_PATH)) {
+            Map<Long, List<String>> 
domainsOfDedicatedResourcesUsedByDomainPath = new HashMap<>();
+
+            String domainSearch = domainPath.concat("%");
+            pstmt.setString(1, domainSearch);
+            pstmt.setString(2, domainSearch);
+
+            try (ResultSet rs = pstmt.executeQuery()) {
+                while (rs.next()) {
+                    Long domainId = rs.getLong(1);
+                    List<String> vmUuids = 
Arrays.asList(rs.getString(2).split(","));
+
+                    domainsOfDedicatedResourcesUsedByDomainPath.put(domainId, 
vmUuids);
+                }
+            }
+
+            return domainsOfDedicatedResourcesUsedByDomainPath;
+        } catch (SQLException e) {
+            LOGGER.error(String.format("Failed to retrieve the domains of the 
dedicated resources used by domain with path [%s] due to [%s]. Returning an 
empty "
+                    + "list of domains.", domainPath, e.getMessage()), e);

Review Comment:
   ```suggestion
               LOGGER.error(String.format("Failed to retrieve the domains of 
the dedicated resources used by domain with path [%s] due to [%s]. Returning an 
empty "
                       + "list of domains.", domainPath, e.getMessage()));
               if (LOGGER.isDebugEnabled()) {
                   LOGGER.debug(String.format("Failed to retrieve the domains 
of the dedicated resources used by domain with path [%s]. Returning an empty "
                           + "list of domains.", domainPath), e);
               }
   ```



##########
server/src/main/java/com/cloud/api/query/dao/NetworkOfferingJoinDaoImpl.java:
##########
@@ -120,4 +138,36 @@ public NetworkOfferingJoinVO 
newNetworkOfferingView(NetworkOffering offering) {
         assert offerings != null && offerings.size() == 1 : "No network 
offering found for offering id " + offering.getId();
         return offerings.get(0);
     }
+
+
+
+    @Override
+    public Map<Long, List<String>> 
listDomainsOfNetworkOfferingsUsedByDomainPath(String domainPath) {
+        s_logger.debug(String.format("Retrieving the domains of the network 
offerings used by domain with path [%s].", domainPath));
+
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        try (PreparedStatement pstmt = 
txn.prepareStatement(LIST_DOMAINS_OF_NETWORK_OFFERINGS_USED_BY_DOMAIN_PATH)) {
+            Map<Long, List<String>> domainsOfNetworkOfferingsUsedByDomainPath 
= new HashMap<>();
+
+            String domainSearch = domainPath.concat("%");
+            pstmt.setString(1, domainSearch);
+            pstmt.setString(2, domainSearch);
+
+            try (ResultSet rs = pstmt.executeQuery()) {
+                while (rs.next()) {
+                    Long domainId = rs.getLong(1);
+                    List<String> networkUuids = 
Arrays.asList(rs.getString(2).split(","));
+
+                    domainsOfNetworkOfferingsUsedByDomainPath.put(domainId, 
networkUuids);
+                }
+            }
+
+            return domainsOfNetworkOfferingsUsedByDomainPath;
+        } catch (SQLException e) {
+            s_logger.error(String.format("Failed to retrieve the domains of 
the network offerings used by domain with path [%s] due to [%s]. Returning an 
empty "
+                    + "list of domains.", domainPath, e.getMessage()), e);

Review Comment:
   ```suggestion
               s_logger.error(String.format("Failed to retrieve the domains of 
the network offerings used by domain with path [%s] due to [%s]. Returning an 
empty "
                       + "list of domains.", domainPath, e.getMessage()));
               if (s_logger.isDebugEnabled()) {
                    s_logger.debug(String.format("Failed to retrieve the 
domains of the network offerings used by domain with path [%s]. Returning an 
empty "
                            + "list of domains.", domainPath), e);
               }
   ```



##########
engine/schema/src/main/java/org/apache/cloudstack/affinity/dao/AffinityGroupDomainMapDaoImpl.java:
##########
@@ -62,4 +85,35 @@ public List<AffinityGroupDomainMapVO> listByDomain(Object... 
domainId) {
         return listBy(sc);
     }
 
+    @Override
+    public Map<Long, List<String>> 
listDomainsOfAffinityGroupsUsedByDomainPath(String domainPath) {
+        logger.debug(String.format("Retrieving the domains of the affinity 
groups with subdomain access used by domain with path [%s].", domainPath));
+
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        try (PreparedStatement pstmt = 
txn.prepareStatement(LIST_DOMAINS_WITH_AFFINITY_GROUPS_WITH_SUBDOMAIN_ACCESS_USED_BY_DOMAIN_PATH))
 {
+            Map<Long, List<String>> domainsOfAffinityGroupsUsedByDomainPath = 
new HashMap<>();
+
+            String domainSearch = domainPath.concat("%");
+            pstmt.setString(1, domainSearch);
+            pstmt.setString(2, domainSearch);
+
+
+            try (ResultSet rs = pstmt.executeQuery()) {
+                while (rs.next()) {
+                    Long domainId = rs.getLong(1);
+                    List<String> vmUuidsAndAffinityGroupUuids = 
Arrays.asList(rs.getString(2).split(","));
+
+                    domainsOfAffinityGroupsUsedByDomainPath.put(domainId, 
vmUuidsAndAffinityGroupUuids);
+                }
+            }
+
+            return domainsOfAffinityGroupsUsedByDomainPath;
+        } catch (SQLException e) {
+            logger.error(String.format("Failed to retrieve the domains of the 
affinity groups with subdomain access used by domain with path [%s] due to 
[%s]. Returning an " +
+                    "empty list of domains.", domainPath, e.getMessage()), e);

Review Comment:
   ```suggestion
               logger.error(String.format("Failed to retrieve the domains of 
the affinity groups with subdomain access used by domain with path [%s] due to 
[%s]. Returning an " +
                       "empty list of domains.", domainPath, e.getMessage()));
               if (logger.isDebugEnabled()) {
                   logger.debug(String.format("Failed to retrieve the domains 
of the affinity groups with subdomain access used by domain with path [%s]. 
Returning an " +
                           "empty list of domains.", domainPath), e);
               }
   ```



##########
server/src/main/java/com/cloud/api/query/dao/ServiceOfferingJoinDaoImpl.java:
##########
@@ -165,4 +183,35 @@ public ServiceOfferingJoinVO 
newServiceOfferingView(ServiceOffering offering) {
         assert offerings != null && offerings.size() == 1 : "No service 
offering found for offering id " + offering.getId();
         return offerings.get(0);
     }
+
+
+    @Override
+    public Map<Long, List<String>> 
listDomainsOfServiceOfferingsUsedByDomainPath(String domainPath) {
+        s_logger.debug(String.format("Retrieving the domains of the service 
offerings used by domain with path [%s].", domainPath));
+
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        try (PreparedStatement pstmt = 
txn.prepareStatement(LIST_DOMAINS_OF_SERVICE_OFFERINGS_USED_BY_DOMAIN_PATH)) {
+            Map<Long, List<String>> domainsOfServiceOfferingsUsedByDomainPath 
= new HashMap<>();
+
+            String domainSearch = domainPath.concat("%");
+            pstmt.setString(1, domainSearch);
+            pstmt.setString(2, domainSearch);
+
+            try (ResultSet rs = pstmt.executeQuery()) {
+                while (rs.next()) {
+                    Long domainId = rs.getLong(1);
+                    List<String> vmUuids = 
Arrays.asList(rs.getString(2).split(","));
+
+                    domainsOfServiceOfferingsUsedByDomainPath.put(domainId, 
vmUuids);
+                }
+            }
+
+            return domainsOfServiceOfferingsUsedByDomainPath;
+        } catch (SQLException e) {
+            s_logger.error(String.format("Failed to retrieve the domains of 
the service offerings used by domain with path [%s] due to [%s]. Returning an 
empty "
+                    + "list of domains.", domainPath, e.getMessage()), e);

Review Comment:
   ```suggestion
               s_logger.error(String.format("Failed to retrieve the domains of 
the service offerings used by domain with path [%s] due to [%s]. Returning an 
empty "
                       + "list of domains.", domainPath, e.getMessage()));
               if (s_logger.isDebugEnabled()) {
                   s_logger.debug(String.format("Failed to retrieve the domains 
of the service offerings used by domain with path [%s]. Returning an empty "
                           + "list of domains.", domainPath), e);
               }
   ```



##########
engine/schema/src/main/java/com/cloud/network/dao/NetworkDomainDaoImpl.java:
##########
@@ -71,4 +92,34 @@ public List<Long> listNetworkIdsByDomain(long domainId) {
         }
         return networkIdsToReturn;
     }
+
+    @Override
+    public Map<Long, List<String>> 
listDomainsOfSharedNetworksUsedByDomainPath(String domainPath) {
+        logger.debug(String.format("Retrieving the domains of the shared 
networks with subdomain access used by domain with path [%s].", domainPath));
+
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        try (PreparedStatement pstmt = 
txn.prepareStatement(LIST_DOMAINS_OF_SHARED_NETWORKS_USED_BY_DOMAIN_PATH)) {
+            Map<Long, List<String>> domainsOfSharedNetworksUsedByDomainPath = 
new HashMap<>();
+
+            String domainSearch = domainPath.concat("%");
+            pstmt.setString(1, domainSearch);
+            pstmt.setString(2, domainSearch);
+
+            try (ResultSet rs = pstmt.executeQuery()) {
+                while (rs.next()) {
+                    Long domainId = rs.getLong(1);
+                    List<String> vmUuidsAndNetworkUuids = 
Arrays.asList(rs.getString(2).split(","));
+
+                    domainsOfSharedNetworksUsedByDomainPath.put(domainId, 
vmUuidsAndNetworkUuids);
+                }
+            }
+
+            return domainsOfSharedNetworksUsedByDomainPath;
+        } catch (SQLException e) {
+            logger.error(String.format("Failed to retrieve the domains of the 
shared networks with subdomain access used by domain with path [%s] due to 
[%s]. Returning an empty "
+                    + "list of domains.", domainPath, e.getMessage()), e);

Review Comment:
   ```suggestion
               logger.error(String.format("Failed to retrieve the domains of 
the shared networks with subdomain access used by domain with path [%s] due to 
[%s]. Returning an empty "
                       + "list of domains.", domainPath, e.getMessage()));
               if (logger.isDebugEnabled()) {
                   logger.debug(String.format("Failed to retrieve the domains 
of the shared networks with subdomain access used by domain with path [%s]. 
Returning an empty "
                           + "list of domains.", domainPath), e);
               }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to