You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2005/10/24 14:44:14 UTC
svn commit: r328050 - in /lenya/trunk/src/modules:
lenyadoc/java/src/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java
xhtml/sitemap.xmap
Author: andreas
Date: Mon Oct 24 05:44:04 2005
New Revision: 328050
URL: http://svn.apache.org/viewcvs?rev=328050&view=rev
Log:
lenyadoc:/ builds document to retrieve source URL instead of hard-coding the DocumentIdToPathMapper behaviour.
Modified:
lenya/trunk/src/modules/lenyadoc/java/src/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java
lenya/trunk/src/modules/xhtml/sitemap.xmap
Modified: lenya/trunk/src/modules/lenyadoc/java/src/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/lenyadoc/java/src/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java?rev=328050&r1=328049&r2=328050&view=diff
==============================================================================
--- lenya/trunk/src/modules/lenyadoc/java/src/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java (original)
+++ lenya/trunk/src/modules/lenyadoc/java/src/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java Mon Oct 24 05:44:04 2005
@@ -37,6 +37,9 @@
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.SourceFactory;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentBuildException;
+import org.apache.lenya.cms.publication.DocumentIdentityMap;
import org.apache.lenya.cms.publication.Publication;
import org.apache.lenya.cms.publication.PublicationException;
import org.apache.lenya.cms.publication.PublicationUtil;
@@ -89,10 +92,10 @@
public Source getSource(String location, Map parameters) throws MalformedURLException,
IOException, SourceException {
String scheme = null;
- String publicationId = null;
String area = null;
String language = null;
String docId = null;
+ Publication pub;
// Parse the url
int start = 0;
@@ -120,7 +123,13 @@
throw new MalformedURLException("Malformed lenyadoc: URI: publication part not found ["
+ location + "]");
}
- publicationId = location.substring(start, end);
+ String publicationId = location.substring(start, end);
+ try {
+ pub = PublicationUtil.getPublication(this.manager, publicationId);
+ } catch (PublicationException e) {
+ throw new MalformedURLException("Malformed lenyadoc: Publication [" + publicationId
+ + "] does not exist or could not be initialized");
+ }
// Area
start = end + 1;
@@ -136,7 +145,6 @@
// Relative: get publication id and area from page envelope
Map objectModel = ContextHelper.getObjectModel(this.context);
Request request = ObjectModelHelper.getRequest(objectModel);
- Publication pub;
try {
pub = PublicationUtil.getPublication(this.manager, objectModel);
} catch (PublicationException e) {
@@ -144,7 +152,6 @@
+ location + "]");
}
if (pub != null && pub.exists()) {
- publicationId = pub.getId();
String url = ServletHelper.getWebappURI(request);
area = new URLInformation(url).getArea();
} else {
@@ -174,10 +181,15 @@
if (getLogger().isDebugEnabled()) {
getLogger().debug("Creating repository source for URI [" + location + "]");
}
+ DocumentIdentityMap map = new DocumentIdentityMap(session, this.manager, getLogger());
+ Document document;
+ try {
+ document = map.get(pub, area, docId, language);
+ } catch (DocumentBuildException e) {
+ throw new MalformedURLException("Malformed lenyadoc: Document [" + docId + "] could not be created.");
+ }
- // TODO: Replace hardcoded Lenya document structure
- String lenyaURL = "lenya://lenya/pubs/" + publicationId + "/content/" + area + docId
- + "/index_" + language + ".xml";
+ String lenyaURL = document.getSourceURI();
if (getLogger().isDebugEnabled()) {
getLogger().debug("Mapping 'lenyadoc:' URL [" + location + "] to 'lenya:' URL ["
Modified: lenya/trunk/src/modules/xhtml/sitemap.xmap
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/modules/xhtml/sitemap.xmap?rev=328050&r1=328049&r2=328050&view=diff
==============================================================================
--- lenya/trunk/src/modules/xhtml/sitemap.xmap (original)
+++ lenya/trunk/src/modules/xhtml/sitemap.xmap Mon Oct 24 05:44:04 2005
@@ -40,7 +40,7 @@
<!-- parametrized doctype matcher -->
<!-- pattern="{rendertype}" -->
<map:match pattern="*.xml">
- <map:generate src="lenya://lenya/pubs/{page-envelope:publication-id}/content/{page-envelope:area}/{page-envelope:document-path}"/>
+ <map:generate src="lenyadoc:/{page-envelope:document-language}/{page-envelope:document-id}"/>
<map:transform src="fallback://lenya/modules/xhtml/xslt/xhtml2xhtml.xsl">
<map:parameter name="rendertype" value="{request-param:rendertype}"/>
<map:parameter name="nodeid" value="{page-envelope:document-name}"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org