Author: hoang_to
Date: 2010-04-09 02:07:28 -0400 (Fri, 09 Apr 2010)
New Revision: 2539
Removed:
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/SkinService.java
Log:
GTNPORTAL-944: Modify java code to avoid breaks on contract in ResourceResolver 's
javadoc
Deleted:
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 2010-04-09
04:32:12 UTC (rev 2538)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/ResourceNotFoundException.java 2010-04-09
06:07:28 UTC (rev 2539)
@@ -1,59 +0,0 @@
-/*
- * 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-09
04:32:12 UTC (rev 2538)
+++
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource/SkinService.java 2010-04-09
06:07:28 UTC (rev 2539)
@@ -423,40 +423,57 @@
}
/**
- * Add this method to catch <code>ResourceNotFoundException</code>
- * and to log evoquant message
+ *
+ * This method delegates the resource resolving to MainResourceResolver and prints out
appropriated log messages
*
+ * Consider the two cases the method is invoked
+ *
+ * Case 1: Resolve nested .css file
+ *
+ * In Stylesheet.css we have the statement
+ *
+ * @import url(xyzt.css);
+ *
+ * To resolve the resource from xyzt.css, getCSSResource("xyzt.css",
"Stylesheet.css") is called
+ *
+ * Case 2: Resolve top root .css file
+ *
+ * To resolve a top root Stylesheet.css file,
getCSSResource("Stylesheet.css", "Stylesheet.css") is called
+ *
* @param cssPath
+ * @param outerCssFile
* @return
+ *
*/
- private Resource getCSSResource(String cssPath)
+ private Resource getCSSResource(String cssPath, String outerCssFile)
{
- try{
- return mainResolver.resolve(cssPath);
- }
- catch(ResourceNotFoundException NotFoundEx)
+ Resource resource = mainResolver.resolve(cssPath);
+ if (resource == null)
{
- String notFoundResourcePath = NotFoundEx.getResourcePath();
String logMessage;
- if(!cssPath.equals(notFoundResourcePath))
+ if (!cssPath.equals(outerCssFile))
{
+ int lastIndexOfSlash = cssPath.lastIndexOf('/');
+ String loadedCssFile = (lastIndexOfSlash >=
0)?(cssPath.substring(lastIndexOfSlash + 1)) : cssPath;
logMessage =
- "Invalid <CSS FILE> configuration, please check the @import
url(" + notFoundResourcePath + ") in "
- + cssPath + " , SkinService could not load the skin " +
cssPath;
+ "Invalid <CSS FILE> configuration, please check the @import
url(" + loadedCssFile + ") in "
+ + outerCssFile + " , SkinService could not load the skin " +
cssPath;
}
else
{
- logMessage = "Not found <CSS FILE> " + cssPath + " ,
SkinService could not load the skin " + cssPath;
+ logMessage =
+ "Not found <CSS FILE>, the path " + cssPath + " is
invalid, SkinService could not load the skin "
+ + cssPath;
}
log.error(logMessage);
- return null;
}
+ return resource;
}
private void processCSS(Appendable appendable, String cssPath, Orientation
orientation, boolean merge)
throws RenderingException, IOException
{
- Resource skin = getCSSResource(cssPath);
+ Resource skin = getCSSResource(cssPath, cssPath);
processCSSRecursively(appendable, merge, skin, orientation);
}
@@ -487,7 +504,7 @@
{
if (merge)
{
- Resource ssskin = getCSSResource(includedPath);
+ Resource ssskin = getCSSResource(includedPath, basePath +
skin.getFileName());
processCSSRecursively(appendable, merge, ssskin, orientation);
}
else
@@ -502,7 +519,7 @@
if (merge)
{
String path = skin.getContextPath() + skin.getParentPath() +
includedPath;
- Resource ssskin = getCSSResource(path);
+ Resource ssskin = getCSSResource(path, basePath +
skin.getFileName());
processCSSRecursively(appendable, merge, ssskin, orientation);
}
else