diff --git a/trunk/Dockerfile b/trunk/Dockerfile
new file mode 100644
index 0000000..2bc1b7d
--- /dev/null
+++ b/trunk/Dockerfile
@@ -0,0 +1,11 @@
+FROM tomcat:7.0.90-jre8
+MAINTAINER "pkanakakis@di.uoa.gr"
+RUN ["rm", "-fr", "/usr/local/tomcat/webapps/ROOT"]
+COPY ./target/uoa-repository-manager-service.war /usr/local/tomcat/webapps/uoa-repository-manager-service.war
+#COPY src/main/resources/dnet-override-new.properties /usr/local/tomcat/lib/dnet-override.properties
+COPY src/main/resources/application.properties /usr/local/tomcat/lib/dnet-override.properties
+#COPY src/main/resources/application.properties /usr/local/tomcat/lib/application.properties
+#COPY src/main/resources/email-texts.properties /usr/local/tomcat/lib/email-texts.properties
+VOLUME /var/log/uoa-repository-manager-service:/var/log/uoa-repository-manager-service/
+CMD ["catalina.sh", "run"]
+
diff --git a/trunk/pom.xml b/trunk/pom.xml
new file mode 100644
index 0000000..4429d48
--- /dev/null
+++ b/trunk/pom.xml
@@ -0,0 +1,335 @@
+
+
+
+
+ eu.dnetlib
+ dnet45-parent
+ 1.0.0-SNAPSHOT
+
+ 4.0.0
+ eu.dnetlib
+ uoa-repository-manager-service
+ 1.0.0-SNAPSHOT
+ war
+
+
+
+
+
+ org.springframework
+ spring-webmvc
+ ${spring.version}
+
+
+
+ org.hibernate
+ hibernate-validator-annotation-processor
+ 4.1.0.Final
+
+
+
+ log4j
+ log4j
+ (1.2, 1.5]
+ compile
+
+
+
+ eu.dnetlib
+ dnet-runtime
+ [1.0.0-SNAPSHOT, 2.0.0)
+
+
+ org.apache.geronimo.specs
+ geronimo-javamail_1.4_spec
+
+
+
+
+
+ eu.dnetlib
+ uoa-utils
+ [2.0.0-SNAPSHOT, 3.0.0)
+
+
+
+ eu.dnetlib
+ uoa-domain
+ [2.0.0-SNAPSHOT, 3.0.0)
+
+
+ cglib
+ cglib
+
+
+
+
+
+ eu.dnetlib
+ dnet-openaire-usage-stats-sushilite
+ 1.0.0-SNAPSHOT
+
+
+
+
+ cglib
+ cglib-nodep
+ 2.2
+
+
+
+ eu.dnetlib
+ uoa-commons
+ [2.0.0-SNAPSHOT, 3.0.0)
+
+
+ eu.dnetlib
+ uoa-clients
+ [2.0.0-SNAPSHOT, 3.0.0)
+
+
+ eu.dnetlib
+ uoa-hcm
+ [2.0.0-SNAPSHOT, 3.0.0)
+
+
+
+ commons-io
+ commons-io
+ 2.4
+
+
+
+ se.kb
+ oai4j
+ [0.6b1,)
+
+
+ xalan
+ xalan
+ 2.7.2
+
+
+
+ xerces
+ xercesImpl
+ 2.11.0
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ 2.5.1
+ compile
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.5.1
+ compile
+
+
+
+ org.springframework
+ spring-context
+ ${spring.version}
+
+
+
+ org.springframework
+ spring-jdbc
+ ${spring.version}
+
+
+
+ com.sun.jersey
+ jersey-client
+ 1.19.3
+
+
+
+ org.aksw.gson
+ gson-utils-core
+ 1.0.0
+
+
+ org.json
+ json
+ 20080701
+
+
+
+ com.sun.mail
+ javax.mail
+ 1.6.0
+
+
+
+ io.springfox
+ springfox-swagger2
+ 2.7.0
+
+
+ io.springfox
+ springfox-swagger-ui
+ 2.7.0
+
+
+
+
+ postgresql
+ postgresql
+ 9.1-901.jdbc3
+
+
+
+
+ org.apache.tomcat
+ tomcat-catalina
+ 9.0.22
+
+
+
+ commons-fileupload
+ commons-fileupload
+ 1.4
+
+
+
+ org.mitre
+ openid-connect-client
+ 1.3.0
+
+
+ org.slf4j
+ jcl-over-slf4j
+
+
+
+
+
+
+ org.springframework.session
+ spring-session-data-redis
+ 1.3.1.RELEASE
+ pom
+
+
+
+ redis.clients
+ jedis
+ 2.9.0
+
+
+ com.google.code.gson
+ gson
+ 2.6.2
+
+
+
+ com.thetransactioncompany
+ cors-filter
+ 2.5
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-hystrix
+ 1.1.5.RELEASE
+
+
+
+
+ javax.xml.ws
+ jaxws-api
+ 2.3.0
+
+
+
+ javax.jws
+ javax.jws-api
+ 1.1
+
+
+ javax.xml.bind
+ jaxb-api
+ 2.3.0
+
+
+ com.sun.xml.bind
+ jaxb-impl
+ 2.3.0
+
+
+
+ com.sun.xml.bind
+ jaxb-core
+ 2.3.0
+
+
+ javax.activation
+ activation
+ 1.1-rev-1
+
+
+
+
+
+
+ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.7.0
+
+
+ 1.8
+ UTF-8
+
+
+
+
+ maven-war-plugin
+ 2.6
+
+ false
+
+
+
+ cz.habarta.typescript-generator
+ typescript-generator-maven-plugin
+ 2.1.406
+
+
+ java to typeScript
+
+ generate
+
+
+ jackson2
+ implementationFile
+ asClasses
+
+ eu.dnetlib.domain.functionality.validator.*
+
+ target/operation.ts
+ module
+
+
+
+
+
+ uoa-repository-manager-service
+
+
+ src/main/resources
+ true
+
+
+
+
+
+
diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/config/CascadingPropertyLoader.java b/trunk/src/main/java/eu/dnetlib/repo/manager/config/CascadingPropertyLoader.java
new file mode 100644
index 0000000..019f42a
--- /dev/null
+++ b/trunk/src/main/java/eu/dnetlib/repo/manager/config/CascadingPropertyLoader.java
@@ -0,0 +1,55 @@
+package eu.dnetlib.repo.manager.config;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
+
+import java.util.Properties;
+
+/**
+ * CascadingPropertyLoader loads a number of property files and mergers them together, so that the last properties
+ * override the previous. It also supports property expansion like:
+ *
+ *
+ * something = 1
+ * somethingelse = 2
+ * test = ${something}/${somethingelse}
+ *
+ *
+ *
+ * And if you override something to XX, then test will become XX/2
+ *
+ *
+ *
+ * @author marko
+ *
+ */
+public class CascadingPropertyLoader extends PropertyPlaceholderConfigurer implements InitializingBean {
+
+ private Properties properties;
+
+ public void afterPropertiesSet() throws Exception {
+ this.properties = mergeProperties();
+
+ // Convert the merged properties, if necessary.
+ convertProperties(this.properties);
+
+ logger.debug("Properties: " + properties);
+ }
+
+ @Override
+ protected void processProperties(final ConfigurableListableBeanFactory beanFactoryToProcess, final Properties props) throws BeansException {
+ super.processProperties(beanFactoryToProcess, props);
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public void setProperties(final Properties properties) {
+ super.setProperties(properties);
+
+ this.properties = properties;
+ }
+}
\ No newline at end of file
diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/config/Config.java b/trunk/src/main/java/eu/dnetlib/repo/manager/config/Config.java
new file mode 100644
index 0000000..6f9c1c7
--- /dev/null
+++ b/trunk/src/main/java/eu/dnetlib/repo/manager/config/Config.java
@@ -0,0 +1,76 @@
+package eu.dnetlib.repo.manager.config;
+
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
+import org.springframework.context.annotation.*;
+import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
+import org.springframework.session.web.http.CookieSerializer;
+import org.springframework.session.web.http.DefaultCookieSerializer;
+import org.springframework.web.client.RestTemplate;
+
+import javax.annotation.PostConstruct;
+
+@Configuration
+@EnableRedisHttpSession
+@EnableAspectJAutoProxy
+@EnableCircuitBreaker
+@PropertySource(value = {"classpath:application.properties"} )
+@ComponentScan(basePackages = "eu.dnetlib.repo.manager.*")
+public class Config {
+
+ private static Logger LOGGER = Logger.getLogger(Config.class);
+
+ @Value("${redis.host}")
+ private String host;
+
+ @Value("${redis.port:6379}")
+ private String port;
+
+ @Value("${redis.password}")
+ private String password;
+
+ @Value("${aai.mode}")
+ private String aai_mode;
+
+ @PostConstruct
+ private void init(){
+ LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
+ }
+
+ @Bean
+ public JedisConnectionFactory connectionFactory() {
+ LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
+ JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory();
+ jedisConnectionFactory.setHostName(host);
+ jedisConnectionFactory.setPort(Integer.parseInt(port));
+ jedisConnectionFactory.setUsePool(true);
+ if(password != null) jedisConnectionFactory.setPassword(password);
+ return jedisConnectionFactory;
+ }
+
+ @Bean
+ public CookieSerializer cookieSerializer() {
+ DefaultCookieSerializer serializer = new DefaultCookieSerializer();
+ serializer.setCookieName("openAIRESession");
+ serializer.setCookiePath("/");
+ if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
+ serializer.setDomainName(".openaire.eu");
+// serializer.setDomainName(".athenarc.gr");
+ LOGGER.info("Serializer : " + serializer);
+ return serializer;
+ }
+
+ @Bean
+ public RestTemplate restTemplate() {
+ RestTemplate restTemplate = new RestTemplate();
+ restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
+ HttpHeaders httpHeaders = new HttpHeaders();
+ httpHeaders.set("Content-Type", "application/json");
+ return restTemplate;
+ }
+
+}
diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/config/FrontEndLinkURIAuthenticationSuccessHandler.java b/trunk/src/main/java/eu/dnetlib/repo/manager/config/FrontEndLinkURIAuthenticationSuccessHandler.java
new file mode 100644
index 0000000..c0ab9ba
--- /dev/null
+++ b/trunk/src/main/java/eu/dnetlib/repo/manager/config/FrontEndLinkURIAuthenticationSuccessHandler.java
@@ -0,0 +1,94 @@
+package eu.dnetlib.repo.manager.config;
+
+import com.google.gson.JsonObject;
+import org.apache.log4j.Logger;
+import org.mitre.openid.connect.model.OIDCAuthenticationToken;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
+import com.google.gson.*;
+
+public class FrontEndLinkURIAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
+
+ private String frontEndURI;
+
+ private static final Logger LOGGER = Logger
+ .getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
+
+ public void init(){
+ LOGGER.debug("Front end uri : " + frontEndURI);
+ }
+
+
+ @Value("${aai.mode}")
+ private String aai_mode;
+
+ @Override
+ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
+
+ OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
+ JsonObject userInfo = new JsonObject();
+
+ if (authOIDC.getUserInfo().getSub() == null)
+ userInfo.addProperty("sub", "");
+ else
+ userInfo.addProperty("sub", URLEncoder.encode(authOIDC.getUserInfo().getSub(), "UTF-8"));
+
+
+ if(authOIDC.getUserInfo().getName() != null)
+ userInfo.addProperty("fullname", URLEncoder.encode(authOIDC.getUserInfo().getName(), "UTF-8"));
+
+ if (authOIDC.getUserInfo().getGivenName() == null)
+ userInfo.addProperty("firstname", "");
+ else
+ userInfo.addProperty("firstname", URLEncoder.encode(authOIDC.getUserInfo().getGivenName(), "UTF-8") + "");
+
+ if (authOIDC.getUserInfo().getFamilyName() == null)
+ userInfo.addProperty("lastname", "");
+ else
+ userInfo.addProperty("lastname", URLEncoder.encode(authOIDC.getUserInfo().getFamilyName(), "UTF-8") + "");
+
+ userInfo.addProperty("email", authOIDC.getUserInfo().getEmail() + "");
+ if (authOIDC.getUserInfo().getSource().getAsJsonArray("edu_person_entitlements") == null)
+ userInfo.addProperty("role", "");
+ else
+ userInfo.addProperty("role", URLEncoder.encode(authOIDC.getUserInfo()
+ .getSource().getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + "");
+
+
+ Cookie openAIREUser = new Cookie("openAIREUser", new Gson().toJson(userInfo) );
+ openAIREUser.setMaxAge(14400);
+ openAIREUser.setPath("/");
+ if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
+ openAIREUser .setDomain(".openaire.eu");
+// openAIREUser.setDomain(".athenarc.gr");
+ response.addCookie(openAIREUser);
+
+
+ Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
+ accessToken.setMaxAge(14400);
+ if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
+ accessToken.setDomain(".openaire.eu");
+ accessToken.setPath("/");
+
+// accessToken.setDomain(".athenarc.gr");
+ response.addCookie(accessToken);
+ response.sendRedirect(frontEndURI);
+ }
+
+ public String getFrontEndURI() {
+ return frontEndURI;
+ }
+
+ public void setFrontEndURI(String frontEndURI) {
+ this.frontEndURI = frontEndURI;
+ }
+}
+
diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/config/OpenAireProviderAuthoritiesMapper.java b/trunk/src/main/java/eu/dnetlib/repo/manager/config/OpenAireProviderAuthoritiesMapper.java
new file mode 100644
index 0000000..16c98cf
--- /dev/null
+++ b/trunk/src/main/java/eu/dnetlib/repo/manager/config/OpenAireProviderAuthoritiesMapper.java
@@ -0,0 +1,42 @@
+package eu.dnetlib.repo.manager.config;
+
+import com.nimbusds.jwt.JWT;
+import org.mitre.openid.connect.client.OIDCAuthoritiesMapper;
+import org.mitre.openid.connect.model.UserInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+
+import java.util.*;
+
+public class OpenAireProviderAuthoritiesMapper implements OIDCAuthoritiesMapper {
+
+ private static Logger logger = LoggerFactory.getLogger(OpenAireProviderAuthoritiesMapper.class);
+
+ final private static String ROLE_CLAIMS = "edu_person_entitlements";
+
+ private Map userRolesMap;
+
+ OpenAireProviderAuthoritiesMapper(Map userRoles) {
+ userRolesMap = new HashMap<>();
+ userRoles.forEach((openaireRole, appRole) -> userRolesMap.put(openaireRole, new SimpleGrantedAuthority(appRole)));
+ }
+
+ @Override
+ public Collection extends GrantedAuthority> mapAuthorities(JWT idToken, UserInfo userInfo) {
+ Set out = new HashSet<>();
+ out.add(new SimpleGrantedAuthority("ROLE_USER"));
+
+ if(userInfo.getSource().getAsJsonArray(ROLE_CLAIMS) != null) {
+ userInfo.getSource().getAsJsonArray(ROLE_CLAIMS).forEach(role -> {
+ SimpleGrantedAuthority authority = userRolesMap.get(role.getAsString());
+ if (authority != null) {
+ logger.debug("Role mapped " + role);
+ out.add(authority);
+ }
+ });
+ }
+ return out;
+ }
+}
diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/config/RepoManagerContextLoaderListener.java b/trunk/src/main/java/eu/dnetlib/repo/manager/config/RepoManagerContextLoaderListener.java
new file mode 100644
index 0000000..ed14f18
--- /dev/null
+++ b/trunk/src/main/java/eu/dnetlib/repo/manager/config/RepoManagerContextLoaderListener.java
@@ -0,0 +1,109 @@
+package eu.dnetlib.repo.manager.config;
+
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.log4j.Logger;
+import org.springframework.beans.BeansException;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.web.context.ContextLoaderListener;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.XmlWebApplicationContext;
+
+import javax.servlet.ServletContext;
+import java.util.Properties;
+
+public class RepoManagerContextLoaderListener extends ContextLoaderListener {
+ private static Logger logger = Logger.getLogger(RepoManagerContextLoaderListener.class);
+
+
+ public RepoManagerContextLoaderListener() {
+ super();
+ }
+
+ public RepoManagerContextLoaderListener(WebApplicationContext context) {
+ super(context);
+ }
+
+ @Override
+ protected WebApplicationContext createWebApplicationContext(
+ ServletContext servletContext)
+ throws BeansException {
+ logger.debug("Creating web application context");
+ Properties props = this.loadProperties();
+ String repoMode = props.getProperty("services.validator.mode.repo");
+ String userMode = props.getProperty("services.validator.mode.user");
+ Boolean standaloneMode = Boolean.parseBoolean(props.getProperty("services.validator.mode.standalone"));
+
+ logger.info("User mode: " + userMode);
+ logger.info("Repo mode: " + repoMode);
+ logger.info("Standalone mode: " + standaloneMode);
+// logger.info("Dnet workflow enabled: " + repoMode);
+ XmlWebApplicationContext ctx = new XmlWebApplicationContext();
+
+ ctx.setServletContext(servletContext);
+
+ String userApiContext = null;
+ if (userMode.equalsIgnoreCase("local"))
+ userApiContext = "eu/dnetlib/validator/web/api/impls/users/springContext-validator-user-local.xml";
+ else if (userMode.equalsIgnoreCase("ldap"))
+ userApiContext = "eu/dnetlib/users/springContext-users-ldap.xml";
+
+ String[] springContextCore = new String[] {
+ "classpath:META-INF/cxf/cxf.xml",
+ "classpath:META-INF/cxf/cxf-extension-soap.xml",
+ "classpath:META-INF/cxf/cxf-extension-jaxws.xml",
+ "classpath:META-INF/cxf/cxf-servlet.xml",
+ "classpath*:/cxf.xml",
+ "classpath*:/eu/dnetlib/repos/ehcacher/springContext-repos-ehcacher.xml",
+ "classpath*:/eu/dnetlib/clients/ws/springContext-locatorFactory.xml",
+ "classpath*:/eu/dnetlib/soap/cxf/applicationContext-eprbuilders.xml",
+// "classpath*:/eu/dnetlib/validator/web/actions/springContext-validator-struts.xml",
+// "classpath*:/eu/dnetlib/validator/web/actions/springContext-validator-emailer.xml",
+// "classpath*:/eu/dnetlib/validator/web/config/springContext-validator.xml",
+ "classpath*:/eu/dnetlib/repo/manager/server/config/springContext-repo-manager-config.xml",
+// "classpath*:/eu/dnetlib/validator/commons/dao/springContext-*.xml",
+ "classpath*:/eu/dnetlib/repos/springContext-repos-" + repoMode + ".xml",
+ "classpath*:/" + userApiContext
+ };
+
+
+ String[] springContextForStandalone = new String[] {
+ };
+
+ String[] springContextForIS = new String[] {
+ "classpath*:/gr/uoa/di/driver/util/springContext-locators.xml",
+ "classpath*:/gr/uoa/di/driver/app/springContext-lookupFactory.xml",
+ "classpath*:/gr/uoa/di/driver/app/springContext-lookupClients.xml",
+ "classpath*:/eu/dnetlib/enabling/hcm/springContext-hcmService.xml",
+ "classpath*:/gr/uoa/di/driver/app/springContext-commons.xml",
+ "classpath*:/gr/uoa/di/driver/app/springContext-registrator.xml"
+ };
+
+ if (standaloneMode) {
+ logger.debug("Loading contexts for standalone mode");
+ ctx.setConfigLocations((String[])ArrayUtils.addAll(springContextCore,springContextForStandalone));
+ } else {
+ logger.debug("Loading contexts for dnet");
+ ctx.setConfigLocations((String[])ArrayUtils.addAll(springContextCore,springContextForIS));
+ }
+
+ ctx.refresh();
+
+ logger.debug("done");
+
+ return ctx;
+ }
+
+ private Properties loadProperties() {
+ ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {
+ "classpath*:/eu/dnetlib/repo/manager/server/config/springContext-repo-manager-config.xml"
+ });
+
+ CascadingPropertyLoader pLoader = (CascadingPropertyLoader) ctx.getBean("propertyLoader");
+ Properties props = pLoader.getProperties();
+
+ ctx.destroy();
+ ctx.close();
+ return props;
+ }
+
+}
diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/config/SwaggerConfig.java b/trunk/src/main/java/eu/dnetlib/repo/manager/config/SwaggerConfig.java
new file mode 100644
index 0000000..f868a28
--- /dev/null
+++ b/trunk/src/main/java/eu/dnetlib/repo/manager/config/SwaggerConfig.java
@@ -0,0 +1,66 @@
+package eu.dnetlib.repo.manager.config;
+
+import eu.dnetlib.repo.manager.controllers.*;
+import eu.dnetlib.repo.manager.service.MonitorService;
+import eu.dnetlib.repo.manager.service.PiWikService;
+import eu.dnetlib.repo.manager.service.RepositoryService;
+import eu.dnetlib.repo.manager.service.ValidatorService;
+import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
+import org.springframework.cloud.netflix.hystrix.EnableHystrix;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.service.VendorExtension;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.ArrayList;
+
+
+/**
+ * Created by panagiotis on 16/11/2017.
+ */
+@Configuration
+@EnableSwagger2
+@EnableWebMvc
+@EnableCircuitBreaker
+@ComponentScan(basePackageClasses = {
+ RepositoryController.class,
+ MonitorController.class,
+ ValidatorController.class,
+ PiWikController.class,
+ BrokerController.class,
+ StatsController.class,
+ UserController.class,
+ SushiliteController.class
+},basePackages = "eu.dnetlib.repo.manager.*")
+public class SwaggerConfig {
+
+ @Bean
+ public Docket productApi() {
+ return new Docket(DocumentationType.SWAGGER_2)
+ .select()
+ .apis(RequestHandlerSelectors.any())
+ .paths(PathSelectors.any())
+ .build()
+ .pathMapping("/")
+ .apiInfo(getApiInfo());
+ }
+
+ private ApiInfo getApiInfo() {
+ return new ApiInfo("Repository Manager Dashboard API Documentation",
+ "Repository Manager Dashboard API Documentation",
+ "1.0",
+ "urn:tos",
+ new Contact("", "", ""),
+ "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0",
+ new ArrayList());
+ }
+
+}
diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/BrokerController.java b/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/BrokerController.java
new file mode 100644
index 0000000..0515905
--- /dev/null
+++ b/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/BrokerController.java
@@ -0,0 +1,126 @@
+package eu.dnetlib.repo.manager.controllers;
+
+import eu.dnetlib.repo.manager.service.BrokerServiceImpl;
+import eu.dnetlib.repo.manager.shared.BrokerException;
+import eu.dnetlib.repo.manager.shared.Term;
+import eu.dnetlib.repo.manager.shared.broker.*;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiParam;
+import org.json.JSONException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping(value = "/broker")
+@Api(description = "Broker API", tags = {"broker"})
+public class BrokerController{
+
+ @Autowired
+ private BrokerServiceImpl brokerService;
+
+
+ @RequestMapping(value = "/getDatasourcesOfUser" , method = RequestMethod.GET,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ @ResponseBody
+ @PreAuthorize("hasRole('ROLE_USER')")
+ public DatasourcesBroker getDatasourcesOfUser(@RequestParam("user")
+ @ApiParam(value = "User email", required = true) String user,
+ @RequestParam("includeShared")
+ @ApiParam(value = "Include shared datasources", required = true , defaultValue = "false") String includeShared,
+ @RequestParam("includeByOthers")
+ @ApiParam(value = "Include datasources of other", required = true,defaultValue = "false") String includeByOthers) throws JSONException {
+ return brokerService.getDatasourcesOfUser(user, includeShared, includeByOthers);
+ }
+
+ @RequestMapping(value = "/getTopicsForDatasource/{datasourceName:.+}" ,
+ method = RequestMethod.GET,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public List getTopicsForDatasource(@PathVariable("datasourceName") String datasourceName) throws BrokerException{
+ return brokerService.getTopicsForDatasource(datasourceName);
+ }
+
+ @RequestMapping(value = "/advancedShowEvents/{page}/{size}" ,
+ method = RequestMethod.POST,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ @ResponseBody
+ @PreAuthorize("hasRole('ROLE_USER')")
+ public EventsPage advancedShowEvents(@PathVariable("page") String page,
+ @PathVariable("size") String size,
+ @RequestBody AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException{
+ return brokerService.advancedShowEvents(page, size, advQueryObject);
+ }
+
+ @RequestMapping(value = "/showEvents/{datasourceName:.+}/{topic}/{page}" ,
+ method = RequestMethod.GET,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ @ResponseBody
+ @PreAuthorize("hasRole('ROLE_USER')")
+ public EventsPage showEvents(@RequestParam("datasourceName") String datasourceName,
+ @RequestParam("topic") String topic,
+ @RequestParam("page") String page,
+ @RequestParam("size") String size) throws BrokerException, JSONException{
+ return brokerService.showEvents(datasourceName, topic, page, size);
+ }
+
+ @RequestMapping(value = "/getSimpleSubscriptionsOfUser/{userEmail}" ,
+ method = RequestMethod.GET,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ @ResponseBody
+ @PreAuthorize("hasRole('ROLE_USER')")
+ public Map> getSimpleSubscriptionsOfUser(@PathVariable("userEmail") String userEmail) throws BrokerException{
+ return brokerService.getSimpleSubscriptionsOfUser(userEmail);
+ }
+
+ @RequestMapping(value = "/subscribe" , method = RequestMethod.POST,
+ consumes = MediaType.APPLICATION_JSON_VALUE,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ @ResponseBody
+ @PreAuthorize("hasRole('ROLE_USER') ")
+ public Subscription subscribe(@RequestBody OpenaireSubscription obj) throws BrokerException{
+ return brokerService.subscribe(obj);
+ }
+
+ @RequestMapping(value = "/unsubscribe/{subscriptionId}" , method = RequestMethod.POST,
+ consumes = MediaType.APPLICATION_JSON_VALUE,
+ produces = MediaType.APPLICATION_JSON_VALUE)
+ @ResponseBody
+ @PreAuthorize("hasRole('ROLE_USER')")
+ public ResponseEntity