From: <cl...@hy...> - 2008-10-23 21:25:13
|
Author: clee Date: 2008-10-23 14:25:06 -0700 (Thu, 23 Oct 2008) New Revision: 11581 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=11581 Modified: trunk/src/org/hyperic/hq/appdef/server/session/ResourceTreeGenerator.java trunk/src/org/hyperic/hq/appdef/server/session/ServerManagerEJBImpl.java trunk/src/org/hyperic/hq/appdef/shared/resourceTree/PlatformNode.java trunk/src/org/hyperic/hq/appdef/shared/resourceTree/ServerNode.java Log: Move to use Server in ServerNode as well Modified: trunk/src/org/hyperic/hq/appdef/server/session/ResourceTreeGenerator.java =================================================================== --- trunk/src/org/hyperic/hq/appdef/server/session/ResourceTreeGenerator.java 2008-10-23 21:22:39 UTC (rev 11580) +++ trunk/src/org/hyperic/hq/appdef/server/session/ResourceTreeGenerator.java 2008-10-23 21:25:06 UTC (rev 11581) @@ -25,10 +25,10 @@ package org.hyperic.hq.appdef.server.session; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.List; import org.hyperic.hq.appdef.shared.AppdefEntityConstants; import org.hyperic.hq.appdef.shared.AppdefEntityID; @@ -172,18 +172,14 @@ private void addFromServer(Integer id, int direction, ResourceTree tree) throws PermissionException, AppdefEntityNotFoundException { - ServerValue val; - try { AppdefEntityValue aeval = new AppdefEntityValue( AppdefEntityID.newServerID(id), _subject); - val = (ServerValue) aeval.getResourceValue(); + traverseServer((Server) aeval.getResourcePOJO(), direction, tree); } catch(PermissionException exc){ throw new PermissionException("Failed to find server " + id + ": permission denied"); } - - traverseServer(val, direction, tree); } private void addFromService(Integer id, int direction, ResourceTree tree) @@ -229,33 +225,20 @@ dnPlats.put(platformID, res); } - if((direction & GO_UP) != 0 && - !upPlats.contains(platformID)) + if ((direction & GO_UP) != 0 && !upPlats.contains(platformID)) { - List servers; - upPlats.add(platform.getId()); - try { - servers = ServerManagerEJBImpl.getOne().getServersByPlatform( - _subject, platformID, true, null); - } catch(AppdefEntityNotFoundException exc){ - throw new SystemException("Internal inconsistancy: " + - "could not find servers for " + - "platform '" + platform + "'"); - } catch(PermissionException exc){ - throw new SystemException("Failed to get servers for " + - "platform " + platformID + - ": permission denied"); - } + Collection servers = ServerManagerEJBImpl.getOne() + .getViewableServers(_subject, platform); for (Iterator i = servers.iterator(); i.hasNext();) { - traverseServer((ServerValue) i.next(), GO_UP, tree); + traverseServer((Server) i.next(), GO_UP, tree); } } return res; } - private ServerNode traverseServer(ServerValue server, int direction, + private ServerNode traverseServer(Server server, int direction, ResourceTree tree) throws PermissionException { @@ -293,7 +276,7 @@ if ((direction & GO_UP) != 0 && !upServers.contains(serverID)) { - List services; + Collection services; upServers.add(serverID); try { @@ -326,12 +309,12 @@ serviceID = service.getId(); if((res = (ServiceNode)dnServices.get(serviceID)) == null){ ServerNode serverNode; - ServerValue server; AppdefEntityValue aeval = new AppdefEntityValue(service.getServer().getEntityId(), _subject); try { - server = (ServerValue) aeval.getResourceValue(); + serverNode = traverseServer((Server) aeval.getResourcePOJO(), + GO_DOWN, tree); } catch(AppdefEntityNotFoundException exc){ throw new SystemException("Internal inconsistancy: " + "could not find server " + @@ -346,14 +329,13 @@ "Permission denied"); } - serverNode = traverseServer(server, GO_DOWN, tree); res = serverNode.addService(service); dnServices.put(serviceID, res); } if ((direction & GO_UP) != 0 && !upServices.contains(service.getId())) { - List apps; + Collection apps; upServices.add(service.getId()); try { @@ -380,7 +362,7 @@ throws PermissionException { ApplicationNode appNode; - List services; + Collection services; if(dnApps.contains(app.getId())) return; Modified: trunk/src/org/hyperic/hq/appdef/server/session/ServerManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/appdef/server/session/ServerManagerEJBImpl.java 2008-10-23 21:22:39 UTC (rev 11580) +++ trunk/src/org/hyperic/hq/appdef/server/session/ServerManagerEJBImpl.java 2008-10-23 21:25:06 UTC (rev 11581) @@ -838,6 +838,14 @@ } return servers; } + + /** + * @ejb:interface-method + */ + public Collection getViewableServers(AuthzSubject subject, + Platform platform) { + return filterViewableServers(platform.getServers(), subject); + } private Collection getServersByPlatformImpl( AuthzSubject subject, Integer platId, Modified: trunk/src/org/hyperic/hq/appdef/shared/resourceTree/PlatformNode.java =================================================================== --- trunk/src/org/hyperic/hq/appdef/shared/resourceTree/PlatformNode.java 2008-10-23 21:22:39 UTC (rev 11580) +++ trunk/src/org/hyperic/hq/appdef/shared/resourceTree/PlatformNode.java 2008-10-23 21:25:06 UTC (rev 11581) @@ -30,7 +30,7 @@ import java.util.List; import org.hyperic.hq.appdef.server.session.Platform; -import org.hyperic.hq.appdef.shared.ServerValue; +import org.hyperic.hq.appdef.server.session.Server; public class PlatformNode implements java.io.Serializable @@ -51,7 +51,7 @@ return this.platform; } - public ServerNode addServer(ServerValue server){ + public ServerNode addServer(Server server){ ServerNode node; node = new ServerNode(this.tree, this, server); Modified: trunk/src/org/hyperic/hq/appdef/shared/resourceTree/ServerNode.java =================================================================== --- trunk/src/org/hyperic/hq/appdef/shared/resourceTree/ServerNode.java 2008-10-23 21:22:39 UTC (rev 11580) +++ trunk/src/org/hyperic/hq/appdef/shared/resourceTree/ServerNode.java 2008-10-23 21:25:06 UTC (rev 11581) @@ -29,19 +29,18 @@ import java.util.Iterator; import java.util.List; +import org.hyperic.hq.appdef.server.session.Server; import org.hyperic.hq.appdef.server.session.Service; -import org.hyperic.hq.appdef.shared.ServerValue; public class ServerNode implements java.io.Serializable { private ResourceTree tree; private PlatformNode ownerPlatform; - private ServerValue server; + private Server server; private ArrayList services; - ServerNode(ResourceTree tree, PlatformNode ownerPlatform, - ServerValue server) + ServerNode(ResourceTree tree, PlatformNode ownerPlatform, Server server) { this.tree = tree; this.ownerPlatform = ownerPlatform; @@ -49,7 +48,7 @@ this.services = new ArrayList(); } - public ServerValue getServer(){ + public Server getServer(){ return this.server; } |