You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2014/05/16 16:21:17 UTC
svn commit: r1595205 -
/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/RepositoryAccessor.java
Author: rombert
Date: Fri May 16 14:21:17 2014
New Revision: 1595205
URL: http://svn.apache.org/r1595205
Log:
SLING-3161 - SlingIDE Import Content wizard should respect .vltignore
files
Added RepositoryAccessor.createFile
Modified:
sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/RepositoryAccessor.java
Modified: sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/RepositoryAccessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/RepositoryAccessor.java?rev=1595205&r1=1595204&r2=1595205&view=diff
==============================================================================
--- sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/RepositoryAccessor.java (original)
+++ sling/trunk/tooling/ide/eclipse-test/src/org/apache/sling/ide/test/impl/helpers/RepositoryAccessor.java Fri May 16 14:21:17 2014
@@ -18,6 +18,7 @@ package org.apache.sling.ide.test.impl.h
import static org.junit.Assert.assertThat;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.jcr.Credentials;
@@ -122,6 +123,24 @@ public class RepositoryAccessor {
}
}
+ public void createFile(String path, byte[] bytes) throws RepositoryException {
+ Session session = login();
+ try {
+ if (session.nodeExists(path)) {
+ return;
+ }
+
+ Node parent = session.getNode(Text.getRelativeParent(path, 1));
+ Node resourceNode = parent.addNode(Text.getName(path), "nt:file");
+ Node contentNode = resourceNode.addNode("jcr:content", "nt:resource");
+ contentNode
+ .setProperty("jcr:data", session.getValueFactory().createBinary(new ByteArrayInputStream(bytes)));
+ session.save();
+ } finally {
+ session.logout();
+ }
+ }
+
private Session login() throws RepositoryException {
RepositoryInfo repositoryInfo = new RepositoryInfo(config.getUsername(), config.getPassword(), config.getUrl());