portals-portalapps-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r946121 [1/3] - in /portals/applications/sandbox/content/trunk: ./ apa-content-portlet/ apa-content-portlet/src/ apa-content-portlet/src/main/ apa-content-portlet/src/main/java/ apa-content-portlet/src/main/java/org/ apa-content-portlet/src...
Date Wed, 19 May 2010 10:57:17 GMT
Author: woonsan
Date: Wed May 19 10:57:15 2010
New Revision: 946121

URL: http://svn.apache.org/viewvc?rev=946121&view=rev
Log:
Restructuring projects

Added:
    portals/applications/sandbox/content/trunk/apa-content-portlet/
    portals/applications/sandbox/content/trunk/apa-content-portlet/pom.xml   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/DynamicContentPortlet.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/NewsItemPortlet.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/HtmlBodyContent.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/NewsItem.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/TextPage.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DefaultObjectContentManagerProvider.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DelegatingObjectContentManagerProvider.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProvider.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProviderObjectFactory.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/RepositoryObjectFactory.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/tools/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/tools/ant/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/demo/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/demo/resources/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/demo/resources/NewsItemPortlet.properties   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/resources/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/resources/GenericContentPortlet.properties   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/resources/GenericQueryContentPortlet.properties   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/resources/GenericSearchQueryContentPortlet.properties   (with props)
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/webapp/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/webapp/META-INF/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/webapp/WEB-INF/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/webapp/WEB-INF/classes/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/webapp/WEB-INF/tool/
    portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/webapp/WEB-INF/view/
    portals/applications/sandbox/content/trunk/apa-content-tools/   (with props)
    portals/applications/sandbox/content/trunk/apa-content-tools/pom.xml   (with props)
    portals/applications/sandbox/content/trunk/apa-content-tools/src/
    portals/applications/sandbox/content/trunk/apa-content-tools/src/main/
    portals/applications/sandbox/content/trunk/apa-content-tools/src/main/java/
    portals/applications/sandbox/content/trunk/apa-content-tools/src/main/java/org/
    portals/applications/sandbox/content/trunk/apa-content-tools/src/main/java/org/apache/
    portals/applications/sandbox/content/trunk/apa-content-tools/src/main/java/org/apache/portals/
    portals/applications/sandbox/content/trunk/apa-content-tools/src/main/java/org/apache/portals/applications/
    portals/applications/sandbox/content/trunk/apa-content-tools/src/main/java/org/apache/portals/applications/content/
    portals/applications/sandbox/content/trunk/apa-content-tools/src/main/java/org/apache/portals/applications/content/tools/
    portals/applications/sandbox/content/trunk/apa-content-tools/src/main/java/org/apache/portals/applications/content/tools/ant/
    portals/applications/sandbox/content/trunk/apa-content-tools/src/main/java/org/apache/portals/applications/content/tools/ant/AbstractRepositoryTask.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-tools/src/main/java/org/apache/portals/applications/content/tools/ant/Import.java   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/
    portals/applications/sandbox/content/trunk/apa-content-webapp/pom.xml   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/META-INF/
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/META-INF/context.xml   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/classes/
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/classes/log4j.properties   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/portlet.xml   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/tool/
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/generic-content-edit.jsp   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/generic-content-help.jsp   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/generic-content-view.jsp   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/generic-query-content-edit.jsp   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/generic-query-content-help.jsp   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/generic-query-content-view.jsp   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/generic-search-query-content-help.jsp   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/generic-search-query-content-view.jsp   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/news-item-view.jsp   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/simple-search-query-content-edit.jsp   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/simple-search-query-content-help.jsp   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/view/simple-search-query-content-view.jsp   (with props)
    portals/applications/sandbox/content/trunk/apa-content-webapp/src/main/webapp/WEB-INF/web.xml   (with props)
    portals/applications/sandbox/content/trunk/pom.xml   (with props)
Removed:
    portals/applications/sandbox/content/trunk/src/
