-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into scala-2.11
- Loading branch information
Showing
14 changed files
with
213 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
interp.repositories() ++= Seq(coursier.MavenRepository("file://" + java.lang.System.getProperties.get("user.home") + "/.m2/repository/")) | ||
interp.load.ivy(coursier.Dependency("michid"%%"script-oak-1.9.0", "1.3")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
interp.repositories() ++= Seq(coursier.MavenRepository("file://" + java.lang.System.getProperties.get("user.home") + "/.m2/repository/")) | ||
interp.load.ivy(coursier.Dependency("michid"%%"script-oak-1.9.1", "1.4")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>michid</groupId> | ||
<artifactId>script-oak-parent_2.11</artifactId> | ||
<version>1.4</version> | ||
<relativePath>../../script-oak-parent/pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>script-oak-1.9.1_2.11</artifactId> | ||
<name>Script Oak 1.9.1 Fixture</name> | ||
|
||
<properties> | ||
<oak.fixture.version>1.9.1</oak.fixture.version> | ||
</properties> | ||
|
||
<build> | ||
<sourceDirectory>src/main/scala</sourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<groupId>net.alchim31.maven</groupId> | ||
<artifactId>scala-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.jackrabbit</groupId> | ||
<artifactId>oak-segment-tar</artifactId> | ||
<version>${oak.fixture.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.jackrabbit</groupId> | ||
<artifactId>oak-blob</artifactId> | ||
<version>${oak.fixture.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.jackrabbit</groupId> | ||
<artifactId>oak-blob-plugins</artifactId> | ||
<version>${oak.fixture.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.lihaoyi</groupId> | ||
<artifactId>ammonite-ops_2.11</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.scala-lang</groupId> | ||
<artifactId>scala-library</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>michid</groupId> | ||
<artifactId>script-oak-core_2.11</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.jackrabbit</groupId> | ||
<artifactId>oak-tooling-api</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
42 changes: 42 additions & 0 deletions
42
...or/script-oak-1.9.1/src/main/scala/michid/script/oak/fixture/BasicReadOnlyBlobStore.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package michid.script.oak.fixture | ||
|
||
import java.io.{ByteArrayInputStream, IOException, InputStream} | ||
|
||
import org.apache.jackrabbit.oak.spi.blob.{BlobOptions, BlobStore} | ||
|
||
/** | ||
* Utility BlobStore implementation to be used in tooling that can work with a | ||
* FileStore without the need of the DataStore being present locally | ||
*/ | ||
class BasicReadOnlyBlobStore extends BlobStore { | ||
@throws[IOException] | ||
override def writeBlob(in: InputStream) = throw new UnsupportedOperationException | ||
|
||
/** | ||
* Ignores the options provided and delegates to `writeBlob(InputStream)` | ||
* | ||
* @param in the input stream to write | ||
* @param options the options to use | ||
* @return | ||
* @throws IOException | ||
*/ | ||
@throws[IOException] | ||
override def writeBlob(in: InputStream, options: BlobOptions): String = writeBlob(in) | ||
|
||
@throws[IOException] | ||
override def readBlob(blobId: String, pos: Long, buff: Array[Byte], off: Int, length: Int) = throw new UnsupportedOperationException | ||
|
||
@throws[IOException] | ||
override def getBlobLength(blobId: String): Long = { // best effort length extraction | ||
val indexOfSep = blobId.lastIndexOf("#") | ||
if (indexOfSep != -1) java.lang.Long.valueOf(blobId.substring(indexOfSep + 1)) | ||
else -1 | ||
} | ||
|
||
@throws[IOException] | ||
override def getInputStream(blobId: String) = new ByteArrayInputStream(new Array[Byte](0)) | ||
|
||
override def getBlobId(reference: String): String = reference | ||
|
||
override def getReference(blobId: String): String = blobId | ||
} |
72 changes: 72 additions & 0 deletions
72
...k-fixture-reactor/script-oak-1.9.1/src/main/scala/michid/script/oak/fixture/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package michid.script.oak | ||
|
||
import java.io.Closeable | ||
|
||
import ammonite.ops.{Path, pwd} | ||
import michid.script.oak.filestore.FileStoreAnalyser | ||
import org.apache.jackrabbit.oak.plugins.blob.datastore.{DataStoreBlobStore, OakFileDataStore} | ||
import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder | ||
import org.apache.jackrabbit.oak.segment.file.FileStoreBuilder.fileStoreBuilder | ||
import org.apache.jackrabbit.oak.segment.file.proc.Proc | ||
import org.apache.jackrabbit.oak.spi.blob.BlobStore | ||
import org.apache.jackrabbit.oak.tooling.filestore.bindings.nodestate.NodeStateBackedSegmentStore | ||
|
||
import scala.util.Random | ||
|
||
/** Common predefs used by script-oak */ | ||
package object fixture { | ||
|
||
/** A blob store that actually ignores the binaries. Useful if the blob store is not available */ | ||
val dummyBlobStore: BlobStore = new BasicReadOnlyBlobStore | ||
|
||
/** A plain file store builder that can be customised and passed to pass to fileStoreAnalyser */ | ||
val plainFileStoreBuilder: Path => FileStoreBuilder = | ||
path => fileStoreBuilder(path.toNIO.toFile) | ||
|
||
/** A customised file store builder, which configures a dummyBlobStore */ | ||
val dummyBlobStoreBuilder: Path => FileStoreBuilder = | ||
plainFileStoreBuilder(_).withBlobStore(dummyBlobStore) | ||
|
||
/** A file data store based blob store */ | ||
def newBlobStore(directory: Path): BlobStore = { | ||
val delegate = new OakFileDataStore | ||
delegate.setPath(directory.toString) | ||
delegate.init(null) | ||
new DataStoreBlobStore(delegate) | ||
} | ||
|
||
/** Create a new file store analyser. If no data store exists at the given path the | ||
* segment store is created without an external data store unless one is specified | ||
* within the passed builder. */ | ||
def fileStoreAnalyser( | ||
segmentStoreDirectory: Path = pwd / "segmentstore", | ||
dataStoreDirectory: Path = pwd / "datastore", | ||
readOnly: Boolean = true, | ||
builder: Path => FileStoreBuilder = plainFileStoreBuilder) | ||
: FileStoreAnalyser = { | ||
val fileStoreBuilder = builder(segmentStoreDirectory) | ||
if (dataStoreDirectory.toIO.exists()) | ||
fileStoreBuilder.withBlobStore(newBlobStore(dataStoreDirectory)) | ||
|
||
val fileStore = if (readOnly) | ||
fileStoreBuilder.buildReadOnly() else | ||
fileStoreBuilder.build() | ||
|
||
val store = NodeStateBackedSegmentStore.newSegmentStore( | ||
Proc.of(fileStoreBuilder.buildProcBackend(fileStore))) | ||
new FileStoreAnalyser(store) with Closeable { | ||
override def close(): Unit = { | ||
super.close() | ||
fileStore.close() | ||
} | ||
} | ||
} | ||
|
||
object EmptyFileStore { | ||
def path: Path = { | ||
val path = pwd / "target" / Random.nextInt(1000000).toString / "segmentstore" | ||
plainFileStoreBuilder(path).build().close() | ||
path | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters