diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..176a458 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a5f2c3a --- /dev/null +++ b/pom.xml @@ -0,0 +1,104 @@ + + + + + 4.0.0 + + de.qucosa + qucosa-sword-filehandler + 1.0-SNAPSHOT + jar + Qucosa SWORD 1.3 Filehandler + + + UTF-8 + + + + + junit + junit + 4.11 + test + + + + org.mockito + mockito-core + 1.10.8 + test + + + + org.powermock + powermock-module-junit4 + 1.5.6 + test + + + + org.powermock + powermock-api-mockito + 1.5.6 + + + + sword + sword-fedora + 1.4.0 + classes + provided + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.2 + + 1.7 + 1.7 + + + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.17 + + + + integration-test + verify + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/purl/sword/server/fedora/fileHandlers/QucosaMETSFileHandler.java b/src/main/java/org/purl/sword/server/fedora/fileHandlers/QucosaMETSFileHandler.java new file mode 100644 index 0000000..cd106a1 --- /dev/null +++ b/src/main/java/org/purl/sword/server/fedora/fileHandlers/QucosaMETSFileHandler.java @@ -0,0 +1,34 @@ +/* + * Copyright 2014 Saxon State and University Library Dresden (SLUB) + * + * 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 org.purl.sword.server.fedora.fileHandlers; + +import org.purl.sword.base.SWORDEntry; +import org.purl.sword.base.SWORDException; +import org.purl.sword.base.ServiceDocument; +import org.purl.sword.server.fedora.baseExtensions.DepositCollection; + +public class QucosaMETSFileHandler extends DefaultFileHandler { + + public QucosaMETSFileHandler() { + super("application/vnd.qucosa.mets+xml", ""); + } + + @Override + public SWORDEntry ingestDeposit(DepositCollection depositCollection, ServiceDocument serviceDocument) throws SWORDException { + return null; + } +} diff --git a/src/test/java/org/purl/sword/server/fedora/fileHandlers/QucosaMETSFileHandlerTest.java b/src/test/java/org/purl/sword/server/fedora/fileHandlers/QucosaMETSFileHandlerTest.java new file mode 100644 index 0000000..b36b73c --- /dev/null +++ b/src/test/java/org/purl/sword/server/fedora/fileHandlers/QucosaMETSFileHandlerTest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2014 Saxon State and University Library Dresden (SLUB) + * + * 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 org.purl.sword.server.fedora.fileHandlers; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.purl.sword.server.fedora.utils.StartupListener; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; + +@RunWith(PowerMockRunner.class) +@PrepareForTest(StartupListener.class) +public class QucosaMETSFileHandlerTest { + + @BeforeClass + public static void setupStaticMock() { + PowerMockito.mockStatic(StartupListener.class); + when(StartupListener.getPropertiesLocation()).thenReturn( + System.class.getResource("/properties.xml").getFile()); + } + + @Test + public void handlesQucosaMETS() { + FileHandler fh = new QucosaMETSFileHandler(); + + assertTrue(fh.isHandled("application/vnd.qucosa.mets+xml", "")); + } + +} \ No newline at end of file diff --git a/src/test/resources/properties.xml b/src/test/resources/properties.xml new file mode 100644 index 0000000..b939ecc --- /dev/null +++ b/src/test/resources/properties.xml @@ -0,0 +1,60 @@ + + + + + + http://localhost:8080/fedora/get/##PID## + http://localhost:8080/fedora/get/##PID##/##DS## + http + localhost + 8080 + qucosa + + + http://localhost:8080/sword + /tmp + /sub_service_documents + /entries + + + + + + WEB-INF/mime-types.xml + + + 1 + true + true + + + http://localhost:8080/sword/##COLLECTION_PID## + + Open Collection + This is a collection of objects which can be freely deposited to. + This collection accepts any deposit from anyone + Preservation actions may occur on submitted deposits + + application/vnd.qucosa.mets+xml + + + http://www.loc.gov/METS/ + + + + +