Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
claussni committed Dec 6, 2014
0 parents commit 5a6aa5f
Show file tree
Hide file tree
Showing 6 changed files with 248 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
104 changes: 104 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->

<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>

<groupId>de.qucosa</groupId>
<artifactId>qucosa-sword-filehandler</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Qucosa SWORD 1.3 Filehandler</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.8</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.5.6</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.5.6</version>
</dependency>

<dependency>
<groupId>sword</groupId>
<artifactId>sword-fedora</artifactId>
<version>1.4.0</version>
<classifier>classes</classifier>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<!-- Project wide plugin setting -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<!-- Actual plugin invocations -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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", ""));
}

}
60 changes: 60 additions & 0 deletions src/test/resources/properties.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->

<properties>
<fedora>
<external_obj_url>http://localhost:8080/fedora/get/##PID##</external_obj_url>
<external_ds_url>http://localhost:8080/fedora/get/##PID##/##DS##</external_ds_url>
<protocol>http</protocol>
<host>localhost</host>
<port>8080</port>
<pid_namespace>qucosa</pid_namespace>
</fedora>
<general>
<repository_uri>http://localhost:8080/sword</repository_uri>
<temp_dir>/tmp</temp_dir>
<sub-service-documents>/sub_service_documents</sub-service-documents>
<entry-location>/entries</entry-location>
</general>
<file_handlers>
<handler class="org.purl.sword.server.fedora.fileHandlers.QucosaMETSFileHandler"/>
</file_handlers>
<files>
<mime-type>WEB-INF/mime-types.xml</mime-type>
</files>
<service_document>
<level>1</level>
<noOp>true</noOp>
<verbose>true</verbose>
<workspace title="Fedora SWORD Workspace">
<collection collection_pid="qucosa:open" mediation="true" mediationSet="true">
<deposit_url>http://localhost:8080/sword/##COLLECTION_PID##</deposit_url>
<users/>
<title>Open Collection</title>
<abstract>This is a collection of objects which can be freely deposited to.</abstract>
<policy>This collection accepts any deposit from anyone</policy>
<treatment>Preservation actions may occur on submitted deposits</treatment>
<accepts>
<accept>application/vnd.qucosa.mets+xml</accept>
</accepts>
<packaging>
<package>http://www.loc.gov/METS/</package>
</packaging>
</collection>
</workspace>
</service_document>
</properties>

0 comments on commit 5a6aa5f

Please sign in to comment.