Index: modules/uoa-claims-api/branches/indexFeed/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(revision 47510)
@@ -0,0 +1,35 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.TException;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * Created by antleb on 6/20/14.
+ */
+public class TestConnector {
+
+	public static void main(String[] args) throws TException {
+
+		OpenAIREConnector.Client client = new ThriftClient().getConnector("194.177.192.223", 7911);
+
+		String id = client.insertDocument("123123/3434.23", "doi", "a title", " a description", "OPEN ACCESS", null,
+                Arrays.asList(new Author("id" ,"lastname", "firstname")), "url", "dcsource", "antleb@di.uoa.gr",
+                Arrays.asList("subject"), "2012-01-02", "publisher", "language", "category", "doioioioi" ,
+                new ArrayList<Project4Index>(), new ArrayList<String>());
+		System.out.println(id);
+
+		client.insertConcept(id, "doi", "egi", "antleb@di.uoa.gr", "123");
+		client.insertProjectRelation(id, "doi", new Project("ec", "1233312"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "doi", new Project(null, "1233312"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "doi", id, "result", "antleb@di.uoa.gr");
+
+		id = "od______1406::fbda7b28cda277b04c8dc27a5e0deb68";
+
+		client.insertConcept(id, "openaire", "ec", "antleb@di.uoa.gr", "123");
+		client.insertProjectRelation(id, "openaire", new Project("ec", "099809987"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "openaire", new Project(null, "098908908"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "openaire", id, "dataset", "antleb@di.uoa.gr");
+	}
+}
Index: modules/uoa-claims-api/branches/indexFeed/pom.xml
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/pom.xml	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/pom.xml	(revision 47510)
@@ -0,0 +1,148 @@
+<?xml version="1.0"?>
+<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>uoa-openaire-connector</artifactId>
+	<version>1.3.1-SNAPSHOT</version>
+        <scm>
+                <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk</developerConnection>
+        </scm>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>dtrotts</id>
+			<name>Repository for maven thrift plugin</name>
+			<url>http://maven.davidtrott.com/repository</url>
+			<layout>default</layout>
+		</pluginRepository>
+	</pluginRepositories>
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<archive>
+
+					</archive>
+					<descriptorRefs>
+						<descriptorRef>jar-with-dependencies</descriptorRef>
+					</descriptorRefs>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.thrift.tools</groupId>
+				<artifactId>maven-thrift-plugin</artifactId>
+				<version>0.1.10</version>
+				<executions>
+					<execution>
+						<id>thrift-sources</id>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>compile</goal>
+						</goals>
+					</execution>
+					<execution>
+						<id>thrift-test-sources</id>
+						<phase>generate-test-sources</phase>
+						<goals>
+							<goal>testCompile</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings 
+					only. It has no influence on the Maven build itself. -->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>org.apache.thrift.tools</groupId>
+										<artifactId>maven-thrift-plugin</artifactId>
+										<versionRange>[0.1.10,)</versionRange>
+										<goals>
+											<goal>testCompile</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore />
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>[0.0.0,)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.7.5</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-dbcp</groupId>
+			<artifactId>commons-dbcp</artifactId>
+			<version>[1.2, 1.3)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-utils</artifactId>
+			<version>[1.1.0, 1.3.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-commons</artifactId>
+			<version>[1.1.0, 1.3.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.thrift</groupId>
+			<artifactId>libthrift</artifactId>
+			<version>0.8.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.postgresql</groupId>
+			<artifactId>jdbc4driver</artifactId>
+			<version>9.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.velocity</groupId>
+			<artifactId>velocity</artifactId>
+			<version>1.7</version>
+		</dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.googlecode.json-simple</groupId>
+            <artifactId>json-simple</artifactId>
+            <version>1.1</version>
+        </dependency>
+    </dependencies>
+
+</project>
Index: modules/uoa-claims-api/branches/newClaimSchema/pom.xml
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/pom.xml	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/pom.xml	(revision 47510)
@@ -0,0 +1,143 @@
+<?xml version="1.0"?>
+<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>uoa-openaire-connector</artifactId>
+	<version>1.3.1-SNAPSHOT</version>
+        <scm>
+                <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk</developerConnection>
+        </scm>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>dtrotts</id>
+			<name>Repository for maven thrift plugin</name>
+			<url>http://maven.davidtrott.com/repository</url>
+			<layout>default</layout>
+		</pluginRepository>
+	</pluginRepositories>
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<archive>
+
+					</archive>
+					<descriptorRefs>
+						<descriptorRef>jar-with-dependencies</descriptorRef>
+					</descriptorRefs>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.thrift.tools</groupId>
+				<artifactId>maven-thrift-plugin</artifactId>
+				<version>0.1.10</version>
+				<executions>
+					<execution>
+						<id>thrift-sources</id>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>compile</goal>
+						</goals>
+					</execution>
+					<execution>
+						<id>thrift-test-sources</id>
+						<phase>generate-test-sources</phase>
+						<goals>
+							<goal>testCompile</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings 
+					only. It has no influence on the Maven build itself. -->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>org.apache.thrift.tools</groupId>
+										<artifactId>maven-thrift-plugin</artifactId>
+										<versionRange>[0.1.10,)</versionRange>
+										<goals>
+											<goal>testCompile</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore />
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>[0.0.0,)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.7.5</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-dbcp</groupId>
+			<artifactId>commons-dbcp</artifactId>
+			<version>[1.2, 1.3)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-utils</artifactId>
+			<version>[1.1.0, 1.2.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-commons</artifactId>
+			<version>[1.1.0, 1.2.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.thrift</groupId>
+			<artifactId>libthrift</artifactId>
+			<version>0.8.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.postgresql</groupId>
+			<artifactId>jdbc4driver</artifactId>
+			<version>9.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.velocity</groupId>
+			<artifactId>velocity</artifactId>
+			<version>1.7</version>
+		</dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>
Index: modules/uoa-claims-api/branches/newClaimAPI/src/main/java/eu/dnetlib/openaire/rest/HelloWorldService.java
===================================================================
--- modules/uoa-claims-api/branches/newClaimAPI/src/main/java/eu/dnetlib/openaire/rest/HelloWorldService.java	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimAPI/src/main/java/eu/dnetlib/openaire/rest/HelloWorldService.java	(revision 47510)
@@ -0,0 +1,1120 @@
+package eu.dnetlib.openaire.rest;
+
+import com.google.gson.*;
+import eu.dnetlib.api.enabling.ISLookUpService;
+import eu.dnetlib.api.enabling.ISLookUpServiceException;
+import eu.dnetlib.data.claims.migration.ClaimValidationException;
+import eu.dnetlib.data.claims.migration.entity.Claim;
+import eu.dnetlib.data.claims.migration.handler.ClaimHandler;
+import eu.dnetlib.data.claims.migration.handler.DirectIndexHandler;
+import eu.dnetlib.data.claims.migration.handler.FetchClaimHandler;
+import eu.dnetlib.data.claims.migration.handler.FetchProjectHandler;
+import eu.dnetlib.data.claimsDemo.SQLStoreException;
+import eu.dnetlib.openaire.rest.authorization.Authorization;
+import eu.dnetlib.openaire.rest.inputHandler.UserHandler;
+import eu.dnetlib.openaire.rest.security.JWTValidator;
+import gr.uoa.di.driver.util.ServiceLocator;
+import org.apache.commons.validator.EmailValidator;
+import org.apache.log4j.Logger;
+import org.json.XML;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by kiatrop on 15/4/2016.
+ */
+@Component
+@Path("/claimsService")
+public class HelloWorldService {
+
+    private static final Logger logger = Logger.getLogger(HelloWorldService.class);
+
+    @Autowired
+    private FetchClaimHandler fetchClaimHandler = null;
+
+    @Autowired
+    private FetchProjectHandler fetchProjectHandler= null;
+
+    @Resource
+    private ServiceLocator<ISLookUpService> lookupServiceLocator = null;
+
+    @Autowired
+    private ClaimHandler claimHandler = null;
+
+    @Autowired
+    private DirectIndexHandler directIndexHandler = null;
+
+
+
+    @GET
+    @Path("projects/{projectId}/claims")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getProjectClaims(@PathParam("projectId") String projectId,
+                           @DefaultValue("0") @QueryParam("offset") int offset,
+                           @DefaultValue("20") @QueryParam("limit") int limit,
+                           @DefaultValue("") @QueryParam("keyword") String keyword,
+                           @DefaultValue("") @QueryParam("sortby") String orderby,
+                           @DefaultValue("true") @QueryParam("descending") boolean descending,
+                           @DefaultValue("") @QueryParam("types") String types,
+                                     @QueryParam("token") String token,
+                           @Context HttpServletRequest request) {
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+        if(Authorization.isAdmin(token)) {
+
+            int total = -1;
+
+            if (projectId == null || projectId.isEmpty()) {
+                return Response.status(Response.Status.BAD_REQUEST).entity(compose400Message("Project id cannot be empty."))
+                        .type(MediaType.APPLICATION_JSON).build();
+            }
+
+            List<Claim> claims = null;
+            List<String> listTypes = new ArrayList<String>();
+            String[] types_array = types.split(",");
+            for (int i = 0; i < types_array.length; i++) {
+                if (types_array[i].length() > 0) {
+                    listTypes.add(types_array[i]);
+                }
+            }
+            try {
+                claims = fetchClaimHandler.fetchClaimsByProject(projectId, limit, offset, keyword, orderby, descending, listTypes,false);
+                total = fetchClaimHandler.countClaimsByProject(projectId, keyword, listTypes);
+
+            } catch (SQLStoreException|Exception e) {  //TODO check this with exception
+                logger.error("Could not fetch claims for project with id " + projectId, e);
+                return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500Message("Fail to fetch claims" +
+                        " for projects with id " + projectId + ".", e)).type(MediaType.APPLICATION_JSON).build();
+
+            }
+
+            return Response.status(200).entity(composeDataResponse(request, claims, total, offset, limit)).build();
+        }
+
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access"))
+                .type(MediaType.APPLICATION_JSON)
+                .build();
+    }
+
+    @GET
+    @Path("project/claims")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getProjectClaimsByToken(@QueryParam("projectToken") String projectToken,
+                                     @DefaultValue("-1") @QueryParam("offset") int offset,
+                                     @DefaultValue("-1") @QueryParam("limit") int limit,
+                                     @DefaultValue("") @QueryParam("keyword") String keyword,
+                                     @DefaultValue("") @QueryParam("sortby") String orderby,
+                                     @DefaultValue("true") @QueryParam("descending") boolean descending,
+                                     @DefaultValue("") @QueryParam("types") String types,
+                                     @QueryParam("token") String token,
+                                     @Context HttpServletRequest request) {
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+        if(Authorization.isRegistered(token)) {
+            String userMail = UserHandler.getMail(token);
+
+            int total = -1;
+
+            if (projectToken == null || projectToken.isEmpty()) {
+                return Response.status(Response.Status.BAD_REQUEST).entity(compose400Message("Project token cannot be empty."))
+                        .type(MediaType.APPLICATION_JSON).build();
+            }
+
+            List<Claim> claims = null;
+            List<String> listTypes = new ArrayList<String>();
+            String[] types_array = types.split(",");
+            for (int i = 0; i < types_array.length; i++) {
+                if (types_array[i].length() > 0) {
+                    listTypes.add(types_array[i]);
+                }
+            }
+            try {
+                String projectId = fetchProjectHandler.fetchProjectIdByToken(projectToken,userMail);
+                if(projectId == null){
+                    return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access"))
+                            .type(MediaType.APPLICATION_JSON)
+                            .build();
+                }else{
+                    if(offset == -1 && limit == -1) {
+                        // when offset and limit are -1 fetch claims with null values, to ignore paging and limit clause
+                        claims = fetchClaimHandler.fetchClaimsByProject(projectId, null, null, keyword, orderby, descending, listTypes, true);
+                    } else {
+                        claims = fetchClaimHandler.fetchClaimsByProject(projectId, limit, offset, keyword, orderby, descending, listTypes, true);
+                    }
+                    total = fetchClaimHandler.countClaimsByProject(projectId, keyword, listTypes);
+
+                    return Response.status(200).entity(composeDataResponse(request, claims, total, offset, limit)).build();
+                }
+
+            } catch (SQLStoreException|Exception e) {
+                logger.error("Could not fetch claims for project token " + projectToken, e);
+                return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500Message("Fail to fetch claims" +
+                        " for projects with token " + projectToken + ".", e)).type(MediaType.APPLICATION_JSON).build();
+            }
+        }
+
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access"))
+                .type(MediaType.APPLICATION_JSON)
+                .build();
+    }
+    @GET
+    @Path("/contexts/{contextId}/claims")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getContextClaims(@PathParam("contextId") String contextId,
+                           @DefaultValue("0") @QueryParam("offset") int offset,
+                           @DefaultValue("20") @QueryParam("limit") int limit,
+                           @DefaultValue("") @QueryParam("keyword") String keyword,
+                           @DefaultValue("") @QueryParam("sortby") String orderby,
+                           @DefaultValue("true") @QueryParam("descending") boolean descending,
+                           @DefaultValue("") @QueryParam("types") String types,
+                                     @QueryParam("token") String token,
+                                     @Context HttpServletRequest request) {
+
+        logger.debug("Calling API for context with token " + token);
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+
+        if(Authorization.isAdmin(token)) {
+
+            int total = -1;
+            if (contextId == null || contextId.isEmpty()) {
+                return Response.status(Response.Status.BAD_REQUEST).entity(compose400Message("Context id cannot be empty."))
+                        .type(MediaType.APPLICATION_JSON).build();
+            }
+
+            List<Claim> claims = null;
+            List<String> listTypes = new ArrayList<String>();
+            String[] types_array = types.split(",");
+            for (int i = 0; i < types_array.length; i++) {
+                if (types_array[i].length() > 0) {
+                    listTypes.add(types_array[i]);
+                }
+            }
+            try {
+                claims = fetchClaimHandler.fetchClaimsByContext(contextId, limit, offset, keyword, orderby, descending, listTypes,false);
+                total = fetchClaimHandler.countClaimsByContext(contextId, keyword, listTypes);
+
+            } catch (SQLStoreException|Exception e) {
+                logger.error("Could not fetch claims for context with id " + contextId, e);
+                return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500Message("Fail to fetch claims" +
+                        " for context with id " + contextId + ".", e)).type(MediaType.APPLICATION_JSON).build();
+            }
+
+            return Response.status(200).entity(composeDataResponse(request, claims, total, offset, limit)).build();
+        }
+
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access"))
+                .type(MediaType.APPLICATION_JSON)
+                .build();
+    }
+
+
+    @GET
+    @Path("/results/{resultId}/claims")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getResultClaims(@PathParam("resultId") String resultId,
+                                    @DefaultValue("0") @QueryParam("offset") int offset,
+                                    @DefaultValue("20") @QueryParam("limit") int limit,
+                                    @DefaultValue("") @QueryParam("keyword") String keyword,
+                                    @DefaultValue("") @QueryParam("sortby") String orderby,
+                                    @DefaultValue("true") @QueryParam("descending") boolean descending,
+                                    @DefaultValue("") @QueryParam("types") String types,
+                                    @QueryParam("token") String token,
+                                    @Context HttpServletRequest request) {
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+        if(Authorization.isAdmin(token)) {
+
+            int total = -1;
+            if (resultId == null || resultId.isEmpty()) {
+                return Response.status(Response.Status.BAD_REQUEST).entity(compose400Message("Context id cannot be empty."))
+                        .type(MediaType.APPLICATION_JSON).build();
+            }
+
+            List<Claim> claims = null;
+            List<String> listTypes = new ArrayList<String>();
+            String[] types_array = types.split(",");
+            for (int i = 0; i < types_array.length; i++) {
+                if (types_array[i].length() > 0) {
+                    listTypes.add(types_array[i]);
+                }
+            }
+
+            try {
+                claims = fetchClaimHandler.fetchClaimsByResult(resultId, limit, offset, keyword, orderby, descending, listTypes,false);
+                total = fetchClaimHandler.countClaimsByResult(resultId, keyword, listTypes);
+
+            } catch (SQLStoreException|Exception e) {
+                logger.error("Could not fetch claims for result with id " + resultId, e);
+                return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500Message("Fail to fetch claims" +
+                        " for result with id " + resultId + ".", e)).type(MediaType.APPLICATION_JSON).build();
+            }
+
+            return Response.status(200).entity(composeDataResponse(request, claims, total, offset, limit)).build();
+        }
+
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access"))
+                .type(MediaType.APPLICATION_JSON)
+                .build();
+    }
+
+
+    @GET
+    @Path("/users/{userMail}/claims")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getUserClaims(@PathParam("userMail") String userMail,
+                                  @DefaultValue("0") @QueryParam("offset") int offset,
+                                  @DefaultValue("20") @QueryParam("limit") int limit,
+                                  @DefaultValue("") @QueryParam("keyword") String keyword,
+                                  @DefaultValue("") @QueryParam("sortby") String orderby,
+                                  @DefaultValue("true") @QueryParam("descending") boolean descending,
+                                  @DefaultValue("") @QueryParam("types") String types,
+                                  @QueryParam("token") String token,
+                                  @Context HttpServletRequest request) {
+
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+        if(Authorization.isRegistered(token)) {
+//            String userMail = UserHandler.getMail(token);
+            int total = -1;
+            EmailValidator emailValidator = EmailValidator.getInstance();
+
+            if (userMail == null || userMail.isEmpty()) {
+                return Response.status(Response.Status.BAD_REQUEST).entity(compose400Message("User e-mail cannot be empty."))
+                        .type(MediaType.APPLICATION_JSON).build();
+            }
+
+            if (!emailValidator.isValid(userMail)) {
+                return Response.status(Response.Status.BAD_REQUEST).entity(compose400Message("User e-mail is not valid."))
+                        .type(MediaType.APPLICATION_JSON).build();
+            }
+
+            List<Claim> claims = null;
+            List<String> listTypes = new ArrayList<String>();
+            String[] types_array = types.split(",");
+            for (int i = 0; i < types_array.length; i++) {
+                if (types_array[i].length() > 0) {
+                    listTypes.add(types_array[i]);
+                }
+            }
+            try {
+                claims = fetchClaimHandler.fetchClaimsByUser(userMail, limit, offset, keyword, orderby, descending, listTypes,false);
+                total = fetchClaimHandler.countClaimsByUser(userMail, keyword, listTypes);
+
+            } catch (SQLStoreException|Exception e) {
+                logger.error("Could not fetch claims for result with id " + userMail, e);
+                return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500Message("Fail to fetch claims" +
+                        " for user with e-mail " + userMail + ".", e)).type(MediaType.APPLICATION_JSON).build();
+            }
+
+            return Response.status(200).entity(composeDataResponse(request, claims, total, offset, limit)).build();
+        }
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access. You are not registered."))
+                .type(MediaType.APPLICATION_JSON)
+                .build();
+    }
+
+    @GET
+    @Path("/claims/{claimId}")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getClaimsById(@PathParam("claimId") String claimId,
+                                  @DefaultValue("0") @QueryParam("offset") int offset,
+                                  @DefaultValue("20") @QueryParam("limit") int limit,
+                                  @QueryParam("token") String token,
+                                  @Context HttpServletRequest request) {
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+        if(Authorization.isRegistered(token)) {
+
+            List<Claim> claims = null;
+
+            int total = -1;
+            if (claimId == null || claimId.isEmpty()) {
+                try {
+                    claims = fetchClaimHandler.fetchAllClaims(limit, offset,false);
+                    total = fetchClaimHandler.countAllClaims("", new ArrayList<String>());
+
+                    return Response.status(200).entity(composeDataResponse(request, claims, total, offset, limit)).type(MediaType.APPLICATION_JSON).build();
+
+                } catch (SQLStoreException|Exception e) {
+                    logger.error("Could not fetch claims.", e);
+                    return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500Message("Fail to fetch claims.", e))
+                            .type(MediaType.APPLICATION_JSON).build();
+                }
+            }
+
+            try {
+                Claim claim = fetchClaimHandler.fetchClaimById(claimId,false);
+                if (claim == null) {
+                    return Response.status(Response.Status.NOT_FOUND).entity(compose404Message("Cannot find claim with id " + claimId + "."))
+                            .type(MediaType.APPLICATION_JSON).build();
+                }
+
+                return Response.status(200).entity(composeDataResponse(claim)).build();
+
+            } catch (SQLStoreException|Exception e) {
+                return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500Message("Fail to fetch claim " +
+                        "with id " + claimId + " id.", e)).type(MediaType.APPLICATION_JSON).build();
+            }
+        }
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access. You are not registered."))
+                .type(MediaType.APPLICATION_JSON)
+                .build();
+    }
+
+    @GET
+    @Path("/claims")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getAllClaims(@DefaultValue("0") @QueryParam("offset") int offset,
+                                  @DefaultValue("20") @QueryParam("limit") int limit,
+                                  @DefaultValue("") @QueryParam("keyword") String keyword,
+                                  @DefaultValue("date") @QueryParam("sortby") String orderby,
+                                  @DefaultValue("true") @QueryParam("descending") boolean descending,
+                                  @DefaultValue("") @QueryParam("types") String types,
+                                  @QueryParam("token") String token,
+                                  @Context HttpServletRequest request) {
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+        if(Authorization.isAdmin(token)) {
+
+            List<Claim> claims = null;
+            List<String> listTypes = new ArrayList<String>();
+            String[] types_array = types.split(",");
+            for (int i = 0; i < types_array.length; i++) {
+                if (types_array[i].length() > 0) {
+                    listTypes.add(types_array[i]);
+                }
+            }
+            logger.debug("Types: " + listTypes.toString());
+
+            int total = -1;
+            try {
+                claims = fetchClaimHandler.fetchAllClaims(limit, offset, keyword, orderby, descending, listTypes,false);
+                total = fetchClaimHandler.countAllClaims(keyword, listTypes);
+
+                return Response.status(200).entity(composeDataResponse(request, claims, total, offset, limit)).build();
+
+            } catch (SQLStoreException|Exception e) {
+                logger.error("Could not fetch claims.", e);
+                return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500Message("Fail to fetch claims.", e))
+                        .type(MediaType.APPLICATION_JSON).build();
+            }
+        }
+
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access"))
+               .type(MediaType.APPLICATION_JSON)
+               .build();
+    }
+
+    //ARGIRO TODO: Na thn tsekarw
+//    @POST
+//    @Path("/claims/{claimId}")
+//    @Produces(MediaType.APPLICATION_JSON)
+//    public Response deleteClaim(@PathParam("claimId") String claimId,
+//                                @QueryParam("token") String token) {
+//
+//        if(!JWTValidator.isValid(token)) {
+//            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+//                    .type(MediaType.APPLICATION_JSON)
+//                    .build();
+//        }
+//        try {
+//
+//            if (Authorization.isRegistered(token) && (userHandler.getMail(token).equals(fetchClaimHandler.fetchClaimById(claimId).getUserMail()))) {
+//                if (claimId == null || claimId.isEmpty()) {
+//                    return Response.status(Response.Status.NOT_FOUND).entity(compose404Message("Claim id cannot be empty."))
+//                            .type(MediaType.APPLICATION_JSON).build();
+//                }
+//
+//                try {
+//                    if (claimHandler.deleteClaim(claimId)) {
+//                        return Response.status(204).entity(compose204Message()).type(MediaType.APPLICATION_JSON).build();
+//                    }
+//
+//                } catch (Exception e) {
+//                    logger.error("Fail to delete claim with id " + claimId + ".", e);
+//                    return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500Message("Fail to delete claim with id " + claimId + ".", e))
+//                            .type(MediaType.APPLICATION_JSON).build();
+//                }
+//
+//                return Response.status(Response.Status.NOT_FOUND).entity(compose404Message("Claim id cannot be empty."))
+//                        .type(MediaType.APPLICATION_JSON).build();
+//            }
+//
+//            return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access. Maybe you are not registered."))
+//                    .type(MediaType.APPLICATION_JSON)
+//                    .build();
+//
+//        } catch (Exception e) {
+//            logger.error("Could not fetch claims.", e);
+//            return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500Message("Fail to fetch claims.", e))
+//                    .type(MediaType.APPLICATION_JSON).build();
+//        }
+//    }
+/*
+
+    @DELETE
+    @Path("/claims/{claimId}")
+    public Response deleteClaim(@PathParam("claimId") String claimId) {
+
+        if (claimId == null || claimId.isEmpty()) {
+            return Response.status(Response.Status.NOT_FOUND).entity(compose404Message("Claim id cannot be empty.")).header("Access-Control-Allow-Origin", "*")
+                    .header("Access-Control-Allow-Methods", "DELETE")
+                    .type(MediaType.APPLICATION_JSON).build();
+        }
+
+        try {
+            if(claimHandler.deleteClaim(claimId)) {
+                return Response.status(204).entity(compose204Message()).header("Access-Control-Allow-Origin", "*")
+                        .header("Access-Control-Allow-Methods", "DELETE").type(MediaType.APPLICATION_JSON).build();
+            }
+
+        } catch (Exception e) {return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+            logger.error("Fail to delete claim with id " + claimId + ".", e);
+            return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500Message("Fail to delete claim with id " + claimId +".", e))
+                    .header("Access-Control-Allow-Origin", "*")
+                    .header("Access-Control-Allow-Methods", "DELETE")
+                    .type(MediaType.APPLICATION_JSON).build();
+        }
+
+        return Response.status(Response.Status.NOT_FOUND).entity(compose404Message("Claim id cannot be empty.")).header("Access-Control-Allow-Origin", "*")
+                .header("Access-Control-Allow-Methods", "DELETE")
+                .type(MediaType.APPLICATION_JSON).build();
+    }
+ */
+    @DELETE
+    @Path("/claims/bulk")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response deleteBulkClaims(@QueryParam("claimId") List<String> claimIds,
+                                     @QueryParam("token") String token) {
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+
+        ArrayList<String> deletedIds= new ArrayList<String>();
+        ArrayList<String> notFoundIds= new ArrayList<String>();
+
+        if (claimIds == null || claimIds.size() == 0) {
+            return Response.status(Response.Status.NOT_FOUND).entity(compose404BulkDeleteMessage("Claim ids cannot be empty.",deletedIds,notFoundIds))
+                    .type(MediaType.APPLICATION_JSON).build();
+        }
+
+        logger.debug("Trying to delete claims with ids: " + claimIds.toString() + ".");
+
+        for (String claimId : claimIds) {
+            try {
+
+                if (Authorization.isRegistered(token)) {
+                    if (UserHandler.getMail(token).equals(fetchClaimHandler.fetchClaimById(claimId,false).getUserMail())) {
+                        if (claimHandler.deleteClaim(claimId)) {
+                            deletedIds.add(claimId);
+                        } else {
+                            notFoundIds.add(claimId);
+                        }
+                    } else {
+                        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to delete."))
+                                .type(MediaType.APPLICATION_JSON)
+                                .build();
+                    }
+                } else {
+                    return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access. Maybe you are not registered."))
+                            .type(MediaType.APPLICATION_JSON)
+                            .build();
+                }
+            } catch (SQLStoreException|Exception e) {
+                logger.error("Fail to delete claim with id " + claimId + ".", e);
+                notFoundIds.add(claimId);
+            }
+        }
+        logger.debug("Successfully deleted " + deletedIds.size() + " from " + claimIds.size()  +". Deleted claims with ids: " + deletedIds.toString() + ".");
+        if (claimIds.size() == notFoundIds.size()) {
+            return Response.status(Response.Status.NOT_FOUND).entity(compose404BulkDeleteMessage("Claim ids cannot be empty.",deletedIds,notFoundIds))
+                    .type(MediaType.APPLICATION_JSON).build();
+        } else if (claimIds.size() == notFoundIds.size()) {
+            return Response.status(204).entity(compose204BulkDeleteMessage(deletedIds,notFoundIds)).type(MediaType.APPLICATION_JSON).build();
+        } else {
+            return Response.status(204).entity(compose204BulkDeleteMessage(deletedIds,notFoundIds)).type(MediaType.APPLICATION_JSON).build();
+        }
+    }
+
+    @POST
+    @Path("/claims")
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response addClaim(String input, @Context HttpServletRequest request,
+                             @QueryParam("token") String token) {
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+        if(Authorization.isRegistered(token)) {
+            JsonObject jsonObject = new JsonParser().parse(input).getAsJsonObject();
+
+            String claimedBy = jsonObject.get("claimedBy").getAsString();
+            logger.info("claimedBy " + claimedBy);
+
+            String sourceId = jsonObject.get("sourceId").getAsString();
+            logger.info("sourceId " + sourceId);
+            String sourceType = jsonObject.get("sourceType").getAsString();
+            logger.info("sourceType " + sourceType);
+            String sourceCollectedFrom = jsonObject.get("sourceCollectedFrom").getAsString();
+            logger.info("sourceCollectedFrom " + sourceCollectedFrom);
+            String sourceAccessRights = jsonObject.get("sourceAccessRights").getAsString();
+            logger.info("sourceAccessRights " + sourceAccessRights);
+            String sourceEmbargoEndDate = jsonObject.get("sourceEmbargoEndDate").getAsString();
+            sourceEmbargoEndDate = (sourceEmbargoEndDate != null && sourceEmbargoEndDate.equals("")) ? null : sourceEmbargoEndDate;
+            logger.info("sourceEmbargoEndDate " + sourceEmbargoEndDate);
+
+            String targetId = jsonObject.get("targetId").getAsString();
+            logger.info("targetId " + targetId);
+            String targetType = jsonObject.get("targetType").getAsString();
+            logger.info("targetType " + targetType);
+            String targetCollectedFrom = jsonObject.get("targetCollectedFrom").getAsString();
+            logger.info("targetCollectedFrom " + targetCollectedFrom);
+            String targetAccessRights = jsonObject.get("targetAccessRights").getAsString();
+            logger.info("targetAccessRights " + targetAccessRights);
+            String targetEmbargoEndDate = jsonObject.get("targetEmbargoEndDate").getAsString();
+            targetEmbargoEndDate = (targetEmbargoEndDate != null && targetEmbargoEndDate.equals("")) ? null : targetEmbargoEndDate;
+            logger.info("targetEmbargoEndDate " + targetEmbargoEndDate);
+
+            EmailValidator emailValidator = EmailValidator.getInstance();
+            if (!emailValidator.isValid(claimedBy)) {
+                return Response.status(Response.Status.BAD_REQUEST).entity(compose400Message("User e-mail is invalid."))
+                        .type(MediaType.APPLICATION_JSON).build();
+            }
+
+
+            try {
+                String claimId = claimHandler.buildAndInsertClaim(claimedBy, sourceType, sourceId, sourceCollectedFrom, sourceAccessRights, sourceEmbargoEndDate, targetType, targetId, targetCollectedFrom, targetAccessRights, targetEmbargoEndDate);
+                return Response.status(200).entity(compose201PostMessage(request, claimId)).type(MediaType.APPLICATION_JSON).build();
+
+            } catch (ClaimValidationException ve) {
+                return Response.status(Response.Status.BAD_REQUEST).entity(compose400Message("The given ids are wrong.", ve))
+                        .type(MediaType.APPLICATION_JSON).build();
+
+            } catch (SQLStoreException|Exception e) {
+                logger.error("Fail to add new claim.", e);
+                return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500Message("Fail to add new claim.", e))
+                        .type(MediaType.APPLICATION_JSON).build();
+            }
+        }
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access."))
+                .type(MediaType.APPLICATION_JSON)
+                .build();
+    }
+
+    @POST
+    @Path("/claims/bulk")
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response addBulkClaims(String input, @Context HttpServletRequest request,
+                                  @QueryParam("token") String token) {
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+        if (Authorization.isRegistered(token)) {
+            ArrayList<String> insertedIds = new ArrayList<String>();
+            JsonArray errorInClaims = new JsonArray();
+
+            int code200 = 0;
+            int code400 = 0;
+            int code500 = 0;
+
+            JsonArray jsonArray = new JsonParser().parse(input).getAsJsonArray();
+            for (JsonElement je : jsonArray) {
+                JsonObject jsonObject = je.getAsJsonObject();
+
+                logger.info("targetId " + jsonObject.toString());
+                String claimedBy = jsonObject.get("claimedBy").getAsString();
+                logger.info("claimedBy " + claimedBy);
+
+                String sourceId = jsonObject.get("sourceId").getAsString();
+                logger.info("sourceId " + sourceId);
+                String sourceType = jsonObject.get("sourceType").getAsString();
+                logger.info("sourceType " + sourceType);
+                String sourceCollectedFrom = jsonObject.get("sourceCollectedFrom").getAsString();
+                logger.info("sourceCollectedFrom " + sourceCollectedFrom);
+                String sourceAccessRights = jsonObject.get("sourceAccessRights").getAsString();
+                logger.info("sourceAccessRights " + sourceAccessRights);
+                String sourceEmbargoEndDate = jsonObject.get("sourceEmbargoEndDate").getAsString();
+                sourceEmbargoEndDate = (sourceEmbargoEndDate != null && sourceEmbargoEndDate.equals("")) ? null : sourceEmbargoEndDate;
+                logger.info("sourceEmbargoEndDate " + sourceEmbargoEndDate);
+
+                String targetId = jsonObject.get("targetId").getAsString();
+                logger.info("targetId " + targetId);
+                String targetType = jsonObject.get("targetType").getAsString();
+                logger.info("targetType " + targetType);
+                String targetCollectedFrom = jsonObject.get("targetCollectedFrom").getAsString();
+                logger.info("targetCollectedFrom " + targetCollectedFrom);
+                String targetAccessRights = jsonObject.get("targetAccessRights").getAsString();
+                logger.info("targetAccessRights " + targetAccessRights);
+                String targetEmbargoEndDate = jsonObject.get("targetEmbargoEndDate").getAsString();
+                targetEmbargoEndDate = (targetEmbargoEndDate != null && targetEmbargoEndDate.equals("")) ? null : targetEmbargoEndDate;
+                logger.info("targetEmbargoEndDate " + targetEmbargoEndDate);
+
+                EmailValidator emailValidator = EmailValidator.getInstance();
+                if (!emailValidator.isValid(claimedBy)) {
+                    jsonObject.addProperty("error", "user");
+                    //                return Response.status(Response.Status.BAD_REQUEST).entity(compose400Message("User e-mail is invalid."))
+                    //                        .type(MediaType.APPLICATION_JSON).build();
+                    code400++;
+                    errorInClaims.add(jsonObject);
+                }
+
+
+                try {
+                    String claimId = claimHandler.buildAndInsertClaim(claimedBy, sourceType, sourceId, sourceCollectedFrom, sourceAccessRights, sourceEmbargoEndDate, targetType, targetId, targetCollectedFrom, targetAccessRights, targetEmbargoEndDate);
+                    insertedIds.add(claimId);
+                    code200++;
+                    //                return Response.status(200).entity(compose201PostMessage(request, claimId)).type(MediaType.APPLICATION_JSON).build();
+
+                } catch (ClaimValidationException ve) {
+                    //                return Response.status(Response.Status.BAD_REQUEST).entity(compose400Message("The given ids are wrong.", ve))
+                    //                        .type(MediaType.APPLICATION_JSON).build();
+                    jsonObject.addProperty("error", "validation");
+                    errorInClaims.add(jsonObject);
+                    code400++;
+
+                } catch (SQLStoreException|Exception e) {
+                    //                logger.error("Fail to add new claim.", e);
+                    //                return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500Message("Fail to add new claim.", e))
+                    //                        .type(MediaType.APPLICATION_JSON).build();
+                    jsonObject.addProperty("error", "insertion");
+                    errorInClaims.add(jsonObject);
+                    code500++;
+                }
+            }
+            if (jsonArray.size() == code500) {
+                return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500BulkInsertMessage("Fail to add new claim.", insertedIds, errorInClaims))
+                        .type(MediaType.APPLICATION_JSON).build();
+            } else if (code200 > 0) {
+                return Response.status(200).entity(compose201BulkInsertMessage(insertedIds, errorInClaims)).type(MediaType.APPLICATION_JSON).build();
+            } else {
+                return Response.status(Response.Status.BAD_REQUEST).entity(compose400BulkInsertMessage("The given ids are wrong.", insertedIds, errorInClaims))
+                        .type(MediaType.APPLICATION_JSON).build();
+            }
+        }
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access. You are not registered."))
+                .type(MediaType.APPLICATION_JSON)
+                .build();
+
+    }
+    @POST
+    @Path("/curate/bulk")
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response curateBulkClaims(String input, @Context HttpServletRequest request,
+                                  @QueryParam("token") String token) {
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+        if (Authorization.isRegistered(token)) {
+            ArrayList<String> insertedIds = new ArrayList<String>();
+            JsonArray errorInClaims = new JsonArray();
+            int code200 = 0;
+            int code400 = 0;
+            int code500 = 0;
+            JsonArray jsonArray = new JsonParser().parse(input).getAsJsonArray();
+            String curatedBy = UserHandler.getMail(token);
+
+            for (JsonElement je : jsonArray) {
+                JsonObject jsonObject = je.getAsJsonObject();
+
+                 String id = jsonObject.get("id").getAsString();
+                logger.info("id " + id);
+
+                Boolean approved = jsonObject.get("approved").getAsBoolean();
+                logger.info("approved " + approved);
+                EmailValidator emailValidator = EmailValidator.getInstance();
+                if (!emailValidator.isValid(curatedBy)) {
+                    jsonObject.addProperty("error", "user");
+                    //                return Response.status(Response.Status.BAD_REQUEST).entity(compose400Message("User e-mail is invalid."))
+                    //                        .type(MediaType.APPLICATION_JSON).build();
+                    code400++;
+                    errorInClaims.add(jsonObject);
+                }
+
+                try {
+                    claimHandler.updateClaimCurationInfo(curatedBy,id, approved);
+                    insertedIds.add(id);
+                    code200++;
+
+                } catch (SQLStoreException|Exception e) {
+                    jsonObject.addProperty("error", "insertion");
+                    errorInClaims.add(jsonObject);
+                    code500++;
+                }
+            }
+            if (jsonArray.size() == code500) {
+                return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500BulkInsertMessage("Fail to update claims.", insertedIds, errorInClaims))
+                        .type(MediaType.APPLICATION_JSON).build();
+            } else if (code200 > 0) {
+                return Response.status(200).entity(compose201BulkInsertMessage(insertedIds, errorInClaims)).type(MediaType.APPLICATION_JSON).build();
+            } else {
+                return Response.status(Response.Status.BAD_REQUEST).entity(compose400BulkInsertMessage("The given ids are wrong.", insertedIds, errorInClaims))
+                        .type(MediaType.APPLICATION_JSON).build();
+            }
+        }
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access. You are not registered."))
+                .type(MediaType.APPLICATION_JSON)
+                .build();
+
+    }
+    @POST
+    @Path("/feed/bulk")
+    @Produces(MediaType.APPLICATION_JSON)
+    @Consumes(MediaType.APPLICATION_JSON)
+    public Response feedBulkRecords(String input, @Context HttpServletRequest request,@QueryParam("token") String token
+    ) {
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+        if (Authorization.isRegistered(token)) {
+            ArrayList<String> insertedIds = new ArrayList<String>();
+            JsonArray errorInClaims = new JsonArray();
+            int code200 = 0;
+            int code400 = 0;
+            int code500 = 0;
+            JsonArray jsonArray = new JsonParser().parse(input).getAsJsonArray();
+            for (JsonElement je : jsonArray) {
+                JsonObject jsonObject = je.getAsJsonObject();
+                Boolean inserted = directIndexHandler.insertRecord(new Gson().toJson(jsonObject.get("record")));
+                if (inserted) {
+                    insertedIds.add(jsonObject.get("id").getAsString());
+                    code200++;
+                } else {
+                    errorInClaims.add(jsonObject.get("id").getAsString());
+                    code400++;
+                }
+
+
+            }
+            if (jsonArray.size() == code500) {
+                return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(compose500BulkInsertMessage("Fail to add new claim.", insertedIds, errorInClaims))
+                        .type(MediaType.APPLICATION_JSON).build();
+            } else if (code200 > 0) {
+                return Response.status(200).entity(compose201BulkInsertMessage(insertedIds, errorInClaims)).type(MediaType.APPLICATION_JSON).build();
+            } else {
+                return Response.status(Response.Status.BAD_REQUEST).entity(compose400BulkInsertMessage("The given ids are wrong.", insertedIds, errorInClaims))
+                        .type(MediaType.APPLICATION_JSON).build();
+            }
+        }
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access. You are not registered."))
+                .type(MediaType.APPLICATION_JSON)
+                .build();
+
+    }
+
+    @Path("/communities")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response fetchCommunities(@QueryParam("token") String token) throws ISLookUpServiceException {
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+        if (Authorization.isRegistered(token)) {
+            //it needs to have at lease one category with @claim=true
+            List<String> communities = lookupServiceLocator.getService().quickSearchProfile
+                    ("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')  \n" +
+                            "                where $x//context[@type='community']//category[@claim='true'] \n" +
+                            "            return <communities>{$x//context/@id}{$x//context/@label}</communities>");
+
+            return Response.status(200).entity(composeDataResponse(xml2Json(communities))).type(MediaType.APPLICATION_JSON).build();
+        }
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access. You are not registered."))
+                .type(MediaType.APPLICATION_JSON)
+                .build();
+    }
+
+    @Path("/communities/{communityid}/categories")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response fetchCommunityCategories(@PathParam("communityid") String communityid,
+                                             @QueryParam("token") String token) throws ISLookUpServiceException {
+
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+        if (Authorization.isRegistered(token)) {
+            List<String> categories = lookupServiceLocator.getService().quickSearchProfile
+                    ("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')//context[@id='" + communityid + "']//category[@claim=\'true\']\n" +
+                            "return <category>{$x/@id}{$x/@label}</category>");
+
+            logger.info("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType')//context[@id='" + communityid + "']//category[@claim=\'true\']\n" +
+                    "return <category>{$x/@id}{$x/@label}</category>");
+
+            if (categories == null || categories.isEmpty()) {
+                return Response.status(404).entity(compose404Message("There are no categories for community with id " + communityid)).type(MediaType.APPLICATION_JSON).build();
+            }
+
+            xml2Json(categories);
+
+            return Response.status(200).entity(composeDataResponse(xml2Json(categories))).type(MediaType.APPLICATION_JSON).build();
+        }
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access. You are not registered."))
+                .type(MediaType.APPLICATION_JSON)
+                .build();
+    }
+
+    @Path("/categories/{categoryid}/concepts")
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response fetchCategoryConcepts(@PathParam("categoryid") String categoryid,
+                                          @QueryParam("token") String token) throws ISLookUpServiceException {
+        if(!JWTValidator.isValid(token)) {
+            return Response.status(Response.Status.UNAUTHORIZED).entity(compose404Message("Not valid Token"))
+                    .type(MediaType.APPLICATION_JSON)
+                    .build();
+        }
+        if (Authorization.isRegistered(token)) {
+            List<String> concepts = lookupServiceLocator.getService().quickSearchProfile
+                    ("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') return $x//category[@id='" + categoryid + "']//concept");
+
+            if (concepts == null || concepts.isEmpty()) {
+                return Response.status(404).entity(compose404Message("There are no concepts for category with id " + categoryid)).type(MediaType.APPLICATION_JSON).build();
+            }
+
+            return Response.status(200).entity(composeDataResponse(xml2Json(concepts))).type(MediaType.APPLICATION_JSON).build();
+        }
+        return Response.status(Response.Status.FORBIDDEN).entity(compose403Message("Forbidden: You don't have permission to access. You are not registered."))
+                .type(MediaType.APPLICATION_JSON)
+                .build();
+    }
+
+    private String xml2Json(List<String> input) {
+        StringBuilder builder = new StringBuilder();
+        for(String category: input) {
+            builder.append(category);
+        }
+        return builder.toString();
+    }
+
+    private String compose400Message(String message) {
+        return  "{ \"status\" : \"error\", \"code\" : \"400\", \"message\" : \"  " + message +" \" }";
+    }
+
+    private String compose400Message(String message, Exception exception) {
+        return  "{ \"status\" : \"error\", \"code\" : \"400\", \"message\" : \"  " + message +"\", " +
+                "\"description\" : \""+  exception.getMessage() +"\" }";
+    }
+
+    private String compose403Message(String message) {
+        return  "{ \"status\" : \"error\", \"code\" : \"400\", \"message\" : \"  " + message +"\", " +
+                "\"description\" : \"\" }";
+    }
+
+    private String compose404BulkDeleteMessage(String message, List<String> deletedIds, List<String> notFoundIds) {
+        return  "{ \"status\" : \"error\", \"code\" : \"404\", \"message\" : \"  " + message +" \""+  "\"deletedIds\" : " + new Gson().toJson(deletedIds) +","+  "\"notFoundIds\" : " + new Gson().toJson(notFoundIds) + " }";
+    }
+    private String compose404Message(String message) {
+        return  "{ \"status\" : \"error\", \"code\" : \"404\", \"message\" : \"  " + message +" \" }";
+    }
+
+    private String compose400BulkInsertMessage(String message, List<String> insertedIds,JsonArray errorInClaims) {
+        return  "{ \"status\" : \"error\", \"code\" : \"400\", \"message\" : \"  " + message +" \""+  ", \"insertedIds\" : " + new Gson().toJson(insertedIds) +","+  "\"errorInClaims\" : " + new Gson().toJson(errorInClaims) + " }";
+    }
+
+    private String compose500Message(String message, Throwable throwable) {
+        return  "{ \"status\" : \"fail\", \"code\" : \"500\", \"message\" : \"  " + message + "\", " +
+                "\"description\" : \""+  throwable.getMessage() +"\" }";
+    }
+
+    private String compose500BulkInsertMessage(String message,  List<String> insertedIds, JsonArray errorInClaims) {
+        return  "{ \"status\" : \"fail\", \"code\" : \"500\", \"message\" : \"  " + message + "\", " +
+                "\"description\" : \""+   "\" , " +  "\"insertedIds\" : " + new Gson().toJson(insertedIds) +","+  "\"errorInClaims\" : " + new Gson().toJson(errorInClaims) + " }";
+    }
+
+    /*
+    TODO check if needed
+    private String compose500BulkDeleteMessage(String message,  List<String> deletedIds, List<String> notFoundIds, Exception exception) {
+        return  "{ \"status\" : \"fail\", \"code\" : \"500\", \"message\" : \"  " + message + "\", " +
+                "\"description\" : \""+  exception.getMessage() +"\" ," +  "\"deletedIds\" : " + new Gson().toJson(deletedIds) +","+  "\"notFoundIds\" : " + new Gson().toJson(notFoundIds) + " }";
+    }
+
+    TODO check if needed
+    private  String compose200Message(){
+        return " { \"status\" : \"success\", \"code\": \"200\" }";
+    }
+
+    TODO check if needed
+    private  String compose204Message(){
+        return " { \"status\" : \"success\", \"code\": \"204\" }";
+    } */
+
+    private  String compose204BulkDeleteMessage(List<String> deletedIds, List<String> notFoundIds){
+        return " { \"status\" : \"success\", \"code\": \"204\", "+ "\"deletedIds\" : " + new Gson().toJson(deletedIds) +","+  "\"notFoundIds\" : " + new Gson().toJson(notFoundIds) + "}";
+    }
+
+
+    private  String compose201PostMessage(@Context HttpServletRequest request, String claimId){
+        String url = request.getRequestURL().toString();
+        //String query = request.getQueryString();
+
+        return " { \"status\" : \"success\", \"code\": \"201\", \"link\": \"" + url  +"/"+ claimId +"\" }";
+    }
+    private  String compose201BulkInsertMessage(List<String> insertedIds, JsonArray errorInClaims){
+        //String url = request.getRequestURL().toString();
+        //String query = request.getQueryString();
+
+        return " { \"status\" : \"success\", \"code\": \"201\","+ "\"insertedIds\" : " + new Gson().toJson(insertedIds) +","+  "\"errorInClaims\" : " + new Gson().toJson(errorInClaims)+ "}";
+    }
+    private String composeDataResponse(HttpServletRequest request, List<Claim> claims, int total, int offset, int limit) {
+        if(offset != -1 && limit != -1) {   // if offset and limit are -1, no paging in the response
+            return " { \"status\" : \"success\", \"code\": \"200\",  "+composeTotalResults(total)+", " + composePaging(request, total, offset, limit) + ", "
+                    + "\"data\" : " + new Gson().toJson(claims) + " }";
+        } else {
+            return " { \"status\" : \"success\", \"code\": \"200\",  "+composeTotalResults(total)+", "
+                    + "\"data\" : " + new Gson().toJson(claims) + " }";
+        }
+    }
+
+    private String composeDataResponse(String xml) {
+        return " { \"status\" : \"success\", \"code\": \"200\", "
+                + "\"data\" : " + XML.toJSONObject(xml).toString() + " }";
+    }
+
+    private String composeDataResponse(Claim claim) {
+        return " { \"status\" : \"success\", \"code\": \"200\", " + "\"data\" : " + new Gson().toJson(claim) + " }";
+    }
+
+    private static String composePaging(HttpServletRequest request, int total, int currentOffset, int limit) {
+        logger.info("total " + total);
+        logger.info("currentOffset " + currentOffset);
+        logger.info("limit " + limit);
+
+        String url = request.getRequestURL().toString();
+        //String query = request.getQueryString();
+
+        String first = url+"?offset=0&limit=20";
+
+        int previousPage;
+        int nextPage;
+        int lastPage;
+
+        if (total <= limit) {
+            lastPage = 0;
+        } else {
+            if(total%limit == 0) {
+                lastPage = total/limit-1;
+            } else {
+                lastPage = total/limit ;
+            }
+        }
+        String last = url+"?offset=" + lastPage + "&limit=20";
+
+        if (currentOffset-1 <= 0) {
+            previousPage = 0;
+        } else {
+            previousPage = currentOffset-1;
+        }
+        String previous = url+"?offset=" + previousPage + "&limit=20";
+
+        if (currentOffset+1 >= lastPage) {
+            nextPage = lastPage;
+
+        } else {
+            nextPage = currentOffset + 1;
+        }
+        String next = url+"?offset=" + nextPage + "&limit=20";
+
+        return "\"paging\": [" +  "{\"rel\":\"first\", \"href\":\"" + first +"\"}, {\"rel\":\"last\", \"href\":\"" + last + "\"}, {\"rel\":\"previous\", \"href\": \"" + previous + "\"}, {\"rel\":\"next\", \"href\":\"" +  next +"\"}"+ "]";
+    }
+    private String composeTotalResults(int total) {
+        return "\"total\": \""+total+"\"";
+    }
+
+     public static void main(String[] args) {
+/*        HelloWorldService helloWorldService = new HelloWorldService();
+
+
+       System.out.println(helloWorldService.composePaging2(100, 0, 20));
+        System.out.println(helloWorldService.composePaging2(100, 4, 20));
+
+        System.out.println(helloWorldService.composePaging2(99, 4, 20));
+        System.out.println(helloWorldService.composePaging2(99, 4, 20));
+
+        System.out.println(helloWorldService.composePaging2(85, 4, 20));
+
+         System.out.println(helloWorldService.composePaging2(0, 4, 20));
+*/
+/*
+         EmailValidator emailValidator = EmailValidator.getInstance();
+         System.out.println(emailValidator.isValid("jate@gdddd"));
+
+         InternetAddress emailAddr = null;
+         try {
+             emailAddr = new InternetAddress("jate@gdddd");
+             emailAddr.validate();
+         } catch (AddressException e) {
+             System.out.println("false");
+         }
+         System.out.println("true");
+
+         ArrayList<String> insertedIds= new ArrayList<String>();
+         insertedIds.add("1");
+         insertedIds.add("2");
+         insertedIds.add("3");
+         System.out.println(helloWorldService.compose403Message("hello"));
+
+*/
+    }
+
+}
Index: modules/uoa-claims-api/branches/newClaimSchema/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(revision 47510)
@@ -0,0 +1,25 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+
+public class ThriftClient {
+
+	public OpenAIREConnector.Client getConnector() throws TTransportException {
+		return getConnector("localhost", 7911);
+	}
+
+	public OpenAIREConnector.Client getConnector(String host, int port) throws TTransportException {
+		TTransport transport = new TSocket(host, port);
+		transport.open();
+
+		TProtocol protocol = new  TBinaryProtocol(transport);
+		
+		return new OpenAIREConnector.Client(protocol);
+	}
+}
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(revision 47510)
@@ -0,0 +1,340 @@
+package eu.dnetlib.openaire.thrift;
+
+
+import eu.dnetlib.api.enabling.ISLookUpService;
+import eu.dnetlib.api.enabling.ISLookUpServiceException;
+import eu.dnetlib.openaire.action.ActionUtils;
+import gr.uoa.di.driver.enabling.ISLookUpException;
+import gr.uoa.di.driver.util.ServiceLocator;
+import org.apache.log4j.Logger;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.springframework.jdbc.datasource.DataSourceUtils;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+@Transactional
+public class ClaimConnector {
+
+	private static Logger logger = Logger.getLogger(ClaimConnector.class);
+
+	private DataSource datasource = null;
+
+	//Using an isLookUp Impl just to make an xQuery to IS. Maybe move all the
+	//functionality to commons?
+	private ServiceLocator<ISLookUpService> lookupServiceLocator = null;
+
+	public List<Claim> getClaimedPublications(final String user) throws SQLException {
+		Connection con = DataSourceUtils.getConnection(datasource);
+		PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"date\" , \"type\", \"xml\", \"id\" from claims where \"agent\" = ?");
+		stmt.setString(1, user);
+		ResultSet rs = stmt.executeQuery();
+		List<Claim> res = new ArrayList<Claim>();
+
+		while (rs.next()) {
+			res.add(new Claim(user, rs.getString(1), rs.getTimestamp(2).getTime(), rs.getString(3), rs.getString(4), rs.getString(5)));
+		}
+
+		rs.close();
+		stmt.close();
+
+        logger.info("Returning " + res.size() + " claimed publications for user "  + user);
+
+		return res;
+	}
+
+	public List<Claim> getClaimedPublications(Date from, Date to) throws SQLException {
+		Connection con = DataSourceUtils.getConnection(datasource);
+
+		PreparedStatement stmt = con.prepareStatement("select \"agent\", \"resultid\", \"date\" , \"type\", \"xml\",  \"id\"  from claims where \"agent\" != 'inference' and \"date\" >= ?::timestamp and \"date\" <= ?::timestamp ");
+		stmt.setTimestamp(1, new Timestamp(from.getTime()));
+        stmt.setTimestamp(2, new Timestamp(to.getTime()));
+
+		ResultSet rs = stmt.executeQuery();
+		List<Claim> res = new ArrayList<Claim>();
+
+		while (rs.next()) {
+			res.add(new Claim(rs.getString(1), rs.getString(2), rs.getTimestamp(3).getTime(), rs.getString(4), rs.getString(5), rs.getString(6)));
+		}
+
+		rs.close();
+		stmt.close();
+
+		logger.debug("number of claims: " + res.size());
+        logger.info("Returning " + res.size() + " claimed publications for date "  + from + "-" + to);
+
+		return res;
+	}
+
+	public void deleteClaim(String userEmail, String id) throws SQLException {
+        logger.info("Deleting claim with id " + id + " for agent " +  userEmail);
+
+		Connection con = DataSourceUtils.getConnection(datasource);
+        int claim_id = Integer.parseInt(id);
+        String type = null;
+
+		PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"type\" from claims where \"id\" =?");
+        stmt.setInt(1, claim_id);
+
+        ResultSet rs = stmt.executeQuery();
+        
+        String resultid = null;
+        String xml = null;
+
+        while (rs.next()) {
+            resultid = rs.getString("resultid");
+            type = rs.getString("type");
+        }
+
+        if (resultid != null) {
+            stmt = con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =?");
+            stmt.setString(1, userEmail);
+            stmt.setInt(2, claim_id);
+
+            stmt.executeUpdate();
+            logger.info("Deleted claim with claim id: " + claim_id + ", result id: " + resultid + " and type: " + type +".") ;
+
+            //prepare to get 2nd claim to be deleted
+            int claim2_id = claim_id - 1;
+
+            if (type != null && type.equals("rels2actions")) {
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+                rs = stmt.executeQuery();
+
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //check if the relation has dmf
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            } /*else if (type != null && type.equals("dmf2actions")) {
+                logger.info("dmf2actions");
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+
+                rs = stmt.executeQuery();
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                logger.info("xml: " + xml);
+                logger.info("xml? " + xml.contains("oaf:concept"));
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //delete concept with extra dmf (doi,orchid,... etc)
+                    logger.debug("dmf2actions and not concept");
+
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            }*/
+        }
+
+        stmt.close();
+        
+        logger.info("Deleted claim with id " + id + " for agent " +  userEmail);
+	}
+
+	/**
+	 * @param id     {openaireId, publication doi, ORCIDId (personId-ORCIDPublicationId), data doi}
+	 * @param source {openaire, doi (crossref), orcid, datacite}
+	 * @throws ResourceNotFoundException
+	 * @throws ParseErrorException
+	 * @throws Exception
+	 */
+	public String insertDocument(
+			String id,
+			String source,
+			String title,
+			String description,
+			String access_mode,
+			String embargoEndDate,
+			List<Author> authors,
+			String url,
+			String dcSource,
+			String userEmail,
+			List<String> subjects,
+			String publicationDate,
+			String publisher,
+			String language,
+			String category,
+			String doi) throws Exception {
+
+        logger.info("Request to insert document with id " + id + " and source " + source);
+		String resultId;
+
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String dmf;
+			resultId = ActionUtils.getIdentifier(ActionUtils.getPrefix(source), id);
+			Date now = new Date();
+
+			if (!source.toLowerCase().equals("openaire") && title != null) {
+				stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+				dmf = ActionUtils.createDMF(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, doi, Collections.EMPTY_LIST, subjects, Collections.EMPTY_LIST, publicationDate, publisher, language, category, false);
+
+				stmt.setString(1, userEmail);
+				stmt.setString(2, resultId);
+				stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+				stmt.setString(4, "dmf2actions");
+				stmt.setString(5, dmf);
+				stmt.setString(6, "userclaim_dmf");
+				stmt.setString(7, ActionUtils.getProvenance(source));
+				stmt.setString(8, ActionUtils.getPrefix(source));
+
+				stmt.executeUpdate();
+				stmt.close();
+			}
+		} catch (Exception e) {
+			logger.error("Error inserting document", e);
+			throw e;
+		}
+
+        logger.info("Inserted document with id " + id + ", source " + source + " and given resultId " + resultId);
+		return resultId;
+	}
+
+	public void insertConceptRelation(String documentId, String documentSource, String concept, String userEmail, String doi) throws Exception {
+        logger.info("Request for concept relation between document with id " + documentId + " with source " + documentSource + " and concept " + concept + "with doi " + doi);
+
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String dmf;
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+			dmf = ActionUtils.createDMF(documentId, documentSource, null, null, null, null, Collections.EMPTY_LIST, null, null, doi, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Arrays.asList(concept), null, null, null, null, true);
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, documentId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "updates2actions");
+			stmt.setString(5, dmf);
+			stmt.setString(6, "userclaim_dmf");
+			stmt.setString(7, ActionUtils.getProvenance(documentSource));
+			stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding concept", e);
+			throw e;
+		}
+
+        logger.info("Inserted concept relation between document with id " + documentId + " with source " + documentSource + " and concept " + concept);
+	}
+
+	public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws Exception {
+        logger.info("Request for project relation between document with id " + docId + " with source " + documentSource + " and project " + project);
+
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String xml = ActionUtils.createResultProjectRelation("openaire".equals(documentSource) ? null : documentSource, docId, project.getType(), project.getProjectId());
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, docId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "rels2actions");
+			stmt.setString(5, xml);
+			stmt.setString(6, "userclaim_result_project");
+			stmt.setString(7, ActionUtils.getProvenance(documentSource));
+			stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding project", e);
+			throw e;
+		}
+
+        logger.info("Inserted project relation between document with id " + docId + " with source " + documentSource + " and project " + project);
+	}
+
+	public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws Exception {
+        logger.info("Request for result relation between source document with id " + sourceResultId + ", type " + sourceResultType + "and source " + sourceResultSource + " and " +
+                "target document with id " + targetResultId + ", type " + targetResultType);
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String xml = ActionUtils.createResultResultRelation(sourceResultId, sourceResultType, targetResultId, targetResultType);
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, sourceResultId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "rels2actions");
+			stmt.setString(5, xml);
+			stmt.setString(6, "userclaim_result_result");
+			stmt.setString(7, ActionUtils.getProvenance(sourceResultSource));
+			stmt.setString(8, ActionUtils.getPrefix(sourceResultSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding result relation", e);
+			throw e;
+		}
+
+        logger.info("Inserted result relation between source document with id " + sourceResultId + ", type " + sourceResultType + "and source " + sourceResultSource + " and " +
+                "target document with id " + targetResultId + ", type " + targetResultType);
+	}
+
+	public DataSource getDatasource() {
+		return datasource;
+	}
+
+	public void setDatasource(DataSource datasource) {
+		this.datasource = datasource;
+	}
+
+	public ServiceLocator<ISLookUpService> getLookupServiceLocator() {
+		return lookupServiceLocator;
+	}
+
+	public void setLookupServiceLocator(
+			ServiceLocator<ISLookUpService> lookupServiceLocator) {
+		this.lookupServiceLocator = lookupServiceLocator;
+	}
+
+	public List<String> getContexts() throws ISLookUpException, ISLookUpServiceException {
+		return lookupServiceLocator.getService().quickSearchProfile("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') return $x");
+	}
+}
Index: modules/uoa-claims-api/branches/newClaimAPI/src/main/java/eu/dnetlib/openaire/rest/security/JWTValidator.java
===================================================================
--- modules/uoa-claims-api/branches/newClaimAPI/src/main/java/eu/dnetlib/openaire/rest/security/JWTValidator.java	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimAPI/src/main/java/eu/dnetlib/openaire/rest/security/JWTValidator.java	(revision 47510)
@@ -0,0 +1,66 @@
+package eu.dnetlib.openaire.rest.security;
+
+import eu.dnetlib.openaire.rest.HelloWorldService;
+import io.jsonwebtoken.*;
+import org.apache.log4j.Logger;
+
+import javax.xml.bind.DatatypeConverter;
+
+/**
+ * Created by kiatrop on 10/4/2017.
+ */
+public class JWTValidator {
+
+    private static final Logger logger = Logger.getLogger(HelloWorldService.class);
+
+    public static boolean isValid(String token) {
+
+        //String subject = "my-very-secret";
+        try {
+
+            //This line will throw an exception if it is not a signed JWS (as expected)
+            Claims claims = Jwts.parser()
+                .setSigningKey(DatatypeConverter.parseBase64Binary("my-very-secret"))
+                .parseClaimsJws(token).getBody();
+
+            logger.debug("Id: " + claims.get("userId"));
+            logger.debug("Subject: " + claims.getSubject());
+            logger.debug("Fullname: " + claims.get("fullname"));
+            logger.debug("Email: " + claims.get("email"));
+            logger.debug("Role: " + claims.get("role"));
+            logger.debug("Expiration: " + claims.getExpiration());
+
+            return true;
+
+        } catch (SignatureException e) {
+            logger.error("Either calculating a signature or verifying an existing signature of a JWT failed", e);
+            return false;
+        } catch(PrematureJwtException e) {
+            logger.error("A JWT was accepted before it is allowed to be accessed and must be rejected", e);
+            return false;
+        } catch(ClaimJwtException e){
+            logger.error("After a validation of a JWT claim failed", e);
+            return false;
+        } catch(MalformedJwtException e){
+            logger.error("A JWT was not correctly constructed and should be rejected", e);
+            return false;
+        } catch(UnsupportedJwtException e){
+            logger.error("Receiving a JWT in a particular format/configuration that does not match the format expected by the application", e);
+            return false;
+        }
+    }
+
+//    public static void main(String[] args) {
+//
+//        // valid (isValid("eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBcmdpcm8iLCJmdWxsbmFtZSI6IkFyZ2lybyBLb2tvZ2lhbmFraSIsInVzZXJJZCI6IjgiLCJlbWFpbCI6ImFyZ2lyb0BnbWFpbC5jb20iLCJyb2xlIjoyLCJleHAiOjE0OTIwMDEyMzN9.u2xTTyjF6_n60yiz-Pfj72TQIaVNRgxt7Qe8w_AxoTBulKuiq6ldzZHDvgcef2jsA12TFRgfIyfXhsTj-04P5A"))
+//        // not valid "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBcmdpcm8iLCJmdWxsbmFtZSI6IkFyZ2lybyBLb2tvZ2lhbmFraSIsInVzZXJJZCI6IjgiLCJlbWFpbCI6ImFyZ2lyb0BnbWFpbC5jb20iLCJyb2xlIjoyLCJleHAiOjE0OTE5ODk2Njh9.JUiFGEverBVbo3eXlV2nX265cwNTYH1EJGZT0IcGyY31WUDHiGmtnTY-NwZsy0R93irVhAzVhTlmZI_DSRQ"
+//        //if (isValid("eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJzYmEiLCJmdWxsbmFtZSI6InNvZmlhICIsInVzZXJJZCI6IjYiLCJlbWFpbCI6InNvZmllX21wbEBob3RtYWlsLmNvbSIsInJvbGUiOjEsImV4cCI6MTQ5Mjc3ODY2M30.LcgYcBuI0V8tsZZR_Pnnb5Kk0_GfblxNC6FH1CHT2q7u4j9hcETb1EYLIKPZdkErXJ_MSC1jHNUiS5qCzEQQ2w"))
+//
+//        if(isValid("eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBcmdpcm8iLCJmdWxsbmFtZSI6IkFyZ2lybyBLb2tvZ2lhbmFraSIsInVzZXJJZCI6IjgiLCJlbWFpbCI6ImFyZ2lyb0BnbWFpbC5jb20iLCJyb2xlIjoyLCJleHAiOjE0OTI3ODY4MTl9.F-cFGmSvZLAF70PCz9PE6jOwSg6aAiUW2lklkS-eKCxkjwbqPJLWlNWP10Czg4j1_iKDTvHR7wbhbRyJPoqvNQ"))
+//            System.out.println("Valid");
+//        else
+//            System.out.println("Not Valid");
+//
+//    }
+
+}
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(revision 47510)
@@ -0,0 +1,185 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertServiceException;
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.List;
+
+public class OpenAIREConnectorImpl implements OpenAIREConnector.Iface {
+	private static final Logger logger = Logger.getLogger(OpenAIREConnectorImpl.class);
+
+	private ClaimConnector claimConnector;
+	private AlertConnector alertConnector;
+
+	public void setClaimConnector(final ClaimConnector claimConnector) {
+		this.claimConnector = claimConnector;
+	}
+
+	public void setAlertConnector(final AlertConnector alertConnector) {
+		this.alertConnector = alertConnector;
+	}
+
+	@Override
+	public List<Claim> getClaimedPublications(final String user) throws TException {
+		try {
+			return claimConnector.getClaimedPublications(user);
+		} catch (final Exception e) {
+			logger.error("Error retrieving claimed publications (user: " + user + ")", e);
+			throw new TException("Error retrieving claimed publications (user: " + user + ")", e);
+		}
+	}
+
+    @Override
+    public List<Claim> getAllClaimedPublications(long from, long to) throws TException {
+        try {
+            return claimConnector.getClaimedPublications(new Date(from), new Date(to));
+        } catch (Exception e) {
+            logger.error("Error retrieving claimed publications", e);
+
+            throw new TException("Error retrieving claimed publications", e);
+        }
+    }
+
+    @Override
+    public String insertDocument(String originalId, String source, String title, String description, String access_mode, String embargoEndDate, List<Author> authors, String url, String dcSource, String userEmail, List<String> subjects, String publicationDate, String publisher, String language, String category, String doi) throws org.apache.thrift.TException {
+        try {
+            return claimConnector.insertDocument(originalId, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, userEmail, subjects, publicationDate, publisher, language, category, doi);
+        } catch (Exception e) {
+            logger.error("Error adding document", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertConcept(String docId, String documentSource, String concept, String userEmail, String doi) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertConceptRelation(docId, documentSource, concept, userEmail, doi);
+        } catch (Exception e) {
+            logger.error("Error adding concept relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertProjectRelation(docId, documentSource, project, userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding project relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws TException {
+        try {
+            claimConnector.insertResultRelation(sourceResultId, sourceResultType, sourceResultSource, targetResultId, targetResultType,userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding result relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+	public List<AlertSubscription> getSubscriptions(final String alertMode, final String subscriber, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getSubscriptions(alertMode, subscriber, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+	@Override
+	public void addSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.addSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		}
+	}
+
+	@Override
+	public void removeSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.removeSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		}
+	}
+
+	@Override
+	public int countAlertResults(final String notificationService, final String queryId, final long date, final String resultId) throws TException {
+		try {
+			return alertConnector.countAlertResults(notificationService, queryId, date, resultId);
+		} catch (final AlertServiceException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		}
+	}
+
+	@Override
+	public ResultPage getAlertResults(final String notificationService, final String queryId, final String resultId, final long fromDate, final long toDate, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getAlertResults(notificationService, queryId, resultId, fromDate, toDate, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+    @Override
+    public void deleteClaim(String userEmail, String resultId) throws TException {
+        try {
+            claimConnector.deleteClaim(userEmail, resultId);
+        } catch (Exception e) {
+            logger.error("Error deleting claim", e);
+
+            throw new TException(e);
+        }
+    }
+
+	@Override
+	public List<String> getContexts() throws TException {
+		try {
+			return claimConnector.getContexts();
+		} catch (Exception e) {
+			logger.error("Error getting contexts from IS.", e);
+			
+			throw new TException(e);
+		}
+		
+	}
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(revision 47510)
@@ -0,0 +1,43 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TTransportException;
+
+public class ThriftServer {
+	private OpenAIREConnector.Iface openAireConnector;
+	private int port;
+	private int timeout;
+	private Thread thread;
+
+	public void setOpenAireConnector(final OpenAIREConnector.Iface openAireConnector) {
+		this.openAireConnector = openAireConnector;
+	}
+	
+	public void setPort(final int port) {
+		this.port = port;
+	}
+	
+	public void setTimeout(final int timeout) {
+		this.timeout = timeout;
+	}
+	
+	public void start() {
+		thread = new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					new TThreadPoolServer(new TThreadPoolServer.Args(new TServerSocket(port, timeout)).processor(new OpenAIREConnector.Processor<OpenAIREConnector.Iface>(openAireConnector))).serve();
+				} catch (final TTransportException e) {
+					Logger.getLogger(ThriftServer.class).error("Error starting thrift server", e);
+				}
+			}
+		});
+		thread.start();
+	}
+	
+	public void stop() {
+		thread.interrupt();
+	}
+}
Index: modules/uoa-claims-api/branches/newClaimAPI/src/main/java/eu/dnetlib/openaire/rest/authorization/Authorization.java
===================================================================
--- modules/uoa-claims-api/branches/newClaimAPI/src/main/java/eu/dnetlib/openaire/rest/authorization/Authorization.java	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimAPI/src/main/java/eu/dnetlib/openaire/rest/authorization/Authorization.java	(revision 47510)
@@ -0,0 +1,42 @@
+package eu.dnetlib.openaire.rest.authorization;
+
+import io.jsonwebtoken.Claims;
+import io.jsonwebtoken.Jwts;
+import org.apache.log4j.Logger;
+
+import javax.xml.bind.DatatypeConverter;
+
+/**
+ * Created by sofia on 20/4/2017.
+ */
+public class Authorization {
+
+    private static Logger logger = Logger.getLogger(Authorization.class);
+
+    public static boolean isRegistered(String token) {
+
+        Claims claims = Jwts.parser()
+                .setSigningKey(DatatypeConverter.parseBase64Binary("my-very-secret"))
+                .parseClaimsJws(token).getBody();
+
+        if (claims.get("role").equals(1) || claims.get("role").equals(2)) {
+            logger.debug(claims.get("role"));
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public static boolean isAdmin(String token) {
+        Claims claims = Jwts.parser()
+                .setSigningKey(DatatypeConverter.parseBase64Binary("my-very-secret"))
+                .parseClaimsJws(token).getBody();
+
+        if (claims.get("role").equals(2)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+}
Index: modules/uoa-claims-api/branches/newClaimAPI/src/main/java/eu/dnetlib/openaire/rest/inputHandler/UserHandler.java
===================================================================
--- modules/uoa-claims-api/branches/newClaimAPI/src/main/java/eu/dnetlib/openaire/rest/inputHandler/UserHandler.java	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimAPI/src/main/java/eu/dnetlib/openaire/rest/inputHandler/UserHandler.java	(revision 47510)
@@ -0,0 +1,22 @@
+package eu.dnetlib.openaire.rest.inputHandler;
+
+import io.jsonwebtoken.Claims;
+import io.jsonwebtoken.Jwts;
+
+import javax.xml.bind.DatatypeConverter;
+
+/**
+ * Created by sofia on 20/4/2017.
+ */
+public class UserHandler{
+
+        public static String getMail(String token) {
+
+            Claims claims = Jwts.parser()
+                    .setSigningKey(DatatypeConverter.parseBase64Binary("my-very-secret"))
+                    .parseClaimsJws(token).getBody();
+
+            return (String) claims.get("email");
+
+        }
+}
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/ehcache.xml
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/ehcache.xml	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/ehcache.xml	(revision 47510)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
+    <!--
+     | Please see http://ehcache.sourceforge.net/documentation/configuration.html for
+     | detailed information on how to configurigure caches in this file
+     +-->
+    <!-- Location of persistent caches on disk -->
+    <diskStore path="java.io.tmpdir/EhCacheSpringAnnotationsExampleApp" />
+
+    <defaultCache eternal="true" maxElementsInMemory="10000"
+        overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
+        timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU"/>
+
+	<cache name="claimator"/>
+	<cache name="alertator.subscriptions"/>
+	<cache name="querynator"/>
+</ehcache>
\ No newline at end of file
Index: modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
--- modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(revision 47510)

Property changes on: modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(revision 47510)
@@ -0,0 +1,285 @@
+package eu.dnetlib.openaire.action;
+
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.Project;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+import java.io.StringWriter;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class ActionUtils {
+
+	private static Logger logger = Logger.getLogger(ActionUtils.class);
+
+	public static String createResultProjectRelation(String source,
+			String resultId, String projectType, String projectId)
+			throws Exception {
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+		ve.init();
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+		VelocityContext vc = new VelocityContext();
+
+		List<Relation> rels = new ArrayList<Relation>();
+
+		rels.add(createRelation(source, resultId, projectType, projectId));
+
+		vc.put("relations", rels);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+
+		return sw.toString();
+	}
+
+    public static String createResultResultRelation(String sourceResultId, String sourceResultType, String targetResultId, String targetResultType) {
+        VelocityEngine ve = new VelocityEngine();
+        ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+        ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+        ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+        ve.init();
+
+        Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+        VelocityContext vc = new VelocityContext();
+
+        List<Relation> rels = new ArrayList<Relation>();
+
+        rels.add(new Relation("resultResult_" + sourceResultType + targetResultType + "_isRelatedTo", "50|" + sourceResultId, "50|" + targetResultId));
+
+        vc.put("relations", rels);
+
+        StringWriter sw = new StringWriter();
+        t.merge(vc, sw);
+
+        return sw.toString();
+    }
+
+	// input id: 1306.3402
+	// oai:arXiv.org:1306.3402
+	// MD5("od________18::oai:arXiv.org:1306.3402")
+
+    /**
+     * Creates a new relation action.
+     * @param source the result source. If not null, the resultId is transformed to openaire id. If null, the result is
+     *               considered to be already an openaire result and is used verbatim
+     * @param resultId the result id
+     * @param projectType the project type. If not null, the projectId is transformed to openaire id. If null, the projectId is
+     *               considered to be already in openaire format and is used verbatim
+     * @param projectId the project id
+     *
+     * @return a relation
+     */
+	private static Relation createRelation(String source, String resultId,
+			String projectType, String projectId) {
+		String resultPrefix;
+		String projectPrefix = null;
+
+        if (!isValidOpenaireId(resultId) && source != null) {
+            if (source.equals("arxiv")) {
+                resultId = "oai:arXiv.org:" + resultId;
+            } else if (source.equals("pubmed")) {
+                resultId = "oai:europepmc.org:" + resultId;
+            }
+
+            resultPrefix = getPrefix(source);
+            resultId = getIdentifier(resultPrefix, resultId);
+        }
+
+	resultId = "50|" + resultId;
+
+        if (projectType != null) {
+            if (projectType.equals("ec")) {
+                projectPrefix = "corda_______";
+            } else if (projectType.equals("wt")) {
+                projectPrefix = "wt__________::WT";
+            }
+
+            projectId = projectPrefix + "::" + projectId;
+        }
+
+	projectId = "40|" + projectId;
+
+		return new Relation("resultProject", resultId, projectId);
+	}
+
+	private static boolean isValidOpenaireId(String resultId) {
+
+		return Pattern.matches("\\w{12}::[a-f0-9]{32}", resultId);
+	}
+
+	public static String getPrefix(String source) {
+        logger.debug("SOURCE " + source);
+		if (source == null || source.equals("openaire")) {
+			return "openaire____";
+		} else if (source.equals("doi")) {
+			return "crossref____";
+		} if (source.equals("orcid")) {
+            		return "orcid_______";
+		} else if (source.equals("datacite")) {
+			return "datacite____";
+		} else if (source.equals("driver")) {
+			return "driver______";
+		} else
+			return null;
+	}
+
+    public static String getProvenance(String source) {
+        if (source == null || source.equals("openaire"))
+            return "user:claim:search";
+        else if (source.equals("doi") || source.equals("orcid"))
+            return "user:claim:pid";
+		else if (source.equals("datacite"))
+			return "user:claim:datacite";
+        else
+            return null;
+    }
+
+	public static String createDMF(String id, String source, String title,
+			String description, String access_mode, String embargoEndDate,
+			List<Author> authors, String url, String dcSource, String doi,
+			List<Project> projects, List<String> subjects, List<String> concepts, String publicationDate, String publisher, String language, String category, boolean isConcept) throws Exception {
+
+        logger.info("create with doi " + doi);
+
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+		ve.init();
+		
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/dmf.vm");
+		VelocityContext vc = new VelocityContext();
+
+		String hostedby = null;
+		String hostedbyName = null;
+		String collectedFrom = null;
+		String collectedFromName = null;
+        String recordIdentifier = id;
+		String prefix = getPrefix(source);
+
+
+        //if the orcid id exists
+        String orcid = null;
+
+		if (source.equals("doi") && !isConcept) {
+			hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+			hostedbyName = "Unknown Repository";
+			collectedFrom = "openaire____::crossref";
+			collectedFromName = "Crossref";
+			doi = id;
+
+        } else if (source.equals("datacite")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::datacite";
+            collectedFromName = "Datacite";
+
+        } else if (source.equals("orcid")) {
+            orcid = id;
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::orcid";
+            collectedFromName = "ORCID";
+
+        } else if (source.equals("driver")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::driver";
+            collectedFromName = "Digital Repository Infrastructure Vision for European Research";
+        }
+
+        logger.info("create with doi " + doi);
+
+        if (doi != null) {
+            vc.put("doi", doi);
+        } else if (orcid != null){
+          //if there is no doi but we have an orcid, id we store it
+          vc.put("orcid", orcid);
+        }
+
+        // openaire ids should not be touched!
+        if (!source.equals("openaire"))
+		    id = getIdentifier(prefix, id);
+
+		vc.put("objIdentifier", id);
+		vc.put("recordIdentifier", recordIdentifier);
+		vc.put("dateOfCollection", DateUtils.calculate_ISO8601(System.currentTimeMillis()));
+		vc.put("hostedby", hostedby);
+		vc.put("collectedFrom", collectedFrom);
+		vc.put("hostedbyName", hostedbyName);
+		vc.put("collectedFromName", collectedFromName);
+        vc.put("embargoEndDate", embargoEndDate);
+		vc.put("title", title);
+		vc.put("description", description);
+		vc.put("accessMode", access_mode);
+		vc.put("dcSource", dcSource);
+		vc.put("url", url);
+		vc.put("publisher", publisher);
+		vc.put("language", language);
+		vc.put("objCategory", category);
+
+		vc.put("datasourceprefix", prefix);
+
+		List<String> creators = new ArrayList<String>();
+		for (Author author : authors) {
+            String name = author.getLastName();
+
+
+            if (author.getFirstName() != null && !author.getFirstName().trim().isEmpty())
+                name += ", " + author.getFirstName();
+
+            creators.add(name);
+		}
+
+		vc.put("creators", creators);
+		vc.put("projects", projects);
+		vc.put("subjects", subjects);
+        vc.put("concepts", concepts);
+		
+		if (publicationDate != null && !publicationDate.equals(""))
+			vc.put("publicationDate", publicationDate + "-01-01T00:00:00Z");
+		
+		vc.put("StringEscapeUtils", StringEscapeUtils.class);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+		
+		return sw.toString();
+	}
+
+	// private static String getIdentifier(String prefix, String id) {
+	// return prefix + "::" +
+	// com.google.common.hash.Hashing.md5().hashString(id).toString();
+	// }
+
+	public static String getIdentifier(String prefix, String id) {
+		try {
+            logger.debug("PREFIX " + prefix);
+			MessageDigest md = MessageDigest.getInstance("MD5");
+
+			md.update(id.getBytes("UTF-8"));
+
+			return prefix + "::" + new String(Hex.encodeHex(md.digest()));
+		} catch (Exception e) {
+			logger.error("Error creating id", e);
+			return null;
+		}
+	}
+}
Index: modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/eu/dnetlib/openaire/action/relation.vm
===================================================================
--- modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(revision 47510)
@@ -0,0 +1,5 @@
+<RELATIONS>
+#foreach ($rel in $relations)
+    <RELATION type='$rel.Type' source='$rel.SourceId' target='$rel.TargetId' />
+#end
+</RELATIONS>
\ No newline at end of file
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(revision 47510)

Property changes on: modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(revision 47510)
@@ -0,0 +1,311 @@
+	package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.actionmanager.common.Agent;
+import eu.dnetlib.actionmanager.common.Agent.AGENT_TYPE;
+import eu.dnetlib.actionmanager.common.Operation;
+import eu.dnetlib.actionmanager.common.Provenance;
+import eu.dnetlib.actionmanager.set.ActionManagerSet;
+import eu.dnetlib.api.enabling.ActionManagerService;
+import eu.dnetlib.api.enabling.ISLookUpService;
+import eu.dnetlib.api.enabling.ISLookUpServiceException;
+import eu.dnetlib.openaire.action.ActionUtils;
+import gr.uoa.di.driver.enabling.ISLookUpException;
+import gr.uoa.di.driver.util.ServiceLocator;
+
+import java.io.FileWriter;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.*;
+
+import javax.sql.DataSource;
+
+import org.apache.log4j.Logger;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.jdbc.datasource.DataSourceUtils;
+
+@Transactional
+public class ClaimConnector {
+	
+	private static Logger logger = Logger.getLogger(ClaimConnector.class);
+	
+	private DataSource datasource = null;
+	private ServiceLocator<ActionManagerService> actionManagerLocator = null;
+
+	//Using an isLookUp Impl just to make an xQuery to IS. Maybe move all the 
+	//functionality to commons?
+	private ServiceLocator<ISLookUpService> lookupServiceLocator = null;   
+	
+	public List<Claim> getClaimedPublications(final String user) throws SQLException {
+		Connection con = DataSourceUtils.getConnection(datasource);
+		PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"date\" , \"type\", \"xml\" from claims where \"agent\" = ?");
+		stmt.setString(1, user);
+		ResultSet rs = stmt.executeQuery();
+		List<Claim> res = new ArrayList<Claim>();
+		
+		while (rs.next()) {
+            res.add(new Claim(user, rs.getString(1), rs.getDate(2).getTime(), rs.getString(3), rs.getString(4)));
+		}
+
+        rs.close();
+        stmt.close();
+	con.close();
+
+		return res;
+	}
+
+    public List<Claim> getClaimedPublications(Date from, Date to) throws SQLException {
+	logger.info("Returning all claimed publications from " + from + " to " + to);
+        Connection con = DataSourceUtils.getConnection(datasource);
+
+        PreparedStatement stmt = con.prepareStatement("select \"agent\", \"resultid\", \"date\" , \"type\", \"xml\" from claims where \"agent\" != 'inference' and \"date\" >= ?::date and \"date\" <= ?::date ");
+
+        stmt.setDate(1, new java.sql.Date(from.getTime()));
+        stmt.setDate(2, new java.sql.Date(to.getTime()));
+
+        ResultSet rs = stmt.executeQuery();
+        List<Claim> res = new ArrayList<Claim>();
+
+        while (rs.next()) {
+            res.add(new Claim(rs.getString(1), rs.getString(2), rs.getDate(3).getTime(), rs.getString(4), rs.getString(5)));
+        }
+
+        rs.close();
+        stmt.close();
+	con.close();
+
+	logger.debug("number of claims: " + res.size());
+
+        return res;
+    }
+
+    public void deleteClaim(String userEmail, String resultId) throws SQLException {
+
+        Connection con = DataSourceUtils.getConnection(datasource);
+
+        PreparedStatement stmt = con.prepareStatement("delete from claims where \"agent\" = ? and resultid =?");
+        stmt.setString(1, userEmail);
+        stmt.setString(2, resultId);
+
+        stmt.executeUpdate();
+        stmt.close();
+	con.close();
+    }
+
+    /**
+     *
+     * @param id {openaireId, publication doi, ORCIDId (personId-ORCIDPublicationId), data doi}
+     * @param source {openaire, doi (crossref), orcid, datacite}
+     * @param title
+     * @param description
+     * @param access_mode
+     * @param embargoEndDate
+     * @param authors
+     * @param url
+     * @param dcSource
+     * @param userEmail
+     * @param subjects
+     * @param publicationDate
+     * @param publisher
+     * @param language
+     * @param category
+     * @param doi
+     * @throws ResourceNotFoundException
+     * @throws ParseErrorException
+     * @throws Exception
+     */
+	@Transactional
+	public String insertDocument(
+			String id, 
+			String source, 
+			String title, 
+			String description, 
+			String access_mode, 
+			String embargoEndDate, 
+			List<Author> authors, 
+			String url,
+			String dcSource,
+			String userEmail,
+			List<String> subjects,
+			String publicationDate,
+			String publisher, 
+			String language, 
+			String category, 
+			String doi) throws Exception {
+		
+		Connection con = DataSourceUtils.getConnection(datasource);
+		PreparedStatement stmt;
+		String dmf;
+		String resultId = ActionUtils.getIdentifier(ActionUtils.getPrefix(source), id);
+		Date now = new Date();
+
+		if (!source.toLowerCase().equals("openaire") && title != null) {
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+			dmf = ActionUtils.createDMF(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, doi, Collections.EMPTY_LIST, subjects, Collections.EMPTY_LIST, publicationDate, publisher, language, category);
+			
+			stmt.setString(1, userEmail);
+			stmt.setString(2, resultId);
+			stmt.setDate(3, new java.sql.Date(now.getTime()));
+			stmt.setString(4, "dmf2actions");
+			stmt.setString(5, dmf);
+            stmt.setString(6, ActionUtils.getSet(source, "dmf"));
+            stmt.setString(7, ActionUtils.getProvenance(source));
+            stmt.setString(8, ActionUtils.getPrefix(source));
+			
+			stmt.executeUpdate();
+			stmt.close();
+		}
+
+		con.close();
+
+        return resultId;
+	}
+
+    public void insertConceptRelation(String documentId, String documentSource, String concept, String userEmail) throws Exception {
+        Connection con = DataSourceUtils.getConnection(datasource);
+        PreparedStatement stmt;
+        String dmf;
+
+        stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+        dmf = ActionUtils.createDMF(documentId, documentSource, null, null, null, null, Collections.EMPTY_LIST, null, null, null, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Arrays.asList(concept), null, null, null, null);
+
+        stmt.setString(1, userEmail);
+        stmt.setString(2, documentId);
+        stmt.setDate(3, new java.sql.Date(new Date().getTime()));
+        stmt.setString(4, "dmf2actions");
+        stmt.setString(5, dmf);
+        stmt.setString(6, ActionUtils.getSet(documentSource, "dmf"));
+        stmt.setString(7, ActionUtils.getProvenance(documentSource));
+        stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+        stmt.executeUpdate();
+        stmt.close();
+        con.close();
+    }
+
+    public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws Exception {
+        Connection con = DataSourceUtils.getConnection(datasource);
+        PreparedStatement stmt;
+        String xml = ActionUtils.createResultProjectRelation("openaire".equals(documentSource)?null:documentSource, docId, project.getType(), project.getProjectId());
+
+        stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+        stmt.setString(1, userEmail);
+        stmt.setString(2, docId);
+        stmt.setDate(3, new java.sql.Date(new Date().getTime()));
+        stmt.setString(4, "rels2actions");
+        stmt.setString(5, xml);
+        stmt.setString(6, ActionUtils.getSet(documentSource, "relation"));
+        stmt.setString(7, ActionUtils.getProvenance(documentSource));
+        stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+        stmt.executeUpdate();
+        stmt.close();
+    }
+
+    public void insertDatasetRelation(String docId, String documentSource, String datasetId, String userEmail) {
+        throw new UnsupportedOperationException();
+    }
+
+	@Deprecated
+	public void insertInferredDocument(
+			String id, 
+			String source, 
+			String title,
+			String description, 
+			String access_mode, 
+			String embargoEndDate,
+			List<Author> authors, 
+			String url, 
+			String dcSource,
+			List<Project> projects,
+			List<String> subjects,
+            List<String> concepts,
+			String publicationDate, 
+			String publisher, 
+			String language, 
+			String category, 
+			String doi,
+            String setName) throws Exception {
+
+        System.out.println("Adding doc " + id);
+
+        try {
+            actionManagerLocator.getService().createSet(new ActionManagerSet(setName, setName));
+        } catch (Exception e) {
+            if (e.getMessage() != null && e.getMessage().contains("already registered")) {
+                logger.debug("Set already exists");
+            } else {
+                throw e;
+            }
+        }
+
+        if (title != null) {
+            String dmf = ActionUtils.createDMF(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, doi, projects, subjects, new ArrayList<String>(), publicationDate, publisher, language, category);
+            FileWriter fw = new FileWriter("/tmp/concepts/" + id + "-insert.xml");
+
+            fw.append(dmf);
+
+            fw.close();
+           actionManagerLocator.getService().createAction("dmf2actions", setName, new Agent("inference", "inference",  AGENT_TYPE.service), Operation.INSERT, dmf, Provenance.sysimport_mining_repository, "0.9", ActionUtils.getPrefix(source));
+        }
+
+        String dmf = ActionUtils.createDMF(id, source, null, null, null, null, new ArrayList<Author>(), null, null, null, new ArrayList<Project>(), new ArrayList<String>(), concepts, null, null, null, null);
+
+        FileWriter fw = new FileWriter("/tmp/concepts/" + id + "-update.xml");
+
+        fw.append(dmf);
+
+        fw.close();
+
+        actionManagerLocator.getService().createAction("dmf2updateActions", setName, new Agent("inference", "inference",  AGENT_TYPE.service), Operation.INSERT, dmf, Provenance.sysimport_mining_repository, "0.9", ActionUtils.getPrefix(source));
+
+	}
+	
+	@Deprecated
+	public void insertInferredRelation(String resultSource, String resultId,
+			String projectType, String projectId, String setName) throws Exception {
+        String relation = ActionUtils.createResultProjectRelation(resultSource, resultId, projectType, projectId);
+
+		try {
+			actionManagerLocator.getService().createSet(new ActionManagerSet(setName, setName));
+		} catch (Exception e) {
+			logger.warn("Set already exists");
+		}
+
+		//actionManagerLocator.getService().createAction("rels2actions", setName, new Agent("inference", "inference",  AGENT_TYPE.service), Operation.INSERT, relation, Provenance.sysimport_mining_repository, "0.9", "openaire____");
+	}
+	
+	public ServiceLocator<ActionManagerService> getActionManagerLocator() {
+		return actionManagerLocator;
+	}
+
+	public void setActionManagerLocator(
+			ServiceLocator<ActionManagerService> actionManagerLocator) {
+		this.actionManagerLocator = actionManagerLocator;
+	}
+
+	public DataSource getDatasource() {
+		return datasource;
+	}
+
+	public void setDatasource(DataSource datasource) {
+		this.datasource = datasource;
+	}
+	
+	public ServiceLocator<ISLookUpService> getLookupServiceLocator() {
+		return lookupServiceLocator;
+	}
+
+	public void setLookupServiceLocator(
+			ServiceLocator<ISLookUpService> lookupServiceLocator) {
+		this.lookupServiceLocator = lookupServiceLocator;
+	}
+
+	public List<String> getContexts() throws ISLookUpException, ISLookUpServiceException {
+		return lookupServiceLocator.getService().quickSearchProfile("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') return $x");
+	}
+}
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(revision 47510)
@@ -0,0 +1,9 @@
+openaire.connector.thrift.port = 7911
+openaire.connector.thrift.timeout = 15000
+
+openaire.connector.unknownRepositoryName = Unknown Repository
+
+openaire.db.driverClassName = org.postgresql.Driver
+openaire.db.url = jdbc:postgresql://194.177.192.223:5432/dnet_claims
+openaire.db.username = dnet
+openaire.db.password = dnetPwd
Index: modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/ISIImport.java
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/ISIImport.java	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/ISIImport.java	(revision 47510)
@@ -0,0 +1,104 @@
+package eu.dnetlib.openaire.utils;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.*;
+
+import eu.dnetlib.openaire.thrift.Project;
+import org.apache.thrift.TException;
+
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+
+public class ISIImport {
+
+	public static void main(String[] args) throws IOException, TException {
+		
+		if (args.length != 1) {
+			System.out.println("Usage: ISIImport <file>");
+			System.exit(1);
+		}
+		
+		String filename = args[0];
+		
+		BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filename))));
+		String line;
+		OpenAIREConnector.Client client = new ThriftClient().getConnector();
+		int count = 0;
+
+		while ((line = br.readLine()) != null) {
+			String[] values = line.split("\t");
+			System.out.println("Current line: " + ++count);
+			
+			if (values.length != 57) {
+				continue;
+			}
+			
+			String id = values[56];
+			
+			if (id.length() == 19) {
+				String access_mode = "OPEN"; if (values[0].toLowerCase().equals("false")) access_mode = "CLOSED";
+				String doi = values[50];
+				String authors = values[6];
+				String title = values[9];
+				String description = values[21];
+				List<Author> authorList = new ArrayList<Author>();
+				String url = null;
+				String dcSource = values[10];
+				String subjects = values[54];
+				String publicationDate = values[40];
+				List<String> subjectList = new ArrayList<String>();
+				String publisher = values[32];
+				String language = values[12];
+				String category = values[13];
+				
+				if (doi != null)
+					url = "http://dx.doi.org/" + doi;
+
+                if (category == null || category.trim().isEmpty())
+                    category = "0000";
+
+				if (authors != null) {
+					List<String> authorSet = new ArrayList<String>();
+
+					for (String author:authors.split(";"))
+						if (!authorSet.contains(author))
+							authorSet.add(author.trim());
+
+					for (String author:authorSet) {
+						String authorParts[] = author.trim().split(",");
+
+						String name;
+						String newSurname = "UNKNOWN";
+
+						if (authorParts.length ==  1) {
+							name = authorParts[0];
+						} else {
+							name = authorParts[authorParts.length - 1];
+							newSurname = author.substring(0, author.length() - name.length() - 1 );
+						}
+						
+						authorList.add(new Author("", newSurname.trim(), name.trim()));
+					}
+				}
+				
+				if (subjects != null) {
+					for (String subject:subjects.split(";")) {
+						subjectList.add(subject.trim());
+					}
+				}
+/*
+				client.insertAndClaimDocument(id, "wos", title, description,
+						access_mode, "", authorList, url, dcSource, null, "inference",
+                        new ArrayList<Project>(), subjectList, new ArrayList<String>(),
+                        publicationDate, publisher, language, category, doi);
+*/
+			}
+		}
+		
+		br.close();
+	}
+}
Index: modules/uoa-claims-api/branches/import/src/main/thrift/OpenAIREConnector.thrift
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/thrift/OpenAIREConnector.thrift	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/thrift/OpenAIREConnector.thrift	(revision 47510)
@@ -0,0 +1,142 @@
+namespace java eu.dnetlib.openaire.thrift
+
+struct Author {
+	1: string id,
+	2: string lastName,
+	3: string firstName
+}
+
+// alerts
+struct AlertSubscription {
+	1: string templateId,
+	2: string notificationService,
+	3: string queryId,
+	4: string resultId,
+	5: string alertMode,
+	6: string subscriber
+}
+
+struct ResultPage {
+	1: i32 limit,
+	2: i32 offset,
+	3: list<string> columns,
+	4: list<list<string>> rows
+}
+
+struct Claim {
+    1: string userEmail,
+	2: string resultid,
+	3: i64 date,
+	4: string type,
+	5: string xml
+}
+
+struct Project {
+    1: string type,
+    2: string projectId
+}
+
+// connector
+service OpenAIREConnector {
+	// claim
+	list<Claim> getClaimedPublications(1: string userEmail),
+
+	// from: date in milisecs
+	// to: ditto
+	list<Claim> getAllClaimedPublications(1: i64 from, 2: i64 to),
+	
+	string insertDocument(
+			1: string originalId,
+			2: string source, 
+			3: string title, 
+			4: string description, 
+			5: string access_mode, 
+			6: string embargoEndDate, 
+			7: list<Author> authors, 
+			8: string url,
+			9: string dcSource,
+			10: string userEmail,
+			11: list<string> subjects,
+			12: string publicationDate,
+			13: string publisher,
+			14: string language,
+			15: string category,
+			16: string doi),
+
+    void insertConcept(
+        1: string docId,
+        2: string documentSource,
+        3: string concept,
+        4: string userEmail),
+
+    void insertProjectRelation(
+        1: string docId,
+        2: string documentSource,
+        3: Project project,
+        4: string userEmail),
+
+    void insertDatasetRelation(
+        1: string docId,
+        2: string documentSource,
+        3: string datasetId,
+        4: string userEmail
+    ),
+
+	void deleteClaim(1: string userEmail, 2:string resultId),
+			
+	// inferred stuff  --- DO NOT USE FROM PORTAL!!!
+	void insertInferredDocument(
+			1: string id, 
+			2: string source, 
+			3: string title, 
+			4: string description, 
+			5: string access_mode, 
+			6: string embargoEndDate, 
+			7: list<Author> authors, 
+			8: string url,
+			9: string dcSource, 
+			10: list<Project> projects,
+			11: list<string> subjects,
+			12: list<string> concepts,
+			13: string publicationDate,
+			14: string publisher,
+			15: string language,
+			16: string category,
+			17: string doi,
+			18: string setName),
+			
+	void insertInferredRelation(
+	        1: string resultSource,
+	        2: string resultId,
+	        3: string projectType,
+	        4: string projectId,
+	        5: string setName),
+
+	// alerts
+	list<AlertSubscription> getSubscriptions(
+			1: string alertMode, 
+			2: string subscriber, 
+			3: i32 limit, 
+			4: i32 offset),
+			
+	void addSubscription(1: AlertSubscription subscription),
+	
+	void removeSubscription(1: AlertSubscription subscription),
+	
+	i32 countAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: i64 date, 
+			5: string resultId),
+			
+	ResultPage getAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: string resultId, 
+			4: i64 fromDate, 
+			5: i64 toDate, 
+			6: i32 limit, 
+			7: i32 offset),
+	
+	list<string> getContexts(),
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/ThriftClient.java
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/ThriftClient.java	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/ThriftClient.java	(revision 47510)
@@ -0,0 +1,21 @@
+package eu.dnetlib.openaire.utils;
+
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+
+public class ThriftClient {
+
+	public OpenAIREConnector.Client getConnector() throws TTransportException {
+		TTransport transport = new TSocket("localhost", 7911);
+		transport.open();
+
+		TProtocol protocol = new  TBinaryProtocol(transport);
+		
+		return new OpenAIREConnector.Client(protocol);
+	}
+}
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/action/relation.vm
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(revision 47510)
@@ -0,0 +1,5 @@
+<RELATIONS>
+#foreach ($rel in $relations)
+    <RELATION type='$rel.Type' source='$rel.SourceId' target='$rel.TargetId' />
+#end
+</RELATIONS>
\ No newline at end of file
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/utils/claims.sql
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(revision 47510)
@@ -0,0 +1,45 @@
+select
+        r.resultid                                          as dri_objidentifier,
+        r.title                                             as dc_title,
+        array_agg(DISTINCT lpad('0'||aut.rank,5,'0')||'§§§'||ltrim(replace(per.surname||', '||per.name,'UNKNOWN, ',''), ', ')) as dc_creator,
+      r.description                                       as dc_description,
+        r.publisher                                         as dc_publisher,
+        r.keywords                                          as dc_subject,
+        r.language                                          as dc_language,
+        array_agg(DISTINCT ws.file_url)                     as dc_identifier,
+        r.publication_date                                  as oaf_publicationdate,
+        r.embargo_end_date                                  as oaf_embargoenddate,
+        r.access_mode                                       as oaf_accessmode,
+        r.haskind                                           as oaf_haskind,
+        r.hastype                                           as "dr_CobjCategory",
+        r.storagedate                                           as oaf_storagedate,
+        createdfrom                                         as createdfrom,
+        array_agg(DISTINCT p.projectid)                     as oaf_projectid,
+        array_agg(DISTINCT cr.creator)                              as creators
+
+from
+
+       results r
+        left outer join results_projects rp on (r.resultid = rp.result)
+        left outer join projects p on (p.projectid = rp.project)
+        left outer join projects_projectsubjects ps on (ps.project = p.projectID)
+        left outer join fundingschemes fs on (p.fundedhow = fs.fundingschemeid)
+        left outer join programs s on (p.fundedby = s.programid)
+        left outer join specificprograms sp on (s.hasspecificprogram = sp.specificprogramid)
+        left outer join frameworkprograms fp on (sp.hasframeworkprogram = fp.frameworkprogramid)
+        left outer join authorships aut on (r.resultid = aut.result)
+        left outer join persons per on (per.personid = aut.author)
+        left outer join organizations o on (o.organizationid = aut.affiliation)
+        left outer join instances i on (r.resultid = i.resource)
+        left outer join webresources_instances wsi on (wsi.instanceid = i.instanceid)
+        left outer join webresources ws on (ws.webresourceid = wsi.webresourceid)
+
+        join creations cr on cr.creation = r.resultid
+
+where
+        r.pmhdeleted != true and r.pendingforclaim = false
+
+group by
+        r.resultid, r.title, r.description, r.publisher, r.keywords, r.language,
+        r.publication_date, r.embargo_end_date, r.access_mode, r.haskind, r.hastype,
+        r.storagedate, r.createdfrom
\ No newline at end of file
Index: modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(revision 47510)
@@ -0,0 +1,9 @@
+openaire.connector.thrift.port = 7911
+openaire.connector.thrift.timeout = 15000
+
+openaire.connector.unknownRepositoryName = Unknown Repository
+
+openaire.db.driverClassName = org.postgresql.Driver
+openaire.db.url = jdbc:postgresql://194.177.192.223:5432/dnet_claims
+openaire.db.username = dnet
+openaire.db.password = dnetPwd
Index: modules/uoa-claims-api/branches/import/src/main/resources/ehcache.xml
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/resources/ehcache.xml	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/resources/ehcache.xml	(revision 47510)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
+    <!--
+     | Please see http://ehcache.sourceforge.net/documentation/configuration.html for
+     | detailed information on how to configurigure caches in this file
+     +-->
+    <!-- Location of persistent caches on disk -->
+    <diskStore path="java.io.tmpdir/EhCacheSpringAnnotationsExampleApp" />
+
+    <defaultCache eternal="true" maxElementsInMemory="10000"
+        overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
+        timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU"/>
+
+	<cache name="claimator"/>
+	<cache name="alertator.subscriptions"/>
+	<cache name="querynator"/>
+</ehcache>
\ No newline at end of file
Index: modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(revision 47510)
@@ -0,0 +1,43 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TTransportException;
+
+public class ThriftServer {
+	private OpenAIREConnector.Iface openAireConnector;
+	private int port;
+	private int timeout;
+	private Thread thread;
+
+	public void setOpenAireConnector(final OpenAIREConnector.Iface openAireConnector) {
+		this.openAireConnector = openAireConnector;
+	}
+	
+	public void setPort(final int port) {
+		this.port = port;
+	}
+	
+	public void setTimeout(final int timeout) {
+		this.timeout = timeout;
+	}
+	
+	public void start() {
+		thread = new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					new TThreadPoolServer(new TThreadPoolServer.Args(new TServerSocket(port, timeout)).processor(new OpenAIREConnector.Processor<OpenAIREConnector.Iface>(openAireConnector))).serve();
+				} catch (final TTransportException e) {
+					Logger.getLogger(ThriftServer.class).error("Error starting thrift server", e);
+				}
+			}
+		});
+		thread.start();
+	}
+	
+	public void stop() {
+		thread.interrupt();
+	}
+}
Index: modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(revision 47510)
@@ -0,0 +1,215 @@
+package eu.dnetlib.openaire.thrift;
+
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+
+import eu.dnetlib.api.functionality.AlertServiceException;
+
+public class OpenAIREConnectorImpl implements OpenAIREConnector.Iface {
+	private static final Logger LOGGER = Logger.getLogger(OpenAIREConnectorImpl.class);
+
+	private ClaimConnector claimConnector;
+	private AlertConnector alertConnector;
+
+	public void setClaimConnector(final ClaimConnector claimConnector) {
+		this.claimConnector = claimConnector;
+	}
+
+	public void setAlertConnector(final AlertConnector alertConnector) {
+		this.alertConnector = alertConnector;
+	}
+
+	@Override
+	public List<Claim> getClaimedPublications(final String user) throws TException {
+		try {
+			return claimConnector.getClaimedPublications(user);
+		} catch (final Exception e) {
+			LOGGER.error("Error retrieving claimed publications (user: " + user + ")", e);
+			throw new TException("Error retrieving claimed publications (user: " + user + ")", e);
+		}
+	}
+
+    @Override
+    public List<Claim> getAllClaimedPublications(long from, long to) throws TException {
+        try {
+            return claimConnector.getClaimedPublications(new Date(from), new Date(to));
+        } catch (Exception e) {
+            LOGGER.error("Error retrieving claimed publications", e);
+
+            throw new TException("Error retrieving claimed publications", e);
+        }
+    }
+
+    @Override
+    public String insertDocument(String originalId, String source, String title, String description, String access_mode, String embargoEndDate, List<Author> authors, String url, String dcSource, String userEmail, List<String> subjects, String publicationDate, String publisher, String language, String category, String doi) throws org.apache.thrift.TException {
+        try {
+            return claimConnector.insertDocument(originalId, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, userEmail, subjects, publicationDate, publisher, language, category, doi);
+        } catch (Exception e) {
+            LOGGER.error("Error adding document", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertConcept(String docId, String documentSource, String concept, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertConceptRelation(docId, documentSource, concept, userEmail);
+        } catch (Exception e) {
+            LOGGER.error("Error adding concept relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertProjectRelation(docId, documentSource, project, userEmail);
+        } catch (Exception e) {
+            LOGGER.error("Error adding project relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertDatasetRelation(String docId, String documentSource, String datasetId, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertDatasetRelation(docId, documentSource, datasetId, userEmail);
+        } catch (Exception e) {
+            LOGGER.error("Error adding dataset relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+	public List<AlertSubscription> getSubscriptions(final String alertMode, final String subscriber, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getSubscriptions(alertMode, subscriber, limit, offset);
+		} catch (final AlertServiceException e) {
+			LOGGER.error("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+	@Override
+	public void addSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.addSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			LOGGER.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final MalformedURLException e) {
+			LOGGER.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final URISyntaxException e) {
+			LOGGER.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		}
+	}
+
+	@Override
+	public void removeSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.removeSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			LOGGER.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final MalformedURLException e) {
+			LOGGER.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final URISyntaxException e) {
+			LOGGER.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		}
+	}
+
+	@Override
+	public int countAlertResults(final String notificationService, final String queryId, final long date, final String resultId) throws TException {
+		try {
+			return alertConnector.countAlertResults(notificationService, queryId, date, resultId);
+		} catch (final AlertServiceException e) {
+			LOGGER.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		} catch (final MalformedURLException e) {
+			LOGGER.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		}
+	}
+
+	@Override
+	public ResultPage getAlertResults(final String notificationService, final String queryId, final String resultId, final long fromDate, final long toDate, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getAlertResults(notificationService, queryId, resultId, fromDate, toDate, limit, offset);
+		} catch (final AlertServiceException e) {
+			LOGGER.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		} catch (final MalformedURLException e) {
+			LOGGER.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+    @Override
+    public void deleteClaim(String userEmail, String resultId) throws TException {
+        try {
+            claimConnector.deleteClaim(userEmail, resultId);
+        } catch (Exception e) {
+            LOGGER.error("Error deleting claim", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+	@Deprecated
+	public void insertInferredDocument(String id, String source, String title,
+			String description, String access_mode, String embargoEndDate,
+			List<Author> authors, String url, String dcSource,
+			List<Project> projects, List<String> subjects, List<String> concepts, String publicationDate, String publisher, String language, String category, String doi, String setName) throws TException {
+		try {
+			claimConnector.insertInferredDocument(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, projects, subjects, concepts, publicationDate, publisher, language, category, doi, setName);
+		} catch (Exception e) {
+			LOGGER.error("Error inserting inferred document", e);
+			
+			throw new TException(e);
+		}
+		
+	}
+
+	@Override
+	@Deprecated
+	public void insertInferredRelation(String resultSource, String resultId,
+			String projectType, String projectId, String setName) throws TException {
+		try {
+			claimConnector.insertInferredRelation(resultSource, resultId, projectType, projectId, setName);
+		} catch (Exception e) {
+			LOGGER.error("Error inserting inferred relation", e);
+			
+			throw new TException(e);
+		}
+	}
+
+	@Override
+	public List<String> getContexts() throws TException {
+		try {
+			return claimConnector.getContexts();
+		} catch (Exception e) {
+			LOGGER.error("Error getting contexts from IS.", e);
+			
+			throw new TException(e);
+		}
+		
+	}
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/WOSConceptImport.java
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/WOSConceptImport.java	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/WOSConceptImport.java	(revision 47510)
@@ -0,0 +1,129 @@
+package eu.dnetlib.openaire.utils;
+
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+import eu.dnetlib.openaire.thrift.Project;
+import org.apache.thrift.TException;
+import org.apache.thrift.transport.TTransportException;
+
+import java.io.*;
+import java.util.*;
+
+public class WOSConceptImport {
+
+    private static Map<String, List<String>> readConcepts(String filename) throws IOException, TTransportException {
+        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filename))));
+        String line;
+        Map<String, List<String>> map = new HashMap<String, List<String>>();
+
+        while ((line = br.readLine()) != null) {
+            String[] values = line.split("\t");
+            String resultId = values[0];
+            String conceptId = values[1];
+
+            List<String> concepts = map.get(resultId);
+
+            if (concepts == null) {
+                concepts = new ArrayList<String>();
+                map.put(resultId, concepts);
+            }
+
+            concepts.add(conceptId);
+        }
+
+        br.close();
+
+        return map;
+    }
+
+	public static void main(String[] args) throws IOException, TException {
+		
+		if (args.length != 4) {
+			System.out.println("Usage: ISIImport <context (egi)> <concept file> <metadata file> <action (insert | update)");
+			System.exit(1);
+		}
+
+        Map<String, List<String>> conceptMap = readConcepts(args[1]);
+        String setName = "sysimport_mining_repository_" + args[0];
+		String filename = args[2];
+        String action = args[3];
+		
+		BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filename))));
+		String line;
+		OpenAIREConnector.Client client = new ThriftClient().getConnector();
+
+		while ((line = br.readLine()) != null) {
+			String[] values = line.split("\t");
+			
+			if (values.length != 57) {
+				continue;
+			}
+			
+			String id = values[56];
+
+			
+			if (id.length() == 19 && conceptMap.containsKey(id)) {
+				String access_mode = "OPEN"; if (values[0].toLowerCase().equals("false")) access_mode = "CLOSED";
+				String doi = values[50];
+				String authors = values[6];
+				String title = values[9];
+				String description = values[21];
+				List<Author> authorList = new ArrayList<Author>();
+				String url = null;
+				String dcSource = values[10];
+				String subjects = values[54];
+				String publicationDate = values[40];
+				List<String> subjectList = new ArrayList<String>();
+				String publisher = values[32];
+				String language = values[12];
+				String category = values[13];
+				
+				if (doi != null)
+					url = "http://dx.doi.org/" + doi;
+
+				if (authors != null) {
+					List<String> authorSet = new ArrayList<String>();
+
+					for (String author:authors.split(";"))
+						if (!authorSet.contains(author))
+							authorSet.add(author.trim());
+
+					for (String author:authorSet) {
+						String authorParts[] = author.trim().split(",");
+
+						String name;
+						String newSurname = "UNKNOWN";
+
+						if (authorParts.length ==  1) {
+							name = authorParts[0];
+						} else {
+							name = authorParts[authorParts.length - 1];
+							newSurname = author.substring(0, author.length() - name.length() - 1 );
+						}
+						
+						authorList.add(new Author("", newSurname.trim(), name.trim()));
+					}
+				}
+				
+				if (subjects != null) {
+					for (String subject:subjects.split(";")) {
+						subjectList.add(subject.trim());
+					}
+				}
+
+                if (action.equals("insert"))
+				    client.insertInferredDocument(id, "wos", title, description,
+						access_mode, "", authorList, url, dcSource,
+						new ArrayList<Project>(), subjectList, conceptMap.get(id),
+                        publicationDate, publisher, language, category, doi, setName);
+                else
+                    client.insertInferredDocument(id, "wos", null, null,
+                            null, "", new ArrayList<Author>(), null, null,
+                            new ArrayList<Project>(), new ArrayList<String>(), conceptMap.get(id),
+                            null, null, null, null, null, setName);
+			}
+		}
+		
+		br.close();
+	}
+}
Index: modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/ClaimMigration.java
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/ClaimMigration.java	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/ClaimMigration.java	(revision 47510)
@@ -0,0 +1,111 @@
+package eu.dnetlib.openaire.utils;
+
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+import eu.dnetlib.openaire.thrift.Project;
+import org.apache.commons.io.IOUtils;
+import org.apache.log4j.BasicConfigurator;
+import org.apache.thrift.TException;
+import org.apache.thrift.transport.TTransportException;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Created by antleb on 3/13/14.
+ */
+public class ClaimMigration {
+
+    public static void main(String[] args) throws Exception {
+        BasicConfigurator.configure();
+
+        Class.forName("org.postgresql.Driver");
+        foo("jdbc:postgresql://194.177.192.223:5432/dnet_openaire?user=dnet&password=dnetPwd");
+    }
+
+    public ClaimMigration() throws ClassNotFoundException {
+
+    }
+
+    private static void foo(String url) throws SQLException, IOException, TException {
+        OpenAIREConnector.Client client = new ThriftClient().getConnector();
+        Connection con = DriverManager.getConnection(url);
+        PreparedStatement stmt = con.prepareStatement(readStatement());
+        ResultSet rs = stmt.executeQuery();
+
+        while (rs.next()) {
+            String id = rs.getString("createdfrom");
+            List<Author> authors = new ArrayList<Author>();
+            List<Project> projects = new ArrayList<Project>();
+            List<String> subjects = new ArrayList<String>();
+
+            id = id.substring(id.indexOf(':') + 1);
+
+            if (rs.getString("createdFrom").startsWith("driver")) {
+                id = id.split("::")[1];
+            }
+
+            System.out.println("authors: " + rs.getArray("dc_creator"));
+
+            for (String s:(String[]) rs.getArray("dc_creator").getArray()) {
+                if (s != null)
+                    authors.add(new Author(null, s.split("§§§")[1], null));
+            }
+
+            for (String s:(String[]) rs.getArray("oaf_projectid").getArray()) {
+                projects.add(new Project(null, "corda_______::" + s));
+            }
+
+            for (String claimer:(String[]) rs.getArray("creators").getArray()) {
+// String id, String source, String title, String description, String access_mode,
+// String embargoEndDate, List<Author> authors, String url, String dcSource,
+// String userName, String userEmail, List<String> projects, List<String> subjects,
+// List<String> concepts, String publicationDate, String publisher, String language,
+// String category, String doi
+
+/*
+            client.insertAndClaimDocument(id,
+                    (rs.getString("createdfrom").startsWith("doi")?"doi":"driver"),
+                    rs.getString("dc_title"),
+                    rs.getString("dc_description"),
+                    rs.getString("oaf_accessmode"),
+                    rs.getString("oaf_embargoenddate"),
+                    authors,
+                    ((String[])rs.getArray("dc_identifier").getArray())[0],
+                    null,
+                    null,
+                    claimer,
+                    projects,
+                    subjects,
+                    new ArrayList<String>(),
+                    rs.getString("oaf_publicationdate"),
+                    rs.getString("dc_publisher"),
+                    rs.getString("dc_language"),
+                    rs.getString("dr_CobjCategory"),
+                    null);
+*/
+            }
+        }
+
+        rs.close();
+        stmt.close();
+        con.close();
+
+    }
+
+    private static String readStatement() throws IOException {
+        InputStream is = ClassLoader.getSystemResourceAsStream("eu/dnetlib/openaire/utils/claims.sql");
+        StringWriter sw = new StringWriter();
+
+        IOUtils.copy(is, sw);
+
+        is.close();
+
+        return sw.toString();
+    }
+}
Index: modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/eu/dnetlib/openaire/utils/claims.sql
===================================================================
--- modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(revision 47510)
@@ -0,0 +1,45 @@
+select
+        r.resultid                                          as dri_objidentifier,
+        r.title                                             as dc_title,
+        array_agg(DISTINCT lpad('0'||aut.rank,5,'0')||'§§§'||ltrim(replace(per.surname||', '||per.name,'UNKNOWN, ',''), ', ')) as dc_creator,
+      r.description                                       as dc_description,
+        r.publisher                                         as dc_publisher,
+        r.keywords                                          as dc_subject,
+        r.language                                          as dc_language,
+        array_agg(DISTINCT ws.file_url)                     as dc_identifier,
+        r.publication_date                                  as oaf_publicationdate,
+        r.embargo_end_date                                  as oaf_embargoenddate,
+        r.access_mode                                       as oaf_accessmode,
+        r.haskind                                           as oaf_haskind,
+        r.hastype                                           as "dr_CobjCategory",
+        r.storagedate                                           as oaf_storagedate,
+        createdfrom                                         as createdfrom,
+        array_agg(DISTINCT p.projectid)                     as oaf_projectid,
+        array_agg(DISTINCT cr.creator)                              as creators
+
+from
+
+       results r
+        left outer join results_projects rp on (r.resultid = rp.result)
+        left outer join projects p on (p.projectid = rp.project)
+        left outer join projects_projectsubjects ps on (ps.project = p.projectID)
+        left outer join fundingschemes fs on (p.fundedhow = fs.fundingschemeid)
+        left outer join programs s on (p.fundedby = s.programid)
+        left outer join specificprograms sp on (s.hasspecificprogram = sp.specificprogramid)
+        left outer join frameworkprograms fp on (sp.hasframeworkprogram = fp.frameworkprogramid)
+        left outer join authorships aut on (r.resultid = aut.result)
+        left outer join persons per on (per.personid = aut.author)
+        left outer join organizations o on (o.organizationid = aut.affiliation)
+        left outer join instances i on (r.resultid = i.resource)
+        left outer join webresources_instances wsi on (wsi.instanceid = i.instanceid)
+        left outer join webresources ws on (ws.webresourceid = wsi.webresourceid)
+
+        join creations cr on cr.creation = r.resultid
+
+where
+        r.pmhdeleted != true and r.pendingforclaim = false
+
+group by
+        r.resultid, r.title, r.description, r.publisher, r.keywords, r.language,
+        r.publication_date, r.embargo_end_date, r.access_mode, r.haskind, r.hastype,
+        r.storagedate, r.createdfrom
\ No newline at end of file
Index: modules/uoa-claims-api/trunk/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java
===================================================================
--- modules/uoa-claims-api/trunk/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(revision 47510)
@@ -0,0 +1,35 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.TException;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * Created by antleb on 6/20/14.
+ */
+public class TestConnector {
+
+	public static void main(String[] args) throws TException {
+
+		OpenAIREConnector.Client client = new ThriftClient().getConnector("194.177.192.223", 7911);
+
+		String id = client.insertDocument("123123/3434.23", "doi", "a title", " a description", "OPEN ACCESS", null,
+                Arrays.asList(new Author("id" ,"lastname", "firstname")), "url", "dcsource", "antleb@di.uoa.gr",
+                Arrays.asList("subject"), "2012-01-02", "publisher", "language", "category", "doioioioi" ,
+                new ArrayList<Project4Index>(), new ArrayList<String>());
+		System.out.println(id);
+
+		client.insertConcept(id, "doi", "egi", "antleb@di.uoa.gr", "123");
+		client.insertProjectRelation(id, "doi", new Project("ec", "1233312"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "doi", new Project(null, "1233312"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "doi", id, "result", "antleb@di.uoa.gr");
+
+		id = "od______1406::fbda7b28cda277b04c8dc27a5e0deb68";
+
+		client.insertConcept(id, "openaire", "ec", "antleb@di.uoa.gr", "123");
+		client.insertProjectRelation(id, "openaire", new Project("ec", "099809987"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "openaire", new Project(null, "098908908"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "openaire", id, "dataset", "antleb@di.uoa.gr");
+	}
+}
Index: modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/action/Relation.java
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/action/Relation.java	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/action/Relation.java	(revision 47510)
@@ -0,0 +1,39 @@
+package eu.dnetlib.openaire.action;
+
+public class Relation {
+	private String type;
+	private String sourceId;
+	private String targetId;
+
+	public Relation(String type, String sourceId, String targetId) {
+		super();
+		this.type = type;
+		this.sourceId = sourceId;
+		this.targetId = targetId;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getSourceId() {
+		return sourceId;
+	}
+
+	public void setSourceId(String sourceId) {
+		this.sourceId = sourceId;
+	}
+
+	public String getTargetId() {
+		return targetId;
+	}
+
+	public void setTargetId(String targetId) {
+		this.targetId = targetId;
+	}
+
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/ehcache.xml
===================================================================
--- modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/ehcache.xml	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimAPI/src/main/resources/ehcache.xml	(revision 47510)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
+    <!--
+     | Please see http://ehcache.sourceforge.net/documentation/configuration.html for
+     | detailed information on how to configurigure caches in this file
+     +-->
+    <!-- Location of persistent caches on disk -->
+    <diskStore path="java.io.tmpdir/EhCacheSpringAnnotationsExampleApp" />
+
+    <defaultCache eternal="true" maxElementsInMemory="10000"
+        overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
+        timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU"/>
+
+	<cache name="claimator"/>
+	<cache name="alertator.subscriptions"/>
+	<cache name="querynator"/>
+</ehcache>
\ No newline at end of file
Index: modules/uoa-claims-api/branches/newClaimAPI/src/main/thrift/OpenAIREConnector.thrift
===================================================================
--- modules/uoa-claims-api/branches/newClaimAPI/src/main/thrift/OpenAIREConnector.thrift	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimAPI/src/main/thrift/OpenAIREConnector.thrift	(revision 47510)
@@ -0,0 +1,118 @@
+namespace java eu.dnetlib.openaire.thrift
+
+struct Author {
+	1: string id,
+	2: string lastName,
+	3: string firstName
+}
+
+// alerts
+struct AlertSubscription {
+	1: string templateId,
+	2: string notificationService,
+	3: string queryId,
+	4: string resultId,
+	5: string alertMode,
+	6: string subscriber
+}
+
+struct ResultPage {
+	1: i32 limit,
+	2: i32 offset,
+	3: list<string> columns,
+	4: list<list<string>> rows
+}
+
+struct Claim {
+    1: string userEmail,
+	2: string resultid,
+	3: i64 date,
+	4: string type,
+	5: string xml,
+	6: string id
+}
+
+struct Project {
+    1: string type,
+    2: string projectId
+}
+
+// connector
+service OpenAIREConnector {
+	// claim
+	list<Claim> getClaimedPublications(1: string userEmail),
+
+	// from: date in milisecs
+	// to: ditto
+	list<Claim> getAllClaimedPublications(1: i64 from, 2: i64 to),
+	
+	string insertDocument (
+			1: string originalId,
+			2: string source, 
+			3: string title, 
+			4: string description, 
+			5: string access_mode, 
+			6: string embargoEndDate, 
+			7: list<Author> authors, 
+			8: string url,
+			9: string dcSource,
+			10: string userEmail,
+			11: list<string> subjects,
+			12: string publicationDate,
+			13: string publisher,
+			14: string language,
+			15: string category,
+			16: string doi),
+
+    void insertConcept (
+        1: string docId,
+        2: string documentSource,
+        3: string concept,
+        4: string userEmail,
+        5: string doi),
+
+    void insertProjectRelation (
+        1: string docId,
+        2: string documentSource,
+        3: Project project,
+        4: string userEmail),
+
+    void insertResultRelation (
+        1: string sourceResultId,
+        2: string sourceResultType,
+        3: string sourceResultSource,
+        4: string targetResultId,
+        5: string targetResultType,
+        6: string userEmail
+    ),
+
+	void deleteClaim(1: string userEmail, 2:string resultId),
+
+	// alerts
+	list<AlertSubscription> getSubscriptions(
+			1: string alertMode, 
+			2: string subscriber, 
+			3: i32 limit, 
+			4: i32 offset),
+			
+	void addSubscription(1: AlertSubscription subscription),
+	
+	void removeSubscription(1: AlertSubscription subscription),
+	
+	i32 countAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: i64 date, 
+			5: string resultId),
+			
+	ResultPage getAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: string resultId, 
+			4: i64 fromDate, 
+			5: i64 toDate, 
+			6: i32 limit, 
+			7: i32 offset),
+	
+	list<string> getContexts(),
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/newClaimAPI/src
===================================================================
--- modules/uoa-claims-api/branches/newClaimAPI/src	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimAPI/src	(revision 47510)

Property changes on: modules/uoa-claims-api/branches/newClaimAPI/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+
Index: modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(revision 47510)

Property changes on: modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/uoa-claims-api/branches/newClaimAPI/pom.xml
===================================================================
--- modules/uoa-claims-api/branches/newClaimAPI/pom.xml	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimAPI/pom.xml	(revision 47510)
@@ -0,0 +1,237 @@
+<?xml version="1.0"?>
+<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>uoa-openaire-connector</artifactId>
+	<version>2.0.0-SNAPSHOT</version>
+        <scm>
+                <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk</developerConnection>
+        </scm>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>dtrotts</id>
+			<name>Repository for maven thrift plugin</name>
+			<url>http://maven.davidtrott.com/repository</url>
+			<layout>default</layout>
+		</pluginRepository>
+	</pluginRepositories>
+	<build>
+<!--		<plugins>
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<archive>
+
+                    </archive>
+                    <descriptorRefs>
+                        <descriptorRef>jar-with-dependencies</descriptorRef>
+                    </descriptorRefs>
+                </configuration>
+            </plugin>
+       
+            <plugin>
+                <groupId>org.apache.thrift.tools</groupId>
+                <artifactId>maven-thrift-plugin</artifactId>
+                <version>0.1.10</version>
+                <executions>
+                    <execution>
+                        <id>thrift-sources</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>compile</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>thrift-test-sources</id>
+                        <phase>generate-test-sources</phase>
+                        <goals>
+                            <goal>testCompile</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            
+        </plugins>
+    
+        <pluginManagement>
+            <plugins>
+                This plugin's configuration is used to store Eclipse m2e settings
+                    only. It has no influence on the Maven build itself.
+                <plugin>
+                    <groupId>org.eclipse.m2e</groupId>
+                    <artifactId>lifecycle-mapping</artifactId>
+                    <version>1.0.0</version>
+                    <configuration>
+                        <lifecycleMappingMetadata>
+                            <pluginExecutions>
+                                <pluginExecution>
+                                    <pluginExecutionFilter>
+                                        <groupId>org.apache.thrift.tools</groupId>
+                                        <artifactId>maven-thrift-plugin</artifactId>
+                                        <versionRange>[0.1.10,)</versionRange>
+                                        <goals>
+                                            <goal>testCompile</goal>
+                                        </goals>
+                                    </pluginExecutionFilter>
+                                    <action>
+                                        <ignore/>
+                                    </action>
+                                </pluginExecution>
+                            </pluginExecutions>
+                        </lifecycleMappingMetadata>
+                    </configuration>
+                </plugin>
+            </plugins>
+        </pluginManagement> -->
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.7</source>
+                    <target>1.7</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>[0.0.0,)</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.5</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-dbcp</groupId>
+            <artifactId>commons-dbcp</artifactId>
+            <version>[1.2, 1.3)</version>
+        </dependency>
+        <dependency>
+            <groupId>eu.dnetlib</groupId>
+            <artifactId>uoa-claims-demo</artifactId>
+            <version>[1.0.0-SNAPSHOT,)</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.thrift</groupId>
+            <artifactId>libthrift</artifactId>
+            <version>0.8.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.postgresql</groupId>
+            <artifactId>jdbc4driver</artifactId>
+            <version>9.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity</artifactId>
+            <version>1.7</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+
+        <!-- Jersey -->
+        <dependency>
+            <groupId>asm</groupId>
+            <artifactId>asm</artifactId>
+            <version>3.3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-bundle</artifactId>
+            <version>1.19</version>
+        </dependency>
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>20140107</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-server</artifactId>
+            <version>1.19</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey</groupId>
+            <artifactId>jersey-core</artifactId>
+            <version>1.19</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-validator</groupId>
+            <artifactId>commons-validator</artifactId>
+            <version>1.3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.jersey.contribs</groupId>
+            <artifactId>jersey-spring</artifactId>
+            <version>1.8</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-core</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-web</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-beans</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-context</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-utils</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-aop</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>io.jsonwebtoken</groupId>
+            <artifactId>jjwt</artifactId>
+            <version>0.7.0</version>
+        </dependency>
+        <!-- <dependency>
+            <groupId>org.glassfish.jersey.containers</groupId>
+            <artifactId>jersey-container-servlet</artifactId>
+            <version>2.19</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.jersey.core</groupId>
+            <artifactId>jersey-server</artifactId>
+            <version>2.19</version>
+        </dependency>
+       <dependency>
+            <groupId>org.glassfish.jersey.ext</groupId>
+            <artifactId>jersey-spring3</artifactId>
+            <version>2.19</version>
+        </dependency> -->
+    </dependencies>
+</project>
Index: modules/uoa-claims-api/branches/newClaimAPI/deploy.info
===================================================================
--- modules/uoa-claims-api/branches/newClaimAPI/deploy.info	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimAPI/deploy.info	(revision 47510)
@@ -0,0 +1,10 @@
+{
+  "type_source": "SVN", 
+  "goal": "package -U -T 4C source:jar", 
+  "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk", 
+  "deploy_repository": "dnet4-snapshots", 
+  "version": "4", 
+  "mail": "antleb@di.uoa.gr, kiatrop@di.uoa.gr", 
+  "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", 
+  "name": "uoa-openaire-connector"
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/newClaimAPI
===================================================================
--- modules/uoa-claims-api/branches/newClaimAPI	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimAPI	(revision 47510)

Property changes on: modules/uoa-claims-api/branches/newClaimAPI
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+.project
+.settings
+.idea
+*.iml
+target
Index: modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java
===================================================================
--- modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(revision 47510)
@@ -0,0 +1,361 @@
+package eu.dnetlib.openaire.thrift;
+
+
+import eu.dnetlib.api.enabling.ISLookUpService;
+import eu.dnetlib.api.enabling.ISLookUpServiceException;
+import eu.dnetlib.openaire.action.ActionUtils;
+import eu.dnetlib.openaire.action.IndexUtils;
+import gr.uoa.di.driver.enabling.ISLookUpException;
+import gr.uoa.di.driver.util.ServiceLocator;
+import org.apache.log4j.Logger;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.springframework.jdbc.datasource.DataSourceUtils;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+@Transactional
+public class ClaimConnector {
+
+    private static Logger logger = Logger.getLogger(ClaimConnector.class);
+
+    private String directClaimAPIUrl = null;
+    private DataSource datasource = null;
+
+    //Using an isLookUp Impl just to make an xQuery to IS. Maybe move all the
+    //functionality to commons?
+    private ServiceLocator<ISLookUpService> lookupServiceLocator = null;
+
+    public List<Claim> getClaimedPublications(final String user) throws SQLException {
+        Connection con = DataSourceUtils.getConnection(datasource);
+        PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"date\" , \"type\", \"xml\", \"id\" from claims where \"agent\" = ?");
+        stmt.setString(1, user);
+        ResultSet rs = stmt.executeQuery();
+        List<Claim> res = new ArrayList<Claim>();
+
+        while (rs.next()) {
+            res.add(new Claim(user, rs.getString(1), rs.getTimestamp(2).getTime(), rs.getString(3), rs.getString(4), rs.getString(5)));
+        }
+
+        rs.close();
+        stmt.close();
+
+        logger.info("Returning " + res.size() + " claimed publications for user "  + user);
+
+        return res;
+    }
+
+    public List<Claim> getClaimedPublications(Date from, Date to) throws SQLException {
+        Connection con = DataSourceUtils.getConnection(datasource);
+
+        PreparedStatement stmt = con.prepareStatement("select \"agent\", \"resultid\", \"date\" , \"type\", \"xml\",  \"id\"  from claims where \"agent\" != 'inference' and \"date\" >= ?::timestamp and \"date\" <= ?::timestamp ");
+        stmt.setTimestamp(1, new Timestamp(from.getTime()));
+        stmt.setTimestamp(2, new Timestamp(to.getTime()));
+
+        ResultSet rs = stmt.executeQuery();
+        List<Claim> res = new ArrayList<Claim>();
+
+        while (rs.next()) {
+            res.add(new Claim(rs.getString(1), rs.getString(2), rs.getTimestamp(3).getTime(), rs.getString(4), rs.getString(5), rs.getString(6)));
+        }
+
+        rs.close();
+        stmt.close();
+
+        logger.debug("number of claims: " + res.size());
+        logger.info("Returning " + res.size() + " claimed publications for date "  + from + "-" + to);
+
+        return res;
+    }
+
+    public void deleteClaim(String userEmail, String id) throws SQLException {
+        logger.info("Deleting claim with id " + id + " for agent " +  userEmail);
+
+        Connection con = DataSourceUtils.getConnection(datasource);
+        int claim_id = Integer.parseInt(id);
+        String type = null;
+
+        PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"type\" from claims where \"id\" =?");
+        stmt.setInt(1, claim_id);
+
+        ResultSet rs = stmt.executeQuery();
+
+        String resultid = null;
+        String xml = null;
+
+        while (rs.next()) {
+            resultid = rs.getString("resultid");
+            type = rs.getString("type");
+        }
+
+        if (resultid != null) {
+            stmt = con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =?");
+            stmt.setString(1, userEmail);
+            stmt.setInt(2, claim_id);
+
+            stmt.executeUpdate();
+            logger.info("Deleted claim with claim id: " + claim_id + ", result id: " + resultid + " and type: " + type +".") ;
+
+            //prepare to get 2nd claim to be deleted
+            int claim2_id = claim_id - 1;
+
+            if (type != null && type.equals("rels2actions")) {
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+                rs = stmt.executeQuery();
+
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //check if the relation has dmf
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            } /*else if (type != null && type.equals("dmf2actions")) {
+                logger.info("dmf2actions");
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+
+                rs = stmt.executeQuery();
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                logger.info("xml: " + xml);
+                logger.info("xml? " + xml.contains("oaf:concept"));
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //delete concept with extra dmf (doi,orchid,... etc)
+                    logger.debug("dmf2actions and not concept");
+
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            }*/
+        }
+
+        stmt.close();
+
+        logger.info("Deleted claim with id " + id + " for agent " +  userEmail);
+    }
+
+    /**
+     * @param id     {openaireId, publication doi, ORCIDId (personId-ORCIDPublicationId), data doi}
+     * @param source {openaire, doi (crossref), orcid, datacite}
+     * @throws ResourceNotFoundException
+     * @throws ParseErrorException
+     * @throws Exception
+     */
+    public String insertDocument(
+            String id,
+            String source,
+            String title,
+            String description,
+            String access_mode,
+            String embargoEndDate,
+            List<Author> authors,
+            String url,
+            String dcSource,
+            String userEmail,
+            List<String> subjects,
+            String publicationDate,
+            String publisher,
+            String language,
+            String category,
+            String doi,
+            List<Project4Index> project4Indexes,
+            List<String> concepts) throws Exception {
+
+        logger.info("Request to insert document with id " + id + " and source " + source);
+        logger.info("The title is: " + title);
+
+        String resultId;
+
+        try {
+            Connection con = DataSourceUtils.getConnection(datasource);
+            PreparedStatement stmt;
+            String dmf;
+
+            resultId = ActionUtils.getIdentifier(ActionUtils.getPrefix(source), id);
+            Date now = new Date();
+
+            if (!source.toLowerCase().equals("openaire") && title != null) {
+                stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+                dmf = ActionUtils.createDMF(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, doi, Collections.EMPTY_LIST, subjects, Collections.EMPTY_LIST, publicationDate, publisher, language, category, false);
+
+                stmt.setString(1, userEmail);
+                stmt.setString(2, resultId);
+                stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+                stmt.setString(4, "dmf2actions");
+                stmt.setString(5, dmf);
+                stmt.setString(6, "userclaim_dmf");
+                stmt.setString(7, ActionUtils.getProvenance(source));
+                stmt.setString(8, ActionUtils.getPrefix(source));
+
+                stmt.executeUpdate();
+                stmt.close();
+
+            }
+        } catch (Exception e) {
+            logger.error("Error inserting document", e);
+            throw e;
+        }
+
+        if (!datasource.equals("openaire"))
+            IndexUtils.feedIndex(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource,
+                    doi, Collections.EMPTY_LIST, subjects, Collections.EMPTY_LIST, publicationDate, publisher,
+                    language, category, false, project4Indexes, concepts, directClaimAPIUrl);
+
+        logger.info("Inserted document with id " + id + ", source " + source + " and given resultId " + resultId);
+        return resultId;
+    }
+
+    public void insertConceptRelation(String documentId, String documentSource, String concept, String userEmail, String doi) throws Exception {
+        logger.info("Request for concept relation between document with id " + documentId + " with source " + documentSource + " and concept " + concept + "with doi " + doi);
+
+        try {
+            Connection con = DataSourceUtils.getConnection(datasource);
+            PreparedStatement stmt;
+            String dmf;
+
+            stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+            dmf = ActionUtils.createDMF(documentId, documentSource, null, null, null, null, Collections.EMPTY_LIST, null, null, doi, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Arrays.asList(concept), null, null, null, null, true);
+
+            stmt.setString(1, userEmail);
+            stmt.setString(2, documentId);
+            stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+            stmt.setString(4, "updates2actions");
+            stmt.setString(5, dmf);
+            stmt.setString(6, "userclaim_dmf");
+            stmt.setString(7, ActionUtils.getProvenance(documentSource));
+            stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+            stmt.executeUpdate();
+            stmt.close();
+        } catch (Exception e) {
+            logger.error("Error adding concept", e);
+            throw e;
+        }
+
+        logger.info("Inserted concept relation between document with id " + documentId + " with source " + documentSource + " and concept " + concept);
+    }
+
+    public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws Exception {
+        logger.info("Request for project relation between document with id " + docId + " with source " + documentSource + " and project " + project);
+
+        try {
+            Connection con = DataSourceUtils.getConnection(datasource);
+            PreparedStatement stmt;
+            String xml = ActionUtils.createResultProjectRelation("openaire".equals(documentSource) ? null : documentSource, docId, project.getType(), project.getProjectId());
+
+            stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+            stmt.setString(1, userEmail);
+            stmt.setString(2, docId);
+            stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+            stmt.setString(4, "rels2actions");
+            stmt.setString(5, xml);
+            stmt.setString(6, "userclaim_result_project");
+            stmt.setString(7, ActionUtils.getProvenance(documentSource));
+            stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+            stmt.executeUpdate();
+            stmt.close();
+        } catch (Exception e) {
+            logger.error("Error adding project", e);
+            throw e;
+        }
+
+        logger.info("Inserted project relation between document with id " + docId + " with source " + documentSource + " and project " + project);
+    }
+
+    public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws Exception {
+        logger.info("Request for result relation between source document with id " + sourceResultId + ", type " + sourceResultType + "and source " + sourceResultSource + " and " +
+                "target document with id " + targetResultId + ", type " + targetResultType);
+        try {
+            Connection con = DataSourceUtils.getConnection(datasource);
+            PreparedStatement stmt;
+            String xml = ActionUtils.createResultResultRelation(sourceResultId, sourceResultType, targetResultId, targetResultType);
+
+            stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+            stmt.setString(1, userEmail);
+            stmt.setString(2, sourceResultId);
+            stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+            stmt.setString(4, "rels2actions");
+            stmt.setString(5, xml);
+            stmt.setString(6, "userclaim_result_result");
+            stmt.setString(7, ActionUtils.getProvenance(sourceResultSource));
+            stmt.setString(8, ActionUtils.getPrefix(sourceResultSource));
+
+            stmt.executeUpdate();
+            stmt.close();
+        } catch (Exception e) {
+            logger.error("Error adding result relation", e);
+            throw e;
+        }
+
+        logger.info("Inserted result relation between source document with id " + sourceResultId + ", type " + sourceResultType + "and source " + sourceResultSource + " and " +
+                "target document with id " + targetResultId + ", type " + targetResultType);
+    }
+
+    public DataSource getDatasource() {
+        return datasource;
+    }
+
+    public void setDatasource(DataSource datasource) {
+        this.datasource = datasource;
+    }
+
+    public ServiceLocator<ISLookUpService> getLookupServiceLocator() {
+        return lookupServiceLocator;
+    }
+
+    public void setLookupServiceLocator(
+            ServiceLocator<ISLookUpService> lookupServiceLocator) {
+        this.lookupServiceLocator = lookupServiceLocator;
+    }
+
+    public List<String> getContexts() throws ISLookUpException, ISLookUpServiceException {
+        return lookupServiceLocator.getService().quickSearchProfile("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') return $x");
+    }
+
+    public String getDirectClaimAPIUrl() {
+        return directClaimAPIUrl;
+    }
+
+    public void setDirectClaimAPIUrl(String directClaimAPIUrl) {
+        this.directClaimAPIUrl = directClaimAPIUrl;
+    }
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(revision 47510)
@@ -0,0 +1,361 @@
+package eu.dnetlib.openaire.thrift;
+
+
+import eu.dnetlib.api.enabling.ISLookUpService;
+import eu.dnetlib.api.enabling.ISLookUpServiceException;
+import eu.dnetlib.openaire.action.ActionUtils;
+import eu.dnetlib.openaire.action.IndexUtils;
+import gr.uoa.di.driver.enabling.ISLookUpException;
+import gr.uoa.di.driver.util.ServiceLocator;
+import org.apache.log4j.Logger;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.springframework.jdbc.datasource.DataSourceUtils;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+@Transactional
+public class ClaimConnector {
+
+    private static Logger logger = Logger.getLogger(ClaimConnector.class);
+
+    private String directClaimAPIUrl = null;
+    private DataSource datasource = null;
+
+    //Using an isLookUp Impl just to make an xQuery to IS. Maybe move all the
+    //functionality to commons?
+    private ServiceLocator<ISLookUpService> lookupServiceLocator = null;
+
+    public List<Claim> getClaimedPublications(final String user) throws SQLException {
+        Connection con = DataSourceUtils.getConnection(datasource);
+        PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"date\" , \"type\", \"xml\", \"id\" from claims where \"agent\" = ?");
+        stmt.setString(1, user);
+        ResultSet rs = stmt.executeQuery();
+        List<Claim> res = new ArrayList<Claim>();
+
+        while (rs.next()) {
+            res.add(new Claim(user, rs.getString(1), rs.getTimestamp(2).getTime(), rs.getString(3), rs.getString(4), rs.getString(5)));
+        }
+
+        rs.close();
+        stmt.close();
+
+        logger.info("Returning " + res.size() + " claimed publications for user "  + user);
+
+        return res;
+    }
+
+    public List<Claim> getClaimedPublications(Date from, Date to) throws SQLException {
+        Connection con = DataSourceUtils.getConnection(datasource);
+
+        PreparedStatement stmt = con.prepareStatement("select \"agent\", \"resultid\", \"date\" , \"type\", \"xml\",  \"id\"  from claims where \"agent\" != 'inference' and \"date\" >= ?::timestamp and \"date\" <= ?::timestamp ");
+        stmt.setTimestamp(1, new Timestamp(from.getTime()));
+        stmt.setTimestamp(2, new Timestamp(to.getTime()));
+
+        ResultSet rs = stmt.executeQuery();
+        List<Claim> res = new ArrayList<Claim>();
+
+        while (rs.next()) {
+            res.add(new Claim(rs.getString(1), rs.getString(2), rs.getTimestamp(3).getTime(), rs.getString(4), rs.getString(5), rs.getString(6)));
+        }
+
+        rs.close();
+        stmt.close();
+
+        logger.debug("number of claims: " + res.size());
+        logger.info("Returning " + res.size() + " claimed publications for date "  + from + "-" + to);
+
+        return res;
+    }
+
+    public void deleteClaim(String userEmail, String id) throws SQLException {
+        logger.info("Deleting claim with id " + id + " for agent " +  userEmail);
+
+        Connection con = DataSourceUtils.getConnection(datasource);
+        int claim_id = Integer.parseInt(id);
+        String type = null;
+
+        PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"type\" from claims where \"id\" =?");
+        stmt.setInt(1, claim_id);
+
+        ResultSet rs = stmt.executeQuery();
+
+        String resultid = null;
+        String xml = null;
+
+        while (rs.next()) {
+            resultid = rs.getString("resultid");
+            type = rs.getString("type");
+        }
+
+        if (resultid != null) {
+            stmt = con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =?");
+            stmt.setString(1, userEmail);
+            stmt.setInt(2, claim_id);
+
+            stmt.executeUpdate();
+            logger.info("Deleted claim with claim id: " + claim_id + ", result id: " + resultid + " and type: " + type +".") ;
+
+            //prepare to get 2nd claim to be deleted
+            int claim2_id = claim_id - 1;
+
+            if (type != null && type.equals("rels2actions")) {
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+                rs = stmt.executeQuery();
+
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //check if the relation has dmf
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            } /*else if (type != null && type.equals("dmf2actions")) {
+                logger.info("dmf2actions");
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+
+                rs = stmt.executeQuery();
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                logger.info("xml: " + xml);
+                logger.info("xml? " + xml.contains("oaf:concept"));
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //delete concept with extra dmf (doi,orchid,... etc)
+                    logger.debug("dmf2actions and not concept");
+
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            }*/
+        }
+
+        stmt.close();
+
+        logger.info("Deleted claim with id " + id + " for agent " +  userEmail);
+    }
+
+    /**
+     * @param id     {openaireId, publication doi, ORCIDId (personId-ORCIDPublicationId), data doi}
+     * @param source {openaire, doi (crossref), orcid, datacite}
+     * @throws ResourceNotFoundException
+     * @throws ParseErrorException
+     * @throws Exception
+     */
+    public String insertDocument(
+            String id,
+            String source,
+            String title,
+            String description,
+            String access_mode,
+            String embargoEndDate,
+            List<Author> authors,
+            String url,
+            String dcSource,
+            String userEmail,
+            List<String> subjects,
+            String publicationDate,
+            String publisher,
+            String language,
+            String category,
+            String doi,
+            List<Project4Index> project4Indexes,
+            List<String> concepts) throws Exception {
+
+        logger.info("Request to insert document with id " + id + " and source " + source);
+        logger.info("The title is: " + title);
+
+        String resultId;
+
+        try {
+            Connection con = DataSourceUtils.getConnection(datasource);
+            PreparedStatement stmt;
+            String dmf;
+
+            resultId = ActionUtils.getIdentifier(ActionUtils.getPrefix(source), id);
+            Date now = new Date();
+
+            if (!source.toLowerCase().equals("openaire") && title != null) {
+                stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+                dmf = ActionUtils.createDMF(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, doi, Collections.EMPTY_LIST, subjects, Collections.EMPTY_LIST, publicationDate, publisher, language, category, false);
+
+                stmt.setString(1, userEmail);
+                stmt.setString(2, resultId);
+                stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+                stmt.setString(4, "dmf2actions");
+                stmt.setString(5, dmf);
+                stmt.setString(6, "userclaim_dmf");
+                stmt.setString(7, ActionUtils.getProvenance(source));
+                stmt.setString(8, ActionUtils.getPrefix(source));
+
+                stmt.executeUpdate();
+                stmt.close();
+
+            }
+        } catch (Exception e) {
+            logger.error("Error inserting document", e);
+            throw e;
+        }
+
+        if (!datasource.equals("openaire"))
+            IndexUtils.feedIndex(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource,
+                    doi, Collections.EMPTY_LIST, subjects, Collections.EMPTY_LIST, publicationDate, publisher,
+                    language, category, false, project4Indexes, concepts, directClaimAPIUrl);
+
+        logger.info("Inserted document with id " + id + ", source " + source + " and given resultId " + resultId);
+        return resultId;
+    }
+
+    public void insertConceptRelation(String documentId, String documentSource, String concept, String userEmail, String doi) throws Exception {
+        logger.info("Request for concept relation between document with id " + documentId + " with source " + documentSource + " and concept " + concept + "with doi " + doi);
+
+        try {
+            Connection con = DataSourceUtils.getConnection(datasource);
+            PreparedStatement stmt;
+            String dmf;
+
+            stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+            dmf = ActionUtils.createDMF(documentId, documentSource, null, null, null, null, Collections.EMPTY_LIST, null, null, doi, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Arrays.asList(concept), null, null, null, null, true);
+
+            stmt.setString(1, userEmail);
+            stmt.setString(2, documentId);
+            stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+            stmt.setString(4, "updates2actions");
+            stmt.setString(5, dmf);
+            stmt.setString(6, "userclaim_dmf");
+            stmt.setString(7, ActionUtils.getProvenance(documentSource));
+            stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+            stmt.executeUpdate();
+            stmt.close();
+        } catch (Exception e) {
+            logger.error("Error adding concept", e);
+            throw e;
+        }
+
+        logger.info("Inserted concept relation between document with id " + documentId + " with source " + documentSource + " and concept " + concept);
+    }
+
+    public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws Exception {
+        logger.info("Request for project relation between document with id " + docId + " with source " + documentSource + " and project " + project);
+
+        try {
+            Connection con = DataSourceUtils.getConnection(datasource);
+            PreparedStatement stmt;
+            String xml = ActionUtils.createResultProjectRelation("openaire".equals(documentSource) ? null : documentSource, docId, project.getType(), project.getProjectId());
+
+            stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+            stmt.setString(1, userEmail);
+            stmt.setString(2, docId);
+            stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+            stmt.setString(4, "rels2actions");
+            stmt.setString(5, xml);
+            stmt.setString(6, "userclaim_result_project");
+            stmt.setString(7, ActionUtils.getProvenance(documentSource));
+            stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+            stmt.executeUpdate();
+            stmt.close();
+        } catch (Exception e) {
+            logger.error("Error adding project", e);
+            throw e;
+        }
+
+        logger.info("Inserted project relation between document with id " + docId + " with source " + documentSource + " and project " + project);
+    }
+
+    public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws Exception {
+        logger.info("Request for result relation between source document with id " + sourceResultId + ", type " + sourceResultType + "and source " + sourceResultSource + " and " +
+                "target document with id " + targetResultId + ", type " + targetResultType);
+        try {
+            Connection con = DataSourceUtils.getConnection(datasource);
+            PreparedStatement stmt;
+            String xml = ActionUtils.createResultResultRelation(sourceResultId, sourceResultType, targetResultId, targetResultType);
+
+            stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+            stmt.setString(1, userEmail);
+            stmt.setString(2, sourceResultId);
+            stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+            stmt.setString(4, "rels2actions");
+            stmt.setString(5, xml);
+            stmt.setString(6, "userclaim_result_result");
+            stmt.setString(7, ActionUtils.getProvenance(sourceResultSource));
+            stmt.setString(8, ActionUtils.getPrefix(sourceResultSource));
+
+            stmt.executeUpdate();
+            stmt.close();
+        } catch (Exception e) {
+            logger.error("Error adding result relation", e);
+            throw e;
+        }
+
+        logger.info("Inserted result relation between source document with id " + sourceResultId + ", type " + sourceResultType + "and source " + sourceResultSource + " and " +
+                "target document with id " + targetResultId + ", type " + targetResultType);
+    }
+
+    public DataSource getDatasource() {
+        return datasource;
+    }
+
+    public void setDatasource(DataSource datasource) {
+        this.datasource = datasource;
+    }
+
+    public ServiceLocator<ISLookUpService> getLookupServiceLocator() {
+        return lookupServiceLocator;
+    }
+
+    public void setLookupServiceLocator(
+            ServiceLocator<ISLookUpService> lookupServiceLocator) {
+        this.lookupServiceLocator = lookupServiceLocator;
+    }
+
+    public List<String> getContexts() throws ISLookUpException, ISLookUpServiceException {
+        return lookupServiceLocator.getService().quickSearchProfile("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') return $x");
+    }
+
+    public String getDirectClaimAPIUrl() {
+        return directClaimAPIUrl;
+    }
+
+    public void setDirectClaimAPIUrl(String directClaimAPIUrl) {
+        this.directClaimAPIUrl = directClaimAPIUrl;
+    }
+}
\ No newline at end of file
Index: modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java
===================================================================
--- modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(revision 47510)
@@ -0,0 +1,286 @@
+package eu.dnetlib.openaire.action;
+
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.Project;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+import java.io.StringWriter;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class ActionUtils {
+
+	private static Logger logger = Logger.getLogger(ActionUtils.class);
+
+	public static String createResultProjectRelation(String source,
+			String resultId, String projectType, String projectId)
+			throws Exception {
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+		ve.init();
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+		VelocityContext vc = new VelocityContext();
+
+		List<Relation> rels = new ArrayList<Relation>();
+
+		rels.add(createRelation(source, resultId, projectType, projectId));
+
+		vc.put("relations", rels);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+
+		return sw.toString();
+	}
+
+    public static String createResultResultRelation(String sourceResultId, String sourceResultType, String targetResultId, String targetResultType) {
+        VelocityEngine ve = new VelocityEngine();
+        ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+        ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+        ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+        ve.init();
+
+        Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+        VelocityContext vc = new VelocityContext();
+
+        List<Relation> rels = new ArrayList<Relation>();
+
+        rels.add(new Relation("resultResult_" + sourceResultType + targetResultType + "_isRelatedTo", "50|" + sourceResultId, "50|" + targetResultId));
+
+        vc.put("relations", rels);
+
+        StringWriter sw = new StringWriter();
+        t.merge(vc, sw);
+
+        return sw.toString();
+    }
+
+	// input id: 1306.3402
+	// oai:arXiv.org:1306.3402
+	// MD5("od________18::oai:arXiv.org:1306.3402")
+
+    /**
+     * Creates a new relation action.
+     * @param source the result source. If not null, the resultId is transformed to openaire id. If null, the result is
+     *               considered to be already an openaire result and is used verbatim
+     * @param resultId the result id
+     * @param projectType the project type. If not null, the projectId is transformed to openaire id. If null, the projectId is
+     *               considered to be already in openaire format and is used verbatim
+     * @param projectId the project id
+     *
+     * @return a relation
+     */
+	private static Relation createRelation(String source, String resultId,
+			String projectType, String projectId) {
+		String resultPrefix;
+		String projectPrefix = null;
+
+        if (!isValidOpenaireId(resultId) && source != null) {
+            if (source.equals("arxiv")) {
+                resultId = "oai:arXiv.org:" + resultId;
+            } else if (source.equals("pubmed")) {
+                resultId = "oai:europepmc.org:" + resultId;
+            }
+
+            resultPrefix = getPrefix(source);
+            resultId = getIdentifier(resultPrefix, resultId);
+        }
+
+	resultId = "50|" + resultId;
+
+        if (projectType != null) {
+            if (projectType.equals("ec")) {
+                projectPrefix = "corda_______";
+            } else if (projectType.equals("wt")) {
+                projectPrefix = "wt__________::WT";
+            }
+
+            projectId = projectPrefix + "::" + projectId;
+        }
+
+	projectId = "40|" + projectId;
+
+		return new Relation("resultProject", resultId, projectId);
+	}
+
+	private static boolean isValidOpenaireId(String resultId) {
+
+		return Pattern.matches("\\w{12}::[a-f0-9]{32}", resultId);
+	}
+
+	public static String getPrefix(String source) {
+        logger.debug("SOURCE " + source);
+		if (source == null || source.equals("openaire")) {
+			return "openaire____";
+		} else if (source.equals("doi")) {
+			return "crossref____";
+		} if (source.equals("orcid")) {
+            		return "orcid_______";
+		} else if (source.equals("datacite")) {
+			return "datacite____";
+		} else if (source.equals("driver")) {
+			return "driver______";
+		} else
+			return null;
+	}
+
+    public static String getProvenance(String source) {
+        if (source == null || source.equals("openaire"))
+            return "user:claim:search";
+        else if (source.equals("doi") || source.equals("orcid"))
+            return "user:claim:pid";
+		else if (source.equals("datacite"))
+			return "user:claim:datacite";
+        else
+            return null;
+    }
+
+	public static String createDMF(String id, String source, String title,
+			String description, String access_mode, String embargoEndDate,
+			List<Author> authors, String url, String dcSource, String doi,
+			List<Project> projects, List<String> subjects, List<String> concepts, String publicationDate,
+            String publisher, String language, String category, boolean isConcept) throws Exception {
+
+        logger.info("create with doi " + doi);
+
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+		ve.init();
+		
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/dmf.vm");
+		VelocityContext vc = new VelocityContext();
+
+		String hostedby = null;
+		String hostedbyName = null;
+		String collectedFrom = null;
+		String collectedFromName = null;
+        String recordIdentifier = id;
+		String prefix = getPrefix(source);
+
+
+        //if the orcid id exists
+        String orcid = null;
+
+		if (source.equals("doi") && !isConcept) {
+			hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+			hostedbyName = "Unknown Repository";
+			collectedFrom = "openaire____::crossref";
+			collectedFromName = "Crossref";
+			doi = id;
+
+        } else if (source.equals("datacite")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::datacite";
+            collectedFromName = "Datacite";
+
+        } else if (source.equals("orcid")) {
+            orcid = id;
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::orcid";
+            collectedFromName = "ORCID";
+
+        } else if (source.equals("driver")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::driver";
+            collectedFromName = "Digital Repository Infrastructure Vision for European Research";
+        }
+
+        logger.info("create with doi " + doi);
+
+        if (doi != null) {
+            vc.put("doi", doi);
+        } else if (orcid != null){
+          //if there is no doi but we have an orcid, id we store it
+          vc.put("orcid", orcid);
+        }
+
+        // openaire ids should not be touched!
+        if (!source.equals("openaire"))
+		    id = getIdentifier(prefix, id);
+
+		vc.put("objIdentifier", id);
+		vc.put("recordIdentifier", recordIdentifier);
+		vc.put("dateOfCollection", DateUtils.calculate_ISO8601(System.currentTimeMillis()));
+		vc.put("hostedby", hostedby);
+		vc.put("collectedFrom", collectedFrom);
+		vc.put("hostedbyName", hostedbyName);
+		vc.put("collectedFromName", collectedFromName);
+        vc.put("embargoEndDate", embargoEndDate);
+		vc.put("title", title);
+		vc.put("description", description);
+		vc.put("accessMode", access_mode);
+		vc.put("dcSource", dcSource);
+		vc.put("url", url);
+		vc.put("publisher", publisher);
+		vc.put("language", language);
+		vc.put("objCategory", category);
+
+		vc.put("datasourceprefix", prefix);
+
+		List<String> creators = new ArrayList<String>();
+		for (Author author : authors) {
+            String name = author.getLastName();
+
+
+            if (author.getFirstName() != null && !author.getFirstName().trim().isEmpty())
+                name += ", " + author.getFirstName();
+
+            creators.add(name);
+		}
+
+		vc.put("creators", creators);
+		vc.put("projects", projects);
+		vc.put("subjects", subjects);
+        vc.put("concepts", concepts);
+		
+		if (publicationDate != null && !publicationDate.equals(""))
+			vc.put("publicationDate", publicationDate + "-01-01T00:00:00Z");
+		
+		vc.put("StringEscapeUtils", StringEscapeUtils.class);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+		
+		return sw.toString();
+	}
+
+	// private static String getIdentifier(String prefix, String id) {
+	// return prefix + "::" +
+	// com.google.common.hash.Hashing.md5().hashString(id).toString();
+	// }
+
+	public static String getIdentifier(String prefix, String id) {
+		try {
+            logger.debug("PREFIX " + prefix);
+			MessageDigest md = MessageDigest.getInstance("MD5");
+
+			md.update(id.getBytes("UTF-8"));
+
+			return prefix + "::" + new String(Hex.encodeHex(md.digest()));
+		} catch (Exception e) {
+			logger.error("Error creating id", e);
+			return null;
+		}
+	}
+}
Index: modules/uoa-claims-api/branches/import/deploy.info
===================================================================
--- modules/uoa-claims-api/branches/import/deploy.info	(nonexistent)
+++ modules/uoa-claims-api/branches/import/deploy.info	(revision 47510)
@@ -0,0 +1,10 @@
+{
+  "type_source": "SVN", 
+  "goal": "package -U -T 4C source:jar", 
+  "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk", 
+  "deploy_repository": "dnet4-snapshots", 
+  "version": "4", 
+  "mail": "antleb@di.uoa.gr, kiatrop@di.uoa.gr", 
+  "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", 
+  "name": "uoa-openaire-connector"
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(revision 47510)
@@ -0,0 +1,192 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertServiceException;
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.List;
+
+public class OpenAIREConnectorImpl implements OpenAIREConnector.Iface {
+	private static final Logger logger = Logger.getLogger(OpenAIREConnectorImpl.class);
+
+	private ClaimConnector claimConnector;
+	private AlertConnector alertConnector;
+
+	public void setClaimConnector(final ClaimConnector claimConnector) {
+		this.claimConnector = claimConnector;
+	}
+
+	public void setAlertConnector(final AlertConnector alertConnector) {
+		this.alertConnector = alertConnector;
+	}
+
+	@Override
+	public List<Claim> getClaimedPublications(final String user) throws TException {
+		try {
+			return claimConnector.getClaimedPublications(user);
+		} catch (final Exception e) {
+			logger.error("Error retrieving claimed publications (user: " + user + ")", e);
+			throw new TException("Error retrieving claimed publications (user: " + user + ")", e);
+		}
+	}
+
+    @Override
+    public List<Claim> getAllClaimedPublications(long from, long to) throws TException {
+        try {
+            return claimConnector.getClaimedPublications(new Date(from), new Date(to));
+        } catch (Exception e) {
+            logger.error("Error retrieving claimed publications", e);
+
+            throw new TException("Error retrieving claimed publications", e);
+        }
+    }
+
+    @Override
+    public String insertDocument(String originalId, String source, String title, String description, String access_mode,
+                                 String embargoEndDate, List<Author> authors, String url, String dcSource,
+                                 String userEmail, List<String> subjects, String publicationDate, String publisher,
+                                 String language, String category, String doi, List<Project4Index> project4Indexes,
+                                 List<String> concepts) throws org.apache.thrift.TException {
+        try {
+            logger.info("concepts " + concepts);
+            return claimConnector.insertDocument(originalId, source, title, description, access_mode, embargoEndDate,
+                    authors, url, dcSource, userEmail, subjects, publicationDate, publisher, language, category, doi,
+                    project4Indexes, concepts);
+        } catch (Exception e) {
+            logger.error("Error adding document", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertConcept(String docId, String documentSource, String concept, String userEmail, String doi) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertConceptRelation(docId, documentSource, concept, userEmail, doi);
+        } catch (Exception e) {
+            logger.error("Error adding concept relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertProjectRelation(docId, documentSource, project, userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding project relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws TException {
+        try {
+            claimConnector.insertResultRelation(sourceResultId, sourceResultType, sourceResultSource, targetResultId, targetResultType,userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding result relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+	public List<AlertSubscription> getSubscriptions(final String alertMode, final String subscriber, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getSubscriptions(alertMode, subscriber, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+	@Override
+	public void addSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.addSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		}
+	}
+
+	@Override
+	public void removeSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.removeSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		}
+	}
+
+	@Override
+	public int countAlertResults(final String notificationService, final String queryId, final long date, final String resultId) throws TException {
+		try {
+			return alertConnector.countAlertResults(notificationService, queryId, date, resultId);
+		} catch (final AlertServiceException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		}
+	}
+
+	@Override
+	public ResultPage getAlertResults(final String notificationService, final String queryId, final String resultId, final long fromDate, final long toDate, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getAlertResults(notificationService, queryId, resultId, fromDate, toDate, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+    @Override
+    public void deleteClaim(String userEmail, String resultId) throws TException {
+        try {
+            claimConnector.deleteClaim(userEmail, resultId);
+        } catch (Exception e) {
+            logger.error("Error deleting claim", e);
+
+            throw new TException(e);
+        }
+    }
+
+	@Override
+	public List<String> getContexts() throws TException {
+		try {
+			return claimConnector.getContexts();
+		} catch (Exception e) {
+			logger.error("Error getting contexts from IS.", e);
+			
+			throw new TException(e);
+		}
+		
+	}
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/ConceptImport.java
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/ConceptImport.java	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/ConceptImport.java	(revision 47510)
@@ -0,0 +1,58 @@
+package eu.dnetlib.openaire.utils;
+
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+import org.apache.log4j.BasicConfigurator;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.*;
+
+public class ConceptImport {
+
+	public static void main(String[] args) throws Exception {
+		
+		BasicConfigurator.configure();
+		int count = 0;
+		
+		if (args.length != 3) {
+			System.err.println("Usage: ConceptImport <context (egi)> <datatasource (arxiv|pubmed)> <file> ");
+			System.exit(1);
+		}
+
+        String setName = "sysimport_mining_repository_" + args[0];
+		String datasource = args[1];
+		String filename = args[2];
+
+		
+		BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filename))));
+        String line = null;
+        OpenAIREConnector.Client client = new ThriftClient().getConnector();
+
+        Map<String, List<String>> map = new HashMap<String, List<String>>();
+        
+        while ((line = br.readLine()) != null) {
+            String[] values = line.split("\t");
+            String resultId = values[0];
+            String conceptId = values[1];
+
+            List<String> concepts = map.get(resultId);
+
+            if (concepts == null) {
+                concepts = new ArrayList<String>();
+                map.put(resultId, concepts);
+            }
+
+            concepts.add(conceptId);
+        }
+
+        for (String resultId:map.keySet()) {
+            List<String> concepts = map.get(resultId);
+
+            client.insertInferredDocument(resultId, datasource, null, null, null, null, Collections.EMPTY_LIST, null, null, Collections.EMPTY_LIST, Collections.EMPTY_LIST, concepts, null, null, null, null, null, setName);
+        }
+        
+        br.close();
+	}
+}
Index: modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
--- modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(revision 47510)

Property changes on: modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/uoa-claims-api/trunk/deploy.info
===================================================================
--- modules/uoa-claims-api/trunk/deploy.info	(nonexistent)
+++ modules/uoa-claims-api/trunk/deploy.info	(revision 47510)
@@ -0,0 +1,10 @@
+{
+  "type_source": "SVN", 
+  "goal": "package -U -T 4C source:jar", 
+  "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk", 
+  "deploy_repository": "dnet4-snapshots", 
+  "version": "4", 
+  "mail": "antleb@di.uoa.gr, kiatrop@di.uoa.gr", 
+  "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", 
+  "name": "uoa-openaire-connector"
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(revision 47510)
@@ -0,0 +1,84 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertService;
+import eu.dnetlib.api.functionality.AlertServiceException;
+import gr.uoa.di.driver.util.ServiceLocator;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+public class AlertConnector {
+	private ServiceLocator<AlertService> alertServiceLocator;
+
+	public void setAlertServiceLocator(
+			final ServiceLocator<AlertService> alertServiceLocator) {
+		this.alertServiceLocator = alertServiceLocator;
+	}
+
+	public List<AlertSubscription> getSubscriptions(final String alertMode,
+			final String subscriber, final int limit, final int offset)
+			throws AlertServiceException {
+		final List<AlertSubscription> subscriptions = new ArrayList<AlertSubscription>();
+		for (eu.dnetlib.domain.functionality.AlertSubscription subscription : alertServiceLocator
+				.getService().getSubscriptions(alertMode, subscriber, limit,
+						offset))
+			subscriptions.add(new AlertSubscription(subscription
+					.getTemplateId(), subscription.getNotificationService()
+					.toString(), subscription.getQueryId(), subscription
+					.getResultId(), subscription.getAlertMode(), subscription
+					.getSubscriber().toString()));
+		return subscriptions;
+	}
+
+	public void addSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().addSubscription(
+				new eu.dnetlib.domain.functionality.AlertSubscription(
+						subscription.getTemplateId(), new URL(subscription
+								.getNotificationService()), subscription
+								.getQueryId(), subscription.getResultId(),
+						subscription.getAlertMode(), new URI(subscription
+								.getSubscriber()), true));
+	}
+
+	public void removeSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().removeSubscription(
+				subscription.getTemplateId(),
+				new URL(subscription.getNotificationService()),
+				subscription.getQueryId(), subscription.getResultId(),
+				subscription.getAlertMode(),
+				new URI(subscription.getSubscriber()));
+	}
+
+	public int countAlertResults(final String notificationService,
+			final String queryId, final long date, final String resultId)
+			throws AlertServiceException, MalformedURLException {
+		return alertServiceLocator.getService()
+				.countAlertResults(new URL(notificationService), queryId,
+						new Date(date), resultId);
+	}
+
+	public ResultPage getAlertResults(final String notificationService,
+			final String queryId, final String resultId, final long fromDate,
+			final long toDate, final int limit, final int offset)
+			throws AlertServiceException, MalformedURLException {
+		final eu.dnetlib.domain.functionality.ResultPage resultPage = alertServiceLocator
+				.getService().getAlertResults(new URL(notificationService),
+						queryId, resultId, new Date(fromDate),
+						new Date(toDate), limit, offset);
+		final List<List<String>> rows = new ArrayList<List<String>>();
+		for (String[] row : resultPage.getRows())
+			rows.add(Arrays.asList(row));
+		return new ResultPage(resultPage.getLimit(), resultPage.getOffset(),
+				Arrays.asList(resultPage.getColumns()), rows);
+	}
+}
Index: modules/uoa-claims-api/trunk/src/main/thrift/OpenAIREConnector.thrift
===================================================================
--- modules/uoa-claims-api/trunk/src/main/thrift/OpenAIREConnector.thrift	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/thrift/OpenAIREConnector.thrift	(revision 47510)
@@ -0,0 +1,132 @@
+namespace java eu.dnetlib.openaire.thrift
+
+struct Author {
+	1: string id,
+	2: string lastName,
+	3: string firstName
+}
+
+// alerts
+struct AlertSubscription {
+	1: string templateId,
+	2: string notificationService,
+	3: string queryId,
+	4: string resultId,
+	5: string alertMode,
+	6: string subscriber
+}
+
+struct ResultPage {
+	1: i32 limit,
+	2: i32 offset,
+	3: list<string> columns,
+	4: list<list<string>> rows
+}
+
+struct Claim {
+    1: string userEmail,
+	2: string resultid,
+	3: i64 date,
+	4: string type,
+	5: string xml,
+	6: string id
+}
+
+struct Project {
+    1: string type,
+    2: string projectId
+}
+
+struct Project4Index {
+    1: string projectid,
+    2: string funder,
+    3: string fundingStreamLevel0,
+    4: string fundingStreamLevel1,
+    5: string fundingStreamLevel2,
+    6: string name,
+    7: string code,
+    8: string acronym,
+    9: string type
+}
+
+// connector
+service OpenAIREConnector {
+	// claim
+	list<Claim> getClaimedPublications(1: string userEmail),
+
+	// from: date in milisecs
+	// to: ditto
+	list<Claim> getAllClaimedPublications(1: i64 from, 2: i64 to),
+	
+	string insertDocument (
+			1: string originalId,
+			2: string source, 
+			3: string title, 
+			4: string description, 
+			5: string access_mode, 
+			6: string embargoEndDate, 
+			7: list<Author> authors, 
+			8: string url,
+			9: string dcSource,
+			10: string userEmail,
+			11: list<string> subjects,
+			12: string publicationDate,
+			13: string publisher,
+			14: string language,
+			15: string category,
+			16: string doi,
+			17: list<Project4Index> projects,
+			18: list<string> concepts),
+
+    void insertConcept (
+        1: string docId,
+        2: string documentSource,
+        3: string concept,
+        4: string userEmail,
+        5: string doi),
+
+    void insertProjectRelation (
+        1: string docId,
+        2: string documentSource,
+        3: Project project,
+        4: string userEmail),
+
+    void insertResultRelation (
+        1: string sourceResultId,
+        2: string sourceResultType,
+        3: string sourceResultSource,
+        4: string targetResultId,
+        5: string targetResultType,
+        6: string userEmail
+    ),
+
+	void deleteClaim(1: string userEmail, 2:string resultId),
+
+	// alerts
+	list<AlertSubscription> getSubscriptions(
+			1: string alertMode, 
+			2: string subscriber, 
+			3: i32 limit, 
+			4: i32 offset),
+			
+	void addSubscription(1: AlertSubscription subscription),
+	
+	void removeSubscription(1: AlertSubscription subscription),
+	
+	i32 countAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: i64 date, 
+			5: string resultId),
+			
+	ResultPage getAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: string resultId, 
+			4: i64 fromDate, 
+			5: i64 toDate, 
+			6: i32 limit, 
+			7: i32 offset),
+	
+	list<string> getContexts(),
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(revision 47510)
@@ -0,0 +1,43 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TTransportException;
+
+public class ThriftServer {
+	private OpenAIREConnector.Iface openAireConnector;
+	private int port;
+	private int timeout;
+	private Thread thread;
+
+	public void setOpenAireConnector(final OpenAIREConnector.Iface openAireConnector) {
+		this.openAireConnector = openAireConnector;
+	}
+	
+	public void setPort(final int port) {
+		this.port = port;
+	}
+	
+	public void setTimeout(final int timeout) {
+		this.timeout = timeout;
+	}
+	
+	public void start() {
+		thread = new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					new TThreadPoolServer(new TThreadPoolServer.Args(new TServerSocket(port, timeout)).processor(new OpenAIREConnector.Processor<OpenAIREConnector.Iface>(openAireConnector))).serve();
+				} catch (final TTransportException e) {
+					Logger.getLogger(ThriftServer.class).error("Error starting thrift server", e);
+				}
+			}
+		});
+		thread.start();
+	}
+	
+	public void stop() {
+		thread.interrupt();
+	}
+}
Index: modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java
===================================================================
--- modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(revision 47510)
@@ -0,0 +1,43 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TTransportException;
+
+public class ThriftServer {
+	private OpenAIREConnector.Iface openAireConnector;
+	private int port;
+	private int timeout;
+	private Thread thread;
+
+	public void setOpenAireConnector(final OpenAIREConnector.Iface openAireConnector) {
+		this.openAireConnector = openAireConnector;
+	}
+	
+	public void setPort(final int port) {
+		this.port = port;
+	}
+	
+	public void setTimeout(final int timeout) {
+		this.timeout = timeout;
+	}
+	
+	public void start() {
+		thread = new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					new TThreadPoolServer(new TThreadPoolServer.Args(new TServerSocket(port, timeout)).processor(new OpenAIREConnector.Processor<OpenAIREConnector.Iface>(openAireConnector))).serve();
+				} catch (final TTransportException e) {
+					Logger.getLogger(ThriftServer.class).error("Error starting thrift server", e);
+				}
+			}
+		});
+		thread.start();
+	}
+	
+	public void stop() {
+		thread.interrupt();
+	}
+}
Index: modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/action/IndexUtils.java
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/action/IndexUtils.java	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/action/IndexUtils.java	(revision 47510)
@@ -0,0 +1,341 @@
+package eu.dnetlib.openaire.action;
+
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.Project;
+import eu.dnetlib.openaire.thrift.Project4Index;
+import org.apache.log4j.Logger;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import sun.net.www.protocol.http.HttpURLConnection;
+
+import java.io.*;
+import java.net.URL;
+import java.util.List;
+
+/**
+ * Created by kiatrop on 26/1/2016.
+ */
+public class IndexUtils {
+
+    private static final Logger logger = Logger.getLogger(IndexUtils.class);
+
+    public static JSONObject createJSON(String id, String source, String title, String description, String access_mode,
+                                        String embargoEndDate, List<Author> authors, String url, String dcSource,
+                                        String doi, List<Project> projects, List<String> subjects, List<String> concepts,
+                                        String publicationDate, String publisher, String language, String category,
+                                        boolean isConcept, List<Project4Index> project4Indexes, List<String> concepts4index) throws Exception {
+
+        if (source.equals("openaire"))
+            throw new IllegalArgumentException("cannot create JSON for openaire");
+
+        //logger.info("create JSON for doi " + doi);
+        //logger.info("projects " + project4Indexes);
+
+        //if the orcid id exists
+        String orcid = null;
+        String hostedby = null;
+        String hostedbyName = null;
+        String collectedFrom = null;
+        String collectedFromName = null;
+        String recordIdentifier = id;
+
+        if (source.equals("doi") && !isConcept) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::crossref";
+            collectedFromName = "Crossref";
+            doi = id;
+
+        } else if (source.equals("datacite")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::datacite";
+            collectedFromName = "Datacite";
+
+        } else if (source.equals("orcid")) {
+            orcid = id;
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::orcid";
+            collectedFromName = "ORCID";
+
+        } else if (source.equals("driver")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::driver";
+            collectedFromName = "Digital Repository Infrastructure Vision for European Research";
+        }
+
+        JSONObject claimJSON = new JSONObject();
+        String prefix = ActionUtils.getPrefix(source);
+        claimJSON.put("originalId", id);
+        claimJSON.put("title", title);
+
+        JSONArray authorsJSONArray = new JSONArray();
+        for (Author author: authors) {
+            authorsJSONArray.add(author.getFirstName() + " " + author.getLastName());
+        }
+        claimJSON.put("authors", authorsJSONArray);
+
+        claimJSON.put("publisher", publisher);
+        claimJSON.put("description", description);
+        claimJSON.put("language", language);
+
+        JSONArray pidsJSONArray = new JSONArray();
+        JSONObject pidJSON = null;
+        if (doi != null) {
+            pidJSON = new JSONObject();
+            pidJSON.put("type", "doi");
+            pidJSON.put("value", doi);
+            pidsJSONArray.add(pidJSON);
+        }
+        if (orcid != null) {
+            pidJSON = new JSONObject();
+            pidJSON.put("type", "orcidworkid");
+            pidJSON.put("value", orcid);
+            pidsJSONArray.add(pidJSON);
+        }
+        claimJSON.put("pids", pidsJSONArray);
+
+        claimJSON.put("licenseCode", access_mode);
+        if(source.equals("crossref")) {
+            claimJSON.put("resourceType", "0001");
+        } else if (source.equals("datacite")) {
+            claimJSON.put("resourceType", "0021");
+        } else {
+            claimJSON.put("resourceType", "0001");
+        }
+
+        claimJSON.put("url", url);
+        claimJSON.put("collectedFromId", collectedFrom);
+        claimJSON.put("hostedById", hostedby);
+
+        JSONArray linksToProjectsJSONArray = new JSONArray();
+        for (Project4Index project:project4Indexes) {
+            linksToProjectsJSONArray.add(createProjectPath(project)) ;
+        }
+        claimJSON.put("linksToProjects",linksToProjectsJSONArray);
+
+        JSONArray contextsJSONArray = new JSONArray();
+        if(!concepts4index.isEmpty()) {
+            for (String context: concepts4index) {
+                contextsJSONArray.add(context); //TODO check
+            }
+        }
+        claimJSON.put("contexts", contextsJSONArray);
+
+        return claimJSON;
+    }
+
+    public static void feedIndex(String id, String source, String title,
+                                 String description, String access_mode, String embargoEndDate,
+                                 List<Author> authors, String url, String dcSource, String doi,
+                                 List<Project> projects, List<String> subjects, List<String> concepts,
+                                 String publicationDate, String publisher, String language, String category,
+                                 boolean isConcept, List<Project4Index> project4Indexes, List<String> concepts4index,
+                                 String directClaimAPIUrl) throws Exception {
+
+        logger.info("number of projects " + project4Indexes);
+        if (project4Indexes!= null) {
+            logger.info("number of projects " + project4Indexes.size());
+        }
+
+        URL obj = new URL(directClaimAPIUrl);
+        HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+        JSONObject claimJson = createJSON(id, source, title, description, access_mode, embargoEndDate,
+                                    authors, url, dcSource, doi, projects, subjects, concepts, publicationDate,
+                                    publisher, language, category, isConcept, project4Indexes, concepts4index);
+        //add request header
+        con.setRequestMethod("POST");
+        //con.setRequestProperty("User-Agent", USER_AGENT);
+        con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
+        con.setRequestProperty("Content-Type", "application/json");
+
+        logger.info("Feeding index with " + claimJson.toJSONString());
+        String urlParameters = claimJson.toJSONString();
+
+        // Send post request
+        con.setDoOutput(true);
+        DataOutputStream wr = new DataOutputStream(con.getOutputStream());
+        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(wr, "UTF-8"));
+        writer.write(urlParameters);
+        writer.close();
+        wr.close();
+
+        int responseCode = con.getResponseCode();
+        System.out.println("\nSending 'POST' request to URL : " + url);
+        System.out.println("Post parameters : " + urlParameters);
+        System.out.println("Response Code : " + responseCode);
+
+        BufferedReader in = new BufferedReader(
+                new InputStreamReader(con.getInputStream()));
+        String inputLine;
+        StringBuffer response = new StringBuffer();
+
+        while ((inputLine = in.readLine()) != null) {
+            response.append(inputLine);
+        }
+        in.close();
+
+        //print result
+        System.out.println(response.toString());
+    }
+
+    private static String createProjectPath(Project4Index project) {
+        if (project.getFunder().equals("EC")) {
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/EC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/EU//"+project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/EC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/EU//"+project.getName();
+        }
+
+        if (project.getFunder().equals("WT")) {
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/WT//"+project.getCode()+"//" + project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/WT//"+project.getCode()+project.getName();
+        }
+
+        if (project.getFunder().equals("ARC")) {
+            logger.debug("name: '" + project.getName()+"'");
+            logger.debug("name: '" + project.getAcronym()+"'");
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/ARC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/AU//"+project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/ARC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/AU//"+project.getName();
+        }
+
+        if (project.getFunder().equals("NHMRC")) {
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/NHMRC/"+project.getFundingStreamLevel0()+"/"
+                        +project.getCode()+"/AU//"+project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/NHMRC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/AU//"+project.getName();
+        }
+
+        if (project.getFunder().equals("FCT")) {
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/FCT/"+project.getFundingStreamLevel0()+"/"
+                        +project.getCode()+"/PT//"+project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/FCT/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/PT//"+project.getName();
+        }
+
+        return "";
+    }
+
+    public static void main(String[] args) throws IOException {
+
+        String url = "http://beta.services.openaire.eu:8280/is/mvc/api/publications/feedObject";
+        URL obj = new URL(url);
+        HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+        //add reuqest header
+        con.setRequestMethod("POST");
+        //con.setRequestProperty("User-Agent", USER_AGENT);
+        con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
+        con.setRequestProperty("Content-Type", "application/json");
+
+
+        /*String urlParameters = "{\n" +
+                "\"collectedFromId\": \"openaire____::crossref\",\n" +
+                "\"authors\": [\"George Papastefanatos\", \"Panos Vassiliadis\", \"Alkis Simitsis\", \"Yannis Vassiliou\"],\n" +
+                "\"title\": \"HECATAEUS: Regulating schema evolution\",\n" +
+                "\"hostedById\": \"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\",\n" +
+                "\"licenseCode\": \"OPEN\",\n" +
+                "\"pids\": [{\n" +
+                "\"value\": \"10.1109\\/icde.2010.5447778\",\n" +
+                "\"type\": \"doi\"\n" +
+                "}],\n" +
+                "\"description\": null,\n" +
+                "\"originalId\": \"crossref____::817ee94bc4a0515adadb1fdaa78927f6\",\n" +
+                "\"contexts\": [],\n" +
+                "\"language\": null,\n" +
+                "\"linksToProjects\": [\"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus\"],\n" +
+                "\"url\": \"http:\\/\\/dx.doi.org\\/10.1109\\/icde.2010.5447778\",\n" +
+                "\"resourceType\": \"0001\",\n" +
+                "\"publisher\": \"Institute of Electrical & Electronics Engineers (IEEE)\"\n" +
+                "}";
+
+        String urlParameters = "{\n" +
+                "\"collectedFromId\": \"openaire____::crossref\",\n" +
+                "\"authors\": [\"George Papastefanatos\", \"Panos Vassiliadis\", \"Alkis Simitsis\", \"Yannis Vassiliou\"],\n" +
+                " \"title\": \"â\\\\ dark bottomless Abyss, that lies under our feet, had yawned openâ\\\\\",\n" +
+                "\"hostedById\": \"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\",\n" +
+                "\"licenseCode\": \"CLOSED\",\n" +
+                "\"pids\": [{\n" +
+                "\"value\": \"10.1007\\/s13740_012_0006_9\",\n" +
+                "\"type\": \"doi\"\n" +
+                "}],\n" +
+                "\"description\": null,\n" +
+                "\"originalId\": \"crossref____::test\",\n" +
+                "\"contexts\": [\"egi::classification::natsc::infos::dmin\"], " +
+                "\"language\": null, " +
+                "\"linksToProjects\": [\"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus\"], " +
+                "\"url\": \"http:\\/\\/dx.doi.org\\/10.1007\\/s13740_012_0006_9\", " +
+                "\"resourceType\": \"0001\", " +
+                "\"publisher\": \"Springer Science + Business Media\" " +
+                "}";
+*/
+
+        String urlParameters = "{ " +
+                "\"collectedFromId\": \"openaire____::crossref\", " +
+                "\"authors\": [\"Agapi Dalkou\"], " +
+                "\"title\": \"Η ανάπτυξη ερμηνευτικών στρατηγικών στο μάθημα της νεοελληνικής λογοτεχνίας στη δευτεροβάθμια εκπαίδευση σε περιβάλλον συνεργατικής μάθησης\", " +
+                "\"hostedById\": \"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\", " +
+                "\"licenseCode\": \"CLOSED\", " +
+                "\"pids\": [{ " +
+                "\"value\": \"10.12681\\/eadd\\/29202\", " +
+                "\"type\": \"doi\" " +
+                "}], " +
+                "\"description\": null, " +
+                "\"originalId\": \"crossref____::cf7d85a13ac43f92431b102723d13d5a\", " +
+                "\"contexts\": [\"egi\", \"egi::country::gr\"], " +
+                "\"language\": null, " +
+                "\"linksToProjects\": [\"info:eu-repo\\/grantAgreement\\/EC\\/FP7\\/246686\\/EU\\/\\/OPENAIRE\", \"info:eu-repo\\/grantAgreement\\/EC\\/FP7\\/288611\\/EU\\/\\/ECODRIVER\"], " +
+                "\"url\": \"http:\\/\\/dx.doi.org\\/10.12681\\/eadd\\/29202\", " +
+                "\"resourceType\": \"0001\", " +
+                "\"publisher\": \"National Documentation Centre\"" +
+                "}";
+
+        // Send post request
+        con.setDoOutput(true);
+        /*DataOutputStream wr = new DataOutputStream(con.getOutputStream());
+        wr.writeBytes(urlParameters);
+        wr.flush();
+        wr.close();
+        */
+
+        DataOutputStream wr = new DataOutputStream(con.getOutputStream());
+        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(wr, "UTF-8"));
+        writer.write(urlParameters);
+        writer.close();
+        wr.close();
+
+
+        int responseCode = con.getResponseCode();
+        System.out.println(" Sending 'POST' request to URL : " + url);
+        System.out.println("Post parameters : " + urlParameters);
+        System.out.println("Response Code : " + responseCode);
+
+        BufferedReader in = new BufferedReader(
+                new InputStreamReader(con.getInputStream()));
+        String inputLine;
+        StringBuffer response = new StringBuffer();
+
+        while ((inputLine = in.readLine()) != null) {
+            response.append(inputLine);
+        }
+        in.close();
+
+        //print result
+        System.out.println(response.toString());
+    }
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/thrift/OpenAIREConnector.thrift
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/thrift/OpenAIREConnector.thrift	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/thrift/OpenAIREConnector.thrift	(revision 47510)
@@ -0,0 +1,132 @@
+namespace java eu.dnetlib.openaire.thrift
+
+struct Author {
+	1: string id,
+	2: string lastName,
+	3: string firstName
+}
+
+// alerts
+struct AlertSubscription {
+	1: string templateId,
+	2: string notificationService,
+	3: string queryId,
+	4: string resultId,
+	5: string alertMode,
+	6: string subscriber
+}
+
+struct ResultPage {
+	1: i32 limit,
+	2: i32 offset,
+	3: list<string> columns,
+	4: list<list<string>> rows
+}
+
+struct Claim {
+    1: string userEmail,
+	2: string resultid,
+	3: i64 date,
+	4: string type,
+	5: string xml,
+	6: string id
+}
+
+struct Project {
+    1: string type,
+    2: string projectId
+}
+
+struct Project4Index {
+    1: string projectid,
+    2: string funder,
+    3: string fundingStreamLevel0,
+    4: string fundingStreamLevel1,
+    5: string fundingStreamLevel2,
+    6: string name,
+    7: string code,
+    8: string acronym,
+    9: string type
+}
+
+// connector
+service OpenAIREConnector {
+	// claim
+	list<Claim> getClaimedPublications(1: string userEmail),
+
+	// from: date in milisecs
+	// to: ditto
+	list<Claim> getAllClaimedPublications(1: i64 from, 2: i64 to),
+	
+	string insertDocument (
+			1: string originalId,
+			2: string source, 
+			3: string title, 
+			4: string description, 
+			5: string access_mode, 
+			6: string embargoEndDate, 
+			7: list<Author> authors, 
+			8: string url,
+			9: string dcSource,
+			10: string userEmail,
+			11: list<string> subjects,
+			12: string publicationDate,
+			13: string publisher,
+			14: string language,
+			15: string category,
+			16: string doi,
+			17: list<Project4Index> projects,
+			18: list<string> concepts),
+
+    void insertConcept (
+        1: string docId,
+        2: string documentSource,
+        3: string concept,
+        4: string userEmail,
+        5: string doi),
+
+    void insertProjectRelation (
+        1: string docId,
+        2: string documentSource,
+        3: Project project,
+        4: string userEmail),
+
+    void insertResultRelation (
+        1: string sourceResultId,
+        2: string sourceResultType,
+        3: string sourceResultSource,
+        4: string targetResultId,
+        5: string targetResultType,
+        6: string userEmail
+    ),
+
+	void deleteClaim(1: string userEmail, 2:string resultId),
+
+	// alerts
+	list<AlertSubscription> getSubscriptions(
+			1: string alertMode, 
+			2: string subscriber, 
+			3: i32 limit, 
+			4: i32 offset),
+			
+	void addSubscription(1: AlertSubscription subscription),
+	
+	void removeSubscription(1: AlertSubscription subscription),
+	
+	i32 countAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: i64 date, 
+			5: string resultId),
+			
+	ResultPage getAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: string resultId, 
+			4: i64 fromDate, 
+			5: i64 toDate, 
+			6: i32 limit, 
+			7: i32 offset),
+	
+	list<string> getContexts(),
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(revision 47510)
@@ -0,0 +1,286 @@
+package eu.dnetlib.openaire.action;
+
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.Project;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+import java.io.StringWriter;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class ActionUtils {
+
+	private static Logger logger = Logger.getLogger(ActionUtils.class);
+
+	public static String createResultProjectRelation(String source,
+			String resultId, String projectType, String projectId)
+			throws Exception {
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+		ve.init();
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+		VelocityContext vc = new VelocityContext();
+
+		List<Relation> rels = new ArrayList<Relation>();
+
+		rels.add(createRelation(source, resultId, projectType, projectId));
+
+		vc.put("relations", rels);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+
+		return sw.toString();
+	}
+
+    public static String createResultResultRelation(String sourceResultId, String sourceResultType, String targetResultId, String targetResultType) {
+        VelocityEngine ve = new VelocityEngine();
+        ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+        ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+        ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+        ve.init();
+
+        Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+        VelocityContext vc = new VelocityContext();
+
+        List<Relation> rels = new ArrayList<Relation>();
+
+        rels.add(new Relation("resultResult_" + sourceResultType + targetResultType + "_isRelatedTo", "50|" + sourceResultId, "50|" + targetResultId));
+
+        vc.put("relations", rels);
+
+        StringWriter sw = new StringWriter();
+        t.merge(vc, sw);
+
+        return sw.toString();
+    }
+
+	// input id: 1306.3402
+	// oai:arXiv.org:1306.3402
+	// MD5("od________18::oai:arXiv.org:1306.3402")
+
+    /**
+     * Creates a new relation action.
+     * @param source the result source. If not null, the resultId is transformed to openaire id. If null, the result is
+     *               considered to be already an openaire result and is used verbatim
+     * @param resultId the result id
+     * @param projectType the project type. If not null, the projectId is transformed to openaire id. If null, the projectId is
+     *               considered to be already in openaire format and is used verbatim
+     * @param projectId the project id
+     *
+     * @return a relation
+     */
+	private static Relation createRelation(String source, String resultId,
+			String projectType, String projectId) {
+		String resultPrefix;
+		String projectPrefix = null;
+
+        if (!isValidOpenaireId(resultId) && source != null) {
+            if (source.equals("arxiv")) {
+                resultId = "oai:arXiv.org:" + resultId;
+            } else if (source.equals("pubmed")) {
+                resultId = "oai:europepmc.org:" + resultId;
+            }
+
+            resultPrefix = getPrefix(source);
+            resultId = getIdentifier(resultPrefix, resultId);
+        }
+
+	resultId = "50|" + resultId;
+
+        if (projectType != null) {
+            if (projectType.equals("ec")) {
+                projectPrefix = "corda_______";
+            } else if (projectType.equals("wt")) {
+                projectPrefix = "wt__________::WT";
+            }
+
+            projectId = projectPrefix + "::" + projectId;
+        }
+
+	projectId = "40|" + projectId;
+
+		return new Relation("resultProject", resultId, projectId);
+	}
+
+	private static boolean isValidOpenaireId(String resultId) {
+
+		return Pattern.matches("\\w{12}::[a-f0-9]{32}", resultId);
+	}
+
+	public static String getPrefix(String source) {
+        logger.debug("SOURCE " + source);
+		if (source == null || source.equals("openaire")) {
+			return "openaire____";
+		} else if (source.equals("doi")) {
+			return "crossref____";
+		} if (source.equals("orcid")) {
+            		return "orcid_______";
+		} else if (source.equals("datacite")) {
+			return "datacite____";
+		} else if (source.equals("driver")) {
+			return "driver______";
+		} else
+			return null;
+	}
+
+    public static String getProvenance(String source) {
+        if (source == null || source.equals("openaire"))
+            return "user:claim:search";
+        else if (source.equals("doi") || source.equals("orcid"))
+            return "user:claim:pid";
+		else if (source.equals("datacite"))
+			return "user:claim:datacite";
+        else
+            return null;
+    }
+
+	public static String createDMF(String id, String source, String title,
+			String description, String access_mode, String embargoEndDate,
+			List<Author> authors, String url, String dcSource, String doi,
+			List<Project> projects, List<String> subjects, List<String> concepts, String publicationDate,
+            String publisher, String language, String category, boolean isConcept) throws Exception {
+
+        logger.info("create with doi " + doi);
+
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+		ve.init();
+		
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/dmf.vm");
+		VelocityContext vc = new VelocityContext();
+
+		String hostedby = null;
+		String hostedbyName = null;
+		String collectedFrom = null;
+		String collectedFromName = null;
+        String recordIdentifier = id;
+		String prefix = getPrefix(source);
+
+
+        //if the orcid id exists
+        String orcid = null;
+
+		if (source.equals("doi") && !isConcept) {
+			hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+			hostedbyName = "Unknown Repository";
+			collectedFrom = "openaire____::crossref";
+			collectedFromName = "Crossref";
+			doi = id;
+
+        } else if (source.equals("datacite")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::datacite";
+            collectedFromName = "Datacite";
+
+        } else if (source.equals("orcid")) {
+            orcid = id;
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::orcid";
+            collectedFromName = "ORCID";
+
+        } else if (source.equals("driver")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::driver";
+            collectedFromName = "Digital Repository Infrastructure Vision for European Research";
+        }
+
+        logger.info("create with doi " + doi);
+
+        if (doi != null) {
+            vc.put("doi", doi);
+        } else if (orcid != null){
+          //if there is no doi but we have an orcid, id we store it
+          vc.put("orcid", orcid);
+        }
+
+        // openaire ids should not be touched!
+        if (!source.equals("openaire"))
+		    id = getIdentifier(prefix, id);
+
+		vc.put("objIdentifier", id);
+		vc.put("recordIdentifier", recordIdentifier);
+		vc.put("dateOfCollection", DateUtils.calculate_ISO8601(System.currentTimeMillis()));
+		vc.put("hostedby", hostedby);
+		vc.put("collectedFrom", collectedFrom);
+		vc.put("hostedbyName", hostedbyName);
+		vc.put("collectedFromName", collectedFromName);
+        vc.put("embargoEndDate", embargoEndDate);
+		vc.put("title", title);
+		vc.put("description", description);
+		vc.put("accessMode", access_mode);
+		vc.put("dcSource", dcSource);
+		vc.put("url", url);
+		vc.put("publisher", publisher);
+		vc.put("language", language);
+		vc.put("objCategory", category);
+
+		vc.put("datasourceprefix", prefix);
+
+		List<String> creators = new ArrayList<String>();
+		for (Author author : authors) {
+            String name = author.getLastName();
+
+
+            if (author.getFirstName() != null && !author.getFirstName().trim().isEmpty())
+                name += ", " + author.getFirstName();
+
+            creators.add(name);
+		}
+
+		vc.put("creators", creators);
+		vc.put("projects", projects);
+		vc.put("subjects", subjects);
+        vc.put("concepts", concepts);
+		
+		if (publicationDate != null && !publicationDate.equals(""))
+			vc.put("publicationDate", publicationDate + "-01-01T00:00:00Z");
+		
+		vc.put("StringEscapeUtils", StringEscapeUtils.class);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+		
+		return sw.toString();
+	}
+
+	// private static String getIdentifier(String prefix, String id) {
+	// return prefix + "::" +
+	// com.google.common.hash.Hashing.md5().hashString(id).toString();
+	// }
+
+	public static String getIdentifier(String prefix, String id) {
+		try {
+            logger.debug("PREFIX " + prefix);
+			MessageDigest md = MessageDigest.getInstance("MD5");
+
+			md.update(id.getBytes("UTF-8"));
+
+			return prefix + "::" + new String(Hex.encodeHex(md.digest()));
+		} catch (Exception e) {
+			logger.error("Error creating id", e);
+			return null;
+		}
+	}
+}
Index: modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/action/Relation.java
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/action/Relation.java	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/java/eu/dnetlib/openaire/action/Relation.java	(revision 47510)
@@ -0,0 +1,39 @@
+package eu.dnetlib.openaire.action;
+
+public class Relation {
+	private String type;
+	private String sourceId;
+	private String targetId;
+
+	public Relation(String type, String sourceId, String targetId) {
+		super();
+		this.type = type;
+		this.sourceId = sourceId;
+		this.targetId = targetId;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getSourceId() {
+		return sourceId;
+	}
+
+	public void setSourceId(String sourceId) {
+		this.sourceId = sourceId;
+	}
+
+	public String getTargetId() {
+		return targetId;
+	}
+
+	public void setTargetId(String targetId) {
+		this.targetId = targetId;
+	}
+
+}
\ No newline at end of file
Index: modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties
===================================================================
--- modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(revision 47510)
@@ -0,0 +1,11 @@
+openaire.connector.thrift.port = 7911
+openaire.connector.thrift.timeout = 15000
+
+openaire.connector.unknownRepositoryName = Unknown Repository
+
+openaire.db.driverClassName = org.postgresql.Driver
+openaire.db.url = jdbc:postgresql://194.177.192.223:5432/dnet_claims
+openaire.db.username = dnet
+openaire.db.password = dnetPwd
+
+openaire.connector.api.directClaimAPIUrl = http://beta.services.openaire.eu:8280/is/mvc/api/publications/feedObject
\ No newline at end of file
Index: modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/utils/claims.sql
===================================================================
--- modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(revision 47510)
@@ -0,0 +1,45 @@
+select
+        r.resultid                                          as dri_objidentifier,
+        r.title                                             as dc_title,
+        array_agg(DISTINCT lpad('0'||aut.rank,5,'0')||'§§§'||ltrim(replace(per.surname||', '||per.name,'UNKNOWN, ',''), ', ')) as dc_creator,
+      r.description                                       as dc_description,
+        r.publisher                                         as dc_publisher,
+        r.keywords                                          as dc_subject,
+        r.language                                          as dc_language,
+        array_agg(DISTINCT ws.file_url)                     as dc_identifier,
+        r.publication_date                                  as oaf_publicationdate,
+        r.embargo_end_date                                  as oaf_embargoenddate,
+        r.access_mode                                       as oaf_accessmode,
+        r.haskind                                           as oaf_haskind,
+        r.hastype                                           as "dr_CobjCategory",
+        r.storagedate                                           as oaf_storagedate,
+        createdfrom                                         as createdfrom,
+        array_agg(DISTINCT p.projectid)                     as oaf_projectid,
+        array_agg(DISTINCT cr.creator)                              as creators
+
+from
+
+       results r
+        left outer join results_projects rp on (r.resultid = rp.result)
+        left outer join projects p on (p.projectid = rp.project)
+        left outer join projects_projectsubjects ps on (ps.project = p.projectID)
+        left outer join fundingschemes fs on (p.fundedhow = fs.fundingschemeid)
+        left outer join programs s on (p.fundedby = s.programid)
+        left outer join specificprograms sp on (s.hasspecificprogram = sp.specificprogramid)
+        left outer join frameworkprograms fp on (sp.hasframeworkprogram = fp.frameworkprogramid)
+        left outer join authorships aut on (r.resultid = aut.result)
+        left outer join persons per on (per.personid = aut.author)
+        left outer join organizations o on (o.organizationid = aut.affiliation)
+        left outer join instances i on (r.resultid = i.resource)
+        left outer join webresources_instances wsi on (wsi.instanceid = i.instanceid)
+        left outer join webresources ws on (ws.webresourceid = wsi.webresourceid)
+
+        join creations cr on cr.creation = r.resultid
+
+where
+        r.pmhdeleted != true and r.pendingforclaim = false
+
+group by
+        r.resultid, r.title, r.description, r.publisher, r.keywords, r.language,
+        r.publication_date, r.embargo_end_date, r.access_mode, r.haskind, r.hastype,
+        r.storagedate, r.createdfrom
\ No newline at end of file
Index: modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(revision 47510)
@@ -0,0 +1,11 @@
+openaire.connector.thrift.port = 7911
+openaire.connector.thrift.timeout = 15000
+
+openaire.connector.unknownRepositoryName = Unknown Repository
+
+openaire.db.driverClassName = org.postgresql.Driver
+openaire.db.url = jdbc:postgresql://194.177.192.223:5432/dnet_claims
+openaire.db.username = dnet
+openaire.db.password = dnetPwd
+
+openaire.connector.api.directClaimAPIUrl = http://beta.services.openaire.eu:8280/is/mvc/api/publications/feedObject
\ No newline at end of file
Index: modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(revision 47510)
@@ -0,0 +1,57 @@
+<?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:tx="http://www.springframework.org/schema/tx"
+
+        xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/tx
+        http://www.springframework.org/schema/tx/spring-tx.xsd">
+		
+	<bean id="openaire.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+		<property name="driverClassName" value="${openaire.db.driverClassName}" />
+		<property name="url" value="${openaire.db.url}" />
+		<property name="username" value="${openaire.db.username}" />
+		<property name="password" value="${openaire.db.password}" />
+		<property name="maxIdle" value="10" />
+		<property name="maxActive" value="100" />
+		<property name="maxWait" value="10000" />
+		<property name="validationQuery" value="SELECT 1;" />
+		<property name="testOnBorrow" value="true" />
+		<property name="testOnReturn" value="true" />
+		<property name="testWhileIdle" value="true" />
+		<property name="timeBetweenEvictionRunsMillis" value="1200000" />
+		<property name="minEvictableIdleTimeMillis" value="1800000" />
+		<property name="numTestsPerEvictionRun" value="5" />
+		<property name="poolPreparedStatements" value="true" />
+		<property name="defaultAutoCommit" value="true" />
+	</bean>
+
+	<bean id="claimConnector" class="eu.dnetlib.openaire.thrift.ClaimConnector">
+		<property name="datasource" ref="openaire.dataSource" />
+		<property name="lookupServiceLocator" ref="lookupServiceLocator"/>
+		<property name="directClaimAPIUrl" value="${openaire.connector.api.directClaimAPIUrl}"/>
+	</bean>
+	
+	<bean id="alertConnector" class="eu.dnetlib.openaire.thrift.AlertConnector">
+		<property name="alertServiceLocator" ref="alertServiceLocator" />
+	</bean>
+	
+	<bean id="openAireConnector" class="eu.dnetlib.openaire.thrift.OpenAIREConnectorImpl">
+		<property name="claimConnector" ref="claimConnector" />
+		<property name="alertConnector" ref="alertConnector" />
+	</bean>
+	
+	<bean id="thriftServer" class="eu.dnetlib.openaire.thrift.ThriftServer" init-method="start" destroy-method="stop">
+		<property name="openAireConnector" ref="openAireConnector" />
+		<property name="port" value="${openaire.connector.thrift.port}"/>
+		<property name="timeout" value="${openaire.connector.thrift.timeout}" />
+	</bean>
+
+    <tx:annotation-driven transaction-manager="txManager"/>
+    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="openaire.dataSource"/>
+    </bean>
+
+</beans>
+
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(revision 47510)
@@ -0,0 +1,43 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TTransportException;
+
+public class ThriftServer {
+	private OpenAIREConnector.Iface openAireConnector;
+	private int port;
+	private int timeout;
+	private Thread thread;
+
+	public void setOpenAireConnector(final OpenAIREConnector.Iface openAireConnector) {
+		this.openAireConnector = openAireConnector;
+	}
+	
+	public void setPort(final int port) {
+		this.port = port;
+	}
+	
+	public void setTimeout(final int timeout) {
+		this.timeout = timeout;
+	}
+	
+	public void start() {
+		thread = new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					new TThreadPoolServer(new TThreadPoolServer.Args(new TServerSocket(port, timeout)).processor(new OpenAIREConnector.Processor<OpenAIREConnector.Iface>(openAireConnector))).serve();
+				} catch (final TTransportException e) {
+					Logger.getLogger(ThriftServer.class).error("Error starting thrift server", e);
+				}
+			}
+		});
+		thread.start();
+	}
+	
+	public void stop() {
+		thread.interrupt();
+	}
+}
Index: modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(revision 47510)
@@ -0,0 +1,58 @@
+<?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:tx="http://www.springframework.org/schema/tx"
+
+        xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/tx
+        http://www.springframework.org/schema/tx/spring-tx.xsd">
+		
+	<bean id="openaire.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+		<property name="driverClassName" value="${openaire.db.driverClassName}" />
+		<property name="url" value="${openaire.db.url}" />
+		<property name="username" value="${openaire.db.username}" />
+		<property name="password" value="${openaire.db.password}" />
+		<property name="maxIdle" value="10" />
+		<property name="maxActive" value="100" />
+		<property name="maxWait" value="10000" />
+		<property name="validationQuery" value="SELECT 1;" />
+		<property name="testOnBorrow" value="true" />
+		<property name="testOnReturn" value="true" />
+		<property name="testWhileIdle" value="true" />
+		<property name="timeBetweenEvictionRunsMillis" value="1200000" />
+		<property name="minEvictableIdleTimeMillis" value="1800000" />
+		<property name="numTestsPerEvictionRun" value="5" />
+		<property name="poolPreparedStatements" value="true" />
+		<property name="defaultAutoCommit" value="true" />
+	</bean>
+
+	<bean id="claimConnector" class="eu.dnetlib.openaire.thrift.ClaimConnector">
+		<property name="actionManagerLocator" ref="actionManagerLocator" />
+		<property name="datasource" ref="openaire.dataSource" />
+		<property name="lookupServiceLocator" ref="lookupServiceLocator"/>
+	</bean>
+	
+	<bean id="alertConnector" class="eu.dnetlib.openaire.thrift.AlertConnector">
+		<property name="alertServiceLocator" ref="alertServiceLocator" />
+	</bean>
+	
+	<bean id="openAireConnector" class="eu.dnetlib.openaire.thrift.OpenAIREConnectorImpl">
+		<property name="claimConnector" ref="claimConnector" />
+		<property name="alertConnector" ref="alertConnector" />
+	</bean>
+	
+	<bean id="thriftServer" class="eu.dnetlib.openaire.thrift.ThriftServer" init-method="start" destroy-method="stop">
+		<property name="openAireConnector" ref="openAireConnector" />
+		<property name="port" value="${openaire.connector.thrift.port}"/>
+		<property name="timeout" value="${openaire.connector.thrift.timeout}" />
+	</bean>
+
+    <tx:annotation-driven transaction-manager="txManager"/>
+    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="openaire.dataSource"/>
+    </bean>
+
+
+</beans>
+
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(revision 47510)
@@ -0,0 +1,11 @@
+openaire.connector.thrift.port = 7911
+openaire.connector.thrift.timeout = 15000
+
+openaire.connector.unknownRepositoryName = Unknown Repository
+
+openaire.db.driverClassName = org.postgresql.Driver
+openaire.db.url = jdbc:postgresql://194.177.192.223:5432/dnet_claims
+openaire.db.username = dnet
+openaire.db.password = dnetPwd
+
+openaire.connector.api.directClaimAPIUrl = http://beta.services.openaire.eu:8280/is/mvc/api/publications/feedObject
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/utils/claims.sql
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(revision 47510)
@@ -0,0 +1,45 @@
+select
+        r.resultid                                          as dri_objidentifier,
+        r.title                                             as dc_title,
+        array_agg(DISTINCT lpad('0'||aut.rank,5,'0')||'§§§'||ltrim(replace(per.surname||', '||per.name,'UNKNOWN, ',''), ', ')) as dc_creator,
+      r.description                                       as dc_description,
+        r.publisher                                         as dc_publisher,
+        r.keywords                                          as dc_subject,
+        r.language                                          as dc_language,
+        array_agg(DISTINCT ws.file_url)                     as dc_identifier,
+        r.publication_date                                  as oaf_publicationdate,
+        r.embargo_end_date                                  as oaf_embargoenddate,
+        r.access_mode                                       as oaf_accessmode,
+        r.haskind                                           as oaf_haskind,
+        r.hastype                                           as "dr_CobjCategory",
+        r.storagedate                                           as oaf_storagedate,
+        createdfrom                                         as createdfrom,
+        array_agg(DISTINCT p.projectid)                     as oaf_projectid,
+        array_agg(DISTINCT cr.creator)                              as creators
+
+from
+
+       results r
+        left outer join results_projects rp on (r.resultid = rp.result)
+        left outer join projects p on (p.projectid = rp.project)
+        left outer join projects_projectsubjects ps on (ps.project = p.projectID)
+        left outer join fundingschemes fs on (p.fundedhow = fs.fundingschemeid)
+        left outer join programs s on (p.fundedby = s.programid)
+        left outer join specificprograms sp on (s.hasspecificprogram = sp.specificprogramid)
+        left outer join frameworkprograms fp on (sp.hasframeworkprogram = fp.frameworkprogramid)
+        left outer join authorships aut on (r.resultid = aut.result)
+        left outer join persons per on (per.personid = aut.author)
+        left outer join organizations o on (o.organizationid = aut.affiliation)
+        left outer join instances i on (r.resultid = i.resource)
+        left outer join webresources_instances wsi on (wsi.instanceid = i.instanceid)
+        left outer join webresources ws on (ws.webresourceid = wsi.webresourceid)
+
+        join creations cr on cr.creation = r.resultid
+
+where
+        r.pmhdeleted != true and r.pendingforclaim = false
+
+group by
+        r.resultid, r.title, r.description, r.publisher, r.keywords, r.language,
+        r.publication_date, r.embargo_end_date, r.access_mode, r.haskind, r.hastype,
+        r.storagedate, r.createdfrom
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(revision 47510)
@@ -0,0 +1,35 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.TException;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+/**
+ * Created by antleb on 6/20/14.
+ */
+public class TestConnector {
+
+	public static void main(String[] args) throws TException {
+
+		OpenAIREConnector.Client client = new ThriftClient().getConnector("194.177.192.223", 7911);
+
+		String id = client.insertDocument("123123/3434.23", "doi", "a title", " a description", "OPEN ACCESS", null,
+                Arrays.asList(new Author("id" ,"lastname", "firstname")), "url", "dcsource", "antleb@di.uoa.gr",
+                Arrays.asList("subject"), "2012-01-02", "publisher", "language", "category", "doioioioi" ,
+                new ArrayList<Project4Index>(), new ArrayList<String>());
+		System.out.println(id);
+
+		client.insertConcept(id, "doi", "egi", "antleb@di.uoa.gr", "123");
+		client.insertProjectRelation(id, "doi", new Project("ec", "1233312"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "doi", new Project(null, "1233312"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "doi", id, "result", "antleb@di.uoa.gr");
+
+		id = "od______1406::fbda7b28cda277b04c8dc27a5e0deb68";
+
+		client.insertConcept(id, "openaire", "ec", "antleb@di.uoa.gr", "123");
+		client.insertProjectRelation(id, "openaire", new Project("ec", "099809987"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "openaire", new Project(null, "098908908"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "openaire", id, "dataset", "antleb@di.uoa.gr");
+	}
+}
Index: modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/action/relation.vm
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(revision 47510)
@@ -0,0 +1,5 @@
+<RELATIONS>
+#foreach ($rel in $relations)
+    <RELATION type='$rel.Type' source='$rel.SourceId' target='$rel.TargetId' />
+#end
+</RELATIONS>
\ No newline at end of file
Index: modules/uoa-claims-api/trunk/pom.xml
===================================================================
--- modules/uoa-claims-api/trunk/pom.xml	(nonexistent)
+++ modules/uoa-claims-api/trunk/pom.xml	(revision 47510)
@@ -0,0 +1,148 @@
+<?xml version="1.0"?>
+<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>uoa-openaire-connector</artifactId>
+	<version>1.3.3-SNAPSHOT</version>
+        <scm>
+                <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk</developerConnection>
+        </scm>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>dtrotts</id>
+			<name>Repository for maven thrift plugin</name>
+			<url>http://maven.davidtrott.com/repository</url>
+			<layout>default</layout>
+		</pluginRepository>
+	</pluginRepositories>
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<archive>
+
+					</archive>
+					<descriptorRefs>
+						<descriptorRef>jar-with-dependencies</descriptorRef>
+					</descriptorRefs>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.thrift.tools</groupId>
+				<artifactId>maven-thrift-plugin</artifactId>
+				<version>0.1.10</version>
+				<executions>
+					<execution>
+						<id>thrift-sources</id>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>compile</goal>
+						</goals>
+					</execution>
+					<execution>
+						<id>thrift-test-sources</id>
+						<phase>generate-test-sources</phase>
+						<goals>
+							<goal>testCompile</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings 
+					only. It has no influence on the Maven build itself. -->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>org.apache.thrift.tools</groupId>
+										<artifactId>maven-thrift-plugin</artifactId>
+										<versionRange>[0.1.10,)</versionRange>
+										<goals>
+											<goal>testCompile</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore />
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>[0.0.0,)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.7.5</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-dbcp</groupId>
+			<artifactId>commons-dbcp</artifactId>
+			<version>[1.2, 1.3)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-utils</artifactId>
+			<version>[1.1.0, 1.3.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-commons</artifactId>
+			<version>[1.1.0, 1.3.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.thrift</groupId>
+			<artifactId>libthrift</artifactId>
+			<version>0.8.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.postgresql</groupId>
+			<artifactId>jdbc4driver</artifactId>
+			<version>9.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.velocity</groupId>
+			<artifactId>velocity</artifactId>
+			<version>1.7</version>
+		</dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.googlecode.json-simple</groupId>
+            <artifactId>json-simple</artifactId>
+            <version>1.1</version>
+        </dependency>
+    </dependencies>
+
+</project>
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(revision 47510)
@@ -0,0 +1,361 @@
+package eu.dnetlib.openaire.thrift;
+
+
+import eu.dnetlib.api.enabling.ISLookUpService;
+import eu.dnetlib.api.enabling.ISLookUpServiceException;
+import eu.dnetlib.openaire.action.ActionUtils;
+import eu.dnetlib.openaire.action.IndexUtils;
+import gr.uoa.di.driver.enabling.ISLookUpException;
+import gr.uoa.di.driver.util.ServiceLocator;
+import org.apache.log4j.Logger;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.springframework.jdbc.datasource.DataSourceUtils;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+@Transactional
+public class ClaimConnector {
+
+    private static Logger logger = Logger.getLogger(ClaimConnector.class);
+
+    private String directClaimAPIUrl = null;
+    private DataSource datasource = null;
+
+    //Using an isLookUp Impl just to make an xQuery to IS. Maybe move all the
+    //functionality to commons?
+    private ServiceLocator<ISLookUpService> lookupServiceLocator = null;
+
+    public List<Claim> getClaimedPublications(final String user) throws SQLException {
+        Connection con = DataSourceUtils.getConnection(datasource);
+        PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"date\" , \"type\", \"xml\", \"id\" from claims where \"agent\" = ?");
+        stmt.setString(1, user);
+        ResultSet rs = stmt.executeQuery();
+        List<Claim> res = new ArrayList<Claim>();
+
+        while (rs.next()) {
+            res.add(new Claim(user, rs.getString(1), rs.getTimestamp(2).getTime(), rs.getString(3), rs.getString(4), rs.getString(5)));
+        }
+
+        rs.close();
+        stmt.close();
+
+        logger.info("Returning " + res.size() + " claimed publications for user "  + user);
+
+        return res;
+    }
+
+    public List<Claim> getClaimedPublications(Date from, Date to) throws SQLException {
+        Connection con = DataSourceUtils.getConnection(datasource);
+
+        PreparedStatement stmt = con.prepareStatement("select \"agent\", \"resultid\", \"date\" , \"type\", \"xml\",  \"id\"  from claims where \"agent\" != 'inference' and \"date\" >= ?::timestamp and \"date\" <= ?::timestamp ");
+        stmt.setTimestamp(1, new Timestamp(from.getTime()));
+        stmt.setTimestamp(2, new Timestamp(to.getTime()));
+
+        ResultSet rs = stmt.executeQuery();
+        List<Claim> res = new ArrayList<Claim>();
+
+        while (rs.next()) {
+            res.add(new Claim(rs.getString(1), rs.getString(2), rs.getTimestamp(3).getTime(), rs.getString(4), rs.getString(5), rs.getString(6)));
+        }
+
+        rs.close();
+        stmt.close();
+
+        logger.debug("number of claims: " + res.size());
+        logger.info("Returning " + res.size() + " claimed publications for date "  + from + "-" + to);
+
+        return res;
+    }
+
+    public void deleteClaim(String userEmail, String id) throws SQLException {
+        logger.info("Deleting claim with id " + id + " for agent " +  userEmail);
+
+        Connection con = DataSourceUtils.getConnection(datasource);
+        int claim_id = Integer.parseInt(id);
+        String type = null;
+
+        PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"type\" from claims where \"id\" =?");
+        stmt.setInt(1, claim_id);
+
+        ResultSet rs = stmt.executeQuery();
+
+        String resultid = null;
+        String xml = null;
+
+        while (rs.next()) {
+            resultid = rs.getString("resultid");
+            type = rs.getString("type");
+        }
+
+        if (resultid != null) {
+            stmt = con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =?");
+            stmt.setString(1, userEmail);
+            stmt.setInt(2, claim_id);
+
+            stmt.executeUpdate();
+            logger.info("Deleted claim with claim id: " + claim_id + ", result id: " + resultid + " and type: " + type +".") ;
+
+            //prepare to get 2nd claim to be deleted
+            int claim2_id = claim_id - 1;
+
+            if (type != null && type.equals("rels2actions")) {
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+                rs = stmt.executeQuery();
+
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //check if the relation has dmf
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            } /*else if (type != null && type.equals("dmf2actions")) {
+                logger.info("dmf2actions");
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+
+                rs = stmt.executeQuery();
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                logger.info("xml: " + xml);
+                logger.info("xml? " + xml.contains("oaf:concept"));
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //delete concept with extra dmf (doi,orchid,... etc)
+                    logger.debug("dmf2actions and not concept");
+
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            }*/
+        }
+
+        stmt.close();
+
+        logger.info("Deleted claim with id " + id + " for agent " +  userEmail);
+    }
+
+    /**
+     * @param id     {openaireId, publication doi, ORCIDId (personId-ORCIDPublicationId), data doi}
+     * @param source {openaire, doi (crossref), orcid, datacite}
+     * @throws ResourceNotFoundException
+     * @throws ParseErrorException
+     * @throws Exception
+     */
+    public String insertDocument(
+            String id,
+            String source,
+            String title,
+            String description,
+            String access_mode,
+            String embargoEndDate,
+            List<Author> authors,
+            String url,
+            String dcSource,
+            String userEmail,
+            List<String> subjects,
+            String publicationDate,
+            String publisher,
+            String language,
+            String category,
+            String doi,
+            List<Project4Index> project4Indexes,
+            List<String> concepts) throws Exception {
+
+        logger.info("Request to insert document with id " + id + " and source " + source);
+        logger.info("The title is: " + title);
+
+        String resultId;
+
+        try {
+            Connection con = DataSourceUtils.getConnection(datasource);
+            PreparedStatement stmt;
+            String dmf;
+
+            resultId = ActionUtils.getIdentifier(ActionUtils.getPrefix(source), id);
+            Date now = new Date();
+
+            if (!source.toLowerCase().equals("openaire") && title != null) {
+                stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+                dmf = ActionUtils.createDMF(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, doi, Collections.EMPTY_LIST, subjects, Collections.EMPTY_LIST, publicationDate, publisher, language, category, false);
+
+                stmt.setString(1, userEmail);
+                stmt.setString(2, resultId);
+                stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+                stmt.setString(4, "dmf2actions");
+                stmt.setString(5, dmf);
+                stmt.setString(6, "userclaim_dmf");
+                stmt.setString(7, ActionUtils.getProvenance(source));
+                stmt.setString(8, ActionUtils.getPrefix(source));
+
+                stmt.executeUpdate();
+                stmt.close();
+
+            }
+        } catch (Exception e) {
+            logger.error("Error inserting document", e);
+            throw e;
+        }
+
+        if (!datasource.equals("openaire"))
+            IndexUtils.feedIndex(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource,
+                    doi, Collections.EMPTY_LIST, subjects, Collections.EMPTY_LIST, publicationDate, publisher,
+                    language, category, false, project4Indexes, concepts, directClaimAPIUrl);
+
+        logger.info("Inserted document with id " + id + ", source " + source + " and given resultId " + resultId);
+        return resultId;
+    }
+
+    public void insertConceptRelation(String documentId, String documentSource, String concept, String userEmail, String doi) throws Exception {
+        logger.info("Request for concept relation between document with id " + documentId + " with source " + documentSource + " and concept " + concept + "with doi " + doi);
+
+        try {
+            Connection con = DataSourceUtils.getConnection(datasource);
+            PreparedStatement stmt;
+            String dmf;
+
+            stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+            dmf = ActionUtils.createDMF(documentId, documentSource, null, null, null, null, Collections.EMPTY_LIST, null, null, doi, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Arrays.asList(concept), null, null, null, null, true);
+
+            stmt.setString(1, userEmail);
+            stmt.setString(2, documentId);
+            stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+            stmt.setString(4, "updates2actions");
+            stmt.setString(5, dmf);
+            stmt.setString(6, "userclaim_dmf");
+            stmt.setString(7, ActionUtils.getProvenance(documentSource));
+            stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+            stmt.executeUpdate();
+            stmt.close();
+        } catch (Exception e) {
+            logger.error("Error adding concept", e);
+            throw e;
+        }
+
+        logger.info("Inserted concept relation between document with id " + documentId + " with source " + documentSource + " and concept " + concept);
+    }
+
+    public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws Exception {
+        logger.info("Request for project relation between document with id " + docId + " with source " + documentSource + " and project " + project);
+
+        try {
+            Connection con = DataSourceUtils.getConnection(datasource);
+            PreparedStatement stmt;
+            String xml = ActionUtils.createResultProjectRelation("openaire".equals(documentSource) ? null : documentSource, docId, project.getType(), project.getProjectId());
+
+            stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+            stmt.setString(1, userEmail);
+            stmt.setString(2, docId);
+            stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+            stmt.setString(4, "rels2actions");
+            stmt.setString(5, xml);
+            stmt.setString(6, "userclaim_result_project");
+            stmt.setString(7, ActionUtils.getProvenance(documentSource));
+            stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+            stmt.executeUpdate();
+            stmt.close();
+        } catch (Exception e) {
+            logger.error("Error adding project", e);
+            throw e;
+        }
+
+        logger.info("Inserted project relation between document with id " + docId + " with source " + documentSource + " and project " + project);
+    }
+
+    public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws Exception {
+        logger.info("Request for result relation between source document with id " + sourceResultId + ", type " + sourceResultType + "and source " + sourceResultSource + " and " +
+                "target document with id " + targetResultId + ", type " + targetResultType);
+        try {
+            Connection con = DataSourceUtils.getConnection(datasource);
+            PreparedStatement stmt;
+            String xml = ActionUtils.createResultResultRelation(sourceResultId, sourceResultType, targetResultId, targetResultType);
+
+            stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+            stmt.setString(1, userEmail);
+            stmt.setString(2, sourceResultId);
+            stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+            stmt.setString(4, "rels2actions");
+            stmt.setString(5, xml);
+            stmt.setString(6, "userclaim_result_result");
+            stmt.setString(7, ActionUtils.getProvenance(sourceResultSource));
+            stmt.setString(8, ActionUtils.getPrefix(sourceResultSource));
+
+            stmt.executeUpdate();
+            stmt.close();
+        } catch (Exception e) {
+            logger.error("Error adding result relation", e);
+            throw e;
+        }
+
+        logger.info("Inserted result relation between source document with id " + sourceResultId + ", type " + sourceResultType + "and source " + sourceResultSource + " and " +
+                "target document with id " + targetResultId + ", type " + targetResultType);
+    }
+
+    public DataSource getDatasource() {
+        return datasource;
+    }
+
+    public void setDatasource(DataSource datasource) {
+        this.datasource = datasource;
+    }
+
+    public ServiceLocator<ISLookUpService> getLookupServiceLocator() {
+        return lookupServiceLocator;
+    }
+
+    public void setLookupServiceLocator(
+            ServiceLocator<ISLookUpService> lookupServiceLocator) {
+        this.lookupServiceLocator = lookupServiceLocator;
+    }
+
+    public List<String> getContexts() throws ISLookUpException, ISLookUpServiceException {
+        return lookupServiceLocator.getService().quickSearchProfile("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') return $x");
+    }
+
+    public String getDirectClaimAPIUrl() {
+        return directClaimAPIUrl;
+    }
+
+    public void setDirectClaimAPIUrl(String directClaimAPIUrl) {
+        this.directClaimAPIUrl = directClaimAPIUrl;
+    }
+}
\ No newline at end of file
Index: modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java
===================================================================
--- modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(revision 47510)
@@ -0,0 +1,192 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertServiceException;
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.List;
+
+public class OpenAIREConnectorImpl implements OpenAIREConnector.Iface {
+	private static final Logger logger = Logger.getLogger(OpenAIREConnectorImpl.class);
+
+	private ClaimConnector claimConnector;
+	private AlertConnector alertConnector;
+
+	public void setClaimConnector(final ClaimConnector claimConnector) {
+		this.claimConnector = claimConnector;
+	}
+
+	public void setAlertConnector(final AlertConnector alertConnector) {
+		this.alertConnector = alertConnector;
+	}
+
+	@Override
+	public List<Claim> getClaimedPublications(final String user) throws TException {
+		try {
+			return claimConnector.getClaimedPublications(user);
+		} catch (final Exception e) {
+			logger.error("Error retrieving claimed publications (user: " + user + ")", e);
+			throw new TException("Error retrieving claimed publications (user: " + user + ")", e);
+		}
+	}
+
+    @Override
+    public List<Claim> getAllClaimedPublications(long from, long to) throws TException {
+        try {
+            return claimConnector.getClaimedPublications(new Date(from), new Date(to));
+        } catch (Exception e) {
+            logger.error("Error retrieving claimed publications", e);
+
+            throw new TException("Error retrieving claimed publications", e);
+        }
+    }
+
+    @Override
+    public String insertDocument(String originalId, String source, String title, String description, String access_mode,
+                                 String embargoEndDate, List<Author> authors, String url, String dcSource,
+                                 String userEmail, List<String> subjects, String publicationDate, String publisher,
+                                 String language, String category, String doi, List<Project4Index> project4Indexes,
+                                 List<String> concepts) throws org.apache.thrift.TException {
+        try {
+            logger.info("concepts " + concepts);
+            return claimConnector.insertDocument(originalId, source, title, description, access_mode, embargoEndDate,
+                    authors, url, dcSource, userEmail, subjects, publicationDate, publisher, language, category, doi,
+                    project4Indexes, concepts);
+        } catch (Exception e) {
+            logger.error("Error adding document", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertConcept(String docId, String documentSource, String concept, String userEmail, String doi) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertConceptRelation(docId, documentSource, concept, userEmail, doi);
+        } catch (Exception e) {
+            logger.error("Error adding concept relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertProjectRelation(docId, documentSource, project, userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding project relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws TException {
+        try {
+            claimConnector.insertResultRelation(sourceResultId, sourceResultType, sourceResultSource, targetResultId, targetResultType,userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding result relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+	public List<AlertSubscription> getSubscriptions(final String alertMode, final String subscriber, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getSubscriptions(alertMode, subscriber, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+	@Override
+	public void addSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.addSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		}
+	}
+
+	@Override
+	public void removeSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.removeSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		}
+	}
+
+	@Override
+	public int countAlertResults(final String notificationService, final String queryId, final long date, final String resultId) throws TException {
+		try {
+			return alertConnector.countAlertResults(notificationService, queryId, date, resultId);
+		} catch (final AlertServiceException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		}
+	}
+
+	@Override
+	public ResultPage getAlertResults(final String notificationService, final String queryId, final String resultId, final long fromDate, final long toDate, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getAlertResults(notificationService, queryId, resultId, fromDate, toDate, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+    @Override
+    public void deleteClaim(String userEmail, String resultId) throws TException {
+        try {
+            claimConnector.deleteClaim(userEmail, resultId);
+        } catch (Exception e) {
+            logger.error("Error deleting claim", e);
+
+            throw new TException(e);
+        }
+    }
+
+	@Override
+	public List<String> getContexts() throws TException {
+		try {
+			return claimConnector.getContexts();
+		} catch (Exception e) {
+			logger.error("Error getting contexts from IS.", e);
+			
+			throw new TException(e);
+		}
+		
+	}
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(revision 47510)
@@ -0,0 +1,286 @@
+package eu.dnetlib.openaire.action;
+
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.Project;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+import java.io.StringWriter;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class ActionUtils {
+
+	private static Logger logger = Logger.getLogger(ActionUtils.class);
+
+	public static String createResultProjectRelation(String source,
+			String resultId, String projectType, String projectId)
+			throws Exception {
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+		ve.init();
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+		VelocityContext vc = new VelocityContext();
+
+		List<Relation> rels = new ArrayList<Relation>();
+
+		rels.add(createRelation(source, resultId, projectType, projectId));
+
+		vc.put("relations", rels);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+
+		return sw.toString();
+	}
+
+    public static String createResultResultRelation(String sourceResultId, String sourceResultType, String targetResultId, String targetResultType) {
+        VelocityEngine ve = new VelocityEngine();
+        ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+        ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+        ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+        ve.init();
+
+        Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+        VelocityContext vc = new VelocityContext();
+
+        List<Relation> rels = new ArrayList<Relation>();
+
+        rels.add(new Relation("resultResult_" + sourceResultType + targetResultType + "_isRelatedTo", "50|" + sourceResultId, "50|" + targetResultId));
+
+        vc.put("relations", rels);
+
+        StringWriter sw = new StringWriter();
+        t.merge(vc, sw);
+
+        return sw.toString();
+    }
+
+	// input id: 1306.3402
+	// oai:arXiv.org:1306.3402
+	// MD5("od________18::oai:arXiv.org:1306.3402")
+
+    /**
+     * Creates a new relation action.
+     * @param source the result source. If not null, the resultId is transformed to openaire id. If null, the result is
+     *               considered to be already an openaire result and is used verbatim
+     * @param resultId the result id
+     * @param projectType the project type. If not null, the projectId is transformed to openaire id. If null, the projectId is
+     *               considered to be already in openaire format and is used verbatim
+     * @param projectId the project id
+     *
+     * @return a relation
+     */
+	private static Relation createRelation(String source, String resultId,
+			String projectType, String projectId) {
+		String resultPrefix;
+		String projectPrefix = null;
+
+        if (!isValidOpenaireId(resultId) && source != null) {
+            if (source.equals("arxiv")) {
+                resultId = "oai:arXiv.org:" + resultId;
+            } else if (source.equals("pubmed")) {
+                resultId = "oai:europepmc.org:" + resultId;
+            }
+
+            resultPrefix = getPrefix(source);
+            resultId = getIdentifier(resultPrefix, resultId);
+        }
+
+	resultId = "50|" + resultId;
+
+        if (projectType != null) {
+            if (projectType.equals("ec")) {
+                projectPrefix = "corda_______";
+            } else if (projectType.equals("wt")) {
+                projectPrefix = "wt__________::WT";
+            }
+
+            projectId = projectPrefix + "::" + projectId;
+        }
+
+	projectId = "40|" + projectId;
+
+		return new Relation("resultProject", resultId, projectId);
+	}
+
+	private static boolean isValidOpenaireId(String resultId) {
+
+		return Pattern.matches("\\w{12}::[a-f0-9]{32}", resultId);
+	}
+
+	public static String getPrefix(String source) {
+        logger.debug("SOURCE " + source);
+		if (source == null || source.equals("openaire")) {
+			return "openaire____";
+		} else if (source.equals("doi")) {
+			return "crossref____";
+		} if (source.equals("orcid")) {
+            		return "orcid_______";
+		} else if (source.equals("datacite")) {
+			return "datacite____";
+		} else if (source.equals("driver")) {
+			return "driver______";
+		} else
+			return null;
+	}
+
+    public static String getProvenance(String source) {
+        if (source == null || source.equals("openaire"))
+            return "user:claim:search";
+        else if (source.equals("doi") || source.equals("orcid"))
+            return "user:claim:pid";
+		else if (source.equals("datacite"))
+			return "user:claim:datacite";
+        else
+            return null;
+    }
+
+	public static String createDMF(String id, String source, String title,
+			String description, String access_mode, String embargoEndDate,
+			List<Author> authors, String url, String dcSource, String doi,
+			List<Project> projects, List<String> subjects, List<String> concepts, String publicationDate,
+            String publisher, String language, String category, boolean isConcept) throws Exception {
+
+        logger.info("create with doi " + doi);
+
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+		ve.init();
+		
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/dmf.vm");
+		VelocityContext vc = new VelocityContext();
+
+		String hostedby = null;
+		String hostedbyName = null;
+		String collectedFrom = null;
+		String collectedFromName = null;
+        String recordIdentifier = id;
+		String prefix = getPrefix(source);
+
+
+        //if the orcid id exists
+        String orcid = null;
+
+		if (source.equals("doi") && !isConcept) {
+			hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+			hostedbyName = "Unknown Repository";
+			collectedFrom = "openaire____::crossref";
+			collectedFromName = "Crossref";
+			doi = id;
+
+        } else if (source.equals("datacite")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::datacite";
+            collectedFromName = "Datacite";
+
+        } else if (source.equals("orcid")) {
+            orcid = id;
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::orcid";
+            collectedFromName = "ORCID";
+
+        } else if (source.equals("driver")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::driver";
+            collectedFromName = "Digital Repository Infrastructure Vision for European Research";
+        }
+
+        logger.info("create with doi " + doi);
+
+        if (doi != null) {
+            vc.put("doi", doi);
+        } else if (orcid != null){
+          //if there is no doi but we have an orcid, id we store it
+          vc.put("orcid", orcid);
+        }
+
+        // openaire ids should not be touched!
+        if (!source.equals("openaire"))
+		    id = getIdentifier(prefix, id);
+
+		vc.put("objIdentifier", id);
+		vc.put("recordIdentifier", recordIdentifier);
+		vc.put("dateOfCollection", DateUtils.calculate_ISO8601(System.currentTimeMillis()));
+		vc.put("hostedby", hostedby);
+		vc.put("collectedFrom", collectedFrom);
+		vc.put("hostedbyName", hostedbyName);
+		vc.put("collectedFromName", collectedFromName);
+        vc.put("embargoEndDate", embargoEndDate);
+		vc.put("title", title);
+		vc.put("description", description);
+		vc.put("accessMode", access_mode);
+		vc.put("dcSource", dcSource);
+		vc.put("url", url);
+		vc.put("publisher", publisher);
+		vc.put("language", language);
+		vc.put("objCategory", category);
+
+		vc.put("datasourceprefix", prefix);
+
+		List<String> creators = new ArrayList<String>();
+		for (Author author : authors) {
+            String name = author.getLastName();
+
+
+            if (author.getFirstName() != null && !author.getFirstName().trim().isEmpty())
+                name += ", " + author.getFirstName();
+
+            creators.add(name);
+		}
+
+		vc.put("creators", creators);
+		vc.put("projects", projects);
+		vc.put("subjects", subjects);
+        vc.put("concepts", concepts);
+		
+		if (publicationDate != null && !publicationDate.equals(""))
+			vc.put("publicationDate", publicationDate + "-01-01T00:00:00Z");
+		
+		vc.put("StringEscapeUtils", StringEscapeUtils.class);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+		
+		return sw.toString();
+	}
+
+	// private static String getIdentifier(String prefix, String id) {
+	// return prefix + "::" +
+	// com.google.common.hash.Hashing.md5().hashString(id).toString();
+	// }
+
+	public static String getIdentifier(String prefix, String id) {
+		try {
+            logger.debug("PREFIX " + prefix);
+			MessageDigest md = MessageDigest.getInstance("MD5");
+
+			md.update(id.getBytes("UTF-8"));
+
+			return prefix + "::" + new String(Hex.encodeHex(md.digest()));
+		} catch (Exception e) {
+			logger.error("Error creating id", e);
+			return null;
+		}
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(revision 47510)
@@ -0,0 +1,31 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.TException;
+
+import java.util.Arrays;
+
+/**
+ * Created by antleb on 6/20/14.
+ */
+public class TestConnector {
+
+	public static void main(String[] args) throws TException {
+
+		OpenAIREConnector.Client client = new ThriftClient().getConnector("194.177.192.223", 7911);
+
+		String id = client.insertDocument("123123/3434.23", "doi", "a title", " a description", "OPEN ACCESS", null, Arrays.asList(new Author("id" ,"lastname", "firstname")), "url", "dcsource", "antleb@di.uoa.gr", Arrays.asList("subject"), "2012-01-02", "publisher", "language", "category", "doioioioi" );
+		System.out.println(id);
+
+		client.insertConcept(id, "doi", "egi", "antleb@di.uoa.gr", "123");
+		client.insertProjectRelation(id, "doi", new Project("ec", "1233312"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "doi", new Project(null, "1233312"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "doi", id, "result", "antleb@di.uoa.gr");
+
+		id = "od______1406::fbda7b28cda277b04c8dc27a5e0deb68";
+
+		client.insertConcept(id, "openaire", "ec", "antleb@di.uoa.gr", "123");
+		client.insertProjectRelation(id, "openaire", new Project("ec", "099809987"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "openaire", new Project(null, "098908908"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "openaire", id, "dataset", "antleb@di.uoa.gr");
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/deploy.info
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/deploy.info	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/deploy.info	(revision 47510)
@@ -0,0 +1,10 @@
+{
+  "type_source": "SVN", 
+  "goal": "package -U -T 4C source:jar", 
+  "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk", 
+  "deploy_repository": "dnet4-snapshots", 
+  "version": "4", 
+  "mail": "antleb@di.uoa.gr, kiatrop@di.uoa.gr", 
+  "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", 
+  "name": "uoa-openaire-connector"
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(revision 47510)

Property changes on: modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/action/relation.vm
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(revision 47510)
@@ -0,0 +1,5 @@
+<RELATIONS>
+#foreach ($rel in $relations)
+    <RELATION type='$rel.Type' source='$rel.SourceId' target='$rel.TargetId' />
+#end
+</RELATIONS>
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/thrift/OpenAIREConnector.thrift
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/thrift/OpenAIREConnector.thrift	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/thrift/OpenAIREConnector.thrift	(revision 47510)
@@ -0,0 +1,118 @@
+namespace java eu.dnetlib.openaire.thrift
+
+struct Author {
+	1: string id,
+	2: string lastName,
+	3: string firstName
+}
+
+// alerts
+struct AlertSubscription {
+	1: string templateId,
+	2: string notificationService,
+	3: string queryId,
+	4: string resultId,
+	5: string alertMode,
+	6: string subscriber
+}
+
+struct ResultPage {
+	1: i32 limit,
+	2: i32 offset,
+	3: list<string> columns,
+	4: list<list<string>> rows
+}
+
+struct Claim {
+    1: string userEmail,
+	2: string resultid,
+	3: i64 date,
+	4: string type,
+	5: string xml,
+	6: string id
+}
+
+struct Project {
+    1: string type,
+    2: string projectId
+}
+
+// connector
+service OpenAIREConnector {
+	// claim
+	list<Claim> getClaimedPublications(1: string userEmail),
+
+	// from: date in milisecs
+	// to: ditto
+	list<Claim> getAllClaimedPublications(1: i64 from, 2: i64 to),
+	
+	string insertDocument (
+			1: string originalId,
+			2: string source, 
+			3: string title, 
+			4: string description, 
+			5: string access_mode, 
+			6: string embargoEndDate, 
+			7: list<Author> authors, 
+			8: string url,
+			9: string dcSource,
+			10: string userEmail,
+			11: list<string> subjects,
+			12: string publicationDate,
+			13: string publisher,
+			14: string language,
+			15: string category,
+			16: string doi),
+
+    void insertConcept (
+        1: string docId,
+        2: string documentSource,
+        3: string concept,
+        4: string userEmail,
+        5: string doi),
+
+    void insertProjectRelation (
+        1: string docId,
+        2: string documentSource,
+        3: Project project,
+        4: string userEmail),
+
+    void insertResultRelation (
+        1: string sourceResultId,
+        2: string sourceResultType,
+        3: string sourceResultSource,
+        4: string targetResultId,
+        5: string targetResultType,
+        6: string userEmail
+    ),
+
+	void deleteClaim(1: string userEmail, 2:string resultId),
+
+	// alerts
+	list<AlertSubscription> getSubscriptions(
+			1: string alertMode, 
+			2: string subscriber, 
+			3: i32 limit, 
+			4: i32 offset),
+			
+	void addSubscription(1: AlertSubscription subscription),
+	
+	void removeSubscription(1: AlertSubscription subscription),
+	
+	i32 countAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: i64 date, 
+			5: string resultId),
+			
+	ResultPage getAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: string resultId, 
+			4: i64 fromDate, 
+			5: i64 toDate, 
+			6: i32 limit, 
+			7: i32 offset),
+	
+	list<string> getContexts(),
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/utils/claims.sql
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(revision 47510)
@@ -0,0 +1,45 @@
+select
+        r.resultid                                          as dri_objidentifier,
+        r.title                                             as dc_title,
+        array_agg(DISTINCT lpad('0'||aut.rank,5,'0')||'§§§'||ltrim(replace(per.surname||', '||per.name,'UNKNOWN, ',''), ', ')) as dc_creator,
+      r.description                                       as dc_description,
+        r.publisher                                         as dc_publisher,
+        r.keywords                                          as dc_subject,
+        r.language                                          as dc_language,
+        array_agg(DISTINCT ws.file_url)                     as dc_identifier,
+        r.publication_date                                  as oaf_publicationdate,
+        r.embargo_end_date                                  as oaf_embargoenddate,
+        r.access_mode                                       as oaf_accessmode,
+        r.haskind                                           as oaf_haskind,
+        r.hastype                                           as "dr_CobjCategory",
+        r.storagedate                                           as oaf_storagedate,
+        createdfrom                                         as createdfrom,
+        array_agg(DISTINCT p.projectid)                     as oaf_projectid,
+        array_agg(DISTINCT cr.creator)                              as creators
+
+from
+
+       results r
+        left outer join results_projects rp on (r.resultid = rp.result)
+        left outer join projects p on (p.projectid = rp.project)
+        left outer join projects_projectsubjects ps on (ps.project = p.projectID)
+        left outer join fundingschemes fs on (p.fundedhow = fs.fundingschemeid)
+        left outer join programs s on (p.fundedby = s.programid)
+        left outer join specificprograms sp on (s.hasspecificprogram = sp.specificprogramid)
+        left outer join frameworkprograms fp on (sp.hasframeworkprogram = fp.frameworkprogramid)
+        left outer join authorships aut on (r.resultid = aut.result)
+        left outer join persons per on (per.personid = aut.author)
+        left outer join organizations o on (o.organizationid = aut.affiliation)
+        left outer join instances i on (r.resultid = i.resource)
+        left outer join webresources_instances wsi on (wsi.instanceid = i.instanceid)
+        left outer join webresources ws on (ws.webresourceid = wsi.webresourceid)
+
+        join creations cr on cr.creation = r.resultid
+
+where
+        r.pmhdeleted != true and r.pendingforclaim = false
+
+group by
+        r.resultid, r.title, r.description, r.publisher, r.keywords, r.language,
+        r.publication_date, r.embargo_end_date, r.access_mode, r.haskind, r.hastype,
+        r.storagedate, r.createdfrom
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(revision 47510)
@@ -0,0 +1,43 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TTransportException;
+
+public class ThriftServer {
+	private OpenAIREConnector.Iface openAireConnector;
+	private int port;
+	private int timeout;
+	private Thread thread;
+
+	public void setOpenAireConnector(final OpenAIREConnector.Iface openAireConnector) {
+		this.openAireConnector = openAireConnector;
+	}
+	
+	public void setPort(final int port) {
+		this.port = port;
+	}
+	
+	public void setTimeout(final int timeout) {
+		this.timeout = timeout;
+	}
+	
+	public void start() {
+		thread = new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					new TThreadPoolServer(new TThreadPoolServer.Args(new TServerSocket(port, timeout)).processor(new OpenAIREConnector.Processor<OpenAIREConnector.Iface>(openAireConnector))).serve();
+				} catch (final TTransportException e) {
+					Logger.getLogger(ThriftServer.class).error("Error starting thrift server", e);
+				}
+			}
+		});
+		thread.start();
+	}
+	
+	public void stop() {
+		thread.interrupt();
+	}
+}
Index: modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/action/IndexUtils.java
===================================================================
--- modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/action/IndexUtils.java	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/action/IndexUtils.java	(revision 47510)
@@ -0,0 +1,341 @@
+package eu.dnetlib.openaire.action;
+
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.Project;
+import eu.dnetlib.openaire.thrift.Project4Index;
+import org.apache.log4j.Logger;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import sun.net.www.protocol.http.HttpURLConnection;
+
+import java.io.*;
+import java.net.URL;
+import java.util.List;
+
+/**
+ * Created by kiatrop on 26/1/2016.
+ */
+public class IndexUtils {
+
+    private static final Logger logger = Logger.getLogger(IndexUtils.class);
+
+    public static JSONObject createJSON(String id, String source, String title, String description, String access_mode,
+                                        String embargoEndDate, List<Author> authors, String url, String dcSource,
+                                        String doi, List<Project> projects, List<String> subjects, List<String> concepts,
+                                        String publicationDate, String publisher, String language, String category,
+                                        boolean isConcept, List<Project4Index> project4Indexes, List<String> concepts4index) throws Exception {
+
+        if (source.equals("openaire"))
+            throw new IllegalArgumentException("cannot create JSON for openaire");
+
+        //logger.info("create JSON for doi " + doi);
+        //logger.info("projects " + project4Indexes);
+
+        //if the orcid id exists
+        String orcid = null;
+        String hostedby = null;
+        String hostedbyName = null;
+        String collectedFrom = null;
+        String collectedFromName = null;
+        String recordIdentifier = id;
+
+        if (source.equals("doi") && !isConcept) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::crossref";
+            collectedFromName = "Crossref";
+            doi = id;
+
+        } else if (source.equals("datacite")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::datacite";
+            collectedFromName = "Datacite";
+
+        } else if (source.equals("orcid")) {
+            orcid = id;
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::orcid";
+            collectedFromName = "ORCID";
+
+        } else if (source.equals("driver")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::driver";
+            collectedFromName = "Digital Repository Infrastructure Vision for European Research";
+        }
+
+        JSONObject claimJSON = new JSONObject();
+        String prefix = ActionUtils.getPrefix(source);
+        claimJSON.put("originalId", id);
+        claimJSON.put("title", title);
+
+        JSONArray authorsJSONArray = new JSONArray();
+        for (Author author: authors) {
+            authorsJSONArray.add(author.getFirstName() + " " + author.getLastName());
+        }
+        claimJSON.put("authors", authorsJSONArray);
+
+        claimJSON.put("publisher", publisher);
+        claimJSON.put("description", description);
+        claimJSON.put("language", language);
+
+        JSONArray pidsJSONArray = new JSONArray();
+        JSONObject pidJSON = null;
+        if (doi != null) {
+            pidJSON = new JSONObject();
+            pidJSON.put("type", "doi");
+            pidJSON.put("value", doi);
+            pidsJSONArray.add(pidJSON);
+        }
+        if (orcid != null) {
+            pidJSON = new JSONObject();
+            pidJSON.put("type", "orcidworkid");
+            pidJSON.put("value", orcid);
+            pidsJSONArray.add(pidJSON);
+        }
+        claimJSON.put("pids", pidsJSONArray);
+
+        claimJSON.put("licenseCode", access_mode);
+        if(source.equals("crossref")) {
+            claimJSON.put("resourceType", "0001");
+        } else if (source.equals("datacite")) {
+            claimJSON.put("resourceType", "0021");
+        } else {
+            claimJSON.put("resourceType", "0001");
+        }
+
+        claimJSON.put("url", url);
+        claimJSON.put("collectedFromId", collectedFrom);
+        claimJSON.put("hostedById", hostedby);
+
+        JSONArray linksToProjectsJSONArray = new JSONArray();
+        for (Project4Index project:project4Indexes) {
+            linksToProjectsJSONArray.add(createProjectPath(project)) ;
+        }
+        claimJSON.put("linksToProjects",linksToProjectsJSONArray);
+
+        JSONArray contextsJSONArray = new JSONArray();
+        if(!concepts4index.isEmpty()) {
+            for (String context: concepts4index) {
+                contextsJSONArray.add(context); //TODO check
+            }
+        }
+        claimJSON.put("contexts", contextsJSONArray);
+
+        return claimJSON;
+    }
+
+    public static void feedIndex(String id, String source, String title,
+                                 String description, String access_mode, String embargoEndDate,
+                                 List<Author> authors, String url, String dcSource, String doi,
+                                 List<Project> projects, List<String> subjects, List<String> concepts,
+                                 String publicationDate, String publisher, String language, String category,
+                                 boolean isConcept, List<Project4Index> project4Indexes, List<String> concepts4index,
+                                 String directClaimAPIUrl) throws Exception {
+
+        logger.info("number of projects " + project4Indexes);
+        if (project4Indexes!= null) {
+            logger.info("number of projects " + project4Indexes.size());
+        }
+
+        URL obj = new URL(directClaimAPIUrl);
+        HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+        JSONObject claimJson = createJSON(id, source, title, description, access_mode, embargoEndDate,
+                                    authors, url, dcSource, doi, projects, subjects, concepts, publicationDate,
+                                    publisher, language, category, isConcept, project4Indexes, concepts4index);
+        //add request header
+        con.setRequestMethod("POST");
+        //con.setRequestProperty("User-Agent", USER_AGENT);
+        con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
+        con.setRequestProperty("Content-Type", "application/json");
+
+        logger.info("Feeding index with " + claimJson.toJSONString());
+        String urlParameters = claimJson.toJSONString();
+
+        // Send post request
+        con.setDoOutput(true);
+        DataOutputStream wr = new DataOutputStream(con.getOutputStream());
+        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(wr, "UTF-8"));
+        writer.write(urlParameters);
+        writer.close();
+        wr.close();
+
+        int responseCode = con.getResponseCode();
+        System.out.println("\nSending 'POST' request to URL : " + url);
+        System.out.println("Post parameters : " + urlParameters);
+        System.out.println("Response Code : " + responseCode);
+
+        BufferedReader in = new BufferedReader(
+                new InputStreamReader(con.getInputStream()));
+        String inputLine;
+        StringBuffer response = new StringBuffer();
+
+        while ((inputLine = in.readLine()) != null) {
+            response.append(inputLine);
+        }
+        in.close();
+
+        //print result
+        System.out.println(response.toString());
+    }
+
+    private static String createProjectPath(Project4Index project) {
+        if (project.getFunder().equals("EC")) {
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/EC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/EU//"+project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/EC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/EU//"+project.getName();
+        }
+
+        if (project.getFunder().equals("WT")) {
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/WT//"+project.getCode()+"//" + project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/WT//"+project.getCode()+project.getName();
+        }
+
+        if (project.getFunder().equals("ARC")) {
+            logger.debug("name: '" + project.getName()+"'");
+            logger.debug("name: '" + project.getAcronym()+"'");
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/ARC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/AU//"+project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/ARC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/AU//"+project.getName();
+        }
+
+        if (project.getFunder().equals("NHMRC")) {
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/NHMRC/"+project.getFundingStreamLevel0()+"/"
+                        +project.getCode()+"/AU//"+project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/NHMRC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/AU//"+project.getName();
+        }
+
+        if (project.getFunder().equals("FCT")) {
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/FCT/"+project.getFundingStreamLevel0()+"/"
+                        +project.getCode()+"/PT//"+project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/FCT/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/PT//"+project.getName();
+        }
+
+        return "";
+    }
+
+    public static void main(String[] args) throws IOException {
+
+        String url = "http://beta.services.openaire.eu:8280/is/mvc/api/publications/feedObject";
+        URL obj = new URL(url);
+        HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+        //add reuqest header
+        con.setRequestMethod("POST");
+        //con.setRequestProperty("User-Agent", USER_AGENT);
+        con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
+        con.setRequestProperty("Content-Type", "application/json");
+
+
+        /*String urlParameters = "{\n" +
+                "\"collectedFromId\": \"openaire____::crossref\",\n" +
+                "\"authors\": [\"George Papastefanatos\", \"Panos Vassiliadis\", \"Alkis Simitsis\", \"Yannis Vassiliou\"],\n" +
+                "\"title\": \"HECATAEUS: Regulating schema evolution\",\n" +
+                "\"hostedById\": \"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\",\n" +
+                "\"licenseCode\": \"OPEN\",\n" +
+                "\"pids\": [{\n" +
+                "\"value\": \"10.1109\\/icde.2010.5447778\",\n" +
+                "\"type\": \"doi\"\n" +
+                "}],\n" +
+                "\"description\": null,\n" +
+                "\"originalId\": \"crossref____::817ee94bc4a0515adadb1fdaa78927f6\",\n" +
+                "\"contexts\": [],\n" +
+                "\"language\": null,\n" +
+                "\"linksToProjects\": [\"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus\"],\n" +
+                "\"url\": \"http:\\/\\/dx.doi.org\\/10.1109\\/icde.2010.5447778\",\n" +
+                "\"resourceType\": \"0001\",\n" +
+                "\"publisher\": \"Institute of Electrical & Electronics Engineers (IEEE)\"\n" +
+                "}";
+
+        String urlParameters = "{\n" +
+                "\"collectedFromId\": \"openaire____::crossref\",\n" +
+                "\"authors\": [\"George Papastefanatos\", \"Panos Vassiliadis\", \"Alkis Simitsis\", \"Yannis Vassiliou\"],\n" +
+                " \"title\": \"â\\\\ dark bottomless Abyss, that lies under our feet, had yawned openâ\\\\\",\n" +
+                "\"hostedById\": \"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\",\n" +
+                "\"licenseCode\": \"CLOSED\",\n" +
+                "\"pids\": [{\n" +
+                "\"value\": \"10.1007\\/s13740_012_0006_9\",\n" +
+                "\"type\": \"doi\"\n" +
+                "}],\n" +
+                "\"description\": null,\n" +
+                "\"originalId\": \"crossref____::test\",\n" +
+                "\"contexts\": [\"egi::classification::natsc::infos::dmin\"], " +
+                "\"language\": null, " +
+                "\"linksToProjects\": [\"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus\"], " +
+                "\"url\": \"http:\\/\\/dx.doi.org\\/10.1007\\/s13740_012_0006_9\", " +
+                "\"resourceType\": \"0001\", " +
+                "\"publisher\": \"Springer Science + Business Media\" " +
+                "}";
+*/
+
+        String urlParameters = "{ " +
+                "\"collectedFromId\": \"openaire____::crossref\", " +
+                "\"authors\": [\"Agapi Dalkou\"], " +
+                "\"title\": \"Η ανάπτυξη ερμηνευτικών στρατηγικών στο μάθημα της νεοελληνικής λογοτεχνίας στη δευτεροβάθμια εκπαίδευση σε περιβάλλον συνεργατικής μάθησης\", " +
+                "\"hostedById\": \"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\", " +
+                "\"licenseCode\": \"CLOSED\", " +
+                "\"pids\": [{ " +
+                "\"value\": \"10.12681\\/eadd\\/29202\", " +
+                "\"type\": \"doi\" " +
+                "}], " +
+                "\"description\": null, " +
+                "\"originalId\": \"crossref____::cf7d85a13ac43f92431b102723d13d5a\", " +
+                "\"contexts\": [\"egi\", \"egi::country::gr\"], " +
+                "\"language\": null, " +
+                "\"linksToProjects\": [\"info:eu-repo\\/grantAgreement\\/EC\\/FP7\\/246686\\/EU\\/\\/OPENAIRE\", \"info:eu-repo\\/grantAgreement\\/EC\\/FP7\\/288611\\/EU\\/\\/ECODRIVER\"], " +
+                "\"url\": \"http:\\/\\/dx.doi.org\\/10.12681\\/eadd\\/29202\", " +
+                "\"resourceType\": \"0001\", " +
+                "\"publisher\": \"National Documentation Centre\"" +
+                "}";
+
+        // Send post request
+        con.setDoOutput(true);
+        /*DataOutputStream wr = new DataOutputStream(con.getOutputStream());
+        wr.writeBytes(urlParameters);
+        wr.flush();
+        wr.close();
+        */
+
+        DataOutputStream wr = new DataOutputStream(con.getOutputStream());
+        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(wr, "UTF-8"));
+        writer.write(urlParameters);
+        writer.close();
+        wr.close();
+
+
+        int responseCode = con.getResponseCode();
+        System.out.println(" Sending 'POST' request to URL : " + url);
+        System.out.println("Post parameters : " + urlParameters);
+        System.out.println("Response Code : " + responseCode);
+
+        BufferedReader in = new BufferedReader(
+                new InputStreamReader(con.getInputStream()));
+        String inputLine;
+        StringBuffer response = new StringBuffer();
+
+        while ((inputLine = in.readLine()) != null) {
+            response.append(inputLine);
+        }
+        in.close();
+
+        //print result
+        System.out.println(response.toString());
+    }
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/action/relation.vm
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(revision 47510)
@@ -0,0 +1,5 @@
+<RELATIONS>
+#foreach ($rel in $relations)
+    <RELATION type='$rel.Type' source='$rel.SourceId' target='$rel.TargetId' />
+#end
+</RELATIONS>
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(revision 47510)
@@ -0,0 +1,340 @@
+package eu.dnetlib.openaire.thrift;
+
+
+import eu.dnetlib.api.enabling.ISLookUpService;
+import eu.dnetlib.api.enabling.ISLookUpServiceException;
+import eu.dnetlib.openaire.action.ActionUtils;
+import gr.uoa.di.driver.enabling.ISLookUpException;
+import gr.uoa.di.driver.util.ServiceLocator;
+import org.apache.log4j.Logger;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.springframework.jdbc.datasource.DataSourceUtils;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+@Transactional
+public class ClaimConnector {
+
+	private static Logger logger = Logger.getLogger(ClaimConnector.class);
+
+	private DataSource datasource = null;
+
+	//Using an isLookUp Impl just to make an xQuery to IS. Maybe move all the
+	//functionality to commons?
+	private ServiceLocator<ISLookUpService> lookupServiceLocator = null;
+
+	public List<Claim> getClaimedPublications(final String user) throws SQLException {
+		Connection con = DataSourceUtils.getConnection(datasource);
+		PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"date\" , \"type\", \"xml\", \"id\" from claims where \"agent\" = ?");
+		stmt.setString(1, user);
+		ResultSet rs = stmt.executeQuery();
+		List<Claim> res = new ArrayList<Claim>();
+
+		while (rs.next()) {
+			res.add(new Claim(user, rs.getString(1), rs.getTimestamp(2).getTime(), rs.getString(3), rs.getString(4), rs.getString(5)));
+		}
+
+		rs.close();
+		stmt.close();
+
+        logger.info("Returning " + res.size() + " claimed publications for user "  + user);
+
+		return res;
+	}
+
+	public List<Claim> getClaimedPublications(Date from, Date to) throws SQLException {
+		Connection con = DataSourceUtils.getConnection(datasource);
+
+		PreparedStatement stmt = con.prepareStatement("select \"agent\", \"resultid\", \"date\" , \"type\", \"xml\",  \"id\"  from claims where \"agent\" != 'inference' and \"date\" >= ?::timestamp and \"date\" <= ?::timestamp ");
+		stmt.setTimestamp(1, new Timestamp(from.getTime()));
+        stmt.setTimestamp(2, new Timestamp(to.getTime()));
+
+		ResultSet rs = stmt.executeQuery();
+		List<Claim> res = new ArrayList<Claim>();
+
+		while (rs.next()) {
+			res.add(new Claim(rs.getString(1), rs.getString(2), rs.getTimestamp(3).getTime(), rs.getString(4), rs.getString(5), rs.getString(6)));
+		}
+
+		rs.close();
+		stmt.close();
+
+		logger.debug("number of claims: " + res.size());
+        logger.info("Returning " + res.size() + " claimed publications for date "  + from + "-" + to);
+
+		return res;
+	}
+
+	public void deleteClaim(String userEmail, String id) throws SQLException {
+        logger.info("Deleting claim with id " + id + " for agent " +  userEmail);
+
+		Connection con = DataSourceUtils.getConnection(datasource);
+        int claim_id = Integer.parseInt(id);
+        String type = null;
+
+		PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"type\" from claims where \"id\" =?");
+        stmt.setInt(1, claim_id);
+
+        ResultSet rs = stmt.executeQuery();
+        
+        String resultid = null;
+        String xml = null;
+
+        while (rs.next()) {
+            resultid = rs.getString("resultid");
+            type = rs.getString("type");
+        }
+
+        if (resultid != null) {
+            stmt = con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =?");
+            stmt.setString(1, userEmail);
+            stmt.setInt(2, claim_id);
+
+            stmt.executeUpdate();
+            logger.info("Deleted claim with claim id: " + claim_id + ", result id: " + resultid + " and type: " + type +".") ;
+
+            //prepare to get 2nd claim to be deleted
+            int claim2_id = claim_id - 1;
+
+            if (type != null && type.equals("rels2actions")) {
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+                rs = stmt.executeQuery();
+
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //check if the relation has dmf
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            } /*else if (type != null && type.equals("dmf2actions")) {
+                logger.info("dmf2actions");
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+
+                rs = stmt.executeQuery();
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                logger.info("xml: " + xml);
+                logger.info("xml? " + xml.contains("oaf:concept"));
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //delete concept with extra dmf (doi,orchid,... etc)
+                    logger.debug("dmf2actions and not concept");
+
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            }*/
+        }
+
+        stmt.close();
+        
+        logger.info("Deleted claim with id " + id + " for agent " +  userEmail);
+	}
+
+	/**
+	 * @param id     {openaireId, publication doi, ORCIDId (personId-ORCIDPublicationId), data doi}
+	 * @param source {openaire, doi (crossref), orcid, datacite}
+	 * @throws ResourceNotFoundException
+	 * @throws ParseErrorException
+	 * @throws Exception
+	 */
+	public String insertDocument(
+			String id,
+			String source,
+			String title,
+			String description,
+			String access_mode,
+			String embargoEndDate,
+			List<Author> authors,
+			String url,
+			String dcSource,
+			String userEmail,
+			List<String> subjects,
+			String publicationDate,
+			String publisher,
+			String language,
+			String category,
+			String doi) throws Exception {
+
+        logger.info("Request to insert document with id " + id + " and source " + source);
+		String resultId;
+
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String dmf;
+			resultId = ActionUtils.getIdentifier(ActionUtils.getPrefix(source), id);
+			Date now = new Date();
+
+			if (!source.toLowerCase().equals("openaire") && title != null) {
+				stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+				dmf = ActionUtils.createDMF(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, doi, Collections.EMPTY_LIST, subjects, Collections.EMPTY_LIST, publicationDate, publisher, language, category, false);
+
+				stmt.setString(1, userEmail);
+				stmt.setString(2, resultId);
+				stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+				stmt.setString(4, "dmf2actions");
+				stmt.setString(5, dmf);
+				stmt.setString(6, "userclaim_dmf");
+				stmt.setString(7, ActionUtils.getProvenance(source));
+				stmt.setString(8, ActionUtils.getPrefix(source));
+
+				stmt.executeUpdate();
+				stmt.close();
+			}
+		} catch (Exception e) {
+			logger.error("Error inserting document", e);
+			throw e;
+		}
+
+        logger.info("Inserted document with id " + id + ", source " + source + " and given resultId " + resultId);
+		return resultId;
+	}
+
+	public void insertConceptRelation(String documentId, String documentSource, String concept, String userEmail, String doi) throws Exception {
+        logger.info("Request for concept relation between document with id " + documentId + " with source " + documentSource + " and concept " + concept + "with doi " + doi);
+
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String dmf;
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+			dmf = ActionUtils.createDMF(documentId, documentSource, null, null, null, null, Collections.EMPTY_LIST, null, null, doi, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Arrays.asList(concept), null, null, null, null, true);
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, documentId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "updates2actions");
+			stmt.setString(5, dmf);
+			stmt.setString(6, "userclaim_dmf");
+			stmt.setString(7, ActionUtils.getProvenance(documentSource));
+			stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding concept", e);
+			throw e;
+		}
+
+        logger.info("Inserted concept relation between document with id " + documentId + " with source " + documentSource + " and concept " + concept);
+	}
+
+	public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws Exception {
+        logger.info("Request for project relation between document with id " + docId + " with source " + documentSource + " and project " + project);
+
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String xml = ActionUtils.createResultProjectRelation("openaire".equals(documentSource) ? null : documentSource, docId, project.getType(), project.getProjectId());
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, docId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "rels2actions");
+			stmt.setString(5, xml);
+			stmt.setString(6, "userclaim_result_project");
+			stmt.setString(7, ActionUtils.getProvenance(documentSource));
+			stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding project", e);
+			throw e;
+		}
+
+        logger.info("Inserted project relation between document with id " + docId + " with source " + documentSource + " and project " + project);
+	}
+
+	public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws Exception {
+        logger.info("Request for result relation between source document with id " + sourceResultId + ", type " + sourceResultType + "and source " + sourceResultSource + " and " +
+                "target document with id " + targetResultId + ", type " + targetResultType);
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String xml = ActionUtils.createResultResultRelation(sourceResultId, sourceResultType, targetResultId, targetResultType);
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, sourceResultId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "rels2actions");
+			stmt.setString(5, xml);
+			stmt.setString(6, "userclaim_result_result");
+			stmt.setString(7, ActionUtils.getProvenance(sourceResultSource));
+			stmt.setString(8, ActionUtils.getPrefix(sourceResultSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding result relation", e);
+			throw e;
+		}
+
+        logger.info("Inserted result relation between source document with id " + sourceResultId + ", type " + sourceResultType + "and source " + sourceResultSource + " and " +
+                "target document with id " + targetResultId + ", type " + targetResultType);
+	}
+
+	public DataSource getDatasource() {
+		return datasource;
+	}
+
+	public void setDatasource(DataSource datasource) {
+		this.datasource = datasource;
+	}
+
+	public ServiceLocator<ISLookUpService> getLookupServiceLocator() {
+		return lookupServiceLocator;
+	}
+
+	public void setLookupServiceLocator(
+			ServiceLocator<ISLookUpService> lookupServiceLocator) {
+		this.lookupServiceLocator = lookupServiceLocator;
+	}
+
+	public List<String> getContexts() throws ISLookUpException, ISLookUpServiceException {
+		return lookupServiceLocator.getService().quickSearchProfile("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') return $x");
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/action/Relation.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/action/Relation.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/action/Relation.java	(revision 47510)
@@ -0,0 +1,39 @@
+package eu.dnetlib.openaire.action;
+
+public class Relation {
+	private String type;
+	private String sourceId;
+	private String targetId;
+
+	public Relation(String type, String sourceId, String targetId) {
+		super();
+		this.type = type;
+		this.sourceId = sourceId;
+		this.targetId = targetId;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getSourceId() {
+		return sourceId;
+	}
+
+	public void setSourceId(String sourceId) {
+		this.sourceId = sourceId;
+	}
+
+	public String getTargetId() {
+		return targetId;
+	}
+
+	public void setTargetId(String targetId) {
+		this.targetId = targetId;
+	}
+
+}
\ No newline at end of file
Index: modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml
===================================================================
--- modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(revision 47510)
@@ -0,0 +1,57 @@
+<?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:tx="http://www.springframework.org/schema/tx"
+
+        xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/tx
+        http://www.springframework.org/schema/tx/spring-tx.xsd">
+		
+	<bean id="openaire.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+		<property name="driverClassName" value="${openaire.db.driverClassName}" />
+		<property name="url" value="${openaire.db.url}" />
+		<property name="username" value="${openaire.db.username}" />
+		<property name="password" value="${openaire.db.password}" />
+		<property name="maxIdle" value="10" />
+		<property name="maxActive" value="100" />
+		<property name="maxWait" value="10000" />
+		<property name="validationQuery" value="SELECT 1;" />
+		<property name="testOnBorrow" value="true" />
+		<property name="testOnReturn" value="true" />
+		<property name="testWhileIdle" value="true" />
+		<property name="timeBetweenEvictionRunsMillis" value="1200000" />
+		<property name="minEvictableIdleTimeMillis" value="1800000" />
+		<property name="numTestsPerEvictionRun" value="5" />
+		<property name="poolPreparedStatements" value="true" />
+		<property name="defaultAutoCommit" value="true" />
+	</bean>
+
+	<bean id="claimConnector" class="eu.dnetlib.openaire.thrift.ClaimConnector">
+		<property name="datasource" ref="openaire.dataSource" />
+		<property name="lookupServiceLocator" ref="lookupServiceLocator"/>
+		<property name="directClaimAPIUrl" value="${openaire.connector.api.directClaimAPIUrl}"/>
+	</bean>
+	
+	<bean id="alertConnector" class="eu.dnetlib.openaire.thrift.AlertConnector">
+		<property name="alertServiceLocator" ref="alertServiceLocator" />
+	</bean>
+	
+	<bean id="openAireConnector" class="eu.dnetlib.openaire.thrift.OpenAIREConnectorImpl">
+		<property name="claimConnector" ref="claimConnector" />
+		<property name="alertConnector" ref="alertConnector" />
+	</bean>
+	
+	<bean id="thriftServer" class="eu.dnetlib.openaire.thrift.ThriftServer" init-method="start" destroy-method="stop">
+		<property name="openAireConnector" ref="openAireConnector" />
+		<property name="port" value="${openaire.connector.thrift.port}"/>
+		<property name="timeout" value="${openaire.connector.thrift.timeout}" />
+	</bean>
+
+    <tx:annotation-driven transaction-manager="txManager"/>
+    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="openaire.dataSource"/>
+    </bean>
+
+</beans>
+
Index: modules/uoa-claims-api/trunk/src/main/resources/ehcache.xml
===================================================================
--- modules/uoa-claims-api/trunk/src/main/resources/ehcache.xml	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/resources/ehcache.xml	(revision 47510)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
+    <!--
+     | Please see http://ehcache.sourceforge.net/documentation/configuration.html for
+     | detailed information on how to configurigure caches in this file
+     +-->
+    <!-- Location of persistent caches on disk -->
+    <diskStore path="java.io.tmpdir/EhCacheSpringAnnotationsExampleApp" />
+
+    <defaultCache eternal="true" maxElementsInMemory="10000"
+        overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
+        timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU"/>
+
+	<cache name="claimator"/>
+	<cache name="alertator.subscriptions"/>
+	<cache name="querynator"/>
+</ehcache>
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(revision 47510)
@@ -0,0 +1,9 @@
+openaire.connector.thrift.port = 7911
+openaire.connector.thrift.timeout = 15000
+
+openaire.connector.unknownRepositoryName = Unknown Repository
+
+openaire.db.driverClassName = org.postgresql.Driver
+openaire.db.url = jdbc:postgresql://194.177.192.223:5432/dnet_claims
+openaire.db.username = dnet
+openaire.db.password = dnetPwd
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(revision 47510)
@@ -0,0 +1,25 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+
+public class ThriftClient {
+
+	public OpenAIREConnector.Client getConnector() throws TTransportException {
+		return getConnector("localhost", 7911);
+	}
+
+	public OpenAIREConnector.Client getConnector(String host, int port) throws TTransportException {
+		TTransport transport = new TSocket(host, port);
+		transport.open();
+
+		TProtocol protocol = new  TBinaryProtocol(transport);
+		
+		return new OpenAIREConnector.Client(protocol);
+	}
+}
Index: modules/uoa-claims-api/branches/indexFeed/src/main/resources/ehcache.xml
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/resources/ehcache.xml	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/resources/ehcache.xml	(revision 47510)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
+    <!--
+     | Please see http://ehcache.sourceforge.net/documentation/configuration.html for
+     | detailed information on how to configurigure caches in this file
+     +-->
+    <!-- Location of persistent caches on disk -->
+    <diskStore path="java.io.tmpdir/EhCacheSpringAnnotationsExampleApp" />
+
+    <defaultCache eternal="true" maxElementsInMemory="10000"
+        overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
+        timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU"/>
+
+	<cache name="claimator"/>
+	<cache name="alertator.subscriptions"/>
+	<cache name="querynator"/>
+</ehcache>
\ No newline at end of file
Index: modules/uoa-claims-api/branches/indexFeed/src/main/thrift/OpenAIREConnector.thrift
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/main/thrift/OpenAIREConnector.thrift	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/main/thrift/OpenAIREConnector.thrift	(revision 47510)
@@ -0,0 +1,132 @@
+namespace java eu.dnetlib.openaire.thrift
+
+struct Author {
+	1: string id,
+	2: string lastName,
+	3: string firstName
+}
+
+// alerts
+struct AlertSubscription {
+	1: string templateId,
+	2: string notificationService,
+	3: string queryId,
+	4: string resultId,
+	5: string alertMode,
+	6: string subscriber
+}
+
+struct ResultPage {
+	1: i32 limit,
+	2: i32 offset,
+	3: list<string> columns,
+	4: list<list<string>> rows
+}
+
+struct Claim {
+    1: string userEmail,
+	2: string resultid,
+	3: i64 date,
+	4: string type,
+	5: string xml,
+	6: string id
+}
+
+struct Project {
+    1: string type,
+    2: string projectId
+}
+
+struct Project4Index {
+    1: string projectid,
+    2: string funder,
+    3: string fundingStreamLevel0,
+    4: string fundingStreamLevel1,
+    5: string fundingStreamLevel2,
+    6: string name,
+    7: string code,
+    8: string acronym,
+    9: string type
+}
+
+// connector
+service OpenAIREConnector {
+	// claim
+	list<Claim> getClaimedPublications(1: string userEmail),
+
+	// from: date in milisecs
+	// to: ditto
+	list<Claim> getAllClaimedPublications(1: i64 from, 2: i64 to),
+	
+	string insertDocument (
+			1: string originalId,
+			2: string source, 
+			3: string title, 
+			4: string description, 
+			5: string access_mode, 
+			6: string embargoEndDate, 
+			7: list<Author> authors, 
+			8: string url,
+			9: string dcSource,
+			10: string userEmail,
+			11: list<string> subjects,
+			12: string publicationDate,
+			13: string publisher,
+			14: string language,
+			15: string category,
+			16: string doi,
+			17: list<Project4Index> projects,
+			18: list<string> concepts),
+
+    void insertConcept (
+        1: string docId,
+        2: string documentSource,
+        3: string concept,
+        4: string userEmail,
+        5: string doi),
+
+    void insertProjectRelation (
+        1: string docId,
+        2: string documentSource,
+        3: Project project,
+        4: string userEmail),
+
+    void insertResultRelation (
+        1: string sourceResultId,
+        2: string sourceResultType,
+        3: string sourceResultSource,
+        4: string targetResultId,
+        5: string targetResultType,
+        6: string userEmail
+    ),
+
+	void deleteClaim(1: string userEmail, 2:string resultId),
+
+	// alerts
+	list<AlertSubscription> getSubscriptions(
+			1: string alertMode, 
+			2: string subscriber, 
+			3: i32 limit, 
+			4: i32 offset),
+			
+	void addSubscription(1: AlertSubscription subscription),
+	
+	void removeSubscription(1: AlertSubscription subscription),
+	
+	i32 countAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: i64 date, 
+			5: string resultId),
+			
+	ResultPage getAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: string resultId, 
+			4: i64 fromDate, 
+			5: i64 toDate, 
+			6: i32 limit, 
+			7: i32 offset),
+	
+	list<string> getContexts(),
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/indexFeed/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(revision 47510)
@@ -0,0 +1,25 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+
+public class ThriftClient {
+
+	public OpenAIREConnector.Client getConnector() throws TTransportException {
+		return getConnector("localhost", 7911);
+	}
+
+	public OpenAIREConnector.Client getConnector(String host, int port) throws TTransportException {
+		TTransport transport = new TSocket(host, port);
+		transport.open();
+
+		TProtocol protocol = new  TBinaryProtocol(transport);
+		
+		return new OpenAIREConnector.Client(protocol);
+	}
+}
Index: modules/uoa-claims-api/branches/indexFeed/src
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/src	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/src	(revision 47510)

Property changes on: modules/uoa-claims-api/branches/indexFeed/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+
Index: modules/uoa-claims-api/branches/indexFeed/deploy.info
===================================================================
--- modules/uoa-claims-api/branches/indexFeed/deploy.info	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed/deploy.info	(revision 47510)
@@ -0,0 +1,10 @@
+{
+  "type_source": "SVN", 
+  "goal": "package -U -T 4C source:jar", 
+  "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk", 
+  "deploy_repository": "dnet4-snapshots", 
+  "version": "4", 
+  "mail": "antleb@di.uoa.gr, kiatrop@di.uoa.gr", 
+  "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", 
+  "name": "uoa-openaire-connector"
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/indexFeed
===================================================================
--- modules/uoa-claims-api/branches/indexFeed	(nonexistent)
+++ modules/uoa-claims-api/branches/indexFeed	(revision 47510)

Property changes on: modules/uoa-claims-api/branches/indexFeed
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+.project
+.settings
+.idea
+*.iml
+target
Index: modules/uoa-claims-api/branches/newClaimSchema/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(revision 47510)
@@ -0,0 +1,31 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.TException;
+
+import java.util.Arrays;
+
+/**
+ * Created by antleb on 6/20/14.
+ */
+public class TestConnector {
+
+	public static void main(String[] args) throws TException {
+
+		OpenAIREConnector.Client client = new ThriftClient().getConnector("194.177.192.223", 7911);
+
+		String id = client.insertDocument("123123/3434.23", "doi", "a title", " a description", "OPEN ACCESS", null, Arrays.asList(new Author("id" ,"lastname", "firstname")), "url", "dcsource", "antleb@di.uoa.gr", Arrays.asList("subject"), "2012-01-02", "publisher", "language", "category", "doioioioi" );
+		System.out.println(id);
+
+		client.insertConcept(id, "doi", "egi", "antleb@di.uoa.gr", "123");
+		client.insertProjectRelation(id, "doi", new Project("ec", "1233312"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "doi", new Project(null, "1233312"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "doi", id, "result", "antleb@di.uoa.gr");
+
+		id = "od______1406::fbda7b28cda277b04c8dc27a5e0deb68";
+
+		client.insertConcept(id, "openaire", "ec", "antleb@di.uoa.gr", "123");
+		client.insertProjectRelation(id, "openaire", new Project("ec", "099809987"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "openaire", new Project(null, "098908908"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "openaire", id, "dataset", "antleb@di.uoa.gr");
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/ehcache.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/ehcache.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/ehcache.xml	(revision 47510)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
+    <!--
+     | Please see http://ehcache.sourceforge.net/documentation/configuration.html for
+     | detailed information on how to configurigure caches in this file
+     +-->
+    <!-- Location of persistent caches on disk -->
+    <diskStore path="java.io.tmpdir/EhCacheSpringAnnotationsExampleApp" />
+
+    <defaultCache eternal="true" maxElementsInMemory="10000"
+        overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
+        timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU"/>
+
+	<cache name="claimator"/>
+	<cache name="alertator.subscriptions"/>
+	<cache name="querynator"/>
+</ehcache>
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/pom.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/pom.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/pom.xml	(revision 47510)
@@ -0,0 +1,143 @@
+<?xml version="1.0"?>
+<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>uoa-openaire-connector</artifactId>
+	<version>1.2.0</version>
+        <scm>
+                <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/tags/uoa-openaire-connector-1.2.0</developerConnection>
+        </scm>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>dtrotts</id>
+			<name>Repository for maven thrift plugin</name>
+			<url>http://maven.davidtrott.com/repository</url>
+			<layout>default</layout>
+		</pluginRepository>
+	</pluginRepositories>
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<archive>
+
+					</archive>
+					<descriptorRefs>
+						<descriptorRef>jar-with-dependencies</descriptorRef>
+					</descriptorRefs>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.thrift.tools</groupId>
+				<artifactId>maven-thrift-plugin</artifactId>
+				<version>0.1.10</version>
+				<executions>
+					<execution>
+						<id>thrift-sources</id>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>compile</goal>
+						</goals>
+					</execution>
+					<execution>
+						<id>thrift-test-sources</id>
+						<phase>generate-test-sources</phase>
+						<goals>
+							<goal>testCompile</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings 
+					only. It has no influence on the Maven build itself. -->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>org.apache.thrift.tools</groupId>
+										<artifactId>maven-thrift-plugin</artifactId>
+										<versionRange>[0.1.10,)</versionRange>
+										<goals>
+											<goal>testCompile</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore />
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>[0.0.0,)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.7.5</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-dbcp</groupId>
+			<artifactId>commons-dbcp</artifactId>
+			<version>[1.2, 1.3)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-utils</artifactId>
+			<version>[1.1.0, 1.2.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-commons</artifactId>
+			<version>[1.1.0, 1.2.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.thrift</groupId>
+			<artifactId>libthrift</artifactId>
+			<version>0.8.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.postgresql</groupId>
+			<artifactId>jdbc4driver</artifactId>
+			<version>9.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.velocity</groupId>
+			<artifactId>velocity</artifactId>
+			<version>1.7</version>
+		</dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/action/Relation.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/action/Relation.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/action/Relation.java	(revision 47510)
@@ -0,0 +1,39 @@
+package eu.dnetlib.openaire.action;
+
+public class Relation {
+	private String type;
+	private String sourceId;
+	private String targetId;
+
+	public Relation(String type, String sourceId, String targetId) {
+		super();
+		this.type = type;
+		this.sourceId = sourceId;
+		this.targetId = targetId;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getSourceId() {
+		return sourceId;
+	}
+
+	public void setSourceId(String sourceId) {
+		this.sourceId = sourceId;
+	}
+
+	public String getTargetId() {
+		return targetId;
+	}
+
+	public void setTargetId(String targetId) {
+		this.targetId = targetId;
+	}
+
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/thrift/OpenAIREConnector.thrift
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/main/thrift/OpenAIREConnector.thrift	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/main/thrift/OpenAIREConnector.thrift	(revision 47510)
@@ -0,0 +1,118 @@
+namespace java eu.dnetlib.openaire.thrift
+
+struct Author {
+	1: string id,
+	2: string lastName,
+	3: string firstName
+}
+
+// alerts
+struct AlertSubscription {
+	1: string templateId,
+	2: string notificationService,
+	3: string queryId,
+	4: string resultId,
+	5: string alertMode,
+	6: string subscriber
+}
+
+struct ResultPage {
+	1: i32 limit,
+	2: i32 offset,
+	3: list<string> columns,
+	4: list<list<string>> rows
+}
+
+struct Claim {
+    1: string userEmail,
+	2: string resultid,
+	3: i64 date,
+	4: string type,
+	5: string xml,
+	6: string id
+}
+
+struct Project {
+    1: string type,
+    2: string projectId
+}
+
+// connector
+service OpenAIREConnector {
+	// claim
+	list<Claim> getClaimedPublications(1: string userEmail),
+
+	// from: date in milisecs
+	// to: ditto
+	list<Claim> getAllClaimedPublications(1: i64 from, 2: i64 to),
+	
+	string insertDocument (
+			1: string originalId,
+			2: string source, 
+			3: string title, 
+			4: string description, 
+			5: string access_mode, 
+			6: string embargoEndDate, 
+			7: list<Author> authors, 
+			8: string url,
+			9: string dcSource,
+			10: string userEmail,
+			11: list<string> subjects,
+			12: string publicationDate,
+			13: string publisher,
+			14: string language,
+			15: string category,
+			16: string doi),
+
+    void insertConcept (
+        1: string docId,
+        2: string documentSource,
+        3: string concept,
+        4: string userEmail,
+        5: string doi),
+
+    void insertProjectRelation (
+        1: string docId,
+        2: string documentSource,
+        3: Project project,
+        4: string userEmail),
+
+    void insertResultRelation (
+        1: string sourceResultId,
+        2: string sourceResultType,
+        3: string sourceResultSource,
+        4: string targetResultId,
+        5: string targetResultType,
+        6: string userEmail
+    ),
+
+	void deleteClaim(1: string userEmail, 2:string resultId),
+
+	// alerts
+	list<AlertSubscription> getSubscriptions(
+			1: string alertMode, 
+			2: string subscriber, 
+			3: i32 limit, 
+			4: i32 offset),
+			
+	void addSubscription(1: AlertSubscription subscription),
+	
+	void removeSubscription(1: AlertSubscription subscription),
+	
+	i32 countAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: i64 date, 
+			5: string resultId),
+			
+	ResultPage getAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: string resultId, 
+			4: i64 fromDate, 
+			5: i64 toDate, 
+			6: i32 limit, 
+			7: i32 offset),
+	
+	list<string> getContexts(),
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(revision 47510)
@@ -0,0 +1,84 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertService;
+import eu.dnetlib.api.functionality.AlertServiceException;
+import gr.uoa.di.driver.util.ServiceLocator;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+public class AlertConnector {
+	private ServiceLocator<AlertService> alertServiceLocator;
+
+	public void setAlertServiceLocator(
+			final ServiceLocator<AlertService> alertServiceLocator) {
+		this.alertServiceLocator = alertServiceLocator;
+	}
+
+	public List<AlertSubscription> getSubscriptions(final String alertMode,
+			final String subscriber, final int limit, final int offset)
+			throws AlertServiceException {
+		final List<AlertSubscription> subscriptions = new ArrayList<AlertSubscription>();
+		for (eu.dnetlib.domain.functionality.AlertSubscription subscription : alertServiceLocator
+				.getService().getSubscriptions(alertMode, subscriber, limit,
+						offset))
+			subscriptions.add(new AlertSubscription(subscription
+					.getTemplateId(), subscription.getNotificationService()
+					.toString(), subscription.getQueryId(), subscription
+					.getResultId(), subscription.getAlertMode(), subscription
+					.getSubscriber().toString()));
+		return subscriptions;
+	}
+
+	public void addSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().addSubscription(
+				new eu.dnetlib.domain.functionality.AlertSubscription(
+						subscription.getTemplateId(), new URL(subscription
+								.getNotificationService()), subscription
+								.getQueryId(), subscription.getResultId(),
+						subscription.getAlertMode(), new URI(subscription
+								.getSubscriber()), true));
+	}
+
+	public void removeSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().removeSubscription(
+				subscription.getTemplateId(),
+				new URL(subscription.getNotificationService()),
+				subscription.getQueryId(), subscription.getResultId(),
+				subscription.getAlertMode(),
+				new URI(subscription.getSubscriber()));
+	}
+
+	public int countAlertResults(final String notificationService,
+			final String queryId, final long date, final String resultId)
+			throws AlertServiceException, MalformedURLException {
+		return alertServiceLocator.getService()
+				.countAlertResults(new URL(notificationService), queryId,
+						new Date(date), resultId);
+	}
+
+	public ResultPage getAlertResults(final String notificationService,
+			final String queryId, final String resultId, final long fromDate,
+			final long toDate, final int limit, final int offset)
+			throws AlertServiceException, MalformedURLException {
+		final eu.dnetlib.domain.functionality.ResultPage resultPage = alertServiceLocator
+				.getService().getAlertResults(new URL(notificationService),
+						queryId, resultId, new Date(fromDate),
+						new Date(toDate), limit, offset);
+		final List<List<String>> rows = new ArrayList<List<String>>();
+		for (String[] row : resultPage.getRows())
+			rows.add(Arrays.asList(row));
+		return new ResultPage(resultPage.getLimit(), resultPage.getOffset(),
+				Arrays.asList(resultPage.getColumns()), rows);
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(revision 47510)
@@ -0,0 +1,186 @@
+package eu.dnetlib.openaire.thrift;
+
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+
+import eu.dnetlib.api.functionality.AlertServiceException;
+
+public class OpenAIREConnectorImpl implements OpenAIREConnector.Iface {
+	private static final Logger logger = Logger.getLogger(OpenAIREConnectorImpl.class);
+
+	private ClaimConnector claimConnector;
+	private AlertConnector alertConnector;
+
+	public void setClaimConnector(final ClaimConnector claimConnector) {
+		this.claimConnector = claimConnector;
+	}
+
+	public void setAlertConnector(final AlertConnector alertConnector) {
+		this.alertConnector = alertConnector;
+	}
+
+	@Override
+	public List<Claim> getClaimedPublications(final String user) throws TException {
+		try {
+			return claimConnector.getClaimedPublications(user);
+		} catch (final Exception e) {
+			logger.error("Error retrieving claimed publications (user: " + user + ")", e);
+			throw new TException("Error retrieving claimed publications (user: " + user + ")", e);
+		}
+	}
+
+    @Override
+    public List<Claim> getAllClaimedPublications(long from, long to) throws TException {
+        try {
+            return claimConnector.getClaimedPublications(new Date(from), new Date(to));
+        } catch (Exception e) {
+            logger.error("Error retrieving claimed publications", e);
+
+            throw new TException("Error retrieving claimed publications", e);
+        }
+    }
+
+    @Override
+    public String insertDocument(String originalId, String source, String title, String description, String access_mode, String embargoEndDate, List<Author> authors, String url, String dcSource, String userEmail, List<String> subjects, String publicationDate, String publisher, String language, String category, String doi) throws org.apache.thrift.TException {
+        try {
+            return claimConnector.insertDocument(originalId, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, userEmail, subjects, publicationDate, publisher, language, category, doi);
+        } catch (Exception e) {
+            logger.error("Error adding document", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertConcept(String docId, String documentSource, String concept, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertConceptRelation(docId, documentSource, concept, userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding concept relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertProjectRelation(docId, documentSource, project, userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding project relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws TException {
+        try {
+            claimConnector.insertResultRelation(sourceResultId, sourceResultType, sourceResultSource, targetResultId, targetResultType,userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding result relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+	public List<AlertSubscription> getSubscriptions(final String alertMode, final String subscriber, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getSubscriptions(alertMode, subscriber, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+	@Override
+	public void addSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.addSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		}
+	}
+
+	@Override
+	public void removeSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.removeSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		}
+	}
+
+	@Override
+	public int countAlertResults(final String notificationService, final String queryId, final long date, final String resultId) throws TException {
+		try {
+			return alertConnector.countAlertResults(notificationService, queryId, date, resultId);
+		} catch (final AlertServiceException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		}
+	}
+
+	@Override
+	public ResultPage getAlertResults(final String notificationService, final String queryId, final String resultId, final long fromDate, final long toDate, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getAlertResults(notificationService, queryId, resultId, fromDate, toDate, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+    @Override
+    public void deleteClaim(String userEmail, String resultId) throws TException {
+        try {
+            claimConnector.deleteClaim(userEmail, resultId);
+        } catch (Exception e) {
+            logger.error("Error deleting claim", e);
+
+            throw new TException(e);
+        }
+    }
+
+	@Override
+	public List<String> getContexts() throws TException {
+		try {
+			return claimConnector.getContexts();
+		} catch (Exception e) {
+			logger.error("Error getting contexts from IS.", e);
+			
+			throw new TException(e);
+		}
+		
+	}
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/action/Relation.java
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/action/Relation.java	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/main/java/eu/dnetlib/openaire/action/Relation.java	(revision 47510)
@@ -0,0 +1,39 @@
+package eu.dnetlib.openaire.action;
+
+public class Relation {
+	private String type;
+	private String sourceId;
+	private String targetId;
+
+	public Relation(String type, String sourceId, String targetId) {
+		super();
+		this.type = type;
+		this.sourceId = sourceId;
+		this.targetId = targetId;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getSourceId() {
+		return sourceId;
+	}
+
+	public void setSourceId(String sourceId) {
+		this.sourceId = sourceId;
+	}
+
+	public String getTargetId() {
+		return targetId;
+	}
+
+	public void setTargetId(String targetId) {
+		this.targetId = targetId;
+	}
+
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(revision 47510)
@@ -0,0 +1,57 @@
+<?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:tx="http://www.springframework.org/schema/tx"
+
+        xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/tx
+        http://www.springframework.org/schema/tx/spring-tx.xsd">
+		
+	<bean id="openaire.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+		<property name="driverClassName" value="${openaire.db.driverClassName}" />
+		<property name="url" value="${openaire.db.url}" />
+		<property name="username" value="${openaire.db.username}" />
+		<property name="password" value="${openaire.db.password}" />
+		<property name="maxIdle" value="10" />
+		<property name="maxActive" value="100" />
+		<property name="maxWait" value="10000" />
+		<property name="validationQuery" value="SELECT 1;" />
+		<property name="testOnBorrow" value="true" />
+		<property name="testOnReturn" value="true" />
+		<property name="testWhileIdle" value="true" />
+		<property name="timeBetweenEvictionRunsMillis" value="1200000" />
+		<property name="minEvictableIdleTimeMillis" value="1800000" />
+		<property name="numTestsPerEvictionRun" value="5" />
+		<property name="poolPreparedStatements" value="true" />
+		<property name="defaultAutoCommit" value="true" />
+	</bean>
+
+	<bean id="claimConnector" class="eu.dnetlib.openaire.thrift.ClaimConnector">
+		<property name="datasource" ref="openaire.dataSource" />
+		<property name="lookupServiceLocator" ref="lookupServiceLocator"/>
+	</bean>
+	
+	<bean id="alertConnector" class="eu.dnetlib.openaire.thrift.AlertConnector">
+		<property name="alertServiceLocator" ref="alertServiceLocator" />
+	</bean>
+	
+	<bean id="openAireConnector" class="eu.dnetlib.openaire.thrift.OpenAIREConnectorImpl">
+		<property name="claimConnector" ref="claimConnector" />
+		<property name="alertConnector" ref="alertConnector" />
+	</bean>
+	
+	<bean id="thriftServer" class="eu.dnetlib.openaire.thrift.ThriftServer" init-method="start" destroy-method="stop">
+		<property name="openAireConnector" ref="openAireConnector" />
+		<property name="port" value="${openaire.connector.thrift.port}"/>
+		<property name="timeout" value="${openaire.connector.thrift.timeout}" />
+	</bean>
+
+    <tx:annotation-driven transaction-manager="txManager"/>
+    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="openaire.dataSource"/>
+    </bean>
+
+
+</beans>
+
Index: modules/uoa-claims-api/branches/newClaimSchema/src
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/src	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/src	(revision 47510)

Property changes on: modules/uoa-claims-api/branches/newClaimSchema/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+
Index: modules/uoa-claims-api/branches/newClaimSchema/deploy.info
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema/deploy.info	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema/deploy.info	(revision 47510)
@@ -0,0 +1,10 @@
+{
+  "type_source": "SVN", 
+  "goal": "package -U -T 4C source:jar", 
+  "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk", 
+  "deploy_repository": "dnet4-snapshots", 
+  "version": "4", 
+  "mail": "antleb@di.uoa.gr, kiatrop@di.uoa.gr", 
+  "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", 
+  "name": "uoa-openaire-connector"
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/newClaimSchema
===================================================================
--- modules/uoa-claims-api/branches/newClaimSchema	(nonexistent)
+++ modules/uoa-claims-api/branches/newClaimSchema	(revision 47510)

Property changes on: modules/uoa-claims-api/branches/newClaimSchema
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+.project
+.settings
+.idea
+*.iml
+target
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/action/relation.vm
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(revision 47510)
@@ -0,0 +1,5 @@
+<RELATIONS>
+#foreach ($rel in $relations)
+    <RELATION type='$rel.Type' source='$rel.SourceId' target='$rel.TargetId' />
+#end
+</RELATIONS>
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(revision 47510)
@@ -0,0 +1,43 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TTransportException;
+
+public class ThriftServer {
+	private OpenAIREConnector.Iface openAireConnector;
+	private int port;
+	private int timeout;
+	private Thread thread;
+
+	public void setOpenAireConnector(final OpenAIREConnector.Iface openAireConnector) {
+		this.openAireConnector = openAireConnector;
+	}
+	
+	public void setPort(final int port) {
+		this.port = port;
+	}
+	
+	public void setTimeout(final int timeout) {
+		this.timeout = timeout;
+	}
+	
+	public void start() {
+		thread = new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					new TThreadPoolServer(new TThreadPoolServer.Args(new TServerSocket(port, timeout)).processor(new OpenAIREConnector.Processor<OpenAIREConnector.Iface>(openAireConnector))).serve();
+				} catch (final TTransportException e) {
+					Logger.getLogger(ThriftServer.class).error("Error starting thrift server", e);
+				}
+			}
+		});
+		thread.start();
+	}
+	
+	public void stop() {
+		thread.interrupt();
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(revision 47510)
@@ -0,0 +1,9 @@
+openaire.connector.thrift.port = 7911
+openaire.connector.thrift.timeout = 15000
+
+openaire.connector.unknownRepositoryName = Unknown Repository
+
+openaire.db.driverClassName = org.postgresql.Driver
+openaire.db.url = jdbc:postgresql://194.177.192.223:5432/dnet_claims
+openaire.db.username = dnet
+openaire.db.password = dnetPwd
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(revision 47510)
@@ -0,0 +1,84 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertService;
+import eu.dnetlib.api.functionality.AlertServiceException;
+import gr.uoa.di.driver.util.ServiceLocator;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+public class AlertConnector {
+	private ServiceLocator<AlertService> alertServiceLocator;
+
+	public void setAlertServiceLocator(
+			final ServiceLocator<AlertService> alertServiceLocator) {
+		this.alertServiceLocator = alertServiceLocator;
+	}
+
+	public List<AlertSubscription> getSubscriptions(final String alertMode,
+			final String subscriber, final int limit, final int offset)
+			throws AlertServiceException {
+		final List<AlertSubscription> subscriptions = new ArrayList<AlertSubscription>();
+		for (eu.dnetlib.domain.functionality.AlertSubscription subscription : alertServiceLocator
+				.getService().getSubscriptions(alertMode, subscriber, limit,
+						offset))
+			subscriptions.add(new AlertSubscription(subscription
+					.getTemplateId(), subscription.getNotificationService()
+					.toString(), subscription.getQueryId(), subscription
+					.getResultId(), subscription.getAlertMode(), subscription
+					.getSubscriber().toString()));
+		return subscriptions;
+	}
+
+	public void addSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().addSubscription(
+				new eu.dnetlib.domain.functionality.AlertSubscription(
+						subscription.getTemplateId(), new URL(subscription
+								.getNotificationService()), subscription
+								.getQueryId(), subscription.getResultId(),
+						subscription.getAlertMode(), new URI(subscription
+								.getSubscriber()), true));
+	}
+
+	public void removeSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().removeSubscription(
+				subscription.getTemplateId(),
+				new URL(subscription.getNotificationService()),
+				subscription.getQueryId(), subscription.getResultId(),
+				subscription.getAlertMode(),
+				new URI(subscription.getSubscriber()));
+	}
+
+	public int countAlertResults(final String notificationService,
+			final String queryId, final long date, final String resultId)
+			throws AlertServiceException, MalformedURLException {
+		return alertServiceLocator.getService()
+				.countAlertResults(new URL(notificationService), queryId,
+						new Date(date), resultId);
+	}
+
+	public ResultPage getAlertResults(final String notificationService,
+			final String queryId, final String resultId, final long fromDate,
+			final long toDate, final int limit, final int offset)
+			throws AlertServiceException, MalformedURLException {
+		final eu.dnetlib.domain.functionality.ResultPage resultPage = alertServiceLocator
+				.getService().getAlertResults(new URL(notificationService),
+						queryId, resultId, new Date(fromDate),
+						new Date(toDate), limit, offset);
+		final List<List<String>> rows = new ArrayList<List<String>>();
+		for (String[] row : resultPage.getRows())
+			rows.add(Arrays.asList(row));
+		return new ResultPage(resultPage.getLimit(), resultPage.getOffset(),
+				Arrays.asList(resultPage.getColumns()), rows);
+	}
+}
Index: modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(revision 47510)
@@ -0,0 +1,84 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertService;
+import eu.dnetlib.api.functionality.AlertServiceException;
+import gr.uoa.di.driver.util.ServiceLocator;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+public class AlertConnector {
+	private ServiceLocator<AlertService> alertServiceLocator;
+
+	public void setAlertServiceLocator(
+			final ServiceLocator<AlertService> alertServiceLocator) {
+		this.alertServiceLocator = alertServiceLocator;
+	}
+
+	public List<AlertSubscription> getSubscriptions(final String alertMode,
+			final String subscriber, final int limit, final int offset)
+			throws AlertServiceException {
+		final List<AlertSubscription> subscriptions = new ArrayList<AlertSubscription>();
+		for (eu.dnetlib.domain.functionality.AlertSubscription subscription : alertServiceLocator
+				.getService().getSubscriptions(alertMode, subscriber, limit,
+						offset))
+			subscriptions.add(new AlertSubscription(subscription
+					.getTemplateId(), subscription.getNotificationService()
+					.toString(), subscription.getQueryId(), subscription
+					.getResultId(), subscription.getAlertMode(), subscription
+					.getSubscriber().toString()));
+		return subscriptions;
+	}
+
+	public void addSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().addSubscription(
+				new eu.dnetlib.domain.functionality.AlertSubscription(
+						subscription.getTemplateId(), new URL(subscription
+								.getNotificationService()), subscription
+								.getQueryId(), subscription.getResultId(),
+						subscription.getAlertMode(), new URI(subscription
+								.getSubscriber()), true));
+	}
+
+	public void removeSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().removeSubscription(
+				subscription.getTemplateId(),
+				new URL(subscription.getNotificationService()),
+				subscription.getQueryId(), subscription.getResultId(),
+				subscription.getAlertMode(),
+				new URI(subscription.getSubscriber()));
+	}
+
+	public int countAlertResults(final String notificationService,
+			final String queryId, final long date, final String resultId)
+			throws AlertServiceException, MalformedURLException {
+		return alertServiceLocator.getService()
+				.countAlertResults(new URL(notificationService), queryId,
+						new Date(date), resultId);
+	}
+
+	public ResultPage getAlertResults(final String notificationService,
+			final String queryId, final String resultId, final long fromDate,
+			final long toDate, final int limit, final int offset)
+			throws AlertServiceException, MalformedURLException {
+		final eu.dnetlib.domain.functionality.ResultPage resultPage = alertServiceLocator
+				.getService().getAlertResults(new URL(notificationService),
+						queryId, resultId, new Date(fromDate),
+						new Date(toDate), limit, offset);
+		final List<List<String>> rows = new ArrayList<List<String>>();
+		for (String[] row : resultPage.getRows())
+			rows.add(Arrays.asList(row));
+		return new ResultPage(resultPage.getLimit(), resultPage.getOffset(),
+				Arrays.asList(resultPage.getColumns()), rows);
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/ehcache.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/ehcache.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/ehcache.xml	(revision 47510)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
+    <!--
+     | Please see http://ehcache.sourceforge.net/documentation/configuration.html for
+     | detailed information on how to configurigure caches in this file
+     +-->
+    <!-- Location of persistent caches on disk -->
+    <diskStore path="java.io.tmpdir/EhCacheSpringAnnotationsExampleApp" />
+
+    <defaultCache eternal="true" maxElementsInMemory="10000"
+        overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
+        timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU"/>
+
+	<cache name="claimator"/>
+	<cache name="alertator.subscriptions"/>
+	<cache name="querynator"/>
+</ehcache>
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/deploy.info
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/deploy.info	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/deploy.info	(revision 47510)
@@ -0,0 +1,10 @@
+{
+  "type_source": "SVN", 
+  "goal": "package -U -T 4C source:jar", 
+  "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk", 
+  "deploy_repository": "dnet4-snapshots", 
+  "version": "4", 
+  "mail": "antleb@di.uoa.gr, kiatrop@di.uoa.gr", 
+  "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", 
+  "name": "uoa-openaire-connector"
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(revision 47510)
@@ -0,0 +1,25 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+
+public class ThriftClient {
+
+	public OpenAIREConnector.Client getConnector() throws TTransportException {
+		return getConnector("localhost", 7911);
+	}
+
+	public OpenAIREConnector.Client getConnector(String host, int port) throws TTransportException {
+		TTransport transport = new TSocket(host, port);
+		transport.open();
+
+		TProtocol protocol = new  TBinaryProtocol(transport);
+		
+		return new OpenAIREConnector.Client(protocol);
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(revision 47510)
@@ -0,0 +1,84 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertService;
+import eu.dnetlib.api.functionality.AlertServiceException;
+import gr.uoa.di.driver.util.ServiceLocator;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+public class AlertConnector {
+	private ServiceLocator<AlertService> alertServiceLocator;
+
+	public void setAlertServiceLocator(
+			final ServiceLocator<AlertService> alertServiceLocator) {
+		this.alertServiceLocator = alertServiceLocator;
+	}
+
+	public List<AlertSubscription> getSubscriptions(final String alertMode,
+			final String subscriber, final int limit, final int offset)
+			throws AlertServiceException {
+		final List<AlertSubscription> subscriptions = new ArrayList<AlertSubscription>();
+		for (eu.dnetlib.domain.functionality.AlertSubscription subscription : alertServiceLocator
+				.getService().getSubscriptions(alertMode, subscriber, limit,
+						offset))
+			subscriptions.add(new AlertSubscription(subscription
+					.getTemplateId(), subscription.getNotificationService()
+					.toString(), subscription.getQueryId(), subscription
+					.getResultId(), subscription.getAlertMode(), subscription
+					.getSubscriber().toString()));
+		return subscriptions;
+	}
+
+	public void addSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().addSubscription(
+				new eu.dnetlib.domain.functionality.AlertSubscription(
+						subscription.getTemplateId(), new URL(subscription
+								.getNotificationService()), subscription
+								.getQueryId(), subscription.getResultId(),
+						subscription.getAlertMode(), new URI(subscription
+								.getSubscriber()), true));
+	}
+
+	public void removeSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().removeSubscription(
+				subscription.getTemplateId(),
+				new URL(subscription.getNotificationService()),
+				subscription.getQueryId(), subscription.getResultId(),
+				subscription.getAlertMode(),
+				new URI(subscription.getSubscriber()));
+	}
+
+	public int countAlertResults(final String notificationService,
+			final String queryId, final long date, final String resultId)
+			throws AlertServiceException, MalformedURLException {
+		return alertServiceLocator.getService()
+				.countAlertResults(new URL(notificationService), queryId,
+						new Date(date), resultId);
+	}
+
+	public ResultPage getAlertResults(final String notificationService,
+			final String queryId, final String resultId, final long fromDate,
+			final long toDate, final int limit, final int offset)
+			throws AlertServiceException, MalformedURLException {
+		final eu.dnetlib.domain.functionality.ResultPage resultPage = alertServiceLocator
+				.getService().getAlertResults(new URL(notificationService),
+						queryId, resultId, new Date(fromDate),
+						new Date(toDate), limit, offset);
+		final List<List<String>> rows = new ArrayList<List<String>>();
+		for (String[] row : resultPage.getRows())
+			rows.add(Arrays.asList(row));
+		return new ResultPage(resultPage.getLimit(), resultPage.getOffset(),
+				Arrays.asList(resultPage.getColumns()), rows);
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(revision 47510)
@@ -0,0 +1,322 @@
+package eu.dnetlib.openaire.thrift;
+
+
+import eu.dnetlib.api.enabling.ISLookUpService;
+import eu.dnetlib.api.enabling.ISLookUpServiceException;
+import eu.dnetlib.openaire.action.ActionUtils;
+import gr.uoa.di.driver.enabling.ISLookUpException;
+import gr.uoa.di.driver.util.ServiceLocator;
+import org.apache.log4j.Logger;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.springframework.jdbc.datasource.DataSourceUtils;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+@Transactional
+public class ClaimConnector {
+
+	private static Logger logger = Logger.getLogger(ClaimConnector.class);
+
+	private DataSource datasource = null;
+
+	//Using an isLookUp Impl just to make an xQuery to IS. Maybe move all the
+	//functionality to commons?
+	private ServiceLocator<ISLookUpService> lookupServiceLocator = null;
+
+	public List<Claim> getClaimedPublications(final String user) throws SQLException {
+		Connection con = DataSourceUtils.getConnection(datasource);
+		PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"date\" , \"type\", \"xml\", \"id\" from claims where \"agent\" = ?");
+		stmt.setString(1, user);
+		ResultSet rs = stmt.executeQuery();
+		List<Claim> res = new ArrayList<Claim>();
+
+		while (rs.next()) {
+			res.add(new Claim(user, rs.getString(1), rs.getTimestamp(2).getTime(), rs.getString(3), rs.getString(4), rs.getString(5)));
+		}
+
+		rs.close();
+		stmt.close();
+
+		return res;
+	}
+
+	public List<Claim> getClaimedPublications(Date from, Date to) throws SQLException {
+		Connection con = DataSourceUtils.getConnection(datasource);
+
+		PreparedStatement stmt = con.prepareStatement("select \"agent\", \"resultid\", \"date\" , \"type\", \"xml\",  \"id\"  from claims where \"agent\" != 'inference' and \"date\" >= ?::timestamp and \"date\" <= ?::timestamp ");
+		stmt.setTimestamp(1, new Timestamp(from.getTime()));
+        stmt.setTimestamp(2, new Timestamp(to.getTime()));
+
+		ResultSet rs = stmt.executeQuery();
+		List<Claim> res = new ArrayList<Claim>();
+
+		while (rs.next()) {
+			res.add(new Claim(rs.getString(1), rs.getString(2), rs.getTimestamp(3).getTime(), rs.getString(4), rs.getString(5), rs.getString(6)));
+		}
+
+		rs.close();
+		stmt.close();
+
+		logger.debug("number of claims: " + res.size());
+
+		return res;
+	}
+
+	public void deleteClaim(String userEmail, String id) throws SQLException {
+        logger.info("Deleting claim with id " + id + " for agent " +  userEmail);
+
+		Connection con = DataSourceUtils.getConnection(datasource);
+        int claim_id = Integer.parseInt(id);
+        String type = null;
+
+		PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"type\" from claims where \"id\" =?");
+        stmt.setInt(1, claim_id);
+
+        ResultSet rs = stmt.executeQuery();
+        
+        String resultid = null;
+        String xml = null;
+
+        while (rs.next()) {
+            resultid = rs.getString("resultid");
+            type = rs.getString("type");
+        }
+
+        if (resultid != null) {
+            stmt = con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =?");
+            stmt.setString(1, userEmail);
+            stmt.setInt(2, claim_id);
+
+            stmt.executeUpdate();
+            logger.info("Deleted claim with claim id: " + claim_id + ", result id: " + resultid + " and type: " + type +".") ;
+
+            //prepare to get 2nd claim to be deleted
+            int claim2_id = claim_id - 1;
+
+            if (type != null && type.equals("rels2actions")) {
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+                rs = stmt.executeQuery();
+
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //check if the relation has dmf
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            } /*else if (type != null && type.equals("dmf2actions")) {
+                logger.info("dmf2actions");
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+
+                rs = stmt.executeQuery();
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                logger.info("xml: " + xml);
+                logger.info("xml? " + xml.contains("oaf:concept"));
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //delete concept with extra dmf (doi,orchid,... etc)
+                    logger.debug("dmf2actions and not concept");
+
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            }*/
+        }
+
+        stmt.close();
+        
+        logger.info("Deleted claim with id " + id + " for agent " +  userEmail);
+	}
+
+	/**
+	 * @param id     {openaireId, publication doi, ORCIDId (personId-ORCIDPublicationId), data doi}
+	 * @param source {openaire, doi (crossref), orcid, datacite}
+	 * @throws ResourceNotFoundException
+	 * @throws ParseErrorException
+	 * @throws Exception
+	 */
+	public String insertDocument(
+			String id,
+			String source,
+			String title,
+			String description,
+			String access_mode,
+			String embargoEndDate,
+			List<Author> authors,
+			String url,
+			String dcSource,
+			String userEmail,
+			List<String> subjects,
+			String publicationDate,
+			String publisher,
+			String language,
+			String category,
+			String doi) throws Exception {
+
+		String resultId;
+
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String dmf;
+			resultId = ActionUtils.getIdentifier(ActionUtils.getPrefix(source), id);
+			Date now = new Date();
+
+			if (!source.toLowerCase().equals("openaire") && title != null) {
+				stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+				dmf = ActionUtils.createDMF(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, doi, Collections.EMPTY_LIST, subjects, Collections.EMPTY_LIST, publicationDate, publisher, language, category);
+
+				stmt.setString(1, userEmail);
+				stmt.setString(2, resultId);
+				stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+				stmt.setString(4, "dmf2actions");
+				stmt.setString(5, dmf);
+				stmt.setString(6, "userclaim_dmf");
+				stmt.setString(7, ActionUtils.getProvenance(source));
+				stmt.setString(8, ActionUtils.getPrefix(source));
+
+				stmt.executeUpdate();
+				stmt.close();
+			}
+		} catch (Exception e) {
+			logger.error("Error inserting document", e);
+			throw e;
+		}
+
+		return resultId;
+	}
+
+	public void insertConceptRelation(String documentId, String documentSource, String concept, String userEmail) throws Exception {
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String dmf;
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+			dmf = ActionUtils.createDMF(documentId, documentSource, null, null, null, null, Collections.EMPTY_LIST, null, null, null, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Arrays.asList(concept), null, null, null, null);
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, documentId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "dmf2actions");
+			stmt.setString(5, dmf);
+			stmt.setString(6, "userclaim_dmf");
+			stmt.setString(7, ActionUtils.getProvenance(documentSource));
+			stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding concept", e);
+			throw e;
+		}
+	}
+
+	public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws Exception {
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String xml = ActionUtils.createResultProjectRelation("openaire".equals(documentSource) ? null : documentSource, docId, project.getType(), project.getProjectId());
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, docId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "rels2actions");
+			stmt.setString(5, xml);
+			stmt.setString(6, "userclaim_result_project");
+			stmt.setString(7, ActionUtils.getProvenance(documentSource));
+			stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding project", e);
+			throw e;
+		}
+	}
+
+	public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws Exception {
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String xml = ActionUtils.createResultResultRelation(sourceResultId, sourceResultType, targetResultId, targetResultType);
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, sourceResultId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "rels2actions");
+			stmt.setString(5, xml);
+			stmt.setString(6, "userclaim_result_result");
+			stmt.setString(7, ActionUtils.getProvenance(sourceResultSource));
+			stmt.setString(8, ActionUtils.getPrefix(sourceResultSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding result relation", e);
+			throw e;
+		}
+	}
+
+	public DataSource getDatasource() {
+		return datasource;
+	}
+
+	public void setDatasource(DataSource datasource) {
+		this.datasource = datasource;
+	}
+
+	public ServiceLocator<ISLookUpService> getLookupServiceLocator() {
+		return lookupServiceLocator;
+	}
+
+	public void setLookupServiceLocator(
+			ServiceLocator<ISLookUpService> lookupServiceLocator) {
+		this.lookupServiceLocator = lookupServiceLocator;
+	}
+
+	public List<String> getContexts() throws ISLookUpException, ISLookUpServiceException {
+		return lookupServiceLocator.getService().quickSearchProfile("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') return $x");
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/RelationImport.java
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/RelationImport.java	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/utils/RelationImport.java	(revision 47510)
@@ -0,0 +1,68 @@
+package eu.dnetlib.openaire.utils;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+import java.util.Collections;
+
+import eu.dnetlib.openaire.thrift.Project;
+import org.apache.log4j.BasicConfigurator;
+
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+
+public class RelationImport {
+
+	public static void main(String[] args) throws Exception {
+		
+		BasicConfigurator.configure();
+		int count = 0;
+		
+		if (args.length != 3) {
+			System.err.println("Usage: RelationImport <datatasource (arxiv|pubmed|wos)> <projectType (ec|wt)> <file> ");
+			System.exit(1);
+		}
+		
+		String datasource = args[0];
+		String projectType = args[1];
+		String filename = args[2];
+		
+		BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filename))));
+        String line;
+        OpenAIREConnector.Client client = new ThriftClient().getConnector();
+        
+        while ((line = br.readLine()) != null) {
+            String[] values = line.split("\t");
+            String resultId = values[0];
+            String projectId = values[1];
+
+            System.out.println("adding relation " + ++count);
+/*
+            client.insertAndClaimDocument(
+                    resultId,
+                    datasource,
+                    null,
+                    null,
+                    null,
+                    null,
+                    Collections.EMPTY_LIST,
+                    null,
+                    null,
+                    null,
+                    "inference",
+                    Arrays.asList(new Project(projectType, projectId)),
+                    Collections.EMPTY_LIST,
+                    Collections.EMPTY_LIST,
+                    null,
+                    null,
+                    null,
+                    null,
+                    null);
+*/
+            //client.insertInferredRelation(datasource, resultId, projectType, projectId, "sysimport_mining_repository_" + datasource);
+        }
+        
+        br.close();
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(revision 47510)
@@ -0,0 +1,281 @@
+package eu.dnetlib.openaire.action;
+
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.Project;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+import java.io.StringWriter;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class ActionUtils {
+
+	private static Logger logger = Logger.getLogger(ActionUtils.class);
+
+	public static String createResultProjectRelation(String source,
+			String resultId, String projectType, String projectId)
+			throws Exception {
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+		ve.init();
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+		VelocityContext vc = new VelocityContext();
+
+		List<Relation> rels = new ArrayList<Relation>();
+
+		rels.add(createRelation(source, resultId, projectType, projectId));
+
+		vc.put("relations", rels);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+
+		return sw.toString();
+	}
+
+    public static String createResultResultRelation(String sourceResultId, String sourceResultType, String targetResultId, String targetResultType) {
+        VelocityEngine ve = new VelocityEngine();
+        ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+        ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+        ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+        ve.init();
+
+        Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+        VelocityContext vc = new VelocityContext();
+
+        List<Relation> rels = new ArrayList<Relation>();
+
+        rels.add(new Relation("resultResult_" + sourceResultType + targetResultType + "_isRelatedTo", "50|" + sourceResultId, "50|" + targetResultId));
+
+        vc.put("relations", rels);
+
+        StringWriter sw = new StringWriter();
+        t.merge(vc, sw);
+
+        return sw.toString();
+    }
+
+	// input id: 1306.3402
+	// oai:arXiv.org:1306.3402
+	// MD5("od________18::oai:arXiv.org:1306.3402")
+
+    /**
+     * Creates a new relation action.
+     * @param source the result source. If not null, the resultId is transformed to openaire id. If null, the result is
+     *               considered to be already an openaire result and is used verbatim
+     * @param resultId the result id
+     * @param projectType the project type. If not null, the projectId is transformed to openaire id. If null, the projectId is
+     *               considered to be already in openaire format and is used verbatim
+     * @param projectId the project id
+     *
+     * @return a relation
+     */
+	private static Relation createRelation(String source, String resultId,
+			String projectType, String projectId) {
+		String resultPrefix;
+		String projectPrefix = null;
+
+        if (!isValidOpenaireId(resultId) && source != null) {
+            if (source.equals("arxiv")) {
+                resultId = "oai:arXiv.org:" + resultId;
+            } else if (source.equals("pubmed")) {
+                resultId = "oai:europepmc.org:" + resultId;
+            }
+
+            resultPrefix = getPrefix(source);
+            resultId = getIdentifier(resultPrefix, resultId);
+        }
+
+	resultId = "50|" + resultId;
+
+        if (projectType != null) {
+            if (projectType.equals("ec")) {
+                projectPrefix = "corda_______";
+            } else if (projectType.equals("wt")) {
+                projectPrefix = "welcometrust";
+            }
+
+            projectId = projectPrefix + "::" + projectId;
+        }
+
+	projectId = "40|" + projectId;
+
+		return new Relation("resultProject", resultId, projectId);
+	}
+
+	private static boolean isValidOpenaireId(String resultId) {
+
+		return Pattern.matches("\\w{12}::[a-f0-9]{32}", resultId);
+	}
+
+	public static String getPrefix(String source) {
+        logger.debug("SOURCE " + source);
+		if (source == null || source.equals("openaire")) {
+			return "openaire____";
+		} else if (source.equals("doi")) {
+			return "crossref____";
+		} if (source.equals("orcid")) {
+            		return "orcid_______";
+		} else if (source.equals("datacite")) {
+			return "datacite____";
+		} else if (source.equals("driver")) {
+			return "driver______";
+		} else
+			return null;
+	}
+
+    public static String getProvenance(String source) {
+        if (source == null || source.equals("openaire"))
+            return "user:claim:search";
+        else if (source.equals("doi") || source.equals("orcid"))
+            return "user:claim:pid";
+		else if (source.equals("datacite"))
+			return "user:claim:datacite";
+        else
+            return null;
+    }
+
+	public static String createDMF(String id, String source, String title,
+			String description, String access_mode, String embargoEndDate,
+			List<Author> authors, String url, String dcSource, String doi,
+			List<Project> projects, List<String> subjects, List<String> concepts, String publicationDate, String publisher, String language, String category) throws Exception {
+
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+		ve.init();
+		
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/dmf.vm");
+		VelocityContext vc = new VelocityContext();
+
+		String hostedby = null;
+		String hostedbyName = null;
+		String collectedFrom = null;
+		String collectedFromName = null;
+        String recordIdentifier = id;
+		String prefix = getPrefix(source);
+
+
+        //if the orcid id exists
+        String orcid = null;
+
+		if (source.equals("doi")) {
+			hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+			hostedbyName = "Unknown Repository";
+			collectedFrom = "openaire____::crossref";
+			collectedFromName = "Crossref";
+			doi = id;
+
+        } else if (source.equals("datacite")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::datacite";
+            collectedFromName = "Datacite";
+
+        } else if (source.equals("orcid")) {
+            orcid = id;
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::orcid";
+            collectedFromName = "ORCID";
+
+        } else if (source.equals("driver")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::driver";
+            collectedFromName = "Digital Repository Infrastructure Vision for European Research";
+        }
+
+        if (doi != null) {
+            vc.put("doi", doi);
+        } else if (orcid != null){
+          //if there is no doi but we have an orcid, id we store it
+          vc.put("orcid", orcid);
+        }
+
+        // openaire ids should not be touched!
+        if (!source.equals("openaire"))
+		    id = getIdentifier(prefix, id);
+
+		vc.put("objIdentifier", id);
+		vc.put("recordIdentifier", recordIdentifier);
+		vc.put("dateOfCollection", DateUtils.calculate_ISO8601(System.currentTimeMillis()));
+		vc.put("hostedby", hostedby);
+		vc.put("collectedFrom", collectedFrom);
+		vc.put("hostedbyName", hostedbyName);
+		vc.put("collectedFromName", collectedFromName);
+        vc.put("embargoEndDate", embargoEndDate);
+		vc.put("title", title);
+		vc.put("description", description);
+		vc.put("accessMode", access_mode);
+		vc.put("dcSource", dcSource);
+		vc.put("url", url);
+		vc.put("publisher", publisher);
+		vc.put("language", language);
+		vc.put("objCategory", category);
+
+		vc.put("datasourceprefix", prefix);
+
+		List<String> creators = new ArrayList<String>();
+		for (Author author : authors) {
+            String name = author.getLastName();
+
+
+            if (author.getFirstName() != null && !author.getFirstName().trim().isEmpty())
+                name += ", " + author.getFirstName();
+
+            creators.add(name);
+		}
+
+		vc.put("creators", creators);
+		vc.put("projects", projects);
+		vc.put("subjects", subjects);
+        vc.put("concepts", concepts);
+		
+		if (publicationDate != null && !publicationDate.equals(""))
+			vc.put("publicationDate", publicationDate + "-01-01T00:00:00Z");
+		
+		vc.put("StringEscapeUtils", StringEscapeUtils.class);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+		
+		return sw.toString();
+	}
+
+	// private static String getIdentifier(String prefix, String id) {
+	// return prefix + "::" +
+	// com.google.common.hash.Hashing.md5().hashString(id).toString();
+	// }
+
+	public static String getIdentifier(String prefix, String id) {
+		try {
+            logger.debug("PREFIX " + prefix);
+			MessageDigest md = MessageDigest.getInstance("MD5");
+
+			md.update(id.getBytes("UTF-8"));
+
+			return prefix + "::" + new String(Hex.encodeHex(md.digest()));
+		} catch (Exception e) {
+			logger.error("Error creating id", e);
+			return null;
+		}
+	}
+}
Index: modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(revision 47510)
@@ -0,0 +1,282 @@
+package eu.dnetlib.openaire.action;
+
+import java.io.StringWriter;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.List;
+
+import eu.dnetlib.openaire.thrift.Project;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import eu.dnetlib.openaire.thrift.Author;
+
+public class ActionUtils {
+
+	private static Logger logger = Logger.getLogger(ActionUtils.class);
+
+	public static String createResultProjectRelation(String source,
+			String resultId, String projectType, String projectId)
+			throws Exception {
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+		ve.init();
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+		VelocityContext vc = new VelocityContext();
+
+		List<Relation> rels = new ArrayList<Relation>();
+
+		rels.add(createRelation(source, resultId, projectType, projectId));
+
+		vc.put("relations", rels);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+
+		return sw.toString();
+	}
+
+	// input id: 1306.3402
+	// oai:arXiv.org:1306.3402
+	// MD5("od________18::oai:arXiv.org:1306.3402")
+
+    /**
+     * Creates a new relation action.
+     * @param source the result source. If not null, the resultId is transformed to openaire id. If null, the result is
+     *               considered to be already an openaire result and is used verbatim
+     * @param resultId the result id
+     * @param projectType the project type. If not null, the projectId is transformed to openaire id. If null, the projectId is
+     *               considered to be already in openaire format and is used verbatim
+     * @param projectId the project id
+     *
+     * @return a relation
+     */
+	private static Relation createRelation(String source, String resultId,
+			String projectType, String projectId) {
+		String resultPrefix;
+		String projectPrefix = null;
+
+        if (source != null) {
+            if (source.equals("arxiv")) {
+                resultId = "oai:arXiv.org:" + resultId;
+            } else if (source.equals("pubmed")) {
+                resultId = "oai:europepmc.org:" + resultId;
+            }
+
+            resultPrefix = getPrefix(source);
+            resultId = "50|" + getIdentifier(resultPrefix, resultId);
+        }
+
+        if (projectType != null) {
+            if (projectType.equals("ec")) {
+                projectPrefix = "corda_______";
+            } else if (projectType.equals("wt")) {
+                projectPrefix = "welcometrust";
+            }
+
+            projectId = projectPrefix + "::" + projectId;
+        }
+
+		return new Relation("resultProject", resultId, projectId);
+	}
+	
+	public static String getPrefix(String source) {
+		if (source.equals("doi")) {
+			return "crossref____";
+		} else if (source.equals("wos")) {
+			return "webcrawl____";
+		} else if (source.equals("arxiv")) {
+			return "od________18";
+		} else if (source.equals("openaire")) {
+			return "openaire____";
+		} else if (source.equals("pubmed")) {
+			return "od_______908";
+		} if (source.equals("orcid")) {
+            return "crossref____";
+        } if (source.equals("datacite")) {
+            return "datacite____";
+        } else if (source.equals("driver")) {
+            return "driver______";
+        } else
+			return null;
+	}
+
+    public static String getSet(String source, String actionType) {
+        if (source != null && (source.equals("wos") || source.equals("arxiv") || source.equals("pubmed"))) {
+            if (actionType.equals("dmf"))
+                return "iis-wos-entities";
+            else if (actionType.equals("relation"))
+                return "iis-referenced-projects";
+        } else {
+            if (actionType.equals("dmf"))
+                return "userclaim_dmf";
+            else if (actionType.equals("relation"))
+                return "userclaim_result_project";
+        }
+
+        return null;
+    }
+
+    public static String getProvenance(String source) {
+        if (source == null || source.equals("openaire"))
+            return "user:claim:search";
+        else if (source.equals("driver"))
+            return "user:claim:search";
+        else if (source.equals("doi"))
+            return "user:claim:pid";
+        else if (source.equals("wos") || source.equals("arxiv") || source.equals("pubmed"))
+            return "sysimport:mining:repository";
+        else
+            return null;
+    }
+
+	public static String createDMF(String id, String source, String title,
+			String description, String access_mode, String embargoEndDate,
+			List<Author> authors, String url, String dcSource, String doi,
+			List<Project> projects, List<String> subjects, List<String> concepts, String publicationDate, String publisher, String language, String category) throws Exception {
+
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+		ve.init();
+		
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/dmf.vm");
+		VelocityContext vc = new VelocityContext();
+
+		String hostedby = null;
+		String hostedbyName = null;
+		String collectedFrom = null;
+		String collectedFromName = null;
+        String recordIdentifier = id;
+		String prefix = getPrefix(source);
+
+		if (source.equals("doi")) {
+			hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+			hostedbyName = "Unknown Repository";
+			collectedFrom = "openaire____::crossref";
+			collectedFromName = "Crossref";
+			doi = id;
+		} else if (source.equals("wos")) {
+			hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+			hostedbyName = "Unknown Repository";
+			collectedFrom = "openaire____::webcrawl";
+			collectedFromName = "Web Crawl";
+		} else if (source.equals("arxiv")) {
+            id = "oai:arXiv.org:" + id;
+            recordIdentifier = id;
+			hostedby = "opendoar____::18";
+			hostedbyName = "arXiv.org e-Print Archive";
+			collectedFrom = "opendoar____::18";
+			collectedFromName = "arXiv.org e-Print Archive";
+		} else if (source.equals("datacite")) {
+            hostedby = "openaire____::datacite";
+            hostedbyName = "Datacite";
+            collectedFrom = "openaire____::datacite";
+            collectedFromName = "Datacite";
+        } else if (source.equals("orcid")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "infospace___::crossref";
+            collectedFromName = "Crossref";
+            doi = id;
+        } else if (source.equals("pubmed")) {
+            id = "oai:europepmc.org:" + id;
+            recordIdentifier = id;
+            hostedby = "opendoar____::908";
+            hostedbyName = "Europe PubMed Central";
+            collectedFrom = "opendoar____::908";
+            collectedFromName = "Europe PubMed Central";
+        } else if (source.equals("driver")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::driver";
+            collectedFromName = "Digital Repository Infrastructure Vision for European Research";
+        }
+
+        if (doi != null)
+			vc.put("doi", doi);
+
+        // openaire ids should not be touched!
+        if (!source.equals("openaire"))
+		    id = getIdentifier(prefix, id);
+
+		vc.put("objIdentifier", id);
+		vc.put("recordIdentifier", recordIdentifier);
+		vc.put("dateOfCollection", DateUtils.calculate_ISO8601(System.currentTimeMillis()));
+		vc.put("hostedby", hostedby);
+		vc.put("collectedFrom", collectedFrom);
+		vc.put("hostedbyName", hostedbyName);
+		vc.put("collectedFromName", collectedFromName);
+
+		vc.put("title", title);
+		vc.put("description", description);
+		vc.put("accessMode", access_mode);
+		vc.put("dcSource", dcSource);
+		vc.put("url", url);
+		vc.put("publisher", publisher);
+		vc.put("language", language);
+		vc.put("objCategory", category);
+
+		vc.put("datasourceprefix", prefix);
+
+		List<String> creators = new ArrayList<String>();
+		for (Author author : authors) {
+            String name = author.getLastName();
+
+
+            if (author.getFirstName() != null && !author.getFirstName().trim().isEmpty())
+                name += ", " + author.getFirstName();
+
+            creators.add(name);
+		}
+
+		vc.put("creators", creators);
+		vc.put("projects", projects);
+		vc.put("subjects", subjects);
+        vc.put("concepts", concepts);
+		
+		if (publicationDate != null && !publicationDate.equals(""))
+			vc.put("publicationDate", publicationDate + "-01-01T00:00:00Z");
+		
+		vc.put("StringEscapeUtils", StringEscapeUtils.class);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+		
+		return sw.toString();
+	}
+
+	// private static String getIdentifier(String prefix, String id) {
+	// return prefix + "::" +
+	// com.google.common.hash.Hashing.md5().hashString(id).toString();
+	// }
+
+	public static String getIdentifier(String prefix, String id) {
+		try {
+			MessageDigest md = MessageDigest.getInstance("MD5");
+
+			md.update(id.getBytes("UTF-8"));
+
+			return prefix + "::" + new String(org.apache.commons.codec.binary.Hex.encodeHex(md.digest()));
+		} catch (Exception e) {
+			logger.error("Error creating id", e);
+			return null;
+		}
+	}
+
+    public static void main(String[] args) throws  Exception {
+        System.out.println(createRelation("pubmed", "662141", "ec", "sdfdf").getSourceId());
+    }
+}
\ No newline at end of file
Index: modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/utils/claims.sql
===================================================================
--- modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(revision 47510)
@@ -0,0 +1,45 @@
+select
+        r.resultid                                          as dri_objidentifier,
+        r.title                                             as dc_title,
+        array_agg(DISTINCT lpad('0'||aut.rank,5,'0')||'§§§'||ltrim(replace(per.surname||', '||per.name,'UNKNOWN, ',''), ', ')) as dc_creator,
+      r.description                                       as dc_description,
+        r.publisher                                         as dc_publisher,
+        r.keywords                                          as dc_subject,
+        r.language                                          as dc_language,
+        array_agg(DISTINCT ws.file_url)                     as dc_identifier,
+        r.publication_date                                  as oaf_publicationdate,
+        r.embargo_end_date                                  as oaf_embargoenddate,
+        r.access_mode                                       as oaf_accessmode,
+        r.haskind                                           as oaf_haskind,
+        r.hastype                                           as "dr_CobjCategory",
+        r.storagedate                                           as oaf_storagedate,
+        createdfrom                                         as createdfrom,
+        array_agg(DISTINCT p.projectid)                     as oaf_projectid,
+        array_agg(DISTINCT cr.creator)                              as creators
+
+from
+
+       results r
+        left outer join results_projects rp on (r.resultid = rp.result)
+        left outer join projects p on (p.projectid = rp.project)
+        left outer join projects_projectsubjects ps on (ps.project = p.projectID)
+        left outer join fundingschemes fs on (p.fundedhow = fs.fundingschemeid)
+        left outer join programs s on (p.fundedby = s.programid)
+        left outer join specificprograms sp on (s.hasspecificprogram = sp.specificprogramid)
+        left outer join frameworkprograms fp on (sp.hasframeworkprogram = fp.frameworkprogramid)
+        left outer join authorships aut on (r.resultid = aut.result)
+        left outer join persons per on (per.personid = aut.author)
+        left outer join organizations o on (o.organizationid = aut.affiliation)
+        left outer join instances i on (r.resultid = i.resource)
+        left outer join webresources_instances wsi on (wsi.instanceid = i.instanceid)
+        left outer join webresources ws on (ws.webresourceid = wsi.webresourceid)
+
+        join creations cr on cr.creation = r.resultid
+
+where
+        r.pmhdeleted != true and r.pendingforclaim = false
+
+group by
+        r.resultid, r.title, r.description, r.publisher, r.keywords, r.language,
+        r.publication_date, r.embargo_end_date, r.access_mode, r.haskind, r.hastype,
+        r.storagedate, r.createdfrom
\ No newline at end of file
Index: modules/uoa-claims-api/branches/import/src
===================================================================
--- modules/uoa-claims-api/branches/import/src	(nonexistent)
+++ modules/uoa-claims-api/branches/import/src	(revision 47510)

Property changes on: modules/uoa-claims-api/branches/import/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/utils/claims.sql
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(revision 47510)
@@ -0,0 +1,45 @@
+select
+        r.resultid                                          as dri_objidentifier,
+        r.title                                             as dc_title,
+        array_agg(DISTINCT lpad('0'||aut.rank,5,'0')||'§§§'||ltrim(replace(per.surname||', '||per.name,'UNKNOWN, ',''), ', ')) as dc_creator,
+      r.description                                       as dc_description,
+        r.publisher                                         as dc_publisher,
+        r.keywords                                          as dc_subject,
+        r.language                                          as dc_language,
+        array_agg(DISTINCT ws.file_url)                     as dc_identifier,
+        r.publication_date                                  as oaf_publicationdate,
+        r.embargo_end_date                                  as oaf_embargoenddate,
+        r.access_mode                                       as oaf_accessmode,
+        r.haskind                                           as oaf_haskind,
+        r.hastype                                           as "dr_CobjCategory",
+        r.storagedate                                           as oaf_storagedate,
+        createdfrom                                         as createdfrom,
+        array_agg(DISTINCT p.projectid)                     as oaf_projectid,
+        array_agg(DISTINCT cr.creator)                              as creators
+
+from
+
+       results r
+        left outer join results_projects rp on (r.resultid = rp.result)
+        left outer join projects p on (p.projectid = rp.project)
+        left outer join projects_projectsubjects ps on (ps.project = p.projectID)
+        left outer join fundingschemes fs on (p.fundedhow = fs.fundingschemeid)
+        left outer join programs s on (p.fundedby = s.programid)
+        left outer join specificprograms sp on (s.hasspecificprogram = sp.specificprogramid)
+        left outer join frameworkprograms fp on (sp.hasframeworkprogram = fp.frameworkprogramid)
+        left outer join authorships aut on (r.resultid = aut.result)
+        left outer join persons per on (per.personid = aut.author)
+        left outer join organizations o on (o.organizationid = aut.affiliation)
+        left outer join instances i on (r.resultid = i.resource)
+        left outer join webresources_instances wsi on (wsi.instanceid = i.instanceid)
+        left outer join webresources ws on (ws.webresourceid = wsi.webresourceid)
+
+        join creations cr on cr.creation = r.resultid
+
+where
+        r.pmhdeleted != true and r.pendingforclaim = false
+
+group by
+        r.resultid, r.title, r.description, r.publisher, r.keywords, r.language,
+        r.publication_date, r.embargo_end_date, r.access_mode, r.haskind, r.hastype,
+        r.storagedate, r.createdfrom
\ No newline at end of file
Index: modules/uoa-claims-api/branches/import/pom.xml
===================================================================
--- modules/uoa-claims-api/branches/import/pom.xml	(nonexistent)
+++ modules/uoa-claims-api/branches/import/pom.xml	(revision 47510)
@@ -0,0 +1,141 @@
+<?xml version="1.0"?>
+<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-SNAPSHOT</version>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>uoa-openaire-connector</artifactId>
+	<packaging>jar</packaging>
+	<version>1.0.0-SNAPSHOT</version>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>dtrotts</id>
+			<name>Repository for maven thrift plugin</name>
+			<url>http://maven.davidtrott.com/repository</url>
+			<layout>default</layout>
+		</pluginRepository>
+	</pluginRepositories>
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<archive>
+
+					</archive>
+					<descriptorRefs>
+						<descriptorRef>jar-with-dependencies</descriptorRef>
+					</descriptorRefs>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.thrift.tools</groupId>
+				<artifactId>maven-thrift-plugin</artifactId>
+				<version>0.1.10</version>
+				<executions>
+					<execution>
+						<id>thrift-sources</id>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>compile</goal>
+						</goals>
+					</execution>
+					<execution>
+						<id>thrift-test-sources</id>
+						<phase>generate-test-sources</phase>
+						<goals>
+							<goal>testCompile</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings 
+					only. It has no influence on the Maven build itself. -->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>org.apache.thrift.tools</groupId>
+										<artifactId>maven-thrift-plugin</artifactId>
+										<versionRange>[0.1.10,)</versionRange>
+										<goals>
+											<goal>testCompile</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore />
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>[0.0.0,)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.7.5</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-dbcp</groupId>
+			<artifactId>commons-dbcp</artifactId>
+			<version>[1.2, 1.3)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-utils</artifactId>
+			<version>[1.0.0-SNAPSHOT,)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-commons</artifactId>
+			<version>[1.0.0-SNAPSHOT,)</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.thrift</groupId>
+			<artifactId>libthrift</artifactId>
+			<version>0.8.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.postgresql</groupId>
+			<artifactId>jdbc4driver</artifactId>
+			<version>9.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.velocity</groupId>
+			<artifactId>velocity</artifactId>
+			<version>1.7</version>
+		</dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+    </dependencies>
+</project>
Index: modules/uoa-claims-api/branches/import
===================================================================
--- modules/uoa-claims-api/branches/import	(nonexistent)
+++ modules/uoa-claims-api/branches/import	(revision 47510)

Property changes on: modules/uoa-claims-api/branches/import
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+.project
+.settings
+.idea
+*.iml
+target
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(revision 47510)
@@ -0,0 +1,57 @@
+<?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:tx="http://www.springframework.org/schema/tx"
+
+        xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/tx
+        http://www.springframework.org/schema/tx/spring-tx.xsd">
+		
+	<bean id="openaire.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+		<property name="driverClassName" value="${openaire.db.driverClassName}" />
+		<property name="url" value="${openaire.db.url}" />
+		<property name="username" value="${openaire.db.username}" />
+		<property name="password" value="${openaire.db.password}" />
+		<property name="maxIdle" value="10" />
+		<property name="maxActive" value="100" />
+		<property name="maxWait" value="10000" />
+		<property name="validationQuery" value="SELECT 1;" />
+		<property name="testOnBorrow" value="true" />
+		<property name="testOnReturn" value="true" />
+		<property name="testWhileIdle" value="true" />
+		<property name="timeBetweenEvictionRunsMillis" value="1200000" />
+		<property name="minEvictableIdleTimeMillis" value="1800000" />
+		<property name="numTestsPerEvictionRun" value="5" />
+		<property name="poolPreparedStatements" value="true" />
+		<property name="defaultAutoCommit" value="true" />
+	</bean>
+
+	<bean id="claimConnector" class="eu.dnetlib.openaire.thrift.ClaimConnector">
+		<property name="datasource" ref="openaire.dataSource" />
+		<property name="lookupServiceLocator" ref="lookupServiceLocator"/>
+	</bean>
+	
+	<bean id="alertConnector" class="eu.dnetlib.openaire.thrift.AlertConnector">
+		<property name="alertServiceLocator" ref="alertServiceLocator" />
+	</bean>
+	
+	<bean id="openAireConnector" class="eu.dnetlib.openaire.thrift.OpenAIREConnectorImpl">
+		<property name="claimConnector" ref="claimConnector" />
+		<property name="alertConnector" ref="alertConnector" />
+	</bean>
+	
+	<bean id="thriftServer" class="eu.dnetlib.openaire.thrift.ThriftServer" init-method="start" destroy-method="stop">
+		<property name="openAireConnector" ref="openAireConnector" />
+		<property name="port" value="${openaire.connector.thrift.port}"/>
+		<property name="timeout" value="${openaire.connector.thrift.timeout}" />
+	</bean>
+
+    <tx:annotation-driven transaction-manager="txManager"/>
+    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="openaire.dataSource"/>
+    </bean>
+
+
+</beans>
+
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(revision 47510)
@@ -0,0 +1,32 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.TException;
+import org.apache.thrift.transport.TTransportException;
+
+import java.util.Arrays;
+
+/**
+ * Created by antleb on 6/20/14.
+ */
+public class TestConnector {
+
+	public static void main(String[] args) throws TException {
+
+		OpenAIREConnector.Client client = new ThriftClient().getConnector("194.177.192.223", 7911);
+
+		String id = client.insertDocument("123123/3434.23", "doi", "a title", " a description", "OPEN ACCESS", null, Arrays.asList(new Author("id" ,"lastname", "firstname")), "url", "dcsource", "antleb@di.uoa.gr", Arrays.asList("subject"), "2012-01-02", "publisher", "language", "category", "doioioioi" );
+		System.out.println(id);
+
+		client.insertConcept(id, "doi", "egi", "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "doi", new Project("ec", "1233312"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "doi", new Project(null, "1233312"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "doi", id, "result", "antleb@di.uoa.gr");
+
+		id = "od______1406::fbda7b28cda277b04c8dc27a5e0deb68";
+
+		client.insertConcept(id, "openaire", "ec", "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "openaire", new Project("ec", "099809987"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "openaire", new Project(null, "098908908"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "openaire", id, "dataset", "antleb@di.uoa.gr");
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/thrift/OpenAIREConnector.thrift
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/thrift/OpenAIREConnector.thrift	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/thrift/OpenAIREConnector.thrift	(revision 47510)
@@ -0,0 +1,117 @@
+namespace java eu.dnetlib.openaire.thrift
+
+struct Author {
+	1: string id,
+	2: string lastName,
+	3: string firstName
+}
+
+// alerts
+struct AlertSubscription {
+	1: string templateId,
+	2: string notificationService,
+	3: string queryId,
+	4: string resultId,
+	5: string alertMode,
+	6: string subscriber
+}
+
+struct ResultPage {
+	1: i32 limit,
+	2: i32 offset,
+	3: list<string> columns,
+	4: list<list<string>> rows
+}
+
+struct Claim {
+    1: string userEmail,
+	2: string resultid,
+	3: i64 date,
+	4: string type,
+	5: string xml,
+	6: string id
+}
+
+struct Project {
+    1: string type,
+    2: string projectId
+}
+
+// connector
+service OpenAIREConnector {
+	// claim
+	list<Claim> getClaimedPublications(1: string userEmail),
+
+	// from: date in milisecs
+	// to: ditto
+	list<Claim> getAllClaimedPublications(1: i64 from, 2: i64 to),
+	
+	string insertDocument (
+			1: string originalId,
+			2: string source, 
+			3: string title, 
+			4: string description, 
+			5: string access_mode, 
+			6: string embargoEndDate, 
+			7: list<Author> authors, 
+			8: string url,
+			9: string dcSource,
+			10: string userEmail,
+			11: list<string> subjects,
+			12: string publicationDate,
+			13: string publisher,
+			14: string language,
+			15: string category,
+			16: string doi),
+
+    void insertConcept (
+        1: string docId,
+        2: string documentSource,
+        3: string concept,
+        4: string userEmail),
+
+    void insertProjectRelation (
+        1: string docId,
+        2: string documentSource,
+        3: Project project,
+        4: string userEmail),
+
+    void insertResultRelation (
+        1: string sourceResultId,
+        2: string sourceResultType,
+        3: string sourceResultSource,
+        4: string targetResultId,
+        5: string targetResultType,
+        6: string userEmail
+    ),
+
+	void deleteClaim(1: string userEmail, 2:string resultId),
+
+	// alerts
+	list<AlertSubscription> getSubscriptions(
+			1: string alertMode, 
+			2: string subscriber, 
+			3: i32 limit, 
+			4: i32 offset),
+			
+	void addSubscription(1: AlertSubscription subscription),
+	
+	void removeSubscription(1: AlertSubscription subscription),
+	
+	i32 countAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: i64 date, 
+			5: string resultId),
+			
+	ResultPage getAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: string resultId, 
+			4: i64 fromDate, 
+			5: i64 toDate, 
+			6: i32 limit, 
+			7: i32 offset),
+	
+	list<string> getContexts(),
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/action/Relation.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/action/Relation.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/action/Relation.java	(revision 47510)
@@ -0,0 +1,39 @@
+package eu.dnetlib.openaire.action;
+
+public class Relation {
+	private String type;
+	private String sourceId;
+	private String targetId;
+
+	public Relation(String type, String sourceId, String targetId) {
+		super();
+		this.type = type;
+		this.sourceId = sourceId;
+		this.targetId = targetId;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getSourceId() {
+		return sourceId;
+	}
+
+	public void setSourceId(String sourceId) {
+		this.sourceId = sourceId;
+	}
+
+	public String getTargetId() {
+		return targetId;
+	}
+
+	public void setTargetId(String targetId) {
+		this.targetId = targetId;
+	}
+
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/pom.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/pom.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/pom.xml	(revision 47510)
@@ -0,0 +1,143 @@
+<?xml version="1.0"?>
+<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>uoa-openaire-connector</artifactId>
+	<version>1.0.0</version>
+        <scm>
+                <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/tags/uoa-openaire-connector-1.0.0</developerConnection>
+        </scm>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>dtrotts</id>
+			<name>Repository for maven thrift plugin</name>
+			<url>http://maven.davidtrott.com/repository</url>
+			<layout>default</layout>
+		</pluginRepository>
+	</pluginRepositories>
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<archive>
+
+					</archive>
+					<descriptorRefs>
+						<descriptorRef>jar-with-dependencies</descriptorRef>
+					</descriptorRefs>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.thrift.tools</groupId>
+				<artifactId>maven-thrift-plugin</artifactId>
+				<version>0.1.10</version>
+				<executions>
+					<execution>
+						<id>thrift-sources</id>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>compile</goal>
+						</goals>
+					</execution>
+					<execution>
+						<id>thrift-test-sources</id>
+						<phase>generate-test-sources</phase>
+						<goals>
+							<goal>testCompile</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings 
+					only. It has no influence on the Maven build itself. -->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>org.apache.thrift.tools</groupId>
+										<artifactId>maven-thrift-plugin</artifactId>
+										<versionRange>[0.1.10,)</versionRange>
+										<goals>
+											<goal>testCompile</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore />
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>[0.0.0,)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.7.5</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-dbcp</groupId>
+			<artifactId>commons-dbcp</artifactId>
+			<version>[1.2, 1.3)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-utils</artifactId>
+			<version>[1.0.0]</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-commons</artifactId>
+			<version>[1.0.0]</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.thrift</groupId>
+			<artifactId>libthrift</artifactId>
+			<version>0.8.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.postgresql</groupId>
+			<artifactId>jdbc4driver</artifactId>
+			<version>9.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.velocity</groupId>
+			<artifactId>velocity</artifactId>
+			<version>1.7</version>
+		</dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>
Index: modules/uoa-claims-api/trunk/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java
===================================================================
--- modules/uoa-claims-api/trunk/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(revision 47510)
@@ -0,0 +1,25 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+
+public class ThriftClient {
+
+	public OpenAIREConnector.Client getConnector() throws TTransportException {
+		return getConnector("localhost", 7911);
+	}
+
+	public OpenAIREConnector.Client getConnector(String host, int port) throws TTransportException {
+		TTransport transport = new TSocket(host, port);
+		transport.open();
+
+		TProtocol protocol = new  TBinaryProtocol(transport);
+		
+		return new OpenAIREConnector.Client(protocol);
+	}
+}
Index: modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java
===================================================================
--- modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(revision 47510)
@@ -0,0 +1,84 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertService;
+import eu.dnetlib.api.functionality.AlertServiceException;
+import gr.uoa.di.driver.util.ServiceLocator;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+public class AlertConnector {
+	private ServiceLocator<AlertService> alertServiceLocator;
+
+	public void setAlertServiceLocator(
+			final ServiceLocator<AlertService> alertServiceLocator) {
+		this.alertServiceLocator = alertServiceLocator;
+	}
+
+	public List<AlertSubscription> getSubscriptions(final String alertMode,
+			final String subscriber, final int limit, final int offset)
+			throws AlertServiceException {
+		final List<AlertSubscription> subscriptions = new ArrayList<AlertSubscription>();
+		for (eu.dnetlib.domain.functionality.AlertSubscription subscription : alertServiceLocator
+				.getService().getSubscriptions(alertMode, subscriber, limit,
+						offset))
+			subscriptions.add(new AlertSubscription(subscription
+					.getTemplateId(), subscription.getNotificationService()
+					.toString(), subscription.getQueryId(), subscription
+					.getResultId(), subscription.getAlertMode(), subscription
+					.getSubscriber().toString()));
+		return subscriptions;
+	}
+
+	public void addSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().addSubscription(
+				new eu.dnetlib.domain.functionality.AlertSubscription(
+						subscription.getTemplateId(), new URL(subscription
+								.getNotificationService()), subscription
+								.getQueryId(), subscription.getResultId(),
+						subscription.getAlertMode(), new URI(subscription
+								.getSubscriber()), true));
+	}
+
+	public void removeSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().removeSubscription(
+				subscription.getTemplateId(),
+				new URL(subscription.getNotificationService()),
+				subscription.getQueryId(), subscription.getResultId(),
+				subscription.getAlertMode(),
+				new URI(subscription.getSubscriber()));
+	}
+
+	public int countAlertResults(final String notificationService,
+			final String queryId, final long date, final String resultId)
+			throws AlertServiceException, MalformedURLException {
+		return alertServiceLocator.getService()
+				.countAlertResults(new URL(notificationService), queryId,
+						new Date(date), resultId);
+	}
+
+	public ResultPage getAlertResults(final String notificationService,
+			final String queryId, final String resultId, final long fromDate,
+			final long toDate, final int limit, final int offset)
+			throws AlertServiceException, MalformedURLException {
+		final eu.dnetlib.domain.functionality.ResultPage resultPage = alertServiceLocator
+				.getService().getAlertResults(new URL(notificationService),
+						queryId, resultId, new Date(fromDate),
+						new Date(toDate), limit, offset);
+		final List<List<String>> rows = new ArrayList<List<String>>();
+		for (String[] row : resultPage.getRows())
+			rows.add(Arrays.asList(row));
+		return new ResultPage(resultPage.getLimit(), resultPage.getOffset(),
+				Arrays.asList(resultPage.getColumns()), rows);
+	}
+}
Index: modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/action/Relation.java
===================================================================
--- modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/action/Relation.java	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/java/eu/dnetlib/openaire/action/Relation.java	(revision 47510)
@@ -0,0 +1,39 @@
+package eu.dnetlib.openaire.action;
+
+public class Relation {
+	private String type;
+	private String sourceId;
+	private String targetId;
+
+	public Relation(String type, String sourceId, String targetId) {
+		super();
+		this.type = type;
+		this.sourceId = sourceId;
+		this.targetId = targetId;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getSourceId() {
+		return sourceId;
+	}
+
+	public void setSourceId(String sourceId) {
+		this.sourceId = sourceId;
+	}
+
+	public String getTargetId() {
+		return targetId;
+	}
+
+	public void setTargetId(String targetId) {
+		this.targetId = targetId;
+	}
+
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/action/Relation.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/action/Relation.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/action/Relation.java	(revision 47510)
@@ -0,0 +1,39 @@
+package eu.dnetlib.openaire.action;
+
+public class Relation {
+	private String type;
+	private String sourceId;
+	private String targetId;
+
+	public Relation(String type, String sourceId, String targetId) {
+		super();
+		this.type = type;
+		this.sourceId = sourceId;
+		this.targetId = targetId;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getSourceId() {
+		return sourceId;
+	}
+
+	public void setSourceId(String sourceId) {
+		this.sourceId = sourceId;
+	}
+
+	public String getTargetId() {
+		return targetId;
+	}
+
+	public void setTargetId(String targetId) {
+		this.targetId = targetId;
+	}
+
+}
\ No newline at end of file
Index: modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/action/relation.vm
===================================================================
--- modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(nonexistent)
+++ modules/uoa-claims-api/trunk/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(revision 47510)
@@ -0,0 +1,5 @@
+<RELATIONS>
+#foreach ($rel in $relations)
+    <RELATION type='$rel.Type' source='$rel.SourceId' target='$rel.TargetId' />
+#end
+</RELATIONS>
\ No newline at end of file
Index: modules/uoa-claims-api/trunk/src
===================================================================
--- modules/uoa-claims-api/trunk/src	(nonexistent)
+++ modules/uoa-claims-api/trunk/src	(revision 47510)

Property changes on: modules/uoa-claims-api/trunk/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+
Index: modules/uoa-claims-api/trunk
===================================================================
--- modules/uoa-claims-api/trunk	(nonexistent)
+++ modules/uoa-claims-api/trunk	(revision 47510)

Property changes on: modules/uoa-claims-api/trunk
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+.project
+.settings
+.idea
+*.iml
+target
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(revision 47510)
@@ -0,0 +1,43 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TTransportException;
+
+public class ThriftServer {
+	private OpenAIREConnector.Iface openAireConnector;
+	private int port;
+	private int timeout;
+	private Thread thread;
+
+	public void setOpenAireConnector(final OpenAIREConnector.Iface openAireConnector) {
+		this.openAireConnector = openAireConnector;
+	}
+	
+	public void setPort(final int port) {
+		this.port = port;
+	}
+	
+	public void setTimeout(final int timeout) {
+		this.timeout = timeout;
+	}
+	
+	public void start() {
+		thread = new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					new TThreadPoolServer(new TThreadPoolServer.Args(new TServerSocket(port, timeout)).processor(new OpenAIREConnector.Processor<OpenAIREConnector.Iface>(openAireConnector))).serve();
+				} catch (final TTransportException e) {
+					Logger.getLogger(ThriftServer.class).error("Error starting thrift server", e);
+				}
+			}
+		});
+		thread.start();
+	}
+	
+	public void stop() {
+		thread.interrupt();
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(revision 47510)
@@ -0,0 +1,186 @@
+package eu.dnetlib.openaire.thrift;
+
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+
+import eu.dnetlib.api.functionality.AlertServiceException;
+
+public class OpenAIREConnectorImpl implements OpenAIREConnector.Iface {
+	private static final Logger logger = Logger.getLogger(OpenAIREConnectorImpl.class);
+
+	private ClaimConnector claimConnector;
+	private AlertConnector alertConnector;
+
+	public void setClaimConnector(final ClaimConnector claimConnector) {
+		this.claimConnector = claimConnector;
+	}
+
+	public void setAlertConnector(final AlertConnector alertConnector) {
+		this.alertConnector = alertConnector;
+	}
+
+	@Override
+	public List<Claim> getClaimedPublications(final String user) throws TException {
+		try {
+			return claimConnector.getClaimedPublications(user);
+		} catch (final Exception e) {
+			logger.error("Error retrieving claimed publications (user: " + user + ")", e);
+			throw new TException("Error retrieving claimed publications (user: " + user + ")", e);
+		}
+	}
+
+    @Override
+    public List<Claim> getAllClaimedPublications(long from, long to) throws TException {
+        try {
+            return claimConnector.getClaimedPublications(new Date(from), new Date(to));
+        } catch (Exception e) {
+            logger.error("Error retrieving claimed publications", e);
+
+            throw new TException("Error retrieving claimed publications", e);
+        }
+    }
+
+    @Override
+    public String insertDocument(String originalId, String source, String title, String description, String access_mode, String embargoEndDate, List<Author> authors, String url, String dcSource, String userEmail, List<String> subjects, String publicationDate, String publisher, String language, String category, String doi) throws org.apache.thrift.TException {
+        try {
+            return claimConnector.insertDocument(originalId, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, userEmail, subjects, publicationDate, publisher, language, category, doi);
+        } catch (Exception e) {
+            logger.error("Error adding document", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertConcept(String docId, String documentSource, String concept, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertConceptRelation(docId, documentSource, concept, userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding concept relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertProjectRelation(docId, documentSource, project, userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding project relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws TException {
+        try {
+            claimConnector.insertResultRelation(sourceResultId, sourceResultType, sourceResultSource, targetResultId, targetResultType,userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding result relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+	public List<AlertSubscription> getSubscriptions(final String alertMode, final String subscriber, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getSubscriptions(alertMode, subscriber, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+	@Override
+	public void addSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.addSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		}
+	}
+
+	@Override
+	public void removeSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.removeSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		}
+	}
+
+	@Override
+	public int countAlertResults(final String notificationService, final String queryId, final long date, final String resultId) throws TException {
+		try {
+			return alertConnector.countAlertResults(notificationService, queryId, date, resultId);
+		} catch (final AlertServiceException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		}
+	}
+
+	@Override
+	public ResultPage getAlertResults(final String notificationService, final String queryId, final String resultId, final long fromDate, final long toDate, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getAlertResults(notificationService, queryId, resultId, fromDate, toDate, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+    @Override
+    public void deleteClaim(String userEmail, String resultId) throws TException {
+        try {
+            claimConnector.deleteClaim(userEmail, resultId);
+        } catch (Exception e) {
+            logger.error("Error deleting claim", e);
+
+            throw new TException(e);
+        }
+    }
+
+	@Override
+	public List<String> getContexts() throws TException {
+		try {
+			return claimConnector.getContexts();
+		} catch (Exception e) {
+			logger.error("Error getting contexts from IS.", e);
+			
+			throw new TException(e);
+		}
+		
+	}
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/pom.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/pom.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/pom.xml	(revision 47510)
@@ -0,0 +1,148 @@
+<?xml version="1.0"?>
+<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>uoa-openaire-connector</artifactId>
+	<version>1.3.2</version>
+        <scm>
+                <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/tags/uoa-openaire-connector-1.3.2</developerConnection>
+        </scm>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>dtrotts</id>
+			<name>Repository for maven thrift plugin</name>
+			<url>http://maven.davidtrott.com/repository</url>
+			<layout>default</layout>
+		</pluginRepository>
+	</pluginRepositories>
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<archive>
+
+					</archive>
+					<descriptorRefs>
+						<descriptorRef>jar-with-dependencies</descriptorRef>
+					</descriptorRefs>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.thrift.tools</groupId>
+				<artifactId>maven-thrift-plugin</artifactId>
+				<version>0.1.10</version>
+				<executions>
+					<execution>
+						<id>thrift-sources</id>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>compile</goal>
+						</goals>
+					</execution>
+					<execution>
+						<id>thrift-test-sources</id>
+						<phase>generate-test-sources</phase>
+						<goals>
+							<goal>testCompile</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings 
+					only. It has no influence on the Maven build itself. -->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>org.apache.thrift.tools</groupId>
+										<artifactId>maven-thrift-plugin</artifactId>
+										<versionRange>[0.1.10,)</versionRange>
+										<goals>
+											<goal>testCompile</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore />
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>[0.0.0,)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.7.5</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-dbcp</groupId>
+			<artifactId>commons-dbcp</artifactId>
+			<version>[1.2, 1.3)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-utils</artifactId>
+			<version>[1.1.0, 1.3.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-commons</artifactId>
+			<version>[1.1.0, 1.3.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.thrift</groupId>
+			<artifactId>libthrift</artifactId>
+			<version>0.8.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.postgresql</groupId>
+			<artifactId>jdbc4driver</artifactId>
+			<version>9.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.velocity</groupId>
+			<artifactId>velocity</artifactId>
+			<version>1.7</version>
+		</dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.googlecode.json-simple</groupId>
+            <artifactId>json-simple</artifactId>
+            <version>1.1</version>
+        </dependency>
+    </dependencies>
+
+</project>
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/action/relation.vm
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(revision 47510)
@@ -0,0 +1,5 @@
+<RELATIONS>
+#foreach ($rel in $relations)
+    <RELATION type='$rel.Type' source='$rel.SourceId' target='$rel.TargetId' />
+#end
+</RELATIONS>
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/action/relation.vm
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(revision 47510)
@@ -0,0 +1,5 @@
+<RELATIONS>
+#foreach ($rel in $relations)
+    <RELATION type='$rel.Type' source='$rel.SourceId' target='$rel.TargetId' />
+#end
+</RELATIONS>
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(revision 47510)
@@ -0,0 +1,192 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertServiceException;
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.List;
+
+public class OpenAIREConnectorImpl implements OpenAIREConnector.Iface {
+	private static final Logger logger = Logger.getLogger(OpenAIREConnectorImpl.class);
+
+	private ClaimConnector claimConnector;
+	private AlertConnector alertConnector;
+
+	public void setClaimConnector(final ClaimConnector claimConnector) {
+		this.claimConnector = claimConnector;
+	}
+
+	public void setAlertConnector(final AlertConnector alertConnector) {
+		this.alertConnector = alertConnector;
+	}
+
+	@Override
+	public List<Claim> getClaimedPublications(final String user) throws TException {
+		try {
+			return claimConnector.getClaimedPublications(user);
+		} catch (final Exception e) {
+			logger.error("Error retrieving claimed publications (user: " + user + ")", e);
+			throw new TException("Error retrieving claimed publications (user: " + user + ")", e);
+		}
+	}
+
+    @Override
+    public List<Claim> getAllClaimedPublications(long from, long to) throws TException {
+        try {
+            return claimConnector.getClaimedPublications(new Date(from), new Date(to));
+        } catch (Exception e) {
+            logger.error("Error retrieving claimed publications", e);
+
+            throw new TException("Error retrieving claimed publications", e);
+        }
+    }
+
+    @Override
+    public String insertDocument(String originalId, String source, String title, String description, String access_mode,
+                                 String embargoEndDate, List<Author> authors, String url, String dcSource,
+                                 String userEmail, List<String> subjects, String publicationDate, String publisher,
+                                 String language, String category, String doi, List<Project4Index> project4Indexes,
+                                 List<String> concepts) throws org.apache.thrift.TException {
+        try {
+            logger.info("concepts " + concepts);
+            return claimConnector.insertDocument(originalId, source, title, description, access_mode, embargoEndDate,
+                    authors, url, dcSource, userEmail, subjects, publicationDate, publisher, language, category, doi,
+                    project4Indexes, concepts);
+        } catch (Exception e) {
+            logger.error("Error adding document", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertConcept(String docId, String documentSource, String concept, String userEmail, String doi) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertConceptRelation(docId, documentSource, concept, userEmail, doi);
+        } catch (Exception e) {
+            logger.error("Error adding concept relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertProjectRelation(docId, documentSource, project, userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding project relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws TException {
+        try {
+            claimConnector.insertResultRelation(sourceResultId, sourceResultType, sourceResultSource, targetResultId, targetResultType,userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding result relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+	public List<AlertSubscription> getSubscriptions(final String alertMode, final String subscriber, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getSubscriptions(alertMode, subscriber, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+	@Override
+	public void addSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.addSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		}
+	}
+
+	@Override
+	public void removeSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.removeSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		}
+	}
+
+	@Override
+	public int countAlertResults(final String notificationService, final String queryId, final long date, final String resultId) throws TException {
+		try {
+			return alertConnector.countAlertResults(notificationService, queryId, date, resultId);
+		} catch (final AlertServiceException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		}
+	}
+
+	@Override
+	public ResultPage getAlertResults(final String notificationService, final String queryId, final String resultId, final long fromDate, final long toDate, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getAlertResults(notificationService, queryId, resultId, fromDate, toDate, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+    @Override
+    public void deleteClaim(String userEmail, String resultId) throws TException {
+        try {
+            claimConnector.deleteClaim(userEmail, resultId);
+        } catch (Exception e) {
+            logger.error("Error deleting claim", e);
+
+            throw new TException(e);
+        }
+    }
+
+	@Override
+	public List<String> getContexts() throws TException {
+		try {
+			return claimConnector.getContexts();
+		} catch (Exception e) {
+			logger.error("Error getting contexts from IS.", e);
+			
+			throw new TException(e);
+		}
+		
+	}
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/ehcache.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/ehcache.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/ehcache.xml	(revision 47510)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
+    <!--
+     | Please see http://ehcache.sourceforge.net/documentation/configuration.html for
+     | detailed information on how to configurigure caches in this file
+     +-->
+    <!-- Location of persistent caches on disk -->
+    <diskStore path="java.io.tmpdir/EhCacheSpringAnnotationsExampleApp" />
+
+    <defaultCache eternal="true" maxElementsInMemory="10000"
+        overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
+        timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU"/>
+
+	<cache name="claimator"/>
+	<cache name="alertator.subscriptions"/>
+	<cache name="querynator"/>
+</ehcache>
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(revision 47510)
@@ -0,0 +1,9 @@
+openaire.connector.thrift.port = 7911
+openaire.connector.thrift.timeout = 15000
+
+openaire.connector.unknownRepositoryName = Unknown Repository
+
+openaire.db.driverClassName = org.postgresql.Driver
+openaire.db.url = jdbc:postgresql://194.177.192.223:5432/dnet_claims
+openaire.db.username = dnet
+openaire.db.password = dnetPwd
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/action/IndexUtils.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/action/IndexUtils.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/java/eu/dnetlib/openaire/action/IndexUtils.java	(revision 47510)
@@ -0,0 +1,341 @@
+package eu.dnetlib.openaire.action;
+
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.Project;
+import eu.dnetlib.openaire.thrift.Project4Index;
+import org.apache.log4j.Logger;
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import sun.net.www.protocol.http.HttpURLConnection;
+
+import java.io.*;
+import java.net.URL;
+import java.util.List;
+
+/**
+ * Created by kiatrop on 26/1/2016.
+ */
+public class IndexUtils {
+
+    private static final Logger logger = Logger.getLogger(IndexUtils.class);
+
+    public static JSONObject createJSON(String id, String source, String title, String description, String access_mode,
+                                        String embargoEndDate, List<Author> authors, String url, String dcSource,
+                                        String doi, List<Project> projects, List<String> subjects, List<String> concepts,
+                                        String publicationDate, String publisher, String language, String category,
+                                        boolean isConcept, List<Project4Index> project4Indexes, List<String> concepts4index) throws Exception {
+
+        if (source.equals("openaire"))
+            throw new IllegalArgumentException("cannot create JSON for openaire");
+
+        //logger.info("create JSON for doi " + doi);
+        //logger.info("projects " + project4Indexes);
+
+        //if the orcid id exists
+        String orcid = null;
+        String hostedby = null;
+        String hostedbyName = null;
+        String collectedFrom = null;
+        String collectedFromName = null;
+        String recordIdentifier = id;
+
+        if (source.equals("doi") && !isConcept) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::crossref";
+            collectedFromName = "Crossref";
+            doi = id;
+
+        } else if (source.equals("datacite")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::datacite";
+            collectedFromName = "Datacite";
+
+        } else if (source.equals("orcid")) {
+            orcid = id;
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::orcid";
+            collectedFromName = "ORCID";
+
+        } else if (source.equals("driver")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::driver";
+            collectedFromName = "Digital Repository Infrastructure Vision for European Research";
+        }
+
+        JSONObject claimJSON = new JSONObject();
+        String prefix = ActionUtils.getPrefix(source);
+        claimJSON.put("originalId", id);
+        claimJSON.put("title", title);
+
+        JSONArray authorsJSONArray = new JSONArray();
+        for (Author author: authors) {
+            authorsJSONArray.add(author.getFirstName() + " " + author.getLastName());
+        }
+        claimJSON.put("authors", authorsJSONArray);
+
+        claimJSON.put("publisher", publisher);
+        claimJSON.put("description", description);
+        claimJSON.put("language", language);
+
+        JSONArray pidsJSONArray = new JSONArray();
+        JSONObject pidJSON = null;
+        if (doi != null) {
+            pidJSON = new JSONObject();
+            pidJSON.put("type", "doi");
+            pidJSON.put("value", doi);
+            pidsJSONArray.add(pidJSON);
+        }
+        if (orcid != null) {
+            pidJSON = new JSONObject();
+            pidJSON.put("type", "orcidworkid");
+            pidJSON.put("value", orcid);
+            pidsJSONArray.add(pidJSON);
+        }
+        claimJSON.put("pids", pidsJSONArray);
+
+        claimJSON.put("licenseCode", access_mode);
+        if(source.equals("crossref")) {
+            claimJSON.put("resourceType", "0001");
+        } else if (source.equals("datacite")) {
+            claimJSON.put("resourceType", "0021");
+        } else {
+            claimJSON.put("resourceType", "0001");
+        }
+
+        claimJSON.put("url", url);
+        claimJSON.put("collectedFromId", collectedFrom);
+        claimJSON.put("hostedById", hostedby);
+
+        JSONArray linksToProjectsJSONArray = new JSONArray();
+        for (Project4Index project:project4Indexes) {
+            linksToProjectsJSONArray.add(createProjectPath(project)) ;
+        }
+        claimJSON.put("linksToProjects",linksToProjectsJSONArray);
+
+        JSONArray contextsJSONArray = new JSONArray();
+        if(!concepts4index.isEmpty()) {
+            for (String context: concepts4index) {
+                contextsJSONArray.add(context); //TODO check
+            }
+        }
+        claimJSON.put("contexts", contextsJSONArray);
+
+        return claimJSON;
+    }
+
+    public static void feedIndex(String id, String source, String title,
+                                 String description, String access_mode, String embargoEndDate,
+                                 List<Author> authors, String url, String dcSource, String doi,
+                                 List<Project> projects, List<String> subjects, List<String> concepts,
+                                 String publicationDate, String publisher, String language, String category,
+                                 boolean isConcept, List<Project4Index> project4Indexes, List<String> concepts4index,
+                                 String directClaimAPIUrl) throws Exception {
+
+        logger.info("number of projects " + project4Indexes);
+        if (project4Indexes!= null) {
+            logger.info("number of projects " + project4Indexes.size());
+        }
+
+        URL obj = new URL(directClaimAPIUrl);
+        HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+        JSONObject claimJson = createJSON(id, source, title, description, access_mode, embargoEndDate,
+                                    authors, url, dcSource, doi, projects, subjects, concepts, publicationDate,
+                                    publisher, language, category, isConcept, project4Indexes, concepts4index);
+        //add request header
+        con.setRequestMethod("POST");
+        //con.setRequestProperty("User-Agent", USER_AGENT);
+        con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
+        con.setRequestProperty("Content-Type", "application/json");
+
+        logger.info("Feeding index with " + claimJson.toJSONString());
+        String urlParameters = claimJson.toJSONString();
+
+        // Send post request
+        con.setDoOutput(true);
+        DataOutputStream wr = new DataOutputStream(con.getOutputStream());
+        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(wr, "UTF-8"));
+        writer.write(urlParameters);
+        writer.close();
+        wr.close();
+
+        int responseCode = con.getResponseCode();
+        System.out.println("\nSending 'POST' request to URL : " + url);
+        System.out.println("Post parameters : " + urlParameters);
+        System.out.println("Response Code : " + responseCode);
+
+        BufferedReader in = new BufferedReader(
+                new InputStreamReader(con.getInputStream()));
+        String inputLine;
+        StringBuffer response = new StringBuffer();
+
+        while ((inputLine = in.readLine()) != null) {
+            response.append(inputLine);
+        }
+        in.close();
+
+        //print result
+        System.out.println(response.toString());
+    }
+
+    private static String createProjectPath(Project4Index project) {
+        if (project.getFunder().equals("EC")) {
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/EC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/EU//"+project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/EC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/EU//"+project.getName();
+        }
+
+        if (project.getFunder().equals("WT")) {
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/WT//"+project.getCode()+"//" + project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/WT//"+project.getCode()+project.getName();
+        }
+
+        if (project.getFunder().equals("ARC")) {
+            logger.debug("name: '" + project.getName()+"'");
+            logger.debug("name: '" + project.getAcronym()+"'");
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/ARC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/AU//"+project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/ARC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/AU//"+project.getName();
+        }
+
+        if (project.getFunder().equals("NHMRC")) {
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/NHMRC/"+project.getFundingStreamLevel0()+"/"
+                        +project.getCode()+"/AU//"+project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/NHMRC/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/AU//"+project.getName();
+        }
+
+        if (project.getFunder().equals("FCT")) {
+            if(project.getAcronym() != null && !project.getAcronym().trim().isEmpty())
+                return "info:eu-repo/grantAgreement/FCT/"+project.getFundingStreamLevel0()+"/"
+                        +project.getCode()+"/PT//"+project.getAcronym();
+
+            return "info:eu-repo/grantAgreement/FCT/"+project.getFundingStreamLevel0()+"/"
+                    +project.getCode()+"/PT//"+project.getName();
+        }
+
+        return "";
+    }
+
+    public static void main(String[] args) throws IOException {
+
+        String url = "http://beta.services.openaire.eu:8280/is/mvc/api/publications/feedObject";
+        URL obj = new URL(url);
+        HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+
+        //add reuqest header
+        con.setRequestMethod("POST");
+        //con.setRequestProperty("User-Agent", USER_AGENT);
+        con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
+        con.setRequestProperty("Content-Type", "application/json");
+
+
+        /*String urlParameters = "{\n" +
+                "\"collectedFromId\": \"openaire____::crossref\",\n" +
+                "\"authors\": [\"George Papastefanatos\", \"Panos Vassiliadis\", \"Alkis Simitsis\", \"Yannis Vassiliou\"],\n" +
+                "\"title\": \"HECATAEUS: Regulating schema evolution\",\n" +
+                "\"hostedById\": \"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\",\n" +
+                "\"licenseCode\": \"OPEN\",\n" +
+                "\"pids\": [{\n" +
+                "\"value\": \"10.1109\\/icde.2010.5447778\",\n" +
+                "\"type\": \"doi\"\n" +
+                "}],\n" +
+                "\"description\": null,\n" +
+                "\"originalId\": \"crossref____::817ee94bc4a0515adadb1fdaa78927f6\",\n" +
+                "\"contexts\": [],\n" +
+                "\"language\": null,\n" +
+                "\"linksToProjects\": [\"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus\"],\n" +
+                "\"url\": \"http:\\/\\/dx.doi.org\\/10.1109\\/icde.2010.5447778\",\n" +
+                "\"resourceType\": \"0001\",\n" +
+                "\"publisher\": \"Institute of Electrical & Electronics Engineers (IEEE)\"\n" +
+                "}";
+
+        String urlParameters = "{\n" +
+                "\"collectedFromId\": \"openaire____::crossref\",\n" +
+                "\"authors\": [\"George Papastefanatos\", \"Panos Vassiliadis\", \"Alkis Simitsis\", \"Yannis Vassiliou\"],\n" +
+                " \"title\": \"â\\\\ dark bottomless Abyss, that lies under our feet, had yawned openâ\\\\\",\n" +
+                "\"hostedById\": \"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\",\n" +
+                "\"licenseCode\": \"CLOSED\",\n" +
+                "\"pids\": [{\n" +
+                "\"value\": \"10.1007\\/s13740_012_0006_9\",\n" +
+                "\"type\": \"doi\"\n" +
+                "}],\n" +
+                "\"description\": null,\n" +
+                "\"originalId\": \"crossref____::test\",\n" +
+                "\"contexts\": [\"egi::classification::natsc::infos::dmin\"], " +
+                "\"language\": null, " +
+                "\"linksToProjects\": [\"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus\"], " +
+                "\"url\": \"http:\\/\\/dx.doi.org\\/10.1007\\/s13740_012_0006_9\", " +
+                "\"resourceType\": \"0001\", " +
+                "\"publisher\": \"Springer Science + Business Media\" " +
+                "}";
+*/
+
+        String urlParameters = "{ " +
+                "\"collectedFromId\": \"openaire____::crossref\", " +
+                "\"authors\": [\"Agapi Dalkou\"], " +
+                "\"title\": \"Η ανάπτυξη ερμηνευτικών στρατηγικών στο μάθημα της νεοελληνικής λογοτεχνίας στη δευτεροβάθμια εκπαίδευση σε περιβάλλον συνεργατικής μάθησης\", " +
+                "\"hostedById\": \"openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18\", " +
+                "\"licenseCode\": \"CLOSED\", " +
+                "\"pids\": [{ " +
+                "\"value\": \"10.12681\\/eadd\\/29202\", " +
+                "\"type\": \"doi\" " +
+                "}], " +
+                "\"description\": null, " +
+                "\"originalId\": \"crossref____::cf7d85a13ac43f92431b102723d13d5a\", " +
+                "\"contexts\": [\"egi\", \"egi::country::gr\"], " +
+                "\"language\": null, " +
+                "\"linksToProjects\": [\"info:eu-repo\\/grantAgreement\\/EC\\/FP7\\/246686\\/EU\\/\\/OPENAIRE\", \"info:eu-repo\\/grantAgreement\\/EC\\/FP7\\/288611\\/EU\\/\\/ECODRIVER\"], " +
+                "\"url\": \"http:\\/\\/dx.doi.org\\/10.12681\\/eadd\\/29202\", " +
+                "\"resourceType\": \"0001\", " +
+                "\"publisher\": \"National Documentation Centre\"" +
+                "}";
+
+        // Send post request
+        con.setDoOutput(true);
+        /*DataOutputStream wr = new DataOutputStream(con.getOutputStream());
+        wr.writeBytes(urlParameters);
+        wr.flush();
+        wr.close();
+        */
+
+        DataOutputStream wr = new DataOutputStream(con.getOutputStream());
+        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(wr, "UTF-8"));
+        writer.write(urlParameters);
+        writer.close();
+        wr.close();
+
+
+        int responseCode = con.getResponseCode();
+        System.out.println(" Sending 'POST' request to URL : " + url);
+        System.out.println("Post parameters : " + urlParameters);
+        System.out.println("Response Code : " + responseCode);
+
+        BufferedReader in = new BufferedReader(
+                new InputStreamReader(con.getInputStream()));
+        String inputLine;
+        StringBuffer response = new StringBuffer();
+
+        while ((inputLine = in.readLine()) != null) {
+            response.append(inputLine);
+        }
+        in.close();
+
+        //print result
+        System.out.println(response.toString());
+    }
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(revision 47510)
@@ -0,0 +1,25 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+
+public class ThriftClient {
+
+	public OpenAIREConnector.Client getConnector() throws TTransportException {
+		return getConnector("localhost", 7911);
+	}
+
+	public OpenAIREConnector.Client getConnector(String host, int port) throws TTransportException {
+		TTransport transport = new TSocket(host, port);
+		transport.open();
+
+		TProtocol protocol = new  TBinaryProtocol(transport);
+		
+		return new OpenAIREConnector.Client(protocol);
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/deploy.info
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/deploy.info	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/deploy.info	(revision 47510)
@@ -0,0 +1,10 @@
+{
+  "type_source": "SVN", 
+  "goal": "package -U -T 4C source:jar", 
+  "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk", 
+  "deploy_repository": "dnet4-snapshots", 
+  "version": "4", 
+  "mail": "antleb@di.uoa.gr, kiatrop@di.uoa.gr", 
+  "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", 
+  "name": "uoa-openaire-connector"
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(revision 47510)
@@ -0,0 +1,57 @@
+<?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:tx="http://www.springframework.org/schema/tx"
+
+        xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/tx
+        http://www.springframework.org/schema/tx/spring-tx.xsd">
+		
+	<bean id="openaire.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+		<property name="driverClassName" value="${openaire.db.driverClassName}" />
+		<property name="url" value="${openaire.db.url}" />
+		<property name="username" value="${openaire.db.username}" />
+		<property name="password" value="${openaire.db.password}" />
+		<property name="maxIdle" value="10" />
+		<property name="maxActive" value="100" />
+		<property name="maxWait" value="10000" />
+		<property name="validationQuery" value="SELECT 1;" />
+		<property name="testOnBorrow" value="true" />
+		<property name="testOnReturn" value="true" />
+		<property name="testWhileIdle" value="true" />
+		<property name="timeBetweenEvictionRunsMillis" value="1200000" />
+		<property name="minEvictableIdleTimeMillis" value="1800000" />
+		<property name="numTestsPerEvictionRun" value="5" />
+		<property name="poolPreparedStatements" value="true" />
+		<property name="defaultAutoCommit" value="true" />
+	</bean>
+
+	<bean id="claimConnector" class="eu.dnetlib.openaire.thrift.ClaimConnector">
+		<property name="datasource" ref="openaire.dataSource" />
+		<property name="lookupServiceLocator" ref="lookupServiceLocator"/>
+		<property name="directClaimAPIUrl" value="${openaire.connector.api.directClaimAPIUrl}"/>
+	</bean>
+	
+	<bean id="alertConnector" class="eu.dnetlib.openaire.thrift.AlertConnector">
+		<property name="alertServiceLocator" ref="alertServiceLocator" />
+	</bean>
+	
+	<bean id="openAireConnector" class="eu.dnetlib.openaire.thrift.OpenAIREConnectorImpl">
+		<property name="claimConnector" ref="claimConnector" />
+		<property name="alertConnector" ref="alertConnector" />
+	</bean>
+	
+	<bean id="thriftServer" class="eu.dnetlib.openaire.thrift.ThriftServer" init-method="start" destroy-method="stop">
+		<property name="openAireConnector" ref="openAireConnector" />
+		<property name="port" value="${openaire.connector.thrift.port}"/>
+		<property name="timeout" value="${openaire.connector.thrift.timeout}" />
+	</bean>
+
+    <tx:annotation-driven transaction-manager="txManager"/>
+    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="openaire.dataSource"/>
+    </bean>
+
+</beans>
+
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/ehcache.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/ehcache.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src/main/resources/ehcache.xml	(revision 47510)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
+    <!--
+     | Please see http://ehcache.sourceforge.net/documentation/configuration.html for
+     | detailed information on how to configurigure caches in this file
+     +-->
+    <!-- Location of persistent caches on disk -->
+    <diskStore path="java.io.tmpdir/EhCacheSpringAnnotationsExampleApp" />
+
+    <defaultCache eternal="true" maxElementsInMemory="10000"
+        overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
+        timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU"/>
+
+	<cache name="claimator"/>
+	<cache name="alertator.subscriptions"/>
+	<cache name="querynator"/>
+</ehcache>
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.2
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+.project
+.settings
+.idea
+*.iml
+target
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/pom.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/pom.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/pom.xml	(revision 47510)
@@ -0,0 +1,143 @@
+<?xml version="1.0"?>
+<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>uoa-openaire-connector</artifactId>
+	<version>1.3.0</version>
+        <scm>
+                <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/tags/uoa-openaire-connector-1.3.0</developerConnection>
+        </scm>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>dtrotts</id>
+			<name>Repository for maven thrift plugin</name>
+			<url>http://maven.davidtrott.com/repository</url>
+			<layout>default</layout>
+		</pluginRepository>
+	</pluginRepositories>
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<archive>
+
+					</archive>
+					<descriptorRefs>
+						<descriptorRef>jar-with-dependencies</descriptorRef>
+					</descriptorRefs>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.thrift.tools</groupId>
+				<artifactId>maven-thrift-plugin</artifactId>
+				<version>0.1.10</version>
+				<executions>
+					<execution>
+						<id>thrift-sources</id>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>compile</goal>
+						</goals>
+					</execution>
+					<execution>
+						<id>thrift-test-sources</id>
+						<phase>generate-test-sources</phase>
+						<goals>
+							<goal>testCompile</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings 
+					only. It has no influence on the Maven build itself. -->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>org.apache.thrift.tools</groupId>
+										<artifactId>maven-thrift-plugin</artifactId>
+										<versionRange>[0.1.10,)</versionRange>
+										<goals>
+											<goal>testCompile</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore />
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>[0.0.0,)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.7.5</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-dbcp</groupId>
+			<artifactId>commons-dbcp</artifactId>
+			<version>[1.2, 1.3)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-utils</artifactId>
+			<version>[1.1.0, 1.2.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-commons</artifactId>
+			<version>[1.1.0, 1.2.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.thrift</groupId>
+			<artifactId>libthrift</artifactId>
+			<version>0.8.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.postgresql</groupId>
+			<artifactId>jdbc4driver</artifactId>
+			<version>9.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.velocity</groupId>
+			<artifactId>velocity</artifactId>
+			<version>1.7</version>
+		</dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(revision 47510)
@@ -0,0 +1,25 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+
+public class ThriftClient {
+
+	public OpenAIREConnector.Client getConnector() throws TTransportException {
+		return getConnector("localhost", 7911);
+	}
+
+	public OpenAIREConnector.Client getConnector(String host, int port) throws TTransportException {
+		TTransport transport = new TSocket(host, port);
+		transport.open();
+
+		TProtocol protocol = new  TBinaryProtocol(transport);
+		
+		return new OpenAIREConnector.Client(protocol);
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(revision 47510)
@@ -0,0 +1,185 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertServiceException;
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.List;
+
+public class OpenAIREConnectorImpl implements OpenAIREConnector.Iface {
+	private static final Logger logger = Logger.getLogger(OpenAIREConnectorImpl.class);
+
+	private ClaimConnector claimConnector;
+	private AlertConnector alertConnector;
+
+	public void setClaimConnector(final ClaimConnector claimConnector) {
+		this.claimConnector = claimConnector;
+	}
+
+	public void setAlertConnector(final AlertConnector alertConnector) {
+		this.alertConnector = alertConnector;
+	}
+
+	@Override
+	public List<Claim> getClaimedPublications(final String user) throws TException {
+		try {
+			return claimConnector.getClaimedPublications(user);
+		} catch (final Exception e) {
+			logger.error("Error retrieving claimed publications (user: " + user + ")", e);
+			throw new TException("Error retrieving claimed publications (user: " + user + ")", e);
+		}
+	}
+
+    @Override
+    public List<Claim> getAllClaimedPublications(long from, long to) throws TException {
+        try {
+            return claimConnector.getClaimedPublications(new Date(from), new Date(to));
+        } catch (Exception e) {
+            logger.error("Error retrieving claimed publications", e);
+
+            throw new TException("Error retrieving claimed publications", e);
+        }
+    }
+
+    @Override
+    public String insertDocument(String originalId, String source, String title, String description, String access_mode, String embargoEndDate, List<Author> authors, String url, String dcSource, String userEmail, List<String> subjects, String publicationDate, String publisher, String language, String category, String doi) throws org.apache.thrift.TException {
+        try {
+            return claimConnector.insertDocument(originalId, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, userEmail, subjects, publicationDate, publisher, language, category, doi);
+        } catch (Exception e) {
+            logger.error("Error adding document", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertConcept(String docId, String documentSource, String concept, String userEmail, String doi) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertConceptRelation(docId, documentSource, concept, userEmail, doi);
+        } catch (Exception e) {
+            logger.error("Error adding concept relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertProjectRelation(docId, documentSource, project, userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding project relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws TException {
+        try {
+            claimConnector.insertResultRelation(sourceResultId, sourceResultType, sourceResultSource, targetResultId, targetResultType,userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding result relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+	public List<AlertSubscription> getSubscriptions(final String alertMode, final String subscriber, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getSubscriptions(alertMode, subscriber, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+	@Override
+	public void addSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.addSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		}
+	}
+
+	@Override
+	public void removeSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.removeSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		}
+	}
+
+	@Override
+	public int countAlertResults(final String notificationService, final String queryId, final long date, final String resultId) throws TException {
+		try {
+			return alertConnector.countAlertResults(notificationService, queryId, date, resultId);
+		} catch (final AlertServiceException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		}
+	}
+
+	@Override
+	public ResultPage getAlertResults(final String notificationService, final String queryId, final String resultId, final long fromDate, final long toDate, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getAlertResults(notificationService, queryId, resultId, fromDate, toDate, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+    @Override
+    public void deleteClaim(String userEmail, String resultId) throws TException {
+        try {
+            claimConnector.deleteClaim(userEmail, resultId);
+        } catch (Exception e) {
+            logger.error("Error deleting claim", e);
+
+            throw new TException(e);
+        }
+    }
+
+	@Override
+	public List<String> getContexts() throws TException {
+		try {
+			return claimConnector.getContexts();
+		} catch (Exception e) {
+			logger.error("Error getting contexts from IS.", e);
+			
+			throw new TException(e);
+		}
+		
+	}
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(revision 47510)
@@ -0,0 +1,84 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertService;
+import eu.dnetlib.api.functionality.AlertServiceException;
+import gr.uoa.di.driver.util.ServiceLocator;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+public class AlertConnector {
+	private ServiceLocator<AlertService> alertServiceLocator;
+
+	public void setAlertServiceLocator(
+			final ServiceLocator<AlertService> alertServiceLocator) {
+		this.alertServiceLocator = alertServiceLocator;
+	}
+
+	public List<AlertSubscription> getSubscriptions(final String alertMode,
+			final String subscriber, final int limit, final int offset)
+			throws AlertServiceException {
+		final List<AlertSubscription> subscriptions = new ArrayList<AlertSubscription>();
+		for (eu.dnetlib.domain.functionality.AlertSubscription subscription : alertServiceLocator
+				.getService().getSubscriptions(alertMode, subscriber, limit,
+						offset))
+			subscriptions.add(new AlertSubscription(subscription
+					.getTemplateId(), subscription.getNotificationService()
+					.toString(), subscription.getQueryId(), subscription
+					.getResultId(), subscription.getAlertMode(), subscription
+					.getSubscriber().toString()));
+		return subscriptions;
+	}
+
+	public void addSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().addSubscription(
+				new eu.dnetlib.domain.functionality.AlertSubscription(
+						subscription.getTemplateId(), new URL(subscription
+								.getNotificationService()), subscription
+								.getQueryId(), subscription.getResultId(),
+						subscription.getAlertMode(), new URI(subscription
+								.getSubscriber()), true));
+	}
+
+	public void removeSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().removeSubscription(
+				subscription.getTemplateId(),
+				new URL(subscription.getNotificationService()),
+				subscription.getQueryId(), subscription.getResultId(),
+				subscription.getAlertMode(),
+				new URI(subscription.getSubscriber()));
+	}
+
+	public int countAlertResults(final String notificationService,
+			final String queryId, final long date, final String resultId)
+			throws AlertServiceException, MalformedURLException {
+		return alertServiceLocator.getService()
+				.countAlertResults(new URL(notificationService), queryId,
+						new Date(date), resultId);
+	}
+
+	public ResultPage getAlertResults(final String notificationService,
+			final String queryId, final String resultId, final long fromDate,
+			final long toDate, final int limit, final int offset)
+			throws AlertServiceException, MalformedURLException {
+		final eu.dnetlib.domain.functionality.ResultPage resultPage = alertServiceLocator
+				.getService().getAlertResults(new URL(notificationService),
+						queryId, resultId, new Date(fromDate),
+						new Date(toDate), limit, offset);
+		final List<List<String>> rows = new ArrayList<List<String>>();
+		for (String[] row : resultPage.getRows())
+			rows.add(Arrays.asList(row));
+		return new ResultPage(resultPage.getLimit(), resultPage.getOffset(),
+				Arrays.asList(resultPage.getColumns()), rows);
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(revision 47510)
@@ -0,0 +1,285 @@
+package eu.dnetlib.openaire.action;
+
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.Project;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+import java.io.StringWriter;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class ActionUtils {
+
+	private static Logger logger = Logger.getLogger(ActionUtils.class);
+
+	public static String createResultProjectRelation(String source,
+			String resultId, String projectType, String projectId)
+			throws Exception {
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+		ve.init();
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+		VelocityContext vc = new VelocityContext();
+
+		List<Relation> rels = new ArrayList<Relation>();
+
+		rels.add(createRelation(source, resultId, projectType, projectId));
+
+		vc.put("relations", rels);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+
+		return sw.toString();
+	}
+
+    public static String createResultResultRelation(String sourceResultId, String sourceResultType, String targetResultId, String targetResultType) {
+        VelocityEngine ve = new VelocityEngine();
+        ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+        ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+        ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+        ve.init();
+
+        Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+        VelocityContext vc = new VelocityContext();
+
+        List<Relation> rels = new ArrayList<Relation>();
+
+        rels.add(new Relation("resultResult_" + sourceResultType + targetResultType + "_isRelatedTo", "50|" + sourceResultId, "50|" + targetResultId));
+
+        vc.put("relations", rels);
+
+        StringWriter sw = new StringWriter();
+        t.merge(vc, sw);
+
+        return sw.toString();
+    }
+
+	// input id: 1306.3402
+	// oai:arXiv.org:1306.3402
+	// MD5("od________18::oai:arXiv.org:1306.3402")
+
+    /**
+     * Creates a new relation action.
+     * @param source the result source. If not null, the resultId is transformed to openaire id. If null, the result is
+     *               considered to be already an openaire result and is used verbatim
+     * @param resultId the result id
+     * @param projectType the project type. If not null, the projectId is transformed to openaire id. If null, the projectId is
+     *               considered to be already in openaire format and is used verbatim
+     * @param projectId the project id
+     *
+     * @return a relation
+     */
+	private static Relation createRelation(String source, String resultId,
+			String projectType, String projectId) {
+		String resultPrefix;
+		String projectPrefix = null;
+
+        if (!isValidOpenaireId(resultId) && source != null) {
+            if (source.equals("arxiv")) {
+                resultId = "oai:arXiv.org:" + resultId;
+            } else if (source.equals("pubmed")) {
+                resultId = "oai:europepmc.org:" + resultId;
+            }
+
+            resultPrefix = getPrefix(source);
+            resultId = getIdentifier(resultPrefix, resultId);
+        }
+
+	resultId = "50|" + resultId;
+
+        if (projectType != null) {
+            if (projectType.equals("ec")) {
+                projectPrefix = "corda_______";
+            } else if (projectType.equals("wt")) {
+                projectPrefix = "wt__________::WT";
+            }
+
+            projectId = projectPrefix + "::" + projectId;
+        }
+
+	projectId = "40|" + projectId;
+
+		return new Relation("resultProject", resultId, projectId);
+	}
+
+	private static boolean isValidOpenaireId(String resultId) {
+
+		return Pattern.matches("\\w{12}::[a-f0-9]{32}", resultId);
+	}
+
+	public static String getPrefix(String source) {
+        logger.debug("SOURCE " + source);
+		if (source == null || source.equals("openaire")) {
+			return "openaire____";
+		} else if (source.equals("doi")) {
+			return "crossref____";
+		} if (source.equals("orcid")) {
+            		return "orcid_______";
+		} else if (source.equals("datacite")) {
+			return "datacite____";
+		} else if (source.equals("driver")) {
+			return "driver______";
+		} else
+			return null;
+	}
+
+    public static String getProvenance(String source) {
+        if (source == null || source.equals("openaire"))
+            return "user:claim:search";
+        else if (source.equals("doi") || source.equals("orcid"))
+            return "user:claim:pid";
+		else if (source.equals("datacite"))
+			return "user:claim:datacite";
+        else
+            return null;
+    }
+
+	public static String createDMF(String id, String source, String title,
+			String description, String access_mode, String embargoEndDate,
+			List<Author> authors, String url, String dcSource, String doi,
+			List<Project> projects, List<String> subjects, List<String> concepts, String publicationDate, String publisher, String language, String category, boolean isConcept) throws Exception {
+
+        logger.info("create with doi " + doi);
+
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+		ve.init();
+		
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/dmf.vm");
+		VelocityContext vc = new VelocityContext();
+
+		String hostedby = null;
+		String hostedbyName = null;
+		String collectedFrom = null;
+		String collectedFromName = null;
+        String recordIdentifier = id;
+		String prefix = getPrefix(source);
+
+
+        //if the orcid id exists
+        String orcid = null;
+
+		if (source.equals("doi") && !isConcept) {
+			hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+			hostedbyName = "Unknown Repository";
+			collectedFrom = "openaire____::crossref";
+			collectedFromName = "Crossref";
+			doi = id;
+
+        } else if (source.equals("datacite")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::datacite";
+            collectedFromName = "Datacite";
+
+        } else if (source.equals("orcid")) {
+            orcid = id;
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::orcid";
+            collectedFromName = "ORCID";
+
+        } else if (source.equals("driver")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::driver";
+            collectedFromName = "Digital Repository Infrastructure Vision for European Research";
+        }
+
+        logger.info("create with doi " + doi);
+
+        if (doi != null) {
+            vc.put("doi", doi);
+        } else if (orcid != null){
+          //if there is no doi but we have an orcid, id we store it
+          vc.put("orcid", orcid);
+        }
+
+        // openaire ids should not be touched!
+        if (!source.equals("openaire"))
+		    id = getIdentifier(prefix, id);
+
+		vc.put("objIdentifier", id);
+		vc.put("recordIdentifier", recordIdentifier);
+		vc.put("dateOfCollection", DateUtils.calculate_ISO8601(System.currentTimeMillis()));
+		vc.put("hostedby", hostedby);
+		vc.put("collectedFrom", collectedFrom);
+		vc.put("hostedbyName", hostedbyName);
+		vc.put("collectedFromName", collectedFromName);
+        vc.put("embargoEndDate", embargoEndDate);
+		vc.put("title", title);
+		vc.put("description", description);
+		vc.put("accessMode", access_mode);
+		vc.put("dcSource", dcSource);
+		vc.put("url", url);
+		vc.put("publisher", publisher);
+		vc.put("language", language);
+		vc.put("objCategory", category);
+
+		vc.put("datasourceprefix", prefix);
+
+		List<String> creators = new ArrayList<String>();
+		for (Author author : authors) {
+            String name = author.getLastName();
+
+
+            if (author.getFirstName() != null && !author.getFirstName().trim().isEmpty())
+                name += ", " + author.getFirstName();
+
+            creators.add(name);
+		}
+
+		vc.put("creators", creators);
+		vc.put("projects", projects);
+		vc.put("subjects", subjects);
+        vc.put("concepts", concepts);
+		
+		if (publicationDate != null && !publicationDate.equals(""))
+			vc.put("publicationDate", publicationDate + "-01-01T00:00:00Z");
+		
+		vc.put("StringEscapeUtils", StringEscapeUtils.class);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+		
+		return sw.toString();
+	}
+
+	// private static String getIdentifier(String prefix, String id) {
+	// return prefix + "::" +
+	// com.google.common.hash.Hashing.md5().hashString(id).toString();
+	// }
+
+	public static String getIdentifier(String prefix, String id) {
+		try {
+            logger.debug("PREFIX " + prefix);
+			MessageDigest md = MessageDigest.getInstance("MD5");
+
+			md.update(id.getBytes("UTF-8"));
+
+			return prefix + "::" + new String(Hex.encodeHex(md.digest()));
+		} catch (Exception e) {
+			logger.error("Error creating id", e);
+			return null;
+		}
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/utils/claims.sql
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(revision 47510)
@@ -0,0 +1,45 @@
+select
+        r.resultid                                          as dri_objidentifier,
+        r.title                                             as dc_title,
+        array_agg(DISTINCT lpad('0'||aut.rank,5,'0')||'§§§'||ltrim(replace(per.surname||', '||per.name,'UNKNOWN, ',''), ', ')) as dc_creator,
+      r.description                                       as dc_description,
+        r.publisher                                         as dc_publisher,
+        r.keywords                                          as dc_subject,
+        r.language                                          as dc_language,
+        array_agg(DISTINCT ws.file_url)                     as dc_identifier,
+        r.publication_date                                  as oaf_publicationdate,
+        r.embargo_end_date                                  as oaf_embargoenddate,
+        r.access_mode                                       as oaf_accessmode,
+        r.haskind                                           as oaf_haskind,
+        r.hastype                                           as "dr_CobjCategory",
+        r.storagedate                                           as oaf_storagedate,
+        createdfrom                                         as createdfrom,
+        array_agg(DISTINCT p.projectid)                     as oaf_projectid,
+        array_agg(DISTINCT cr.creator)                              as creators
+
+from
+
+       results r
+        left outer join results_projects rp on (r.resultid = rp.result)
+        left outer join projects p on (p.projectid = rp.project)
+        left outer join projects_projectsubjects ps on (ps.project = p.projectID)
+        left outer join fundingschemes fs on (p.fundedhow = fs.fundingschemeid)
+        left outer join programs s on (p.fundedby = s.programid)
+        left outer join specificprograms sp on (s.hasspecificprogram = sp.specificprogramid)
+        left outer join frameworkprograms fp on (sp.hasframeworkprogram = fp.frameworkprogramid)
+        left outer join authorships aut on (r.resultid = aut.result)
+        left outer join persons per on (per.personid = aut.author)
+        left outer join organizations o on (o.organizationid = aut.affiliation)
+        left outer join instances i on (r.resultid = i.resource)
+        left outer join webresources_instances wsi on (wsi.instanceid = i.instanceid)
+        left outer join webresources ws on (ws.webresourceid = wsi.webresourceid)
+
+        join creations cr on cr.creation = r.resultid
+
+where
+        r.pmhdeleted != true and r.pendingforclaim = false
+
+group by
+        r.resultid, r.title, r.description, r.publisher, r.keywords, r.language,
+        r.publication_date, r.embargo_end_date, r.access_mode, r.haskind, r.hastype,
+        r.storagedate, r.createdfrom
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(revision 47510)
@@ -0,0 +1,57 @@
+<?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:tx="http://www.springframework.org/schema/tx"
+
+        xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/tx
+        http://www.springframework.org/schema/tx/spring-tx.xsd">
+		
+	<bean id="openaire.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+		<property name="driverClassName" value="${openaire.db.driverClassName}" />
+		<property name="url" value="${openaire.db.url}" />
+		<property name="username" value="${openaire.db.username}" />
+		<property name="password" value="${openaire.db.password}" />
+		<property name="maxIdle" value="10" />
+		<property name="maxActive" value="100" />
+		<property name="maxWait" value="10000" />
+		<property name="validationQuery" value="SELECT 1;" />
+		<property name="testOnBorrow" value="true" />
+		<property name="testOnReturn" value="true" />
+		<property name="testWhileIdle" value="true" />
+		<property name="timeBetweenEvictionRunsMillis" value="1200000" />
+		<property name="minEvictableIdleTimeMillis" value="1800000" />
+		<property name="numTestsPerEvictionRun" value="5" />
+		<property name="poolPreparedStatements" value="true" />
+		<property name="defaultAutoCommit" value="true" />
+	</bean>
+
+	<bean id="claimConnector" class="eu.dnetlib.openaire.thrift.ClaimConnector">
+		<property name="datasource" ref="openaire.dataSource" />
+		<property name="lookupServiceLocator" ref="lookupServiceLocator"/>
+	</bean>
+	
+	<bean id="alertConnector" class="eu.dnetlib.openaire.thrift.AlertConnector">
+		<property name="alertServiceLocator" ref="alertServiceLocator" />
+	</bean>
+	
+	<bean id="openAireConnector" class="eu.dnetlib.openaire.thrift.OpenAIREConnectorImpl">
+		<property name="claimConnector" ref="claimConnector" />
+		<property name="alertConnector" ref="alertConnector" />
+	</bean>
+	
+	<bean id="thriftServer" class="eu.dnetlib.openaire.thrift.ThriftServer" init-method="start" destroy-method="stop">
+		<property name="openAireConnector" ref="openAireConnector" />
+		<property name="port" value="${openaire.connector.thrift.port}"/>
+		<property name="timeout" value="${openaire.connector.thrift.timeout}" />
+	</bean>
+
+    <tx:annotation-driven transaction-manager="txManager"/>
+    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="openaire.dataSource"/>
+    </bean>
+
+
+</beans>
+
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/deploy.info
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/deploy.info	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0/deploy.info	(revision 47510)
@@ -0,0 +1,10 @@
+{
+  "type_source": "SVN", 
+  "goal": "package -U -T 4C source:jar", 
+  "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk", 
+  "deploy_repository": "dnet4-snapshots", 
+  "version": "4", 
+  "mail": "antleb@di.uoa.gr, kiatrop@di.uoa.gr", 
+  "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", 
+  "name": "uoa-openaire-connector"
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.3.0
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+.project
+.settings
+.idea
+*.iml
+target
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(revision 47510)
@@ -0,0 +1,281 @@
+package eu.dnetlib.openaire.action;
+
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.Project;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+import java.io.StringWriter;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class ActionUtils {
+
+	private static Logger logger = Logger.getLogger(ActionUtils.class);
+
+	public static String createResultProjectRelation(String source,
+			String resultId, String projectType, String projectId)
+			throws Exception {
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+		ve.init();
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+		VelocityContext vc = new VelocityContext();
+
+		List<Relation> rels = new ArrayList<Relation>();
+
+		rels.add(createRelation(source, resultId, projectType, projectId));
+
+		vc.put("relations", rels);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+
+		return sw.toString();
+	}
+
+    public static String createResultResultRelation(String sourceResultId, String sourceResultType, String targetResultId, String targetResultType) {
+        VelocityEngine ve = new VelocityEngine();
+        ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+        ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+        ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+        ve.init();
+
+        Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+        VelocityContext vc = new VelocityContext();
+
+        List<Relation> rels = new ArrayList<Relation>();
+
+        rels.add(new Relation("resultResult_" + sourceResultType + targetResultType + "_isRelatedTo", "50|" + sourceResultId, "50|" + targetResultId));
+
+        vc.put("relations", rels);
+
+        StringWriter sw = new StringWriter();
+        t.merge(vc, sw);
+
+        return sw.toString();
+    }
+
+	// input id: 1306.3402
+	// oai:arXiv.org:1306.3402
+	// MD5("od________18::oai:arXiv.org:1306.3402")
+
+    /**
+     * Creates a new relation action.
+     * @param source the result source. If not null, the resultId is transformed to openaire id. If null, the result is
+     *               considered to be already an openaire result and is used verbatim
+     * @param resultId the result id
+     * @param projectType the project type. If not null, the projectId is transformed to openaire id. If null, the projectId is
+     *               considered to be already in openaire format and is used verbatim
+     * @param projectId the project id
+     *
+     * @return a relation
+     */
+	private static Relation createRelation(String source, String resultId,
+			String projectType, String projectId) {
+		String resultPrefix;
+		String projectPrefix = null;
+
+        if (!isValidOpenaireId(resultId) && source != null) {
+            if (source.equals("arxiv")) {
+                resultId = "oai:arXiv.org:" + resultId;
+            } else if (source.equals("pubmed")) {
+                resultId = "oai:europepmc.org:" + resultId;
+            }
+
+            resultPrefix = getPrefix(source);
+            resultId = getIdentifier(resultPrefix, resultId);
+        }
+
+	resultId = "50|" + resultId;
+
+        if (projectType != null) {
+            if (projectType.equals("ec")) {
+                projectPrefix = "corda_______";
+            } else if (projectType.equals("wt")) {
+                projectPrefix = "wt__________::WT";
+            }
+
+            projectId = projectPrefix + "::" + projectId;
+        }
+
+	projectId = "40|" + projectId;
+
+		return new Relation("resultProject", resultId, projectId);
+	}
+
+	private static boolean isValidOpenaireId(String resultId) {
+
+		return Pattern.matches("\\w{12}::[a-f0-9]{32}", resultId);
+	}
+
+	public static String getPrefix(String source) {
+        logger.debug("SOURCE " + source);
+		if (source == null || source.equals("openaire")) {
+			return "openaire____";
+		} else if (source.equals("doi")) {
+			return "crossref____";
+		} if (source.equals("orcid")) {
+            		return "orcid_______";
+		} else if (source.equals("datacite")) {
+			return "datacite____";
+		} else if (source.equals("driver")) {
+			return "driver______";
+		} else
+			return null;
+	}
+
+    public static String getProvenance(String source) {
+        if (source == null || source.equals("openaire"))
+            return "user:claim:search";
+        else if (source.equals("doi") || source.equals("orcid"))
+            return "user:claim:pid";
+		else if (source.equals("datacite"))
+			return "user:claim:datacite";
+        else
+            return null;
+    }
+
+	public static String createDMF(String id, String source, String title,
+			String description, String access_mode, String embargoEndDate,
+			List<Author> authors, String url, String dcSource, String doi,
+			List<Project> projects, List<String> subjects, List<String> concepts, String publicationDate, String publisher, String language, String category) throws Exception {
+
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+		ve.init();
+		
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/dmf.vm");
+		VelocityContext vc = new VelocityContext();
+
+		String hostedby = null;
+		String hostedbyName = null;
+		String collectedFrom = null;
+		String collectedFromName = null;
+        String recordIdentifier = id;
+		String prefix = getPrefix(source);
+
+
+        //if the orcid id exists
+        String orcid = null;
+
+		if (source.equals("doi")) {
+			hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+			hostedbyName = "Unknown Repository";
+			collectedFrom = "openaire____::crossref";
+			collectedFromName = "Crossref";
+			doi = id;
+
+        } else if (source.equals("datacite")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::datacite";
+            collectedFromName = "Datacite";
+
+        } else if (source.equals("orcid")) {
+            orcid = id;
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::orcid";
+            collectedFromName = "ORCID";
+
+        } else if (source.equals("driver")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::driver";
+            collectedFromName = "Digital Repository Infrastructure Vision for European Research";
+        }
+
+        if (doi != null) {
+            vc.put("doi", doi);
+        } else if (orcid != null){
+          //if there is no doi but we have an orcid, id we store it
+          vc.put("orcid", orcid);
+        }
+
+        // openaire ids should not be touched!
+        if (!source.equals("openaire"))
+		    id = getIdentifier(prefix, id);
+
+		vc.put("objIdentifier", id);
+		vc.put("recordIdentifier", recordIdentifier);
+		vc.put("dateOfCollection", DateUtils.calculate_ISO8601(System.currentTimeMillis()));
+		vc.put("hostedby", hostedby);
+		vc.put("collectedFrom", collectedFrom);
+		vc.put("hostedbyName", hostedbyName);
+		vc.put("collectedFromName", collectedFromName);
+        vc.put("embargoEndDate", embargoEndDate);
+		vc.put("title", title);
+		vc.put("description", description);
+		vc.put("accessMode", access_mode);
+		vc.put("dcSource", dcSource);
+		vc.put("url", url);
+		vc.put("publisher", publisher);
+		vc.put("language", language);
+		vc.put("objCategory", category);
+
+		vc.put("datasourceprefix", prefix);
+
+		List<String> creators = new ArrayList<String>();
+		for (Author author : authors) {
+            String name = author.getLastName();
+
+
+            if (author.getFirstName() != null && !author.getFirstName().trim().isEmpty())
+                name += ", " + author.getFirstName();
+
+            creators.add(name);
+		}
+
+		vc.put("creators", creators);
+		vc.put("projects", projects);
+		vc.put("subjects", subjects);
+        vc.put("concepts", concepts);
+		
+		if (publicationDate != null && !publicationDate.equals(""))
+			vc.put("publicationDate", publicationDate + "-01-01T00:00:00Z");
+		
+		vc.put("StringEscapeUtils", StringEscapeUtils.class);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+		
+		return sw.toString();
+	}
+
+	// private static String getIdentifier(String prefix, String id) {
+	// return prefix + "::" +
+	// com.google.common.hash.Hashing.md5().hashString(id).toString();
+	// }
+
+	public static String getIdentifier(String prefix, String id) {
+		try {
+            logger.debug("PREFIX " + prefix);
+			MessageDigest md = MessageDigest.getInstance("MD5");
+
+			md.update(id.getBytes("UTF-8"));
+
+			return prefix + "::" + new String(Hex.encodeHex(md.digest()));
+		} catch (Exception e) {
+			logger.error("Error creating id", e);
+			return null;
+		}
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(revision 47510)
@@ -0,0 +1,84 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertService;
+import eu.dnetlib.api.functionality.AlertServiceException;
+import gr.uoa.di.driver.util.ServiceLocator;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+public class AlertConnector {
+	private ServiceLocator<AlertService> alertServiceLocator;
+
+	public void setAlertServiceLocator(
+			final ServiceLocator<AlertService> alertServiceLocator) {
+		this.alertServiceLocator = alertServiceLocator;
+	}
+
+	public List<AlertSubscription> getSubscriptions(final String alertMode,
+			final String subscriber, final int limit, final int offset)
+			throws AlertServiceException {
+		final List<AlertSubscription> subscriptions = new ArrayList<AlertSubscription>();
+		for (eu.dnetlib.domain.functionality.AlertSubscription subscription : alertServiceLocator
+				.getService().getSubscriptions(alertMode, subscriber, limit,
+						offset))
+			subscriptions.add(new AlertSubscription(subscription
+					.getTemplateId(), subscription.getNotificationService()
+					.toString(), subscription.getQueryId(), subscription
+					.getResultId(), subscription.getAlertMode(), subscription
+					.getSubscriber().toString()));
+		return subscriptions;
+	}
+
+	public void addSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().addSubscription(
+				new eu.dnetlib.domain.functionality.AlertSubscription(
+						subscription.getTemplateId(), new URL(subscription
+								.getNotificationService()), subscription
+								.getQueryId(), subscription.getResultId(),
+						subscription.getAlertMode(), new URI(subscription
+								.getSubscriber()), true));
+	}
+
+	public void removeSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().removeSubscription(
+				subscription.getTemplateId(),
+				new URL(subscription.getNotificationService()),
+				subscription.getQueryId(), subscription.getResultId(),
+				subscription.getAlertMode(),
+				new URI(subscription.getSubscriber()));
+	}
+
+	public int countAlertResults(final String notificationService,
+			final String queryId, final long date, final String resultId)
+			throws AlertServiceException, MalformedURLException {
+		return alertServiceLocator.getService()
+				.countAlertResults(new URL(notificationService), queryId,
+						new Date(date), resultId);
+	}
+
+	public ResultPage getAlertResults(final String notificationService,
+			final String queryId, final String resultId, final long fromDate,
+			final long toDate, final int limit, final int offset)
+			throws AlertServiceException, MalformedURLException {
+		final eu.dnetlib.domain.functionality.ResultPage resultPage = alertServiceLocator
+				.getService().getAlertResults(new URL(notificationService),
+						queryId, resultId, new Date(fromDate),
+						new Date(toDate), limit, offset);
+		final List<List<String>> rows = new ArrayList<List<String>>();
+		for (String[] row : resultPage.getRows())
+			rows.add(Arrays.asList(row));
+		return new ResultPage(resultPage.getLimit(), resultPage.getOffset(),
+				Arrays.asList(resultPage.getColumns()), rows);
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(revision 47510)
@@ -0,0 +1,340 @@
+package eu.dnetlib.openaire.thrift;
+
+
+import eu.dnetlib.api.enabling.ISLookUpService;
+import eu.dnetlib.api.enabling.ISLookUpServiceException;
+import eu.dnetlib.openaire.action.ActionUtils;
+import gr.uoa.di.driver.enabling.ISLookUpException;
+import gr.uoa.di.driver.util.ServiceLocator;
+import org.apache.log4j.Logger;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.springframework.jdbc.datasource.DataSourceUtils;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+@Transactional
+public class ClaimConnector {
+
+	private static Logger logger = Logger.getLogger(ClaimConnector.class);
+
+	private DataSource datasource = null;
+
+	//Using an isLookUp Impl just to make an xQuery to IS. Maybe move all the
+	//functionality to commons?
+	private ServiceLocator<ISLookUpService> lookupServiceLocator = null;
+
+	public List<Claim> getClaimedPublications(final String user) throws SQLException {
+		Connection con = DataSourceUtils.getConnection(datasource);
+		PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"date\" , \"type\", \"xml\", \"id\" from claims where \"agent\" = ?");
+		stmt.setString(1, user);
+		ResultSet rs = stmt.executeQuery();
+		List<Claim> res = new ArrayList<Claim>();
+
+		while (rs.next()) {
+			res.add(new Claim(user, rs.getString(1), rs.getTimestamp(2).getTime(), rs.getString(3), rs.getString(4), rs.getString(5)));
+		}
+
+		rs.close();
+		stmt.close();
+
+        logger.info("Returning " + res.size() + " claimed publications for user "  + user);
+
+		return res;
+	}
+
+	public List<Claim> getClaimedPublications(Date from, Date to) throws SQLException {
+		Connection con = DataSourceUtils.getConnection(datasource);
+
+		PreparedStatement stmt = con.prepareStatement("select \"agent\", \"resultid\", \"date\" , \"type\", \"xml\",  \"id\"  from claims where \"agent\" != 'inference' and \"date\" >= ?::timestamp and \"date\" <= ?::timestamp ");
+		stmt.setTimestamp(1, new Timestamp(from.getTime()));
+        stmt.setTimestamp(2, new Timestamp(to.getTime()));
+
+		ResultSet rs = stmt.executeQuery();
+		List<Claim> res = new ArrayList<Claim>();
+
+		while (rs.next()) {
+			res.add(new Claim(rs.getString(1), rs.getString(2), rs.getTimestamp(3).getTime(), rs.getString(4), rs.getString(5), rs.getString(6)));
+		}
+
+		rs.close();
+		stmt.close();
+
+		logger.debug("number of claims: " + res.size());
+        logger.info("Returning " + res.size() + " claimed publications for date "  + from + "-" + to);
+
+		return res;
+	}
+
+	public void deleteClaim(String userEmail, String id) throws SQLException {
+        logger.info("Deleting claim with id " + id + " for agent " +  userEmail);
+
+		Connection con = DataSourceUtils.getConnection(datasource);
+        int claim_id = Integer.parseInt(id);
+        String type = null;
+
+		PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"type\" from claims where \"id\" =?");
+        stmt.setInt(1, claim_id);
+
+        ResultSet rs = stmt.executeQuery();
+        
+        String resultid = null;
+        String xml = null;
+
+        while (rs.next()) {
+            resultid = rs.getString("resultid");
+            type = rs.getString("type");
+        }
+
+        if (resultid != null) {
+            stmt = con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =?");
+            stmt.setString(1, userEmail);
+            stmt.setInt(2, claim_id);
+
+            stmt.executeUpdate();
+            logger.info("Deleted claim with claim id: " + claim_id + ", result id: " + resultid + " and type: " + type +".") ;
+
+            //prepare to get 2nd claim to be deleted
+            int claim2_id = claim_id - 1;
+
+            if (type != null && type.equals("rels2actions")) {
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+                rs = stmt.executeQuery();
+
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //check if the relation has dmf
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            } /*else if (type != null && type.equals("dmf2actions")) {
+                logger.info("dmf2actions");
+                con = DataSourceUtils.getConnection(datasource);
+                stmt = con.prepareStatement("select \"type\", \"xml\" from claims where \"id\" =? and \"resultid\"=?");
+                stmt.setInt(1, claim2_id);
+                stmt.setString(2, resultid);
+
+                rs = stmt.executeQuery();
+                while (rs.next()) {
+                    type = rs.getString("type");
+                    xml = rs.getString("xml");
+                }
+
+                logger.info("xml: " + xml);
+                logger.info("xml? " + xml.contains("oaf:concept"));
+
+                if(type!= null && type.equals("dmf2actions") && xml != null && !xml.contains("oaf:concept")) { //delete concept with extra dmf (doi,orchid,... etc)
+                    logger.debug("dmf2actions and not concept");
+
+                    stmt =  con.prepareStatement("delete from claims where \"agent\" =? and \"id\" =? and \"resultid\" =? and \"type\" = ?");
+                    stmt.setString(1, userEmail);
+                    stmt.setInt(2, claim2_id);
+                    stmt.setString(3, resultid);
+                    stmt.setString(4, "dmf2actions");
+
+                    stmt.executeUpdate();
+                    logger.info("Deleted claim with id " + claim2_id + " and type: dmf2actions.");
+                }
+
+            }*/
+        }
+
+        stmt.close();
+        
+        logger.info("Deleted claim with id " + id + " for agent " +  userEmail);
+	}
+
+	/**
+	 * @param id     {openaireId, publication doi, ORCIDId (personId-ORCIDPublicationId), data doi}
+	 * @param source {openaire, doi (crossref), orcid, datacite}
+	 * @throws ResourceNotFoundException
+	 * @throws ParseErrorException
+	 * @throws Exception
+	 */
+	public String insertDocument(
+			String id,
+			String source,
+			String title,
+			String description,
+			String access_mode,
+			String embargoEndDate,
+			List<Author> authors,
+			String url,
+			String dcSource,
+			String userEmail,
+			List<String> subjects,
+			String publicationDate,
+			String publisher,
+			String language,
+			String category,
+			String doi) throws Exception {
+
+        logger.info("Request to insert document with id " + id + " and source " + source);
+		String resultId;
+
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String dmf;
+			resultId = ActionUtils.getIdentifier(ActionUtils.getPrefix(source), id);
+			Date now = new Date();
+
+			if (!source.toLowerCase().equals("openaire") && title != null) {
+				stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+				dmf = ActionUtils.createDMF(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, doi, Collections.EMPTY_LIST, subjects, Collections.EMPTY_LIST, publicationDate, publisher, language, category);
+
+				stmt.setString(1, userEmail);
+				stmt.setString(2, resultId);
+				stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+				stmt.setString(4, "dmf2actions");
+				stmt.setString(5, dmf);
+				stmt.setString(6, "userclaim_dmf");
+				stmt.setString(7, ActionUtils.getProvenance(source));
+				stmt.setString(8, ActionUtils.getPrefix(source));
+
+				stmt.executeUpdate();
+				stmt.close();
+			}
+		} catch (Exception e) {
+			logger.error("Error inserting document", e);
+			throw e;
+		}
+
+        logger.info("Inserted document with id " + id + ", source " + source + " and given resultId " + resultId);
+		return resultId;
+	}
+
+	public void insertConceptRelation(String documentId, String documentSource, String concept, String userEmail) throws Exception {
+        logger.info("Request for concept relation between document with id " + documentId + " with source " + documentSource + " and concept " + concept);
+
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String dmf;
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+			dmf = ActionUtils.createDMF(documentId, documentSource, null, null, null, null, Collections.EMPTY_LIST, null, null, null, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Arrays.asList(concept), null, null, null, null);
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, documentId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "dmf2actions");
+			stmt.setString(5, dmf);
+			stmt.setString(6, "userclaim_dmf");
+			stmt.setString(7, ActionUtils.getProvenance(documentSource));
+			stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding concept", e);
+			throw e;
+		}
+
+        logger.info("Inserted concept relation between document with id " + documentId + " with source " + documentSource + " and concept " + concept);
+	}
+
+	public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws Exception {
+        logger.info("Request for project relation between document with id " + docId + " with source " + documentSource + " and project " + project);
+
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String xml = ActionUtils.createResultProjectRelation("openaire".equals(documentSource) ? null : documentSource, docId, project.getType(), project.getProjectId());
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, docId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "rels2actions");
+			stmt.setString(5, xml);
+			stmt.setString(6, "userclaim_result_project");
+			stmt.setString(7, ActionUtils.getProvenance(documentSource));
+			stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding project", e);
+			throw e;
+		}
+
+        logger.info("Inserted project relation between document with id " + docId + " with source " + documentSource + " and project " + project);
+	}
+
+	public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws Exception {
+        logger.info("Request for result relation between source document with id " + sourceResultId + ", type " + sourceResultType + "and source " + sourceResultSource + " and " +
+                "target document with id " + targetResultId + ", type " + targetResultType);
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String xml = ActionUtils.createResultResultRelation(sourceResultId, sourceResultType, targetResultId, targetResultType);
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, sourceResultId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "rels2actions");
+			stmt.setString(5, xml);
+			stmt.setString(6, "userclaim_result_result");
+			stmt.setString(7, ActionUtils.getProvenance(sourceResultSource));
+			stmt.setString(8, ActionUtils.getPrefix(sourceResultSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding result relation", e);
+			throw e;
+		}
+
+        logger.info("Inserted result relation between source document with id " + sourceResultId + ", type " + sourceResultType + "and source " + sourceResultSource + " and " +
+                "target document with id " + targetResultId + ", type " + targetResultType);
+	}
+
+	public DataSource getDatasource() {
+		return datasource;
+	}
+
+	public void setDatasource(DataSource datasource) {
+		this.datasource = datasource;
+	}
+
+	public ServiceLocator<ISLookUpService> getLookupServiceLocator() {
+		return lookupServiceLocator;
+	}
+
+	public void setLookupServiceLocator(
+			ServiceLocator<ISLookUpService> lookupServiceLocator) {
+		this.lookupServiceLocator = lookupServiceLocator;
+	}
+
+	public List<String> getContexts() throws ISLookUpException, ISLookUpServiceException {
+		return lookupServiceLocator.getService().quickSearchProfile("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') return $x");
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(revision 47510)
@@ -0,0 +1,57 @@
+<?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:tx="http://www.springframework.org/schema/tx"
+
+        xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/tx
+        http://www.springframework.org/schema/tx/spring-tx.xsd">
+		
+	<bean id="openaire.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+		<property name="driverClassName" value="${openaire.db.driverClassName}" />
+		<property name="url" value="${openaire.db.url}" />
+		<property name="username" value="${openaire.db.username}" />
+		<property name="password" value="${openaire.db.password}" />
+		<property name="maxIdle" value="10" />
+		<property name="maxActive" value="100" />
+		<property name="maxWait" value="10000" />
+		<property name="validationQuery" value="SELECT 1;" />
+		<property name="testOnBorrow" value="true" />
+		<property name="testOnReturn" value="true" />
+		<property name="testWhileIdle" value="true" />
+		<property name="timeBetweenEvictionRunsMillis" value="1200000" />
+		<property name="minEvictableIdleTimeMillis" value="1800000" />
+		<property name="numTestsPerEvictionRun" value="5" />
+		<property name="poolPreparedStatements" value="true" />
+		<property name="defaultAutoCommit" value="true" />
+	</bean>
+
+	<bean id="claimConnector" class="eu.dnetlib.openaire.thrift.ClaimConnector">
+		<property name="datasource" ref="openaire.dataSource" />
+		<property name="lookupServiceLocator" ref="lookupServiceLocator"/>
+	</bean>
+	
+	<bean id="alertConnector" class="eu.dnetlib.openaire.thrift.AlertConnector">
+		<property name="alertServiceLocator" ref="alertServiceLocator" />
+	</bean>
+	
+	<bean id="openAireConnector" class="eu.dnetlib.openaire.thrift.OpenAIREConnectorImpl">
+		<property name="claimConnector" ref="claimConnector" />
+		<property name="alertConnector" ref="alertConnector" />
+	</bean>
+	
+	<bean id="thriftServer" class="eu.dnetlib.openaire.thrift.ThriftServer" init-method="start" destroy-method="stop">
+		<property name="openAireConnector" ref="openAireConnector" />
+		<property name="port" value="${openaire.connector.thrift.port}"/>
+		<property name="timeout" value="${openaire.connector.thrift.timeout}" />
+	</bean>
+
+    <tx:annotation-driven transaction-manager="txManager"/>
+    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="openaire.dataSource"/>
+    </bean>
+
+
+</beans>
+
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/utils/claims.sql
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(revision 47510)
@@ -0,0 +1,45 @@
+select
+        r.resultid                                          as dri_objidentifier,
+        r.title                                             as dc_title,
+        array_agg(DISTINCT lpad('0'||aut.rank,5,'0')||'§§§'||ltrim(replace(per.surname||', '||per.name,'UNKNOWN, ',''), ', ')) as dc_creator,
+      r.description                                       as dc_description,
+        r.publisher                                         as dc_publisher,
+        r.keywords                                          as dc_subject,
+        r.language                                          as dc_language,
+        array_agg(DISTINCT ws.file_url)                     as dc_identifier,
+        r.publication_date                                  as oaf_publicationdate,
+        r.embargo_end_date                                  as oaf_embargoenddate,
+        r.access_mode                                       as oaf_accessmode,
+        r.haskind                                           as oaf_haskind,
+        r.hastype                                           as "dr_CobjCategory",
+        r.storagedate                                           as oaf_storagedate,
+        createdfrom                                         as createdfrom,
+        array_agg(DISTINCT p.projectid)                     as oaf_projectid,
+        array_agg(DISTINCT cr.creator)                              as creators
+
+from
+
+       results r
+        left outer join results_projects rp on (r.resultid = rp.result)
+        left outer join projects p on (p.projectid = rp.project)
+        left outer join projects_projectsubjects ps on (ps.project = p.projectID)
+        left outer join fundingschemes fs on (p.fundedhow = fs.fundingschemeid)
+        left outer join programs s on (p.fundedby = s.programid)
+        left outer join specificprograms sp on (s.hasspecificprogram = sp.specificprogramid)
+        left outer join frameworkprograms fp on (sp.hasframeworkprogram = fp.frameworkprogramid)
+        left outer join authorships aut on (r.resultid = aut.result)
+        left outer join persons per on (per.personid = aut.author)
+        left outer join organizations o on (o.organizationid = aut.affiliation)
+        left outer join instances i on (r.resultid = i.resource)
+        left outer join webresources_instances wsi on (wsi.instanceid = i.instanceid)
+        left outer join webresources ws on (ws.webresourceid = wsi.webresourceid)
+
+        join creations cr on cr.creation = r.resultid
+
+where
+        r.pmhdeleted != true and r.pendingforclaim = false
+
+group by
+        r.resultid, r.title, r.description, r.publisher, r.keywords, r.language,
+        r.publication_date, r.embargo_end_date, r.access_mode, r.haskind, r.hastype,
+        r.storagedate, r.createdfrom
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/thrift/OpenAIREConnector.thrift
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/thrift/OpenAIREConnector.thrift	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/main/thrift/OpenAIREConnector.thrift	(revision 47510)
@@ -0,0 +1,117 @@
+namespace java eu.dnetlib.openaire.thrift
+
+struct Author {
+	1: string id,
+	2: string lastName,
+	3: string firstName
+}
+
+// alerts
+struct AlertSubscription {
+	1: string templateId,
+	2: string notificationService,
+	3: string queryId,
+	4: string resultId,
+	5: string alertMode,
+	6: string subscriber
+}
+
+struct ResultPage {
+	1: i32 limit,
+	2: i32 offset,
+	3: list<string> columns,
+	4: list<list<string>> rows
+}
+
+struct Claim {
+    1: string userEmail,
+	2: string resultid,
+	3: i64 date,
+	4: string type,
+	5: string xml,
+	6: string id
+}
+
+struct Project {
+    1: string type,
+    2: string projectId
+}
+
+// connector
+service OpenAIREConnector {
+	// claim
+	list<Claim> getClaimedPublications(1: string userEmail),
+
+	// from: date in milisecs
+	// to: ditto
+	list<Claim> getAllClaimedPublications(1: i64 from, 2: i64 to),
+	
+	string insertDocument (
+			1: string originalId,
+			2: string source, 
+			3: string title, 
+			4: string description, 
+			5: string access_mode, 
+			6: string embargoEndDate, 
+			7: list<Author> authors, 
+			8: string url,
+			9: string dcSource,
+			10: string userEmail,
+			11: list<string> subjects,
+			12: string publicationDate,
+			13: string publisher,
+			14: string language,
+			15: string category,
+			16: string doi),
+
+    void insertConcept (
+        1: string docId,
+        2: string documentSource,
+        3: string concept,
+        4: string userEmail),
+
+    void insertProjectRelation (
+        1: string docId,
+        2: string documentSource,
+        3: Project project,
+        4: string userEmail),
+
+    void insertResultRelation (
+        1: string sourceResultId,
+        2: string sourceResultType,
+        3: string sourceResultSource,
+        4: string targetResultId,
+        5: string targetResultType,
+        6: string userEmail
+    ),
+
+	void deleteClaim(1: string userEmail, 2:string resultId),
+
+	// alerts
+	list<AlertSubscription> getSubscriptions(
+			1: string alertMode, 
+			2: string subscriber, 
+			3: i32 limit, 
+			4: i32 offset),
+			
+	void addSubscription(1: AlertSubscription subscription),
+	
+	void removeSubscription(1: AlertSubscription subscription),
+	
+	i32 countAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: i64 date, 
+			5: string resultId),
+			
+	ResultPage getAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: string resultId, 
+			4: i64 fromDate, 
+			5: i64 toDate, 
+			6: i32 limit, 
+			7: i32 offset),
+	
+	list<string> getContexts(),
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(revision 47510)
@@ -0,0 +1,32 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.TException;
+import org.apache.thrift.transport.TTransportException;
+
+import java.util.Arrays;
+
+/**
+ * Created by antleb on 6/20/14.
+ */
+public class TestConnector {
+
+	public static void main(String[] args) throws TException {
+
+		OpenAIREConnector.Client client = new ThriftClient().getConnector("194.177.192.223", 7911);
+
+		String id = client.insertDocument("123123/3434.23", "doi", "a title", " a description", "OPEN ACCESS", null, Arrays.asList(new Author("id" ,"lastname", "firstname")), "url", "dcsource", "antleb@di.uoa.gr", Arrays.asList("subject"), "2012-01-02", "publisher", "language", "category", "doioioioi" );
+		System.out.println(id);
+
+		client.insertConcept(id, "doi", "egi", "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "doi", new Project("ec", "1233312"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "doi", new Project(null, "1233312"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "doi", id, "result", "antleb@di.uoa.gr");
+
+		id = "od______1406::fbda7b28cda277b04c8dc27a5e0deb68";
+
+		client.insertConcept(id, "openaire", "ec", "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "openaire", new Project("ec", "099809987"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "openaire", new Project(null, "098908908"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "openaire", id, "dataset", "antleb@di.uoa.gr");
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.2.0
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+.project
+.settings
+.idea
+*.iml
+target
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/pom.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/pom.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/pom.xml	(revision 47510)
@@ -0,0 +1,143 @@
+<?xml version="1.0"?>
+<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>uoa-openaire-connector</artifactId>
+	<version>1.1.0</version>
+        <scm>
+                <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/tags/uoa-openaire-connector-1.1.0</developerConnection>
+        </scm>
+	<pluginRepositories>
+		<pluginRepository>
+			<id>dtrotts</id>
+			<name>Repository for maven thrift plugin</name>
+			<url>http://maven.davidtrott.com/repository</url>
+			<layout>default</layout>
+		</pluginRepository>
+	</pluginRepositories>
+	<build>
+		<plugins>
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<configuration>
+					<archive>
+
+					</archive>
+					<descriptorRefs>
+						<descriptorRef>jar-with-dependencies</descriptorRef>
+					</descriptorRefs>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.thrift.tools</groupId>
+				<artifactId>maven-thrift-plugin</artifactId>
+				<version>0.1.10</version>
+				<executions>
+					<execution>
+						<id>thrift-sources</id>
+						<phase>generate-sources</phase>
+						<goals>
+							<goal>compile</goal>
+						</goals>
+					</execution>
+					<execution>
+						<id>thrift-test-sources</id>
+						<phase>generate-test-sources</phase>
+						<goals>
+							<goal>testCompile</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+		<pluginManagement>
+			<plugins>
+				<!--This plugin's configuration is used to store Eclipse m2e settings 
+					only. It has no influence on the Maven build itself. -->
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>org.apache.thrift.tools</groupId>
+										<artifactId>maven-thrift-plugin</artifactId>
+										<versionRange>[0.1.10,)</versionRange>
+										<goals>
+											<goal>testCompile</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore />
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>[0.0.0,)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+			<version>1.7.5</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-dbcp</groupId>
+			<artifactId>commons-dbcp</artifactId>
+			<version>[1.2, 1.3)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-utils</artifactId>
+			<version>[1.0.0]</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>uoa-commons</artifactId>
+			<version>[1.0.0]</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.thrift</groupId>
+			<artifactId>libthrift</artifactId>
+			<version>0.8.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.postgresql</groupId>
+			<artifactId>jdbc4driver</artifactId>
+			<version>9.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.velocity</groupId>
+			<artifactId>velocity</artifactId>
+			<version>1.7</version>
+		</dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-jdbc</artifactId>
+            <version>${spring.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/thrift/ThriftServer.java	(revision 47510)
@@ -0,0 +1,43 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TServerSocket;
+import org.apache.thrift.transport.TTransportException;
+
+public class ThriftServer {
+	private OpenAIREConnector.Iface openAireConnector;
+	private int port;
+	private int timeout;
+	private Thread thread;
+
+	public void setOpenAireConnector(final OpenAIREConnector.Iface openAireConnector) {
+		this.openAireConnector = openAireConnector;
+	}
+	
+	public void setPort(final int port) {
+		this.port = port;
+	}
+	
+	public void setTimeout(final int timeout) {
+		this.timeout = timeout;
+	}
+	
+	public void start() {
+		thread = new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					new TThreadPoolServer(new TThreadPoolServer.Args(new TServerSocket(port, timeout)).processor(new OpenAIREConnector.Processor<OpenAIREConnector.Iface>(openAireConnector))).serve();
+				} catch (final TTransportException e) {
+					Logger.getLogger(ThriftServer.class).error("Error starting thrift server", e);
+				}
+			}
+		});
+		thread.start();
+	}
+	
+	public void stop() {
+		thread.interrupt();
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/thrift/OpenAIREConnectorImpl.java	(revision 47510)
@@ -0,0 +1,186 @@
+package eu.dnetlib.openaire.thrift;
+
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+
+import eu.dnetlib.api.functionality.AlertServiceException;
+
+public class OpenAIREConnectorImpl implements OpenAIREConnector.Iface {
+	private static final Logger logger = Logger.getLogger(OpenAIREConnectorImpl.class);
+
+	private ClaimConnector claimConnector;
+	private AlertConnector alertConnector;
+
+	public void setClaimConnector(final ClaimConnector claimConnector) {
+		this.claimConnector = claimConnector;
+	}
+
+	public void setAlertConnector(final AlertConnector alertConnector) {
+		this.alertConnector = alertConnector;
+	}
+
+	@Override
+	public List<Claim> getClaimedPublications(final String user) throws TException {
+		try {
+			return claimConnector.getClaimedPublications(user);
+		} catch (final Exception e) {
+			logger.error("Error retrieving claimed publications (user: " + user + ")", e);
+			throw new TException("Error retrieving claimed publications (user: " + user + ")", e);
+		}
+	}
+
+    @Override
+    public List<Claim> getAllClaimedPublications(long from, long to) throws TException {
+        try {
+            return claimConnector.getClaimedPublications(new Date(from), new Date(to));
+        } catch (Exception e) {
+            logger.error("Error retrieving claimed publications", e);
+
+            throw new TException("Error retrieving claimed publications", e);
+        }
+    }
+
+    @Override
+    public String insertDocument(String originalId, String source, String title, String description, String access_mode, String embargoEndDate, List<Author> authors, String url, String dcSource, String userEmail, List<String> subjects, String publicationDate, String publisher, String language, String category, String doi) throws org.apache.thrift.TException {
+        try {
+            return claimConnector.insertDocument(originalId, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, userEmail, subjects, publicationDate, publisher, language, category, doi);
+        } catch (Exception e) {
+            logger.error("Error adding document", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertConcept(String docId, String documentSource, String concept, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertConceptRelation(docId, documentSource, concept, userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding concept relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws org.apache.thrift.TException {
+        try {
+            claimConnector.insertProjectRelation(docId, documentSource, project, userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding project relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+    public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws TException {
+        try {
+            claimConnector.insertResultRelation(sourceResultId, sourceResultType, sourceResultSource, targetResultId, targetResultType,userEmail);
+        } catch (Exception e) {
+            logger.error("Error adding result relation", e);
+
+            throw new TException(e);
+        }
+    }
+
+    @Override
+	public List<AlertSubscription> getSubscriptions(final String alertMode, final String subscriber, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getSubscriptions(alertMode, subscriber, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving subscriptions (alert mode: " + alertMode + ", subscriber: " + subscriber + ", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+	@Override
+	public void addSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.addSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error adding subscription", e);
+			throw new TException("Error adding subscription", e);
+		}
+	}
+
+	@Override
+	public void removeSubscription(final AlertSubscription subscription) throws TException {
+		try {
+			alertConnector.removeSubscription(subscription);
+		} catch (final AlertServiceException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		} catch (final URISyntaxException e) {
+			logger.error("Error removing subscription", e);
+			throw new TException("Error removing subscription", e);
+		}
+	}
+
+	@Override
+	public int countAlertResults(final String notificationService, final String queryId, final long date, final String resultId) throws TException {
+		try {
+			return alertConnector.countAlertResults(notificationService, queryId, date, resultId);
+		} catch (final AlertServiceException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+			throw new TException("Error counting alert results (notification service: " + notificationService + ", query: " + queryId + ", date: " + date + ", result: " + resultId + ")", e);
+		}
+	}
+
+	@Override
+	public ResultPage getAlertResults(final String notificationService, final String queryId, final String resultId, final long fromDate, final long toDate, final int limit, final int offset) throws TException {
+		try {
+			return alertConnector.getAlertResults(notificationService, queryId, resultId, fromDate, toDate, limit, offset);
+		} catch (final AlertServiceException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		} catch (final MalformedURLException e) {
+			logger.error("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate + ", limit: " +
+					limit + ", offset: " + offset + ")", e);
+			throw new TException("Error retrieving alert results (notification service: " + notificationService + ", query: " + queryId + ", result: " + resultId + ", from date: " + fromDate + ", to date: " + toDate +
+					", limit: " + limit + ", offset: " + offset + ")", e);
+		}
+	}
+
+    @Override
+    public void deleteClaim(String userEmail, String resultId) throws TException {
+        try {
+            claimConnector.deleteClaim(userEmail, resultId);
+        } catch (Exception e) {
+            logger.error("Error deleting claim", e);
+
+            throw new TException(e);
+        }
+    }
+
+	@Override
+	public List<String> getContexts() throws TException {
+		try {
+			return claimConnector.getContexts();
+		} catch (Exception e) {
+			logger.error("Error getting contexts from IS.", e);
+			
+			throw new TException(e);
+		}
+		
+	}
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/action/Relation.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/action/Relation.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/java/eu/dnetlib/openaire/action/Relation.java	(revision 47510)
@@ -0,0 +1,39 @@
+package eu.dnetlib.openaire.action;
+
+public class Relation {
+	private String type;
+	private String sourceId;
+	private String targetId;
+
+	public Relation(String type, String sourceId, String targetId) {
+		super();
+		this.type = type;
+		this.sourceId = sourceId;
+		this.targetId = targetId;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
+	public String getSourceId() {
+		return sourceId;
+	}
+
+	public void setSourceId(String sourceId) {
+		this.sourceId = sourceId;
+	}
+
+	public String getTargetId() {
+		return targetId;
+	}
+
+	public void setTargetId(String targetId) {
+		this.targetId = targetId;
+	}
+
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.properties	(revision 47510)
@@ -0,0 +1,9 @@
+openaire.connector.thrift.port = 7911
+openaire.connector.thrift.timeout = 15000
+
+openaire.connector.unknownRepositoryName = Unknown Repository
+
+openaire.db.driverClassName = org.postgresql.Driver
+openaire.db.url = jdbc:postgresql://194.177.192.223:5432/dnet_claims
+openaire.db.username = dnet
+openaire.db.password = dnetPwd
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/test/java/eu/dnetlib/openaire/thrift/ThriftClient.java	(revision 47510)
@@ -0,0 +1,25 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+import org.apache.thrift.transport.TTransportException;
+
+import eu.dnetlib.openaire.thrift.OpenAIREConnector;
+
+public class ThriftClient {
+
+	public OpenAIREConnector.Client getConnector() throws TTransportException {
+		return getConnector("localhost", 7911);
+	}
+
+	public OpenAIREConnector.Client getConnector(String host, int port) throws TTransportException {
+		TTransport transport = new TSocket(host, port);
+		transport.open();
+
+		TProtocol protocol = new  TBinaryProtocol(transport);
+		
+		return new OpenAIREConnector.Client(protocol);
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/action/relation.vm
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/eu/dnetlib/openaire/action/relation.vm	(revision 47510)
@@ -0,0 +1,5 @@
+<RELATIONS>
+#foreach ($rel in $relations)
+    <RELATION type='$rel.Type' source='$rel.SourceId' target='$rel.TargetId' />
+#end
+</RELATIONS>
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/ehcache.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/ehcache.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src/main/resources/ehcache.xml	(revision 47510)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
+    <!--
+     | Please see http://ehcache.sourceforge.net/documentation/configuration.html for
+     | detailed information on how to configurigure caches in this file
+     +-->
+    <!-- Location of persistent caches on disk -->
+    <diskStore path="java.io.tmpdir/EhCacheSpringAnnotationsExampleApp" />
+
+    <defaultCache eternal="true" maxElementsInMemory="10000"
+        overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
+        timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU"/>
+
+	<cache name="claimator"/>
+	<cache name="alertator.subscriptions"/>
+	<cache name="querynator"/>
+</ehcache>
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/deploy.info
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/deploy.info	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0/deploy.info	(revision 47510)
@@ -0,0 +1,10 @@
+{
+  "type_source": "SVN", 
+  "goal": "package -U -T 4C source:jar", 
+  "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-openaire-connector/trunk", 
+  "deploy_repository": "dnet4-snapshots", 
+  "version": "4", 
+  "mail": "antleb@di.uoa.gr, kiatrop@di.uoa.gr", 
+  "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", 
+  "name": "uoa-openaire-connector"
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.1.0
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+.project
+.settings
+.idea
+*.iml
+target
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/action/ActionUtils.java	(revision 47510)
@@ -0,0 +1,281 @@
+package eu.dnetlib.openaire.action;
+
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import eu.dnetlib.openaire.thrift.Author;
+import eu.dnetlib.openaire.thrift.Project;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.log4j.Logger;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+
+import java.io.StringWriter;
+import java.security.MessageDigest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class ActionUtils {
+
+	private static Logger logger = Logger.getLogger(ActionUtils.class);
+
+	public static String createResultProjectRelation(String source,
+			String resultId, String projectType, String projectId)
+			throws Exception {
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+		ve.init();
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+		VelocityContext vc = new VelocityContext();
+
+		List<Relation> rels = new ArrayList<Relation>();
+
+		rels.add(createRelation(source, resultId, projectType, projectId));
+
+		vc.put("relations", rels);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+
+		return sw.toString();
+	}
+
+    public static String createResultResultRelation(String sourceResultId, String sourceResultType, String targetResultId, String targetResultType) {
+        VelocityEngine ve = new VelocityEngine();
+        ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+        ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+        ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+
+        ve.init();
+
+        Template t = ve.getTemplate("/eu/dnetlib/openaire/action/relation.vm");
+        VelocityContext vc = new VelocityContext();
+
+        List<Relation> rels = new ArrayList<Relation>();
+
+        rels.add(new Relation("resultResult_" + sourceResultType + targetResultType + "_isRelatedTo", "50|" + sourceResultId, "50|" + targetResultId));
+
+        vc.put("relations", rels);
+
+        StringWriter sw = new StringWriter();
+        t.merge(vc, sw);
+
+        return sw.toString();
+    }
+
+	// input id: 1306.3402
+	// oai:arXiv.org:1306.3402
+	// MD5("od________18::oai:arXiv.org:1306.3402")
+
+    /**
+     * Creates a new relation action.
+     * @param source the result source. If not null, the resultId is transformed to openaire id. If null, the result is
+     *               considered to be already an openaire result and is used verbatim
+     * @param resultId the result id
+     * @param projectType the project type. If not null, the projectId is transformed to openaire id. If null, the projectId is
+     *               considered to be already in openaire format and is used verbatim
+     * @param projectId the project id
+     *
+     * @return a relation
+     */
+	private static Relation createRelation(String source, String resultId,
+			String projectType, String projectId) {
+		String resultPrefix;
+		String projectPrefix = null;
+
+        if (!isValidOpenaireId(resultId) && source != null) {
+            if (source.equals("arxiv")) {
+                resultId = "oai:arXiv.org:" + resultId;
+            } else if (source.equals("pubmed")) {
+                resultId = "oai:europepmc.org:" + resultId;
+            }
+
+            resultPrefix = getPrefix(source);
+            resultId = getIdentifier(resultPrefix, resultId);
+        }
+
+	resultId = "50|" + resultId;
+
+        if (projectType != null) {
+            if (projectType.equals("ec")) {
+                projectPrefix = "corda_______";
+            } else if (projectType.equals("wt")) {
+                projectPrefix = "welcometrust";
+            }
+
+            projectId = projectPrefix + "::" + projectId;
+        }
+
+	projectId = "40|" + projectId;
+
+		return new Relation("resultProject", resultId, projectId);
+	}
+
+	private static boolean isValidOpenaireId(String resultId) {
+
+		return Pattern.matches("\\w{12}::[a-f0-9]{32}", resultId);
+	}
+
+	public static String getPrefix(String source) {
+        logger.debug("SOURCE " + source);
+		if (source == null || source.equals("openaire")) {
+			return "openaire____";
+		} else if (source.equals("doi")) {
+			return "crossref____";
+		} if (source.equals("orcid")) {
+            		return "orcid_______";
+		} else if (source.equals("datacite")) {
+			return "datacite____";
+		} else if (source.equals("driver")) {
+			return "driver______";
+		} else
+			return null;
+	}
+
+    public static String getProvenance(String source) {
+        if (source == null || source.equals("openaire"))
+            return "user:claim:search";
+        else if (source.equals("doi") || source.equals("orcid"))
+            return "user:claim:pid";
+		else if (source.equals("datacite"))
+			return "user:claim:datacite";
+        else
+            return null;
+    }
+
+	public static String createDMF(String id, String source, String title,
+			String description, String access_mode, String embargoEndDate,
+			List<Author> authors, String url, String dcSource, String doi,
+			List<Project> projects, List<String> subjects, List<String> concepts, String publicationDate, String publisher, String language, String category) throws Exception {
+
+		VelocityEngine ve = new VelocityEngine();
+		ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
+		ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
+		ve.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem");
+		ve.init();
+		
+
+		Template t = ve.getTemplate("/eu/dnetlib/openaire/action/dmf.vm");
+		VelocityContext vc = new VelocityContext();
+
+		String hostedby = null;
+		String hostedbyName = null;
+		String collectedFrom = null;
+		String collectedFromName = null;
+        String recordIdentifier = id;
+		String prefix = getPrefix(source);
+
+
+        //if the orcid id exists
+        String orcid = null;
+
+		if (source.equals("doi")) {
+			hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+			hostedbyName = "Unknown Repository";
+			collectedFrom = "openaire____::crossref";
+			collectedFromName = "Crossref";
+			doi = id;
+
+        } else if (source.equals("datacite")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::datacite";
+            collectedFromName = "Datacite";
+
+        } else if (source.equals("orcid")) {
+            orcid = id;
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::orcid";
+            collectedFromName = "ORCID";
+
+        } else if (source.equals("driver")) {
+            hostedby = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
+            hostedbyName = "Unknown Repository";
+            collectedFrom = "openaire____::driver";
+            collectedFromName = "Digital Repository Infrastructure Vision for European Research";
+        }
+
+        if (doi != null) {
+            vc.put("doi", doi);
+        } else if (orcid != null){
+          //if there is no doi but we have an orcid, id we store it
+          vc.put("orcid", orcid);
+        }
+
+        // openaire ids should not be touched!
+        if (!source.equals("openaire"))
+		    id = getIdentifier(prefix, id);
+
+		vc.put("objIdentifier", id);
+		vc.put("recordIdentifier", recordIdentifier);
+		vc.put("dateOfCollection", DateUtils.calculate_ISO8601(System.currentTimeMillis()));
+		vc.put("hostedby", hostedby);
+		vc.put("collectedFrom", collectedFrom);
+		vc.put("hostedbyName", hostedbyName);
+		vc.put("collectedFromName", collectedFromName);
+        vc.put("embargoEndDate", embargoEndDate);
+		vc.put("title", title);
+		vc.put("description", description);
+		vc.put("accessMode", access_mode);
+		vc.put("dcSource", dcSource);
+		vc.put("url", url);
+		vc.put("publisher", publisher);
+		vc.put("language", language);
+		vc.put("objCategory", category);
+
+		vc.put("datasourceprefix", prefix);
+
+		List<String> creators = new ArrayList<String>();
+		for (Author author : authors) {
+            String name = author.getLastName();
+
+
+            if (author.getFirstName() != null && !author.getFirstName().trim().isEmpty())
+                name += ", " + author.getFirstName();
+
+            creators.add(name);
+		}
+
+		vc.put("creators", creators);
+		vc.put("projects", projects);
+		vc.put("subjects", subjects);
+        vc.put("concepts", concepts);
+		
+		if (publicationDate != null && !publicationDate.equals(""))
+			vc.put("publicationDate", publicationDate + "-01-01T00:00:00Z");
+		
+		vc.put("StringEscapeUtils", StringEscapeUtils.class);
+
+		StringWriter sw = new StringWriter();
+		t.merge(vc, sw);
+		
+		return sw.toString();
+	}
+
+	// private static String getIdentifier(String prefix, String id) {
+	// return prefix + "::" +
+	// com.google.common.hash.Hashing.md5().hashString(id).toString();
+	// }
+
+	public static String getIdentifier(String prefix, String id) {
+		try {
+            logger.debug("PREFIX " + prefix);
+			MessageDigest md = MessageDigest.getInstance("MD5");
+
+			md.update(id.getBytes("UTF-8"));
+
+			return prefix + "::" + new String(Hex.encodeHex(md.digest()));
+		} catch (Exception e) {
+			logger.error("Error creating id", e);
+			return null;
+		}
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/thrift/AlertConnector.java	(revision 47510)
@@ -0,0 +1,84 @@
+package eu.dnetlib.openaire.thrift;
+
+import eu.dnetlib.api.functionality.AlertService;
+import eu.dnetlib.api.functionality.AlertServiceException;
+import gr.uoa.di.driver.util.ServiceLocator;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+public class AlertConnector {
+	private ServiceLocator<AlertService> alertServiceLocator;
+
+	public void setAlertServiceLocator(
+			final ServiceLocator<AlertService> alertServiceLocator) {
+		this.alertServiceLocator = alertServiceLocator;
+	}
+
+	public List<AlertSubscription> getSubscriptions(final String alertMode,
+			final String subscriber, final int limit, final int offset)
+			throws AlertServiceException {
+		final List<AlertSubscription> subscriptions = new ArrayList<AlertSubscription>();
+		for (eu.dnetlib.domain.functionality.AlertSubscription subscription : alertServiceLocator
+				.getService().getSubscriptions(alertMode, subscriber, limit,
+						offset))
+			subscriptions.add(new AlertSubscription(subscription
+					.getTemplateId(), subscription.getNotificationService()
+					.toString(), subscription.getQueryId(), subscription
+					.getResultId(), subscription.getAlertMode(), subscription
+					.getSubscriber().toString()));
+		return subscriptions;
+	}
+
+	public void addSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().addSubscription(
+				new eu.dnetlib.domain.functionality.AlertSubscription(
+						subscription.getTemplateId(), new URL(subscription
+								.getNotificationService()), subscription
+								.getQueryId(), subscription.getResultId(),
+						subscription.getAlertMode(), new URI(subscription
+								.getSubscriber()), true));
+	}
+
+	public void removeSubscription(final AlertSubscription subscription)
+			throws AlertServiceException, MalformedURLException,
+			URISyntaxException {
+		alertServiceLocator.getService().removeSubscription(
+				subscription.getTemplateId(),
+				new URL(subscription.getNotificationService()),
+				subscription.getQueryId(), subscription.getResultId(),
+				subscription.getAlertMode(),
+				new URI(subscription.getSubscriber()));
+	}
+
+	public int countAlertResults(final String notificationService,
+			final String queryId, final long date, final String resultId)
+			throws AlertServiceException, MalformedURLException {
+		return alertServiceLocator.getService()
+				.countAlertResults(new URL(notificationService), queryId,
+						new Date(date), resultId);
+	}
+
+	public ResultPage getAlertResults(final String notificationService,
+			final String queryId, final String resultId, final long fromDate,
+			final long toDate, final int limit, final int offset)
+			throws AlertServiceException, MalformedURLException {
+		final eu.dnetlib.domain.functionality.ResultPage resultPage = alertServiceLocator
+				.getService().getAlertResults(new URL(notificationService),
+						queryId, resultId, new Date(fromDate),
+						new Date(toDate), limit, offset);
+		final List<List<String>> rows = new ArrayList<List<String>>();
+		for (String[] row : resultPage.getRows())
+			rows.add(Arrays.asList(row));
+		return new ResultPage(resultPage.getLimit(), resultPage.getOffset(),
+				Arrays.asList(resultPage.getColumns()), rows);
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/java/eu/dnetlib/openaire/thrift/ClaimConnector.java	(revision 47510)
@@ -0,0 +1,247 @@
+package eu.dnetlib.openaire.thrift;
+
+
+import eu.dnetlib.api.enabling.ISLookUpService;
+import eu.dnetlib.api.enabling.ISLookUpServiceException;
+import eu.dnetlib.openaire.action.ActionUtils;
+import gr.uoa.di.driver.enabling.ISLookUpException;
+import gr.uoa.di.driver.util.ServiceLocator;
+import org.apache.log4j.Logger;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.springframework.jdbc.datasource.DataSourceUtils;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+@Transactional
+public class ClaimConnector {
+
+	private static Logger logger = Logger.getLogger(ClaimConnector.class);
+
+	private DataSource datasource = null;
+
+	//Using an isLookUp Impl just to make an xQuery to IS. Maybe move all the
+	//functionality to commons?
+	private ServiceLocator<ISLookUpService> lookupServiceLocator = null;
+
+	public List<Claim> getClaimedPublications(final String user) throws SQLException {
+		Connection con = DataSourceUtils.getConnection(datasource);
+		PreparedStatement stmt = con.prepareStatement("select \"resultid\", \"date\" , \"type\", \"xml\" from claims where \"agent\" = ?");
+		stmt.setString(1, user);
+		ResultSet rs = stmt.executeQuery();
+		List<Claim> res = new ArrayList<Claim>();
+
+		while (rs.next()) {
+			res.add(new Claim(user, rs.getString(1), rs.getTimestamp(2).getTime(), rs.getString(3), rs.getString(4)));
+		}
+
+		rs.close();
+		stmt.close();
+
+		return res;
+	}
+
+	public List<Claim> getClaimedPublications(Date from, Date to) throws SQLException {
+		logger.info("Returning all claimed publications from " + from + " to " + to);
+		Connection con = DataSourceUtils.getConnection(datasource);
+
+		PreparedStatement stmt = con.prepareStatement("select \"agent\", \"resultid\", \"date\" , \"type\", \"xml\" from claims where \"agent\" != 'inference' and \"date\" >= ?::date and \"date\" <= ?::date ");
+
+		stmt.setTimestamp(1, new Timestamp(from.getTime()));
+		stmt.setTimestamp(2, new Timestamp(to.getTime()));
+
+		ResultSet rs = stmt.executeQuery();
+		List<Claim> res = new ArrayList<Claim>();
+
+		while (rs.next()) {
+			res.add(new Claim(rs.getString(1), rs.getString(2), rs.getTimestamp(3).getTime(), rs.getString(4), rs.getString(5)));
+		}
+
+		rs.close();
+		stmt.close();
+
+		logger.debug("number of claims: " + res.size());
+
+		return res;
+	}
+
+	public void deleteClaim(String userEmail, String resultId) throws SQLException {
+
+		Connection con = DataSourceUtils.getConnection(datasource);
+
+		PreparedStatement stmt = con.prepareStatement("delete from claims where \"agent\" = ? and resultid =?");
+		stmt.setString(1, userEmail);
+		stmt.setString(2, resultId);
+
+		stmt.executeUpdate();
+		stmt.close();
+	}
+
+	/**
+	 * @param id     {openaireId, publication doi, ORCIDId (personId-ORCIDPublicationId), data doi}
+	 * @param source {openaire, doi (crossref), orcid, datacite}
+	 * @throws ResourceNotFoundException
+	 * @throws ParseErrorException
+	 * @throws Exception
+	 */
+	public String insertDocument(
+			String id,
+			String source,
+			String title,
+			String description,
+			String access_mode,
+			String embargoEndDate,
+			List<Author> authors,
+			String url,
+			String dcSource,
+			String userEmail,
+			List<String> subjects,
+			String publicationDate,
+			String publisher,
+			String language,
+			String category,
+			String doi) throws Exception {
+
+		String resultId;
+
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String dmf;
+			resultId = ActionUtils.getIdentifier(ActionUtils.getPrefix(source), id);
+			Date now = new Date();
+
+			if (!source.toLowerCase().equals("openaire") && title != null) {
+				stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+				dmf = ActionUtils.createDMF(id, source, title, description, access_mode, embargoEndDate, authors, url, dcSource, doi, Collections.EMPTY_LIST, subjects, Collections.EMPTY_LIST, publicationDate, publisher, language, category);
+
+				stmt.setString(1, userEmail);
+				stmt.setString(2, resultId);
+				stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+				stmt.setString(4, "dmf2actions");
+				stmt.setString(5, dmf);
+				stmt.setString(6, "userclaim_dmf");
+				stmt.setString(7, ActionUtils.getProvenance(source));
+				stmt.setString(8, ActionUtils.getPrefix(source));
+
+				stmt.executeUpdate();
+				stmt.close();
+			}
+		} catch (Exception e) {
+			logger.error("Error inserting document", e);
+			throw e;
+		}
+
+		return resultId;
+	}
+
+	public void insertConceptRelation(String documentId, String documentSource, String concept, String userEmail) throws Exception {
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String dmf;
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+			dmf = ActionUtils.createDMF(documentId, documentSource, null, null, null, null, Collections.EMPTY_LIST, null, null, null, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Arrays.asList(concept), null, null, null, null);
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, documentId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "dmf2actions");
+			stmt.setString(5, dmf);
+			stmt.setString(6, "userclaim_dmf");
+			stmt.setString(7, ActionUtils.getProvenance(documentSource));
+			stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding concept", e);
+			throw e;
+		}
+	}
+
+	public void insertProjectRelation(String docId, String documentSource, Project project, String userEmail) throws Exception {
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String xml = ActionUtils.createResultProjectRelation("openaire".equals(documentSource) ? null : documentSource, docId, project.getType(), project.getProjectId());
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, docId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "rels2actions");
+			stmt.setString(5, xml);
+			stmt.setString(6, "userclaim_result_project");
+			stmt.setString(7, ActionUtils.getProvenance(documentSource));
+			stmt.setString(8, ActionUtils.getPrefix(documentSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding project", e);
+			throw e;
+		}
+	}
+
+	public void insertResultRelation(String sourceResultId, String sourceResultType, String sourceResultSource, String targetResultId, String targetResultType, String userEmail) throws Exception {
+		try {
+			Connection con = DataSourceUtils.getConnection(datasource);
+			PreparedStatement stmt;
+			String xml = ActionUtils.createResultResultRelation(sourceResultId, sourceResultType, targetResultId, targetResultType);
+
+			stmt = con.prepareStatement("insert into claims (\"agent\", \"resultid\", \"date\", type, xml, set, provenance, nsprefix) values (?, ?, ?, ?, ?, ?, ?, ?)");
+
+			stmt.setString(1, userEmail);
+			stmt.setString(2, sourceResultId);
+			stmt.setTimestamp(3, new Timestamp(new Date().getTime()));
+			stmt.setString(4, "rels2actions");
+			stmt.setString(5, xml);
+			stmt.setString(6, "userclaim_result_result");
+			stmt.setString(7, ActionUtils.getProvenance(sourceResultSource));
+			stmt.setString(8, ActionUtils.getPrefix(sourceResultSource));
+
+			stmt.executeUpdate();
+			stmt.close();
+		} catch (Exception e) {
+			logger.error("Error adding result relation", e);
+			throw e;
+		}
+	}
+
+	public DataSource getDatasource() {
+		return datasource;
+	}
+
+	public void setDatasource(DataSource datasource) {
+		this.datasource = datasource;
+	}
+
+	public ServiceLocator<ISLookUpService> getLookupServiceLocator() {
+		return lookupServiceLocator;
+	}
+
+	public void setLookupServiceLocator(
+			ServiceLocator<ISLookUpService> lookupServiceLocator) {
+		this.lookupServiceLocator = lookupServiceLocator;
+	}
+
+	public List<String> getContexts() throws ISLookUpException, ISLookUpServiceException {
+		return lookupServiceLocator.getService().quickSearchProfile("for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') return $x");
+	}
+
+
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/action/dmf.vm
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/thrift/springContext-openaire-thrift.xml	(revision 47510)
@@ -0,0 +1,57 @@
+<?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:tx="http://www.springframework.org/schema/tx"
+
+        xsi:schemaLocation="http://www.springframework.org/schema/beans
+        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
+        http://www.springframework.org/schema/tx
+        http://www.springframework.org/schema/tx/spring-tx.xsd">
+		
+	<bean id="openaire.dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
+		<property name="driverClassName" value="${openaire.db.driverClassName}" />
+		<property name="url" value="${openaire.db.url}" />
+		<property name="username" value="${openaire.db.username}" />
+		<property name="password" value="${openaire.db.password}" />
+		<property name="maxIdle" value="10" />
+		<property name="maxActive" value="100" />
+		<property name="maxWait" value="10000" />
+		<property name="validationQuery" value="SELECT 1;" />
+		<property name="testOnBorrow" value="true" />
+		<property name="testOnReturn" value="true" />
+		<property name="testWhileIdle" value="true" />
+		<property name="timeBetweenEvictionRunsMillis" value="1200000" />
+		<property name="minEvictableIdleTimeMillis" value="1800000" />
+		<property name="numTestsPerEvictionRun" value="5" />
+		<property name="poolPreparedStatements" value="true" />
+		<property name="defaultAutoCommit" value="true" />
+	</bean>
+
+	<bean id="claimConnector" class="eu.dnetlib.openaire.thrift.ClaimConnector">
+		<property name="datasource" ref="openaire.dataSource" />
+		<property name="lookupServiceLocator" ref="lookupServiceLocator"/>
+	</bean>
+	
+	<bean id="alertConnector" class="eu.dnetlib.openaire.thrift.AlertConnector">
+		<property name="alertServiceLocator" ref="alertServiceLocator" />
+	</bean>
+	
+	<bean id="openAireConnector" class="eu.dnetlib.openaire.thrift.OpenAIREConnectorImpl">
+		<property name="claimConnector" ref="claimConnector" />
+		<property name="alertConnector" ref="alertConnector" />
+	</bean>
+	
+	<bean id="thriftServer" class="eu.dnetlib.openaire.thrift.ThriftServer" init-method="start" destroy-method="stop">
+		<property name="openAireConnector" ref="openAireConnector" />
+		<property name="port" value="${openaire.connector.thrift.port}"/>
+		<property name="timeout" value="${openaire.connector.thrift.timeout}" />
+	</bean>
+
+    <tx:annotation-driven transaction-manager="txManager"/>
+    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="openaire.dataSource"/>
+    </bean>
+
+
+</beans>
+
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/thrift/OpenAIREConnector.thrift
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/thrift/OpenAIREConnector.thrift	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/thrift/OpenAIREConnector.thrift	(revision 47510)
@@ -0,0 +1,116 @@
+namespace java eu.dnetlib.openaire.thrift
+
+struct Author {
+	1: string id,
+	2: string lastName,
+	3: string firstName
+}
+
+// alerts
+struct AlertSubscription {
+	1: string templateId,
+	2: string notificationService,
+	3: string queryId,
+	4: string resultId,
+	5: string alertMode,
+	6: string subscriber
+}
+
+struct ResultPage {
+	1: i32 limit,
+	2: i32 offset,
+	3: list<string> columns,
+	4: list<list<string>> rows
+}
+
+struct Claim {
+    1: string userEmail,
+	2: string resultid,
+	3: i64 date,
+	4: string type,
+	5: string xml
+}
+
+struct Project {
+    1: string type,
+    2: string projectId
+}
+
+// connector
+service OpenAIREConnector {
+	// claim
+	list<Claim> getClaimedPublications(1: string userEmail),
+
+	// from: date in milisecs
+	// to: ditto
+	list<Claim> getAllClaimedPublications(1: i64 from, 2: i64 to),
+	
+	string insertDocument (
+			1: string originalId,
+			2: string source, 
+			3: string title, 
+			4: string description, 
+			5: string access_mode, 
+			6: string embargoEndDate, 
+			7: list<Author> authors, 
+			8: string url,
+			9: string dcSource,
+			10: string userEmail,
+			11: list<string> subjects,
+			12: string publicationDate,
+			13: string publisher,
+			14: string language,
+			15: string category,
+			16: string doi),
+
+    void insertConcept (
+        1: string docId,
+        2: string documentSource,
+        3: string concept,
+        4: string userEmail),
+
+    void insertProjectRelation (
+        1: string docId,
+        2: string documentSource,
+        3: Project project,
+        4: string userEmail),
+
+    void insertResultRelation (
+        1: string sourceResultId,
+        2: string sourceResultType,
+        3: string sourceResultSource,
+        4: string targetResultId,
+        5: string targetResultType,
+        6: string userEmail
+    ),
+
+	void deleteClaim(1: string userEmail, 2:string resultId),
+
+	// alerts
+	list<AlertSubscription> getSubscriptions(
+			1: string alertMode, 
+			2: string subscriber, 
+			3: i32 limit, 
+			4: i32 offset),
+			
+	void addSubscription(1: AlertSubscription subscription),
+	
+	void removeSubscription(1: AlertSubscription subscription),
+	
+	i32 countAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: i64 date, 
+			5: string resultId),
+			
+	ResultPage getAlertResults(
+			1: string notificationService, 
+			2: string queryId, 
+			3: string resultId, 
+			4: i64 fromDate, 
+			5: i64 toDate, 
+			6: i32 limit, 
+			7: i32 offset),
+	
+	list<string> getContexts(),
+}
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/utils/claims.sql
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/main/resources/eu/dnetlib/openaire/utils/claims.sql	(revision 47510)
@@ -0,0 +1,45 @@
+select
+        r.resultid                                          as dri_objidentifier,
+        r.title                                             as dc_title,
+        array_agg(DISTINCT lpad('0'||aut.rank,5,'0')||'§§§'||ltrim(replace(per.surname||', '||per.name,'UNKNOWN, ',''), ', ')) as dc_creator,
+      r.description                                       as dc_description,
+        r.publisher                                         as dc_publisher,
+        r.keywords                                          as dc_subject,
+        r.language                                          as dc_language,
+        array_agg(DISTINCT ws.file_url)                     as dc_identifier,
+        r.publication_date                                  as oaf_publicationdate,
+        r.embargo_end_date                                  as oaf_embargoenddate,
+        r.access_mode                                       as oaf_accessmode,
+        r.haskind                                           as oaf_haskind,
+        r.hastype                                           as "dr_CobjCategory",
+        r.storagedate                                           as oaf_storagedate,
+        createdfrom                                         as createdfrom,
+        array_agg(DISTINCT p.projectid)                     as oaf_projectid,
+        array_agg(DISTINCT cr.creator)                              as creators
+
+from
+
+       results r
+        left outer join results_projects rp on (r.resultid = rp.result)
+        left outer join projects p on (p.projectid = rp.project)
+        left outer join projects_projectsubjects ps on (ps.project = p.projectID)
+        left outer join fundingschemes fs on (p.fundedhow = fs.fundingschemeid)
+        left outer join programs s on (p.fundedby = s.programid)
+        left outer join specificprograms sp on (s.hasspecificprogram = sp.specificprogramid)
+        left outer join frameworkprograms fp on (sp.hasframeworkprogram = fp.frameworkprogramid)
+        left outer join authorships aut on (r.resultid = aut.result)
+        left outer join persons per on (per.personid = aut.author)
+        left outer join organizations o on (o.organizationid = aut.affiliation)
+        left outer join instances i on (r.resultid = i.resource)
+        left outer join webresources_instances wsi on (wsi.instanceid = i.instanceid)
+        left outer join webresources ws on (ws.webresourceid = wsi.webresourceid)
+
+        join creations cr on cr.creation = r.resultid
+
+where
+        r.pmhdeleted != true and r.pendingforclaim = false
+
+group by
+        r.resultid, r.title, r.description, r.publisher, r.keywords, r.language,
+        r.publication_date, r.embargo_end_date, r.access_mode, r.haskind, r.hastype,
+        r.storagedate, r.createdfrom
\ No newline at end of file
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src/test/java/eu/dnetlib/openaire/thrift/TestConnector.java	(revision 47510)
@@ -0,0 +1,32 @@
+package eu.dnetlib.openaire.thrift;
+
+import org.apache.thrift.TException;
+import org.apache.thrift.transport.TTransportException;
+
+import java.util.Arrays;
+
+/**
+ * Created by antleb on 6/20/14.
+ */
+public class TestConnector {
+
+	public static void main(String[] args) throws TException {
+
+		OpenAIREConnector.Client client = new ThriftClient().getConnector("194.177.192.223", 7911);
+
+		String id = client.insertDocument("123123/3434.23", "doi", "a title", " a description", "OPEN ACCESS", null, Arrays.asList(new Author("id" ,"lastname", "firstname")), "url", "dcsource", "antleb@di.uoa.gr", Arrays.asList("subject"), "2012-01-02", "publisher", "language", "category", "doioioioi" );
+		System.out.println(id);
+
+		client.insertConcept(id, "doi", "egi", "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "doi", new Project("ec", "1233312"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "doi", new Project(null, "1233312"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "doi", id, "result", "antleb@di.uoa.gr");
+
+		id = "od______1406::fbda7b28cda277b04c8dc27a5e0deb68";
+
+		client.insertConcept(id, "openaire", "ec", "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "openaire", new Project("ec", "099809987"), "antleb@di.uoa.gr");
+		client.insertProjectRelation(id, "openaire", new Project(null, "098908908"), "antleb@di.uoa.gr");
+		client.insertResultRelation(id, "result", "openaire", id, "dataset", "antleb@di.uoa.gr");
+	}
+}
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0/src
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+
Index: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0
===================================================================
--- modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0	(nonexistent)
+++ modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0	(revision 47510)

Property changes on: modules/uoa-claims-api/tags/uoa-openaire-connector-1.0.0
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+.project
+.settings
+.idea
+*.iml
+target
