From: <jt...@hy...> - 2007-09-20 21:46:54
|
Author: jtravis Date: 2007-09-20 14:46:48 -0700 (Thu, 20 Sep 2007) New Revision: 5974 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=5974 Modified: trunk/src/org/hyperic/hq/appdef/server/session/PlatformManagerEJBImpl.java trunk/src/org/hyperic/hq/appdef/server/session/ServerManagerEJBImpl.java Log: Audit platform deletion Modified: trunk/src/org/hyperic/hq/appdef/server/session/PlatformManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/appdef/server/session/PlatformManagerEJBImpl.java 2007-09-20 21:37:23 UTC (rev 5973) +++ trunk/src/org/hyperic/hq/appdef/server/session/PlatformManagerEJBImpl.java 2007-09-20 21:46:48 UTC (rev 5974) @@ -73,6 +73,10 @@ import org.hyperic.hq.appdef.AppService; import org.hyperic.hq.appdef.ConfigResponseDB; import org.hyperic.hq.appdef.Ip; +import org.hyperic.hq.authz.server.session.AuthzSubject; +import org.hyperic.hq.authz.server.session.AuthzSubjectManagerEJBImpl; +import org.hyperic.hq.authz.server.session.Resource; +import org.hyperic.hq.authz.server.session.ResourceManagerEJBImpl; import org.hyperic.hq.authz.shared.AuthzConstants; import org.hyperic.hq.authz.shared.AuthzSubjectValue; import org.hyperic.hq.authz.shared.PermissionException; @@ -80,6 +84,9 @@ import org.hyperic.hq.common.ApplicationException; import org.hyperic.hq.common.SystemException; import org.hyperic.hq.common.VetoException; +import org.hyperic.hq.common.server.session.Audit; +import org.hyperic.hq.common.server.session.AuditManagerEJBImpl; +import org.hyperic.hq.common.server.session.ResourceAudit; import org.hyperic.hq.common.shared.ProductProperties; import org.hyperic.hq.product.PlatformTypeInfo; import org.hyperic.util.pager.PageControl; @@ -270,12 +277,21 @@ throws RemoveException, PermissionException, PlatformNotFoundException, VetoException { + AppdefEntityID aeid = platform.getEntityId(); + Resource r = ResourceManagerEJBImpl.getOne().findResource(aeid); + AuthzSubject platPojo = + AuthzSubjectManagerEJBImpl.getOne().findSubjectById(subject.getId()); + Audit audit = ResourceAudit.deleteResource(r, platPojo, 0, 0); + boolean pushed = false; + try { + AuditManagerEJBImpl.getOne().pushContainer(audit); + pushed = true; + checkRemovePermission(subject, platform.getEntityId()); // keep the configresponseId so we can remove it later Integer cid = platform.getConfigResponseId(); - AppdefEntityID aeid = platform.getEntityId(); ServerManagerLocal srvMgr = getServerMgrLocal(); // Server manager will update the collection, so we need to copy @@ -291,7 +307,7 @@ } // now remove the resource for the platform - removeAuthzResource(subject, aeid); + removeAuthzResource(subject, aeid, false); getPlatformDAO().remove(platform); @@ -318,6 +334,9 @@ _log.debug("Error while removing Platform"); rollback(); throw e; + } finally { + if (pushed) + AuditManagerEJBImpl.getOne().popContainer(false); } } Modified: trunk/src/org/hyperic/hq/appdef/server/session/ServerManagerEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/appdef/server/session/ServerManagerEJBImpl.java 2007-09-20 21:37:23 UTC (rev 5973) +++ trunk/src/org/hyperic/hq/appdef/server/session/ServerManagerEJBImpl.java 2007-09-20 21:46:48 UTC (rev 5974) @@ -265,12 +265,11 @@ throws ServerNotFoundException, RemoveException, PermissionException, VetoException { - Server server; - try { - server = getServerDAO().findById(id); - } catch (ObjectNotFoundException e) { + Server server = getServerDAO().get(id); + + if (server == null) throw new ServerNotFoundException(id); - } + removeServer(subject, server); } |