portals-portalapps-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r945196 - in /portals/applications/sandbox/content/trunk: ./ etc/ant/ etc/ant/sources/ src/main/java/org/apache/portals/applications/content/ src/main/java/org/apache/portals/applications/content/tools/ src/main/java/org/apache/portals/appl...
Date Mon, 17 May 2010 15:02:30 GMT
Author: woonsan
Date: Mon May 17 15:02:29 2010
New Revision: 945196

URL: http://svn.apache.org/viewvc?rev=945196&view=rev
Log:
Adding ant task example

Added:
    portals/applications/sandbox/content/trunk/etc/ant/
    portals/applications/sandbox/content/trunk/etc/ant/build.properties   (with props)
    portals/applications/sandbox/content/trunk/etc/ant/build.xml   (with props)
    portals/applications/sandbox/content/trunk/etc/ant/sources/
    portals/applications/sandbox/content/trunk/etc/ant/sources/Jetspeed-2-release.xml   (with
props)
    portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/
    portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/
    portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/AbstractRepositoryTask.java
  (with props)
    portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/Import.java
  (with props)
Modified:
    portals/applications/sandbox/content/trunk/pom.xml
    portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java

Added: portals/applications/sandbox/content/trunk/etc/ant/build.properties
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/etc/ant/build.properties?rev=945196&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/etc/ant/build.properties (added)
+++ portals/applications/sandbox/content/trunk/etc/ant/build.properties Mon May 17 15:02:29
2010
@@ -0,0 +1,18 @@
+# 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.
+
+repository.url = rmi://127.0.0.1:1099/hipporepository
+repository.username = admin
+repository.password = admin

Propchange: portals/applications/sandbox/content/trunk/etc/ant/build.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/etc/ant/build.properties
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/applications/sandbox/content/trunk/etc/ant/build.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/applications/sandbox/content/trunk/etc/ant/build.xml
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/etc/ant/build.xml?rev=945196&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/etc/ant/build.xml (added)
+++ portals/applications/sandbox/content/trunk/etc/ant/build.xml Mon May 17 15:02:29 2010
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<project default="import-content" basedir="." name="content import example">
+  
+  <property name="repository.url" value="rmi://127.0.0.1:1099/hipporepository" />
+  <property name="repository.username" value="admin" />
+  <property name="repository.password" value="admin" />
+  
+  <taskdef name="import" 
+  	       classname="org.apache.portals.applications.content.tools.ant.Import" 
+  	       classpath="classes" />
+  
+  <target name="import-content">
+  	
+  	<import parentAbsPath="/content/documents/en/news/2009/05" 
+  		    source="${basedir}/sources/Jetspeed-2-release.xml" 
+    />
+  	
+  </target>
+  
+</project>
\ No newline at end of file

