--- /dev/null
+# Example for Windows
+jboss.dir=c:/dev/jboss-4.2.3.GA
+# Example for Unix
+#jboss.dir=/opt/jboss
+
+# Which JBoss server config to use
+jboss.config=default
+
+# nuxeo deployment
+jboss.nuxeo.ear.dir=${jboss.dir}/server/${jboss.config}/deploy/nuxeo.ear
+
+
+# additional command line parameters for mvn commands
+# e.g. to work offline:
+#mvn.opts=-o
--- /dev/null
+<?xml version="1.0"?>
+<project name="nuxeo cs" default="all" basedir=".">
+
+ <property file="build.properties" />
+ <property name="cs.nuxeo.jar" value="nuxeo-platform-collectionspace-5.2-SNAPSHOT.jar"/>
+
+ <target name="all" description="all">
+ <delete file="${jboss.nuxeo.ear.dir}/system/${cs.nuxeo.jar}"/>
+ <copy todir="${jboss.nuxeo.ear.dir}/system">
+ <fileset file="${basedir}/target/${cs.nuxeo.jar}" />
+ </copy>
+ </target>
+
+</project>
--- /dev/null
+<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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-parent</artifactId>
+ <version>5.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>nuxeo-platform-collectionspace</artifactId>
+ <packaging>jar</packaging>
+ <name>Nuxeo CS extensions</name>
+ <description>
+ Nuxeo Enterprise Platform: CS extensions
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.nuxeo.ecm.core</groupId>
+ <artifactId>nuxeo-core-schema</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.nuxeo.ecm.platform</groupId>
+ <artifactId>nuxeo-platform-types-core</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
--- /dev/null
+Manifest-Version: 1.0 \r
+Bundle-ManifestVersion: 1 \r
+Bundle-Name: NuxeoCS\r
+Bundle-SymbolicName: org.collectionspace.collectionobject;singleton:=true \r
+Bundle-Version: 1.0.0\r
+Bundle-Localization: plugin\r
+Bundle-Vendor: Nuxeo \r
+Require-Bundle: org.nuxeo.runtime, \r
+ org.nuxeo.ecm.core.api, \r
+ org.nuxeo.ecm.core,\r
+ org.nuxeo.ecm.core.api,\r
+ org.nuxeo.ecm.platform.types.api,\r
+ org.nuxeo.ecm.platform.versioning.api,\r
+ org.nuxeo.ecm.platform.ui,\r
+ org.nuxeo.ecm.platform.forms.layout.client,\r
+ org.nuxeo.ecm.platform.publishing.api,\r
+ org.nuxeo.ecm.platform.ws \r
+Provide-Package: org.collectionspace.collectionobject\r
+Nuxeo-Component: OSGI-INF/core-types-contrib.xml,\r
+ OSGI-INF/ecm-types-contrib.xml,\r
+ OSGI-INF/layouts-contrib.xml\r
+\r
--- /dev/null
+<?xml version="1.0"?>
+<component name="org.collectionspace.collectionobject.coreTypes">
+ <extension target="org.nuxeo.ecm.core.schema.TypeService" point="schema">
+ <schema name="collectionobject" prefix="collectionobject" src="schemas/collectionobject.xsd"/>
+ </extension>
+ <extension target="org.nuxeo.ecm.core.schema.TypeService" point="doctype">
+ <doctype name="CollectionObject" extends="Document">
+ <schema name="common"/>
+ <schema name="dublincore"/>
+ <schema name="collectionobject"/>
+ </doctype>
+ </extension>
+</component>
--- /dev/null
+<?xml version="1.0"?>
+<fragment>
+
+ <extension target="application#MODULE">
+ <module>
+ <ejb>${bundle.fileName}</ejb>
+ </module>
+
+ <module>
+ <web>
+ <web-uri>nuxeo.war</web-uri>
+ <context-root>/nuxeo</context-root>
+ </web>
+ </module>
+ </extension>
+
+ <!-- uncomment that to enable tomcat based auth
+ <extension target="web#LOGIN-CONFIG">
+ <login-config>
+ <auth-method>FORM</auth-method>
+ <realm-name>nuxeo.ecm</realm-name>
+ <form-login-config>
+ <form-login-page>/login.jsp</form-login-page>
+ <form-error-page>/login.jsp?loginFailed=true</form-error-page>
+ </form-login-config>
+ </login-config>
+ </extension>
+ -->
+
+ <extension target="web#FILTER-MAPPING">
+
+ <!-- Seam Context Filter is declared in org.nuxeo.ecm.platform.ui.web
+ deployment fragment -->
+
+ <filter-mapping>
+ <filter-name>Seam Context Filter</filter-name>
+ <url-pattern>/ws/FileManageWS</url-pattern>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>Seam Context Filter</filter-name>
+ <url-pattern>/DocumentManagerWS</url-pattern>
+ </filter-mapping>
+ </extension>
+
+ <extension target="web#SERVLET">
+ </extension>
+
+ <extension target="web#SERVLET-MAPPING">
+ </extension>
+
+ <extension target="pages#PAGES">
+ <!-- This calls a method which load the Workspace logo -->
+ <page view-id="/showLogo.xhtml" action="#{logoHelper.getLogo}"/>
+
+ <!-- Bind URL to the Document URL resolver-->
+ <page view-id="/getDocument.xhtml"
+ action="#{navigationContext.navigateToURL}">
+ </page>
+
+ <page view-id="/nxliveedit.xhtml" action="#{liveEditHelper.getBootstrap()}"/>
+
+ <!-- Bind URL to the Parallele conversation Document URL resolver-->
+ <page view-id="/parallele.xhtml"
+ action="#{paralleleNavigationHelper.navigateToURL}">
+ </page>
+
+ <!-- Post login and 'home' view handler -->
+ <page view-id="/nxstartup.xhtml"
+ action="#{startupHelper.initDomainAndFindStartupPage('Default domain', 'view')}"/>
+
+ <!-- To redirect to the user dashboard instead, use instead:
+
+ <page view-id="/nxstartup.xhtml"
+ action="#{startupHelper.initDomainAndFindStartupPage('Default domain', 'user_dashboard')}" />
+ -->
+
+ <!-- config for workspace management
+ = give a description for each viewId
+ -->
+
+ <page view-id="/view_domains.xhtml">
+ #{currentServerLocation.name}/#{currentTabAction.label}
+ </page>
+
+ <page view-id="/select_document_type.faces.xhtml">
+ Create new document in #{currentDocument.name}
+ </page>
+
+ <page view-id="/create_document.faces.xhtml">
+ Create new document in #{currentDocument.name}
+ </page>
+
+ <page view-id="/user_dashboard.xhtml">
+ breadcrumb=command.user_dashboard
+ </page>
+
+ <page view-id="/view_users.xhtml">
+ breadcrumb=command.manageMembers
+ </page>
+
+ <page view-id="/view_many_users.xhtml">
+ breadcrumb=command.manageMembers
+ </page>
+
+ <page view-id="/view_vocabularies.xhtml">
+ breadcrumb=title.vocabularies
+ </page>
+
+ <page view-id="/search/search_form.xhtml">
+ breadcrumb=command.advancedSearch
+ </page>
+ </extension>
+
+ <extension target="faces-config#APPLICATION">
+ <locale-config>
+ <default-locale>en</default-locale>
+ <supported-locale>en_GB</supported-locale>
+ <supported-locale>en_US</supported-locale>
+ <supported-locale>fr</supported-locale>
+ <supported-locale>de</supported-locale>
+ <supported-locale>es</supported-locale>
+ <supported-locale>it</supported-locale>
+ <supported-locale>ar</supported-locale>
+ <supported-locale>ru</supported-locale>
+ <supported-locale>ja</supported-locale>
+ <supported-locale>vn</supported-locale>
+ </locale-config>
+
+ <message-bundle>messages</message-bundle>
+ </extension>
+
+ <extension target="components#PAGEFLOW">
+ <value>config/addWorkspace.jpdl.xml</value>
+ </extension>
+
+ <extension target="faces-config#NAVIGATION">
+ <!-- generic pages -->
+ <navigation-case>
+ <from-outcome>generic_error_page</from-outcome>
+ <to-view-id>/generic_error_page.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>generic_message_page</from-outcome>
+ <to-view-id>/generic_message_page.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>home</from-outcome>
+ <to-view-id>/nxstartup.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>user_login</from-outcome>
+ <to-view-id>/login.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>user_logout</from-outcome>
+ <to-view-id>/logout.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_servers</from-outcome>
+ <to-view-id>/view_servers.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- pages for document actions -->
+
+ <navigation-case>
+ <from-outcome>view_domains</from-outcome>
+ <to-view-id>/view_domains.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>select_document_type</from-outcome>
+ <to-view-id>/select_document_type.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>create_document</from-outcome>
+ <to-view-id>/create_document.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>edit_document</from-outcome>
+ <to-view-id>/edit_document.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_documents</from-outcome>
+ <to-view-id>/view_documents.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>create_file</from-outcome>
+ <to-view-id>/create_file.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>create_workspace_wizard</from-outcome>
+ <to-view-id>/createWorkspaceWizard.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>send_email</from-outcome>
+ <to-view-id>/document_email.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- AT: BBB, use view_documents instead -->
+ <navigation-case>
+ <from-outcome>view_workspaces</from-outcome>
+ <to-view-id>/view_workspaces.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- AT: BBB, use create_document instead -->
+ <navigation-case>
+ <from-outcome>create_domain</from-outcome>
+ <to-view-id>/create_domain.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- AT: BBB, use edit_document instead -->
+ <navigation-case>
+ <from-outcome>edit_domain</from-outcome>
+ <to-view-id>/edit_domain.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- AT: BBB, use create_document instead -->
+ <navigation-case>
+ <from-outcome>create_workspace</from-outcome>
+ <to-view-id>/create_workspace.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- AT: BBB, use edit_document instead -->
+ <navigation-case>
+ <from-outcome>edit_workspace</from-outcome>
+ <to-view-id>/edit_workspace.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- users ang groups -->
+
+ <navigation-case>
+ <from-outcome>members_management</from-outcome>
+ <to-view-id>/members_management.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_users</from-outcome>
+ <to-view-id>/view_users.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_many_users</from-outcome>
+ <to-view-id>/view_many_users.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>edit_user</from-outcome>
+ <to-view-id>/edit_user.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>edit_user_password</from-outcome>
+ <to-view-id>/edit_user_password.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_user</from-outcome>
+ <to-view-id>/view_user.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>create_user</from-outcome>
+ <to-view-id>/create_user.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_groups</from-outcome>
+ <to-view-id>/view_groups.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_group</from-outcome>
+ <to-view-id>/view_group.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>edit_group</from-outcome>
+ <to-view-id>/edit_group.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>create_group</from-outcome>
+ <to-view-id>/create_group.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_vocabularies</from-outcome>
+ <to-view-id>/view_vocabularies.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>view_vocabulary</from-outcome>
+ <to-view-id>/view_vocabulary.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- search -->
+
+ <navigation-case>
+ <from-outcome>search_form</from-outcome>
+ <to-view-id>/search/search_form.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>search_results_nxql</from-outcome>
+ <to-view-id>/search/search_results_nxql.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>search_results_advanced</from-outcome>
+ <to-view-id>
+ /search/search_results_advanced.xhtml
+ </to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>search_results_simple</from-outcome>
+ <to-view-id>/search/search_results_simple.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <!-- miscellaneaous -->
+
+ <navigation-case>
+ <from-outcome>clipboard</from-outcome>
+ <to-view-id>/incl/clipboard.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>user_dashboard</from-outcome>
+ <to-view-id>/user_dashboard.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>select_workspace_template</from-outcome>
+ <to-view-id>/select_workspace_template.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>pdf_generation_error</from-outcome>
+ <to-view-id>/pdf_generation_error.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>mass_edit</from-outcome>
+ <to-view-id>/massedit_documents.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+
+ <navigation-case>
+ <from-outcome>mass_edit_confirm</from-outcome>
+ <to-view-id>/massedit_documents_preview.xhtml</to-view-id>
+ <redirect/>
+ </navigation-case>
+ </extension>
+
+</fragment>
+
--- /dev/null
+<?xml version="1.0"?>
+<component name="org.collectionspace.collectionobject.ecm.types">
+ <extension target="org.nuxeo.ecm.platform.types.TypeService" point="types">
+ <type id="CollectionObject" coretype="CollectionObject">
+ <label>org.collectionspace.collectionobject</label>
+ <!--icon>/icons/file.gif</icon-->
+ <default-view>view_documents</default-view>
+
+ <layouts mode="any">
+ <layout>heading</layout>
+ <layout>collectionobject</layout>
+ </layouts>
+ </type>
+
+ <type id="Folder" coretype="Folder">
+ <subtypes>
+ <type>CollectionObject</type>
+ </subtypes>
+ </type>
+
+ <type id="Workspace" coretype="Workspace">
+ <subtypes>
+ <type>CollectionObject</type>
+ </subtypes>
+ </type>
+
+ </extension>
+</component>
--- /dev/null
+<?xml version="1.0"?>
+
+<component name="org.collectionspace.collectionobject.layouts.webapp">
+
+ <extension target="org.nuxeo.ecm.platform.forms.layout.WebLayoutManager"
+ point="layouts">
+
+ <layout name="collectionobject">
+ <templates>
+ <template mode="any">/layouts/layout_default_template.xhtml</template>
+ </templates>
+ <rows>
+ <row><widget>objectNumber</widget></row>
+ <row><widget>otherNumber</widget></row>
+ <row><widget>briefDescription</widget></row>
+ <row><widget>comments</widget></row>
+ <row><widget>distFeatures</widget></row>
+ <row><widget>objectName</widget></row>
+ <row><widget>responsibleDept</widget></row>
+ <row><widget>title</widget></row>
+ </rows>
+
+ <widget name="objectNumber" type="text">
+ <labels>
+ <label mode="any">objectNumber</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="collectionobject">objectNumber</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="otherNumber" type="text">
+ <labels>
+ <label mode="any">otherNumber</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="collectionobject">otherNumber</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="briefDescription" type="text">
+ <labels>
+ <label mode="any">briefDescription</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="collectionobject">briefDescription</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="comments" type="text">
+ <labels>
+ <label mode="any">comments</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="collectionobject">comments</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="distFeatures" type="text">
+ <labels>
+ <label mode="any">distFeatures</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="collectionobject">distFeatures</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="objectName" type="text">
+ <labels>
+ <label mode="any">objectName</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="collectionobject">objectName</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="responsibleDept" type="text">
+ <labels>
+ <label mode="any">responsibleDept</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="collectionobject">responsibleDept</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ <widget name="title" type="text">
+ <labels>
+ <label mode="any">title</label>
+ </labels>
+ <translated>true</translated>
+ <fields>
+ <field schema="collectionobject">title</field>
+ </fields>
+ <properties widgetMode="edit">
+ <property name="styleClass">dataInputText</property>
+ </properties>
+ </widget>
+
+ </layout>
+ </extension>
+</component>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r
+<xs:schema \r
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"\r
+ xmlns:ns="http://collectionspace.org/collectionobject/"\r
+ xmlns="http://collectionspace.org/collectionobject/"\r
+ targetNamespace="http://collectionspace.org/collectionobject/"\r
+ version="0.1">\r
+\r
+ <xs:element name="objectNumber" type="xs:string"/>\r
+ <xs:element name="otherNumber" type="xs:string"/>\r
+ <xs:element name="briefDescription" type="xs:string"/>\r
+ <xs:element name="comments" type="xs:string"/>\r
+ <xs:element name="distFeatures" type="xs:string"/>\r
+ <xs:element name="objectName" type="xs:string"/>\r
+ <xs:element name="responsibleDept" type="xs:string"/>\r
+ <xs:element name="title" type="xs:string"/>\r
+ \r
+</xs:schema>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>\r
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>\r
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>javaee-addressbook-jaxb</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+#Thu Feb 26 16:32:52 PST 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5\r
+org.eclipse.jdt.core.compiler.compliance=1.5\r
+org.eclipse.jdt.core.compiler.source=1.5\r
--- /dev/null
+#Thu Feb 26 16:30:28 PST 2009\r
+activeProfiles=\r
+eclipse.preferences.version=1\r
+fullBuildGoals=process-test-resources\r
+includeModules=false\r
+resolveWorkspaceProjects=true\r
+resourceFilterGoals=process-resources resources\:testResources\r
+version=1\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!--
+ <parent>
+ <artifactId>helloworld</artifactId>
+ <groupId>org.collectionspace.hello.services</groupId>
+ <version>0.1</version>
+ </parent>
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>collectionobject-jaxb</artifactId>
+ <version>0.1</version>
+ <name>CollectionObject Service JAXB</name>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>java.net</id>
+ <name>java.net Maven Repository</name>
+ <url>https://maven-repository.dev.java.net/nonav/repository</url>
+ <layout>legacy</layout>
+ </pluginRepository>
+ <pluginRepository>
+ <id>maven2-repository.dev.java.net</id>
+ <name>Java.net Maven 2 Repository</name>
+ <url>http://download.java.net/maven/2</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jvnet.jaxb2-commons</groupId>
+ <artifactId>property-listener-injector</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jvnet.jaxb2_commons</groupId>
+ <artifactId>runtime</artifactId>
+ <version>0.4.1.4</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <!-- javax.activation.DataSource provider is required by spec -->
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.1.2</version>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <args>
+ <arg>-XtoString</arg>
+ <arg>-Xinject-listener-code</arg>
+
+ <!-- <arg>-Xcollection-setter-injector</arg>
+ <arg>-Xfluent-api</arg> -->
+ </args>
+ <plugins>
+ <plugin>
+ <groupId>
+ org.jvnet.jaxb2_commons
+ </groupId>
+ <artifactId>basic</artifactId>
+ <version>0.4.1</version>
+ </plugin>
+ <plugin>
+ <groupId>
+ org.jvnet.jaxb2-commons
+ </groupId>
+ <artifactId>
+ property-listener-injector
+ </artifactId>
+ <version>1.0</version>
+ </plugin>
+
+ </plugins>
+ <!--generatePackage>
+ org.collectionspace.hello
+ </generatePackage-->
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
--- /dev/null
+/**\r
+ * \r
+ */\r
+package org.collectionspace.services;\r
+\r
+/**\r
+ * @author remillet\r
+ *\r
+ */\r
+public interface CollectionObjectJAXBSchema {\r
+ final static String OBJECT_NUMBER = "objectNumber";\r
+ final static String OTHER_NUMBER = "otherNumber";\r
+ final static String BRIEF_DESCRIPTION = "briefDescription";\r
+ final static String COMMENTS = "comments";\r
+ final static String DIST_FEATURES = "distFeatures";\r
+ final static String OBJECT_NAME = "objectName";\r
+ final static String RESPONSIBLE_DEPT = "responsibleDept";\r
+ final static String TITLE = "title";\r
+}\r
+\r
+\r
--- /dev/null
+package org.collectionspace.services;\r
+\r
+public interface CollectionObjectListItemJAXBSchema {\r
+ final static String OBJECT_NUMBER = "objectNumber";\r
+ final static String CSID = "csid";\r
+ final static String URI = "url";\r
+}\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:ns="http://collectionspace.org/collectionobject"
+ xmlns="http://collectionspace.org/collectionobject"
+ targetNamespace="http://services.collectionspace.org/collectionobject"
+ version="0.1"
+>
+
+<!-- avoid XmlRootElement nightnmare, see http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html-->
+
+ <!-- collection-object -->
+ <xs:element name="collection-object">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="csid" type="xs:string" />
+ <xs:element name="objectNumber" type="xs:string"/>
+ <xs:element name="otherNumber" type="xs:string"/>
+ <xs:element name="briefDescription" type="xs:string"/>
+ <xs:element name="comments" type="xs:string"/>
+ <xs:element name="distFeatures" type="xs:string"/>
+ <xs:element name="objectName" type="xs:string"/>
+ <xs:element name="responsibleDept" type="xs:string"/>
+ <xs:element name="title" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <!-- collection objects as in nuxeo repository -->
+ <xs:element name="collection-object-list">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="collection-object-list-item" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="objectNumber" type="xs:string"
+ minOccurs="1" />
+ <!-- uri to retrive collection object details -->
+ <xs:element name="uri" type="xs:anyURI"
+ minOccurs="1" />
+ <xs:element name="csid" type="xs:string"
+ minOccurs="1" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+</xs:schema>
+
--- /dev/null
+package org.collectionspace.services;
+
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import java.util.Map;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+
+import org.collectionspace.*;
+import org.collectionspace.services.nuxeo.NuxeoRESTClient;
+import org.collectionspace.services.collectionobject.*;
+import org.collectionspace.services.collectionobject.CollectionObjectList.*;
+import org.collectionspace.services.CollectionObjectJAXBSchema;
+import org.collectionspace.services.CollectionObjectListItemJAXBSchema;
+
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Namespace;
+import org.dom4j.io.SAXReader;
+import org.restlet.resource.Representation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Path("/collectionobjects")
+@Consumes("application/xml")
+@Produces("application/xml")
+public class CollectionObjectResource extends CollectionSpaceResource {
+
+ final static String CO_NUXEO_DOCTYPE = "CollectionObject";
+ final static String CO_NUXEO_SCHEMA_NAME = "collectionobject";
+ final static String CO_NUXEO_DC_TITLE = "CollectionSpace-CollectionObject";
+
+ final Logger logger = LoggerFactory.getLogger(CollectionObjectResource.class);
+
+ public CollectionObjectResource() {
+ // do nothing
+ }
+
+ @GET
+ public CollectionObjectList getCollectionObjectList(@Context UriInfo ui) {
+ CollectionObjectList p = new CollectionObjectList();
+ try{
+ NuxeoRESTClient nxClient = getClient();
+
+ List<String> pathParams = new ArrayList<String>();
+ Map<String, String> queryParams = new HashMap<String, String>();
+ pathParams = Arrays.asList("default", CS_COLLECTIONOBJECT_WORKSPACE_UID, "browse");
+ Representation res = nxClient.get(pathParams, queryParams);
+ SAXReader reader = new SAXReader();
+ Document document = reader.read(res.getStream());
+ Element root = document.getRootElement();
+
+ //debug
+ System.err.println(res.toString());
+ System.err.println(document.asXML());
+
+ List<CollectionObjectList.CollectionObjectListItem> list = p.getCollectionObjectListItem();
+ for(Iterator i = root.elementIterator(); i.hasNext();){
+ Element element = (Element) i.next();
+ //debug
+ System.err.println();element.asXML();
+
+ // set the CollectionObject list item entity elements
+ CollectionObjectListItem pli = new CollectionObjectListItem();
+ pli.setObjectNumber(element.attributeValue("title"));
+ pli.setUri(element.attributeValue("url"));
+ pli.setCsid(element.attributeValue("id"));
+ list.add(pli);
+ }
+
+ }catch(Exception e){
+ e.printStackTrace();
+ }
+
+ return p;
+ }
+
+ @POST
+ public Response createCollectionObject(CollectionObject co) {
+
+ NuxeoRESTClient nxClient = getClient();
+
+ List<String> pathParams = new ArrayList<String>();
+ Map<String, String> queryParams = new HashMap<String, String>();
+ pathParams.add("default");
+ pathParams.add(CS_COLLECTIONOBJECT_WORKSPACE_UID);
+ pathParams.add("createDocument");
+ queryParams.put("docType", CO_NUXEO_DOCTYPE);
+
+ // a default title for the Dublin Core schema
+ queryParams.put("dublincore:title", CO_NUXEO_DC_TITLE);
+
+ // CollectionObject core values
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.OBJECT_NUMBER,
+ co.getObjectNumber());
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.OTHER_NUMBER,
+ co.getOtherNumber());
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.BRIEF_DESCRIPTION,
+ co.getBriefDescription());
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.COMMENTS,
+ co.getComments());
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.DIST_FEATURES,
+ co.getDistFeatures());
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.OBJECT_NAME,
+ co.getObjectName());
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.RESPONSIBLE_DEPT,
+ co.getResponsibleDept());
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.TITLE,
+ co.getTitle());
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);
+ Representation res = nxClient.post(pathParams, queryParams, bais);
+
+ String csid = null;
+ SAXReader reader = new SAXReader();
+ try {
+ Document document = reader.read(res.getStream());
+ Element root = document.getRootElement();
+ for (Iterator i = root.elementIterator(); i.hasNext();){
+ Element element = (Element) i.next();
+ if ("docRef".equals(element.getName())){
+ csid = (String) element.getData();
+ co.setCsid(csid);
+ }
+ }
+ } catch(Exception e){
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Create failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+
+
+ verbose("createCollectionObject: ", co);
+ UriBuilder path = UriBuilder.fromResource(CollectionObjectResource.class);
+ path.path("" + csid);
+ Response response = Response.created(path.build()).build();
+
+ return response;
+ }
+
+ @GET
+ @Path("{csid}")
+ public CollectionObject getCollectionObject(@PathParam("csid") String csid) {
+
+ CollectionObject co = null;
+ try {
+ List<String> pathParams = new ArrayList<String>();
+ Map<String, String> queryParams = new HashMap<String, String>();
+
+ pathParams.add("default");
+ pathParams.add(csid);
+ pathParams.add("export");
+ queryParams.put("format", "XML");
+
+ NuxeoRESTClient nxClient = getClient();
+ Representation res = nxClient.get(pathParams, queryParams);
+
+ SAXReader reader = new SAXReader();
+ Document document = reader.read(res.getStream());
+ Element root = document.getRootElement();
+ co = new CollectionObject();
+
+ // TODO: recognize schema thru namespace uri
+// Namespace ns = new Namespace("collectionobject", "http://collectionspace.org/collectionobject");
+
+ Iterator<Element> siter = root.elementIterator("schema");
+ while (siter.hasNext()) {
+
+ Element schemaElement = siter.next();
+ System.err.println("CollectionObject.getCollectionObject() called.");
+
+ //TODO: recognize schema thru namespace uri
+ if (CO_NUXEO_SCHEMA_NAME.equals(schemaElement.attribute("name").getValue())){
+ Element ele = schemaElement.element(CollectionObjectJAXBSchema.OBJECT_NUMBER);
+ if(ele != null){
+ co.setObjectNumber((String) ele.getData());
+ }
+ ele = schemaElement.element(CollectionObjectJAXBSchema.OTHER_NUMBER);
+ if(ele != null){
+ co.setOtherNumber((String) ele.getData());
+ }
+ ele = schemaElement.element(CollectionObjectJAXBSchema.BRIEF_DESCRIPTION);
+ if(ele != null){
+ co.setBriefDescription((String) ele.getData());
+ }
+ ele = schemaElement.element(CollectionObjectJAXBSchema.COMMENTS);
+ if(ele != null){
+ co.setComments((String) ele.getData());
+ }
+ ele = schemaElement.element(CollectionObjectJAXBSchema.DIST_FEATURES);
+ if(ele != null){
+ co.setDistFeatures((String) ele.getData());
+ }
+ ele = schemaElement.element(CollectionObjectJAXBSchema.OBJECT_NAME);
+ if(ele != null){
+ co.setObjectName((String) ele.getData());
+ }
+ ele = schemaElement.element(CollectionObjectJAXBSchema.RESPONSIBLE_DEPT);
+ if(ele != null){
+ co.setResponsibleDept((String) ele.getData());
+ }
+ ele = schemaElement.element(CollectionObjectJAXBSchema.TITLE);
+ if(ele != null){
+ co.setTitle((String) ele.getData());
+ }
+ }
+ }
+ } catch(Exception e){
+ e.printStackTrace();
+ Response response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
+ "Get failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ if (co == null) {
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Get failed, the requested CollectionObject CSID:" + csid + ": was not found.").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+ verbose("getCollectionObject: ", co);
+
+ return co;
+ }
+
+ @PUT
+ @Path("{csid}")
+ public CollectionObject updateCollectionObject(
+ @PathParam("csid") String csid,
+ CollectionObject theUpdate) {
+
+ verbose("updateCollectionObject with input: ", theUpdate);
+
+ List<String> pathParams = new ArrayList<String>();
+ Map<String, String> queryParams = new HashMap<String, String>();
+ pathParams.add("default");
+ pathParams.add(csid);
+ pathParams.add("updateDocumentRestlet");
+
+ //todo: intelligent merge needed
+ if(theUpdate.getObjectNumber() != null){
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.OBJECT_NUMBER,
+ theUpdate.getObjectNumber());
+ }
+
+ if(theUpdate.getOtherNumber() != null){
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.OTHER_NUMBER,
+ theUpdate.getOtherNumber());
+ }
+
+ if(theUpdate.getBriefDescription()!= null){
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.BRIEF_DESCRIPTION,
+ theUpdate.getBriefDescription());
+ }
+
+ if(theUpdate.getComments() != null){
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.COMMENTS,
+ theUpdate.getComments());
+ }
+
+ if(theUpdate.getDistFeatures() != null){
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.DIST_FEATURES,
+ theUpdate.getDistFeatures());
+ }
+
+ if(theUpdate.getObjectName() != null){
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.OBJECT_NAME,
+ theUpdate.getObjectName());
+ }
+
+ if(theUpdate.getResponsibleDept() != null){
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.RESPONSIBLE_DEPT,
+ theUpdate.getResponsibleDept());
+ }
+
+ if(theUpdate.getTitle() != null){
+ queryParams.put(CO_NUXEO_SCHEMA_NAME + ":" + CollectionObjectJAXBSchema.TITLE,
+ theUpdate.getTitle());
+ }
+
+ NuxeoRESTClient nxClient = getClient();
+ Representation res = nxClient.get(pathParams, queryParams);
+ SAXReader reader = new SAXReader();
+ String status = null;
+ try {
+ Document document = reader.read(res.getStream());
+ Element root = document.getRootElement();
+ for(Iterator i = root.elementIterator(); i.hasNext();){
+ Element element = (Element) i.next();
+ if("docRef".equals(element.getName())){
+ status = (String) element.getData();
+ verbose("updateCollectionObject response: " + status);
+ }
+ }
+ } catch(Exception e) {
+ //FIXME: NOT_FOUND?
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Update failed ").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+
+ return theUpdate;
+ }
+
+ @DELETE
+ @Path("{csid}")
+ public void deleteCollectionObject(@PathParam("csid") String csid) {
+
+ verbose("deleteCollectionObject with csid=" + csid);
+
+ NuxeoRESTClient nxClient = getClient();
+ List<String> pathParams = new ArrayList<String>();
+ Map<String, String> queryParams = new HashMap<String, String>();
+
+ pathParams.add("default");
+ pathParams.add(csid);
+ pathParams.add("deleteDocumentRestlet");
+ Representation res = nxClient.get(pathParams, queryParams);
+ SAXReader reader = new SAXReader();
+ String status = "";
+
+ try {
+ Document document = reader.read(res.getStream());
+ Element root = document.getRootElement();
+ for(Iterator i = root.elementIterator(); i.hasNext();){
+ Element element = (Element) i.next();
+ if("docRef".equals(element.getName())){
+ status = (String) element.getData();
+ verbose("deleteCollectionObjectt response: " + status);
+ }
+ }
+ }catch(Exception e){
+ //FIXME: NOT_FOUND?
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(
+ "Delete failed ").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+
+ }
+
+ private void verbose(String msg, CollectionObject co) {
+ try {
+ verbose(msg);
+ JAXBContext jc = JAXBContext.newInstance(
+ CollectionObject.class);
+
+ Marshaller m = jc.createMarshaller();
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
+ Boolean.TRUE);
+ m.marshal(co, System.out);
+ } catch(Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ private void verbose(String msg) {
+ System.out.println("CollectionObjectResource. " + msg);
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<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/maven-v4_0_0.xsd">\r
+<!-- \r
+ <parent>\r
+ <artifactId>collectionspace-services</artifactId>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <version>0.1</version>\r
+ </parent> -->\r
+ \r
+ <modelVersion>4.0.0</modelVersion>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org-collectionspace-services-common</artifactId>\r
+ <packaging>jar</packaging>\r
+ <version>0.1</version>\r
+ <name>CollectionSpace Services Common</name>\r
+\r
+ <repositories>\r
+ <repository>\r
+ <id>java.net</id>\r
+ <url>http://download.java.net/maven/1</url>\r
+ <layout>legacy</layout>\r
+ </repository>\r
+ <repository>\r
+ <id>maven repo</id>\r
+ <name>maven repo</name>\r
+ <url>http://repo1.maven.org/maven2/</url>\r
+ </repository>\r
+ <!-- For resteasy -->\r
+ <repository>\r
+ <id>jboss</id>\r
+ <name>jboss repo</name>\r
+ <url>http://repository.jboss.org/maven2</url>\r
+ </repository>\r
+ <repository>\r
+ <id>mojo</id>\r
+ <name>mojo repo</name>\r
+ <url>http://svn.codehaus.org/mojo/trunk/mojo/jboss-maven-plugin</url>\r
+ </repository>\r
+\r
+ <repository>\r
+ <id>maven-restlet</id>\r
+ <name>Public online Restlet repository</name>\r
+ <url>http://maven.restlet.org</url>\r
+ </repository>\r
+ \r
+ <repository>\r
+ <id>cspace.local.nuxeo</id>\r
+ <url>${nuxeo.local.repo.dir}</url>\r
+ </repository>\r
+ <repository>\r
+ <id>cspace.local.nuxeo.client</id>\r
+ <url>${nuxeo.local.repo.client.dir}</url>\r
+ </repository>\r
+ <repository>\r
+ <id>public</id>\r
+ <url>http://maven.nuxeo.org/public</url>\r
+ <releases>\r
+ </releases>\r
+ <snapshots>\r
+ <enabled>false</enabled>\r
+ </snapshots>\r
+ </repository>\r
+ <repository>\r
+ <id>public-snapshot</id>\r
+ <url>http://maven.nuxeo.org/public-snapshot</url>\r
+ <releases>\r
+ <enabled>false</enabled>\r
+ </releases>\r
+ <snapshots>\r
+ </snapshots>\r
+ </repository>\r
+ </repositories>\r
+\r
+ <pluginRepositories>\r
+ <pluginRepository>\r
+ <id>public</id>\r
+ <url>http://maven.nuxeo.org/public</url>\r
+ <name>Nuxeo virtual release repository</name>\r
+ <releases>\r
+ </releases>\r
+ <snapshots>\r
+ <enabled>false</enabled>\r
+ </snapshots>\r
+ </pluginRepository>\r
+ <pluginRepository>\r
+ <id>public-snapshot</id>\r
+ <url>http://maven.nuxeo.org/public-snapshot</url>\r
+ <name>Nuxeo virtual snapshot repository</name>\r
+ <releases>\r
+ <enabled>false</enabled>\r
+ </releases>\r
+ <snapshots>\r
+ </snapshots>\r
+ </pluginRepository>\r
+ </pluginRepositories>\r
+\r
+\r
+ <properties>\r
+ <jboss.version>4.2.3.GA</jboss.version>\r
+ <jboss.ejb.version>3.0</jboss.ejb.version>\r
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
+ <apacheds.version>1.5.1</apacheds.version>\r
+ <apachedshared.version>0.9.7</apachedshared.version>\r
+ <nuxeo.version.5.2>5.2-SNAPSHOT</nuxeo.version.5.2>\r
+ <nuxeo.version.1.5>1.5-SNAPSHOT</nuxeo.version.1.5>\r
+ </properties>\r
+\r
+ <dependencies>\r
+<!-- <dependency>\r
+ <groupId>org.collectionspace.hello.services</groupId>\r
+ <artifactId>helloworld-jaxb</artifactId>\r
+ <version>0.1</version>\r
+ </dependency> -->\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxrs</artifactId>\r
+ <version>1.0.2.GA</version>\r
+ <exclusions>\r
+ <exclusion>\r
+ <groupId>tjws</groupId>\r
+ <artifactId>webserver</artifactId>\r
+ </exclusion>\r
+ </exclusions>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxb-provider</artifactId>\r
+ <version>1.0.2.GA</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-multipart-provider</artifactId>\r
+ <version>1.0.2.GA</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>junit</groupId>\r
+ <artifactId>junit</artifactId>\r
+ <version>4.1</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
+\r
+ <!-- javax -->\r
+\r
+\r
+ <dependency>\r
+ <groupId>javax.security</groupId>\r
+ <artifactId>jaas</artifactId>\r
+ <version>1.0.01</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>dom4j</groupId>\r
+ <artifactId>dom4j</artifactId>\r
+ <version>1.6.1</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ \r
+ <!-- jboss -->\r
+\r
+ <!-- nuxeo -->\r
+\r
+ <dependency>\r
+ <groupId>org.nuxeo.ecm.core</groupId>\r
+ <artifactId>nuxeo-core-api</artifactId>\r
+ <version>${nuxeo.version.1.5}</version>\r
+ <exclusions>\r
+ <exclusion>\r
+ <artifactId>jboss-remoting</artifactId>\r
+ <groupId>jboss</groupId>\r
+ </exclusion>\r
+ </exclusions>\r
+ </dependency>\r
+\r
+<!--\r
+ <dependency>\r
+ <groupId>org.nuxeo.ecm.core</groupId>\r
+ <artifactId>nuxeo-core-client</artifactId>\r
+ <version>${nuxeo.version.1.5}</version>\r
+ </dependency>\r
+-->\r
+\r
+ <dependency>\r
+ <groupId>org.restlet</groupId>\r
+ <artifactId>org.restlet</artifactId>\r
+ <version>1.0.7</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.noelios.restlet</groupId>\r
+ <artifactId>com.noelios.restlet.ext.httpclient</artifactId>\r
+ <version>1.0.7</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.noelios.restlet</groupId>\r
+ <artifactId>com.noelios.restlet</artifactId>\r
+ <version>1.0.7</version>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>jaxen</groupId>\r
+ <artifactId>jaxen</artifactId>\r
+ <version>1.1.1</version>\r
+ </dependency>\r
+ </dependencies>\r
+ \r
+ <build>\r
+ <finalName>org-collectionspace-services-common</finalName>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-surefire-plugin</artifactId>\r
+ <configuration></configuration>\r
+ <executions>\r
+ <execution>\r
+ <id>surefire-it</id>\r
+ <phase>integration-test</phase>\r
+ <goals>\r
+ <goal>test</goal>\r
+ </goals>\r
+ <configuration>\r
+ <skip>false</skip>\r
+ </configuration>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-compiler-plugin</artifactId>\r
+ <configuration>\r
+ <source>1.5</source>\r
+ <target>1.5</target>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+</project>\r
--- /dev/null
+package org.collectionspace.services;\r
+\r
+import org.collectionspace.services.nuxeo.NuxeoRESTClient;\r
+\r
+public abstract class CollectionSpaceResource {\r
+ //replace WORKSPACE_UID for resource workspace\r
+ static String CS_COLLECTIONOBJECT_WORKSPACE_UID = "4416ba45-08ca-47b2-aafa-7f4483611d76";\r
+ //rem demo.collectionspace.org UID for CO's is 5a37d40f-59c4-4d15-93ad-e0e6a0c33587\r
+ //sanjay 6c7881fe-54c5-486e-b144-a025dee3a484\r
+ //demo eae0d7b6-580a-45a3-a0f3-e25e980e03bb\r
+ static String CS_PERSON_WORKSPACE_UID = "eae0d7b6-580a-45a3-a0f3-e25e980e03bb";\r
+ \r
+ //replace host if not running on localhost\r
+ //static String CS_NUXEO_HOST = "173.45.234.217";\r
+ static String CS_NUXEO_HOST = "localhost";\r
+ static String CS_NUXEO_URI = "http://" + CS_NUXEO_HOST + ":8080/nuxeo";\r
+ \r
+ NuxeoRESTClient getClient() {\r
+ NuxeoRESTClient nxClient = new NuxeoRESTClient(CS_NUXEO_URI);\r
+ nxClient.setAuthType(NuxeoRESTClient.AUTH_TYPE_BASIC);\r
+ nxClient.setBasicAuthentication("Administrator", "Administrator");\r
+ return nxClient;\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.collectionspace.services.nuxeo;
+
+
+import javax.security.auth.callback.Callback;
+
+/**
+ * Copied from jbossx
+ *
+ * An implementation of Callback that simply obtains an Object to be used
+ * as the authentication credential. Interpretation of the Object is up to
+ * the LoginModules that validate the credential.
+ *
+ * @author Scott.Stark@jboss.org
+ */
+public class NuxeoCallback implements Callback {
+
+ private final String prompt;
+
+ private Object credential;
+
+ public NuxeoCallback() {
+ this("");
+ }
+
+ public NuxeoCallback(String prompt) {
+ this.prompt = prompt;
+ }
+
+ public String getPrompt() {
+ return prompt;
+ }
+
+ public Object getCredential() {
+ return credential;
+ }
+
+ public void setCredential(Object credential) {
+ this.credential = credential;
+ }
+
+ public void clearCredential() {
+ credential = null;
+ }
+
+}
--- /dev/null
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.collectionspace.services.nuxeo;
+
+/**
+ *
+ * @author sanjaydalal
+ */
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+/**
+ * Copied from jbossx.
+ *
+ * @author Scott.Stark@jboss.org
+ */
+public class NuxeoCallbackHandler implements CallbackHandler {
+
+ private final String username;
+ private char[] password;
+ private final Object credential;
+
+ /**
+ * Initializes the UsernamePasswordHandler with the username and password to
+ * use.
+ *
+ * @param username the user name
+ * @param password the password for this user
+ */
+ public NuxeoCallbackHandler(String username, char[] password) {
+ this.username = username;
+ this.password = password;
+ credential = password;
+ }
+
+ public NuxeoCallbackHandler(String username, Object credential) {
+ this.username = username;
+ this.credential = credential;
+ if (credential instanceof char[]) {
+ password = (char[]) credential;
+ } else if (credential instanceof CharSequence) {
+ password = credential.toString().toCharArray();
+ }
+ }
+
+ /**
+ * Sets any NameCallback name property to the instance username, sets any
+ * PasswordCallback password property to the instance, and any password.
+ *
+ * @exception UnsupportedCallbackException,
+ * thrown if any callback of type other than NameCallback or
+ * PasswordCallback are seen.
+ */
+ public void handle(Callback[] callbacks)
+ throws UnsupportedCallbackException {
+ for (Callback c : callbacks) {
+ if (c instanceof NameCallback) {
+ NameCallback nc = (NameCallback) c;
+ nc.setName(username);
+ } else if (c instanceof PasswordCallback) {
+ PasswordCallback pc = (PasswordCallback) c;
+ if (password == null) {
+ // We were given an opaque Object credential but a char[] is
+ // requested?
+ if (credential != null) {
+ String tmp = credential.toString();
+ password = tmp.toCharArray();
+ }
+ }
+ pc.setPassword(password);
+ } else if (c instanceof NuxeoCallback) {
+ NuxeoCallback oc = (NuxeoCallback) c;
+ oc.setCredential(credential);
+ } else {
+ throw new UnsupportedCallbackException(c,
+ "Unrecognized Callback");
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.collectionspace.services.nuxeo;
+
+/**
+ *
+ * @author sanjaydalal
+ */
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
+
+public class NuxeoLoginConfiguration extends Configuration {
+
+ private final Configuration parent;
+ public static final String LOGIN_DOMAIN = "nuxeo-client-login";
+
+ public NuxeoLoginConfiguration(Configuration parent) {
+ this.parent = parent;
+ }
+
+ @Override
+ public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
+
+ if (LOGIN_DOMAIN.equals(name)) {
+ AppConfigurationEntry[] entries = new AppConfigurationEntry[1];
+
+ Map<String, Object> options = new HashMap<String, Object>();
+
+ options.put("restore-login-identity", "True");
+ options.put("multi-threaded", "True");
+
+ entries[0] = new AppConfigurationEntry("org.jboss.security.ClientLoginModule", LoginModuleControlFlag.REQUIRED, options);
+
+
+ return entries;
+ } else {
+ return parent.getAppConfigurationEntry(name);
+ }
+ }
+
+ @Override
+ public void refresh() {
+ if (parent != null) {
+ parent.refresh();
+ }
+ }
+}
--- /dev/null
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.collectionspace.services.nuxeo;
+
+/**
+ *
+ * @author sanjaydalal
+ */
+
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+public class NuxeoLoginContextFactory {
+
+
+ private static boolean initDone=false;
+
+ private static void initLoginConfig()
+ {
+ if (initDone)
+ return;
+
+ Configuration parentConfig = null;
+ try {
+ parentConfig = Configuration.getConfiguration();
+ } catch (Exception e) {
+ // do nothing - this can happen if default configuration provider is not correctly configured
+ // for examnple FileConfig fails if no config file was defined
+ }
+ Configuration config = new NuxeoLoginConfiguration(parentConfig);
+ Configuration.setConfiguration(config);
+
+ initDone=true;
+
+ }
+
+
+ public static LoginContext getLoginContext(CallbackHandler handler) throws LoginException
+ {
+ initLoginConfig();
+ return new LoginContext(NuxeoLoginConfiguration.LOGIN_DOMAIN, handler);
+ }
+}
--- /dev/null
+/*
+ * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Lesser General Public License
+ * (LGPL) version 2.1 which accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Contributors:
+ * Nuxeo - initial API and implementation
+ *
+ * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $
+ */
+package org.collectionspace.services.nuxeo;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.Map;
+
+
+import org.restlet.Client;
+import org.restlet.data.ChallengeResponse;
+import org.restlet.data.ChallengeScheme;
+import org.restlet.data.Cookie;
+import org.restlet.data.Form;
+import org.restlet.data.MediaType;
+import org.restlet.data.Method;
+import org.restlet.data.Parameter;
+import org.restlet.data.Protocol;
+import org.restlet.data.Request;
+import org.restlet.resource.OutputRepresentation;
+import org.restlet.resource.Representation;
+import org.restlet.util.Series;
+
+public class NuxeoRESTClient {
+
+ public static final int AUTH_TYPE_NONE = 0;
+ public static final int AUTH_TYPE_BASIC = 1;
+ public static final int AUTH_TYPE_SECRET = 2;
+ protected String baseURL = "http://127.0.0.1:8080/nuxeo";
+ protected String restPrefix = "restAPI";
+ protected String davPrefix = "dav";
+ protected List<Cookie> cookies;
+ protected int authType = AUTH_TYPE_NONE;
+ protected String userName;
+ protected String password;
+ protected String secretToken;
+ protected Client restClient;
+
+ public NuxeoRESTClient(String baseURL) {
+ this.baseURL = baseURL;
+ }
+
+ public NuxeoRESTClient(String protocol, String serverIP, String serverPort) {
+ this(protocol, serverIP, serverPort, "nuxeo");
+ }
+
+ public NuxeoRESTClient(String protocol, String serverIP, String serverPort,
+ String servletPath) {
+ StringBuffer sb = new StringBuffer();
+ sb.append(protocol);
+ sb.append("://");
+ sb.append(serverIP);
+ if (serverPort != null && !serverIP.equals("80")) {
+ sb.append(':');
+ sb.append(serverPort);
+ }
+ sb.append(servletPath);
+ sb.append('/');
+ baseURL = sb.toString();
+ }
+
+ public void setBasicAuthentication(String userName, String password) {
+ authType = AUTH_TYPE_BASIC;
+ this.userName = userName;
+ this.password = password;
+ }
+
+ public void setSharedSecretAuthentication(String userName,
+ String secretToken) {
+ authType = AUTH_TYPE_SECRET;
+ this.userName = userName;
+ this.secretToken = secretToken;
+ }
+
+ public void setCookies(List<Cookie> cookies) {
+ this.cookies = cookies;
+ }
+
+ public Representation post(List<String> pathParams,
+ Map<String, String> queryParams, InputStream istream) {
+ String path = "";
+ StringBuffer pathBuffer = new StringBuffer();
+
+ if (pathParams != null) {
+ for (String p : pathParams) {
+ pathBuffer.append(p);
+ pathBuffer.append('/');
+ }
+ path = pathBuffer.toString();
+ }
+
+ return post(path, queryParams, istream);
+ }
+
+ public Representation post(String subPath,
+ Map<String, String> queryParams, InputStream istream) {
+ StringBuffer urlBuffer = new StringBuffer();
+
+ if (subPath.startsWith("/")) {
+ subPath = subPath.substring(1);
+ }
+ if (subPath.endsWith("/")) {
+ subPath = subPath.substring(0, subPath.length() - 1);
+ }
+
+ urlBuffer.append(baseURL);
+ urlBuffer.append('/');
+ urlBuffer.append(restPrefix);
+ urlBuffer.append('/');
+ urlBuffer.append(subPath);
+
+ if (queryParams != null) {
+ urlBuffer.append('?');
+
+ String qpValue = null;
+ for (String qpName : queryParams.keySet()) {
+ urlBuffer.append(qpName);
+ urlBuffer.append('=');
+ qpValue = queryParams.get(qpName);
+ if (qpValue != null) {
+ urlBuffer.append(qpValue.replaceAll(" ", "%20"));
+ }
+ urlBuffer.append('&');
+ }
+ }
+
+ String completeURL = urlBuffer.toString();
+ System.out.println("\nNuxeoRESTClient: calling " + completeURL);
+ Request request = new Request(Method.POST, completeURL);
+
+ setupAuth(request);
+ setupCookies(request);
+ final InputStream in = istream;
+ request.setEntity(new OutputRepresentation(
+ MediaType.MULTIPART_FORM_DATA) {
+
+ @Override
+ public void write(OutputStream outputStream) throws IOException {
+ byte[] buffer = new byte[1024 * 64];
+ int read;
+ while ((read = in.read(buffer)) != -1) {
+ outputStream.write(buffer, 0, read);
+ }
+
+ }
+ });
+
+ return getRestClient().handle(request).getEntity();
+ }
+
+ public Representation get(List<String> pathParams,
+ Map<String, String> queryParams) {
+ String path = "";
+ StringBuffer pathBuffer = new StringBuffer();
+
+ if (pathParams != null) {
+ for (String p : pathParams) {
+ pathBuffer.append(p);
+ pathBuffer.append('/');
+ }
+ path = pathBuffer.toString();
+ }
+
+ return get(path, queryParams);
+ }
+
+ public Representation get(String subPath,
+ Map<String, String> queryParams) {
+ StringBuffer urlBuffer = new StringBuffer();
+
+ if (subPath.startsWith("/")) {
+ subPath = subPath.substring(1);
+ }
+ if (subPath.endsWith("/")) {
+ subPath = subPath.substring(0, subPath.length() - 1);
+ }
+
+ urlBuffer.append(baseURL);
+ urlBuffer.append('/');
+ urlBuffer.append(restPrefix);
+ urlBuffer.append('/');
+ urlBuffer.append(subPath);
+
+ if (queryParams != null) {
+ urlBuffer.append('?');
+ for (String qpName : queryParams.keySet()) {
+ urlBuffer.append(qpName);
+ urlBuffer.append('=');
+ urlBuffer.append(queryParams.get(qpName).replaceAll(" ", "%20"));
+ urlBuffer.append('&');
+ }
+ }
+
+ String completeURL = urlBuffer.toString();
+ System.out.println("\nNuxeoRESTClient: calling " + completeURL);
+ Request request = new Request(Method.GET, completeURL);
+ setupAuth(request);
+ setupCookies(request);
+
+ return getRestClient().handle(request).getEntity();
+ }
+
+ protected void setupAuth(Request request) {
+
+ if (authType == AUTH_TYPE_BASIC) {
+ ChallengeScheme scheme = ChallengeScheme.HTTP_BASIC;
+ ChallengeResponse authentication = new ChallengeResponse(scheme,
+ userName, password);
+ request.setChallengeResponse(authentication);
+
+ } else if (authType == AUTH_TYPE_SECRET) {
+ Series<Parameter> additionnalHeaders = new Form();
+
+ Map<String, String> securityHeaders = PortalSSOAuthenticationProvider.getHeaders(
+ secretToken, userName);
+
+ for (String hn : securityHeaders.keySet()) {
+ additionnalHeaders.add(hn, securityHeaders.get(hn));
+ }
+
+ request.getAttributes().put("org.restlet.http.headers",
+ additionnalHeaders);
+ }
+ }
+
+ protected void setupCookies(Request request) {
+ if (cookies != null) {
+ request.getCookies().clear();
+ for (Cookie cookie : cookies) {
+ request.getCookies().add(cookie);
+ }
+ }
+
+ }
+
+ protected Client getRestClient() {
+ if (restClient == null) {
+ if (baseURL.startsWith("https")) {
+ restClient = new Client(Protocol.HTTPS);
+ } else {
+ restClient = new Client(Protocol.HTTP);
+ }
+ }
+
+ return restClient;
+ }
+
+ public int getAuthType() {
+ return authType;
+ }
+
+ public void setAuthType(int authType) {
+ this.authType = authType;
+ }
+
+ public String getDavPrefix() {
+ return davPrefix;
+ }
+
+ public void setDavPrefix(String davPrefix) {
+ this.davPrefix = davPrefix;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getRestPrefix() {
+ return restPrefix;
+ }
+
+ public void setRestPrefix(String restPrefix) {
+ this.restPrefix = restPrefix;
+ }
+
+ public String getSecretToken() {
+ return secretToken;
+ }
+
+ public void setSecretToken(String secretToken) {
+ this.secretToken = secretToken;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+}
--- /dev/null
+/*
+ * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Lesser General Public License
+ * (LGPL) version 2.1 which accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Contributors:
+ * Nuxeo - initial API and implementation
+ *
+ * $Id: JOOoConvertPluginImpl.java 18651 2007-05-13 20:28:53Z sfermigier $
+ */
+
+package org.collectionspace.services.nuxeo;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+import com.noelios.restlet.util.Base64;
+
+public class PortalSSOAuthenticationProvider {
+
+ private static final String TOKEN_SEP = ":";
+
+ private static final String TS_HEADER = "NX_TS";
+
+ private static final String RANDOM_HEADER = "NX_RD";
+
+ private static final String TOKEN_HEADER = "NX_TOKEN";
+
+ private static final String USER_HEADER = "NX_USER";
+
+ public static Map<String, String> getHeaders(String secretKey,
+ String userName) {
+
+ Map<String, String> headers = new HashMap<String, String>();
+
+ Date timestamp = new Date();
+ int randomData = new Random(timestamp.getTime()).nextInt();
+
+ String clearToken = timestamp.getTime() + TOKEN_SEP + randomData
+ + TOKEN_SEP + secretKey + TOKEN_SEP + userName;
+
+ byte[] hashedToken;
+
+ try {
+ hashedToken = MessageDigest.getInstance("MD5").digest(
+ clearToken.getBytes());
+ } catch (NoSuchAlgorithmException e) {
+ return null;
+ }
+
+ String base64HashedToken = Base64.encodeBytes(hashedToken);
+
+ headers.put(TS_HEADER, String.valueOf(timestamp.getTime()));
+ headers.put(RANDOM_HEADER, String.valueOf(randomData));
+ headers.put(TOKEN_HEADER, base64HashedToken);
+ headers.put(USER_HEADER, userName);
+
+ return headers;
+ }
+
+}