Index: SRUAggregator/trunk/build.sh
===================================================================
--- SRUAggregator/trunk/build.sh	(revision 6145)
+++ SRUAggregator/trunk/build.sh	(revision 6153)
@@ -6,5 +6,40 @@
 JSDIR=$ASSETDIR/js
 
-if [ ! -e bower_components ]
+RUN_BOWER=
+BUILD_JSX=1
+BUILD_JAR=
+BUILD_GO=
+RUN_JAR=
+RUN_JAR_PRODUCTION=
+
+while [[ $# > 0 ]]
+do
+key="$1"
+# echo $# " :" $key
+case $key in
+    --bower)
+    RUN_BOWER=1
+    ;;
+    --jsx)
+    BUILD_JSX=1
+    ;;
+    --jar)
+    BUILD_JAR=1
+    ;;
+    --run)
+    RUN_JAR=1
+    ;;
+    --run-production)
+    RUN_JAR_PRODUCTION=1
+    ;;
+    *)
+    echo "Unknown option:" $1
+    exit 1
+    ;;
+esac
+shift
+done
+
+if [ $RUN_BOWER ]
 then
 	mkdir -p $LIBDIR
@@ -27,17 +62,32 @@
 fi
 
-for f in $JSDIR/*.jsx; do 
-	cp -v $f $JSDIR/`basename $f .jsx`.js; 
-done
-node_modules/react-tools/bin/jsx --no-cache-dir $JSDIR $JSDIR
+if [ $BUILD_JSX ]
+then
+	echo; echo "---- jsx"
+	for f in $JSDIR/*.jsx; do
+		cp -v $f $JSDIR/`basename $f .jsx`.js;
+	done
+	node_modules/react-tools/bin/jsx --no-cache-dir $JSDIR $JSDIR
+fi
 
-if [ "$1" == "--jar" ]
+if [ $BUILD_JAR ]
 then
+	echo; echo "---- mvn clean package"
 	mvn -q clean package
 fi
 
-# Run in production:
-#java -jar target/Aggregator2-2.0.0.jar server aggregator.yml
+if [ $RUN_JAR ]
+then
+	echo; echo "---- run devel"
+	JAR=`find target -iname 'Aggregator2-*.jar'`
+	echo java -cp src/main/resources:$JAR eu.clarin.sru.fcs.aggregator.app.Aggregator server aggregator_development.yml
+	java -cp src/main/resources:$JAR eu.clarin.sru.fcs.aggregator.app.Aggregator server aggregator_development.yml
+fi
 
-# Run for development:
-# java -cp src/main/resources:target/Aggregator2-2.0.0.jar eu.clarin.sru.fcs.aggregator.app.Aggregator server aggregator_development.yml
+if [ $RUN_JAR_PRODUCTION ]
+then
+	echo; echo "---- run production"
+	JAR=`find target -iname 'Aggregator2-*.jar'`
+	echo java -jar $JAR server aggregator.yml
+	java -jar $JAR server aggregator.yml
+fi
Index: SRUAggregator/trunk/pom.xml
===================================================================
--- SRUAggregator/trunk/pom.xml	(revision 6145)
+++ SRUAggregator/trunk/pom.xml	(revision 6153)
@@ -8,5 +8,5 @@
 	<groupId>eu.clarin.sru.fcs</groupId>
 	<artifactId>aggregator</artifactId>
-	<version>2.0.0-beta-36</version>
+	<version>2.0.0-beta-39</version>
 	<name>FCS Aggregator</name>
 
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/app/Aggregator.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/app/Aggregator.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/app/Aggregator.java	(revision 6153)
@@ -68,6 +68,4 @@
  * @author edima
  *
- * TODO: update comments everywhere
- *
  * TODO: add some basic docs
  *
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/app/ErrorHandler.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/app/ErrorHandler.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/app/ErrorHandler.java	(revision 6153)
@@ -11,10 +11,19 @@
 
 /**
+ * @author edima
  *
- * @author edima
+ * The Aggregator is a single web page application, and most of the URLs are
+ * routed and handled by the javascript client, not in the server.
+ * Therefore, whenever a 404 pops up in the server, it probably means that the
+ * URL should be handled by javascript, and to do that we must return the normal
+ * index.html HTML code.
+ *
+ * Sometimes the server gets POST calls from external apps (VLO, for example).
+ * We must keep the special parameters which are sent to the Aggregator and
+ * pass them to the js client, and, again, serve the normal index.html file.
  */
 public class ErrorHandler extends org.eclipse.jetty.server.handler.ErrorHandler {
 
-	private static final org.slf4j.Logger log = LoggerFactory.getLogger(Aggregator.class);
+	private static final org.slf4j.Logger log = LoggerFactory.getLogger(ErrorHandler.class);
 
 	public static final String PARAM_QUERY = "query";
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/client/GenericClient.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/client/GenericClient.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/client/GenericClient.java	(revision 6153)
@@ -12,4 +12,8 @@
  *
  * @author edima
+ *
+ * This is a SRUThreadedClient wrapper that only allows a limited number of
+ * requests per endpoint, no matter what SRU operation the requests make.
+ * This class is an internal utility class, used by the ThrottledClient class.
  */
 class GenericClient {
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/client/ThrottledClient.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/client/ThrottledClient.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/client/ThrottledClient.java	(revision 6153)
@@ -14,4 +14,8 @@
 /**
  * @author edima
+ *
+ * This is a SRUThreadedClient wrapper that only allows a limited number of
+ * requests per endpoint, depending on the requests type. To determine the
+ * number of requests for each endpoint the user must provide a callback.
  */
 public class ThrottledClient {
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/rest/DataTransfer.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/rest/DataTransfer.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/rest/DataTransfer.java	(revision 6153)
@@ -14,4 +14,7 @@
  * @author Yana Panchenko
  * @author edima
+ *
+ * A utility class that allows moving data from the Aggregator server to some
+ * public location (currently the drop-off service).
  */
 public class DataTransfer {
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/rest/RestService.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/rest/RestService.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/rest/RestService.java	(revision 6153)
@@ -43,4 +43,6 @@
  *
  * @author edima
+ * The REST API of the Aggregator (actually, it's a HTTP API, not very restful).
+ *
  */
 @Produces(MediaType.APPLICATION_JSON)
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/Corpora.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/Corpora.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/Corpora.java	(revision 6153)
@@ -11,5 +11,6 @@
 /**
  * Implementation of the cached scan data (endpoints descriptions) that stores
- * the cache in memory in maps.
+ * the cache in memory in maps. Must be thread safe, updates in the maps are
+ * asynchronous.
  *
  * @author yanapanchenko
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/Corpus.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/Corpus.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/Corpus.java	(revision 6153)
@@ -12,5 +12,5 @@
 /**
  * Represents information about corpus resource, such as corpus handle (id),
- * institution, title, description, language(s), etc. Does not store the
+ * institution, title, description, language(s), etc. Also store the
  * information about corpus sub-corpora.
  *
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/Diagnostic.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/Diagnostic.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/Diagnostic.java	(revision 6153)
@@ -3,5 +3,5 @@
 import com.fasterxml.jackson.annotation.JsonProperty;
 
-/*
+/**
  * @author edima
  */
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/EndpointUrlFilterAllow.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/EndpointUrlFilterAllow.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/EndpointUrlFilterAllow.java	(revision 6153)
@@ -6,9 +6,7 @@
 
 /**
- * Allow takes precedence over deny; default is to include
- * everything.
- * Filters for the cache of scan data (endpoint/resources
- * descriptions) based on
- * endpoint url.
+ * Allow takes precedence over deny; default is to include everything.
+ * Filters for the cache of scan data (endpoint/resources descriptions)
+ * based on endpoint url.
  *
  * @author yanapanchenko
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/EndpointUrlFilterDeny.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/EndpointUrlFilterDeny.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/EndpointUrlFilterDeny.java	(revision 6153)
@@ -6,9 +6,7 @@
 
 /**
- * Allow takes precedence over deny; default is to include
- * everything.
- * Filters for the cache of scan data (endpoint/resources
- * descriptions) based on
- * endpoint url.
+ * Allow takes precedence over deny; default is to include everything.
+ * Filters for the cache of scan data (endpoint/resources descriptions)
+ * based on endpoint url.
  *
  * @author yanapanchenko
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/JsonException.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/JsonException.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/JsonException.java	(revision 6153)
@@ -6,4 +6,7 @@
  *
  * @author edima
+ *
+ * A Json representation of an exception in the scan/search process, to be sent
+ * to the JS client
  */
 public class JsonException {
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/ScanCrawlTask.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/ScanCrawlTask.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/ScanCrawlTask.java	(revision 6153)
@@ -14,4 +14,6 @@
  * @author yanapanchenko
  * @author edima
+ *
+ * This task is run by an executor every now and then to scan for new endpoints
  */
 public class ScanCrawlTask implements Runnable {
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/Statistics.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/Statistics.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/scan/Statistics.java	(revision 6153)
@@ -12,4 +12,7 @@
  *
  * @author edima
+ *
+ * Stores statistics information about scans or searches. The info is then sent
+ * to the JS client and displayed in the /Aggregator/stats page.
  */
 public class Statistics {
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/search/Result.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/search/Result.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/search/Result.java	(revision 6153)
@@ -25,7 +25,6 @@
 
 /**
- * Represents the results of a SRU search-retrieve operation request. It
- * contains the endpoint/corpus (if specified in the request) to which a request
- * was sent, and the corresponding SRU search-retrieve response.
+ * The results of a SRU search-retrieve operation for a particular corpus.
+ * Its content is json-serialized and sent to the JS client for display.
  *
  * @author Yana Panchenko
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/search/Search.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/search/Search.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/search/Search.java	(revision 6153)
@@ -20,5 +20,5 @@
 
 /**
- * Class representing a search operation
+ * A search operation done on a list of corpora.
  *
  * @author Yana Panchenko
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/util/CounterLatch.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/util/CounterLatch.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/util/CounterLatch.java	(revision 6153)
@@ -4,6 +4,8 @@
 
 /**
+ * @author edima
  *
- * @author edima
+ * Similar to a java CountDownLatch, but can also count up.
+ *
  */
 public class CounterLatch {
Index: SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/util/LanguagesISO693.java
===================================================================
--- SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/util/LanguagesISO693.java	(revision 6145)
+++ SRUAggregator/trunk/src/main/java/eu/clarin/sru/fcs/aggregator/util/LanguagesISO693.java	(revision 6153)
@@ -14,5 +14,5 @@
 
 /**
- * Represents collection of languages.
+ * Utility class to convert between various language codes.
  *
  * @author Yana Panchenko
@@ -28,5 +28,5 @@
 	public static class Language {
 
-		// code is ISO-639-3 (3 letters) while code_2 is ISO-639-1 (2 letters)
+		// code is ISO-639-3 (3 letters) while code_1 is ISO-639-1 (2 letters)
 		private String code_3, code_1, name;
 
Index: SRUAggregator/trunk/src/main/resources/assets/js/main.js
===================================================================
--- SRUAggregator/trunk/src/main/resources/assets/js/main.js	(revision 6145)
+++ SRUAggregator/trunk/src/main/resources/assets/js/main.js	(revision 6153)
@@ -3,5 +3,5 @@
 "use strict";
 
-var VERSION = window.MyAggregator.VERSION = "VERSION 2.0.0-beta-36";
+var VERSION = window.MyAggregator.VERSION = "VERSION 2.0.0-beta-38";
 
 var URLROOT = window.MyAggregator.URLROOT =
@@ -141,5 +141,5 @@
 				React.createElement("ul", {id: "CLARIN_header_right", className: "nav navbar-nav navbar-right"}, 
 					React.createElement("li", null, 
-						React.createElement("div", {id: "clarinservices", style: {padding:10}})
+						React.createElement("div", {id: "clarinservices", style: {padding:5}})
 					), 
 					this.renderLogin()
Index: SRUAggregator/trunk/src/main/resources/assets/js/main.jsx
===================================================================
--- SRUAggregator/trunk/src/main/resources/assets/js/main.jsx	(revision 6145)
+++ SRUAggregator/trunk/src/main/resources/assets/js/main.jsx	(revision 6153)
@@ -3,5 +3,5 @@
 "use strict";
 
-var VERSION = window.MyAggregator.VERSION = "VERSION 2.0.0-beta-36";
+var VERSION = window.MyAggregator.VERSION = "VERSION 2.0.0-beta-39";
 
 var URLROOT = window.MyAggregator.URLROOT =
Index: SRUAggregator/trunk/src/main/resources/assets/js/search.js
===================================================================
--- SRUAggregator/trunk/src/main/resources/assets/js/search.js	(revision 6145)
+++ SRUAggregator/trunk/src/main/resources/assets/js/search.js	(revision 6153)
@@ -153,5 +153,5 @@
 Corpora.prototype.setAggregationContext = function(endpoints2handles) {
 	var selectSubTree = function(select, corpus) {
-		corpus.selected = false;
+		corpus.selected = select;
 		this.recurseCorpora(corpus.subCorpora, function(c) { c.selected = corpus.selected; });
 	};
@@ -253,4 +253,9 @@
 						query: this.state.query || json.query || '',
 					});
+
+					// // for testing aggregation context
+					// json['x-aggregation-context'] = {
+					// 	'EKUT': ["http://hdl.handle.net/11858/00-1778-0000-0001-DDAF-D"]
+					// };
 
 					if (json['x-aggregation-context']) {
Index: SRUAggregator/trunk/src/main/resources/assets/js/search.jsx
===================================================================
--- SRUAggregator/trunk/src/main/resources/assets/js/search.jsx	(revision 6145)
+++ SRUAggregator/trunk/src/main/resources/assets/js/search.jsx	(revision 6153)
@@ -153,5 +153,5 @@
 Corpora.prototype.setAggregationContext = function(endpoints2handles) {
 	var selectSubTree = function(select, corpus) {
-		corpus.selected = false;
+		corpus.selected = select;
 		this.recurseCorpora(corpus.subCorpora, function(c) { c.selected = corpus.selected; });
 	};
@@ -253,4 +253,9 @@
 						query: this.state.query || json.query || '',
 					});
+
+					// // for testing aggregation context
+					// json['x-aggregation-context'] = {
+					// 	'EKUT': ["http://hdl.handle.net/11858/00-1778-0000-0001-DDAF-D"]
+					// };
 
 					if (json['x-aggregation-context']) {