Propchange: portals/applications/sandbox/content/trunk/etc/ant/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/etc/ant/build.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/applications/sandbox/content/trunk/etc/ant/build.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/applications/sandbox/content/trunk/etc/ant/sources/Jetspeed-2-release.xml
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/etc/ant/sources/Jetspeed-2-release.xml?rev=945196&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/etc/ant/sources/Jetspeed-2-release.xml (added)
+++ portals/applications/sandbox/content/trunk/etc/ant/sources/Jetspeed-2-release.xml Mon
May 17 15:02:29 2010
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" 
+         sv:name="Jetspeed-2-release">
+  <sv:property sv:name="jcr:primaryType" sv:type="Name">
+    <sv:value>hippo:handle</sv:value>
+  </sv:property>
+  <sv:property sv:name="jcr:mixinTypes" sv:type="Name">
+    <sv:value>hippo:hardhandle</sv:value>
+  </sv:property>
+  <sv:property sv:name="jcr:uuid" sv:type="String">
+    <sv:value>8131ec27-867d-467c-8160-3b1c91d2f204</sv:value>
+  </sv:property>
+  <sv:node sv:name="Jetspeed-2-2">
+    <sv:property sv:name="jcr:primaryType" sv:type="Name">
+      <sv:value>onehippo:newsitem</sv:value>
+    </sv:property>
+    <sv:property sv:name="jcr:mixinTypes" sv:type="Name">
+      <sv:value>hippo:harddocument</sv:value>
+    </sv:property>
+    <sv:property sv:name="jcr:uuid" sv:type="String">
+      <sv:value>4c2f4d3f-46f7-4295-915d-b9d387af5673</sv:value>
+    </sv:property>
+    <sv:property sv:name="hippo:paths" sv:type="String">
+      <sv:value>4c2f4d3f-46f7-4295-915d-b9d387af5673</sv:value>
+      <sv:value>8131ec27-867d-467c-8160-3b1c91d2f204</sv:value>
+      <sv:value>e5083a0c-f666-4c42-9ec9-cb651fb56312</sv:value>
+      <sv:value>a08221f4-c388-44fb-af0f-af5f6367fc70</sv:value>
+      <sv:value>a8ae83c4-8991-4b42-ae5e-9269a9009be9</sv:value>
+      <sv:value>76353ec9-7069-41a5-b8bb-0002503e3887</sv:value>
+      <sv:value>996bcac5-86cf-49b5-a7a3-16a74863e814</sv:value>
+      <sv:value>7d92c518-511b-49e0-92b5-126970694fa8</sv:value>
+      <sv:value>cafebabe-cafe-babe-cafe-babecafebabe</sv:value>
+    </sv:property>
+    <sv:property sv:name="hippo:related___pathreference"
+      sv:type="String">
+      <sv:value>Jetspeed-2-release</sv:value>
+    </sv:property>
+    <sv:property sv:name="hippostd:state" sv:type="String">
+      <sv:value>published</sv:value>
+    </sv:property>
+    <sv:property sv:name="hippostd:stateSummary" sv:type="String">
+      <sv:value>live</sv:value>
+    </sv:property>
+    <sv:property sv:name="hippostdpubwf:createdBy" sv:type="String">
+      <sv:value></sv:value>
+    </sv:property>
+    <sv:property sv:name="hippostdpubwf:creationDate"
+      sv:type="Date">
+      <sv:value>1970-01-01T01:00:00.000+01:00</sv:value>
+    </sv:property>
+    <sv:property sv:name="hippostdpubwf:lastModificationDate"
+      sv:type="Date">
+      <sv:value>1970-01-01T01:00:00.000+01:00</sv:value>
+    </sv:property>
+    <sv:property sv:name="hippostdpubwf:lastModifiedBy"
+      sv:type="String">
+      <sv:value></sv:value>
+    </sv:property>
+    <sv:property sv:name="onehippo:documentdate" sv:type="Date">
+      <sv:value>2009-06-01T00:00:00.000Z</sv:value>
+    </sv:property>
+    <sv:property sv:name="onehippo:introduction" sv:type="String">
+      <sv:value> &lt;introduction&gt;&lt;html&gt;
+                                                &lt;body&gt; &lt;p&gt;Hippo,
the leading developer of
+                                                web-based, open source Enterprise Content
Management (ECM) and Portal
+                                                software, has launched a full product and
support offering around the
+                                                latest version of Apache Jetspeed, version
2.2 released on May 28th,
+                                                supporting the Portal 2.0 specification.&lt;/p&gt;
+                                                &lt;/body&gt;
+                                          &lt;/html&gt;&lt;/introduction&gt;
+      </sv:value>
+    </sv:property>
+    <sv:property sv:name="onehippo:title" sv:type="String">
+      <sv:value>Hippo launches full product and support to complement Apache
+                                                Jetspeed 2.2</sv:value>
+    </sv:property>
+    <sv:node sv:name="onehippo:body">
+      <sv:property sv:name="jcr:primaryType" sv:type="Name">
+        <sv:value>hippostd:html</sv:value>
+      </sv:property>
+      <sv:property sv:name="hippostd:content" sv:type="String">
+        <sv:value> &lt;section&gt; &lt;text
+                                                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;&lt;html&gt;
+                                                      &lt;body&gt; &lt;p&gt;Hippo’s
developers, with ten
+                                                      officially recognized committers already
noted for their
+                                                      commitment to a range of The Apache
Software Foundation’s
+                                                      projects, have contributed to the community
effort to develop
+                                                      Jetspeed 2.2. Hippo’s close involvement
in the Jetspeed community
+                                                      enables it to bring training, consulting
and 24x7 support for the
+                                                      new version straight to the market,
and to offer Jetspeed 1.x and
+                                                      2.1 users an upgrade package and full
support.&lt;/p&gt;
+                                                      &lt;p&gt;&lt;strong&gt;Jetspeed&lt;/strong&gt;&lt;/p&gt;
+                                                      &lt;p&gt; &lt;a
+                                                      href="http://portals.apache.org/jetspeed-2/"&gt;http://portals.apache.org/jetspeed-2/&lt;/a&gt;
+                                                      &lt;/p&gt; &lt;p&gt;Jetspeed
is an easy-to-access
+                                                      open source Enterprise Information
Portal using Java and XML to
+                                                      collect and present information from
multiple sources via an
+                                                      intuitive and user-friendly interface.
As a product of The Apache
+                                                      Software Foundation (ASF), one of the
leading open source
+                                                      organizations dedicated to collaborative
software development,
+                                                      Jetspeed is available for free under
the business-friendly Apache
+                                                      License.&lt;/p&gt; &lt;p&gt;Hippo’s
own product
+                                                      range is the first to feature full
integration with Jetspeed 2.2,
+                                                      including Hippo CMS 7, the Hippo Site
Toolkit and the integrated
+                                                      ECM suite. Its products provide organizations
with an innovative
+                                                      and cost effective solution for content
management and online
+                                                      collaboration. The new release, combined
with Jetspeed’s track
+                                                      record of performance, stability and
its unmatched support for
+                                                      open standards, is an ideal fit for
the highly scalable
+                                                      collaborative intranet and web architectures
built on Hippo’s
+                                                      products.&lt;/p&gt; &lt;p&gt;David
Sean Taylor,
+                                                      Apache Member, founder of the Jetspeed
2 project and VP of
+                                                      Engineering for Hippo, said, “There’s
been a build up of
+                                                      excitement behind the scenes as the
open source community has been
+                                                      gearing up to complete and release
Jetspeed 2.2. At Hippo, we’ve
+                                                      been busy contributing to the community
effort while also planning
+                                                      how to ensure our customers reap the
range of features and
+                                                      benefits available in the new version.
It’s going to be a strong
+                                                      comeback for Jetspeed with a range
of new capabilities in
+                                                      usability, scalability and extensibility
that were previously only
+                                                      available for clients in custom projects
– it’s a leap forward
+                                                      towards the next generation of enterprise
+                                                      portals.”&lt;/p&gt; &lt;p&gt;New
features and
+                                                      improvements in Jetspeed 2.2 and Hippo’s
accompanying product
+                                                      range include:&lt;/p&gt; &lt;p&gt;Open
design for
+                                                      optimal interoperability&lt;/p&gt;
&lt;ul&gt;
+                                                      &lt;li&gt;Full Portlet API
2.0 support and compliance,
+                                                      built on Pluto 2.0.0&lt;/li&gt;
&lt;/ul&gt;
+                                                      &lt;ul&gt; &lt;li&gt;New
pluggable and extensible
+                                                      security model with LDAP (Lightweight
Directory Access Protocol)
+                                                      synchronization to provide integrated
secure
+                                                      environments&lt;/li&gt; &lt;/ul&gt;
+                                                      &lt;ul&gt; &lt;li&gt;Improved
integration support
+                                                      for popular web development frameworks
such as Wicket, Spring MVC,
+                                                      Struts and JSF (JavaServer Faces)&lt;/li&gt;
+                                                      &lt;/ul&gt; &lt;p&gt;Facilitating
truly
+                                                      interactive collaboration&lt;/p&gt;
&lt;ul&gt;
+                                                      &lt;li&gt;Inter-portlet communication
through standards
+                                                      based eventing and shared state management&lt;/li&gt;
+                                                      &lt;/ul&gt; &lt;p&gt;Fast,
cost effective
+                                                      integration&lt;/p&gt; &lt;ul&gt;
+                                                      &lt;li&gt;Fresh looks and improved
usability with new
+                                                      administrative portlets and new skins&lt;/li&gt;
+                                                      &lt;/ul&gt; &lt;ul&gt;
&lt;li&gt;New high
+                                                      performance preferences database storage&lt;/li&gt;
+                                                      &lt;/ul&gt; &lt;ul&gt;
&lt;li&gt;Custom
+                                                      and customizable portal project templates
and full Maven-2 build
+                                                      support&lt;/li&gt; &lt;/ul&gt;
&lt;ul&gt;
+                                                      &lt;li&gt;Improved documentation
including 5 new guides
+                                                      focused on users, admin, developers,
building and
+                                                      deploying&lt;/li&gt; &lt;/ul&gt;
+                                                      &lt;p&gt;These features provide
a range of extensibility
+                                                      and usability enhancements. Together
they dramatically improve the
+                                                      ease of adding custom functionality
while increasing the control
+                                                      of end-users. Hippo expects Jetspeed
2.2 to reestablish Jetspeed’s
+                                                      position as the portal of choice for
building performance oriented
+                                                      enterprise portals in a rapid and cost-effective
+                                                      way.&lt;/p&gt; &lt;/body&gt;
+                                                      &lt;/html&gt;&lt;/text&gt;
+                                                      &lt;header/&gt;&lt;image/&gt;&lt;/section&gt;
+        </sv:value>
+      </sv:property>
+    </sv:node>
+  </sv:node>
+</sv:node>

