Index: MDRepository/trunk/build.props.template
===================================================================
--- MDRepository/trunk/build.props.template	(revision 3106)
+++ MDRepository/trunk/build.props.template	(revision 3106)
@@ -0,0 +1,2 @@
+user=data-upload
+pwd=pwd
Index: MDRepository/trunk/build.xml
===================================================================
--- MDRepository/trunk/build.xml	(revision 3106)
+++ MDRepository/trunk/build.xml	(revision 3106)
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="mdrepo" xmlns:xdb="http://exist-db.org/ant" >
+
+
+<!--
+two flags:
+skip.download
+skip.clean-target
+-->
+  <property name="data.dir" value="data/_current"/>
+	<property name="dataset" value="cmdi-providers" />   <!-- cmdi-providers mpi-self-harvest  olac-and-dc-providers -->
+  <property name="target.server" value="localhost:8680/exist"/>
+ 	<property name="target.path" value="http://${target.server}/rest/db/mdrepo-data"/>
+ 	<property name="target-xmldb.path" value="xmldb:exist://${target.server}/xmlrpc/db/mdrepo-data"/>
+
+	<target name="init">
+		<mkdir dir="${data.dir}" />
+		<mkdir dir="${data.dir}/logs" />		
+		<tstamp>
+            <format property="start.time" pattern="yyyy-MM-dd HH:mm:ss" />
+     </tstamp>     
+	</target>
+	
+	<target name="download" depends="init" unless="skip.download">
+		<!-- <get usetimestamp="true" src="http://catalog.clarin.eu/oai-harvester/resultsets/cmdi-providers.tar.bz2" dest="${data.dir}/cmdi-providers.tar.bz2"/>    
+				 <get usetimestamp="true" src="http://catalog.clarin.eu/oai-harvester/resultsets/mpi-self-harvest.tar.bz2" dest="${data.dir}/mpi-self-harvest.tar.bz2"/>    
+		-->		
+		<get usetimestamp="true" src="http://catalog.clarin.eu/oai-harvester/resultsets/${dataset}.tar.bz2" dest="${data.dir}/${dataset}.tar.bz2"
+			/>
+		
+	</target>
+	<!--unless="skip.download"-->
+	<target name="unzip" depends="download" unless="skip.unzip">
+	
+		<!-- <bunzip2 src="${data.dir}/${dataset}.tar.bz2" dest="${data.dir}" /> -->
+		<untar src="${data.dir}/${dataset}.tar.bz2" dest="${data.dir}/${dataset}" compression="bzip2"/>
+	</target>
+
+	<target name="upload" depends="unzip">	
+		<tstamp>
+            <format property="start-upload.time" pattern="yyyy-MM-dd HH:mm:ss" />
+     </tstamp>
+			<exec executable="./upload.sh">
+				<!-- <arg value="${data.dir}/${dataset}/results/cmdi/Academia_Sinica_Balanced_Corpus_of_Modern_Chinese/" />				 -->
+				<arg value="${data.dir}/${dataset}/results/cmdi" />				
+				<arg value="${target.path}/${dataset}" />				
+				<arg value="${user}" />				
+				<arg value="${pwd}" />				
+					 <!-- -exec curl -i -H "Accept: application/xml" -u "cr-writer:pwd" -X PUT -T \{} http://localhost/exist9/rest/db/mdrepo-data/${dataset}/\{} \; > upload.log' /> -->
+			</exec>
+			<antcall target="log-import" />
+	</target>
+
+<!-- depends="unzip, clean-target"--> 
+	<target name="upload-xdb" >	
+		
+		<!-- <antcall target="clean-target" /> -->
+		
+		<tstamp>
+            <format property="start-upload.time" pattern="yyyy-MM-dd HH:mm:ss" />
+     </tstamp>     
+			 	
+			<xdb:store xmlns:xdb="http://exist-db.org/ant"
+			    uri="${target-xmldb.path}/${dataset}"
+			    						user="${user}" password="${pwd}"
+    				createcollection="true"
+    				createsubcollections="true" >
+				    <fileset dir="${data.dir}/${dataset}/results/cmdi">         
+				    </fileset>
+			</xdb:store>
+			<antcall target="log-import" />
+	
+	</target>
+
+	
+	<target name="clean-target" unless="skip.clean-target" >		
+				<xdb:remove xmlns:xdb="http://exist-db.org/ant" user="${user}" password="${pwd}"		
+			    uri="${target-xmldb.path}"  collection="${dataset}" />
+	</target>
+	
+	<target name="clean" >
+		<delete dir="${data.dir}" />
+	</target>
+
+
+<target name="backup-raw"  >
+	<echo>TODO</echo>	 
+	
+</target>
+
+<target name="log-import"  >
+					
+     <tstamp>
+            <format property="file.time" pattern="yyyyMMdd-HHmmss-S" />
+     </tstamp>
+		 <tstamp>
+            <format property="end.time" pattern="yyyy-MM-dd HH:mm:ss" />
+     </tstamp>
+    
+     <resourcecount property="count.files">
+            <fileset dir="${data.dir}/${dataset}/results/cmdi">         
+				    </fileset>
+    </resourcecount>
+		
+    <property name="file.name" value="import-log-${dataset}-${file.time}.xml"/>
+		<property name="file.path" value="${data.dir}/logs/${file.name}"/>
+		
+		<echoxml file="${file.path}"><log dataset="${dataset}" start-time="${start.time}" 
+												start-upload-time="${start-upload.time}" end-time="${end.time}" 
+												count-files="${count.files}" />
+												
+		</echoxml> 
+    
+    <echo>uploaded files: ${count.files}</echo>
+    <echo>wrote import-log to ${file.path}</echo>
+    <echo>start-time: ${start.time}</echo>
+    <echo>end-time: ${end.time}</echo>
+    
+	<xdb:store xmlns:xdb="http://exist-db.org/ant"
+			uri="${target-xmldb.path}/logs"
+						user="${user}" password="${pwd}"
+				createcollection="true" 
+				srcfile="${file.path}"/>
+		<echo>uploaded import-log to ${target-xmldb.path}/logs/${file.name}</echo>
+		
+	</target>	
+
+
+<!--		<property name="server.dir" value="/opt/exist-code"/>-->
+			<property name="server.dir" value="C:/apps/exist-code"/>
+
+	<path id="classpath.core">
+		<fileset dir="${server.dir}/lib/core">
+		    <include name="*.jar"/>
+		</fileset>
+		<pathelement path="${server.dir}/exist.jar"/>
+		<pathelement path="${server.dir}/exist-optional.jar"/>
+	</path>
+
+	<typedef resource="org/exist/ant/antlib.xml" uri="http://exist-db.org/ant">
+		<classpath refid="classpath.core"/>
+	</typedef>
+
+</project>
Index: MDRepository/trunk/upload.sh
===================================================================
--- MDRepository/trunk/upload.sh	(revision 3106)
+++ MDRepository/trunk/upload.sh	(revision 3106)
@@ -0,0 +1,11 @@
+#!/bin/bash
+src=$1
+trg=$2
+echo source directory: $src
+echo target dir: $trg
+# count=0
+#echo ${st/mdrepo/xx}
+#find $1 -name "*.xml" | while read xml; do echo ${xml/$src/$trg};  done
+find $1 -name "*.xml" | while read srcfile; do (( count ++ )); echo $count;  curl -i -H "Accept: application/xml" -u "$3:$4" -X PUT -T $srcfile ${srcfile/$src/$trg} >> upload.log 2> /dev/null; done
+echo uploaded $count files
+#curl -i -H "Accept: application/xml" -u "data-upload:$3" -X PUT -T \{} http://localhost:8681/exist/rest/db/mdrepo-data/
Index: MDRepository/trunk/upload_all.sh
===================================================================
--- MDRepository/trunk/upload_all.sh	(revision 3106)
+++ MDRepository/trunk/upload_all.sh	(revision 3106)
@@ -0,0 +1,2 @@
+
+nohup ant upload -Ddataset=cmdi-providers &
