modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java | 5 modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/perspectives/PerspectiveUIBean.java | 4 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/entitlement/EntitlementManagerBean.java | 118 -- modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/entitlement/EntitlementManagerLocal.java | 29 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/Extension.java | 92 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/MenuItem.java | 90 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PageLink.java | 48 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveException.java | 40 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveManagerBean.java | 477 --------- modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveManagerHelper.java | 42 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveTarget.java | 108 -- modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/RenderedExtension.java | 53 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/Tab.java | 84 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/AbstractGlobalActivator.java | 33 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/AbstractResourceOrGroupActivator.java | 33 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/Activator.java | 37 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ActivatorHelper.java | 269 ----- modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/FacetActivator.java | 39 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/GlobalPermissionActivator.java | 39 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/InventoryActivator.java | 74 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/LicenseFeature.java | 26 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/LicenseFeatureActivator.java | 40 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ResourceConditionSet.java | 85 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ResourcePermissionActivator.java | 39 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ResourceTypeActivator.java | 82 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/SuperuserActivator.java | 34 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/TraitActivator.java | 48 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/AbstractResourceOrGroupActivationContext.java | 54 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ActivationContext.java | 30 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ActivationContextScope.java | 35 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/GlobalActivationContext.java | 87 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/GroupActivationContext.java | 98 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ResourceActivationContext.java | 99 - modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java | 4 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/entitlement/EntitlementPluginValidator.java | 37 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/entitlement/EntitlementServerPluginContainer.java | 50 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/entitlement/EntitlementServerPluginManager.java | 51 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectivePluginValidator.java | 30 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginContainer.java | 50 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginManager.java | 268 ----- modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/metadata/PerspectivePluginMetadataManager.java | 513 ---------- modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java | 6 modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java | 4 43 files changed, 4 insertions(+), 3480 deletions(-)
New commits: commit c206f1cfb90856b4fc2c53060a87dc8b8a7992b1 Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 5 14:23:57 2012 -0400
remove Seam
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java index 3a266e8..bd15f35 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/resource/ResourceUIBean.java @@ -46,7 +46,6 @@ import org.rhq.enterprise.gui.util.EnterpriseFacesContextUtility; import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; import org.rhq.enterprise.server.measurement.AvailabilityManagerLocal; import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal; -import org.rhq.enterprise.server.perspective.Tab; import org.rhq.enterprise.server.resource.ResourceManagerLocal; import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal; import org.rhq.enterprise.server.util.LookupUtil; @@ -70,7 +69,7 @@ public class ResourceUIBean { private Resource parent; private ResourcePermission permissions; private ResourceFacets facets; - private List<Tab> tabs; + private List<?> tabs; private ResourceError invalidPluginConfigurationError; private ResourceAvailabilitySummary availabilitySummary; private AvailabilityType availabilityType; @@ -185,7 +184,7 @@ public class ResourceUIBean { return this.facets; }
- public List<Tab> getTabs() { + public List<?> getTabs() { return this.tabs; }
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/perspectives/PerspectiveUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/perspectives/PerspectiveUIBean.java index e8a38ed..d7d19fc 100644 --- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/perspectives/PerspectiveUIBean.java +++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/perspectives/PerspectiveUIBean.java @@ -43,9 +43,9 @@ public class PerspectiveUIBean {
//PerspectiveManagerLocal perspectiveManager = LookupUtil.getPerspectiveManager();
- public List<org.rhq.enterprise.server.perspective.MenuItem> getCoreMenu() { + public List<?> getCoreMenu() { Subject subject = EnterpriseFacesContextUtility.getSubject(); - List<org.rhq.enterprise.server.perspective.MenuItem> result = null; + List<?> result = null;
try { //result = perspectiveManager.getMenu(subject); diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/Extension.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/Extension.java deleted file mode 100644 index 67ecbd1..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/Extension.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective; - -import java.util.ArrayList; -import java.util.List; - -import org.rhq.enterprise.server.perspective.activator.Activator; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.ExtensionType; - -/** - * A GUI extension defined by the Perspective subsystem. Currently there are four types of extensions - - * menu item, tab, global task, and Resource task. - * - * @author Ian Springer - */ -public abstract class Extension { - protected String perspectiveName; - protected String name; - protected String url; - protected boolean debugMode; - private List<Activator<?>> activators; - - public Extension(ExtensionType rawExtension, String perspectiveName, String url) { - this.perspectiveName = perspectiveName; - this.name = rawExtension.getName(); - this.url = url; - this.activators = new ArrayList<Activator<?>>(); - this.debugMode = false; - } - - public String getPerspectiveName() { - return perspectiveName; - } - - public String getName() { - return name; - } - - public String getUrl() { - return url; - } - - public boolean isDebugMode() { - return debugMode; - } - - public List<Activator<?>> getActivators() { - return activators; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - Extension extension = (Extension) o; - - if (!name.equals(extension.name)) - return false; - - return true; - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - @Override - public String toString() { - return this.getClass().getSimpleName() + "[name=" + this.name + ", url=" + this.url + "]"; - } -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/MenuItem.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/MenuItem.java deleted file mode 100644 index 5d7758a..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/MenuItem.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2009 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.jetbrains.annotations.NotNull; - -import org.rhq.enterprise.server.perspective.activator.ActivatorHelper; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.MenuItemFeatureType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.MenuItemType; - -/** - * An item in the RHQ GUI's menu. - */ -public class MenuItem extends RenderedExtension implements Serializable, Cloneable { - private static final long serialVersionUID = 1L; - - private MenuItemFeatureType feature; - private boolean newWindow; - private boolean addBreak; - private List<MenuItem> children; - - public MenuItem(MenuItemType rawMenuItem, String perspectiveName) { - super(rawMenuItem, perspectiveName, rawMenuItem.getUrl()); - this.feature = rawMenuItem.getFeature(); - this.newWindow = rawMenuItem.isNewWindow(); - this.addBreak = rawMenuItem.isAddBreak(); - this.children = new ArrayList<MenuItem>(); - this.debugMode = ActivatorHelper.initGlobalActivators(rawMenuItem.getActivators(), getActivators()); - } - - public MenuItemFeatureType getFeature() { - return feature; - } - - public boolean isNewWindow() { - return newWindow; - } - - public boolean isAddBreak() { - return addBreak; - } - - @NotNull - public List<MenuItem> getChildren() { - return children; - } - - public void setChildren(List<MenuItem> children) { - this.children = (children != null) ? children : new ArrayList<MenuItem>(); - } - - public boolean isMenuGroup() { - return (null != this.children && this.children.size() > 0); - } - - public boolean isGraphic() { - String displayName = getDisplayName(); - return (null == displayName || "".equals(displayName.trim())); - } - - /** - * Note that this will clone the children list but not the child MenuItem objects themselves. - * @see java.lang.Object#clone() - */ - @Override - protected Object clone() throws CloneNotSupportedException { - return super.clone(); - } - -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PageLink.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PageLink.java deleted file mode 100644 index 4454555..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PageLink.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2009 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective; - -import java.io.Serializable; - -import org.rhq.enterprise.server.perspective.activator.ActivatorHelper; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.PageLinkType; - -/** - * An item in the RHQ GUI's menu. - */ -public class PageLink extends Extension implements Serializable, Cloneable { - private static final long serialVersionUID = 1L; - - private String pageName; - - public PageLink(PageLinkType rawPageLink, String perspectiveName, String pageName, String url) { - super(rawPageLink, perspectiveName, url); - - this.pageName = pageName; - this.debugMode = ActivatorHelper.initGlobalActivators(rawPageLink.getActivators(), getActivators()); - } - - /** - * @return the pageName - */ - public String getPageName() { - return pageName; - } - -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveException.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveException.java deleted file mode 100644 index b238b44..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective; - -public class PerspectiveException extends Exception { - - private static final long serialVersionUID = 1L; - - public PerspectiveException() { - } - - public PerspectiveException(String message) { - super(message); - } - - public PerspectiveException(Throwable cause) { - super(cause); - } - - public PerspectiveException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveManagerBean.java deleted file mode 100644 index 1b1f5fb..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveManagerBean.java +++ /dev/null @@ -1,477 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective; - -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jetbrains.annotations.NotNull; - -import org.rhq.core.domain.auth.Subject; -import org.rhq.core.domain.cloud.Server; -import org.rhq.core.domain.resource.Resource; -import org.rhq.enterprise.server.auth.SubjectManagerLocal; -import org.rhq.enterprise.server.cloud.instance.ServerManagerLocal; -import org.rhq.enterprise.server.perspective.activator.Activator; -import org.rhq.enterprise.server.perspective.activator.context.ActivationContext; -import org.rhq.enterprise.server.perspective.activator.context.ActivationContextScope; -import org.rhq.enterprise.server.perspective.activator.context.GlobalActivationContext; -import org.rhq.enterprise.server.perspective.activator.context.ResourceActivationContext; -import org.rhq.enterprise.server.plugin.pc.perspective.metadata.PerspectivePluginMetadataManager; - -/** - * @author Jay Shaughnessy - * @author Ian Springer - */ -//@Stateless -public class PerspectiveManagerBean {//implements PerspectiveManagerLocal { - - // Map of sessionId to cached menu entry. The cached menu is re-used for the same sessionId. - // This should more appropriately use Subject as the key, but since Subject equality is - // based on username, it's not quite appropriate. - // The cache is cleaned anytime there is a new entry. - static private final Map<Integer, CacheEntry> CACHE = new HashMap<Integer, CacheEntry>(); - - static private Server server = null; - - private final Log log = LogFactory.getLog(PerspectiveManagerBean.class); - - //@EJB - private ServerManagerLocal serverManager; - - //@EJB - private SubjectManagerLocal subjectManager; - - /* (non-Javadoc) - * @see org.rhq.enterprise.server.perspective.PerspectiveManagerLocal#getCoreMenu(org.rhq.core.domain.auth.Subject) - */ - public synchronized List<MenuItem> getMenu(Subject subject) throws PerspectiveException { - CacheEntry cacheEntry = getCacheEntry(subject); - List<MenuItem> menu = cacheEntry.getMenu(); - return menu; - } - - @NotNull - public List<Tab> getResourceTabs(Subject subject, Resource resource) { - // First get a cached copy of the tabs that has the global-scoped activators already applied in the context of - // the current Subject. - CacheEntry cacheEntry = getCacheEntry(subject); - List<Tab> tabs = cacheEntry.getTabs(); - - // Now apply the Resource-scoped activators in the context of the current Resource. - ResourceActivationContext context = new ResourceActivationContext(subject, resource); - EnumSet<ActivationContextScope> scopes = EnumSet.of(ActivationContextScope.RESOURCE_OR_GROUP); - List<Tab> filteredTabs = applyActivatorsToTabs(context, scopes, tabs); - - return filteredTabs; - } - - public String getPageLink(Subject subject, String pageName, String linkName, String defaultValue) { - CacheEntry cacheEntry = getCacheEntry(subject); - List<PageLink> pageLinks = cacheEntry.getPageLinks(); - - String result = defaultValue; - - for (PageLink pageLink : pageLinks) { - if (pageLink.getPageName().equals(pageName) && pageLink.getName().equals(linkName)) { - result = pageLink.getUrl(); - break; - } - } - - return result; - } - - /** - * Recursively applies activators, based on the specified contexts, to a menu, and returns a - * filtered, deep copy of the menu. The supplied <menu> is unmodified. - */ - private List<MenuItem> applyActivatorsToMenu(ActivationContext context, EnumSet<ActivationContextScope> scopes, - List<MenuItem> menu) { - - List<MenuItem> filteredMenu = new ArrayList<MenuItem>(); - for (MenuItem menuItem : menu) { - if (isActive(context, scopes, menuItem)) { - MenuItem clone = null; - try { - clone = (MenuItem) menuItem.clone(); - } catch (CloneNotSupportedException e) { - log.error("Invalid Clone - This should not happen: " + e); - } - - filteredMenu.add(clone); - // Recurse... - List<MenuItem> filteredChildren = applyActivatorsToMenu(context, scopes, clone.getChildren()); - clone.setChildren(filteredChildren); - } - } - return filteredMenu; - } - - /** - * Recursively applies activators, based on the specified contexts, to a list of tabs, and returns a - * filtered, deep copy of the list. The supplied <tabs> are unmodified. - */ - private List<Tab> applyActivatorsToTabs(ActivationContext context, EnumSet<ActivationContextScope> scopes, - List<Tab> tabs) { - - List<Tab> filteredTabs = new ArrayList<Tab>(); - for (Tab tab : tabs) { - if (isActive(context, scopes, tab)) { - Tab clone = null; - try { - clone = (Tab) tab.clone(); - } catch (CloneNotSupportedException e) { - log.error("Invalid Clone - This should not happen: " + e); - } - filteredTabs.add(clone); - // Recurse... - List<Tab> filteredChildren = applyActivatorsToTabs(context, scopes, clone.getChildren()); - clone.setChildren(filteredChildren); - } - } - return filteredTabs; - } - - /** - * Applies activators, based on the specified contexts, to a list of PageLinks, and returns a - * filtered list. The supplied <List> is unmodified. - */ - private List<PageLink> applyActivatorsToPageLinks(ActivationContext context, - EnumSet<ActivationContextScope> scopes, List<PageLink> pageLinks) { - - List<PageLink> filteredPageLinks = new ArrayList<PageLink>(); - for (PageLink pageLink : pageLinks) { - if (isActive(context, scopes, pageLink)) { - filteredPageLinks.add(pageLink); - } - } - - return filteredPageLinks; - } - - @SuppressWarnings("unchecked") - private boolean isActive(ActivationContext context, EnumSet<ActivationContextScope> scopes, Extension extension) { - List<Activator<?>> activators = extension.getActivators(); - for (Activator activator : activators) { - if (scopes.contains(activator.getScope()) && !activator.isActive(context)) { - return false; - } - } - return true; - } - - private CacheEntry getCacheEntry(Subject subject) { - Integer sessionId = subject.getSessionId(); - CacheEntry cacheEntry; - synchronized (CACHE) { - cacheEntry = CACHE.get(sessionId); - } - long metadataLastModifiedTime = getPluginMetadataManager().getLastModifiedTime(); - if (cacheEntry == null || cacheEntry.getMetadataLastModifiedTime() < metadataLastModifiedTime) { - // Take this opportunity to clean expired sessions from the cache. - cleanCache(); - - GlobalActivationContext context = new GlobalActivationContext(subject); - EnumSet<ActivationContextScope> scopes = EnumSet.of(ActivationContextScope.GLOBAL); - - List<MenuItem> baseMenu = getPluginMetadataManager().getMenu(); - List<MenuItem> filteredMenu = applyActivatorsToMenu(context, scopes, baseMenu); - - List<Tab> baseTabs = getPluginMetadataManager().getResourceTabs(); - List<Tab> filteredTabs = applyActivatorsToTabs(context, scopes, baseTabs); - - List<PageLink> basePageLinks = getPluginMetadataManager().getPageLinks(); - List<PageLink> filteredPageLinks = applyActivatorsToPageLinks(context, scopes, basePageLinks); - - cacheEntry = new CacheEntry(metadataLastModifiedTime, filteredMenu, filteredTabs, filteredPageLinks); - synchronized (CACHE) { - CACHE.put(sessionId, cacheEntry); - } - } - return cacheEntry; - } - - private PerspectivePluginMetadataManager getPluginMetadataManager() { - return PerspectiveManagerHelper.getPluginMetadataManager(); - } - - // TODO: Is there any sort of listener approach we could use to clear an individual cache entry - // for various events like: change to role defs, change to inventory? Perhaps even a manual or - // automated refresh for the session? - private void cleanCache() { - Subject subject; - - synchronized (CACHE) { - Iterator<Integer> iterator = CACHE.keySet().iterator(); // so we can use iterator.remove and avoid concurrent-mod-exception - while (iterator.hasNext()) { - Integer sessionId = iterator.next(); - try { - subject = subjectManager.getSubjectBySessionId(sessionId); - if (null == subject) { - log.debug("Removing perspective cache entry for session. " + sessionId); - iterator.remove(); - } - } catch (Exception e) { - log.debug("Removing perspective cache entry for session: " + sessionId); - iterator.remove(); - } - } - } - } - - // TODO: remove this debug code - @SuppressWarnings("unused") - private void printMenu(List<MenuItem> menu, String indent) { - if (null == menu) - return; - - for (MenuItem menuItem : menu) { - System.out.println(indent + menuItem.getName()); - printMenu(menuItem.getChildren(), indent + ".."); - } - } - - private static class CacheEntry { - private long metadataLastModifiedTime; - - // This is a copy of the base menu that has had all global-scoped activators already applied to it. - // We cache it because the variables used by the global activators do not change very often. - private List<MenuItem> menu; - - // This is a copy of the base tabs that has had all global-scoped activators already applied to it. - // We cache it because the variables used by the global activators do not change very often. - private List<Tab> tabs; - - // This is a list of references into the base pageLinks that has had all global-scoped activators - // already applied to it. We cache it because the variables used by the global activators do not - // change very often. - private List<PageLink> pageLinks; - - public CacheEntry(long metadataLastModifiedTime, List<MenuItem> menu, List<Tab> tabs, List<PageLink> pageLinks) { - this.metadataLastModifiedTime = metadataLastModifiedTime; - this.menu = menu; - this.tabs = tabs; - this.pageLinks = pageLinks; - } - - public long getMetadataLastModifiedTime() { - return metadataLastModifiedTime; - } - - public List<MenuItem> getMenu() { - return menu; - } - - public List<Tab> getTabs() { - return tabs; - } - - public List<PageLink> getPageLinks() { - return pageLinks; - } - } - - /** - * Given a targetUrlKey parameter value, as set in the extension, resolve that key into the targetUrl - * for the extension's content. - * - * @param key, a valid key - * @return the target url - * - */ - public String getUrlViaKey(int key) throws PerspectiveException { - try { - return getPluginMetadataManager().getUrlViaKey(key); - } catch (Exception e) { - throw new PerspectiveException("Failed to get URL for key: " + key, e); - } - } - - /* (non-Javadoc) - * @see org.rhq.enterprise.server.perspective.PerspectiveManagerLocal#getMenuUrl(org.rhq.core.domain.auth.Subject, java.lang.String) - */ - public String getMenuItemUrl(Subject subject, String menuItemName, boolean makeExplicit, boolean makeSecure) { - if (null == menuItemName) { - throw new IllegalArgumentException("Invalid menuItemName: null "); - } - - String result = null; - - try { - result = getMenuItemUrlByName(menuItemName, getMenu(subject)); - } catch (Exception e) { - throw new IllegalArgumentException("Invalid menuItemName: " + menuItemName, e); - } - - return (null == result) ? result : makeUrl(result, makeExplicit, makeSecure); - } - - private String getMenuItemUrlByName(String menuItemName, List<MenuItem> menuItems) { - if (null == menuItems) { - return null; - } - - String result = null; - - for (MenuItem menuItem : menuItems) { - String url = menuItem.getUrl(); - if (null != url && menuItemName.equals(menuItem.getName())) { - result = url; - break; - } else { - result = getMenuItemUrlByName(menuItemName, menuItem.getChildren()); - if (null != result) { - break; - } - } - } - - return result; - } - - /* (non-Javadoc) - * @see org.rhq.enterprise.server.perspective.PerspectiveManagerLocal#getResourceTabUrl(org.rhq.core.domain.auth.Subject, java.lang.String) - */ - public String getResourceTabUrl(Subject subject, String tabName, int resourceId, boolean makeExplicit, - boolean makeSecure) { - if (null == tabName) { - throw new IllegalArgumentException("Invalid tabName: null "); - } - - String result = null; - - try { - result = getResourceTabUrlByName(tabName, this.getPluginMetadataManager().getResourceTabs()); - } catch (Exception e) { - throw new IllegalArgumentException("Invalid tabName: " + tabName, e); - } - - return (null == result) ? result : makeUrl(result, makeExplicit, makeSecure); - } - - private String getResourceTabUrlByName(String tabName, List<Tab> tabs) { - if (null == tabs) { - return null; - } - - String result = null; - - for (Tab tab : tabs) { - String url = tab.getUrl(); - if (null != url && tabName.equals(tab.getName())) { - result = url; - break; - } else { - result = getResourceTabUrlByName(tabName, tab.getChildren()); - if (null != result) { - break; - } - } - } - - return result; - - } - - /* - * @see org.rhq.enterprise.server.perspective.PerspectiveManagerLocal#getRootUrl(org.rhq.core.domain.auth.Subject) - */ - public String getRootUrl(Subject subject, boolean makeExplicit, boolean makeSecure) { - return makeUrl("/", makeExplicit, makeSecure); - } - - /* - * @see org.rhq.enterprise.server.perspective.PerspectiveManagerLocal#getTargetUrl(org.rhq.core.domain.auth.Subject, org.rhq.enterprise.server.perspective.PerspectiveTarget, int, boolean, boolean) - */ - public String getTargetUrl(Subject subject, PerspectiveTarget target, int targetId, boolean makeExplicit, - boolean makeSecure) { - - return makeUrl(target.getTargetUrl(targetId), makeExplicit, makeSecure); - } - - /* - * @see org.rhq.enterprise.server.perspective.PerspectiveManagerLocal#getTargetUrls(org.rhq.core.domain.auth.Subject, org.rhq.enterprise.server.perspective.PerspectiveTarget, int[], boolean, boolean) - */ - public Map<Integer, String> getTargetUrls(Subject subject, PerspectiveTarget target, int[] targetIds, - boolean makeExplicit, boolean makeSecure) { - - Map<Integer, String> result = new HashMap<Integer, String>(targetIds.length); - - for (int targetId : targetIds) { - result.put(targetId, makeUrl(target.getTargetUrl(targetId), makeExplicit, makeSecure)); - } - - return result; - } - - /* - * @see org.rhq.enterprise.server.perspective.PerspectiveManagerLocal#getResourceTargetUrl(org.rhq.core.domain.auth.Subject, int, org.rhq.enterprise.server.perspective.PerspectiveTarget, int, boolean, boolean) - */ - public String getResourceTargetUrl(Subject subject, int resourceId, PerspectiveTarget target, int targetId, - boolean makeExplicit, boolean makeSecure) { - - return makeUrl(target.getResourceTargetUrl(resourceId, targetId), makeExplicit, makeSecure); - } - - /* - * @see org.rhq.enterprise.server.perspective.PerspectiveManagerLocal#getResourceTargetUrls(org.rhq.core.domain.auth.Subject, int, org.rhq.enterprise.server.perspective.PerspectiveTarget, int[], boolean, boolean) - */ - public Map<Integer, String> getResourceTargetUrls(Subject subject, int resourceId, PerspectiveTarget target, - int[] targetIds, boolean makeExplicit, boolean makeSecure) { - - Map<Integer, String> result = new HashMap<Integer, String>(targetIds.length); - - for (int targetId : targetIds) { - result.put(targetId, makeUrl(target.getResourceTargetUrl(resourceId, targetId), makeExplicit, makeSecure)); - } - - return result; - } - - /* (non-Javadoc) - * @see org.rhq.enterprise.server.perspective.PerspectiveManagerLocal#getTemplateTargetUrl(org.rhq.core.domain.auth.Subject, int, org.rhq.enterprise.server.perspective.PerspectiveTarget, int, boolean, boolean) - */ - public String getTemplateTargetUrl(Subject subject, int resourceId, PerspectiveTarget target, int targetId, - boolean makeExplicit, boolean makeSecure) { - - return makeUrl(target.getTemplateTargetUrl(resourceId, targetId), makeExplicit, makeSecure); - } - - private String makeUrl(String url, boolean makeExplicit, boolean makeSecure) { - if (null == url || !makeExplicit || url.startsWith("http")) { - return url; - } - - if (null == server) { - server = serverManager.getServer(); - } - - String protocol = (makeSecure) ? "https://" : "http://"; - int port = (makeSecure) ? server.getSecurePort() : server.getPort(); - String result = protocol + server.getAddress() + ":" + port + url; - return result; - } -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveManagerHelper.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveManagerHelper.java deleted file mode 100644 index bcc6ba0..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveManagerHelper.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.rhq.enterprise.server.perspective; - -import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer; -import org.rhq.enterprise.server.plugin.pc.ServerPluginServiceManagement; -import org.rhq.enterprise.server.plugin.pc.perspective.PerspectiveServerPluginContainer; -import org.rhq.enterprise.server.plugin.pc.perspective.PerspectiveServerPluginManager; -import org.rhq.enterprise.server.plugin.pc.perspective.metadata.PerspectivePluginMetadataManager; -import org.rhq.enterprise.server.util.LookupUtil; - -public class PerspectiveManagerHelper { - - public static PerspectiveServerPluginContainer getPluginContainer() { - PerspectiveServerPluginContainer pc; - - try { - ServerPluginServiceManagement mbean = LookupUtil.getServerPluginService(); - if (!mbean.isMasterPluginContainerStarted()) { - throw new IllegalStateException("The master plugin container is not started!"); - } - - MasterServerPluginContainer master = mbean.getMasterPluginContainer(); - pc = master.getPluginContainerByClass(PerspectiveServerPluginContainer.class); - } catch (IllegalStateException ise) { - throw ise; - } catch (Exception e) { - throw new IllegalStateException("Cannot obtain the Perspective plugin container!", e); - } - - if (pc == null) { - throw new IllegalStateException("Perspective plugin container is null!"); - } - - return pc; - } - - public static PerspectivePluginMetadataManager getPluginMetadataManager() { - PerspectiveServerPluginManager manager = (PerspectiveServerPluginManager) getPluginContainer() - .getPluginManager(); - return manager.getMetadataManager(); - } - -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveTarget.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveTarget.java deleted file mode 100644 index 0ea233b..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/PerspectiveTarget.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -package org.rhq.enterprise.server.perspective; - -/** - * @author jshaughnessy - */ -public enum PerspectiveTarget { - AGENT("/rhq/ha/viewAgent.xhtml?mode=view&agentId="), // - ALERT("/alerts/Alerts.do?mode=viewAlert&a=", true, false), // - ALERT_DEFINITION("/alerts/Config.do?mode=viewRoles&ad=", true, false), // - ALERT_TEMPLATE("/alerts/Config.do?mode=viewRoles&ad=", false, true), // - CONTENT_PROVIDER("/rhq/content/contentProvider.xhtml?mode=view&id="), // - GROUP_COMPATIBLE("/rhq/group/monitor/graphs.xhtml?category=COMPATIBLE&groupId="), // - GROUP_DEFINITION("/rhq/definition/group/view.xhtml?groupDefinitionId="), // - GROUP_MIXED("/rhq/group/inventory/view.xhtml?category=MIXED&groupId="), // - METRIC_TEMPLATE("/admin/platform/monitor/Config.do?mode=configure&id=", false, true), // - REPO("/rhq/content/repo.xhtml?mode=view&id="), // - RESOURCE("/rhq/resource/summary/summary.xhtml?id="), // - ROLE("/admin/role/RoleAdmin.do?mode=view&r="), // - SERVER("/rhq/ha/viewServer.xhtml?mode=view&serverId="), // - USER("/admin/user/UserAdmin.do?mode=view&u="); - - private final String baseUrl; - private final boolean isResourceTarget; - private final boolean isTemplateTarget; - - PerspectiveTarget(String baseUrl) { - this(baseUrl, false, false); - } - - private PerspectiveTarget(String baseUrl, boolean isResourceTarget, boolean isTemplateTarget) { - this.baseUrl = baseUrl; - this.isResourceTarget = isResourceTarget; - this.isTemplateTarget = isTemplateTarget; - } - - /** - * @param targetId The target id. For example, the group id. - * @return The url path for the target. - * @throws IllegalArgumentException If the PerspectiveTarget is resource qualified (requires a resource id). - */ - public String getTargetUrl(int targetId) { - if (this.isResourceTarget || this.isTemplateTarget) { - throw new IllegalArgumentException( - "This PerspectiveTarget requires resource or resource type information, use appropriate getter: " - + this); - } - - return this.baseUrl + targetId; - } - - /** - * @param resourceId The target's resource. For example, the resource on which the alert fired. - * @param targetId The resource target. For example, the alert for the specified resource. - * @return The url path for the resource qualified target. - * @throws IllegalArgumentException If the PerspectiveTarget is not resource qualified. - */ - public String getResourceTargetUrl(int resourceId, int targetId) { - if (!this.isResourceTarget) { - throw new IllegalArgumentException( - "This is not a resource qualified PerspectiveTarget. Use appropriate getter: " + this); - } - - return this.baseUrl + targetId + "&id=" + resourceId; - } - - /** - * @param resourceTypeId The target's resource type. For example, the resource type for the alert template. - * @param targetId The target. For example, the alert definition for the alert template. - * @return The url path for the template target. - * @throws IllegalArgumentException If the PerspectiveTarget is not a template target. - */ - public String getTemplateTargetUrl(int resourceTypeId, int targetId) { - if (!this.isTemplateTarget) { - throw new IllegalArgumentException("This is not a template PerspectiveTarget. Use appropriate getter: " - + this); - } - - return this.baseUrl + targetId + "&type=" + resourceTypeId; - } - - public boolean isResourceTarget() { - return isResourceTarget; - } - - public boolean isTemplateTarget() { - return isTemplateTarget; - } - -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/RenderedExtension.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/RenderedExtension.java deleted file mode 100644 index f21d0d5..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/RenderedExtension.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective; - -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.RenderedExtensionType; - -/** - * A GUI extension defined by the Perspective subsystem. Currently there are four types of extensions - - * menu item, tab, global task, and Resource task. - * - * @author Ian Springer - */ -public abstract class RenderedExtension extends Extension { - - private String displayName; - private String iconUrl; - - public RenderedExtension(RenderedExtensionType rawExtension, String perspectiveName, String url) { - super(rawExtension, perspectiveName, url); - this.displayName = rawExtension.getDisplayName(); - this.iconUrl = rawExtension.getIconUrl(); - } - - public String getDisplayName() { - return displayName; - } - - public String getIconUrl() { - return iconUrl; - } - - @Override - public String toString() { - return this.getClass().getSimpleName() + "[name=" + this.name + ", displayName=" + this.displayName + ", url=" - + this.url + ", iconUrl=" + this.iconUrl + "]"; - } -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/Tab.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/Tab.java deleted file mode 100644 index 4d833f8..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/Tab.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.jetbrains.annotations.NotNull; - -import org.rhq.enterprise.server.perspective.activator.ActivatorHelper; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.TabType; - -/** - * A tab in the Resource or Group view. - * - * @author Ian Springer - */ -public class Tab extends RenderedExtension implements Serializable, Cloneable { - private static final long serialVersionUID = 1L; - - private String name; - private String qualifiedName; - private List<Tab> children; - - public Tab(TabType rawTab, String perspectiveName) { - super(rawTab, perspectiveName, rawTab.getUrl()); - this.name = getSimpleName(rawTab.getName()); - this.qualifiedName = rawTab.getName(); - if (rawTab.getApplication() != null) { - this.url += "&tab=" + this.qualifiedName; - } - this.children = new ArrayList<Tab>(); - this.debugMode = ActivatorHelper.initResourceActivators(rawTab.getActivators(), getActivators()); - } - - @NotNull - public List<Tab> getChildren() { - return children; - } - - public void setChildren(List<Tab> children) { - this.children = (children != null) ? children : new ArrayList<Tab>(); - } - - public String getQualifiedName() { - return qualifiedName; - } - - public String getName() { - return name; - } - - private static String getSimpleName(String qualifiedName) { - int lastDotIndex = qualifiedName.lastIndexOf("."); - return qualifiedName.substring(lastDotIndex + 1); - } - - /** - * Note that this will clone the children list but not the child Tab objects themselves. - * @see java.lang.Object#clone() - */ - @Override - protected Object clone() throws CloneNotSupportedException { - return super.clone(); - } - -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/AbstractGlobalActivator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/AbstractGlobalActivator.java deleted file mode 100644 index 419c10a..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/AbstractGlobalActivator.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator; - -import org.rhq.enterprise.server.perspective.activator.context.ActivationContextScope; -import org.rhq.enterprise.server.perspective.activator.context.GlobalActivationContext; - -/** - * @author Ian Springer - */ -public abstract class AbstractGlobalActivator implements Activator<GlobalActivationContext> { - private static final long serialVersionUID = 1L; - - public ActivationContextScope getScope() { - return ActivationContextScope.GLOBAL; - } -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/AbstractResourceOrGroupActivator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/AbstractResourceOrGroupActivator.java deleted file mode 100644 index cb47d13..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/AbstractResourceOrGroupActivator.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator; - -import org.rhq.enterprise.server.perspective.activator.context.AbstractResourceOrGroupActivationContext; -import org.rhq.enterprise.server.perspective.activator.context.ActivationContextScope; - -/** - * @author Ian Springer - */ -public abstract class AbstractResourceOrGroupActivator implements Activator<AbstractResourceOrGroupActivationContext> { - private static final long serialVersionUID = 1L; - - public ActivationContextScope getScope() { - return ActivationContextScope.RESOURCE_OR_GROUP; - } -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/Activator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/Activator.java deleted file mode 100644 index b08dcad..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/Activator.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator; - -import java.io.Serializable; - -import org.rhq.enterprise.server.perspective.activator.context.ActivationContext; -import org.rhq.enterprise.server.perspective.activator.context.ActivationContextScope; - -/** - * @author Ian Springer - */ -public interface Activator<C extends ActivationContext> extends Serializable { - ActivationContextScope getScope(); - - /** - * @param context The context information required to process the activation conditions. - * @return true if all of the activation cnditions for this Activator have been met. Otherwise, false. - */ - boolean isActive(C context); -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ActivatorHelper.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ActivatorHelper.java deleted file mode 100644 index 3e36830..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ActivatorHelper.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -package org.rhq.enterprise.server.perspective.activator; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.rhq.core.domain.auth.Subject; -import org.rhq.core.domain.authz.Permission; -import org.rhq.core.domain.measurement.MeasurementDataTrait; -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceTypeFacet; -import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal; -import org.rhq.enterprise.server.util.LookupUtil; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.CommonActivatorsType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.DebugModeActivatorType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.FacetActivatorType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.GlobalActivatorsType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.GlobalPermissionActivatorType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.InventoryActivatorType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.LicenseFeatureActivatorType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.ResourceActivatorsType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.ResourcePermissionActivatorType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.ResourceType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.SuperuserActivatorType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.TraitActivatorType; - -public class ActivatorHelper { - - private static final Log LOG = LogFactory.getLog(ActivatorHelper.class); - - /** - * Test trait conditions against resources. Optionally, one or all resources must much all of the - * trait conditions. - * - * @param subject The current user - * @param traitMatchers The trait activator pattern matchers that must all be satisfied - * @param resources The resources whose trait values will be tested - * @param matchAll If true then all resources must pass, if false only one must pass - * @return true if, optionally, all or any resources satisfy the trait conditions - */ - public static boolean areTraitsSatisfied(Subject subject, Map<String, Matcher> traitMatchers, - Collection<Resource> resources, boolean matchAll) { - - // return true if there are no trait activators to satisfy - if (traitMatchers.isEmpty()) { - return true; - } - - MeasurementDataManagerLocal measurementDataManager = LookupUtil.getMeasurementDataManager(); - - for (Resource resource : resources) { - boolean traitsSatisfied = true; - List<MeasurementDataTrait> traits = measurementDataManager.findCurrentTraitsForResource(subject, resource - .getId(), null); - - int numTraitsTested = 0; - for (MeasurementDataTrait trait : traits) { - Matcher traitMatcher = traitMatchers.get(trait.getName()); - if (null != traitMatcher) { - ++numTraitsTested; - - traitMatcher.reset(trait.getValue()); - if (!traitMatcher.find()) { - traitsSatisfied = false; - break; - } - } - } - - if (traitsSatisfied) { - if (numTraitsTested != traitMatchers.size()) { - if (LOG.isDebugEnabled()) { - String error = "" // - + "Potential error in perspective descriptor." // - + " Not all trait activators matched trait for resource type: " + traitMatchers.keySet() // - + " Or, Trait value may not yet have been collected for resource."; - LOG.debug(error); - } - - return false; - } - - if (!matchAll) { - return true; - } - } else { - if (matchAll) { - return false; - } - } - } - - // if we've run through all the resources then either every resource matched (for matchAll) or - // every resource failed (for !matchAll) - return matchAll; - } - - public static boolean initCommonActivators(CommonActivatorsType rawActivators, List<Activator<?>> activators) { - boolean debugMode = false; - - if (rawActivators == null) { - return debugMode; - } - - DebugModeActivatorType rawDebugModeActivator = rawActivators.getDebugMode(); - if (rawDebugModeActivator != null) { - debugMode = true; - } - - List<LicenseFeatureActivatorType> rawLicenseFeatures = rawActivators.getLicenseFeature(); - for (LicenseFeatureActivatorType rawLicenseFeature : rawLicenseFeatures) { - String rawName = rawLicenseFeature.getName().value(); - LicenseFeature licenseFeature = LicenseFeature.valueOf(rawName.toUpperCase(Locale.US)); - LicenseFeatureActivator licenseFeatureActivator = new LicenseFeatureActivator(licenseFeature); - activators.add(licenseFeatureActivator); - } - - SuperuserActivatorType rawSuperuserActivator = rawActivators.getSuperuser(); - if (rawSuperuserActivator != null) { - SuperuserActivator superuserActivator = new SuperuserActivator(); - activators.add(superuserActivator); - } - - List<GlobalPermissionActivatorType> rawGlobalPermissionActivators = rawActivators.getGlobalPermission(); - for (GlobalPermissionActivatorType rawGlobalPermissionActivator : rawGlobalPermissionActivators) { - String rawName = rawGlobalPermissionActivator.getName().value(); - Permission permission = Permission.valueOf(rawName.toUpperCase(Locale.US)); - GlobalPermissionActivator globalPermissionActivator = new GlobalPermissionActivator(permission); - activators.add(globalPermissionActivator); - } - - return debugMode; - } - - public static boolean initGlobalActivators(GlobalActivatorsType rawActivators, List<Activator<?>> activators) { - if (rawActivators == null) { - return false; - } - - // Let our super class init the "common" activators. - boolean debugMode = initCommonActivators(rawActivators, activators); - - List<InventoryActivatorType> rawInventoryActivators = rawActivators.getInventory(); - for (InventoryActivatorType rawInventoryActivator : rawInventoryActivators) { - List<ResourceType> rawResourceConditions = rawInventoryActivator.getResource(); - List<ResourceConditionSet> resourceConditionSets = new ArrayList<ResourceConditionSet>( - rawResourceConditions.size()); - for (ResourceType rawResourceCondition : rawResourceConditions) { - List<ResourcePermissionActivatorType> rawPermissions = rawResourceCondition.getResourcePermission(); - EnumSet<Permission> permissions = EnumSet.noneOf(Permission.class); - for (ResourcePermissionActivatorType rawPermission : rawPermissions) { - String rawName = rawPermission.getName().toString(); - Permission permission = Permission.valueOf(rawName.toUpperCase(Locale.US)); - permissions.add(permission); - } - - List<TraitActivatorType> rawTraits = rawResourceCondition.getTrait(); - Map<String, Pattern> traits = new HashMap<String, Pattern>(); - for (TraitActivatorType rawTraitActivator : rawTraits) { - String name = rawTraitActivator.getName(); - String value = rawTraitActivator.getValue(); - traits.put(name, Pattern.compile(value)); - } - - ResourceConditionSet resourceConditionSet = new ResourceConditionSet(rawResourceCondition.getPlugin(), - rawResourceCondition.getType(), permissions, traits); - resourceConditionSets.add(resourceConditionSet); - } - InventoryActivator resourceTypeActivator = new InventoryActivator(resourceConditionSets); - activators.add(resourceTypeActivator); - } - - return debugMode; - } - - public static boolean initResourceActivators(ResourceActivatorsType rawActivators, List<Activator<?>> activators) { - if (rawActivators == null) { - return false; - } - - // Let our super class init the "common" activators. - boolean debugMode = initCommonActivators(rawActivators, activators); - - List<FacetActivatorType> rawFacetActivators = rawActivators.getFacet(); - for (FacetActivatorType rawFacetActivator : rawFacetActivators) { - String rawName = rawFacetActivator.getName().toString(); - FacetActivator facetActivator = new FacetActivator(ResourceTypeFacet - .valueOf(rawName.toUpperCase(Locale.US))); - activators.add(facetActivator); - } - - List<ResourcePermissionActivatorType> rawResourcePermissionActivators = rawActivators.getResourcePermission(); - for (ResourcePermissionActivatorType rawResourcePermissionActivator : rawResourcePermissionActivators) { - String rawName = rawResourcePermissionActivator.getName().toString(); - Permission permission = Permission.valueOf(rawName.toUpperCase(Locale.US)); - ResourcePermissionActivator resourcePermissionActivator = new ResourcePermissionActivator(permission); - activators.add(resourcePermissionActivator); - } - - List<TraitActivatorType> rawTraitActivators = rawActivators.getTrait(); - for (TraitActivatorType rawTraitActivator : rawTraitActivators) { - String name = rawTraitActivator.getName(); - String value = rawTraitActivator.getValue(); - TraitActivator traitActivator = new TraitActivator(name, Pattern.compile(value)); - activators.add(traitActivator); - } - - List<InventoryActivatorType> rawInventoryActivators = rawActivators.getResourceType(); - for (InventoryActivatorType rawInventoryActivator : rawInventoryActivators) { - List<ResourceType> rawResourceConditions = rawInventoryActivator.getResource(); - List<ResourceConditionSet> resourceConditionSets = new ArrayList<ResourceConditionSet>( - rawResourceConditions.size()); - for (ResourceType rawResourceCondition : rawResourceConditions) { - List<ResourcePermissionActivatorType> rawPermissions = rawResourceCondition.getResourcePermission(); - EnumSet<Permission> permissions = EnumSet.noneOf(Permission.class); - for (ResourcePermissionActivatorType rawPermission : rawPermissions) { - String rawName = rawPermission.getName().toString(); - Permission permission = Permission.valueOf(rawName.toUpperCase(Locale.US)); - permissions.add(permission); - } - - List<TraitActivatorType> rawTraits = rawResourceCondition.getTrait(); - Map<String, Pattern> traits = new HashMap<String, Pattern>(); - for (TraitActivatorType rawTraitActivator : rawTraits) { - String name = rawTraitActivator.getName(); - String value = rawTraitActivator.getValue(); - traits.put(name, Pattern.compile(value)); - } - - ResourceConditionSet resourceConditionSet = new ResourceConditionSet(rawResourceCondition.getPlugin(), - rawResourceCondition.getType(), permissions, traits); - resourceConditionSets.add(resourceConditionSet); - } - ResourceTypeActivator resourceTypeActivator = new ResourceTypeActivator(resourceConditionSets); - activators.add(resourceTypeActivator); - } - - return debugMode; - } - -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/FacetActivator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/FacetActivator.java deleted file mode 100644 index 5145bc6..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/FacetActivator.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator; - -import org.rhq.core.domain.resource.ResourceTypeFacet; -import org.rhq.enterprise.server.perspective.activator.context.AbstractResourceOrGroupActivationContext; - -/** - * @author Ian Springer - */ -public class FacetActivator extends AbstractResourceOrGroupActivator { - static final long serialVersionUID = 1L; - - private ResourceTypeFacet facet; - - public FacetActivator(ResourceTypeFacet facet) { - this.facet = facet; - } - - public boolean isActive(AbstractResourceOrGroupActivationContext context) { - return context.getFacets().contains(this.facet); - } -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/GlobalPermissionActivator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/GlobalPermissionActivator.java deleted file mode 100644 index 7f1efd5..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/GlobalPermissionActivator.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator; - -import org.rhq.core.domain.authz.Permission; -import org.rhq.enterprise.server.perspective.activator.context.GlobalActivationContext; - -/** - * @author Ian Springer - */ -public class GlobalPermissionActivator extends AbstractGlobalActivator { - static final long serialVersionUID = 1L; - - private Permission permission; - - public GlobalPermissionActivator(Permission permission) { - this.permission = permission; - } - - public boolean isActive(GlobalActivationContext context) { - return context.isSuperuser() || context.hasGlobalPermission(this.permission); - } -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/InventoryActivator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/InventoryActivator.java deleted file mode 100644 index 4003d7b..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/InventoryActivator.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator; - -import java.util.List; -import java.util.Set; - -import org.rhq.core.domain.auth.Subject; -import org.rhq.core.domain.authz.Permission; -import org.rhq.core.domain.criteria.ResourceCriteria; -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.server.perspective.activator.context.GlobalActivationContext; -import org.rhq.enterprise.server.resource.ResourceManagerLocal; -import org.rhq.enterprise.server.util.LookupUtil; - -/** - * @author Ian Springer - */ -public class InventoryActivator extends AbstractGlobalActivator { - static final long serialVersionUID = 1L; - - private List<ResourceConditionSet> resourceConditionSets; - - public InventoryActivator(List<ResourceConditionSet> resourceConditionSets) { - this.resourceConditionSets = resourceConditionSets; - } - - /** - * Returns true if any of the condition sets match an inventoried Resource. - * - * @param context - * @return - */ - public boolean isActive(GlobalActivationContext context) { - ResourceManagerLocal resourceManager = LookupUtil.getResourceManager(); - Subject subject = context.getSubject(); - - for (ResourceConditionSet rcs : this.resourceConditionSets) { - ResourceCriteria criteria = new ResourceCriteria(); - - criteria.addFilterPluginName(rcs.getPluginName()); - criteria.addFilterResourceTypeName(rcs.getResourceTypeName()); - Set<Permission> requiredPermissions = rcs.getPermissions(); - if (!((null == requiredPermissions) || requiredPermissions.isEmpty())) { - Permission[] arr = requiredPermissions.toArray(new Permission[requiredPermissions.size()]); - criteria.addRequiredPermissions(arr); - } - - PageList<Resource> resources = resourceManager.findResourcesByCriteria(context.getSubject(), criteria); - if (!((null == resources) || resources.isEmpty())) { - return ActivatorHelper.areTraitsSatisfied(subject, rcs.getTraitMatchers(), resources, false); - } - } - - return false; - } -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/LicenseFeature.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/LicenseFeature.java deleted file mode 100644 index aadb67a..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/LicenseFeature.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator; - -/** - * @author Ian Springer - */ -public enum LicenseFeature { - MONITORING -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/LicenseFeatureActivator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/LicenseFeatureActivator.java deleted file mode 100644 index 6e8d91e..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/LicenseFeatureActivator.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator; - -import org.rhq.enterprise.server.perspective.activator.context.GlobalActivationContext; - -/** - * A global-scoped activator that checks if a particular license feature is enabled. - * - * @author Ian Springer - */ -public class LicenseFeatureActivator extends AbstractGlobalActivator { - static final long serialVersionUID = 1L; - - private LicenseFeature licenseFeature; - - public LicenseFeatureActivator(LicenseFeature licenseFeature) { - this.licenseFeature = licenseFeature; - } - - public boolean isActive(GlobalActivationContext context) { - return context.getLicenseFeatures().contains(this.licenseFeature); - } -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ResourceConditionSet.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ResourceConditionSet.java deleted file mode 100644 index cf6fc42..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ResourceConditionSet.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator; - -import java.util.Collections; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.rhq.core.domain.authz.Permission; - -/** - * An immutable set of conditions pertaining to a Resource: - * - * 1) the ResourceType the Resource must have (required) - * 2) a set of Resource permissions a user must possess on the Resource (optional) - * 3) a set of traits with specific current values the Resource must possess (optional) - * - * @author Ian Springer - */ -public class ResourceConditionSet { - static final long serialVersionUID = 1L; - - private String pluginName; - private String resourceTypeName; - private EnumSet<Permission> permissions; - private Map<String, Pattern> traits; - private Map<String, Matcher> traitMatchers; - - public ResourceConditionSet(String pluginName, String resourceTypeName, EnumSet<Permission> permissions, - Map<String, Pattern> traits) { - this.pluginName = pluginName; - this.resourceTypeName = resourceTypeName; - this.permissions = permissions != null ? permissions : EnumSet.noneOf(Permission.class); - if (null != traits) { - this.traits = traits; - this.traitMatchers = new HashMap<String, Matcher>(traits.size()); - for (String trait : traits.keySet()) { - traitMatchers.put(trait, traits.get(trait).matcher("")); - } - } else { - this.traits = Collections.<String, Pattern> emptyMap(); - this.traitMatchers = Collections.<String, Matcher> emptyMap(); - } - } - - public String getPluginName() { - return pluginName; - } - - public String getResourceTypeName() { - return resourceTypeName; - } - - public EnumSet<Permission> getPermissions() { - return permissions; - } - - public Map<String, Pattern> getTraits() { - return traits; - } - - public Map<String, Matcher> getTraitMatchers() { - return traitMatchers; - } - -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ResourcePermissionActivator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ResourcePermissionActivator.java deleted file mode 100644 index b9061d0..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ResourcePermissionActivator.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator; - -import org.rhq.core.domain.authz.Permission; -import org.rhq.enterprise.server.perspective.activator.context.AbstractResourceOrGroupActivationContext; - -/** - * @author Ian Springer - */ -public class ResourcePermissionActivator extends AbstractResourceOrGroupActivator { - static final long serialVersionUID = 1L; - - private Permission permission; - - public ResourcePermissionActivator(Permission permission) { - this.permission = permission; - } - - public boolean isActive(AbstractResourceOrGroupActivationContext context) { - return context.hasResourcePermission(this.permission); - } -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ResourceTypeActivator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ResourceTypeActivator.java deleted file mode 100644 index 317ebe2..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/ResourceTypeActivator.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator; - -import java.util.Collection; -import java.util.EnumSet; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; - -import org.rhq.core.domain.authz.Permission; -import org.rhq.core.domain.resource.Resource; -import org.rhq.enterprise.server.perspective.activator.context.AbstractResourceOrGroupActivationContext; - -/** - * @author Ian Springer - */ -public class ResourceTypeActivator extends AbstractResourceOrGroupActivator { - static final long serialVersionUID = 1L; - - private List<ResourceConditionSet> resourceConditionSets; - - public ResourceTypeActivator(List<ResourceConditionSet> resourceConditionSets) { - this.resourceConditionSets = resourceConditionSets; - } - - /** - * Returns true if the current Resource or compatible Group matches at least one of our resource condition sets. - * - * @param context - * @return - */ - public boolean isActive(AbstractResourceOrGroupActivationContext context) { - for (ResourceConditionSet resourceConditionSet : this.resourceConditionSets) { - if (context.getResourceType().getPlugin().equals(resourceConditionSet.getPluginName()) - && context.getResourceType().getName().equals(resourceConditionSet.getResourceTypeName())) { - if (hasResourcePermissions(context, resourceConditionSet.getPermissions())) { - if (hasTraits(context, resourceConditionSet.getTraitMatchers())) { - return true; - } - } - } - } - return false; - } - - private boolean hasResourcePermissions(AbstractResourceOrGroupActivationContext context, - EnumSet<Permission> resourcePermissions) { - for (Permission permission : resourcePermissions) { - if (!context.hasResourcePermission(permission)) { - return false; - } - } - return true; - } - - private boolean hasTraits(AbstractResourceOrGroupActivationContext context, Map<String, Matcher> traitMatchers) { - - if (traitMatchers.isEmpty()) { - return true; - } - - Collection<Resource> resources = context.getResources(); - return ActivatorHelper.areTraitsSatisfied(context.getSubject(), traitMatchers, resources, true); - } -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/SuperuserActivator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/SuperuserActivator.java deleted file mode 100644 index 768b25f..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/SuperuserActivator.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator; - -import org.rhq.enterprise.server.perspective.activator.context.GlobalActivationContext; - -/** - * An subject-scoped activator that checks if the current user is the RHQ superuser. - * - * @author Ian Springer - */ -public class SuperuserActivator extends AbstractGlobalActivator { - static final long serialVersionUID = 1L; - - public boolean isActive(GlobalActivationContext context) { - return context.isSuperuser(); - } -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/TraitActivator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/TraitActivator.java deleted file mode 100644 index c5098f1..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/TraitActivator.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.rhq.core.domain.resource.Resource; -import org.rhq.enterprise.server.perspective.activator.context.AbstractResourceOrGroupActivationContext; - -/** - * @author Ian Springer - */ -public class TraitActivator extends AbstractResourceOrGroupActivator { - static final long serialVersionUID = 1L; - - private Map<String, Matcher> traitMatcher; - - public TraitActivator(String traitName, Pattern pattern) { - traitMatcher = new HashMap<String, Matcher>(1); - traitMatcher.put(traitName, pattern.matcher("")); - } - - public boolean isActive(AbstractResourceOrGroupActivationContext context) { - - Collection<Resource> resources = context.getResources(); - return ActivatorHelper.areTraitsSatisfied(context.getSubject(), traitMatcher, resources, true); - } -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/AbstractResourceOrGroupActivationContext.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/AbstractResourceOrGroupActivationContext.java deleted file mode 100644 index cf044f8..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/AbstractResourceOrGroupActivationContext.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator.context; - -import java.util.EnumSet; -import java.util.Set; - -import org.rhq.core.domain.auth.Subject; -import org.rhq.core.domain.authz.Permission; -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.domain.resource.ResourceTypeFacet; - -/** - * @author Ian Springer - */ -public abstract class AbstractResourceOrGroupActivationContext extends GlobalActivationContext { - protected AbstractResourceOrGroupActivationContext(Subject subject) { - super(subject); - } - - @Override - public ActivationContextScope getScope() { - return ActivationContextScope.RESOURCE_OR_GROUP; - } - - public abstract ResourceType getResourceType(); - - public abstract EnumSet<ResourceTypeFacet> getFacets(); - - public abstract Set<Resource> getResources(); - - protected abstract EnumSet<Permission> getResourcePermissions(); - - public boolean hasResourcePermission(Permission permission) { - return hasGlobalPermission(Permission.MANAGE_INVENTORY) || getResourcePermissions().contains(permission); - } -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ActivationContext.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ActivationContext.java deleted file mode 100644 index e50c604..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ActivationContext.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator.context; - -/** - * An activation context is used to provide contextual information, relevant to the scope of the current GUI request, to - * a set of activators. - * - * @author Ian Springer - */ -public interface ActivationContext { - - ActivationContextScope getScope(); -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ActivationContextScope.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ActivationContextScope.java deleted file mode 100644 index faee329..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ActivationContextScope.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator.context; - -/** - * The activation context scopes, from widest to narrowest. - * - * @author Ian Springer - */ -public enum ActivationContextScope { - /** - * The user is logged in to te GUI, but is not in the context of a particular Resource or Group. - */ - GLOBAL, - /** - * The user is in the context of a particular Resource or Group. - */ - RESOURCE_OR_GROUP -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/GlobalActivationContext.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/GlobalActivationContext.java deleted file mode 100644 index bc1937f..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/GlobalActivationContext.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator.context; - -import java.util.EnumSet; -import java.util.Set; - -import org.jetbrains.annotations.NotNull; - -import org.rhq.core.domain.auth.Subject; -import org.rhq.core.domain.authz.Permission; -import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; -import org.rhq.enterprise.server.perspective.activator.LicenseFeature; -import org.rhq.enterprise.server.util.LookupUtil; - -/** - * @author Ian Springer - */ -public class GlobalActivationContext implements ActivationContext { - private Subject subject; - - private transient EnumSet<LicenseFeature> licenseFeatures; - private transient Boolean superuser; - private transient EnumSet<Permission> globalPermissions; - - public GlobalActivationContext(Subject subject) { - this.subject = subject; - } - - public ActivationContextScope getScope() { - return ActivationContextScope.GLOBAL; - } - - @NotNull - public EnumSet<LicenseFeature> getLicenseFeatures() { - // lazy load - if (this.licenseFeatures == null) { - this.licenseFeatures = EnumSet.noneOf(LicenseFeature.class); - this.licenseFeatures.add(LicenseFeature.MONITORING); // always give this permission - } - return this.licenseFeatures; - } - - public Subject getSubject() { - return this.subject; - } - - public boolean isSuperuser() { - // lazy load - if (this.superuser == null) { - AuthorizationManagerLocal authorizationManager = LookupUtil.getAuthorizationManager(); - this.superuser = authorizationManager.isSystemSuperuser(this.subject); - } - return this.superuser; - } - - public boolean hasGlobalPermission(Permission permission) { - return isSuperuser() || getGlobalPermissions().contains(permission); - } - - protected EnumSet<Permission> getGlobalPermissions() { - // lazy load - if (this.globalPermissions == null) { - AuthorizationManagerLocal authorizationManager = LookupUtil.getAuthorizationManager(); - Set<Permission> perms = authorizationManager.getExplicitGlobalPermissions(this.subject); - this.globalPermissions = EnumSet.noneOf(Permission.class); - this.globalPermissions.addAll(perms); - } - return this.globalPermissions; - } -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/GroupActivationContext.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/GroupActivationContext.java deleted file mode 100644 index 7b1fe4c..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/GroupActivationContext.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator.context; - -import java.util.EnumSet; -import java.util.List; -import java.util.Set; - -import org.rhq.core.domain.auth.Subject; -import org.rhq.core.domain.authz.Permission; -import org.rhq.core.domain.criteria.ResourceGroupCriteria; -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.domain.resource.ResourceTypeFacet; -import org.rhq.core.domain.resource.composite.ResourceFacets; -import org.rhq.core.domain.resource.group.ResourceGroup; -import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; -import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal; -import org.rhq.enterprise.server.util.LookupUtil; - -/** - * @author Ian Springer - */ -public class GroupActivationContext extends AbstractResourceOrGroupActivationContext { - private ResourceGroup group; - transient EnumSet<ResourceTypeFacet> facets; - transient EnumSet<Permission> resourcePermissions; - - private ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager(); - private AuthorizationManagerLocal authorizationManager = LookupUtil.getAuthorizationManager(); - - public GroupActivationContext(Subject subject, ResourceGroup group) { - super(subject); - this.group = group; - } - - @Override - public ResourceType getResourceType() { - return this.group.getResourceType(); - } - - @Override - public EnumSet<ResourceTypeFacet> getFacets() { - // lazy load - if (this.facets == null) { - ResourceFacets resourceFacets = this.resourceTypeManager.getResourceFacets(getResourceType().getId()); - this.facets = EnumSet.copyOf(resourceFacets.getFacets()); - } - return this.facets; - } - - public EnumSet<Permission> getResourcePermissions() { - // lazy load - if (this.resourcePermissions == null) { - Set<Permission> perms = this.authorizationManager.getImplicitGroupPermissions(getSubject(), this.group - .getId()); - this.resourcePermissions = EnumSet.noneOf(Permission.class); - this.resourcePermissions.addAll(perms); - } - return this.resourcePermissions; - } - - public Set<Resource> getResources() { - // lazy load - if (this.group.getExplicitResources() == null) { - ResourceGroupCriteria criteria = new ResourceGroupCriteria(); - criteria.addFilterId(this.group.getId()); - criteria.fetchExplicitResources(true); - List<ResourceGroup> resourceGroups = LookupUtil.getResourceGroupManager().findResourceGroupsByCriteria( - this.getSubject(), criteria); - if (!resourceGroups.isEmpty()) { - this.group.setExplicitResources(resourceGroups.get(0).getExplicitResources()); - } - } - return this.group.getExplicitResources(); - } - - public ResourceGroup getGroup() { - return group; - } - -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ResourceActivationContext.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ResourceActivationContext.java deleted file mode 100644 index b636eff..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/perspective/activator/context/ResourceActivationContext.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.perspective.activator.context; - -import java.util.EnumSet; -import java.util.HashSet; -import java.util.Set; - -import org.rhq.core.domain.auth.Subject; -import org.rhq.core.domain.authz.Permission; -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.domain.resource.ResourceTypeFacet; -import org.rhq.core.domain.resource.composite.ResourceFacets; -import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; -import org.rhq.enterprise.server.resource.ResourceTypeManagerLocal; -import org.rhq.enterprise.server.util.LookupUtil; - -/** - * @author Ian Springer - */ -public class ResourceActivationContext extends AbstractResourceOrGroupActivationContext { - private Resource resource; - private Set<Resource> resourceAsSet; - transient EnumSet<ResourceTypeFacet> facets; - transient EnumSet<Permission> resourcePermissions; - - private ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager(); - private AuthorizationManagerLocal authorizationManager = LookupUtil.getAuthorizationManager(); - - public ResourceActivationContext(Subject subject, Resource resource) { - super(subject); - this.resource = resource; - this.resourceAsSet = new HashSet<Resource>(1); - this.resourceAsSet.add(resource); - } - - @Override - public ResourceType getResourceType() { - return this.resource.getResourceType(); - } - - @Override - public EnumSet<ResourceTypeFacet> getFacets() { - // lazy load - if (this.facets == null) { - ResourceFacets resourceFacets = this.resourceTypeManager.getResourceFacets(resource.getResourceType() - .getId()); - try { - this.facets = EnumSet.copyOf(resourceFacets.getFacets()); - } catch (IllegalArgumentException e) { - this.facets = EnumSet.noneOf(ResourceTypeFacet.class); - } - } - return this.facets; - } - - @Override - public boolean hasResourcePermission(Permission permission) { - return hasGlobalPermission(Permission.MANAGE_INVENTORY) || getResourcePermissions().contains(permission); - } - - @Override - protected EnumSet<Permission> getResourcePermissions() { - // lazy load - if (this.resourcePermissions == null) { - Set<Permission> perms = this.authorizationManager.getImplicitResourcePermissions(getSubject(), - this.resource.getId()); - this.resourcePermissions = EnumSet.noneOf(Permission.class); - this.resourcePermissions.addAll(perms); - } - return this.resourcePermissions; - } - - public Resource getResource() { - return resource; - } - - public Set<Resource> getResources() { - return this.resourceAsSet; - } - -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java index e585f91..0134031 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java @@ -43,7 +43,6 @@ import org.rhq.enterprise.server.plugin.pc.content.ContentServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.content.PackageTypeServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.generic.GenericServerPluginContainer; -import org.rhq.enterprise.server.plugin.pc.perspective.PerspectiveServerPluginContainer; import org.rhq.enterprise.server.scheduler.EnhancedScheduler; import org.rhq.enterprise.server.scheduler.EnhancedSchedulerImpl; import org.rhq.enterprise.server.util.LookupUtil; @@ -475,7 +474,6 @@ public class MasterServerPluginContainer { ArrayList<AbstractTypeServerPluginContainer> pcs = new ArrayList<AbstractTypeServerPluginContainer>(5); pcs.add(new GenericServerPluginContainer(this)); pcs.add(new ContentServerPluginContainer(this)); - pcs.add(new PerspectiveServerPluginContainer(this)); pcs.add(new AlertServerPluginContainer(this)); pcs.add(new BundleServerPluginContainer(this)); pcs.add(new PackageTypeServerPluginContainer(this)); diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectivePluginValidator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectivePluginValidator.java deleted file mode 100644 index f08cd78..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectivePluginValidator.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2009 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -package org.rhq.enterprise.server.plugin.pc.perspective; - -import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment; -import org.rhq.enterprise.server.plugin.pc.ServerPluginValidator; - -public class PerspectivePluginValidator implements ServerPluginValidator { - public boolean validate(ServerPluginEnvironment env) { - // TODO test validate env.getPluginDescriptor() - return true; - } -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginContainer.java deleted file mode 100644 index 355e023..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginContainer.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -package org.rhq.enterprise.server.plugin.pc.perspective; - -import org.rhq.enterprise.server.plugin.pc.AbstractTypeServerPluginContainer; -import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer; -import org.rhq.enterprise.server.plugin.pc.ServerPluginManager; -import org.rhq.enterprise.server.plugin.pc.ServerPluginType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.PerspectivePluginDescriptorType; - -/** - * Manages perspective server plugins. - * - * @author Jay Shaughnessy - * @author John Mazzitelli - */ -public class PerspectiveServerPluginContainer extends AbstractTypeServerPluginContainer { - - public PerspectiveServerPluginContainer(MasterServerPluginContainer master) { - super(master); - } - - @Override - public ServerPluginType getSupportedServerPluginType() { - return new ServerPluginType(PerspectivePluginDescriptorType.class); - } - - @Override - protected ServerPluginManager createPluginManager() { - return new PerspectiveServerPluginManager(this); - } - -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginManager.java deleted file mode 100644 index 104e85d..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/PerspectiveServerPluginManager.java +++ /dev/null @@ -1,268 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.plugin.pc.perspective; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Collections; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - -import javax.management.MBeanException; -import javax.management.MBeanServerConnection; -import javax.management.ObjectName; -import javax.naming.Context; -import javax.naming.InitialContext; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.rhq.core.util.file.FileUtil; -import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment; -import org.rhq.enterprise.server.plugin.pc.ServerPluginManager; -import org.rhq.enterprise.server.plugin.pc.perspective.metadata.PerspectivePluginMetadataManager; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.PerspectivePluginDescriptorType; - -/** - * This loads in all perspective server plugins that can be found. You can obtain a loaded plugin's - * {@link ServerPluginEnvironment environment}, including its classloader, from this object as well. - * - * @author Jay Shaughnessy - * @author John Mazzitelli - */ -public class PerspectiveServerPluginManager extends ServerPluginManager { - private final Log log = LogFactory.getLog(this.getClass()); - - private PerspectivePluginMetadataManager metadataManager; - - public PerspectiveServerPluginManager(PerspectiveServerPluginContainer pc) { - super(pc); - } - - @Override - public void initialize() throws Exception { - super.initialize(); - this.metadataManager = new PerspectivePluginMetadataManager(); - } - - @Override - public void shutdown() { - super.shutdown(); - this.metadataManager = null; - } - - /** - * An object that can be used to process and store all metadata from all perspective plugins. This object will contain all the - * metadata found in all loaded perspective plugins. - * - * @return object to retrieve plugin metadata from - */ - public PerspectivePluginMetadataManager getMetadataManager() { - return this.metadataManager; - } - - /* At load-time ensure that any WAR files packaged with the server plugin are deployed to the RHQ - * Server. Note, perspective apps are logically deployed along-side, not inside the rhq.ear (although physically - * under the default/work). They should have access to the same shared components. - * - * @see org.rhq.enterprise.server.plugin.pc.AbstractTypeServerPluginContainer#loadPlugin(org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment) - */ - @Override - public synchronized void loadPlugin(ServerPluginEnvironment env, boolean enabled) throws Exception { - super.loadPlugin(env, enabled); - - this.metadataManager.loadPlugin((PerspectivePluginDescriptorType) env.getPluginDescriptor()); - - // Do this here and not startPlugin() because if the app does not deploy the perspective should - // be considered invalid. - deployEmbeddedWars(env); - } - - private void deployEmbeddedWars(ServerPluginEnvironment env) { - String name = null; - try { - JarFile pluginJarFile = new JarFile(env.getPluginUrl().getFile()); - try { - for (JarEntry entry : Collections.list(pluginJarFile.entries())) { - name = entry.getName(); - if (name.toLowerCase().endsWith(".war")) { - deployWar(env, entry.getName(), pluginJarFile.getInputStream(entry)); - } - } - } finally { - pluginJarFile.close(); - } - } catch (Exception e) { - Throwable t = (e instanceof MBeanException) ? e.getCause() : e; - log.error("Failed to deploy " + env.getPluginKey().getPluginName() + "#" + name, t); - } - } - - private void deployWar(ServerPluginEnvironment env, String name, InputStream iStream) throws Exception { - // Save the war file to the plugins data directory. This survives restarts and will - // act as our deploy directory. - File deployFile = writeWarToFile(getDeployFile(env, name), iStream); - - // get reference to MBean server - Context ic = new InitialContext(); - MBeanServerConnection server = (MBeanServerConnection) ic.lookup("jmx/invoker/RMIAdaptor"); - - // get reference to MainDeployer MBean - ObjectName mainDeployer = new ObjectName("jboss.system:service=MainDeployer"); - - server.invoke(mainDeployer, "deploy", new Object[] { deployFile.getAbsolutePath() }, - new String[] { String.class.getName() }); - } - - private File getDeployFile(ServerPluginEnvironment env, String name) throws IOException { - File dataDir = getServerPluginContext(env).getDataDirectory(); - dataDir.mkdirs(); - return new File(dataDir, name); - } - - private File writeWarToFile(File destFile, InputStream iStream) throws Exception { - // Delete any previous instance of the file - if (destFile.exists()) { - getLog().debug("Existing file found and will be deleted at: " + destFile); - destFile.delete(); - } - - FileUtil.writeFile(iStream, destFile); - - if (!destFile.exists()) { - String err = "Temporary file for application update not written to: " + destFile; - getLog().error(err); - throw new Exception(err); - } - - return destFile; - } - - @Override - protected void startPlugin(String pluginName) { - super.startPlugin(pluginName); - - // If the metadata manager is started, then this is a hot deploy (or redeploy) of the perspective, so restart - // the metadata manage to merge the metadata from this perspective and all other previously loaded perspectives. - // If the metadata manager is *not* started, then this is the initial load of the perspective, and the master PC - // will call startPlugins() once all perspectives have been loaded, which will take care of starting the - // metadata manager. - if (isPluginEnabled(pluginName) && this.metadataManager.isStarted()) { - this.metadataManager.stop(); - this.metadataManager.start(); - } - - // TODO: execute An MBean Start on any perspective webapps? - } - - /** - * All of the plugins have been loaded, so now let the metadata manager sort through the definitions. - * - * @see org.rhq.enterprise.server.plugin.pc.ServerPluginManager#startPlugins() - */ - @Override - public synchronized void startPlugins() { - super.startPlugins(); - this.metadataManager.start(); - } - - @Override - protected void stopPlugin(String pluginName) { - // TODO: This method can be called in three cases: - // 1) hot-undeploy of a plugin - // 2) hot-redeploy of a plugin (stopPlugin() is called, then startPlugin() is called) - // 3) during shutdown of the plugin container - // We only want to restart our metadata manager in case 2, but there's no way for us to tell which case we're - // dealing with... - /*if (case2 && this.metadataManager.isStarted()) { - this.metadataManager.stop(); - this.metadataManager.start(); - }*/ - - // TODO: execute An MBean Stop on any perspective webapps? - - super.stopPlugin(pluginName); - } - - /* (non-Javadoc) - * @see org.rhq.enterprise.server.plugin.pc.ServerPluginManager#stopPlugins() - */ - @Override - public synchronized void stopPlugins() { - this.metadataManager.stop(); - super.stopPlugins(); - } - - /* At unload-time ensure that any WAR files packaged with the server plugin are un-deployed on - * the RHQ Server. - * - * @see org.rhq.enterprise.server.plugin.pc.AbstractTypeServerPluginContainer#unloadPlugin(org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment) - */ - @Override - public synchronized void unloadPlugin(String pluginName) throws Exception { - ServerPluginEnvironment env = getPluginEnvironment(pluginName); - // Do this here and not stopPlugin(), treat this as a precursor to a possible perspectve deletion - undeployWars(env); - this.metadataManager.unloadPlugin((PerspectivePluginDescriptorType) env.getPluginDescriptor()); - super.unloadPlugin(pluginName); - } - - private void undeployWars(ServerPluginEnvironment env) { - String name = null; - try { - JarFile plugin = new JarFile(env.getPluginUrl().getFile()); - try { - for (JarEntry entry : Collections.list(plugin.entries())) { - name = entry.getName(); - if (name.toLowerCase().endsWith(".war")) { - undeployWar(getDeployFile(env, entry.getName())); - } - } - } finally { - plugin.close(); - } - } catch (Exception e) { - this.log.error("Failed to deploy " + env.getPluginKey().getPluginName() + "#" + name, e); - } - } - - private void undeployWar(File deployFile) { - try { - // get reference to MBean server - Context ic = new InitialContext(); - MBeanServerConnection server = (MBeanServerConnection) ic.lookup("jmx/invoker/RMIAdaptor"); - - // get reference to MainDeployer MBean - ObjectName mainDeployer = new ObjectName("jboss.system:service=MainDeployer"); - - URL fileUrl = deployFile.toURI().toURL(); - - Boolean isDeployed = (Boolean) server.invoke(mainDeployer, "isDeployed", new Object[] { fileUrl }, - new String[] { URL.class.getName() }); - - if (isDeployed) { - server.invoke(mainDeployer, "undeploy", new Object[] { fileUrl }, new String[] { URL.class.getName() }); - } - } catch (Exception e) { - log.error("Failed to undeploy perspective WAR [" + deployFile + "].", e); - } - } -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/metadata/PerspectivePluginMetadataManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/metadata/PerspectivePluginMetadataManager.java deleted file mode 100644 index 2d39f87..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/perspective/metadata/PerspectivePluginMetadataManager.java +++ /dev/null @@ -1,513 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2009 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.plugin.pc.perspective.metadata; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.rhq.enterprise.server.perspective.MenuItem; -import org.rhq.enterprise.server.perspective.PageLink; -import org.rhq.enterprise.server.perspective.Tab; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.ActionType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.ApplicationType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.ExtensionType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.MenuItemType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.PageLinkType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.PageType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.PerspectivePluginDescriptorType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.PlacementType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.PositionType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.RenderedExtensionType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.TabType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.perspective.TaskType; - -/** - * This loads in all deployed perspective server plugins and maintains the complete set of - * metadata found in all plugin descriptors. Individual plugin - * metadata is irrelevant and not retrievable. The union of the perspective definitions is - * maintained and made available. Conflict resolution rules are applied as needed for - * clashing perspective definitions. - * - * Activators are not processed here, they use session-time information. This is performed at - * plugin-load-time. - * - * @author Jay Shaughnessy - * @author Ian Springer - */ -public class PerspectivePluginMetadataManager { - private final String CORE_PERSPECTIVE_NAME = "CorePerspective"; - - private static final String TARGET_MAIN_URL = "/rhq/perspective/main.xhtml?targetUrlKey="; - private static final String TARGET_RESOURCE_URL = "/rhq/perspective/resource.xhtml?targetUrlKey="; - - private static final Map<Integer, String> KEY_URL_MAP = new HashMap<Integer, String>(); - - private final Log log = LogFactory.getLog(this.getClass()); - - private Map<String, PerspectivePluginDescriptorType> loadedPlugins = new HashMap<String, PerspectivePluginDescriptorType>(); - - private boolean isStarted; - private long lastModifiedTime; - private List<Tab> resourceTabs; - private List<MenuItem> menu; - private List<PageLink> pageLinks; - - public PerspectivePluginMetadataManager() { - } - - /** - * Transforms the pluginDescriptor into domain object form and stores those objects. - * - * @param descriptor the descriptor to transform - */ - public synchronized void loadPlugin(PerspectivePluginDescriptorType descriptor) { - loadedPlugins.put(descriptor.getName(), descriptor); - } - - public synchronized void unloadPlugin(PerspectivePluginDescriptorType descriptor) { - loadedPlugins.remove(descriptor.getName()); - } - - public synchronized void start() { - if (isStarted) { - return; - } - - this.menu = new ArrayList<MenuItem>(); - this.resourceTabs = new ArrayList<Tab>(); - // TODO: Init lists of global tasks and resource tasks. - this.pageLinks = new ArrayList<PageLink>(); - - // Always process the Core perspective first, as other perspectives may remove extensions it defines. - try { - processCorePerspective(); - processNonCorePerspectives(); - } finally { - this.isStarted = true; - this.lastModifiedTime = System.currentTimeMillis(); - } - } - - public synchronized void stop() { - if (!isStarted) { - return; - } - this.menu = null; - this.resourceTabs = null; - this.isStarted = false; - } - - private void processCorePerspective() { - PerspectivePluginDescriptorType corePerspectiveDescriptor = this.loadedPlugins.get(CORE_PERSPECTIVE_NAME); - if (corePerspectiveDescriptor == null) { - throw new IllegalStateException("Core perspective is required but is missing."); - } - try { - processPerspective(corePerspectiveDescriptor); - } catch (Exception e) { - throw new IllegalStateException("Failed to load core perspective.", e); - } - } - - private void processNonCorePerspectives() { - for (String perspectiveName : this.loadedPlugins.keySet()) { - if (!CORE_PERSPECTIVE_NAME.equals(perspectiveName)) { - PerspectivePluginDescriptorType pluginDescriptor = this.loadedPlugins.get(perspectiveName); - try { - processPerspective(pluginDescriptor); - } catch (Exception e) { - log.error("Failed to load perspective [" + perspectiveName + "].", e); - } - } - } - } - - private void processPerspective(PerspectivePluginDescriptorType perspective) { - List<ApplicationType> applications = perspective.getApplication(); - - // Process MenuItem Extensions - for (MenuItemType rawMenuItem : perspective.getMenuItem()) { - resolveUrls(applications, rawMenuItem, TARGET_MAIN_URL); - ActionType action = rawMenuItem.getAction(); - switch (action) { - case ADD: - menuAdd(rawMenuItem, perspective.getName()); - break; - case REMOVE: - menuRemove(rawMenuItem); - break; - } - } - - // Process Tab Extensions - for (TabType rawTab : perspective.getTab()) { - resolveUrls(applications, rawTab, TARGET_RESOURCE_URL); - ActionType action = rawTab.getAction(); - switch (action) { - case ADD: - addTab(rawTab, perspective.getName()); - break; - case REMOVE: - removeTab(rawTab); - break; - } - } - - // TODO: Process global tasks and resource tasks. - - // Process Page Extensions - // For now just assume there are a reasonable number of page extesnions such that throwing - // them all into one list will have acceptable performance. If necessary we could segregate - // by page name etc... - for (PageType rawPage : perspective.getPage()) { - for (PageLinkType rawPageLink : rawPage.getPageLink()) { - resolveUrls(applications, rawPageLink, TARGET_MAIN_URL); - this.pageLinks.add(new PageLink(rawPageLink, perspective.getName(), rawPage.getName(), rawPageLink - .getUrl())); - } - } - } - - /** - * Update the url and iconUrl as needed by applying declared application information. - * - * @param applications - * @param extension - */ - private void resolveUrls(List<ApplicationType> applications, ExtensionType extension, String targetUrl) { - ApplicationType applicationType = getApplicationByName(applications, extension.getApplication()); - - if (extension instanceof TaskType) { - TaskType task = (TaskType) extension; - String resolvedUrl = resolveUrl(applicationType, task.getUrl(), targetUrl); - task.setUrl(resolvedUrl); - } else if (extension instanceof MenuItemType) { - MenuItemType menuItem = (MenuItemType) extension; - String resolvedUrl = resolveUrl(applicationType, menuItem.getUrl(), targetUrl); - menuItem.setUrl(resolvedUrl); - } else if (extension instanceof TabType) { - TabType tab = (TabType) extension; - String resolvedUrl = resolveUrl(applicationType, tab.getUrl(), targetUrl); - tab.setUrl(resolvedUrl); - } else if (extension instanceof PageLinkType) { - PageLinkType pageLink = (PageLinkType) extension; - String resolvedUrl = resolveUrl(applicationType, pageLink.getUrl(), targetUrl); - pageLink.setUrl(resolvedUrl); - } - - if (extension instanceof RenderedExtensionType) { - String resolvedIconUrl = resolveUrl(applicationType, ((RenderedExtensionType) extension).getIconUrl(), null); - ((RenderedExtensionType) extension).setIconUrl(resolvedIconUrl); - } - } - - private String resolveUrl(ApplicationType applicationType, String url, String targetUrl) { - String result = url; - - if (null != url) { - if (isPerspectiveUrl(url)) { - if (null == applicationType) { - throw new IllegalArgumentException( - "Relative URL found without application. Add application attribute to fully resolve url '" - + url + "'"); - } - - String baseUrl = applicationType.getBaseUrl(); - // fix the baseUrl if it lacks the separator - if (!baseUrl.endsWith("/")) { - baseUrl += "/"; - applicationType.setBaseUrl(baseUrl); - } - - result = baseUrl + url; - - // if a targetUrl is supplied then it is assumed that the url will actually - // be passed as a parameter to a predefined perspective (xhtml) page. And then - // content will be rendered within that page. We don't want to pass urls as request - // parameters (long, could contain characters that would need to be escaped, etc) - // so instead we'll now replace the actual url with a numeric key for short and - // safe param passing. The key can then be used to get back the real url at runtime. - if (null != targetUrl) { - String keyedUrl = baseUrl + url; - int key = getUrlKey(keyedUrl); - - // return the targetUrl with the proper targetUrlKey param - result = targetUrl + key; - } - } - } - - return result; - } - - /** - * Determine whether the url is relative to a perspective application or whether the url is - * for the RHQ Portal War. - * @param url - * @return true for a relative url in a declared perspective application - */ - private static boolean isPerspectiveUrl(String url) { - return (!(url.startsWith("/") || url.startsWith("http"))); - } - - private ApplicationType getApplicationByName(List<ApplicationType> applications, String name) { - ApplicationType result = null; - - if (null != applications && null != name) { - for (ApplicationType application : applications) { - if (application.getName().equals(name)) { - result = application; - break; - } - } - } - - return result; - } - - /** - * Return a unique key for the url. - * @param url - * @return - */ - public synchronized int getUrlKey(String url) { - int key = url.hashCode(); - - // in the very unlikely case that we have multiple urls with the same hashcode, protect - // ourselves. This will mess up user bookmarking of the url but saves us from internal confusion. - String mapEntry = KEY_URL_MAP.get(key); - while (!((null == mapEntry) || mapEntry.equals(url))) { - key *= 13; - mapEntry = KEY_URL_MAP.get(key); - } - - if (null == mapEntry) { - KEY_URL_MAP.put(key, url); - } - - return key; - } - - /** - * Return the url for the given key. - */ - public String getUrlViaKey(int key) { - return KEY_URL_MAP.get(key); - } - - // TODO: remove this debug code - @SuppressWarnings("unused") - private void printMenu(List<MenuItem> menu, String indent) { - if (null == menu) - return; - - for (MenuItem menuItem : menu) { - System.out.println(indent + menuItem.getName()); - printMenu(menuItem.getChildren(), indent + " "); - } - } - - private void menuAdd(MenuItemType rawMenuItem, String perspectiveName) { - PositionType position = rawMenuItem.getPosition(); - List<MenuItem> containingMenu = getContainingMenu(rawMenuItem); - - MenuItem menuItem = new MenuItem(rawMenuItem, perspectiveName); - - if (PlacementType.FIRST_CHILD == position.getPlacement()) { - containingMenu.add(0, menuItem); - } else if (PlacementType.LAST_CHILD == position.getPlacement()) { - containingMenu.add(menuItem); - } else { - int index = getMenuItemIndex(containingMenu, position.getName()); - if (-1 == index) { - throw new IllegalArgumentException("Invalid position defined for menuItem [" + rawMenuItem.getName() - + "]. Referenced menuItem not found : " + position.getName() - + ". Make sure supporting menus are defined for the menuItem."); - } - - containingMenu.add((PlacementType.AFTER == position.getPlacement() ? ++index : --index), menuItem); - } - } - - private void menuRemove(MenuItemType rawMenuItem) { - PositionType position = rawMenuItem.getPosition(); - List<MenuItem> containingMenu; - try { - containingMenu = getContainingMenu(rawMenuItem); - int index = getMenuItemIndex(containingMenu, rawMenuItem.getName()); - if (-1 == index) { - throw new IllegalArgumentException("Invalid position defined for menuItem [" + rawMenuItem.getName() - + "]. Referenced menuItem not found : " + position.getName() - + ". Make sure supporting menus are defined for the menuItem."); - } - MenuItem menuItem = containingMenu.get(index); - if (!menuItem.getPerspectiveName().equals(CORE_PERSPECTIVE_NAME)) { - throw new IllegalArgumentException("Invalid position defined for menuItem [" + rawMenuItem.getName() - + "]. Referenced menuItem is defined but not by the Core perspective : " + position.getName() - + ". Only Core menuItems can be removed."); - } - containingMenu.remove(index); - - } catch (IllegalArgumentException e) { - log.debug("Menu item not found. Ignoring removal of menu item [" + rawMenuItem.getName() + "]: " + e); - } - } - - private List<MenuItem> getContainingMenu(MenuItemType rawMenuItem) { - List<MenuItem> result = this.menu; - - String name = rawMenuItem.getName(); - String[] nameTokens = (null != name) ? name.split("\.") : new String[0]; - for (int i = 0; (i + 1 < nameTokens.length); ++i) { - int index = this.getMenuItemIndex(result, nameTokens[i]); - if (-1 == index) { - throw new IllegalArgumentException("Invalid position defined for menuItem [" + rawMenuItem.getName() - + "]. No containing menu found for : " + name - + ". Make sure supporting menus are defined for the menuItem."); - } - MenuItem menuItem = result.get(index); - result = menuItem.getChildren(); - } - - return result; - } - - private int getMenuItemIndex(List<MenuItem> menu, String name) { - for (int i = 0, size = menu.size(); (i < size); ++i) { - if (menu.get(i).getName().endsWith(name)) { - return i; - } - } - return -1; - } - - private void addTab(TabType rawTab, String perspectiveName) { - PositionType position = rawTab.getPosition(); - List<Tab> siblingTabs = getSiblingTabs(rawTab); - Tab tab = new Tab(rawTab, perspectiveName); - - if (PlacementType.FIRST_CHILD == position.getPlacement()) { - siblingTabs.add(0, tab); - } else if (PlacementType.LAST_CHILD == position.getPlacement()) { - siblingTabs.add(tab); - } else { - int index = getTabIndex(siblingTabs, position.getName()); - if (index == -1) { - throw new IllegalArgumentException("Invalid position defined for tab [" + rawTab.getName() - + "]. Referenced tab not found : " + position.getName() - + ". Make sure supporting tabs are defined for the tab."); - } - siblingTabs.add((PlacementType.AFTER == position.getPlacement() ? ++index : --index), tab); - } - } - - private void removeTab(TabType rawTab) { - PositionType position = rawTab.getPosition(); - List<Tab> siblingTabs; - try { - siblingTabs = getSiblingTabs(rawTab); - int index = getTabIndex(siblingTabs, rawTab.getName()); - if (index == -1) { - throw new IllegalArgumentException("Invalid position defined for menuItem [" + rawTab.getName() - + "]. Referenced menuItem not found : " + position.getName() - + ". Make sure supporting menus are defined for the menuItem."); - } - Tab tab = siblingTabs.get(index); - if (!tab.getPerspectiveName().equals(CORE_PERSPECTIVE_NAME)) { - throw new IllegalArgumentException("Invalid position defined for tab [" + tab.getName() - + "]. Referenced tab is defined but not by the Core perspective : " + position.getName() - + ". Only Core tabs can be removed."); - } - siblingTabs.remove(index); - } catch (IllegalArgumentException e) { - log.debug("Tab not found. Ignoring removal of tab [" + rawTab.getName() + "]: " + e); - } - } - - private List<Tab> getSiblingTabs(TabType rawTab) { - List<Tab> result = this.resourceTabs; - - String name = rawTab.getName(); - String[] nameTokens = (name != null) ? name.split("\.") : new String[0]; - for (int i = 0; (i + 1) < nameTokens.length; i++) { - int index = getTabIndex(result, nameTokens[i]); - if (index == -1) { - throw new IllegalArgumentException("Invalid position defined for tab [" + rawTab.getName() - + "]. No parent tab found for tab [" + name - + "]. Make sure supporting tabs are defined for the tab."); - } - Tab parentTab = result.get(index); - result = parentTab.getChildren(); - } - - return result; - } - - private int getTabIndex(List<Tab> tabs, String name) { - for (int i = 0, size = tabs.size(); (i < size); ++i) { - if (tabs.get(i).getQualifiedName().endsWith(name)) { - return i; - } - } - return -1; - } - - /** - * Returns the full menu, with no activators applied. Callers should not modify the returned list or any of its - * descendant lists. - * - * @return the full menu, with no activators applied - */ - public List<MenuItem> getMenu() { - return this.menu; - } - - /** - * Returns the full Resource tab bar, with no activators applied. Callers should not modify the returned list or any - * of its descendant lists. - * - * @return the full Resource tab bar, with no activators applied - */ - public List<Tab> getResourceTabs() { - return this.resourceTabs; - } - - /** - * Returns the full set of defined PageLink extensions with no activators applied. Callers should not - * modify the returned list or any of its descendant lists. - * - * @return the full Resource tab bar, with no activators applied - */ - public List<PageLink> getPageLinks() { - return this.pageLinks; - } - - public synchronized boolean isStarted() { - return this.isStarted; - } - - public long getLastModifiedTime() { - return this.lastModifiedTime; - } -} diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java index a1f6232..5f5692f 100644 --- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java +++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java @@ -36,7 +36,6 @@ import org.rhq.enterprise.server.plugin.pc.bundle.BundleServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.content.ContentServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.content.PackageTypeServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.generic.GenericServerPluginContainer; -import org.rhq.enterprise.server.plugin.pc.perspective.PerspectiveServerPluginContainer;
/** * An MBean to use as a ServerPluginService for tests that actually don't care @@ -93,7 +92,6 @@ public class StandardServerPluginService extends ServerPluginService implements pluginContainerClasses.add(ContentServerPluginContainer.class); pluginContainerClasses.add(GenericServerPluginContainer.class); pluginContainerClasses.add(PackageTypeServerPluginContainer.class); - pluginContainerClasses.add(PerspectiveServerPluginContainer.class); }
@Override
commit f0769f3a620b080a86021cf12f0b36c044542c35 Author: John Mazzitelli mazz@redhat.com Date: Wed Sep 5 13:44:27 2012 -0400
remove entitlement service - this is old PoC legacy code that was never implemented
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/entitlement/EntitlementManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/entitlement/EntitlementManagerBean.java deleted file mode 100644 index 6b5738e..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/entitlement/EntitlementManagerBean.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.entitlement; - -import java.util.Collection; - -import javax.ejb.Stateless; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.rhq.core.domain.plugin.PluginKey; -import org.rhq.enterprise.server.RHQConstants; -import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer; -import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment; -import org.rhq.enterprise.server.plugin.pc.ServerPluginServiceManagement; -import org.rhq.enterprise.server.plugin.pc.entitlement.EntitlementServerPluginContainer; -import org.rhq.enterprise.server.plugin.pc.entitlement.EntitlementServerPluginManager; -import org.rhq.enterprise.server.util.LookupUtil; - -/** - * SLSB that provides the interface point to the entitlement subsystem and entitlement server side plugins. - */ -@Stateless -public class EntitlementManagerBean implements EntitlementManagerLocal { - private final Log log = LogFactory.getLog(EntitlementManagerBean.class.getName()); - - // TODO: might not even need this if this SLSB never needs to access the database - @PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME) - private EntityManager entityManager; - - public void doSomething() { - // TODO do something "entitlement-y" - // you can call into the entitlement plugin container to do things that require the entitlement plugin to work - // you can have the plugin container have any API you can and it interacts with the plugins - try { - Collection<ServerPluginEnvironment> envs = getEntitlementServerPluginManager().getPluginEnvironments(); - for (ServerPluginEnvironment env : envs) { - PluginKey pluginKey = env.getPluginKey(); - log.info("Deployed Entitlement plugin: " + pluginKey); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * This will return the entitlement server plugin manager. If it is not available, an exception - * is thrown. - * - * The returned object has information available on all loaded entitlement server plugins. - * - * @return the plugin manager that can be used to look up entitlement plugins and their environments. - * @throws Exception if the plugin manager is not available (usually because the master plugin container - * hasn't been started) - */ - private EntitlementServerPluginManager getEntitlementServerPluginManager() throws Exception { - EntitlementServerPluginManager pluginMgr; - pluginMgr = (EntitlementServerPluginManager) getEntitlementServerPluginContainer().getPluginManager(); - if (pluginMgr == null) { - throw new Exception("Entitlement server plugin manager does not exist"); - } - return pluginMgr; - } - - /** - * This will return the entitlement server plugin container. If it is not available, an exception - * is thrown. - * - * The returned object has the plugin manager that manages all entitlement server plugins. - * - * @return the plugin container that hosts all entitlement server plugins - * @throws Exception if the plugin container is not available (usually because the master plugin container - * hasn't been started) - */ - private EntitlementServerPluginContainer getEntitlementServerPluginContainer() throws Exception { - MasterServerPluginContainer master = getMasterServerPluginContainer(); - EntitlementServerPluginContainer pc = master.getPluginContainerByClass(EntitlementServerPluginContainer.class); - if (pc == null) { - throw new Exception("Entitlement server plugin container does not exist"); - } - return pc; - } - - /** - * This will return the master server plugin container. If the master has not been started, an exception - * is thrown. - * - * @return the master plugin container that hosts all server plugin containers - * @throws Exception if the master plugin container is not started - */ - private MasterServerPluginContainer getMasterServerPluginContainer() throws Exception { - ServerPluginServiceManagement serverPluginService = LookupUtil.getServerPluginService(); - MasterServerPluginContainer master = serverPluginService.getMasterPluginContainer(); - if (master == null) { - throw new Exception("Master plugin container has not be started"); - } - return master; - } -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/entitlement/EntitlementManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/entitlement/EntitlementManagerLocal.java deleted file mode 100644 index e777307..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/entitlement/EntitlementManagerLocal.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.entitlement; - -import javax.ejb.Local; - -/** - * The local interface to the entitlement subsystem. - */ -@Local -public interface EntitlementManagerLocal { - void doSomething(); -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java index 5591deb..e585f91 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/MasterServerPluginContainer.java @@ -42,7 +42,6 @@ import org.rhq.enterprise.server.plugin.pc.bundle.BundleServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.content.ContentServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.content.PackageTypeServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.drift.DriftServerPluginContainer; -import org.rhq.enterprise.server.plugin.pc.entitlement.EntitlementServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.generic.GenericServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.perspective.PerspectiveServerPluginContainer; import org.rhq.enterprise.server.scheduler.EnhancedScheduler; @@ -478,7 +477,6 @@ public class MasterServerPluginContainer { pcs.add(new ContentServerPluginContainer(this)); pcs.add(new PerspectiveServerPluginContainer(this)); pcs.add(new AlertServerPluginContainer(this)); - pcs.add(new EntitlementServerPluginContainer(this)); pcs.add(new BundleServerPluginContainer(this)); pcs.add(new PackageTypeServerPluginContainer(this)); pcs.add(new DriftServerPluginContainer(this)); diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/entitlement/EntitlementPluginValidator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/entitlement/EntitlementPluginValidator.java deleted file mode 100644 index 8aae26c..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/entitlement/EntitlementPluginValidator.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2009 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -package org.rhq.enterprise.server.plugin.pc.entitlement; - -import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment; -import org.rhq.enterprise.server.plugin.pc.ServerPluginValidator; - -/** - * Validate an entitlement plugin. - * - * See {@link ServerPluginValidator} for more information. - * - * @author John Mazzitelli - */ -public class EntitlementPluginValidator implements ServerPluginValidator { - public boolean validate(ServerPluginEnvironment env) { - // TODO test validate env.getPluginDescriptor() - return true; - } -} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/entitlement/EntitlementServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/entitlement/EntitlementServerPluginContainer.java deleted file mode 100644 index 6eb4203..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/entitlement/EntitlementServerPluginContainer.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.plugin.pc.entitlement; - -import org.rhq.enterprise.server.plugin.pc.AbstractTypeServerPluginContainer; -import org.rhq.enterprise.server.plugin.pc.MasterServerPluginContainer; -import org.rhq.enterprise.server.plugin.pc.ServerPluginManager; -import org.rhq.enterprise.server.plugin.pc.ServerPluginType; -import org.rhq.enterprise.server.xmlschema.generated.serverplugin.entitlement.EntitlementPluginDescriptorType; - -/** - * The container responsible for managing the lifecycle of entitlement server-side plugins. - * - * @author John Mazzitelli - */ -public class EntitlementServerPluginContainer extends AbstractTypeServerPluginContainer { - - public EntitlementServerPluginContainer(MasterServerPluginContainer master) { - super(master); - } - - @Override - public ServerPluginType getSupportedServerPluginType() { - return new ServerPluginType(EntitlementPluginDescriptorType.class); - } - - @Override - protected ServerPluginManager createPluginManager() { - return new EntitlementServerPluginManager(this); - } - - // TODO: override methods if need to perform custom entitlement plugin container stuff - -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/entitlement/EntitlementServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/entitlement/EntitlementServerPluginManager.java deleted file mode 100644 index 8a4e3b7..0000000 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/entitlement/EntitlementServerPluginManager.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.server.plugin.pc.entitlement; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment; -import org.rhq.enterprise.server.plugin.pc.ServerPluginManager; - -/** - * This loads in all entitlement server plugins that can be found. You can obtain a loaded plugin's - * {@link ServerPluginEnvironment environment}, including its classloader, from this object as well. - * - * @author John Mazzitelli - */ -public class EntitlementServerPluginManager extends ServerPluginManager { - private final Log log = LogFactory.getLog(this.getClass()); - - public EntitlementServerPluginManager(EntitlementServerPluginContainer pc) { - super(pc); - } - - // TODO override methods like initialize, shutdown, loadPlugin, etc. for custom entitlement functionality - - @Override - public void initialize() throws Exception { - super.initialize(); - } - - @Override - public void shutdown() { - super.shutdown(); - } -} \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java index 989b546..05b3662 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/LookupUtil.java @@ -112,8 +112,6 @@ import org.rhq.enterprise.server.drift.DriftTemplateManagerBean; import org.rhq.enterprise.server.drift.DriftTemplateManagerLocal; import org.rhq.enterprise.server.drift.JPADriftServerBean; import org.rhq.enterprise.server.drift.JPADriftServerLocal; -import org.rhq.enterprise.server.entitlement.EntitlementManagerBean; -import org.rhq.enterprise.server.entitlement.EntitlementManagerLocal; import org.rhq.enterprise.server.event.EventManagerBean; import org.rhq.enterprise.server.event.EventManagerLocal; import org.rhq.enterprise.server.install.remote.RemoteInstallManagerBean; @@ -380,10 +378,6 @@ public final class LookupUtil { return lookupLocal(EmailManagerBean.class); }
- public static EntitlementManagerLocal getEntitlementManagerBean() { - return lookupLocal(EntitlementManagerBean.class); - } - public static EntityManagerFacadeLocal getEntityManagerFacade() { return lookupLocal(EntityManagerFacade.class); } diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java index d17981c..a1f6232 100644 --- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java +++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/StandardServerPluginService.java @@ -35,7 +35,6 @@ import org.rhq.enterprise.server.plugin.pc.alert.AlertServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.bundle.BundleServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.content.ContentServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.content.PackageTypeServerPluginContainer; -import org.rhq.enterprise.server.plugin.pc.entitlement.EntitlementServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.generic.GenericServerPluginContainer; import org.rhq.enterprise.server.plugin.pc.perspective.PerspectiveServerPluginContainer;
@@ -92,7 +91,6 @@ public class StandardServerPluginService extends ServerPluginService implements pluginContainerClasses.add(AlertServerPluginContainer.class); pluginContainerClasses.add(BundleServerPluginContainer.class); pluginContainerClasses.add(ContentServerPluginContainer.class); - pluginContainerClasses.add(EntitlementServerPluginContainer.class); pluginContainerClasses.add(GenericServerPluginContainer.class); pluginContainerClasses.add(PackageTypeServerPluginContainer.class); pluginContainerClasses.add(PerspectiveServerPluginContainer.class);
rhq-commits@lists.fedorahosted.org