Propchange: portals/applications/sandbox/content/trunk/etc/ant/sources/Jetspeed-2-release.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/etc/ant/sources/Jetspeed-2-release.xml
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/applications/sandbox/content/trunk/etc/ant/sources/Jetspeed-2-release.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/applications/sandbox/content/trunk/pom.xml
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/pom.xml?rev=945196&r1=945195&r2=945196&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/pom.xml (original)
+++ portals/applications/sandbox/content/trunk/pom.xml Mon May 17 15:02:29 2010
@@ -39,6 +39,7 @@
     <org.apache.portals.bridges.common.version>2.0</org.apache.portals.bridges.common.version>
     <javax.jcr.version>1.0</javax.jcr.version>
     <jackrabbit.version>1.5.0</jackrabbit.version>
+    <ant.version>1.7.1</ant.version>
     <commons-lang.version>2.4</commons-lang.version>
     <slf4j.version>1.5.6</slf4j.version>
     <log4j.version>1.2.14</log4j.version>
@@ -78,6 +79,13 @@
     </dependency>
     
     <dependency>
+      <groupId>org.apache.ant</groupId>
+      <artifactId>ant</artifactId>
+      <version>${ant.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    
+    <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>jstl</artifactId>
       <version>${javax.servlet.jstl.version}</version>

Modified: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java?rev=945196&r1=945195&r2=945196&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
(original)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
Mon May 17 15:02:29 2010
@@ -46,6 +46,7 @@ public class GenericContentPortlet exten
     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";
     
@@ -83,6 +84,13 @@ public class GenericContentPortlet exten
             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))
@@ -181,14 +189,29 @@ public class GenericContentPortlet exten
         try
         {
             Credentials credentials = getCredentials(request);
+            String repositoryWorkspace = request.getPreferences().getValue("repositoryWorkspace",
defaultRepositoryWorkspace);
             
             if (credentials == null)
             {
-                session = getRepository().login();
+                if (StringUtils.isBlank(repositoryWorkspace))
+                {
+                    session = getRepository().login();
+                }
+                else
+                {
+                    session = getRepository().login(repositoryWorkspace);
+                }
             }
             else
             {
-                session = getRepository().login(credentials);
+                if (StringUtils.isBlank(repositoryWorkspace))
+                {
+                    session = getRepository().login(credentials);
+                }
+                else
+                {
+                    session = getRepository().login(credentials, repositoryWorkspace);
+                }
             }
         }
         catch (Exception e)

Added: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/AbstractRepositoryTask.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/AbstractRepositoryTask.java?rev=945196&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/AbstractRepositoryTask.java
(added)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/AbstractRepositoryTask.java
Mon May 17 15:02:29 2010
@@ -0,0 +1,149 @@
+/*
+ * 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.tools.ant;
+
+import javax.jcr.Credentials;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+import org.apache.jackrabbit.rmi.client.ClientRepositoryFactory;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+/**
+ * AbstractRepositoryTask
+ */
+public abstract class AbstractRepositoryTask extends Task 
+{
+    
+    private String repositoryUrl;
+    private String repositoryUsername = "";
+    private String repositoryPassword = "";
+    private String repositoryWorkspace;
+    
+    private Repository repository;
+    
+    /**
+     * Does the work.
+     *
+     * @exception BuildException if something goes wrong with the build
+     */
+    public abstract void execute();
+    
+    public String getRepositoryUrl()
+    {
+        return repositoryUrl;
+    }
+
+    public void setRepositoryUrl(String repositoryUrl)
+    {
+        this.repositoryUrl = repositoryUrl;
+    }
+
+    public String getRepositoryUsername()
+    {
+        return repositoryUsername;
+    }
+
+    public void setRepositoryUsername(String repositoryUsername)
+    {
+        this.repositoryUsername = repositoryUsername;
+    }
+
+    public String getRepositoryPassword()
+    {
+        return repositoryPassword;
+    }
+
+    public void setRepositoryPassword(String repositoryPassword)
+    {
+        this.repositoryPassword = repositoryPassword;
+    }
+
+    public String getRepositoryWorkspace()
+    {
+        return repositoryWorkspace;
+    }
+
+    public void setRepositoryWorkspace(String repositoryWorkspace)
+    {
+        this.repositoryWorkspace = repositoryWorkspace;
+    }
+
+    protected Repository getRepository() throws BuildException
+    {
+        if (repository == null)
+        {
+            if (repositoryUrl == null || "".equals(repositoryUrl))
+            {
+                throw new BuildException("Repository URL is not set.");
+            }
+            
+            try
+            {
+                ClientRepositoryFactory factory = new ClientRepositoryFactory();
+                repository = factory.getRepository(repositoryUrl);
+            }
+            catch (Exception e)
+            {
+                throw new BuildException(e);
+            }
+        }
+        
+        return repository;
+    }
+    
+    protected Session getSession() throws BuildException
+    {
+        Session session = null;
+        
+        try
+        {
+            if (repositoryUsername == null || "".equals(repositoryUsername))
+            {
+                if (repositoryWorkspace == null || "".equals(repositoryWorkspace))
+                {
+                    session = getRepository().login();
+                }
+                else
+                {
+                    session = getRepository().login(repositoryWorkspace);
+                }
+            }
+            else
+            {
+                Credentials credentials = new SimpleCredentials(repositoryUsername, repositoryPassword.toCharArray());
+                
+                if (repositoryWorkspace == null || "".equals(repositoryWorkspace))
+                {
+                    session = getRepository().login(credentials);
+                }
+                else
+                {
+                    session = getRepository().login(credentials, repositoryWorkspace);
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            throw new BuildException(e);
+        }
+        
+        return session;
+    }
+}

Propchange: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/AbstractRepositoryTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/AbstractRepositoryTask.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/AbstractRepositoryTask.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/Import.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/Import.java?rev=945196&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/Import.java
(added)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/Import.java
Mon May 17 15:02:29 2010
@@ -0,0 +1,146 @@
+/*
+ * 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.tools.ant;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import javax.jcr.ImportUUIDBehavior;
+import javax.jcr.Session;
+import javax.jcr.Workspace;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Writes a message to the Ant logging facilities.
+ *
+ * @ant.task category="jcr"
+ */
+public class Import extends AbstractRepositoryTask 
+{
+    
+    private String parentAbsPath;
+    private File source;
+    private int uuidBehavior = ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW;
+    private boolean useSession;
+    
+    public String getParentAbsPath()
+    {
+        return parentAbsPath;
+    }
+
+    public void setParentAbsPath(String parentAbsPath)
+    {
+        this.parentAbsPath = parentAbsPath;
+    }
+
+    public File getSource()
+    {
+        return source;
+    }
+
+    public void setSource(File source)
+    {
+        this.source = source;
+    }
+
+    public int getUuidBehavior()
+    {
+        return uuidBehavior;
+    }
+
+    public void setUuidBehavior(int uuidBehavior)
+    {
+        this.uuidBehavior = uuidBehavior;
+    }
+    
+    public boolean isUseSession()
+    {
+        return useSession;
+    }
+
+    public void setUseSession(boolean useSession)
+    {
+        this.useSession = useSession;
+    }
+
+    @Override
+    public void execute() throws BuildException 
+    {
+        Session session = null;
+        InputStream is = null;
+        BufferedInputStream bis = null;
+        
+        try
+        {
+            session = getSession();
+            is = new FileInputStream(source);
+            bis = new BufferedInputStream(is);
+            
+            if (useSession)
+            {
+                session.importXML(parentAbsPath, bis, uuidBehavior);
+            }
+            else
+            {
+                Workspace workspace = session.getWorkspace();
+                workspace.importXML(parentAbsPath, bis, uuidBehavior);
+            }
+        }
+        catch (Exception e) 
+        {
+            throw new BuildException(e);
+        }
+        finally
+        {
+            if (bis != null)
+            {
+                try
+                {
+                    bis.close();
+                }
+                catch (Exception ignore)
+                {
+                }
+            }
+            
+            if (is != null)
+            {
+                try
+                {
+                    is.close();
+                }
+                catch (Exception ignore)
+                {
+                }
+            }
+            
+            if (session != null)
+            {
+                try
+                {
+                    session.logout();
+                }
+                catch (Exception ignore)
+                {
+                }
+            }
+        }
+    }
+}

Propchange: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/Import.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/Import.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/tools/ant/Import.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message