diff --git a/trunk/Dockerfile b/trunk/Dockerfile deleted file mode 100644 index 2bc1b7d..0000000 --- a/trunk/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index 4429d48..0000000 --- a/trunk/pom.xml +++ /dev/null @@ -1,335 +0,0 @@ - - - - - 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 - 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 deleted file mode 100644 index 019f42a..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/config/CascadingPropertyLoader.java +++ /dev/null @@ -1,55 +0,0 @@ -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 deleted file mode 100644 index 6f9c1c7..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/config/Config.java +++ /dev/null @@ -1,76 +0,0 @@ -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 deleted file mode 100644 index c0ab9ba..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/config/FrontEndLinkURIAuthenticationSuccessHandler.java +++ /dev/null @@ -1,94 +0,0 @@ -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 deleted file mode 100644 index 16c98cf..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/config/OpenAireProviderAuthoritiesMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -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 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 deleted file mode 100644 index ed14f18..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/config/RepoManagerContextLoaderListener.java +++ /dev/null @@ -1,109 +0,0 @@ -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 deleted file mode 100644 index f868a28..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/config/SwaggerConfig.java +++ /dev/null @@ -1,66 +0,0 @@ -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 deleted file mode 100644 index 0515905..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/BrokerController.java +++ /dev/null @@ -1,126 +0,0 @@ -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 unsubscribe(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{ - return brokerService.unsubscribe(subscriptionId); - } - - @RequestMapping(value = "/getSubscription/{subscriptionId}" , method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER')") - public Subscription getSubscription(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException{ - return brokerService.getSubscription(subscriptionId); - } - - - @RequestMapping(value = "/getDnetTopics" , method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public Map getDnetTopics() throws BrokerException{ - return brokerService.getDnetTopics(); - } - - @RequestMapping(value = "/getNotificationsBySubscriptionId/{subscriptionId}/{page}/{size}" , method = RequestMethod.GET - ,produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER')") - public EventsPage getNotificationsBySubscriptionId(@PathVariable("subscriptionId") String subscriptionId, - @PathVariable("page") String page, - @PathVariable("size") String size) throws BrokerException{ - return brokerService.getNotificationsBySubscriptionId(subscriptionId, page, size); - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/DashboardController.java b/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/DashboardController.java deleted file mode 100644 index 8ba1032..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/DashboardController.java +++ /dev/null @@ -1,100 +0,0 @@ -package eu.dnetlib.repo.manager.controllers; - -import eu.dnetlib.repo.manager.domain.BrokerSummary; -import eu.dnetlib.repo.manager.domain.CollectionMonitorSummary; -import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo; -import eu.dnetlib.repo.manager.domain.UsageSummary; -import eu.dnetlib.repo.manager.service.BrokerService; -import eu.dnetlib.repo.manager.service.DashboardService; -import eu.dnetlib.repo.manager.service.PiWikService; -import eu.dnetlib.repo.manager.service.RepositoryService; -import eu.dnetlib.repo.manager.shared.AggregationDetails; -import eu.dnetlib.repo.manager.shared.BrokerException; -import eu.dnetlib.repo.manager.shared.MetricsInfo; -import eu.dnetlib.repo.manager.shared.RepositoryServiceException; -import io.swagger.annotations.Api; -import org.json.JSONException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -@RestController -@RequestMapping(value = "/dashboard") -@Api(description = "Dashboard API", tags = {"dashboard"}) -public class DashboardController { - - @Autowired - private DashboardService dashboardService; - - @Autowired - private RepositoryService repositoryService; - - @Autowired - private BrokerService brokerService; - - @Autowired - private PiWikService piWikService; - - @RequestMapping(value = "/getRepositoriesSummary/{userEmail}/{page}/{size}" , method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER')") - public List getRepositoriesSummaryInfo(@PathVariable("userEmail") String userEmail, - @PathVariable("page") String page, - @PathVariable("size") String size) throws JSONException { - return dashboardService.getRepositoriesSummaryInfo(userEmail, page, size); - } - - @RequestMapping(value = "/collectionMonitorSummary/{repoId}" , method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER')") - public CollectionMonitorSummary getCollectionMonitorSummary( - @PathVariable("repoId") String repoId, - @RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException { - - List aggregationDetails = repositoryService.getRepositoryAggregations(repoId,0,size); - CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary(); - collectionMonitorSummary.setAggregationDetails(aggregationDetails); - size=0; - do { - aggregationDetails = repositoryService.getRepositoryAggregations(repoId,size,size+50); - for(AggregationDetails aggregationDetail : aggregationDetails){ - if(aggregationDetail.getIndexedVersion()){ - collectionMonitorSummary.setLastIndexedVersion(aggregationDetail); - break; - } - } - size+=30; - }while (aggregationDetails.size() != 0 && collectionMonitorSummary.getLastIndexedVersion()==null); - - return collectionMonitorSummary; - } - - @RequestMapping(value = "/usageSummary/{repoId}" , method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER')") - public UsageSummary getUsageSummary( - @PathVariable("repoId") String repoId - ) throws RepositoryServiceException { - return new UsageSummary(repositoryService.getMetricsInfoForRepository(repoId), piWikService.getPiwikSiteForRepo(repoId)); - } - - @RequestMapping(value = "/brokerSummary/{email}/{ds_name}" , method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER')") - public BrokerSummary getBrokerSummary( - @PathVariable("email") String email, - @PathVariable("ds_name") String datasourceName) throws BrokerException { - return new BrokerSummary(brokerService.getSimpleSubscriptionsOfUser(email), brokerService.getTopicsForDatasource(datasourceName)); - } - - - - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/GenericControllerAdvice.java b/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/GenericControllerAdvice.java deleted file mode 100644 index ce2f810..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/GenericControllerAdvice.java +++ /dev/null @@ -1,64 +0,0 @@ -package eu.dnetlib.repo.manager.controllers; - - -import eu.dnetlib.api.functionality.ValidatorServiceException; -import eu.dnetlib.repo.manager.exception.EndPointException; -import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; -import eu.dnetlib.repo.manager.exception.ServerError; -import eu.dnetlib.repo.manager.shared.BrokerException; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; -import org.json.JSONException; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.http.HttpStatus; -import org.springframework.security.access.AccessDeniedException; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletRequest; -import java.net.UnknownHostException; - - -@ControllerAdvice -@Order(Ordered.HIGHEST_PRECEDENCE) -public class GenericControllerAdvice { - - private Logger logger = LogManager.getLogger(GenericControllerAdvice.class); - - - @ResponseStatus(HttpStatus.NOT_FOUND) - @ExceptionHandler(ResourceNotFoundException.class) - @ResponseBody - public ServerError securityException(HttpServletRequest req, Exception ex) { - return new ServerError(req.getRequestURL().toString(),ex); - } - - @ResponseStatus(HttpStatus.FORBIDDEN) - @ExceptionHandler(AccessDeniedException.class) - @ResponseBody - public ServerError accessDeniedException(HttpServletRequest req, Exception ex) { - return new ServerError(req.getRequestURL().toString(),ex); - } - - @ResponseStatus(HttpStatus.NOT_FOUND) - @ExceptionHandler(UnknownHostException.class) - @ResponseBody - public ServerError unknownHostException(HttpServletRequest req, Exception ex) { - return new ServerError(req.getRequestURL().toString(),ex); - } - - @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - @ExceptionHandler({JSONException.class,BrokerException.class,ValidatorServiceException.class}) - @ResponseBody - public ServerError internalException(HttpServletRequest req, Exception ex) { - return new ServerError(req.getRequestURL().toString(),ex); - } - - @ResponseStatus(HttpStatus.GATEWAY_TIMEOUT) - @ExceptionHandler(EndPointException.class) - @ResponseBody - public ServerError endPointException(HttpServletRequest req, Exception ex) { - return new ServerError(req.getRequestURL().toString(),ex); - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/MonitorController.java b/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/MonitorController.java deleted file mode 100644 index 2d7540e..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/MonitorController.java +++ /dev/null @@ -1,60 +0,0 @@ -package eu.dnetlib.repo.manager.controllers; - -import eu.dnetlib.api.functionality.ValidatorServiceException; -import eu.dnetlib.domain.functionality.validator.StoredJob; -import eu.dnetlib.repo.manager.service.MonitorServiceImpl; -import eu.dnetlib.repo.manager.shared.JobsOfUser; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiParam; -import org.apache.log4j.Logger; -import org.json.JSONException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -@RestController -@RequestMapping(value = "/monitor") -@Api(description = "Monitor API", tags = {"monitor"}) -public class MonitorController { - - private static final Logger LOGGER = Logger - .getLogger(MonitorController.class); - - @Autowired - private MonitorServiceImpl monitorService; - - @RequestMapping(value = "/getJobsOfUser" , method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER')") - public JobsOfUser getJobsOfUser(@RequestParam("user") @ApiParam(value = "User email", required = true) String user, - @RequestParam(value = "jobType", required = false) - @ApiParam(value = "Equals to filter job type on validation history page") String jobType, - @RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset, - @RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit, - @RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom, - @RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo, - @RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = false) String validationStatus, - @RequestParam("includeJobsTotal") @ApiParam(value = "Always true", required = true) String includeJobsTotal) throws JSONException, ValidatorServiceException { - - return monitorService.getJobsOfUser(user, jobType, offset, limit, dateFrom, dateTo, validationStatus, includeJobsTotal); - } - - @RequestMapping(value = "/getJobsOfUserPerValidationStatus" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER')") - public int getJobsOfUserPerValidationStatus(@RequestBody String user, - @RequestBody String jobType, - @RequestBody String validationStatus) throws JSONException { - return monitorService.getJobsOfUserPerValidationStatus(user, jobType, validationStatus); - } - - @RequestMapping(value = "/getJobSummary" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public StoredJob getJobSummary(@RequestParam String jobId, - @RequestParam String groupBy) throws JSONException { - return monitorService.getJobSummary(jobId, groupBy); - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/PiWikController.java b/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/PiWikController.java deleted file mode 100644 index ef9d0ae..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/PiWikController.java +++ /dev/null @@ -1,189 +0,0 @@ -package eu.dnetlib.repo.manager.controllers; - -import eu.dnetlib.domain.data.PiwikInfo; -import eu.dnetlib.repo.manager.domain.OrderByField; -import eu.dnetlib.repo.manager.domain.OrderByType; -import eu.dnetlib.repo.manager.domain.Paging; -import eu.dnetlib.repo.manager.service.PiWikServiceImpl; -import eu.dnetlib.repo.manager.service.RepositoryService; -import eu.dnetlib.repo.manager.shared.RepositoryServiceException; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.FileSystemResource; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PostAuthorize; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.PrintWriter; -import java.nio.file.Files; -import java.nio.file.Path; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -@RestController -@RequestMapping(value = "/piwik") -@Api(description = "Piwik API", tags = {"piwik"}) -public class PiWikController { - - private static final Logger LOGGER = Logger - .getLogger(PiWikController.class); - - @Autowired - private PiWikServiceImpl piWikService; - - @Autowired - private RepositoryService repositoryService; - - - @RequestMapping(value = "/getPiwikSiteForRepo/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repositoryId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repositoryId).registeredBy=='null') and hasRole('ROLE_USER'))") - public PiwikInfo getPiwikSiteForRepo(@PathVariable("repositoryId") String repositoryId) { - return piWikService.getPiwikSiteForRepo(repositoryId); - } - - @RequestMapping(value = "/savePiwikInfo" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE) - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#piwikInfo.repositoryId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#piwikInfo.repositoryId).registeredBy=='null') and hasRole('ROLE_USER'))") - public PiwikInfo savePiwikInfo(@RequestBody PiwikInfo piwikInfo) { - return piWikService.savePiwikInfo(piwikInfo); - } - - @RequestMapping(value = "/getPiwikSitesForRepos" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - @ApiImplicitParams({ - @ApiImplicitParam(name = "from", dataType = "number", paramType = "query"), - @ApiImplicitParam(name = "quantity", dataType = "number", paramType = "query"), - @ApiImplicitParam(name = "order", dataType = "eu.dnetlib.repo.manager.domain.OrderByType", paramType = "query"), - @ApiImplicitParam(name = "orderField", dataType = "eu.dnetlib.repo.manager.domain.OrderByField", paramType = "query"), - @ApiImplicitParam(name = "searchField", dataType = "string", paramType = "query"), - }) - public Paging getPiwikSitesForRepos( - @RequestParam(value = "from",required=false,defaultValue = "0") int from, - @RequestParam(value = "quantity",required=false,defaultValue = "100") int quantity, - @RequestParam(value = "order",required=false,defaultValue = "DSC") OrderByType orderType, - @RequestParam(value = "orderField", required = false, defaultValue = "REPOSITORY_NAME") OrderByField orderField, - @RequestParam(value = "searchField", required = false, defaultValue = "") String searchField - - ){ - Paging results = new Paging<>(); - List returning = piWikService.getPiwikSitesForRepos(orderField,orderType,from,quantity,searchField); - results.setFrom(from); - results.setTo(from + returning.size()); - results.setTotal(piWikService.getPiwikSitesTotals(searchField)); - results.setResults(returning); - return results; - } - @ApiImplicitParams({ - @ApiImplicitParam(name = "from", dataType = "number", paramType = "query"), - @ApiImplicitParam(name = "quantity", dataType = "number", paramType = "query"), - @ApiImplicitParam(name = "order", dataType = "eu.dnetlib.repo.manager.domain.OrderByType", paramType = "query"), - @ApiImplicitParam(name = "searchField", dataType = "eu.dnetlib.repo.manager.domain.OrderByField", paramType = "query"), - @ApiImplicitParam(name = "orderField", dataType = "string", paramType = "query"), - }) - @RequestMapping(value = "/getPiwikSitesForRepos/csv" , method = RequestMethod.GET,produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) - @ResponseBody - public FileSystemResource getPiwikSitesForReposToCsv( - @RequestParam(value = "from",required=false,defaultValue = "0") int from, - @RequestParam(value = "quantity",required=false,defaultValue = "10000") int quantity, - @RequestParam(value = "order",required=false,defaultValue = "DSC") OrderByType orderType, - @RequestParam(value = "orderField", required = false, defaultValue = "REPOSITORY_NAME") OrderByField orderField, - @RequestParam(value = "searchField", required = false, defaultValue = "") String searchField, - HttpServletResponse response, - HttpServletRequest request - ) throws IOException { - - Path p = Files.createTempFile("exportingCsv-", new Date().toString()); - List returning = piWikService.getPiwikSitesForRepos(orderField,orderType,0,10000,searchField); - try (PrintWriter writer = new PrintWriter(p.toFile())) { - - StringBuilder sb = new StringBuilder(); - sb.append(" Repository ID , Repository name, Country, Site ID, Authentication token, Creation date, Requestor full name, Requestor email, Validated, Validation date, Comment \n"); - - for(PiwikInfo piwikInfo : returning){ - sb.append( - (piwikInfo.getRepositoryId() == null ? "," : piwikInfo.getRepositoryId()+ ",")+ - (piwikInfo.getRepositoryName() == null ? "," : piwikInfo.getRepositoryName()+ ",")+ - (piwikInfo.getCountry() == null ? "," : piwikInfo.getCountry()+ ",")+ - (piwikInfo.getSiteId() == null ? "," : piwikInfo.getSiteId()+ ",") + - (piwikInfo.getAuthenticationToken() == null ? "," : piwikInfo.getAuthenticationToken()+ ",")+ - (piwikInfo.getCreationDate() == null ? "," : piwikInfo.getCreationDate().toString()+ ",") + - (piwikInfo.getRequestorName() == null ? "," : piwikInfo.getRequestorName()+ ",") + - (piwikInfo.getRequestorEmail() == null ? "," : piwikInfo.getRequestorEmail()+ ",")+ - piwikInfo.isValidated() + "," + - (piwikInfo.getValidationDate() == null ? "," : piwikInfo.getValidationDate().toString()+ ",") + - (piwikInfo.getComment() == null ? "\n" : piwikInfo.getComment()+ "\n") - - ); - } - writer.write(sb.toString()); - - } catch (FileNotFoundException e) { - LOGGER.error(e.getMessage()); - } - - - String mimeType = request.getServletContext().getMimeType(p.toFile().getAbsolutePath()); - if (mimeType == null) { - mimeType = "application/octet-stream"; - } - response.setContentType(mimeType); - response.setContentLength((int) p.toFile().length()); - - - String headerKey = "Content-Disposition"; - SimpleDateFormat sdfDate = new SimpleDateFormat("ddMMyyyy");//dd/MM/yyyy - Date now = new Date(); - String strDate = sdfDate.format(now); - String headerValue = String.format("attachment; filename=\"csv-%s.csv\"", - strDate); - response.setHeader(headerKey, headerValue); - - - return new FileSystemResource(p.toFile()); - - } - - - @RequestMapping(value = "/approvePiwikSite/{repositoryId}" , method = RequestMethod.GET) - @ResponseBody - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')") - public ResponseEntity approvePiwikSite(@PathVariable("repositoryId") String repositoryId) { - return piWikService.approvePiwikSite(repositoryId); - } - - @RequestMapping(value = "/getOpenaireId/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')") - public String getOpenaireId(String repositoryid){ - return piWikService.getOpenaireId(repositoryid); - } - - @RequestMapping(value = "/markPiwikSiteAsValidated/{repositoryId}" , method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')") - public ResponseEntity markPiwikSiteAsValidated(@PathVariable("repositoryId") String repositoryId) throws RepositoryServiceException { - return piWikService.markPiwikSiteAsValidated(repositoryId); - } - - @RequestMapping(value = "/enableMetricsForRepository", method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_VALUE) - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)") - public PiwikInfo enableMetricsForRepository(@RequestParam("officialName") String officialName, - @RequestParam("repoWebsite") String repoWebsite, - @RequestBody PiwikInfo piwikInfo) throws RepositoryServiceException { - return piWikService.enableMetricsForRepository(officialName, repoWebsite, piwikInfo); - } - - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/RepositoryController.java b/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/RepositoryController.java deleted file mode 100644 index 2f760ac..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/RepositoryController.java +++ /dev/null @@ -1,227 +0,0 @@ -package eu.dnetlib.repo.manager.controllers; - -import eu.dnetlib.api.functionality.ValidatorServiceException; -import eu.dnetlib.domain.data.Repository; -import eu.dnetlib.domain.data.RepositoryInterface; -import eu.dnetlib.repo.manager.domain.RepositorySnippet; -import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; -import eu.dnetlib.repo.manager.service.RepositoryServiceImpl; -import eu.dnetlib.repo.manager.shared.*; -import io.swagger.annotations.Api; -import org.json.JSONException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.security.access.prepost.PostAuthorize; -import org.springframework.security.access.prepost.PostFilter; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.web.bind.annotation.*; - -import javax.ws.rs.Path; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -@RestController -@RequestMapping(value = "/repository") -@Api(description = "Repository API", tags = {"repository"}) -public class RepositoryController { - - @Autowired - private RepositoryServiceImpl repositoryService; - - @RequestMapping(value = "/getCountries", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public Country[] getCountries() { - return repositoryService.getCountries(); - } - - @RequestMapping(value = "/getRepositoriesByCountry/{country}/{mode}", method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public List getRepositoriesByCountry(@PathVariable("country") String country, - @PathVariable("mode") String mode, - @RequestParam(value = "managed",required=false) Boolean managed) throws JSONException, IOException { - return repositoryService.getRepositoriesByCountry(country, mode, managed); - } - - @RequestMapping(value = "/getRepositoriesOfUser/{userEmail}/{page}/{size}",method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER')") - public List getRepositoriesOfUser(@PathVariable("userEmail") String userEmail, - @PathVariable("page") String page, - @PathVariable("size") String size) throws JSONException { - return repositoryService.getRepositoriesOfUser(userEmail, page, size); - } - - @RequestMapping(value = "/searchRegisteredRepositories/{page}/{size}",method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')") - public List searchRegisteredRepositories(@RequestParam(name="country", required=false) String country, - @RequestParam(name="typology", required=false) String typology, - @RequestParam(name="englishName", required=false) String englishName, - @RequestParam(name="officialName", required=false) String officialName, - @RequestParam("requestSortBy") String requestSortBy, - @RequestParam("order") String order, - @PathVariable("page") int page, - @PathVariable("size") int pageSize) throws Exception { - - return repositoryService.searchRegisteredRepositories(country, typology, englishName, officialName, requestSortBy, order, page, pageSize); - } - - @RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PostAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((returnObject.registeredBy=='null' or returnObject.registeredBy==authentication.userInfo.email) and hasRole('ROLE_USER'))") - public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException,ResourceNotFoundException { - Repository repo = repositoryService.getRepositoryById(id); - return repo; - } - - @RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public List getRepositoryAggregations(@PathVariable("id") String id) throws JSONException { - return repositoryService.getRepositoryAggregations(id,0,20); - } - - @RequestMapping(value = "/getRepositoryAggregationsByYear/{id}", method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public Map> getRepositoryAggregationsByYear(@PathVariable("id") String id) throws JSONException { - return repositoryService.getRepositoryAggregationsByYear(id); - } - - @RequestMapping(value = "/getRepositoriesByName/{name:.+}/{page}/{size}/", method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public List getRepositoriesByName(@PathVariable("name") String name, - @PathVariable("page") String page, - @PathVariable("size") String size) throws JSONException { - return repositoryService.getRepositoriesByName(name, page, size); - } - - @RequestMapping(value = "/getRepositoryInterface/{id}", method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PostAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#id).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#id).registeredBy=='null' ) and hasRole('ROLE_USER'))") - public List getRepositoryInterface(@PathVariable("id") String id) throws JSONException { - return repositoryService.getRepositoryInterface(id); - } - - @RequestMapping(value = "/addRepository", method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((#repository.registeredBy==authentication.userInfo.email or returnObject.registeredBy=='null') and hasRole('ROLE_USER'))") - public Repository addRepository(@RequestParam("datatype") String datatype, - @RequestBody Repository repository) throws Exception { - - return repositoryService.addRepository(datatype, repository); - } - - @RequestMapping(value = "/getDnetCountries", method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public List getDnetCountries(){ - return repositoryService.getDnetCountries(); - } - - @RequestMapping(value = "/getTypologies", method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public List getTypologies(){ - return repositoryService.getTypologies(); - } - - @RequestMapping(value = "/getTimezones", method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public List getTimezones(){ - return repositoryService.getTimezones(); - } - - @RequestMapping(value = "/updateRepository", method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((#repository.registeredBy==authentication.userInfo.email or #repository.registeredBy=='null') and hasRole('ROLE_USER'))") - public Repository updateRepository(@RequestBody Repository repository,Authentication authentication) throws Exception { - return repositoryService.updateRepository(repository, authentication); - } - - @RequestMapping(value = "/deleteInterface/", method = RequestMethod.DELETE) - @PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email") - public void deleteRepositoryInterface(@RequestParam("id") String id , - @RequestParam("registeredBy") String registeredBy){ - repositoryService.deleteRepositoryInterface(id, registeredBy); - } - - @RequestMapping(value = "/addInterface", method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repoId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repoId).registeredBy=='null') and hasRole('ROLE_USER'))") - public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype, - @RequestParam("repoId") String repoId, - @RequestParam("registeredBy") String registeredBy, - @RequestBody RepositoryInterface repositoryInterface) throws JSONException, ResourceNotFoundException, ValidatorServiceException { - return repositoryService.addRepositoryInterface(datatype, repoId, registeredBy, repositoryInterface); - } - - @RequestMapping(value = "/getUrlsOfUserRepos/{user_email}/{page}/{size}/",method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER')") - public List getUrlsOfUserRepos(@PathVariable("user_email") String userEmail, - @PathVariable("page") String page, - @PathVariable("size") String size) throws JSONException { - return repositoryService.getUrlsOfUserRepos(userEmail, page, size); - } - - @RequestMapping(value = "/getDatasourceVocabularies/{mode}",method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public List getDatasourceVocabularies(@PathVariable("mode") String mode) { - return repositoryService.getDatasourceVocabularies(mode); - } - - @RequestMapping(value = "/getCompatibilityClasses/{mode}",method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public Map getCompatibilityClasses(@PathVariable("mode") String mode) { - - return repositoryService.getCompatibilityClasses(mode); - } - - @RequestMapping(value = "/getDatasourceClasses/{mode}",method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public Map getDatasourceClasses(@PathVariable("mode") String mode) { - return repositoryService.getDatasourceClasses(mode); - } - - @RequestMapping(value = "/getMetricsInfoForRepository/{repoId}",method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public MetricsInfo getMetricsInfoForRepository(@PathVariable("repoId") String repoId) throws RepositoryServiceException { - return repositoryService.getMetricsInfoForRepository(repoId); - } - - @RequestMapping(value = "/getListLatestUpdate/{mode}",method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public Map getListLatestUpdate(@PathVariable("mode") String mode) throws JSONException { - return repositoryService.getListLatestUpdate(mode); - } - - @RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repoId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repoId).registeredBy=='null') and hasRole('ROLE_USER'))") - public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId, - @RequestParam("registeredBy") String registeredBy, - @RequestBody RepositoryInterface repositoryInterface) throws Exception { - return repositoryService.updateRepositoryInterface(repoId, registeredBy, repositoryInterface); - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/RestTemplateResponseErrorHandler.java b/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/RestTemplateResponseErrorHandler.java deleted file mode 100644 index 488b557..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/RestTemplateResponseErrorHandler.java +++ /dev/null @@ -1,34 +0,0 @@ -package eu.dnetlib.repo.manager.controllers; - -import eu.dnetlib.repo.manager.exception.EndPointException; -import org.springframework.http.HttpStatus; -import org.springframework.http.client.ClientHttpResponse; -import org.springframework.stereotype.Component; -import org.springframework.web.client.ResponseErrorHandler; - -import java.io.IOException; - -import static org.springframework.http.HttpStatus.Series.CLIENT_ERROR; -import static org.springframework.http.HttpStatus.Series.SERVER_ERROR; - -@Component -public class RestTemplateResponseErrorHandler implements ResponseErrorHandler { - - @Override - public boolean hasError(ClientHttpResponse httpResponse) throws IOException { - return (httpResponse.getStatusCode().series() == CLIENT_ERROR - || httpResponse.getStatusCode().series() == SERVER_ERROR); - } - - @Override - public void handleError(ClientHttpResponse httpResponse) throws IOException { - - if (httpResponse.getStatusCode().series() == HttpStatus.Series.SERVER_ERROR) { - throw new EndPointException(); - } else if (httpResponse.getStatusCode().series() == HttpStatus.Series.CLIENT_ERROR) { - if (httpResponse.getStatusCode() == HttpStatus.NOT_FOUND) { - throw new IOException(); - } - } - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/StatsController.java b/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/StatsController.java deleted file mode 100644 index 10e8925..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/StatsController.java +++ /dev/null @@ -1,29 +0,0 @@ -package eu.dnetlib.repo.manager.controllers; - -import eu.dnetlib.repo.manager.service.StatsServiceImpl; -import io.swagger.annotations.Api; -import org.json.JSONException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Map; - -@RestController -@RequestMapping(value = "/stats") -@Api(description = "Stats API", tags = {"statistics"}) -public class StatsController { - - @Autowired - private StatsServiceImpl statsService; - - @RequestMapping(value = "/getStatistics" , method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public Map getStatistics(){ - return statsService.getStatistics(); - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/SushiliteController.java b/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/SushiliteController.java deleted file mode 100644 index 7f934d5..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/SushiliteController.java +++ /dev/null @@ -1,39 +0,0 @@ -package eu.dnetlib.repo.manager.controllers; - -import eu.dnetlib.repo.manager.service.SushiliteServiceImpl; -import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper; -import io.swagger.annotations.Api; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; - -@RestController -@RequestMapping(value = "/sushilite") -@Api(description = "Sushi-Lite API", tags = {"sushilite"}) -public class SushiliteController { - - - @Autowired - private SushiliteServiceImpl sushiliteService; - - @RequestMapping(value = "/getReportResults/{page}/{pageSize}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER')") - public ReportResponseWrapper getReportResults(@PathVariable("page") String page, - @PathVariable("pageSize") String pageSize, - @RequestParam(value = "Report") String Report, - @RequestParam(value = "Release",defaultValue="4") String Release, - @RequestParam(value = "RequestorID",required=false,defaultValue="anonymous") String RequestorID, - @RequestParam(value = "BeginDate",required=false,defaultValue="") String BeginDate, - @RequestParam(value = "EndDate",required=false,defaultValue="") String EndDate, - @RequestParam(value = "RepositoryIdentifier") String RepositoryIdentifier, - @RequestParam(value = "ItemIdentifier",required=false,defaultValue="") String ItemIdentifier, - @RequestParam(value = "ItemDataType",required=false,defaultValue="") String ItemDataType, - @RequestParam(value = "Granularity") String Granularity, - @RequestParam(value = "Pretty",required=false,defaultValue="") String Pretty) { - - return sushiliteService.getReportResults(page, pageSize, Report, Release, RequestorID, BeginDate, EndDate, RepositoryIdentifier, ItemIdentifier, ItemDataType, Granularity, Pretty); - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/UserController.java b/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/UserController.java deleted file mode 100644 index a7641a2..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/UserController.java +++ /dev/null @@ -1,25 +0,0 @@ -package eu.dnetlib.repo.manager.controllers; - -import eu.dnetlib.repo.manager.service.UserServiceImpl; -import io.swagger.annotations.Api; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping(value = "/user") -@Api(description = "User API", tags = {"user"}) -public class UserController { - - @Autowired - private UserServiceImpl userService; - - @RequestMapping(value = "/login" , method = RequestMethod.GET) - @PreAuthorize("hasRole('ROLE_USER')") - public ResponseEntity login() { - return userService.login(); - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/ValidatorController.java b/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/ValidatorController.java deleted file mode 100644 index 7f38d05..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/ValidatorController.java +++ /dev/null @@ -1,134 +0,0 @@ -package eu.dnetlib.repo.manager.controllers; - -import eu.dnetlib.api.functionality.ValidatorServiceException; -import eu.dnetlib.domain.data.RepositoryInterface; -import eu.dnetlib.domain.functionality.validator.JobResultEntry; -import eu.dnetlib.domain.functionality.validator.StoredJob; -import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; -import eu.dnetlib.repo.manager.service.EmailUtils; -import eu.dnetlib.repo.manager.service.RepositoryService; -import eu.dnetlib.repo.manager.service.ValidatorServiceImpl; -import eu.dnetlib.repo.manager.shared.InterfaceInformation; -import eu.dnetlib.repo.manager.shared.ValidationServiceException; -import eu.dnetlib.domain.functionality.validator.JobForValidation; -import eu.dnetlib.domain.functionality.validator.RuleSet; - -import java.util.*; - -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 javax.ws.rs.Path; - - -@RestController -@RequestMapping(value = "/validator") -@Api(description = "Validator API", tags = {"validator"}) -public class ValidatorController { - - @Autowired - private ValidatorServiceImpl validatorService; - - @Autowired - private EmailUtils emailUtils; - - @RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER') and #jobForValidation.userEmail == authentication.userInfo.email") - public JobForValidation submitJobForValidation(@RequestBody JobForValidation jobForValidation) throws ValidatorServiceException { - return validatorService.submitJobForValidation(jobForValidation); - } - - @RequestMapping(value = "/reSubmitJobForValidation/{email}/{jobId}",method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_VALUE, - produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email") - public ResponseEntity reSubmitJobForValidation(@PathVariable("email") String email, - @PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException { - return validatorService.reSubmitJobForValidation(email, jobId); - } - - @RequestMapping(value = "/getRuleSets/{mode}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public List getRuleSets(@PathVariable("mode") String mode) { - return validatorService.getRuleSets(mode); - } - - @RequestMapping(value = "/getSetsOfRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public List getSetsOfRepository(@RequestParam(value = "url", required = true) String url) { - return validatorService.getSetsOfRepository(url); - } - - @RequestMapping(value = "/identifyRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public boolean identifyRepo(@RequestParam(value = "url", required = true) String url) { - return validatorService.identifyRepo(url); - } - - @RequestMapping(value = "/getRuleSet/{acronym}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public RuleSet getRuleSet(@PathVariable("acronym") String acronym) { - return validatorService.getRuleSet(acronym); - } - - @RequestMapping(value = "/getStoredJobsNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - @PreAuthorize("hasRole('ROLE_USER')") - public List getStoredJobsNew(@RequestParam("user") @ApiParam(value = "User email", required = true) String user, - @RequestParam(value = "jobType", required = false) - @ApiParam(value = "Equals to filter job type on validation history page") String jobType, - @RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset, - @RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit, - @RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom, - @RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo, - @RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = true) String validationStatus - ) throws ValidatorServiceException { - return validatorService.getStoredJobsNew(user, jobType, offset, limit, dateFrom, dateTo, validationStatus); - } - - @RequestMapping(value = "/getStoredJobsTotalNumberNew" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException { - return validatorService.getStoredJobsTotalNumberNew(user, jobType, validationStatus); - } - - @RequestMapping(value = "/getInterfaceInformation" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl") String baseUrl) throws ValidationServiceException { - return validatorService.getInterfaceInformation(baseUrl); - } - - @RequestMapping(value = "/validationSummary/{repoId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public List getInterfaceInformation(@PathVariable(value = "repoId") String repoId, @RequestParam(name = "size", defaultValue = "20") int size ) throws ValidatorServiceException, ResourceNotFoundException, JSONException { - return validatorService.getJobsSummary(repoId,size); - } - - - @RequestMapping(value = "/complete" , method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseBody - public void validationCompleted( - @RequestParam(value = "interfaceId") String interfaceId, - @RequestParam(value = "repoId") String repoId, - @RequestParam(value = "jobId") String jobId, - @RequestParam(value = "issuerEmail") String issuerEmail, - @RequestParam(value = "isUpdate") boolean isUpdate, - @RequestParam(value = "isSuccess") boolean isSuccess, - @RequestParam(value = "scoreUsage") int scoreUsage, - @RequestParam(value = "scoreContent") int scoreContent) throws Exception { - - emailUtils.sendUponJobCompletion(repoId,interfaceId,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId); - } - - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/BrokerSummary.java b/trunk/src/main/java/eu/dnetlib/repo/manager/domain/BrokerSummary.java deleted file mode 100644 index 17355ae..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/BrokerSummary.java +++ /dev/null @@ -1,36 +0,0 @@ -package eu.dnetlib.repo.manager.domain; - -import eu.dnetlib.repo.manager.shared.broker.BrowseEntry; -import eu.dnetlib.repo.manager.shared.broker.SimpleSubscriptionDesc; - -import java.util.List; -import java.util.Map; - -public class BrokerSummary { - private Map> userSubs; - - private List topicsForDatasource; - - public BrokerSummary(){} - - public BrokerSummary(Map> userSubs, List topicsForDatasource) { - this.userSubs = userSubs; - this.topicsForDatasource = topicsForDatasource; - } - - public Map> getUserSubs() { - return userSubs; - } - - public void setUserSubs(Map> userSubs) { - this.userSubs = userSubs; - } - - public List getTopicsForDatasource() { - return topicsForDatasource; - } - - public void setTopicsForDatasource(List topicsForDatasource) { - this.topicsForDatasource = topicsForDatasource; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/CollectionMonitorSummary.java b/trunk/src/main/java/eu/dnetlib/repo/manager/domain/CollectionMonitorSummary.java deleted file mode 100644 index 7dffb8e..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/CollectionMonitorSummary.java +++ /dev/null @@ -1,37 +0,0 @@ -package eu.dnetlib.repo.manager.domain; - -import eu.dnetlib.repo.manager.shared.AggregationDetails; -import eu.dnetlib.repo.manager.shared.broker.BrowseEntry; -import eu.dnetlib.repo.manager.shared.broker.SimpleSubscriptionDesc; - -import java.util.List; -import java.util.Map; - -public class CollectionMonitorSummary { - private List aggregationDetails; - - private AggregationDetails lastIndexedVersion; - - public CollectionMonitorSummary(){} - - public CollectionMonitorSummary(List aggregationDetails, AggregationDetails lastIndexedVersion) { - this.aggregationDetails = aggregationDetails; - this.lastIndexedVersion = lastIndexedVersion; - } - - public List getAggregationDetails() { - return aggregationDetails; - } - - public void setAggregationDetails(List aggregationDetails) { - this.aggregationDetails = aggregationDetails; - } - - public AggregationDetails getLastIndexedVersion() { - return lastIndexedVersion; - } - - public void setLastIndexedVersion(AggregationDetails lastIndexedVersion) { - this.lastIndexedVersion = lastIndexedVersion; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/OrderByField.java b/trunk/src/main/java/eu/dnetlib/repo/manager/domain/OrderByField.java deleted file mode 100644 index 13cba54..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/OrderByField.java +++ /dev/null @@ -1,26 +0,0 @@ -package eu.dnetlib.repo.manager.domain; - -public enum OrderByField { - - REPOSITORY_NAME("repositoryname"), - REPOSITORY_ID("repositoryid"), - SITE_ID("siteid"), - CREATION_DATE("creationdate"), - VALIDATION_DATE("validationdate"), - REQUESTOR_NAME("requestorname"), - REQUESTOR_EMAIL("requestoremail"), - VALIDATED("validated"), - COUNTRY("country"); - - - private final String text; - - OrderByField(String text) { - this.text = text; - } - - @Override - public String toString() { - return text; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/OrderByType.java b/trunk/src/main/java/eu/dnetlib/repo/manager/domain/OrderByType.java deleted file mode 100644 index 920ca14..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/OrderByType.java +++ /dev/null @@ -1,18 +0,0 @@ -package eu.dnetlib.repo.manager.domain; - -public enum OrderByType { - - ASC("ASC"), - DSC("DESC"); - - private final String text; - - OrderByType(String text) { - this.text = text; - } - - @Override - public String toString() { - return text; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/Organization.java b/trunk/src/main/java/eu/dnetlib/repo/manager/domain/Organization.java deleted file mode 100644 index 6a64898..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/Organization.java +++ /dev/null @@ -1,51 +0,0 @@ -package eu.dnetlib.repo.manager.domain; - -import java.io.Serializable; - -public class Organization implements Serializable { - private String country; - private String legalname; - private String websiteurl; - private String legalshortname; - private String logourl; - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - public String getLegalname() { - return legalname; - } - - public void setLegalname(String legalname) { - this.legalname = legalname; - } - - public String getWebsiteurl() { - return websiteurl; - } - - public void setWebsiteurl(String websiteurl) { - this.websiteurl = websiteurl; - } - - public String getLegalshortname() { - return legalshortname; - } - - public void setLegalshortname(String legalshortname) { - this.legalshortname = legalshortname; - } - - public String getLogourl() { - return logourl; - } - - public void setLogourl(String logourl) { - this.logourl = logourl; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/Paging.java b/trunk/src/main/java/eu/dnetlib/repo/manager/domain/Paging.java deleted file mode 100644 index 86ebccc..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/Paging.java +++ /dev/null @@ -1,77 +0,0 @@ -package eu.dnetlib.repo.manager.domain; - - -import javax.validation.constraints.NotNull; -import java.util.ArrayList; -import java.util.List; - -public class Paging { - - private int total; - - private int from; - - private int to; - - private List results; - - public Paging(int total, int from, int to, List results) { - this.total = total; - this.from = from; - this.to = to; - this.results = results; - } - - public Paging(@NotNull Paging page) { - this.total = page.getTotal(); - this.from = page.getFrom(); - this.to = page.getTo(); - this.results = page.getResults(); - } - - public Paging(@NotNull Paging page, List results) { - this.total = page.getTotal(); - this.from = page.getFrom(); - this.to = page.getTo(); - this.results = results; - } - - public Paging() { - this.total = 0; - this.from = 0; - this.to = 0; - this.results = new ArrayList<>(); - } - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - this.total = total; - } - - public int getFrom() { - return from; - } - - public void setFrom(int from) { - this.from = from; - } - - public int getTo() { - return to; - } - - public void setTo(int to) { - this.to = to; - } - - public List getResults() { - return results; - } - - public void setResults(List results) { - this.results = results; - } -} \ No newline at end of file diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/RepositorySnippet.java b/trunk/src/main/java/eu/dnetlib/repo/manager/domain/RepositorySnippet.java deleted file mode 100644 index d35e2e2..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/RepositorySnippet.java +++ /dev/null @@ -1,81 +0,0 @@ -package eu.dnetlib.repo.manager.domain; - -import com.google.gwt.user.client.rpc.IsSerializable; - -public class RepositorySnippet implements IsSerializable { - - private String id; - private String officialname; - private String englishname; - private String websiteurl; - private String typology; - private String registeredby; - private Organization[] organizations; - private String registrationdate; - - public RepositorySnippet() {} - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getOfficialname() { - return officialname; - } - - public void setOfficialname(String officialname) { - this.officialname = officialname; - } - - public String getEnglishname() { - return englishname; - } - - public void setEnglishname(String englishname) { - this.englishname = englishname; - } - - public String getWebsiteurl() { - return websiteurl; - } - - public void setWebsiteurl(String websiteurl) { - this.websiteurl = websiteurl; - } - - public String getRegisteredby() { - return registeredby; - } - - public void setRegisteredby(String registeredby) { - this.registeredby = registeredby; - } - - public String getTypology() { - return typology; - } - - public void setTypology(String typology) { - this.typology = typology; - } - - public Organization[] getOrganizations() { - return organizations; - } - - public void setOrganizations(Organization[] organizations) { - this.organizations = organizations; - } - - public String getRegistrationdate() { - return registrationdate; - } - - public void setRegistrationdate(String registrationdate) { - this.registrationdate = registrationdate; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/RepositorySummaryInfo.java b/trunk/src/main/java/eu/dnetlib/repo/manager/domain/RepositorySummaryInfo.java deleted file mode 100644 index 009052a..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/RepositorySummaryInfo.java +++ /dev/null @@ -1,84 +0,0 @@ -package eu.dnetlib.repo.manager.domain; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.Date; - -public class RepositorySummaryInfo implements IsSerializable { - - String id; - String repositoryName; - String logoURL; - int recordsCollected; - Date lastIndexedVersion; - long enrichmentEvents; - String totalViews; - String totalDownloads; - - public RepositorySummaryInfo() { - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getRepositoryName() { - return repositoryName; - } - - public void setRepositoryName(String repositoryName) { - this.repositoryName = repositoryName; - } - - public String getLogoURL() { - return logoURL; - } - - public void setLogoURL(String logoURL) { - this.logoURL = logoURL; - } - - public int getRecordsCollected() { - return recordsCollected; - } - - public void setRecordsCollected(int recordsCollected) { - this.recordsCollected = recordsCollected; - } - - public Date getLastIndexedVersion() { - return lastIndexedVersion; - } - - public void setLastIndexedVersion(Date lastIndexedVersion) { - this.lastIndexedVersion = lastIndexedVersion; - } - - public long getEnrichmentEvents() { - return enrichmentEvents; - } - - public void setEnrichmentEvents(long enrichmentEvents) { - this.enrichmentEvents = enrichmentEvents; - } - - public String getTotalViews() { - return totalViews; - } - - public void setTotalViews(String totalViews) { - this.totalViews = totalViews; - } - - public String getTotalDownloads() { - return totalDownloads; - } - - public void setTotalDownloads(String totalDownloads) { - this.totalDownloads = totalDownloads; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/RequestFilter.java b/trunk/src/main/java/eu/dnetlib/repo/manager/domain/RequestFilter.java deleted file mode 100644 index ebb586e..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/RequestFilter.java +++ /dev/null @@ -1,78 +0,0 @@ -package eu.dnetlib.repo.manager.domain; - -import com.fasterxml.jackson.annotation.JsonInclude; - -@JsonInclude(JsonInclude.Include.NON_NULL) -public class RequestFilter{ - - private String registeredby = null; - private String typology = null; - private String country = null; - private String id = null; - private String officialname = null; - private String englishname = null; - private String collectedfrom = null; - - - - - public RequestFilter() { - - } - - public String getTypology() { - return typology; - } - - public void setTypology(String typology) { - this.typology = typology; - } - - public String getRegisteredby() { - return registeredby; - } - - public void setRegisteredby(String registeredby) { - this.registeredby = registeredby; - } - - public String getCountry() { - return country; - } - - public void setCountry(String country) { - this.country = country; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getOfficialname() { - return officialname; - } - - public void setOfficialname(String officialname) { - this.officialname = officialname; - } - - public String getCollectedfrom() { - return collectedfrom; - } - - public void setCollectedfrom(String collectedfrom) { - this.collectedfrom = collectedfrom; - } - - public String getEnglishname() { - return englishname; - } - - public void setEnglishname(String englishname) { - this.englishname = englishname; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/UsageSummary.java b/trunk/src/main/java/eu/dnetlib/repo/manager/domain/UsageSummary.java deleted file mode 100644 index 9327109..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/domain/UsageSummary.java +++ /dev/null @@ -1,39 +0,0 @@ -package eu.dnetlib.repo.manager.domain; - -import eu.dnetlib.domain.data.PiwikInfo; -import eu.dnetlib.repo.manager.shared.MetricsInfo; -import eu.dnetlib.repo.manager.shared.broker.BrowseEntry; -import eu.dnetlib.repo.manager.shared.broker.SimpleSubscriptionDesc; - -import java.util.List; -import java.util.Map; - -public class UsageSummary { - private MetricsInfo metricsInfo; - - private PiwikInfo piwikInfo; - - public UsageSummary() { - } - - public UsageSummary(MetricsInfo metricsInfo, PiwikInfo piwikInfo) { - this.metricsInfo = metricsInfo; - this.piwikInfo = piwikInfo; - } - - public MetricsInfo getMetricsInfo() { - return metricsInfo; - } - - public void setMetricsInfo(MetricsInfo metricsInfo) { - this.metricsInfo = metricsInfo; - } - - public PiwikInfo getPiwikInfo() { - return piwikInfo; - } - - public void setPiwikInfo(PiwikInfo piwikInfo) { - this.piwikInfo = piwikInfo; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/exception/EndPointException.java b/trunk/src/main/java/eu/dnetlib/repo/manager/exception/EndPointException.java deleted file mode 100644 index d4f5051..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/exception/EndPointException.java +++ /dev/null @@ -1,19 +0,0 @@ -package eu.dnetlib.repo.manager.exception; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ResponseStatus; - -import java.io.IOException; - -//@ResponseStatus(HttpStatus.GATEWAY_TIMEOUT) -public class EndPointException extends IOException { - - public EndPointException() { - super("Endpoint not responding!"); - } - - public EndPointException(String url) { - super("Endpoint with url: " + url + " not responding!"); - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/exception/ResourceNotFoundException.java b/trunk/src/main/java/eu/dnetlib/repo/manager/exception/ResourceNotFoundException.java deleted file mode 100644 index 68042cf..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/exception/ResourceNotFoundException.java +++ /dev/null @@ -1,15 +0,0 @@ -package eu.dnetlib.repo.manager.exception; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ResponseStatus; - -@ResponseStatus(HttpStatus.NOT_FOUND) -public class ResourceNotFoundException extends Exception { - public ResourceNotFoundException() { - super("Resource Not Found"); - } - - public ResourceNotFoundException(String id, String resourceType) { - super(resourceType + " with id " + id + " was not found"); - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/exception/ServerError.java b/trunk/src/main/java/eu/dnetlib/repo/manager/exception/ServerError.java deleted file mode 100644 index a9fa7fc..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/exception/ServerError.java +++ /dev/null @@ -1,21 +0,0 @@ -package eu.dnetlib.repo.manager.exception; - -public class ServerError { - - public final String url; - public final String error; - - public ServerError(String url, Exception ex) { - this.url = url; - this.error = ex.getMessage(); - } - - public String getUrl() { - return this.url; - } - - public String getError() { - return this.error; - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/BrokerService.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/BrokerService.java deleted file mode 100644 index c8e149c..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/BrokerService.java +++ /dev/null @@ -1,50 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -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 org.json.JSONException; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; - -import java.io.IOException; -import java.util.List; -import java.util.Map; - - -public interface BrokerService { - - DatasourcesBroker getDatasourcesOfUser(String user, String includeShared, String includeByOthers) throws BrokerException, JSONException; - - List getTopicsForDatasource(String datasourceName) throws BrokerException; - - EventsPage advancedShowEvents(String page, - String size, - AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException; - - EventsPage showEvents(String datasourceName, - String topic, - String page, - String size) throws BrokerException, JSONException; - - Map> getSimpleSubscriptionsOfUser(String userEmail) throws BrokerException; - - Map> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) throws BrokerException; - - Subscription subscribe(OpenaireSubscription obj) throws BrokerException; - - ResponseEntity unsubscribe(String subscriptionId) throws BrokerException; - - Subscription getSubscription(String subscriptionId) throws BrokerException; - - Map getDnetTopics() throws BrokerException; - - EventsPage getNotificationsBySubscriptionId(String subscriptionId, String page, String size) throws BrokerException; - - Map> getSubscriptionsOfUser(String userEmail) throws BrokerException; -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/BrokerServiceImpl.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/BrokerServiceImpl.java deleted file mode 100644 index 4b92d3f..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/BrokerServiceImpl.java +++ /dev/null @@ -1,397 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import eu.dnetlib.domain.data.Repository; -import eu.dnetlib.repo.manager.shared.BrokerException; -import eu.dnetlib.repo.manager.shared.Term; -import eu.dnetlib.repo.manager.shared.Tuple; -import eu.dnetlib.repo.manager.shared.broker.*; -import org.json.JSONException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.*; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.stereotype.Service; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestClientException; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponents; -import org.springframework.web.util.UriComponentsBuilder; - -import javax.annotation.PostConstruct; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.*; - -@Service("brokerService") -public class BrokerServiceImpl implements BrokerService { - - @Autowired - private RepositoryServiceImpl repoAPI; - @Value("${services.broker.url}:${services.broker.port}/${services.broker.api}${services.broker.openaire}") - private String openairePath; - @Value("${services.broker.url}:${services.broker.port}/${services.broker.api}") - private String apiPath; - @Value("${topic_types.url}") - private String topicsURL; - - private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger - .getLogger(BrokerServiceImpl.class); - - @Autowired - RestTemplate restTemplate ; - - private HttpHeaders httpHeaders; - - private HashMap topics = new HashMap(); - - @Autowired - private EmailUtils emailUtils; - - @PostConstruct - private void initDnetTopicsMap() { - - httpHeaders = new HttpHeaders(); - httpHeaders.set("Content-Type", "application/json"); - - LOGGER.debug("Init dnet topics!"); - try (InputStream is = new URL(topicsURL).openStream() ){ - ObjectMapper mapper = new ObjectMapper(); - JsonNode root = mapper.readTree(is); - for (JsonNode term : root.path("terms") ) - topics.put(term.path("code").textValue(), parseTerm(term)); - } catch (IOException e) { - LOGGER.debug("Exception on initDnetTopicsMap" , e); - emailUtils.reportException(e); - } - } - - private Term parseTerm(JsonNode term) { - return new Term(term.path("englishName").textValue(),term.path("nativeName").textValue(), - term.path("encoding").textValue(),term.path("code").textValue()); - } - - - @Override - public DatasourcesBroker getDatasourcesOfUser(String user,String includeShared,String includeByOthers) throws JSONException { - - DatasourcesBroker ret = new DatasourcesBroker(); - try { - ret.setDatasourcesOfUser(getDatasourcesOfUserType(getRepositoriesOfUser(user))); - //TODO fix bug when values are true - if (Boolean.parseBoolean(includeShared)) { - List sharedDatasourceIds = new ArrayList(); - ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds))); - } - - if (Boolean.parseBoolean(includeByOthers)) { - ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user))); - } - } catch (BrokerException e) { - LOGGER.debug("Exception on getDatasourcesOfUser" , e); - emailUtils.reportException(e); - } - - return ret; - } - - @Override - public List getTopicsForDatasource(String datasourceName) throws BrokerException { - final String service = "/topicsForDatasource"; - - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service) - .queryParam("ds", datasourceName); - - ResponseEntity> resp; - try { - resp = restTemplate.exchange( - builder.build().encode().toUri(), - HttpMethod.GET, - null, - new ParameterizedTypeReference>() { - }); - } catch (RestClientException e) { - LOGGER.debug("Exception on getTopicsForDatasource" , e); - emailUtils.reportException(e); - throw new BrokerException(e); - } - - return resp.getBody(); - } - - @Override - public EventsPage advancedShowEvents(String page, - String size, - AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException { - - final String service = "/events/{page}/{pageSize}"; - - Map uriParams = new HashMap<>(); - uriParams.put("page", Long.parseLong(page)); - uriParams.put("pageSize", Long.parseLong(size)); - - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service); - - MultiValueMap headers = new LinkedMultiValueMap<>(); - advQueryObject.setPage(Long.parseLong(page)); - HttpEntity entity = new HttpEntity<>(advQueryObject, httpHeaders); - ResponseEntity resp; - try { - resp = restTemplate.exchange( - builder.buildAndExpand(uriParams).encode().toUri(), - HttpMethod.POST, - entity, - new ParameterizedTypeReference() { - } - ); - } catch (RestClientException e) { - LOGGER.debug("Exception on advancedShowEvents" , e); - emailUtils.reportException(e); - throw new BrokerException(e); - } - return resp.getBody(); - - - } - - - private List> getDatasourcesOfUserType(List repositories) throws BrokerException { - - List> entries = new ArrayList<>(); - for (Repository repo : repositories) { - BrowseEntry temp = new BrowseEntry(); - temp.setValue(repo.getOfficialName()); - temp.setSize(new Long(0)); - for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialName())) { - temp.setSize(temp.getSize() + e.getSize()); - } - Tuple tup = new Tuple<>(temp, repo.getLogoUrl()); - entries.add(tup); - } - - // sort the collection by the second field of the tuple which is size - Collections.sort(entries, new Comparator>() { - @Override - public int compare(Tuple e1, Tuple e2) { - return (int) (e2.getFirst().getSize().longValue() - e1.getFirst().getSize().longValue()); - } - }); - - return entries; - } - - private List getRepositoriesOfUser(String userEmail) throws JSONException { - - int page = 0; - int size = 50; - List rs ; - List resultSet = new ArrayList<>(); - - while (true){ - rs = repoAPI.getRepositoriesOfUser(userEmail, String.valueOf(page), String.valueOf(size)); - resultSet.addAll(rs); - page+=1; - if(rs.size() == 0) break; - } - return resultSet; - } - - private List getRepositoriesByIds(List sharedDatasourceIds) { - return null; - } - - @Override - public EventsPage showEvents(String datasourceName, - String topic, - String page, - String size) throws BrokerException, JSONException { - - final String service = "/events"; - - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service) - .queryParam("ds", datasourceName) - .queryParam("topic", topic) - .path("/{page}/{size}/"); - - ResponseEntity resp; - try { - resp = restTemplate.exchange( - builder.build().expand(page, size).encode().toUri(), - HttpMethod.GET, - null, - new ParameterizedTypeReference() { - }); - } catch (RestClientException e) { - LOGGER.debug("Exception on showEvents" , e); - emailUtils.reportException(e); - throw new BrokerException(e); - } - return resp.getBody(); - } - - @Override - public Map> getSimpleSubscriptionsOfUser(String userEmail) - throws BrokerException { - - final String service = "/subscriptions"; - - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service) - .queryParam("email", userEmail); - - LOGGER.debug(builder.build().encode().toUri()); - ResponseEntity>> resp; - try { - resp = restTemplate.exchange( - builder.build().encode().toUri(), - HttpMethod.GET, - null, - new ParameterizedTypeReference>>() { - }); - } catch (RestClientException e) { - LOGGER.debug("Exception on getSimpleSubscriptionsOfUser" , e); - emailUtils.reportException(e); - throw new BrokerException(e); - } - return resp.getBody(); - } - - @Override - public Map> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) throws BrokerException { - Map> subscriptionsOfUser = getSimpleSubscriptionsOfUser(userEmail); - - return null; - } - - @Override - public Subscription subscribe(OpenaireSubscription obj) throws BrokerException { - final String service = "/subscribe"; - - //build the uri params - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service); - - HttpEntity entity = new HttpEntity<>(obj, httpHeaders); - - //create new template engine - RestTemplate template = new RestTemplate(); - template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); - ResponseEntity resp; - try { - //communicate with endpoint - resp = restTemplate.exchange( - builder.build().encode().toUri(), - HttpMethod.POST, - entity, - new ParameterizedTypeReference() { - }); - } catch (RestClientException e) { - LOGGER.debug("Exception on OpenaireSubscription" , e); - emailUtils.reportException(e); - throw new BrokerException(e); - } - - return resp.getBody(); - } - - @Override - public ResponseEntity unsubscribe(String subscriptionId) throws BrokerException { - final String service = "/subscriptions/" + subscriptionId; - - //build the uri params - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(apiPath + service); - - try { - //communicate with endpoint - restTemplate.exchange( - builder.build().encode().toUri(), - HttpMethod.DELETE, - null, - new ParameterizedTypeReference() { - }); - } catch (RestClientException e) { - LOGGER.debug("Exception on unsubscribe" , e); - emailUtils.reportException(e); - throw new BrokerException(e); - } - return new ResponseEntity<>("OK",HttpStatus.OK); - } - - @Override - public Subscription getSubscription( String subscriptionId) throws BrokerException { - final String service = "/subscriptions/" + subscriptionId; - - //build the uri params - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(apiPath + service); - - ResponseEntity resp; - try { - //communicate with endpoint - resp = restTemplate.exchange( - builder.build().encode().toUri(), - HttpMethod.GET, - null, - new ParameterizedTypeReference() { - }); - } catch (RestClientException e) { - LOGGER.debug("Exception on getSubscription" , e); - emailUtils.reportException(e); - throw new BrokerException(e); - } - return resp.getBody(); - } - - @Override - public Map getDnetTopics() throws BrokerException { - return topics; - } - - @Override - public EventsPage getNotificationsBySubscriptionId(String subscriptionId, - String page, - String size) throws BrokerException { - - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(openairePath + "/notifications/") - .path("/{id}/{page}/{size}/") - .build().expand(subscriptionId,page, size).encode(); - - ResponseEntity resp; - try { - resp = restTemplate.exchange( - uriComponents.toUri(), - HttpMethod.GET, - null, - new ParameterizedTypeReference() { - }); - } catch (RestClientException e) { - LOGGER.debug("Exception on getNotificationsBySubscriptionId" , e); - emailUtils.reportException(e); - throw new BrokerException(e); - } - return resp.getBody(); - } - - //@Override - public Map> getSubscriptionsOfUser(String userEmail) - throws BrokerException { - - Map> simpleSubs = getSimpleSubscriptionsOfUser(userEmail); - Map> subs = new HashMap<>(); - List subscriptions = null; - - for(String s:simpleSubs.keySet()){ - List simpleSubscriptionDescs = simpleSubs.get(s); - for(SimpleSubscriptionDesc simpleSubscriptionDesc : simpleSubscriptionDescs) { - subscriptions = new ArrayList<>(); - subscriptions.add(getSubscription(simpleSubscriptionDesc.getId())); - } - subs.put(s,subscriptions); - } - return subs; - } - - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/DashboardService.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/DashboardService.java deleted file mode 100644 index cd417e5..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/DashboardService.java +++ /dev/null @@ -1,14 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo; -import org.json.JSONException; -import org.springframework.web.bind.annotation.PathVariable; - -import java.util.List; - -public interface DashboardService { - - List getRepositoriesSummaryInfo(@PathVariable("userEmail") String userEmail, - @PathVariable("page") String page, - @PathVariable("size") String size) throws JSONException; -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/DashboardServiceImpl.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/DashboardServiceImpl.java deleted file mode 100644 index c0379d6..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/DashboardServiceImpl.java +++ /dev/null @@ -1,97 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import eu.dnetlib.domain.data.Repository; -import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo; -import eu.dnetlib.repo.manager.shared.AggregationDetails; -import eu.dnetlib.repo.manager.shared.BrokerException; -import eu.dnetlib.repo.manager.shared.MetricsInfo; -import eu.dnetlib.repo.manager.shared.RepositoryServiceException; -import eu.dnetlib.repo.manager.shared.broker.BrowseEntry; -import org.apache.log4j.Logger; -import org.json.JSONException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.PathVariable; - -import javax.xml.ws.ServiceMode; -import java.util.ArrayList; -import java.util.List; - -@Service("dashboardService") -public class DashboardServiceImpl implements DashboardService { - - private static final Logger logger = Logger.getLogger(DashboardServiceImpl.class); - - @Autowired - private EmailUtils emailUtils; - - @Autowired - private RepositoryService repositoryService; - - @Autowired - private BrokerService brokerService; - - @Override - public List getRepositoriesSummaryInfo(String userEmail, - String page, - String size){ - - List repositorySummaryInfoList = new ArrayList<>(); - - try { - - List repositoriesOfUser = repositoryService.getRepositoriesOfUser(userEmail, page, size); - for(Repository repository: repositoriesOfUser) { - - RepositorySummaryInfo repositorySummaryInfo = new RepositorySummaryInfo(); - repositorySummaryInfo.setId(repository.getId()); - repositorySummaryInfo.setRepositoryName(repository.getOfficialName()); - repositorySummaryInfo.setLogoURL(repository.getLogoUrl()); - - //TODO getRepositoryAggregations returns only the 20 more recent items. Is it positive that we will find an indexed version there? - long start = System.currentTimeMillis(); - List aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId(),0,20); - for(AggregationDetails aggregationDetails: aggregationDetailsList) { - if(aggregationDetails.getIndexedVersion()) { - repositorySummaryInfo.setRecordsCollected(aggregationDetails.getNumberOfRecords()); - repositorySummaryInfo.setLastIndexedVersion(aggregationDetails.getDate()); - break; - } - } - long end = System.currentTimeMillis(); - - System.out.println("Got repo aggregations in "+ (end-start)+"ms"); - - try { - - MetricsInfo metricsInfo = repositoryService.getMetricsInfoForRepository(repository.getId()); - repositorySummaryInfo.setTotalDownloads(metricsInfo.getMetricsNumbers().getTotalDownloads()); - repositorySummaryInfo.setTotalViews(metricsInfo.getMetricsNumbers().getTotalViews()); - - } catch (RepositoryServiceException e) { - logger.error("Exception getting metrics info for repository: " + repository.getId(), e); - } - - try { - - List events = brokerService.getTopicsForDatasource(repository.getOfficialName()); - Long totalEvents = 0L; - for(BrowseEntry browseEntry: events) - totalEvents += browseEntry.getSize(); - repositorySummaryInfo.setEnrichmentEvents(totalEvents); - - - } catch (BrokerException e) { - logger.error("Exception getting broker events for repository: " + repository.getId(), e); - } - - repositorySummaryInfoList.add(repositorySummaryInfo); - } - - } catch (Exception e) { - logger.error("Something baad happened!", e); - } - - return repositorySummaryInfoList; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/EmailUtils.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/EmailUtils.java deleted file mode 100644 index a8720b6..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/EmailUtils.java +++ /dev/null @@ -1,73 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import eu.dnetlib.domain.data.PiwikInfo; -import eu.dnetlib.domain.data.Repository; -import eu.dnetlib.domain.data.RepositoryInterface; -import eu.dnetlib.domain.functionality.validator.JobForValidation; -import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; -import eu.dnetlib.repo.manager.shared.ValidationServiceException; -import org.json.JSONException; -import org.springframework.security.core.Authentication; - -public interface EmailUtils { - - - void reportException(Exception exception); - - void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception; - - void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception; - - void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception; - - void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception; - - /****USER REGISTRATION REQUEST EMAILS****/ - void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception; - - void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception; - - /****SUCCESSFUL REGISTRATION RESULTS EMAILS****/ - void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; - - void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; - - /****FAILURE REGISTRATION RESULTS EMAILS****/ - void sendUserRegistrationResultsFailureEmail(String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; - - void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; - - /****SUCCESSFUL UPDATE RESULTS EMAILS****/ - void sendUserUpdateResultsSuccessEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; - - void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; - - /****FAILURE UPDATE RESULTS EMAILS****/ - void sendUserUpdateResultsFailureEmail(String issuer, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; - - void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; - - /****VALIDATION OF CONTENT PROVIDER EMAILS****/ - void sendUserValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; - - void sendAdminValidationResults(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; - - /****GENERAL FAILURE OF VALIDATOR****/ - void sendAdminGeneralFailure(String issuer,String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception; - - - void sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception; - - void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception; - - void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception; - - void sendUponJobCompletion(String repoId, - String repoInterfaceId, - int scoreUsage, - int scoreContent, - boolean isSuccess, - boolean isUpdate, - String issuerEmail, - String jobId) throws Exception; -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/EmailUtilsImpl.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/EmailUtilsImpl.java deleted file mode 100644 index fe3339d..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/EmailUtilsImpl.java +++ /dev/null @@ -1,772 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import eu.dnetlib.domain.data.PiwikInfo; -import eu.dnetlib.domain.data.Repository; -import eu.dnetlib.domain.data.RepositoryInterface; -import eu.dnetlib.domain.functionality.validator.JobForValidation; -import eu.dnetlib.repo.manager.config.CascadingPropertyLoader; -import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; -import eu.dnetlib.repo.manager.shared.ValidationServiceException; -import eu.dnetlib.utils.MailLibrary; -import org.apache.log4j.Logger; -import org.json.JSONException; -import org.mitre.openid.connect.model.OIDCAuthenticationToken; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Component; - -import javax.annotation.PostConstruct; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - - -@Component("emailUtils") -public class EmailUtilsImpl implements EmailUtils { - - private static Logger LOGGER = Logger.getLogger(EmailUtilsImpl.class); - - private List specialRecipients = new ArrayList(); - private boolean override = false, logonly = false; - private String overrideEmail = null, from = null; - - @Autowired - private MailLibrary mailLibrary; - - @Autowired - private CascadingPropertyLoader pLoader; - - @Value("${services.repo-manager.baseUrl}") - private String baseUrl; - - @Value("${services.repo-manager.adminEmail}") - private String adminEmail; - - @Value("${services.repomanager.usagestats.adminEmail}") - private String usageStatsAdminEmail; - - @Value("${services.provide.adminEmail}") - private String provideAdminEmail; - - @Value("${validator.results.url}") - private String valBaseUrl; - - @Autowired - private RepositoryService repositoryService; - - - @PostConstruct - public void init(){ - System.out.println("url -> " + this.baseUrl); - } - - - @Override - public void reportException(Exception exception) { - Writer writer = new StringWriter(); - PrintWriter printWriter = new PrintWriter(writer); - exception.printStackTrace(printWriter); - - List recipients = new ArrayList(); - - try { - recipients.add(this.adminEmail); - String message = "An exception has occurred:\n"+writer.toString(); - String subject = "Automatic Bug Report"; - this.sendMail(recipients, subject, message, false, null); - } catch (Exception e) { - LOGGER.error("Error sending error report", e); - } - } - - @Override - public void sendAdministratorRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception { - - try { - String subject = "[OpenAIRE-Usage Statistics] New request to enable usage statistics"; - - String message = "Dear administrator,\n" + - "\n" + - "we have received a request to enable the OpenAIRE usage statistics for the following repository \n" + - "\n" + - "Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" + - "Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" + - "Piwik ID - " + piwikInfo.getSiteId() + "\n" + - "Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" + - "\n" + - "For more information about this request, go here: \n" + - this.baseUrl + "/admin/metrics\n" + - "\n" + - "Best,\n" + - "The OpenAIRE team"; - - this.sendMail(this.usageStatsAdminEmail, subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending request to enable metrics email to administrator: " + this.usageStatsAdminEmail, e); - throw e; - } - } - - @Override - public void sendUserRequestToEnableMetrics(PiwikInfo piwikInfo) throws Exception { - - try { - String subject = "[OpenAIRE-Usage Statistics] Your request to enable usage statistics"; - - String message = "Dear " + piwikInfo.getRequestorName() + ",\n" + - "\n" + - "we have received your request to enable the OpenAIRE usage statistics for your repository\n" + - "\n" + - "Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" + - "Piwik ID - " + piwikInfo.getSiteId() + "\n" + - "Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" + - "\n" + - "In order to enable the usage statistics, you must install the OpenAIRE's tracking code in your repository software. " + - "OpenAIRE's usage statistics service tracking code is maintained on Github as a patch for various versions of DSpace " + - "(https://github.com/openaire/OpenAIRE-Piwik-DSpace) and as an Eprints plugin for version 3 " + - "(https://github.com/openaire/EPrints-OAPiwik). In case the platform is different from DSpace or EPrints please contact " + - "the OpenAIRE team in repositoryusagestats@openaire.eu in order to find a solution.\n" + - "\n" + - "For more information about your request and configuration details, go here: \n" + - this.baseUrl + "/getImpact/instructions/" + piwikInfo.getRepositoryId() + "\n" + - "\n" + - "Once you have finished configuring your repository or if you have any questions, please notify the OpenAIRE team by sending \n" + - "an email to repositoryusagestats@openaire.eu\n" + - "\n" + - "Best,\n" + - "The OpenAIRE team"; - - this.sendMail(piwikInfo.getRequestorEmail(), subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending request to enable metrics email to user: " + piwikInfo.getRequestorEmail(), e); - throw e; - } - } - - @Override - public void sendAdministratorMetricsEnabled(PiwikInfo piwikInfo) throws Exception { - - try { - String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled"; - - String message = "Dear administrator,\n" + - "\n" + - "The installation and configuration of OpenAIRE's tracking code for the following repository " + - "has been completed and validated and the usage statistics have been enabled in OpenAIRE.\n" + - "\n" + - "Repository - " + piwikInfo.getRepositoryName() + ", " + piwikInfo.getCountry() + " (" + piwikInfo.getRepositoryId() + ")\n" + - "Requestor - " + piwikInfo.getRequestorName() + ", " + piwikInfo.getRequestorEmail() + "\n" + - "Piwik ID - " + piwikInfo.getSiteId() + "\n" + - "Authentication token - " + piwikInfo.getAuthenticationToken() + "\n" + - "\n" + - "Best,\n" + - "The OpenAIRE team"; - - this.sendMail(this.usageStatsAdminEmail, subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending metrics enabled notification email to administator: " + this.usageStatsAdminEmail, e); - throw e; - } - } - - @Override - public void sendUserMetricsEnabled(PiwikInfo piwikInfo) throws Exception { - - try { - String subject = "[OpenAIRE-Usage Statistics] Usage statistics have been enabled"; - - String message = "Dear " + piwikInfo.getRequestorName() + ",\n" + - "\n" + - "The installation and configuration of OpenAIRE's tracking code for your repository \"" + piwikInfo.getRepositoryName() + - "\" has been completed and validated and the usage statistics have been enabled in OpenAIRE.\n" + - "\n" + - "You can preview the statistics in your repository's dashboard: \n" + - this.baseUrl + "/getImpact/" + piwikInfo.getRepositoryId() + "\n" + - "\n" + - " For more information and questions, you can contact the openaire support team by sending an email to " + - "repositoryusagestats@openaire.eu\n" + - "\n" + - "Best,\n" + - "The OpenAIRE team"; - - this.sendMail(piwikInfo.getRequestorEmail(), subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending metrics enabled notification email to user: " + piwikInfo.getRequestorEmail(), e); - throw e; - } - } - - @Override - public void sendAdminRegistrationEmail(Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE content provider registration request started for " + - repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - - String message = "Dear administrator" + ",\n" + - "\n" + - "We received a request to register the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" + - " to the OpenAIRE compliant list of content providers. " + - "A validation process against the OpenAIRE guidelines compatibility " + - "has been started. You will be informed in another message once the process is finished." + - "\n\n" + - "Please do not reply to this message\n" + - "This message has been generated automatically.\n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(this.provideAdminEmail, subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending registration notification email to the administrator", e); - throw e; - } - } - - @Override - public void sendUserRegistrationEmail(Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE content provider registration request started for " + - repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - -// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" + - String message = "Dear "+SecurityContextHolder.getContext().getAuthentication().getName()+",\n" + - "\n" + - "We received a request to register the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" + - " to the OpenAIRE compliant list of content providers. " + - "A validation process against the OpenAIRE guidelines compatibility " + - "has been started. You will be informed in another message once the process is finished." + - "\n\n" + - "Please do not reply to this message\n" + - "This message has been generated automatically.\n\n" + - "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(repository.getRegisteredBy(), subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e); - throw e; - } - } - - @Override - public void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE content provider registration request - results (success) for " + - repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - -// String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" + - String message = "Dear user,\n" + - "\n" + - "the compatibility test on " + "[" + repository.getEnglishName() + "]" + - " was successful and the datasource type \""+ repository.getDatasourceType() + "\" will be prepared for aggregation in OpenAIRE."+ - "\n\n" + - "Please note that it usually takes about 3-4 weeks until a data source is indexed and it’s metadata visible on openaire.eu.\n\n" + - "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+ - "\nOfficial Name:" + repository.getOfficialName() + - "\n\nBase URL: "+ repositoryInterface.getBaseUrl() + - "\n\nValidation Set: " + repositoryInterface.getAccessSet() + - "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() + - "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + - "\n\n\nPlease do not reply to this email\n"+ - "This message has been generated manually\n\n"+ - "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(repository.getRegisteredBy(), subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e); - throw e; - } - } - - @Override - public void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId,RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE content provider registration request - results (success) for " + - repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - - String message = "Dear admin ,\n" + - "\n" + - "the compatibility test on " + "[" + repository.getEnglishName() + "]" + - " was successful and the datasource type \""+ repository.getDatasourceType() + "\" will be prepared for aggregation in OpenAIRE."+ - "\n\n" + - "Please note that it usually takes about 3-4 weeks until a data source is indexed and it’s metadata visible on openaire.eu.\n\n" + - "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+ - "\nOfficial Name:" + repository.getOfficialName() + - "\n\nBase URL: "+ repositoryInterface.getBaseUrl() + - "\n\nValidation Set: " + repositoryInterface.getAccessSet() + - "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() + - "\n\nUser Contact:"+ issuerEmail +""+ - "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + - "\n\n\nPlease do not reply to this email\n"+ - "This message has been generated manually\n\n"+ - "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(this.provideAdminEmail, subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e); - throw e; - } - } - - @Override - public void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE content provider registration request - results (failure) for " + - repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - // String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" + - String message = "Dear user,\n" + - "\n" + - "the compatibility test on " + "[" + repository.getEnglishName() + "]" + - " was not successful and the registration process was interrupted."+ - "\n\n" + - "We will check what caused the problem and get back to you within a couple of days.\n\n" + - "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+ - "\nOfficial Name:" + repository.getOfficialName() + - "\n\nBase URL: "+ repositoryInterface.getBaseUrl() + - "\n\nValidation Set: " + repositoryInterface.getAccessSet() + - "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() + - "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + - "\n\n\nPlease do not reply to this email\n"+ - "This message has been generated manually\n\n"+ - "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(repository.getRegisteredBy(), subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e); - throw e; - } - } - - @Override - public void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE content provider registration request - results (failure) for " + - repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - - String message = "Dear admin,\n" + - "\n" + - "the compatibility test on " + "[" + repository.getEnglishName() + "]" + - " was not successful and the registration process was interrupted."+ - "\n\n" + - "We will check what caused the problem and get back to you within a couple of days.\n\n" + - "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+ - "\nOfficial Name:" + repository.getOfficialName() + - "\n\nBase URL: "+ repositoryInterface.getBaseUrl() + - "\n\nValidation Set: " + repositoryInterface.getAccessSet() + - "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() + - "\n\nUser Contact:"+ issuerEmail +""+ - "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + - "\n\n\nPlease do not reply to this email\n"+ - "This message has been generated manually\n\n"+ - "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(this.provideAdminEmail, subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e); - throw e; - } - } - - @Override - public void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE content provider registration request - results (success) for " + - repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - - // String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" + - String message = "Dear user,\n" + - "\n" + - "the compatibility test on [" + repository.getEnglishName()+"] has been successful\n\n" + - "We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu."+"\n\n" + - "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+ - "\nOfficial Name:" + repository.getOfficialName() + - "\n\nBase URL: "+ repositoryInterface.getBaseUrl() + - "\n\nValidation Set: " + repositoryInterface.getAccessSet() + - "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() + - "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + - "\n\n\nPlease do not reply to this email\n"+ - "This message has been generated manually\n\n"+ - "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(issuer, subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending registration notification email to the administrator", e); - throw e; - } - } - - @Override - public void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE content provider registration request - results (success) for " + - repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - - String message = "Dear admin,\n" + - "\n" + - "the compatibility test on [" + repository.getEnglishName()+"] has been successful\n\n" + - "We will check your transmitted information and adjust the aggregation settings accordingly. Please note that it usually takes about 3-4 weeks until the changes are visible on openaire.eu."+"\n\n" + - "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+ - "\nOfficial Name:" + repository.getOfficialName() + - "\n\nBase URL: "+ repositoryInterface.getBaseUrl() + - "\n\nValidation Set: " + repositoryInterface.getAccessSet() + - "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() + - "\n\nUser Contact:"+ issuerEmail +""+ - "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + - "\n\n\nPlease do not reply to this email\n"+ - "This message has been generated manually\n\n"+ - "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(this.provideAdminEmail, subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending registration notification email to the administrator", e); - throw e; - } - } - - @Override - public void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE content provider update request - results (failure) for " + - repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - - // String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" + - String message = "Dear user,\n" + - "\n" + - "the compatibility test on " + "[" + repository.getEnglishName() + "]" + - " was not successful."+ - "\n\n" + - "WWe will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" + - "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+ - "\nOfficial Name:" + repository.getOfficialName() + - "\n\nBase URL: "+ repositoryInterface.getBaseUrl() + - "\n\nValidation Set: " + repositoryInterface.getAccessSet() + - "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() + - "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + - "\n\n\nPlease do not reply to this email\n"+ - "This message has been generated manually\n\n"+ - "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(issuer, subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e); - throw e; - } - } - - @Override - public void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE content provider update request - results (failure) for " + - repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - - String message = "Dear admin,\n" + - "\n" + - "the compatibility test on " + "[" + repository.getEnglishName() + "]" + - " was not successful."+ - "\n\n" + - "WWe will check your transmitted information to see what caused the problem and get back to you within a couple of days.\n\n" + - "Registration identifier in OpenAIRE: "+ repository.getNamespacePrefix()+ - "\nOfficial Name:" + repository.getOfficialName() + - "\n\nBase URL: "+ repositoryInterface.getBaseUrl() + - "\n\nValidation Set: " + repositoryInterface.getAccessSet() + - "\n\nGuidelines: "+ repositoryInterface.getDesiredCompatibilityLevel() + - "\n\nUser Contact:"+ issuerEmail +""+ - "\n\nYou can review the validation results here.\n" + valBaseUrl + "" + jobId + - "\n\n\nPlease do not reply to this email\n"+ - "This message has been generated manually\n\n"+ - "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(this.provideAdminEmail, subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e); - throw e; - } - } - - @Override - public void sendUserValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE validator - Test results "; - - // String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" + - String message = "Dear user,\n" + - "\n" + - "the validation request you have submitted has finished. You can retrieve the results by following this url: "+ valBaseUrl+"" + jobId+" .\n\n" + - "Please do not reply to this message.\n" + - "This message has been generated automatically.\n" + - "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(issuer, subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e); - throw e; - } - } - - @Override - public void sendAdminValidationResults(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE validator - Test results "; - - String message = "Dear admin,\n" + - "\n" + - "the validation request you have submitted has finished. You can retrieve the results by following this url: "+ valBaseUrl+"" + jobId+" .\n\n" + - "\n\nUser Contact:"+ issuer +""+ - "Please do not reply to this message.\n" + - "This message has been generated automatically.\n" + - "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(this.provideAdminEmail, subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e); - throw e; - } - } - - @Override - public void sendAdminGeneralFailure(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE validator - job failure"; - - String message = "Dear admin,\n" + - "\n" + - "the validation job that was automatically submitted for the update/registration of the interface "+repositoryInterface.getId()+" ("+repositoryInterface.getBaseUrl()+", "+repositoryInterface.getAccessSet()+") of the repository "+repository.getId()+" ("+repository.getOfficialName()+") failed to complete." + - "This message has been generated automatically.\n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(this.provideAdminEmail, subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending validation submission notification email to user: " + issuer, e); - throw e; - } - } - - @Override - public void sendAdminUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE content provider update request started for " + - repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - - String message = "Dear administrator" + ",\n" + - "\n" + - "We received a request to update the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]." + - "A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" + - "Please do not reply to this message\n" + - "This message has been generated automatically.\n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(this.provideAdminEmail, subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending registration notification email to the administrator", e); - throw e; - } - } - - @Override - public void sendUserUpdateRepositoryEmail(Repository repository, Authentication authentication) throws Exception { - try { - String subject = "OpenAIRE content provider update request started for " + - repository.getDatasourceType() + "[" + repository.getEnglishName() + "]"; - - // String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" + - String message = "Dear user,\n" + - "\n" + - "We received a request to update the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]." + - "A new iteration process of the validation against the OpenAIRE guidelines compatibility has been started.\n\n" + - "Please do not reply to this message\n" + - "This message has been generated automatically.\n\n" + - "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(repository.getRegisteredBy(), subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e); - throw e; - } - } - - @Override - public void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation) throws Exception { - try { - String subject = "OpenAIRE validator - Test submission "; - - // String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" + - String message = "Dear user,\n" + - "\n" + - "The validation request you have submitted has started.\n" + - "Please do not reply to this message.\n" + - "This message has been generated automatically.\n" + - "If you have any questions, write to 'helpdesk@openaire.eu'. \n\n" + - "Regards,\n" + - "the OpenAIRE technical team\n"; - - this.sendMail(jobForValidation.getUserEmail(), subject, message, false, null); - - } catch (Exception e) { - LOGGER.error("Error while sending validation submission notification email to user: " + jobForValidation.getUserEmail(), e); - throw e; - } - } - - @Override - public void sendUponJobCompletion( - String repoId, - String repoInterfaceId, - int scoreUsage, - int scoreContent, - boolean isSuccess, - boolean isUpdate, - String issuerEmail, - String jobId) throws Exception { - List repositoryInterfaces = repositoryService.getRepositoryInterface(repoId); - if(repositoryInterfaces.size()==0) - throw new ValidationServiceException("Repository interface with id \""+repoInterfaceId+"\" not found",ValidationServiceException.ErrorCode.GENERAL_ERROR); - - RepositoryInterface repositoryInterface = repositoryInterfaces.stream().filter( repoInterface -> repoInterface.getId().equals(repoInterfaceId)).collect(Collectors.toList()).get(0); - Repository repository = repositoryService.getRepositoryById(repoId); - - if(!isUpdate){ - if(isSuccess){ - if(scoreContent>=50 && scoreUsage >= 50){ - this.sendUserRegistrationResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication()); - this.sendAdminRegistrationResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication()); - }else{ - this.sendUserRegistrationResultsFailureEmail(jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication()); - this.sendAdminRegistrationResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication()); - } - }else{ - this.sendAdminGeneralFailure(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication()); - } - }else{ - if(isSuccess){ - if(scoreContent>=50 && scoreUsage >= 50){ - this.sendUserUpdateResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication()); - this.sendAdminUpdateResultsSuccessEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication()); - }else{ - this.sendUserUpdateResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication()); - this.sendAdminUpdateResultsFailureEmail(issuerEmail,jobId,repositoryInterface,repository, SecurityContextHolder.getContext().getAuthentication()); - } - }else{ - this.sendAdminGeneralFailure(issuerEmail,jobId,repositoryInterface,repository,SecurityContextHolder.getContext().getAuthentication()); - } - } - - } - - - private void sendMail(String email, String subject, String message, boolean sendToSpecial, List repoAdminMails) throws Exception { - ArrayList to = new ArrayList(); - to.add(email); - this.sendMail(to,subject,message,sendToSpecial,repoAdminMails); - } - - public void sendMail(List recipients, String subject, String message, boolean sendToSpecial, List repoAdminMails) throws Exception { - - try { - if (sendToSpecial) { - recipients.addAll(this.specialRecipients); - } - - if (repoAdminMails != null) - recipients.addAll(repoAdminMails); - - if (this.override) { - recipients.clear(); - recipients.add(overrideEmail); - } - if (!logonly) - mailLibrary.sendEmail(recipients.toArray(new String[]{}), subject, message); - LOGGER.debug("Sending mail to Recipients: " + recipients + " Subject: " + subject + " Message: " + message); - } catch (Exception e) { - LOGGER.error("Error sending mail to Recipients: " + recipients + " Subject: " + subject + " Message: " + message, e); - throw new Exception(e); - } - } - - private String getEmailProperty(String key) { - return pLoader.getProperties().getProperty(key); - } - - public void setSpecialRecipients(String specialRecipients) { - String[] recps = specialRecipients.split(","); - - for (String recp : recps) { - recp = recp.trim(); - - this.specialRecipients.add(recp); - } - } - - - public void setOverride(boolean override) { - this.override = override; - } - - public void setOverrideEmail(String overrideEmail) { - this.overrideEmail = overrideEmail; - } - - public String getFrom() { - return from; - } - - public void setFrom(String from) { - this.from = from; - } - - public boolean isLogonly() { - return logonly; - } - - public void setLogonly(boolean logonly) { - this.logonly = logonly; - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/MonitorService.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/MonitorService.java deleted file mode 100644 index a9832a0..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/MonitorService.java +++ /dev/null @@ -1,32 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import eu.dnetlib.api.functionality.ValidatorServiceException; -import eu.dnetlib.domain.functionality.validator.StoredJob; -import eu.dnetlib.repo.manager.shared.JobsOfUser; -import io.swagger.annotations.Api; -import org.json.JSONException; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.*; - - -public interface MonitorService { - - - JobsOfUser getJobsOfUser(String user, - String jobType, - String offset, - String limit, - String dateFrom, - String dateTo, - String validationStatus, - String includeJobsTotal) throws JSONException, ValidatorServiceException; - - int getJobsOfUserPerValidationStatus(String user, - String jobType, - String validationStatus) throws JSONException; - - - StoredJob getJobSummary(String jobId, - String groupBy) throws JSONException; - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/MonitorServiceImpl.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/MonitorServiceImpl.java deleted file mode 100644 index bb9a73e..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/MonitorServiceImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import eu.dnetlib.api.functionality.ValidatorService; -import eu.dnetlib.api.functionality.ValidatorServiceException; -import eu.dnetlib.domain.functionality.validator.StoredJob; -import eu.dnetlib.repo.manager.shared.Constants; -import eu.dnetlib.repo.manager.shared.JobsOfUser; -import gr.uoa.di.driver.util.ServiceLocator; -import org.apache.log4j.Logger; -import org.json.JSONException; -import org.springframework.stereotype.Service; - -import javax.annotation.Resource; - -@Service("monitorService") -public class MonitorServiceImpl implements MonitorService { - - @Resource(name = "validatorServiceLocator") - private ServiceLocator validatorServiceLocator; - - private ValidatorService getValidationService() { - return this.validatorServiceLocator.getService(); - } - - public ServiceLocator getValidatorServiceLocator() { - return validatorServiceLocator; - } - - public void setValidatorServiceLocator(ServiceLocator validatorServiceLocator) { - this.validatorServiceLocator = validatorServiceLocator; - } - - - private static final Logger LOGGER = Logger - .getLogger(MonitorServiceImpl.class); - - @Override - public JobsOfUser getJobsOfUser(String user, - String jobType, - String offset, - String limit, - String dateFrom, - String dateTo, - String validationStatus, - String includeJobsTotal) throws JSONException, ValidatorServiceException { - - LOGGER.debug("Getting jobs of user : " + user); - LOGGER.debug(user + "/" + jobType + "/" + offset + "/" + dateFrom + "/" + dateTo + "/" + validationStatus + "/" + includeJobsTotal); - JobsOfUser retJobs = new JobsOfUser(); - retJobs.setJobs(getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset), - Integer.parseInt(limit), dateFrom, dateTo, validationStatus)); - if (Boolean.parseBoolean(includeJobsTotal)) { - retJobs.setTotalJobs(this.getJobsTotalNumberOfUser(user, jobType, null)); - retJobs.setTotalJobsSuccessful(this.getJobsTotalNumberOfUser(user, jobType, Constants.VALIDATION_JOB_STATUS_SUCCESSFUL)); - retJobs.setTotalJobsFailed(this.getJobsTotalNumberOfUser(user, jobType, Constants.VALIDATION_JOB_STATUS_FAILED)); - retJobs.setTotalJobsOngoing(this.getJobsTotalNumberOfUser(user, jobType,Constants.VALIDATION_JOB_STATUS_ONGOING)); - } - - //TODO fix status with new validator version - if(retJobs.getJobs() != null){ - for(StoredJob job :retJobs.getJobs()){ - if (job.getContentJobStatus().equals("ongoing") || job.getUsageJobStatus().equals("ongoing")) { - job.setValidationStatus("ongoing"); - } else if ((job.getValidationType().equals("CU") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("finished") && job.getContentJobScore() > 50 && job.getUsageJobScore() > 50) - || (job.getValidationType().equals("C") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("none") && job.getContentJobScore() > 50) - || (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() > 50)) { - job.setValidationStatus("successful"); - } else if ((job.getValidationType().equals("CU") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("finished") && (job.getContentJobScore() <= 50 || job.getUsageJobScore() <= 50)) - || (job.getValidationType().equals("C") && job.getContentJobStatus().equals("finished") && job.getUsageJobStatus().equals("none") && job.getContentJobScore() <= 50) - || (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() <= 50) ) { - job.setValidationStatus("failed"); - } - - } - } - - - return retJobs; - - } - - private int getJobsTotalNumberOfUser(String user, String jobType, String validationStatus) throws ValidatorServiceException { - return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus); - } - - @Override - public int getJobsOfUserPerValidationStatus(String user, - String jobType, - String validationStatus) throws JSONException { - LOGGER.debug("Getting job with validation status : " + validationStatus); - try { - return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus); - } catch (ValidatorServiceException e) { - LOGGER.error(e); - } - return 0; - } - - @Override - public StoredJob getJobSummary(String jobId, - String groupBy) throws JSONException { - LOGGER.debug("Getting job summary with id : " + jobId); - try { - return getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy); - } catch (ValidatorServiceException e) { - LOGGER.error(e); - } - return null; - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/PiWikService.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/PiWikService.java deleted file mode 100644 index a4e9dc4..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/PiWikService.java +++ /dev/null @@ -1,30 +0,0 @@ -package eu.dnetlib.repo.manager.service; - - -import eu.dnetlib.domain.data.PiwikInfo; -import eu.dnetlib.repo.manager.domain.OrderByField; -import eu.dnetlib.repo.manager.domain.OrderByType; -import eu.dnetlib.repo.manager.shared.RepositoryServiceException; -import org.springframework.http.ResponseEntity; - -import java.util.List; - - -public interface PiWikService { - - PiwikInfo getPiwikSiteForRepo(String repositoryId); - - PiwikInfo savePiwikInfo(PiwikInfo piwikInfo); - - List getPiwikSitesForRepos(OrderByField orderByField, OrderByType orderByType, int from, int quantity, String searchField); - - int getPiwikSitesTotals(String searchField); - - ResponseEntity approvePiwikSite(String repositoryId); - - String getOpenaireId(String repositoryid); - - ResponseEntity markPiwikSiteAsValidated(String repositoryId) throws RepositoryServiceException; - - PiwikInfo enableMetricsForRepository(String officialName, String repoWebsite, PiwikInfo piwikInfo) throws RepositoryServiceException; -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/PiWikServiceImpl.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/PiWikServiceImpl.java deleted file mode 100644 index 86fdc06..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/PiWikServiceImpl.java +++ /dev/null @@ -1,232 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import com.fasterxml.jackson.databind.ObjectMapper; -import eu.dnetlib.domain.data.PiwikInfo; -import eu.dnetlib.domain.data.Repository; -import eu.dnetlib.repo.manager.domain.OrderByField; -import eu.dnetlib.repo.manager.domain.OrderByType; -import eu.dnetlib.repo.manager.shared.RepositoryServiceException; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.log4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.dao.EmptyResultDataAccessException; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.PreparedStatementSetter; -import org.springframework.jdbc.core.RowMapper; -import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; -import org.springframework.jdbc.core.namedparam.SqlParameterSource; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -import javax.sql.DataSource; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.net.URLEncoder; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.sql.Types; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -@Service("piwikService") -public class PiWikServiceImpl implements PiWikService { - - @Qualifier("repomanager.dataSource") - @Autowired - private DataSource dataSource; - - - @Value("${services.repomanager.analyticsURL}") - private String analyticsURL; - - - @Autowired - private RepositoryService repositoryService; - - @Autowired - @Qualifier("emailUtils") - private EmailUtils emailUtils; - - private static final Logger LOGGER = Logger - .getLogger(PiWikServiceImpl.class); - - private final static String GET_PIWIK_SITE = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site where repositoryid = ?;"; - - private final static String INSERT_PIWIK_INFO = "insert into piwik_site (repositoryid, siteid, creationdate, requestorname, requestoremail, validated, repositoryname, country, authenticationtoken) values (?, ?, now(), ?, ?, ?, ?, ?, ?)"; - - private final static String GET_PIWIK_SITES = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site "; - - private final static String GET_PIWIK_SITES_TOTAL = "select count(*) as totals from piwik_site "; - - private final static String APPROVE_PIWIK_SITE = "update piwik_site set validated=true, validationdate=now() where repositoryid = ?;"; - - private RowMapper piwikRowMapper = (rs, i) -> new PiwikInfo(rs.getString("repositoryid"), getOpenaireId(rs.getString("repositoryid")), rs.getString("repositoryname"), rs.getString("country"), - rs.getString("siteid"), rs.getString("authenticationtoken"), rs.getTimestamp("creationdate"), rs.getString("requestorname"), rs.getString("requestoremail"), - rs.getBoolean("validated"), rs.getTimestamp("validationdate"), rs.getString("comment")); - - - @Override - public PiwikInfo getPiwikSiteForRepo(String repositoryId) { - try{ - return new JdbcTemplate(dataSource).queryForObject(GET_PIWIK_SITE, new String[]{repositoryId}, new int[]{Types.VARCHAR}, piwikRowMapper); - }catch (EmptyResultDataAccessException e){ - return null; - } - } - - @Override - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)") - public PiwikInfo savePiwikInfo(PiwikInfo piwikInfo) { - JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); - jdbcTemplate.update(INSERT_PIWIK_INFO, new Object[]{piwikInfo.getRepositoryId(), piwikInfo.getSiteId(), piwikInfo.getRequestorName(), - piwikInfo.getRequestorEmail(), piwikInfo.isValidated(), piwikInfo.getRepositoryName(), piwikInfo.getCountry(), piwikInfo.getAuthenticationToken()}, - new int[]{Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BOOLEAN, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR}); - return piwikInfo; - } - - @Override - public List getPiwikSitesForRepos(OrderByField orderByField, OrderByType orderByType, int from, int quantity, String searchField) { - try{ - String finalizedQuery = GET_PIWIK_SITES + " where ("+ - " repositoryid ilike ? " + - " or siteid ilike ?" + - " or requestorname ilike ?" + - " or requestoremail ilike ?" + - " or comment ilike ?" + - " or repositoryname ilike ?"+ - " or country ilike ?" - +") order by "+orderByField + " " + orderByType + " offset ? limit ?"; - - return new JdbcTemplate(dataSource).query(finalizedQuery, preparedStatement -> { - preparedStatement.setString(1,"%"+searchField+"%"); - preparedStatement.setString(2,"%"+searchField+"%"); - preparedStatement.setString(3,"%"+searchField+"%"); - preparedStatement.setString(4,"%"+searchField+"%"); - preparedStatement.setString(5,"%"+searchField+"%"); - preparedStatement.setString(6,"%"+searchField+"%"); - preparedStatement.setString(7,"%"+searchField+"%"); - preparedStatement.setInt(8,from); - preparedStatement.setInt(9,quantity); - }, piwikRowMapper); - }catch (EmptyResultDataAccessException e){ - return null; - } - - } - - @Override - public int getPiwikSitesTotals(String searchField){ - try{ - String finalizedQuery = GET_PIWIK_SITES_TOTAL + " where ("+ - " repositoryid ilike ? " + - " or siteid ilike ?" + - " or requestorname ilike ?" + - " or requestoremail ilike ?" + - " or comment ilike ?" + - " or repositoryname ilike ?"+ - " or country ilike ?)"; - - return new JdbcTemplate(dataSource).query(finalizedQuery, preparedStatement -> { - preparedStatement.setString(1,"%"+searchField+"%"); - preparedStatement.setString(2,"%"+searchField+"%"); - preparedStatement.setString(3,"%"+searchField+"%"); - preparedStatement.setString(4,"%"+searchField+"%"); - preparedStatement.setString(5,"%"+searchField+"%"); - preparedStatement.setString(6,"%"+searchField+"%"); - preparedStatement.setString(7,"%"+searchField+"%"); - },rowMapper -> { - rowMapper.next(); - return rowMapper.getInt("totals"); - }); - }catch (EmptyResultDataAccessException e){ - return 0; - } - } - - @Override - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')") - public ResponseEntity approvePiwikSite(String repositoryId) { - new JdbcTemplate(dataSource).update(APPROVE_PIWIK_SITE, new Object[] {repositoryId}, new int[] {Types.VARCHAR}); - return new ResponseEntity<>("OK",HttpStatus.OK); - } - - @Override - public String getOpenaireId(String repositoryId) { - if (repositoryId != null && repositoryId.contains("::")) - return repositoryId.split("::")[0] + "::" + DigestUtils.md5Hex(repositoryId.split("::")[1]); - return null; - } - - @Override - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN')") - public ResponseEntity markPiwikSiteAsValidated(String repositoryId) throws RepositoryServiceException { - try { - approvePiwikSite(repositoryId); - - PiwikInfo piwikInfo = getPiwikSiteForRepo(repositoryId); - emailUtils.sendAdministratorMetricsEnabled(piwikInfo); - emailUtils.sendUserMetricsEnabled(piwikInfo); - - } catch (EmptyResultDataAccessException e) { - LOGGER.error("Error while approving piwik site: ", e); - emailUtils.reportException(e); - throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR); - } catch (Exception e) { - LOGGER.error("Error while sending email to administrator or user about the enabling of metrics", e); - emailUtils.reportException(e); - } - return new ResponseEntity<>("OK",HttpStatus.OK); - } - - @Override - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or (hasRole('ROLE_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)") - public PiwikInfo enableMetricsForRepository(String officialName, - String repoWebsite, - PiwikInfo piwikInfo) throws RepositoryServiceException { - try { - String URL = analyticsURL + "siteName=" + URLEncoder.encode(officialName, "UTF-8") + "&url=" - + URLEncoder.encode(repoWebsite, "UTF-8"); - Map map = new ObjectMapper().readValue(new URL(URL), Map.class); - String siteId = null; - if(map.get("value")!=null) { - siteId = map.get("value").toString(); - } - piwikInfo.setSiteId(siteId); - - savePiwikInfo(piwikInfo); - - Repository repository = repositoryService.getRepositoryById(piwikInfo.getRepositoryId()); - repository.setPiwikInfo(piwikInfo); - - repositoryService.updateRepository(repository, SecurityContextHolder.getContext().getAuthentication()); - - emailUtils.sendAdministratorRequestToEnableMetrics(piwikInfo); - emailUtils.sendUserRequestToEnableMetrics(piwikInfo); - } catch (UnsupportedEncodingException uee) { - LOGGER.error("Error while creating piwikScript URL", uee); - emailUtils.reportException(uee); - throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR); - } catch (IOException ioe) { - LOGGER.error("Error while creating piwik site", ioe); - emailUtils.reportException(ioe); - throw new RepositoryServiceException("login.generalError", RepositoryServiceException.ErrorCode.GENERAL_ERROR); - } catch (Exception e) { - LOGGER.error("Error while sending email to administrator or user about the request to enable metrics", e); - emailUtils.reportException(e); - } - return piwikInfo; - } - - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/RepositoryService.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/RepositoryService.java deleted file mode 100644 index c57fcd6..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/RepositoryService.java +++ /dev/null @@ -1,77 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import eu.dnetlib.api.functionality.ValidatorServiceException; -import eu.dnetlib.domain.data.Repository; -import eu.dnetlib.domain.data.RepositoryInterface; -import eu.dnetlib.repo.manager.domain.RepositorySnippet; -import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; -import eu.dnetlib.repo.manager.shared.*; -import org.json.JSONException; -import org.springframework.security.core.Authentication; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -public interface RepositoryService { - - - Country[] getCountries() ; - - List getRepositoriesByCountry(String country, String mode, Boolean managed) throws JSONException, IOException; - - List getRepositoriesOfUser(String userEmail, - String page, - String size) throws JSONException; - - Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException; - - List getRepositoryAggregations(String id, int from, int size) throws JSONException; - - Map> getRepositoryAggregationsByYear(String id) throws JSONException; - - List getRepositoriesByName(String name, - String page, - String size) throws JSONException; - - List searchRegisteredRepositories(String country, String typology, String englishName, - String officialName, String requestSortBy, String order, - int page, int pageSize) throws Exception; - - List getRepositoryInterface(String id) throws JSONException; - - Repository addRepository(String datatype, Repository repository) throws Exception; - - void deleteRepositoryInterface(String id, String registeredBy); - - RepositoryInterface addRepositoryInterface(String datatype, - String repoId, - String registeredBy, - RepositoryInterface iFace) throws JSONException, ResourceNotFoundException, ValidatorServiceException; - - List getDnetCountries(); - - List getTypologies(); - - List getTimezones(); - - Repository updateRepository(Repository repository, Authentication authentication) throws Exception; - - List getUrlsOfUserRepos(String user_email, - String page, - String size) throws JSONException; - - List getDatasourceVocabularies(String mode); - - Map getCompatibilityClasses(String mode); - - Map getDatasourceClasses(String mode); - - String getCountryName(String countryCode); - - MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException; - - Map getListLatestUpdate(String mode) throws RepositoryServiceException, JSONException; - - RepositoryInterface updateRepositoryInterface(String repositoryId, String registeredBy, RepositoryInterface repositoryInterface) throws Exception; - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java deleted file mode 100644 index 525576b..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java +++ /dev/null @@ -1,901 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import eu.dnetlib.api.functionality.ValidatorServiceException; -import eu.dnetlib.domain.data.Repository; -import eu.dnetlib.domain.data.RepositoryInterface; -import eu.dnetlib.domain.enabling.Vocabulary; -import eu.dnetlib.domain.functionality.validator.JobForValidation; -import eu.dnetlib.repo.manager.domain.RepositorySnippet; -import eu.dnetlib.repo.manager.domain.RequestFilter; -import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; -import eu.dnetlib.repo.manager.shared.*; -import eu.dnetlib.repo.manager.utils.Converter; -import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader; -import gr.uoa.di.driver.xml.repository.INTERFACE; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.log4j.Logger; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.*; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.client.RestClientException; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponents; -import org.springframework.web.util.UriComponentsBuilder; - -import javax.annotation.PostConstruct; -import java.io.IOException; -import java.sql.Timestamp; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; - -@Service("repositoryService") -public class RepositoryServiceImpl implements RepositoryService { - - @Value("${api.baseAddress}") - private String baseAddress; - - @Value("${services.repo-manager.adminEmail}") - private String adminEmail; - - @Autowired - RestTemplate restTemplate; - - private HttpHeaders httpHeaders; - - private final String[] vocabularyNames = {"dnet:countries", "dnet:datasource_typologies", "dnet:compatibilityLevel"}; - - private static final Logger LOGGER = Logger.getLogger(RepositoryServiceImpl.class); - - @Value("${services.repomanager.usageStatisticsDiagramsBaseURL}") - private String usageStatisticsDiagramsBaseURL; - - @Value("${services.repomanager.usageStatisticsNumbersBaseURL}") - private String usageStatisticsNumbersBaseURL; - - @Autowired - private VocabularyLoader vocabularyLoader; - - @Autowired - private PiWikService piWikService; - - @Autowired - private EmailUtils emailUtils; - - @Autowired - ValidatorService validatorService; - - - private Map vocabularyMap = new ConcurrentHashMap<>(); - - private Map countriesMap = new HashMap<>(); - private Map inverseCountriesMap = new HashMap<>(); - - private static Map> dataSourceClass = new HashMap<>(); - - private static Map invertedDataSourceClass = new HashMap<>(); - - - - @PostConstruct - private void init() { - LOGGER.debug("Initialization method of repository api!"); - LOGGER.debug("Updated version!"); - - dataSourceClass.put("opendoar",Arrays.asList("pubsrepository::institutional","pubsrepository::thematic","pubsrepository::unknown","pubsrepository::mock")); - dataSourceClass.put("re3data", Collections.singletonList("datarepository::unknown")); - dataSourceClass.put("journal", Collections.singletonList("pubsrepository::journal")); - dataSourceClass.put("aggregator",Arrays.asList("aggregator::pubsrepository::institutional","aggregator::pubsrepository::journals","aggregator::datarepository", "aggregator::pubsrepository::unknown")); - - invertedDataSourceClass.put("pubsrepository::institutional","opendoar"); - invertedDataSourceClass.put("pubsrepository::thematic","opendoar"); - invertedDataSourceClass.put("pubsrepository::unknown","opendoar"); - invertedDataSourceClass.put("pubsrepository::mock","opendoar"); - invertedDataSourceClass.put("datarepository::unknown","re3data"); - invertedDataSourceClass.put("pubsrepository::journal","journal"); - invertedDataSourceClass.put("aggregator::pubsrepository::institutional","aggregator"); - invertedDataSourceClass.put("aggregator::pubsrepository::journals","aggregator"); - invertedDataSourceClass.put("aggregator::datarepository","aggregator"); - invertedDataSourceClass.put("aggregator::pubsrepository::unknown","aggregator"); - - - httpHeaders = new HttpHeaders(); - httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8); - - for (String vocName : vocabularyNames) { - vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT)); - } - - Country[] countries = getCountries(); - for (Country c : countries) { - countriesMap.put(c.getName(), c.getCode()); - inverseCountriesMap.put(c.getCode(), c.getName()); - } - - - } - - @Override - public Country[] getCountries() { - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(baseAddress + "/ds/countries") - .build().encode(); - return restTemplate.getForObject(uriComponents.toUri(), Country[].class); - } - - - @Override - public List getRepositoriesByCountry(String country, - String mode, - Boolean managed) throws JSONException, IOException { - - LOGGER.debug("Getting repositories by country!"); - int page = 0; - int size = 100; - List resultSet = new ArrayList<>(); - ObjectMapper mapper = new ObjectMapper(); - - String filterKey = "UNKNOWN"; - if (mode.equalsIgnoreCase("opendoar")) - filterKey = "openaire____::opendoar"; - else if (mode.equalsIgnoreCase("re3data")) - filterKey = "openaire____::re3data"; - - - LOGGER.debug("Country code equals : " + country); - LOGGER.debug("Filter mode equals : " + filterKey); - - UriComponents uriComponents = searchSnipperDatasource(String.valueOf(page),String.valueOf(size)); - RequestFilter requestFilter = new RequestFilter(); - requestFilter.setCountry(country); - requestFilter.setCollectedfrom(filterKey); - - try{ - String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); - JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo"); - while (jsonArray.length() > 0 ) { - resultSet.addAll(mapper.readValue(String.valueOf(jsonArray), - mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class))); - page += 1; - uriComponents = searchSnipperDatasource(String.valueOf(page),String.valueOf(size)); - rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); - jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo"); - } - return resultSet; - }catch (Exception e){ - LOGGER.debug("Exception on getRepositoriesByCountry" , e); -// emailUtils.reportException(e); - throw e; - } - } - - public List searchRegisteredRepositories(String country, String typology, String englishName, - String officialName, String requestSortBy, String order, int page, int pageSize) throws Exception { - - LOGGER.debug("Searching registered repositories"); - - List resultSet = new ArrayList<>(); - ObjectMapper mapper = new ObjectMapper(); - - UriComponents uriComponents = searchRegisteredDatasource(requestSortBy, order, Integer.toString(page), Integer.toString(pageSize)); - - RequestFilter requestFilter = new RequestFilter(); - requestFilter.setCountry(country); - requestFilter.setTypology(typology); - requestFilter.setOfficialname(officialName); - requestFilter.setEnglishname(englishName); - - try { - String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); - JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo"); - - resultSet.addAll(mapper.readValue(String.valueOf(jsonArray), mapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class))); - - return resultSet; - }catch (Exception e){ - LOGGER.error("Error searching registered datasources" , e); - throw e; - } - } - - private Repository updateRepositoryInfo(Repository r) throws JSONException { - - /* - * from datasource class - * we get the datasource type form the inverted map - * */ - r.setDatasourceType(getRepositoryType(r.getDatasourceClass())); - r.setInterfaces(this.getRepositoryInterface(r.getId())); - r.setPiwikInfo(piWikService.getPiwikSiteForRepo(r.getId())); - r.setCountryName(getCountryName(r.getCountryCode())); - return r; - } - - - private Collection getRepositoriesByMode(String mode, List rs) { - - List reps = new ArrayList<>(); - for (Repository r : rs) { - if (r.getCollectedFrom() != null && r.getCollectedFrom().equals(mode)) - reps.add(r); - - } - return reps; - } - - @Override - public List getRepositoriesOfUser(String userEmail, - String page, - String size) throws JSONException { - - LOGGER.debug("Retreiving repositories of user : " + userEmail ); - UriComponents uriComponents = searchDatasource(page,size); - RequestFilter requestFilter = new RequestFilter(); - requestFilter.setRegisteredby(userEmail); - - try{ - long start = System.currentTimeMillis(); - String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); - long end = System.currentTimeMillis(); - - System.out.println("POST request finished in " + (end-start)+"ms"); - start=System.currentTimeMillis(); - List repos = Converter.jsonToRepositoryList(new JSONObject(rs)); - end=System.currentTimeMillis(); - System.out.println("Converting json to repo list finished in " + (end-start)+"ms"); - start=System.currentTimeMillis(); - for (Repository r : repos) - this.updateRepositoryInfo(r); - end=System.currentTimeMillis(); - System.out.println("Updating "+repos.size()+" repository infos in " + (end-start)+"ms"); - return repos; - }catch (Exception e){ - LOGGER.debug("Exception on getRepositoriesOfUser" , e); - emailUtils.reportException(e); - throw e; - } - } - - @Override - public Repository getRepositoryById(String id) throws JSONException,ResourceNotFoundException { - - LOGGER.debug("Retreiving repositories with id : " + id ); - Repository repo = null; - UriComponents uriComponents = searchDatasource("0","100"); - RequestFilter requestFilter = new RequestFilter(); - requestFilter.setId(id); - - try{ - String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); - JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo"); - - if(jsonArray.length() == 0) - throw new ResourceNotFoundException(); - - repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0)); - return updateRepositoryInfo(repo); - }catch (JSONException e){ - LOGGER.debug("Exception on getRepositoryById" , e); - emailUtils.reportException(e); - throw e; - } - - } - - - @Override - public List getRepositoryAggregations(String id, int from, int size) throws JSONException { - - LOGGER.debug("Retreiving aggregations for repository with id : " + id ); - UriComponents uriComponents = searchDatasource(from+"",size+""); - RequestFilter requestFilter = new RequestFilter(); - requestFilter.setId(id); - - List aggregationHistory = new ArrayList<>(); - - try { - long start = System.currentTimeMillis(); - String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); - long end = System.currentTimeMillis(); - - System.out.println("Aggregations request through rest template took " + (end-start)+"ms"); - JSONObject repository = new JSONObject(rs); - - if(repository.getJSONArray("datasourceInfo").length() == 0) - return aggregationHistory; - - start = System.currentTimeMillis(); - aggregationHistory.addAll(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0))); - end = System.currentTimeMillis(); - - System.out.println("Getting aggregations history from json " + (end-start)+"ms"); - return aggregationHistory.size() == 0? aggregationHistory : aggregationHistory.stream() - .sorted(Comparator.comparing(AggregationDetails::getDate).reversed()) - .limit(size) - .collect(Collectors.toList()); - } catch (JSONException e) { - LOGGER.debug("Exception on getRepositoryAggregations" , e); - emailUtils.reportException(e); - throw e; - } - - } - - @Override - public Map> getRepositoryAggregationsByYear(String id) throws JSONException { - LOGGER.debug("Retreiving aggregations (by year) for repository with id : " + id ); - UriComponents uriComponents = searchDatasource("0","100"); - RequestFilter requestFilter = new RequestFilter(); - requestFilter.setId(id); - - List aggregationHistory = new ArrayList<>(); - Map> aggregationByYear = new HashMap<>(); - try { - String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); - JSONObject repository = new JSONObject(rs); - - if(repository.getJSONArray("datasourceInfo").length() == 0) - return aggregationByYear; - - aggregationHistory.addAll(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0))); - return aggregationHistory.size() == 0? aggregationByYear:createYearMap(aggregationHistory); - - } catch (JSONException e) { - LOGGER.debug("Exception on getRepositoryAggregations" , e); - emailUtils.reportException(e); - throw e; - } - } - - private Map> createYearMap(List aggregationHistory) { - Map> aggregationByYear; - aggregationHistory = aggregationHistory.stream() - .sorted(Comparator.comparing(AggregationDetails::getDate).reversed()) - .collect(Collectors.toList()); - - return aggregationHistory.stream() - .collect(Collectors.groupingBy(AggregationDetails::getYear)); - } - - - @Override - public List getRepositoriesByName(String name, - String page, - String size) throws JSONException { - - LOGGER.debug("Retreiving repositories with official name : " + name ); - UriComponents uriComponents = searchDatasource("0","100"); - RequestFilter requestFilter = new RequestFilter(); - requestFilter.setOfficialname(name); - - try{ - String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); - List repos = Converter.jsonToRepositoryList(new JSONObject(rs)); - for (Repository r : repos) - updateRepositoryInfo(r); - return repos; - }catch (Exception e){ - LOGGER.debug("Exception on getRepositoriesByName" , e); - emailUtils.reportException(e); - throw e; - } - - } - - @Override - public List getRepositoryInterface(String id) throws JSONException { - - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(baseAddress + "/ds/api/") - .path("/{id}") - .build().expand(id).encode(); - - try{ - String rs = restTemplate.getForObject(uriComponents.toUri(), String.class); - return Converter.jsonToRepositoryInterfaceList(new JSONObject(rs)); - }catch (Exception e ){ - LOGGER.debug("Exception on getRepositoryInterface" , e); - emailUtils.reportException(e); - throw e; - } - - } - - @Override - public Repository addRepository(String datatype, - Repository repository) throws Exception { - - LOGGER.debug("storing " + datatype + " repository with id: " + repository.getId()); - - repository.setCountryCode(countriesMap.get(repository.getCountryName())); - repository.setActivationId(UUID.randomUUID().toString()); - repository.setCollectedFrom("infrastruct_::openaire"); - - if (datatype.equals("journal")) { - repository.setId("openaire____::issn" + repository.getIssn()); - repository.setNamespacePrefix("issn" + repository.getIssn()); - this.storeRepository(repository, SecurityContextHolder.getContext().getAuthentication()); - }else if (datatype.equals("aggregator")) { - repository.setId("openaire____::" + com.unboundid.util.Base64.encode(repository.getOfficialName())); - repository.setNamespacePrefix(DigestUtils.md5Hex(repository.getOfficialName()).substring(0,12)); - this.storeRepository(repository, SecurityContextHolder.getContext().getAuthentication()); - }else { - this.latentUpdate(repository, SecurityContextHolder.getContext().getAuthentication()); - } - - return repository; - } - - /* update method acting as add -> send email with registration topic/body*/ - private Repository latentUpdate(Repository repository, Authentication authentication) throws Exception { - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(baseAddress + "/ds/update/") - .build() - .encode(); - - try { - String json_repository = Converter.repositoryObjectToJson(repository); - LOGGER.debug("JSON to add(update) -> " + json_repository); - - HttpEntity httpEntity = new HttpEntity(json_repository, httpHeaders); - ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, httpEntity, ResponseEntity.class); - - if (responseEntity.getStatusCode().equals(HttpStatus.OK)) { - emailUtils.sendUserRegistrationEmail(repository, authentication); - emailUtils.sendAdminRegistrationEmail(repository, authentication); - } else - LOGGER.debug(responseEntity.getBody().toString()); - - return repository; - } catch (Exception e) { - LOGGER.debug("Exception on updateRepository" , e); - emailUtils.reportException(e); - throw e; - } - - - } - - @Override - public Repository updateRepository(Repository repository,Authentication authentication) throws Exception { - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(baseAddress + "/ds/update/") - .build() - .encode(); - - try { - String json_repository = Converter.repositoryObjectToJson(repository); - - LOGGER.debug("JSON to update -> " + json_repository); - - HttpEntity httpEntity = new HttpEntity(json_repository, httpHeaders); - ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, httpEntity - , ResponseEntity.class); - - if (responseEntity.getStatusCode().equals(HttpStatus.OK)) { - emailUtils.sendUserUpdateRepositoryEmail(repository, authentication); - emailUtils.sendAdminUpdateRepositoryEmail(repository, authentication); - } else - LOGGER.debug(responseEntity.getBody().toString()); - - return repository; - } catch (Exception e) { - LOGGER.debug("Exception on updateRepository" , e); - emailUtils.reportException(e); - throw e; - } - } - - private void storeRepository(Repository repository, Authentication authentication) throws Exception { - - Date utilDate = new Date(); - Timestamp date = new Timestamp(utilDate.getTime()); - repository.setDateOfCollection(date); - repository.setAggregator("OPENAIRE"); - repository.setCountryCode(countriesMap.get(repository.getCountryName())); - - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(baseAddress + "/ds/add/") - .build() - .encode(); - String json_repository = Converter.repositoryObjectToJson(repository); - HttpEntity httpEntity = new HttpEntity (json_repository,httpHeaders); - ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, httpEntity, ResponseEntity.class); - - if(responseEntity.getStatusCode().equals(HttpStatus.OK)) { - emailUtils.sendUserRegistrationEmail(repository, authentication); - emailUtils.sendAdminRegistrationEmail(repository, authentication); - } else { - LOGGER.debug(responseEntity.getBody().toString()); - } - } - - @Override - public void deleteRepositoryInterface(String id , - String registeredBy){ - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(baseAddress + "/ds/api/") - .path("/{id}") - .build().expand(id).encode(); - LOGGER.debug(uriComponents.toUri()); - restTemplate.delete(uriComponents.toUri()); - } - - @Override - public RepositoryInterface addRepositoryInterface(String datatype, - String repoId, - String registeredBy, - RepositoryInterface repositoryInterface) throws JSONException, ResourceNotFoundException, ValidatorServiceException { - try { - Repository e = this.getRepositoryById(repoId); - repositoryInterface = createRepositoryInterface(e,repositoryInterface,datatype); - String json_interface = Converter.repositoryInterfaceObjectToJson(e,repositoryInterface); - - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(baseAddress + "/ds/api/add/") - .build() - .encode(); - - HttpEntity httpEntity = new HttpEntity <> (json_interface,httpHeaders); - restTemplate.postForObject(uriComponents.toUri(),httpEntity,String.class); - submitInterfaceValidation(e, registeredBy, repositoryInterface, false); - - return repositoryInterface; - - } catch (JSONException | ValidatorServiceException e) { - LOGGER.debug("Exception on addRepositoryInterface" , e); - emailUtils.reportException(e); - throw e; - } - } - - @Override - public RepositoryInterface updateRepositoryInterface(String repoId, - String registeredBy, - RepositoryInterface repositoryInterface) throws Exception { - - this.updateBaseUrl(repoId,repositoryInterface.getId(),repositoryInterface.getBaseUrl()); - this.updateCompliance(repoId,repositoryInterface.getId(),repositoryInterface.getCompliance()); - this.updateValidationSet(repoId,repositoryInterface.getId(),repositoryInterface.getAccessSet()); - submitInterfaceValidation(getRepositoryById(repoId),registeredBy,repositoryInterface,true); - return repositoryInterface; - } - - private void submitInterfaceValidation(Repository repo, String userEmail, RepositoryInterface iFace, boolean updateExisting) throws ValidatorServiceException { - JobForValidation job = new JobForValidation(); - - job.setActivationId(UUID.randomUUID().toString()); - job.setAdminEmails(Collections.singletonList(this.adminEmail)); - job.setBaseUrl(iFace.getBaseUrl()); - job.setDatasourceId(repo.getId()); - job.setDesiredCompatibilityLevel(iFace.getDesiredCompatibilityLevel()); - job.setInterfaceId(iFace.getId()); - job.setOfficialName(repo.getOfficialName()); - job.setRepoType(repo.getDatasourceType()); - job.setUserEmail(userEmail); - job.setValidationSet((iFace.getAccessSet().isEmpty() ? "none" : iFace.getAccessSet())); - job.setRecords(-1); - job.setRegistration(!updateExisting); - job.setUpdateExisting(updateExisting); - - this.validatorService.submitJobForValidation(job); - } - - private RepositoryInterface createRepositoryInterface(Repository repo, RepositoryInterface iFace, String datatype) { - - iFace.setContentDescription("metadata"); - iFace.setCompliance("UNKNOWN"); - - if (datatype.equals("re3data")) - iFace.setAccessFormat("oai_datacite"); - else - iFace.setAccessFormat("oai_dc"); - - - if (repo.getDatasourceClass() != null && !repo.getDatasourceClass().isEmpty()) - iFace.setTypology(repo.getDatasourceClass()); - else if (datatype.equalsIgnoreCase("journal")) - iFace.setTypology("pubsrepository::journal"); - else if (datatype.equalsIgnoreCase("aggregator")) - iFace.setTypology("aggregator::pubsrepository::unknown"); - else if (datatype.equalsIgnoreCase("opendoar")) - iFace.setTypology("pubsrepository::unknown"); - else if (datatype.equalsIgnoreCase("re3data")) - iFace.setTypology("datarepository::unknown"); - - iFace.setRemovable(true); - iFace.setAccessProtocol("oai"); - iFace.setMetadataIdentifierPath("//*[local-name()='header']/*[local-name()='identifier']"); - iFace.setId("api_________::" + repo.getId() + "::" + UUID.randomUUID().toString().substring(0, 8)); - if (iFace.getAccessSet() == null || iFace.getAccessSet().isEmpty()) { - LOGGER.debug("set is empty: " + iFace.getAccessSet()); - iFace.removeAccessSet(); - iFace.setAccessSet("none"); - } - return iFace; - } - - @Override - public List getDnetCountries() { - LOGGER.debug("Getting dnet-countries!"); - return Converter.readFile("countries.txt"); - } - - @Override - public List getTypologies() { - return Converter.readFile("typologies.txt"); - } - - @Override - public List getTimezones() { - List timezones = Converter.readFile("timezones.txt"); - return Converter.toTimezones(timezones); - } - - @Override - public List getUrlsOfUserRepos(String userEmail, - String page, - String size){ - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(baseAddress + "/api/baseurl/") - .path("/{page}/{size}") - .build().expand(page,size).encode(); - - try{ - RequestFilter requestFilter = new RequestFilter(); - requestFilter.setRegisteredby(userEmail); - return Arrays.asList(restTemplate.postForObject(uriComponents.toUri(),requestFilter, String[].class)); - }catch (Exception e){ - LOGGER.debug("Exception on addRepositoryInterface" , e); - emailUtils.reportException(e); - throw e; - } - } - - @Override - public List getDatasourceVocabularies(String mode) { - - List resultSet = new ArrayList<>(); - for (Map.Entry entry : this.getVocabulary("dnet:datasource_typologies").getAsMap().entrySet()) { - if (mode.equalsIgnoreCase("aggregator")) { - if (entry.getKey().contains("aggregator")) - resultSet.add(entry.getValue()); - } else if (mode.equalsIgnoreCase("journal")) { - if (entry.getKey().contains("journal")) - resultSet.add(entry.getValue()); - } else if (mode.equalsIgnoreCase("opendoar")) { - if (entry.getKey().contains("pubsrepository")) - resultSet.add(entry.getValue()); - } else if (mode.equalsIgnoreCase("re3data")) { - if (entry.getKey().contains("datarepository")) - resultSet.add(entry.getValue()); - } - } - - - return resultSet; - } - - private Vocabulary getVocabulary(String vocName) { - - if (!vocabularyMap.containsKey(vocName)) { - vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT)); - } - return vocabularyMap.get(vocName); - } - - - @Override - public Map getCompatibilityClasses(String mode) { - - LOGGER.debug("Getting compatibility classes for mode: " + mode); - Map retMap = new HashMap(); - - Map compatibilityClasses = this.getVocabulary("dnet:compatibilityLevel").getAsMap(); - boolean foundData = false; - for (Map.Entry entry : compatibilityClasses.entrySet()) { - if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_ALL)) - return compatibilityClasses; - else if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA)) { - if (entry.getKey().matches("^openaire[1-9].0_data$")) { - retMap.put(entry.getKey(), entry.getValue()); - foundData = true; - } - } else { - if (entry.getKey().matches("^openaire[1-9].0$") || entry.getKey().equals("driver")) - retMap.put(entry.getKey(), entry.getValue()); - } - } - - //TODO TO BE REMOVED WHEN VOCABULARIES ARE UPDATED - if (mode.equalsIgnoreCase(Constants.REPOSITORY_MODE_RE3DATA) && !foundData) - retMap.put("openaire2.0_data", "OpenAIRE Data (funded, referenced datasets)"); - - return retMap; - } - - @Override - public Map getDatasourceClasses(String mode) { - - LOGGER.debug("Getting datasource classes for mode: " + mode); - - Map retMap = new HashMap(); - - for (Map.Entry entry : this.getVocabulary("dnet:datasource_typologies").getAsMap().entrySet()) { - if (mode.equalsIgnoreCase("aggregator")) { - if (entry.getKey().contains("aggregator")) - retMap.put(entry.getKey(), entry.getValue()); - } else if (mode.equalsIgnoreCase("journal")) { - if (entry.getKey().contains("journal")) - retMap.put(entry.getKey(), entry.getValue()); - } else if (mode.equalsIgnoreCase("opendoar")) { - if (entry.getKey().contains("pubsrepository")) - retMap.put(entry.getKey(), entry.getValue()); - } else if (mode.equalsIgnoreCase("re3data")) { - if (entry.getKey().contains("datarepository")) - retMap.put(entry.getKey(), entry.getValue()); - } - } - return filterResults(retMap,mode); - - } - - private Map filterResults(Map map,String mode) { - - HashMap filteredMap = new HashMap<>(); - for(String key:map.keySet()) - if(dataSourceClass.get(mode).contains(key)) - filteredMap.put(key,map.get(key)); - - return filteredMap; - } - - @Override - public String getCountryName(String countryCode) { - return inverseCountriesMap.get(countryCode); - } - - @Override - public MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException { - try { - - MetricsInfo metricsInfo = new MetricsInfo(); - metricsInfo.setDiagramsBaseURL(this.usageStatisticsDiagramsBaseURL); - metricsInfo.setMetricsNumbers(getMetricsNumbers(getOpenAIREId(repoId))); - return metricsInfo; - - } catch (Exception e) { - LOGGER.error("Error while getting metrics info for repository: ", e); - emailUtils.reportException(e); - throw new RepositoryServiceException("General error", RepositoryServiceException.ErrorCode.GENERAL_ERROR); - } - } - - @Override - public Map getListLatestUpdate(String mode) throws JSONException { - if(mode.equals("opendoar")) - return Collections.singletonMap("lastCollectionDate", getRepositoryInterface("openaire____::"+mode).get(0).getLastCollectionDate()); - else - /* - * first api of re3data has null value on collection date - * */ - return Collections.singletonMap("lastCollectionDate", getRepositoryInterface("openaire____::"+mode).get(1).getLastCollectionDate()); - } - - private void updateValidationSet(String repositoryId, String repositoryInterfaceId, String validationSet) throws Exception { - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(baseAddress + "/ds/api/oaiset") - .queryParam("dsId",repositoryId) - .queryParam("apiId",repositoryInterfaceId) - .queryParam("oaiSet",validationSet) - .build().encode(); - restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, null, ResponseEntity.class); - - } - - - private void updateBaseUrl(String repositoryId, String repositoryInterfaceId, String baseUrl) { - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(baseAddress + "/ds/api/baseurl") - .queryParam("dsId",repositoryId) - .queryParam("apiId",repositoryInterfaceId) - .queryParam("baseUrl",baseUrl) - .build().encode(); - restTemplate.postForObject(uriComponents.toUri(),null,String.class); - } - - private void updateCompliance(String repositoryId, String repositoryInterfaceId,String compliance) { - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(baseAddress + "/ds/api/compliance") - .queryParam("dsId",repositoryId) - .queryParam("apiId",repositoryInterfaceId) - .queryParam("compliance",compliance) - .build().encode(); - restTemplate.postForObject(uriComponents.toUri(),null,String.class); - } - - private MetricsNumbers getMetricsNumbers(String openAIREID) throws BrokerException { - - //build the uri params - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.usageStatisticsNumbersBaseURL + openAIREID + "/clicks"); - - //create new template engine - RestTemplate template = new RestTemplate(); - template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); - ResponseEntity resp; - try { - //communicate with endpoint - resp = template.exchange( - builder.build().encode().toUri(), - HttpMethod.GET, - null, - new ParameterizedTypeReference() { - }); - } catch (RestClientException e) { - LOGGER.debug("Exception on getMetricsNumbers" , e); - emailUtils.reportException(e); - throw e; - } - - return resp.getBody(); - } - - private String getOpenAIREId(String repoId) { - - if (repoId != null && repoId.contains("::")) { - return repoId.split("::")[0] + "::" + DigestUtils.md5Hex(repoId.split("::")[1]); - } - - return null; - } - - private UriComponents searchDatasource(String page,String size){ - - return UriComponentsBuilder - .fromHttpUrl(baseAddress + "/ds/search/") - .path("/{page}/{size}/") - .queryParam("requestSortBy","officialname") - .queryParam("order","ASCENDING") - .build().expand(page, size).encode(); - } - - private UriComponents searchSnipperDatasource(String page,String size){ - - return UriComponentsBuilder - .fromHttpUrl(baseAddress + "/ds/searchsnippet/") - .path("/{page}/{size}/") - .queryParam("requestSortBy","officialname") - .queryParam("order","ASCENDING") - .build().expand(page, size).encode(); - } - - private UriComponents searchRegisteredDatasource(String requestSortBy, String order, String page,String size){ - - return UriComponentsBuilder - .fromHttpUrl(baseAddress + "/ds/searchregistered/") - .path("/{page}/{size}/") - .queryParam("requestSortBy",requestSortBy) - .queryParam("order",order) - .build().expand(page, size).encode(); - } - - private String getRepositoryType(String typology){ - return invertedDataSourceClass.get(typology); - } - - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/StatsService.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/StatsService.java deleted file mode 100644 index 3a2da65..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/StatsService.java +++ /dev/null @@ -1,13 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; -import eu.dnetlib.repo.manager.exception.EndPointException; -import org.json.JSONException; - -import java.util.Map; - - -public interface StatsService { - - Map getStatistics() ; -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/StatsServiceImpl.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/StatsServiceImpl.java deleted file mode 100644 index 845ed10..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/StatsServiceImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import eu.dnetlib.repo.manager.service.customHystrixCommands.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; - -import java.util.HashMap; -import java.util.Map; - -@Service("statsService") -public class StatsServiceImpl implements StatsService { - - @Autowired - RestTemplate restTemplate; - - @Value("${search.api.baseAddress}") - private String baseAddress; - @Value("${search.api.usagestats}") - private String usagestatsBaseAddress; - @Value("${search.api.usageEvents}") - private String usagestatsEvents; - - @Override - public Map getStatistics() { - - UsageStatsTotalHystrixCommand usageStatsTotalHystrixCommand = new UsageStatsTotalHystrixCommand(usagestatsEvents,restTemplate); - DataRepositoriesHystrixCommand dataRepositoriesHystrixCommand = new DataRepositoriesHystrixCommand(baseAddress,restTemplate); - AggregatorsHystrixCommand aggregatorsHystrixCommand = new AggregatorsHystrixCommand(baseAddress,restTemplate); - LiteratureHystrixCommand literatureHystrixCommand = new LiteratureHystrixCommand(baseAddress,restTemplate); - JournalHystrixCommand journalHystrixCommand = new JournalHystrixCommand(baseAddress,restTemplate); - PublicationHystrixCommand publicationHystrixCommand = new PublicationHystrixCommand(baseAddress,restTemplate); - DatasetsHystrixCommand datasetsHystrixCommand = new DatasetsHystrixCommand(baseAddress,restTemplate); - SoftwareHystrixCommand softwareHystrixCommand = new SoftwareHystrixCommand(baseAddress,restTemplate); - LastYearUsageStatsHystrixCommand lastYearUsageStatsHystrixCommand = new LastYearUsageStatsHystrixCommand(usagestatsBaseAddress,restTemplate); - - Map stats = new HashMap<>(); - stats.put("aggregators",aggregatorsHystrixCommand.execute()); - stats.put("dataRepositories",dataRepositoriesHystrixCommand.execute()); - stats.put("literature",literatureHystrixCommand.execute()); - stats.put("journal",journalHystrixCommand.execute()); - stats.put("publications",publicationHystrixCommand.execute()); - stats.put("datasets",datasetsHystrixCommand.execute()); - stats.put("software",softwareHystrixCommand.execute()); - stats.put("lastYearUsagestats", lastYearUsageStatsHystrixCommand.execute()); - stats.put("usagestats",usageStatsTotalHystrixCommand.execute()); - return stats; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/SushiliteService.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/SushiliteService.java deleted file mode 100644 index 15ea811..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/SushiliteService.java +++ /dev/null @@ -1,23 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper; -import org.json.JSONException; - - -public interface SushiliteService { - - - ReportResponseWrapper getReportResults(String page, - String pageSize, - String Report, - String Release, - String RequestorID, - String BeginDate, - String EndDate, - String RepositoryIdentifier, - String ItemIdentifier, - String ItemDataType, - String Granularity, - String Pretty) throws JSONException; - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/SushiliteServiceImpl.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/SushiliteServiceImpl.java deleted file mode 100644 index 76e7e28..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/SushiliteServiceImpl.java +++ /dev/null @@ -1,116 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import eu.dnetlib.usagestats.sushilite.domain.ReportItem; -import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.client.RestClientException; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.ArrayList; -import java.util.List; - -@Service("sushiliteService") -public class SushiliteServiceImpl implements SushiliteService { - - - @Value("${services.repomanager.usagestats.sushiliteEndpoint}") - private String usagestatsSushiliteEndpoint; - - @Autowired - private EmailUtils emailUtils; - - private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(SushiliteServiceImpl.class); - - - @Override - @PreAuthorize("hasRole('ROLE_USER')") - public ReportResponseWrapper getReportResults(String page, - String pageSize, - String Report, - String Release, - String RequestorID, - String BeginDate, - String EndDate, - String RepositoryIdentifier, - String ItemIdentifier, - String ItemDataType, - String Granularity, - String Pretty) { - - //build the uri params - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.usagestatsSushiliteEndpoint + "GetReport/") - .queryParam("Report", Report) - .queryParam("Release", Release) - .queryParam("RequestorID", RequestorID) - .queryParam("BeginDate", BeginDate) - .queryParam("EndDate", EndDate) - .queryParam("RepositoryIdentifier", RepositoryIdentifier) - .queryParam("ItemIdentifier", ItemIdentifier) - .queryParam("ItemDataType", ItemDataType) - .queryParam("Granularity", Granularity) - .queryParam("Pretty", Pretty); - - //create new template engine - RestTemplate template = new RestTemplate(); - template.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); - - ResponseEntity resp; - try { - //communicate with endpoint - resp = template.exchange( - builder.build().encode().toUri(), - HttpMethod.GET, - null, - new ParameterizedTypeReference() { - }); - } catch (RestClientException e) { - LOGGER.debug("Exception on getReportResults" , e); - emailUtils.reportException(e); - throw e; - } - - // check remote api's response - System.out.println("sushi responded status " + resp.getStatusCode()); - - // get the items corresponding to the requested page - List requestedItemList = new ArrayList<>(); - if (resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems() != null) { - try { - int totalItems = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().size(); - int size = Integer.parseInt(pageSize); - int offset = Integer.parseInt(page)*size; - - if (offset < totalItems ) { - int upperIndex = offset+size; - if (upperIndex > totalItems) { - upperIndex = totalItems; - } - requestedItemList = resp.getBody().getReportResponse().getReportWrapper().getReport().getCustomer().getReportItems().subList(offset,upperIndex); - } - - } catch (NumberFormatException e) { - LOGGER.debug("Exception on getReportResults - trying to cast strings to integers", e); - //emailUtils.reportException(e); - throw e; - } - - } - - ReportResponseWrapper newReportResponse = resp.getBody(); - newReportResponse.getReportResponse().getReportWrapper().getReport().getCustomer().setReportItems(requestedItemList); - - - return newReportResponse; - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/UserService.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/UserService.java deleted file mode 100644 index 5b345c9..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/UserService.java +++ /dev/null @@ -1,9 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import org.springframework.http.ResponseEntity; - - -public interface UserService { - - ResponseEntity login(); -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/UserServiceImpl.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/UserServiceImpl.java deleted file mode 100644 index 8e736ab..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/UserServiceImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import org.mitre.openid.connect.model.OIDCAuthenticationToken; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Service; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -@Service("userService") -public class UserServiceImpl implements UserService { - - private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger - .getLogger(UserServiceImpl.class); - - @Value("${oidc.issuer}") - private String oidc_issuer; - - @Override - public ResponseEntity login() { - OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); - LOGGER.debug("User authentication : " + authentication); - Map body = new HashMap<>(); - body.put("sub",authentication.getSub()); - if(authentication.getUserInfo().getName() == null || authentication.getUserInfo().getName().equals("")) - body.put("name",authentication.getUserInfo().getGivenName() + " " + authentication.getUserInfo().getFamilyName()); - else - body.put("name",authentication.getUserInfo().getName()); - - body.put("email",authentication.getUserInfo().getEmail()); - List roles = authentication.getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList()); - body.put("role",roles); - - return new ResponseEntity<>(body, HttpStatus.OK); - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/ValidatorService.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/ValidatorService.java deleted file mode 100644 index bc710a6..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/ValidatorService.java +++ /dev/null @@ -1,46 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import eu.dnetlib.api.functionality.ValidatorServiceException; -import eu.dnetlib.domain.functionality.validator.JobForValidation; -import eu.dnetlib.domain.functionality.validator.JobResultEntry; -import eu.dnetlib.domain.functionality.validator.RuleSet; -import eu.dnetlib.domain.functionality.validator.StoredJob; -import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; -import eu.dnetlib.repo.manager.shared.InterfaceInformation; -import eu.dnetlib.repo.manager.shared.ValidationServiceException; -import org.json.JSONException; -import org.springframework.http.ResponseEntity; - -import java.util.List; - - - -public interface ValidatorService { - - - JobForValidation submitJobForValidation(JobForValidation jobForValidation) throws ValidatorServiceException; - - ResponseEntity reSubmitJobForValidation(String email, String jobId) throws JSONException, ValidatorServiceException; - - List getRuleSets(String mode); - - List getSetsOfRepository(String url); - - boolean identifyRepo(String url); - - RuleSet getRuleSet(String acronym); - - List getStoredJobsNew(String user, - String jobType, - String offset, - String limit, - String dateFrom, - String dateTo, - String validationStatus) throws ValidatorServiceException; - - int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException; - - InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException; - - List getJobsSummary(String repoId, int limit) throws ValidatorServiceException, ResourceNotFoundException, JSONException; -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/ValidatorServiceImpl.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/ValidatorServiceImpl.java deleted file mode 100644 index b72c264..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/ValidatorServiceImpl.java +++ /dev/null @@ -1,233 +0,0 @@ -package eu.dnetlib.repo.manager.service; - -import eu.dnetlib.api.functionality.ValidatorServiceException; -import eu.dnetlib.domain.data.Repository; -import eu.dnetlib.domain.data.RepositoryInterface; -import eu.dnetlib.domain.functionality.validator.JobForValidation; -import eu.dnetlib.domain.functionality.validator.JobResultEntry; -import eu.dnetlib.domain.functionality.validator.RuleSet; -import eu.dnetlib.domain.functionality.validator.StoredJob; -import eu.dnetlib.repo.manager.exception.ResourceNotFoundException; -import eu.dnetlib.repo.manager.shared.Constants; -import eu.dnetlib.repo.manager.shared.InterfaceInformation; -import eu.dnetlib.repo.manager.shared.ValidationServiceException; -import eu.dnetlib.repo.manager.utils.OaiTools; -import gr.uoa.di.driver.util.ServiceLocator; -import org.apache.log4j.Logger; -import org.json.JSONException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Service; - -import javax.annotation.PostConstruct; -import javax.annotation.Resource; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; - - -@Service("validatorService") -public class ValidatorServiceImpl implements ValidatorService { - - @Autowired - private MonitorServiceImpl monitorApi; - - @Autowired - private RepositoryService repositoryService; - - @Resource(name = "validatorServiceLocator") - private ServiceLocator validatorServiceLocator; - - private eu.dnetlib.api.functionality.ValidatorService getValidationService() { - return this.validatorServiceLocator.getService(); - } - - public ServiceLocator getValidatorServiceLocator() { - return validatorServiceLocator; - } - - public void setValidatorServiceLocator(ServiceLocator validatorServiceLocator) { - this.validatorServiceLocator = validatorServiceLocator; - } - - private Map> rulesetMap = new ConcurrentHashMap>(); - - private static final Logger LOGGER = Logger - .getLogger(ValidatorServiceImpl.class); - - @Autowired - private EmailUtils emailUtils; - - @PostConstruct - private void loadRules(){ - LOGGER.debug("PostConstruct method! Load rules!"); - try { - for (RuleSet ruleSet : getValidationService().getRuleSets()) { - if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains("development")) { - String key = ""; - if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_data$")) - key = Constants.VALIDATION_MODE_DATA; - else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0$") || ruleSet.getGuidelinesAcronym().equals("driver")) - key = Constants.VALIDATION_MODE_LITERATURE; - else if (ruleSet.getGuidelinesAcronym().matches("^openaire[1-9].0_cris$")) - key = Constants.VALIDATION_MODE_CRIS; - - if (rulesetMap.containsKey(key)) - rulesetMap.get(key).add(ruleSet); - else { - List ruleSets = new ArrayList(); - ruleSets.add(ruleSet); - rulesetMap.put(key, ruleSets); - } - } - } - } catch (ValidatorServiceException e) { - LOGGER.error(e); - } - - } - - @Override - @PreAuthorize("hasRole('ROLE_USER') and #jobForValidation.userEmail == authentication.userInfo.email") - public JobForValidation submitJobForValidation(JobForValidation jobForValidation) throws ValidatorServiceException { - LOGGER.debug("Submit job for validation with id : " + jobForValidation.getDatasourceId()); - try { - emailUtils.sendSubmitJobForValidationEmail(SecurityContextHolder.getContext().getAuthentication(),jobForValidation); - this.getValidationService().submitValidationJob(jobForValidation); - } catch (ValidatorServiceException e) { - LOGGER.debug("Exception on submitJobForValidation" , e); - emailUtils.reportException(e); - throw e; - } catch (Exception e) { - LOGGER.error(e); - } - return jobForValidation; - } - - @Override - @PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email") - public ResponseEntity reSubmitJobForValidation(String email, - String jobId) throws JSONException, ValidatorServiceException { - LOGGER.debug("Resubmit validation job with id : " + jobId); - StoredJob job = monitorApi.getJobSummary(jobId, "all"); - Set contentRules = new HashSet(); - Set usageRules = new HashSet(); - - RuleSet ruleSet = null; - for (List ruleSets : this.rulesetMap.values()) { - for (RuleSet rSet : ruleSets) - if (rSet.getGuidelinesAcronym().equals(job.getDesiredCompatibilityLevel())) { - ruleSet = rSet; - break; - } - } - if (ruleSet != null){ - for (int ruleId : job.getRules()) { - if (ruleSet.getContentRulesIds().contains(ruleId)) - contentRules.add(ruleId); - else if (ruleSet.getUsageRulesIds().contains(ruleId)) - usageRules.add(ruleId); - } - } - if (!contentRules.isEmpty()) - job.setSelectedContentRules(contentRules); - if (!usageRules.isEmpty()) - job.setSelectedUsageRules(usageRules); - this.submitJobForValidation(job); - return new ResponseEntity<>("OK",HttpStatus.OK); - } - - @Override - public List getRuleSets(String mode) { - LOGGER.info("Getting rulesets for mode: " + mode); - return rulesetMap.get(mode); - } - - @Override - public List getSetsOfRepository(String url) { - LOGGER.debug("Getting sets of repository with url : " + url); - try { - return OaiTools.getSetsOfRepo(url); - } catch (Exception e) { - LOGGER.debug("Exception on getSetsOfRepository" , e); - emailUtils.reportException(e); - } - return null; - } - - @Override - public boolean identifyRepo(String url) { - LOGGER.debug("Identify repository with url : " + url); - try { - return OaiTools.identifyRepository(url); - } catch (Exception e) { - LOGGER.error("Error while identifying repository with url: " + url, e); - emailUtils.reportException(e); - return false; - } - } - - @Override - public RuleSet getRuleSet(String acronym) { - LOGGER.debug("Getting ruleset with acronym : " + acronym); - RuleSet ruleSet = null; - try { - for (List ruleSets : this.rulesetMap.values()) { - for (RuleSet rSet : ruleSets) - if (rSet.getGuidelinesAcronym().equals(acronym)) { - ruleSet = rSet; - break; - } - } - return ruleSet; - } catch (Exception e) { - LOGGER.error("Error getting ruleset", e); - emailUtils.reportException(e); - return null; - } - } - - @Override - @PreAuthorize("hasRole('ROLE_USER')") - public List getStoredJobsNew(String user, - String jobType, - String offset, - String limit, - String dateFrom, - String dateTo, - String validationStatus ) throws ValidatorServiceException { - return getValidationService().getStoredJobsNew(user, jobType, Integer.parseInt(offset), Integer.parseInt(limit), dateFrom, dateTo, validationStatus); - } - - @Override - public int getStoredJobsTotalNumberNew(String user, String jobType, String validationStatus) throws ValidatorServiceException { - return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus); - } - - @Override - public InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException { - try { - LOGGER.debug("Getting interface information with url: " + baseUrl); - InterfaceInformation interfaceInformation = new InterfaceInformation(); - interfaceInformation.setIdentified(this.identifyRepo(baseUrl)); - if (interfaceInformation.isIdentified()) - interfaceInformation.setSets(this.getSetsOfRepository(baseUrl)); - - return interfaceInformation; - } catch (Exception e) { - LOGGER.error("Error getting interface information with url: " + baseUrl, e); - emailUtils.reportException(e); - throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR); - } - } - - @Override - public List getJobsSummary(String repoId, int limit) throws JSONException, ValidatorServiceException { - return getValidationService().getJobSummary(repositoryService.getRepositoryInterface(repoId).stream().map(RepositoryInterface::getBaseUrl).collect(Collectors.toList()),limit); - } - - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/AggregatorsHystrixCommand.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/AggregatorsHystrixCommand.java deleted file mode 100644 index 653fb72..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/AggregatorsHystrixCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -package eu.dnetlib.repo.manager.service.customHystrixCommands; - -import com.netflix.hystrix.HystrixCommand; -import com.netflix.hystrix.HystrixCommandGroupKey; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponents; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.Map; - -public class AggregatorsHystrixCommand extends HystrixCommand { - - RestTemplate restTemplate; - String baseAddress; - - public AggregatorsHystrixCommand(String baseAddress, RestTemplate restTemplate) { - super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup")); - this.baseAddress = baseAddress; - this.restTemplate = restTemplate; - } - - @Override - protected String run() throws Exception { - String url = baseAddress + "/resources" + - "?query= " + - " oaftype exact datasource and " + - " ( datasourcetypename exact Institutional Repository Aggregator " + - " or datasourcetypename exact Publication Repository Aggregator )"; - - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(url) - .queryParam("page", 0) - .queryParam("size", 0) - .queryParam("format", "json") - .build().encode(); - - ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class); - Map metadata = (Map) ((Map) rs.getBody()).get("meta"); - return String.valueOf(metadata.get("total")); - } - - @Override - protected String getFallback() { - return null; - } -} \ No newline at end of file diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/DataRepositoriesHystrixCommand.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/DataRepositoriesHystrixCommand.java deleted file mode 100644 index 8bdd0ca..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/DataRepositoriesHystrixCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -package eu.dnetlib.repo.manager.service.customHystrixCommands; - -import com.netflix.hystrix.HystrixCommand; -import com.netflix.hystrix.HystrixCommandGroupKey; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponents; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.Map; - -public class DataRepositoriesHystrixCommand extends HystrixCommand { - - RestTemplate restTemplate ; - private String baseAddress; - - public DataRepositoriesHystrixCommand(String baseAddress,RestTemplate restTemplate) { - super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup")); - this.baseAddress = baseAddress; - this.restTemplate = restTemplate; - } - - @Override - protected String run() { - String url = baseAddress+"/resources" + - "?query= " + - " oaftype exact datasource and " + - " datasourcetypename exact Data Repository "; - - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(url) - .queryParam("page",0) - .queryParam("size",0) - .queryParam("format","json") - .build().encode(); - - ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class); - Map metadata = (Map) ((Map)rs.getBody()).get("meta"); - return String.valueOf(metadata.get("total")); - } - - @Override - protected String getFallback() { - return null; - } -} \ No newline at end of file diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/DatasetsHystrixCommand.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/DatasetsHystrixCommand.java deleted file mode 100644 index 7353716..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/DatasetsHystrixCommand.java +++ /dev/null @@ -1,44 +0,0 @@ -package eu.dnetlib.repo.manager.service.customHystrixCommands; - -import com.netflix.hystrix.HystrixCommand; -import com.netflix.hystrix.HystrixCommandGroupKey; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponents; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.Map; - -public class DatasetsHystrixCommand extends HystrixCommand { - - RestTemplate restTemplate; - String baseAddress; - - public DatasetsHystrixCommand(String baseAddress,RestTemplate restTemplate) { - super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup")); - this.restTemplate = restTemplate; - this.baseAddress = baseAddress; - } - - @Override - protected String run() throws Exception { - String url = baseAddress+"/datasets/count"; - - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(url) - .queryParam("page", 0) - .queryParam("size", 0) - .queryParam("format", "json") - .build().encode(); - - ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class); - Map metadata = (Map) (rs.getBody()); - return String.valueOf(metadata.get("total")); - } - - @Override - protected String getFallback() { - return null; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/JournalHystrixCommand.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/JournalHystrixCommand.java deleted file mode 100644 index 0ba0bba..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/JournalHystrixCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -package eu.dnetlib.repo.manager.service.customHystrixCommands; - -import com.netflix.hystrix.HystrixCommand; -import com.netflix.hystrix.HystrixCommandGroupKey; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponents; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.Map; - -public class JournalHystrixCommand extends HystrixCommand { - - RestTemplate restTemplate; - private String baseAddress; - - public JournalHystrixCommand(String baseAddress, RestTemplate restTemplate) { - super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup")); - this.baseAddress = baseAddress; - this.restTemplate = restTemplate; - } - - @Override - protected String run() throws Exception { - String url = baseAddress+"/resources"+ - "?query= " + - " oaftype exact datasource and " + - " datasourcetypename exact Journal"; - - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(url) - .queryParam("page", 0) - .queryParam("size", 0) - .queryParam("format", "json") - .build().encode(); - - ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class); - Map metadata = (Map) ((Map) rs.getBody()).get("meta"); - return String.valueOf(metadata.get("total")); - } - - @Override - protected String getFallback() { - return null; - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/LastYearUsageStatsHystrixCommand.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/LastYearUsageStatsHystrixCommand.java deleted file mode 100644 index eb9561a..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/LastYearUsageStatsHystrixCommand.java +++ /dev/null @@ -1,52 +0,0 @@ -package eu.dnetlib.repo.manager.service.customHystrixCommands; - -import com.netflix.hystrix.HystrixCommand; -import com.netflix.hystrix.HystrixCommandGroupKey; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponents; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class LastYearUsageStatsHystrixCommand extends HystrixCommand { - - RestTemplate restTemplate; - String usagestatsBaseAddress; - - public LastYearUsageStatsHystrixCommand(String usagestatsBaseAddress,RestTemplate restTemplate) { - super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup")); - this.usagestatsBaseAddress = usagestatsBaseAddress; - this.restTemplate = restTemplate; - } - - @Override - protected Map run() throws Exception { - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(usagestatsBaseAddress + "/totals") - .build().encode(); - - ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class); - - List yearly_stats = (List) ((Map)rs.getBody()).get("yearly_stats"); - Map lastYear = (Map) yearly_stats.get(yearly_stats.size()-1); - Integer downloads = (Integer) lastYear.get("downloads"); - Integer views = (Integer) lastYear.get("views"); - Integer year = (Integer) lastYear.get("year"); - - Map usagestats = new HashMap<>(); - usagestats.put("number",String.valueOf(downloads+views)); - usagestats.put("year",year); - - return usagestats; - } - - @Override - protected Map getFallback() { - return null; - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/LiteratureHystrixCommand.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/LiteratureHystrixCommand.java deleted file mode 100644 index 2242e6f..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/LiteratureHystrixCommand.java +++ /dev/null @@ -1,49 +0,0 @@ -package eu.dnetlib.repo.manager.service.customHystrixCommands; - -import com.netflix.hystrix.HystrixCommand; -import com.netflix.hystrix.HystrixCommandGroupKey; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponents; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.Map; - -public class LiteratureHystrixCommand extends HystrixCommand { - - RestTemplate restTemplate; - private String baseAddress; - - public LiteratureHystrixCommand(String baseAddress , RestTemplate restTemplate) { - super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup")); - this.baseAddress = baseAddress; - this.restTemplate = restTemplate; - } - - @Override - protected String run() throws Exception { - String url = baseAddress+"/resources"+ - "?query= " + - " oaftype exact datasource and " + - " ( datasourcetypename exact Institutional Repository " + - " or datasourcetypename exact Publication Repository )"; - - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(url) - .queryParam("page", 0) - .queryParam("size", 0) - .queryParam("format", "json") - .build().encode(); - - ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class); - Map metadata = (Map) ((Map) rs.getBody()).get("meta"); - return String.valueOf(metadata.get("total")); - } - - @Override - protected String getFallback() { - return null; - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/PublicationHystrixCommand.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/PublicationHystrixCommand.java deleted file mode 100644 index 094198a..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/PublicationHystrixCommand.java +++ /dev/null @@ -1,45 +0,0 @@ -package eu.dnetlib.repo.manager.service.customHystrixCommands; - -import com.netflix.hystrix.HystrixCommand; -import com.netflix.hystrix.HystrixCommandGroupKey; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponents; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.Map; - -public class PublicationHystrixCommand extends HystrixCommand { - - RestTemplate restTemplate; - private String baseAddress; - - public PublicationHystrixCommand(String baseAddress, RestTemplate restTemplate) { - super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup")); - this.baseAddress = baseAddress; - this.restTemplate = restTemplate; - } - - @Override - protected String run() throws Exception { - String url = baseAddress + "/publications/count"; - - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(url) - .queryParam("page", 0) - .queryParam("size", 0) - .queryParam("format", "json") - .build().encode(); - - ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class); - Map metadata = (Map) (rs.getBody()); - return String.valueOf(metadata.get("total")); - } - - @Override - protected String getFallback() { - return null; - } - -} \ No newline at end of file diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/SoftwareHystrixCommand.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/SoftwareHystrixCommand.java deleted file mode 100644 index 09b9f07..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/SoftwareHystrixCommand.java +++ /dev/null @@ -1,44 +0,0 @@ -package eu.dnetlib.repo.manager.service.customHystrixCommands; - -import com.netflix.hystrix.HystrixCommand; -import com.netflix.hystrix.HystrixCommandGroupKey; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponents; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.Map; - -public class SoftwareHystrixCommand extends HystrixCommand { - - String baseAddress; - RestTemplate restTemplate; - - public SoftwareHystrixCommand(String baseAddress, RestTemplate restTemplate) { - super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup")); - this.baseAddress = baseAddress; - this.restTemplate = restTemplate; - } - - @Override - protected String run() { - String url = baseAddress + "/software/count"; - - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(url) - .queryParam("page", 0) - .queryParam("size", 0) - .queryParam("format", "json") - .build().encode(); - - ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET, null, Map.class); - Map metadata = (Map) (rs.getBody()); - return String.valueOf(metadata.get("total")); - } - - @Override - protected String getFallback() { - return null; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/UsageStatsTotalHystrixCommand.java b/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/UsageStatsTotalHystrixCommand.java deleted file mode 100644 index c878d9b..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/service/customHystrixCommands/UsageStatsTotalHystrixCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -package eu.dnetlib.repo.manager.service.customHystrixCommands; - -import com.netflix.hystrix.HystrixCommand; -import com.netflix.hystrix.HystrixCommandGroupKey; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponents; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.Map; - -public class UsageStatsTotalHystrixCommand extends HystrixCommand { - - RestTemplate restTemplate ; - String usagestatsEvents; - - public UsageStatsTotalHystrixCommand(String usagestatsEvents,RestTemplate restTemplate) { - super(HystrixCommandGroupKey.Factory.asKey("StatisticsGroup")); - this.usagestatsEvents = usagestatsEvents; - this.restTemplate = restTemplate; - } - - @Override - protected Integer run() { - UriComponents uriComponents = UriComponentsBuilder - .fromHttpUrl(usagestatsEvents) - .build().encode(); - - ResponseEntity rs = restTemplate.exchange(uriComponents.toUri(), HttpMethod.GET,null,Map.class); - Map metadata = (Map) ((Map)rs.getBody()).get("totals"); -// String rs = restTemplate.getForObject(uriComponents.toUri(), String.class); -// JSONObject resultSet = new JSONObject(rs); -// JSONObject totals = resultSet.getJSONObject("totals"); - return (Integer) metadata.get("events"); - } - - @Override - protected Integer getFallback() { - return null; - } - -} \ No newline at end of file diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/AggregationDetails.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/AggregationDetails.java deleted file mode 100644 index e458a1c..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/AggregationDetails.java +++ /dev/null @@ -1,65 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.Calendar; -import java.util.Date; - -public class AggregationDetails implements IsSerializable{ - - - private String aggregationStage; - private Date date; - private int numberOfRecords; - private String collectionMode; - private Boolean indexedVersion; - - public AggregationDetails() { - } - - public String getAggregationStage() { - return aggregationStage; - } - - public String getCollectionMode() { - return collectionMode; - } - - public void setCollectionMode(String collectionMode) { - this.collectionMode = collectionMode; - } - - public void setAggregationStage(String aggregationStage) { - this.aggregationStage = aggregationStage; - } - - public Date getDate() { - return date; - } - - public void setDate(Date date) { - this.date = date; - } - - public int getNumberOfRecords() { - return numberOfRecords; - } - - public void setNumberOfRecords(int numberOfRecords) { - this.numberOfRecords = numberOfRecords; - } - - public String getYear() { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(getDate()); - return String.valueOf(calendar.get(Calendar.YEAR)); - } - - public Boolean getIndexedVersion() { - return indexedVersion; - } - - public void setIndexedVersion(Boolean indexedVersion) { - this.indexedVersion = indexedVersion; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Aggregations.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Aggregations.java deleted file mode 100644 index 44b3d8d..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Aggregations.java +++ /dev/null @@ -1,40 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.ArrayList; -import java.util.List; - -public class Aggregations implements IsSerializable{ - - private List aggregationHistory = new ArrayList<>(); - private AggregationDetails lastCollection; - private AggregationDetails lastTransformation; - - public Aggregations() { - } - - public List getAggregationHistory() { - return aggregationHistory; - } - - public void setAggregationHistory(List aggregationHistory) { - this.aggregationHistory = aggregationHistory; - } - - public AggregationDetails getLastCollection() { - return lastCollection; - } - - public void setLastCollection(AggregationDetails lastCollection) { - this.lastCollection = lastCollection; - } - - public AggregationDetails getLastTransformation() { - return lastTransformation; - } - - public void setLastTransformation(AggregationDetails lastTransformation) { - this.lastTransformation = lastTransformation; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/BrokerException.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/BrokerException.java deleted file mode 100644 index 655ccc4..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/BrokerException.java +++ /dev/null @@ -1,17 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - - -/** - * Created by stefanos on 27-Oct-16. - */ -public class BrokerException extends Exception { - - public BrokerException(Throwable th) { - super(th); - } - - public BrokerException() { - } - - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Constants.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Constants.java deleted file mode 100644 index 4647fe3..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Constants.java +++ /dev/null @@ -1,44 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by nikonas on 23/12/15. - */ - -public class Constants implements IsSerializable { - - public static final String MODE_LOCAL = "local"; - public static final String MODE_DNET = "dnet"; - public static final String MODE_LDAP = "ldap"; - public static final String ENV_LAREFERENCIA = "lareferencia"; - - public static final String ENV_MINCYT = "mincyt"; - public static final String ENV_OPENAIRE_PRODUCTION = "openaire-production"; - public static final String ENV_OPENAIRE_BETA = "openaire-beta"; - public static final String ENV_DEVELOPMENT = "development"; - public static final String LATITUDE_PATTERN = "^(\\+|-)?(?:90(?:(?:\\.0{1,6})?)|(?:[0-9]|[1-8][0-9])(?:(?:\\.[0-9]{1,6})?))$"; - - public static final String LONGITUDE_PATTERN = "^(\\+|-)?(?:180(?:(?:\\.0{1,6})?)|(?:[0-9]|[1-9][0-9]|1[0-7][0-9])(?:(?:\\.[0-9]{1,6})?))$"; - public static final String EMAIL_PATTERN = "^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"; - - - public static final String REPOSITORY_MODE_OPENDOAR = "opendoar"; - public static final String REPOSITORY_MODE_RE3DATA = "re3data"; - public static final String REPOSITORY_MODE_JOURNAL = "journal"; - public static final String REPOSITORY_MODE_AGGREGATOR = "aggregator"; - public static final String REPOSITORY_MODE_ALL = "all"; - - public static final String VALIDATION_MODE_LITERATURE = "literature"; - public static final String VALIDATION_MODE_DATA = "data"; - public static final String VALIDATION_MODE_CRIS = "cris"; - - public static final String VALIDATION_JOB_TYPE_COMPATIBILITY_TEST = "Compatibility Test"; - public static final String VALIDATION_JOB_TYPE_REGISTRATION_REQUEST = "Registration Request"; - public static final String VALIDATION_JOB_TYPE_WORKFLOW_REQUEST = "Workflow Request"; - - public static final String VALIDATION_JOB_STATUS_SUCCESSFUL = "successful"; - public static final String VALIDATION_JOB_STATUS_FAILED = "failed"; - public static final String VALIDATION_JOB_STATUS_ONGOING = "ongoing"; - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Country.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Country.java deleted file mode 100644 index 0e2401e..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Country.java +++ /dev/null @@ -1,24 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -public class Country { - - private String name; - private String code; - - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/DatasourceRegistrationState.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/DatasourceRegistrationState.java deleted file mode 100644 index 9fdf1e9..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/DatasourceRegistrationState.java +++ /dev/null @@ -1,48 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; -import eu.dnetlib.domain.data.Repository; - -/** - * Created by stefania on 12/17/15. - */ -public class DatasourceRegistrationState extends WizardState implements IsSerializable { - - private String mode; - private String selectedRepositoryId; - - private Repository repository; - - public DatasourceRegistrationState() { - } - - public DatasourceRegistrationState(String mode, String selectedRepositoryId, Repository repository) { - this.mode = mode; - this.selectedRepositoryId = selectedRepositoryId; - this.repository = repository; - } - - public String getMode() { - return mode; - } - - public void setMode(String mode) { - this.mode = mode; - } - - public String getSelectedRepositoryId() { - return selectedRepositoryId; - } - - public void setSelectedRepositoryId(String selectedRepositoryId) { - this.selectedRepositoryId = selectedRepositoryId; - } - - public Repository getRepository() { - return repository; - } - - public void setRepository(Repository repository) { - this.repository = repository; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/DatasourceVocabularies.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/DatasourceVocabularies.java deleted file mode 100644 index f382e05..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/DatasourceVocabularies.java +++ /dev/null @@ -1,61 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.List; -import java.util.Map; - -/** - * Created by nikonas on 21/12/15. - */ -public class DatasourceVocabularies implements IsSerializable { - - private Map countries; - private List timezones; - private Map datasourceClasses; - private List typologies; - private Map compatibilityLevels; - - public DatasourceVocabularies() { - } - - public Map getCountries() { - return countries; - } - - public void setCountries(Map countries) { - this.countries = countries; - } - - public List getTimezones() { - return timezones; - } - - public void setTimezones(List timezones) { - this.timezones = timezones; - } - - public Map getDatasourceClasses() { - return datasourceClasses; - } - - public void setDatasourceClasses(Map datasourceClasses) { - this.datasourceClasses = datasourceClasses; - } - - public List getTypologies() { - return typologies; - } - - public void setTypologies(List typologies) { - this.typologies = typologies; - } - - public Map getCompatibilityLevels() { - return compatibilityLevels; - } - - public void setCompatibilityLevels(Map compatibilityLevels) { - this.compatibilityLevels = compatibilityLevels; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/DatasourcesCollection.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/DatasourcesCollection.java deleted file mode 100644 index e19193c..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/DatasourcesCollection.java +++ /dev/null @@ -1,47 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; -import eu.dnetlib.domain.data.Repository; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by nikonas on 14/1/16. - */ -public class DatasourcesCollection implements IsSerializable{ - - private List datasourcesOfUser; - private List sharedDatasources; - private List datasourcesOfOthers; - - public DatasourcesCollection() { - this.datasourcesOfOthers = new ArrayList(); - this.datasourcesOfUser = new ArrayList(); - this.datasourcesOfOthers = new ArrayList(); - } - - public List getDatasourcesOfUser() { - return datasourcesOfUser; - } - - public void setDatasourcesOfUser(List datasourcesOfUser) { - this.datasourcesOfUser = datasourcesOfUser; - } - - public List getDatasourcesOfOthers() { - return datasourcesOfOthers; - } - - public void setDatasourcesOfOthers(List datasourcesOfOthers) { - this.datasourcesOfOthers = datasourcesOfOthers; - } - - public List getSharedDatasources() { - return sharedDatasources; - } - - public void setSharedDatasources(List sharedDatasources) { - this.sharedDatasources = sharedDatasources; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/InterfaceInformation.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/InterfaceInformation.java deleted file mode 100644 index 9efdecf..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/InterfaceInformation.java +++ /dev/null @@ -1,42 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.List; - -/** - * Created by nikonas on 7/1/16. - */ -public class InterfaceInformation implements IsSerializable { - - private boolean identified; - private List sets; - private List adminEmails; - - public InterfaceInformation() { - } - - public boolean isIdentified() { - return identified; - } - - public void setIdentified(boolean identified) { - this.identified = identified; - } - - public List getSets() { - return sets; - } - - public void setSets(List sets) { - this.sets = sets; - } - - public List getAdminEmails() { - return adminEmails; - } - - public void setAdminEmails(List adminEmails) { - this.adminEmails = adminEmails; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/JobsOfUser.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/JobsOfUser.java deleted file mode 100644 index b4498c5..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/JobsOfUser.java +++ /dev/null @@ -1,59 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; -import eu.dnetlib.domain.functionality.validator.StoredJob; - -import java.util.List; - -/** - * Created by nikonas on 29/3/16. - */ -public class JobsOfUser implements IsSerializable { - - private int totalJobs; - private int totalJobsSuccessful; - private int totalJobsFailed; - private int totalJobsOngoing; - - private List jobs; - - public int getTotalJobs() { - return totalJobs; - } - - public void setTotalJobs(int totalJobs) { - this.totalJobs = totalJobs; - } - - public int getTotalJobsSuccessful() { - return totalJobsSuccessful; - } - - public void setTotalJobsSuccessful(int totalJobsSuccessful) { - this.totalJobsSuccessful = totalJobsSuccessful; - } - - public int getTotalJobsFailed() { - return totalJobsFailed; - } - - public void setTotalJobsFailed(int totalJobsFailed) { - this.totalJobsFailed = totalJobsFailed; - } - - public int getTotalJobsOngoing() { - return totalJobsOngoing; - } - - public void setTotalJobsOngoing(int totalJobsOngoing) { - this.totalJobsOngoing = totalJobsOngoing; - } - - public List getJobs() { - return jobs; - } - - public void setJobs(List jobs) { - this.jobs = jobs; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/MetricsInfo.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/MetricsInfo.java deleted file mode 100644 index faf87cf..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/MetricsInfo.java +++ /dev/null @@ -1,36 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by stefania on 11/6/17. - */ -public class MetricsInfo implements IsSerializable { - - private MetricsNumbers metricsNumbers; - private String diagramsBaseURL; - - public MetricsInfo() { - } - - public MetricsInfo(MetricsNumbers metricsNumbers, String diagramsBaseURL) { - this.metricsNumbers = metricsNumbers; - this.diagramsBaseURL = diagramsBaseURL; - } - - public MetricsNumbers getMetricsNumbers() { - return metricsNumbers; - } - - public void setMetricsNumbers(MetricsNumbers metricsNumbers) { - this.metricsNumbers = metricsNumbers; - } - - public String getDiagramsBaseURL() { - return diagramsBaseURL; - } - - public void setDiagramsBaseURL(String diagramsBaseURL) { - this.diagramsBaseURL = diagramsBaseURL; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/MetricsNumbers.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/MetricsNumbers.java deleted file mode 100644 index d3e6175..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/MetricsNumbers.java +++ /dev/null @@ -1,101 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.List; - -/** - * Created by stefania on 11/7/17. - */ -public class MetricsNumbers implements IsSerializable { - - private List downloads; - private List views; - - @JsonProperty("total_downloads") - private String totalDownloads; - - @JsonProperty("total_views") - private String totalViews; - - @JsonProperty("total_openaire_downloads") - private String totalOpenAIREDownloads; - - @JsonProperty("total_openaire_views") - private String totalOpenAIREViews; - - @JsonProperty("pageviews") - private String pageViews; - - public MetricsNumbers() { - } - - public MetricsNumbers(List downloads, List views, String totalDownloads, String totalViews, - String totalOpenAIREDownloads, String totalOpenAIREViews, String pageViews) { - this.downloads = downloads; - this.views = views; - this.totalDownloads = totalDownloads; - this.totalViews = totalViews; - this.totalOpenAIREDownloads = totalOpenAIREDownloads; - this.totalOpenAIREViews = totalOpenAIREViews; - this.pageViews = pageViews; - } - - public List getDownloads() { - return downloads; - } - - public void setDownloads(List downloads) { - this.downloads = downloads; - } - - public List getViews() { - return views; - } - - public void setViews(List views) { - this.views = views; - } - - public String getTotalDownloads() { - return totalDownloads; - } - - public void setTotalDownloads(String totalDownloads) { - this.totalDownloads = totalDownloads; - } - - public String getTotalViews() { - return totalViews; - } - - public void setTotalViews(String totalViews) { - this.totalViews = totalViews; - } - - public String getTotalOpenAIREDownloads() { - return totalOpenAIREDownloads; - } - - public void setTotalOpenAIREDownloads(String totalOpenAIREDownloads) { - this.totalOpenAIREDownloads = totalOpenAIREDownloads; - } - - public String getTotalOpenAIREViews() { - return totalOpenAIREViews; - } - - public void setTotalOpenAIREViews(String totalOpenAIREViews) { - this.totalOpenAIREViews = totalOpenAIREViews; - } - - public String getPageViews() { - return pageViews; - } - - public void setPageViews(String pageViews) { - this.pageViews = pageViews; - } -} - diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/RepositoryServiceException.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/RepositoryServiceException.java deleted file mode 100644 index 696b624..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/RepositoryServiceException.java +++ /dev/null @@ -1,53 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by nikonas on 7/12/15. - */ -public class RepositoryServiceException extends Exception implements IsSerializable { - - public enum ErrorCode implements IsSerializable { - REPOSITORY_ALREADY_EXISTS, - SQL_ERROR, - NOT_ACTIVATED, - ACTIVATION_ERROR, - LDAP_ERROR, - MAIL_ALREADY_EXISTS, - GENERAL_ERROR, - ALREADY_ACTIVATED, - INVALID_EMAIL_FORMAT, - NO_REPOS_FOR_THIS_COUNTRY, REPOSITORY_NOT_EXISTS, INCORRECT_CAPTCHA - } - - private ErrorCode errorCode = null; - - public RepositoryServiceException() { - } - - public RepositoryServiceException(ErrorCode errorCode) { - this.errorCode = errorCode; - } - - public RepositoryServiceException(String message, Throwable cause, ErrorCode errorCode) { - super(message, cause); - - this.errorCode = errorCode; - } - - public RepositoryServiceException(String message, ErrorCode errorCode) { - super(message); - - this.errorCode = errorCode; - } - - public RepositoryServiceException(Throwable cause, ErrorCode errorCode) { - super(cause); - - this.errorCode = errorCode; - } - - public ErrorCode getErrorCode() { - return errorCode; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Term.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Term.java deleted file mode 100644 index 01f70e6..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Term.java +++ /dev/null @@ -1,53 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by panagiotis on 15/1/2018. - */ -public class Term implements IsSerializable { - - private String englishName; - private String nativeName; - private String encoding; - private String code; - - public Term(String englishName, String nativeName, String encoding, String code) { - this.englishName = englishName; - this.nativeName = nativeName; - this.encoding = encoding; - this.code = code; - } - - public String getEnglishName() { - return englishName; - } - - public void setEnglishName(String englishName) { - this.englishName = englishName; - } - - public String getNativeName() { - return nativeName; - } - - public void setNativeName(String nativeName) { - this.nativeName = nativeName; - } - - public String getEncoding() { - return encoding; - } - - public void setEncoding(String encoding) { - this.encoding = encoding; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Timezone.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Timezone.java deleted file mode 100644 index 5e922dd..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Timezone.java +++ /dev/null @@ -1,17 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -public class Timezone implements IsSerializable { - private String name; - private double offset; - - public Timezone(){ - } - - public Timezone(String name, double offset) { - super(); - this.name = name; - this.offset = offset; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Triple.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Triple.java deleted file mode 100644 index ba5ee22..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Triple.java +++ /dev/null @@ -1,27 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by stefania on 3/8/16. - */ -public class Triple extends Tuple implements IsSerializable { - - private L third; - - public Triple() { - } - - public Triple(K first, V second, L third) { - super(first, second); - this.third = third; - } - - public L getThird() { - return third; - } - - public void setThird(L third) { - this.third = third; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Tuple.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Tuple.java deleted file mode 100644 index 6e87a71..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Tuple.java +++ /dev/null @@ -1,36 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by stefania on 12/18/15. - */ -public class Tuple implements IsSerializable { - - private K first; - private V second; - - public Tuple() { - } - - public Tuple(K first, V second) { - this.first = first; - this.second = second; - } - - public K getFirst() { - return first; - } - - public void setFirst(K first) { - this.first = first; - } - - public V getSecond() { - return second; - } - - public void setSecond(V second) { - this.second = second; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/UserAccessException.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/UserAccessException.java deleted file mode 100644 index df12af0..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/UserAccessException.java +++ /dev/null @@ -1,51 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by nikonas on 7/12/15. - */ -public class UserAccessException extends Exception implements IsSerializable { - - public enum ErrorCode implements IsSerializable { - USER_ALREADY_EXISTS, - SQL_ERROR, - INVALID_USERNAME, - INVALID_PASSWORD, - NOT_ACTIVATED, - ACTIVATION_ERROR, - LDAP_ERROR, - USERNAME_ALREADY_EXISTS, MAIL_ALREADY_EXISTS, GENERAL_ERROR, ALREADY_ACTIVATED, INVALID_EMAIL_FORMAT, WRONG_SECURITY_CODE, INCORRECT_CAPTCHA - } - - private ErrorCode errorCode = null; - - public UserAccessException() { - } - - public UserAccessException(ErrorCode errorCode) { - this.errorCode = errorCode; - } - - public UserAccessException(String message, Throwable cause, ErrorCode errorCode) { - super(message, cause); - - this.errorCode = errorCode; - } - - public UserAccessException(String message, ErrorCode errorCode) { - super(message); - - this.errorCode = errorCode; - } - - public UserAccessException(Throwable cause, ErrorCode errorCode) { - super(cause); - - this.errorCode = errorCode; - } - - public ErrorCode getErrorCode() { - return errorCode; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/ValidationServiceException.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/ValidationServiceException.java deleted file mode 100644 index 678575f..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/ValidationServiceException.java +++ /dev/null @@ -1,46 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by nikonas on 7/12/15. - */ -public class ValidationServiceException extends Exception implements IsSerializable { - - public enum ErrorCode implements IsSerializable { - NO_ADMIN_EMAILS, - NOT_VALID_BASEURL, - GENERAL_ERROR, NOT_VALID_SET - } - - private ErrorCode errorCode = null; - - public ValidationServiceException() { - } - - public ValidationServiceException(ErrorCode errorCode) { - this.errorCode = errorCode; - } - - public ValidationServiceException(String message, Throwable cause, ErrorCode errorCode) { - super(message, cause); - - this.errorCode = errorCode; - } - - public ValidationServiceException(String message, ErrorCode errorCode) { - super(message); - - this.errorCode = errorCode; - } - - public ValidationServiceException(Throwable cause, ErrorCode errorCode) { - super(cause); - - this.errorCode = errorCode; - } - - public ErrorCode getErrorCode() { - return errorCode; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/ValidationState.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/ValidationState.java deleted file mode 100644 index 4054c5f..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/ValidationState.java +++ /dev/null @@ -1,16 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; -import eu.dnetlib.domain.functionality.validator.JobForValidation; - -/** - * Created by stefania on 2/10/16. - */ -public class ValidationState extends WizardState implements IsSerializable { - - private JobForValidation jobForValidation = new JobForValidation(); - - public JobForValidation getJobForValidation() { - return jobForValidation; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Vocabulary.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Vocabulary.java deleted file mode 100644 index e131418..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/Vocabulary.java +++ /dev/null @@ -1,36 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by stefania on 3/8/16. - */ -public class Vocabulary implements IsSerializable { - - private String id; - private String name; - - public Vocabulary() { - } - - public Vocabulary(String id, String name) { - this.id = id; - this.name = name; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/WizardState.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/WizardState.java deleted file mode 100644 index 0a34b31..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/WizardState.java +++ /dev/null @@ -1,9 +0,0 @@ -package eu.dnetlib.repo.manager.shared; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by stefania on 2/10/16. - */ -public class WizardState implements IsSerializable { -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/AdvQueryObject.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/AdvQueryObject.java deleted file mode 100644 index 39bc2cf..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/AdvQueryObject.java +++ /dev/null @@ -1,99 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.ArrayList; -import java.util.List; - -public class AdvQueryObject implements IsSerializable { - - private String datasource = ""; - private String topic = ""; - private List titles = new ArrayList<>(); - private List subjects = new ArrayList<>(); - private List authors = new ArrayList<>(); - private List dates = new ArrayList<>(); - private Range trust = new Range("0", "1"); - - private long page = 0; - - public AdvQueryObject() { - } - - public AdvQueryObject(String datasource, String topic, List titles, List subjects, List authors, - List dates, Range trust, long page) { - this.datasource = datasource; - this.topic = topic; - this.titles = titles; - this.subjects = subjects; - this.authors = authors; - this.dates = dates; - this.trust = trust; - this.page = page; - } - - public String getDatasource() { - return datasource; - } - - public void setDatasource(String datasource) { - this.datasource = datasource; - } - - public String getTopic() { - return topic; - } - - public void setTopic(String topic) { - this.topic = topic; - } - - public List getTitles() { - return titles; - } - - public void setTitles(List titles) { - this.titles = titles; - } - - public List getSubjects() { - return subjects; - } - - public void setSubjects(List subjects) { - this.subjects = subjects; - } - - public List getAuthors() { - return authors; - } - - public void setAuthors(List authors) { - this.authors = authors; - } - - public List getDates() { - return dates; - } - - public void setDates(List dates) { - this.dates = dates; - } - - public Range getTrust() { - return trust; - } - - public void setTrust(Range trust) { - this.trust = trust; - } - - public long getPage() { - return page; - } - - public void setPage(long page) { - this.page = page; - } -} - diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/BrowseEntry.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/BrowseEntry.java deleted file mode 100644 index 0d72a2e..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/BrowseEntry.java +++ /dev/null @@ -1,42 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by stefanos on 26/10/2016. - */ -public class BrowseEntry implements Comparable, IsSerializable{ - - private String value; - private Long size; - - public BrowseEntry() { - } - - public BrowseEntry(final String value, final Long size) { - this.value = value; - this.size = size; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public Long getSize() { - return size; - } - - public void setSize(Long size) { - this.size = size; - } - - @Override - public int compareTo(final BrowseEntry bv) { - return Long.compare(getSize(), bv.getSize()); - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/ConditionOperator.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/ConditionOperator.java deleted file mode 100644 index 73a1777..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/ConditionOperator.java +++ /dev/null @@ -1,10 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by stefanos on 17/3/2017. - */ -public enum ConditionOperator implements IsSerializable { - EXACT, MATCH_ANY, MATCH_ALL, RANGE -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/ConditionParams.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/ConditionParams.java deleted file mode 100644 index 323f76c..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/ConditionParams.java +++ /dev/null @@ -1,36 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by stefanos on 17/3/2017. - */ -public class ConditionParams implements IsSerializable { - - private String value; - private String otherValue; - - public ConditionParams() { - } - - public ConditionParams(final String value, final String otherValue) { - this.value = value; - this.otherValue = otherValue; - } - - public String getValue() { - return this.value; - } - - public void setValue(final String value) { - this.value = value; - } - - public String getOtherValue() { - return this.otherValue; - } - - public void setOtherValue(final String otherValue) { - this.otherValue = otherValue; - } -} \ No newline at end of file diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Dataset.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Dataset.java deleted file mode 100644 index 8471cd1..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Dataset.java +++ /dev/null @@ -1,58 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.List; - -public class Dataset implements IsSerializable { - - private List titles; - - private List collectedFrom; - - private List pids; - - private List instances; - - public Dataset() { - } - - public Dataset(final List titles, final List collectedFrom, final List pids, final List instances) { - this.titles = titles; - this.collectedFrom = collectedFrom; - this.pids = pids; - this.instances = instances; - } - - public List getTitles() { - return titles; - } - - public void setTitles(List titles) { - this.titles = titles; - } - - public List getCollectedFrom() { - return collectedFrom; - } - - public void setCollectedFrom(List collectedFrom) { - this.collectedFrom = collectedFrom; - } - - public List getPids() { - return pids; - } - - public void setPids(List pids) { - this.pids = pids; - } - - public List getInstances() { - return instances; - } - - public void setInstances(List instances) { - this.instances = instances; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/DatasourcesBroker.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/DatasourcesBroker.java deleted file mode 100644 index 66df443..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/DatasourcesBroker.java +++ /dev/null @@ -1,40 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; -import eu.dnetlib.repo.manager.shared.Tuple; - -import java.util.List; - -/** - * Created by stefanos on 31/10/2016. - */ -public class DatasourcesBroker implements IsSerializable { - - private List> datasourcesOfUser; - private List> sharedDatasources; - private List> datasourcesOfOthers; - - public List> getDatasourcesOfUser() { - return datasourcesOfUser; - } - - public void setDatasourcesOfUser(List> datasourcesOfUser) { - this.datasourcesOfUser = datasourcesOfUser; - } - - public List> getSharedDatasources() { - return sharedDatasources; - } - - public void setSharedDatasources(List> sharedDatasources) { - this.sharedDatasources = sharedDatasources; - } - - public List> getDatasourcesOfOthers() { - return datasourcesOfOthers; - } - - public void setDatasourcesOfOthers(List> datasourcesOfOthers) { - this.datasourcesOfOthers = datasourcesOfOthers; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/EventsPage.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/EventsPage.java deleted file mode 100644 index 1c1adee..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/EventsPage.java +++ /dev/null @@ -1,80 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - - -import java.util.List; - -/** - * Created by stefanos on 26/10/2016. - */ -public class EventsPage implements IsSerializable{ - - private String datasource; - private String topic; - private long currPage; - private long totalPages; - private long total; - private List values; - - public EventsPage() { - - } - public EventsPage(final String datasource, final String topic, final long currPage, final long totalPages, final long total, - final List values) { - this.datasource = datasource; - this.topic = topic; - this.currPage = currPage; - this.totalPages = totalPages; - this.total = total; - this.values = values; - } - - public String getDatasource() { - return datasource; - } - - public void setDatasource(String datasource) { - this.datasource = datasource; - } - - public String getTopic() { - return topic; - } - - public void setTopic(String topic) { - this.topic = topic; - } - - public long getCurrPage() { - return currPage; - } - - public void setCurrPage(long currPage) { - this.currPage = currPage; - } - - public long getTotalPages() { - return totalPages; - } - - public void setTotalPages(long totalPages) { - this.totalPages = totalPages; - } - - public long getTotal() { - return total; - } - - public void setTotal(long total) { - this.total = total; - } - - public List getValues() { - return values; - } - - public void setValues(List values) { - this.values = values; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/ExternalReference.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/ExternalReference.java deleted file mode 100644 index 8bdfff3..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/ExternalReference.java +++ /dev/null @@ -1,52 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by claudio on 22/07/16. - */ -public class ExternalReference implements IsSerializable { - - private String url; - - private String sitename; - - private String type; - - private String refidentifier; - - public ExternalReference() { - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getSitename() { - return sitename; - } - - public void setSitename(String sitename) { - this.sitename = sitename; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getRefidentifier() { - return refidentifier; - } - - public void setRefidentifier(String refidentifier) { - this.refidentifier = refidentifier; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Instance.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Instance.java deleted file mode 100644 index 6a8121e..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Instance.java +++ /dev/null @@ -1,52 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by claudio on 22/07/16. - */ -public class Instance implements IsSerializable { - - private String url; - - private String license; - - private String hostedby; - - private String instancetype; - - public Instance() { - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getLicense() { - return license; - } - - public void setLicense(String license) { - this.license = license; - } - - public String getHostedby() { - return hostedby; - } - - public void setHostedby(String hostedby) { - this.hostedby = hostedby; - } - - public String getInstancetype() { - return instancetype; - } - - public void setInstancetype(String instancetype) { - this.instancetype = instancetype; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Journal.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Journal.java deleted file mode 100644 index 4b11eb5..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Journal.java +++ /dev/null @@ -1,52 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by claudio on 22/07/16. - */ -public class Journal implements IsSerializable { - - private String name; - - private String issn; - - private String eissn; - - private String lissn; - - public Journal() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getIssn() { - return issn; - } - - public void setIssn(String issn) { - this.issn = issn; - } - - public String getEissn() { - return eissn; - } - - public void setEissn(String eissn) { - this.eissn = eissn; - } - - public String getLissn() { - return lissn; - } - - public void setLissn(String lissn) { - this.lissn = lissn; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/MapConditions.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/MapConditions.java deleted file mode 100644 index 9f8f72c..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/MapConditions.java +++ /dev/null @@ -1,52 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by stefanos on 17/3/2017. - */ -public class MapConditions implements IsSerializable { - - private String field; - private MapValueType fieldType; - private ConditionOperator operator; - private List listParams = new ArrayList<>(); - - public MapConditions() { - } - - public String getField() { - return field; - } - - public void setField(String field) { - this.field = field; - } - - public MapValueType getFieldType() { - return fieldType; - } - - public void setFieldType(MapValueType fieldType) { - this.fieldType = fieldType; - } - - public ConditionOperator getOperator() { - return operator; - } - - public void setOperator(ConditionOperator operator) { - this.operator = operator; - } - - public List getListParams() { - return listParams; - } - - public void setListParams(List listParams) { - this.listParams = listParams; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/MapValueType.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/MapValueType.java deleted file mode 100644 index 2abbc68..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/MapValueType.java +++ /dev/null @@ -1,10 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by stefanos on 17/3/2017. - */ -public enum MapValueType implements IsSerializable { - STRING, INTEGER, FLOAT, DATE, BOOLEAN, LIST_STRING, LIST_INTEGER, LIST_FLOAT, LIST_DATE, LIST_BOOLEAN; -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/NotificationFrequency.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/NotificationFrequency.java deleted file mode 100644 index e458d11..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/NotificationFrequency.java +++ /dev/null @@ -1,10 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by stefanos on 10-Mar-17. - */ -public enum NotificationFrequency implements IsSerializable { - never, realtime, daily, weekly, monthly -} \ No newline at end of file diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/NotificationMode.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/NotificationMode.java deleted file mode 100644 index 18c413d..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/NotificationMode.java +++ /dev/null @@ -1,10 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by stefanos on 10-Mar-17. - */ -public enum NotificationMode implements IsSerializable { - MOCK, EMAIL -} \ No newline at end of file diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/OpenAireEventPayload.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/OpenAireEventPayload.java deleted file mode 100644 index 6a63da9..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/OpenAireEventPayload.java +++ /dev/null @@ -1,52 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by claudio on 11/07/16. - */ -public class OpenAireEventPayload implements IsSerializable { - - private Publication publication; - - private Publication highlight; - - private Provenance provenance; - - private float trust; - - public OpenAireEventPayload() { - } - - public Publication getPublication() { - return publication; - } - - public void setPublication(Publication publication) { - this.publication = publication; - } - - public Publication getHighlight() { - return highlight; - } - - public void setHighlight(Publication highlight) { - this.highlight = highlight; - } - - public Provenance getProvenance() { - return provenance; - } - - public void setProvenance(Provenance provenance) { - this.provenance = provenance; - } - - public float getTrust() { - return trust; - } - - public void setTrust(float trust) { - this.trust = trust; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/OpenaireSubscription.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/OpenaireSubscription.java deleted file mode 100644 index 89350c1..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/OpenaireSubscription.java +++ /dev/null @@ -1,61 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by stefanos on 10-Mar-17. - */ - -public class OpenaireSubscription implements IsSerializable { - - private String subscriber; - private NotificationFrequency frequency; - private NotificationMode mode; - private AdvQueryObject query; - - public OpenaireSubscription() { - } - - public OpenaireSubscription(final String subscriber, final NotificationFrequency frequency, final - NotificationMode mode, - final AdvQueryObject query) { - this.subscriber = subscriber; - this.frequency = frequency; - this.mode = mode; - this.query = query; - } - - public String getSubscriber() { - return this.subscriber; - } - - public void setSubscriber(final String subscriber) { - this.subscriber = subscriber; - } - - public NotificationFrequency getFrequency() { - return this.frequency; - } - - public void setFrequency(final NotificationFrequency frequency) { - this.frequency = frequency; - } - - public NotificationMode getMode() { - return this.mode; - } - - public void setMode(final NotificationMode mode) { - this.mode = mode; - } - - public AdvQueryObject getQuery() { - return this.query; - } - - public void setQuery(final AdvQueryObject query) { - this.query = query; - } - - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Pid.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Pid.java deleted file mode 100644 index 9889b9e..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Pid.java +++ /dev/null @@ -1,32 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by claudio on 22/07/16. - */ -public class Pid implements IsSerializable { - - private String value; - - private String type; - - public Pid() { - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Project.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Project.java deleted file mode 100644 index fb99116..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Project.java +++ /dev/null @@ -1,73 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -public class Project implements IsSerializable { - - private String code; - private String acronym; - private String title; - private String funder; - private String fundingProgram; - private String jurisdiction; - - public Project() { - } - - public Project(final String code, final String acronym, final String title, final String funder, final String fundingProgram, final String jurisdiction) { - this.code = code; - this.acronym = acronym; - this.title = title; - this.funder = funder; - this.fundingProgram = fundingProgram; - this.jurisdiction = jurisdiction; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getAcronym() { - return acronym; - } - - public void setAcronym(String acronym) { - this.acronym = acronym; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getFunder() { - return funder; - } - - public void setFunder(String funder) { - this.funder = funder; - } - - public String getFundingProgram() { - return fundingProgram; - } - - public void setFundingProgram(String fundingProgram) { - this.fundingProgram = fundingProgram; - } - - public String getJurisdiction() { - return jurisdiction; - } - - public void setJurisdiction(String jurisdiction) { - this.jurisdiction = jurisdiction; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Provenance.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Provenance.java deleted file mode 100644 index 0a5936b..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Provenance.java +++ /dev/null @@ -1,42 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by claudio on 26/07/16. - */ -public class Provenance implements IsSerializable { - - private String repositoryName; - - private String url; - - private String id; - - public Provenance() { - } - - public String getRepositoryName() { - return repositoryName; - } - - public void setRepositoryName(String repositoryName) { - this.repositoryName = repositoryName; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Publication.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Publication.java deleted file mode 100644 index dbe9479..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Publication.java +++ /dev/null @@ -1,195 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.ArrayList; -import java.util.List; - -/** - * Created by claudio on 22/07/16. - */ -public class Publication implements IsSerializable { - - private String originalId; - - private List titles = new ArrayList<>(); - - private List abstracts = new ArrayList<>(); - - private String language; - - private List subjects = new ArrayList<>(); - - private List creators = new ArrayList<>(); - - private String publicationdate; - - private String publisher; - - private String embargoenddate; - - private List contributor = new ArrayList<>(); - - private Journal journal; - - private List collectedFrom = new ArrayList<>(); - - private List pids = new ArrayList<>(); - - private List instances = new ArrayList<>(); - - private List externalReferences = new ArrayList<>(); - - private List projects = new ArrayList<>(); - - private List publications = new ArrayList<>(); - - private List datasets = new ArrayList<>(); - - public Publication() { - } - - public String getOriginalId() { - return originalId; - } - - public void setOriginalId(String originalId) { - this.originalId = originalId; - } - - public List getTitles() { - return titles; - } - - public void setTitles(List titles) { - this.titles = titles; - } - - public List getAbstracts() { - return abstracts; - } - - public void setAbstracts(List abstracts) { - this.abstracts = abstracts; - } - - public String getLanguage() { - return language; - } - - public void setLanguage(String language) { - this.language = language; - } - - public List getSubjects() { - return subjects; - } - - public void setSubjects(List subjects) { - this.subjects = subjects; - } - - public List getCreators() { - return creators; - } - - public void setCreators(List creators) { - this.creators = creators; - } - - public String getPublicationdate() { - return publicationdate; - } - - public void setPublicationdate(String publicationdate) { - this.publicationdate = publicationdate; - } - - public String getPublisher() { - return publisher; - } - - public void setPublisher(String publisher) { - this.publisher = publisher; - } - - public String getEmbargoenddate() { - return embargoenddate; - } - - public void setEmbargoenddate(String embargoenddate) { - this.embargoenddate = embargoenddate; - } - - public List getContributor() { - return contributor; - } - - public void setContributor(List contributor) { - this.contributor = contributor; - } - - public Journal getJournal() { - return journal; - } - - public void setJournal(Journal journal) { - this.journal = journal; - } - - public List getCollectedFrom() { - return collectedFrom; - } - - public void setCollectedFrom(List collectedFrom) { - this.collectedFrom = collectedFrom; - } - - public List getPids() { - return pids; - } - - public void setPids(List pids) { - this.pids = pids; - } - - public List getInstances() { - return instances; - } - - public void setInstances(List instances) { - this.instances = instances; - } - - public List getExternalReferences() { - return externalReferences; - } - - public void setExternalReferences(List externalReferences) { - this.externalReferences = externalReferences; - } - - public List getProjects() { - return projects; - } - - public void setProjects(List projects) { - this.projects = projects; - } - - public List getDatasets() { - return datasets; - } - - public void setDatasets(List datasets) { - this.datasets = datasets; - } - - public List getPublications() { - return publications; - } - - public void setPublications(List publications) { - this.publications = publications; - } -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Range.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Range.java deleted file mode 100644 index 4878c9b..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Range.java +++ /dev/null @@ -1,38 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * Created by stefanos on 26/10/2016. - */ -public class Range implements IsSerializable { - - private String min; - private String max; - - public Range() { - } - - public Range(final String min, final String max) { - super(); - this.min = min; - this.max = max; - } - - public String getMin() { - return this.min; - } - - public void setMin(final String min) { - this.min = min; - } - - public String getMax() { - return this.max; - } - - public void setMax(final String max) { - this.max = max; - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/SimpleSubscriptionDesc.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/SimpleSubscriptionDesc.java deleted file mode 100644 index 508ed08..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/SimpleSubscriptionDesc.java +++ /dev/null @@ -1,76 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.Date; - -/** - * Created by stefanos on 10-Mar-17. - */ -public class SimpleSubscriptionDesc implements IsSerializable { - - private String id; - private String datasource; - private String topic; - private long count; - private Date creationDate; - private Date lastNotificationDate; - - public SimpleSubscriptionDesc() { - } - - public SimpleSubscriptionDesc(final String id, final String datasource, final String topic, final long count) { - this.id = id; - this.datasource = datasource; - this.topic = topic; - this.count = count; - } - - public String getId() { - return this.id; - } - - public void setId(final String id) { - this.id = id; - } - - public String getDatasource() { - return this.datasource; - } - - public void setDatasource(final String datasource) { - this.datasource = datasource; - } - - public String getTopic() { - return this.topic; - } - - public void setTopic(final String topic) { - this.topic = topic; - } - - public long getCount() { - return this.count; - } - - public void setCount(final long count) { - this.count = count; - } - - public Date getCreationDate() { - return creationDate; - } - - public void setCreationDate(Date creationDate) { - this.creationDate = creationDate; - } - - public Date getLastNotificationDate() { - return lastNotificationDate; - } - - public void setLastNotificationDate(Date lastNotificationDate) { - this.lastNotificationDate = lastNotificationDate; - } -} \ No newline at end of file diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Subscription.java b/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Subscription.java deleted file mode 100644 index 273648c..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/shared/broker/Subscription.java +++ /dev/null @@ -1,109 +0,0 @@ -package eu.dnetlib.repo.manager.shared.broker; - -/** - * Created by stefanos on 10-Mar-17. - */ - - -import com.google.gwt.user.client.rpc.IsSerializable; - -import java.util.Date; -import java.util.List; - - -public class Subscription implements IsSerializable { - - private String subscriptionId; - - private String subscriber; - - private String topic; - - private NotificationFrequency frequency; - - private NotificationMode mode; - - private Date lastNotificationDate; - - private Date creationDate; - - private String conditions; - - private List conditionsAsList; - - public Subscription() { - } - - public String getSubscriptionId() { - return subscriptionId; - } - - public void setSubscriptionId(String subscriptionId) { - this.subscriptionId = subscriptionId; - } - - public String getSubscriber() { - return subscriber; - } - - public void setSubscriber(String subscriber) { - this.subscriber = subscriber; - } - - public String getTopic() { - return topic; - } - - public void setTopic(String topic) { - this.topic = topic; - } - - public NotificationFrequency getFrequency() { - return frequency; - } - - public void setFrequency(NotificationFrequency frequency) { - this.frequency = frequency; - } - - public NotificationMode getMode() { - return mode; - } - - public void setMode(NotificationMode mode) { - this.mode = mode; - } - - public Date getLastNotificationDate() { - return lastNotificationDate; - } - - public void setLastNotificationDate(Date lastNotificationDate) { - this.lastNotificationDate = lastNotificationDate; - } - - public String getConditions() { - return conditions; - } - - public void setConditions(String conditions) { - this.conditions = conditions; - } - - public List getConditionsAsList() { - return conditionsAsList; - } - - public void setConditionsAsList(List conditionsAsList) { - this.conditionsAsList = conditionsAsList; - } - - public Date getCreationDate() { - return creationDate; - } - - public void setCreationDate(Date creationDate) { - this.creationDate = creationDate; - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/utils/Converter.java b/trunk/src/main/java/eu/dnetlib/repo/manager/utils/Converter.java deleted file mode 100644 index 9eae9c0..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/utils/Converter.java +++ /dev/null @@ -1,406 +0,0 @@ -package eu.dnetlib.repo.manager.utils; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import eu.dnetlib.domain.data.PiwikInfo; -import eu.dnetlib.domain.data.Repository; -import eu.dnetlib.domain.data.RepositoryInterface; -import eu.dnetlib.repo.manager.domain.RepositorySnippet; -import eu.dnetlib.repo.manager.shared.AggregationDetails; -import eu.dnetlib.repo.manager.shared.Timezone; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.log4j.Logger; -import org.json.JSONArray; -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.*; - -public class Converter { - - private static final Logger LOGGER = Logger.getLogger(Converter.class); - - public static Repository jsonToRepositoryObject(JSONObject repositoryObject) throws JSONException { - - Repository repository = new Repository(); - - JSONObject datasource = repositoryObject.getJSONObject("datasource"); - - //if( datasource.equals(null)) - // return null; - - repository.setId(datasource.get("id").toString()); - repository.setOfficialName(datasource.get("officialname").toString()); - - repository.setEnglishName( datasource.get("englishname").toString()); - if(repository.getEnglishName().equals("null")) - repository.setEnglishName(""); - - repository.setWebsiteUrl(datasource.get("websiteurl").toString()); - if(repository.getWebsiteUrl().equals("null")) - repository.setWebsiteUrl(""); - - repository.setLogoUrl(datasource.get("logourl").toString()); - if(repository.getLogoUrl().equals("null")) - repository.setLogoUrl(""); - - repository.setContactEmail(datasource.get("contactemail").toString()); - if(repository.getContactEmail().equals("null")) - repository.setContactEmail(""); - - - repository.setLatitude( toDouble(datasource.get("latitude").toString())); - repository.setLongitude(toDouble(datasource.get("longitude").toString())); - Double timezone = toDouble(datasource.get("timezone").toString()); - repository.setTimezone(timezone!=null?timezone:0.0); - repository.setNamespacePrefix(datasource.get("namespaceprefix").toString()); - repository.setOdLanguages(datasource.get("languages").toString()); - repository.setDateOfValidation(convertStringToDate( datasource.get("dateofvalidation").toString())); - - /* typology -> platform - * datasource class -> typology */ - repository.setTypology(datasource.get("platform").toString()); - if(repository.getTypology().equals("null")) - repository.setTypology(""); - repository.setDatasourceClass(datasource.get("typology").toString()); - - repository.setDateOfCollection(convertStringToDate( datasource.get("dateofcollection").toString())); - repository.setActivationId(datasource.get("activationId").toString()); - - repository.setDescription(datasource.get("description").toString()); - if(repository.getDescription().equals("null")) - repository.setDescription(""); - - repository.setIssn(datasource.get("issn").toString()); - repository.setLissn(datasource.get("lissn").toString()); - if(repository.getLissn().equals("null")) - repository.setLissn(""); - repository.setEissn(datasource.get("eissn").toString()); - if(repository.getEissn().equals("null")) - repository.setEissn(""); - repository.setRegisteredBy(datasource.get("registeredby").toString()); - - /* managed field */ - repository.setRegistered(Boolean.parseBoolean(datasource.get("managed").toString())); - - //subjects - - repository.setAggregator(datasource.get("aggregator").toString()); - repository.setCollectedFrom(datasource.get("collectedfrom").toString()); - - //TODO change organization to list - JSONArray organizations = ((JSONArray)datasource.get("organizations")); - if(organizations.length() != 0) { - repository.setOrganization(((JSONArray) datasource.get("organizations")).getJSONObject(0).get("legalname").toString()); - String countryCode = ((JSONArray) datasource.get("organizations")).getJSONObject(0).get("country").toString(); - repository.setCountryCode(countryCode); - } - - /* identities field */ - - return repository; - } - - public static Date convertStringToDate(String date){ - - if(Objects.equals(date, "null")) - return null; - - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - try { - return formatter.parse(date); - } catch (ParseException e) { - LOGGER.error(e); - } - return null; - } - - public static String convertDateToString(Date date){ - - if(Objects.equals(date, null)) - return null; - - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - return formatter.format(date); - } - - public static Double toDouble(String number){ - if(Objects.equals(number, "null")) - return 0.0; - else - return Double.valueOf(number); - } - - public static List jsonToRepositorySnippetList(JSONObject json) throws JSONException { - - List resultSet = new ArrayList<>(); - JSONArray rs = json.getJSONArray("datasourceInfo"); - for(int i=0;i jsonToRepositoryList(JSONObject json) throws JSONException { - - List resultSet = new ArrayList<>(); - JSONArray rs = json.getJSONArray("datasourceInfo"); - for(int i=0;i jsonToRepositoryInterfaceList(JSONObject json) throws JSONException { - - List resultSet = new ArrayList<>(); - JSONArray rs = json.getJSONArray("api"); - for(int i=0;i accessParams = new HashMap<>(); - Map extraFields = new HashMap<>(); - - ObjectMapper mapper = new ObjectMapper(); - JSONArray apiparams = repositoryInterfaceObject.getJSONArray("apiParams"); - - for(int i=0;i repositoryMap = new HashMap<>(); - ObjectMapper mapper = new ObjectMapper(); - - repositoryMap.put("id",repository.getId()); - repositoryMap.put("openaireId",getOpenaireId(repository.getId())); - repositoryMap.put("officialname",repository.getOfficialName()); - repositoryMap.put("englishname",repository.getEnglishName()); - repositoryMap.put("websiteurl",repository.getWebsiteUrl()); - repositoryMap.put("logourl",repository.getLogoUrl()); - repositoryMap.put("contactemail",repository.getContactEmail()); - repositoryMap.put("longitude",repository.getLongitude().toString()); - repositoryMap.put("latitude",repository.getLatitude().toString()); - repositoryMap.put("timezone",repository.getTimezone()); - - repositoryMap.put("namespaceprefix",repository.getNamespacePrefix()!=null?repository.getNamespacePrefix():""); - repositoryMap.put("languages",repository.getOdLanguages()!=null?repository.getOdLanguages():""); - - repositoryMap.put("dateofcollection",repository.getDateOfCollection()!=null?convertDateToString(repository.getDateOfCollection()):""); - - /* - * typology -> platform - * datasource class -> typology - * */ - repositoryMap.put("typology",repository.getDatasourceClass()); - repositoryMap.put("platform",repository.getTypology()); - - repositoryMap.put("dateofvalidation",repository.getDateOfCollection()!=null?convertDateToString(repository.getDateOfCollection()):""); - repositoryMap.put("activationId",repository.getActivationId()!=null?repository.getActivationId():""); - - repositoryMap.put("description",repository.getDescription()); - - repositoryMap.put("eissn",repository.getEissn()!=null?repository.getEissn():""); - repositoryMap.put("issn",repository.getIssn()!=null?repository.getIssn():""); - repositoryMap.put("lissn",repository.getLissn()!=null?repository.getLissn():""); - - repositoryMap.put("registeredby",repository.getRegisteredBy()); - - repositoryMap.put("aggregator",repository.getAggregator()!=null?repository.getAggregator():""); - repositoryMap.put("collectedfrom",repository.getCollectedFrom()!=null?repository.getCollectedFrom():""); - - repositoryMap.put("managed",repository.isRegistered()); - - Map organization = new HashMap<>(); - organization.put("legalname",repository.getOrganization()); - organization.put("country",repository.getCountryCode()); - organization.put("legalshortname",""); - organization.put("websiteurl",""); - organization.put("logourl",""); - - List organizations = new ArrayList(); - organizations.add(organization); - repositoryMap.put("organizations",organizations); - - //TODO check identitites - //Map identity = new HashMap<>(); - - if (repository.getPiwikInfo() != null) { - Map identity = new HashMap<>(); - HashSet> identities = new HashSet<>(); - - identity.put("issuertype", "piwik"); - identity.put("pid", "piwik:" + repository.getPiwikInfo().getSiteId()); - - identities.add(identity); - - repositoryMap.put("identities", identities); - } - - repositoryMap.put("subjects",""); - - return mapper.writeValueAsString(repositoryMap); - } - - public static String repositoryInterfaceObjectToJson(Repository repository,RepositoryInterface repositoryInterface) throws JSONException { - - JSONObject jsonObject = new JSONObject(); - - jsonObject.put("id",repositoryInterface.getId()); - jsonObject.put("protocol",repositoryInterface.getAccessProtocol()); - jsonObject.put("datasource",repository.getId()); - jsonObject.put("contentdescription",repositoryInterface.getContentDescription()); - jsonObject.put("typology",repositoryInterface.getTypology()); - jsonObject.put("compatibility",repositoryInterface.getDesiredCompatibilityLevel()); - jsonObject.put("compatibilityOverride",repositoryInterface.getDesiredCompatibilityLevel()); - - jsonObject.put("lastCollectionTotal",""); - - jsonObject.put("lastCollectionDate",repositoryInterface.getLastCollectionDate()); - jsonObject.put("lastAggregationTotal",""); - jsonObject.put("lastAggregationDate",""); - jsonObject.put("lastDownloadTotal",""); - jsonObject.put("lastDownloadDate",""); - - jsonObject.put("baseurl",repositoryInterface.getBaseUrl()); - jsonObject.put("removable",repositoryInterface.isRemovable()); - - - JSONArray apiparams = new JSONArray(); - for(String param: repositoryInterface.getAccessParams().keySet()){ - JSONObject jo = new JSONObject(); - jo.put("param",param); - jo.put("value",repositoryInterface.getAccessParams().get(param)); - apiparams.put(jo); - } - jsonObject.put("apiParams",apiparams); - - -// jsonObject.put("metadataIdentifierPath",repositoryInterface.getMetadataIdentifierPath()); - - - return jsonObject.toString(); - } - - public static ArrayList readFile(String filename) { - String line; - ArrayList list = new ArrayList(); - try { - //InputStream in = Converter.class.getResourceAsStream("resources/eu/dnetlib/repo/manager/service/utils/"+filename); - InputStream in = Converter.class.getClass().getResourceAsStream("/eu/**/" + filename); - BufferedReader br = new BufferedReader(new InputStreamReader(in)); - while((line = br.readLine()) != null) { - list.add(line.trim()); - } - br.close(); - } catch (IOException e) { - LOGGER.debug("Error opening file!"); - LOGGER.error(e); - } - return list; - } - - public static List getAggregationHistoryFromJson(JSONObject datasourceInfo) throws JSONException { - JSONArray rs; - List aggregationDetailsList = new ArrayList<>(); - - if (datasourceInfo.get("aggregationHistory") != null && !datasourceInfo.get("aggregationHistory").toString().equals("null")) { - rs = new JSONArray(datasourceInfo.get("aggregationHistory").toString()); - - for (int i = 0; i < rs.length(); i++) - aggregationDetailsList.add(jsonToAggregationDetails(rs.getJSONObject(i))); - } - - return aggregationDetailsList; - } - - private static AggregationDetails jsonToAggregationDetails(JSONObject aggregationObject) throws JSONException { - - AggregationDetails aggregationDetails = new AggregationDetails(); - - aggregationDetails.setAggregationStage(aggregationObject.get("aggregationStage").toString()); - if(aggregationObject.has("collectionMode")) - aggregationDetails.setCollectionMode(aggregationObject.get("collectionMode").toString()); - if(aggregationObject.has("indexedVersion")) - aggregationDetails.setIndexedVersion(Boolean.parseBoolean(aggregationObject.get("indexedVersion").toString())); - aggregationDetails.setDate(convertStringToDate(aggregationObject.get("date").toString())); - aggregationDetails.setNumberOfRecords(Integer.parseInt(aggregationObject.get("numberOfRecords").toString())); - return aggregationDetails; - } - - - public static List toTimezones(List timezones) { - - List tmz = new ArrayList<>(); - for(String t : timezones){ - String[] s = t.split("\t"); - tmz.add(new Timezone(s[1],Double.parseDouble(s[0]))); - } - return tmz; - } - - private static String getOpenaireId(String repositoryId) { - if (repositoryId != null && repositoryId.contains("::")) - return repositoryId.split("::")[0] + "::" + DigestUtils.md5Hex(repositoryId.split("::")[1]); - return null; - } - -} diff --git a/trunk/src/main/java/eu/dnetlib/repo/manager/utils/OaiTools.java b/trunk/src/main/java/eu/dnetlib/repo/manager/utils/OaiTools.java deleted file mode 100644 index 855042f..0000000 --- a/trunk/src/main/java/eu/dnetlib/repo/manager/utils/OaiTools.java +++ /dev/null @@ -1,146 +0,0 @@ -package eu.dnetlib.repo.manager.utils; - -import org.apache.log4j.Logger; -import org.dom4j.io.DOMWriter; -import org.w3c.dom.Document; -import se.kb.oai.pmh.*; -import se.kb.oai.pmh.Set; - -import javax.net.ssl.*; -import javax.xml.namespace.NamespaceContext; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.X509Certificate; -import java.util.*; - -public class OaiTools { - - { - disableSslVerification(); - } - - private static Logger LOGGER = Logger.getLogger(OaiTools.class); - - public static List getSetsOfRepo(String baseUrl) throws Exception { - try { - LOGGER.debug("Getting sets of repository " + baseUrl); - OaiPmhServer harvester = new OaiPmhServer(baseUrl); - SetsList setList = harvester.listSets(); - ResumptionToken token = setList.getResumptionToken(); - List sets = new ArrayList(); - sets.addAll(setList.asList()); - while (token != null) { - setList = harvester.listSets(token); - token = setList.getResumptionToken(); - sets.addAll(setList.asList()); - } - - List ret = new ArrayList(); - for (Set set : sets) { - ret.add(set.getSpec().trim()); - } - if (ret.size() > 0 ) - Collections.sort(ret); - return ret; - - } catch (Exception e) { - LOGGER.error("Error getting sets of repository " + baseUrl, e); - return new ArrayList(); - //throw e; - } - } - - public static boolean identifyRepository(String baseUrl) throws Exception { - LOGGER.debug("sending identify request to repo " + baseUrl); - - OaiPmhServer harvester = new OaiPmhServer(baseUrl); - - if (baseUrl.trim().isEmpty()) { - return false; - } - - try { - Identification identification = harvester.identify(); - DOMWriter d4Writer = new DOMWriter(); - Document d = d4Writer.write(identification.getResponse()); - - return verifyIdentify(d); - } catch (Exception e) { - LOGGER.debug("Error verifying identify response", e); - throw e; - } - } - - private static boolean verifyIdentify(Document doc) throws XPathExpressionException { - NamespaceContext ctx = new NamespaceContext() { - public String getNamespaceURI(String prefix) { - String uri; - if (prefix.equals("oai")) - uri = "http://www.openarchives.org/OAI/2.0/"; - else - uri = null; - return uri; - } - - // Dummy implementation - not used! - public Iterator getPrefixes(String val) { - return null; - } - - // Dummy implemenation - not used! - public String getPrefix(String uri) { - return null; - } - }; - - // Now the XPath expression - - String xpathStr = "//oai:OAI-PMH/oai:Identify"; - XPathFactory xpathFact = XPathFactory.newInstance(); - XPath xpath = xpathFact.newXPath(); - xpath.setNamespaceContext(ctx); - String result = xpath.evaluate(xpathStr, doc); - - return (result != null && !result.equals("")); - } - - private static void disableSslVerification() { - try - { - LOGGER.debug("disabling ssl verification"); - // Create a trust manager that does not validate certificate chains - TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() { - public X509Certificate[] getAcceptedIssuers() { - return null; - } - public void checkClientTrusted(X509Certificate[] certs, String authType) { - } - public void checkServerTrusted(X509Certificate[] certs, String authType) { - } - } - }; - - // Install the all-trusting trust manager - SSLContext sc = SSLContext.getInstance("SSL"); - sc.init(null, trustAllCerts, new java.security.SecureRandom()); - HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); - - // Create all-trusting host name verifier - HostnameVerifier allHostsValid = new HostnameVerifier() { - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; - - // Install the all-trusting host verifier - HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid); - } catch (NoSuchAlgorithmException e) { - LOGGER.error("disabling ssl verification", e); - } catch (KeyManagementException e) { - LOGGER.error("error while disabling ssl verification", e); - } - } -} diff --git a/trunk/src/main/resources/application-context.xml b/trunk/src/main/resources/application-context.xml deleted file mode 100644 index ae07910..0000000 --- a/trunk/src/main/resources/application-context.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - classpath*:/gr/**/springContext-*.properties - classpath*:/eu/**/springContext-*.properties - - classpath*:/application.properties - classpath*:email-texts.properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/trunk/src/main/resources/application.properties b/trunk/src/main/resources/application.properties deleted file mode 100644 index e5488e9..0000000 --- a/trunk/src/main/resources/application.properties +++ /dev/null @@ -1,89 +0,0 @@ -infrastructure.name=integration - -## Container properties -container.hostname=estella.athenarc.gr -container.context=uoa-repository-manager-service -container.port=8480 - -IS.url = https://dev-openaire.d4science.org/is/services -ISLookUpService.url = ${IS.url}/isLookUp -ISRegistryService.url = ${IS.url}/isRegistry -ISSNService.url = ${IS.url}/services/isSN - -#ValidatorService.url=http://88.197.53.69:8080/validator-service/services/validatorWebService -#ValidatorService.url=http://beta.services.openaire.eu/validator-service/services/validatorWebService -ValidatorService.url=http://localhost:8080/validator-service/services/validatorWebService - -services.provide.adminEmail=provide-admin@openaire.eu - -## Broker Service -services.broker.url = http://broker1-dev-dnet.d4science.org -services.broker.port = 8080 -services.broker.api = api/ -services.broker.openaire = openaireBroker - -#api.baseAddress=https://dev-openaire.d4science.org/openaire -api.baseAddress=http://beta.services.openaire.eu/openaire - -service.repository-rest-api.baseUrl =http://${container.hostname}:${container.port} -services.repo-manager.baseUrl = http://${container.hostname}:${container.port}/${container.context} - -transport.soap.baseAddress = http://${container.hostname}:${container.port}/${container.context} -transport.soap.force.local.address = false - - -validator.results.url=https://${container.hostname}:${container.port}/compatibility/browseHistory/ -services.repo-manager.adminEmail = antleb@di.uoa.gr -services.repo-manager.repository.testing.mode = false -services.repo-manager.deploy.environment = development -services.validator.mail.host = smtp.gmail.com -services.validator.mail.port = 465 -services.validator.mail.fromAddress = no-reply@openaire.eu -services.validator.mail.replyToAddress = no-reply@openaire.eu -services.validator.mail.username = test.openaire@gmail.com -services.validator.mail.password = ^($*@$)*!$ -services.validator.mail.authenticate = true -services.validator.mail.override = false -services.validator.mail.logonly = false -services.validator.mail.mode = ssl -services.validator.mail.debug = false -services.validator.mail.overrideEmail = antleb@di.uoa.gr -services.validator.mail.specialRecipients = antleb@di.uoa.gr - -services.validator.repoRegistration.override = antleb@di.uoa.gr - -repomanager.db.driverClassName = org.postgresql.Driver -repomanager.db.url = jdbc:postgresql://194.177.192.119:5432/repomanager -repomanager.db.username = dnet -repomanager.db.password = dnetPwd - -services.repomanager.analyticsURL = http://analytics.openaire.eu/addsite.php? - -topic_types.url = https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:topic_types.json - -oidc.issuer = https://aai.openaire.eu/oidc/ -oidc.id = 767422b9-5461-4807-a80a-f9a2072d3a7d -oidc.secret = AMQtGlbTXNjwjhF0st28LmM6V0XypMdaVS7tJmGuYFlmH36iIv4t7tVqYuLYrNPkhnZ_GPUJvhymBhFupdgb6aU - -oidc.dev.home = http://localhost:8480/uoa-repository-manager-service/openid_connect_login -webapp.dev.front = http://localhost:4200/landing - -##REDIS-AAI - -redis.host=estella.athenarc.gr -redis.port=6379 -redis.password=redis123 -aai.mode=develop - - -services.repomanager.usageStatisticsDiagramsBaseURL = https://beta.openaire.eu/stats3/ -services.repomanager.usageStatisticsNumbersBaseURL = https://beta.services.openaire.eu/usagestats/datasources/ -services.repomanager.usagestats.adminEmail = antleb@di.uoa.gr - -##SUSHI -services.repomanager.usagestats.sushiliteEndpoint = http://beta.services.openaire.eu/usagestats/sushilite/ - -##SEARCH API -search.api.baseAddress=https://beta.services.openaire.eu/search/v2/api -search.api.usagestats=https://services.openaire.eu/usagestats -search.api.usageEvents=http://beta.lbs.openaire.eu:8080/ajax/summary diff --git a/trunk/src/main/resources/email-texts.properties b/trunk/src/main/resources/email-texts.properties deleted file mode 100644 index b783daa..0000000 --- a/trunk/src/main/resources/email-texts.properties +++ /dev/null @@ -1,7 +0,0 @@ -user.registration.mail.subject = OpenAIRE Account Activation -user.registration.mail.message = Please follow this link to activate your account - -user.forgotPassword.mail.Subject = OpenAIRE Reset Password Request -user.forgotPassword.mail.Body1 = To complete your password reset please follow this link -user.forgotPassword.mail.Body2 = Security Code - diff --git a/trunk/src/main/resources/eu/dnetlib/repo/manager/service/countries.txt b/trunk/src/main/resources/eu/dnetlib/repo/manager/service/countries.txt deleted file mode 100644 index 656fd7d..0000000 --- a/trunk/src/main/resources/eu/dnetlib/repo/manager/service/countries.txt +++ /dev/null @@ -1,195 +0,0 @@ -Afghanistan -Albania -Algeria -Andorra -Angola -Antigua & Deps -Argentina -Armenia -Australia -Austria -Azerbaijan -Bahamas -Bahrain -Bangladesh -Barbados -Belarus -Belgium -Belize -Benin -Bhutan -Bolivia -Bosnia Herzegovina -Botswana -Brazil -Brunei -Bulgaria -Burkina -Burundi -Cambodia -Cameroon -Canada -Cape Verde -Central African Rep -Chad -Chile -China -Colombia -Comoros -Congo -Congo {Democratic Rep} -Costa Rica -Croatia -Cuba -Cyprus -Czech Republic -Denmark -Djibouti -Dominica -Dominican Republic -East Timor -Ecuador -Egypt -El Salvador -Equatorial Guinea -Eritrea -Estonia -Ethiopia -Fiji -Finland -France -Gabon -Gambia -Georgia -Germany -Ghana -Greece -Grenada -Guatemala -Guinea -Guinea-Bissau -Guyana -Haiti -Honduras -Hungary -Iceland -India -Indonesia -Iran -Iraq -Ireland {Republic} -Israel -Italy -Ivory Coast -Jamaica -Japan -Jordan -Kazakhstan -Kenya -Kiribati -Korea North -Korea South -Kosovo -Kuwait -Kyrgyzstan -Laos -Latvia -Lebanon -Lesotho -Liberia -Libya -Liechtenstein -Lithuania -Luxembourg -Macedonia -Madagascar -Malawi -Malaysia -Maldives -Mali -Malta -Marshall Islands -Mauritania -Mauritius -Mexico -Micronesia -Moldova -Monaco -Mongolia -Montenegro -Morocco -Mozambique -Myanmar, {Burma} -Namibia -Nauru -Nepal -Netherlands -New Zealand -Nicaragua -Niger -Nigeria -Norway -Oman -Pakistan -Palau -Panama -Papua New Guinea -Paraguay -Peru -Philippines -Poland -Portugal -Qatar -Romania -Russian Federation -Rwanda -St Kitts & Nevis -St Lucia -Saint Vincent & the Grenadines -Samoa -San Marino -Sao Tome & Principe -Saudi Arabia -Senegal -Serbia -Seychelles -Sierra Leone -Singapore -Slovakia -Slovenia -Solomon Islands -Somalia -South Africa -Spain -Sri Lanka -Sudan -Suriname -Swaziland -Sweden -Switzerland -Syria -Taiwan -Tajikistan -Tanzania -Thailand -Togo -Tonga -Trinidad & Tobago -Tunisia -Turkey -Turkmenistan -Tuvalu -Uganda -Ukraine -United Arab Emirates -United Kingdom -United States -Uruguay -Uzbekistan -Vanuatu -Vatican City -Venezuela -Vietnam -Yemen -Zambia -Zimbabwe \ No newline at end of file diff --git a/trunk/src/main/resources/eu/dnetlib/repo/manager/service/timezones.txt b/trunk/src/main/resources/eu/dnetlib/repo/manager/service/timezones.txt deleted file mode 100644 index 04f5f8a..0000000 --- a/trunk/src/main/resources/eu/dnetlib/repo/manager/service/timezones.txt +++ /dev/null @@ -1,11 +0,0 @@ --2.0 [GMT - 2] Fernando de Noronha Time, South Georg... --1.0 [GMT - 1] Azores Standard Time, Cape Verde Time... -0.0 [GMT] Western European Time, Greenwich Mean Time -1.0 [GMT + 1] Central European Time, West African Time -2.0 [GMT + 2] Eastern European Time, Central Africa... -3.0 [GMT + 3] Moscow Standard Time, Eastern African... -3.5 [GMT + 3:30] Iran Standard Time -4.0 [GMT + 4] Gulf Standard Time, Samara Standard Time -4.5 [GMT + 4:30] Afghanistan Time -5.0 [GMT + 5] Pakistan Standard Time, Yekaterinburg... -8.0 [GMT + 8] Beijing, Hong Kong, Irkutsk, Kuala Lumpur, Manila, Perth \ No newline at end of file diff --git a/trunk/src/main/resources/eu/dnetlib/repo/manager/service/typologies.txt b/trunk/src/main/resources/eu/dnetlib/repo/manager/service/typologies.txt deleted file mode 100644 index eba3776..0000000 --- a/trunk/src/main/resources/eu/dnetlib/repo/manager/service/typologies.txt +++ /dev/null @@ -1,42 +0,0 @@ -CONTENTdm -Digibib -Digital Commons -DigiTool -DIVA -Diva-Portal -dLibra -Doks -Drupal -DSpace -Earmas -EPrints -ETD -ETD-db -Fedora -Fez -Greenstone -HAL -invenio -MyCoRe -Open Repository -OPUS -Pica-Verbundkatalog -Proprietary Software -PUMA -PURE -SciELO -SFIX -VITAL -VTOAI -WEKO -XooNIps ------------------------- -OJS -HyperJournal -ePubTk -GAPworks -DPubS -E-Journal ------------------------- -[Other] - diff --git a/trunk/src/main/webapp/WEB-INF/aai-security.xml b/trunk/src/main/webapp/WEB-INF/aai-security.xml deleted file mode 100644 index 93d14e7..0000000 --- a/trunk/src/main/webapp/WEB-INF/aai-security.xml +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - openid - - - - - - ${oidc.dev.home} - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/trunk/src/main/webapp/WEB-INF/applicationContext.xml b/trunk/src/main/webapp/WEB-INF/applicationContext.xml deleted file mode 100644 index 72ee304..0000000 --- a/trunk/src/main/webapp/WEB-INF/applicationContext.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - classpath*:/gr/**/springContext-*.properties - classpath*:/eu/**/springContext-*.properties - - classpath*:/application.properties - classpath*:/email-texts.properties - - classpath*:dnet-site-wizard.properties - classpath*:dnet-site-override.properties - classpath*:dnet-wizard.properties - classpath*:dnet-override.properties - classpath*:dnet-validator-wizard.properties - classpath*:dnet-validator-override.properties - classpath*:dnet-site-force-override.properties - classpath*:dnet-force-override.properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/trunk/src/main/webapp/WEB-INF/log4j.properties b/trunk/src/main/webapp/WEB-INF/log4j.properties deleted file mode 100644 index c1839f3..0000000 --- a/trunk/src/main/webapp/WEB-INF/log4j.properties +++ /dev/null @@ -1,24 +0,0 @@ -log4j.rootLogger = WARN, R - -log4j.logger.eu.dnetlib = INFO -log4j.logger.eu.dnetlib.repo.manager = INFO -log4j.logger.eu.dnetlib.clients.data.datasourcemanager.ws.Converter = FATAL - -log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack = FATAL -log4j.logger.com.opensymphony.xwork2.ObjectFactory = FATAL - -log4j.appender.R=org.apache.log4j.RollingFileAppender -log4j.appender.R.File=/tmp/repository-service.log -#log4j.appender.R.File=/var/log/tomcat_dnet/8780/repository-service.log -log4j.appender.R.MaxFileSize=10MB -log4j.appender.R.MaxBackupIndex=10 -log4j.appender.R.layout=org.apache.log4j.PatternLayout -log4j.appender.R.layout.ConversionPattern= %d %p %t [%c] - %m%n - -log4j.appender.S=org.apache.log4j.RollingFileAppender -log4j.appender.S.File=/tmp/repository-service-spring.log -#log4j.appender.S.File=/var/log/tomcat_dnet/8780/repository-service-spring.log -log4j.appender.S.MaxFileSize=10MB -log4j.appender.S.MaxBackupIndex=10 -log4j.appender.S.layout=org.apache.log4j.PatternLayout -log4j.appender.S.layout.ConversionPattern= %d %p %t [%c] - %m%n \ No newline at end of file diff --git a/trunk/src/main/webapp/WEB-INF/spring-servlet.xml b/trunk/src/main/webapp/WEB-INF/spring-servlet.xml deleted file mode 100644 index d8964ef..0000000 --- a/trunk/src/main/webapp/WEB-INF/spring-servlet.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/trunk/src/main/webapp/WEB-INF/web.xml b/trunk/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index ec73e02..0000000 --- a/trunk/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - org.springframework.web.context.ContextLoaderListener - - - org.springframework.web.util.Log4jConfigListener - - - - - - contextConfigLocation - - /WEB-INF/applicationContext.xml - /WEB-INF/aai-security.xml - - - - log4jConfigLocation - /WEB-INF/log4j.properties - - - log4jRefreshInterval - 1000 - - - log4jExposeWebAppRoot - false - - - - spring - - org.springframework.web.servlet.DispatcherServlet - - - throwExceptionIfNoHandlerFound - true - - 1 - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - contextAttribute - org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring - - - - - CorsFilter - org.apache.catalina.filters.CorsFilter - - cors.allowed.origins - * - - - cors.allowed.headers - Content-Type,X-Requested-With,accept,authorization,Origin,Access-Control-Request-Method,Access-Control-Request-Headers - - - cors.allowed.methods - GET, POST, PUT, DELETE, OPTIONS, HEAD - - - - - CorsFilter - /* - - - - springSessionRepositoryFilter - org.springframework.web.filter.DelegatingFilterProxy - - - springSessionRepositoryFilter - /* - REQUEST - ERROR - - - - springSecurityFilterChain - /* - - - - spring - / - - diff --git a/trunk/src/test/java/unitest/PiwikTest.java b/trunk/src/test/java/unitest/PiwikTest.java deleted file mode 100644 index 3b55e6b..0000000 --- a/trunk/src/test/java/unitest/PiwikTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* -package unitest; - -import com.fasterxml.jackson.databind.ObjectMapper; -import eu.dnetlib.repo.manager.config.RepoManagerContextLoaderListener; -import org.apache.commons.lang.StringEscapeUtils; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.net.URLEncoder; -import java.util.Map; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = RepoManagerContextLoaderListener.class) -public class PiwikTest { - - String analyticsURL = "https://analytics.openaire.eu/addsite.php?"; - - @Test - public void enableMetricsRepo1(){ - - String officialName = "BỘ SƯU TẬP SỐ"; - String repoWebsite = "http://www.vnulib.edu.vn:8000/dspace/"; - - enableMetrics(officialName, repoWebsite, analyticsURL); - - } - - @Test - public void enableMetricsRepo2(){ - - String officialName = "ILC4CLARIN repository of language resources and tools"; - String repoWebsite = "https://dspace-clarin-it.ilc.cnr.it/repository/xmlui"; - - enableMetrics(officialName, repoWebsite, analyticsURL); - } - - @Test - public void enableMetricsRepo3(){ - - String officialName = "ANSTO Publications Online"; - String repoWebsite = "http://apo.ansto.gov.au/dspace/"; - - enableMetrics(officialName, repoWebsite, analyticsURL); - } - - private void enableMetrics(String officialName, String repoWebsite, String analyticsURL) { - String url; - try { - url = analyticsURL + "siteName=" + URLEncoder.encode(officialName, "UTF-8") + "&url=" - + URLEncoder.encode(repoWebsite, "UTF-8"); - url = StringEscapeUtils.escapeJava(url); - - Map map = null; - String siteId = null; - - URL u = new URL(url); - map = new ObjectMapper().readValue(u, Map.class); - if(map.get("value")!=null) { - siteId = map.get("value").toString(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } -}*/ diff --git a/trunk/src/test/java/unitest/ValidatorTest.java b/trunk/src/test/java/unitest/ValidatorTest.java deleted file mode 100644 index 3c5ce65..0000000 --- a/trunk/src/test/java/unitest/ValidatorTest.java +++ /dev/null @@ -1,31 +0,0 @@ -//package unitest; -// -//import eu.dnetlib.repo.manager.config.RepoManagerContextLoaderListener; -//import eu.dnetlib.repo.manager.utils.OaiTools; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.springframework.test.context.ContextConfiguration; -//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -// -//@RunWith(SpringJUnit4ClassRunner.class) -//@ContextConfiguration(classes = RepoManagerContextLoaderListener.class) -////@WebAppConfiguration -//public class ValidatorTest { -// -// -// @Test -// public void identiFy(){ -// -// String url = "https://repozitorij.srce.unizg.hr/oai"; -// -// -// System.out.println("Identify repository with url : " + url); -// try { -// System.out.println(OaiTools.identifyRepository(url)); -// } catch (Exception e) { -// System.out.println(e); -// } -// } -// -// -//} diff --git a/trunk/src/test/resources/application-context.xml b/trunk/src/test/resources/application-context.xml deleted file mode 100644 index 5684b24..0000000 --- a/trunk/src/test/resources/application-context.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - classpath*:/gr/**/springContext-*.properties - classpath*:/eu/**/springContext-*.properties - - classpath*:/application.properties - classpath*:/email-texts.properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/trunk/src/test/resources/applicationContext.xml b/trunk/src/test/resources/applicationContext.xml deleted file mode 100644 index c5a6bc1..0000000 --- a/trunk/src/test/resources/applicationContext.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - classpath*:/gr/**/springContext-*.properties - classpath*:/eu/**/springContext-*.properties - - classpath*:/application.properties - classpath*:/email-texts.properties - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file