From: <sc...@hy...> - 2009-03-17 22:58:19
|
Author: scottmf Date: 2009-03-17 15:58:07 -0700 (Tue, 17 Mar 2009) New Revision: 12795 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=12795 Modified: trunk/src/org/hyperic/hq/appdef/server/session/AIQSynchronizer.java trunk/src/org/hyperic/hq/appdef/server/session/AIQueueManagerEJBImpl.java trunk/src/org/hyperic/hq/dao/AIPlatformDAO.java Log: changed AIPlatformDAO.findByFQDN() to return an AIPlatfrom instead of a Collection since there is a unique db constraint on fqdn. Added an abstraction method private AIPlatform getAIPlatformByPlatformID(Integer platformID) in order to access the pojo instead of the valueobject Modified: trunk/src/org/hyperic/hq/appdef/server/session/AIQSynchronizer.java =================================================================== --- trunk/src/org/hyperic/hq/appdef/server/session/AIQSynchronizer.java 2009-03-17 22:51:36 UTC (rev 12794) +++ trunk/src/org/hyperic/hq/appdef/server/session/AIQSynchronizer.java 2009-03-17 22:58:07 UTC (rev 12795) @@ -127,23 +127,14 @@ AIPlatform aiPlatform; String certdn = aiPlatformValue.getCertdn(); String fqdn = aiPlatformValue.getFqdn(); - Collection fqdnMatches; // Try FQDN first - fqdnMatches = aiPlatformLH.findByFQDN(fqdn); + AIPlatform fqdnMatch = aiPlatformLH.findByFQDN(fqdn); - if (fqdnMatches.size() != 1) { + if (fqdnMatch == null) { aiPlatform = aiPlatformLH.findByCertDN(certdn); - if (aiPlatform == null) { - if (fqdnMatches.size() > 1) { - _log.warn("Multiple platforms matched FQDN: " + - fqdn + " [" + fqdnMatches + "]"); - } - return null; - } return aiPlatform; + } else { + return fqdnMatch; } - - Iterator i = fqdnMatches.iterator(); - return (AIPlatform) i.next(); } } Modified: trunk/src/org/hyperic/hq/appdef/server/session/AIQueueManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/appdef/server/session/AIQueueManagerEJBImpl.java 2009-03-17 22:51:36 UTC (rev 12794) +++ trunk/src/org/hyperic/hq/appdef/server/session/AIQueueManagerEJBImpl.java 2009-03-17 22:58:07 UTC (rev 12795) @@ -337,17 +337,9 @@ AIPlatformValue aiplatformValue = null; // XXX Do authz check - Collection aiplatforms = getAIPlatformDAO().findByFQDN(fqdn); + AIPlatform aiPlatform = getAIPlatformDAO().findByFQDN(fqdn); + aiplatformValue = aiPlatform.getAIPlatformValue(); - Iterator i = aiplatforms.iterator(); - while (i.hasNext()) { - if (aiplatform != null) { - throw new SystemException("Multiple platforms matched fqdn."); - } - aiplatform = (AIPlatform) i.next(); - aiplatformValue = aiplatform.getAIPlatformValue(); - } - if (aiplatformValue == null) { return null; } @@ -681,7 +673,11 @@ * @ejb:interface-method */ public AIPlatformValue getAIPlatformByPlatformID(AuthzSubject subject, - Integer platformID) + Integer platformID) { + return getAIPlatformByPlatformID(platformID).getAIPlatformValue(); + } + + private AIPlatform getAIPlatformByPlatformID(Integer platformID) { Platform pLocal = getPlatformDAO().get(platformID); @@ -703,7 +699,7 @@ if (addrs.size() > 0) { AIPlatform aiplatform = ((AIIp) addrs.get(0)).getAIPlatform(); - return aiplatform.getAIPlatformValue(); + return aiplatform; } } @@ -723,7 +719,7 @@ List addrs = getAIIpDAO().findByAddress(address); if (addrs.size() > 0) { AIPlatform aiplatform = ((AIIp) addrs.get(0)).getAIPlatform(); - return aiplatform.getAIPlatformValue(); + return aiplatform; } } Modified: trunk/src/org/hyperic/hq/dao/AIPlatformDAO.java =================================================================== --- trunk/src/org/hyperic/hq/dao/AIPlatformDAO.java 2009-03-17 22:51:36 UTC (rev 12794) +++ trunk/src/org/hyperic/hq/dao/AIPlatformDAO.java 2009-03-17 22:58:07 UTC (rev 12795) @@ -137,12 +137,12 @@ return getSession().createQuery(sql).list(); } - public Collection findByFQDN(String fqdn) + public AIPlatform findByFQDN(String fqdn) { String sql="from AIPlatform where fqdn=?"; - return getSession().createQuery(sql) + return (AIPlatform)getSession().createQuery(sql) .setString(0, fqdn) - .list(); + .uniqueResult(); } public AIPlatform findByCertDN(String dn) |