Modified:
    portals/applications/sandbox/content/trunk/build.xml

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/pom.xml
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/pom.xml?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/pom.xml (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/pom.xml Wed May 19 10:57:15 2010
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements. See the NOTICE file distributed with this
+  work for additional information regarding copyright ownership. The ASF
+  licenses this file to You 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$
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <!-- POM Identification -->
+  <parent>
+    <groupId>org.apache.portals.applications</groupId>
+    <artifactId>apa-content</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>apa-content-portlet</artifactId>
+  <packaging>jar</packaging>
+  <name>Apache Portals Applications Content Portlet</name>
+  <description>Content Portlet Application Portlet</description>
+
+  <dependencies>
+    
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.portals.jetspeed-2</groupId>
+      <artifactId>jetspeed-api</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.portals</groupId>
+      <artifactId>portlet-api_2.0_spec</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.portals.bridges</groupId>
+      <artifactId>portals-bridges-common</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.ant</groupId>
+      <artifactId>ant</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    
+    <dependency>
+      <groupId>javax.jcr</groupId>
+      <artifactId>jcr</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-jcr-rmi</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-ocm</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-jta_1.1_spec</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <!-- only include this in top level project poms -->
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <skipAssembly>true</skipAssembly>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  
+</project>

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/DynamicContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/DynamicContentPortlet.java?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/DynamicContentPortlet.java (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/DynamicContentPortlet.java Wed May 19 10:57:15 2010
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portals.applications.content;
+
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.jetspeed.request.RequestContext;
+
+/**
+ * DynamicContentPortlet
+ * 
+ * @version $Id$
+ */
+public class DynamicContentPortlet extends GenericContentPortlet 
+{
+    
+    @Override
+    protected String getContentPath(final PortletRequest request) throws PortletException
+    {
+        RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
+        String contentBasePath = request.getPreferences().getValue("contentBasePath", null);
+        String basePathInfo = request.getPreferences().getValue("basePathInfo", null);
+        
+        if (StringUtils.isBlank(contentBasePath) || StringUtils.isBlank(basePathInfo))
+        {
+            throw new PortletException("Required contentBasePath and portalBasePath preferences are not set!");
+        }
+        
+        String requestPathInfo = rc.getPath();
+        
+        if (!requestPathInfo.startsWith(basePathInfo))
+        {
+            throw new PortletException("Unable to map portal request path: " + requestPathInfo + " onto base path info: " + basePathInfo);
+        }
+        
+        return contentBasePath + StringUtils.substringAfter(requestPathInfo, basePathInfo);
+    }
+    
+}

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/DynamicContentPortlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/DynamicContentPortlet.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java Wed May 19 10:57:15 2010
@@ -0,0 +1,333 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portals.applications.content;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.jcr.Credentials;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+import org.apache.portals.applications.content.jndi.ObjectContentManagerProvider;
+import org.apache.portals.bridges.common.GenericServletPortlet;
+
+/**
+ * GenericContentPortlet
+ * 
+ * @version $Id$
+ */
+public class GenericContentPortlet extends GenericServletPortlet
+{
+    
+    private String repositoryJndiName = "java:comp/env/jcr/repository";
+    private String defaultRepositoryUsername;
+    private String defaultRepositoryPassword;
+    private String defaultRepositoryWorkspace;
+    
+    private String ocmProviderJndiName = "java:comp/env/jcr/ocmprovider";
+    
+    private String contentBeanAttributeName = "contentBean";
+    
+    private String preferenceRequestParamPrefix = "preference.";
+    
+    @Override
+    public void init(PortletConfig config) throws PortletException 
+    {
+        super.init(config);
+        
+        String param = StringUtils.trim(getInitParameterFromConfigOrContext(config, "repositoryJndiName", null));
+        
+        if (!StringUtils.isBlank(param))
+        {
+            repositoryJndiName = param;
+        }
+        
+        param = StringUtils.trim(getInitParameterFromConfigOrContext(config, "ocmProviderJndiName", null));
+        
+        if (!StringUtils.isBlank(param))
+        {
+            ocmProviderJndiName = param;
+        }
+        
+        param = StringUtils.trim(getInitParameterFromConfigOrContext(config, "defaultRepositoryUsername", null));
+        
+        if (!StringUtils.isBlank(param))
+        {
+            defaultRepositoryUsername = param;
+        }
+        
+        param = StringUtils.trim(getInitParameterFromConfigOrContext(config, "defaultRepositoryPassword", null));
+        
+        if (!StringUtils.isBlank(param))
+        {
+            defaultRepositoryPassword = param;
+        }
+        
+        param = StringUtils.trim(getInitParameterFromConfigOrContext(config, "defaultRepositoryWorkspace", null));
+        
+        if (!StringUtils.isBlank(param))
+        {
+            defaultRepositoryWorkspace = param;
+        }
+        
+        param = StringUtils.trim(getInitParameterFromConfigOrContext(config, "contentBeanAttributeName", null));
+        
+        if (!StringUtils.isBlank(param))
+        {
+            contentBeanAttributeName = param;
+        }
+        
+        param = StringUtils.trim(getInitParameterFromConfigOrContext(config, "contentBeanAttributeName", null));
+        
+        if (param != null)
+        {
+            preferenceRequestParamPrefix = param;
+        }
+    }
+    
+    @Override
+    public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
+    {
+        String contentPath = getContentPath(request);
+        
+        Session session = null;
+        ObjectContentManager ocm = null;
+        
+        try
+        {
+            if (contentPath != null)
+            {
+                session = getSession(request);
+                ocm = getObjectContentManagerProvider().getObjectContentManager(session);
+                
+                Object contentBean = getContentBean(request, ocm, contentPath);
+                
+                if (contentBean != null)
+                {
+                    request.setAttribute(contentBeanAttributeName, contentBean);
+                }
+            }
+            
+            super.doView(request, response);
+            
+        }
+        finally
+        {
+            if (ocm != null)
+            {
+                try
+                {
+                    ocm.logout();
+                }
+                catch (Exception ignore)
+                {
+                }
+            }
+            if (session != null)
+            {
+                try
+                {
+                    session.logout();
+                }
+                catch (Exception ignore)
+                {
+                }
+            }
+        }
+    }
+    
+    @Override
+    public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException
+    {
+        if (isPreferencesStoringAction(request))
+        {
+            processPreferencesAction(request, response);
+        }
+        else
+        {
+            super.processAction(request, response);
+        }
+    }
+    
+    protected Object getContentBean(final PortletRequest request, final ObjectContentManager ocm, final String contentPath) throws PortletException
+    {
+        Object contentBean = ocm.getObject(contentPath);
+        return contentBean;
+    }
+    
+    protected String getContentPath(final PortletRequest request) throws PortletException
+    {
+        return request.getPreferences().getValue("contentPath", null);
+    }
+    
+    protected Repository getRepository() throws NamingException
+    {
+        InitialContext ctx = new InitialContext();
+        return (Repository) ctx.lookup(repositoryJndiName);
+    }
+    
+    protected Credentials getCredentials(final PortletRequest request)
+    {
+        Credentials credentials = null;
+        
+        String username = request.getPreferences().getValue("repositoryUsername", defaultRepositoryUsername);
+        
+        if (!StringUtils.isBlank(username))
+        {
+            String password = request.getPreferences().getValue("repositoryPassword", defaultRepositoryPassword);
+            credentials = new SimpleCredentials(username, password.toCharArray());
+        }
+        
+        return credentials;
+    }
+    
+    protected Session getSession(final PortletRequest request) throws PortletException
+    {
+        Session session = null;
+        
+        try
+        {
+            Credentials credentials = getCredentials(request);
+            String repositoryWorkspace = request.getPreferences().getValue("repositoryWorkspace", defaultRepositoryWorkspace);
+            
+            if (credentials == null)
+            {
+                if (StringUtils.isBlank(repositoryWorkspace))
+                {
+                    session = getRepository().login();
+                }
+                else
+                {
+                    session = getRepository().login(repositoryWorkspace);
+                }
+            }
+            else
+            {
+                if (StringUtils.isBlank(repositoryWorkspace))
+                {
+                    session = getRepository().login(credentials);
+                }
+                else
+                {
+                    session = getRepository().login(credentials, repositoryWorkspace);
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            throw new PortletException("Failed to connect to repository.", e);
+        }
+        
+        return session;
+    }
+    
+    protected ObjectContentManagerProvider getObjectContentManagerProvider() throws PortletException
+    {
+        try
+        {
+            InitialContext ctx = new InitialContext();
+            return (ObjectContentManagerProvider) ctx.lookup(ocmProviderJndiName);
+        }
+        catch (NamingException e)
+        {
+            throw new PortletException("Failed to look up ocm provider resource.");
+        }
+    }
+    
+    protected String getInitParameterFromConfigOrContext(final PortletConfig config, String name, String defaultValue)
+    {
+        String value = config.getInitParameter(name);
+        
+        if (value == null)
+        {
+            value = config.getPortletContext().getInitParameter(name);
+        }
+        
+        return (value != null ? value.trim() : defaultValue);
+    }
+    
+    protected boolean isPreferencesStoringAction(ActionRequest request)
+    {
+        String preferenceActionParamName = StringUtils.join(new Object [] { preferenceRequestParamPrefix, "action" });
+        return ("store".equals(request.getParameter(preferenceActionParamName)));
+    }
+    
+    @Override
+    public void processPreferencesAction(ActionRequest request, ActionResponse response) throws PortletException, IOException
+    {
+        Map<String, String []> params = request.getParameterMap();
+        PortletPreferences prefs = request.getPreferences();
+        Map<String, String []> prefsMap = prefs.getMap();
+
+        try
+        {
+            boolean preferenceRequestParamsPrefixed = !StringUtils.isEmpty(preferenceRequestParamPrefix);
+            
+            for (Map.Entry<String, String []> entry : params.entrySet())
+            {
+                String paramName = entry.getKey();
+                String [] values = entry.getValue();
+                String prefName = null;
+                
+                if (!preferenceRequestParamsPrefixed)
+                {
+                    prefName = paramName;
+                }
+                else
+                {
+                    if (!paramName.startsWith(preferenceRequestParamPrefix))
+                    {
+                        continue;
+                    }
+                    
+                    prefName = paramName.substring(preferenceRequestParamPrefix.length());
+                }
+                
+                if (!prefsMap.containsKey(prefName))
+                {
+                    continue;
+                }
+                
+                prefs.setValue(prefName, values[0]);
+            }
+            
+            prefs.store();
+            
+            response.setPortletMode(PortletMode.VIEW);
+        }
+        catch (Exception e)
+        {
+            throw new PortletException("Exception mapping request Params to Preferences: ", e);
+        }
+    }
+    
+}

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java Wed May 19 10:57:15 2010
@@ -0,0 +1,260 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portals.applications.content;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+import org.apache.jackrabbit.ocm.query.Filter;
+import org.apache.jackrabbit.ocm.query.Query;
+import org.apache.jackrabbit.ocm.query.QueryManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * GenericQueryContentPortlet
+ * 
+ * @version $Id$
+ */
+public class GenericQueryContentPortlet extends GenericContentPortlet 
+{
+    private static Logger log = LoggerFactory.getLogger(GenericQueryContentPortlet.class);
+    
+    private String defaultQueryLanguage = javax.jcr.query.Query.XPATH;
+    
+    @Override
+    public void init(PortletConfig config) throws PortletException 
+    {
+        super.init(config);
+        
+        String param = StringUtils.trim(getInitParameterFromConfigOrContext(config, "defaultQueryLanguage", null));
+        
+        if (!StringUtils.isBlank(param))
+        {
+            defaultQueryLanguage = param;
+        }
+    }
+    
+    @Override
+    public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
+    {
+        String contentUrlBase = request.getPreferences().getValue("contentUrlBase", null);
+        
+        if (contentUrlBase != null)
+        {
+            request.setAttribute("contentUrlBase", contentUrlBase);
+        }
+        
+        super.doView(request, response);
+    }
+    
+    @Override
+    protected Object getContentBean(final PortletRequest request, final ObjectContentManager ocm, final String contentPath) throws PortletException
+    {
+        String queryClassName = request.getPreferences().getValue("queryClass", null);
+        
+        if (StringUtils.isBlank(queryClassName))
+        {
+            throw new PortletException("No query class provided.");
+        }
+        
+        int pageIndex = 1;
+        String param = request.getParameter("page");
+        
+        if (!StringUtils.isBlank(param))
+        {
+            try 
+            {
+                pageIndex = Math.max(1, Integer.parseInt(param.trim())); 
+            }
+            catch (NumberFormatException e)
+            {
+            }
+        }
+        
+        int pageSize = Math.max(0, Integer.parseInt(request.getPreferences().getValue("pageSize", "0")));
+        int pageCount = 1;
+        
+        try
+        {
+            Class<?> queryClass = Thread.currentThread().getContextClassLoader().loadClass(queryClassName);
+            
+            String jcrExpression = getParameterOrPreference(request, "fullQueryJcrExpression", null);
+            
+            if (!StringUtils.isBlank(jcrExpression))
+            {
+                request.setAttribute("fullQueryJcrExpression", jcrExpression);
+            }
+            else
+            {
+                jcrExpression = buildFullQueryJcrExpression(request, ocm, queryClass, contentPath);
+            }
+            
+            if (log.isDebugEnabled())
+            {
+                log.debug("Executing jcr query: " + jcrExpression);
+            }
+            
+            String queryLanguage = request.getPreferences().getValue("queryLanguage", defaultQueryLanguage);
+            Collection result = ocm.getObjects(jcrExpression, queryLanguage);
+            int itemCount = result.size();
+            
+            if (pageSize > 0)
+            {
+                pageCount = itemCount / pageSize;
+                
+                if (itemCount % pageSize != 0)
+                {
+                    ++pageCount;
+                }
+            }
+            
+            request.setAttribute("itemCount", new Integer(itemCount));
+            request.setAttribute("pageCount", new Integer(pageCount));
+            request.setAttribute("pageIndex", new Integer(pageIndex));
+            
+            Object contentBean = null;
+            
+            int beginIndex = (pageIndex - 1) * pageSize;
+            
+            if (beginIndex == 0 && pageSize == 0)
+            {
+                contentBean = result;
+            }
+            else
+            {
+                List<Object> list = new ArrayList<Object>(pageSize > 0 ? pageSize : 10);
+                int index = 0;
+                int count = 0;
+                
+                for (Object item : result)
+                {
+                    if (index++ < beginIndex)
+                    {
+                        continue;
+                    }
+                    
+                    if (pageSize > 0 && count >= pageSize)
+                    {
+                        break;
+                    }
+                    
+                    list.add(item);
+                    ++count;
+                }
+                
+                contentBean = list;
+            }
+            
+            return contentBean;
+        }
+        catch (Exception e)
+        {
+            throw new PortletException("Failed to execute query. " + e, e);
+        }
+    }
+    
+    protected String buildFullQueryJcrExpression(final PortletRequest request, final ObjectContentManager ocm, Class<?> queryClass, String scope)
+    {
+        QueryManager queryManager = ocm.getQueryManager();
+        Filter filter = createFilter(request, queryManager, queryClass, scope);
+        Query query = queryManager.createQuery(filter);
+        
+        String jcrExpression = queryManager.buildJCRExpression(query);
+        String queryOrderByClause = request.getPreferences().getValue("queryOrderByClause", null);
+        
+        if (!StringUtils.isBlank(queryOrderByClause))
+        {
+            jcrExpression += " order by " + queryOrderByClause;
+        }
+        
+        return jcrExpression;
+    }
+    
+    protected Filter createFilter(final PortletRequest request, final QueryManager queryManager, Class<?> queryClass, String scope)
+    {
+        Filter filter = queryManager.createFilter(queryClass);
+        filter.setScope(scope);
+        
+        String query = getParameterOrPreference(request, "query", null);
+        String queryNode = getParameterOrPreference(request, "queryNode", ".");
+        String queryOperator = getParameterOrPreference(request, "queryOperator", "contains");
+        String queryJcrExpression = getParameterOrPreference(request, "queryJcrExpression", null);
+        
+        if (query != null)
+        {
+            if ("contains".equals(queryOperator))
+            {
+                filter.addContains(queryNode, query);
+            }
+            else if ("equalto".equals(queryOperator))
+            {
+                filter.addEqualTo(queryNode, query);
+            }
+        }
+        
+        if (!StringUtils.isBlank(queryJcrExpression))
+        {
+            filter.addJCRExpression(queryJcrExpression);
+        }
+        
+        if (query != null)
+        {
+            request.setAttribute("query", query);
+        }
+        
+        if (queryNode != null)
+        {
+            request.setAttribute("queryNode", queryNode);
+        }
+        
+        if (queryOperator != null)
+        {
+            request.setAttribute("queryOperator", queryOperator);
+        }
+        
+        if (queryJcrExpression != null)
+        {
+            request.setAttribute("queryJcrExpression", queryJcrExpression);
+        }
+        
+        return filter;
+    }
+    
+    protected String getParameterOrPreference(final PortletRequest request, String name, String defaultValue)
+    {
+        String value = request.getParameter(name);
+        
+        if (value == null)
+        {
+            value = request.getPreferences().getValue(name, null);
+        }
+        
+        return (value != null ? value.trim() : defaultValue);
+    }
+}

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java Wed May 19 10:57:15 2010
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portals.applications.content;
+
+import java.io.IOException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+
+
+/**
+ * GenericSearchQueryContentPortlet
+ * 
+ * @version $Id$
+ */
+public class GenericSearchQueryContentPortlet extends GenericQueryContentPortlet 
+{
+    @Override
+    public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException
+    {
+        if (isPreferencesStoringAction(request))
+        {
+            processPreferencesAction(request, response);
+            return;
+        }
+        
+        String query = request.getParameter("query");
+        String queryNode = request.getParameter("queryNode");
+        String queryOperator = request.getParameter("queryOperator");
+        String queryJcrExpression = request.getParameter("queryJcrExpression");
+        String fullQueryJcrExpression = request.getParameter("fullQueryJcrExpression");
+        
+        if (query != null)
+        {
+            response.setRenderParameter("query", query.trim());
+        }
+        
+        if (queryNode != null)
+        {
+            response.setRenderParameter("queryNode", queryNode.trim());
+        }
+        
+        if (queryOperator != null)
+        {
+            response.setRenderParameter("queryOperator", queryOperator.trim());
+        }
+        
+        if (queryJcrExpression != null)
+        {
+            response.setRenderParameter("queryJcrExpression", queryJcrExpression.trim());
+        }
+        
+        if (fullQueryJcrExpression != null)
+        {
+            response.setRenderParameter("fullQueryJcrExpression", fullQueryJcrExpression.trim());
+        }
+        
+        super.processAction(request, response);
+    }
+    
+    @Override
+    protected Object getContentBean(final PortletRequest request, final ObjectContentManager ocm, final String contentPath) throws PortletException
+    {
+        String query = request.getParameter("query");
+        String fullQueryJcrExpression = request.getParameter("fullQueryJcrExpression");
+        
+        if (StringUtils.isBlank(query) && StringUtils.isBlank(fullQueryJcrExpression))
+        {
+            return null;
+        }
+        
+        return super.getContentBean(request, ocm, contentPath);
+    }
+}

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/NewsItemPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/NewsItemPortlet.java?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/NewsItemPortlet.java (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/NewsItemPortlet.java Wed May 19 10:57:15 2010
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portals.applications.content.demo;
+
+import org.apache.portals.applications.content.DynamicContentPortlet;
+
+/**
+ * NewsItemPortlet
+ * 
+ * @version $Id$
+ */
+public class NewsItemPortlet extends DynamicContentPortlet 
+{
+
+}

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/NewsItemPortlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/NewsItemPortlet.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/HtmlBodyContent.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/HtmlBodyContent.java?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/HtmlBodyContent.java (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/HtmlBodyContent.java Wed May 19 10:57:15 2010
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portals.applications.content.demo.beans;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+/**
+ * HtmlBodyContent
+ * 
+ * @version $Id$
+ */
+@Node(jcrType="hippostd:html", discriminator=false)
+public class HtmlBodyContent 
+{
+    protected String path;
+    protected String content;
+    
+    @Field(path=true)
+    public String getPath() 
+    {
+        return path;
+    }
+    
+    public void setPath(String path) 
+    {
+        this.path = path;
+    }
+    
+    @Field(jcrName="hippostd:content")
+    public String getContent() 
+    {
+        return this.content;
+    }
+    
+    public void setContent(String content) 
+    {
+        this.content = content;
+    }
+    
+}

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/HtmlBodyContent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/HtmlBodyContent.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/NewsItem.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/NewsItem.java?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/NewsItem.java (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/NewsItem.java Wed May 19 10:57:15 2010
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portals.applications.content.demo.beans;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+/**
+ * NewsItem from One Hippo Live Site
+ * 
+ * @version $Id$
+ */
+@Node(jcrType="onehippo:newsitem", discriminator=false)
+public class NewsItem extends TextPage
+{
+}

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/NewsItem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/NewsItem.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/TextPage.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/TextPage.java?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/TextPage.java (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/TextPage.java Wed May 19 10:57:15 2010
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portals.applications.content.demo.beans;
+
+import java.util.Date;
+
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Bean;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+/**
+ * TextPage
+ * 
+ * @version $Id$
+ */
+@Node(jcrType="onehippo:document", discriminator=false)
+public class TextPage 
+{
+    protected String path;
+    protected Date documentDate;
+    protected String title;
+    protected String introduction; 
+    protected HtmlBodyContent body;
+    
+    @Field(path=true)
+    public String getPath() 
+    {
+        return path;
+    }
+    
+    public void setPath(String path) 
+    {
+        this.path = path;
+    }
+    
+    @Field(jcrName="onehippo:documentdate")
+    public Date getDocumentDate()
+    {
+        return documentDate;
+    }
+    
+    public void setDocumentDate(Date documentDate)
+    {
+        this.documentDate = documentDate;
+    }
+    
+    @Field(jcrName="onehippo:title")
+    public String getTitle() 
+    {
+        return this.title;
+    }
+    
+    public void setTitle(String title) 
+    {
+        this.title = title;
+    }
+    
+    @Field(jcrName="onehippo:introduction")
+    public String getIntroduction() 
+    {
+        return this.introduction;
+    }
+    
+    public void setIntroduction(String introduction) 
+    {
+        this.introduction = introduction;
+    }
+    
+    @Bean(jcrName="onehippo:body", proxy=true)
+    public HtmlBodyContent getBody()
+    {
+        return body;
+    }
+    
+    public void setBody(HtmlBodyContent body)
+    {
+        this.body = body;
+    }
+}

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/TextPage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/demo/beans/TextPage.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DefaultObjectContentManagerProvider.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DefaultObjectContentManagerProvider.java?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DefaultObjectContentManagerProvider.java (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DefaultObjectContentManagerProvider.java Wed May 19 10:57:15 2010
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portals.applications.content.jndi;
+
+import java.util.List;
+
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl;
+import org.apache.jackrabbit.ocm.mapper.Mapper;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.AnnotationMapperImpl;
+import org.apache.jackrabbit.ocm.mapper.impl.digester.DigesterMapperImpl;
+
+public class DefaultObjectContentManagerProvider implements ObjectContentManagerProvider
+{
+    private List<Class> annotatedClasses;
+    private String [] xmlMappingFiles;
+    
+    public DefaultObjectContentManagerProvider(List<Class> annotatedClasses)
+    {
+        this.annotatedClasses = annotatedClasses;
+    }
+    
+    public DefaultObjectContentManagerProvider(String [] xmlMappingFiles)
+    {
+        this.xmlMappingFiles = xmlMappingFiles;
+    }
+    
+    public ObjectContentManager getObjectContentManager(Session session)
+    {
+        if (annotatedClasses != null)
+        {
+            Mapper mapper = new AnnotationMapperImpl(annotatedClasses);
+            return createObjectContentManager(session, mapper);
+        }
+        else if (xmlMappingFiles != null)
+        {
+            Mapper mapper = new DigesterMapperImpl(xmlMappingFiles);
+            return createObjectContentManager(session, mapper);
+        }
+        else
+        {
+            throw new IllegalStateException("No configuration found. Annotated class names or xml configurations should be provided.");
+        }
+    }
+    
+    protected ObjectContentManager createObjectContentManager(Session session, Mapper mapper) 
+    {
+        return new ObjectContentManagerImpl(session, mapper);
+    }
+}

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DefaultObjectContentManagerProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DefaultObjectContentManagerProvider.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DelegatingObjectContentManagerProvider.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DelegatingObjectContentManagerProvider.java?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DelegatingObjectContentManagerProvider.java (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DelegatingObjectContentManagerProvider.java Wed May 19 10:57:15 2010
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portals.applications.content.jndi;
+
+import java.lang.reflect.Method;
+
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+
+/**
+ * DelegatingObjectContentManagerProvider
+ * 
+ * @version $Id$
+ */
+public class DelegatingObjectContentManagerProvider implements ObjectContentManagerProvider
+{
+    private Object delegatee;
+    private Method getObjectContentManagerMethod;
+    
+    public DelegatingObjectContentManagerProvider(Object delegatee) throws Exception
+    {
+        this.delegatee = delegatee;
+        this.getObjectContentManagerMethod = delegatee.getClass().getMethod("getObjectContentManager", new Class [] { Session.class });
+    }
+    
+    public ObjectContentManager getObjectContentManager(Session session)
+    {
+        try
+        {
+            return (ObjectContentManager) getObjectContentManagerMethod.invoke(delegatee, new Object [] { session });
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException(e.toString(), e);
+        }
+    }
+}

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DelegatingObjectContentManagerProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/DelegatingObjectContentManagerProvider.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProvider.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProvider.java?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProvider.java (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProvider.java Wed May 19 10:57:15 2010
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portals.applications.content.jndi;
+
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+
+/**
+ * ObjectContentManagerProvider
+ * 
+ * @version $Id$
+ */
+public interface ObjectContentManagerProvider
+{
+    
+    public ObjectContentManager getObjectContentManager(Session session);
+    
+}

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProvider.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProviderObjectFactory.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProviderObjectFactory.java?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProviderObjectFactory.java (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProviderObjectFactory.java Wed May 19 10:57:15 2010
@@ -0,0 +1,147 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portals.applications.content.jndi;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+
+
+/**
+ * ObjectContentManagerProviderObjectFactory
+ * 
+ * @version $Id$
+ */
+public class ObjectContentManagerProviderObjectFactory implements ObjectFactory 
+{
+    
+    public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception 
+    {
+        String providerClassName = null;
+        String annotatedClassNames = null;
+        String xmlMappingResources = null;
+        
+        if (obj != null && obj instanceof Reference) {
+            Reference ref = (Reference) obj;
+            Enumeration<RefAddr> addrs = ref.getAll();
+            
+            while (addrs.hasMoreElements()) {
+                RefAddr addr = (RefAddr) addrs.nextElement();
+                String type = addr.getType();
+                String value = (String) addr.getContent();
+                
+                if ("providerClassName".equals(type))
+                {
+                    providerClassName = (value != null ? value.trim() : value);
+                }
+                else if ("annotatedClassNames".equals(type))
+                {
+                    annotatedClassNames = (value != null ? value.trim() : value);
+                }
+                else if ("xmlMappingResources".equals(type))
+                {
+                    xmlMappingResources = (value != null ? value.trim() : value);
+                }
+            }
+        }
+        
+        ObjectContentManagerProvider provider = null;
+        
+        if (annotatedClassNames != null && !"".equals(annotatedClassNames))
+        {
+            List<Class> annotatedBeanClasses = new ArrayList<Class>();
+            
+            for (String annotatedClassName : split(annotatedClassNames, " ,\t\r\n"))
+            {
+                annotatedBeanClasses.add(Thread.currentThread().getContextClassLoader().loadClass(annotatedClassName));
+            }
+            
+            if (providerClassName != null && !"".equals(providerClassName))
+            {
+                Object providerObj = Thread.currentThread().getContextClassLoader().loadClass(providerClassName).getConstructor(new Class [] { List.class }).newInstance(new Object [] { annotatedBeanClasses });
+                
+                if (providerObj instanceof ObjectContentManagerProvider)
+                {
+                    provider = (ObjectContentManagerProvider) providerObj;
+                }
+                else
+                {
+                    provider = new DelegatingObjectContentManagerProvider(providerObj);
+                }
+            }
+            else
+            {
+                provider = new DefaultObjectContentManagerProvider(annotatedBeanClasses);
+            }
+        }
+        else if (xmlMappingResources != null && !"".equals(xmlMappingResources))
+        {
+            String [] xmlMappingFiles = split(xmlMappingResources, " ,\t\r\n");
+            
+            if (providerClassName != null && !"".equals(providerClassName))
+            {
+                Object providerObj = (ObjectContentManagerProvider) Thread.currentThread().getContextClassLoader().loadClass(providerClassName).getConstructor(new Class [] { String [].class }).newInstance(new Object [] { xmlMappingFiles });
+                
+                if (providerObj instanceof ObjectContentManagerProvider)
+                {
+                    provider = (ObjectContentManagerProvider) providerObj;
+                }
+                else
+                {
+                    provider = new DelegatingObjectContentManagerProvider(providerObj);
+                }
+            }
+            else
+            {
+                provider = new DefaultObjectContentManagerProvider(xmlMappingFiles);
+            }
+        }
+        else
+        {
+            throw new IllegalArgumentException("Invalid configuration. annotatedClassNames or xmlMappingResources should be configured.");
+        }
+        
+        return provider;
+    }
+    
+    private String [] split(String source, String tokens)
+    {
+        ArrayList<String> list = new ArrayList<String>();
+        
+        StringTokenizer st = new StringTokenizer(source, tokens);
+        
+        while (st.hasMoreTokens())
+        {
+            String token = st.nextToken();
+            
+            if (!"".equals(token))
+            {
+                list.add(token);
+            }
+        }
+        
+        return list.toArray(new String[list.size()]);
+    }
+}
\ No newline at end of file

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProviderObjectFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/ObjectContentManagerProviderObjectFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/RepositoryObjectFactory.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/RepositoryObjectFactory.java?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/RepositoryObjectFactory.java (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/RepositoryObjectFactory.java Wed May 19 10:57:15 2010
@@ -0,0 +1,199 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.portals.applications.content.jndi;
+
+import java.lang.reflect.Method;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+
+import org.apache.jackrabbit.rmi.client.ClientRepositoryFactory;
+
+/**
+ * RepositoryObjectFactory
+ * 
+ * @version $Id$
+ */
+public class RepositoryObjectFactory implements ObjectFactory 
+{
+    
+    public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception 
+    {
+        String url = null;
+        String factoryName = null;
+        String factoryStaticMethodName = null;
+        String factoryMethodName = null;
+        
+        if (obj != null && obj instanceof Reference) {
+            Reference ref = (Reference) obj;
+            Enumeration<RefAddr> addrs = ref.getAll();
+            
+            while (addrs.hasMoreElements()) {
+                RefAddr addr = (RefAddr) addrs.nextElement();
+                String type = addr.getType();
+                String value = (String) addr.getContent();
+                
+                if ("repositoryUrl".equals(type))
+                {
+                    url = (value != null ? value.trim() : value);
+                }
+                else if ("repositoryFactoryName".equals(type))
+                {
+                    factoryName = (value != null ? value.trim() : value);
+                }
+                else if ("repositoryFactoryStaticMethodName".equals(type))
+                {
+                    factoryStaticMethodName = (value != null ? value.trim() : value);
+                }
+                else if ("repositoryFactoryMethodName".equals(type))
+                {
+                    factoryMethodName = (value != null ? value.trim() : value);
+                }
+            }
+        }
+        
+        Repository repository = null;
+        
+        if (!isEmpty(factoryName) && isEmpty(factoryStaticMethodName) && isEmpty(factoryMethodName))
+        {
+            Class<?> factoryClass = Thread.currentThread().getContextClassLoader().loadClass(factoryName);
+            
+            if (ObjectFactory.class.isAssignableFrom(factoryClass))
+            {
+                ObjectFactory factory = (ObjectFactory) factoryClass.newInstance();
+                repository = (Repository) factory.getObjectInstance(obj, name, nameCtx, environment);
+            }
+        }
+        
+        if (repository == null)
+        {
+            if (!isEmpty(url))
+            {
+                repository = new LazyDelegatingRepository(url, factoryName, factoryStaticMethodName, factoryMethodName);
+            }
+            else
+            {
+                throw new IllegalArgumentException("The repository url is not configured.");
+            }
+        }
+        
+        return repository;
+    }
+    
+    private static boolean isEmpty(String s)
+    {
+        return s == null || "".equals(s);
+    }
+    
+    private static class LazyDelegatingRepository implements Repository
+    {
+        private Repository delegatee;
+        private String url = null;
+        private String factoryName = null;
+        private String factoryStaticMethodName = null;
+        private String factoryMethodName = null;
+        
+        private LazyDelegatingRepository(String url, String factoryName, String factoryStaticMethodName, String factoryMethodName)
+        {
+            this.url = url;
+            this.factoryName = factoryName;
+            this.factoryStaticMethodName = factoryStaticMethodName;
+            this.factoryMethodName = factoryMethodName;
+        }
+        
+        public String getDescriptor(String key)
+        {
+            return getDelegatee().getDescriptor(key);
+        }
+
+        public String[] getDescriptorKeys()
+        {
+            return getDelegatee().getDescriptorKeys();
+        }
+
+        public Session login() throws LoginException, RepositoryException
+        {
+            return getDelegatee().login();
+        }
+
+        public Session login(Credentials credentials) throws LoginException, RepositoryException
+        {
+            return getDelegatee().login(credentials);
+        }
+
+        public Session login(String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException
+        {
+            return getDelegatee().login(workspaceName);
+        }
+
+        public Session login(Credentials credentials, String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException
+        {
+            return getDelegatee().login(credentials, workspaceName);
+        }
+        
+        private Repository getDelegatee()
+        {
+            try
+            {
+                if (delegatee == null)
+                {
+                    synchronized (this)
+                    {
+                        if (delegatee == null)
+                        {
+                            if (isEmpty(factoryName))
+                            {
+                                ClientRepositoryFactory factory = new ClientRepositoryFactory();
+                                delegatee = factory.getRepository(url);
+                            }
+                            else if (!isEmpty(factoryStaticMethodName))
+                            {
+                                Class<?> factoryClass = Thread.currentThread().getContextClassLoader().loadClass(factoryName);
+                                Method method = factoryClass.getMethod(factoryStaticMethodName, new Class [] { String.class });
+                                delegatee = (Repository) method.invoke(factoryClass, new Object [] { url } );
+                            }
+                            else if (!isEmpty(factoryMethodName))
+                            {
+                                Class<?> factoryClass = Thread.currentThread().getContextClassLoader().loadClass(factoryName);
+                                Object factory = factoryClass.newInstance();
+                                Method method = factoryClass.getMethod(factoryMethodName, new Class [] { String.class });
+                                delegatee = (Repository) method.invoke(factory, new Object [] { url } );
+                            }
+                        }
+                    }
+                }
+            }
+            catch (Exception e)
+            {
+                throw new RuntimeException("Failed to create repository: " + e, e);
+            }
+            
+            return delegatee;
+        }
+    }
+}
\ No newline at end of file

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/RepositoryObjectFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/java/org/apache/portals/applications/content/jndi/RepositoryObjectFactory.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/demo/resources/NewsItemPortlet.properties
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/demo/resources/NewsItemPortlet.properties?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/demo/resources/NewsItemPortlet.properties (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/demo/resources/NewsItemPortlet.properties Wed May 19 10:57:15 2010
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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$
+#
+
+label.contentPath = Content Path:
+label.repositoryUsername = User name:
+label.repositoryPassword = Password:
+label.repositoryWorkspace = Workspace name:
+
+label.contentBasePath = Content base path:
+label.basePathInfo = Base path info:

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/demo/resources/NewsItemPortlet.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/demo/resources/NewsItemPortlet.properties
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/resources/GenericContentPortlet.properties
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/resources/GenericContentPortlet.properties?rev=946121&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/resources/GenericContentPortlet.properties (added)
+++ portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/resources/GenericContentPortlet.properties Wed May 19 10:57:15 2010
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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$
+#
+
+label.contentPath = Content Path:
+label.repositoryUsername = User name:
+label.repositoryPassword = Password:
+label.repositoryWorkspace = Workspace name:

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/resources/GenericContentPortlet.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/apa-content-portlet/src/main/resources/org/apache/portals/applications/content/resources/GenericContentPortlet.properties
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message