[Yanel-commits] rev 43910 - in public/yanel/trunk/src:
core/java/org/wyona/yanel/core/source
impl/java/org/wyona/yanel/impl/resources
webapp/global-resource-configs/user-mgmt webapp/htdocs
guillaume at wyona.com
guillaume at wyona.com
Wed Jul 29 13:50:42 CEST 2009
Author: guillaume
Date: 2009-07-29 13:50:41 +0200 (Wed, 29 Jul 2009)
New Revision: 43910
Added:
public/yanel/trunk/src/core/java/org/wyona/yanel/core/source/YanelHtdocsResolver.java
public/yanel/trunk/src/webapp/htdocs/html.xslt
Modified:
public/yanel/trunk/src/core/java/org/wyona/yanel/core/source/SourceResolver.java
public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources/BasicXMLResource.java
public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/create-group_yanel-rc.xml
public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/create-user_yanel-rc.xml
public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/delete-group_yanel-rc.xml
public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/delete-user_yanel-rc.xml
public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/list-groups_yanel-rc.xml
public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/list-users_yanel-rc.xml
public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/update-user-admin_yanel-rc.xml
public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/update-user_yanel-rc.xml
Log:
All realms should now be able to access the user and group management without configuration
(esp. there is no need to have an /xslt/usecase.xsl file in each realm's data repo.
IOW we are now using by default a Yanel-global, not-RT-specific, not-repo-stored XSLT to
layout the user and group management screens (and in the future all other admin screens).
Had to do quite some Java coding for this:
- painfully implemented the "yanelhtdocs" protocol
- registered it in SourceResolver and cleaned up code there a bit (removed generic warnings, used Log4J's newest Logger API)
- made BasicXMLResource finally use SourceResolver
Issue: 6897
Modified: public/yanel/trunk/src/core/java/org/wyona/yanel/core/source/SourceResolver.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/source/SourceResolver.java 2009-07-29 10:20:05 UTC (rev 43909)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/source/SourceResolver.java 2009-07-29 11:50:41 UTC (rev 43910)
@@ -6,7 +6,7 @@
import javax.xml.transform.TransformerException;
import javax.xml.transform.URIResolver;
-import org.apache.log4j.Category;
+import org.apache.log4j.Logger;
import org.wyona.yanel.core.Resource;
import org.wyona.commons.io.PathUtil;
@@ -18,19 +18,16 @@
*/
public class SourceResolver implements URIResolver {
- private static Category log = Category.getInstance(SourceResolver.class);
+ private static final Logger log = Logger.getLogger(SourceResolver.class);
- private HashMap resolvers;
+ private HashMap<String, URIResolver> resolvers;
private Resource resource;
public SourceResolver(Resource resource) {
this.resource = resource;
- this.resolvers = new HashMap();
+ this.resolvers = new HashMap<String, URIResolver>();
}
- /**
- *
- */
public Source resolve(String uri, String base) throws SourceException {
if (log.isDebugEnabled()) {
log.debug("URI to be resolved: " + uri);
@@ -75,13 +72,10 @@
throw new SourceException("No resolver could be loaded for scheme: " + uriScheme);
}
- /**
- *
- */
private URIResolver getResolver(String scheme) {
URIResolver resolver = null;
if (this.resolvers.containsKey(scheme)) {
- resolver = (URIResolver)this.resolvers.get(scheme);
+ resolver = this.resolvers.get(scheme);
} else {
if (scheme.equals("yanelresource")) {
resolver = new ResourceResolver(this.resource);
@@ -99,6 +93,9 @@
} else if (scheme.equals("rtyanelhtdocs")) {
resolver = new RTYanelHtdocsResolver(this.resource);
this.resolvers.put(scheme, resolver);
+ } else if (scheme.equals("yanelhtdocs")) {
+ resolver = new YanelHtdocsResolver(this.resource);
+ this.resolvers.put(scheme, resolver);
}
}
return resolver;
Added: public/yanel/trunk/src/core/java/org/wyona/yanel/core/source/YanelHtdocsResolver.java
===================================================================
--- public/yanel/trunk/src/core/java/org/wyona/yanel/core/source/YanelHtdocsResolver.java (rev 0)
+++ public/yanel/trunk/src/core/java/org/wyona/yanel/core/source/YanelHtdocsResolver.java 2009-07-29 11:50:41 UTC (rev 43910)
@@ -0,0 +1,78 @@
+package org.wyona.yanel.core.source;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
+
+import org.apache.log4j.Logger;
+import org.wyona.yanel.core.Resource;
+
+public class YanelHtdocsResolver implements URIResolver {
+
+ private static Logger log = Logger.getLogger(YanelHtdocsResolver.class);
+
+ private static final String SCHEME = "yanelhtdocs";
+ private static final String PATH_PREFIX = "htdocs";
+ private Resource resource;
+
+ public YanelHtdocsResolver(Resource resource) {
+ this.resource = resource;
+ }
+
+ protected String getScheme() { return SCHEME; }
+
+ public Source resolve(String href, String base) throws TransformerException {
+ String prefix = getScheme() + ":";
+ // only accept '<scheme>:' URIs
+ if (href == null || !href.startsWith(prefix)){
+ return null;
+ }
+ // we can't resolve to a Collection (indicated by a trailing '/')
+ if (href.endsWith("/")){
+ return null;
+ }
+ String path = href.substring(prefix.length());
+
+ HttpServletRequest request = resource.getEnvironment().getRequest();
+
+ //XXX HACK: we have no other way to have access to this directory from the Yanel environment alone:
+ String localFilePath = request.getRealPath("/" + PATH_PREFIX + path);
+ log.fatal("localFilePath: "+localFilePath);
+ File resourceFile = new File(localFilePath);
+ //return new YanelStreamSource(resourceFile);
+ InputStream in;
+ try {
+ in = new java.io.FileInputStream(resourceFile);
+ } catch (FileNotFoundException e) {
+ throw new SourceException(e.getMessage(), e);
+ }
+ YanelStreamSource source = new YanelStreamSource(in);
+ long resourceLastModified = resourceFile.lastModified();
+ source.setLastModified(resourceLastModified);
+ return source;
+ /*TODO REMOVEME does not work with HTTPS, credential problems...
+ StringBuffer sb = request.getRequestURL();
+ log.fatal("sb: "+sb);
+ String globalHtdocsPath = PathUtil.getGlobalHtdocsPath(resource);
+ log.fatal("globalHtdocsPath: "+globalHtdocsPath);
+ try {
+ URL url = new URL(sb.toString() + globalHtdocsPath + path);
+ if (log.isDebugEnabled()) log.debug("Resolve: " + url.toString());
+ return new StreamSource(url.openConnection().getInputStream());
+ } catch (Exception e) {
+ String errorMsg = "Could not resolve URI: <" + href + ">: " + e.toString();
+ throw new SourceException(errorMsg, e);
+ }
+ */
+ /*TODO REMOVEME does not work, the reserved area is indeed not handled by a resource-type!
+ String reservedPrefix = resource.getYanel().getReservedPrefix();
+ return resolver.resolve("yanelresource:" + "/" + reservedPrefix + path, base);
+ */
+ }
+
+}
Property changes on: public/yanel/trunk/src/core/java/org/wyona/yanel/core/source/YanelHtdocsResolver.java
___________________________________________________________________
Name: svn:mime-type
+ text/x-java
Modified: public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources/BasicXMLResource.java
===================================================================
--- public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources/BasicXMLResource.java 2009-07-29 10:20:05 UTC (rev 43909)
+++ public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/resources/BasicXMLResource.java 2009-07-29 11:50:41 UTC (rev 43910)
@@ -252,24 +252,26 @@
Repository repo = getRealm().getRepository();
TransformerHandler[] xsltHandlers = new TransformerHandler[xsltPaths.length];
for (int i = 0; i < xsltPaths.length; i++) {
- // TODO: Use resolver
+ String xsltPath = xsltPaths[i];
+ int schemeEndIndex = xsltPath.indexOf(':');
if (xsltPaths[i].startsWith("file:")) {
+ // TODO: Handle "file:" in SourceResolver
log.info("Scheme: file (" + xsltPaths[i] + ")");
xsltHandlers[i] = tf.newTransformerHandler(new StreamSource(new java.io.FileInputStream(xsltPaths[i].substring(5))));
- } else if(xsltPaths[i].startsWith("rthtdocs:")) {
- log.info("Scheme: rthtdocs (" + xsltPaths[i] + ")");
- xsltHandlers[i] = tf.newTransformerHandler(new org.wyona.yanel.core.source.RTHtdocsResolver(this).resolve(xsltPaths[i], null));
- } else if(xsltPaths[i].startsWith("yanelresource:")) {
- log.info("Scheme: yanelresource (" + xsltPaths[i] + ")");
- xsltHandlers[i] = tf.newTransformerHandler(new org.wyona.yanel.core.source.ResourceResolver(this).resolve(xsltPaths[i], null));
+ } else if (schemeEndIndex >= 0) {
+ String scheme = xsltPath.substring(0, schemeEndIndex);
+ log.info("Scheme: " + scheme + " (" + xsltPath + ")");
+ xsltHandlers[i] = tf.newTransformerHandler(uriResolver.resolve(xsltPath, null));
+ /*XXX BACKWARD-COMPATIBILITY from now on we
+ throw new SourceException("No resolver could be loaded for scheme: " + scheme);
+ instead of simply only doing
+ log.error("No such protocol implemented: " + xsltPaths[i].substring(0, xsltPaths[i].indexOf(":/")));
+ and then probably also throwing some other exception anyway...
+ */
} else {
- if (xsltPaths[i].indexOf(":/") > 0) {
- log.error("No such protocol implemented: " + xsltPaths[i].substring(0, xsltPaths[i].indexOf(":/")));
- } else {
if (log.isDebugEnabled()) {
log.debug("Default Content repository will be used!");
}
- }
xsltHandlers[i] = tf.newTransformerHandler(new StreamSource(repo.getNode(xsltPaths[i]).getInputStream(), "yanelrepo:" + xsltPaths[i]));
}
xsltHandlers[i].getTransformer().setURIResolver(uriResolver);
Modified: public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/create-group_yanel-rc.xml
===================================================================
--- public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/create-group_yanel-rc.xml 2009-07-29 10:20:05 UTC (rev 43909)
+++ public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/create-group_yanel-rc.xml 2009-07-29 11:50:41 UTC (rev 43910)
@@ -3,7 +3,7 @@
<yanel:resource-config xmlns:yanel="http://www.wyona.org/yanel/rti/1.0">
<yanel:rti name="create-group" namespace="http://www.wyona.org/yanel/resource/1.0"/>
- <yanel:property name="xslt" value="/xslt/usecase.xsl"/>
+ <yanel:property name="xslt" value="yanelhtdocs:/html.xslt"/>
<yanel:custom-config>
<views>
Modified: public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/create-user_yanel-rc.xml
===================================================================
--- public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/create-user_yanel-rc.xml 2009-07-29 10:20:05 UTC (rev 43909)
+++ public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/create-user_yanel-rc.xml 2009-07-29 11:50:41 UTC (rev 43910)
@@ -3,7 +3,7 @@
<yanel:resource-config xmlns:yanel="http://www.wyona.org/yanel/rti/1.0">
<yanel:rti name="create-user" namespace="http://www.wyona.org/yanel/resource/1.0"/>
- <yanel:property name="xslt" value="/xslt/usecase.xsl"/>
+ <yanel:property name="xslt" value="yanelhtdocs:/html.xslt"/>
<yanel:custom-config>
<views>
Modified: public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/delete-group_yanel-rc.xml
===================================================================
--- public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/delete-group_yanel-rc.xml 2009-07-29 10:20:05 UTC (rev 43909)
+++ public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/delete-group_yanel-rc.xml 2009-07-29 11:50:41 UTC (rev 43910)
@@ -3,7 +3,7 @@
<yanel:resource-config xmlns:yanel="http://www.wyona.org/yanel/rti/1.0">
<yanel:rti name="delete-group" namespace="http://www.wyona.org/yanel/resource/1.0"/>
- <yanel:property name="xslt" value="/xslt/usecase.xsl"/>
+ <yanel:property name="xslt" value="yanelhtdocs:/html.xslt"/>
<yanel:custom-config>
<views>
Modified: public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/delete-user_yanel-rc.xml
===================================================================
--- public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/delete-user_yanel-rc.xml 2009-07-29 10:20:05 UTC (rev 43909)
+++ public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/delete-user_yanel-rc.xml 2009-07-29 11:50:41 UTC (rev 43910)
@@ -3,7 +3,7 @@
<yanel:resource-config xmlns:yanel="http://www.wyona.org/yanel/rti/1.0">
<yanel:rti name="delete-user" namespace="http://www.wyona.org/yanel/resource/1.0"/>
- <yanel:property name="xslt" value="/xslt/usecase.xsl"/>
+ <yanel:property name="xslt" value="yanelhtdocs:/html.xslt"/>
<yanel:custom-config>
<views>
Modified: public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/list-groups_yanel-rc.xml
===================================================================
--- public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/list-groups_yanel-rc.xml 2009-07-29 10:20:05 UTC (rev 43909)
+++ public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/list-groups_yanel-rc.xml 2009-07-29 11:50:41 UTC (rev 43910)
@@ -3,7 +3,7 @@
<yanel:resource-config xmlns:yanel="http://www.wyona.org/yanel/rti/1.0">
<yanel:rti name="list-groups" namespace="http://www.wyona.org/yanel/resource/1.0"/>
- <yanel:property name="xslt" value="/xslt/usecase.xsl"/>
+ <yanel:property name="xslt" value="yanelhtdocs:/html.xslt"/>
<yanel:custom-config>
<views>
Modified: public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/list-users_yanel-rc.xml
===================================================================
--- public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/list-users_yanel-rc.xml 2009-07-29 10:20:05 UTC (rev 43909)
+++ public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/list-users_yanel-rc.xml 2009-07-29 11:50:41 UTC (rev 43910)
@@ -3,7 +3,7 @@
<yanel:resource-config xmlns:yanel="http://www.wyona.org/yanel/rti/1.0">
<yanel:rti name="list-users" namespace="http://www.wyona.org/yanel/resource/1.0"/>
- <yanel:property name="xslt" value="/xslt/usecase.xsl"/>
+ <yanel:property name="xslt" value="yanelhtdocs:/html.xslt"/>
<yanel:custom-config>
<views>
Modified: public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/update-user-admin_yanel-rc.xml
===================================================================
--- public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/update-user-admin_yanel-rc.xml 2009-07-29 10:20:05 UTC (rev 43909)
+++ public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/update-user-admin_yanel-rc.xml 2009-07-29 11:50:41 UTC (rev 43910)
@@ -3,7 +3,7 @@
<yanel:resource-config xmlns:yanel="http://www.wyona.org/yanel/rti/1.0">
<yanel:rti name="update-user" namespace="http://www.wyona.org/yanel/resource/1.0"/>
- <yanel:property name="xslt" value="/xslt/usecase.xsl"/>
+ <yanel:property name="xslt" value="yanelhtdocs:/html.xslt"/>
<yanel:property name="allowEditGroups" value="true"/>
<yanel:property name="verifyPassword" value="false"/>
Modified: public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/update-user_yanel-rc.xml
===================================================================
--- public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/update-user_yanel-rc.xml 2009-07-29 10:20:05 UTC (rev 43909)
+++ public/yanel/trunk/src/webapp/global-resource-configs/user-mgmt/update-user_yanel-rc.xml 2009-07-29 11:50:41 UTC (rev 43910)
@@ -3,7 +3,7 @@
<yanel:resource-config xmlns:yanel="http://www.wyona.org/yanel/rti/1.0">
<yanel:rti name="update-user" namespace="http://www.wyona.org/yanel/resource/1.0"/>
- <yanel:property name="xslt" value="/xslt/usecase.xsl"/>
+ <yanel:property name="xslt" value="yanelhtdocs:/html.xslt"/>
<yanel:property name="allowEditGroups" value="false"/>
<yanel:property name="verifyPassword" value="true"/>
Copied: public/yanel/trunk/src/webapp/htdocs/html.xslt (from rev 43897, public/yanel/trunk/src/realms/yanel-website/content/xslt/usecase.xsl)
===================================================================
--- public/yanel/trunk/src/webapp/htdocs/html.xslt (rev 0)
+++ public/yanel/trunk/src/webapp/htdocs/html.xslt 2009-07-29 11:50:41 UTC (rev 43910)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:yanel="http://www.wyona.org/yanel/1.0">
+
+ <xsl:param name="yanel.back2realm" select="'BACK2REALM_IS_NULL'"/>
+ <xsl:param name="yanel.reservedPrefix" select="'RESERVEDPREFIX_IS_NULL'"/>
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <link rel="stylesheet" href="{$yanel.back2realm}{$yanel.reservedPrefix}/yanel-css/global.css" type="text/css"/>
+ <xsl:apply-templates select="/xhtml:html/xhtml:head/*"/>
+ </head>
+ <body>
+ <table cellspacing="0" cellpadding="0" id="bodytable">
+ <tr>
+ <td id="title"></td>
+ <td id="logo">
+ <img src="{$yanel.back2realm}{$yanel.reservedPrefix}/yanel-img/yanel_header.png"/>
+ </td>
+ </tr>
+ <tr>
+ <td width="100%" valign="top" colspan="2">
+ <div id="content">
+ <xsl:apply-templates select="/xhtml:html/xhtml:body/*"/>
+ </div>
+ </td>
+ </tr>
+ </table>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="@*|node()">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+
+</xsl:stylesheet>
Property changes on: public/yanel/trunk/src/webapp/htdocs/html.xslt
___________________________________________________________________
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
More information about the Yanel-commits
mailing list