From do-not-reply at jboss.org Fri Apr 9 02:07:29 2010
Content-Type: multipart/mixed; boundary="===============7338830040890782674=="
MIME-Version: 1.0
From: do-not-reply at jboss.org
To: gatein-commits at lists.jboss.org
Subject: [gatein-commits] gatein SVN: r2539 -
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resource.
Date: Fri, 09 Apr 2010 02:07:29 -0400
Message-ID: <201004090607.o3967T3U009351@svn01.web.mwc.hst.phx2.redhat.com>
--===============7338830040890782674==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
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/resou=
rce/ResourceNotFoundException.java
Modified:
portal/trunk/component/portal/src/main/java/org/exoplatform/portal/resou=
rce/SkinService.java
Log:
GTNPORTAL-944: Modify java code to avoid breaks on contract in ResourceReso=
lver 's javadoc
Deleted: portal/trunk/component/portal/src/main/java/org/exoplatform/portal=
/resource/ResourceNotFoundException.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/reso=
urce/ResourceNotFoundException.java 2010-04-09 04:32:12 UTC (rev 2538)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/reso=
urce/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 Minh Hoang TO
- * @version $Id$
- *
- */
-public class ResourceNotFoundException extends RuntimeException
-{
- private String resourcePath;
- =
- private String errorType;
- =
- private final static String INVALID_RESOURCE_PATH =3D "invalid resource=
path";
- =
- private final static String RESOURCE_RESOLVER_WRONG_PROCESSING =3D "wro=
ng processing in resource resolver";
- =
- public ResourceNotFoundException(String _resourcePath, String message)
- {
- super(message);
- resourcePath =3D _resourcePath;
- errorType =3D INVALID_RESOURCE_PATH;
- }
- =
- public ResourceNotFoundException(String _resourcePath, String _errorTyp=
e, String message)
- {
- super(message);
- resourcePath =3D _resourcePath;
- errorType =3D _errorType;
- }
- =
- public String getResourcePath()
- {
- return resourcePath;
- }
- =
- public String getErrorType()
- {
- return errorType;
- }
-}
Modified: portal/trunk/component/portal/src/main/java/org/exoplatform/porta=
l/resource/SkinService.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- portal/trunk/component/portal/src/main/java/org/exoplatform/portal/reso=
urce/SkinService.java 2010-04-09 04:32:12 UTC (rev 2538)
+++ portal/trunk/component/portal/src/main/java/org/exoplatform/portal/reso=
urce/SkinService.java 2010-04-09 06:07:28 UTC (rev 2539)
@@ -423,40 +423,57 @@
}
=
/**
- * Add this method to catch ResourceNotFoundException
- * 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("Styleshe=
et.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 =3D mainResolver.resolve(cssPath);
+ if (resource =3D=3D null)
{
- String notFoundResourcePath =3D NotFoundEx.getResourcePath();
String logMessage;
- if(!cssPath.equals(notFoundResourcePath))
+ if (!cssPath.equals(outerCssFile))
{
+ int lastIndexOfSlash =3D cssPath.lastIndexOf('/');
+ String loadedCssFile =3D (lastIndexOfSlash >=3D 0)?(cssPath.su=
bstring(lastIndexOfSlash + 1)) : cssPath;
logMessage =3D
- "Invalid configuration, please check the @import=
url(" + notFoundResourcePath + ") in "
- + cssPath + " , SkinService could not load the skin " + =
cssPath;
+ "Invalid configuration, please check the @import=
url(" + loadedCssFile + ") in "
+ + outerCssFile + " , SkinService could not load the skin=
" + cssPath;
}
else
{
- logMessage =3D "Not found " + cssPath + " , SkinSer=
vice could not load the skin " + cssPath;
+ logMessage =3D
+ "Not found , 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, Orientat=
ion orientation, boolean merge)
throws RenderingException, IOException
{
- Resource skin =3D getCSSResource(cssPath);
+ Resource skin =3D getCSSResource(cssPath, cssPath);
processCSSRecursively(appendable, merge, skin, orientation);
}
=
@@ -487,7 +504,7 @@
{
if (merge)
{
- Resource ssskin =3D getCSSResource(includedPath);
+ Resource ssskin =3D getCSSResource(includedPath, base=
Path + skin.getFileName());
processCSSRecursively(appendable, merge, ssskin, orie=
ntation);
}
else
@@ -502,7 +519,7 @@
if (merge)
{
String path =3D skin.getContextPath() + skin.getParen=
tPath() + includedPath;
- Resource ssskin =3D getCSSResource(path);
+ Resource ssskin =3D getCSSResource(path, basePath + s=
kin.getFileName());
processCSSRecursively(appendable, merge, ssskin, orie=
ntation);
}
else
--===============7338830040890782674==--