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: r533723 - in /lenya/trunk/src: java/org/apache/lenya/cms/cocoon: msg#00241

cms.lenya.cvs

Subject: svn commit: r533723 - in /lenya/trunk/src: java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java

Author: andreas
Date: Mon Apr 30 05:34:26 2007
New Revision: 533723

URL: http://svn.apache.org/viewvc?view=rev&rev=533723
Log:
Move session selection from DocumentSourceFactory to LenyaSourceFactory. This
fixes bugs 42237 and 42266.

Modified:

lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java

lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java

Modified:
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java?view=diff&rev=533723&r1=533722&r2=533723
==============================================================================
---
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java
(original)
+++
lenya/trunk/src/java/org/apache/lenya/cms/cocoon/source/LenyaSourceFactory.java
Mon Apr 30 05:34:26 2007
@@ -20,6 +20,8 @@
import java.net.MalformedURLException;
import java.util.Map;

+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
@@ -29,6 +31,10 @@
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.components.flow.FlowHelper;
+import org.apache.cocoon.components.modules.input.JXPathHelper;
+import org.apache.cocoon.components.modules.input.JXPathHelperConfiguration;
+import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
@@ -37,6 +43,7 @@
import org.apache.lenya.cms.repository.RepositoryException;
import org.apache.lenya.cms.repository.RepositoryUtil;
import org.apache.lenya.cms.repository.Session;
+import org.apache.lenya.util.Query;

/**
* A factory for the "lenya" scheme (virtual protocol), which is used to
resolve any src="lenya:..."
@@ -79,10 +86,17 @@
public Source getSource(final String location, final Map parameters)
throws MalformedURLException, IOException, SourceException {

- Request request = ContextHelper.getRequest(this.context);
+ String sessionName = null;
+
+ String[] uriAndQuery = location.split("\\?");
+ if (uriAndQuery.length > 1) {
+ Query query = new Query(uriAndQuery[1]);
+ sessionName = query.getValue("session");
+ }
+
Session session;
try {
- session = RepositoryUtil.getSession(this.manager, request);
+ session = getSession(sessionName);
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
@@ -93,6 +107,33 @@

return new RepositorySource(this.manager, location, session,
getLogger());

+ }
+
+ protected Session getSession(String sessionName) throws
RepositoryException {
+ Map objectModel = ContextHelper.getObjectModel(this.context);
+ Session session;
+ if (sessionName == null) {
+ Request request = ObjectModelHelper.getRequest(objectModel);
+ session = RepositoryUtil.getSession(this.manager, request);
+ } else if (sessionName.equals("usecase")) {
+ session = getUsecaseSession(objectModel);
+ } else {
+ throw new RepositoryException("Invalid session: [" + sessionName +
"]");
+ }
+
+ return session;
+ }
+
+ protected Session getUsecaseSession(Map objectModel) throws
RepositoryException {
+ try {
+ Configuration config = new DefaultConfiguration("foo");
+ JXPathHelperConfiguration helperConfig =
JXPathHelper.setup(config);
+ Object contextObject = FlowHelper.getContextObject(objectModel);
+ return (Session) JXPathHelper.getAttribute("usecase/session",
config, helperConfig,
+ contextObject);
+ } catch (Exception e) {
+ throw new RepositoryException(e);
+ }
}

/**

Modified:
lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java
URL:
http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java?view=diff&rev=533723&r1=533722&r2=533723
==============================================================================
---
lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java
(original)
+++
lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/source/DocumentSourceFactory.java
Mon Apr 30 05:34:26 2007
@@ -24,7 +24,6 @@
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.configuration.DefaultConfiguration;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
@@ -34,9 +33,6 @@
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.components.flow.FlowHelper;
-import org.apache.cocoon.components.modules.input.JXPathHelper;
-import org.apache.cocoon.components.modules.input.JXPathHelperConfiguration;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.excalibur.source.Source;
@@ -49,9 +45,6 @@
import org.apache.lenya.cms.publication.DocumentException;
import org.apache.lenya.cms.publication.DocumentFactory;
import org.apache.lenya.cms.publication.DocumentUtil;
-import org.apache.lenya.cms.repository.RepositoryException;
-import org.apache.lenya.cms.repository.RepositoryUtil;
-import org.apache.lenya.cms.repository.Session;
import org.apache.lenya.util.Query;
import org.apache.lenya.util.ServletHelper;

@@ -162,32 +155,6 @@
throw new RuntimeException(e);
}

- }
-
- protected Session getSession(Map objectModel, String sessionName) throws
RepositoryException {
- Session session;
- if (sessionName == null) {
- Request request = ObjectModelHelper.getRequest(objectModel);
- session = RepositoryUtil.getSession(this.manager, request);
- } else if (sessionName.equals("usecase")) {
- session = getUsecaseSession(objectModel);
- } else {
- throw new RepositoryException("Invalid session: [" + sessionName +
"]");
- }
-
- return session;
- }
-
- protected Session getUsecaseSession(Map objectModel) throws
RepositoryException {
- try {
- Configuration config = new DefaultConfiguration("foo");
- JXPathHelperConfiguration helperConfig =
JXPathHelper.setup(config);
- Object contextObject = FlowHelper.getContextObject(objectModel);
- return (Session) JXPathHelper.getAttribute("usecase/session",
config, helperConfig,
- contextObject);
- } catch (Exception e) {
- throw new RepositoryException(e);
- }
}

protected Source getFormatSource(Document doc, String format) throws
DocumentException,


<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