Author: hoang_to
Date: 2010-04-08 08:35:38 -0400 (Thu, 08 Apr 2010)
New Revision: 2533
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/ResourceNotFoundException.java
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/MainResourceResolver.java
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinService.java
portal/trunk/web/eXoResources/src/main/webapp/skin/Stylesheet.css
Log:
GTNPORTAL-944: Improve error management in SkinService
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/MainResourceResolver.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/MainResourceResolver.java 2010-04-08
10:28:32 UTC (rev 2532)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/MainResourceResolver.java 2010-04-08
12:35:38 UTC (rev 2533)
@@ -94,12 +94,21 @@
//
if (context == null)
{
- log.warn("Could not resolve " + targetedContextPath + " resource
for path " + path);
- return null;
+ String message = "Could not resolve " + targetedContextPath + "
resource for path " + path;
+ log.warn(message);
+ throw new ResourceNotFoundException(path, message);
}
else
{
- return context.getResource(path.substring(i1));
+ Resource resource = context.getResource(path.substring(i1));
+ if(resource == null)
+ {
+ throw new ResourceNotFoundException(path, "Could not resolve resource
with path " + path.substring(i1) + " under context path " +
targetedContextPath);
+ }
+ else
+ {
+ return resource;
+ }
}
}
}
Added:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/ResourceNotFoundException.java
===================================================================
---
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/ResourceNotFoundException.java
(rev 0)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/ResourceNotFoundException.java 2010-04-08
12:35:38 UTC (rev 2533)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 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;
+
+/**
+ * @author <a href="mailto:hoang281283@gmail.com">Minh Hoang
TO</a>
+ * @version $Id$
+ *
+ */
+public class ResourceNotFoundException extends RuntimeException
+{
+ private String resourcePath;
+
+ private String errorType;
+
+ private final static String INVALID_RESOURCE_PATH = "invalid resource
path";
+
+ private final static String RESOURCE_RESOLVER_WRONG_PROCESSING = "wrong
processing in resource resolver";
+
+ public ResourceNotFoundException(String _resourcePath, String message)
+ {
+ super(message);
+ resourcePath = _resourcePath;
+ errorType = INVALID_RESOURCE_PATH;
+ }
+
+ public ResourceNotFoundException(String _resourcePath, String _errorType, String
message)
+ {
+ super(message);
+ resourcePath = _resourcePath;
+ errorType = _errorType;
+ }
+
+ public String getResourcePath()
+ {
+ return resourcePath;
+ }
+
+ public String getErrorType()
+ {
+ return errorType;
+ }
+}
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-04-08
10:28:32 UTC (rev 2532)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-04-08
12:35:38 UTC (rev 2533)
@@ -421,11 +421,42 @@
{
return skinConfigs_.size();
}
+
+ /**
+ * Add this method to catch <code>ResourceNotFoundException</code>
+ * and to log evoquant message
+ *
+ * @param cssPath
+ * @return
+ */
+ private Resource getCSSResource(String cssPath)
+ {
+ try{
+ return mainResolver.resolve(cssPath);
+ }
+ catch(ResourceNotFoundException NotFoundEx)
+ {
+ String notFoundResourcePath = NotFoundEx.getResourcePath();
+ String logMessage;
+ if(!cssPath.equals(notFoundResourcePath))
+ {
+ logMessage =
+ "Invalid <CSS FILE> configuration, please check the @import
url(" + notFoundResourcePath + ") in "
+ + cssPath + " , SkinService could not load the skin " +
cssPath;
+ }
+ else
+ {
+ logMessage = "Not found <CSS FILE> " + cssPath + " ,
SkinService could not load the skin " + cssPath;
+ }
+ log.error(logMessage);
+ return null;
+ }
+ }
private void processCSS(Appendable appendable, String cssPath, Orientation
orientation, boolean merge)
throws RenderingException, IOException
{
- Resource skin = mainResolver.resolve(cssPath);
+ Resource skin = getCSSResource(cssPath);
processCSSRecursively(appendable, merge, skin, orientation);
}
@@ -456,7 +487,7 @@
{
if (merge)
{
- Resource ssskin = mainResolver.resolve(includedPath);
+ Resource ssskin = getCSSResource(includedPath);
processCSSRecursively(appendable, merge, ssskin, orientation);
}
else
@@ -471,7 +502,7 @@
if (merge)
{
String path = skin.getContextPath() + skin.getParentPath() +
includedPath;
- Resource ssskin = mainResolver.resolve(path);
+ Resource ssskin = getCSSResource(path);
processCSSRecursively(appendable, merge, ssskin, orientation);
}
else
Modified: portal/trunk/web/eXoResources/src/main/webapp/skin/Stylesheet.css
===================================================================
--- portal/trunk/web/eXoResources/src/main/webapp/skin/Stylesheet.css 2010-04-08 10:28:32
UTC (rev 2532)
+++ portal/trunk/web/eXoResources/src/main/webapp/skin/Stylesheet.css 2010-04-08 12:35:38
UTC (rev 2533)
@@ -19,4 +19,5 @@
@import url(DefaultSkin/portal/webui/component/UIPortalApplicationSkin.css);
@import url(DefaultSkin/webui/component/Stylesheet.css);
-@import url(PortletThemes/Stylesheet.css);
\ No newline at end of file
+@import url(PortletThemes/Stylesheet.css);
+@import url(blahblah.css);
\ No newline at end of file