Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
Ioannis Diplas | cba5f4ec17 | |
Ioannis Diplas | ee78250918 | |
Ioannis Diplas | 22605ad0ad |
150
pom.xml
150
pom.xml
|
@ -176,20 +176,12 @@
|
|||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/cz.habarta.typescript-generator/typescript-generator-maven-plugin -->
|
||||
<!--<dependency>
|
||||
<groupId>cz.habarta.typescript-generator</groupId>
|
||||
<artifactId>typescript-generator-maven-plugin</artifactId>
|
||||
<version>1.29.366</version>
|
||||
</dependency>-->
|
||||
<!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
|
||||
<dependency>
|
||||
<groupId>postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>9.1-901.jdbc3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-catalina -->
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
|
@ -246,39 +238,39 @@
|
|||
<version>1.1.5.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.ws</groupId>
|
||||
<artifactId>jaxws-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
|
||||
<dependency>
|
||||
<groupId>javax.jws</groupId>
|
||||
<artifactId>javax.jws-api</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core -->
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1-rev-1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.ws</groupId>
|
||||
<artifactId>jaxws-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
|
||||
<dependency>
|
||||
<groupId>javax.jws</groupId>
|
||||
<artifactId>javax.jws-api</artifactId>
|
||||
<version>1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core -->
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-core</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1-rev-1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
@ -304,82 +296,6 @@
|
|||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<!--<plugin>-->
|
||||
<!--<groupId>com.googlecode.maven-download-plugin</groupId>-->
|
||||
<!--<artifactId>download-maven-plugin</artifactId>-->
|
||||
<!--<version>1.3.0</version>-->
|
||||
<!--<executions>-->
|
||||
<!--<execution>-->
|
||||
<!--<phase>process-resources</phase>-->
|
||||
<!--<goals>-->
|
||||
<!--<goal>wget</goal>-->
|
||||
<!--</goals>-->
|
||||
<!--<configuration>-->
|
||||
<!--<url>-->
|
||||
<!--https://github.com/ostranme/swagger-ui-themes/archive/v3.0.0.zip-->
|
||||
<!--</url>-->
|
||||
<!--<unpack>true</unpack>-->
|
||||
<!--<outputDirectory>${project.build.directory}</outputDirectory>-->
|
||||
<!--</configuration>-->
|
||||
<!--</execution>-->
|
||||
<!--</executions>-->
|
||||
<!--</plugin>-->
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.8</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<sequential>
|
||||
<echo>Add theme</echo>
|
||||
<replace token="</head>"
|
||||
value="<link href='webjars/springfox-swagger-ui/themes/2.x/theme-feeling-blue.css' rel="stylesheet"/></head>"
|
||||
dir="${settings.localRepository}/io/springfox/springfox-swagger-ui/2.7.0/META-INF/resources">
|
||||
<include name="swagger-ui.html"/>
|
||||
</replace>
|
||||
</sequential>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
-->
|
||||
|
||||
<!--<plugin>
|
||||
<groupId>cz.habarta.typescript-generator</groupId>
|
||||
<artifactId>typescript-generator-maven-plugin</artifactId>
|
||||
<version>1.29.366</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate1</id>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<jsonLibrary>jackson2</jsonLibrary>
|
||||
<outputFileType>implementationFile</outputFileType>
|
||||
<mapClasses>asClasses</mapClasses>
|
||||
<classPatterns>
|
||||
<pattern>eu.dnetlib.domain.data.*</pattern>
|
||||
</classPatterns>
|
||||
<outputFile>target/typeScriptClasses.ts</outputFile>
|
||||
<outputKind>module</outputKind>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>-->
|
||||
</plugins>
|
||||
<finalName>uoa-repository-manager-service</finalName>
|
||||
<resources>
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
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;
|
||||
|
@ -38,18 +36,12 @@ public class CascadingPropertyLoader extends PropertyPlaceholderConfigurer imple
|
|||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(final Properties properties) {
|
||||
super.setProperties(properties);
|
||||
|
||||
this.properties = properties;
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ import javax.annotation.PostConstruct;
|
|||
@ComponentScan(basePackages = "eu.dnetlib.repo.manager.*")
|
||||
public class Config {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(Config.class);
|
||||
private static Logger logger = Logger.getLogger(Config.class);
|
||||
|
||||
@Value("${redis.host:194.177.192.121}")
|
||||
private String host;
|
||||
|
@ -34,16 +34,16 @@ public class Config {
|
|||
private String password;
|
||||
|
||||
@Value("${aai.mode}")
|
||||
private String aai_mode;
|
||||
private String aaiMode;
|
||||
|
||||
@PostConstruct
|
||||
private void init(){
|
||||
LOGGER.info(host);
|
||||
logger.info(host);
|
||||
}
|
||||
|
||||
@Bean
|
||||
JedisConnectionFactory connectionFactory() {
|
||||
LOGGER.info(String.format("Redis : %s Port : %s Password : %s",host,port,password));
|
||||
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));
|
||||
|
@ -56,10 +56,9 @@ public class Config {
|
|||
DefaultCookieSerializer serializer = new DefaultCookieSerializer();
|
||||
serializer.setCookieName("openAIRESession");
|
||||
serializer.setCookiePath("/");
|
||||
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
|
||||
if(aaiMode.equalsIgnoreCase("production") || aaiMode.equalsIgnoreCase("beta"))
|
||||
serializer.setDomainName(".openaire.eu");
|
||||
// serializer.setDomainName(".athenarc.gr");
|
||||
LOGGER.info("Serializer : " + serializer);
|
||||
logger.info("Serializer : " + serializer);
|
||||
return serializer;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,16 +19,18 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
|
|||
|
||||
private String frontEndURI;
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
private static final Logger logger = Logger
|
||||
.getLogger(FrontEndLinkURIAuthenticationSuccessHandler.class);
|
||||
|
||||
public void init(){
|
||||
LOGGER.debug("Front end uri : " + frontEndURI);
|
||||
logger.debug("Front end uri : " + frontEndURI);
|
||||
}
|
||||
|
||||
|
||||
@Value("${aai.mode}")
|
||||
private String aai_mode;
|
||||
private String aaiMode;
|
||||
|
||||
private final static String ENCODING = "UTF-8";
|
||||
|
||||
@Override
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||
|
@ -39,46 +41,48 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
|
|||
if (authOIDC.getUserInfo().getSub() == null)
|
||||
userInfo.addProperty("sub", "");
|
||||
else
|
||||
userInfo.addProperty("sub", URLEncoder.encode(authOIDC.getUserInfo().getSub(), "UTF-8"));
|
||||
userInfo.addProperty("sub", URLEncoder.encode(authOIDC.getUserInfo().getSub(), ENCODING));
|
||||
|
||||
|
||||
if(authOIDC.getUserInfo().getName() != null)
|
||||
userInfo.addProperty("fullname", URLEncoder.encode(authOIDC.getUserInfo().getName(), "UTF-8"));
|
||||
userInfo.addProperty("fullname", URLEncoder.encode(authOIDC.getUserInfo().getName(), ENCODING));
|
||||
|
||||
if (authOIDC.getUserInfo().getGivenName() == null)
|
||||
userInfo.addProperty("firstname", "");
|
||||
else
|
||||
userInfo.addProperty("firstname", URLEncoder.encode(authOIDC.getUserInfo().getGivenName(), "UTF-8") + "");
|
||||
userInfo.addProperty("firstname", URLEncoder.encode(authOIDC.getUserInfo().getGivenName(), ENCODING) + "");
|
||||
|
||||
if (authOIDC.getUserInfo().getFamilyName() == null)
|
||||
userInfo.addProperty("lastname", "");
|
||||
else
|
||||
userInfo.addProperty("lastname", URLEncoder.encode(authOIDC.getUserInfo().getFamilyName(), "UTF-8") + "");
|
||||
userInfo.addProperty("lastname", URLEncoder.encode(authOIDC.getUserInfo().getFamilyName(), ENCODING) + "");
|
||||
|
||||
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") + "");
|
||||
.getSource().getAsJsonArray("edu_person_entitlements").toString(), ENCODING) + "");
|
||||
|
||||
|
||||
Cookie openAIREUser = new Cookie("openAIREUser", new Gson().toJson(userInfo) );
|
||||
openAIREUser.setMaxAge(14400);
|
||||
openAIREUser.setPath("/");
|
||||
if(aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
|
||||
openAIREUser.setHttpOnly(true);
|
||||
|
||||
if(aaiMode.equalsIgnoreCase("production") || aaiMode.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.setHttpOnly(true);
|
||||
|
||||
if(aaiMode.equalsIgnoreCase("production") || aaiMode.equalsIgnoreCase("beta"))
|
||||
accessToken.setDomain(".openaire.eu");
|
||||
accessToken.setPath("/");
|
||||
|
||||
// accessToken.setDomain(".athenarc.gr");
|
||||
response.addCookie(accessToken);
|
||||
response.sendRedirect(frontEndURI);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class OpenAireProviderAuthoritiesMapper implements OIDCAuthoritiesMapper
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(OpenAireProviderAuthoritiesMapper.class);
|
||||
|
||||
final private static String ROLE_CLAIMS = "edu_person_entitlements";
|
||||
private final static String ROLE_CLAIMS = "edu_person_entitlements";
|
||||
|
||||
private Map<String,SimpleGrantedAuthority> userRolesMap;
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class OpenAireProviderAuthoritiesMapper implements OIDCAuthoritiesMapper
|
|||
userInfo.getSource().getAsJsonArray(ROLE_CLAIMS).forEach(role -> {
|
||||
SimpleGrantedAuthority authority = userRolesMap.get(role.getAsString());
|
||||
if (authority != null) {
|
||||
logger.debug("Role mapped " + role);
|
||||
logger.debug(String.format("Role mapped %s",role));
|
||||
out.add(authority);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -36,7 +36,6 @@ public class RepoManagerContextLoaderListener extends ContextLoaderListener {
|
|||
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);
|
||||
|
@ -56,11 +55,7 @@ public class RepoManagerContextLoaderListener extends ContextLoaderListener {
|
|||
"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
|
||||
};
|
||||
|
|
|
@ -23,9 +23,6 @@ import java.net.UnknownHostException;
|
|||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class GenericControllerAdvice {
|
||||
|
||||
private Logger logger = LogManager.getLogger(GenericControllerAdvice.class);
|
||||
|
||||
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
@ExceptionHandler(ResourceNotFoundException.class)
|
||||
@ResponseBody
|
||||
|
|
|
@ -18,9 +18,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
@Api(description = "Monitor API", tags = {"monitor"})
|
||||
public class MonitorController {
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
.getLogger(MonitorController.class);
|
||||
|
||||
@Autowired
|
||||
private MonitorServiceImpl monitorService;
|
||||
|
||||
|
@ -35,8 +32,8 @@ public class MonitorController {
|
|||
@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 {
|
||||
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs") String validationStatus,
|
||||
@RequestParam("includeJobsTotal") @ApiParam(value = "Always true", required = true) String includeJobsTotal) throws ValidatorServiceException {
|
||||
|
||||
return monitorService.getJobsOfUser(user, jobType, offset, limit, dateFrom, dateTo, validationStatus, includeJobsTotal);
|
||||
}
|
||||
|
@ -46,14 +43,14 @@ public class MonitorController {
|
|||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public int getJobsOfUserPerValidationStatus(@RequestBody String user,
|
||||
@RequestBody String jobType,
|
||||
@RequestBody String validationStatus) throws JSONException {
|
||||
@RequestBody String validationStatus){
|
||||
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 {
|
||||
@RequestParam String groupBy){
|
||||
return monitorService.getJobSummary(jobId, groupBy);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.List;
|
|||
@Api(description = "Piwik API", tags = {"piwik"})
|
||||
public class PiWikController {
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
private static final Logger logger = Logger
|
||||
.getLogger(PiWikController.class);
|
||||
|
||||
@Autowired
|
||||
|
@ -123,7 +123,7 @@ public class PiWikController {
|
|||
writer.write(sb.toString());
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
LOGGER.error(e.getMessage());
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class PiWikController {
|
|||
|
||||
|
||||
String headerKey = "Content-Disposition";
|
||||
SimpleDateFormat sdfDate = new SimpleDateFormat("ddMMyyyy");//dd/MM/yyyy
|
||||
SimpleDateFormat sdfDate = new SimpleDateFormat("ddMMyyyy");
|
||||
Date now = new Date();
|
||||
String strDate = sdfDate.format(now);
|
||||
String headerValue = String.format("attachment; filename=\"csv-%s.csv\"",
|
||||
|
|
|
@ -108,7 +108,6 @@ public class RepositoryController {
|
|||
@RequestMapping(value = "/addRepository", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
// @PreAuthorize("hasRole('ROLE_USER') and #repository.registeredBy == authentication.userInfo.email")
|
||||
public Repository addRepository(@RequestParam("datatype") String datatype,
|
||||
@RequestBody Repository repository) throws Exception {
|
||||
|
||||
|
@ -139,7 +138,6 @@ public class RepositoryController {
|
|||
@RequestMapping(value = "/updateRepository", method = RequestMethod.POST,
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
//@PreAuthorize("hasRole('ROLE_USER') and #repository.registeredBy == authentication.userInfo.email")
|
||||
public Repository updateRepository(@RequestBody Repository repository,Authentication authentication) throws Exception {
|
||||
return repositoryService.updateRepository(repository, authentication);
|
||||
}
|
||||
|
|
|
@ -25,10 +25,8 @@ public class RestTemplateResponseErrorHandler implements ResponseErrorHandler {
|
|||
|
||||
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();
|
||||
}
|
||||
} else if (httpResponse.getStatusCode().series() == HttpStatus.Series.CLIENT_ERROR && httpResponse.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||
throw new IOException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,13 +55,13 @@ public class ValidatorController {
|
|||
|
||||
@RequestMapping(value = "/getSetsOfRepository" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public List<String> getSetsOfRepository(@RequestParam(value = "url", required = true) String url) {
|
||||
public List<String> getSetsOfRepository(@RequestParam(value = "url") 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) {
|
||||
public boolean identifyRepo(@RequestParam(value = "url") String url) {
|
||||
return validatorService.identifyRepo(url);
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class ValidatorController {
|
|||
|
||||
@RequestMapping(value = "/getInterfaceInformation" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseBody
|
||||
public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl", required = true) String baseUrl) throws ValidationServiceException {
|
||||
public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl") String baseUrl) throws ValidationServiceException {
|
||||
return validatorService.getInterfaceInformation(baseUrl);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
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() {
|
||||
|
|
|
@ -44,5 +44,4 @@ public interface BrokerService {
|
|||
|
||||
EventsPage getNotificationsBySubscriptionId(String subscriptionId, String page, String size) throws BrokerException;
|
||||
|
||||
Map<String, List<Subscription>> getSubscriptionsOfUser(String userEmail) throws BrokerException;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
@Value("${topic_types.url}")
|
||||
private String topicsURL;
|
||||
|
||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger
|
||||
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger
|
||||
.getLogger(BrokerServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
|
@ -58,14 +58,14 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
httpHeaders = new HttpHeaders();
|
||||
httpHeaders.set("Content-Type", "application/json");
|
||||
|
||||
LOGGER.debug("Init dnet topics!");
|
||||
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);
|
||||
logger.debug("Exception on initDnetTopicsMap" , e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,6 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
DatasourcesBroker ret = new DatasourcesBroker();
|
||||
try {
|
||||
ret.setDatasourcesOfUser(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
||||
//TODO fix bug when values are true
|
||||
if (Boolean.parseBoolean(includeShared)) {
|
||||
List<String> sharedDatasourceIds = new ArrayList<String>();
|
||||
ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds)));
|
||||
|
@ -92,7 +91,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
||||
}
|
||||
} catch (BrokerException e) {
|
||||
LOGGER.debug("Exception on getDatasourcesOfUser" , e);
|
||||
logger.debug("Exception on getDatasourcesOfUser" , e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
|
||||
|
@ -115,7 +114,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<List<BrowseEntry>>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on getTopicsForDatasource" , e);
|
||||
logger.debug("Exception on getTopicsForDatasource" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
|
@ -126,7 +125,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
@Override
|
||||
public EventsPage advancedShowEvents(String page,
|
||||
String size,
|
||||
AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException {
|
||||
AdvQueryObject advQueryObject) throws BrokerException {
|
||||
|
||||
final String service = "/events/{page}/{pageSize}";
|
||||
|
||||
|
@ -136,7 +135,6 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service);
|
||||
|
||||
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
||||
advQueryObject.setPage(Long.parseLong(page));
|
||||
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, httpHeaders);
|
||||
ResponseEntity<EventsPage> resp;
|
||||
|
@ -149,7 +147,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
}
|
||||
);
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on advancedShowEvents" , e);
|
||||
logger.debug("Exception on advancedShowEvents" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
|
@ -165,7 +163,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
for (Repository repo : repositories) {
|
||||
BrowseEntry temp = new BrowseEntry();
|
||||
temp.setValue(repo.getOfficialName());
|
||||
temp.setSize(new Long(0));
|
||||
temp.setSize(0L);
|
||||
for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialName())) {
|
||||
temp.setSize(temp.getSize() + e.getSize());
|
||||
}
|
||||
|
@ -174,12 +172,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
}
|
||||
|
||||
// sort the collection by the second field of the tuple which is size
|
||||
Collections.sort(entries, new Comparator<Tuple<BrowseEntry, String>>() {
|
||||
@Override
|
||||
public int compare(Tuple<BrowseEntry, String> e1, Tuple<BrowseEntry, String> e2) {
|
||||
return (int) (e2.getFirst().getSize().longValue() - e1.getFirst().getSize().longValue());
|
||||
}
|
||||
});
|
||||
entries.sort((e1, e2) -> (int) (e2.getFirst().getSize() - e1.getFirst().getSize()));
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
@ -201,14 +194,14 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
}
|
||||
|
||||
private List<Repository> getRepositoriesByIds(List<String> sharedDatasourceIds) {
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventsPage showEvents(String datasourceName,
|
||||
String topic,
|
||||
String page,
|
||||
String size) throws BrokerException, JSONException {
|
||||
String size) throws BrokerException{
|
||||
|
||||
final String service = "/events";
|
||||
|
||||
|
@ -226,7 +219,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<EventsPage>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on showEvents" , e);
|
||||
logger.debug("Exception on showEvents" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
|
@ -242,7 +235,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||
.queryParam("email", userEmail);
|
||||
|
||||
LOGGER.debug(builder.build().encode().toUri());
|
||||
logger.debug(builder.build().encode().toUri());
|
||||
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
||||
try {
|
||||
resp = restTemplate.exchange(
|
||||
|
@ -252,7 +245,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on getSimpleSubscriptionsOfUser" , e);
|
||||
logger.debug("Exception on getSimpleSubscriptionsOfUser" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
|
@ -281,7 +274,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<Subscription>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on OpenaireSubscription" , e);
|
||||
logger.debug("Exception on OpenaireSubscription" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
|
@ -305,7 +298,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<Void>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on unsubscribe" , e);
|
||||
logger.debug("Exception on unsubscribe" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
|
@ -329,7 +322,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<Subscription>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on getSubscription" , e);
|
||||
logger.debug("Exception on getSubscription" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
|
@ -337,7 +330,7 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Term> getDnetTopics() throws BrokerException {
|
||||
public Map<String, Term> getDnetTopics(){
|
||||
return topics;
|
||||
}
|
||||
|
||||
|
@ -360,31 +353,11 @@ public class BrokerServiceImpl implements BrokerService {
|
|||
new ParameterizedTypeReference<EventsPage>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on getNotificationsBySubscriptionId" , e);
|
||||
logger.debug("Exception on getNotificationsBySubscriptionId" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw new BrokerException(e);
|
||||
}
|
||||
return resp.getBody();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public Map<String, List<Subscription>> getSubscriptionsOfUser(String userEmail)
|
||||
throws BrokerException {
|
||||
|
||||
Map<String, List<SimpleSubscriptionDesc>> simpleSubs = getSimpleSubscriptionsOfUser(userEmail);
|
||||
Map<String,List<Subscription>> subs = new HashMap<>();
|
||||
List<Subscription> subscriptions = null;
|
||||
|
||||
for(String s:simpleSubs.keySet()){
|
||||
List<SimpleSubscriptionDesc> simpleSubscriptionDescs = simpleSubs.get(s);
|
||||
for(SimpleSubscriptionDesc simpleSubscriptionDesc : simpleSubscriptionDescs) {
|
||||
subscriptions = new ArrayList<>();
|
||||
subscriptions.add(getSubscription(simpleSubscriptionDesc.getId()));
|
||||
}
|
||||
subs.put(s,subscriptions);
|
||||
}
|
||||
return subs;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -22,9 +22,6 @@ public class DashboardServiceImpl implements DashboardService {
|
|||
|
||||
private static final Logger logger = Logger.getLogger(DashboardServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
|
@ -32,63 +29,61 @@ public class DashboardServiceImpl implements DashboardService {
|
|||
private BrokerService brokerService;
|
||||
|
||||
@Override
|
||||
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(@PathVariable("userEmail") String userEmail,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(String userEmail,
|
||||
String page,
|
||||
String size){
|
||||
|
||||
List<RepositorySummaryInfo> repositorySummaryInfoList = new ArrayList<>();
|
||||
|
||||
try {
|
||||
try {
|
||||
|
||||
List<Repository> repositoriesOfUser = repositoryService.getRepositoriesOfUser(userEmail, page, size);
|
||||
for(Repository repository: repositoriesOfUser) {
|
||||
List<Repository> 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());
|
||||
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?
|
||||
List<AggregationDetails> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId());
|
||||
for(AggregationDetails aggregationDetails: aggregationDetailsList) {
|
||||
if(aggregationDetails.getIndexedVersion()) {
|
||||
repositorySummaryInfo.setRecordsCollected(aggregationDetails.getNumberOfRecords());
|
||||
repositorySummaryInfo.setLastIndexedVersion(aggregationDetails.getDate());
|
||||
break;
|
||||
List<AggregationDetails> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId());
|
||||
for(AggregationDetails aggregationDetails: aggregationDetailsList) {
|
||||
if(aggregationDetails.getIndexedVersion()) {
|
||||
repositorySummaryInfo.setRecordsCollected(aggregationDetails.getNumberOfRecords());
|
||||
repositorySummaryInfo.setLastIndexedVersion(aggregationDetails.getDate());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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<BrowseEntry> 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);
|
||||
}
|
||||
}
|
||||
|
||||
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<BrowseEntry> 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);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Something baad happened!", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return repositorySummaryInfoList;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,11 +23,11 @@ import java.util.List;
|
|||
@Component("emailUtils")
|
||||
public class EmailUtilsImpl implements EmailUtils {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(EmailUtilsImpl.class);
|
||||
private static Logger logger = Logger.getLogger(EmailUtilsImpl.class);
|
||||
|
||||
private List<String> specialRecipients = new ArrayList<String>();
|
||||
private List<String> specialRecipients = new ArrayList<>();
|
||||
private boolean override = false, logonly = false;
|
||||
private String overrideEmail = null, from = null;
|
||||
private String overrideEmail = null;
|
||||
|
||||
@Autowired
|
||||
private MailLibrary mailLibrary;
|
||||
|
@ -50,7 +50,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
System.out.println("url -> " + this.baseUrl);
|
||||
logger.info(String.format("url -> %s", this.baseUrl));
|
||||
}
|
||||
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
String subject = "Automatic Bug Report";
|
||||
this.sendMail(recipients, subject, message, false, null);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error sending error report", e);
|
||||
logger.error("Error sending error report", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
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);
|
||||
logger.error("Error while sending request to enable metrics email to administrator: " + this.usageStatsAdminEmail, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
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);
|
||||
logger.error("Error while sending request to enable metrics email to user: " + piwikInfo.getRequestorEmail(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
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);
|
||||
logger.error("Error while sending metrics enabled notification email to administator: " + this.usageStatsAdminEmail, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
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);
|
||||
logger.error("Error while sending metrics enabled notification email to user: " + piwikInfo.getRequestorEmail(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to the administrator", e);
|
||||
logger.error("Error while sending registration notification email to the administrator", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
this.sendMail(this.provideAdminEmail, subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to the administrator", e);
|
||||
logger.error("Error while sending registration notification email to the administrator", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
this.sendMail(repository.getRegisteredBy(), subject, message, false, null);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
logger.error("Error while sending registration notification email to user: " + repository.getRegisteredBy(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
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);
|
||||
logger.error("Error while sending validation submission notification email to user: " + jobForValidation.getUserEmail(), e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -337,51 +337,17 @@ public class EmailUtilsImpl implements EmailUtils {
|
|||
}
|
||||
if (!logonly)
|
||||
mailLibrary.sendEmail(recipients.toArray(new String[]{}), subject, message);
|
||||
LOGGER.debug("Sending mail to Recipients: " + recipients + " Subject: " + subject + " Message: " + 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);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -22,16 +22,7 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
return this.validatorServiceLocator.getService();
|
||||
}
|
||||
|
||||
public ServiceLocator<ValidatorService> getValidatorServiceLocator() {
|
||||
return validatorServiceLocator;
|
||||
}
|
||||
|
||||
public void setValidatorServiceLocator(ServiceLocator<ValidatorService> validatorServiceLocator) {
|
||||
this.validatorServiceLocator = validatorServiceLocator;
|
||||
}
|
||||
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
private static final Logger logger = Logger
|
||||
.getLogger(MonitorServiceImpl.class);
|
||||
|
||||
@Override
|
||||
|
@ -42,10 +33,10 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
String dateFrom,
|
||||
String dateTo,
|
||||
String validationStatus,
|
||||
String includeJobsTotal) throws JSONException, ValidatorServiceException {
|
||||
String includeJobsTotal) throws ValidatorServiceException {
|
||||
|
||||
LOGGER.debug("Getting jobs of user : " + user);
|
||||
LOGGER.debug(user + "/" + jobType + "/" + offset + "/" + dateFrom + "/" + dateTo + "/" + validationStatus + "/" + includeJobsTotal);
|
||||
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));
|
||||
|
@ -56,7 +47,6 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
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")) {
|
||||
|
@ -86,24 +76,24 @@ public class MonitorServiceImpl implements MonitorService {
|
|||
@Override
|
||||
public int getJobsOfUserPerValidationStatus(String user,
|
||||
String jobType,
|
||||
String validationStatus) throws JSONException {
|
||||
LOGGER.debug("Getting job with validation status : " + validationStatus);
|
||||
String validationStatus){
|
||||
logger.debug("Getting job with validation status : " + validationStatus);
|
||||
try {
|
||||
return getValidationService().getStoredJobsTotalNumberNew(user, jobType, validationStatus);
|
||||
} catch (ValidatorServiceException e) {
|
||||
e.printStackTrace();
|
||||
logger.error(e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoredJob getJobSummary(String jobId,
|
||||
String groupBy) throws JSONException {
|
||||
LOGGER.debug("Getting job summary with id : " + jobId);
|
||||
String groupBy){
|
||||
logger.debug("Getting job summary with id : " + jobId);
|
||||
try {
|
||||
return getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
|
||||
} catch (ValidatorServiceException e) {
|
||||
e.printStackTrace();
|
||||
logger.error(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -15,28 +15,19 @@ 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.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 {
|
||||
|
@ -57,7 +48,7 @@ public class PiWikServiceImpl implements PiWikService {
|
|||
@Qualifier("emailUtils")
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
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 = ?;";
|
||||
|
@ -96,7 +87,7 @@ public class PiWikServiceImpl implements PiWikService {
|
|||
|
||||
@Override
|
||||
public List<PiwikInfo> getPiwikSitesForRepos(OrderByField orderByField, OrderByType orderByType, int from, int quantity, String searchField) {
|
||||
LOGGER.debug("Getting piwik sites for repos! ");
|
||||
logger.debug("Getting piwik sites for repos! ");
|
||||
try{
|
||||
String finalizedQuery = GET_PIWIK_SITES + " where ("+
|
||||
" repositoryid ilike ? " +
|
||||
|
@ -159,11 +150,11 @@ public class PiWikServiceImpl implements PiWikService {
|
|||
emailUtils.sendUserMetricsEnabled(piwikInfo);
|
||||
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
LOGGER.error("Error while approving piwik site: ", 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);
|
||||
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);
|
||||
|
@ -194,15 +185,15 @@ public class PiWikServiceImpl implements PiWikService {
|
|||
emailUtils.sendAdministratorRequestToEnableMetrics(piwikInfo);
|
||||
emailUtils.sendUserRequestToEnableMetrics(piwikInfo);
|
||||
} catch (UnsupportedEncodingException uee) {
|
||||
LOGGER.error("Error while creating piwikScript URL", 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);
|
||||
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);
|
||||
logger.error("Error while sending email to administrator or user about the request to enable metrics", e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
return piwikInfo;
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
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;
|
||||
|
@ -14,7 +12,6 @@ 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;
|
||||
|
@ -59,7 +56,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
private final String[] vocabularyNames = {"dnet:countries", "dnet:datasource_typologies", "dnet:compatibilityLevel"};
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(RepositoryServiceImpl.class);
|
||||
private static final Logger logger = Logger.getLogger(RepositoryServiceImpl.class);
|
||||
|
||||
@Value("${services.repomanager.usageStatisticsDiagramsBaseURL}")
|
||||
private String usageStatisticsDiagramsBaseURL;
|
||||
|
@ -85,46 +82,43 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
private Map<String, String> countriesMap = new HashMap<>();
|
||||
private Map<String, String> inverseCountriesMap = new HashMap<>();
|
||||
|
||||
private static Map<String,List<String>> dataSourceClass = new HashMap<String,List<String>>(){{
|
||||
put("opendoar",new ArrayList<String>(){{ add("pubsrepository::institutional");
|
||||
add("pubsrepository::thematic");
|
||||
add("pubsrepository::unknown");
|
||||
add("pubsrepository::mock");
|
||||
}});
|
||||
put("re3data",new ArrayList<String>(){{ add("datarepository::unknown");
|
||||
}});
|
||||
put("journal",new ArrayList<String>(){{ add("pubsrepository::journal");
|
||||
}});
|
||||
put("aggregator",new ArrayList<String>(){{ add("aggregator::pubsrepository::institutional");
|
||||
add("aggregator::pubsrepository::journals");
|
||||
add("aggregator::datarepository");
|
||||
add("aggregator::pubsrepository::unknown");
|
||||
}});
|
||||
}};
|
||||
private static Map<String,List<String>> dataSourceClass = new HashMap<>();
|
||||
|
||||
private static Map<String,String> invertedDataSourceClass = new HashMap<String,String>(){{
|
||||
put("pubsrepository::institutional","opendoar");
|
||||
put("pubsrepository::thematic","opendoar");
|
||||
put("pubsrepository::unknown","opendoar");
|
||||
put("pubsrepository::mock","opendoar");
|
||||
|
||||
put("datarepository::unknown","re3data");
|
||||
|
||||
put("pubsrepository::journal","journal");
|
||||
|
||||
put("aggregator::pubsrepository::institutional","aggregator");
|
||||
put("aggregator::pubsrepository::journals","aggregator");
|
||||
put("aggregator::datarepository","aggregator");
|
||||
put("aggregator::pubsrepository::unknown","aggregator");
|
||||
|
||||
}};
|
||||
private static Map<String,String> invertedDataSourceClass = new HashMap<>();
|
||||
|
||||
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
LOGGER.debug("Initialization method of repository api!");
|
||||
LOGGER.debug("Updated version!");
|
||||
logger.debug("Initialization method of repository api!");
|
||||
logger.debug("Updated version!");
|
||||
|
||||
|
||||
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");
|
||||
|
||||
|
||||
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"));
|
||||
|
||||
|
||||
|
||||
httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||
|
@ -152,11 +146,11 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
|
||||
@Override
|
||||
public List<RepositorySnippet> getRepositoriesByCountry(@PathVariable("country") String country,
|
||||
@PathVariable("mode") String mode,
|
||||
@RequestParam(value = "managed",required=false) Boolean managed) throws JSONException, IOException {
|
||||
public List<RepositorySnippet> getRepositoriesByCountry(String country,
|
||||
String mode,
|
||||
Boolean managed) throws JSONException, IOException {
|
||||
|
||||
LOGGER.debug("Getting repositories by country!");
|
||||
logger.debug("Getting repositories by country!");
|
||||
int page = 0;
|
||||
int size = 100;
|
||||
List<RepositorySnippet> resultSet = new ArrayList<>();
|
||||
|
@ -169,8 +163,8 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
filterKey = "openaire____::re3data";
|
||||
|
||||
|
||||
LOGGER.debug("Country code equals : " + country);
|
||||
LOGGER.debug("Filter mode equals : " + filterKey);
|
||||
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();
|
||||
|
@ -190,7 +184,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
}
|
||||
return resultSet;
|
||||
}catch (Exception e){
|
||||
LOGGER.debug("Exception on getRepositoriesByCountry" , e);
|
||||
logger.debug("Exception on getRepositoriesByCountry" , e);
|
||||
// emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
@ -199,7 +193,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
public List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
||||
String officialName, String requestSortBy, String order, int page, int pageSize) throws Exception {
|
||||
|
||||
LOGGER.debug("Searching registered repositories");
|
||||
logger.debug("Searching registered repositories");
|
||||
|
||||
List<RepositorySnippet> resultSet = new ArrayList<>();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
@ -220,7 +214,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
return resultSet;
|
||||
}catch (Exception e){
|
||||
LOGGER.error("Error searching registered datasources" , e);
|
||||
logger.error("Error searching registered datasources" , e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -238,24 +232,12 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
return r;
|
||||
}
|
||||
|
||||
|
||||
private Collection<Repository> getRepositoriesByMode(String mode, List<Repository> rs) {
|
||||
|
||||
List<Repository> reps = new ArrayList<>();
|
||||
for (Repository r : rs) {
|
||||
if (r.getCollectedFrom() != null && r.getCollectedFrom().equals(mode))
|
||||
reps.add(r);
|
||||
|
||||
}
|
||||
return reps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Repository> getRepositoriesOfUser(@PathVariable("userEmail") String userEmail,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
public List<Repository> getRepositoriesOfUser(String userEmail,
|
||||
String page,
|
||||
String size) throws JSONException {
|
||||
|
||||
LOGGER.debug("Retreiving repositories of user : " + userEmail );
|
||||
logger.debug("Retreiving repositories of user : " + userEmail );
|
||||
UriComponents uriComponents = searchDatasource(page,size);
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setRegisteredby(userEmail);
|
||||
|
@ -269,7 +251,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
return repos;
|
||||
}catch (Exception e){
|
||||
LOGGER.debug("Exception on getRepositoriesOfUser" , e);
|
||||
logger.debug("Exception on getRepositoriesOfUser" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
@ -278,7 +260,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
@Override
|
||||
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException,ResourceNotFoundException {
|
||||
|
||||
LOGGER.debug("Retreiving repositories with id : " + id );
|
||||
logger.debug("Retreiving repositories with id : " + id );
|
||||
Repository repo = null;
|
||||
UriComponents uriComponents = searchDatasource("0","100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
|
@ -294,7 +276,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0));
|
||||
return updateRepositoryInfo(repo);
|
||||
}catch (JSONException e){
|
||||
LOGGER.debug("Exception on getRepositoryById" , e);
|
||||
logger.debug("Exception on getRepositoryById" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
@ -303,9 +285,9 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
|
||||
@Override
|
||||
public List<AggregationDetails> getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
|
||||
public List<AggregationDetails> getRepositoryAggregations(String id) throws JSONException {
|
||||
|
||||
LOGGER.debug("Retreiving aggregations for repository with id : " + id );
|
||||
logger.debug("Retreiving aggregations for repository with id : " + id );
|
||||
UriComponents uriComponents = searchDatasource("0","100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setId(id);
|
||||
|
@ -324,7 +306,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
.limit(20)
|
||||
.collect(Collectors.toList());
|
||||
} catch (JSONException e) {
|
||||
LOGGER.debug("Exception on getRepositoryAggregations" , e);
|
||||
logger.debug("Exception on getRepositoryAggregations" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
@ -332,8 +314,8 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<AggregationDetails>> getRepositoryAggregationsByYear(@PathVariable("id") String id) throws JSONException {
|
||||
LOGGER.debug("Retreiving aggregations (by year) for repository with id : " + id );
|
||||
public Map<String, List<AggregationDetails>> 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);
|
||||
|
@ -351,14 +333,13 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
return aggregationHistory.size() == 0? aggregationByYear:createYearMap(aggregationHistory);
|
||||
|
||||
} catch (JSONException e) {
|
||||
LOGGER.debug("Exception on getRepositoryAggregations" , e);
|
||||
logger.debug("Exception on getRepositoryAggregations" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String,List<AggregationDetails>> createYearMap(List<AggregationDetails> aggregationHistory) {
|
||||
Map<String, List<AggregationDetails>> aggregationByYear;
|
||||
aggregationHistory = aggregationHistory.stream()
|
||||
.sorted(Comparator.comparing(AggregationDetails::getDate).reversed())
|
||||
.collect(Collectors.toList());
|
||||
|
@ -369,11 +350,11 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
|
||||
@Override
|
||||
public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
public List<Repository> getRepositoriesByName(String name,
|
||||
String page,
|
||||
String size ) throws JSONException {
|
||||
|
||||
LOGGER.debug("Retreiving repositories with official name : " + name );
|
||||
logger.debug("Retreiving repositories with official name : " + name );
|
||||
UriComponents uriComponents = searchDatasource("0","100");
|
||||
RequestFilter requestFilter = new RequestFilter();
|
||||
requestFilter.setOfficialname(name);
|
||||
|
@ -385,7 +366,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
updateRepositoryInfo(r);
|
||||
return repos;
|
||||
}catch (Exception e){
|
||||
LOGGER.debug("Exception on getRepositoriesByName" , e);
|
||||
logger.debug("Exception on getRepositoriesByName" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
@ -393,7 +374,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) throws JSONException {
|
||||
public List<RepositoryInterface> getRepositoryInterface(String id) throws JSONException {
|
||||
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/")
|
||||
|
@ -404,7 +385,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class);
|
||||
return Converter.jsonToRepositoryInterfaceList(new JSONObject(rs));
|
||||
}catch (Exception e ){
|
||||
LOGGER.debug("Exception on getRepositoryInterface" , e);
|
||||
logger.debug("Exception on getRepositoryInterface" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
@ -412,10 +393,10 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Repository addRepository(@RequestParam("datatype") String datatype,
|
||||
@RequestBody Repository repository) throws Exception {
|
||||
public Repository addRepository( String datatype,
|
||||
Repository repository) throws Exception {
|
||||
|
||||
LOGGER.debug("storing " + datatype + " repository with id: " + repository.getId());
|
||||
logger.debug("storing " + datatype + " repository with id: " + repository.getId());
|
||||
|
||||
repository.setCountryCode(countriesMap.get(repository.getCountryName()));
|
||||
repository.setActivationId(UUID.randomUUID().toString());
|
||||
|
@ -445,12 +426,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
try {
|
||||
String json_repository = Converter.repositoryObjectToJson(repository);
|
||||
LOGGER.debug("JSON to add(update) -> " + json_repository);
|
||||
|
||||
//
|
||||
// // TODO delete these 3 lines
|
||||
// HttpHeaders temp = new HttpHeaders();
|
||||
// temp.setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||
logger.debug("JSON to add(update) -> " + json_repository);
|
||||
|
||||
HttpEntity<String> httpEntity = new HttpEntity<String>(json_repository, httpHeaders);
|
||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, httpEntity, ResponseEntity.class);
|
||||
|
@ -459,11 +435,11 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
emailUtils.sendUserRegistrationEmail(repository, authentication);
|
||||
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
||||
} else
|
||||
LOGGER.debug(responseEntity.getBody().toString());
|
||||
logger.debug(responseEntity.getBody().toString());
|
||||
|
||||
return repository;
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("Exception on updateRepository" , e);
|
||||
logger.debug("Exception on updateRepository" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
@ -472,7 +448,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Repository updateRepository(@RequestBody Repository repository,Authentication authentication) throws Exception {
|
||||
public Repository updateRepository(Repository repository,Authentication authentication) throws Exception {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/update/")
|
||||
.build()
|
||||
|
@ -481,7 +457,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
try {
|
||||
String json_repository = Converter.repositoryObjectToJson(repository);
|
||||
|
||||
LOGGER.debug("JSON to update -> " + json_repository);
|
||||
logger.debug("JSON to update -> " + json_repository);
|
||||
|
||||
HttpEntity<String> httpEntity = new HttpEntity<String>(json_repository, httpHeaders);
|
||||
ResponseEntity responseEntity = restTemplate.exchange(uriComponents.toUri(),HttpMethod.POST, httpEntity
|
||||
|
@ -491,41 +467,15 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
emailUtils.sendUserUpdateRepositoryEmail(repository, authentication);
|
||||
emailUtils.sendAdminUpdateRepositoryEmail(repository, authentication);
|
||||
} else
|
||||
LOGGER.debug(responseEntity.getBody().toString());
|
||||
logger.debug(responseEntity.getBody().toString());
|
||||
|
||||
return repository;
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("Exception on updateRepository" , e);
|
||||
logger.debug("Exception on updateRepository" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateInterface(String datatype,RepositoryInterface iFace) {
|
||||
//TODO call update base url
|
||||
//((DatasourceManagerService) this.dmService.getService()).updateBaseUrl(repo.getId(), iFace.getId(), iFace.getBaseUrl());
|
||||
if (!iFace.getAccessSet().isEmpty()) {
|
||||
LOGGER.debug("set not empty: " + iFace.getAccessSet());
|
||||
//TODO call update method for access params
|
||||
// ((DatasourceManagerService) this.dmService.getService()).updateAccessParam(repo.getId(), iFace.getId(), "set", iFace.getAccessSet(), false);
|
||||
} else {
|
||||
//TODO call deleteAccessParamOrExtraField
|
||||
//((DatasourceManagerService) this.dmService.getService()).deleteAccessParamOrExtraField(repo.getId(), iFace.getId(), "set");
|
||||
}
|
||||
//TODO update content description
|
||||
//((DatasourceManagerService) this.dmService.getService()).updateContentDescription(repo.getId(), iFace.getId(), "metadata");
|
||||
if (datatype.equals("re3data")) {
|
||||
//TODO call update access params
|
||||
// ((DatasourceManagerService) this.dmService.getService()).updateAccessParam(repo.getId(), iFace.getId(), "format", "oai_datacite", false);
|
||||
iFace.setAccessFormat("oai_datacite");
|
||||
} else {
|
||||
//TODO call update access params
|
||||
//((DatasourceManagerService) this.dmService.getService()).updateAccessParam(repo.getId(), iFace.getId(), "format", "oai_dc", false);
|
||||
iFace.setAccessFormat("oai_dc");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void storeRepository(Repository repository, Authentication authentication) throws Exception {
|
||||
|
||||
Date utilDate = new Date();
|
||||
|
@ -546,26 +496,26 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
emailUtils.sendUserRegistrationEmail(repository, authentication);
|
||||
emailUtils.sendAdminRegistrationEmail(repository, authentication);
|
||||
} else {
|
||||
LOGGER.debug(responseEntity.getBody().toString());
|
||||
logger.debug(responseEntity.getBody().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRepositoryInterface(@RequestParam("id") String id ,
|
||||
@RequestParam("registeredBy") String registeredBy){
|
||||
public void deleteRepositoryInterface(String id ,
|
||||
String registeredBy){
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/ds/api/")
|
||||
.path("/{id}")
|
||||
.build().expand(id).encode();
|
||||
LOGGER.debug(uriComponents.toUri());
|
||||
logger.debug(uriComponents.toUri());
|
||||
restTemplate.delete(uriComponents.toUri());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
||||
@RequestParam("repoId") String repoId,
|
||||
@RequestParam("registeredBy") String registeredBy,
|
||||
@RequestBody RepositoryInterface repositoryInterface) throws JSONException,ResourceNotFoundException {
|
||||
public RepositoryInterface addRepositoryInterface(String datatype,
|
||||
String repoId,
|
||||
String registeredBy,
|
||||
RepositoryInterface repositoryInterface) throws JSONException,ResourceNotFoundException {
|
||||
try {
|
||||
Repository e = this.getRepositoryById(repoId);
|
||||
repositoryInterface = createRepositoryInterface(e,repositoryInterface,datatype);
|
||||
|
@ -581,16 +531,16 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
return repositoryInterface;
|
||||
|
||||
} catch (JSONException e) {
|
||||
LOGGER.debug("Exception on addRepositoryInterface" , e);
|
||||
logger.debug("Exception on addRepositoryInterface" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId,
|
||||
@RequestParam("registeredBy") String registeredBy,
|
||||
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
||||
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());
|
||||
|
@ -598,27 +548,6 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
return repositoryInterface;
|
||||
}
|
||||
|
||||
private void submitInterfaceValidation(Repository repo, String repoType, String userEmail, RepositoryInterface iFace) 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.setInterfaceIdOld(null);
|
||||
job.setOfficialName(repo.getOfficialName());
|
||||
job.setRepoType(repoType);
|
||||
job.setUserEmail(userEmail);
|
||||
job.setValidationSet(iFace.getAccessSet());
|
||||
job.setRecords(-1);
|
||||
job.setRegistration(true);
|
||||
job.setUpdateExisting(false);
|
||||
|
||||
this.validatorService.submitJobForValidation(job);
|
||||
}
|
||||
|
||||
private RepositoryInterface createRepositoryInterface(Repository repo, RepositoryInterface iFace, String datatype) {
|
||||
|
||||
iFace.setContentDescription("metadata");
|
||||
|
@ -646,7 +575,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
iFace.setMetadataIdentifierPath("//*[local-name()='header']/*[local-name()='identifier']");
|
||||
iFace.setId("api_________::" + repo.getId() + "::" + UUID.randomUUID().toString().substring(0, 8));
|
||||
if (iFace.getAccessSet().isEmpty()) {
|
||||
LOGGER.debug("set is empty: " + iFace.getAccessSet());
|
||||
logger.debug("set is empty: " + iFace.getAccessSet());
|
||||
iFace.removeAccessSet();
|
||||
}
|
||||
return iFace;
|
||||
|
@ -654,7 +583,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
@Override
|
||||
public List<String> getDnetCountries() {
|
||||
LOGGER.debug("Getting dnet-countries!");
|
||||
logger.debug("Getting dnet-countries!");
|
||||
return Converter.readFile("countries.txt");
|
||||
}
|
||||
|
||||
|
@ -670,9 +599,9 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUrlsOfUserRepos(@PathVariable("user_email") String userEmail,
|
||||
@PathVariable("page") String page,
|
||||
@PathVariable("size") String size) throws JSONException {
|
||||
public List<String> getUrlsOfUserRepos(String userEmail,
|
||||
String page,
|
||||
String size) {
|
||||
UriComponents uriComponents = UriComponentsBuilder
|
||||
.fromHttpUrl(baseAddress + "/api/baseurl/")
|
||||
.path("/{page}/{size}")
|
||||
|
@ -683,14 +612,14 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
requestFilter.setRegisteredby(userEmail);
|
||||
return Arrays.asList(restTemplate.postForObject(uriComponents.toUri(),requestFilter, String[].class));
|
||||
}catch (Exception e){
|
||||
LOGGER.debug("Exception on addRepositoryInterface" , e);
|
||||
logger.debug("Exception on addRepositoryInterface" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDatasourceVocabularies(@PathVariable("mode") String mode) {
|
||||
public List<String> getDatasourceVocabularies(String mode) {
|
||||
|
||||
List<String> resultSet = new ArrayList<>();
|
||||
for (Map.Entry<String, String> entry : this.getVocabulary("dnet:datasource_typologies").getAsMap().entrySet()) {
|
||||
|
@ -723,9 +652,9 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCompatibilityClasses(@PathVariable("mode") String mode) {
|
||||
public Map<String, String> getCompatibilityClasses(String mode) {
|
||||
|
||||
LOGGER.debug("Getting compatibility classes for mode: " + mode);
|
||||
logger.debug("Getting compatibility classes for mode: " + mode);
|
||||
Map<String, String> retMap = new HashMap<String, String>();
|
||||
|
||||
Map<String, String> compatibilityClasses = this.getVocabulary("dnet:compatibilityLevel").getAsMap();
|
||||
|
@ -744,7 +673,6 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
}
|
||||
}
|
||||
|
||||
//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)");
|
||||
|
||||
|
@ -752,9 +680,9 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getDatasourceClasses(@PathVariable("mode") String mode) {
|
||||
public Map<String, String> getDatasourceClasses(String mode) {
|
||||
|
||||
LOGGER.debug("Getting datasource classes for mode: " + mode);
|
||||
logger.debug("Getting datasource classes for mode: " + mode);
|
||||
|
||||
Map<String, String> retMap = new HashMap<String, String>();
|
||||
|
||||
|
@ -793,7 +721,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public MetricsInfo getMetricsInfoForRepository(@PathVariable("repoId") String repoId) throws RepositoryServiceException {
|
||||
public MetricsInfo getMetricsInfoForRepository(String repoId) throws RepositoryServiceException {
|
||||
try {
|
||||
|
||||
MetricsInfo metricsInfo = new MetricsInfo();
|
||||
|
@ -802,14 +730,14 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
return metricsInfo;
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error while getting metrics info for repository: ", 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<String, String> getListLatestUpdate(@PathVariable("mode") String mode) throws JSONException {
|
||||
public Map<String, String> getListLatestUpdate(String mode) throws JSONException {
|
||||
if(mode.equals("opendoar"))
|
||||
return Collections.singletonMap("lastCollectionDate", getRepositoryInterface("openaire____::"+mode).get(0).getLastCollectionDate());
|
||||
else
|
||||
|
@ -851,7 +779,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
restTemplate.postForObject(uriComponents.toUri(),null,String.class);
|
||||
}
|
||||
|
||||
private MetricsNumbers getMetricsNumbers(String openAIREID) throws BrokerException {
|
||||
private MetricsNumbers getMetricsNumbers(String openAIREID) {
|
||||
|
||||
//build the uri params
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.usageStatisticsNumbersBaseURL + openAIREID + "/clicks");
|
||||
|
@ -869,7 +797,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
|||
new ParameterizedTypeReference<MetricsNumbers>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on getMetricsNumbers" , e);
|
||||
logger.debug("Exception on getMetricsNumbers" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
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;
|
||||
|
||||
|
||||
|
|
|
@ -29,23 +29,23 @@ public class SushiliteServiceImpl implements SushiliteService {
|
|||
@Autowired
|
||||
private EmailUtils emailUtils;
|
||||
|
||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger.getLogger(SushiliteServiceImpl.class);
|
||||
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(SushiliteServiceImpl.class);
|
||||
|
||||
|
||||
@Override
|
||||
@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) {
|
||||
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/")
|
||||
|
@ -74,7 +74,7 @@ public class SushiliteServiceImpl implements SushiliteService {
|
|||
new ParameterizedTypeReference<ReportResponseWrapper>() {
|
||||
});
|
||||
} catch (RestClientException e) {
|
||||
LOGGER.debug("Exception on getReportResults" , e);
|
||||
logger.debug("Exception on getReportResults" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class SushiliteServiceImpl implements SushiliteService {
|
|||
}
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
LOGGER.debug("Exception on getReportResults - trying to cast strings to integers", e);
|
||||
logger.debug("Exception on getReportResults - trying to cast strings to integers", e);
|
||||
//emailUtils.reportException(e);
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.stream.Collectors;
|
|||
@Service("userService")
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger
|
||||
private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger
|
||||
.getLogger(UserServiceImpl.class);
|
||||
|
||||
@Value("${oidc.issuer}")
|
||||
|
@ -25,7 +25,7 @@ public class UserServiceImpl implements UserService {
|
|||
@Override
|
||||
public ResponseEntity<Object> login() {
|
||||
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||
LOGGER.debug("User authentication : " + authentication);
|
||||
logger.debug("User authentication : " + authentication);
|
||||
Map<String,Object> body = new HashMap<>();
|
||||
body.put("sub",authentication.getSub());
|
||||
if(authentication.getUserInfo().getName() == null || authentication.getUserInfo().getName().equals(""))
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
|
||||
private Map<String, List<RuleSet>> rulesetMap = new ConcurrentHashMap<String, List<RuleSet>>();
|
||||
|
||||
private static final Logger LOGGER = Logger
|
||||
private static final Logger logger = Logger
|
||||
.getLogger(ValidatorServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
|
@ -59,7 +59,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
|
||||
@PostConstruct
|
||||
private void loadRules(){
|
||||
LOGGER.debug("PostConstruct method! Load rules!");
|
||||
logger.debug("PostConstruct method! Load rules!");
|
||||
try {
|
||||
for (RuleSet ruleSet : getValidationService().getRuleSets()) {
|
||||
if (ruleSet.getVisibility() != null && ruleSet.getVisibility().contains("development")) {
|
||||
|
@ -81,33 +81,33 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
}
|
||||
}
|
||||
} catch (ValidatorServiceException e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Exception on loadRules" , e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_USER') and #jobForValidation.userEmail == authentication.userInfo.email")
|
||||
public JobForValidation submitJobForValidation(@RequestBody JobForValidation jobForValidation) throws ValidatorServiceException {
|
||||
LOGGER.debug("Submit job for validation with id : " + jobForValidation.getDatasourceId());
|
||||
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);
|
||||
logger.debug("Exception on submitJobForValidation" , e);
|
||||
emailUtils.reportException(e);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Exception on submitJobForValidation", e);
|
||||
}
|
||||
return jobForValidation;
|
||||
}
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email")
|
||||
public ResponseEntity<Object> reSubmitJobForValidation(@PathVariable("email") String email,
|
||||
@PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException {
|
||||
LOGGER.debug("Resubmit validation job with id : " + jobId);
|
||||
public ResponseEntity<Object> reSubmitJobForValidation(String email,
|
||||
String jobId) throws ValidatorServiceException {
|
||||
logger.debug("Resubmit validation job with id : " + jobId);
|
||||
StoredJob job = monitorApi.getJobSummary(jobId,"all");
|
||||
Set<Integer> contentRules = new HashSet<Integer>();
|
||||
Set<Integer> usageRules = new HashSet<Integer>();
|
||||
|
@ -120,12 +120,13 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int ruleId : job.getRules()) {
|
||||
if (ruleSet.getContentRulesIds().contains(ruleId))
|
||||
contentRules.add(ruleId);
|
||||
else if (ruleSet.getUsageRulesIds().contains(ruleId))
|
||||
usageRules.add(ruleId);
|
||||
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);
|
||||
|
@ -136,38 +137,38 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<RuleSet> getRuleSets(@PathVariable("mode") String mode) {
|
||||
LOGGER.info("Getting rulesets for mode: " + mode);
|
||||
public List<RuleSet> getRuleSets(String mode) {
|
||||
logger.info("Getting rulesets for mode: " + mode);
|
||||
return rulesetMap.get(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSetsOfRepository(@RequestParam(value = "url", required = true) String url) {
|
||||
LOGGER.debug("Getting sets of repository with url : " + url);
|
||||
public List<String> 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);
|
||||
logger.debug("Exception on getSetsOfRepository" , e);
|
||||
emailUtils.reportException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean identifyRepo(@RequestParam(value = "url", required = true) String url) {
|
||||
LOGGER.debug("Identify repository with url : " + url);
|
||||
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);
|
||||
logger.error("Error while identifying repository with url: " + url, e);
|
||||
emailUtils.reportException(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuleSet getRuleSet(@PathVariable("acronym") String acronym) {
|
||||
LOGGER.debug("Getting ruleset with acronym : " + acronym);
|
||||
public RuleSet getRuleSet( String acronym) {
|
||||
logger.debug("Getting ruleset with acronym : " + acronym);
|
||||
RuleSet ruleSet = null;
|
||||
try {
|
||||
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
||||
|
@ -179,7 +180,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
}
|
||||
return ruleSet;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error getting ruleset", e);
|
||||
logger.error("Error getting ruleset", e);
|
||||
emailUtils.reportException(e);
|
||||
return null;
|
||||
}
|
||||
|
@ -187,14 +188,13 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
|
||||
@Override
|
||||
@PreAuthorize("hasRole('ROLE_USER')")
|
||||
public List<StoredJob> 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
|
||||
public List<StoredJob> 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);
|
||||
}
|
||||
|
@ -205,9 +205,9 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public InterfaceInformation getInterfaceInformation(@RequestParam(value = "baseUrl", required = true) String baseUrl) throws ValidationServiceException {
|
||||
public InterfaceInformation getInterfaceInformation(String baseUrl) throws ValidationServiceException {
|
||||
try {
|
||||
LOGGER.debug("Getting interface information with url: " + baseUrl);
|
||||
logger.debug("Getting interface information with url: " + baseUrl);
|
||||
InterfaceInformation interfaceInformation = new InterfaceInformation();
|
||||
interfaceInformation.setIdentified(this.identifyRepo(baseUrl));
|
||||
if (interfaceInformation.isIdentified())
|
||||
|
@ -215,7 +215,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
|||
|
||||
return interfaceInformation;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error getting interface information with url: " + baseUrl, e);
|
||||
logger.error("Error getting interface information with url: " + baseUrl, e);
|
||||
emailUtils.reportException(e);
|
||||
throw new ValidationServiceException("login.generalError", ValidationServiceException.ErrorCode.GENERAL_ERROR);
|
||||
}
|
||||
|
|
|
@ -29,9 +29,6 @@ public class UsageStatsTotalHystrixCommand extends HystrixCommand<Integer> {
|
|||
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ import com.google.gwt.user.client.rpc.IsSerializable;
|
|||
*/
|
||||
public class Term implements IsSerializable {
|
||||
|
||||
public String englishName;
|
||||
public String nativeName;
|
||||
public String encoding;
|
||||
public String code;
|
||||
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;
|
||||
|
@ -19,35 +19,4 @@ public class Term implements IsSerializable {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,9 @@ package eu.dnetlib.repo.manager.shared;
|
|||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class Timezone implements IsSerializable {
|
||||
public String name;
|
||||
public double offset;
|
||||
|
||||
private String name;
|
||||
private double offset;
|
||||
|
||||
public Timezone(){
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import com.google.gwt.user.client.rpc.IsSerializable;
|
|||
*/
|
||||
public class BrowseEntry implements Comparable<BrowseEntry>, IsSerializable{
|
||||
|
||||
public String value;
|
||||
public Long size;
|
||||
private String value;
|
||||
private Long size;
|
||||
|
||||
public BrowseEntry() {
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.*;
|
|||
|
||||
public class Converter {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(Converter.class);
|
||||
private static final Logger logger = Logger.getLogger(Converter.class);
|
||||
|
||||
public static Repository jsonToRepositoryObject(JSONObject repositoryObject) throws JSONException {
|
||||
|
||||
|
@ -32,9 +32,6 @@ public class Converter {
|
|||
|
||||
JSONObject datasource = repositoryObject.getJSONObject("datasource");
|
||||
|
||||
//if( datasource.equals(null))
|
||||
// return null;
|
||||
|
||||
repository.setId(datasource.get("id").toString());
|
||||
repository.setOfficialName(datasource.get("officialname").toString());
|
||||
|
||||
|
@ -107,7 +104,7 @@ public class Converter {
|
|||
return repository;
|
||||
}
|
||||
|
||||
public static Date convertStringToDate(String date){
|
||||
private static Date convertStringToDate(String date){
|
||||
|
||||
if(Objects.equals(date, "null"))
|
||||
return null;
|
||||
|
@ -116,12 +113,12 @@ public class Converter {
|
|||
try {
|
||||
return formatter.parse(date);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
logger.error("Error converting string to date",e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String convertDateToString(Date date){
|
||||
private static String convertDateToString(Date date){
|
||||
|
||||
if(Objects.equals(date, null))
|
||||
return null;
|
||||
|
@ -130,47 +127,13 @@ public class Converter {
|
|||
return formatter.format(date);
|
||||
}
|
||||
|
||||
public static Double toDouble(String number){
|
||||
private static Double toDouble(String number){
|
||||
if(Objects.equals(number, "null"))
|
||||
return 0.0;
|
||||
else
|
||||
return Double.valueOf(number);
|
||||
}
|
||||
|
||||
public static List<RepositorySnippet> jsonToRepositorySnippetList(JSONObject json) throws JSONException {
|
||||
|
||||
List<RepositorySnippet> resultSet = new ArrayList<>();
|
||||
JSONArray rs = json.getJSONArray("datasourceInfo");
|
||||
for(int i=0;i<rs.length();i++)
|
||||
resultSet.add(jsonToRepositorySnippetObject( rs.getJSONObject(i)) );
|
||||
return resultSet;
|
||||
}
|
||||
|
||||
private static RepositorySnippet jsonToRepositorySnippetObject(JSONObject repositorySnippetObject) throws JSONException {
|
||||
|
||||
|
||||
RepositorySnippet repositorySnippet = new RepositorySnippet();
|
||||
|
||||
// JSONObject datasource = repositorySnippetObject.getJSONObject("datasource");
|
||||
|
||||
|
||||
repositorySnippet.setId(repositorySnippetObject.get("id").toString());
|
||||
repositorySnippet.setOfficialname(repositorySnippetObject.get("officialname").toString());
|
||||
|
||||
repositorySnippet.setEnglishname( repositorySnippetObject.get("englishname").toString());
|
||||
if(repositorySnippet.getEnglishname().equals("null"))
|
||||
repositorySnippet.setEnglishname("");
|
||||
|
||||
repositorySnippet.setWebsiteurl(repositorySnippetObject.get("websiteurl").toString());
|
||||
if(repositorySnippet.getWebsiteurl().equals("null"))
|
||||
repositorySnippet.setWebsiteurl("");
|
||||
|
||||
repositorySnippet.setRegisteredby(repositorySnippetObject.get("registeredby").toString());
|
||||
if(repositorySnippet.getRegisteredby().equals("null"))
|
||||
repositorySnippet.setRegisteredby("");
|
||||
return repositorySnippet;
|
||||
|
||||
}
|
||||
|
||||
public static List<Repository> jsonToRepositoryList(JSONObject json) throws JSONException {
|
||||
|
||||
|
@ -205,15 +168,10 @@ public class Converter {
|
|||
repositoryInterface.setRemovable(Boolean.parseBoolean(repositoryInterfaceObject.get("removable").toString()));
|
||||
|
||||
|
||||
// repositoryInterface.setMetadataIdentifierPath(repositoryInterfaceObject.get("metadataIdentifierPath").toString());
|
||||
repositoryInterface.setDesiredCompatibilityLevel(repositoryInterfaceObject.get("compatibility").toString());
|
||||
//repositoryInterface.setActive(Boolean.parseBoolean(repositoryInterfaceObject.get("active").toString()));
|
||||
|
||||
|
||||
Map<String, String> accessParams = new HashMap<>();
|
||||
Map<String, String> extraFields = new HashMap<>();
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JSONArray apiparams = repositoryInterfaceObject.getJSONArray("apiParams");
|
||||
|
||||
for(int i=0;i<apiparams.length();i++)
|
||||
|
@ -224,7 +182,7 @@ public class Converter {
|
|||
return repositoryInterface;
|
||||
}
|
||||
|
||||
public static String repositoryObjectToJson(Repository repository) throws JSONException, JsonProcessingException {
|
||||
public static String repositoryObjectToJson(Repository repository) throws JsonProcessingException {
|
||||
|
||||
HashMap<String,Object> repositoryMap = new HashMap<>();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
@ -279,34 +237,12 @@ public class Converter {
|
|||
organizations.add(organization);
|
||||
repositoryMap.put("organizations",organizations);
|
||||
|
||||
//TODO check identitites
|
||||
//Map<String,String> identity = new HashMap<>();
|
||||
Map<String, Object> identities = new HashMap<>();
|
||||
identities.put("issuertype", "piwik");
|
||||
identities.put("pid","piwik:"+repository.getPiwikInfo().getSiteId());
|
||||
repositoryMap.put("identities",identities);
|
||||
repositoryMap.put("subjects","");
|
||||
|
||||
//TODO check fields
|
||||
/* jsonObject.put("certificates",repository.getCertificates());
|
||||
jsonObject.put("citationguidelineurl",repository.getCitationGuidelineUrl());
|
||||
jsonObject.put("databaseaccessrestriction",repository.getDatabaseAccessRestriction());
|
||||
jsonObject.put("databaseaccesstype",repository.getDatabaseAccessType());
|
||||
jsonObject.put("datauploadrestriction",repository.getDataUploadRestriction());
|
||||
jsonObject.put("datauploadtype",repository.getDataUploadType());
|
||||
jsonObject.put("missionstatementurl",repository.getMissionStatementUrl());
|
||||
jsonObject.put("od_contenttypes",repository.getOdContentTypes());
|
||||
jsonObject.put("officialname",repository.getOfficialname());
|
||||
jsonObject.put("pidsystems",repository.getPidSystems());
|
||||
jsonObject.put("provenanceaction",repository.getProvenanceActionClass());
|
||||
jsonObject.put("qualitymanagementkind",repository.getQualityManagementKind());
|
||||
jsonObject.put("releaseenddate",convertDateToString(repository.getReleaseEndDate()));
|
||||
jsonObject.put("releasestartdate",convertDateToString(repository.getReleaseStartDate()));
|
||||
jsonObject.put("serviceprovider",repository.getServiceProvider());
|
||||
jsonObject.put("versioning",repository.getVersioning());
|
||||
//datasource.get("platform");
|
||||
//datasource.get("subjects");*/
|
||||
|
||||
return mapper.writeValueAsString(repositoryMap);
|
||||
}
|
||||
|
||||
|
@ -344,9 +280,6 @@ public class Converter {
|
|||
jsonObject.put("apiParams",apiparams);
|
||||
|
||||
|
||||
// jsonObject.put("metadataIdentifierPath",repositoryInterface.getMetadataIdentifierPath());
|
||||
|
||||
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
|
@ -354,7 +287,6 @@ public class Converter {
|
|||
String line;
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
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) {
|
||||
|
@ -362,8 +294,7 @@ public class Converter {
|
|||
}
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
LOGGER.debug("Error opening file!");
|
||||
e.printStackTrace();
|
||||
logger.debug("Error opening file!",e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
@ -396,21 +327,6 @@ public class Converter {
|
|||
return aggregationDetails;
|
||||
}
|
||||
|
||||
public static AggregationDetails getLastCollectionFromJson(JSONObject datasourceInfo) throws JSONException {
|
||||
|
||||
if( datasourceInfo.get("lastCollection").equals(null))
|
||||
return null;
|
||||
|
||||
return jsonToAggregationDetails(datasourceInfo.getJSONObject("lastCollection"));
|
||||
}
|
||||
|
||||
public static AggregationDetails getLastTransformationFromJson(JSONObject datasourceInfo) throws JSONException {
|
||||
|
||||
if( datasourceInfo.get("lastTransformation").equals(null))
|
||||
return null;
|
||||
|
||||
return jsonToAggregationDetails(datasourceInfo.getJSONObject("lastTransformation"));
|
||||
}
|
||||
|
||||
public static List<Timezone> toTimezones(List<String> timezones) {
|
||||
|
||||
|
@ -422,7 +338,7 @@ public class Converter {
|
|||
return tmz;
|
||||
}
|
||||
|
||||
public static String getOpenaireId(String repositoryId) {
|
||||
private static String getOpenaireId(String repositoryId) {
|
||||
if (repositoryId != null && repositoryId.contains("::"))
|
||||
return repositoryId.split("::")[0] + "::" + DigestUtils.md5Hex(repositoryId.split("::")[1]);
|
||||
return null;
|
||||
|
|
|
@ -22,11 +22,11 @@ public class OaiTools {
|
|||
disableSslVerification();
|
||||
}
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(OaiTools.class);
|
||||
private static Logger logger = Logger.getLogger(OaiTools.class);
|
||||
|
||||
public static List<String> getSetsOfRepo(String baseUrl) throws Exception {
|
||||
try {
|
||||
LOGGER.debug("Getting sets of repository " + baseUrl);
|
||||
logger.debug("Getting sets of repository " + baseUrl);
|
||||
OaiPmhServer harvester = new OaiPmhServer(baseUrl);
|
||||
SetsList setList = harvester.listSets();
|
||||
ResumptionToken token = setList.getResumptionToken();
|
||||
|
@ -47,14 +47,13 @@ public class OaiTools {
|
|||
return ret;
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error getting sets of repository " + baseUrl, e);
|
||||
return new ArrayList<String>();
|
||||
//throw e;
|
||||
logger.error("Error getting sets of repository " + baseUrl, e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean identifyRepository(String baseUrl) throws Exception {
|
||||
LOGGER.debug("sending identify request to repo " + baseUrl);
|
||||
logger.debug("sending identify request to repo " + baseUrl);
|
||||
|
||||
OaiPmhServer harvester = new OaiPmhServer(baseUrl);
|
||||
|
||||
|
@ -69,7 +68,7 @@ public class OaiTools {
|
|||
|
||||
return verifyIdentify(d);
|
||||
} catch (Exception e) {
|
||||
LOGGER.debug("Error verifying identify response", e);
|
||||
logger.debug("Error verifying identify response", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
@ -110,21 +109,23 @@ public class OaiTools {
|
|||
private static void disableSslVerification() {
|
||||
try
|
||||
{
|
||||
LOGGER.debug("disabling ssl verification");
|
||||
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");
|
||||
SSLContext sc = SSLContext.getInstance("TLS");
|
||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
|
||||
|
@ -138,9 +139,9 @@ public class OaiTools {
|
|||
// Install the all-trusting host verifier
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
LOGGER.error("disabling ssl verification", e);
|
||||
logger.error("disabling ssl verification", e);
|
||||
} catch (KeyManagementException e) {
|
||||
LOGGER.error("error while disabling ssl verification", e);
|
||||
logger.error("error while disabling ssl verification", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}*/
|
|
@ -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);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
Loading…
Reference in New Issue