|
From: <jt...@hy...> - 2007-03-27 23:45:47
|
Author: jtravis Date: 2007-03-27 15:45:44 -0800 (Tue, 27 Mar 2007) New Revision: 3933 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3933 Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/dispatcher.groovy Log: Cleanup some tabs. Start using categories to add methods to resource types Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy 2007-03-27 23:42:45 UTC (rev 3932) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/BaseController.groovy 2007-03-27 23:45:44 UTC (rev 3933) @@ -1,5 +1,7 @@ package org.hyperic.hq.ui.rendit +import org.hyperic.hq.ui.rendit.util.UserUtil + import org.apache.commons.lang.StringEscapeUtils import java.io.OutputStreamWriter @@ -8,8 +10,6 @@ import org.apache.commons.logging.LogFactory import org.hyperic.hq.authz.server.session.AuthzSubject -import org.hyperic.hq.ui.util.ContextUtils -import org.hyperic.hq.ui.util.RequestUtils import org.hyperic.hq.ui.rendit.helpers.LiveDataHelper import org.hyperic.hq.ui.rendit.helpers.ResourceHelper @@ -58,10 +58,7 @@ if (this.user != null) return this.user - def sessId = RequestUtils.getSessionId(invokeArgs.request) - def ctx = invokeArgs.request.session.servletContext - - this.user = ContextUtils.getAuthzBoss(ctx).getCurrentSubject(sessId) + this.user = UserUtil.getUser(invokeArgs) } // TODO: This all needs to be moved to a separate class Modified: trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/dispatcher.groovy =================================================================== --- trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/dispatcher.groovy 2007-03-27 23:42:45 UTC (rev 3932) +++ trunk/ui_plugins/rendit_sys/org/hyperic/hq/ui/rendit/dispatcher.groovy 2007-03-27 23:45:44 UTC (rev 3933) @@ -1,5 +1,11 @@ package org.hyperic.hq.ui.rendit +import org.hyperic.hq.ui.rendit.util.UserUtil +import org.hyperic.hq.ui.rendit.metaclass.AppdefLiveDataCategory +import org.hyperic.hq.ui.rendit.metaclass.CategoryInfo +import org.hyperic.hq.appdef.shared.AppdefEntityID + +import org.codehaus.groovy.runtime.InvokerHelper import org.apache.commons.logging.Log import org.apache.commons.logging.LogFactory @@ -9,6 +15,9 @@ * setting up the environment, and invoking the request. */ class Dispatcher { + private static final CATEGORIES = [ + AppdefLiveDataCategory + ] private Log log = LogFactory.getLog(Dispatcher.class); private String controllerName @@ -60,23 +69,32 @@ def loader = this.class.classLoader loader.addURL(appDir.toURL()) def controller = Class.forName(controllerName, true, - loader).newInstance() + loader).newInstance() action = path[2] - controller.setAction(action) - controller.setControllerName(path[1]) + controller.setAction(action) + controller.setControllerName(path[1]) controller.setPluginDir(invokeArgs.pluginDir) - controller.setInvokeArgs(invokeArgs) + controller.setInvokeArgs(invokeArgs) def runner = controller."$action" if (runner == null) - throw new IllegalArgumentException("Unknown action [$action]") + throw new IllegalArgumentException("Unknown action [$action]") - def start = System.currentTimeMillis() - runner(invokeArgs.request.parameterMap) - log.info "Executed $controllerName:$action in " + - "${System.currentTimeMillis() - start} ms" - return true + def start = System.currentTimeMillis() + + try { + CategoryInfo.setUser(UserUtil.getUser(invokeArgs)) + use (*CATEGORIES) { + runner(invokeArgs.request.parameterMap) + } + } finally { + CategoryInfo.setUser(null) + } + + log.info "Executed $controllerName:$action in " + + "${System.currentTimeMillis() - start} ms" + return true } } |