Skip to content
Browse files

moved forms server side project into workbench build

the form feature is more tightly integrated into workbench than CDR
the form model project and it's antecedents span workbench and forms server
removed CDR project dependencies from forms service
abstracted authorization handling to an injected API
  • Loading branch information...
1 parent 05196ee commit 85a8fe08f2f7d4f90fe7c664d879bb266e2f47c3 @gregjan gregjan committed Sep 18, 2012
Showing with 1,877 additions and 7 deletions.
  1. +12 −0 forms/.classpath
  2. +7 −0 forms/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch
  3. +47 −0 forms/.project
  4. +12 −0 forms/.settings/.jsdtscope
  5. +5 −0 forms/.settings/org.eclipse.core.resources.prefs
  6. +9 −0 forms/.settings/org.eclipse.jdt.core.prefs
  7. +3 −0 forms/.settings/org.eclipse.jst.jsp.core.prefs
  8. +5 −0 forms/.settings/org.eclipse.m2e.core.prefs
  9. +23 −0 forms/.settings/org.eclipse.wst.common.component
  10. +7 −0 forms/.settings/org.eclipse.wst.common.project.facet.core.xml
  11. +3 −0 forms/.settings/org.eclipse.wst.html.core.prefs
  12. +40 −0 forms/.settings/org.eclipse.wst.jsdt.core.prefs
  13. +1 −0 forms/.settings/org.eclipse.wst.jsdt.ui.superType.container
  14. +1 −0 forms/.settings/org.eclipse.wst.jsdt.ui.superType.name
  15. +3 −0 forms/.settings/org.maven.ide.eclipse.wtp.prefs
  16. +146 −0 forms/pom.xml
  17. +28 −0 forms/src/main/java/cdr/forms/AbstractFormFactory.java
  18. +16 −0 forms/src/main/java/cdr/forms/AuthorizationHandler.java
  19. +107 −0 forms/src/main/java/cdr/forms/CachedXMIFormFactory.java
  20. +44 −0 forms/src/main/java/cdr/forms/DateEditor.java
  21. +22 −0 forms/src/main/java/cdr/forms/DepositHandler.java
  22. +34 −0 forms/src/main/java/cdr/forms/DepositResult.java
  23. +299 −0 forms/src/main/java/cdr/forms/FormController.java
  24. +22 −0 forms/src/main/java/cdr/forms/FormFactory.java
  25. +57 −0 forms/src/main/java/cdr/forms/FormValidator.java
  26. +53 −0 forms/src/main/java/cdr/forms/PermissionDeniedException.java
  27. +51 −0 forms/src/main/java/cdr/forms/ShibbolethAuthorizationHandler.java
  28. +226 −0 forms/src/main/java/cdr/forms/SwordDepositHandler.java
  29. +38 −0 forms/src/main/resources/log4j.properties
  30. +3 −0 forms/src/main/webapp/META-INF/MANIFEST.MF
  31. +60 −0 forms/src/main/webapp/WEB-INF/forms-servlet.xml
  32. +87 −0 forms/src/main/webapp/WEB-INF/jsp/403.jsp
  33. +139 −0 forms/src/main/webapp/WEB-INF/jsp/form.jsp
  34. +86 −0 forms/src/main/webapp/WEB-INF/jsp/success.jsp
  35. +95 −0 forms/src/main/webapp/WEB-INF/service-context.xml
  36. +61 −0 forms/src/main/webapp/WEB-INF/web.xml
  37. +22 −0 forms/src/main/webapp/index.jsp
  38. +0 −6 mods.model/.project
  39. +0 −1 mods.model/pom.xml
  40. +3 −0 pom.xml
