Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

svn commit: r240170 - in /lenya/trunk/src/publets/lenyadoc: ./ config/ java: msg#00076

cms.lenya.cvs

Subject: svn commit: r240170 - in /lenya/trunk/src/publets/lenyadoc: ./ config/ java/ java/src/ java/src/org/ java/src/org/apache/ java/src/org/apache/lenya/ java/src/org/apache/lenya/cms/ java/src/org/apache/lenya/cms/cocoon/ java/src/org/apache/lenya/cms/coco...

Author: andreas
Date: Thu Aug 25 23:46:46 2005
New Revision: 240170

URL: http://svn.apache.org/viewcvs?rev=240170&view=rev
Log:
Added lenyadoc:// protocol publet. This fixes bug #36360. Thanks to Felix
Roethenbacher.

Added:
lenya/trunk/src/publets/lenyadoc/
lenya/trunk/src/publets/lenyadoc/config/
lenya/trunk/src/publets/lenyadoc/config/publet.xconf
lenya/trunk/src/publets/lenyadoc/java/
lenya/trunk/src/publets/lenyadoc/java/src/
lenya/trunk/src/publets/lenyadoc/java/src/org/
lenya/trunk/src/publets/lenyadoc/java/src/org/apache/
lenya/trunk/src/publets/lenyadoc/java/src/org/apache/lenya/
lenya/trunk/src/publets/lenyadoc/java/src/org/apache/lenya/cms/
lenya/trunk/src/publets/lenyadoc/java/src/org/apache/lenya/cms/cocoon/

lenya/trunk/src/publets/lenyadoc/java/src/org/apache/lenya/cms/cocoon/source/

lenya/trunk/src/publets/lenyadoc/java/src/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java

Added: lenya/trunk/src/publets/lenyadoc/config/publet.xconf
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/publets/lenyadoc/config/publet.xconf?rev=240170&view=auto
==============================================================================
--- lenya/trunk/src/publets/lenyadoc/config/publet.xconf (added)
+++ lenya/trunk/src/publets/lenyadoc/config/publet.xconf Thu Aug 25 23:46:46
2005
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+ Copyright 1999-2004 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Id:$ -->
+
+<xconf xpath="/cocoon/source-factories"
unless="/cocoon/source-factories/component-instance[@name = 'lenyadoc']">
+
+ <component-instance logger="" name="lenyadoc"
+ class="org.apache.lenya.cms.cocoon.source.LenyaDocSourceFactory"/>
+
+</xconf>

