Author: thomas.heute(a)jboss.com
Date: 2010-02-11 11:37:02 -0500 (Thu, 11 Feb 2010)
New Revision: 1643
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigDeployer.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinService.java
Log:
Proper spelling
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigDeployer.java
(from rev 1637,
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/GateinSkinConfigDeployer.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigDeployer.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigDeployer.java 2010-02-11
16:37:02 UTC (rev 1643)
@@ -0,0 +1,134 @@
+/**
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.resource;
+
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.RootContainer.PortalContainerPostInitTask;
+import org.exoplatform.portal.resource.config.xml.SkinConfigParser;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.gatein.wci.WebAppEvent;
+import org.gatein.wci.WebAppLifeCycleEvent;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.servlet.ServletContext;
+
+/**
+ *
+ * Created by eXoPlatform SAS
+ *
+ * Author: Minh Hoang TO - hoang281283(a)gmail.com
+ *
+ * Sep 16, 2009
+ */
+public class GateInSkinConfigDeployer extends AbstractResourceHandler
+{
+
+ private final SkinService skinService;
+
+ private static final String GATEIN_CONFIG_RESOURCE =
"/WEB-INF/gatein-resources.xml";
+
+ private static Log LOG = ExoLogger.getExoLogger(GateInSkinConfigDeployer.class);
+
+ /**
+ * The name of the portal container
+ */
+ private final String portalContainerName;
+
+ public GateInSkinConfigDeployer(String portalContainerName, SkinService _skinService)
+ {
+ this.skinService = _skinService;
+ this.portalContainerName = portalContainerName;
+ }
+
+ @Override
+ public void onEvent(WebAppEvent event)
+ {
+ if (event instanceof WebAppLifeCycleEvent)
+ {
+ WebAppLifeCycleEvent waEvent = (WebAppLifeCycleEvent)event;
+ if (waEvent.getType() == WebAppLifeCycleEvent.ADDED)
+ {
+ ServletContext scontext = null;
+ try
+ {
+ scontext = event.getWebApp().getServletContext();
+ InputStream is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
+ if (is == null)
+ return;
+ try
+ {
+ is.close();
+ }
+ catch (Exception ex)
+ {
+ // ignore me
+ }
+ final PortalContainerPostInitTask task = new
PortalContainerPostInitTask()
+ {
+
+ public void execute(ServletContext scontext, PortalContainer
portalContainer)
+ {
+ register(scontext, portalContainer);
+ skinService.registerContext(scontext);
+ }
+ };
+ PortalContainer.addInitTask(scontext, task, portalContainerName);
+ }
+ catch (Exception ex)
+ {
+ LOG.error("An error occurs while registering '" +
GATEIN_CONFIG_RESOURCE + "' from the context '"
+ + (scontext == null ? "unknown" :
scontext.getServletContextName()) + "'", ex);
+ }
+ }
+ }
+ }
+
+ private void register(ServletContext scontext, PortalContainer container)
+ {
+ InputStream is = null;
+ try
+ {
+ is = scontext.getResourceAsStream(GATEIN_CONFIG_RESOURCE);
+ SkinConfigParser.processConfigResource(is, skinService, scontext);
+ }
+ catch (Exception ex)
+ {
+ LOG.error("An error occurs while registering '" +
GATEIN_CONFIG_RESOURCE + "' from the context '"
+ + (scontext == null ? "unknown" : scontext.getServletContextName())
+ "'", ex);
+ }
+ finally
+ {
+ if (is != null)
+ {
+ try
+ {
+ is.close();
+ }
+ catch (IOException e)
+ {
+ // ignore me
+ }
+ }
+ }
+ }
+}
Copied:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java
(from rev 1637,
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/GateinSkinConfigRemoval.java)
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/GateInSkinConfigRemoval.java 2010-02-11
16:37:02 UTC (rev 1643)
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.portal.resource;
+
+import java.util.List;
+import java.util.Set;
+
+import org.gatein.wci.WebAppEvent;
+import org.gatein.wci.WebAppLifeCycleEvent;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
+ * @version $Id$
+ *
+ */
+public class GateInSkinConfigRemoval extends AbstractResourceHandler
+{
+
+ private SkinService service;
+
+ private String portalContainerName;
+
+ public GateInSkinConfigRemoval(String _portalContainerName, SkinService _service)
+ {
+ this.portalContainerName = _portalContainerName;
+ this.service = _service;
+ }
+
+ /**
+ * @see
org.exoplatform.portal.resource.AbstractResourceHandler#onEvent(org.gatein.wci.WebAppEvent)
+ */
+ @Override
+ public void onEvent(WebAppEvent event)
+ {
+ // TODO Auto-generated method stub
+ if (event instanceof WebAppLifeCycleEvent)
+ {
+ WebAppLifeCycleEvent waEvent = (WebAppLifeCycleEvent)event;
+ if (waEvent.getType() == WebAppLifeCycleEvent.REMOVED)
+ {
+ String webApp = event.getWebApp().getServletContext().getContextPath();
+ removeWebAppSkin(webApp);
+ }
+ }
+ }
+
+ private void removeWebAppSkin(String webApp)
+ {
+ try
+ {
+ removePortalSkins(webApp);
+ removePortletSkins(webApp);
+ removeSkinName(webApp);
+
+ // Update the 'skinDependentManager'
+ SkinDependentManager.clearAssociatedSkins(webApp);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ private void removePortalSkins(String webApp) throws Exception
+ {
+ List<SkinKey> portalSkins = SkinDependentManager.getPortalSkins(webApp);
+ service.remove(portalSkins);
+ }
+
+ private void removePortletSkins(String webApp) throws Exception
+ {
+ List<SkinKey> portletSkins = SkinDependentManager.getPortletSkins(webApp);
+ service.remove(portletSkins);
+ }
+
+ /**
+ * Remove skinName defined by the webApp, if no other webApps supports the
+ * skinName
+ */
+ private void removeSkinName(String webApp) throws Exception
+ {
+ Set<String> supportedSkins = SkinDependentManager.getSkinNames(webApp);
+ if (supportedSkins != null)
+ {
+ for (String skin : supportedSkins)
+ {
+ if (SkinDependentManager.skinNameIsRemovable(skin, webApp))
+ {
+ service.removeSupportedSkin(skin);
+ }
+ }
+ }
+ }
+
+}
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinService.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-02-11
15:42:32 UTC (rev 1642)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-02-11
16:37:02 UTC (rev 1643)
@@ -141,8 +141,8 @@
portletThemes_ = new HashMap<String, Set<String>>();
portalContainerName = context.getPortalContainerName();
mainResolver = new MainResourceResolver(portalContainerName, skinConfigs_);
- deployer = new GateinSkinConfigDeployer(portalContainerName, this);
- removal = new GateinSkinConfigRemoval(portalContainerName, this);
+ deployer = new GateInSkinConfigDeployer(portalContainerName, this);
+ removal = new GateInSkinConfigRemoval(portalContainerName, this);
}
public void addCategoryTheme(String categoryName)