Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in 
+collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE[$cond$]
+return 
+	<ROW>
+		<REPO 
+			id="{\$x/../../../../HEADER/RESOURCE_IDENTIFIER/@value/string()}" 
+			name="{\$x/../../OFFICIAL_NAME/text()}" 
+			country="{\$x/../../COUNTRY/text()}" 
+			prefix="{\$x/../..//EXTRA_FIELDS/FIELD[./key='NamespacePrefix']/value}" />
+		{\$x}
+	</ROW>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,5 @@
+let \$list := collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE/$xpath$
+
+for \$x in distinct-values(\$list) 
+where string-length(\$x) > 0
+return concat(\$x, ' @-@-@ ', count(\$list[.=\$x]))
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(revision 45190)
@@ -0,0 +1,98 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+
+import com.google.common.base.Function;
+
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class ProfileToDatasourceDesc implements Function<String, DatasourceDesc> {
+
+	private static final Log log = LogFactory.getLog(ProfileToDatasourceDesc.class);
+
+	@Override
+	public DatasourceDesc apply(final String profile) {
+		try {
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+
+	public static DatasourceDesc convert(final String profile) throws Exception {
+		final SAXReader reader = new SAXReader();
+		final Document doc = reader.read(new StringReader(profile));
+
+		final DatasourceDesc ds = new DatasourceDesc();
+		ds.setId(doc.valueOf("//RESOURCE_IDENTIFIER/@value"));
+		ds.setDatasourceClass(doc.valueOf("//DATASOURCE_TYPE"));
+		ds.setTypology(doc.valueOf("//TYPOLOGY"));
+		ds.setOfficialName(doc.valueOf("//OFFICIAL_NAME"));
+		ds.setEnglishName(doc.valueOf("//ENGLISH_NAME"));
+		ds.setCountryCode(doc.valueOf("//COUNTRY"));
+		ds.setLongitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LONGITUDE"), 0.0));
+		ds.setLatitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LATITUDE"), 0.0));
+		ds.setTimezone(NumberUtils.toDouble(doc.valueOf("//LOCATION/TIMEZONE"), 0.0));
+		ds.setWebsiteUrl(doc.valueOf("//REPOSITORY_WEBPAGE"));
+		ds.setOrganization(doc.valueOf("//REPOSITORY_INSTITUTION"));
+		ds.setContactEmail(doc.valueOf("//ADMIN_INFO"));
+
+		for (Object o : doc.selectNodes("//INTERFACES/INTERFACE")) {
+			final Element n = (Element) o;
+
+			final IfaceDesc ifc = new IfaceDesc();
+
+			ifc.setId(n.valueOf("@id"));
+			ifc.setCompliance(n.valueOf("@compliance"));
+			ifc.setTypology(n.valueOf("@typology"));
+			ifc.setContentDescription(n.valueOf("@contentDescription"));
+			ifc.setActive(BooleanUtils.toBoolean(n.valueOf("@active")));
+			ifc.setRemovable(BooleanUtils.toBoolean(n.valueOf("@removable")));
+			ifc.setBaseUrl(n.valueOf("./BASE_URL"));
+			ifc.setAccessProtocol(n.valueOf("./ACCESS_PROTOCOL"));
+
+			for (Object o1 : n.selectNodes("./ACCESS_PROTOCOL/@*")) {
+				final Node attr = (Node) o1;
+				ifc.getAccessParams().put(attr.getName(), attr.getText());
+			}
+			for (Object o1 : n.selectNodes("./INTERFACE_EXTRA_FIELD")) {
+				final Node f = (Node) o1;
+				ifc.getExtraFields().put(f.valueOf("@name"), f.getText());
+			}
+
+			ds.getInterfaces().add(ifc);
+		}
+
+		final DateUtils dateUtils = new DateUtils();
+		for (Object o : doc.selectNodes("//EXTRA_FIELDS/EXTRA_FIELD")) {
+			final String k = ((Element) o).valueOf("./key").trim();
+			final String v = ((Element) o).valueOf("./value").trim();
+
+			if (k.equalsIgnoreCase("ACTIVATION_ID")) {
+				ds.setActivationId(v);
+			} else if (k.equalsIgnoreCase("NamespacePrefix")) {
+				ds.setNamespacePrefix(v);
+			} else if (k.equalsIgnoreCase("aggregatorName")) {
+				ds.setAggregator(v);
+			} else if (k.equalsIgnoreCase("dateOfCollection")) {
+				ds.setDateOfCollection(dateUtils.parse(v));
+			} else if (k.equalsIgnoreCase("dateOfValidation")) {
+				ds.setDateOfValidation(dateUtils.parse(v));
+			}
+		}
+
+		return ds;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/deploy.info
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/deploy.info	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/deploy.info	(revision 45190)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "dnet-datasource-manager-service"}
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(revision 45190)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	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://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<bean id="datasourceManagerService"
+		class="eu.dnetlib.enabling.datasources.DatasourceManagerServiceImpl" p:environment="${dnet.datasource.environment}">
+		<property name="browsableFields">
+			<list>
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="country" p:label="Datasource countries" p:xpath="../../COUNTRY/text()"
+					p:vocabulary="dnet:countries" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="type" p:label="API typologies" p:xpath="@typology/string()"
+					p:vocabulary="dnet:datasource_typologies" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="protocol" p:label="API protocols" p:xpath="ACCESS_PROTOCOL/text()"
+					p:vocabulary="dnet:protocols" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="compliance" p:label="API compatibility levels"
+					p:xpath="concat(substring(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'], 1, number(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])) * string-length(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])), substring(@compliance, 1, number(not(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']))) * string-length(@compliance)))"
+					p:vocabulary="dnet:compatibilityLevel" />
+			</list>
+		</property>
+	</bean>
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="datasourceManagerServiceEndpoint"
+		implementor="#datasourceManagerService"
+		implementorClass="eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService"
+		address="/datasourceManager" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="datasourceManagerServiceRegistrationManager" t:service="datasourceManagerService"
+		t:endpoint="datasourceManagerServiceEndpoint" t:jobScheduler="jobScheduler" />
+
+</beans>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(revision 45190)
@@ -0,0 +1,106 @@
+package eu.dnetlib.enabling.datasources;
+
+import com.google.common.base.Function;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+public class DatasourceDescToProfile implements Function<DatasourceDesc, String> {
+	private static final Log log = LogFactory.getLog(DatasourceDescToProfile.class);
+
+	public DatasourceDescToProfile(final String environment) {
+		this.environment = environment;
+	}
+
+	private String environment;
+
+	public static String convert(final DatasourceDesc ds, String environment) throws Exception {
+		final Element root = DocumentHelper.createElement("RESOURCE_PROFILE");
+
+		final Element header = root.addElement("HEADER");
+		header.addElement("RESOURCE_IDENTIFIER").addAttribute("value", "");
+		header.addElement("RESOURCE_TYPE").addAttribute("value", "RepositoryServiceResourceType");
+		header.addElement("RESOURCE_KIND").addAttribute("value", "RepositoryServiceResources");
+		header.addElement("RESOURCE_URI").addAttribute("value", "");
+		header.addElement("DATE_OF_CREATION").addAttribute("value", DateUtils.now_ISO8601());
+		header.addElement("PROTOCOL");
+
+		final Element body = root.addElement("BODY");
+		final Element conf = body.addElement("CONFIGURATION");
+		conf.addElement("DATASOURCE_TYPE").setText(ds.getDatasourceClass());
+
+		final Element origId = conf.addElement("DATASOURCE_ORIGINAL_ID");
+		origId.addAttribute("provenance", "D-NET");
+		origId.setText(ds.getId());
+
+		conf.addElement("DATASOURCE_AGGREGATED").setText("false");
+		conf.addElement("ENVIRONMENTS").addElement("ENVIRONMENT").setText(environment);
+		conf.addElement("TYPOLOGY").setText(""+ds.getTypology());
+		conf.addElement("MAX_SIZE_OF_DATASTRUCTURE").setText("0");
+		conf.addElement("AVAILABLE_DISKSPACE").setText("0");
+		conf.addElement("MAX_NUMBER_OF_DATASTRUCTURE").setText("0");
+
+		final String officialName = ds.getOfficialName();
+		conf.addElement("OFFICIAL_NAME").setText(officialName);
+		String englishName = ds.getEnglishName();
+		conf.addElement("ENGLISH_NAME").setText(StringUtils.isNotBlank(englishName) ? englishName : officialName);
+		conf.addElement("ICON_URI").setText(""+ds.getLogoUrl());
+		conf.addElement("COUNTRY").setText(ds.getCountryCode());
+
+		final Element location = conf.addElement("LOCATION");
+		location.addElement("LONGITUDE").setText("" + ds.getLongitude());
+		location.addElement("LATITUDE").setText("" + ds.getLatitude());
+		location.addElement("TIMEZONE").setText("" + ds.getTimezone());
+
+		conf.addElement("REPOSITORY_WEBPAGE").setText(ds.getWebsiteUrl());
+		conf.addElement("REPOSITORY_INSTITUTION").setText(ds.getOrganization());
+		conf.addElement("ADMIN_INFO").setText(ds.getContactEmail());
+
+		final Element ifaces = conf.addElement("INTERFACES");
+		for (IfaceDesc ifc : ds.getInterfaces()) {
+			ifaces.add(IfaceDescToNode.convert(ifc));
+		}
+		final Element extraFields = conf.addElement("EXTRA_FIELDS");
+		addExtraField(extraFields, "ACTIVATION_ID", ds.getActivationId());
+		addExtraField(extraFields, "NamespacePrefix", ds.getNamespacePrefix());
+		addExtraField(extraFields, "aggregatorName", ds.getAggregator());
+		addExtraField(extraFields, "dateOfCollection", "" + ds.getDateOfCollection());
+		addExtraField(extraFields, "dateOfValidation", "" + ds.getDateOfValidation());
+		conf.addElement("REGISTERED_BY");
+
+		final Element status = body.addElement("STATUS");
+		status.addElement("NUMBER_OF_OBJECTS").setText("0");
+		status.addElement("LAST_UPDATE").addAttribute("value", DateUtils.now_ISO8601());
+
+		final Element qos = body.addElement("QOS");
+		qos.addElement("AVAILABILITY").setText("0");
+		qos.addElement("CAPACITY");
+		qos.addElement("THROUGHPUT").setText("0");
+
+		body.addElement("SECURITY_PARAMETERS");
+		body.addElement("BLACKBOARD");
+
+		return root.asXML();
+	}
+
+	private static void addExtraField(final Element extraFields, final String field, final String value) {
+		final Element f = extraFields.addElement("FIELD");
+		f.addElement("key").setText(field);
+		f.addElement("value").setText(value != null ? value : "");
+	}
+
+	@Override
+	public String apply(final DatasourceDesc ds) {
+		try {
+			return DatasourceDescToProfile.convert(ds, environment);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in 
+collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE[$cond$]
+return 
+	<ROW>
+		<REPO 
+			id="{\$x/../../../../HEADER/RESOURCE_IDENTIFIER/@value/string()}" 
+			name="{\$x/../../OFFICIAL_NAME/text()}" 
+			country="{\$x/../../COUNTRY/text()}" 
+			prefix="{\$x/../..//EXTRA_FIELDS/FIELD[./key='NamespacePrefix']/value}" />
+		{\$x}
+	</ROW>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.util.Map.Entry;
+
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+
+public class IfaceDescToNode {
+
+	public static Element convert(final IfaceDesc iface) throws Exception {
+
+		final Element ifcNode = DocumentHelper.createElement("INTERFACE");
+		ifcNode.addAttribute("id", iface.getId());
+		ifcNode.addAttribute("label", iface.getTypology() + " (" + iface.getCompliance() + ")");
+		ifcNode.addAttribute("compliance", iface.getCompliance());
+		ifcNode.addAttribute("typology", iface.getTypology());
+		ifcNode.addAttribute("contentDescription", iface.getContentDescription());
+		ifcNode.addAttribute("active", Boolean.toString(iface.getActive()));
+		ifcNode.addAttribute("removable", Boolean.toString(iface.getRemovable()));
+
+		final Element acProtoNode = ifcNode.addElement("ACCESS_PROTOCOL");
+
+		for (Entry<String, String> e : iface.getAccessParams().entrySet()) {
+			acProtoNode.addAttribute(e.getKey(), e.getValue());
+		}
+		acProtoNode.setText(iface.getAccessProtocol());
+
+		ifcNode.addElement("BASE_URL").setText(iface.getBaseUrl());
+
+		for (Entry<String, String> e : iface.getExtraFields().entrySet()) {
+			final Element field = ifcNode.addElement("INTERFACE_EXTRA_FIELD");
+			field.addAttribute("name", e.getKey());
+			field.setText(e.getValue());
+		}
+
+		return ifcNode;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/deploy.info
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/deploy.info	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/deploy.info	(revision 45190)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "dnet-datasource-manager-service"}
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.properties
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.properties	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.properties	(revision 45190)
@@ -0,0 +1 @@
+dnet.datasource.environment = D-Net
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(revision 45190)
@@ -0,0 +1,11 @@
+for $x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where 
+	$x//NUMBER_OF_OBJECTS != 0 and not($x//LATITUDE = 0 and $x//LONGITUDE = 0) 
+return 
+<ds>
+	<dsId>{$x//RESOURCE_IDENTIFIER/@value/string()}</dsId>
+	<name>{$x//OFFICIAL_NAME/text()}</name>
+	<lat>{$x//LATITUDE/text()}</lat>
+	<lng>{$x//LONGITUDE/text()}</lng>
+</ds>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/trunk/pom.xml
===================================================================
--- modules/dnet-datasource-manager-service/trunk/pom.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/pom.xml	(revision 45190)
@@ -0,0 +1,34 @@
+<?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>
+    		<groupId>eu.dnetlib</groupId>
+	        <artifactId>dnet-parent</artifactId>
+                <version>1.0.0</version>
+  	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-datasource-manager-service</artifactId>
+	<packaging>jar</packaging>
+	<version>1.0.7-SNAPSHOT</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/trunk</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-datasource-manager-rmi</artifactId>
+			<version>[4.0.0, 5.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-service-common</artifactId>
+			<version>[2.1.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+  		    <groupId>junit</groupId>
+    		    <artifactId>junit</artifactId>
+      		    <version>${junit.version}</version>
+	            <scope>test</scope>
+    		</dependency>
+	</dependencies>
+</project>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/.springBeans
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/.springBeans	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/.springBeans	(revision 45190)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+	<version>1</version>
+	<pluginVersion><![CDATA[3.6.2.201410090854-RELEASE]]></pluginVersion>
+	<configSuffixes>
+		<configSuffix><![CDATA[xml]]></configSuffix>
+	</configSuffixes>
+	<enableImports><![CDATA[false]]></enableImports>
+	<configs>
+		<config>src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml</config>
+	</configs>
+	<autoconfigs>
+	</autoconfigs>
+	<configSets>
+	</configSets>
+</beansProjectDescription>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(revision 45190)
@@ -0,0 +1,103 @@
+package eu.dnetlib.enabling.datasources;
+
+import com.google.common.base.Function;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+public class DatasourceDescToProfile implements Function<DatasourceDesc, String> {
+	private static final Log log = LogFactory.getLog(DatasourceDescToProfile.class);
+
+	public DatasourceDescToProfile(final String environment) {
+		this.environment = environment;
+	}
+
+	private String environment;
+
+	public static String convert(final DatasourceDesc ds, String environment) throws Exception {
+		final Element root = DocumentHelper.createElement("RESOURCE_PROFILE");
+
+		final Element header = root.addElement("HEADER");
+		header.addElement("RESOURCE_IDENTIFIER").addAttribute("value", "");
+		header.addElement("RESOURCE_TYPE").addAttribute("value", "RepositoryServiceResourceType");
+		header.addElement("RESOURCE_KIND").addAttribute("value", "RepositoryServiceResources");
+		header.addElement("RESOURCE_URI").addAttribute("value", "");
+		header.addElement("DATE_OF_CREATION").addAttribute("value", DateUtils.now_ISO8601());
+		header.addElement("PROTOCOL");
+
+		final Element body = root.addElement("BODY");
+		final Element conf = body.addElement("CONFIGURATION");
+		conf.addElement("DATASOURCE_TYPE").setText(ds.getDatasourceClass());
+
+		final Element origId = conf.addElement("DATASOURCE_ORIGINAL_ID");
+		origId.addAttribute("provenance", "D-NET");
+		origId.setText(ds.getId());
+
+		conf.addElement("DATASOURCE_AGGREGATED").setText("false");
+		conf.addElement("ENVIRONMENTS").addElement("ENVIRONMENT").setText(environment);
+		conf.addElement("TYPOLOGY").setText(ds.getTypology());
+		conf.addElement("MAX_SIZE_OF_DATASTRUCTURE").setText("0");
+		conf.addElement("AVAILABLE_DISKSPACE").setText("0");
+		conf.addElement("MAX_NUMBER_OF_DATASTRUCTURE").setText("0");
+
+		conf.addElement("OFFICIAL_NAME").setText(ds.getOfficialName());
+		conf.addElement("ENGLISH_NAME").setText(ds.getEnglishName());
+		conf.addElement("ICON_URI").setText(ds.getLogoUrl());
+		conf.addElement("COUNTRY").setText(ds.getCountryCode());
+
+		final Element location = conf.addElement("LOCATION");
+		location.addElement("LONGITUDE").setText("" + ds.getLongitude());
+		location.addElement("LATITUDE").setText("" + ds.getLatitude());
+		location.addElement("TIMEZONE").setText("" + ds.getTimezone());
+
+		conf.addElement("REPOSITORY_WEBPAGE").setText(ds.getWebsiteUrl());
+		conf.addElement("REPOSITORY_INSTITUTION").setText(ds.getOrganization());
+		conf.addElement("ADMIN_INFO").setText(ds.getContactEmail());
+
+		final Element ifaces = conf.addElement("INTERFACES");
+		for (IfaceDesc ifc : ds.getInterfaces()) {
+			ifaces.add(IfaceDescToNode.convert(ifc));
+		}
+		final Element extraFields = conf.addElement("EXTRA_FIELDS");
+		addExtraField(extraFields, "ACTIVATION_ID", ds.getActivationId());
+		addExtraField(extraFields, "NamespacePrefix", ds.getNamespacePrefix());
+		addExtraField(extraFields, "aggregatorName", ds.getAggregator());
+		addExtraField(extraFields, "dateOfCollection", "" + ds.getDateOfCollection());
+		addExtraField(extraFields, "dateOfValidation", "" + ds.getDateOfValidation());
+		conf.addElement("REGISTERED_BY");
+
+		final Element status = body.addElement("STATUS");
+		status.addElement("NUMBER_OF_OBJECTS").setText("0");
+		status.addElement("LAST_UPDATE").addAttribute("value", DateUtils.now_ISO8601());
+
+		final Element qos = body.addElement("QOS");
+		qos.addElement("AVAILABILITY").setText("0");
+		qos.addElement("CAPACITY");
+		qos.addElement("THROUGHPUT").setText("0");
+
+		body.addElement("SECURITY_PARAMETERS");
+		body.addElement("BLACKBOARD");
+
+		return root.asXML();
+	}
+
+	private static void addExtraField(final Element extraFields, final String field, final String value) {
+		final Element f = extraFields.addElement("FIELD");
+		f.addElement("key").setText(field);
+		f.addElement("value").setText(value != null ? value : "");
+	}
+
+	@Override
+	public String apply(final DatasourceDesc ds) {
+		try {
+			return DatasourceDescToProfile.convert(ds, environment);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(revision 45190)
@@ -0,0 +1,12 @@
+for \$x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ true'),
+for \$x in
+	collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ false')
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.properties
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.properties	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.properties	(revision 45190)
@@ -0,0 +1 @@
+dnet.datasource.environment = D-Net
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/pom.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/pom.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/pom.xml	(revision 45190)
@@ -0,0 +1,34 @@
+<?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>
+    		<groupId>eu.dnetlib</groupId>
+	        <artifactId>dnet-parent</artifactId>
+                <version>1.0.0</version>
+  	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-datasource-manager-service</artifactId>
+	<packaging>jar</packaging>
+	<version>1.0.4</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-datasource-manager-rmi</artifactId>
+			<version>[4.0.0, 5.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-service-common</artifactId>
+			<version>[2.1.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+  		    <groupId>junit</groupId>
+    		    <artifactId>junit</artifactId>
+      		    <version>${junit.version}</version>
+	            <scope>test</scope>
+    		</dependency>
+	</dependencies>
+</project>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in 
+collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE[$cond$]
+return 
+	<ROW>
+		<REPO 
+			id="{\$x/../../../../HEADER/RESOURCE_IDENTIFIER/@value/string()}" 
+			name="{\$x/../../OFFICIAL_NAME/text()}" 
+			country="{\$x/../../COUNTRY/text()}" 
+			prefix="{\$x/../..//EXTRA_FIELDS/FIELD[./key='NamespacePrefix']/value}" />
+		{\$x}
+	</ROW>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(revision 45190)
@@ -0,0 +1,98 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+
+import com.google.common.base.Function;
+
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class ProfileToDatasourceDesc implements Function<String, DatasourceDesc> {
+
+	private static final Log log = LogFactory.getLog(ProfileToDatasourceDesc.class);
+
+	@Override
+	public DatasourceDesc apply(final String profile) {
+		try {
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+
+	public static DatasourceDesc convert(final String profile) throws Exception {
+		final SAXReader reader = new SAXReader();
+		final Document doc = reader.read(new StringReader(profile));
+
+		final DatasourceDesc ds = new DatasourceDesc();
+		ds.setId(doc.valueOf("//RESOURCE_IDENTIFIER/@value"));
+		ds.setDatasourceClass(doc.valueOf("//DATASOURCE_TYPE"));
+		ds.setTypology(doc.valueOf("//TYPOLOGY"));
+		ds.setOfficialName(doc.valueOf("//OFFICIAL_NAME"));
+		ds.setEnglishName(doc.valueOf("//ENGLISH_NAME"));
+		ds.setCountryCode(doc.valueOf("//COUNTRY"));
+		ds.setLongitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LONGITUDE"), 0.0));
+		ds.setLatitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LATITUDE"), 0.0));
+		ds.setTimezone(NumberUtils.toDouble(doc.valueOf("//LOCATION/TIMEZONE"), 0.0));
+		ds.setWebsiteUrl(doc.valueOf("//REPOSITORY_WEBPAGE"));
+		ds.setOrganization(doc.valueOf("//REPOSITORY_INSTITUTION"));
+		ds.setContactEmail(doc.valueOf("//ADMIN_INFO"));
+
+		for (Object o : doc.selectNodes("//INTERFACES/INTERFACE")) {
+			final Element n = (Element) o;
+
+			final IfaceDesc ifc = new IfaceDesc();
+
+			ifc.setId(n.valueOf("@id"));
+			ifc.setCompliance(n.valueOf("@compliance"));
+			ifc.setTypology(n.valueOf("@typology"));
+			ifc.setContentDescription(n.valueOf("@contentDescription"));
+			ifc.setActive(BooleanUtils.toBoolean(n.valueOf("@active")));
+			ifc.setRemovable(BooleanUtils.toBoolean(n.valueOf("@removable")));
+			ifc.setBaseUrl(n.valueOf("./BASE_URL"));
+			ifc.setAccessProtocol(n.valueOf("./ACCESS_PROTOCOL"));
+
+			for (Object o1 : n.selectNodes("./ACCESS_PROTOCOL/@*")) {
+				final Node attr = (Node) o1;
+				ifc.getAccessParams().put(attr.getName(), attr.getText());
+			}
+			for (Object o1 : n.selectNodes("./INTERFACE_EXTRA_FIELD")) {
+				final Node f = (Node) o1;
+				ifc.getExtraFields().put(f.valueOf("@name"), f.getText());
+			}
+
+			ds.getInterfaces().add(ifc);
+		}
+
+		final DateUtils dateUtils = new DateUtils();
+		for (Object o : doc.selectNodes("//EXTRA_FIELDS/EXTRA_FIELD")) {
+			final String k = ((Element) o).valueOf("./key").trim();
+			final String v = ((Element) o).valueOf("./value").trim();
+
+			if (k.equalsIgnoreCase("ACTIVATION_ID")) {
+				ds.setActivationId(v);
+			} else if (k.equalsIgnoreCase("NamespacePrefix")) {
+				ds.setNamespacePrefix(v);
+			} else if (k.equalsIgnoreCase("aggregatorName")) {
+				ds.setAggregator(v);
+			} else if (k.equalsIgnoreCase("dateOfCollection")) {
+				ds.setDateOfCollection(dateUtils.parse(v));
+			} else if (k.equalsIgnoreCase("dateOfValidation")) {
+				ds.setDateOfValidation(dateUtils.parse(v));
+			}
+		}
+
+		return ds;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
+,
+for \$x in collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/deploy.info
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/deploy.info	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/deploy.info	(revision 45190)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "dnet-datasource-manager-service"}
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,5 @@
+let \$list := collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE/$xpath$
+
+for \$x in distinct-values(\$list) 
+where string-length(\$x) > 0
+return concat(\$x, ' @-@-@ ', count(\$list[.=\$x]))
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.util.Map.Entry;
+
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+
+public class IfaceDescToNode {
+
+	public static Element convert(final IfaceDesc iface) throws Exception {
+
+		final Element ifcNode = DocumentHelper.createElement("INTERFACE");
+		ifcNode.addAttribute("id", iface.getId());
+		ifcNode.addAttribute("label", iface.getTypology() + " (" + iface.getCompliance() + ")");
+		ifcNode.addAttribute("compliance", iface.getCompliance());
+		ifcNode.addAttribute("typology", iface.getTypology());
+		ifcNode.addAttribute("contentDescription", iface.getContentDescription());
+		ifcNode.addAttribute("active", Boolean.toString(iface.getActive()));
+		ifcNode.addAttribute("removable", Boolean.toString(iface.getRemovable()));
+
+		final Element acProtoNode = ifcNode.addElement("ACCESS_PROTOCOL");
+
+		for (Entry<String, String> e : iface.getAccessParams().entrySet()) {
+			acProtoNode.addAttribute(e.getKey(), e.getValue());
+		}
+		acProtoNode.setText(iface.getAccessProtocol());
+
+		ifcNode.addElement("BASE_URL").setText(iface.getBaseUrl());
+
+		for (Entry<String, String> e : iface.getExtraFields().entrySet()) {
+			final Element field = ifcNode.addElement("INTERFACE_EXTRA_FIELD");
+			field.addAttribute("name", e.getKey());
+			field.setText(e.getValue());
+		}
+
+		return ifcNode;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(revision 45190)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	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://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<bean id="datasourceManagerService"
+		class="eu.dnetlib.enabling.datasources.DatasourceManagerServiceImpl" p:environment="${dnet.datasource.environment}">
+		<property name="browsableFields">
+			<list>
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="country" p:label="Datasource countries" p:xpath="../../COUNTRY/text()"
+					p:vocabulary="dnet:countries" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="type" p:label="API typologies" p:xpath="@typology/string()"
+					p:vocabulary="dnet:datasource_typologies" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="protocol" p:label="API protocols" p:xpath="ACCESS_PROTOCOL/text()"
+					p:vocabulary="dnet:protocols" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="compliance" p:label="API compatibility levels"
+					p:xpath="concat(substring(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'], 1, number(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])) * string-length(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])), substring(@compliance, 1, number(not(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']))) * string-length(@compliance)))"
+					p:vocabulary="dnet:compatibilityLevel" />
+			</list>
+		</property>
+	</bean>
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="datasourceManagerServiceEndpoint"
+		implementor="#datasourceManagerService"
+		implementorClass="eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService"
+		address="/datasourceManager" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="datasourceManagerServiceRegistrationManager" t:service="datasourceManagerService"
+		t:endpoint="datasourceManagerServiceEndpoint" t:jobScheduler="jobScheduler" />
+
+</beans>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.util.Map.Entry;
+
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+
+public class IfaceDescToNode {
+
+	public static Element convert(final IfaceDesc iface) throws Exception {
+
+		final Element ifcNode = DocumentHelper.createElement("INTERFACE");
+		ifcNode.addAttribute("id", iface.getId());
+		ifcNode.addAttribute("label", iface.getTypology() + " (" + iface.getCompliance() + ")");
+		ifcNode.addAttribute("compliance", iface.getCompliance());
+		ifcNode.addAttribute("typology", iface.getTypology());
+		ifcNode.addAttribute("contentDescription", iface.getContentDescription());
+		ifcNode.addAttribute("active", Boolean.toString(iface.getActive()));
+		ifcNode.addAttribute("removable", Boolean.toString(iface.getRemovable()));
+
+		final Element acProtoNode = ifcNode.addElement("ACCESS_PROTOCOL");
+
+		for (Entry<String, String> e : iface.getAccessParams().entrySet()) {
+			acProtoNode.addAttribute(e.getKey(), e.getValue());
+		}
+		acProtoNode.setText(iface.getAccessProtocol());
+
+		ifcNode.addElement("BASE_URL").setText(iface.getBaseUrl());
+
+		for (Entry<String, String> e : iface.getExtraFields().entrySet()) {
+			final Element field = ifcNode.addElement("INTERFACE_EXTRA_FIELD");
+			field.addAttribute("name", e.getKey());
+			field.setText(e.getValue());
+		}
+
+		return ifcNode;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(revision 45190)
@@ -0,0 +1,12 @@
+for \$x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ true'),
+for \$x in
+	collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ false')
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+
+public class XmlBrowsableField extends BrowsableField {
+
+	private String xpath;
+	private String vocabulary;
+
+	public XmlBrowsableField() {
+		super();
+	}
+
+	public XmlBrowsableField(final String id, final String label) {
+		super(id, label);
+	}
+
+	public XmlBrowsableField(final String id, final String label, final String xpath, final String vocabulary) {
+		super(id, label);
+		this.xpath = xpath;
+		this.vocabulary = vocabulary;
+	}
+
+	public String getXpath() {
+		return xpath;
+	}
+
+	public void setXpath(final String xpath) {
+		this.xpath = xpath;
+	}
+
+	public String getVocabulary() {
+		return vocabulary;
+	}
+
+	public void setVocabulary(final String vocabulary) {
+		this.vocabulary = vocabulary;
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/pom.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/pom.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/pom.xml	(revision 45190)
@@ -0,0 +1,34 @@
+<?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>
+    		<groupId>eu.dnetlib</groupId>
+	        <artifactId>dnet-parent</artifactId>
+                <version>1.0.0</version>
+  	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-datasource-manager-service</artifactId>
+	<packaging>jar</packaging>
+	<version>1.0.3</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-datasource-manager-rmi</artifactId>
+			<version>[4.0.0, 5.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-service-common</artifactId>
+			<version>[2.1.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+  		    <groupId>junit</groupId>
+    		    <artifactId>junit</artifactId>
+      		    <version>${junit.version}</version>
+	            <scope>test</scope>
+    		</dependency>
+	</dependencies>
+</project>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(revision 45190)
@@ -0,0 +1,12 @@
+for \$x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ true'),
+for \$x in
+	collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ false')
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(revision 45190)
@@ -0,0 +1,98 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+
+import com.google.common.base.Function;
+
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class ProfileToDatasourceDesc implements Function<String, DatasourceDesc> {
+
+	private static final Log log = LogFactory.getLog(ProfileToDatasourceDesc.class);
+
+	@Override
+	public DatasourceDesc apply(final String profile) {
+		try {
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+
+	public static DatasourceDesc convert(final String profile) throws Exception {
+		final SAXReader reader = new SAXReader();
+		final Document doc = reader.read(new StringReader(profile));
+
+		final DatasourceDesc ds = new DatasourceDesc();
+		ds.setId(doc.valueOf("//RESOURCE_IDENTIFIER/@value"));
+		ds.setDatasourceClass(doc.valueOf("//DATASOURCE_TYPE"));
+		ds.setTypology(doc.valueOf("//TYPOLOGY"));
+		ds.setOfficialName(doc.valueOf("//OFFICIAL_NAME"));
+		ds.setEnglishName(doc.valueOf("//ENGLISH_NAME"));
+		ds.setCountryCode(doc.valueOf("//COUNTRY"));
+		ds.setLongitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LONGITUDE"), 0.0));
+		ds.setLatitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LATITUDE"), 0.0));
+		ds.setTimezone(NumberUtils.toDouble(doc.valueOf("//LOCATION/TIMEZONE"), 0.0));
+		ds.setWebsiteUrl(doc.valueOf("//REPOSITORY_WEBPAGE"));
+		ds.setOrganization(doc.valueOf("//REPOSITORY_INSTITUTION"));
+		ds.setContactEmail(doc.valueOf("//ADMIN_INFO"));
+
+		for (Object o : doc.selectNodes("//INTERFACES/INTERFACE")) {
+			final Element n = (Element) o;
+
+			final IfaceDesc ifc = new IfaceDesc();
+
+			ifc.setId(n.valueOf("@id"));
+			ifc.setCompliance(n.valueOf("@compliance"));
+			ifc.setTypology(n.valueOf("@typology"));
+			ifc.setContentDescription(n.valueOf("@contentDescription"));
+			ifc.setActive(BooleanUtils.toBoolean(n.valueOf("@active")));
+			ifc.setRemovable(BooleanUtils.toBoolean(n.valueOf("@removable")));
+			ifc.setBaseUrl(n.valueOf("./BASE_URL"));
+			ifc.setAccessProtocol(n.valueOf("./ACCESS_PROTOCOL"));
+
+			for (Object o1 : n.selectNodes("./ACCESS_PROTOCOL/@*")) {
+				final Node attr = (Node) o1;
+				ifc.getAccessParams().put(attr.getName(), attr.getText());
+			}
+			for (Object o1 : n.selectNodes("./INTERFACE_EXTRA_FIELD")) {
+				final Node f = (Node) o1;
+				ifc.getExtraFields().put(f.valueOf("@name"), f.getText());
+			}
+
+			ds.getInterfaces().add(ifc);
+		}
+
+		final DateUtils dateUtils = new DateUtils();
+		for (Object o : doc.selectNodes("//EXTRA_FIELDS/EXTRA_FIELD")) {
+			final String k = ((Element) o).valueOf("./key").trim();
+			final String v = ((Element) o).valueOf("./value").trim();
+
+			if (k.equalsIgnoreCase("ACTIVATION_ID")) {
+				ds.setActivationId(v);
+			} else if (k.equalsIgnoreCase("NamespacePrefix")) {
+				ds.setNamespacePrefix(v);
+			} else if (k.equalsIgnoreCase("aggregatorName")) {
+				ds.setAggregator(v);
+			} else if (k.equalsIgnoreCase("dateOfCollection")) {
+				ds.setDateOfCollection(dateUtils.parse(v));
+			} else if (k.equalsIgnoreCase("dateOfValidation")) {
+				ds.setDateOfValidation(dateUtils.parse(v));
+			}
+		}
+
+		return ds;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in 
+collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE[$cond$]
+return 
+	<ROW>
+		<REPO 
+			id="{\$x/../../../../HEADER/RESOURCE_IDENTIFIER/@value/string()}" 
+			name="{\$x/../../OFFICIAL_NAME/text()}" 
+			country="{\$x/../../COUNTRY/text()}" 
+			prefix="{\$x/../..//EXTRA_FIELDS/FIELD[./key='NamespacePrefix']/value}" />
+		{\$x}
+	</ROW>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(revision 45190)
@@ -0,0 +1,725 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+import java.text.ParseException;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+import org.quartz.CronExpression;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.core.io.ClassPathResource;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+import eu.dnetlib.enabling.datasources.rmi.BrowseTerm;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceConstants;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerServiceException;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.enabling.datasources.rmi.RepositoryMapEntry;
+import eu.dnetlib.enabling.datasources.rmi.SearchInterfacesEntry;
+import eu.dnetlib.enabling.datasources.rmi.SimpleDatasourceDesc;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+
+public class DatasourceManagerServiceImpl extends AbstractBaseService implements DatasourceManagerService {
+
+	private static final Log log = LogFactory.getLog(DatasourceManagerServiceImpl.class);
+
+	private static final String REPOSITORY_RESOURCE_TYPE = "RepositoryServiceResourceType";
+
+	private List<XmlBrowsableField> browsableFields;
+
+	private ClassPathResource findReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st");
+
+	private ClassPathResource browseRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st");
+	private ClassPathResource findRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st");
+	private ClassPathResource findReposMapQuery = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery");
+	private ClassPathResource simpleFindReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st");
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	private String fixDsId(final String dsId) throws DatasourceManagerServiceException {
+		if (dsId.endsWith("_UGVuZGluZ1JlcG9zaXRvcnlSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=")
+				|| dsId.endsWith("_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=")) {
+			return dsId;
+		} else {
+			try {
+				return serviceLocator
+						.getService(ISLookUpService.class)
+						.getResourceProfileByQuery(
+								"for $x in collection("
+										+ "'/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType',"
+										+ "'/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType') "
+										+ "where $x//DATASOURCE_ORIGINAL_ID = '" + dsId + "' "
+										+ "return $x//RESOURCE_IDENTIFIER/@value/string()");
+			} catch (Exception e) {
+				throw new DatasourceManagerServiceException("Invalid id: " + dsId, e);
+			}
+		}
+	}
+
+	@Override
+	public boolean addDatasource(final DatasourceDesc ds) throws DatasourceManagerServiceException {
+		try {
+			final String profile = DatasourceDescToProfile.convert(ds);
+			serviceLocator.getService(ISRegistryService.class).registerProfile(profile);
+			return true;
+		} catch (Exception e) {
+			log.error("Error registering profile", e);
+			throw new DatasourceManagerServiceException("Error registering profile", e);
+		}
+	}
+
+	@Override
+	public boolean deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		return _deleteDatasource(fixDsId(dsId));
+	}
+
+	private boolean _deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class).deleteProfile(dsId);
+		} catch (ISRegistryException e) {
+			log.error("Error deleting profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error deleting profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public DatasourceDesc getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		return _getDatasource(fixDsId(dsId));
+	}
+
+	private DatasourceDesc _getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error accessing profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error accessing profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public List<DatasourceDesc> listAllDatasources() throws DatasourceManagerServiceException {
+		return listDatasourcesUsingFilter(null, null, null, null);
+	}
+
+	@Override
+	public List<DatasourceDesc> listDatasourcesUsingFilter(final String compliance,
+			final String contentDescription,
+			final String iisProcessingWorkflow,
+			final String collectedFrom)
+			throws DatasourceManagerServiceException {
+		try {
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findReposQueryTmpl.getInputStream()));
+
+			final Map<String, String> conds = Maps.newHashMap();
+
+			if (StringUtils.isNotBlank(compliance)) {
+				conds.put("//INTERFACE/@compliance", compliance);
+			}
+			if (StringUtils.isNotBlank(contentDescription)) {
+				conds.put("//INTERFACE/@contentDescription", contentDescription);
+			}
+			if (StringUtils.isNotBlank(iisProcessingWorkflow)) {
+				// NOT USED
+			}
+			if (StringUtils.isNotBlank(collectedFrom)) {
+				// NOT USED
+			}
+
+			if (!conds.isEmpty()) {
+				st.setAttribute("conds", conds);
+			}
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString());
+
+			return Lists.transform(list, new ProfileToDatasourceDesc());
+		} catch (Exception e) {
+			log.error("Error listing datasources", e);
+			throw new DatasourceManagerServiceException("Error listing datasources", e);
+		}
+	}
+
+	@Override
+	public boolean updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		return _updateLevelOfCompliance(fixDsId(dsId), ifaceId, level);
+	}
+
+	private boolean _updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@compliance", "'" + level + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		return _updateBaseUrl(fixDsId(dsId), ifaceId, baseUrl);
+	}
+
+	private boolean _updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/BASE_URL", "<BASE_URL>" + baseUrl + "</BASE_URL>");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		return _updateActivationStatus(fixDsId(dsId), ifaceId, active);
+	}
+
+	private boolean _updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@active", "'" + active + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		return _updateContentDescription(fixDsId(dsId), ifaceId, desc);
+	}
+
+	private boolean _updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@contentDescription", "'" + desc + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean setIisProcessingWorkflow(final String dsId, final String ifaceId, final String wf) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public boolean updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		return _updateExtraField(fixDsId(dsId), ifaceId, field, value, preserveOriginal);
+	}
+
+	private boolean _updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			final Node node = ifcNode.selectSingleNode("./INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (node != null) {
+				node.setText(value);
+			} else {
+				final Element e = ((Element) ifcNode).addElement("INTERFACE_EXTRA_FIELD");
+				e.addAttribute("name", field);
+				e.setText(value);
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		return _updateAccessParam(fixDsId(dsId), ifaceId, field, value, preserveOriginal);
+	}
+
+	private boolean _updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL");
+			((Element) node).addAttribute(field, value);
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		return _deleteAccessParamOrExtraField(fixDsId(dsId), ifaceId, field);
+	}
+
+	private boolean _deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ef = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (ef != null) {
+				ef.detach();
+			}
+			final Node ap = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL/@" + field);
+			if (ap != null) {
+				ap.detach();
+
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		return _addInterface(fixDsId(dsId), iface);
+	}
+
+	private boolean _addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + iface.getId() + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			((Element) doc.selectSingleNode("//INTERFACES")).add(IfaceDescToNode.convert(iface));
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		return _deleteInterface(fixDsId(dsId), ifaceId);
+	}
+
+	private boolean _deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateSQL(final String dsId, final String sql, final boolean delete) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public Date findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		return _findNextScheduledExecution(fixDsId(dsId), ifaceId);
+	}
+
+	private Date _findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		final String xquery = "/*[.//DATAPROVIDER/@interface='" + ifaceId + "' and .//SCHEDULING/@enabled='true']//CRON/text()";
+		try {
+			final String cronExpression = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
+			final CronExpression cron = new CronExpression(cronExpression);
+			return cron.getNextValidTimeAfter(new Date());
+		} catch (ISLookUpDocumentNotFoundException e) {
+			// When the value is not found a null value must be returned
+			return null;
+		} catch (ISLookUpException e) {
+			log.error("Error in xquery: " + xquery, e);
+			throw new DatasourceManagerServiceException("Error in xquery: " + xquery, e);
+		} catch (ParseException e) {
+			log.error("Error parsing cron expression", e);
+			throw new DatasourceManagerServiceException("Error parsing cron expression", e);
+		}
+	}
+
+	@Override
+	public boolean bulkUpdateApiExtraFields(final String repoId, final String ifaceId, final Map<String, String> fields)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					iface.selectSingleNode("./INTERFACE_EXTRA_FIELD").detach();
+				}
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+
+	}
+
+	@Override
+	public boolean bulkUpdateApiAccessParams(final String dsId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		return _bulkUpdateApiAccessParams(fixDsId(dsId), ifaceId, params);
+	}
+
+	private boolean _bulkUpdateApiAccessParams(final String repoId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element accessNode = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/ACCESS_PROTOCOL");
+			if (accessNode != null) {
+				while (accessNode.attributes().size() > 0) {
+					accessNode.selectSingleNode("@*").detach();
+				}
+				for (Map.Entry<String, String> e : params.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						if (e.getKey().equalsIgnoreCase("baseUrl")) {
+							doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/BASE_URL").setText(e.getValue());
+						} else {
+							accessNode.addAttribute(e.getKey(), e.getValue());
+						}
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+	}
+
+	@Override
+	public boolean overrideCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		return _overrideCompliance(fixDsId(dsId), ifaceId, level);
+	}
+
+	private boolean _overrideCompliance(final String repoId, final String ifaceId, final String compliance) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+				final Map<String, String> fields = Maps.newHashMap();
+
+				if (!StringUtils.isEmpty(compliance)) {
+					fields.put(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD, compliance);
+				}
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					final Node node = iface.selectSingleNode("./INTERFACE_EXTRA_FIELD");
+					final String name = node.valueOf("@name");
+
+					if (!name.equals(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD)) {
+						fields.put(node.valueOf("@name"), node.getText());
+					}
+					node.detach();
+				}
+
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+
+		return true;
+	}
+
+	@Override
+	public List<BrowsableField> listBrowsableFields() throws DatasourceManagerServiceException {
+		return Lists.transform(getBrowsableFields(), new Function<XmlBrowsableField, BrowsableField>() {
+
+			@Override
+			public BrowsableField apply(final XmlBrowsableField f) {
+				return new BrowsableField(f.getId(), f.getLabel());
+			}
+		});
+	}
+
+	@Override
+	public List<BrowseTerm> browseField(final String f) throws DatasourceManagerServiceException {
+
+		final List<BrowseTerm> list = Lists.newArrayList();
+
+		try {
+			final XmlBrowsableField field = findBrowseField(f);
+			if (field != null) {
+				final StringTemplate st = new StringTemplate(IOUtils.toString(browseRepoApisQueryTmpl.getInputStream()));
+				st.setAttribute("xpath", field.getXpath());
+
+				final Map<String, String> terms = fetchVocabularyTerms(field.getVocabulary());
+
+				for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+					final String[] arr = s.split("@-@-@");
+					final String id = arr[0].trim();
+					final int count = NumberUtils.toInt(arr[1].trim(), 0);
+					list.add(new BrowseTerm(id, findLabel(id, terms), count));
+				}
+			}
+		} catch (Exception e) {
+			log.error("Error browsing field " + f, e);
+		}
+
+		return list;
+	}
+
+	private String findLabel(final String code, final Map<String, String> terms) {
+		return terms.containsKey(code) ? terms.get(code) : code;
+	}
+
+	public Map<String, String> fetchVocabularyTerms(final String voc) throws ISLookUpException {
+		final String xquery = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code = '"
+				+ voc.trim() + "']//TERM return concat($x/@code, ' @@@ ', $x/@english_name)";
+
+		final Map<String, String> map = Maps.newHashMap();
+		for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery)) {
+			final String[] arr = s.split("@@@");
+			map.put(arr[0].trim(), arr[1].trim());
+		}
+		return map;
+	}
+
+	private XmlBrowsableField findBrowseField(final String id) {
+		for (XmlBrowsableField f : getBrowsableFields()) {
+			if (f.getId().equals(id)) { return f; }
+		}
+		return null;
+	}
+
+	@Override
+	public List<SearchInterfacesEntry> searchInterface(final String field, final String value) throws DatasourceManagerServiceException {
+		try {
+
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findRepoApisQueryTmpl.getInputStream()));
+
+			if (field.equalsIgnoreCase("__search__")) {
+				st.setAttribute("cond", "contains(../..//(*|@*)/lower-case(.), '" + StringEscapeUtils.escapeXml(value.toLowerCase()) + "')");
+			} else {
+				final XmlBrowsableField f = findBrowseField(field);
+				if (f != null) {
+					st.setAttribute("cond", f.getXpath() + "='" + StringEscapeUtils.escapeXml(value) + "'");
+				} else {
+					return Lists.newArrayList();
+				}
+			}
+
+			final String query = st.toString();
+
+			final SAXReader reader = new SAXReader();
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+
+			return Lists.transform(list, new Function<String, SearchInterfacesEntry>() {
+
+				@Override
+				public SearchInterfacesEntry apply(final String s) {
+					final SearchInterfacesEntry iface = new SearchInterfacesEntry();
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						final String country = doc.valueOf("//REPO/@country");
+
+						iface.setRepoId(doc.valueOf("//REPO/@id"));
+						iface.setRepoCountry(StringUtils.isEmpty(country) ? "-" : country.toUpperCase());
+						iface.setRepoName(doc.valueOf("//REPO/@name"));
+						iface.setRepoPrefix(doc.valueOf("//REPO/@prefix"));
+
+						final Node ifcNode = doc.selectSingleNode("//INTERFACE");
+
+						iface.setId(ifcNode.valueOf("./@id"));
+						iface.setActive(Boolean.valueOf(ifcNode.valueOf("./@active")));
+						iface.setProtocol(ifcNode.valueOf("./ACCESS_PROTOCOL/text()"));
+
+						final String overCompliance = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']");
+						if (StringUtils.isEmpty(overCompliance)) {
+							iface.setCompliance(ifcNode.valueOf("@compliance"));
+						} else {
+							iface.setCompliance(overCompliance);
+						}
+
+						final String lastAggregationDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_date']");
+						if (!StringUtils.isEmpty(lastAggregationDate)) {
+							iface.setAggrDate(lastAggregationDate);
+						} else {
+							final String lastDownloadDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_date']");
+							if (!StringUtils.isEmpty(lastDownloadDate)) {
+								iface.setAggrDate(lastDownloadDate);
+							}
+						}
+						final String lastAggregationTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_total']");
+						if (StringUtils.isEmpty(lastAggregationTotal)) {
+							final String lastDownloadTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_total']");
+							if (StringUtils.isEmpty(lastDownloadTotal)) {
+								iface.setAggrTotal(0);
+							} else {
+								iface.setAggrTotal(NumberUtils.toInt(lastDownloadTotal, 0));
+							}
+						} else {
+							iface.setAggrTotal(NumberUtils.toInt(lastAggregationTotal, 0));
+						}
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return iface;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error searching field " + field + " - value: " + value, e);
+		}
+		return Lists.newArrayList();
+	}
+
+	@Override
+	public List<RepositoryMapEntry> getRepositoryMap() throws DatasourceManagerServiceException {
+		try {
+			final SAXReader reader = new SAXReader();
+
+			final String query = IOUtils.toString(findReposMapQuery.getInputStream());
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+			return Lists.transform(list, new Function<String, RepositoryMapEntry>() {
+
+				@Override
+				public RepositoryMapEntry apply(final String s) {
+					final RepositoryMapEntry r = new RepositoryMapEntry();
+
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						r.setId(doc.valueOf("//dsId"));
+						r.setName(doc.valueOf("//name"));
+						r.setLat(Float.parseFloat(doc.valueOf("//lat")));
+						r.setLng(Float.parseFloat(doc.valueOf("//lng")));
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return r;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error obtaing repo map entries", e);
+		}
+		return Lists.newArrayList();
+	}
+
+	private List<XmlBrowsableField> getBrowsableFields() {
+		return browsableFields;
+	}
+
+	@Required
+	public void setBrowsableFields(final List<XmlBrowsableField> browsableFields) {
+		this.browsableFields = browsableFields;
+	}
+
+	@Override
+	public List<SimpleDatasourceDesc> simpleListDatasourcesByType(final String type) throws DatasourceManagerServiceException {
+		try {
+			final List<SimpleDatasourceDesc> list = Lists.newArrayList();
+
+			final StringTemplate st = new StringTemplate(IOUtils.toString(simpleFindReposQueryTmpl.getInputStream()));
+			st.setAttribute("type", type);
+
+			for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+				final SimpleDatasourceDesc r = new SimpleDatasourceDesc();
+				final String[] arr = s.split("@=@");
+				r.setId(arr[0].trim());
+				r.setName(arr[1].trim());
+				r.setOrigId(arr[2].trim());
+				r.setApis(Sets.newHashSet(arr[3].replaceAll("\\s", "").split(",")));
+				r.setValid("true".equals(arr[4].trim()));
+				r.setTypology(type);
+				list.add(r);
+			}
+
+			Collections.sort(list);
+
+			return list;
+		} catch (Exception e) {
+			log.error("Error listing repos", e);
+		}
+		return Lists.newArrayList();
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(revision 45190)
@@ -0,0 +1,11 @@
+for $x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where 
+	$x//NUMBER_OF_OBJECTS != 0 and not($x//LATITUDE = 0 and $x//LONGITUDE = 0) 
+return 
+<ds>
+	<dsId>{$x//RESOURCE_IDENTIFIER/@value/string()}</dsId>
+	<name>{$x//OFFICIAL_NAME/text()}</name>
+	<lat>{$x//LATITUDE/text()}</lat>
+	<lng>{$x//LONGITUDE/text()}</lng>
+</ds>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java
===================================================================
--- modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(revision 45190)
@@ -0,0 +1,737 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+import java.text.ParseException;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+import org.quartz.CronExpression;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.core.io.ClassPathResource;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+import eu.dnetlib.enabling.datasources.rmi.BrowseTerm;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceConstants;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerServiceException;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.enabling.datasources.rmi.RepositoryMapEntry;
+import eu.dnetlib.enabling.datasources.rmi.SearchInterfacesEntry;
+import eu.dnetlib.enabling.datasources.rmi.SimpleDatasourceDesc;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+
+public class DatasourceManagerServiceImpl extends AbstractBaseService implements DatasourceManagerService {
+
+	private static final Log log = LogFactory.getLog(DatasourceManagerServiceImpl.class);
+
+	private static final String REPOSITORY_RESOURCE_TYPE = "RepositoryServiceResourceType";
+
+	private List<XmlBrowsableField> browsableFields;
+
+	private ClassPathResource findReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st");
+
+	private ClassPathResource browseRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st");
+	private ClassPathResource findRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st");
+	private ClassPathResource findReposMapQuery = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery");
+	private ClassPathResource simpleFindReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st");
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	private String environment;
+
+	private String fixDsId(final String dsId) throws DatasourceManagerServiceException {
+		if (dsId.endsWith("_UGVuZGluZ1JlcG9zaXRvcnlSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=")
+				|| dsId.endsWith("_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=")) {
+			return dsId;
+		} else {
+			try {
+				return serviceLocator
+						.getService(ISLookUpService.class)
+						.getResourceProfileByQuery(
+								"for $x in collection("
+										+ "'/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType',"
+										+ "'/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType') "
+										+ "where $x//DATASOURCE_ORIGINAL_ID = '" + dsId + "' "
+										+ "return $x//RESOURCE_IDENTIFIER/@value/string()");
+			} catch (Exception e) {
+				throw new DatasourceManagerServiceException("Invalid id: " + dsId, e);
+			}
+		}
+	}
+
+	@Override
+	public boolean addDatasource(final DatasourceDesc ds) throws DatasourceManagerServiceException {
+		try {
+			final String profile = DatasourceDescToProfile.convert(ds, environment);
+			serviceLocator.getService(ISRegistryService.class).registerProfile(profile);
+			return true;
+		} catch (Exception e) {
+			log.error("Error registering profile", e);
+			throw new DatasourceManagerServiceException("Error registering profile", e);
+		}
+	}
+
+	@Override
+	public boolean deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		return _deleteDatasource(fixDsId(dsId));
+	}
+
+	private boolean _deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class).deleteProfile(dsId);
+		} catch (ISRegistryException e) {
+			log.error("Error deleting profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error deleting profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public DatasourceDesc getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		return _getDatasource(fixDsId(dsId));
+	}
+
+	private DatasourceDesc _getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error accessing profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error accessing profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public List<DatasourceDesc> listAllDatasources() throws DatasourceManagerServiceException {
+		return listDatasourcesUsingFilter(null, null, null, null);
+	}
+
+	@Override
+	public List<DatasourceDesc> listDatasourcesUsingFilter(final String compliance,
+			final String contentDescription,
+			final String iisProcessingWorkflow,
+			final String collectedFrom)
+			throws DatasourceManagerServiceException {
+		try {
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findReposQueryTmpl.getInputStream()));
+
+			final Map<String, String> conds = Maps.newHashMap();
+
+			if (StringUtils.isNotBlank(compliance)) {
+				conds.put("//INTERFACE/@compliance", compliance);
+			}
+			if (StringUtils.isNotBlank(contentDescription)) {
+				conds.put("//INTERFACE/@contentDescription", contentDescription);
+			}
+			if (StringUtils.isNotBlank(iisProcessingWorkflow)) {
+				// NOT USED
+			}
+			if (StringUtils.isNotBlank(collectedFrom)) {
+				// NOT USED
+			}
+
+			if (!conds.isEmpty()) {
+				st.setAttribute("conds", conds);
+			}
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString());
+
+			return Lists.transform(list, new ProfileToDatasourceDesc());
+		} catch (Exception e) {
+			log.error("Error listing datasources", e);
+			throw new DatasourceManagerServiceException("Error listing datasources", e);
+		}
+	}
+
+	@Override
+	public boolean updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		return _updateLevelOfCompliance(fixDsId(dsId), ifaceId, level);
+	}
+
+	private boolean _updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@compliance", "'" + level + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		return _updateBaseUrl(fixDsId(dsId), ifaceId, baseUrl);
+	}
+
+	private boolean _updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/BASE_URL", "<BASE_URL>" + baseUrl + "</BASE_URL>");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		return _updateActivationStatus(fixDsId(dsId), ifaceId, active);
+	}
+
+	private boolean _updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@active", "'" + active + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		return _updateContentDescription(fixDsId(dsId), ifaceId, desc);
+	}
+
+	private boolean _updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@contentDescription", "'" + desc + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean setIisProcessingWorkflow(final String dsId, final String ifaceId, final String wf) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public boolean updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		return _updateExtraField(fixDsId(dsId), ifaceId, field, value, preserveOriginal);
+	}
+
+	private boolean _updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			final Node node = ifcNode.selectSingleNode("./INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (node != null) {
+				node.setText(value);
+			} else {
+				final Element e = ((Element) ifcNode).addElement("INTERFACE_EXTRA_FIELD");
+				e.addAttribute("name", field);
+				e.setText(value);
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		return _updateAccessParam(fixDsId(dsId), ifaceId, field, value, preserveOriginal);
+	}
+
+	private boolean _updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL");
+			((Element) node).addAttribute(field, value);
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		return _deleteAccessParamOrExtraField(fixDsId(dsId), ifaceId, field);
+	}
+
+	private boolean _deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ef = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (ef != null) {
+				ef.detach();
+			}
+			final Node ap = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL/@" + field);
+			if (ap != null) {
+				ap.detach();
+
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		iface.setRemovable(true);
+		return _addInterface(fixDsId(dsId), iface);
+	}
+
+	private boolean _addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + iface.getId() + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			((Element) doc.selectSingleNode("//INTERFACES")).add(IfaceDescToNode.convert(iface));
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		return _deleteInterface(fixDsId(dsId), ifaceId);
+	}
+
+	private boolean _deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateSQL(final String dsId, final String sql, final boolean delete) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public Date findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		return _findNextScheduledExecution(fixDsId(dsId), ifaceId);
+	}
+
+	private Date _findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		final String xquery = "/*[.//DATAPROVIDER/@interface='" + ifaceId + "' and .//SCHEDULING/@enabled='true']//CRON/text()";
+		try {
+			final String cronExpression = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
+			final CronExpression cron = new CronExpression(cronExpression);
+			return cron.getNextValidTimeAfter(new Date());
+		} catch (ISLookUpDocumentNotFoundException e) {
+			// When the value is not found a null value must be returned
+			return null;
+		} catch (ISLookUpException e) {
+			log.error("Error in xquery: " + xquery, e);
+			throw new DatasourceManagerServiceException("Error in xquery: " + xquery, e);
+		} catch (ParseException e) {
+			log.error("Error parsing cron expression", e);
+			throw new DatasourceManagerServiceException("Error parsing cron expression", e);
+		}
+	}
+
+	@Override
+	public boolean bulkUpdateApiExtraFields(final String repoId, final String ifaceId, final Map<String, String> fields)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					iface.selectSingleNode("./INTERFACE_EXTRA_FIELD").detach();
+				}
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+
+	}
+
+	@Override
+	public boolean bulkUpdateApiAccessParams(final String dsId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		return _bulkUpdateApiAccessParams(fixDsId(dsId), ifaceId, params);
+	}
+
+	private boolean _bulkUpdateApiAccessParams(final String repoId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element accessNode = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/ACCESS_PROTOCOL");
+			if (accessNode != null) {
+				while (accessNode.attributes().size() > 0) {
+					accessNode.selectSingleNode("@*").detach();
+				}
+				for (Map.Entry<String, String> e : params.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						if (e.getKey().equalsIgnoreCase("baseUrl")) {
+							doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/BASE_URL").setText(e.getValue());
+						} else {
+							accessNode.addAttribute(e.getKey(), e.getValue());
+						}
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+	}
+
+	@Override
+	public boolean overrideCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		return _overrideCompliance(fixDsId(dsId), ifaceId, level);
+	}
+
+	private boolean _overrideCompliance(final String repoId, final String ifaceId, final String compliance) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+				final Map<String, String> fields = Maps.newHashMap();
+
+				if (!StringUtils.isEmpty(compliance)) {
+					fields.put(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD, compliance);
+				}
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					final Node node = iface.selectSingleNode("./INTERFACE_EXTRA_FIELD");
+					final String name = node.valueOf("@name");
+
+					if (!name.equals(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD)) {
+						fields.put(node.valueOf("@name"), node.getText());
+					}
+					node.detach();
+				}
+
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+
+		return true;
+	}
+
+	@Override
+	public List<BrowsableField> listBrowsableFields() throws DatasourceManagerServiceException {
+		return Lists.transform(getBrowsableFields(), new Function<XmlBrowsableField, BrowsableField>() {
+
+			@Override
+			public BrowsableField apply(final XmlBrowsableField f) {
+				return new BrowsableField(f.getId(), f.getLabel());
+			}
+		});
+	}
+
+	@Override
+	public List<BrowseTerm> browseField(final String f) throws DatasourceManagerServiceException {
+
+		final List<BrowseTerm> list = Lists.newArrayList();
+
+		try {
+			final XmlBrowsableField field = findBrowseField(f);
+			if (field != null) {
+				final StringTemplate st = new StringTemplate(IOUtils.toString(browseRepoApisQueryTmpl.getInputStream()));
+				st.setAttribute("xpath", field.getXpath());
+
+				final Map<String, String> terms = fetchVocabularyTerms(field.getVocabulary());
+
+				for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+					final String[] arr = s.split("@-@-@");
+					final String id = arr[0].trim();
+					final int count = NumberUtils.toInt(arr[1].trim(), 0);
+					list.add(new BrowseTerm(id, findLabel(id, terms), count));
+				}
+			}
+		} catch (Exception e) {
+			log.error("Error browsing field " + f, e);
+		}
+
+		return list;
+	}
+
+	private String findLabel(final String code, final Map<String, String> terms) {
+		return terms.containsKey(code) ? terms.get(code) : code;
+	}
+
+	public Map<String, String> fetchVocabularyTerms(final String voc) throws ISLookUpException {
+		final String xquery = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code = '"
+				+ voc.trim() + "']//TERM return concat($x/@code, ' @@@ ', $x/@english_name)";
+
+		final Map<String, String> map = Maps.newHashMap();
+		for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery)) {
+			final String[] arr = s.split("@@@");
+			map.put(arr[0].trim(), arr[1].trim());
+		}
+		return map;
+	}
+
+	private XmlBrowsableField findBrowseField(final String id) {
+		for (XmlBrowsableField f : getBrowsableFields()) {
+			if (f.getId().equals(id)) { return f; }
+		}
+		return null;
+	}
+
+	@Override
+	public List<SearchInterfacesEntry> searchInterface(final String field, final String value) throws DatasourceManagerServiceException {
+		try {
+
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findRepoApisQueryTmpl.getInputStream()));
+
+			if (field.equalsIgnoreCase("__search__")) {
+				st.setAttribute("cond", "contains(../..//(*|@*)/lower-case(.), '" + StringEscapeUtils.escapeXml(value.toLowerCase()) + "')");
+			} else {
+				final XmlBrowsableField f = findBrowseField(field);
+				if (f != null) {
+					st.setAttribute("cond", f.getXpath() + "='" + StringEscapeUtils.escapeXml(value) + "'");
+				} else {
+					return Lists.newArrayList();
+				}
+			}
+
+			final String query = st.toString();
+
+			final SAXReader reader = new SAXReader();
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+
+			return Lists.transform(list, new Function<String, SearchInterfacesEntry>() {
+
+				@Override
+				public SearchInterfacesEntry apply(final String s) {
+					final SearchInterfacesEntry iface = new SearchInterfacesEntry();
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						final String country = doc.valueOf("//REPO/@country");
+
+						iface.setRepoId(doc.valueOf("//REPO/@id"));
+						iface.setRepoCountry(StringUtils.isEmpty(country) ? "-" : country.toUpperCase());
+						iface.setRepoName(doc.valueOf("//REPO/@name"));
+						iface.setRepoPrefix(doc.valueOf("//REPO/@prefix"));
+
+						final Node ifcNode = doc.selectSingleNode("//INTERFACE");
+
+						iface.setId(ifcNode.valueOf("./@id"));
+						iface.setActive(Boolean.valueOf(ifcNode.valueOf("./@active")));
+						iface.setProtocol(ifcNode.valueOf("./ACCESS_PROTOCOL/text()"));
+
+						final String overCompliance = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']");
+						if (StringUtils.isEmpty(overCompliance)) {
+							iface.setCompliance(ifcNode.valueOf("@compliance"));
+						} else {
+							iface.setCompliance(overCompliance);
+						}
+
+						final String lastAggregationDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_date']");
+						if (!StringUtils.isEmpty(lastAggregationDate)) {
+							iface.setAggrDate(lastAggregationDate);
+						} else {
+							final String lastDownloadDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_date']");
+							if (!StringUtils.isEmpty(lastDownloadDate)) {
+								iface.setAggrDate(lastDownloadDate);
+							}
+						}
+						final String lastAggregationTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_total']");
+						if (StringUtils.isEmpty(lastAggregationTotal)) {
+							final String lastDownloadTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_total']");
+							if (StringUtils.isEmpty(lastDownloadTotal)) {
+								iface.setAggrTotal(0);
+							} else {
+								iface.setAggrTotal(NumberUtils.toInt(lastDownloadTotal, 0));
+							}
+						} else {
+							iface.setAggrTotal(NumberUtils.toInt(lastAggregationTotal, 0));
+						}
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return iface;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error searching field " + field + " - value: " + value, e);
+		}
+		return Lists.newArrayList();
+	}
+
+	@Override
+	public List<RepositoryMapEntry> getRepositoryMap() throws DatasourceManagerServiceException {
+		try {
+			final SAXReader reader = new SAXReader();
+
+			final String query = IOUtils.toString(findReposMapQuery.getInputStream());
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+			return Lists.transform(list, new Function<String, RepositoryMapEntry>() {
+
+				@Override
+				public RepositoryMapEntry apply(final String s) {
+					final RepositoryMapEntry r = new RepositoryMapEntry();
+
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						r.setId(doc.valueOf("//dsId"));
+						r.setName(doc.valueOf("//name"));
+						r.setLat(Float.parseFloat(doc.valueOf("//lat")));
+						r.setLng(Float.parseFloat(doc.valueOf("//lng")));
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return r;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error obtaing repo map entries", e);
+		}
+		return Lists.newArrayList();
+	}
+
+	private List<XmlBrowsableField> getBrowsableFields() {
+		return browsableFields;
+	}
+
+	@Required
+	public void setBrowsableFields(final List<XmlBrowsableField> browsableFields) {
+		this.browsableFields = browsableFields;
+	}
+
+	@Override
+	public List<SimpleDatasourceDesc> simpleListDatasourcesByType(final String type) throws DatasourceManagerServiceException {
+		try {
+			final List<SimpleDatasourceDesc> list = Lists.newArrayList();
+
+			final StringTemplate st = new StringTemplate(IOUtils.toString(simpleFindReposQueryTmpl.getInputStream()));
+			st.setAttribute("type", type);
+
+			for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+				final SimpleDatasourceDesc r = new SimpleDatasourceDesc();
+				final String[] arr = s.split("@=@");
+				r.setId(arr[0].trim());
+				r.setName(arr[1].trim());
+				r.setOrigId(arr[2].trim());
+				r.setApis(Sets.newHashSet(arr[3].replaceAll("\\s", "").split(",")));
+				r.setValid("true".equals(arr[4].trim()));
+				r.setTypology(type);
+				list.add(r);
+			}
+
+			Collections.sort(list);
+
+			return list;
+		} catch (Exception e) {
+			log.error("Error listing repos", e);
+		}
+		return Lists.newArrayList();
+	}
+
+	public String getEnvironment() {
+		return environment;
+	}
+
+	@Required
+	public void setEnvironment(final String environment) {
+		this.environment = environment;
+	}
+
+}
Index: modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java
===================================================================
--- modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(revision 45190)
@@ -0,0 +1,106 @@
+package eu.dnetlib.enabling.datasources;
+
+import com.google.common.base.Function;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+public class DatasourceDescToProfile implements Function<DatasourceDesc, String> {
+	private static final Log log = LogFactory.getLog(DatasourceDescToProfile.class);
+
+	public DatasourceDescToProfile(final String environment) {
+		this.environment = environment;
+	}
+
+	private String environment;
+
+	public static String convert(final DatasourceDesc ds, String environment) throws Exception {
+		final Element root = DocumentHelper.createElement("RESOURCE_PROFILE");
+
+		final Element header = root.addElement("HEADER");
+		header.addElement("RESOURCE_IDENTIFIER").addAttribute("value", "");
+		header.addElement("RESOURCE_TYPE").addAttribute("value", "RepositoryServiceResourceType");
+		header.addElement("RESOURCE_KIND").addAttribute("value", "RepositoryServiceResources");
+		header.addElement("RESOURCE_URI").addAttribute("value", "");
+		header.addElement("DATE_OF_CREATION").addAttribute("value", DateUtils.now_ISO8601());
+		header.addElement("PROTOCOL");
+
+		final Element body = root.addElement("BODY");
+		final Element conf = body.addElement("CONFIGURATION");
+		conf.addElement("DATASOURCE_TYPE").setText(ds.getDatasourceClass());
+
+		final Element origId = conf.addElement("DATASOURCE_ORIGINAL_ID");
+		origId.addAttribute("provenance", "D-NET");
+		origId.setText(ds.getId());
+
+		conf.addElement("DATASOURCE_AGGREGATED").setText("false");
+		conf.addElement("ENVIRONMENTS").addElement("ENVIRONMENT").setText(environment);
+		conf.addElement("TYPOLOGY").setText(""+ds.getTypology());
+		conf.addElement("MAX_SIZE_OF_DATASTRUCTURE").setText("0");
+		conf.addElement("AVAILABLE_DISKSPACE").setText("0");
+		conf.addElement("MAX_NUMBER_OF_DATASTRUCTURE").setText("0");
+
+		final String officialName = ds.getOfficialName();
+		conf.addElement("OFFICIAL_NAME").setText(officialName);
+		String englishName = ds.getEnglishName();
+		conf.addElement("ENGLISH_NAME").setText(StringUtils.isNotBlank(englishName) ? englishName : officialName);
+		conf.addElement("ICON_URI").setText(""+ds.getLogoUrl());
+		conf.addElement("COUNTRY").setText(ds.getCountryCode());
+
+		final Element location = conf.addElement("LOCATION");
+		location.addElement("LONGITUDE").setText("" + ds.getLongitude());
+		location.addElement("LATITUDE").setText("" + ds.getLatitude());
+		location.addElement("TIMEZONE").setText("" + ds.getTimezone());
+
+		conf.addElement("REPOSITORY_WEBPAGE").setText(ds.getWebsiteUrl());
+		conf.addElement("REPOSITORY_INSTITUTION").setText(ds.getOrganization());
+		conf.addElement("ADMIN_INFO").setText(ds.getContactEmail());
+
+		final Element ifaces = conf.addElement("INTERFACES");
+		for (IfaceDesc ifc : ds.getInterfaces()) {
+			ifaces.add(IfaceDescToNode.convert(ifc));
+		}
+		final Element extraFields = conf.addElement("EXTRA_FIELDS");
+		addExtraField(extraFields, "ACTIVATION_ID", ds.getActivationId());
+		addExtraField(extraFields, "NamespacePrefix", ds.getNamespacePrefix());
+		addExtraField(extraFields, "aggregatorName", ds.getAggregator());
+		addExtraField(extraFields, "dateOfCollection", "" + ds.getDateOfCollection());
+		addExtraField(extraFields, "dateOfValidation", "" + ds.getDateOfValidation());
+		conf.addElement("REGISTERED_BY");
+
+		final Element status = body.addElement("STATUS");
+		status.addElement("NUMBER_OF_OBJECTS").setText("0");
+		status.addElement("LAST_UPDATE").addAttribute("value", DateUtils.now_ISO8601());
+
+		final Element qos = body.addElement("QOS");
+		qos.addElement("AVAILABILITY").setText("0");
+		qos.addElement("CAPACITY");
+		qos.addElement("THROUGHPUT").setText("0");
+
+		body.addElement("SECURITY_PARAMETERS");
+		body.addElement("BLACKBOARD");
+
+		return root.asXML();
+	}
+
+	private static void addExtraField(final Element extraFields, final String field, final String value) {
+		final Element f = extraFields.addElement("FIELD");
+		f.addElement("key").setText(field);
+		f.addElement("value").setText(value != null ? value : "");
+	}
+
+	@Override
+	public String apply(final DatasourceDesc ds) {
+		try {
+			return DatasourceDescToProfile.convert(ds, environment);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+}
Index: modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java
===================================================================
--- modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.util.Map.Entry;
+
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+
+public class IfaceDescToNode {
+
+	public static Element convert(final IfaceDesc iface) throws Exception {
+
+		final Element ifcNode = DocumentHelper.createElement("INTERFACE");
+		ifcNode.addAttribute("id", iface.getId());
+		ifcNode.addAttribute("label", iface.getTypology() + " (" + iface.getCompliance() + ")");
+		ifcNode.addAttribute("compliance", iface.getCompliance());
+		ifcNode.addAttribute("typology", iface.getTypology());
+		ifcNode.addAttribute("contentDescription", iface.getContentDescription());
+		ifcNode.addAttribute("active", Boolean.toString(iface.getActive()));
+		ifcNode.addAttribute("removable", Boolean.toString(iface.getRemovable()));
+
+		final Element acProtoNode = ifcNode.addElement("ACCESS_PROTOCOL");
+
+		for (Entry<String, String> e : iface.getAccessParams().entrySet()) {
+			acProtoNode.addAttribute(e.getKey(), e.getValue());
+		}
+		acProtoNode.setText(iface.getAccessProtocol());
+
+		ifcNode.addElement("BASE_URL").setText(iface.getBaseUrl());
+
+		for (Entry<String, String> e : iface.getExtraFields().entrySet()) {
+			final Element field = ifcNode.addElement("INTERFACE_EXTRA_FIELD");
+			field.addAttribute("name", e.getKey());
+			field.setText(e.getValue());
+		}
+
+		return ifcNode;
+	}
+}
Index: modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java
===================================================================
--- modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(revision 45190)
@@ -0,0 +1,98 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+
+import com.google.common.base.Function;
+
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class ProfileToDatasourceDesc implements Function<String, DatasourceDesc> {
+
+	private static final Log log = LogFactory.getLog(ProfileToDatasourceDesc.class);
+
+	@Override
+	public DatasourceDesc apply(final String profile) {
+		try {
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+
+	public static DatasourceDesc convert(final String profile) throws Exception {
+		final SAXReader reader = new SAXReader();
+		final Document doc = reader.read(new StringReader(profile));
+
+		final DatasourceDesc ds = new DatasourceDesc();
+		ds.setId(doc.valueOf("//RESOURCE_IDENTIFIER/@value"));
+		ds.setDatasourceClass(doc.valueOf("//DATASOURCE_TYPE"));
+		ds.setTypology(doc.valueOf("//TYPOLOGY"));
+		ds.setOfficialName(doc.valueOf("//OFFICIAL_NAME"));
+		ds.setEnglishName(doc.valueOf("//ENGLISH_NAME"));
+		ds.setCountryCode(doc.valueOf("//COUNTRY"));
+		ds.setLongitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LONGITUDE"), 0.0));
+		ds.setLatitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LATITUDE"), 0.0));
+		ds.setTimezone(NumberUtils.toDouble(doc.valueOf("//LOCATION/TIMEZONE"), 0.0));
+		ds.setWebsiteUrl(doc.valueOf("//REPOSITORY_WEBPAGE"));
+		ds.setOrganization(doc.valueOf("//REPOSITORY_INSTITUTION"));
+		ds.setContactEmail(doc.valueOf("//ADMIN_INFO"));
+
+		for (Object o : doc.selectNodes("//INTERFACES/INTERFACE")) {
+			final Element n = (Element) o;
+
+			final IfaceDesc ifc = new IfaceDesc();
+
+			ifc.setId(n.valueOf("@id"));
+			ifc.setCompliance(n.valueOf("@compliance"));
+			ifc.setTypology(n.valueOf("@typology"));
+			ifc.setContentDescription(n.valueOf("@contentDescription"));
+			ifc.setActive(BooleanUtils.toBoolean(n.valueOf("@active")));
+			ifc.setRemovable(BooleanUtils.toBoolean(n.valueOf("@removable")));
+			ifc.setBaseUrl(n.valueOf("./BASE_URL"));
+			ifc.setAccessProtocol(n.valueOf("./ACCESS_PROTOCOL"));
+
+			for (Object o1 : n.selectNodes("./ACCESS_PROTOCOL/@*")) {
+				final Node attr = (Node) o1;
+				ifc.getAccessParams().put(attr.getName(), attr.getText());
+			}
+			for (Object o1 : n.selectNodes("./INTERFACE_EXTRA_FIELD")) {
+				final Node f = (Node) o1;
+				ifc.getExtraFields().put(f.valueOf("@name"), f.getText());
+			}
+
+			ds.getInterfaces().add(ifc);
+		}
+
+		final DateUtils dateUtils = new DateUtils();
+		for (Object o : doc.selectNodes("//EXTRA_FIELDS/EXTRA_FIELD")) {
+			final String k = ((Element) o).valueOf("./key").trim();
+			final String v = ((Element) o).valueOf("./value").trim();
+
+			if (k.equalsIgnoreCase("ACTIVATION_ID")) {
+				ds.setActivationId(v);
+			} else if (k.equalsIgnoreCase("NamespacePrefix")) {
+				ds.setNamespacePrefix(v);
+			} else if (k.equalsIgnoreCase("aggregatorName")) {
+				ds.setAggregator(v);
+			} else if (k.equalsIgnoreCase("dateOfCollection")) {
+				ds.setDateOfCollection(dateUtils.parse(v));
+			} else if (k.equalsIgnoreCase("dateOfValidation")) {
+				ds.setDateOfValidation(dateUtils.parse(v));
+			}
+		}
+
+		return ds;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/.springBeans
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/.springBeans	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/.springBeans	(revision 45190)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+	<version>1</version>
+	<pluginVersion><![CDATA[3.6.2.201410090854-RELEASE]]></pluginVersion>
+	<configSuffixes>
+		<configSuffix><![CDATA[xml]]></configSuffix>
+	</configSuffixes>
+	<enableImports><![CDATA[false]]></enableImports>
+	<configs>
+		<config>src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml</config>
+	</configs>
+	<autoconfigs>
+	</autoconfigs>
+	<configSets>
+	</configSets>
+</beansProjectDescription>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(revision 45190)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	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://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<bean id="datasourceManagerService"
+		class="eu.dnetlib.enabling.datasources.DatasourceManagerServiceImpl">
+		<property name="browsableFields">
+			<list>
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="country" p:label="Datasource countries" p:xpath="../../COUNTRY/text()"
+					p:vocabulary="dnet:countries" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="type" p:label="API typologies" p:xpath="@typology/string()"
+					p:vocabulary="dnet:datasource_typologies" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="protocol" p:label="API protocols" p:xpath="ACCESS_PROTOCOL/text()"
+					p:vocabulary="dnet:protocols" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="compliance" p:label="API compatibility levels"
+					p:xpath="concat(substring(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'], 1, number(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])) * string-length(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])), substring(@compliance, 1, number(not(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']))) * string-length(@compliance)))"
+					p:vocabulary="dnet:compatibilityLevel" />
+			</list>
+		</property>
+	</bean>
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="datasourceManagerServiceEndpoint"
+		implementor="#datasourceManagerService"
+		implementorClass="eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService"
+		address="/datasourceManager" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="datasourceManagerServiceRegistrationManager" t:service="datasourceManagerService"
+		t:endpoint="datasourceManagerServiceEndpoint" t:jobScheduler="jobScheduler" />
+
+</beans>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java
===================================================================
--- modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+
+public class XmlBrowsableField extends BrowsableField {
+
+	private String xpath;
+	private String vocabulary;
+
+	public XmlBrowsableField() {
+		super();
+	}
+
+	public XmlBrowsableField(final String id, final String label) {
+		super(id, label);
+	}
+
+	public XmlBrowsableField(final String id, final String label, final String xpath, final String vocabulary) {
+		super(id, label);
+		this.xpath = xpath;
+		this.vocabulary = vocabulary;
+	}
+
+	public String getXpath() {
+		return xpath;
+	}
+
+	public void setXpath(final String xpath) {
+		this.xpath = xpath;
+	}
+
+	public String getVocabulary() {
+		return vocabulary;
+	}
+
+	public void setVocabulary(final String vocabulary) {
+		this.vocabulary = vocabulary;
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/deploy.info
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/deploy.info	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/deploy.info	(revision 45190)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "dnet-datasource-manager-service"}
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.properties
===================================================================
--- modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.properties	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.properties	(revision 45190)
@@ -0,0 +1 @@
+dnet.datasource.environment = D-Net
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml
===================================================================
--- modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(revision 45190)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	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://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<bean id="datasourceManagerService"
+		class="eu.dnetlib.enabling.datasources.DatasourceManagerServiceImpl" p:environment="${dnet.datasource.environment}">
+		<property name="browsableFields">
+			<list>
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="country" p:label="Datasource countries" p:xpath="../../COUNTRY/text()"
+					p:vocabulary="dnet:countries" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="type" p:label="API typologies" p:xpath="@typology/string()"
+					p:vocabulary="dnet:datasource_typologies" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="protocol" p:label="API protocols" p:xpath="ACCESS_PROTOCOL/text()"
+					p:vocabulary="dnet:protocols" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="compliance" p:label="API compatibility levels"
+					p:xpath="concat(substring(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'], 1, number(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])) * string-length(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])), substring(@compliance, 1, number(not(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']))) * string-length(@compliance)))"
+					p:vocabulary="dnet:compatibilityLevel" />
+			</list>
+		</property>
+	</bean>
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="datasourceManagerServiceEndpoint"
+		implementor="#datasourceManagerService"
+		implementorClass="eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService"
+		address="/datasourceManager" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="datasourceManagerServiceRegistrationManager" t:service="datasourceManagerService"
+		t:endpoint="datasourceManagerServiceEndpoint" t:jobScheduler="jobScheduler" />
+
+</beans>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.util.Map.Entry;
+
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+
+public class IfaceDescToNode {
+
+	public static Element convert(final IfaceDesc iface) throws Exception {
+
+		final Element ifcNode = DocumentHelper.createElement("INTERFACE");
+		ifcNode.addAttribute("id", iface.getId());
+		ifcNode.addAttribute("label", iface.getTypology() + " (" + iface.getCompliance() + ")");
+		ifcNode.addAttribute("compliance", iface.getCompliance());
+		ifcNode.addAttribute("typology", iface.getTypology());
+		ifcNode.addAttribute("contentDescription", iface.getContentDescription());
+		ifcNode.addAttribute("active", Boolean.toString(iface.getActive()));
+		ifcNode.addAttribute("removable", Boolean.toString(iface.getRemovable()));
+
+		final Element acProtoNode = ifcNode.addElement("ACCESS_PROTOCOL");
+
+		for (Entry<String, String> e : iface.getAccessParams().entrySet()) {
+			acProtoNode.addAttribute(e.getKey(), e.getValue());
+		}
+		acProtoNode.setText(iface.getAccessProtocol());
+
+		ifcNode.addElement("BASE_URL").setText(iface.getBaseUrl());;
+
+		for (Entry<String, String> e : iface.getExtraFields().entrySet()) {
+			final Element field = ifcNode.addElement("INTERFACE_EXTRA_FIELD");
+			field.addAttribute("name", e.getKey());
+			field.setText(e.getValue());
+		}
+
+		return ifcNode;
+	}
+}
Index: modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
+,
+for \$x in collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
+,
+for \$x in collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(revision 45190)
@@ -0,0 +1,100 @@
+package eu.dnetlib.enabling.datasources;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import com.google.common.base.Function;
+
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class DatasourceDescToProfile implements Function<DatasourceDesc, String> {
+
+	private static final Log log = LogFactory.getLog(DatasourceDescToProfile.class);
+
+	@Override
+	public String apply(final DatasourceDesc ds) {
+		try {
+			return DatasourceDescToProfile.convert(ds);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+
+	public static String convert(final DatasourceDesc ds) throws Exception {
+		final Element root = DocumentHelper.createElement("RESOURCE_PROFILE");
+
+		final Element header = root.addElement("HEADER");
+		header.addElement("RESOURCE_IDENTIFIER").addAttribute("value", "");
+		header.addElement("RESOURCE_TYPE").addAttribute("value", "RepositoryServiceResourceType");
+		header.addElement("RESOURCE_KIND").addAttribute("value", "RepositoryServiceResources");
+		header.addElement("RESOURCE_URI").addAttribute("value", "");
+		header.addElement("DATE_OF_CREATION").addAttribute("value", DateUtils.now_ISO8601());
+		header.addElement("PROTOCOL");
+
+		final Element body = root.addElement("BODY");
+		final Element conf = body.addElement("CONFIGURATION");
+		conf.addElement("DATASOURCE_TYPE").setText(ds.getDatasourceClass());
+
+		final Element origId = conf.addElement("DATASOURCE_ORIGINAL_ID");
+		origId.addAttribute("provenance", "D-NET");
+		origId.setText(ds.getId());
+
+		conf.addElement("DATASOURCE_AGGREGATED").setText("false");
+		conf.addElement("ENVIRONMENTS");
+		conf.addElement("TYPOLOGY").setText(ds.getTypology());
+		conf.addElement("MAX_SIZE_OF_DATASTRUCTURE").setText("0");
+		conf.addElement("AVAILABLE_DISKSPACE").setText("0");
+		conf.addElement("MAX_NUMBER_OF_DATASTRUCTURE").setText("0");
+
+		conf.addElement("OFFICIAL_NAME").setText(ds.getOfficialName());
+		conf.addElement("ENGLISH_NAME").setText(ds.getEnglishName());
+		conf.addElement("ICON_URI").setText(ds.getLogoUrl());
+		conf.addElement("COUNTRY").setText(ds.getCountryCode());
+
+		final Element location = conf.addElement("LOCATION");
+		location.addElement("LONGITUDE").setText("" + ds.getLongitude());
+		location.addElement("LATITUDE").setText("" + ds.getLatitude());
+		location.addElement("TIMEZONE").setText("" + ds.getTimezone());
+
+		conf.addElement("REPOSITORY_WEBPAGE").setText(ds.getWebsiteUrl());
+		conf.addElement("REPOSITORY_INSTITUTION").setText(ds.getOrganization());
+		conf.addElement("ADMIN_INFO").setText(ds.getContactEmail());
+
+		final Element ifaces = conf.addElement("INTERFACES");
+		for (IfaceDesc ifc : ds.getInterfaces()) {
+			ifaces.add(IfaceDescToNode.convert(ifc));
+		}
+		final Element extraFields = conf.addElement("EXTRA_FIELDS");
+		addExtraField(extraFields, "ACTIVATION_ID", ds.getActivationId());
+		addExtraField(extraFields, "NamespacePrefix", ds.getNamespacePrefix());
+		addExtraField(extraFields, "aggregatorName", ds.getAggregator());
+		addExtraField(extraFields, "dateOfCollection", "" + ds.getDateOfCollection());
+		addExtraField(extraFields, "dateOfValidation", "" + ds.getDateOfValidation());
+		conf.addElement("REGISTERED_BY");
+
+		final Element status = body.addElement("STATUS");
+		status.addElement("NUMBER_OF_OBJECTS").setText("0");
+		status.addElement("LAST_UPDATE").addAttribute("value", "");
+
+		final Element qos = body.addElement("QOS");
+		qos.addElement("AVAILABILITY").setText("0");
+		qos.addElement("CAPACITY");
+		qos.addElement("THROUGHPUT").setText("0");
+
+		body.addElement("SECURITY_PARAMETERS");
+		body.addElement("BLACKBOARD");
+
+		return root.asXML();
+	}
+
+	private static void addExtraField(final Element extraFields, final String field, final String value) {
+		final Element f = extraFields.addElement("FIELD");
+		f.addElement("key").setText(field);
+		f.addElement("value").setText(value);
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,5 @@
+let \$list := collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE/$xpath$
+
+for \$x in distinct-values(\$list) 
+where string-length(\$x) > 0
+return concat(\$x, ' @-@-@ ', count(\$list[.=\$x]))
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(revision 45190)
@@ -0,0 +1,11 @@
+for $x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where 
+	$x//NUMBER_OF_OBJECTS != 0 and not($x//LATITUDE = 0 and $x//LONGITUDE = 0) 
+return 
+<ds>
+	<dsId>{$x//RESOURCE_IDENTIFIER/@value/string()}</dsId>
+	<name>{$x//OFFICIAL_NAME/text()}</name>
+	<lat>{$x//LATITUDE/text()}</lat>
+	<lng>{$x//LONGITUDE/text()}</lng>
+</ds>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(revision 45190)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	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://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<bean id="datasourceManagerService"
+		class="eu.dnetlib.enabling.datasources.DatasourceManagerServiceImpl">
+		<property name="browsableFields">
+			<list>
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="country" p:label="Datasource countries" p:xpath="../../COUNTRY/text()"
+					p:vocabulary="dnet:countries" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="type" p:label="API typologies" p:xpath="@typology/string()"
+					p:vocabulary="dnet:datasource_typologies" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="protocol" p:label="API protocols" p:xpath="ACCESS_PROTOCOL/text()"
+					p:vocabulary="dnet:protocols" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="compliance" p:label="API compatibility levels"
+					p:xpath="concat(substring(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'], 1, number(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])) * string-length(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])), substring(@compliance, 1, number(not(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']))) * string-length(@compliance)))"
+					p:vocabulary="dnet:compatibilityLevel" />
+			</list>
+		</property>
+	</bean>
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="datasourceManagerServiceEndpoint"
+		implementor="#datasourceManagerService"
+		implementorClass="eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService"
+		address="/datasourceManager" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="datasourceManagerServiceRegistrationManager" t:service="datasourceManagerService"
+		t:endpoint="datasourceManagerServiceEndpoint" t:jobScheduler="jobScheduler" />
+
+</beans>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery
===================================================================
--- modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(revision 45190)
@@ -0,0 +1,11 @@
+for $x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where 
+	$x//NUMBER_OF_OBJECTS != 0 and not($x//LATITUDE = 0 and $x//LONGITUDE = 0) 
+return 
+<ds>
+	<dsId>{$x//RESOURCE_IDENTIFIER/@value/string()}</dsId>
+	<name>{$x//OFFICIAL_NAME/text()}</name>
+	<lat>{$x//LATITUDE/text()}</lat>
+	<lng>{$x//LONGITUDE/text()}</lng>
+</ds>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(revision 45190)
@@ -0,0 +1,725 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+import java.text.ParseException;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+import org.quartz.CronExpression;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.core.io.ClassPathResource;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+import eu.dnetlib.enabling.datasources.rmi.BrowseTerm;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceConstants;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerServiceException;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.enabling.datasources.rmi.RepositoryMapEntry;
+import eu.dnetlib.enabling.datasources.rmi.SearchInterfacesEntry;
+import eu.dnetlib.enabling.datasources.rmi.SimpleDatasourceDesc;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+
+public class DatasourceManagerServiceImpl extends AbstractBaseService implements DatasourceManagerService {
+
+	private static final Log log = LogFactory.getLog(DatasourceManagerServiceImpl.class);
+
+	private static final String REPOSITORY_RESOURCE_TYPE = "RepositoryServiceResourceType";
+
+	private List<XmlBrowsableField> browsableFields;
+
+	private ClassPathResource findReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st");
+
+	private ClassPathResource browseRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st");
+	private ClassPathResource findRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st");
+	private ClassPathResource findReposMapQuery = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery");
+	private ClassPathResource simpleFindReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st");
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	private String fixDsId(final String dsId) throws DatasourceManagerServiceException {
+		if (dsId.endsWith("_UGVuZGluZ1JlcG9zaXRvcnlSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=")
+				|| dsId.endsWith("_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=")) {
+			return dsId;
+		} else {
+			try {
+				return serviceLocator
+						.getService(ISLookUpService.class)
+						.getResourceProfileByQuery(
+								"for $x in collection("
+										+ "'/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType',"
+										+ "'/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType') "
+										+ "where $x//DATASOURCE_ORIGINAL_ID = '" + dsId + "' "
+										+ "return $x//RESOURCE_IDENTIFIER/@value/string()");
+			} catch (Exception e) {
+				throw new DatasourceManagerServiceException("Invalid id: " + dsId, e);
+			}
+		}
+	}
+
+	@Override
+	public boolean addDatasource(final DatasourceDesc ds) throws DatasourceManagerServiceException {
+		try {
+			final String profile = DatasourceDescToProfile.convert(ds);
+			serviceLocator.getService(ISRegistryService.class).registerProfile(profile);
+			return true;
+		} catch (Exception e) {
+			log.error("Error registering profile", e);
+			throw new DatasourceManagerServiceException("Error registering profile", e);
+		}
+	}
+
+	@Override
+	public boolean deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		return _deleteDatasource(fixDsId(dsId));
+	}
+
+	private boolean _deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class).deleteProfile(dsId);
+		} catch (ISRegistryException e) {
+			log.error("Error deleting profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error deleting profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public DatasourceDesc getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		return _getDatasource(fixDsId(dsId));
+	}
+
+	private DatasourceDesc _getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error accessing profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error accessing profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public List<DatasourceDesc> listAllDatasources() throws DatasourceManagerServiceException {
+		return listDatasourcesUsingFilter(null, null, null, null);
+	}
+
+	@Override
+	public List<DatasourceDesc> listDatasourcesUsingFilter(final String compliance,
+			final String contentDescription,
+			final String iisProcessingWorkflow,
+			final String collectedFrom)
+			throws DatasourceManagerServiceException {
+		try {
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findReposQueryTmpl.getInputStream()));
+
+			final Map<String, String> conds = Maps.newHashMap();
+
+			if (StringUtils.isNotBlank(compliance)) {
+				conds.put("//INTERFACE/@compliance", compliance);
+			}
+			if (StringUtils.isNotBlank(contentDescription)) {
+				conds.put("//INTERFACE/@contentDescription", contentDescription);
+			}
+			if (StringUtils.isNotBlank(iisProcessingWorkflow)) {
+				// NOT USED
+			}
+			if (StringUtils.isNotBlank(collectedFrom)) {
+				// NOT USED
+			}
+
+			if (!conds.isEmpty()) {
+				st.setAttribute("conds", conds);
+			}
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString());
+
+			return Lists.transform(list, new ProfileToDatasourceDesc());
+		} catch (Exception e) {
+			log.error("Error listing datasources", e);
+			throw new DatasourceManagerServiceException("Error listing datasources", e);
+		}
+	}
+
+	@Override
+	public boolean updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		return _updateLevelOfCompliance(fixDsId(dsId), ifaceId, level);
+	}
+
+	private boolean _updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@compliance", "'" + level + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		return _updateBaseUrl(fixDsId(dsId), ifaceId, baseUrl);
+	}
+
+	private boolean _updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/BASE_URL", "<BASE_URL>" + baseUrl + "</BASE_URL>");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		return _updateActivationStatus(fixDsId(dsId), ifaceId, active);
+	}
+
+	private boolean _updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@active", "'" + active + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		return _updateContentDescription(fixDsId(dsId), ifaceId, desc);
+	}
+
+	private boolean _updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@contentDescription", "'" + desc + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean setIisProcessingWorkflow(final String dsId, final String ifaceId, final String wf) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public boolean updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		return _updateExtraField(fixDsId(dsId), ifaceId, field, value, preserveOriginal);
+	}
+
+	private boolean _updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			final Node node = ifcNode.selectSingleNode("./INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (node != null) {
+				node.setText(value);
+			} else {
+				final Element e = ((Element) ifcNode).addElement("INTERFACE_EXTRA_FIELD");
+				e.addAttribute("name", field);
+				e.setText(value);
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		return _updateAccessParam(fixDsId(dsId), ifaceId, field, value, preserveOriginal);
+	}
+
+	private boolean _updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL");
+			((Element) node).addAttribute(field, value);
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		return _deleteAccessParamOrExtraField(fixDsId(dsId), ifaceId, field);
+	}
+
+	private boolean _deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ef = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (ef != null) {
+				ef.detach();
+			}
+			final Node ap = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL/@" + field);
+			if (ap != null) {
+				ap.detach();
+
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		return _addInterface(fixDsId(dsId), iface);
+	}
+
+	private boolean _addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + iface.getId() + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			((Element) doc.selectSingleNode("//INTERFACES")).add(IfaceDescToNode.convert(iface));
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		return _deleteInterface(fixDsId(dsId), ifaceId);
+	}
+
+	private boolean _deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateSQL(final String dsId, final String sql, final boolean delete) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public Date findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		return _findNextScheduledExecution(fixDsId(dsId), ifaceId);
+	}
+
+	private Date _findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		final String xquery = "/*[.//DATAPROVIDER/@interface='" + ifaceId + "' and .//SCHEDULING/@enabled='true']//CRON/text()";
+		try {
+			final String cronExpression = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
+			final CronExpression cron = new CronExpression(cronExpression);
+			return cron.getNextValidTimeAfter(new Date());
+		} catch (ISLookUpDocumentNotFoundException e) {
+			// When the value is not found a null value must be returned
+			return null;
+		} catch (ISLookUpException e) {
+			log.error("Error in xquery: " + xquery, e);
+			throw new DatasourceManagerServiceException("Error in xquery: " + xquery, e);
+		} catch (ParseException e) {
+			log.error("Error parsing cron expression", e);
+			throw new DatasourceManagerServiceException("Error parsing cron expression", e);
+		}
+	}
+
+	@Override
+	public boolean bulkUpdateApiExtraFields(final String repoId, final String ifaceId, final Map<String, String> fields)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					iface.selectSingleNode("./INTERFACE_EXTRA_FIELD").detach();
+				}
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+
+	}
+
+	@Override
+	public boolean bulkUpdateApiAccessParams(final String dsId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		return _bulkUpdateApiAccessParams(fixDsId(dsId), ifaceId, params);
+	}
+
+	private boolean _bulkUpdateApiAccessParams(final String repoId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element accessNode = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/ACCESS_PROTOCOL");
+			if (accessNode != null) {
+				while (accessNode.attributes().size() > 0) {
+					accessNode.selectSingleNode("@*").detach();
+				}
+				for (Map.Entry<String, String> e : params.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						if (e.getKey().equalsIgnoreCase("baseUrl")) {
+							doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/BASE_URL").setText(e.getValue());
+						} else {
+							accessNode.addAttribute(e.getKey(), e.getValue());
+						}
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+	}
+
+	@Override
+	public boolean overrideCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		return _overrideCompliance(fixDsId(dsId), ifaceId, level);
+	}
+
+	private boolean _overrideCompliance(final String repoId, final String ifaceId, final String compliance) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+				final Map<String, String> fields = Maps.newHashMap();
+
+				if (!StringUtils.isEmpty(compliance)) {
+					fields.put(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD, compliance);
+				}
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					final Node node = iface.selectSingleNode("./INTERFACE_EXTRA_FIELD");
+					final String name = node.valueOf("@name");
+
+					if (!name.equals(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD)) {
+						fields.put(node.valueOf("@name"), node.getText());
+					}
+					node.detach();
+				}
+
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+
+		return true;
+	}
+
+	@Override
+	public List<BrowsableField> listBrowsableFields() throws DatasourceManagerServiceException {
+		return Lists.transform(getBrowsableFields(), new Function<XmlBrowsableField, BrowsableField>() {
+
+			@Override
+			public BrowsableField apply(final XmlBrowsableField f) {
+				return new BrowsableField(f.getId(), f.getLabel());
+			}
+		});
+	}
+
+	@Override
+	public List<BrowseTerm> browseField(final String f) throws DatasourceManagerServiceException {
+
+		final List<BrowseTerm> list = Lists.newArrayList();
+
+		try {
+			final XmlBrowsableField field = findBrowseField(f);
+			if (field != null) {
+				final StringTemplate st = new StringTemplate(IOUtils.toString(browseRepoApisQueryTmpl.getInputStream()));
+				st.setAttribute("xpath", field.getXpath());
+
+				final Map<String, String> terms = fetchVocabularyTerms(field.getVocabulary());
+
+				for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+					final String[] arr = s.split("@-@-@");
+					final String id = arr[0].trim();
+					final int count = NumberUtils.toInt(arr[1].trim(), 0);
+					list.add(new BrowseTerm(id, findLabel(id, terms), count));
+				}
+			}
+		} catch (Exception e) {
+			log.error("Error browsing field " + f, e);
+		}
+
+		return list;
+	}
+
+	private String findLabel(final String code, final Map<String, String> terms) {
+		return terms.containsKey(code) ? terms.get(code) : code;
+	}
+
+	public Map<String, String> fetchVocabularyTerms(final String voc) throws ISLookUpException {
+		final String xquery = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code = '"
+				+ voc.trim() + "']//TERM return concat($x/@code, ' @@@ ', $x/@english_name)";
+
+		final Map<String, String> map = Maps.newHashMap();
+		for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery)) {
+			final String[] arr = s.split("@@@");
+			map.put(arr[0].trim(), arr[1].trim());
+		}
+		return map;
+	}
+
+	private XmlBrowsableField findBrowseField(final String id) {
+		for (XmlBrowsableField f : getBrowsableFields()) {
+			if (f.getId().equals(id)) { return f; }
+		}
+		return null;
+	}
+
+	@Override
+	public List<SearchInterfacesEntry> searchInterface(final String field, final String value) throws DatasourceManagerServiceException {
+		try {
+
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findRepoApisQueryTmpl.getInputStream()));
+
+			if (field.equalsIgnoreCase("__search__")) {
+				st.setAttribute("cond", "contains(../..//(*|@*)/lower-case(.), '" + StringEscapeUtils.escapeXml(value.toLowerCase()) + "')");
+			} else {
+				final XmlBrowsableField f = findBrowseField(field);
+				if (f != null) {
+					st.setAttribute("cond", f.getXpath() + "='" + StringEscapeUtils.escapeXml(value) + "'");
+				} else {
+					return Lists.newArrayList();
+				}
+			}
+
+			final String query = st.toString();
+
+			final SAXReader reader = new SAXReader();
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+
+			return Lists.transform(list, new Function<String, SearchInterfacesEntry>() {
+
+				@Override
+				public SearchInterfacesEntry apply(final String s) {
+					final SearchInterfacesEntry iface = new SearchInterfacesEntry();
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						final String country = doc.valueOf("//REPO/@country");
+
+						iface.setRepoId(doc.valueOf("//REPO/@id"));
+						iface.setRepoCountry(StringUtils.isEmpty(country) ? "-" : country.toUpperCase());
+						iface.setRepoName(doc.valueOf("//REPO/@name"));
+						iface.setRepoPrefix(doc.valueOf("//REPO/@prefix"));
+
+						final Node ifcNode = doc.selectSingleNode("//INTERFACE");
+
+						iface.setId(ifcNode.valueOf("./@id"));
+						iface.setActive(Boolean.valueOf(ifcNode.valueOf("./@active")));
+						iface.setProtocol(ifcNode.valueOf("./ACCESS_PROTOCOL/text()"));
+
+						final String overCompliance = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']");
+						if (StringUtils.isEmpty(overCompliance)) {
+							iface.setCompliance(ifcNode.valueOf("@compliance"));
+						} else {
+							iface.setCompliance(overCompliance);
+						}
+
+						final String lastAggregationDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_date']");
+						if (!StringUtils.isEmpty(lastAggregationDate)) {
+							iface.setAggrDate(lastAggregationDate);
+						} else {
+							final String lastDownloadDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_date']");
+							if (!StringUtils.isEmpty(lastDownloadDate)) {
+								iface.setAggrDate(lastDownloadDate);
+							}
+						}
+						final String lastAggregationTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_total']");
+						if (StringUtils.isEmpty(lastAggregationTotal)) {
+							final String lastDownloadTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_total']");
+							if (StringUtils.isEmpty(lastDownloadTotal)) {
+								iface.setAggrTotal(0);
+							} else {
+								iface.setAggrTotal(NumberUtils.toInt(lastDownloadTotal, 0));
+							}
+						} else {
+							iface.setAggrTotal(NumberUtils.toInt(lastAggregationTotal, 0));
+						}
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return iface;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error searching field " + field + " - value: " + value, e);
+		}
+		return Lists.newArrayList();
+	}
+
+	@Override
+	public List<RepositoryMapEntry> getRepositoryMap() throws DatasourceManagerServiceException {
+		try {
+			final SAXReader reader = new SAXReader();
+
+			final String query = IOUtils.toString(findReposMapQuery.getInputStream());
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+			return Lists.transform(list, new Function<String, RepositoryMapEntry>() {
+
+				@Override
+				public RepositoryMapEntry apply(final String s) {
+					final RepositoryMapEntry r = new RepositoryMapEntry();
+
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						r.setId(doc.valueOf("//dsId"));
+						r.setName(doc.valueOf("//name"));
+						r.setLat(Float.parseFloat(doc.valueOf("//lat")));
+						r.setLng(Float.parseFloat(doc.valueOf("//lng")));
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return r;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error obtaing repo map entries", e);
+		}
+		return Lists.newArrayList();
+	}
+
+	private List<XmlBrowsableField> getBrowsableFields() {
+		return browsableFields;
+	}
+
+	@Required
+	public void setBrowsableFields(final List<XmlBrowsableField> browsableFields) {
+		this.browsableFields = browsableFields;
+	}
+
+	@Override
+	public List<SimpleDatasourceDesc> simpleListDatasourcesByType(final String type) throws DatasourceManagerServiceException {
+		try {
+			final List<SimpleDatasourceDesc> list = Lists.newArrayList();
+
+			final StringTemplate st = new StringTemplate(IOUtils.toString(simpleFindReposQueryTmpl.getInputStream()));
+			st.setAttribute("type", type);
+
+			for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+				final SimpleDatasourceDesc r = new SimpleDatasourceDesc();
+				final String[] arr = s.split("@=@");
+				r.setId(arr[0].trim());
+				r.setName(arr[1].trim());
+				r.setOrigId(arr[2].trim());
+				r.setApis(Sets.newHashSet(arr[3].replaceAll("\\s", "").split(",")));
+				r.setValid("true".equals(arr[4].trim()));
+				r.setTypology(type);
+				list.add(r);
+			}
+
+			Collections.sort(list);
+
+			return list;
+		} catch (Exception e) {
+			log.error("Error listing repos", e);
+		}
+		return Lists.newArrayList();
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+
+public class XmlBrowsableField extends BrowsableField {
+
+	private String xpath;
+	private String vocabulary;
+
+	public XmlBrowsableField() {
+		super();
+	}
+
+	public XmlBrowsableField(final String id, final String label) {
+		super(id, label);
+	}
+
+	public XmlBrowsableField(final String id, final String label, final String xpath, final String vocabulary) {
+		super(id, label);
+		this.xpath = xpath;
+		this.vocabulary = vocabulary;
+	}
+
+	public String getXpath() {
+		return xpath;
+	}
+
+	public void setXpath(final String xpath) {
+		this.xpath = xpath;
+	}
+
+	public String getVocabulary() {
+		return vocabulary;
+	}
+
+	public void setVocabulary(final String vocabulary) {
+		this.vocabulary = vocabulary;
+	}
+
+}
Index: modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in 
+collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE[$cond$]
+return 
+	<ROW>
+		<REPO 
+			id="{\$x/../../../../HEADER/RESOURCE_IDENTIFIER/@value/string()}" 
+			name="{\$x/../../OFFICIAL_NAME/text()}" 
+			country="{\$x/../../COUNTRY/text()}" 
+			prefix="{\$x/../..//EXTRA_FIELDS/FIELD[./key='NamespacePrefix']/value}" />
+		{\$x}
+	</ROW>
Index: modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(revision 45190)
@@ -0,0 +1,12 @@
+for \$x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ true'),
+for \$x in
+	collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ false')
Index: modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,5 @@
+let \$list := collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE/$xpath$
+
+for \$x in distinct-values(\$list) 
+where string-length(\$x) > 0
+return concat(\$x, ' @-@-@ ', count(\$list[.=\$x]))
Index: modules/dnet-datasource-manager-service/trunk/.springBeans
===================================================================
--- modules/dnet-datasource-manager-service/trunk/.springBeans	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/.springBeans	(revision 45190)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+	<version>1</version>
+	<pluginVersion><![CDATA[3.6.2.201410090854-RELEASE]]></pluginVersion>
+	<configSuffixes>
+		<configSuffix><![CDATA[xml]]></configSuffix>
+	</configSuffixes>
+	<enableImports><![CDATA[false]]></enableImports>
+	<configs>
+		<config>src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml</config>
+	</configs>
+	<autoconfigs>
+	</autoconfigs>
+	<configSets>
+	</configSets>
+</beansProjectDescription>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(revision 45190)
@@ -0,0 +1,12 @@
+for \$x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ true'),
+for \$x in
+	collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ false')
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/deploy.info
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/deploy.info	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/deploy.info	(revision 45190)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "dnet-datasource-manager-service"}
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/trunk/deploy.info
===================================================================
--- modules/dnet-datasource-manager-service/trunk/deploy.info	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk/deploy.info	(revision 45190)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "dnet-datasource-manager-service"}
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/trunk
===================================================================
--- modules/dnet-datasource-manager-service/trunk	(nonexistent)
+++ modules/dnet-datasource-manager-service/trunk	(revision 45190)

Property changes on: modules/dnet-datasource-manager-service/trunk
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+target
+.classpath
+.settings
+.project
+*.iml
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/pom.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/pom.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/pom.xml	(revision 45190)
@@ -0,0 +1,34 @@
+<?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>
+    		<groupId>eu.dnetlib</groupId>
+	        <artifactId>dnet-parent</artifactId>
+                <version>1.0.0</version>
+  	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-datasource-manager-service</artifactId>
+	<packaging>jar</packaging>
+	<version>1.0.1</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-datasource-manager-rmi</artifactId>
+			<version>[4.0.0, 5.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-service-common</artifactId>
+			<version>[2.1.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+  		    <groupId>junit</groupId>
+    		    <artifactId>junit</artifactId>
+      		    <version>${junit.version}</version>
+	            <scope>test</scope>
+    		</dependency>
+	</dependencies>
+</project>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/pom.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/pom.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/pom.xml	(revision 45190)
@@ -0,0 +1,34 @@
+<?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>
+    		<groupId>eu.dnetlib</groupId>
+	        <artifactId>dnet-parent</artifactId>
+                <version>1.0.0</version>
+  	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-datasource-manager-service</artifactId>
+	<packaging>jar</packaging>
+	<version>1.0.6</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-datasource-manager-rmi</artifactId>
+			<version>[4.0.0, 5.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-service-common</artifactId>
+			<version>[2.1.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+  		    <groupId>junit</groupId>
+    		    <artifactId>junit</artifactId>
+      		    <version>${junit.version}</version>
+	            <scope>test</scope>
+    		</dependency>
+	</dependencies>
+</project>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(revision 45190)
@@ -0,0 +1,12 @@
+for \$x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ true'),
+for \$x in
+	collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ false')
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(revision 45190)
@@ -0,0 +1,737 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+import java.text.ParseException;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+import org.quartz.CronExpression;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.core.io.ClassPathResource;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+import eu.dnetlib.enabling.datasources.rmi.BrowseTerm;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceConstants;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerServiceException;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.enabling.datasources.rmi.RepositoryMapEntry;
+import eu.dnetlib.enabling.datasources.rmi.SearchInterfacesEntry;
+import eu.dnetlib.enabling.datasources.rmi.SimpleDatasourceDesc;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+
+public class DatasourceManagerServiceImpl extends AbstractBaseService implements DatasourceManagerService {
+
+	private static final Log log = LogFactory.getLog(DatasourceManagerServiceImpl.class);
+
+	private static final String REPOSITORY_RESOURCE_TYPE = "RepositoryServiceResourceType";
+
+	private List<XmlBrowsableField> browsableFields;
+
+	private ClassPathResource findReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st");
+
+	private ClassPathResource browseRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st");
+	private ClassPathResource findRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st");
+	private ClassPathResource findReposMapQuery = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery");
+	private ClassPathResource simpleFindReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st");
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	private String environment;
+
+	private String fixDsId(final String dsId) throws DatasourceManagerServiceException {
+		if (dsId.endsWith("_UGVuZGluZ1JlcG9zaXRvcnlSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=")
+				|| dsId.endsWith("_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=")) {
+			return dsId;
+		} else {
+			try {
+				return serviceLocator
+						.getService(ISLookUpService.class)
+						.getResourceProfileByQuery(
+								"for $x in collection("
+										+ "'/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType',"
+										+ "'/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType') "
+										+ "where $x//DATASOURCE_ORIGINAL_ID = '" + dsId + "' "
+										+ "return $x//RESOURCE_IDENTIFIER/@value/string()");
+			} catch (Exception e) {
+				throw new DatasourceManagerServiceException("Invalid id: " + dsId, e);
+			}
+		}
+	}
+
+	@Override
+	public boolean addDatasource(final DatasourceDesc ds) throws DatasourceManagerServiceException {
+		try {
+			final String profile = DatasourceDescToProfile.convert(ds, environment);
+			serviceLocator.getService(ISRegistryService.class).registerProfile(profile);
+			return true;
+		} catch (Exception e) {
+			log.error("Error registering profile", e);
+			throw new DatasourceManagerServiceException("Error registering profile", e);
+		}
+	}
+
+	@Override
+	public boolean deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		return _deleteDatasource(fixDsId(dsId));
+	}
+
+	private boolean _deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class).deleteProfile(dsId);
+		} catch (ISRegistryException e) {
+			log.error("Error deleting profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error deleting profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public DatasourceDesc getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		return _getDatasource(fixDsId(dsId));
+	}
+
+	private DatasourceDesc _getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error accessing profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error accessing profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public List<DatasourceDesc> listAllDatasources() throws DatasourceManagerServiceException {
+		return listDatasourcesUsingFilter(null, null, null, null);
+	}
+
+	@Override
+	public List<DatasourceDesc> listDatasourcesUsingFilter(final String compliance,
+			final String contentDescription,
+			final String iisProcessingWorkflow,
+			final String collectedFrom)
+			throws DatasourceManagerServiceException {
+		try {
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findReposQueryTmpl.getInputStream()));
+
+			final Map<String, String> conds = Maps.newHashMap();
+
+			if (StringUtils.isNotBlank(compliance)) {
+				conds.put("//INTERFACE/@compliance", compliance);
+			}
+			if (StringUtils.isNotBlank(contentDescription)) {
+				conds.put("//INTERFACE/@contentDescription", contentDescription);
+			}
+			if (StringUtils.isNotBlank(iisProcessingWorkflow)) {
+				// NOT USED
+			}
+			if (StringUtils.isNotBlank(collectedFrom)) {
+				// NOT USED
+			}
+
+			if (!conds.isEmpty()) {
+				st.setAttribute("conds", conds);
+			}
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString());
+
+			return Lists.transform(list, new ProfileToDatasourceDesc());
+		} catch (Exception e) {
+			log.error("Error listing datasources", e);
+			throw new DatasourceManagerServiceException("Error listing datasources", e);
+		}
+	}
+
+	@Override
+	public boolean updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		return _updateLevelOfCompliance(fixDsId(dsId), ifaceId, level);
+	}
+
+	private boolean _updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@compliance", "'" + level + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		return _updateBaseUrl(fixDsId(dsId), ifaceId, baseUrl);
+	}
+
+	private boolean _updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/BASE_URL", "<BASE_URL>" + baseUrl + "</BASE_URL>");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		return _updateActivationStatus(fixDsId(dsId), ifaceId, active);
+	}
+
+	private boolean _updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@active", "'" + active + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		return _updateContentDescription(fixDsId(dsId), ifaceId, desc);
+	}
+
+	private boolean _updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@contentDescription", "'" + desc + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean setIisProcessingWorkflow(final String dsId, final String ifaceId, final String wf) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public boolean updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		return _updateExtraField(fixDsId(dsId), ifaceId, field, value, preserveOriginal);
+	}
+
+	private boolean _updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			final Node node = ifcNode.selectSingleNode("./INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (node != null) {
+				node.setText(value);
+			} else {
+				final Element e = ((Element) ifcNode).addElement("INTERFACE_EXTRA_FIELD");
+				e.addAttribute("name", field);
+				e.setText(value);
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		return _updateAccessParam(fixDsId(dsId), ifaceId, field, value, preserveOriginal);
+	}
+
+	private boolean _updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL");
+			((Element) node).addAttribute(field, value);
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		return _deleteAccessParamOrExtraField(fixDsId(dsId), ifaceId, field);
+	}
+
+	private boolean _deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ef = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (ef != null) {
+				ef.detach();
+			}
+			final Node ap = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL/@" + field);
+			if (ap != null) {
+				ap.detach();
+
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		iface.setRemovable(true);
+		return _addInterface(fixDsId(dsId), iface);
+	}
+
+	private boolean _addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + iface.getId() + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			((Element) doc.selectSingleNode("//INTERFACES")).add(IfaceDescToNode.convert(iface));
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		return _deleteInterface(fixDsId(dsId), ifaceId);
+	}
+
+	private boolean _deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateSQL(final String dsId, final String sql, final boolean delete) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public Date findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		return _findNextScheduledExecution(fixDsId(dsId), ifaceId);
+	}
+
+	private Date _findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		final String xquery = "/*[.//DATAPROVIDER/@interface='" + ifaceId + "' and .//SCHEDULING/@enabled='true']//CRON/text()";
+		try {
+			final String cronExpression = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
+			final CronExpression cron = new CronExpression(cronExpression);
+			return cron.getNextValidTimeAfter(new Date());
+		} catch (ISLookUpDocumentNotFoundException e) {
+			// When the value is not found a null value must be returned
+			return null;
+		} catch (ISLookUpException e) {
+			log.error("Error in xquery: " + xquery, e);
+			throw new DatasourceManagerServiceException("Error in xquery: " + xquery, e);
+		} catch (ParseException e) {
+			log.error("Error parsing cron expression", e);
+			throw new DatasourceManagerServiceException("Error parsing cron expression", e);
+		}
+	}
+
+	@Override
+	public boolean bulkUpdateApiExtraFields(final String repoId, final String ifaceId, final Map<String, String> fields)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					iface.selectSingleNode("./INTERFACE_EXTRA_FIELD").detach();
+				}
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+
+	}
+
+	@Override
+	public boolean bulkUpdateApiAccessParams(final String dsId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		return _bulkUpdateApiAccessParams(fixDsId(dsId), ifaceId, params);
+	}
+
+	private boolean _bulkUpdateApiAccessParams(final String repoId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element accessNode = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/ACCESS_PROTOCOL");
+			if (accessNode != null) {
+				while (accessNode.attributes().size() > 0) {
+					accessNode.selectSingleNode("@*").detach();
+				}
+				for (Map.Entry<String, String> e : params.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						if (e.getKey().equalsIgnoreCase("baseUrl")) {
+							doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/BASE_URL").setText(e.getValue());
+						} else {
+							accessNode.addAttribute(e.getKey(), e.getValue());
+						}
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+	}
+
+	@Override
+	public boolean overrideCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		return _overrideCompliance(fixDsId(dsId), ifaceId, level);
+	}
+
+	private boolean _overrideCompliance(final String repoId, final String ifaceId, final String compliance) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+				final Map<String, String> fields = Maps.newHashMap();
+
+				if (!StringUtils.isEmpty(compliance)) {
+					fields.put(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD, compliance);
+				}
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					final Node node = iface.selectSingleNode("./INTERFACE_EXTRA_FIELD");
+					final String name = node.valueOf("@name");
+
+					if (!name.equals(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD)) {
+						fields.put(node.valueOf("@name"), node.getText());
+					}
+					node.detach();
+				}
+
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+
+		return true;
+	}
+
+	@Override
+	public List<BrowsableField> listBrowsableFields() throws DatasourceManagerServiceException {
+		return Lists.transform(getBrowsableFields(), new Function<XmlBrowsableField, BrowsableField>() {
+
+			@Override
+			public BrowsableField apply(final XmlBrowsableField f) {
+				return new BrowsableField(f.getId(), f.getLabel());
+			}
+		});
+	}
+
+	@Override
+	public List<BrowseTerm> browseField(final String f) throws DatasourceManagerServiceException {
+
+		final List<BrowseTerm> list = Lists.newArrayList();
+
+		try {
+			final XmlBrowsableField field = findBrowseField(f);
+			if (field != null) {
+				final StringTemplate st = new StringTemplate(IOUtils.toString(browseRepoApisQueryTmpl.getInputStream()));
+				st.setAttribute("xpath", field.getXpath());
+
+				final Map<String, String> terms = fetchVocabularyTerms(field.getVocabulary());
+
+				for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+					final String[] arr = s.split("@-@-@");
+					final String id = arr[0].trim();
+					final int count = NumberUtils.toInt(arr[1].trim(), 0);
+					list.add(new BrowseTerm(id, findLabel(id, terms), count));
+				}
+			}
+		} catch (Exception e) {
+			log.error("Error browsing field " + f, e);
+		}
+
+		return list;
+	}
+
+	private String findLabel(final String code, final Map<String, String> terms) {
+		return terms.containsKey(code) ? terms.get(code) : code;
+	}
+
+	public Map<String, String> fetchVocabularyTerms(final String voc) throws ISLookUpException {
+		final String xquery = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code = '"
+				+ voc.trim() + "']//TERM return concat($x/@code, ' @@@ ', $x/@english_name)";
+
+		final Map<String, String> map = Maps.newHashMap();
+		for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery)) {
+			final String[] arr = s.split("@@@");
+			map.put(arr[0].trim(), arr[1].trim());
+		}
+		return map;
+	}
+
+	private XmlBrowsableField findBrowseField(final String id) {
+		for (XmlBrowsableField f : getBrowsableFields()) {
+			if (f.getId().equals(id)) { return f; }
+		}
+		return null;
+	}
+
+	@Override
+	public List<SearchInterfacesEntry> searchInterface(final String field, final String value) throws DatasourceManagerServiceException {
+		try {
+
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findRepoApisQueryTmpl.getInputStream()));
+
+			if (field.equalsIgnoreCase("__search__")) {
+				st.setAttribute("cond", "contains(../..//(*|@*)/lower-case(.), '" + StringEscapeUtils.escapeXml(value.toLowerCase()) + "')");
+			} else {
+				final XmlBrowsableField f = findBrowseField(field);
+				if (f != null) {
+					st.setAttribute("cond", f.getXpath() + "='" + StringEscapeUtils.escapeXml(value) + "'");
+				} else {
+					return Lists.newArrayList();
+				}
+			}
+
+			final String query = st.toString();
+
+			final SAXReader reader = new SAXReader();
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+
+			return Lists.transform(list, new Function<String, SearchInterfacesEntry>() {
+
+				@Override
+				public SearchInterfacesEntry apply(final String s) {
+					final SearchInterfacesEntry iface = new SearchInterfacesEntry();
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						final String country = doc.valueOf("//REPO/@country");
+
+						iface.setRepoId(doc.valueOf("//REPO/@id"));
+						iface.setRepoCountry(StringUtils.isEmpty(country) ? "-" : country.toUpperCase());
+						iface.setRepoName(doc.valueOf("//REPO/@name"));
+						iface.setRepoPrefix(doc.valueOf("//REPO/@prefix"));
+
+						final Node ifcNode = doc.selectSingleNode("//INTERFACE");
+
+						iface.setId(ifcNode.valueOf("./@id"));
+						iface.setActive(Boolean.valueOf(ifcNode.valueOf("./@active")));
+						iface.setProtocol(ifcNode.valueOf("./ACCESS_PROTOCOL/text()"));
+
+						final String overCompliance = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']");
+						if (StringUtils.isEmpty(overCompliance)) {
+							iface.setCompliance(ifcNode.valueOf("@compliance"));
+						} else {
+							iface.setCompliance(overCompliance);
+						}
+
+						final String lastAggregationDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_date']");
+						if (!StringUtils.isEmpty(lastAggregationDate)) {
+							iface.setAggrDate(lastAggregationDate);
+						} else {
+							final String lastDownloadDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_date']");
+							if (!StringUtils.isEmpty(lastDownloadDate)) {
+								iface.setAggrDate(lastDownloadDate);
+							}
+						}
+						final String lastAggregationTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_total']");
+						if (StringUtils.isEmpty(lastAggregationTotal)) {
+							final String lastDownloadTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_total']");
+							if (StringUtils.isEmpty(lastDownloadTotal)) {
+								iface.setAggrTotal(0);
+							} else {
+								iface.setAggrTotal(NumberUtils.toInt(lastDownloadTotal, 0));
+							}
+						} else {
+							iface.setAggrTotal(NumberUtils.toInt(lastAggregationTotal, 0));
+						}
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return iface;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error searching field " + field + " - value: " + value, e);
+		}
+		return Lists.newArrayList();
+	}
+
+	@Override
+	public List<RepositoryMapEntry> getRepositoryMap() throws DatasourceManagerServiceException {
+		try {
+			final SAXReader reader = new SAXReader();
+
+			final String query = IOUtils.toString(findReposMapQuery.getInputStream());
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+			return Lists.transform(list, new Function<String, RepositoryMapEntry>() {
+
+				@Override
+				public RepositoryMapEntry apply(final String s) {
+					final RepositoryMapEntry r = new RepositoryMapEntry();
+
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						r.setId(doc.valueOf("//dsId"));
+						r.setName(doc.valueOf("//name"));
+						r.setLat(Float.parseFloat(doc.valueOf("//lat")));
+						r.setLng(Float.parseFloat(doc.valueOf("//lng")));
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return r;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error obtaing repo map entries", e);
+		}
+		return Lists.newArrayList();
+	}
+
+	private List<XmlBrowsableField> getBrowsableFields() {
+		return browsableFields;
+	}
+
+	@Required
+	public void setBrowsableFields(final List<XmlBrowsableField> browsableFields) {
+		this.browsableFields = browsableFields;
+	}
+
+	@Override
+	public List<SimpleDatasourceDesc> simpleListDatasourcesByType(final String type) throws DatasourceManagerServiceException {
+		try {
+			final List<SimpleDatasourceDesc> list = Lists.newArrayList();
+
+			final StringTemplate st = new StringTemplate(IOUtils.toString(simpleFindReposQueryTmpl.getInputStream()));
+			st.setAttribute("type", type);
+
+			for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+				final SimpleDatasourceDesc r = new SimpleDatasourceDesc();
+				final String[] arr = s.split("@=@");
+				r.setId(arr[0].trim());
+				r.setName(arr[1].trim());
+				r.setOrigId(arr[2].trim());
+				r.setApis(Sets.newHashSet(arr[3].replaceAll("\\s", "").split(",")));
+				r.setValid("true".equals(arr[4].trim()));
+				r.setTypology(type);
+				list.add(r);
+			}
+
+			Collections.sort(list);
+
+			return list;
+		} catch (Exception e) {
+			log.error("Error listing repos", e);
+		}
+		return Lists.newArrayList();
+	}
+
+	public String getEnvironment() {
+		return environment;
+	}
+
+	@Required
+	public void setEnvironment(final String environment) {
+		this.environment = environment;
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.util.Map.Entry;
+
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+
+public class IfaceDescToNode {
+
+	public static Element convert(final IfaceDesc iface) throws Exception {
+
+		final Element ifcNode = DocumentHelper.createElement("INTERFACE");
+		ifcNode.addAttribute("id", iface.getId());
+		ifcNode.addAttribute("label", iface.getTypology() + " (" + iface.getCompliance() + ")");
+		ifcNode.addAttribute("compliance", iface.getCompliance());
+		ifcNode.addAttribute("typology", iface.getTypology());
+		ifcNode.addAttribute("contentDescription", iface.getContentDescription());
+		ifcNode.addAttribute("active", Boolean.toString(iface.getActive()));
+		ifcNode.addAttribute("removable", Boolean.toString(iface.getRemovable()));
+
+		final Element acProtoNode = ifcNode.addElement("ACCESS_PROTOCOL");
+
+		for (Entry<String, String> e : iface.getAccessParams().entrySet()) {
+			acProtoNode.addAttribute(e.getKey(), e.getValue());
+		}
+		acProtoNode.setText(iface.getAccessProtocol());
+
+		ifcNode.addElement("BASE_URL").setText(iface.getBaseUrl());;
+
+		for (Entry<String, String> e : iface.getExtraFields().entrySet()) {
+			final Element field = ifcNode.addElement("INTERFACE_EXTRA_FIELD");
+			field.addAttribute("name", e.getKey());
+			field.setText(e.getValue());
+		}
+
+		return ifcNode;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/.springBeans
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/.springBeans	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/.springBeans	(revision 45190)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+	<version>1</version>
+	<pluginVersion><![CDATA[3.6.2.201410090854-RELEASE]]></pluginVersion>
+	<configSuffixes>
+		<configSuffix><![CDATA[xml]]></configSuffix>
+	</configSuffixes>
+	<enableImports><![CDATA[false]]></enableImports>
+	<configs>
+		<config>src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml</config>
+	</configs>
+	<autoconfigs>
+	</autoconfigs>
+	<configSets>
+	</configSets>
+</beansProjectDescription>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(revision 45190)
@@ -0,0 +1,106 @@
+package eu.dnetlib.enabling.datasources;
+
+import com.google.common.base.Function;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+public class DatasourceDescToProfile implements Function<DatasourceDesc, String> {
+	private static final Log log = LogFactory.getLog(DatasourceDescToProfile.class);
+
+	public DatasourceDescToProfile(final String environment) {
+		this.environment = environment;
+	}
+
+	private String environment;
+
+	public static String convert(final DatasourceDesc ds, String environment) throws Exception {
+		final Element root = DocumentHelper.createElement("RESOURCE_PROFILE");
+
+		final Element header = root.addElement("HEADER");
+		header.addElement("RESOURCE_IDENTIFIER").addAttribute("value", "");
+		header.addElement("RESOURCE_TYPE").addAttribute("value", "RepositoryServiceResourceType");
+		header.addElement("RESOURCE_KIND").addAttribute("value", "RepositoryServiceResources");
+		header.addElement("RESOURCE_URI").addAttribute("value", "");
+		header.addElement("DATE_OF_CREATION").addAttribute("value", DateUtils.now_ISO8601());
+		header.addElement("PROTOCOL");
+
+		final Element body = root.addElement("BODY");
+		final Element conf = body.addElement("CONFIGURATION");
+		conf.addElement("DATASOURCE_TYPE").setText(ds.getDatasourceClass());
+
+		final Element origId = conf.addElement("DATASOURCE_ORIGINAL_ID");
+		origId.addAttribute("provenance", "D-NET");
+		origId.setText(ds.getId());
+
+		conf.addElement("DATASOURCE_AGGREGATED").setText("false");
+		conf.addElement("ENVIRONMENTS").addElement("ENVIRONMENT").setText(environment);
+		conf.addElement("TYPOLOGY").setText(""+ds.getTypology());
+		conf.addElement("MAX_SIZE_OF_DATASTRUCTURE").setText("0");
+		conf.addElement("AVAILABLE_DISKSPACE").setText("0");
+		conf.addElement("MAX_NUMBER_OF_DATASTRUCTURE").setText("0");
+
+		final String officialName = ds.getOfficialName();
+		conf.addElement("OFFICIAL_NAME").setText(officialName);
+		String englishName = ds.getEnglishName();
+		conf.addElement("ENGLISH_NAME").setText(StringUtils.isNotBlank(englishName) ? englishName : officialName);
+		conf.addElement("ICON_URI").setText(""+ds.getLogoUrl());
+		conf.addElement("COUNTRY").setText(ds.getCountryCode());
+
+		final Element location = conf.addElement("LOCATION");
+		location.addElement("LONGITUDE").setText("" + ds.getLongitude());
+		location.addElement("LATITUDE").setText("" + ds.getLatitude());
+		location.addElement("TIMEZONE").setText("" + ds.getTimezone());
+
+		conf.addElement("REPOSITORY_WEBPAGE").setText(ds.getWebsiteUrl());
+		conf.addElement("REPOSITORY_INSTITUTION").setText(ds.getOrganization());
+		conf.addElement("ADMIN_INFO").setText(ds.getContactEmail());
+
+		final Element ifaces = conf.addElement("INTERFACES");
+		for (IfaceDesc ifc : ds.getInterfaces()) {
+			ifaces.add(IfaceDescToNode.convert(ifc));
+		}
+		final Element extraFields = conf.addElement("EXTRA_FIELDS");
+		addExtraField(extraFields, "ACTIVATION_ID", ds.getActivationId());
+		addExtraField(extraFields, "NamespacePrefix", ds.getNamespacePrefix());
+		addExtraField(extraFields, "aggregatorName", ds.getAggregator());
+		addExtraField(extraFields, "dateOfCollection", "" + ds.getDateOfCollection());
+		addExtraField(extraFields, "dateOfValidation", "" + ds.getDateOfValidation());
+		conf.addElement("REGISTERED_BY");
+
+		final Element status = body.addElement("STATUS");
+		status.addElement("NUMBER_OF_OBJECTS").setText("0");
+		status.addElement("LAST_UPDATE").addAttribute("value", DateUtils.now_ISO8601());
+
+		final Element qos = body.addElement("QOS");
+		qos.addElement("AVAILABILITY").setText("0");
+		qos.addElement("CAPACITY");
+		qos.addElement("THROUGHPUT").setText("0");
+
+		body.addElement("SECURITY_PARAMETERS");
+		body.addElement("BLACKBOARD");
+
+		return root.asXML();
+	}
+
+	private static void addExtraField(final Element extraFields, final String field, final String value) {
+		final Element f = extraFields.addElement("FIELD");
+		f.addElement("key").setText(field);
+		f.addElement("value").setText(value != null ? value : "");
+	}
+
+	@Override
+	public String apply(final DatasourceDesc ds) {
+		try {
+			return DatasourceDescToProfile.convert(ds, environment);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in 
+collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE[$cond$]
+return 
+	<ROW>
+		<REPO 
+			id="{\$x/../../../../HEADER/RESOURCE_IDENTIFIER/@value/string()}" 
+			name="{\$x/../../OFFICIAL_NAME/text()}" 
+			country="{\$x/../../COUNTRY/text()}" 
+			prefix="{\$x/../..//EXTRA_FIELDS/FIELD[./key='NamespacePrefix']/value}" />
+		{\$x}
+	</ROW>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
+,
+for \$x in collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,5 @@
+let \$list := collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE/$xpath$
+
+for \$x in distinct-values(\$list) 
+where string-length(\$x) > 0
+return concat(\$x, ' @-@-@ ', count(\$list[.=\$x]))
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.util.Map.Entry;
+
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+
+public class IfaceDescToNode {
+
+	public static Element convert(final IfaceDesc iface) throws Exception {
+
+		final Element ifcNode = DocumentHelper.createElement("INTERFACE");
+		ifcNode.addAttribute("id", iface.getId());
+		ifcNode.addAttribute("label", iface.getTypology() + " (" + iface.getCompliance() + ")");
+		ifcNode.addAttribute("compliance", iface.getCompliance());
+		ifcNode.addAttribute("typology", iface.getTypology());
+		ifcNode.addAttribute("contentDescription", iface.getContentDescription());
+		ifcNode.addAttribute("active", Boolean.toString(iface.getActive()));
+		ifcNode.addAttribute("removable", Boolean.toString(iface.getRemovable()));
+
+		final Element acProtoNode = ifcNode.addElement("ACCESS_PROTOCOL");
+
+		for (Entry<String, String> e : iface.getAccessParams().entrySet()) {
+			acProtoNode.addAttribute(e.getKey(), e.getValue());
+		}
+		acProtoNode.setText(iface.getAccessProtocol());
+
+		ifcNode.addElement("BASE_URL").setText(iface.getBaseUrl());
+
+		for (Entry<String, String> e : iface.getExtraFields().entrySet()) {
+			final Element field = ifcNode.addElement("INTERFACE_EXTRA_FIELD");
+			field.addAttribute("name", e.getKey());
+			field.setText(e.getValue());
+		}
+
+		return ifcNode;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(revision 45190)
@@ -0,0 +1,98 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+
+import com.google.common.base.Function;
+
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class ProfileToDatasourceDesc implements Function<String, DatasourceDesc> {
+
+	private static final Log log = LogFactory.getLog(ProfileToDatasourceDesc.class);
+
+	@Override
+	public DatasourceDesc apply(final String profile) {
+		try {
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+
+	public static DatasourceDesc convert(final String profile) throws Exception {
+		final SAXReader reader = new SAXReader();
+		final Document doc = reader.read(new StringReader(profile));
+
+		final DatasourceDesc ds = new DatasourceDesc();
+		ds.setId(doc.valueOf("//RESOURCE_IDENTIFIER/@value"));
+		ds.setDatasourceClass(doc.valueOf("//DATASOURCE_TYPE"));
+		ds.setTypology(doc.valueOf("//TYPOLOGY"));
+		ds.setOfficialName(doc.valueOf("//OFFICIAL_NAME"));
+		ds.setEnglishName(doc.valueOf("//ENGLISH_NAME"));
+		ds.setCountryCode(doc.valueOf("//COUNTRY"));
+		ds.setLongitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LONGITUDE"), 0.0));
+		ds.setLatitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LATITUDE"), 0.0));
+		ds.setTimezone(NumberUtils.toDouble(doc.valueOf("//LOCATION/TIMEZONE"), 0.0));
+		ds.setWebsiteUrl(doc.valueOf("//REPOSITORY_WEBPAGE"));
+		ds.setOrganization(doc.valueOf("//REPOSITORY_INSTITUTION"));
+		ds.setContactEmail(doc.valueOf("//ADMIN_INFO"));
+
+		for (Object o : doc.selectNodes("//INTERFACES/INTERFACE")) {
+			final Element n = (Element) o;
+
+			final IfaceDesc ifc = new IfaceDesc();
+
+			ifc.setId(n.valueOf("@id"));
+			ifc.setCompliance(n.valueOf("@compliance"));
+			ifc.setTypology(n.valueOf("@typology"));
+			ifc.setContentDescription(n.valueOf("@contentDescription"));
+			ifc.setActive(BooleanUtils.toBoolean(n.valueOf("@active")));
+			ifc.setRemovable(BooleanUtils.toBoolean(n.valueOf("@removable")));
+			ifc.setBaseUrl(n.valueOf("./BASE_URL"));
+			ifc.setAccessProtocol(n.valueOf("./ACCESS_PROTOCOL"));
+
+			for (Object o1 : n.selectNodes("./ACCESS_PROTOCOL/@*")) {
+				final Node attr = (Node) o1;
+				ifc.getAccessParams().put(attr.getName(), attr.getText());
+			}
+			for (Object o1 : n.selectNodes("./INTERFACE_EXTRA_FIELD")) {
+				final Node f = (Node) o1;
+				ifc.getExtraFields().put(f.valueOf("@name"), f.getText());
+			}
+
+			ds.getInterfaces().add(ifc);
+		}
+
+		final DateUtils dateUtils = new DateUtils();
+		for (Object o : doc.selectNodes("//EXTRA_FIELDS/EXTRA_FIELD")) {
+			final String k = ((Element) o).valueOf("./key").trim();
+			final String v = ((Element) o).valueOf("./value").trim();
+
+			if (k.equalsIgnoreCase("ACTIVATION_ID")) {
+				ds.setActivationId(v);
+			} else if (k.equalsIgnoreCase("NamespacePrefix")) {
+				ds.setNamespacePrefix(v);
+			} else if (k.equalsIgnoreCase("aggregatorName")) {
+				ds.setAggregator(v);
+			} else if (k.equalsIgnoreCase("dateOfCollection")) {
+				ds.setDateOfCollection(dateUtils.parse(v));
+			} else if (k.equalsIgnoreCase("dateOfValidation")) {
+				ds.setDateOfValidation(dateUtils.parse(v));
+			}
+		}
+
+		return ds;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(revision 45190)
@@ -0,0 +1,100 @@
+package eu.dnetlib.enabling.datasources;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import com.google.common.base.Function;
+
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class DatasourceDescToProfile implements Function<DatasourceDesc, String> {
+
+	private static final Log log = LogFactory.getLog(DatasourceDescToProfile.class);
+
+	@Override
+	public String apply(final DatasourceDesc ds) {
+		try {
+			return DatasourceDescToProfile.convert(ds);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+
+	public static String convert(final DatasourceDesc ds) throws Exception {
+		final Element root = DocumentHelper.createElement("RESOURCE_PROFILE");
+
+		final Element header = root.addElement("HEADER");
+		header.addElement("RESOURCE_IDENTIFIER").addAttribute("value", "");
+		header.addElement("RESOURCE_TYPE").addAttribute("value", "RepositoryServiceResourceType");
+		header.addElement("RESOURCE_KIND").addAttribute("value", "RepositoryServiceResources");
+		header.addElement("RESOURCE_URI").addAttribute("value", "");
+		header.addElement("DATE_OF_CREATION").addAttribute("value", DateUtils.now_ISO8601());
+		header.addElement("PROTOCOL");
+
+		final Element body = root.addElement("BODY");
+		final Element conf = body.addElement("CONFIGURATION");
+		conf.addElement("DATASOURCE_TYPE").setText(ds.getDatasourceClass());
+
+		final Element origId = conf.addElement("DATASOURCE_ORIGINAL_ID");
+		origId.addAttribute("provenance", "D-NET");
+		origId.setText(ds.getId());
+
+		conf.addElement("DATASOURCE_AGGREGATED").setText("false");
+		conf.addElement("ENVIRONMENTS");
+		conf.addElement("TYPOLOGY").setText(ds.getTypology());
+		conf.addElement("MAX_SIZE_OF_DATASTRUCTURE").setText("0");
+		conf.addElement("AVAILABLE_DISKSPACE").setText("0");
+		conf.addElement("MAX_NUMBER_OF_DATASTRUCTURE").setText("0");
+
+		conf.addElement("OFFICIAL_NAME").setText(ds.getOfficialName());
+		conf.addElement("ENGLISH_NAME").setText(ds.getEnglishName());
+		conf.addElement("ICON_URI").setText(ds.getLogoUrl());
+		conf.addElement("COUNTRY").setText(ds.getCountryCode());
+
+		final Element location = conf.addElement("LOCATION");
+		location.addElement("LONGITUDE").setText("" + ds.getLongitude());
+		location.addElement("LATITUDE").setText("" + ds.getLatitude());
+		location.addElement("TIMEZONE").setText("" + ds.getTimezone());
+
+		conf.addElement("REPOSITORY_WEBPAGE").setText(ds.getWebsiteUrl());
+		conf.addElement("REPOSITORY_INSTITUTION").setText(ds.getOrganization());
+		conf.addElement("ADMIN_INFO").setText(ds.getContactEmail());
+
+		final Element ifaces = conf.addElement("INTERFACES");
+		for (IfaceDesc ifc : ds.getInterfaces()) {
+			ifaces.add(IfaceDescToNode.convert(ifc));
+		}
+		final Element extraFields = conf.addElement("EXTRA_FIELDS");
+		addExtraField(extraFields, "ACTIVATION_ID", ds.getActivationId());
+		addExtraField(extraFields, "NamespacePrefix", ds.getNamespacePrefix());
+		addExtraField(extraFields, "aggregatorName", ds.getAggregator());
+		addExtraField(extraFields, "dateOfCollection", "" + ds.getDateOfCollection());
+		addExtraField(extraFields, "dateOfValidation", "" + ds.getDateOfValidation());
+		conf.addElement("REGISTERED_BY");
+
+		final Element status = body.addElement("STATUS");
+		status.addElement("NUMBER_OF_OBJECTS").setText("0");
+		status.addElement("LAST_UPDATE").addAttribute("value", "");
+
+		final Element qos = body.addElement("QOS");
+		qos.addElement("AVAILABILITY").setText("0");
+		qos.addElement("CAPACITY");
+		qos.addElement("THROUGHPUT").setText("0");
+
+		body.addElement("SECURITY_PARAMETERS");
+		body.addElement("BLACKBOARD");
+
+		return root.asXML();
+	}
+
+	private static void addExtraField(final Element extraFields, final String field, final String value) {
+		final Element f = extraFields.addElement("FIELD");
+		f.addElement("key").setText(field);
+		f.addElement("value").setText(value);
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/deploy.info
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/deploy.info	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/deploy.info	(revision 45190)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "dnet-datasource-manager-service"}
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(revision 45190)
@@ -0,0 +1,646 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+import java.text.ParseException;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+import org.quartz.CronExpression;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.core.io.ClassPathResource;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+import eu.dnetlib.enabling.datasources.rmi.BrowseTerm;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceConstants;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerServiceException;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.enabling.datasources.rmi.RepositoryMapEntry;
+import eu.dnetlib.enabling.datasources.rmi.SearchInterfacesEntry;
+import eu.dnetlib.enabling.datasources.rmi.SimpleDatasourceDesc;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+
+public class DatasourceManagerServiceImpl extends AbstractBaseService implements DatasourceManagerService {
+
+	private static final Log log = LogFactory.getLog(DatasourceManagerServiceImpl.class);
+
+	private static final String REPOSITORY_RESOURCE_TYPE = "RepositoryServiceResourceType";
+
+	private List<XmlBrowsableField> browsableFields;
+
+	private ClassPathResource findReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st");
+
+	private ClassPathResource browseRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st");
+	private ClassPathResource findRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st");
+	private ClassPathResource findReposMapQuery = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery");
+	private ClassPathResource simpleFindReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st");
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	@Override
+	public boolean addDatasource(final DatasourceDesc ds) throws DatasourceManagerServiceException {
+		try {
+			final String profile = DatasourceDescToProfile.convert(ds);
+			serviceLocator.getService(ISRegistryService.class).registerProfile(profile);
+			return true;
+		} catch (Exception e) {
+			log.error("Error registering profile", e);
+			throw new DatasourceManagerServiceException("Error registering profile", e);
+		}
+	}
+
+	@Override
+	public boolean deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class).deleteProfile(dsId);
+		} catch (ISRegistryException e) {
+			log.error("Error deleting profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error deleting profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public DatasourceDesc getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error accessing profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error accessing profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public List<DatasourceDesc> listAllDatasources() throws DatasourceManagerServiceException {
+		return listDatasourcesUsingFilter(null, null, null, null);
+	}
+
+	@Override
+	public List<DatasourceDesc> listDatasourcesUsingFilter(final String compliance,
+			final String contentDescription,
+			final String iisProcessingWorkflow,
+			final String collectedFrom)
+			throws DatasourceManagerServiceException {
+		try {
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findReposQueryTmpl.getInputStream()));
+
+			final Map<String, String> conds = Maps.newHashMap();
+
+			if (StringUtils.isNotBlank(compliance)) {
+				conds.put("//INTERFACE/@compliance", compliance);
+			}
+			if (StringUtils.isNotBlank(contentDescription)) {
+				conds.put("//INTERFACE/@contentDescription", contentDescription);
+			}
+			if (StringUtils.isNotBlank(iisProcessingWorkflow)) {
+				// NOT USED
+			}
+			if (StringUtils.isNotBlank(collectedFrom)) {
+				// NOT USED
+			}
+
+			if (!conds.isEmpty()) {
+				st.setAttribute("conds", conds);
+			}
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString());
+
+			return Lists.transform(list, new ProfileToDatasourceDesc());
+		} catch (Exception e) {
+			log.error("Error listing datasources", e);
+			throw new DatasourceManagerServiceException("Error listing datasources", e);
+		}
+	}
+
+	@Override
+	public boolean updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@compliance", "'" + level + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/BASE_URL", "<BASE_URL>" + baseUrl + "</BASE_URL>");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@active", "'" + active + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@contentDescription", "'" + desc + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean setIisProcessingWorkflow(final String dsId, final String ifaceId, final String wf) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public boolean updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			final Node node = ifcNode.selectSingleNode("./INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (node != null) {
+				node.setText(value);
+			} else {
+				final Element e = ((Element) ifcNode).addElement("INTERFACE_EXTRA_FIELD");
+				e.addAttribute("name", field);
+				e.setText(value);
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL");
+			((Element) node).addAttribute(field, value);
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ef = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (ef != null) {
+				ef.detach();
+			}
+			final Node ap = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL/@" + field);
+			if (ap != null) {
+				ap.detach();
+
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + iface.getId() + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			((Element) doc.selectSingleNode("//INTERFACES")).add(IfaceDescToNode.convert(iface));
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateSQL(final String dsId, final String sql, final boolean delete) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public Date findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		final String xquery = "/*[.//DATAPROVIDER/@interface='" + ifaceId + "' and .//SCHEDULING/@enabled='true']//CRON/text()";
+		try {
+			final String cronExpression = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
+			final CronExpression cron = new CronExpression(cronExpression);
+			return cron.getNextValidTimeAfter(new Date());
+		} catch (ISLookUpDocumentNotFoundException e) {
+			// When the value is not found a null value must be returned
+			return null;
+		} catch (ISLookUpException e) {
+			log.error("Error in xquery: " + xquery, e);
+			throw new DatasourceManagerServiceException("Error in xquery: " + xquery, e);
+		} catch (ParseException e) {
+			log.error("Error parsing cron expression", e);
+			throw new DatasourceManagerServiceException("Error parsing cron expression", e);
+		}
+	}
+
+	@Override
+	public boolean bulkUpdateApiExtraFields(final String repoId, final String ifaceId, final Map<String, String> fields)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					iface.selectSingleNode("./INTERFACE_EXTRA_FIELD").detach();
+				}
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+
+	}
+
+	@Override
+	public boolean bulkUpdateApiAccessParams(final String repoId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element accessNode = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/ACCESS_PROTOCOL");
+			if (accessNode != null) {
+				while (accessNode.attributes().size() > 0) {
+					accessNode.selectSingleNode("@*").detach();
+				}
+				for (Map.Entry<String, String> e : params.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						if (e.getKey().equalsIgnoreCase("baseUrl")) {
+							doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/BASE_URL").setText(e.getValue());
+						} else {
+							accessNode.addAttribute(e.getKey(), e.getValue());
+						}
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+	}
+
+	@Override
+	public boolean overrideCompliance(final String repoId, final String ifaceId, final String compliance) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+				final Map<String, String> fields = Maps.newHashMap();
+
+				if (!StringUtils.isEmpty(compliance)) {
+					fields.put(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD, compliance);
+				}
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					final Node node = iface.selectSingleNode("./INTERFACE_EXTRA_FIELD");
+					final String name = node.valueOf("@name");
+
+					if (!name.equals(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD)) {
+						fields.put(node.valueOf("@name"), node.getText());
+					}
+					node.detach();
+				}
+
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+
+		return true;
+	}
+
+	@Override
+	public List<BrowsableField> listBrowsableFields() throws DatasourceManagerServiceException {
+		return Lists.transform(getBrowsableFields(), new Function<XmlBrowsableField, BrowsableField>() {
+
+			@Override
+			public BrowsableField apply(final XmlBrowsableField f) {
+				return new BrowsableField(f.getId(), f.getLabel());
+			}
+		});
+	}
+
+	@Override
+	public List<BrowseTerm> browseField(final String f) throws DatasourceManagerServiceException {
+
+		final List<BrowseTerm> list = Lists.newArrayList();
+
+		try {
+			final XmlBrowsableField field = findBrowseField(f);
+			if (field != null) {
+				final StringTemplate st = new StringTemplate(IOUtils.toString(browseRepoApisQueryTmpl.getInputStream()));
+				st.setAttribute("xpath", field.getXpath());
+
+				final Map<String, String> terms = fetchVocabularyTerms(field.getVocabulary());
+
+				for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+					final String[] arr = s.split("@-@-@");
+					final String id = arr[0].trim();
+					final int count = NumberUtils.toInt(arr[1].trim(), 0);
+					list.add(new BrowseTerm(id, findLabel(id, terms), count));
+				}
+			}
+		} catch (Exception e) {
+			log.error("Error browsing field " + f, e);
+		}
+
+		return list;
+	}
+
+	private String findLabel(final String code, final Map<String, String> terms) {
+		return terms.containsKey(code) ? terms.get(code) : code;
+	}
+
+	public Map<String, String> fetchVocabularyTerms(final String voc) throws ISLookUpException {
+		final String xquery = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code = '"
+				+ voc.trim() + "']//TERM return concat($x/@code, ' @@@ ', $x/@english_name)";
+
+		final Map<String, String> map = Maps.newHashMap();
+		for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery)) {
+			final String[] arr = s.split("@@@");
+			map.put(arr[0].trim(), arr[1].trim());
+		}
+		return map;
+	}
+
+	private XmlBrowsableField findBrowseField(final String id) {
+		for (XmlBrowsableField f : getBrowsableFields()) {
+			if (f.getId().equals(id)) { return f; }
+		}
+		return null;
+	}
+
+	@Override
+	public List<SearchInterfacesEntry> searchInterface(final String field, final String value) throws DatasourceManagerServiceException {
+		try {
+
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findRepoApisQueryTmpl.getInputStream()));
+
+			if (field.equalsIgnoreCase("__search__")) {
+				st.setAttribute("cond", "contains(../..//(*|@*)/lower-case(.), '" + StringEscapeUtils.escapeXml(value.toLowerCase()) + "')");
+			} else {
+				final XmlBrowsableField f = findBrowseField(field);
+				if (f != null) {
+					st.setAttribute("cond", f.getXpath() + "='" + StringEscapeUtils.escapeXml(value) + "'");
+				} else {
+					return Lists.newArrayList();
+				}
+			}
+
+			final String query = st.toString();
+
+			final SAXReader reader = new SAXReader();
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+
+			return Lists.transform(list, new Function<String, SearchInterfacesEntry>() {
+
+				@Override
+				public SearchInterfacesEntry apply(final String s) {
+					final SearchInterfacesEntry iface = new SearchInterfacesEntry();
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						final String country = doc.valueOf("//REPO/@country");
+
+						iface.setRepoId(doc.valueOf("//REPO/@id"));
+						iface.setRepoCountry(StringUtils.isEmpty(country) ? "-" : country.toUpperCase());
+						iface.setRepoName(doc.valueOf("//REPO/@name"));
+						iface.setRepoPrefix(doc.valueOf("//REPO/@prefix"));
+
+						final Node ifcNode = doc.selectSingleNode("//INTERFACE");
+
+						iface.setId(ifcNode.valueOf("./@id"));
+						iface.setActive(Boolean.valueOf(ifcNode.valueOf("./@active")));
+						iface.setProtocol(ifcNode.valueOf("./ACCESS_PROTOCOL/text()"));
+
+						final String overCompliance = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']");
+						if (StringUtils.isEmpty(overCompliance)) {
+							iface.setCompliance(ifcNode.valueOf("@compliance"));
+						} else {
+							iface.setCompliance(overCompliance);
+						}
+
+						final String lastAggregationDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_date']");
+						if (!StringUtils.isEmpty(lastAggregationDate)) {
+							iface.setAggrDate(lastAggregationDate);
+						} else {
+							final String lastDownloadDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_date']");
+							if (!StringUtils.isEmpty(lastDownloadDate)) {
+								iface.setAggrDate(lastDownloadDate);
+							}
+						}
+						final String lastAggregationTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_total']");
+						if (StringUtils.isEmpty(lastAggregationTotal)) {
+							final String lastDownloadTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_total']");
+							if (StringUtils.isEmpty(lastDownloadTotal)) {
+								iface.setAggrTotal(0);
+							} else {
+								iface.setAggrTotal(NumberUtils.toInt(lastDownloadTotal, 0));
+							}
+						} else {
+							iface.setAggrTotal(NumberUtils.toInt(lastAggregationTotal, 0));
+						}
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return iface;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error searching field " + field + " - value: " + value, e);
+		}
+		return Lists.newArrayList();
+	}
+
+	@Override
+	public List<RepositoryMapEntry> getRepositoryMap() throws DatasourceManagerServiceException {
+		try {
+			final SAXReader reader = new SAXReader();
+
+			final String query = IOUtils.toString(findReposMapQuery.getInputStream());
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+			return Lists.transform(list, new Function<String, RepositoryMapEntry>() {
+
+				@Override
+				public RepositoryMapEntry apply(final String s) {
+					final RepositoryMapEntry r = new RepositoryMapEntry();
+
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						r.setId(doc.valueOf("//dsId"));
+						r.setName(doc.valueOf("//name"));
+						r.setLat(Float.parseFloat(doc.valueOf("//lat")));
+						r.setLng(Float.parseFloat(doc.valueOf("//lng")));
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return r;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error obtaing repo map entries", e);
+		}
+		return Lists.newArrayList();
+	}
+
+	private List<XmlBrowsableField> getBrowsableFields() {
+		return browsableFields;
+	}
+
+	@Required
+	public void setBrowsableFields(final List<XmlBrowsableField> browsableFields) {
+		this.browsableFields = browsableFields;
+	}
+
+	@Override
+	public List<SimpleDatasourceDesc> simpleListDatasourcesByType(final String type) throws DatasourceManagerServiceException {
+		try {
+			final List<SimpleDatasourceDesc> list = Lists.newArrayList();
+
+			final StringTemplate st = new StringTemplate(IOUtils.toString(simpleFindReposQueryTmpl.getInputStream()));
+			st.setAttribute("type", type);
+
+			for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+				final SimpleDatasourceDesc r = new SimpleDatasourceDesc();
+				final String[] arr = s.split("@=@");
+				r.setId(arr[0].trim());
+				r.setName(arr[1].trim());
+				r.setOrigId(arr[2].trim());
+				r.setApis(Sets.newHashSet(arr[3].replaceAll("\\s", "").split(",")));
+				r.setValid("true".equals(arr[4].trim()));
+				r.setTypology(type);
+				list.add(r);
+			}
+
+			Collections.sort(list);
+
+			return list;
+		} catch (Exception e) {
+			log.error("Error listing repos", e);
+		}
+		return Lists.newArrayList();
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+
+public class XmlBrowsableField extends BrowsableField {
+
+	private String xpath;
+	private String vocabulary;
+
+	public XmlBrowsableField() {
+		super();
+	}
+
+	public XmlBrowsableField(final String id, final String label) {
+		super(id, label);
+	}
+
+	public XmlBrowsableField(final String id, final String label, final String xpath, final String vocabulary) {
+		super(id, label);
+		this.xpath = xpath;
+		this.vocabulary = vocabulary;
+	}
+
+	public String getXpath() {
+		return xpath;
+	}
+
+	public void setXpath(final String xpath) {
+		this.xpath = xpath;
+	}
+
+	public String getVocabulary() {
+		return vocabulary;
+	}
+
+	public void setVocabulary(final String vocabulary) {
+		this.vocabulary = vocabulary;
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(revision 45190)
@@ -0,0 +1,11 @@
+for $x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where 
+	$x//NUMBER_OF_OBJECTS != 0 and not($x//LATITUDE = 0 and $x//LONGITUDE = 0) 
+return 
+<ds>
+	<dsId>{$x//RESOURCE_IDENTIFIER/@value/string()}</dsId>
+	<name>{$x//OFFICIAL_NAME/text()}</name>
+	<lat>{$x//LATITUDE/text()}</lat>
+	<lng>{$x//LONGITUDE/text()}</lng>
+</ds>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/IfaceDescToNode.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.util.Map.Entry;
+
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+
+public class IfaceDescToNode {
+
+	public static Element convert(final IfaceDesc iface) throws Exception {
+
+		final Element ifcNode = DocumentHelper.createElement("INTERFACE");
+		ifcNode.addAttribute("id", iface.getId());
+		ifcNode.addAttribute("label", iface.getTypology() + " (" + iface.getCompliance() + ")");
+		ifcNode.addAttribute("compliance", iface.getCompliance());
+		ifcNode.addAttribute("typology", iface.getTypology());
+		ifcNode.addAttribute("contentDescription", iface.getContentDescription());
+		ifcNode.addAttribute("active", Boolean.toString(iface.getActive()));
+		ifcNode.addAttribute("removable", Boolean.toString(iface.getRemovable()));
+
+		final Element acProtoNode = ifcNode.addElement("ACCESS_PROTOCOL");
+
+		for (Entry<String, String> e : iface.getAccessParams().entrySet()) {
+			acProtoNode.addAttribute(e.getKey(), e.getValue());
+		}
+		acProtoNode.setText(iface.getAccessProtocol());
+
+		ifcNode.addElement("BASE_URL").setText(iface.getBaseUrl());;
+
+		for (Entry<String, String> e : iface.getExtraFields().entrySet()) {
+			final Element field = ifcNode.addElement("INTERFACE_EXTRA_FIELD");
+			field.addAttribute("name", e.getKey());
+			field.setText(e.getValue());
+		}
+
+		return ifcNode;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in 
+collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE[$cond$]
+return 
+	<ROW>
+		<REPO 
+			id="{\$x/../../../../HEADER/RESOURCE_IDENTIFIER/@value/string()}" 
+			name="{\$x/../../OFFICIAL_NAME/text()}" 
+			country="{\$x/../../COUNTRY/text()}" 
+			prefix="{\$x/../..//EXTRA_FIELDS/FIELD[./key='NamespacePrefix']/value}" />
+		{\$x}
+	</ROW>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+
+public class XmlBrowsableField extends BrowsableField {
+
+	private String xpath;
+	private String vocabulary;
+
+	public XmlBrowsableField() {
+		super();
+	}
+
+	public XmlBrowsableField(final String id, final String label) {
+		super(id, label);
+	}
+
+	public XmlBrowsableField(final String id, final String label, final String xpath, final String vocabulary) {
+		super(id, label);
+		this.xpath = xpath;
+		this.vocabulary = vocabulary;
+	}
+
+	public String getXpath() {
+		return xpath;
+	}
+
+	public void setXpath(final String xpath) {
+		this.xpath = xpath;
+	}
+
+	public String getVocabulary() {
+		return vocabulary;
+	}
+
+	public void setVocabulary(final String vocabulary) {
+		this.vocabulary = vocabulary;
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+
+public class XmlBrowsableField extends BrowsableField {
+
+	private String xpath;
+	private String vocabulary;
+
+	public XmlBrowsableField() {
+		super();
+	}
+
+	public XmlBrowsableField(final String id, final String label) {
+		super(id, label);
+	}
+
+	public XmlBrowsableField(final String id, final String label, final String xpath, final String vocabulary) {
+		super(id, label);
+		this.xpath = xpath;
+		this.vocabulary = vocabulary;
+	}
+
+	public String getXpath() {
+		return xpath;
+	}
+
+	public void setXpath(final String xpath) {
+		this.xpath = xpath;
+	}
+
+	public String getVocabulary() {
+		return vocabulary;
+	}
+
+	public void setVocabulary(final String vocabulary) {
+		this.vocabulary = vocabulary;
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(revision 45190)
@@ -0,0 +1,100 @@
+package eu.dnetlib.enabling.datasources;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+import com.google.common.base.Function;
+
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class DatasourceDescToProfile implements Function<DatasourceDesc, String> {
+
+	private static final Log log = LogFactory.getLog(DatasourceDescToProfile.class);
+
+	@Override
+	public String apply(final DatasourceDesc ds) {
+		try {
+			return DatasourceDescToProfile.convert(ds);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+
+	public static String convert(final DatasourceDesc ds) throws Exception {
+		final Element root = DocumentHelper.createElement("RESOURCE_PROFILE");
+
+		final Element header = root.addElement("HEADER");
+		header.addElement("RESOURCE_IDENTIFIER").addAttribute("value", "");
+		header.addElement("RESOURCE_TYPE").addAttribute("value", "RepositoryServiceResourceType");
+		header.addElement("RESOURCE_KIND").addAttribute("value", "RepositoryServiceResources");
+		header.addElement("RESOURCE_URI").addAttribute("value", "");
+		header.addElement("DATE_OF_CREATION").addAttribute("value", DateUtils.now_ISO8601());
+		header.addElement("PROTOCOL");
+
+		final Element body = root.addElement("BODY");
+		final Element conf = body.addElement("CONFIGURATION");
+		conf.addElement("DATASOURCE_TYPE").setText(ds.getDatasourceClass());
+
+		final Element origId = conf.addElement("DATASOURCE_ORIGINAL_ID");
+		origId.addAttribute("provenance", "D-NET");
+		origId.setText(ds.getId());
+
+		conf.addElement("DATASOURCE_AGGREGATED").setText("false");
+		conf.addElement("ENVIRONMENTS");
+		conf.addElement("TYPOLOGY").setText(ds.getTypology());
+		conf.addElement("MAX_SIZE_OF_DATASTRUCTURE").setText("0");
+		conf.addElement("AVAILABLE_DISKSPACE").setText("0");
+		conf.addElement("MAX_NUMBER_OF_DATASTRUCTURE").setText("0");
+
+		conf.addElement("OFFICIAL_NAME").setText(ds.getOfficialName());
+		conf.addElement("ENGLISH_NAME").setText(ds.getEnglishName());
+		conf.addElement("ICON_URI").setText(ds.getLogoUrl());
+		conf.addElement("COUNTRY").setText(ds.getCountryCode());
+
+		final Element location = conf.addElement("LOCATION");
+		location.addElement("LONGITUDE").setText("" + ds.getLongitude());
+		location.addElement("LATITUDE").setText("" + ds.getLatitude());
+		location.addElement("TIMEZONE").setText("" + ds.getTimezone());
+
+		conf.addElement("REPOSITORY_WEBPAGE").setText(ds.getWebsiteUrl());
+		conf.addElement("REPOSITORY_INSTITUTION").setText(ds.getOrganization());
+		conf.addElement("ADMIN_INFO").setText(ds.getContactEmail());
+
+		final Element ifaces = conf.addElement("INTERFACES");
+		for (IfaceDesc ifc : ds.getInterfaces()) {
+			ifaces.add(IfaceDescToNode.convert(ifc));
+		}
+		final Element extraFields = conf.addElement("EXTRA_FIELDS");
+		addExtraField(extraFields, "ACTIVATION_ID", ds.getActivationId());
+		addExtraField(extraFields, "NamespacePrefix", ds.getNamespacePrefix());
+		addExtraField(extraFields, "aggregatorName", ds.getAggregator());
+		addExtraField(extraFields, "dateOfCollection", "" + ds.getDateOfCollection());
+		addExtraField(extraFields, "dateOfValidation", "" + ds.getDateOfValidation());
+		conf.addElement("REGISTERED_BY");
+
+		final Element status = body.addElement("STATUS");
+		status.addElement("NUMBER_OF_OBJECTS").setText("0");
+		status.addElement("LAST_UPDATE").addAttribute("value", "");
+
+		final Element qos = body.addElement("QOS");
+		qos.addElement("AVAILABILITY").setText("0");
+		qos.addElement("CAPACITY");
+		qos.addElement("THROUGHPUT").setText("0");
+
+		body.addElement("SECURITY_PARAMETERS");
+		body.addElement("BLACKBOARD");
+
+		return root.asXML();
+	}
+
+	private static void addExtraField(final Element extraFields, final String field, final String value) {
+		final Element f = extraFields.addElement("FIELD");
+		f.addElement("key").setText(field);
+		f.addElement("value").setText(value);
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.properties
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.properties	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.properties	(revision 45190)
@@ -0,0 +1 @@
+dnet.datasource.environment = D-Net
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/.springBeans
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/.springBeans	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/.springBeans	(revision 45190)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+	<version>1</version>
+	<pluginVersion><![CDATA[3.6.2.201410090854-RELEASE]]></pluginVersion>
+	<configSuffixes>
+		<configSuffix><![CDATA[xml]]></configSuffix>
+	</configSuffixes>
+	<enableImports><![CDATA[false]]></enableImports>
+	<configs>
+		<config>src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml</config>
+	</configs>
+	<autoconfigs>
+	</autoconfigs>
+	<configSets>
+	</configSets>
+</beansProjectDescription>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(revision 45190)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	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://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<bean id="datasourceManagerService"
+		class="eu.dnetlib.enabling.datasources.DatasourceManagerServiceImpl" p:environment="${dnet.datasource.environment}">
+		<property name="browsableFields">
+			<list>
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="country" p:label="Datasource countries" p:xpath="../../COUNTRY/text()"
+					p:vocabulary="dnet:countries" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="type" p:label="API typologies" p:xpath="@typology/string()"
+					p:vocabulary="dnet:datasource_typologies" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="protocol" p:label="API protocols" p:xpath="ACCESS_PROTOCOL/text()"
+					p:vocabulary="dnet:protocols" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="compliance" p:label="API compatibility levels"
+					p:xpath="concat(substring(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'], 1, number(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])) * string-length(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])), substring(@compliance, 1, number(not(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']))) * string-length(@compliance)))"
+					p:vocabulary="dnet:compatibilityLevel" />
+			</list>
+		</property>
+	</bean>
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="datasourceManagerServiceEndpoint"
+		implementor="#datasourceManagerService"
+		implementorClass="eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService"
+		address="/datasourceManager" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="datasourceManagerServiceRegistrationManager" t:service="datasourceManagerService"
+		t:endpoint="datasourceManagerServiceEndpoint" t:jobScheduler="jobScheduler" />
+
+</beans>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(revision 45190)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	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://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<bean id="datasourceManagerService"
+		class="eu.dnetlib.enabling.datasources.DatasourceManagerServiceImpl">
+		<property name="browsableFields">
+			<list>
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="country" p:label="Datasource countries" p:xpath="../../COUNTRY/text()"
+					p:vocabulary="dnet:countries" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="type" p:label="API typologies" p:xpath="@typology/string()"
+					p:vocabulary="dnet:datasource_typologies" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="protocol" p:label="API protocols" p:xpath="ACCESS_PROTOCOL/text()"
+					p:vocabulary="dnet:protocols" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="compliance" p:label="API compatibility levels"
+					p:xpath="concat(substring(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'], 1, number(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])) * string-length(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])), substring(@compliance, 1, number(not(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']))) * string-length(@compliance)))"
+					p:vocabulary="dnet:compatibilityLevel" />
+			</list>
+		</property>
+	</bean>
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="datasourceManagerServiceEndpoint"
+		implementor="#datasourceManagerService"
+		implementorClass="eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService"
+		address="/datasourceManager" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="datasourceManagerServiceRegistrationManager" t:service="datasourceManagerService"
+		t:endpoint="datasourceManagerServiceEndpoint" t:jobScheduler="jobScheduler" />
+
+</beans>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
+,
+for \$x in collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,5 @@
+let \$list := collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE/$xpath$
+
+for \$x in distinct-values(\$list) 
+where string-length(\$x) > 0
+return concat(\$x, ' @-@-@ ', count(\$list[.=\$x]))
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(revision 45190)
@@ -0,0 +1,11 @@
+for $x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where 
+	$x//NUMBER_OF_OBJECTS != 0 and not($x//LATITUDE = 0 and $x//LONGITUDE = 0) 
+return 
+<ds>
+	<dsId>{$x//RESOURCE_IDENTIFIER/@value/string()}</dsId>
+	<name>{$x//OFFICIAL_NAME/text()}</name>
+	<lat>{$x//LATITUDE/text()}</lat>
+	<lng>{$x//LONGITUDE/text()}</lng>
+</ds>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(revision 45190)
@@ -0,0 +1,12 @@
+for \$x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ true'),
+for \$x in
+	collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ false')
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/.springBeans
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/.springBeans	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6/.springBeans	(revision 45190)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+	<version>1</version>
+	<pluginVersion><![CDATA[3.6.2.201410090854-RELEASE]]></pluginVersion>
+	<configSuffixes>
+		<configSuffix><![CDATA[xml]]></configSuffix>
+	</configSuffixes>
+	<enableImports><![CDATA[false]]></enableImports>
+	<configs>
+		<config>src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml</config>
+	</configs>
+	<autoconfigs>
+	</autoconfigs>
+	<configSets>
+	</configSets>
+</beansProjectDescription>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6	(revision 45190)

Property changes on: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.6
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+target
+.classpath
+.settings
+.project
+*.iml
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(revision 45190)
@@ -0,0 +1,639 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+import java.text.ParseException;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+import org.quartz.CronExpression;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.core.io.ClassPathResource;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+import eu.dnetlib.enabling.datasources.rmi.BrowseTerm;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceConstants;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerServiceException;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.enabling.datasources.rmi.RepositoryMapEntry;
+import eu.dnetlib.enabling.datasources.rmi.SearchInterfacesEntry;
+import eu.dnetlib.enabling.datasources.rmi.SimpleDatasourceDesc;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+
+public class DatasourceManagerServiceImpl extends AbstractBaseService implements DatasourceManagerService {
+
+	private static final Log log = LogFactory.getLog(DatasourceManagerServiceImpl.class);
+
+	private static final String REPOSITORY_RESOURCE_TYPE = "RepositoryServiceResourceType";
+
+	private List<XmlBrowsableField> browsableFields;
+
+	private ClassPathResource findReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st");
+
+	private ClassPathResource browseRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st");
+	private ClassPathResource findRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st");
+	private ClassPathResource findReposMapQuery = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery");
+	private ClassPathResource simpleFindReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st");
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	@Override
+	public boolean addDatasource(final DatasourceDesc ds) throws DatasourceManagerServiceException {
+		try {
+			final String profile = DatasourceDescToProfile.convert(ds);
+			serviceLocator.getService(ISRegistryService.class).registerProfile(profile);
+			return true;
+		} catch (Exception e) {
+			log.error("Error registering profile", e);
+			throw new DatasourceManagerServiceException("Error registering profile", e);
+		}
+	}
+
+	@Override
+	public boolean deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class).deleteProfile(dsId);
+		} catch (ISRegistryException e) {
+			log.error("Error deleting profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error deleting profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public DatasourceDesc getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error accessing profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error accessing profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public List<DatasourceDesc> listAllDatasources() throws DatasourceManagerServiceException {
+		return listDatasourcesUsingFilter(null, null, null, null);
+	}
+
+	@Override
+	public List<DatasourceDesc> listDatasourcesUsingFilter(final String compliance,
+			final String contentDescription,
+			final String iisProcessingWorkflow,
+			final String collectedFrom)
+			throws DatasourceManagerServiceException {
+		try {
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findReposQueryTmpl.getInputStream()));
+
+			if (StringUtils.isNotBlank(compliance)) {
+				st.setAttribute("compliance", compliance);
+			}
+			if (StringUtils.isNotBlank(contentDescription)) {
+				st.setAttribute("contentDescription", contentDescription);
+			}
+			if (StringUtils.isNotBlank(iisProcessingWorkflow)) {
+				st.setAttribute("iisProcessingWorkflow", iisProcessingWorkflow);
+			}
+			if (StringUtils.isNotBlank(collectedFrom)) {
+				st.setAttribute("collectedFrom", collectedFrom);
+			}
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString());
+
+			return Lists.transform(list, new ProfileToDatasourceDesc());
+		} catch (Exception e) {
+			log.error("Error listing datasources", e);
+			throw new DatasourceManagerServiceException("Error listing datasources", e);
+		}
+	}
+
+	@Override
+	public boolean updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@compliance", "'" + level + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/BASE_URL", "<BASE_URL>" + baseUrl + "</BASE_URL>");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@active", "'" + active + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@contentDescription", "'" + desc + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean setIisProcessingWorkflow(final String dsId, final String ifaceId, final String wf) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public boolean updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			final Node node = ifcNode.selectSingleNode("./INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (node != null) {
+				node.setText(value);
+			} else {
+				final Element e = ((Element) ifcNode).addElement("INTERFACE_EXTRA_FIELD");
+				e.addAttribute("name", field);
+				e.setText(value);
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL");
+			((Element) node).addAttribute(field, value);
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ef = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (ef != null) {
+				ef.detach();
+			}
+			final Node ap = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL/@" + field);
+			if (ap != null) {
+				ap.detach();
+
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + iface.getId() + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			((Element) doc.selectSingleNode("//INTERFACES")).add(IfaceDescToNode.convert(iface));
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateSQL(final String dsId, final String sql, final boolean delete) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public Date findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		final String xquery = "/*[.//DATAPROVIDER/@interface='" + ifaceId + "' and .//SCHEDULING/@enabled='true']//CRON/text()";
+		try {
+			final String cronExpression = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
+			final CronExpression cron = new CronExpression(cronExpression);
+			return cron.getNextValidTimeAfter(new Date());
+		} catch (ISLookUpDocumentNotFoundException e) {
+			// When the value is not found a null value must be returned
+			return null;
+		} catch (ISLookUpException e) {
+			log.error("Error in xquery: " + xquery, e);
+			throw new DatasourceManagerServiceException("Error in xquery: " + xquery, e);
+		} catch (ParseException e) {
+			log.error("Error parsing cron expression", e);
+			throw new DatasourceManagerServiceException("Error parsing cron expression", e);
+		}
+	}
+
+	@Override
+	public boolean bulkUpdateApiExtraFields(final String repoId, final String ifaceId, final Map<String, String> fields)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					iface.selectSingleNode("./INTERFACE_EXTRA_FIELD").detach();
+				}
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+
+	}
+
+	@Override
+	public boolean bulkUpdateApiAccessParams(final String repoId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element accessNode = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/ACCESS_PROTOCOL");
+			if (accessNode != null) {
+				while (accessNode.attributes().size() > 0) {
+					accessNode.selectSingleNode("@*").detach();
+				}
+				for (Map.Entry<String, String> e : params.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						if (e.getKey().equalsIgnoreCase("baseUrl")) {
+							doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/BASE_URL").setText(e.getValue());
+						} else {
+							accessNode.addAttribute(e.getKey(), e.getValue());
+						}
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+	}
+
+	@Override
+	public boolean overrideCompliance(final String repoId, final String ifaceId, final String compliance) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+				final Map<String, String> fields = Maps.newHashMap();
+
+				if (!StringUtils.isEmpty(compliance)) {
+					fields.put(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD, compliance);
+				}
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					final Node node = iface.selectSingleNode("./INTERFACE_EXTRA_FIELD");
+					final String name = node.valueOf("@name");
+
+					if (!name.equals(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD)) {
+						fields.put(node.valueOf("@name"), node.getText());
+					}
+					node.detach();
+				}
+
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+
+		return true;
+	}
+
+	@Override
+	public List<BrowsableField> listBrowsableFields() throws DatasourceManagerServiceException {
+		return Lists.transform(getBrowsableFields(), new Function<XmlBrowsableField, BrowsableField>() {
+
+			@Override
+			public BrowsableField apply(final XmlBrowsableField f) {
+				return new BrowsableField(f.getId(), f.getLabel());
+			}
+		});
+	}
+
+	@Override
+	public List<BrowseTerm> browseField(final String f) throws DatasourceManagerServiceException {
+
+		final List<BrowseTerm> list = Lists.newArrayList();
+
+		try {
+			final XmlBrowsableField field = findBrowseField(f);
+			if (field != null) {
+				final StringTemplate st = new StringTemplate(IOUtils.toString(browseRepoApisQueryTmpl.getInputStream()));
+				st.setAttribute("xpath", field.getXpath());
+
+				final Map<String, String> terms = fetchVocabularyTerms(field.getVocabulary());
+
+				for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+					final String[] arr = s.split("@-@-@");
+					final String id = arr[0].trim();
+					final int count = NumberUtils.toInt(arr[1].trim(), 0);
+					list.add(new BrowseTerm(id, findLabel(id, terms), count));
+				}
+			}
+		} catch (Exception e) {
+			log.error("Error browsing field " + f, e);
+		}
+
+		return list;
+	}
+
+	private String findLabel(final String code, final Map<String, String> terms) {
+		return terms.containsKey(code) ? terms.get(code) : code;
+	}
+
+	public Map<String, String> fetchVocabularyTerms(final String voc) throws ISLookUpException {
+		final String xquery = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code = '"
+				+ voc.trim() + "']//TERM return concat($x/@code, ' @@@ ', $x/@english_name)";
+
+		final Map<String, String> map = Maps.newHashMap();
+		for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery)) {
+			final String[] arr = s.split("@@@");
+			map.put(arr[0].trim(), arr[1].trim());
+		}
+		return map;
+	}
+
+	private XmlBrowsableField findBrowseField(final String id) {
+		for (XmlBrowsableField f : getBrowsableFields()) {
+			if (f.getId().equals(id)) { return f; }
+		}
+		return null;
+	}
+
+	@Override
+	public List<SearchInterfacesEntry> searchInterface(final String field, final String value) throws DatasourceManagerServiceException {
+		try {
+
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findRepoApisQueryTmpl.getInputStream()));
+
+			if (field.equalsIgnoreCase("__search__")) {
+				st.setAttribute("cond", "contains(../..//(*|@*)/lower-case(.), '" + StringEscapeUtils.escapeXml(value.toLowerCase()) + "')");
+			} else {
+				final XmlBrowsableField f = findBrowseField(field);
+				if (f != null) {
+					st.setAttribute("cond", f.getXpath() + "='" + StringEscapeUtils.escapeXml(value) + "'");
+				} else {
+					return Lists.newArrayList();
+				}
+			}
+
+			final String query = st.toString();
+
+			final SAXReader reader = new SAXReader();
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+
+			return Lists.transform(list, new Function<String, SearchInterfacesEntry>() {
+
+				@Override
+				public SearchInterfacesEntry apply(final String s) {
+					final SearchInterfacesEntry iface = new SearchInterfacesEntry();
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						final String country = doc.valueOf("//REPO/@country");
+
+						iface.setRepoId(doc.valueOf("//REPO/@id"));
+						iface.setRepoCountry(StringUtils.isEmpty(country) ? "-" : country.toUpperCase());
+						iface.setRepoName(doc.valueOf("//REPO/@name"));
+						iface.setRepoPrefix(doc.valueOf("//REPO/@prefix"));
+
+						final Node ifcNode = doc.selectSingleNode("//INTERFACE");
+
+						iface.setId(ifcNode.valueOf("./@id"));
+						iface.setActive(Boolean.valueOf(ifcNode.valueOf("./@active")));
+						iface.setProtocol(ifcNode.valueOf("./ACCESS_PROTOCOL/text()"));
+
+						final String overCompliance = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']");
+						if (StringUtils.isEmpty(overCompliance)) {
+							iface.setCompliance(ifcNode.valueOf("@compliance"));
+						} else {
+							iface.setCompliance(overCompliance);
+						}
+
+						final String lastAggregationDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_date']");
+						if (!StringUtils.isEmpty(lastAggregationDate)) {
+							iface.setAggrDate(lastAggregationDate);
+						} else {
+							final String lastDownloadDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_date']");
+							if (!StringUtils.isEmpty(lastDownloadDate)) {
+								iface.setAggrDate(lastDownloadDate);
+							}
+						}
+						final String lastAggregationTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_total']");
+						if (StringUtils.isEmpty(lastAggregationTotal)) {
+							final String lastDownloadTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_total']");
+							if (StringUtils.isEmpty(lastDownloadTotal)) {
+								iface.setAggrTotal(0);
+							} else {
+								iface.setAggrTotal(NumberUtils.toInt(lastDownloadTotal, 0));
+							}
+						} else {
+							iface.setAggrTotal(NumberUtils.toInt(lastAggregationTotal, 0));
+						}
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return iface;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error searching field " + field + " - value: " + value, e);
+		}
+		return Lists.newArrayList();
+	}
+
+	@Override
+	public List<RepositoryMapEntry> getRepositoryMap() throws DatasourceManagerServiceException {
+		try {
+			final SAXReader reader = new SAXReader();
+
+			final String query = IOUtils.toString(findReposMapQuery.getInputStream());
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+			return Lists.transform(list, new Function<String, RepositoryMapEntry>() {
+
+				@Override
+				public RepositoryMapEntry apply(final String s) {
+					final RepositoryMapEntry r = new RepositoryMapEntry();
+
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						r.setId(doc.valueOf("//dsId"));
+						r.setName(doc.valueOf("//name"));
+						r.setLat(Float.parseFloat(doc.valueOf("//lat")));
+						r.setLng(Float.parseFloat(doc.valueOf("//lng")));
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return r;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error obtaing repo map entries", e);
+		}
+		return Lists.newArrayList();
+	}
+
+	private List<XmlBrowsableField> getBrowsableFields() {
+		return browsableFields;
+	}
+
+	@Required
+	public void setBrowsableFields(final List<XmlBrowsableField> browsableFields) {
+		this.browsableFields = browsableFields;
+	}
+
+	@Override
+	public List<SimpleDatasourceDesc> simpleListDatasourcesByType(final String type) throws DatasourceManagerServiceException {
+		try {
+			final List<SimpleDatasourceDesc> list = Lists.newArrayList();
+
+			final StringTemplate st = new StringTemplate(IOUtils.toString(simpleFindReposQueryTmpl.getInputStream()));
+			st.setAttribute("type", type);
+
+			for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+				final SimpleDatasourceDesc r = new SimpleDatasourceDesc();
+				final String[] arr = s.split("@=@");
+				r.setId(arr[0].trim());
+				r.setName(arr[1].trim());
+				r.setOrigId(arr[2].trim());
+				r.setApis(Sets.newHashSet(arr[3].replaceAll("\\s", "").split(",")));
+				r.setValid("true".equals(arr[4].trim()));
+				r.setTypology(type);
+				list.add(r);
+			}
+
+			Collections.sort(list);
+
+			return list;
+		} catch (Exception e) {
+			log.error("Error listing repos", e);
+		}
+		return Lists.newArrayList();
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/pom.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/pom.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/pom.xml	(revision 45190)
@@ -0,0 +1,34 @@
+<?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>
+    		<groupId>eu.dnetlib</groupId>
+	        <artifactId>dnet-parent</artifactId>
+                <version>1.0.0</version>
+  	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-datasource-manager-service</artifactId>
+	<packaging>jar</packaging>
+	<version>1.0.5</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-datasource-manager-rmi</artifactId>
+			<version>[4.0.0, 5.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-service-common</artifactId>
+			<version>[2.1.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+  		    <groupId>junit</groupId>
+    		    <artifactId>junit</artifactId>
+      		    <version>${junit.version}</version>
+	            <scope>test</scope>
+    		</dependency>
+	</dependencies>
+</project>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(revision 45190)
@@ -0,0 +1,736 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+import java.text.ParseException;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+import org.quartz.CronExpression;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.core.io.ClassPathResource;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+import eu.dnetlib.enabling.datasources.rmi.BrowseTerm;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceConstants;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerServiceException;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.enabling.datasources.rmi.RepositoryMapEntry;
+import eu.dnetlib.enabling.datasources.rmi.SearchInterfacesEntry;
+import eu.dnetlib.enabling.datasources.rmi.SimpleDatasourceDesc;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+
+public class DatasourceManagerServiceImpl extends AbstractBaseService implements DatasourceManagerService {
+
+	private static final Log log = LogFactory.getLog(DatasourceManagerServiceImpl.class);
+
+	private static final String REPOSITORY_RESOURCE_TYPE = "RepositoryServiceResourceType";
+
+	private List<XmlBrowsableField> browsableFields;
+
+	private ClassPathResource findReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st");
+
+	private ClassPathResource browseRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st");
+	private ClassPathResource findRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st");
+	private ClassPathResource findReposMapQuery = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery");
+	private ClassPathResource simpleFindReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st");
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	private String environment;
+
+	private String fixDsId(final String dsId) throws DatasourceManagerServiceException {
+		if (dsId.endsWith("_UGVuZGluZ1JlcG9zaXRvcnlSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=")
+				|| dsId.endsWith("_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=")) {
+			return dsId;
+		} else {
+			try {
+				return serviceLocator
+						.getService(ISLookUpService.class)
+						.getResourceProfileByQuery(
+								"for $x in collection("
+										+ "'/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType',"
+										+ "'/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType') "
+										+ "where $x//DATASOURCE_ORIGINAL_ID = '" + dsId + "' "
+										+ "return $x//RESOURCE_IDENTIFIER/@value/string()");
+			} catch (Exception e) {
+				throw new DatasourceManagerServiceException("Invalid id: " + dsId, e);
+			}
+		}
+	}
+
+	@Override
+	public boolean addDatasource(final DatasourceDesc ds) throws DatasourceManagerServiceException {
+		try {
+			final String profile = DatasourceDescToProfile.convert(ds, environment);
+			serviceLocator.getService(ISRegistryService.class).registerProfile(profile);
+			return true;
+		} catch (Exception e) {
+			log.error("Error registering profile", e);
+			throw new DatasourceManagerServiceException("Error registering profile", e);
+		}
+	}
+
+	@Override
+	public boolean deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		return _deleteDatasource(fixDsId(dsId));
+	}
+
+	private boolean _deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class).deleteProfile(dsId);
+		} catch (ISRegistryException e) {
+			log.error("Error deleting profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error deleting profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public DatasourceDesc getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		return _getDatasource(fixDsId(dsId));
+	}
+
+	private DatasourceDesc _getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error accessing profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error accessing profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public List<DatasourceDesc> listAllDatasources() throws DatasourceManagerServiceException {
+		return listDatasourcesUsingFilter(null, null, null, null);
+	}
+
+	@Override
+	public List<DatasourceDesc> listDatasourcesUsingFilter(final String compliance,
+			final String contentDescription,
+			final String iisProcessingWorkflow,
+			final String collectedFrom)
+			throws DatasourceManagerServiceException {
+		try {
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findReposQueryTmpl.getInputStream()));
+
+			final Map<String, String> conds = Maps.newHashMap();
+
+			if (StringUtils.isNotBlank(compliance)) {
+				conds.put("//INTERFACE/@compliance", compliance);
+			}
+			if (StringUtils.isNotBlank(contentDescription)) {
+				conds.put("//INTERFACE/@contentDescription", contentDescription);
+			}
+			if (StringUtils.isNotBlank(iisProcessingWorkflow)) {
+				// NOT USED
+			}
+			if (StringUtils.isNotBlank(collectedFrom)) {
+				// NOT USED
+			}
+
+			if (!conds.isEmpty()) {
+				st.setAttribute("conds", conds);
+			}
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString());
+
+			return Lists.transform(list, new ProfileToDatasourceDesc());
+		} catch (Exception e) {
+			log.error("Error listing datasources", e);
+			throw new DatasourceManagerServiceException("Error listing datasources", e);
+		}
+	}
+
+	@Override
+	public boolean updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		return _updateLevelOfCompliance(fixDsId(dsId), ifaceId, level);
+	}
+
+	private boolean _updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@compliance", "'" + level + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		return _updateBaseUrl(fixDsId(dsId), ifaceId, baseUrl);
+	}
+
+	private boolean _updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/BASE_URL", "<BASE_URL>" + baseUrl + "</BASE_URL>");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		return _updateActivationStatus(fixDsId(dsId), ifaceId, active);
+	}
+
+	private boolean _updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@active", "'" + active + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		return _updateContentDescription(fixDsId(dsId), ifaceId, desc);
+	}
+
+	private boolean _updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@contentDescription", "'" + desc + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean setIisProcessingWorkflow(final String dsId, final String ifaceId, final String wf) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public boolean updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		return _updateExtraField(fixDsId(dsId), ifaceId, field, value, preserveOriginal);
+	}
+
+	private boolean _updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			final Node node = ifcNode.selectSingleNode("./INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (node != null) {
+				node.setText(value);
+			} else {
+				final Element e = ((Element) ifcNode).addElement("INTERFACE_EXTRA_FIELD");
+				e.addAttribute("name", field);
+				e.setText(value);
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		return _updateAccessParam(fixDsId(dsId), ifaceId, field, value, preserveOriginal);
+	}
+
+	private boolean _updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL");
+			((Element) node).addAttribute(field, value);
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		return _deleteAccessParamOrExtraField(fixDsId(dsId), ifaceId, field);
+	}
+
+	private boolean _deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ef = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (ef != null) {
+				ef.detach();
+			}
+			final Node ap = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL/@" + field);
+			if (ap != null) {
+				ap.detach();
+
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		return _addInterface(fixDsId(dsId), iface);
+	}
+
+	private boolean _addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + iface.getId() + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			((Element) doc.selectSingleNode("//INTERFACES")).add(IfaceDescToNode.convert(iface));
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		return _deleteInterface(fixDsId(dsId), ifaceId);
+	}
+
+	private boolean _deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateSQL(final String dsId, final String sql, final boolean delete) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public Date findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		return _findNextScheduledExecution(fixDsId(dsId), ifaceId);
+	}
+
+	private Date _findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		final String xquery = "/*[.//DATAPROVIDER/@interface='" + ifaceId + "' and .//SCHEDULING/@enabled='true']//CRON/text()";
+		try {
+			final String cronExpression = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
+			final CronExpression cron = new CronExpression(cronExpression);
+			return cron.getNextValidTimeAfter(new Date());
+		} catch (ISLookUpDocumentNotFoundException e) {
+			// When the value is not found a null value must be returned
+			return null;
+		} catch (ISLookUpException e) {
+			log.error("Error in xquery: " + xquery, e);
+			throw new DatasourceManagerServiceException("Error in xquery: " + xquery, e);
+		} catch (ParseException e) {
+			log.error("Error parsing cron expression", e);
+			throw new DatasourceManagerServiceException("Error parsing cron expression", e);
+		}
+	}
+
+	@Override
+	public boolean bulkUpdateApiExtraFields(final String repoId, final String ifaceId, final Map<String, String> fields)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					iface.selectSingleNode("./INTERFACE_EXTRA_FIELD").detach();
+				}
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+
+	}
+
+	@Override
+	public boolean bulkUpdateApiAccessParams(final String dsId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		return _bulkUpdateApiAccessParams(fixDsId(dsId), ifaceId, params);
+	}
+
+	private boolean _bulkUpdateApiAccessParams(final String repoId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element accessNode = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/ACCESS_PROTOCOL");
+			if (accessNode != null) {
+				while (accessNode.attributes().size() > 0) {
+					accessNode.selectSingleNode("@*").detach();
+				}
+				for (Map.Entry<String, String> e : params.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						if (e.getKey().equalsIgnoreCase("baseUrl")) {
+							doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/BASE_URL").setText(e.getValue());
+						} else {
+							accessNode.addAttribute(e.getKey(), e.getValue());
+						}
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+	}
+
+	@Override
+	public boolean overrideCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		return _overrideCompliance(fixDsId(dsId), ifaceId, level);
+	}
+
+	private boolean _overrideCompliance(final String repoId, final String ifaceId, final String compliance) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+				final Map<String, String> fields = Maps.newHashMap();
+
+				if (!StringUtils.isEmpty(compliance)) {
+					fields.put(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD, compliance);
+				}
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					final Node node = iface.selectSingleNode("./INTERFACE_EXTRA_FIELD");
+					final String name = node.valueOf("@name");
+
+					if (!name.equals(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD)) {
+						fields.put(node.valueOf("@name"), node.getText());
+					}
+					node.detach();
+				}
+
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+
+		return true;
+	}
+
+	@Override
+	public List<BrowsableField> listBrowsableFields() throws DatasourceManagerServiceException {
+		return Lists.transform(getBrowsableFields(), new Function<XmlBrowsableField, BrowsableField>() {
+
+			@Override
+			public BrowsableField apply(final XmlBrowsableField f) {
+				return new BrowsableField(f.getId(), f.getLabel());
+			}
+		});
+	}
+
+	@Override
+	public List<BrowseTerm> browseField(final String f) throws DatasourceManagerServiceException {
+
+		final List<BrowseTerm> list = Lists.newArrayList();
+
+		try {
+			final XmlBrowsableField field = findBrowseField(f);
+			if (field != null) {
+				final StringTemplate st = new StringTemplate(IOUtils.toString(browseRepoApisQueryTmpl.getInputStream()));
+				st.setAttribute("xpath", field.getXpath());
+
+				final Map<String, String> terms = fetchVocabularyTerms(field.getVocabulary());
+
+				for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+					final String[] arr = s.split("@-@-@");
+					final String id = arr[0].trim();
+					final int count = NumberUtils.toInt(arr[1].trim(), 0);
+					list.add(new BrowseTerm(id, findLabel(id, terms), count));
+				}
+			}
+		} catch (Exception e) {
+			log.error("Error browsing field " + f, e);
+		}
+
+		return list;
+	}
+
+	private String findLabel(final String code, final Map<String, String> terms) {
+		return terms.containsKey(code) ? terms.get(code) : code;
+	}
+
+	public Map<String, String> fetchVocabularyTerms(final String voc) throws ISLookUpException {
+		final String xquery = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code = '"
+				+ voc.trim() + "']//TERM return concat($x/@code, ' @@@ ', $x/@english_name)";
+
+		final Map<String, String> map = Maps.newHashMap();
+		for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery)) {
+			final String[] arr = s.split("@@@");
+			map.put(arr[0].trim(), arr[1].trim());
+		}
+		return map;
+	}
+
+	private XmlBrowsableField findBrowseField(final String id) {
+		for (XmlBrowsableField f : getBrowsableFields()) {
+			if (f.getId().equals(id)) { return f; }
+		}
+		return null;
+	}
+
+	@Override
+	public List<SearchInterfacesEntry> searchInterface(final String field, final String value) throws DatasourceManagerServiceException {
+		try {
+
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findRepoApisQueryTmpl.getInputStream()));
+
+			if (field.equalsIgnoreCase("__search__")) {
+				st.setAttribute("cond", "contains(../..//(*|@*)/lower-case(.), '" + StringEscapeUtils.escapeXml(value.toLowerCase()) + "')");
+			} else {
+				final XmlBrowsableField f = findBrowseField(field);
+				if (f != null) {
+					st.setAttribute("cond", f.getXpath() + "='" + StringEscapeUtils.escapeXml(value) + "'");
+				} else {
+					return Lists.newArrayList();
+				}
+			}
+
+			final String query = st.toString();
+
+			final SAXReader reader = new SAXReader();
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+
+			return Lists.transform(list, new Function<String, SearchInterfacesEntry>() {
+
+				@Override
+				public SearchInterfacesEntry apply(final String s) {
+					final SearchInterfacesEntry iface = new SearchInterfacesEntry();
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						final String country = doc.valueOf("//REPO/@country");
+
+						iface.setRepoId(doc.valueOf("//REPO/@id"));
+						iface.setRepoCountry(StringUtils.isEmpty(country) ? "-" : country.toUpperCase());
+						iface.setRepoName(doc.valueOf("//REPO/@name"));
+						iface.setRepoPrefix(doc.valueOf("//REPO/@prefix"));
+
+						final Node ifcNode = doc.selectSingleNode("//INTERFACE");
+
+						iface.setId(ifcNode.valueOf("./@id"));
+						iface.setActive(Boolean.valueOf(ifcNode.valueOf("./@active")));
+						iface.setProtocol(ifcNode.valueOf("./ACCESS_PROTOCOL/text()"));
+
+						final String overCompliance = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']");
+						if (StringUtils.isEmpty(overCompliance)) {
+							iface.setCompliance(ifcNode.valueOf("@compliance"));
+						} else {
+							iface.setCompliance(overCompliance);
+						}
+
+						final String lastAggregationDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_date']");
+						if (!StringUtils.isEmpty(lastAggregationDate)) {
+							iface.setAggrDate(lastAggregationDate);
+						} else {
+							final String lastDownloadDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_date']");
+							if (!StringUtils.isEmpty(lastDownloadDate)) {
+								iface.setAggrDate(lastDownloadDate);
+							}
+						}
+						final String lastAggregationTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_total']");
+						if (StringUtils.isEmpty(lastAggregationTotal)) {
+							final String lastDownloadTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_total']");
+							if (StringUtils.isEmpty(lastDownloadTotal)) {
+								iface.setAggrTotal(0);
+							} else {
+								iface.setAggrTotal(NumberUtils.toInt(lastDownloadTotal, 0));
+							}
+						} else {
+							iface.setAggrTotal(NumberUtils.toInt(lastAggregationTotal, 0));
+						}
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return iface;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error searching field " + field + " - value: " + value, e);
+		}
+		return Lists.newArrayList();
+	}
+
+	@Override
+	public List<RepositoryMapEntry> getRepositoryMap() throws DatasourceManagerServiceException {
+		try {
+			final SAXReader reader = new SAXReader();
+
+			final String query = IOUtils.toString(findReposMapQuery.getInputStream());
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+			return Lists.transform(list, new Function<String, RepositoryMapEntry>() {
+
+				@Override
+				public RepositoryMapEntry apply(final String s) {
+					final RepositoryMapEntry r = new RepositoryMapEntry();
+
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						r.setId(doc.valueOf("//dsId"));
+						r.setName(doc.valueOf("//name"));
+						r.setLat(Float.parseFloat(doc.valueOf("//lat")));
+						r.setLng(Float.parseFloat(doc.valueOf("//lng")));
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return r;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error obtaing repo map entries", e);
+		}
+		return Lists.newArrayList();
+	}
+
+	private List<XmlBrowsableField> getBrowsableFields() {
+		return browsableFields;
+	}
+
+	@Required
+	public void setBrowsableFields(final List<XmlBrowsableField> browsableFields) {
+		this.browsableFields = browsableFields;
+	}
+
+	@Override
+	public List<SimpleDatasourceDesc> simpleListDatasourcesByType(final String type) throws DatasourceManagerServiceException {
+		try {
+			final List<SimpleDatasourceDesc> list = Lists.newArrayList();
+
+			final StringTemplate st = new StringTemplate(IOUtils.toString(simpleFindReposQueryTmpl.getInputStream()));
+			st.setAttribute("type", type);
+
+			for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+				final SimpleDatasourceDesc r = new SimpleDatasourceDesc();
+				final String[] arr = s.split("@=@");
+				r.setId(arr[0].trim());
+				r.setName(arr[1].trim());
+				r.setOrigId(arr[2].trim());
+				r.setApis(Sets.newHashSet(arr[3].replaceAll("\\s", "").split(",")));
+				r.setValid("true".equals(arr[4].trim()));
+				r.setTypology(type);
+				list.add(r);
+			}
+
+			Collections.sort(list);
+
+			return list;
+		} catch (Exception e) {
+			log.error("Error listing repos", e);
+		}
+		return Lists.newArrayList();
+	}
+
+	public String getEnvironment() {
+		return environment;
+	}
+
+	@Required
+	public void setEnvironment(final String environment) {
+		this.environment = environment;
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+
+public class XmlBrowsableField extends BrowsableField {
+
+	private String xpath;
+	private String vocabulary;
+
+	public XmlBrowsableField() {
+		super();
+	}
+
+	public XmlBrowsableField(final String id, final String label) {
+		super(id, label);
+	}
+
+	public XmlBrowsableField(final String id, final String label, final String xpath, final String vocabulary) {
+		super(id, label);
+		this.xpath = xpath;
+		this.vocabulary = vocabulary;
+	}
+
+	public String getXpath() {
+		return xpath;
+	}
+
+	public void setXpath(final String xpath) {
+		this.xpath = xpath;
+	}
+
+	public String getVocabulary() {
+		return vocabulary;
+	}
+
+	public void setVocabulary(final String vocabulary) {
+		this.vocabulary = vocabulary;
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
+,
+for \$x in collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,5 @@
+let \$list := collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE/$xpath$
+
+for \$x in distinct-values(\$list) 
+where string-length(\$x) > 0
+return concat(\$x, ' @-@-@ ', count(\$list[.=\$x]))
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5	(revision 45190)

Property changes on: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.5
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+target
+.classpath
+.settings
+.project
+*.iml
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/DatasourceManagerServiceImpl.java	(revision 45190)
@@ -0,0 +1,736 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+import java.text.ParseException;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+import org.quartz.CronExpression;
+import org.springframework.beans.factory.annotation.Required;
+import org.springframework.core.io.ClassPathResource;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+import eu.dnetlib.enabling.datasources.rmi.BrowseTerm;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceConstants;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceManagerServiceException;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.enabling.datasources.rmi.RepositoryMapEntry;
+import eu.dnetlib.enabling.datasources.rmi.SearchInterfacesEntry;
+import eu.dnetlib.enabling.datasources.rmi.SimpleDatasourceDesc;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+
+public class DatasourceManagerServiceImpl extends AbstractBaseService implements DatasourceManagerService {
+
+	private static final Log log = LogFactory.getLog(DatasourceManagerServiceImpl.class);
+
+	private static final String REPOSITORY_RESOURCE_TYPE = "RepositoryServiceResourceType";
+
+	private List<XmlBrowsableField> browsableFields;
+
+	private ClassPathResource findReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st");
+
+	private ClassPathResource browseRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st");
+	private ClassPathResource findRepoApisQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st");
+	private ClassPathResource findReposMapQuery = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery");
+	private ClassPathResource simpleFindReposQueryTmpl = new ClassPathResource("/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st");
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	private String environment;
+
+	private String fixDsId(final String dsId) throws DatasourceManagerServiceException {
+		if (dsId.endsWith("_UGVuZGluZ1JlcG9zaXRvcnlSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=")
+				|| dsId.endsWith("_UmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZXMvUmVwb3NpdG9yeVNlcnZpY2VSZXNvdXJjZVR5cGU=")) {
+			return dsId;
+		} else {
+			try {
+				return serviceLocator
+						.getService(ISLookUpService.class)
+						.getResourceProfileByQuery(
+								"for $x in collection("
+										+ "'/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType',"
+										+ "'/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType') "
+										+ "where $x//DATASOURCE_ORIGINAL_ID = '" + dsId + "' "
+										+ "return $x//RESOURCE_IDENTIFIER/@value/string()");
+			} catch (Exception e) {
+				throw new DatasourceManagerServiceException("Invalid id: " + dsId, e);
+			}
+		}
+	}
+
+	@Override
+	public boolean addDatasource(final DatasourceDesc ds) throws DatasourceManagerServiceException {
+		try {
+			final String profile = DatasourceDescToProfile.convert(ds, environment);
+			serviceLocator.getService(ISRegistryService.class).registerProfile(profile);
+			return true;
+		} catch (Exception e) {
+			log.error("Error registering profile", e);
+			throw new DatasourceManagerServiceException("Error registering profile", e);
+		}
+	}
+
+	@Override
+	public boolean deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		return _deleteDatasource(fixDsId(dsId));
+	}
+
+	private boolean _deleteDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class).deleteProfile(dsId);
+		} catch (ISRegistryException e) {
+			log.error("Error deleting profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error deleting profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public DatasourceDesc getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		return _getDatasource(fixDsId(dsId));
+	}
+
+	private DatasourceDesc _getDatasource(final String dsId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error accessing profile " + dsId, e);
+			throw new DatasourceManagerServiceException("Error accessing profile " + dsId, e);
+		}
+	}
+
+	@Override
+	public List<DatasourceDesc> listAllDatasources() throws DatasourceManagerServiceException {
+		return listDatasourcesUsingFilter(null, null, null, null);
+	}
+
+	@Override
+	public List<DatasourceDesc> listDatasourcesUsingFilter(final String compliance,
+			final String contentDescription,
+			final String iisProcessingWorkflow,
+			final String collectedFrom)
+			throws DatasourceManagerServiceException {
+		try {
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findReposQueryTmpl.getInputStream()));
+
+			final Map<String, String> conds = Maps.newHashMap();
+
+			if (StringUtils.isNotBlank(compliance)) {
+				conds.put("//INTERFACE/@compliance", compliance);
+			}
+			if (StringUtils.isNotBlank(contentDescription)) {
+				conds.put("//INTERFACE/@contentDescription", contentDescription);
+			}
+			if (StringUtils.isNotBlank(iisProcessingWorkflow)) {
+				// NOT USED
+			}
+			if (StringUtils.isNotBlank(collectedFrom)) {
+				// NOT USED
+			}
+
+			if (!conds.isEmpty()) {
+				st.setAttribute("conds", conds);
+			}
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString());
+
+			return Lists.transform(list, new ProfileToDatasourceDesc());
+		} catch (Exception e) {
+			log.error("Error listing datasources", e);
+			throw new DatasourceManagerServiceException("Error listing datasources", e);
+		}
+	}
+
+	@Override
+	public boolean updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		return _updateLevelOfCompliance(fixDsId(dsId), ifaceId, level);
+	}
+
+	private boolean _updateLevelOfCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@compliance", "'" + level + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		return _updateBaseUrl(fixDsId(dsId), ifaceId, baseUrl);
+	}
+
+	private boolean _updateBaseUrl(final String dsId, final String ifaceId, final String baseUrl) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/BASE_URL", "<BASE_URL>" + baseUrl + "</BASE_URL>");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		return _updateActivationStatus(fixDsId(dsId), ifaceId, active);
+	}
+
+	private boolean _updateActivationStatus(final String dsId, final String ifaceId, final boolean active) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@active", "'" + active + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		return _updateContentDescription(fixDsId(dsId), ifaceId, desc);
+	}
+
+	private boolean _updateContentDescription(final String dsId, final String ifaceId, final String desc) throws DatasourceManagerServiceException {
+		try {
+			return serviceLocator.getService(ISRegistryService.class)
+					.updateProfileNode(dsId, "//INTERFACE[@id = '" + ifaceId + "']/@contentDescription", "'" + desc + "'");
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean setIisProcessingWorkflow(final String dsId, final String ifaceId, final String wf) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public boolean updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		return _updateExtraField(fixDsId(dsId), ifaceId, field, value, preserveOriginal);
+	}
+
+	private boolean _updateExtraField(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ifcNode = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			final Node node = ifcNode.selectSingleNode("./INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (node != null) {
+				node.setText(value);
+			} else {
+				final Element e = ((Element) ifcNode).addElement("INTERFACE_EXTRA_FIELD");
+				e.addAttribute("name", field);
+				e.setText(value);
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		return _updateAccessParam(fixDsId(dsId), ifaceId, field, value, preserveOriginal);
+	}
+
+	private boolean _updateAccessParam(final String dsId, final String ifaceId, final String field, final String value, final boolean preserveOriginal)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL");
+			((Element) node).addAttribute(field, value);
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		return _deleteAccessParamOrExtraField(fixDsId(dsId), ifaceId, field);
+	}
+
+	private boolean _deleteAccessParamOrExtraField(final String dsId, final String ifaceId, final String field) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node ef = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/INTERFACE_EXTRA_FIELD[@name = '" + field + "']");
+			if (ef != null) {
+				ef.detach();
+			}
+			final Node ap = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']/ACCESS_PROTOCOL/@" + field);
+			if (ap != null) {
+				ap.detach();
+
+			}
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		return _addInterface(fixDsId(dsId), iface);
+	}
+
+	private boolean _addInterface(final String dsId, final IfaceDesc iface) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + iface.getId() + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			((Element) doc.selectSingleNode("//INTERFACES")).add(IfaceDescToNode.convert(iface));
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		return _deleteInterface(fixDsId(dsId), ifaceId);
+	}
+
+	private boolean _deleteInterface(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(dsId);
+			final Document doc = new SAXReader().read(new StringReader(profile));
+
+			final Node node = doc.selectSingleNode("//INTERFACE[@id = '" + ifaceId + "']");
+			if (node != null) {
+				node.detach();
+			}
+
+			return serviceLocator.getService(ISRegistryService.class).updateProfile(dsId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+		} catch (Exception e) {
+			log.error("Error updating profile: " + dsId, e);
+			throw new DatasourceManagerServiceException("Error updating profile: " + dsId, e);
+		}
+	}
+
+	@Override
+	public boolean updateSQL(final String dsId, final String sql, final boolean delete) throws DatasourceManagerServiceException {
+		throw new DatasourceManagerServiceException("NOT IMPLEMENTED");
+	}
+
+	@Override
+	public Date findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		return _findNextScheduledExecution(fixDsId(dsId), ifaceId);
+	}
+
+	private Date _findNextScheduledExecution(final String dsId, final String ifaceId) throws DatasourceManagerServiceException {
+		final String xquery = "/*[.//DATAPROVIDER/@interface='" + ifaceId + "' and .//SCHEDULING/@enabled='true']//CRON/text()";
+		try {
+			final String cronExpression = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
+			final CronExpression cron = new CronExpression(cronExpression);
+			return cron.getNextValidTimeAfter(new Date());
+		} catch (ISLookUpDocumentNotFoundException e) {
+			// When the value is not found a null value must be returned
+			return null;
+		} catch (ISLookUpException e) {
+			log.error("Error in xquery: " + xquery, e);
+			throw new DatasourceManagerServiceException("Error in xquery: " + xquery, e);
+		} catch (ParseException e) {
+			log.error("Error parsing cron expression", e);
+			throw new DatasourceManagerServiceException("Error parsing cron expression", e);
+		}
+	}
+
+	@Override
+	public boolean bulkUpdateApiExtraFields(final String repoId, final String ifaceId, final Map<String, String> fields)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					iface.selectSingleNode("./INTERFACE_EXTRA_FIELD").detach();
+				}
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+
+	}
+
+	@Override
+	public boolean bulkUpdateApiAccessParams(final String dsId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		return _bulkUpdateApiAccessParams(fixDsId(dsId), ifaceId, params);
+	}
+
+	private boolean _bulkUpdateApiAccessParams(final String repoId, final String ifaceId, final Map<String, String> params)
+			throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element accessNode = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/ACCESS_PROTOCOL");
+			if (accessNode != null) {
+				while (accessNode.attributes().size() > 0) {
+					accessNode.selectSingleNode("@*").detach();
+				}
+				for (Map.Entry<String, String> e : params.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						if (e.getKey().equalsIgnoreCase("baseUrl")) {
+							doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']/BASE_URL").setText(e.getValue());
+						} else {
+							accessNode.addAttribute(e.getKey(), e.getValue());
+						}
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+		return true;
+	}
+
+	@Override
+	public boolean overrideCompliance(final String dsId, final String ifaceId, final String level) throws DatasourceManagerServiceException {
+		return _overrideCompliance(fixDsId(dsId), ifaceId, level);
+	}
+
+	private boolean _overrideCompliance(final String repoId, final String ifaceId, final String compliance) throws DatasourceManagerServiceException {
+		try {
+			final String profile = serviceLocator.getService(ISLookUpService.class).getResourceProfile(repoId);
+
+			final SAXReader reader = new SAXReader();
+			final Document doc = reader.read(new StringReader(profile));
+
+			final Element iface = (Element) doc.selectSingleNode("//INTERFACE[@id='" + ifaceId + "']");
+			if (iface != null) {
+				final Map<String, String> fields = Maps.newHashMap();
+
+				if (!StringUtils.isEmpty(compliance)) {
+					fields.put(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD, compliance);
+				}
+
+				while (iface.selectNodes("./INTERFACE_EXTRA_FIELD").size() > 0) {
+					final Node node = iface.selectSingleNode("./INTERFACE_EXTRA_FIELD");
+					final String name = node.valueOf("@name");
+
+					if (!name.equals(DatasourceConstants.OVERRIDING_COMPLIANCE_FIELD)) {
+						fields.put(node.valueOf("@name"), node.getText());
+					}
+					node.detach();
+				}
+
+				for (Map.Entry<String, String> e : fields.entrySet()) {
+					if (e.getValue() != null && !e.getValue().isEmpty()) {
+						final Element field = iface.addElement("INTERFACE_EXTRA_FIELD");
+						field.addAttribute("name", e.getKey());
+						field.addText(e.getValue());
+					}
+				}
+				serviceLocator.getService(ISRegistryService.class).updateProfile(repoId, doc.asXML(), REPOSITORY_RESOURCE_TYPE);
+			} else {
+				log.error("Invalid interface: " + ifaceId);
+				throw new DatasourceManagerServiceException("Missing interface: " + ifaceId);
+			}
+		} catch (Exception e) {
+			log.error("Error updating API of profile: " + repoId);
+			throw new DatasourceManagerServiceException("Error updating API of profile: " + repoId, e);
+		}
+
+		return true;
+	}
+
+	@Override
+	public List<BrowsableField> listBrowsableFields() throws DatasourceManagerServiceException {
+		return Lists.transform(getBrowsableFields(), new Function<XmlBrowsableField, BrowsableField>() {
+
+			@Override
+			public BrowsableField apply(final XmlBrowsableField f) {
+				return new BrowsableField(f.getId(), f.getLabel());
+			}
+		});
+	}
+
+	@Override
+	public List<BrowseTerm> browseField(final String f) throws DatasourceManagerServiceException {
+
+		final List<BrowseTerm> list = Lists.newArrayList();
+
+		try {
+			final XmlBrowsableField field = findBrowseField(f);
+			if (field != null) {
+				final StringTemplate st = new StringTemplate(IOUtils.toString(browseRepoApisQueryTmpl.getInputStream()));
+				st.setAttribute("xpath", field.getXpath());
+
+				final Map<String, String> terms = fetchVocabularyTerms(field.getVocabulary());
+
+				for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+					final String[] arr = s.split("@-@-@");
+					final String id = arr[0].trim();
+					final int count = NumberUtils.toInt(arr[1].trim(), 0);
+					list.add(new BrowseTerm(id, findLabel(id, terms), count));
+				}
+			}
+		} catch (Exception e) {
+			log.error("Error browsing field " + f, e);
+		}
+
+		return list;
+	}
+
+	private String findLabel(final String code, final Map<String, String> terms) {
+		return terms.containsKey(code) ? terms.get(code) : code;
+	}
+
+	public Map<String, String> fetchVocabularyTerms(final String voc) throws ISLookUpException {
+		final String xquery = "for $x in collection('/db/DRIVER/VocabularyDSResources/VocabularyDSResourceType')[.//VOCABULARY_NAME/@code = '"
+				+ voc.trim() + "']//TERM return concat($x/@code, ' @@@ ', $x/@english_name)";
+
+		final Map<String, String> map = Maps.newHashMap();
+		for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(xquery)) {
+			final String[] arr = s.split("@@@");
+			map.put(arr[0].trim(), arr[1].trim());
+		}
+		return map;
+	}
+
+	private XmlBrowsableField findBrowseField(final String id) {
+		for (XmlBrowsableField f : getBrowsableFields()) {
+			if (f.getId().equals(id)) { return f; }
+		}
+		return null;
+	}
+
+	@Override
+	public List<SearchInterfacesEntry> searchInterface(final String field, final String value) throws DatasourceManagerServiceException {
+		try {
+
+			final StringTemplate st = new StringTemplate();
+			st.setTemplate(IOUtils.toString(findRepoApisQueryTmpl.getInputStream()));
+
+			if (field.equalsIgnoreCase("__search__")) {
+				st.setAttribute("cond", "contains(../..//(*|@*)/lower-case(.), '" + StringEscapeUtils.escapeXml(value.toLowerCase()) + "')");
+			} else {
+				final XmlBrowsableField f = findBrowseField(field);
+				if (f != null) {
+					st.setAttribute("cond", f.getXpath() + "='" + StringEscapeUtils.escapeXml(value) + "'");
+				} else {
+					return Lists.newArrayList();
+				}
+			}
+
+			final String query = st.toString();
+
+			final SAXReader reader = new SAXReader();
+
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+
+			return Lists.transform(list, new Function<String, SearchInterfacesEntry>() {
+
+				@Override
+				public SearchInterfacesEntry apply(final String s) {
+					final SearchInterfacesEntry iface = new SearchInterfacesEntry();
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						final String country = doc.valueOf("//REPO/@country");
+
+						iface.setRepoId(doc.valueOf("//REPO/@id"));
+						iface.setRepoCountry(StringUtils.isEmpty(country) ? "-" : country.toUpperCase());
+						iface.setRepoName(doc.valueOf("//REPO/@name"));
+						iface.setRepoPrefix(doc.valueOf("//REPO/@prefix"));
+
+						final Node ifcNode = doc.selectSingleNode("//INTERFACE");
+
+						iface.setId(ifcNode.valueOf("./@id"));
+						iface.setActive(Boolean.valueOf(ifcNode.valueOf("./@active")));
+						iface.setProtocol(ifcNode.valueOf("./ACCESS_PROTOCOL/text()"));
+
+						final String overCompliance = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']");
+						if (StringUtils.isEmpty(overCompliance)) {
+							iface.setCompliance(ifcNode.valueOf("@compliance"));
+						} else {
+							iface.setCompliance(overCompliance);
+						}
+
+						final String lastAggregationDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_date']");
+						if (!StringUtils.isEmpty(lastAggregationDate)) {
+							iface.setAggrDate(lastAggregationDate);
+						} else {
+							final String lastDownloadDate = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_date']");
+							if (!StringUtils.isEmpty(lastDownloadDate)) {
+								iface.setAggrDate(lastDownloadDate);
+							}
+						}
+						final String lastAggregationTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_aggregation_total']");
+						if (StringUtils.isEmpty(lastAggregationTotal)) {
+							final String lastDownloadTotal = ifcNode.valueOf("./INTERFACE_EXTRA_FIELD[@name='last_download_total']");
+							if (StringUtils.isEmpty(lastDownloadTotal)) {
+								iface.setAggrTotal(0);
+							} else {
+								iface.setAggrTotal(NumberUtils.toInt(lastDownloadTotal, 0));
+							}
+						} else {
+							iface.setAggrTotal(NumberUtils.toInt(lastAggregationTotal, 0));
+						}
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return iface;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error searching field " + field + " - value: " + value, e);
+		}
+		return Lists.newArrayList();
+	}
+
+	@Override
+	public List<RepositoryMapEntry> getRepositoryMap() throws DatasourceManagerServiceException {
+		try {
+			final SAXReader reader = new SAXReader();
+
+			final String query = IOUtils.toString(findReposMapQuery.getInputStream());
+			final List<String> list = serviceLocator.getService(ISLookUpService.class).quickSearchProfile(query);
+			return Lists.transform(list, new Function<String, RepositoryMapEntry>() {
+
+				@Override
+				public RepositoryMapEntry apply(final String s) {
+					final RepositoryMapEntry r = new RepositoryMapEntry();
+
+					try {
+						final Document doc = reader.read(new StringReader(s));
+						r.setId(doc.valueOf("//dsId"));
+						r.setName(doc.valueOf("//name"));
+						r.setLat(Float.parseFloat(doc.valueOf("//lat")));
+						r.setLng(Float.parseFloat(doc.valueOf("//lng")));
+					} catch (Exception e) {
+						log.error(e);
+					}
+					return r;
+				}
+			});
+		} catch (Exception e) {
+			log.error("Error obtaing repo map entries", e);
+		}
+		return Lists.newArrayList();
+	}
+
+	private List<XmlBrowsableField> getBrowsableFields() {
+		return browsableFields;
+	}
+
+	@Required
+	public void setBrowsableFields(final List<XmlBrowsableField> browsableFields) {
+		this.browsableFields = browsableFields;
+	}
+
+	@Override
+	public List<SimpleDatasourceDesc> simpleListDatasourcesByType(final String type) throws DatasourceManagerServiceException {
+		try {
+			final List<SimpleDatasourceDesc> list = Lists.newArrayList();
+
+			final StringTemplate st = new StringTemplate(IOUtils.toString(simpleFindReposQueryTmpl.getInputStream()));
+			st.setAttribute("type", type);
+
+			for (String s : serviceLocator.getService(ISLookUpService.class).quickSearchProfile(st.toString())) {
+				final SimpleDatasourceDesc r = new SimpleDatasourceDesc();
+				final String[] arr = s.split("@=@");
+				r.setId(arr[0].trim());
+				r.setName(arr[1].trim());
+				r.setOrigId(arr[2].trim());
+				r.setApis(Sets.newHashSet(arr[3].replaceAll("\\s", "").split(",")));
+				r.setValid("true".equals(arr[4].trim()));
+				r.setTypology(type);
+				list.add(r);
+			}
+
+			Collections.sort(list);
+
+			return list;
+		} catch (Exception e) {
+			log.error("Error listing repos", e);
+		}
+		return Lists.newArrayList();
+	}
+
+	public String getEnvironment() {
+		return environment;
+	}
+
+	@Required
+	public void setEnvironment(final String environment) {
+		this.environment = environment;
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/java/eu/dnetlib/enabling/datasources/XmlBrowsableField.java	(revision 45190)
@@ -0,0 +1,40 @@
+package eu.dnetlib.enabling.datasources;
+
+import eu.dnetlib.enabling.datasources.rmi.BrowsableField;
+
+public class XmlBrowsableField extends BrowsableField {
+
+	private String xpath;
+	private String vocabulary;
+
+	public XmlBrowsableField() {
+		super();
+	}
+
+	public XmlBrowsableField(final String id, final String label) {
+		super(id, label);
+	}
+
+	public XmlBrowsableField(final String id, final String label, final String xpath, final String vocabulary) {
+		super(id, label);
+		this.xpath = xpath;
+		this.vocabulary = vocabulary;
+	}
+
+	public String getXpath() {
+		return xpath;
+	}
+
+	public void setXpath(final String xpath) {
+		this.xpath = xpath;
+	}
+
+	public String getVocabulary() {
+		return vocabulary;
+	}
+
+	public void setVocabulary(final String vocabulary) {
+		this.vocabulary = vocabulary;
+	}
+
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(revision 45190)
@@ -0,0 +1,11 @@
+for $x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where 
+	$x//NUMBER_OF_OBJECTS != 0 and not($x//LATITUDE = 0 and $x//LONGITUDE = 0) 
+return 
+<ds>
+	<dsId>{$x//RESOURCE_IDENTIFIER/@value/string()}</dsId>
+	<name>{$x//OFFICIAL_NAME/text()}</name>
+	<lat>{$x//LATITUDE/text()}</lat>
+	<lng>{$x//LONGITUDE/text()}</lng>
+</ds>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/.springBeans
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/.springBeans	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4/.springBeans	(revision 45190)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+	<version>1</version>
+	<pluginVersion><![CDATA[3.6.2.201410090854-RELEASE]]></pluginVersion>
+	<configSuffixes>
+		<configSuffix><![CDATA[xml]]></configSuffix>
+	</configSuffixes>
+	<enableImports><![CDATA[false]]></enableImports>
+	<configs>
+		<config>src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml</config>
+	</configs>
+	<autoconfigs>
+	</autoconfigs>
+	<configSets>
+	</configSets>
+</beansProjectDescription>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4	(revision 45190)

Property changes on: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.4
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+target
+.classpath
+.settings
+.project
+*.iml
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/java/eu/dnetlib/enabling/datasources/DatasourceDescToProfile.java	(revision 45190)
@@ -0,0 +1,98 @@
+package eu.dnetlib.enabling.datasources;
+
+import com.google.common.base.Function;
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+
+public class DatasourceDescToProfile implements Function<DatasourceDesc, String> {
+
+	private static final Log log = LogFactory.getLog(DatasourceDescToProfile.class);
+
+	public static String convert(final DatasourceDesc ds) throws Exception {
+		final Element root = DocumentHelper.createElement("RESOURCE_PROFILE");
+
+		final Element header = root.addElement("HEADER");
+		header.addElement("RESOURCE_IDENTIFIER").addAttribute("value", "");
+		header.addElement("RESOURCE_TYPE").addAttribute("value", "RepositoryServiceResourceType");
+		header.addElement("RESOURCE_KIND").addAttribute("value", "RepositoryServiceResources");
+		header.addElement("RESOURCE_URI").addAttribute("value", "");
+		header.addElement("DATE_OF_CREATION").addAttribute("value", DateUtils.now_ISO8601());
+		header.addElement("PROTOCOL");
+
+		final Element body = root.addElement("BODY");
+		final Element conf = body.addElement("CONFIGURATION");
+		conf.addElement("DATASOURCE_TYPE").setText(ds.getDatasourceClass());
+
+		final Element origId = conf.addElement("DATASOURCE_ORIGINAL_ID");
+		origId.addAttribute("provenance", "D-NET");
+		origId.setText(ds.getId());
+
+		conf.addElement("DATASOURCE_AGGREGATED").setText("false");
+		conf.addElement("ENVIRONMENTS");
+		conf.addElement("TYPOLOGY").setText(ds.getTypology());
+		conf.addElement("MAX_SIZE_OF_DATASTRUCTURE").setText("0");
+		conf.addElement("AVAILABLE_DISKSPACE").setText("0");
+		conf.addElement("MAX_NUMBER_OF_DATASTRUCTURE").setText("0");
+
+		conf.addElement("OFFICIAL_NAME").setText(ds.getOfficialName());
+		conf.addElement("ENGLISH_NAME").setText(ds.getEnglishName());
+		conf.addElement("ICON_URI").setText(ds.getLogoUrl());
+		conf.addElement("COUNTRY").setText(ds.getCountryCode());
+
+		final Element location = conf.addElement("LOCATION");
+		location.addElement("LONGITUDE").setText("" + ds.getLongitude());
+		location.addElement("LATITUDE").setText("" + ds.getLatitude());
+		location.addElement("TIMEZONE").setText("" + ds.getTimezone());
+
+		conf.addElement("REPOSITORY_WEBPAGE").setText(ds.getWebsiteUrl());
+		conf.addElement("REPOSITORY_INSTITUTION").setText(ds.getOrganization());
+		conf.addElement("ADMIN_INFO").setText(ds.getContactEmail());
+
+		final Element ifaces = conf.addElement("INTERFACES");
+		for (IfaceDesc ifc : ds.getInterfaces()) {
+			ifaces.add(IfaceDescToNode.convert(ifc));
+		}
+		final Element extraFields = conf.addElement("EXTRA_FIELDS");
+		addExtraField(extraFields, "ACTIVATION_ID", ds.getActivationId());
+		addExtraField(extraFields, "NamespacePrefix", ds.getNamespacePrefix());
+		addExtraField(extraFields, "aggregatorName", ds.getAggregator());
+		addExtraField(extraFields, "dateOfCollection", "" + ds.getDateOfCollection());
+		addExtraField(extraFields, "dateOfValidation", "" + ds.getDateOfValidation());
+		conf.addElement("REGISTERED_BY");
+
+		final Element status = body.addElement("STATUS");
+		status.addElement("NUMBER_OF_OBJECTS").setText("0");
+		status.addElement("LAST_UPDATE").addAttribute("value", "");
+
+		final Element qos = body.addElement("QOS");
+		qos.addElement("AVAILABILITY").setText("0");
+		qos.addElement("CAPACITY");
+		qos.addElement("THROUGHPUT").setText("0");
+
+		body.addElement("SECURITY_PARAMETERS");
+		body.addElement("BLACKBOARD");
+
+		return root.asXML();
+	}
+
+	private static void addExtraField(final Element extraFields, final String field, final String value) {
+		final Element f = extraFields.addElement("FIELD");
+		f.addElement("key").setText(field);
+		f.addElement("value").setText(value != null ? value : "");
+	}
+
+	@Override
+	public String apply(final DatasourceDesc ds) {
+		try {
+			return DatasourceDescToProfile.convert(ds);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepos.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
+,
+for \$x in collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+$if(conds)$
+	where $conds.keys:{xpath| \$x$xpath$ = '$conds.(xpath)$'}; separator=" and "$
+$endif$
+return \$x
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3/src/main/resources/eu/dnetlib/enabling/datasources/templates/browseRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,5 @@
+let \$list := collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE/$xpath$
+
+for \$x in distinct-values(\$list) 
+where string-length(\$x) > 0
+return concat(\$x, ' @-@-@ ', count(\$list[.=\$x]))
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3	(revision 45190)

Property changes on: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.3
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+target
+.classpath
+.settings
+.project
+*.iml
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/pom.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/pom.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/pom.xml	(revision 45190)
@@ -0,0 +1,34 @@
+<?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>
+    		<groupId>eu.dnetlib</groupId>
+	        <artifactId>dnet-parent</artifactId>
+                <version>1.0.0</version>
+  	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-datasource-manager-service</artifactId>
+	<packaging>jar</packaging>
+	<version>1.0.2</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-datasource-manager-rmi</artifactId>
+			<version>[4.0.0, 5.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-service-common</artifactId>
+			<version>[2.1.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+  		    <groupId>junit</groupId>
+    		    <artifactId>junit</artifactId>
+      		    <version>${junit.version}</version>
+	            <scope>test</scope>
+    		</dependency>
+	</dependencies>
+</project>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(revision 45190)
@@ -0,0 +1,98 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+
+import com.google.common.base.Function;
+
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class ProfileToDatasourceDesc implements Function<String, DatasourceDesc> {
+
+	private static final Log log = LogFactory.getLog(ProfileToDatasourceDesc.class);
+
+	@Override
+	public DatasourceDesc apply(final String profile) {
+		try {
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+
+	public static DatasourceDesc convert(final String profile) throws Exception {
+		final SAXReader reader = new SAXReader();
+		final Document doc = reader.read(new StringReader(profile));
+
+		final DatasourceDesc ds = new DatasourceDesc();
+		ds.setId(doc.valueOf("//RESOURCE_IDENTIFIER/@value"));
+		ds.setDatasourceClass(doc.valueOf("//DATASOURCE_TYPE"));
+		ds.setTypology(doc.valueOf("//TYPOLOGY"));
+		ds.setOfficialName(doc.valueOf("//OFFICIAL_NAME"));
+		ds.setEnglishName(doc.valueOf("//ENGLISH_NAME"));
+		ds.setCountryCode(doc.valueOf("//COUNTRY"));
+		ds.setLongitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LONGITUDE"), 0.0));
+		ds.setLatitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LATITUDE"), 0.0));
+		ds.setTimezone(NumberUtils.toDouble(doc.valueOf("//LOCATION/TIMEZONE"), 0.0));
+		ds.setWebsiteUrl(doc.valueOf("//REPOSITORY_WEBPAGE"));
+		ds.setOrganization(doc.valueOf("//REPOSITORY_INSTITUTION"));
+		ds.setContactEmail(doc.valueOf("//ADMIN_INFO"));
+
+		for (Object o : doc.selectNodes("//INTERFACES/INTERFACE")) {
+			final Element n = (Element) o;
+
+			final IfaceDesc ifc = new IfaceDesc();
+
+			ifc.setId(n.valueOf("@id"));
+			ifc.setCompliance(n.valueOf("@compliance"));
+			ifc.setTypology(n.valueOf("@typology"));
+			ifc.setContentDescription(n.valueOf("@contentDescription"));
+			ifc.setActive(BooleanUtils.toBoolean(n.valueOf("@active")));
+			ifc.setRemovable(BooleanUtils.toBoolean(n.valueOf("@removable")));
+			ifc.setBaseUrl(n.valueOf("./BASE_URL"));
+			ifc.setAccessProtocol(n.valueOf("./ACCESS_PROTOCOL"));
+
+			for (Object o1 : n.selectNodes("./ACCESS_PROTOCOL/@*")) {
+				final Node attr = (Node) o1;
+				ifc.getAccessParams().put(attr.getName(), attr.getText());
+			}
+			for (Object o1 : n.selectNodes("./INTERFACE_EXTRA_FIELD")) {
+				final Node f = (Node) o1;
+				ifc.getExtraFields().put(f.valueOf("@name"), f.getText());
+			}
+
+			ds.getInterfaces().add(ifc);
+		}
+
+		final DateUtils dateUtils = new DateUtils();
+		for (Object o : doc.selectNodes("//EXTRA_FIELDS/EXTRA_FIELD")) {
+			final String k = ((Element) o).valueOf("./key").trim();
+			final String v = ((Element) o).valueOf("./value").trim();
+
+			if (k.equalsIgnoreCase("ACTIVATION_ID")) {
+				ds.setActivationId(v);
+			} else if (k.equalsIgnoreCase("NamespacePrefix")) {
+				ds.setNamespacePrefix(v);
+			} else if (k.equalsIgnoreCase("aggregatorName")) {
+				ds.setAggregator(v);
+			} else if (k.equalsIgnoreCase("dateOfCollection")) {
+				ds.setDateOfCollection(dateUtils.parse(v));
+			} else if (k.equalsIgnoreCase("dateOfValidation")) {
+				ds.setDateOfValidation(dateUtils.parse(v));
+			}
+		}
+
+		return ds;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/src/main/resources/eu/dnetlib/enabling/datasources/templates/findRepoApis.xquery.st	(revision 45190)
@@ -0,0 +1,11 @@
+for \$x in 
+collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')//INTERFACE[$cond$]
+return 
+	<ROW>
+		<REPO 
+			id="{\$x/../../../../HEADER/RESOURCE_IDENTIFIER/@value/string()}" 
+			name="{\$x/../../OFFICIAL_NAME/text()}" 
+			country="{\$x/../../COUNTRY/text()}" 
+			prefix="{\$x/../..//EXTRA_FIELDS/FIELD[./key='NamespacePrefix']/value}" />
+		{\$x}
+	</ROW>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/.springBeans
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/.springBeans	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2/.springBeans	(revision 45190)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+	<version>1</version>
+	<pluginVersion><![CDATA[3.6.2.201410090854-RELEASE]]></pluginVersion>
+	<configSuffixes>
+		<configSuffix><![CDATA[xml]]></configSuffix>
+	</configSuffixes>
+	<enableImports><![CDATA[false]]></enableImports>
+	<configs>
+		<config>src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml</config>
+	</configs>
+	<autoconfigs>
+	</autoconfigs>
+	<configSets>
+	</configSets>
+</beansProjectDescription>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2	(revision 45190)

Property changes on: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.2
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+target
+.classpath
+.settings
+.project
+
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/templates/findReposMap.xquery	(revision 45190)
@@ -0,0 +1,11 @@
+for $x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where 
+	$x//NUMBER_OF_OBJECTS != 0 and not($x//LATITUDE = 0 and $x//LONGITUDE = 0) 
+return 
+<ds>
+	<dsId>{$x//RESOURCE_IDENTIFIER/@value/string()}</dsId>
+	<name>{$x//OFFICIAL_NAME/text()}</name>
+	<lat>{$x//LATITUDE/text()}</lat>
+	<lng>{$x//LONGITUDE/text()}</lng>
+</ds>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/resources/eu/dnetlib/enabling/datasources/applicationContext-datasource-manager-service.xml	(revision 45190)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	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://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<bean id="datasourceManagerService"
+		class="eu.dnetlib.enabling.datasources.DatasourceManagerServiceImpl">
+		<property name="browsableFields">
+			<list>
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="country" p:label="Datasource countries" p:xpath="../../COUNTRY/text()"
+					p:vocabulary="dnet:countries" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="type" p:label="API typologies" p:xpath="@typology/string()"
+					p:vocabulary="dnet:datasource_typologies" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="protocol" p:label="API protocols" p:xpath="ACCESS_PROTOCOL/text()"
+					p:vocabulary="dnet:protocols" />
+				<bean class="eu.dnetlib.enabling.datasources.XmlBrowsableField"
+					p:id="compliance" p:label="API compatibility levels"
+					p:xpath="concat(substring(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'], 1, number(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])) * string-length(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance'])), substring(@compliance, 1, number(not(boolean(./INTERFACE_EXTRA_FIELD[@name='overriding_compliance']))) * string-length(@compliance)))"
+					p:vocabulary="dnet:compatibilityLevel" />
+			</list>
+		</property>
+	</bean>
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="datasourceManagerServiceEndpoint"
+		implementor="#datasourceManagerService"
+		implementorClass="eu.dnetlib.enabling.datasources.rmi.DatasourceManagerService"
+		address="/datasourceManager" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="datasourceManagerServiceRegistrationManager" t:service="datasourceManagerService"
+		t:endpoint="datasourceManagerServiceEndpoint" t:jobScheduler="jobScheduler" />
+
+</beans>
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(revision 45190)
@@ -0,0 +1,98 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+
+import com.google.common.base.Function;
+
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class ProfileToDatasourceDesc implements Function<String, DatasourceDesc> {
+
+	private static final Log log = LogFactory.getLog(ProfileToDatasourceDesc.class);
+
+	@Override
+	public DatasourceDesc apply(final String profile) {
+		try {
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+
+	public static DatasourceDesc convert(final String profile) throws Exception {
+		final SAXReader reader = new SAXReader();
+		final Document doc = reader.read(new StringReader(profile));
+
+		final DatasourceDesc ds = new DatasourceDesc();
+		ds.setId(doc.valueOf("//RESOURCE_IDENTIFIER/@value"));
+		ds.setDatasourceClass(doc.valueOf("//DATASOURCE_TYPE"));
+		ds.setTypology(doc.valueOf("//TYPOLOGY"));
+		ds.setOfficialName(doc.valueOf("//OFFICIAL_NAME"));
+		ds.setEnglishName(doc.valueOf("//ENGLISH_NAME"));
+		ds.setCountryCode(doc.valueOf("//COUNTRY"));
+		ds.setLongitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LONGITUDE"), 0.0));
+		ds.setLatitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LATITUDE"), 0.0));
+		ds.setTimezone(NumberUtils.toDouble(doc.valueOf("//LOCATION/TIMEZONE"), 0.0));
+		ds.setWebsiteUrl(doc.valueOf("//REPOSITORY_WEBPAGE"));
+		ds.setOrganization(doc.valueOf("//REPOSITORY_INSTITUTION"));
+		ds.setContactEmail(doc.valueOf("//ADMIN_INFO"));
+
+		for (Object o : doc.selectNodes("//INTERFACES/INTERFACE")) {
+			final Element n = (Element) o;
+
+			final IfaceDesc ifc = new IfaceDesc();
+
+			ifc.setId(n.valueOf("@id"));
+			ifc.setCompliance(n.valueOf("@compliance"));
+			ifc.setTypology(n.valueOf("@typology"));
+			ifc.setContentDescription(n.valueOf("@contentDescription"));
+			ifc.setActive(BooleanUtils.toBoolean(n.valueOf("@active")));
+			ifc.setRemovable(BooleanUtils.toBoolean(n.valueOf("@removable")));
+			ifc.setBaseUrl(n.valueOf("./BASE_URL"));
+			ifc.setAccessProtocol(n.valueOf("./ACCESS_PROTOCOL"));
+
+			for (Object o1 : n.selectNodes("./ACCESS_PROTOCOL/@*")) {
+				final Node attr = (Node) o1;
+				ifc.getAccessParams().put(attr.getName(), attr.getText());
+			}
+			for (Object o1 : n.selectNodes("./INTERFACE_EXTRA_FIELD")) {
+				final Node f = (Node) o1;
+				ifc.getExtraFields().put(f.valueOf("@name"), f.getText());
+			}
+
+			ds.getInterfaces().add(ifc);
+		}
+
+		final DateUtils dateUtils = new DateUtils();
+		for (Object o : doc.selectNodes("//EXTRA_FIELDS/EXTRA_FIELD")) {
+			final String k = ((Element) o).valueOf("./key").trim();
+			final String v = ((Element) o).valueOf("./value").trim();
+
+			if (k.equalsIgnoreCase("ACTIVATION_ID")) {
+				ds.setActivationId(v);
+			} else if (k.equalsIgnoreCase("NamespacePrefix")) {
+				ds.setNamespacePrefix(v);
+			} else if (k.equalsIgnoreCase("aggregatorName")) {
+				ds.setAggregator(v);
+			} else if (k.equalsIgnoreCase("dateOfCollection")) {
+				ds.setDateOfCollection(dateUtils.parse(v));
+			} else if (k.equalsIgnoreCase("dateOfValidation")) {
+				ds.setDateOfValidation(dateUtils.parse(v));
+			}
+		}
+
+		return ds;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1	(revision 45190)

Property changes on: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.1
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+target
+.classpath
+.settings
+.project
+
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/pom.xml
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/pom.xml	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/pom.xml	(revision 45190)
@@ -0,0 +1,34 @@
+<?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>
+    		<groupId>eu.dnetlib</groupId>
+	        <artifactId>dnet-parent</artifactId>
+                <version>1.0.0</version>
+  	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-datasource-manager-service</artifactId>
+	<packaging>jar</packaging>
+	<version>1.0.0</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-datasource-manager-rmi</artifactId>
+			<version>[4.0.0, 5.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-service-common</artifactId>
+			<version>[2.1.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+  		    <groupId>junit</groupId>
+    		    <artifactId>junit</artifactId>
+      		    <version>${junit.version}</version>
+	            <scope>test</scope>
+    		</dependency>
+	</dependencies>
+</project>
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/resources/eu/dnetlib/enabling/datasources/templates/simpleFindRepos.xquery.st	(revision 45190)
@@ -0,0 +1,12 @@
+for \$x in
+	collection('/db/DRIVER/RepositoryServiceResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ true'),
+for \$x in
+	collection('/db/DRIVER/PendingRepositoryResources/RepositoryServiceResourceType')
+where
+	\$x//DATASOURCE_TYPE = '$type$'
+return
+	concat(\$x//RESOURCE_IDENTIFIER/@value, ' @=@ ', \$x//OFFICIAL_NAME, ' @=@ ', \$x//DATASOURCE_ORIGINAL_ID, ' @=@ ', string-join(\$x//INTERFACE/@id, ','), ' @=@ false')
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/src/main/java/eu/dnetlib/enabling/datasources/ProfileToDatasourceDesc.java	(revision 45190)
@@ -0,0 +1,98 @@
+package eu.dnetlib.enabling.datasources;
+
+import java.io.StringReader;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.apache.commons.lang.math.NumberUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.dom4j.Document;
+import org.dom4j.Element;
+import org.dom4j.Node;
+import org.dom4j.io.SAXReader;
+
+import com.google.common.base.Function;
+
+import eu.dnetlib.enabling.datasources.rmi.DatasourceDesc;
+import eu.dnetlib.enabling.datasources.rmi.IfaceDesc;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class ProfileToDatasourceDesc implements Function<String, DatasourceDesc> {
+
+	private static final Log log = LogFactory.getLog(ProfileToDatasourceDesc.class);
+
+	@Override
+	public DatasourceDesc apply(final String profile) {
+		try {
+			return ProfileToDatasourceDesc.convert(profile);
+		} catch (Exception e) {
+			log.error("Error convering profile", e);
+			return null;
+		}
+	}
+
+	public static DatasourceDesc convert(final String profile) throws Exception {
+		final SAXReader reader = new SAXReader();
+		final Document doc = reader.read(new StringReader(profile));
+
+		final DatasourceDesc ds = new DatasourceDesc();
+		ds.setId(doc.valueOf("//RESOURCE_IDENTIFIER/@value"));
+		ds.setDatasourceClass(doc.valueOf("//DATASOURCE_TYPE"));
+		ds.setTypology(doc.valueOf("//TYPOLOGY"));
+		ds.setOfficialName(doc.valueOf("//OFFICIAL_NAME"));
+		ds.setEnglishName(doc.valueOf("//ENGLISH_NAME"));
+		ds.setCountryCode(doc.valueOf("//COUNTRY"));
+		ds.setLongitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LONGITUDE"), 0.0));
+		ds.setLatitude(NumberUtils.toDouble(doc.valueOf("//LOCATION/LATITUDE"), 0.0));
+		ds.setTimezone(NumberUtils.toDouble(doc.valueOf("//LOCATION/TIMEZONE"), 0.0));
+		ds.setWebsiteUrl(doc.valueOf("//REPOSITORY_WEBPAGE"));
+		ds.setOrganization(doc.valueOf("//REPOSITORY_INSTITUTION"));
+		ds.setContactEmail(doc.valueOf("//ADMIN_INFO"));
+
+		for (Object o : doc.selectNodes("//INTERFACES/INTERFACE")) {
+			final Element n = (Element) o;
+
+			final IfaceDesc ifc = new IfaceDesc();
+
+			ifc.setId(n.valueOf("@id"));
+			ifc.setCompliance(n.valueOf("@compliance"));
+			ifc.setTypology(n.valueOf("@typology"));
+			ifc.setContentDescription(n.valueOf("@contentDescription"));
+			ifc.setActive(BooleanUtils.toBoolean(n.valueOf("@active")));
+			ifc.setRemovable(BooleanUtils.toBoolean(n.valueOf("@removable")));
+			ifc.setBaseUrl(n.valueOf("./BASE_URL"));
+			ifc.setAccessProtocol(n.valueOf("./ACCESS_PROTOCOL"));
+
+			for (Object o1 : n.selectNodes("./ACCESS_PROTOCOL/@*")) {
+				final Node attr = (Node) o1;
+				ifc.getAccessParams().put(attr.getName(), attr.getText());
+			}
+			for (Object o1 : n.selectNodes("./INTERFACE_EXTRA_FIELD")) {
+				final Node f = (Node) o1;
+				ifc.getExtraFields().put(f.valueOf("@name"), f.getText());
+			}
+
+			ds.getInterfaces().add(ifc);
+		}
+
+		final DateUtils dateUtils = new DateUtils();
+		for (Object o : doc.selectNodes("//EXTRA_FIELDS/EXTRA_FIELD")) {
+			final String k = ((Element) o).valueOf("./key").trim();
+			final String v = ((Element) o).valueOf("./value").trim();
+
+			if (k.equalsIgnoreCase("ACTIVATION_ID")) {
+				ds.setActivationId(v);
+			} else if (k.equalsIgnoreCase("NamespacePrefix")) {
+				ds.setNamespacePrefix(v);
+			} else if (k.equalsIgnoreCase("aggregatorName")) {
+				ds.setAggregator(v);
+			} else if (k.equalsIgnoreCase("dateOfCollection")) {
+				ds.setDateOfCollection(dateUtils.parse(v));
+			} else if (k.equalsIgnoreCase("dateOfValidation")) {
+				ds.setDateOfValidation(dateUtils.parse(v));
+			}
+		}
+
+		return ds;
+	}
+}
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/deploy.info
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/deploy.info	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0/deploy.info	(revision 45190)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-datasource-manager-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "dnet-datasource-manager-service"}
\ No newline at end of file
Index: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0
===================================================================
--- modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0	(nonexistent)
+++ modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0	(revision 45190)

Property changes on: modules/dnet-datasource-manager-service/tags/dnet-datasource-manager-service-1.0.0
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+target
+.classpath
+.settings
+.project
+
