diff --git a/.gitignore b/.gitignore index bb9aff5..21befa0 100644 --- a/.gitignore +++ b/.gitignore @@ -6,18 +6,26 @@ /release.properties /dependency-reduced-pom.xml /buildNumber.properties +/*/target/ +/*/pom.xml.tag +/*/pom.xml.releaseBackup +/*/pom.xml.versionsBackup +/*/pom.xml.next +/*/release.properties +/*/dependency-reduced-pom.xml +/*/buildNumber.properties /init-project.sh *.class *~ *.swp -/*.iml +*.iml *.sc /.idea/ .DS_Store /apphome.sh -/home/ -/data/ -/data-*/ +/command/home/ +/command/data/ +/command/data-*/ /.vagrant/ /.yum-repo /.dans.knaw.nl-yum-repo diff --git a/debug-init-env.sh b/command/debug-init-env.sh similarity index 100% rename from debug-init-env.sh rename to command/debug-init-env.sh diff --git a/command/pom.xml b/command/pom.xml new file mode 100644 index 0000000..d055261 --- /dev/null +++ b/command/pom.xml @@ -0,0 +1,144 @@ + + + 4.0.0 + + + nl.knaw.dans.shared + dans-scala-app-project + 5.1.0 + + + + nl.knaw.dans.easy + easy-stage-dataset + 1.8.6-SNAPSHOT + + EASY Stage Dataset Command + 2015 + + + nl.knaw.dans.easy.stage.command.Command + 1.0.5 + + + + + nl.knaw.dans.easy + easy-stage-dataset-lib + ${project.version} + + + org.rogach + scallop_2.12 + + + + + + dans-releases + + true + + + false + + https://maven.dans.knaw.nl/releases/ + + + dans-snapshots + + false + + + true + + https://maven.dans.knaw.nl/snapshots/ + + + + + + + maven-dependency-plugin + + + resources + generate-resources + + unpack + + + + + nl.knaw.dans.easy + easy-licenses + ${easy.licenses.version} + ${project.build.directory}/easy-licenses + + + + + + + + + + + + rpm + + false + + /usr/local/bin/rpm + + + + + + org.codehaus.mojo + rpm-maven-plugin + + Applications/Archiving + + + /opt/${dans-provider-name}/${project.artifactId}/bin + 755 + + + src/main/assembly/dist/bin/easy-stage-file-item + + + + + /etc/opt/${dans-provider-name}/${project.artifactId}/lic + ${rpm-replace-configuration} + + + target/easy-licenses/licenses + + + + + + + + + + + diff --git a/src/main/assembly/bin.xml b/command/src/main/assembly/bin.xml similarity index 100% rename from src/main/assembly/bin.xml rename to command/src/main/assembly/bin.xml diff --git a/src/main/assembly/dist/bin/easy-stage-dataset b/command/src/main/assembly/dist/bin/easy-stage-dataset similarity index 100% rename from src/main/assembly/dist/bin/easy-stage-dataset rename to command/src/main/assembly/dist/bin/easy-stage-dataset diff --git a/src/main/assembly/dist/bin/easy-stage-file-item b/command/src/main/assembly/dist/bin/easy-stage-file-item similarity index 100% rename from src/main/assembly/dist/bin/easy-stage-file-item rename to command/src/main/assembly/dist/bin/easy-stage-file-item diff --git a/src/main/assembly/dist/bin/version b/command/src/main/assembly/dist/bin/version similarity index 100% rename from src/main/assembly/dist/bin/version rename to command/src/main/assembly/dist/bin/version diff --git a/src/main/assembly/dist/cfg/application.properties b/command/src/main/assembly/dist/cfg/application.properties similarity index 100% rename from src/main/assembly/dist/cfg/application.properties rename to command/src/main/assembly/dist/cfg/application.properties diff --git a/src/main/assembly/dist/cfg/logback.xml b/command/src/main/assembly/dist/cfg/logback.xml similarity index 100% rename from src/main/assembly/dist/cfg/logback.xml rename to command/src/main/assembly/dist/cfg/logback.xml diff --git a/src/main/scala/nl.knaw.dans.easy.stage/Command.scala b/command/src/main/scala/nl.knaw.dans.easy.stage.command/Command.scala similarity index 96% rename from src/main/scala/nl.knaw.dans.easy.stage/Command.scala rename to command/src/main/scala/nl.knaw.dans.easy.stage.command/Command.scala index 7bd6417..d4cf4e5 100644 --- a/src/main/scala/nl.knaw.dans.easy.stage/Command.scala +++ b/command/src/main/scala/nl.knaw.dans.easy.stage.command/Command.scala @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nl.knaw.dans.easy.stage +package nl.knaw.dans.easy.stage.command import java.io.File import java.nio.file.Paths @@ -23,6 +23,8 @@ import nl.knaw.dans.lib.error._ import org.apache.commons.configuration.PropertiesConfiguration import org.joda.time.DateTime +import nl.knaw.dans.easy.stage.{ Settings, EasyStageDataset } + object Command extends App { val configuration = Configuration(Paths.get(System.getProperty("app.home"))) diff --git a/src/main/scala/nl.knaw.dans.easy.stage/CommandLineOptions.scala b/command/src/main/scala/nl.knaw.dans.easy.stage.command/CommandLineOptions.scala similarity index 99% rename from src/main/scala/nl.knaw.dans.easy.stage/CommandLineOptions.scala rename to command/src/main/scala/nl.knaw.dans.easy.stage.command/CommandLineOptions.scala index f7b07c0..819901f 100644 --- a/src/main/scala/nl.knaw.dans.easy.stage/CommandLineOptions.scala +++ b/command/src/main/scala/nl.knaw.dans.easy.stage.command/CommandLineOptions.scala @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nl.knaw.dans.easy.stage +package nl.knaw.dans.easy.stage.command import java.io.File import java.net.URI diff --git a/src/main/scala/nl.knaw.dans.easy.stage/Configuration.scala b/command/src/main/scala/nl.knaw.dans.easy.stage.command/Configuration.scala similarity index 92% rename from src/main/scala/nl.knaw.dans.easy.stage/Configuration.scala rename to command/src/main/scala/nl.knaw.dans.easy.stage.command/Configuration.scala index 9a91f27..5658028 100644 --- a/src/main/scala/nl.knaw.dans.easy.stage/Configuration.scala +++ b/command/src/main/scala/nl.knaw.dans.easy.stage.command/Configuration.scala @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nl.knaw.dans.easy.stage +package nl.knaw.dans.easy.stage.command import java.io.File import java.nio.file.{ Files, Path, Paths } @@ -31,7 +31,9 @@ object Configuration { def apply(home: Path): Configuration = { val cfgPath = Seq(Paths.get(s"/etc/opt/dans.knaw.nl/easy-stage-dataset/"), home.resolve("cfg")) .find(Files.exists(_)) - .getOrElse { throw new IllegalStateException("No configuration directory found") } + .getOrElse { + throw new IllegalStateException("No configuration directory found") + } new Configuration( version = managed(Source.fromFile(home.resolve("bin/version").toFile)).acquireAndGet(_.mkString), diff --git a/command/src/main/scala/nl.knaw.dans.easy.stage.command/fileitem/EasyStageFileItemCommand.scala b/command/src/main/scala/nl.knaw.dans.easy.stage.command/fileitem/EasyStageFileItemCommand.scala new file mode 100644 index 0000000..75c0d0f --- /dev/null +++ b/command/src/main/scala/nl.knaw.dans.easy.stage.command/fileitem/EasyStageFileItemCommand.scala @@ -0,0 +1,82 @@ +/** + * Copyright (C) 2015 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed 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 nl.knaw.dans.easy.stage.command.fileitem + +import java.nio.file.Paths +import java.sql.SQLException + +import com.yourmediashelf.fedora.client.FedoraClientException +import nl.knaw.dans.easy.stage.command.Configuration +import nl.knaw.dans.easy.stage.fileitem.{ EasyFilesAndFoldersImpl, EasyStageFileItem, FileItemSettings } +import nl.knaw.dans.easy.stage.lib._ +import nl.knaw.dans.lib.logging.DebugEnhancedLogging +import resource._ + +import scala.util.{ Success, Try } + +object EasyStageFileItemCommand extends DebugEnhancedLogging { + + def main(args: Array[String]) { + val configuration = Configuration(Paths.get(System.getProperty("app.home"))) + val clo = new FileItemCommandLineOptions(args, configuration) + Fedora.setFedoraConnectionSettings( + configuration.properties.getString("fcrepo.url"), + configuration.properties.getString("fcrepo.user"), + configuration.properties.getString("fcrepo.password")) + getSettingsRows(clo, configuration) + .map(seqOfSettings => + for (settings <- seqOfSettings; + s <- settings) { + EasyStageFileItem.run(s) + .map(_ => logger.info(s"Staging SUCCESS of $settings")) + .recover { case t: Throwable => + logger.error(s"Staging FAIL of $settings", t) + if (t.isInstanceOf[SQLException] || t.isInstanceOf[FedoraClientException]) return + } + }) + .recover { case t: Throwable => logger.error(s"Staging FAIL of $clo with repo url ${ configuration.properties.getString("fcrepo.url") }", t) } + } + + def getSettingsRows(clo: FileItemCommandLineOptions, configuration: Configuration): Try[Seq[ManagedResource[FileItemSettings]]] = { + if (clo.datasetId.isDefined) + Success( + managed(new EasyFilesAndFoldersImpl( + databaseUrl = configuration.properties.getString("db-connection-url"), + databaseUser = configuration.properties.getString("db-connection-user"), + databasePassword = configuration.properties.getString("db-connection-password"))) + .map(FileItemApplySettings(clo, _)) :: Nil) + else { + val trailArgs = Seq(clo.sdoSetDir().toString) + CSV(clo.csvFile(), clo.longOptionNames) + .map { + case (csv, warning) => + for (w <- warning) + logger.warn(w) + + val rows = csv.getRows + if (rows.isEmpty) logger.warn("Empty CSV file") + rows.map(options => { + logger.info(s"Options: ${ options.mkString(" ") }") + managed(new EasyFilesAndFoldersImpl( + databaseUrl = configuration.properties.getString("db-connection-url"), + databaseUser = configuration.properties.getString("db-connection-user"), + databasePassword = configuration.properties.getString("db-connection-password"))) + .map(FileItemApplySettings(new FileItemCommandLineOptions(options ++ trailArgs, configuration), _)) + }) + } + } + } +} diff --git a/command/src/main/scala/nl.knaw.dans.easy.stage.command/fileitem/FileItemApplySettings.scala b/command/src/main/scala/nl.knaw.dans.easy.stage.command/fileitem/FileItemApplySettings.scala new file mode 100644 index 0000000..0f03d07 --- /dev/null +++ b/command/src/main/scala/nl.knaw.dans.easy.stage.command/fileitem/FileItemApplySettings.scala @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2015 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed 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 nl.knaw.dans.easy.stage.command.fileitem + +import nl.knaw.dans.easy.stage.fileitem.{ EasyFilesAndFolders, FileItemSettings } +import nl.knaw.dans.easy.stage.lib.FedoraRelationObject + +object FileItemApplySettings { + /** new file or folder for an existing dataset */ + def apply(conf: FileItemCommandLineOptions, easyFilesAndFolders: EasyFilesAndFolders) = + new FileItemSettings( + sdoSetDir = conf.sdoSetDir.toOption, + file = conf.file.toOption, + datastreamLocation = conf.dsLocation.toOption, + size = conf.size.toOption, + accessibleTo = conf.accessibleTo(), + visibleTo = conf.visibleTo(), + creatorRole = conf.creatorRole(), + ownerId = conf.ownerId.toOption.map(_.trim).filter(_.nonEmpty), + datasetId = conf.datasetId.toOption, + pathInDataset = conf.pathInDataset.toOption, + format = conf.format.toOption, + subordinate = FedoraRelationObject(conf.datasetId()), + easyFilesAndFolders = easyFilesAndFolders) { + override def toString: String = conf.toString + } +} diff --git a/src/main/scala/nl.knaw.dans.easy.stage/fileitem/FileItemCommandLineOptions.scala b/command/src/main/scala/nl.knaw.dans.easy.stage.command/fileitem/FileItemCommandLineOptions.scala similarity index 97% rename from src/main/scala/nl.knaw.dans.easy.stage/fileitem/FileItemCommandLineOptions.scala rename to command/src/main/scala/nl.knaw.dans.easy.stage.command/fileitem/FileItemCommandLineOptions.scala index e7c54f9..4241db1 100644 --- a/src/main/scala/nl.knaw.dans.easy.stage/fileitem/FileItemCommandLineOptions.scala +++ b/command/src/main/scala/nl.knaw.dans.easy.stage.command/fileitem/FileItemCommandLineOptions.scala @@ -13,14 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nl.knaw.dans.easy.stage.fileitem +package nl.knaw.dans.easy.stage.command.fileitem import java.io.File import java.net.URL -import nl.knaw.dans.easy.stage.Configuration import nl.knaw.dans.easy.stage.fileitem.FileAccessRights.UserCategory import nl.knaw.dans.easy.stage.fileitem.FileItemSettings._ +import nl.knaw.dans.easy.stage.fileitem.FileAccessRights +import nl.knaw.dans.easy.stage.command.Configuration import org.rogach.scallop._ class FileItemCommandLineOptions(args: Seq[String], configuration: Configuration) extends ScallopConf(args) { diff --git a/src/test/resources/debug-config/application.properties b/command/src/test/resources/debug-config/application.properties similarity index 100% rename from src/test/resources/debug-config/application.properties rename to command/src/test/resources/debug-config/application.properties diff --git a/src/test/resources/debug-config/logback.xml b/command/src/test/resources/debug-config/logback.xml similarity index 100% rename from src/test/resources/debug-config/logback.xml rename to command/src/test/resources/debug-config/logback.xml diff --git a/src/test/resources/example.csv b/command/src/test/resources/example.csv similarity index 100% rename from src/test/resources/example.csv rename to command/src/test/resources/example.csv diff --git a/src/test/resources/file_properties-test.csv b/command/src/test/resources/file_properties-test.csv similarity index 100% rename from src/test/resources/file_properties-test.csv rename to command/src/test/resources/file_properties-test.csv diff --git a/src/test/resources/logback.xml b/command/src/test/resources/logback.xml similarity index 100% rename from src/test/resources/logback.xml rename to command/src/test/resources/logback.xml diff --git a/src/test/scala/nl.knaw.dans.easy.stage/AbstractConfSpec.scala b/command/src/test/scala/nl.knaw.dans.easy.stage.command/AbstractConfSpec.scala similarity index 94% rename from src/test/scala/nl.knaw.dans.easy.stage/AbstractConfSpec.scala rename to command/src/test/scala/nl.knaw.dans.easy.stage.command/AbstractConfSpec.scala index b7fef21..61d6f62 100644 --- a/src/test/scala/nl.knaw.dans.easy.stage/AbstractConfSpec.scala +++ b/command/src/test/scala/nl.knaw.dans.easy.stage.command/AbstractConfSpec.scala @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nl.knaw.dans.easy.stage +package nl.knaw.dans.easy.stage.command import java.io.{ ByteArrayOutputStream, File } @@ -40,7 +40,7 @@ abstract class AbstractConfSpec extends FlatSpec with Matchers { val lineSeparators = s"(${ System.lineSeparator() })+" val options = helpInfo.split(s"${ lineSeparators }Options:$lineSeparators")(1) options.trim should not be empty - new File("README.md") should containTrimmed(options) + new File("../README.md") should containTrimmed(options) } "distributed default properties" should "be valid options" in { diff --git a/src/test/scala/nl.knaw.dans.easy.stage/ConfSpec.scala b/command/src/test/scala/nl.knaw.dans.easy.stage.command/ConfSpec.scala similarity index 87% rename from src/test/scala/nl.knaw.dans.easy.stage/ConfSpec.scala rename to command/src/test/scala/nl.knaw.dans.easy.stage.command/ConfSpec.scala index f6b62f1..80906be 100644 --- a/src/test/scala/nl.knaw.dans.easy.stage/ConfSpec.scala +++ b/command/src/test/scala/nl.knaw.dans.easy.stage.command/ConfSpec.scala @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nl.knaw.dans.easy.stage +package nl.knaw.dans.easy.stage.command import java.io.File import java.nio.file.Paths @@ -38,11 +38,11 @@ class ConfSpec extends AbstractConfSpec { override def getCommandLineOptions: ScallopConf = clo "synopsis in help info" should "be part of README.md" in { - new File("README.md") should containTrimmed(clo.synopsis) + new File("../README.md") should containTrimmed(clo.synopsis) } "description line(s) in help info" should "be part of README.md and pom.xml" in { - new File("README.md") should containTrimmed(clo.description) - new File("pom.xml") should containTrimmed(clo.description) + new File("../README.md") should containTrimmed(clo.description) + new File("../pom.xml") should containTrimmed(clo.description) } } diff --git a/src/test/scala/nl.knaw.dans.easy.stage/CustomMatchers.scala b/command/src/test/scala/nl.knaw.dans.easy.stage.command/CustomMatchers.scala similarity index 100% rename from src/test/scala/nl.knaw.dans.easy.stage/CustomMatchers.scala rename to command/src/test/scala/nl.knaw.dans.easy.stage.command/CustomMatchers.scala diff --git a/src/test/scala/nl.knaw.dans.easy.stage/DebugConfigSpec.scala b/command/src/test/scala/nl.knaw.dans.easy.stage.command/DebugConfigSpec.scala similarity index 97% rename from src/test/scala/nl.knaw.dans.easy.stage/DebugConfigSpec.scala rename to command/src/test/scala/nl.knaw.dans.easy.stage.command/DebugConfigSpec.scala index d74d301..53a82f2 100644 --- a/src/test/scala/nl.knaw.dans.easy.stage/DebugConfigSpec.scala +++ b/command/src/test/scala/nl.knaw.dans.easy.stage.command/DebugConfigSpec.scala @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nl.knaw.dans.easy.stage +package nl.knaw.dans.easy.stage.command import java.nio.file.{ Files, Paths } diff --git a/src/test/scala/nl.knaw.dans.easy.stage/fileitem/EasyStageFileItemSpec.scala b/command/src/test/scala/nl.knaw.dans.easy.stage.command/fileitem/EasyStageFileItemCommandSpec.scala similarity index 61% rename from src/test/scala/nl.knaw.dans.easy.stage/fileitem/EasyStageFileItemSpec.scala rename to command/src/test/scala/nl.knaw.dans.easy.stage.command/fileitem/EasyStageFileItemCommandSpec.scala index 5498112..d5a110f 100644 --- a/src/test/scala/nl.knaw.dans.easy.stage/fileitem/EasyStageFileItemSpec.scala +++ b/command/src/test/scala/nl.knaw.dans.easy.stage.command/fileitem/EasyStageFileItemCommandSpec.scala @@ -13,25 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nl.knaw.dans.easy.stage.fileitem +package nl.knaw.dans.easy.stage.command.fileitem -import java.io.File -import java.net.URL import java.nio.file.Paths -import nl.knaw.dans.easy.stage.fileitem.EasyStageFileItem._ -import nl.knaw.dans.easy.stage.fileitem.SdoFiles.readDatastreamFoxml -import nl.knaw.dans.easy.stage.lib.Util.loadXML -import nl.knaw.dans.easy.stage.lib.{ Fedora, FedoraRelationObject } -import nl.knaw.dans.easy.stage.{ Configuration, ExistingAncestor } +import nl.knaw.dans.easy.stage.ExistingAncestor +import nl.knaw.dans.easy.stage.command.Configuration +import nl.knaw.dans.easy.stage.command.fileitem.EasyStageFileItemCommand._ +import nl.knaw.dans.easy.stage.command.fileitem.SdoFiles.readDatastreamFoxml +import nl.knaw.dans.easy.stage.fileitem.{ EasyFilesAndFolders, EasyStageFileItem } +import nl.knaw.dans.easy.stage.lib.Fedora import org.apache.commons.configuration.PropertiesConfiguration import org.apache.commons.io.FileUtils.{ deleteQuietly, readFileToString, write } import org.scalatest._ import scala.collection.immutable.HashMap -import scala.util.{ Failure, Success, Try } +import scala.util.{ Success, Try } -class EasyStageFileItemSpec extends FlatSpec with Matchers with Inside with BeforeAndAfterEach { +class EasyStageFileItemCommandSpec extends FlatSpec with Matchers with Inside with BeforeAndAfterEach { private val testDir = Paths.get("target/test", getClass.getSimpleName) @@ -69,76 +68,16 @@ class EasyStageFileItemSpec extends FlatSpec with Matchers with Inside with Befo } } - "run" should "report a missing size" in { - val result = EasyStageFileItem.run(new FileItemSettings( - sdoSetDir = Some(new File("target/testSDO")), - datastreamLocation = Some(new URL("http://x.nl/l/d")), - size = None, - datasetId = Some("easy-dataset:1"), - pathInDataset = Some(new File("original/newSub/file.mpeg")), - format = None, - subordinate = FedoraRelationObject("easy-dataset:1"), - easyFilesAndFolders = mockEasyFilesAndFolders(HashMap( - "easy-dataset:1 original/newSub/file.mpeg" -> Success("original", "easy-folder:1") - )), - fedora = mockFedora(HashMap( - "pid~easy-dataset:1" -> Seq("easy-dataset:1") - )), - accessibleTo = FileAccessRights.NONE, - visibleTo = FileAccessRights.ANONYMOUS - )) - - inside(result) { - case Failure(e: NoSuchElementException) => e should have message "None.get" - } - // the message is vague, a proper FileItemConf/EasyStageDataset - // should take care of something clearer for the end user - } - - it should "report a fedora error" in { - val result = EasyStageFileItem.run(new FileItemSettings( - sdoSetDir = Some(new File("target/testSDO")), - size = Some(1), - datasetId = Some("easy-dataset:1"), - pathInDataset = Some(new File("original/newSub/file.mpeg")), - format = Some("video/mpeg"), - subordinate = FedoraRelationObject("easy-dataset:1"), - easyFilesAndFolders = mockEasyFilesAndFolders(HashMap( - "easy-dataset:1 original/newSub/file.mpeg" -> Failure(new Exception("mocked error")) - )), - fedora = mockFedora(HashMap( - "pid~easy-dataset:1" -> Seq("easy-dataset:1") - )), - accessibleTo = FileAccessRights.NONE, - visibleTo = FileAccessRights.ANONYMOUS - )) - - inside(result) { - case Failure(e) => e should have message "mocked error" - } - } - - it should "report the dataset does not exist" in { - val result = EasyStageFileItem.run(new FileItemSettings( - sdoSetDir = Some(new File("target/testSDO")), - size = Some(1), - datasetId = Some("easy-dataset:1"), - pathInDataset = Some(new File("original/newSub/file.mpeg")), - format = Some("video/mpeg"), - subordinate = FedoraRelationObject("easy-dataset:1"), - easyFilesAndFolders = mockEasyFilesAndFolders(HashMap( - "easy-dataset:1 original/newSub/file.mpeg" -> Success("original", "easy-folder:1") - )), - fedora = mockFedora(HashMap( - "pid~easy-dataset:1" -> Seq() // TODO findObjects should return a Try - )), - accessibleTo = FileAccessRights.NONE, - visibleTo = FileAccessRights.ANONYMOUS - )) - - inside(result) { - case Failure(e) => e should have message "easy-dataset:1 does not exist in repository" - } + private def runForEachCsvRow(filesAndFolders: EasyFilesAndFolders, + fedora: Fedora = mockFedora(HashMap("pid~easy-dataset:1" -> Seq("easy-dataset:1"))), + args: Array[String] = Array( + "--csv-file", + s"$testDir/to-be-staged/some.csv", + s"$testDir/SDO" + )): Unit = { + getSettingsRows(new FileItemCommandLineOptions(args, mockedConfiguration), mockedConfiguration) + .map(_.map(_.map(_.copy(fedora = fedora, easyFilesAndFolders = filesAndFolders)))) + .map(_.foreach(_.map(EasyStageFileItem.run(_)).tried.flatten shouldBe a[Success[_]])) } it should "not overwrite files with same names if folders don't yet exist" in { @@ -238,74 +177,6 @@ class EasyStageFileItemSpec extends FlatSpec with Matchers with Inside with Befo testDir.resolve("SDO/easy-dataset_1").toFile.list() should contain only("dir1_some_txt", "dir2_some_txt") } - private def runForEachCsvRow(filesAndFolders: EasyFilesAndFolders, - fedora: Fedora = mockFedora(HashMap("pid~easy-dataset:1" -> Seq("easy-dataset:1"))), - args: Array[String] = Array( - "--csv-file", - s"$testDir/to-be-staged/some.csv", - s"$testDir/SDO" - )): Unit = { - getSettingsRows(new FileItemCommandLineOptions(args, mockedConfiguration), mockedConfiguration) - .map(_.map(_.map(_.copy(fedora = fedora, easyFilesAndFolders = filesAndFolders)))) - .map(_.foreach(_.map(EasyStageFileItem.run(_)).tried.flatten shouldBe a[Success[_]])) - } - - "createFileSdo" should "use file name even if a title is provided" in { - val sdoSetDir = new File("target/testSdoSet") - val sdoDir = new File(sdoSetDir, "path_to_uuid-as-file-name") - sdoSetDir.mkdirs() - val s = FileItemSettings( - sdoSetDir = sdoSetDir, - file = Some(new File("path/to/uuid-as-file-name")), - datastreamLocation = None, - ownerId = "testOwner", - pathInDataset = new File("path/to/uuid-as-file-name"), - size = Some(1), - format = Some("text/plain"), - sha1 = None, - title = Some("A nice title"), - accessibleTo = FileAccessRights.NONE, - visibleTo = FileAccessRights.ANONYMOUS, - databaseUrl = "", - databaseUser = "", - databasePassword = "") - s.foreach(EasyStageFileItem.createFileSdo(sdoDir, FedoraRelationObject("ficticiousParentSdo"))(_)) - - val efmd = loadXML(new File(sdoDir, "EASY_FILE_METADATA")) - (efmd \ "name").text shouldBe "uuid-as-file-name" - (efmd \ "path").text shouldBe "path/to/uuid-as-file-name" - val foxml = loadXML(new File(sdoDir, "fo.xml")) - (foxml \ "datastream" \ "datastreamVersion" \ "xmlContent" \ "dc" \ "title").text shouldBe "A nice title" - } - - it should "use the filename if title is not provided" in { - val sdoSetDir = new File("target/testSdoSet") - val sdoDir = new File(sdoSetDir, "path_to_uuid-as-file-name") - sdoSetDir.mkdirs() - val s = FileItemSettings( - sdoSetDir = sdoSetDir, - file = Some(new File("path/to/uuid-as-file-name")), - datastreamLocation = None, - ownerId = "testOwner", - pathInDataset = new File("path/to/uuid-as-file-name"), - size = Some(1), - format = Some("text/plain"), - sha1 = None, - title = None, - accessibleTo = FileAccessRights.NONE, - visibleTo = FileAccessRights.ANONYMOUS, - databaseUrl = "", - databaseUser = "", - databasePassword = "") - s.foreach(EasyStageFileItem.createFileSdo(sdoDir, FedoraRelationObject("ficticiousParentSdo"))(_)) - - val efmd = loadXML(new File(sdoDir, "EASY_FILE_METADATA")) - (efmd \ "name").text shouldBe "uuid-as-file-name" - (efmd \ "path").text shouldBe "path/to/uuid-as-file-name" - val foxml = loadXML(new File(sdoDir, "fo.xml")) - (foxml \ "datastream" \ "datastreamVersion" \ "xmlContent" \ "dc" \ "title").text shouldBe "uuid-as-file-name" - } - def mockEasyFilesAndFolders(expectations: Map[String, Try[ExistingAncestor]]): EasyFilesAndFolders = { (file, datasetId) => expectations(s"$datasetId $file") } diff --git a/src/test/scala/nl.knaw.dans.easy.stage/fileitem/FileItemConfSpec.scala b/command/src/test/scala/nl.knaw.dans.easy.stage.command/fileitem/FileItemConfSpec.scala similarity index 90% rename from src/test/scala/nl.knaw.dans.easy.stage/fileitem/FileItemConfSpec.scala rename to command/src/test/scala/nl.knaw.dans.easy.stage.command/fileitem/FileItemConfSpec.scala index 95f0a4a..ac91717 100644 --- a/src/test/scala/nl.knaw.dans.easy.stage/fileitem/FileItemConfSpec.scala +++ b/command/src/test/scala/nl.knaw.dans.easy.stage.command/fileitem/FileItemConfSpec.scala @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nl.knaw.dans.easy.stage.fileitem +package nl.knaw.dans.easy.stage.command.fileitem import java.io.File import java.nio.file.Paths import nl.knaw.dans.easy.stage.CustomMatchers._ -import nl.knaw.dans.easy.stage.{ AbstractConfSpec, Configuration } +import nl.knaw.dans.easy.stage.command.{ AbstractConfSpec, Configuration } import org.apache.commons.configuration.PropertiesConfiguration import org.rogach.scallop.ScallopConf @@ -43,6 +43,6 @@ class FileItemConfSpec extends AbstractConfSpec { override def getCommandLineOptions: ScallopConf = clo "synopsis in help info" should "be part of README.md" in { - new File("README.md") should containTrimmed(clo.synopsis) + new File("../README.md") should containTrimmed(clo.synopsis) } } diff --git a/src/test/scala/nl.knaw.dans.easy.stage/fileitem/SdoFiles.scala b/command/src/test/scala/nl.knaw.dans.easy.stage.command/fileitem/SdoFiles.scala similarity index 96% rename from src/test/scala/nl.knaw.dans.easy.stage/fileitem/SdoFiles.scala rename to command/src/test/scala/nl.knaw.dans.easy.stage.command/fileitem/SdoFiles.scala index bdfeba6..b8493a8 100644 --- a/src/test/scala/nl.knaw.dans.easy.stage/fileitem/SdoFiles.scala +++ b/command/src/test/scala/nl.knaw.dans.easy.stage.command/fileitem/SdoFiles.scala @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nl.knaw.dans.easy.stage.fileitem +package nl.knaw.dans.easy.stage.command.fileitem import java.io.File diff --git a/src/test/scala/nl.knaw.dans.easy.stage/lib/CsvSpec.scala b/command/src/test/scala/nl.knaw.dans.easy.stage.command/lib/CsvSpec.scala similarity index 88% rename from src/test/scala/nl.knaw.dans.easy.stage/lib/CsvSpec.scala rename to command/src/test/scala/nl.knaw.dans.easy.stage.command/lib/CsvSpec.scala index 4e5b753..cb81669 100644 --- a/src/test/scala/nl.knaw.dans.easy.stage/lib/CsvSpec.scala +++ b/command/src/test/scala/nl.knaw.dans.easy.stage.command/lib/CsvSpec.scala @@ -13,15 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package nl.knaw.dans.easy.stage.lib +package nl.knaw.dans.easy.stage.command.lib import java.io.ByteArrayInputStream import java.nio.file.Paths -import nl.knaw.dans.easy.stage.Configuration -import nl.knaw.dans.easy.stage.fileitem.FileItemCommandLineOptions +import nl.knaw.dans.easy.stage.command.Configuration +import nl.knaw.dans.easy.stage.command.fileitem.FileItemCommandLineOptions +import nl.knaw.dans.easy.stage.lib.CSV import org.apache.commons.configuration.PropertiesConfiguration -import org.scalatest.{ FlatSpec, Inside, Matchers } +import org.scalatest.{FlatSpec, Inside, Matchers} import scala.util.Failure diff --git a/stageDataset.sh b/command/stageDataset.sh similarity index 100% rename from stageDataset.sh rename to command/stageDataset.sh diff --git a/stageFileItem.sh b/command/stageFileItem.sh similarity index 100% rename from stageFileItem.sh rename to command/stageFileItem.sh diff --git a/lib/pom.xml b/lib/pom.xml new file mode 100644 index 0000000..b4413bd --- /dev/null +++ b/lib/pom.xml @@ -0,0 +1,233 @@ + + + + 4.0.0 + + + nl.knaw.dans.shared + dans-scala-project + 5.1.0 + + + + nl.knaw.dans.easy + easy-stage-dataset-lib + 1.8.6-SNAPSHOT + + EASY Stage Dataset Library + 2015 + + + 3.9.1 + 1.0.5 + + + + + commons-configuration + commons-configuration + + + org.apache.commons + commons-csv + + + org.scala-lang.modules + scala-xml_2.12 + + + org.json4s + json4s-native_2.12 + + + commons-io + commons-io + + + ch.qos.logback + logback-classic + + + nl.knaw.dans.easy + ddm + ${easy.ddm.version} + + + + dom4j + dom4j + 1.6.1 + + + + xml-apis + xml-apis + + + + + com.yourmediashelf.fedora.client + fedora-client-core + + + nl.knaw.dans.easy + dans-fedora + 3.1.7 + test + + + com.yourmediashelf.fedora.client + fedora-client-messaging + + + + org.apache.geronimo.specs + geronimo-stax-api_1.0_spec + + + + + org.postgresql + postgresql + + + + org.joda + joda-convert + + + org.scalatest + scalatest_2.12 + + + nl.knaw.dans.lib + dans-scala-lib_2.12 + + + com.jsuereth + scala-arm_2.12 + + + gov.loc + bagit + + + + + + dans-releases + + true + + + false + + https://maven.dans.knaw.nl/releases/ + + + dans-snapshots + + false + + + true + + https://maven.dans.knaw.nl/snapshots/ + + + + + + + maven-dependency-plugin + + + resources + generate-resources + + unpack + + + + + nl.knaw.dans.easy + easy-licenses + ${easy.licenses.version} + ${project.build.directory}/easy-licenses + + + + + + + + + + + + stageDataset + + true + + + + + org.codehaus.mojo + exec-maven-plugin + + + + + + stageFileItem + + + stageFileItem + + + + + + org.codehaus.mojo + exec-maven-plugin + + nl.knaw.dans.easy.stage.fileitem.EasyStageFileItem + + + + + + + diff --git a/src/main/scala/nl.knaw.dans.easy.stage/EasyStageDataset.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/EasyStageDataset.scala similarity index 97% rename from src/main/scala/nl.knaw.dans.easy.stage/EasyStageDataset.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/EasyStageDataset.scala index 2f67bb8..c66d6ed 100644 --- a/src/main/scala/nl.knaw.dans.easy.stage/EasyStageDataset.scala +++ b/lib/src/main/scala/nl.knaw.dans.easy.stage/EasyStageDataset.scala @@ -118,9 +118,9 @@ object EasyStageDataset extends DebugEnhancedLogging { .lines.filter(_.nonEmpty) .map(_.split("\\h+", 2)) // split into tokens on sequences of horizontal white space characters .map { - case Array(sha1, filePath) if !sha1.matches("[a-fA-F0-9]") => filePath -> sha1 - case array => throw new IllegalArgumentException(s"Invalid line in $sha1File: ${ array.mkString(" ") }") - } + case Array(sha1, filePath) if !sha1.matches("[a-fA-F0-9]") => filePath -> sha1 + case array => throw new IllegalArgumentException(s"Invalid line in $sha1File: ${ array.mkString(" ") }") + } .toMap }.recoverWith { case _: FileNotFoundException => Success(Map.empty[String, String]) } diff --git a/src/main/scala/nl.knaw.dans.easy.stage/Settings.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/Settings.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/Settings.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/Settings.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/dataset/AMD.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/dataset/AMD.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/dataset/AMD.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/dataset/AMD.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/dataset/AdditionalLicense.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/dataset/AdditionalLicense.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/dataset/AdditionalLicense.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/dataset/AdditionalLicense.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/dataset/DepositorInfo.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/dataset/DepositorInfo.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/dataset/DepositorInfo.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/dataset/DepositorInfo.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/dataset/EMD.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/dataset/EMD.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/dataset/EMD.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/dataset/EMD.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/dataset/PRSQL.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/dataset/PRSQL.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/dataset/PRSQL.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/dataset/PRSQL.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/dataset/Util.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/dataset/Util.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/dataset/Util.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/dataset/Util.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyFileMetadata.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyFileMetadata.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyFileMetadata.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyFileMetadata.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyFilesAndFolders.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyFilesAndFolders.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyFilesAndFolders.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyFilesAndFolders.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyItemContainerMd.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyItemContainerMd.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyItemContainerMd.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyItemContainerMd.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyStageFileItem.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyStageFileItem.scala similarity index 67% rename from src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyStageFileItem.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyStageFileItem.scala index 9b02796..2fa39aa 100644 --- a/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyStageFileItem.scala +++ b/lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/EasyStageFileItem.scala @@ -32,57 +32,6 @@ import scala.util.{ Failure, Success, Try } object EasyStageFileItem extends DebugEnhancedLogging { - def main(args: Array[String]) { - val configuration = Configuration(Paths.get(System.getProperty("app.home"))) - val clo = new FileItemCommandLineOptions(args, configuration) - Fedora.setFedoraConnectionSettings( - configuration.properties.getString("fcrepo.url"), - configuration.properties.getString("fcrepo.user"), - configuration.properties.getString("fcrepo.password")) - getSettingsRows(clo, configuration) - .map(seqOfSettings => - for (settings <- seqOfSettings; - s <- settings) { - run(s) - .map(_ => logger.info(s"Staging SUCCESS of $settings")) - .recover { case t: Throwable => - logger.error(s"Staging FAIL of $settings", t) - if (t.isInstanceOf[SQLException] || t.isInstanceOf[FedoraClientException]) return - } - }) - .recover { case t: Throwable => logger.error(s"Staging FAIL of $clo with repo url ${ configuration.properties.getString("fcrepo.url") }", t) } - } - - def getSettingsRows(clo: FileItemCommandLineOptions, configuration: Configuration): Try[Seq[ManagedResource[FileItemSettings]]] = { - if (clo.datasetId.isDefined) - Success( - managed(new EasyFilesAndFoldersImpl( - databaseUrl = configuration.properties.getString("db-connection-url"), - databaseUser = configuration.properties.getString("db-connection-user"), - databasePassword = configuration.properties.getString("db-connection-password"))) - .map(FileItemSettings(clo, _)) :: Nil) - else { - val trailArgs = Seq(clo.sdoSetDir().toString) - CSV(clo.csvFile(), clo.longOptionNames) - .map { - case (csv, warning) => - for (w <- warning) - logger.warn(w) - - val rows = csv.getRows - if (rows.isEmpty) logger.warn("Empty CSV file") - rows.map(options => { - logger.info(s"Options: ${ options.mkString(" ") }") - managed(new EasyFilesAndFoldersImpl( - databaseUrl = configuration.properties.getString("db-connection-url"), - databaseUser = configuration.properties.getString("db-connection-user"), - databasePassword = configuration.properties.getString("db-connection-password"))) - .map(FileItemSettings(new FileItemCommandLineOptions(options ++ trailArgs, configuration), _)) - }) - } - } - } - def run(implicit s: FileItemSettings): Try[Unit] = { trace(s) for { diff --git a/src/main/scala/nl.knaw.dans.easy.stage/fileitem/FileAccessRights.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/FileAccessRights.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/fileitem/FileAccessRights.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/FileAccessRights.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/fileitem/FileItemSettings.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/FileItemSettings.scala similarity index 83% rename from src/main/scala/nl.knaw.dans.easy.stage/fileitem/FileItemSettings.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/FileItemSettings.scala index 6f925cc..c4262a6 100644 --- a/src/main/scala/nl.knaw.dans.easy.stage/fileitem/FileItemSettings.scala +++ b/lib/src/main/scala/nl.knaw.dans.easy.stage/fileitem/FileItemSettings.scala @@ -98,23 +98,4 @@ object FileItemSettings { easyFilesAndFolders = filesAndFolders )) } - - /** new file or folder for an existing dataset */ - def apply(conf: FileItemCommandLineOptions, easyFilesAndFolders: EasyFilesAndFolders) = - new FileItemSettings( - sdoSetDir = conf.sdoSetDir.toOption, - file = conf.file.toOption, - datastreamLocation = conf.dsLocation.toOption, - size = conf.size.toOption, - accessibleTo = conf.accessibleTo(), - visibleTo = conf.visibleTo(), - creatorRole = conf.creatorRole(), - ownerId = conf.ownerId.toOption.map(_.trim).filter(_.nonEmpty), - datasetId = conf.datasetId.toOption, - pathInDataset = conf.pathInDataset.toOption, - format = conf.format.toOption, - subordinate = FedoraRelationObject(conf.datasetId()), - easyFilesAndFolders = easyFilesAndFolders) { - override def toString: String = conf.toString - } } diff --git a/src/main/scala/nl.knaw.dans.easy.stage/lib/CSV.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/lib/CSV.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/lib/CSV.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/lib/CSV.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/lib/Constants.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/lib/Constants.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/lib/Constants.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/lib/Constants.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/lib/FOXML.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/lib/FOXML.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/lib/FOXML.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/lib/FOXML.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/lib/Fedora.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/lib/Fedora.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/lib/Fedora.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/lib/Fedora.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/lib/JSON.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/lib/JSON.scala similarity index 99% rename from src/main/scala/nl.knaw.dans.easy.stage/lib/JSON.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/lib/JSON.scala index 806cf96..8bf5c74 100644 --- a/src/main/scala/nl.knaw.dans.easy.stage/lib/JSON.scala +++ b/lib/src/main/scala/nl.knaw.dans.easy.stage/lib/JSON.scala @@ -61,7 +61,8 @@ object JSON extends DebugEnhancedLogging { ("dsID" -> "ADDITIONAL_LICENSE") ~ ("label" -> name) ~ ("controlGroup" -> "M") ~ - ("mimeType" -> mimetype) } + ("mimeType" -> mimetype) + } pretty(render(sdoCfg(audiences, datastreams))) } diff --git a/src/main/scala/nl.knaw.dans.easy.stage/lib/RelationObject.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/lib/RelationObject.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/lib/RelationObject.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/lib/RelationObject.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/lib/Util.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/lib/Util.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/lib/Util.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/lib/Util.scala diff --git a/src/main/scala/nl.knaw.dans.easy.stage/package.scala b/lib/src/main/scala/nl.knaw.dans.easy.stage/package.scala similarity index 100% rename from src/main/scala/nl.knaw.dans.easy.stage/package.scala rename to lib/src/main/scala/nl.knaw.dans.easy.stage/package.scala diff --git a/src/test/resources/dataset-bags/additional-license-by-text/bag-info.txt b/lib/src/test/resources/dataset-bags/additional-license-by-text/bag-info.txt similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-text/bag-info.txt rename to lib/src/test/resources/dataset-bags/additional-license-by-text/bag-info.txt diff --git a/src/test/resources/dataset-bags/additional-license-by-text/bagit.txt b/lib/src/test/resources/dataset-bags/additional-license-by-text/bagit.txt similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-text/bagit.txt rename to lib/src/test/resources/dataset-bags/additional-license-by-text/bagit.txt diff --git a/src/test/resources/dataset-bags/additional-license-by-text/data/path/to/file.txt b/lib/src/test/resources/dataset-bags/additional-license-by-text/data/path/to/file.txt similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-text/data/path/to/file.txt rename to lib/src/test/resources/dataset-bags/additional-license-by-text/data/path/to/file.txt diff --git a/src/test/resources/dataset-bags/additional-license-by-text/data/quicksort.hs b/lib/src/test/resources/dataset-bags/additional-license-by-text/data/quicksort.hs similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-text/data/quicksort.hs rename to lib/src/test/resources/dataset-bags/additional-license-by-text/data/quicksort.hs diff --git a/src/test/resources/dataset-bags/additional-license-by-text/manifest-md5.txt b/lib/src/test/resources/dataset-bags/additional-license-by-text/manifest-md5.txt similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-text/manifest-md5.txt rename to lib/src/test/resources/dataset-bags/additional-license-by-text/manifest-md5.txt diff --git a/src/test/resources/dataset-bags/additional-license-by-text/metadata/dataset.xml b/lib/src/test/resources/dataset-bags/additional-license-by-text/metadata/dataset.xml similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-text/metadata/dataset.xml rename to lib/src/test/resources/dataset-bags/additional-license-by-text/metadata/dataset.xml diff --git a/src/test/resources/dataset-bags/additional-license-by-text/metadata/files.xml b/lib/src/test/resources/dataset-bags/additional-license-by-text/metadata/files.xml similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-text/metadata/files.xml rename to lib/src/test/resources/dataset-bags/additional-license-by-text/metadata/files.xml diff --git a/src/test/resources/dataset-bags/additional-license-by-text/tagmanifest-md5.txt b/lib/src/test/resources/dataset-bags/additional-license-by-text/tagmanifest-md5.txt similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-text/tagmanifest-md5.txt rename to lib/src/test/resources/dataset-bags/additional-license-by-text/tagmanifest-md5.txt diff --git a/src/test/resources/dataset-bags/additional-license-by-url/bag-info.txt b/lib/src/test/resources/dataset-bags/additional-license-by-url/bag-info.txt similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-url/bag-info.txt rename to lib/src/test/resources/dataset-bags/additional-license-by-url/bag-info.txt diff --git a/src/test/resources/dataset-bags/additional-license-by-url/bagit.txt b/lib/src/test/resources/dataset-bags/additional-license-by-url/bagit.txt similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-url/bagit.txt rename to lib/src/test/resources/dataset-bags/additional-license-by-url/bagit.txt diff --git a/src/test/resources/dataset-bags/additional-license-by-url/data/path/to/file.txt b/lib/src/test/resources/dataset-bags/additional-license-by-url/data/path/to/file.txt similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-url/data/path/to/file.txt rename to lib/src/test/resources/dataset-bags/additional-license-by-url/data/path/to/file.txt diff --git a/src/test/resources/dataset-bags/additional-license-by-url/data/quicksort.hs b/lib/src/test/resources/dataset-bags/additional-license-by-url/data/quicksort.hs similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-url/data/quicksort.hs rename to lib/src/test/resources/dataset-bags/additional-license-by-url/data/quicksort.hs diff --git a/src/test/resources/dataset-bags/additional-license-by-url/manifest-md5.txt b/lib/src/test/resources/dataset-bags/additional-license-by-url/manifest-md5.txt similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-url/manifest-md5.txt rename to lib/src/test/resources/dataset-bags/additional-license-by-url/manifest-md5.txt diff --git a/src/test/resources/dataset-bags/additional-license-by-url/metadata/dataset.xml b/lib/src/test/resources/dataset-bags/additional-license-by-url/metadata/dataset.xml similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-url/metadata/dataset.xml rename to lib/src/test/resources/dataset-bags/additional-license-by-url/metadata/dataset.xml diff --git a/src/test/resources/dataset-bags/additional-license-by-url/metadata/files.xml b/lib/src/test/resources/dataset-bags/additional-license-by-url/metadata/files.xml similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-url/metadata/files.xml rename to lib/src/test/resources/dataset-bags/additional-license-by-url/metadata/files.xml diff --git a/src/test/resources/dataset-bags/additional-license-by-url/tagmanifest-md5.txt b/lib/src/test/resources/dataset-bags/additional-license-by-url/tagmanifest-md5.txt similarity index 100% rename from src/test/resources/dataset-bags/additional-license-by-url/tagmanifest-md5.txt rename to lib/src/test/resources/dataset-bags/additional-license-by-url/tagmanifest-md5.txt diff --git a/src/test/resources/dataset-bags/bag-with-secret-file/bag-info.txt b/lib/src/test/resources/dataset-bags/bag-with-secret-file/bag-info.txt similarity index 100% rename from src/test/resources/dataset-bags/bag-with-secret-file/bag-info.txt rename to lib/src/test/resources/dataset-bags/bag-with-secret-file/bag-info.txt diff --git a/src/test/resources/dataset-bags/bag-with-secret-file/bagit.txt b/lib/src/test/resources/dataset-bags/bag-with-secret-file/bagit.txt similarity index 100% rename from src/test/resources/dataset-bags/bag-with-secret-file/bagit.txt rename to lib/src/test/resources/dataset-bags/bag-with-secret-file/bagit.txt diff --git a/src/test/resources/dataset-bags/bag-with-secret-file/data/path/to/file.txt b/lib/src/test/resources/dataset-bags/bag-with-secret-file/data/path/to/file.txt similarity index 100% rename from src/test/resources/dataset-bags/bag-with-secret-file/data/path/to/file.txt rename to lib/src/test/resources/dataset-bags/bag-with-secret-file/data/path/to/file.txt diff --git a/src/test/resources/dataset-bags/bag-with-secret-file/data/quicksort.hs b/lib/src/test/resources/dataset-bags/bag-with-secret-file/data/quicksort.hs similarity index 100% rename from src/test/resources/dataset-bags/bag-with-secret-file/data/quicksort.hs rename to lib/src/test/resources/dataset-bags/bag-with-secret-file/data/quicksort.hs diff --git a/src/test/resources/dataset-bags/bag-with-secret-file/manifest-md5.txt b/lib/src/test/resources/dataset-bags/bag-with-secret-file/manifest-md5.txt similarity index 100% rename from src/test/resources/dataset-bags/bag-with-secret-file/manifest-md5.txt rename to lib/src/test/resources/dataset-bags/bag-with-secret-file/manifest-md5.txt diff --git a/src/test/resources/dataset-bags/bag-with-secret-file/metadata/dataset.xml b/lib/src/test/resources/dataset-bags/bag-with-secret-file/metadata/dataset.xml similarity index 100% rename from src/test/resources/dataset-bags/bag-with-secret-file/metadata/dataset.xml rename to lib/src/test/resources/dataset-bags/bag-with-secret-file/metadata/dataset.xml diff --git a/src/test/resources/dataset-bags/bag-with-secret-file/metadata/files.xml b/lib/src/test/resources/dataset-bags/bag-with-secret-file/metadata/files.xml similarity index 100% rename from src/test/resources/dataset-bags/bag-with-secret-file/metadata/files.xml rename to lib/src/test/resources/dataset-bags/bag-with-secret-file/metadata/files.xml diff --git a/src/test/resources/dataset-bags/bag-with-secret-file/tagmanifest-md5.txt b/lib/src/test/resources/dataset-bags/bag-with-secret-file/tagmanifest-md5.txt similarity index 100% rename from src/test/resources/dataset-bags/bag-with-secret-file/tagmanifest-md5.txt rename to lib/src/test/resources/dataset-bags/bag-with-secret-file/tagmanifest-md5.txt diff --git a/src/test/resources/dataset-bags/medium/bag-info.txt b/lib/src/test/resources/dataset-bags/medium/bag-info.txt similarity index 100% rename from src/test/resources/dataset-bags/medium/bag-info.txt rename to lib/src/test/resources/dataset-bags/medium/bag-info.txt diff --git a/src/test/resources/dataset-bags/medium/bagit.txt b/lib/src/test/resources/dataset-bags/medium/bagit.txt similarity index 100% rename from src/test/resources/dataset-bags/medium/bagit.txt rename to lib/src/test/resources/dataset-bags/medium/bagit.txt diff --git a/src/test/resources/dataset-bags/medium/data/README.md b/lib/src/test/resources/dataset-bags/medium/data/README.md similarity index 100% rename from src/test/resources/dataset-bags/medium/data/README.md rename to lib/src/test/resources/dataset-bags/medium/data/README.md diff --git a/src/test/resources/dataset-bags/medium/data/a/deeper/path/With some file.txt b/lib/src/test/resources/dataset-bags/medium/data/a/deeper/path/With some file.txt similarity index 100% rename from src/test/resources/dataset-bags/medium/data/a/deeper/path/With some file.txt rename to lib/src/test/resources/dataset-bags/medium/data/a/deeper/path/With some file.txt diff --git a/src/test/resources/dataset-bags/medium/data/random images/image01.png b/lib/src/test/resources/dataset-bags/medium/data/random images/image01.png similarity index 100% rename from src/test/resources/dataset-bags/medium/data/random images/image01.png rename to lib/src/test/resources/dataset-bags/medium/data/random images/image01.png diff --git a/src/test/resources/dataset-bags/medium/data/random images/image02.jpeg b/lib/src/test/resources/dataset-bags/medium/data/random images/image02.jpeg similarity index 100% rename from src/test/resources/dataset-bags/medium/data/random images/image02.jpeg rename to lib/src/test/resources/dataset-bags/medium/data/random images/image02.jpeg diff --git a/src/test/resources/dataset-bags/medium/data/random images/image03.jpeg b/lib/src/test/resources/dataset-bags/medium/data/random images/image03.jpeg similarity index 100% rename from src/test/resources/dataset-bags/medium/data/random images/image03.jpeg rename to lib/src/test/resources/dataset-bags/medium/data/random images/image03.jpeg diff --git a/src/test/resources/dataset-bags/medium/manifest-md5.txt b/lib/src/test/resources/dataset-bags/medium/manifest-md5.txt similarity index 100% rename from src/test/resources/dataset-bags/medium/manifest-md5.txt rename to lib/src/test/resources/dataset-bags/medium/manifest-md5.txt diff --git a/src/test/resources/dataset-bags/medium/manifest-sha1.txt b/lib/src/test/resources/dataset-bags/medium/manifest-sha1.txt similarity index 100% rename from src/test/resources/dataset-bags/medium/manifest-sha1.txt rename to lib/src/test/resources/dataset-bags/medium/manifest-sha1.txt diff --git a/src/test/resources/dataset-bags/medium/metadata/dataset.xml b/lib/src/test/resources/dataset-bags/medium/metadata/dataset.xml similarity index 100% rename from src/test/resources/dataset-bags/medium/metadata/dataset.xml rename to lib/src/test/resources/dataset-bags/medium/metadata/dataset.xml diff --git a/src/test/resources/dataset-bags/medium/metadata/depositor-info/agreements.xml b/lib/src/test/resources/dataset-bags/medium/metadata/depositor-info/agreements.xml similarity index 100% rename from src/test/resources/dataset-bags/medium/metadata/depositor-info/agreements.xml rename to lib/src/test/resources/dataset-bags/medium/metadata/depositor-info/agreements.xml diff --git a/src/test/resources/dataset-bags/medium/metadata/depositor-info/message-from-depositor.txt b/lib/src/test/resources/dataset-bags/medium/metadata/depositor-info/message-from-depositor.txt similarity index 100% rename from src/test/resources/dataset-bags/medium/metadata/depositor-info/message-from-depositor.txt rename to lib/src/test/resources/dataset-bags/medium/metadata/depositor-info/message-from-depositor.txt diff --git a/src/test/resources/dataset-bags/medium/metadata/files.xml b/lib/src/test/resources/dataset-bags/medium/metadata/files.xml similarity index 100% rename from src/test/resources/dataset-bags/medium/metadata/files.xml rename to lib/src/test/resources/dataset-bags/medium/metadata/files.xml diff --git a/src/test/resources/dataset-bags/medium/tagmanifest-md5.txt b/lib/src/test/resources/dataset-bags/medium/tagmanifest-md5.txt similarity index 100% rename from src/test/resources/dataset-bags/medium/tagmanifest-md5.txt rename to lib/src/test/resources/dataset-bags/medium/tagmanifest-md5.txt diff --git a/src/test/resources/dataset-bags/minimal/bag-info.txt b/lib/src/test/resources/dataset-bags/minimal/bag-info.txt similarity index 100% rename from src/test/resources/dataset-bags/minimal/bag-info.txt rename to lib/src/test/resources/dataset-bags/minimal/bag-info.txt diff --git a/src/test/resources/dataset-bags/minimal/bagit.txt b/lib/src/test/resources/dataset-bags/minimal/bagit.txt similarity index 100% rename from src/test/resources/dataset-bags/minimal/bagit.txt rename to lib/src/test/resources/dataset-bags/minimal/bagit.txt diff --git a/src/test/resources/dataset-bags/minimal/manifest-md5.txt b/lib/src/test/resources/dataset-bags/minimal/manifest-md5.txt similarity index 100% rename from src/test/resources/dataset-bags/minimal/manifest-md5.txt rename to lib/src/test/resources/dataset-bags/minimal/manifest-md5.txt diff --git a/src/test/resources/dataset-bags/minimal/metadata/dataset.xml b/lib/src/test/resources/dataset-bags/minimal/metadata/dataset.xml similarity index 100% rename from src/test/resources/dataset-bags/minimal/metadata/dataset.xml rename to lib/src/test/resources/dataset-bags/minimal/metadata/dataset.xml diff --git a/src/test/resources/dataset-bags/minimal/tagmanifest-md5.txt b/lib/src/test/resources/dataset-bags/minimal/tagmanifest-md5.txt similarity index 100% rename from src/test/resources/dataset-bags/minimal/tagmanifest-md5.txt rename to lib/src/test/resources/dataset-bags/minimal/tagmanifest-md5.txt diff --git a/src/test/resources/dataset-bags/no-additional-license/bag-info.txt b/lib/src/test/resources/dataset-bags/no-additional-license/bag-info.txt similarity index 100% rename from src/test/resources/dataset-bags/no-additional-license/bag-info.txt rename to lib/src/test/resources/dataset-bags/no-additional-license/bag-info.txt diff --git a/src/test/resources/dataset-bags/no-additional-license/bagit.txt b/lib/src/test/resources/dataset-bags/no-additional-license/bagit.txt similarity index 100% rename from src/test/resources/dataset-bags/no-additional-license/bagit.txt rename to lib/src/test/resources/dataset-bags/no-additional-license/bagit.txt diff --git a/src/test/resources/dataset-bags/no-additional-license/data/path/to/file.txt b/lib/src/test/resources/dataset-bags/no-additional-license/data/path/to/file.txt similarity index 100% rename from src/test/resources/dataset-bags/no-additional-license/data/path/to/file.txt rename to lib/src/test/resources/dataset-bags/no-additional-license/data/path/to/file.txt diff --git a/src/test/resources/dataset-bags/no-additional-license/data/quicksort.hs b/lib/src/test/resources/dataset-bags/no-additional-license/data/quicksort.hs similarity index 100% rename from src/test/resources/dataset-bags/no-additional-license/data/quicksort.hs rename to lib/src/test/resources/dataset-bags/no-additional-license/data/quicksort.hs diff --git a/src/test/resources/dataset-bags/no-additional-license/manifest-md5.txt b/lib/src/test/resources/dataset-bags/no-additional-license/manifest-md5.txt similarity index 100% rename from src/test/resources/dataset-bags/no-additional-license/manifest-md5.txt rename to lib/src/test/resources/dataset-bags/no-additional-license/manifest-md5.txt diff --git a/src/test/resources/dataset-bags/no-additional-license/metadata/dataset.xml b/lib/src/test/resources/dataset-bags/no-additional-license/metadata/dataset.xml similarity index 100% rename from src/test/resources/dataset-bags/no-additional-license/metadata/dataset.xml rename to lib/src/test/resources/dataset-bags/no-additional-license/metadata/dataset.xml diff --git a/src/test/resources/dataset-bags/no-additional-license/metadata/files.xml b/lib/src/test/resources/dataset-bags/no-additional-license/metadata/files.xml similarity index 100% rename from src/test/resources/dataset-bags/no-additional-license/metadata/files.xml rename to lib/src/test/resources/dataset-bags/no-additional-license/metadata/files.xml diff --git a/src/test/resources/dataset-bags/no-additional-license/tagmanifest-md5.txt b/lib/src/test/resources/dataset-bags/no-additional-license/tagmanifest-md5.txt similarity index 100% rename from src/test/resources/dataset-bags/no-additional-license/tagmanifest-md5.txt rename to lib/src/test/resources/dataset-bags/no-additional-license/tagmanifest-md5.txt diff --git a/src/test/resources/dataset-bags/one-invalid-sha1/bag-info.txt b/lib/src/test/resources/dataset-bags/one-invalid-sha1/bag-info.txt similarity index 100% rename from src/test/resources/dataset-bags/one-invalid-sha1/bag-info.txt rename to lib/src/test/resources/dataset-bags/one-invalid-sha1/bag-info.txt diff --git a/src/test/resources/dataset-bags/one-invalid-sha1/bagit.txt b/lib/src/test/resources/dataset-bags/one-invalid-sha1/bagit.txt similarity index 100% rename from src/test/resources/dataset-bags/one-invalid-sha1/bagit.txt rename to lib/src/test/resources/dataset-bags/one-invalid-sha1/bagit.txt diff --git a/src/test/resources/dataset-bags/one-invalid-sha1/data/reisverslag/deel01.txt b/lib/src/test/resources/dataset-bags/one-invalid-sha1/data/reisverslag/deel01.txt similarity index 100% rename from src/test/resources/dataset-bags/one-invalid-sha1/data/reisverslag/deel01.txt rename to lib/src/test/resources/dataset-bags/one-invalid-sha1/data/reisverslag/deel01.txt diff --git a/src/test/resources/dataset-bags/one-invalid-sha1/data/reisverslag/deel02.txt b/lib/src/test/resources/dataset-bags/one-invalid-sha1/data/reisverslag/deel02.txt similarity index 100% rename from src/test/resources/dataset-bags/one-invalid-sha1/data/reisverslag/deel02.txt rename to lib/src/test/resources/dataset-bags/one-invalid-sha1/data/reisverslag/deel02.txt diff --git a/src/test/resources/dataset-bags/one-invalid-sha1/data/reisverslag/deel03.txt b/lib/src/test/resources/dataset-bags/one-invalid-sha1/data/reisverslag/deel03.txt similarity index 100% rename from src/test/resources/dataset-bags/one-invalid-sha1/data/reisverslag/deel03.txt rename to lib/src/test/resources/dataset-bags/one-invalid-sha1/data/reisverslag/deel03.txt diff --git a/src/test/resources/dataset-bags/one-invalid-sha1/manifest-sha1.txt b/lib/src/test/resources/dataset-bags/one-invalid-sha1/manifest-sha1.txt similarity index 100% rename from src/test/resources/dataset-bags/one-invalid-sha1/manifest-sha1.txt rename to lib/src/test/resources/dataset-bags/one-invalid-sha1/manifest-sha1.txt diff --git a/src/test/resources/dataset-bags/one-invalid-sha1/metadata/dataset.xml b/lib/src/test/resources/dataset-bags/one-invalid-sha1/metadata/dataset.xml similarity index 100% rename from src/test/resources/dataset-bags/one-invalid-sha1/metadata/dataset.xml rename to lib/src/test/resources/dataset-bags/one-invalid-sha1/metadata/dataset.xml diff --git a/src/test/resources/dataset-bags/one-invalid-sha1/metadata/files.xml b/lib/src/test/resources/dataset-bags/one-invalid-sha1/metadata/files.xml similarity index 100% rename from src/test/resources/dataset-bags/one-invalid-sha1/metadata/files.xml rename to lib/src/test/resources/dataset-bags/one-invalid-sha1/metadata/files.xml diff --git a/src/test/resources/dataset-bags/one-invalid-sha1/tagmanifest-sha1.txt b/lib/src/test/resources/dataset-bags/one-invalid-sha1/tagmanifest-sha1.txt similarity index 100% rename from src/test/resources/dataset-bags/one-invalid-sha1/tagmanifest-sha1.txt rename to lib/src/test/resources/dataset-bags/one-invalid-sha1/tagmanifest-sha1.txt diff --git a/src/test/resources/external-files-for-medium-fail.txt b/lib/src/test/resources/external-files-for-medium-fail.txt similarity index 100% rename from src/test/resources/external-files-for-medium-fail.txt rename to lib/src/test/resources/external-files-for-medium-fail.txt diff --git a/src/test/resources/external-files-for-medium-ok.txt b/lib/src/test/resources/external-files-for-medium-ok.txt similarity index 100% rename from src/test/resources/external-files-for-medium-ok.txt rename to lib/src/test/resources/external-files-for-medium-ok.txt diff --git a/src/test/resources/file-test.pdf b/lib/src/test/resources/file-test.pdf similarity index 100% rename from src/test/resources/file-test.pdf rename to lib/src/test/resources/file-test.pdf diff --git a/lib/src/test/resources/logback.xml b/lib/src/test/resources/logback.xml new file mode 100644 index 0000000..0f28527 --- /dev/null +++ b/lib/src/test/resources/logback.xml @@ -0,0 +1,17 @@ + + + + + %-5level %msg%n + + + + + + + + + + + + diff --git a/src/test/scala/nl.knaw.dans.easy.stage/AdditionalLicenseSpec.scala b/lib/src/test/scala/nl.knaw.dans.easy.stage/AdditionalLicenseSpec.scala similarity index 100% rename from src/test/scala/nl.knaw.dans.easy.stage/AdditionalLicenseSpec.scala rename to lib/src/test/scala/nl.knaw.dans.easy.stage/AdditionalLicenseSpec.scala diff --git a/src/test/scala/nl.knaw.dans.easy.stage/CanConnectFixture.scala b/lib/src/test/scala/nl.knaw.dans.easy.stage/CanConnectFixture.scala similarity index 100% rename from src/test/scala/nl.knaw.dans.easy.stage/CanConnectFixture.scala rename to lib/src/test/scala/nl.knaw.dans.easy.stage/CanConnectFixture.scala diff --git a/src/test/scala/nl.knaw.dans.easy.stage/EasyStageDatasetSpec.scala b/lib/src/test/scala/nl.knaw.dans.easy.stage/EasyStageDatasetSpec.scala similarity index 100% rename from src/test/scala/nl.knaw.dans.easy.stage/EasyStageDatasetSpec.scala rename to lib/src/test/scala/nl.knaw.dans.easy.stage/EasyStageDatasetSpec.scala diff --git a/src/test/scala/nl.knaw.dans.easy.stage/RunSpec.scala b/lib/src/test/scala/nl.knaw.dans.easy.stage/RunSpec.scala similarity index 100% rename from src/test/scala/nl.knaw.dans.easy.stage/RunSpec.scala rename to lib/src/test/scala/nl.knaw.dans.easy.stage/RunSpec.scala diff --git a/src/test/scala/nl.knaw.dans.easy.stage/dataset/AmdSpec.scala b/lib/src/test/scala/nl.knaw.dans.easy.stage/dataset/AmdSpec.scala similarity index 100% rename from src/test/scala/nl.knaw.dans.easy.stage/dataset/AmdSpec.scala rename to lib/src/test/scala/nl.knaw.dans.easy.stage/dataset/AmdSpec.scala diff --git a/src/test/scala/nl.knaw.dans.easy.stage/dataset/DepositorInfoSpec.scala b/lib/src/test/scala/nl.knaw.dans.easy.stage/dataset/DepositorInfoSpec.scala similarity index 100% rename from src/test/scala/nl.knaw.dans.easy.stage/dataset/DepositorInfoSpec.scala rename to lib/src/test/scala/nl.knaw.dans.easy.stage/dataset/DepositorInfoSpec.scala diff --git a/src/test/scala/nl.knaw.dans.easy.stage/dataset/EmdSpec.scala b/lib/src/test/scala/nl.knaw.dans.easy.stage/dataset/EmdSpec.scala similarity index 100% rename from src/test/scala/nl.knaw.dans.easy.stage/dataset/EmdSpec.scala rename to lib/src/test/scala/nl.knaw.dans.easy.stage/dataset/EmdSpec.scala diff --git a/src/test/scala/nl.knaw.dans.easy.stage/dataset/MdFixture.scala b/lib/src/test/scala/nl.knaw.dans.easy.stage/dataset/MdFixture.scala similarity index 100% rename from src/test/scala/nl.knaw.dans.easy.stage/dataset/MdFixture.scala rename to lib/src/test/scala/nl.knaw.dans.easy.stage/dataset/MdFixture.scala diff --git a/lib/src/test/scala/nl.knaw.dans.easy.stage/fileitem/EasyStageFileItemSpec.scala b/lib/src/test/scala/nl.knaw.dans.easy.stage/fileitem/EasyStageFileItemSpec.scala new file mode 100644 index 0000000..edb4ade --- /dev/null +++ b/lib/src/test/scala/nl.knaw.dans.easy.stage/fileitem/EasyStageFileItemSpec.scala @@ -0,0 +1,166 @@ +/** + * Copyright (C) 2015 DANS - Data Archiving and Networked Services (info@dans.knaw.nl) + * + * Licensed 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 nl.knaw.dans.easy.stage.fileitem + +import java.io.File +import java.net.URL + +import nl.knaw.dans.easy.stage.ExistingAncestor +import nl.knaw.dans.easy.stage.lib.Util.loadXML +import nl.knaw.dans.easy.stage.lib.{ Fedora, FedoraRelationObject } +import org.scalatest._ + +import scala.collection.immutable.HashMap +import scala.util.{ Failure, Success, Try } + +class EasyStageFileItemSpec extends FlatSpec with Matchers with Inside with BeforeAndAfterEach { + + "run" should "report a missing size" in { + val result = EasyStageFileItem.run(new FileItemSettings( + sdoSetDir = Some(new File("target/testSDO")), + datastreamLocation = Some(new URL("http://x.nl/l/d")), + size = None, + datasetId = Some("easy-dataset:1"), + pathInDataset = Some(new File("original/newSub/file.mpeg")), + format = None, + subordinate = FedoraRelationObject("easy-dataset:1"), + easyFilesAndFolders = mockEasyFilesAndFolders(HashMap( + "easy-dataset:1 original/newSub/file.mpeg" -> Success("original", "easy-folder:1") + )), + fedora = mockFedora(HashMap( + "pid~easy-dataset:1" -> Seq("easy-dataset:1") + )), + accessibleTo = FileAccessRights.NONE, + visibleTo = FileAccessRights.ANONYMOUS + )) + + inside(result) { + case Failure(e: NoSuchElementException) => e should have message "None.get" + } + // the message is vague, a proper FileItemConf/EasyStageDataset + // should take care of something clearer for the end user + } + + it should "report a fedora error" in { + val result = EasyStageFileItem.run(new FileItemSettings( + sdoSetDir = Some(new File("target/testSDO")), + size = Some(1), + datasetId = Some("easy-dataset:1"), + pathInDataset = Some(new File("original/newSub/file.mpeg")), + format = Some("video/mpeg"), + subordinate = FedoraRelationObject("easy-dataset:1"), + easyFilesAndFolders = mockEasyFilesAndFolders(HashMap( + "easy-dataset:1 original/newSub/file.mpeg" -> Failure(new Exception("mocked error")) + )), + fedora = mockFedora(HashMap( + "pid~easy-dataset:1" -> Seq("easy-dataset:1") + )), + accessibleTo = FileAccessRights.NONE, + visibleTo = FileAccessRights.ANONYMOUS + )) + + inside(result) { + case Failure(e) => e should have message "mocked error" + } + } + + it should "report the dataset does not exist" in { + val result = EasyStageFileItem.run(new FileItemSettings( + sdoSetDir = Some(new File("target/testSDO")), + size = Some(1), + datasetId = Some("easy-dataset:1"), + pathInDataset = Some(new File("original/newSub/file.mpeg")), + format = Some("video/mpeg"), + subordinate = FedoraRelationObject("easy-dataset:1"), + easyFilesAndFolders = mockEasyFilesAndFolders(HashMap( + "easy-dataset:1 original/newSub/file.mpeg" -> Success("original", "easy-folder:1") + )), + fedora = mockFedora(HashMap( + "pid~easy-dataset:1" -> Seq() // TODO findObjects should return a Try + )), + accessibleTo = FileAccessRights.NONE, + visibleTo = FileAccessRights.ANONYMOUS + )) + + inside(result) { + case Failure(e) => e should have message "easy-dataset:1 does not exist in repository" + } + } + + "createFileSdo" should "use file name even if a title is provided" in { + val sdoSetDir = new File("target/testSdoSet") + val sdoDir = new File(sdoSetDir, "path_to_uuid-as-file-name") + sdoSetDir.mkdirs() + val s = FileItemSettings( + sdoSetDir = sdoSetDir, + file = Some(new File("path/to/uuid-as-file-name")), + datastreamLocation = None, + ownerId = "testOwner", + pathInDataset = new File("path/to/uuid-as-file-name"), + size = Some(1), + format = Some("text/plain"), + sha1 = None, + title = Some("A nice title"), + accessibleTo = FileAccessRights.NONE, + visibleTo = FileAccessRights.ANONYMOUS, + databaseUrl = "", + databaseUser = "", + databasePassword = "") + s.foreach(EasyStageFileItem.createFileSdo(sdoDir, FedoraRelationObject("ficticiousParentSdo"))(_)) + + val efmd = loadXML(new File(sdoDir, "EASY_FILE_METADATA")) + (efmd \ "name").text shouldBe "uuid-as-file-name" + (efmd \ "path").text shouldBe "path/to/uuid-as-file-name" + val foxml = loadXML(new File(sdoDir, "fo.xml")) + (foxml \ "datastream" \ "datastreamVersion" \ "xmlContent" \ "dc" \ "title").text shouldBe "A nice title" + } + + it should "use the filename if title is not provided" in { + val sdoSetDir = new File("target/testSdoSet") + val sdoDir = new File(sdoSetDir, "path_to_uuid-as-file-name") + sdoSetDir.mkdirs() + val s = FileItemSettings( + sdoSetDir = sdoSetDir, + file = Some(new File("path/to/uuid-as-file-name")), + datastreamLocation = None, + ownerId = "testOwner", + pathInDataset = new File("path/to/uuid-as-file-name"), + size = Some(1), + format = Some("text/plain"), + sha1 = None, + title = None, + accessibleTo = FileAccessRights.NONE, + visibleTo = FileAccessRights.ANONYMOUS, + databaseUrl = "", + databaseUser = "", + databasePassword = "") + s.foreach(EasyStageFileItem.createFileSdo(sdoDir, FedoraRelationObject("ficticiousParentSdo"))(_)) + + val efmd = loadXML(new File(sdoDir, "EASY_FILE_METADATA")) + (efmd \ "name").text shouldBe "uuid-as-file-name" + (efmd \ "path").text shouldBe "path/to/uuid-as-file-name" + val foxml = loadXML(new File(sdoDir, "fo.xml")) + (foxml \ "datastream" \ "datastreamVersion" \ "xmlContent" \ "dc" \ "title").text shouldBe "uuid-as-file-name" + } + + def mockEasyFilesAndFolders(expectations: Map[String, Try[ExistingAncestor]]): EasyFilesAndFolders = { + (file, datasetId) => expectations(s"$datasetId $file") + } + + def mockFedora(expectations: Map[String, Seq[String]]): Fedora = { + (query, _, _) => expectations(query) + } +} diff --git a/src/test/scala/nl.knaw.dans.easy.stage/fileitem/FileAccesRightsSpec.scala b/lib/src/test/scala/nl.knaw.dans.easy.stage/fileitem/FileAccesRightsSpec.scala similarity index 100% rename from src/test/scala/nl.knaw.dans.easy.stage/fileitem/FileAccesRightsSpec.scala rename to lib/src/test/scala/nl.knaw.dans.easy.stage/fileitem/FileAccesRightsSpec.scala diff --git a/pom.xml b/pom.xml index 7a75f7c..7de91a2 100644 --- a/pom.xml +++ b/pom.xml @@ -19,14 +19,8 @@ 4.0.0 - - nl.knaw.dans.shared - dans-scala-app-project - 5.1.0 - - nl.knaw.dans.easy - easy-stage-dataset + easy-stage-dataset-build 1.8.6-SNAPSHOT EASY Stage Dataset @@ -34,251 +28,36 @@ Stage a dataset in EASY-BagIt format for ingest into an EASY Fedora Commons 3.x Repository. 2015 - - nl.knaw.dans.easy.stage.Command - 3.9.1 - 1.0.5 - + pom - scm:git:https://github.com/DANS-KNAW/${project.artifactId} + scm:git:https://github.com/DANS-KNAW/easy-stage-dataset HEAD - - - commons-configuration - commons-configuration - - - org.apache.commons - commons-csv - - - org.rogach - scallop_2.12 - - - org.scala-lang.modules - scala-xml_2.12 - - - org.json4s - json4s-native_2.12 - - - commons-io - commons-io - - - ch.qos.logback - logback-classic - - - nl.knaw.dans.easy - ddm - ${easy.ddm.version} - - - - dom4j - dom4j - 1.6.1 - - - - xml-apis - xml-apis - - - - - com.yourmediashelf.fedora.client - fedora-client-core - - - nl.knaw.dans.easy - dans-fedora - 3.1.7 - test - - - com.yourmediashelf.fedora.client - fedora-client-messaging - - - - org.apache.geronimo.specs - geronimo-stax-api_1.0_spec - - - - - org.postgresql - postgresql - - - - org.joda - joda-convert - - - org.scalatest - scalatest_2.12 - - - nl.knaw.dans.lib - dans-scala-lib_2.12 - - - com.jsuereth - scala-arm_2.12 - - - gov.loc - bagit - - - - - - dans-releases - - true - - - false - - https://maven.dans.knaw.nl/releases/ - - - dans-snapshots - - false - - - true - - https://maven.dans.knaw.nl/snapshots/ - - - - maven-dependency-plugin - - - resources - generate-resources - - unpack - - - - - nl.knaw.dans.easy - easy-licenses - ${easy.licenses.version} - ${project.build.directory}/easy-licenses - - - - - + maven-deploy-plugin + 3.0.0-M1 + + true + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + v@{project.version} + true + - - - - stageDataset - - true - - - - - org.codehaus.mojo - exec-maven-plugin - - - - - - stageFileItem - - - stageFileItem - - - - - - org.codehaus.mojo - exec-maven-plugin - - nl.knaw.dans.easy.stage.fileitem.EasyStageFileItem - - - - - - - rpm - - false - - /usr/local/bin/rpm - - - - - - org.codehaus.mojo - rpm-maven-plugin - - Applications/Archiving - - - /opt/${dans-provider-name}/${project.artifactId}/bin - 755 - - - src/main/assembly/dist/bin/easy-stage-file-item - - - - - /etc/opt/${dans-provider-name}/${project.artifactId}/lic - ${rpm-replace-configuration} - - - target/easy-licenses/licenses - - - - - - - - - - + + + lib + command +