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/08/04 16:54:59 UTC
svn commit: r227407 - in /lenya/trunk/src:
java/org/apache/lenya/cms/jcr/LenyaRepository.java
webapp/WEB-INF/cocoon-xconf.xsl
Author: andreas
Date: Thu Aug 4 07:54:52 2005
New Revision: 227407
URL: http://svn.apache.org/viewcvs?rev=227407&view=rev
Log:
Added Lenya-specific JCR repository implementation which adds the JCR session to the Cocoon session.
Added:
lenya/trunk/src/java/org/apache/lenya/cms/jcr/LenyaRepository.java
Modified:
lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
Added: lenya/trunk/src/java/org/apache/lenya/cms/jcr/LenyaRepository.java
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/jcr/LenyaRepository.java?rev=227407&view=auto
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/jcr/LenyaRepository.java (added)
+++ lenya/trunk/src/java/org/apache/lenya/cms/jcr/LenyaRepository.java Thu Aug 4 07:54:52 2005
@@ -0,0 +1,59 @@
+/*
+ * 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.jcr;
+
+import java.util.Map;
+
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.RepositoryException;
+
+import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.jcr.JackrabbitRepository;
+
+/**
+ * Lenya-specific repository implementation.
+ */
+public class LenyaRepository extends JackrabbitRepository {
+
+ protected static final String SESSION_ATTRIBUTE = javax.jcr.Session.class.getName();
+
+ /**
+ * @see javax.jcr.Repository#login()
+ */
+ public javax.jcr.Session login() throws LoginException, NoSuchWorkspaceException, RepositoryException {
+
+ javax.jcr.Session jcrSession = null;
+
+ Map objectModel = ContextHelper.getObjectModel(this.context);
+ Request request = ObjectModelHelper.getRequest(objectModel);
+ Session session = request.getSession(false);
+ if (session != null) {
+ jcrSession = (javax.jcr.Session) session.getAttribute(SESSION_ATTRIBUTE);
+ if (jcrSession == null) {
+ jcrSession = super.login();
+ session.setAttribute(SESSION_ATTRIBUTE, jcrSession);
+ }
+ }
+
+ return jcrSession;
+ }
+
+}
Modified: lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl?rev=227407&r1=227406&r2=227407&view=diff
==============================================================================
--- lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl (original)
+++ lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl Thu Aug 4 07:54:52 2005
@@ -588,6 +588,11 @@
</xsl:template>
+ <xsl:template match="component[@role = 'javax.jcr.Repository']/@class">
+ <xsl:attribute name="class">org.apache.lenya.cms.jcr.LenyaRepository</xsl:attribute>
+ </xsl:template>
+
+
<xsl:template match="datasources">
<xsl:copy>
<jdbc logger="core.datasources.lenya.scheduler" name="LenyaScheduler">
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org
Re: svn commit: r227407 - in /lenya/trunk/src: java/org/apache/lenya/cms/jcr/LenyaRepository.java
webapp/WEB-INF/cocoon-xconf.xsl
Posted by Doug Chestnut <dh...@virginia.edu>.
Just a reminder that you now need the latest cocoon2.1.x from svn for
the lenya trunk to build :).
--Doug
C:\src\lenya-1.4.x.WEBDAV\src\java\org\apache\lenya\cms\jcr\LenyaRepository.java
:21: package javax.jcr does not exist
import javax.jcr.LoginException;
^
C:\src\lenya-1.4.x.WEBDAV\src\java\org\apache\lenya\cms\jcr\LenyaRepository.java
:22: package javax.jcr does not exist
import javax.jcr.NoSuchWorkspaceException;
^
C:\src\lenya-1.4.x.WEBDAV\src\java\org\apache\lenya\cms\jcr\LenyaRepository.java
:23: package javax.jcr does not exist
import javax.jcr.RepositoryException;
^
C:\src\lenya-1.4.x.WEBDAV\src\java\org\apache\lenya\cms\jcr\LenyaRepository.java
:29: package org.apache.cocoon.jcr does not exist
import org.apache.cocoon.jcr.JackrabbitRepository;
^
C:\src\lenya-1.4.x.WEBDAV\src\java\org\apache\lenya\cms\jcr\LenyaRepository.java
:34: cannot resolve symbol
symbol : class JackrabbitRepository
location: class org.apache.lenya.cms.jcr.LenyaRepository
public class LenyaRepository extends JackrabbitRepository {
^
C:\src\lenya-1.4.x.WEBDAV\src\java\org\apache\lenya\cms\jcr\LenyaRepository.java
:41: package javax.jcr does not exist
public javax.jcr.Session login() throws LoginException,
NoSuchWorkspaceExcep
tion, RepositoryException {
^
C:\src\lenya-1.4.x.WEBDAV\src\java\org\apache\lenya\cms\jcr\LenyaRepository.java
:41: cannot resolve symbol
symbol : class LoginException
location: class org.apache.lenya.cms.jcr.LenyaRepository
public javax.jcr.Session login() throws LoginException,
NoSuchWorkspaceExcep
tion, RepositoryException {
^
C:\src\lenya-1.4.x.WEBDAV\src\java\org\apache\lenya\cms\jcr\LenyaRepository.java
:41: cannot resolve symbol
symbol : class NoSuchWorkspaceException
location: class org.apache.lenya.cms.jcr.LenyaRepository
public javax.jcr.Session login() throws LoginException,
NoSuchWorkspaceExcep
tion, RepositoryException {
^
C:\src\lenya-1.4.x.WEBDAV\src\java\org\apache\lenya\cms\jcr\LenyaRepository.java
:41: cannot resolve symbol
symbol : class RepositoryException
location: class org.apache.lenya.cms.jcr.LenyaRepository
public javax.jcr.Session login() throws LoginException,
NoSuchWorkspaceExcep
tion, RepositoryException {
andreas@apache.org wrote:
> Author: andreas
> Date: Thu Aug 4 07:54:52 2005
> New Revision: 227407
>
> URL: http://svn.apache.org/viewcvs?rev=227407&view=rev
> Log:
> Added Lenya-specific JCR repository implementation which adds the JCR session to the Cocoon session.
>
> Added:
> lenya/trunk/src/java/org/apache/lenya/cms/jcr/LenyaRepository.java
> Modified:
> lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
>
> Added: lenya/trunk/src/java/org/apache/lenya/cms/jcr/LenyaRepository.java
> URL: http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/jcr/LenyaRepository.java?rev=227407&view=auto
> ==============================================================================
> --- lenya/trunk/src/java/org/apache/lenya/cms/jcr/LenyaRepository.java (added)
> +++ lenya/trunk/src/java/org/apache/lenya/cms/jcr/LenyaRepository.java Thu Aug 4 07:54:52 2005
> @@ -0,0 +1,59 @@
> +/*
> + * 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.jcr;
> +
> +import java.util.Map;
> +
> +import javax.jcr.LoginException;
> +import javax.jcr.NoSuchWorkspaceException;
> +import javax.jcr.RepositoryException;
> +
> +import org.apache.cocoon.components.ContextHelper;
> +import org.apache.cocoon.environment.ObjectModelHelper;
> +import org.apache.cocoon.environment.Request;
> +import org.apache.cocoon.environment.Session;
> +import org.apache.cocoon.jcr.JackrabbitRepository;
> +
> +/**
> + * Lenya-specific repository implementation.
> + */
> +public class LenyaRepository extends JackrabbitRepository {
> +
> + protected static final String SESSION_ATTRIBUTE = javax.jcr.Session.class.getName();
> +
> + /**
> + * @see javax.jcr.Repository#login()
> + */
> + public javax.jcr.Session login() throws LoginException, NoSuchWorkspaceException, RepositoryException {
> +
> + javax.jcr.Session jcrSession = null;
> +
> + Map objectModel = ContextHelper.getObjectModel(this.context);
> + Request request = ObjectModelHelper.getRequest(objectModel);
> + Session session = request.getSession(false);
> + if (session != null) {
> + jcrSession = (javax.jcr.Session) session.getAttribute(SESSION_ATTRIBUTE);
> + if (jcrSession == null) {
> + jcrSession = super.login();
> + session.setAttribute(SESSION_ATTRIBUTE, jcrSession);
> + }
> + }
> +
> + return jcrSession;
> + }
> +
> +}
>
> Modified: lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl
> URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl?rev=227407&r1=227406&r2=227407&view=diff
> ==============================================================================
> --- lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl (original)
> +++ lenya/trunk/src/webapp/WEB-INF/cocoon-xconf.xsl Thu Aug 4 07:54:52 2005
> @@ -588,6 +588,11 @@
> </xsl:template>
>
>
> + <xsl:template match="component[@role = 'javax.jcr.Repository']/@class">
> + <xsl:attribute name="class">org.apache.lenya.cms.jcr.LenyaRepository</xsl:attribute>
> + </xsl:template>
> +
> +
> <xsl:template match="datasources">
> <xsl:copy>
> <jdbc logger="core.datasources.lenya.scheduler" name="LenyaScheduler">
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
> For additional commands, e-mail: commits-help@lenya.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org