View
12 forms/.classpath
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
View
7 forms/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.eclipse.wst.jsdt.core.javascriptValidator"/>
+<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+</launchConfiguration>
View
47 forms/.project
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>wb forms</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
+ <triggers>full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>LaunchConfigHandle</key>
+ <value>&lt;project&gt;/.externalToolBuilders/org.eclipse.wst.jsdt.core.javascriptValidator.launch</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.wst.validation.validationbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+ <nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ </natures>
+</projectDescription>
View
12 forms/.settings/.jsdtscope
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/webapp"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+ <attributes>
+ <attribute name="hide" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
View
5 forms/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,5 @@
+#Fri May 25 15:20:31 EDT 2012
+eclipse.preferences.version=1
+encoding//src/main/java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding/<project>=UTF-8
View
9 forms/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,9 @@
+#Fri May 25 13:37:52 EDT 2012
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
View
3 forms/.settings/org.eclipse.jst.jsp.core.prefs
@@ -0,0 +1,3 @@
+#Thu May 31 13:40:21 EDT 2012
+eclipse.preferences.version=1
+jsp-language/<project>=java
View
5 forms/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,5 @@
+#Thu Jul 12 14:10:43 EDT 2012
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
View
23 forms/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+ <wb-module deploy-name="forms">
+ <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
+ <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
+ <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
+ <dependent-module archiveName="crosswalk-gmf-4.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/crosswalk-gmf/crosswalk-gmf">
+ <dependency-type>uses</dependency-type>
+ </dependent-module>
+ <dependent-module archiveName="mods.model-4.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/mods.model/mods.model">
+ <dependency-type>uses</dependency-type>
+ </dependent-module>
+ <dependent-module archiveName="xlink.model-4.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/xlink.model/xlink.model">
+ <dependency-type>uses</dependency-type>
+ </dependent-module>
+ <dependent-module archiveName="clamavj-0.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/clamavj/clamavj">
+ <dependency-type>uses</dependency-type>
+ </dependent-module>
+ <property name="context-root" value="forms"/>
+ <property name="java-output-path" value="/forms/target/classes"/>
+ </wb-module>
+</project-modules>
View
7 forms/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <fixed facet="wst.jsdt.web"/>
+ <installed facet="java" version="1.6"/>
+ <installed facet="wst.jsdt.web" version="1.0"/>
+ <installed facet="jst.web" version="2.5"/>
+</faceted-project>
View
3 forms/.settings/org.eclipse.wst.html.core.prefs
@@ -0,0 +1,3 @@
+#Thu May 31 13:39:41 EDT 2012
+document-type/<project>=-//W3C//DTD XHTML 1.0 Transitional//EN
+eclipse.preferences.version=1
View
40 forms/.settings/org.eclipse.wst.jsdt.core.prefs
@@ -0,0 +1,40 @@
+#Tue Sep 18 10:05:35 EDT 2012
+eclipse.preferences.version=1
+org.eclipse.wst.jsdt.core.compiler.problem.deprecation=warning
+org.eclipse.wst.jsdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.wst.jsdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.wst.jsdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.wst.jsdt.core.compiler.problem.duplicateLocalVariables=warning
+org.eclipse.wst.jsdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.wst.jsdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.wst.jsdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.wst.jsdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.looseVarDecleration=warning
+org.eclipse.wst.jsdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.wst.jsdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.nullReference=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.optionalSemicolon=warning
+org.eclipse.wst.jsdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.undefinedField=warning
+org.eclipse.wst.jsdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.uninitializedGlobalVariable=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.uninitializedLocalVariable=warning
+org.eclipse.wst.jsdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.unresolvedFieldReference=error
+org.eclipse.wst.jsdt.core.compiler.problem.unresolvedMethodReference=error
+org.eclipse.wst.jsdt.core.compiler.problem.unresolvedTypeReference=error
+org.eclipse.wst.jsdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.wst.jsdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.wst.jsdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.wst.jsdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.wst.jsdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.wst.jsdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.wst.jsdt.core.compiler.problem.unusedPrivateMember=warning
+semanticValidation=disabled
View
1 forms/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
View
1 forms/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
+Window
View
3 forms/.settings/org.maven.ide.eclipse.wtp.prefs
@@ -0,0 +1,3 @@
+#Fri May 25 14:37:06 EDT 2012
+eclipse.preferences.version=1
+org.maven.ide.eclipse.wtp.enabledProjectSpecificPrefs=false
View
146 forms/pom.xml
@@ -0,0 +1,146 @@
+<?xml version="1.0"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>curators.workbench</groupId>
+ <artifactId>parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>forms</artifactId>
+ <packaging>war</packaging>
+ <name>Deposit Forms Webapp</name>
+ <url>http://maven.apache.org</url>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.emf</groupId>
+ <artifactId>ecore</artifactId>
+ <version>2.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.emf</groupId>
+ <artifactId>common</artifactId>
+ <version>2.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.emf</groupId>
+ <artifactId>ecore-xmi</artifactId>
+ <version>2.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${spring.version}</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.ws</groupId>
+ <artifactId>spring-ws-core</artifactId>
+ <version>${spring.ws.version}</version>
+ <type>jar</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-servlet-api</artifactId>
+ <version>7.0.21</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.6.4</version>
+ </dependency>
+ <dependency>
+ <groupId>curators.workbench</groupId>
+ <artifactId>crosswalk-gmf</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>curators.workbench</groupId>
+ <artifactId>mods.model</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>curators.workbench</groupId>
+ <artifactId>xlink.model</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.gmf</groupId>
+ <artifactId>runtime-notation</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4.5</version>
+ </dependency>
+ <dependency>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>4.3.0.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-parser</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>com.philvarner.clamavj</groupId>
+ <artifactId>clamavj</artifactId>
+ <version>0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <finalName>forms</finalName>
+ </build>
+</project>
View
28 forms/src/main/java/cdr/forms/AbstractFormFactory.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2008 The University of North Carolina at Chapel Hill
+ *
+ * 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 cdr.forms;
+
+import crosswalk.Form;
+
+public abstract class AbstractFormFactory {
+
+ /**
+ * Returns a new instance of the given form model.
+ * @param id the identifier of the form, usually file name
+ * @return the form ecore model
+ */
+ abstract public Form getForm(String id);
+}
View
16 forms/src/main/java/cdr/forms/AuthorizationHandler.java
@@ -0,0 +1,16 @@
+package cdr.forms;
+
+import javax.servlet.http.HttpServletRequest;
+
+import crosswalk.Form;
+
+public interface AuthorizationHandler {
+ /**
+ * Checks if the user has permission to submit this form.
+ * @param formId form id
+ * @param form form model
+ * @param session HTTP session
+ * @throws PermissionDeniedException if user does not have permission
+ */
+ public abstract void checkPermission(String formId, Form form, HttpServletRequest request) throws PermissionDeniedException;
+}
View
107 forms/src/main/java/cdr/forms/CachedXMIFormFactory.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright 2008 The University of North Carolina at Chapel Hill
+ *
+ * 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 cdr.forms;
+
+import gov.loc.mods.mods.MODSPackage;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import crosswalk.CrosswalkPackage;
+import crosswalk.Editable;
+import crosswalk.EditingContainer;
+import crosswalk.Form;
+
+public class CachedXMIFormFactory extends AbstractFormFactory {
+ private static final Logger LOG = LoggerFactory.getLogger(CachedXMIFormFactory.class);
+
+ ResourceSet rs = null;
+ Map<String, Form> cache = new HashMap<String, Form>();
+ String formPath = null;
+ CrosswalkPackage crosswalkPackage = null;
+ MODSPackage modsPackage = null;
+ NotationPackage notationPackage = null;
+
+ public CachedXMIFormFactory() {
+ rs = new ResourceSetImpl();
+ rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("form", new XMIResourceFactoryImpl());
+ rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new XMLResourceFactoryImpl());
+ crosswalkPackage = CrosswalkPackage.eINSTANCE;
+ modsPackage = MODSPackage.eINSTANCE;
+ notationPackage = NotationPackage.eINSTANCE;
+ }
+
+ public String getFormPath() {
+ return formPath;
+ }
+
+ public void setFormPath(String formPath) {
+ this.formPath = formPath;
+ }
+
+ @Override
+ public Form getForm(String id) {
+ if (true || !cache.containsKey(id)) {
+ loadForm(id);
+ }
+ Form template = cache.get(id);
+ EcoreUtil.Copier copier = new EcoreUtil.Copier(false, true);
+ EObject copy = copier.copy(template);
+ copier.copyReferences();
+ return (Form)copy;
+ }
+
+ private void loadForm(String id) {
+ File f = new File(getFormPath(), id + ".form");
+ if (f.exists()) {
+ URI formURI = URI.createFileURI(f.getPath());
+ Resource formResource = rs.getResource(formURI, true);
+ formResource.unload();
+ try {
+ formResource.load(Collections.EMPTY_MAP);
+ } catch (IOException e) {
+ LOG.error("Cannot load form: "+f.getPath(), e);
+ cache.remove(id);
+ return;
+ }
+ EObject con = formResource.getContents().get(0);
+ if (con instanceof EditingContainer) {
+ Editable model = ((EditingContainer) con).getModel();
+ if (model instanceof Form) {
+ cache.put(id, (Form) model);
+ }
+ }
+ } else {
+ LOG.error("Cannot load form: "+f.getPath());
+ }
+ }
+
+}
View
44 forms/src/main/java/cdr/forms/DateEditor.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2008 The University of North Carolina at Chapel Hill
+ *
+ * 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 cdr.forms;
+
+import java.beans.PropertyEditorSupport;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.util.Date;
+
+public class DateEditor extends PropertyEditorSupport {
+ private DateFormat format = null;
+
+ public DateEditor(DateFormat format) {
+ this.format = format;
+ }
+
+ public void setAsText(String text) throws IllegalArgumentException {
+ try {
+ setValue(format.parse(text));
+ }
+ catch (ParseException e) {
+ throw new IllegalArgumentException(
+ "Could not convert Date for " + text + ": " + e.getMessage());
+ }
+ }
+
+ public String getAsText() {
+ Date value = (Date) getValue();
+ return (value != null ? format.format(value) : "");
+ }
+}
View
22 forms/src/main/java/cdr/forms/DepositHandler.java
@@ -0,0 +1,22 @@
+/**
+ * Copyright 2008 The University of North Carolina at Chapel Hill
+ *
+ * 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 cdr.forms;
+
+import java.io.File;
+
+public interface DepositHandler {
+ DepositResult deposit(String containerPid, String modsXml, String title, File depositData);
+}
View
34 forms/src/main/java/cdr/forms/DepositResult.java
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2008 The University of North Carolina at Chapel Hill
+ *
+ * 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 cdr.forms;
+
+public class DepositResult {
+ public static enum Status {COMPLETE, PENDING, UNKNOWN, FAILED};
+ private String accessURL;
+ public String getAccessURL() {
+ return accessURL;
+ }
+ public void setAccessURL(String accessURL) {
+ this.accessURL = accessURL;
+ }
+ public Status getStatus() {
+ return status;
+ }
+ public void setStatus(Status status) {
+ this.status = status;
+ }
+ private Status status = Status.UNKNOWN;
+}
View
299 forms/src/main/java/cdr/forms/FormController.java
@@ -0,0 +1,299 @@
+/**
+ * Copyright 2008 The University of North Carolina at Chapel Hill
+ *
+ * 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 cdr.forms;
+
+import gov.loc.mods.mods.DocumentRoot;
+import gov.loc.mods.mods.MODSFactory;
+import gov.loc.mods.mods.MODSPackage;
+import gov.loc.mods.mods.ModsDefinition;
+import gov.loc.mods.mods.util.MODSResourceFactoryImpl;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.security.Principal;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.validation.Valid;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.propertyeditors.StringTrimmerEditor;
+import org.springframework.stereotype.Controller;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.FieldError;
+import org.springframework.web.bind.WebDataBinder;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.InitBinder;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.SessionAttributes;
+import org.springframework.web.bind.support.SessionStatus;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.servlet.ModelAndView;
+import org.w3._1999.xlink.XlinkPackage;
+
+import cdr.forms.DepositResult.Status;
+
+import com.philvarner.clamavj.ClamScan;
+import com.philvarner.clamavj.ScanResult;
+
+import crosswalk.Form;
+import crosswalk.FormElement;
+import crosswalk.MetadataBlock;
+import crosswalk.OutputElement;
+
+@Controller
+@RequestMapping(value = { "/*", "/**" })
+@SessionAttributes("form")
+public class FormController {
+ ResourceSet rs = null;
+
+
+ @Autowired
+ ClamScan clamScan = null;
+
+ public ClamScan getClamScan() {
+ return clamScan;
+ }
+
+ public void setClamScan(ClamScan clamScan) {
+ this.clamScan = clamScan;
+ }
+
+ public FormController() {
+ rs = new ResourceSetImpl();
+ rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("mods", new MODSResourceFactoryImpl());
+ rs.getPackageRegistry().put(MODSPackage.eNS_URI, MODSPackage.eINSTANCE);
+ rs.getPackageRegistry().put(XlinkPackage.eNS_URI, XlinkPackage.eINSTANCE);
+ LOG.debug("FormController created");
+ }
+
+ private static final Logger LOG = LoggerFactory.getLogger(FormController.class);
+
+ @Autowired
+ private DepositHandler depositHandler;
+
+ public DepositHandler getDepositHandler() {
+ return depositHandler;
+ }
+
+ public void setDepositHandler(DepositHandler depositHandler) {
+ this.depositHandler = depositHandler;
+ }
+
+ @Autowired
+ public String administratorEmail = null;
+
+ public String getAdministratorEmail() {
+ return administratorEmail;
+ }
+
+ public void setAdministratorEmail(String administratorEmail) {
+ this.administratorEmail = administratorEmail;
+ }
+
+ @Autowired
+ AbstractFormFactory factory = null;
+
+ public AbstractFormFactory getFactory() {
+ return factory;
+ }
+
+ public void setFactory(AbstractFormFactory factory) {
+ this.factory = factory;
+ }
+
+ @Autowired
+ private AuthorizationHandler authorizationHandler = null;
+
+ public AuthorizationHandler getAuthorizationHandler() {
+ return authorizationHandler;
+ }
+
+ public void setAuthorizationHandler(AuthorizationHandler authorizationHandler) {
+ this.authorizationHandler = authorizationHandler;
+ }
+
+ @InitBinder
+ protected void initBinder(WebDataBinder binder) {
+ binder.setValidator(new FormValidator());
+ binder.registerCustomEditor(java.util.Date.class, new DateEditor(new SimpleDateFormat("yy-MM-dd")));
+ //binder.setBindEmptyMultipartFiles(false);
+ binder.registerCustomEditor(java.lang.String.class, new StringTrimmerEditor(true));
+ }
+
+ @ModelAttribute("form")
+ protected Form getForm(@PathVariable String formId) {
+ return factory.getForm(formId);
+ }
+
+ @RequestMapping(value = "/{formId}.form", method = RequestMethod.GET)
+ public String showForm(@PathVariable String formId, @ModelAttribute("form") Form form, HttpServletRequest request) throws PermissionDeniedException {
+ LOG.debug("in GET for form " + formId);
+ this.getAuthorizationHandler().checkPermission(formId, form, request);
+ return "form";
+ }
+
+ @RequestMapping(value = "/{formId}.form", method = RequestMethod.POST)
+ public String processForm(@PathVariable String formId, @Valid @ModelAttribute("form") Form form, BindingResult errors,
+ Principal user, @RequestParam("file") MultipartFile mpfile, SessionStatus sessionStatus, HttpServletRequest request) throws PermissionDeniedException {
+ LOG.debug("in POST for form " + formId);
+ this.getAuthorizationHandler().checkPermission(formId, form, request);
+ if (user != null) form.setCurrentUser(user.getName());
+ String mods = makeMods(form);
+ LOG.debug(mods);
+ File depositFile = null;
+ if(mpfile.isEmpty()) {
+ errors.addError( new FieldError("form", "file", "You must select a file for upload."));
+ } else {
+ depositFile = handleUpload(mpfile);
+ String scanResult = virusScan(depositFile);
+ if(scanResult != null) {
+ errors.addError( new FieldError("form", "file", scanResult));
+ depositFile.delete();
+ depositFile = null;
+ }
+ }
+ if (errors.hasErrors()) {
+ LOG.debug(errors.getErrorCount() + " errors");
+ return "form";
+ }
+
+ // perform a deposit with the default handler.
+ DepositResult result = this.getDepositHandler().deposit(form.getDepositContainerId(), mods, mpfile.getOriginalFilename(), depositFile);
+
+ if(result.getStatus() == Status.FAILED) {
+ LOG.error("deposit failed");
+ errors.addError( new FieldError("form","file", "Deposit failed with response code: "+result.getStatus()));
+ return "form";
+ }
+
+ // TODO email notices
+
+ // delete files
+ if(depositFile != null) depositFile.delete();
+ // clear session
+ sessionStatus.setComplete();
+ return "success";
+ }
+
+ private synchronized String virusScan(File depositFile) {
+ try {
+ ScanResult result = this.getClamScan().scan(new FileInputStream(depositFile));
+ switch(result.getStatus()) {
+ case PASSED:
+ return null;
+ case FAILED:
+ return "A virus was detected in your file. Please scan your computer for viruses or report this issue to technical support.";
+ case ERROR:
+ throw new Error("There was a problem running the virus scan.", result.getException());
+ }
+ } catch (FileNotFoundException e) {
+ throw new Error("There was a problem finding the uploaded file: "+depositFile.getName(), e);
+ }
+ return null;
+ }
+
+ private File handleUpload(MultipartFile file) {
+ File result = null;
+ OutputStream out = null;
+ try {
+ result = File.createTempFile("form", ".data");
+ InputStream stream = file.getInputStream();
+ out = new BufferedOutputStream(new FileOutputStream(result));
+ for(int i = stream.read(); i >= 0; i = stream.read()) {
+ out.write(i);
+ }
+ out.flush();
+ } catch(IOException e) {
+ throw new Error(e);
+ } finally {
+ if(out != null) {
+ try {
+ out.close();
+ } catch(IOException ignored) {}
+ }
+ }
+ return result;
+ }
+
+ @ExceptionHandler(PermissionDeniedException.class)
+ public ModelAndView handleForbidden(PermissionDeniedException e) {
+ ModelAndView modelview = new ModelAndView("403");
+ modelview.addObject("formId", e.getFormId());
+ modelview.addObject("form", e.getForm());
+ modelview.addObject("message", e.getMessage()+"<br/><br/>Send email to "+this.getAdministratorEmail()+" to request access.");
+ return modelview;
+ }
+
+ private String makeMods(Form form) {
+ // run the mapping and get a MODS record. (report any errors)
+ ModsDefinition mods = MODSFactory.eINSTANCE.createModsDefinition();
+ DocumentRoot root = MODSFactory.eINSTANCE.createDocumentRoot();
+ root.setMods(mods);
+ for (FormElement fe : form.getElements()) {
+ if(MetadataBlock.class.isInstance(fe)) {
+ MetadataBlock mb = (MetadataBlock)fe;
+ for(OutputElement oe : mb.getElements()) {
+ oe.updateRecord(mods);
+ }
+ }
+ }
+ File tmp;
+ try {
+ tmp = File.createTempFile("tmp", ".mods");
+ } catch (IOException e1) {
+ throw new Error(e1);
+ }
+ URI uri = URI.createURI(tmp.toURI().toString());
+ XMLResource res = (XMLResource) rs.createResource(uri);
+ res.getContents().add(root);
+
+ StringWriter sw = new StringWriter();
+ Map<Object, Object> options = new HashMap<Object, Object>();
+ options.put(XMLResource.OPTION_ENCODING, "utf-8");
+
+ options.put(XMLResource.OPTION_DECLARE_XML, "");
+ options.put(XMLResource.OPTION_LINE_WIDTH, new Integer(80));
+ options.put(XMLResource.OPTION_ROOT_OBJECTS, Collections.singletonList(mods));
+ try {
+ res.save(sw, options);
+ } catch (IOException e) {
+ throw new Error("failed to serialize XML for model object", e);
+ }
+ return sw.toString();
+ }
+
+}
View
22 forms/src/main/java/cdr/forms/FormFactory.java
@@ -0,0 +1,22 @@
+/**
+ * Copyright 2008 The University of North Carolina at Chapel Hill
+ *
+ * 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 cdr.forms;
+
+import crosswalk.Form;
+
+public interface FormFactory {
+ public Form getForm(String id);
+}
View
57 forms/src/main/java/cdr/forms/FormValidator.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2008 The University of North Carolina at Chapel Hill
+ *
+ * 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 cdr.forms;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.validation.Errors;
+import org.springframework.validation.ValidationUtils;
+import org.springframework.validation.Validator;
+
+import crosswalk.Form;
+import crosswalk.FormElement;
+import crosswalk.InputField;
+import crosswalk.MetadataBlock;
+
+public class FormValidator implements Validator {
+ private static final Logger LOG = LoggerFactory.getLogger(FormValidator.class);
+
+ @Override
+ public boolean supports(Class clazz) {
+ return Form.class.isAssignableFrom(clazz);
+ }
+
+ @Override
+ public void validate(Object target, Errors errors) {
+ Form form = (Form)target;
+ for (FormElement el : form.getElements()) {
+ if (MetadataBlock.class.isInstance(el)) {
+ MetadataBlock mb = (MetadataBlock) el;
+ int mbIdx = form.getElements().indexOf(mb);
+ for (InputField in : mb.getPorts()) {
+ int inIdx = mb.getPorts().indexOf(in);
+ if(in.isRequired()) {
+ StringBuilder path = new StringBuilder().append("elements[").append(mbIdx)
+ .append("].ports[").append(inIdx).append("].enteredValue");
+ LOG.debug(in.getLabel()+ " | " + path+ " is a required field");
+ ValidationUtils.rejectIfEmptyOrWhitespace(errors, path.toString(), "field.required", "This field is required.");
+ }
+ }
+ }
+ }
+ }
+
+}
View
53 forms/src/main/java/cdr/forms/PermissionDeniedException.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2008 The University of North Carolina at Chapel Hill
+ *
+ * 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 cdr.forms;
+
+import crosswalk.Form;
+
+public class PermissionDeniedException extends RuntimeException {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2942249514946141228L;
+
+ //private UserSecurityProfile userSecurityProfile = null;
+ private Form form = null;
+ private String formId = null;
+
+ public Form getForm() {
+ return form;
+ }
+
+ public void setForm(Form form) {
+ this.form = form;
+ }
+
+ public String getFormId() {
+ return formId;
+ }
+
+ public void setFormId(String formId) {
+ this.formId = formId;
+ }
+
+ public PermissionDeniedException(String message, Form form, String formId) {
+ super(message);
+ //this.userSecurityProfile = userSecurityProfile;
+ this.form = form;
+ this.formId = formId;
+ }
+}
View
51 forms/src/main/java/cdr/forms/ShibbolethAuthorizationHandler.java
@@ -0,0 +1,51 @@
+package cdr.forms;
+
+import java.util.regex.Pattern;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import crosswalk.Form;
+
+public class ShibbolethAuthorizationHandler implements AuthorizationHandler {
+ private String splitCharacter = null;
+ private String groupsHeaderName = null;
+
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LoggerFactory.getLogger(ShibbolethAuthorizationHandler.class);
+
+ public String getSplitCharacter() {
+ return splitCharacter;
+ }
+
+ public void setSplitCharacter(String splitCharacter) {
+ this.splitCharacter = Pattern.quote(splitCharacter);
+ }
+
+ public String getGroupsHeaderName() {
+ return groupsHeaderName;
+ }
+
+ public void setGroupsHeaderName(String groupsHeaderName) {
+ this.groupsHeaderName = groupsHeaderName;
+ }
+
+ @Override
+ public void checkPermission(String formId, Form form, HttpServletRequest request) throws PermissionDeniedException {
+ if(form.getAuthorizedGroups().contains("public")) return;
+
+ // get header string
+ String groupsHeader = request.getHeader(getGroupsHeaderName());
+ if(groupsHeader == null) {
+ throw new PermissionDeniedException("You must first log in to use this deposit form.", form, formId);
+ } else {
+ for(String group : groupsHeader.split(getSplitCharacter())) {
+ if(form.getAuthorizedGroups().contains(group)) return;
+ }
+ throw new PermissionDeniedException("Your login is not authorized to use this form.", form, formId);
+ }
+ }
+
+}
View
226 forms/src/main/java/cdr/forms/SwordDepositHandler.java
@@ -0,0 +1,226 @@
+/**
+ * Copyright 2008 The University of North Carolina at Chapel Hill
+ *
+ * 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 cdr.forms;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Text.Type;
+import org.apache.abdera.parser.Parser;
+import org.apache.abdera.parser.stax.FOMExtensibleElement;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
+import org.apache.commons.httpclient.methods.multipart.FilePart;
+import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
+import org.apache.commons.httpclient.methods.multipart.Part;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.Namespace;
+import org.jdom.input.SAXBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import cdr.forms.DepositResult.Status;
+
+
+public class SwordDepositHandler implements DepositHandler {
+
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LoggerFactory.getLogger(SwordDepositHandler.class);
+
+ private String serviceUrl;
+ private String username;
+ private String password;
+
+ public String getServiceUrl() {
+ return serviceUrl;
+ }
+
+ public void setServiceUrl(String serviceUrl) {
+ this.serviceUrl = serviceUrl;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ private String defaultContainer = null;
+
+ public String getDefaultContainer() {
+ return defaultContainer;
+ }
+
+ /**
+ * Set the default deposit container. String should be appropriate
+ * @param defaultContainer
+ */
+ public void setDefaultContainer(String defaultContainer) {
+ this.defaultContainer = defaultContainer;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see cdr.forms.DepositHandler#deposit(java.lang.String, java.lang.String, java.io.InputStream)
+ */
+ @Override
+ public DepositResult deposit(String containerId, String modsXml, String title, File depositData) {
+ if(containerId == null) containerId = this.getDefaultContainer();
+ Abdera abdera = Abdera.getInstance();
+ Factory factory = abdera.getFactory();
+ Entry entry = factory.newEntry();
+ String pid = "uuid:" + UUID.randomUUID().toString();
+ entry.setId("urn:" + pid);
+ entry.setSummary("mods and binary deposit", Type.TEXT);
+ entry.setTitle(title);
+ entry.setUpdated(new Date(System.currentTimeMillis()));
+ Parser parser = abdera.getParser();
+ Document<FOMExtensibleElement> doc = parser.parse(new ByteArrayInputStream(modsXml.getBytes()));
+ entry.addExtension(doc.getRoot());
+
+ StringWriter swEntry = new StringWriter();
+ try {
+ entry.writeTo(swEntry);
+ } catch (IOException e2) {
+ throw new Error(e2);
+ }
+
+ FilePart payloadPart;
+ try {
+ payloadPart = new FilePart("payload", title, depositData);
+ } catch (FileNotFoundException e1) {
+ throw new Error(e1);
+ }
+ payloadPart.setContentType("binary/octet-stream");
+ payloadPart.setTransferEncoding("binary");
+
+ FilePart atomPart = new FilePart("atom", new ByteArrayPartSource("atom", swEntry.toString().getBytes()),
+ "application/atom+xml", "utf-8");
+
+ Part[] parts = { payloadPart, atomPart };
+
+ String depositPath = getServiceUrl() + "collection/" + containerId;
+ HttpClient client = new HttpClient();
+ UsernamePasswordCredentials creds = new UsernamePasswordCredentials(this.getUsername(), this.getPassword());
+ client.getState().setCredentials(getAuthenticationScope(depositPath), creds);
+ client.getParams().setAuthenticationPreemptive(true);
+ PostMethod post = new PostMethod(depositPath);
+ RequestEntity multipartEntity = new MultipartRequestEntity(parts, post.getParams());
+ String boundary = multipartEntity.getContentType();
+ boundary = boundary.substring(boundary.indexOf("boundary=") + 9);
+ Header header = new Header("Content-type", "multipart/related; type=application/atom+xml; boundary=" + boundary);
+ post.addRequestHeader(header);
+ post.setRequestEntity(multipartEntity);
+ int responseCode;
+
+ DepositResult result = new DepositResult();
+ // result.setObjectPid(pid);
+ try {
+ responseCode = client.executeMethod(post);
+ if (responseCode >= 300) {
+ LOG.error(String.valueOf(responseCode));
+ LOG.error(post.getResponseBodyAsString());
+ result.setStatus(Status.FAILED);
+ } else {
+ result.setStatus(Status.COMPLETE);
+ }
+ SAXBuilder sx = new SAXBuilder();
+ try {
+ org.jdom.Document d = sx.build(post.getResponseBodyAsStream());
+ Namespace atom = d.getRootElement().getNamespace();
+ List<Element> links = d.getRootElement().getChildren("link", atom);
+ for (Element el : links) {
+ if ("alternate".equals(el.getAttributeValue("rel"))) {
+ String accessURL = el.getAttributeValue("href");
+ result.setAccessURL(accessURL);
+ }
+ }
+ } catch (JDOMException e) {
+ LOG.error("There was a problem parsing the SWORD response.", e);
+ }
+ LOG.debug("response was: \n" + post.getResponseBodyAsString());
+ } catch (HttpException e) {
+ LOG.error("Exception during SWORD deposit", e);
+ throw new Error(e);
+ } catch (IOException e) {
+ LOG.error("Exception during SWORD deposit", e);
+ throw new Error(e);
+ }
+ return result;
+ }
+
+ /**
+ * Generates a limited authentication scope for the supplied URL, so that an HTTP client will not send username and
+ * passwords to other URLs.
+ *
+ * @param queryURL
+ * the URL for the query.
+ * @return an authentication scope tuned to the requested URL.
+ * @throws IllegalArgumentException
+ * if <code>queryURL</code> is not a well-formed URL.
+ */
+ public static AuthScope getAuthenticationScope(String queryURL) {
+ if (queryURL == null) {
+ throw new NullPointerException("Cannot derive authentication scope for null URL");
+ }
+ try {
+ URL url = new URL(queryURL);
+ // port defaults to 80 unless the scheme is https
+ // or the port is explicitly set in the URL.
+ int port = 80;
+ if (url.getPort() == -1) {
+ if ("https".equals(url.getProtocol())) {
+ port = 443;
+ }
+ } else {
+ port = url.getPort();
+ }
+ return new AuthScope(url.getHost(), port);
+ } catch (MalformedURLException mue) {
+ throw new IllegalArgumentException("supplied URL <" + queryURL + "> is ill-formed:" + mue.getMessage());
+ }
+ }
+}
View
38 forms/src/main/resources/log4j.properties
@@ -0,0 +1,38 @@
+#
+# Copyright 2008 The University of North Carolina at Chapel Hill
+#
+# 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.
+#
+
+# Root logger set to DEBUG, but SERVER.Threshold blocks below WARN
+log4j.rootLogger=WARN, SERVER, CDRSERVICES
+
+# The SERVER and CDRSERVICES appenders are inherited from the root logger
+log4j.logger.org.apache.commons.httpclient=ERROR
+log4j.logger.httpclient=ERROR
+log4j.logger.org.apache.activemq=WARN
+log4j.logger.org.irods=WARN
+
+# Server level log to standard output ("catalina.out").
+log4j.appender.SERVER=org.apache.log4j.ConsoleAppender
+log4j.appender.SERVER.Threshold=WARN
+log4j.appender.SERVER.layout=edu.unc.lib.dl.log.NoStackTracePatternLayout
+log4j.appender.SERVER.layout.ConversionPattern=%d %-5p [%t] %c - %m%n
+
+# Application Log File
+log4j.appender.CDRSERVICES.File=${catalina.base}/logs/forms.log
+log4j.appender.CDRSERVICES.layout.ConversionPattern=%d %-5p [%t] %c - %m%n
+log4j.appender.CDRSERVICES.layout=org.apache.log4j.PatternLayout
+log4j.appender.CDRSERVICES=org.apache.log4j.RollingFileAppender
+log4j.appender.CDRSERVICES.MaxFileSize=10240KB
+log4j.appender.CDRSERVICES.MaxBackupIndex=100
View
3 forms/src/main/webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
View
60 forms/src/main/webapp/WEB-INF/forms-servlet.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright 2008 The University of North Carolina at Chapel Hill 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. -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jms="http://www.springframework.org/schema/jms"
+ xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd
+ http://www.springframework.org/schema/mvc
+ http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
+
+ <bean name="propertiesURI" class="java.lang.System"
+ factory-method="getProperty">
+ <constructor-arg index="0" value="server.properties.uri" />
+ <!-- property name for properties URI location -->
+ <constructor-arg index="1" value="classpath:server.properties" />
+ <!-- default location for testing -->
+ </bean>
+ <bean id="serverProperties"
+ class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="locations">
+ <list>
+ <ref bean="propertiesURI" />
+ </list>
+ </property>
+ <property name="ignoreResourceNotFound" value="false" />
+ </bean>
+
+ <!-- Scans the classpath of this application for @Components to deploy as
+ beans -->
+ <context:component-scan base-package="cdr.forms" />
+ <!-- Configures the @Controller programming model -->
+ <mvc:annotation-driven />
+ <!-- Resolves view names to protected .jsp resources within the /WEB-INF/jsp
+ directory -->
+ <bean id="viewResolver"
+ class="org.springframework.web.servlet.view.InternalResourceViewResolver">
+ <property name="prefix" value="/WEB-INF/jsp/" />
+ <property name="suffix" value=".jsp" />
+ </bean>
+
+ <!-- Configure the multipart resolver -->
+ <bean id="multipartResolver"
+ class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
+ <!-- one of the properties available; the maximum file size in bytes -->
+ <property name="maxUploadSize" value="5000000" />
+ </bean>
+</beans>
View
87 forms/src/main/webapp/WEB-INF/jsp/403.jsp
@@ -0,0 +1,87 @@
+<%--
+
+ Copyright 2008 The University of North Carolina at Chapel Hill
+
+ 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.
+
+--%>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ page import="crosswalk.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" session="true"%>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="stylesheet" type="text/css" href="/static/css/reset.css" />
+<link rel="stylesheet" type="text/css" href="/static/css/cdrui_styles.css" />
+<!--[if IE 8]>
+ <link rel="stylesheet" type="text/css" href="/static/css/cdrui_styles_ie8.css" />
+<![endif]-->
+<meta name="description" content="Carolina Digital Repository Deposit Form" />
+<meta name="keywords" content="Carolina Digital Repository, deposit" />
+<meta name="robots" content="index, nofollow" />
+<link rel="shortcut icon" href="/static/images/favicon.ico" type="image/x-icon" />
+<title><c:out value="${form.title}"/></title>
+</head>
+<body>
+<div id="pagewrap">
+ <div id="pagewrap_inside">
+ <div class="darkest shadowbottom" id="header">
+ <div class="threecol dark shadowbottom">
+ <div class="contentarea">
+ <h1>Carolina Digital Repository</h1>
+ <a href="/" id="titlelink"><img src="/static/images/carolinadigitalrepository.png"></a>
+
+
+ </div>
+ </div>
+ <div class="fourcol darkest">
+ <div class="contentarea">
+ </div>
+ </div>
+ </div>
+ <div id="content">
+ <div class="contentarea">
+<h2><c:out value="${form.title}"/></h2>
+<p><c:out value="${form.description}"/></p>
+<% if(session != null && session.getAttribute("user") != null) { %>
+<h3>Not Authorized to Deposit</h3>
+<p><c:out value="${message}"/></p>
+<% } else { %>
+<h3>Log In is Required</h3>
+<p><c:out value="${message}"/></p>
+<p style="text-align: center"><a href="/Shibboleth.sso/Login?target=%2fforms%2f${formId}.form">Log In</a></p>
+<% } %>
+</div>
+</div>
+<div id="footer" class="darkest">
+ <div class="threecol dark">
+ <div class="contentarea">
+ <p>
+ <a href="/">Home</a>&nbsp;|&nbsp;
+ <a href="search?types=Collection">Browse Collections</a>&nbsp;|&nbsp;
+ <a href="external?page=about.about">About</a>&nbsp;|&nbsp;
+ <a href="external?page=contact&amp;refer=https%3a%2f%2fcdr.lib.unc.edu%2f">Contact Us</a>&nbsp;|&nbsp;
+ <a href="http://www.lib.unc.edu">Library Home</a>&nbsp;|&nbsp;
+ <a href="http://www.lib.unc.edu/aoffice/policies/privacy_policy.html">Privacy Policy</a>
+ </p>
+ </div>
+ </div>
+ <div class="fourcol darkest">
+ <div class="contentarea"><p class="left"><a href="http://www.unc.edu">UNC Home </a></p><a href="http://www.unc.edu"><img src="/static/images/uncwell.png" id="footer_uncwell"></a></div>
+ </div>
+</div>
+</div>
+</div>
+</body>
+</html>
View
139 forms/src/main/webapp/WEB-INF/jsp/form.jsp
@@ -0,0 +1,139 @@
+<%--
+
+ Copyright 2008 The University of North Carolina at Chapel Hill
+
+ 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.
+
+--%>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ page import="crosswalk.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" session="true"%>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="stylesheet" type="text/css" href="/static/css/reset.css" />
+<link rel="stylesheet" type="text/css" href="/static/css/cdrui_styles.css" />
+
+<link type="text/css" href="/cdradmin/css/jquery/ui/jquery-ui.css" rel="stylesheet" />
+
+<script type="text/javascript" src="/cdradmin/js/jquery/jquery.min.js"></script>
+<script type="text/javascript" src="/cdradmin/js/jquery/ui/jquery-ui.min.js"></script>
+
+<script type="text/javascript">
+ $(document).ready( function() {
+ $(".datepicker").datepicker({dateFormat : 'yy-mm-dd', changeYear : true, changeMonth : true, yearRange : '-300:+02' }).val($.datepicker.formatDate('yy-mm-dd', new Date()));
+ // $(".datepicker").datepicker('option', 'constrainInput', true);
+ // $(".datepicker").datepicker('option', 'maxDate', '+0m +0w');
+ });
+</script>
+
+<!--[if IE 8]>
+ <link rel="stylesheet" type="text/css" href="/static/css/cdrui_styles_ie8.css" />
+<![endif]-->
+<meta name="description" content="Carolina Digital Repository Deposit Form" />
+<meta name="keywords" content="Carolina Digital Repository, deposit" />
+<meta name="robots" content="index, nofollow" />
+<link rel="shortcut icon" href="/static/images/favicon.ico" type="image/x-icon" />
+<title><c:out value="${form.title}"/></title>
+</head>
+<body>
+<div id="pagewrap">
+ <div id="pagewrap_inside">
+ <div class="darkest shadowbottom" id="header">
+ <div class="threecol dark shadowbottom">
+ <div class="contentarea">
+ <h1>Carolina Digital Repository</h1>
+ <a href="/" id="titlelink"><img src="/static/images/carolinadigitalrepository.png"></a>
+
+
+ </div>
+ </div>
+ <div class="fourcol darkest">
+ <div class="contentarea">
+ </div>
+ </div>
+ </div>
+ <div id="content">
+ <div class="contentarea">
+<h2><c:out value="${form.title}"/></h2>
+<p><c:out value="${form.description}"/></p>
+<form:form modelAttribute="form" enctype="multipart/form-data">
+ <c:forEach items="${form.elements}" varStatus="elementRow">
+ <spring:bind path="form.elements[${elementRow.index}]" ignoreNestedPath="true">
+ <% if(Paragraph.class.isInstance(status.getValue())) {
+ Paragraph p = (Paragraph)status.getValue();
+ if(p.getHeading() != null) { %>
+ <br/><h3><%= p.getHeading() %></h3>
+ <% }
+ if(p.getText() != null) { %>
+ <p><%= ((Paragraph)status.getValue()).getText() %></p>
+ <% } %>
+ <% } else if(MetadataBlock.class.isInstance(status.getValue())) {
+ MetadataBlock mb = (MetadataBlock)status.getValue(); %>
+ <br/><h3 style="clear: both;"><%= ((MetadataBlock)status.getValue()).getName() %></h3>
+ <% if(mb.getDescription() != null) { %>
+ <p><%= ((MetadataBlock)status.getValue()).getDescription() %></p>
+ <% } %>
+ <div style="margin: 0em 2em;">
+ <p>
+ <c:forEach items="${form.elements[elementRow.index].ports}" var="port" varStatus="portRow">
+ <spring:bind path="form.elements[${elementRow.index}].ports[${portRow.index}]" ignoreNestedPath="true">
+ <div style="float: left; clear: both; width: 12em; height: 2em; text-align: right; vertical-align: baseline; margin-right: 1em;"><c:out value="${port.label}"/></div>
+ <% if(status.getValue() instanceof DateInputField) { %>
+ <form:input cssClass="datepicker" path="elements[${elementRow.index}].ports[${portRow.index}].enteredValue" title="${port.usage}" />
+ <% } else if(status.getValue() instanceof TextInputField) { %>
+ <form:input path="elements[${elementRow.index}].ports[${portRow.index}].enteredValue" title="${port.usage}" maxlength="${port.maxSize}" size="${port.preferredSize}" />
+ <% } else { %>
+ <form:input path="elements[${elementRow.index}].ports[${portRow.index}].enteredValue" title="${port.usage}" />
+ <% } %>
+ <c:if test="${port.required}"><span style="color:red">*</span></c:if>
+ <form:errors cssStyle="color:red;" path="elements[${elementRow.index}].ports[${portRow.index}].enteredValue" /><br />
+ </spring:bind>
+ </c:forEach>
+ </p>
+ </div>
+ <% } %>
+ </spring:bind>
+ </c:forEach>
+ <br/><h3>File for Deposit</h3>
+ <div style="margin: 0em 2em;">
+ <p><input name="file" type="file" /><spring:hasBindErrors name="form"><span style="color:red"><%= errors.getFieldError("file") == null ? "" : errors.getFieldError("file").getDefaultMessage() %></span></spring:hasBindErrors></p>
+ </div>
+ <div style="text-align: center; margin: 2em;">
+ <input type="submit" value="submit deposit" />
+ </div>
+</form:form>
+</div>
+</div>
+<div id="footer" class="darkest">
+ <div class="threecol dark">
+ <div class="contentarea">
+ <p>
+ <a href="/">Home</a>&nbsp;|&nbsp;
+ <a href="search?types=Collection">Browse Collections</a>&nbsp;|&nbsp;
+ <a href="external?page=about.about">About</a>&nbsp;|&nbsp;
+ <a href="external?page=contact&amp;refer=https%3a%2f%2fcdr.lib.unc.edu%2f">Contact Us</a>&nbsp;|&nbsp;
+ <a href="http://www.lib.unc.edu">Library Home</a>&nbsp;|&nbsp;
+ <a href="http://www.lib.unc.edu/aoffice/policies/privacy_policy.html">Privacy Policy</a>
+ </p>
+ </div>
+ </div>
+ <div class="fourcol darkest">
+ <div class="contentarea"><p class="left"><a href="http://www.unc.edu">UNC Home </a></p><a href="http://www.unc.edu"><img src="/static/images/uncwell.png" id="footer_uncwell"></a></div>
+ </div>
+</div>
+</div>
+</div>
+</body>
+</html>
View
86 forms/src/main/webapp/WEB-INF/jsp/success.jsp
@@ -0,0 +1,86 @@
+<%--
+
+ Copyright 2008 The University of North Carolina at Chapel Hill
+
+ 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.
+
+--%>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
+<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ page import="crosswalk.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" session="true"%>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="stylesheet" type="text/css" href="/static/css/reset.css" />
+<link rel="stylesheet" type="text/css" href="/static/css/cdrui_styles.css" />
+
+<link type="text/css" href="/cdradmin/css/jquery/ui/jquery-ui.css" rel="stylesheet" />
+
+<script type="text/javascript" src="/cdradmin/js/jquery/jquery.min.js"></script>
+<script type="text/javascript" src="/cdradmin/js/jquery/ui/jquery-ui.min.js"></script>
+
+<!--[if IE 8]>
+ <link rel="stylesheet" type="text/css" href="/static/css/cdrui_styles_ie8.css" />
+<![endif]-->
+<meta name="description" content="Carolina Digital Repository Deposit Form" />
+<meta name="keywords" content="Carolina Digital Repository, deposit" />
+<meta name="robots" content="index, nofollow" />
+<link rel="shortcut icon" href="/static/images/favicon.ico" type="image/x-icon" />
+<title><c:out value="${form.title}"/></title>
+</head>
+<body>
+<div id="pagewrap">
+ <div id="pagewrap_inside">
+ <div class="darkest shadowbottom" id="header">
+ <div class="threecol dark shadowbottom">
+ <div class="contentarea">
+ <h1>Carolina Digital Repository</h1>
+ <a href="/" id="titlelink"><img src="/static/images/carolinadigitalrepository.png"></a>
+
+
+ </div>
+ </div>
+ <div class="fourcol darkest">
+ <div class="contentarea">
+ </div>
+ </div>
+ </div>
+ <div id="content">
+ <div class="contentarea">
+<h2><c:out value="${form.title}"/></h2>
+<p><c:out value="${form.description}"/></p>
+<h3>Thank you for your deposit!</h3>
+</div>
+</div>
+<div id="footer" class="darkest">
+ <div class="threecol dark">
+ <div class="contentarea">
+ <p>
+ <a href="/">Home</a>&nbsp;|&nbsp;
+ <a href="search?types=Collection">Browse Collections</a>&nbsp;|&nbsp;
+ <a href="external?page=about.about">About</a>&nbsp;|&nbsp;
+ <a href="external?page=contact&amp;refer=https%3a%2f%2fcdr.lib.unc.edu%2f">Contact Us</a>&nbsp;|&nbsp;
+ <a href="http://www.lib.unc.edu">Library Home</a>&nbsp;|&nbsp;
+ <a href="http://www.lib.unc.edu/aoffice/policies/privacy_policy.html">Privacy Policy</a>
+ </p>
+ </div>
+ </div>
+ <div class="fourcol darkest">
+ <div class="contentarea"><p class="left"><a href="http://www.unc.edu">UNC Home </a></p><a href="http://www.unc.edu"><img src="/static/images/uncwell.png" id="footer_uncwell"></a></div>
+ </div>
+</div>
+</div>
+</div>
+</body>
+</html>
View
95 forms/src/main/webapp/WEB-INF/service-context.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright 2008 The University of North Carolina at Chapel Hill 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. -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jms="http://www.springframework.org/schema/jms"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+
+ <bean name="propertiesURI" class="java.lang.System"
+ factory-method="getProperty">
+ <constructor-arg index="0" value="server.properties.uri" />
+ <!-- property name for properties URI location -->
+ <constructor-arg index="1" value="classpath:server.properties" />
+ <!-- default location for testing -->
+ </bean>
+
+ <bean id="serverProperties"
+ class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
+ <property name="locations">
+ <list>
+ <ref bean="propertiesURI" />
+ </list>
+ </property>
+ <property name="ignoreResourceNotFound" value="false" />
+ </bean>
+
+ <!-- Note that ClamScan is not thread safe. -->
+ <bean id="clamScan" class="com.philvarner.clamavj.ClamScan">
+ <property name="host" value="${clamd.host}"/>
+ <property name="port" value="${clamd.port}"/>
+ <property name="timeout" value="${clamd.timeout}"/>
+ </bean>
+
+ <bean id="formFactory" class="cdr.forms.CachedXMIFormFactory">
+ <property name="formPath" value="${forms.dir}" />
+ </bean>
+
+ <bean id="administratorEmail" class="java.lang.String">
+ <constructor-arg value="${administrator.email}"/>
+ </bean>
+
+ <bean id="depositHandler" class="cdr.forms.SwordDepositHandler">
+ <property name="serviceUrl"
+ value="${admin.services.url}${services.context}/sword/" />
+ <property name="username" value="${forms.sword.username}" />
+ <property name="password" value="${forms.sword.password}" />
+ <property name="defaultContainer" ref="${forms.default.container.pid}"/>
+ </bean>
+
+ <bean id="authorizationHandler" class="cdr.forms.ShibbolethAuthorizationHandler">
+ <property name="groupsHeaderName" value="isMemberOf"/>
+ <property name="splitCharacter" value=";"/>
+ </bean>
+
+ <!-- JMX -->
+
+ <bean id="loggingExporter" class="org.springframework.jmx.export.MBeanExporter"
+ lazy-init="false">
+ <property name="beans">
+ <map>
+ <entry key="cdr-services:jmxservice=loggingConfiguration"
+ value-ref="loggingMBean" />
+ </map>
+ </property>
+ <property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING" />
+ <property name="assembler">
+ <bean
+ class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
+ <property name="managedInterfaces">
+ <array value-type="java.lang.Class">
+ <value>de.stefanheintz.log.jmxservice.LoggingConfig</value>
+ </array>
+ </property>
+ </bean>
+ </property>
+ </bean>
+
+ <!-- Logging MBean -->
+ <!-- http://code.google.com/p/logging-jmx-service/wiki/Tutorial -->
+ <bean id="loggingMBean" class="de.stefanheintz.log.jmxservice.LoggingConfigImpl">
+ </bean>
+
+
+
+</beans>
View
61 forms/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,61 @@
+<!--
+
+ Copyright 2008 The University of North Carolina at Chapel Hill
+
+ 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.
+
+-->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
+ <display-name>CDR Deposit Forms</display-name>
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>
+ /WEB-INF/service-context.xml
+ </param-value>
+ </context-param>
+
+ <servlet>
+ <servlet-name>forms</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>forms</servlet-name>
+ <url-pattern>*.form</url-pattern>
+ </servlet-mapping>
+
+ <filter>
+ <filter-name>UserSecurityProfileFilter</filter-name>
+ <filter-class>edu.unc.lib.dl.security.access.UserSecurityProfileFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>UserSecurityProfileFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>formapp</web-resource-name>
+ <url-pattern>*.form</url-pattern>
+ </web-resource-collection>
+ <user-data-constraint>
+ <transport-guarantee>CONFIDENTIAL</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+</web-app>
View
22 forms/src/main/webapp/index.jsp
@@ -0,0 +1,22 @@
+<%--
+
+ Copyright 2008 The University of North Carolina at Chapel Hill
+
+ 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.
+
+--%>
+<html>
+<body>
+<h2>Hello World!</h2>
+</body>
+</html>
View
6 mods.model/.project
@@ -26,11 +26,6 @@
</arguments>
</buildCommand>
<buildCommand>
- <name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
@@ -47,7 +42,6 @@
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>
View
1 mods.model/pom.xml
@@ -8,6 +8,5 @@
<version>4.0.0-SNAPSHOT</version>
</parent>
<artifactId>mods.model</artifactId>
- <version>4.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
View
3 pom.xml
@@ -14,6 +14,8 @@
<eclipse-repository-url>http://download.eclipse.org/eclipse/updates/3.6</eclipse-repository-url>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <spring.version>3.0.6.RELEASE</spring.version>
+ <spring.ws.version>2.0.1.RELEASE</spring.ws.version>
</properties>
<developers>
<developer>
@@ -67,6 +69,7 @@
<module>crosswalk-gmf.custom</module>
<module>org.slf4j.log4j12</module>
<module>org.apache.log4j</module>
+ <module>forms</module>
</modules>
<build>
<plugins>

0 comments on commit 85a8fe0

Please sign in to comment.
Something went wrong with that request. Please try again.