Added:
lenya/trunk/src/publets/lenyadoc/java/src/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java
URL:
http://svn.apache.org/viewcvs/lenya/trunk/src/publets/lenyadoc/java/src/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java?rev=240170&view=auto
==============================================================================
---
lenya/trunk/src/publets/lenyadoc/java/src/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java
(added)
+++
lenya/trunk/src/publets/lenyadoc/java/src/org/apache/lenya/cms/cocoon/source/LenyaDocSourceFactory.java
Thu Aug 25 23:46:46 2005
@@ -0,0 +1,208 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.cocoon.source;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Map;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceException;
+import org.apache.excalibur.source.SourceFactory;
+import org.apache.lenya.ac.Identity;
+import org.apache.lenya.cms.publication.DocumentIdentityMap;
+import org.apache.lenya.cms.publication.PageEnvelope;
+import org.apache.lenya.cms.publication.PageEnvelopeException;
+import org.apache.lenya.cms.publication.PageEnvelopeFactory;
+import org.apache.lenya.cms.repository.Session;
+
+/**
+ * A factory for the "lenyadoc" scheme (virtual protocol), which is used to
resolve any
+ * src="lenyadoc:<...>" attributes in sitemaps.
+ *
+ * <code>lenyadoc://<publication>/<area>/<language>/<document-id></code>
+ * <code>lenyadoc:/<language>/<document-id></code>
+ *
+ * @version $Id:$
+ */
+public class LenyaDocSourceFactory extends AbstractLogEnabled implements
SourceFactory, ThreadSafe,
+ Contextualizable, Serviceable, Configurable {
+
+ protected static final String SCHEME = "lenyadoc";
+
+ private Context context;
+ private ServiceManager manager;
+
+ /**
+ * Used for resolving the object model.
+ * @see
org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+ */
+ public void contextualize(Context context) throws ContextException {
+ this.context = context;
+ }
+
+ /**
+ * @see
org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+ */
+ public void service(ServiceManager manager) throws ServiceException {
+ this.manager = manager;
+ }
+
+ /**
+ * @see
org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+ */
+ public void configure(Configuration configuration) throws
ConfigurationException {
+ }
+
+ /**
+ * @see
org.apache.excalibur.source.SourceFactory#getSource(java.lang.String,
java.util.Map)
+ */
+ 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;
+
+ // Parse the url
+ int start = 0;
+ int end;
+
+ // Scheme
+ end = location.indexOf(':', start);
+ if (end == -1) {
+ throw new MalformedURLException("Malformed lenyadoc: URI: can not
find scheme part ["
+ + location + "]");
+ }
+ scheme = location.substring(start, end);
+ if (!SCHEME.equals(scheme)) {
+ throw new MalformedURLException("Malformed lenyadoc: URI: unknown
scheme [" + location
+ + "]");
+ }
+
+ // Absolute vs. relative
+ start = end + 1;
+ if (location.startsWith("//", start)) {
+ // Absolute: get publication id
+ start += 2;
+ end = location.indexOf('/', start);
+ if (end == -1) {
+ throw new MalformedURLException("Malformed lenyadoc: URI:
publication part not found ["
+ + location + "]");
+ }
+ publicationId = location.substring(start, end);
+
+ // Area
+ start = end + 1;
+ end = location.indexOf('/', start);
+ if (end == -1) {
+ throw new MalformedURLException("Malformed lenyadoc: URI:
cannot find area ["
+ + location + "]");
+ }
+ area = location.substring(start, end);
+
+ } else if (location.startsWith("/", start)) {
+ end += 1;
+ // Relative: get publication id and area from page envelope
+ Map objectModel = ContextHelper.getObjectModel(this.context);
+ try {
+ DocumentIdentityMap map = new
DocumentIdentityMap(this.manager, getLogger());
+ PageEnvelopeFactory pageEnvelopeFactory =
PageEnvelopeFactory.getInstance();
+
+ if (pageEnvelopeFactory != null) {
+ PageEnvelope pageEnvelope =
pageEnvelopeFactory.getPageEnvelope(map,
+ objectModel);
+
+ if (pageEnvelope != null) {
+ publicationId = pageEnvelope.getPublication().getId();
+ area = pageEnvelope.getArea();
+ } else {
+ throw new SourceException("Error getting publication
id / area from page envelope ["
+ + location + "]");
+ }
+ } else {
+ throw new SourceException("Error getting publication id /
area from page envelope ["
+ + location + "]");
+ }
+ } catch (final PageEnvelopeException e) {
+ throw new SourceException("Error getting publication id / area
from page envelope ["
+ + location + "]",
+ e);
+ }
+ } else {
+ throw new MalformedURLException("Malformed lenyadoc: URI [" +
location + "]");
+ }
+
+ // Language
+ start = end + 1;
+ end = location.indexOf('/', start);
+ if (end == -1) {
+ throw new MalformedURLException("Malformed lenyadoc: URI: cannot
find language ["
+ + location + "]");
+ }
+ language = location.substring(start, end);
+
+ // Document id
+ start = end + 1;
+ docId = location.substring(start);
+
+ Request request = ContextHelper.getRequest(this.context);
+ Session session = (Session)
request.getAttribute(Session.class.getName());
+ if (session == null) {
+ Identity identity = (Identity) request.getSession(false)
+ .getAttribute(Identity.class.getName());
+ session = new Session(identity, getLogger());
+ }
+
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Creating repository source for URI [" +
location + "]");
+ }
+
+ // TODO: Replace hardcoded Lenya document structure
+ String lenyaURL = "lenya://lenya/pubs/" + publicationId + "/content/"
+ area + docId
+ + "/index_" + language + ".xml";
+
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Mapping 'lenyadoc:' URL [" + location + "] to
'lenya:' URL ["
+ + lenyaURL + "]");
+ getLogger().debug("Creating repository source for URI [" +
lenyaURL + "]");
+ }
+
+ return new RepositorySource(manager, lenyaURL, session, getLogger());
+ }
+
+ /**
+ * @see
org.apache.excalibur.source.SourceFactory#release(org.apache.excalibur.source.Source)
+ */
+ public void release(Source source) {
+ // Source will be released by delegated source factory.
+ }
+}
\ No newline at end of file


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
solaris.opensol...    editors.vim/200...    web.turbogears....    jakarta.ant.dev...    mathematics.max...    text.unicode.ge...    lang.ruby.core/...    xfce.announce/2...    network.centeri...    php.cvs.pear/20...    user-groups.lin...    kde.devel.quant...    file-systems.ar...    redhat.fedora.t...    apple.fink.auto...    gnome.orbit.gen...    qplus.devel/200...    culture.transpo...    video.dri.user/...    operators.nanog...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation