You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by ma...@apache.org on 2012/08/23 16:35:42 UTC
svn commit: r1376508 - in /rave/sandbox/content-services:
rave-jcr-tools/src/main/java/org/apache/rave/tools/
rave-jcr-tools/src/main/resources/
rave-jcr-tools/src/test/java/org/apache/rave/tools/
rave-jcr-tools/src/test/resources/META-INF/rave/ rave-w...
Author: marijan
Date: Thu Aug 23 14:35:42 2012
New Revision: 1376508
URL: http://svn.apache.org/viewvc?rev=1376508&view=rev
Log:
RAVE-695 Create new rave-jcr-ocm module providing JCR based Object Content Mapping (OCM) support
- fix compile error
- add export feature
Removed:
rave/sandbox/content-services/rave-jcr-tools/src/test/resources/META-INF/rave/module.json
Modified:
rave/sandbox/content-services/rave-jcr-tools/src/main/java/org/apache/rave/tools/ImportExportTool.java
rave/sandbox/content-services/rave-jcr-tools/src/main/resources/log4j.xml
rave/sandbox/content-services/rave-jcr-tools/src/test/java/org/apache/rave/tools/ImportExportToolTest.java
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMappingByConfig.java
Modified: rave/sandbox/content-services/rave-jcr-tools/src/main/java/org/apache/rave/tools/ImportExportTool.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-jcr-tools/src/main/java/org/apache/rave/tools/ImportExportTool.java?rev=1376508&r1=1376507&r2=1376508&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-jcr-tools/src/main/java/org/apache/rave/tools/ImportExportTool.java (original)
+++ rave/sandbox/content-services/rave-jcr-tools/src/main/java/org/apache/rave/tools/ImportExportTool.java Thu Aug 23 14:35:42 2012
@@ -23,13 +23,17 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.Writer;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import org.apache.jackrabbit.core.TransientRepository;
+import org.apache.rave.jcr.exporting.ContentExporter;
import org.apache.rave.jcr.importing.ContentImporter;
import org.apache.rave.jcr.importing.ImportBehavior;
import org.apache.rave.jcr.importing.ImportException;
@@ -85,6 +89,37 @@ public class ImportExportTool {
}
+ public void exportData(String nodeName, Writer writer) {
+
+ Session sesson = null;
+ try {
+
+ sesson = createConnection(username, password);
+ ContentExporter exporter = new ContentExporter(sesson);
+ final NodeIterator nodes = sesson.getRootNode().getNodes();
+ while (nodes.hasNext()) {
+ final Node node = nodes.nextNode();
+ log.info("node {}", node.getPath());
+ }
+ exporter.exportContent(nodeName, writer);
+
+ } catch (RepositoryException e) {
+ log.error("Error exporting content", e);
+ revertTransaction(sesson);
+ } catch (IOException e) {
+ log.error("Error reading content", e);
+ revertTransaction(sesson);
+ } finally {
+ closeSession(sesson);
+ }
+
+ }
+
+ private void closeSession(Session session) {
+ if (session != null) {
+ session.logout();
+ }
+ }
/**
* Import given filename into repository.
@@ -107,7 +142,7 @@ public class ImportExportTool {
}
final FileInputStream content = new FileInputStream(file);
contentImporter.importContent(parentPath, nodeName, content, ImportBehavior.MERGE);
-
+ session.save();
} catch (RepositoryException e) {
log.error("Error importing file: " + fileName, e);
revertTransaction(session);
@@ -118,9 +153,7 @@ public class ImportExportTool {
} catch (IOException e) {
log.error("Error reading file", e);
} finally {
- if (session != null) {
- session.logout();
- }
+ closeSession(session);
}
}
@@ -155,4 +188,6 @@ public class ImportExportTool {
public void setPassword(String password) {
this.password = password;
}
+
+
}
Modified: rave/sandbox/content-services/rave-jcr-tools/src/main/resources/log4j.xml
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-jcr-tools/src/main/resources/log4j.xml?rev=1376508&r1=1376507&r2=1376508&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-jcr-tools/src/main/resources/log4j.xml (original)
+++ rave/sandbox/content-services/rave-jcr-tools/src/main/resources/log4j.xml Thu Aug 23 14:35:42 2012
@@ -34,7 +34,7 @@
<param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} %-5p [%C.%M():%L] %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
- <param name="levelMin" value="ERROR"/>
+ <param name="levelMin" value="DEBUG"/>
</filter>
</appender>
Modified: rave/sandbox/content-services/rave-jcr-tools/src/test/java/org/apache/rave/tools/ImportExportToolTest.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-jcr-tools/src/test/java/org/apache/rave/tools/ImportExportToolTest.java?rev=1376508&r1=1376507&r2=1376508&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-jcr-tools/src/test/java/org/apache/rave/tools/ImportExportToolTest.java (original)
+++ rave/sandbox/content-services/rave-jcr-tools/src/test/java/org/apache/rave/tools/ImportExportToolTest.java Thu Aug 23 14:35:42 2012
@@ -19,10 +19,14 @@
package org.apache.rave.tools;
+import java.io.StringWriter;
+
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.junit.Assert.assertTrue;
+
/**
* @version "$Id$"
*/
@@ -38,5 +42,23 @@ public class ImportExportToolTest {
tool.setPassword("admin");
tool.setUsername("admin");
tool.importData("/", "testnode");
+ assertTrue("no errors should be thrown", true);
+ }
+
+
+ @Test
+ public void testExport() throws Exception {
+ ImportExportTool tool = new ImportExportTool("repository/repository.xml", "repository", FILE_NAME);
+ tool.setPassword("admin");
+ tool.setUsername("admin");
+ tool.importData("/", "testnode");
+ assertTrue("no errors should be thrown", true);
+ tool = new ImportExportTool("repository/repository.xml", "repository", null);
+ final StringWriter writer = new StringWriter();
+ tool.exportData("/testnode", writer);
+ assertTrue("no errors should be thrown", true);
+ log.info("writer {}", writer);
+
+
}
}
Modified: rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMappingByConfig.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMappingByConfig.java?rev=1376508&r1=1376507&r2=1376508&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMappingByConfig.java (original)
+++ rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMappingByConfig.java Thu Aug 23 14:35:42 2012
@@ -35,7 +35,7 @@ import org.apache.rave.jcr.config.JcrCon
import org.apache.rave.jcr.config.model.api.PageConfiguration;
import org.apache.rave.jcr.config.model.api.PageDefinition;
import org.apache.rave.jcr.config.model.api.PageFragment;
-import org.apache.rave.jcr.config.url.UrlConfig;
+import org.apache.rave.jcr.config.model.api.UrlConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.AnnotationUtils;
@@ -97,7 +97,7 @@ public class HmvcHandlerMethodMappingByC
} else {
final PageConfiguration configuration = configManager.loadConfiguration(configurationPath);
- final UrlConfig urlConfig = configManager.loadUrlConfig(urlMappingsPath, configuration);
+ final UrlConfiguration urlConfig = configManager.loadUrlConfig(urlMappingsPath, configuration);
// TODO use urlConfig
processConfiguration(configuration);
}