1. Dockerize service

2. Add authorization checks
3. Handle exceptions ( controller advice, exception package)
4. Login-logout operations bug fixes
This commit is contained in:
Panagiotis Kanakakis 2018-07-21 15:07:29 +00:00
parent 5c2dd36f0b
commit 5a38abef64
27 changed files with 379 additions and 251 deletions

View File

@ -2,8 +2,9 @@ FROM tomcat:8.5-jre8-alpine
MAINTAINER "pkanakakis@di.uoa.gr" MAINTAINER "pkanakakis@di.uoa.gr"
RUN ["rm", "-fr", "/usr/local/tomcat/webapps/ROOT"] RUN ["rm", "-fr", "/usr/local/tomcat/webapps/ROOT"]
COPY ./target/uoa-repository-manager-service.war /usr/local/tomcat/webapps/uoa-repository-manager-service.war COPY ./target/uoa-repository-manager-service.war /usr/local/tomcat/webapps/uoa-repository-manager-service.war
COPY ./src/main/resources/eu/dnetlib/repo/manager/service/application.properties /usr/local/tomcat/lib/application.properties COPY src/main/resources/dnet-override.properties /usr/local/tomcat/lib/dnet-override.properties
COPY ./src/main/resources/eu/dnetlib/repo/manager/service/email-texts.properties /usr/local/tomcat/lib/email-texts.properties #COPY src/main/resources/application.properties /usr/local/tomcat/lib/application.properties
#COPY src/main/resources/email-texts.properties /usr/local/tomcat/lib/email-texts.properties
VOLUME /var/log/uoa-repository-manager-service:/var/log/uoa-repository-manager-service/ VOLUME /var/log/uoa-repository-manager-service:/var/log/uoa-repository-manager-service/
CMD ["catalina.sh", "run"] CMD ["catalina.sh", "run"]

40
pom.xml
View File

@ -253,26 +253,26 @@
</plugin> </plugin>
<plugin> <!--<plugin>-->
<groupId>com.googlecode.maven-download-plugin</groupId> <!--<groupId>com.googlecode.maven-download-plugin</groupId>-->
<artifactId>download-maven-plugin</artifactId> <!--<artifactId>download-maven-plugin</artifactId>-->
<version>1.3.0</version> <!--<version>1.3.0</version>-->
<executions> <!--<executions>-->
<execution> <!--<execution>-->
<phase>process-resources</phase> <!--<phase>process-resources</phase>-->
<goals> <!--<goals>-->
<goal>wget</goal> <!--<goal>wget</goal>-->
</goals> <!--</goals>-->
<configuration> <!--<configuration>-->
<url> <!--<url>-->
https://github.com/ostranme/swagger-ui-themes/archive/v3.0.0.zip <!--https://github.com/ostranme/swagger-ui-themes/archive/v3.0.0.zip-->
</url> <!--</url>-->
<unpack>true</unpack> <!--<unpack>true</unpack>-->
<outputDirectory>${project.build.directory}</outputDirectory> <!--<outputDirectory>${project.build.directory}</outputDirectory>-->
</configuration> <!--</configuration>-->
</execution> <!--</execution>-->
</executions> <!--</executions>-->
</plugin> <!--</plugin>-->

View File

@ -15,7 +15,7 @@ import javax.annotation.PostConstruct;
@Configuration @Configuration
@EnableRedisHttpSession @EnableRedisHttpSession
@PropertySource(value = { "classpath:eu/dnetlib/repo/manager/service/application.properties"} ) @PropertySource(value = {"classpath:application.properties"} )
@ComponentScan(basePackages = "eu.dnetlib.repo.manager.service.controllers") @ComponentScan(basePackages = "eu.dnetlib.repo.manager.service.controllers")
public class Config { public class Config {
@ -51,8 +51,8 @@ public class Config {
DefaultCookieSerializer serializer = new DefaultCookieSerializer(); DefaultCookieSerializer serializer = new DefaultCookieSerializer();
serializer.setCookieName("openAIRESession"); serializer.setCookieName("openAIRESession");
serializer.setCookiePath("/"); serializer.setCookiePath("/");
// serializer.setDomainName(".openaire.eu"); // serializer.setDomainName(".openaire.eu");
serializer.setDomainName(".di.uoa.gr"); // serializer.setDomainName(".athenarc.gr");
LOGGER.info("Serializer : " + serializer); LOGGER.info("Serializer : " + serializer);
return serializer; return serializer;
} }

View File

@ -56,20 +56,21 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
.getSource().getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + ""); .getSource().getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + "");
Gson gson = new GsonBuilder().create();
Cookie openAIREUser = new Cookie("openAIREUser", new Gson().toJson(userInfo) ); Cookie openAIREUser = new Cookie("openAIREUser", new Gson().toJson(userInfo) );
openAIREUser .setMaxAge(14400); openAIREUser.setMaxAge(14400);
openAIREUser.setPath("/");
// openAIREUser .setDomain(".openaire.eu"); // openAIREUser .setDomain(".openaire.eu");
openAIREUser .setDomain(".di.uoa.gr"); // openAIREUser.setDomain(".athenarc.gr");
response.addCookie(openAIREUser); response.addCookie(openAIREUser);
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue()); Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
accessToken.setMaxAge(14400); accessToken.setMaxAge(14400);
// accessToken.setDomain(".openaire.eu"); // accessToken.setDomain(".openaire.eu");
accessToken.setDomain(".di.uoa.gr"); accessToken.setPath("/");
response.addCookie(accessToken);
// accessToken.setDomain(".athenarc.gr");
response.addCookie(accessToken);
response.sendRedirect(frontEndURI); response.sendRedirect(frontEndURI);
} }

View File

@ -4,9 +4,11 @@ import eu.dnetlib.repo.manager.shared.BrokerException;
import eu.dnetlib.repo.manager.shared.Term; import eu.dnetlib.repo.manager.shared.Term;
import eu.dnetlib.repo.manager.shared.broker.*; import eu.dnetlib.repo.manager.shared.broker.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.json.JSONException; import org.json.JSONException;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.io.IOException; import java.io.IOException;
@ -23,7 +25,7 @@ public interface BrokerApi {
@ResponseBody @ResponseBody
DatasourcesBroker getDatasourcesOfUser(String user,String includeShared,String includeByOthers) throws BrokerException, JSONException; DatasourcesBroker getDatasourcesOfUser(String user,String includeShared,String includeByOthers) throws BrokerException, JSONException;
@RequestMapping(value = "/getTopicsForDatasource/{datasourceName}" , method = RequestMethod.GET, @RequestMapping(value = "/getTopicsForDatasource/{datasourceName:.+}" , method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
List<BrowseEntry> getTopicsForDatasource(String datasourceName) throws BrokerException; List<BrowseEntry> getTopicsForDatasource(String datasourceName) throws BrokerException;
@ -35,7 +37,7 @@ public interface BrokerApi {
String size, String size,
AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException; AdvQueryObject advQueryObject) throws BrokerException, JSONException ,IOException;
@RequestMapping(value = "/showEvents/{datasourceName}/{topic}/{page}" , method = RequestMethod.GET, @RequestMapping(value = "/showEvents/{datasourceName:.+}/{topic}/{page}" , method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
EventsPage showEvents(String datasourceName, EventsPage showEvents(String datasourceName,
@ -56,7 +58,7 @@ public interface BrokerApi {
@RequestMapping(value = "/unsubscribe/{subscriptionId}" , method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_VALUE, @RequestMapping(value = "/unsubscribe/{subscriptionId}" , method = RequestMethod.POST,consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
void unsubscribe(String subscriptionId) throws BrokerException; ResponseEntity<Object> unsubscribe(String subscriptionId) throws BrokerException;
@RequestMapping(value = "/getSubscription/{subscriptionId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getSubscription/{subscriptionId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody

View File

@ -9,14 +9,10 @@ import eu.dnetlib.repo.manager.shared.Tuple;
import eu.dnetlib.repo.manager.shared.broker.*; import eu.dnetlib.repo.manager.shared.broker.*;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity; import org.springframework.http.*;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -284,7 +280,7 @@ public class BrokerApiImpl implements BrokerApi {
} }
@Override @Override
@PreAuthorize("hasRole('ROLE_USER')") @PreAuthorize("hasRole('ROLE_USER') ")
public Subscription subscribe(@RequestBody OpenaireSubscription obj) throws BrokerException { public Subscription subscribe(@RequestBody OpenaireSubscription obj) throws BrokerException {
final String service = "/subscribe"; final String service = "/subscribe";
@ -316,7 +312,7 @@ public class BrokerApiImpl implements BrokerApi {
@Override @Override
@PreAuthorize("hasRole('ROLE_USER')") @PreAuthorize("hasRole('ROLE_USER')")
public void unsubscribe(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException { public ResponseEntity<Object> unsubscribe(@PathVariable("subscriptionId") String subscriptionId) throws BrokerException {
final String service = "/subscriptions/" + subscriptionId; final String service = "/subscriptions/" + subscriptionId;
//build the uri params //build the uri params
@ -335,6 +331,7 @@ public class BrokerApiImpl implements BrokerApi {
emailUtils.reportException(e); emailUtils.reportException(e);
throw new BrokerException(e); throw new BrokerException(e);
} }
return new ResponseEntity<>("OK",HttpStatus.OK);
} }
@Override @Override

View File

@ -8,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.io.Writer; import java.io.Writer;
@ -39,6 +40,13 @@ public class EmailUtilsImpl implements EmailUtils {
@Value("${services.repomanager.usagestats.adminEmail}") @Value("${services.repomanager.usagestats.adminEmail}")
private String usageStatsAdminEmail; private String usageStatsAdminEmail;
@PostConstruct
public void init(){
System.out.println("base url -> " + this.baseUrl);
}
@Override @Override
public void reportException(Exception exception) { public void reportException(Exception exception) {
Writer writer = new StringWriter(); Writer writer = new StringWriter();

View File

@ -0,0 +1,57 @@
package eu.dnetlib.repo.manager.service.controllers;
import eu.dnetlib.api.functionality.ValidatorServiceException;
import eu.dnetlib.repo.manager.service.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.service.exception.ServerError;
import eu.dnetlib.repo.manager.shared.BrokerException;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.json.JSONException;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.net.UnknownHostException;
@ControllerAdvice
@Order(Ordered.HIGHEST_PRECEDENCE)
public class GenericControllerAdvice {
private Logger logger = LogManager.getLogger(GenericControllerAdvice.class);
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(ResourceNotFoundException.class)
@ResponseBody
ServerError securityException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(),ex);
}
@ResponseStatus(HttpStatus.FORBIDDEN)
@ExceptionHandler(AccessDeniedException.class)
@ResponseBody
ServerError accessDeniedException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(),ex);
}
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(UnknownHostException.class)
@ResponseBody
ServerError unknownHostException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(),ex);
}
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler({JSONException.class,BrokerException.class,ValidatorServiceException.class})
@ResponseBody
ServerError internalException(HttpServletRequest req, Exception ex) {
return new ServerError(req.getRequestURL().toString(),ex);
}
}

View File

@ -6,6 +6,7 @@ import eu.dnetlib.repo.manager.shared.JobsOfUser;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.json.JSONException; import org.json.JSONException;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@RestController @RestController

View File

@ -2,11 +2,10 @@ package eu.dnetlib.repo.manager.service.controllers;
import eu.dnetlib.domain.data.PiwikInfo; import eu.dnetlib.domain.data.PiwikInfo;
import eu.dnetlib.domain.data.Repository;
import eu.dnetlib.domain.functionality.UserProfile;
import eu.dnetlib.repo.manager.shared.RepositoryServiceException; import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@ -29,7 +28,7 @@ public interface PiWikApi {
@RequestMapping(value = "/approvePiwikSite/{repositoryId}" , method = RequestMethod.GET) @RequestMapping(value = "/approvePiwikSite/{repositoryId}" , method = RequestMethod.GET)
@ResponseBody @ResponseBody
void approvePiwikSite(String repositoryId); ResponseEntity<Object> approvePiwikSite(String repositoryId);
@RequestMapping(value = "/getOpenaireId/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getOpenaireId/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
@ -39,9 +38,9 @@ public interface PiWikApi {
@RequestMapping(value = "/markPiwikSiteAsValidated/{repositoryId}" , method = RequestMethod.POST, @RequestMapping(value = "/markPiwikSiteAsValidated/{repositoryId}" , method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
void markPiwikSiteAsValidated(String repositoryId) throws RepositoryServiceException; ResponseEntity<Object> markPiwikSiteAsValidated(String repositoryId) throws RepositoryServiceException;
@RequestMapping(value = "/enableMetricsForRepository", method = RequestMethod.POST, @RequestMapping(value = "/enableMetricsForRepository", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
void enableMetricsForRepository(String officialName,String repoWebsite,PiwikInfo piwikInfo) throws RepositoryServiceException; PiwikInfo enableMetricsForRepository(String officialName,String repoWebsite,PiwikInfo piwikInfo) throws RepositoryServiceException;
} }

View File

@ -2,15 +2,18 @@ package eu.dnetlib.repo.manager.service.controllers;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import eu.dnetlib.domain.data.PiwikInfo; import eu.dnetlib.domain.data.PiwikInfo;
import eu.dnetlib.domain.data.Repository;
import eu.dnetlib.repo.manager.shared.RepositoryServiceException; import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.EmptyResultDataAccessException; 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.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.RowMapper;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -29,8 +32,8 @@ import java.util.Map;
@Component @Component
public class PiWikApiImpl implements PiWikApi{ public class PiWikApiImpl implements PiWikApi{
@Autowired
@Qualifier("repomanager.dataSource") @Qualifier("repomanager.dataSource")
@Autowired
private DataSource dataSource; private DataSource dataSource;
@ -42,7 +45,7 @@ public class PiWikApiImpl implements PiWikApi{
@Qualifier("emailUtils") @Qualifier("emailUtils")
EmailUtils emailUtils; EmailUtils emailUtils;
private static final org.apache.log4j.Logger LOGGER = org.apache.log4j.Logger private static final Logger LOGGER = Logger
.getLogger(PiWikApiImpl.class); .getLogger(PiWikApiImpl.class);
private final static String GET_PIWIK_SITE = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site where repositoryid = ?;"; private final static String GET_PIWIK_SITE = "select repositoryid, siteid, authenticationtoken, creationdate, requestorname, requestoremail, validated, validationdate, comment, repositoryname, country from piwik_site where repositoryid = ?;";
@ -92,8 +95,9 @@ public class PiWikApiImpl implements PiWikApi{
@Override @Override
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
public void approvePiwikSite(@PathVariable("repositoryId") String repositoryId) { public ResponseEntity<Object> approvePiwikSite(@PathVariable("repositoryId") String repositoryId) {
new JdbcTemplate(dataSource).update(APPROVE_PIWIK_SITE, new Object[] {repositoryId}, new int[] {Types.VARCHAR}); new JdbcTemplate(dataSource).update(APPROVE_PIWIK_SITE, new Object[] {repositoryId}, new int[] {Types.VARCHAR});
return new ResponseEntity<>("OK",HttpStatus.OK);
} }
@Override @Override
@ -105,7 +109,7 @@ public class PiWikApiImpl implements PiWikApi{
@Override @Override
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
public void markPiwikSiteAsValidated(@PathVariable("repositoryId") String repositoryId) throws RepositoryServiceException { public ResponseEntity<Object> markPiwikSiteAsValidated(@PathVariable("repositoryId") String repositoryId) throws RepositoryServiceException {
try { try {
approvePiwikSite(repositoryId); approvePiwikSite(repositoryId);
@ -121,13 +125,14 @@ public class PiWikApiImpl implements PiWikApi{
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); emailUtils.reportException(e);
} }
return new ResponseEntity<>("OK",HttpStatus.OK);
} }
@Override @Override
@PreAuthorize("hasRole('ROLE_USER')") @PreAuthorize("hasRole('ROLE_ADMIN') or (hasRole('ROLE_USER') and #piwikInfo.requestorEmail == authentication.userInfo.email)")
public void enableMetricsForRepository(@RequestParam("officialName") String officialName, public PiwikInfo enableMetricsForRepository(@RequestParam("officialName") String officialName,
@RequestParam("repoWebsite") String repoWebsite, @RequestParam("repoWebsite") String repoWebsite,
@RequestBody PiwikInfo piwikInfo) throws RepositoryServiceException { @RequestBody PiwikInfo piwikInfo) throws RepositoryServiceException {
try { try {
@ -155,6 +160,7 @@ public class PiWikApiImpl implements PiWikApi{
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); emailUtils.reportException(e);
} }
return piwikInfo;
} }

View File

@ -2,11 +2,12 @@ package eu.dnetlib.repo.manager.service.controllers;
import eu.dnetlib.domain.data.Repository; import eu.dnetlib.domain.data.Repository;
import eu.dnetlib.domain.data.RepositoryInterface; import eu.dnetlib.domain.data.RepositoryInterface;
import eu.dnetlib.domain.functionality.UserProfile; import eu.dnetlib.repo.manager.service.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.shared.*; import eu.dnetlib.repo.manager.shared.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.json.JSONException; import org.json.JSONException;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -38,16 +39,21 @@ public interface RepositoryApi {
@RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET, @RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
Repository getRepositoryById(String id) throws JSONException; Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException;
@RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET, @RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
Aggregations getRepositoryAggregations(String id) throws JSONException; List<AggregationDetails> getRepositoryAggregations(String id) throws JSONException;
@RequestMapping(value = "/getRepositoryAggregationsByYear/{id}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
Map<String,List<AggregationDetails>> getRepositoryAggregationsByYear(String id) throws JSONException;
@RequestMapping(value = "/getRepositoriesByName/{name}/{page}/{size}/", method = RequestMethod.GET, @RequestMapping(value = "/getRepositoriesByName/{name:.+}/{page}/{size}/", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
List<Repository> getRepositoriesByName(String name, List<Repository> getRepositoriesByName(String name,
@ -66,14 +72,15 @@ public interface RepositoryApi {
@RequestMapping(value = "/deleteInterface/", method = RequestMethod.DELETE) @RequestMapping(value = "/deleteInterface/", method = RequestMethod.DELETE)
void deleteRepositoryInterface(String id); void deleteRepositoryInterface(String id,String registeredBy);
@RequestMapping(value = "/addInterface", method = RequestMethod.POST, @RequestMapping(value = "/addInterface", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
RepositoryInterface addRepositoryInterface(String datatype, RepositoryInterface addRepositoryInterface(String datatype,
String repoId, String repoId,
RepositoryInterface iFace) throws JSONException; String registeredBy,
RepositoryInterface iFace) throws JSONException,ResourceNotFoundException;
@RequestMapping(value = "/getDnetCountries", method = RequestMethod.GET, @RequestMapping(value = "/getDnetCountries", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
@ -133,7 +140,7 @@ public interface RepositoryApi {
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST, @RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
RepositoryInterface updateRepositoryInterface(String repositoryId,RepositoryInterface repositoryInterface) throws JSONException; RepositoryInterface updateRepositoryInterface(String repositoryId,String registeredBy,RepositoryInterface repositoryInterface) throws JSONException;

View File

@ -6,8 +6,9 @@ import com.fasterxml.jackson.databind.SerializationFeature;
import eu.dnetlib.domain.data.Repository; import eu.dnetlib.domain.data.Repository;
import eu.dnetlib.domain.data.RepositoryInterface; import eu.dnetlib.domain.data.RepositoryInterface;
import eu.dnetlib.domain.enabling.Vocabulary; import eu.dnetlib.domain.enabling.Vocabulary;
import eu.dnetlib.repo.manager.service.utils.Converter;
import eu.dnetlib.repo.manager.service.domain.RequestFilter; import eu.dnetlib.repo.manager.service.domain.RequestFilter;
import eu.dnetlib.repo.manager.service.exception.ResourceNotFoundException;
import eu.dnetlib.repo.manager.service.utils.Converter;
import eu.dnetlib.repo.manager.shared.*; import eu.dnetlib.repo.manager.shared.*;
import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader; import gr.uoa.di.driver.enabling.vocabulary.VocabularyLoader;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
@ -18,8 +19,13 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.*; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -32,9 +38,10 @@ import org.springframework.web.util.UriComponentsBuilder;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.Normalizer;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.stream.Collectors;
@Component @Component
public class RepositoryApiImpl implements RepositoryApi { public class RepositoryApiImpl implements RepositoryApi {
@ -174,7 +181,7 @@ public class RepositoryApiImpl implements RepositoryApi {
jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo"); jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
} }
for (Repository r : resultSet) for (Repository r : resultSet)
this.getRepositoryInfo(r); this.updateRepositoryInfo(r);
return resultSet; return resultSet;
}catch (Exception e){ }catch (Exception e){
@ -186,7 +193,7 @@ public class RepositoryApiImpl implements RepositoryApi {
} }
private void getRepositoryInfo(Repository r) throws JSONException { private Repository updateRepositoryInfo(Repository r) throws JSONException {
/* /*
* from datasource class * from datasource class
@ -196,6 +203,7 @@ public class RepositoryApiImpl implements RepositoryApi {
r.setInterfaces(this.getRepositoryInterface(r.getId())); r.setInterfaces(this.getRepositoryInterface(r.getId()));
r.setPiwikInfo(piWikApi.getPiwikSiteForRepo(r.getId())); r.setPiwikInfo(piWikApi.getPiwikSiteForRepo(r.getId()));
r.setCountryName(getCountryName(r.getCountryCode())); r.setCountryName(getCountryName(r.getCountryCode()));
return r;
} }
@ -226,7 +234,7 @@ public class RepositoryApiImpl implements RepositoryApi {
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs)); List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
for (Repository r : repos) for (Repository r : repos)
this.getRepositoryInfo(r); this.updateRepositoryInfo(r);
return repos; return repos;
}catch (Exception e){ }catch (Exception e){
@ -237,7 +245,7 @@ public class RepositoryApiImpl implements RepositoryApi {
} }
@Override @Override
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException { 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; Repository repo = null;
@ -248,12 +256,13 @@ public class RepositoryApiImpl implements RepositoryApi {
try{ try{
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo"); JSONArray jsonArray = (JSONArray) new JSONObject(rs).get("datasourceInfo");
if(jsonArray.length() > 0)
repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0)); if(jsonArray.length() == 0)
if (repo != null) throw new ResourceNotFoundException();
getRepositoryInfo(repo);
return repo; repo = Converter.jsonToRepositoryObject(jsonArray.getJSONObject(0));
}catch (Exception e){ return updateRepositoryInfo(repo);
}catch (JSONException e){
LOGGER.debug("Exception on getRepositoryById" , e); LOGGER.debug("Exception on getRepositoryById" , e);
emailUtils.reportException(e); emailUtils.reportException(e);
throw e; throw e;
@ -263,22 +272,23 @@ public class RepositoryApiImpl implements RepositoryApi {
@Override @Override
public Aggregations getRepositoryAggregations(@PathVariable("id") String id) throws JSONException { public List<AggregationDetails> getRepositoryAggregations(@PathVariable("id") 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"); UriComponents uriComponents = searchDatasource("0","100");
RequestFilter requestFilter = new RequestFilter(); RequestFilter requestFilter = new RequestFilter();
requestFilter.setId(id); requestFilter.setId(id);
Aggregations aggregations = new Aggregations();
List<AggregationDetails> aggregationHistory = new ArrayList<>();
try { try {
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
JSONObject repository = new JSONObject(rs); JSONObject repository = new JSONObject(rs);
aggregationHistory.addAll(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
aggregations.setAggregationHistory(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0))); return aggregationHistory.size() == 0? aggregationHistory : aggregationHistory.stream()
aggregations.setLastCollection(Converter.getLastCollectionFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0))); .sorted(Comparator.comparing(AggregationDetails::getDate).reversed())
aggregations.setLastTransformation(Converter.getLastTransformationFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0))); .limit(20)
return aggregations; .collect(Collectors.toList());
} catch (JSONException e) { } catch (JSONException e) {
LOGGER.debug("Exception on getRepositoryAggregations" , e); LOGGER.debug("Exception on getRepositoryAggregations" , e);
emailUtils.reportException(e); emailUtils.reportException(e);
@ -287,6 +297,39 @@ public class RepositoryApiImpl implements RepositoryApi {
} }
@Override
public Map<String, List<AggregationDetails>> getRepositoryAggregationsByYear(@PathVariable("id") String id) throws JSONException {
LOGGER.debug("Retreiving aggregations (by year) for repository with id : " + id );
UriComponents uriComponents = searchDatasource("0","100");
RequestFilter requestFilter = new RequestFilter();
requestFilter.setId(id);
List<AggregationDetails> aggregationHistory = new ArrayList<>();
Map<String, List<AggregationDetails>> aggregationByYear = new HashMap<>();
try {
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
JSONObject repository = new JSONObject(rs);
aggregationHistory.addAll(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
return aggregationHistory.size() == 0? aggregationByYear:createYearMap(aggregationHistory);
} catch (JSONException e) {
LOGGER.debug("Exception on getRepositoryAggregations" , e);
emailUtils.reportException(e);
throw e;
}
}
private Map<String,List<AggregationDetails>> createYearMap(List<AggregationDetails> aggregationHistory) {
Map<String, List<AggregationDetails>> aggregationByYear;
aggregationHistory = aggregationHistory.stream()
.sorted(Comparator.comparing(AggregationDetails::getDate).reversed())
.collect(Collectors.toList());
return aggregationHistory.stream()
.collect(Collectors.groupingBy(AggregationDetails::getYear));
}
@Override @Override
public List<Repository> getRepositoriesByName(@PathVariable("name") String name, public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
@PathVariable("page") String page, @PathVariable("page") String page,
@ -301,7 +344,7 @@ public class RepositoryApiImpl implements RepositoryApi {
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class); String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs)); List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
for (Repository r : repos) for (Repository r : repos)
getRepositoryInfo(r); updateRepositoryInfo(r);
return repos; return repos;
}catch (Exception e){ }catch (Exception e){
LOGGER.debug("Exception on getRepositoriesByName" , e); LOGGER.debug("Exception on getRepositoriesByName" , e);
@ -331,7 +374,7 @@ public class RepositoryApiImpl implements RepositoryApi {
} }
@Override @Override
@PreAuthorize("hasRole('ROLE_USER')") @PreAuthorize("hasRole('ROLE_USER') and #repository.registeredBy == authentication.userInfo.email")
public Repository addRepository(@RequestParam("datatype") String datatype, public Repository addRepository(@RequestParam("datatype") String datatype,
@RequestBody Repository repository) throws Exception { @RequestBody Repository repository) throws Exception {
@ -342,7 +385,7 @@ public class RepositoryApiImpl implements RepositoryApi {
} }
@Override @Override
@PreAuthorize("hasRole('ROLE_USER')") @PreAuthorize("hasRole('ROLE_USER') and #repository.registeredBy == authentication.userInfo.email")
public Repository updateRepository(@RequestBody Repository repository) throws JSONException { public Repository updateRepository(@RequestBody Repository repository) throws JSONException {
UriComponents uriComponents = UriComponentsBuilder UriComponents uriComponents = UriComponentsBuilder
.fromHttpUrl(baseAddress + "/ds/update/") .fromHttpUrl(baseAddress + "/ds/update/")
@ -432,8 +475,9 @@ public class RepositoryApiImpl implements RepositoryApi {
} }
@Override @Override
@PreAuthorize("hasRole('ROLE_USER')") @PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
public void deleteRepositoryInterface(@RequestParam("id") String id){ public void deleteRepositoryInterface(@RequestParam("id") String id ,
@RequestParam("registeredBy") String registeredBy){
UriComponents uriComponents = UriComponentsBuilder UriComponents uriComponents = UriComponentsBuilder
.fromHttpUrl(baseAddress + "/ds/api/") .fromHttpUrl(baseAddress + "/ds/api/")
.path("/{id}") .path("/{id}")
@ -443,10 +487,11 @@ public class RepositoryApiImpl implements RepositoryApi {
} }
@Override @Override
@PreAuthorize("hasRole('ROLE_USER')") @PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype, public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
@RequestParam("repoId") String repoId, @RequestParam("repoId") String repoId,
@RequestBody RepositoryInterface repositoryInterface) throws JSONException { @RequestParam("registeredBy") String registeredBy,
@RequestBody RepositoryInterface repositoryInterface) throws JSONException,ResourceNotFoundException {
try { try {
Repository e = this.getRepositoryById(repoId); Repository e = this.getRepositoryById(repoId);
repositoryInterface = createRepositoryInterface(e,repositoryInterface,datatype); repositoryInterface = createRepositoryInterface(e,repositoryInterface,datatype);
@ -670,8 +715,9 @@ public class RepositoryApiImpl implements RepositoryApi {
} }
@Override @Override
@PreAuthorize("hasRole('ROLE_USER')") @PreAuthorize("hasRole('ROLE_USER') and #registeredBy == authentication.userInfo.email")
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId, public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId,
@RequestParam("registeredBy") String registeredBy,
@RequestBody RepositoryInterface repositoryInterface) throws JSONException { @RequestBody RepositoryInterface repositoryInterface) throws JSONException {
this.updateBaseUrl(repoId,repositoryInterface.getId(),repositoryInterface.getBaseUrl()); this.updateBaseUrl(repoId,repositoryInterface.getId(),repositoryInterface.getBaseUrl());

View File

@ -9,6 +9,7 @@ import eu.dnetlib.repo.manager.shared.ValidationServiceException;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.json.JSONException; import org.json.JSONException;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@ -19,13 +20,17 @@ import java.util.List;
@Api(description = "Validator API", tags = {"validator"}) @Api(description = "Validator API", tags = {"validator"})
public interface ValidatorApi { public interface ValidatorApi {
@RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE ) @RequestMapping(value = "/submitJobForValidation",method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
void submitJobForValidation(JobForValidation jobForValidation); JobForValidation submitJobForValidation(JobForValidation jobForValidation) throws ValidatorServiceException;
@RequestMapping(value = "/reSubmitJobForValidation/{jobId}",method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE ) @RequestMapping(value = "/reSubmitJobForValidation/{email}/{jobId}",method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody
void reSubmitJobForValidation(String jobId) throws JSONException; ResponseEntity<Object> reSubmitJobForValidation(String email,String jobId) throws JSONException, ValidatorServiceException;
@RequestMapping(value = "/getRuleSets/{mode}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getRuleSets/{mode}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody @ResponseBody

View File

@ -17,6 +17,8 @@ import io.swagger.annotations.ApiParam;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.json.JSONException; import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -86,20 +88,23 @@ public class ValidatorApiImpl implements ValidatorApi{
} }
@Override @Override
@PreAuthorize("hasRole('ROLE_USER')") @PreAuthorize("hasRole('ROLE_USER') and #jobForValidation.userEmail == authentication.userInfo.email")
public void submitJobForValidation(@RequestBody JobForValidation jobForValidation) { public JobForValidation submitJobForValidation(@RequestBody JobForValidation jobForValidation) throws ValidatorServiceException {
LOGGER.debug("Submit job for validation with id : " + jobForValidation.getDatasourceId()); LOGGER.debug("Submit job for validation with id : " + jobForValidation.getDatasourceId());
try { try {
this.getValidationService().submitValidationJob(jobForValidation); this.getValidationService().submitValidationJob(jobForValidation);
} catch (ValidatorServiceException e) { } catch (ValidatorServiceException e) {
LOGGER.debug("Exception on submitJobForValidation" , e); LOGGER.debug("Exception on submitJobForValidation" , e);
emailUtils.reportException(e); emailUtils.reportException(e);
throw e;
} }
return jobForValidation;
} }
@Override @Override
@PreAuthorize("hasRole('ROLE_USER')") @PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email")
public void reSubmitJobForValidation(@PathVariable("jobId") String jobId) throws JSONException { public ResponseEntity<Object> reSubmitJobForValidation(@PathVariable("email") String email,
@PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException {
LOGGER.debug("Resubmit validation job with id : " + jobId); LOGGER.debug("Resubmit validation job with id : " + jobId);
StoredJob job = monitorApi.getJobSummary(jobId,"all"); StoredJob job = monitorApi.getJobSummary(jobId,"all");
Set<Integer> contentRules = new HashSet<Integer>(); Set<Integer> contentRules = new HashSet<Integer>();
@ -125,6 +130,7 @@ public class ValidatorApiImpl implements ValidatorApi{
if (!usageRules.isEmpty()) if (!usageRules.isEmpty())
job.setSelectedUsageRules(usageRules); job.setSelectedUsageRules(usageRules);
this.submitJobForValidation(job); this.submitJobForValidation(job);
return new ResponseEntity<>("OK",HttpStatus.OK);
} }
@Override @Override

View File

@ -0,0 +1,15 @@
package eu.dnetlib.repo.manager.service.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ResponseStatus(HttpStatus.NOT_FOUND)
public class ResourceNotFoundException extends Exception {
public ResourceNotFoundException() {
super("Resource Not Found");
}
public ResourceNotFoundException(String id, String resourceType) {
super(resourceType + " with id " + id + " was not found");
}
}

View File

@ -0,0 +1,21 @@
package eu.dnetlib.repo.manager.service.exception;
public class ServerError {
public final String url;
public final String error;
public ServerError(String url, Exception ex) {
this.url = url;
this.error = ex.getMessage();
}
public String getUrl() {
return this.url;
}
public String getError() {
return this.error;
}
}

View File

@ -29,8 +29,8 @@ public class Converter {
JSONObject datasource = repositoryObject.getJSONObject("datasource"); JSONObject datasource = repositoryObject.getJSONObject("datasource");
if( datasource.equals(null)) //if( datasource.equals(null))
return null; // return null;
repository.setId(datasource.get("id").toString()); repository.setId(datasource.get("id").toString());
repository.setOfficialName(datasource.get("officialname").toString()); repository.setOfficialName(datasource.get("officialname").toString());
@ -321,8 +321,8 @@ public class Converter {
public static List<AggregationDetails> getAggregationHistoryFromJson(JSONObject datasourceInfo) throws JSONException { public static List<AggregationDetails> getAggregationHistoryFromJson(JSONObject datasourceInfo) throws JSONException {
if(datasourceInfo.get("aggregationHistory").toString().equals("[]")) // if(datasourceInfo.get("aggregationHistory").toString().equals("[]"))
return null; // return null;
JSONArray rs = new JSONArray(datasourceInfo.get("aggregationHistory").toString()); JSONArray rs = new JSONArray(datasourceInfo.get("aggregationHistory").toString());
List<AggregationDetails> aggregationDetailsList = new ArrayList<>(); List<AggregationDetails> aggregationDetailsList = new ArrayList<>();

View File

@ -2,6 +2,7 @@ package eu.dnetlib.repo.manager.shared;
import com.google.gwt.user.client.rpc.IsSerializable; import com.google.gwt.user.client.rpc.IsSerializable;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
public class AggregationDetails implements IsSerializable{ public class AggregationDetails implements IsSerializable{
@ -46,4 +47,10 @@ public class AggregationDetails implements IsSerializable{
public void setNumberOfRecords(int numberOfRecords) { public void setNumberOfRecords(int numberOfRecords) {
this.numberOfRecords = numberOfRecords; this.numberOfRecords = numberOfRecords;
} }
public String getYear() {
Calendar calendar = Calendar.getInstance();
calendar.setTime(getDate());
return String.valueOf(calendar.get(Calendar.YEAR));
}
} }

View File

@ -1,19 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<context:property-placeholder location="classpath*:/eu/**/application.properties" />
<context:annotation-config/> <context:annotation-config/>
<context:component-scan base-package="eu.dnetlib.repo.manager.service.config"/> <context:component-scan base-package="eu.dnetlib.repo.manager.service.*"/>
<tx:annotation-driven transaction-manager="txManager"/> <tx:annotation-driven transaction-manager="txManager"/>
<bean class="eu.dnetlib.repo.manager.service.config.CascadingPropertyLoader" <bean class="eu.dnetlib.repo.manager.service.config.CascadingPropertyLoader"
@ -32,7 +26,8 @@
<value>classpath*:/gr/**/springContext-*.properties</value> <value>classpath*:/gr/**/springContext-*.properties</value>
<value>classpath*:/eu/**/springContext-*.properties</value> <value>classpath*:/eu/**/springContext-*.properties</value>
<value>classpath*:/eu/dnetlib/repo/manager/service/email-texts.properties</value> <value>classpath*:/application.properties</value>
<value>classpath*:email-texts.properties</value>
<value>classpath*:dnet-site-wizard.properties</value> <value>classpath*:dnet-site-wizard.properties</value>
<value>classpath*:dnet-site-override.properties</value> <value>classpath*:dnet-site-override.properties</value>

View File

@ -0,0 +1,78 @@
infrastructure.name=integration
#
## Container properties
container.hostname=aleka.athenarc.gr
container.context=uoa-repository-manager-service
container.port = 8480
#
## IS
ISLookUpService.url = http://node6.t.openaire.research-infrastructures.eu/is/services/isLookUp
ISRegistryService.url = http://node6.t.openaire.research-infrastructures.eu/is/services/isRegistry
ISSNService.url = http://node6.t.openaire.research-infrastructures.eu/is/services/isSN
#
#
ValidatorService.url=http://adonis.athenarc.gr:8080/validator-service/services/validatorWebService
#
## Broker Service
services.broker.url = http://broker1-dev-dnet.d4science.org
services.broker.port = 8080
services.broker.api = api/
services.broker.openaire = openaireBroker
#
#
api.baseAddress=https://dev-openaire.d4science.org/openaire
##api.baseAddress=http://beta.services.openaire.eu:8080/openaire
#
service.repository-rest-api.baseUrl =http://${container.hostname}:${container.port}
services.repo-manager.baseUrl = http://${container.hostname}:${container.port}/${container.context}
#
transport.soap.baseAddress = http://${container.hostname}:${container.port}/${container.context}
transport.soap.force.local.address = false
#
services.repo-manager.adminEmail = pkanakakis@di.uoa.gr
services.repo-manager.repository.testing.mode = false
services.repo-manager.deploy.environment = development
services.validator.mail.host = smtp.gmail.com
services.validator.mail.port = 465
services.validator.mail.fromAddress = no-reply@openaire.eu
services.validator.mail.replyToAddress = no-reply@openaire.eu
services.validator.mail.username = test.openaire@gmail.com
services.validator.mail.password = ^($*@$)*!$
services.validator.mail.authenticate = true
services.validator.mail.override = false
services.validator.mail.logonly = false
services.validator.mail.mode = ssl
services.validator.mail.debug = false
services.validator.mail.overrideEmail = pkanakakis@di.uoa.gr
services.validator.mail.specialRecipients = pkanakakis@di.uoa.gr
#
services.validator.repoRegistration.override = pkanakakis@di.uoa.gr
#
#
repomanager.db.driverClassName = org.postgresql.Driver
repomanager.db.url = jdbc:postgresql://194.177.192.119:5432/repomanager
repomanager.db.username = dnet
repomanager.db.password = dnetPwd
#
services.repomanager.analyticsURL = http://analytics.openaire.eu/addsite.php?
#
topic_types.url = https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:topic_types.json
#
oidc.issuer = https://aai.openaire.eu/oidc/
oidc.id = 767422b9-5461-4807-a80a-f9a2072d3a7d
oidc.secret = AMQtGlbTXNjwjhF0st28LmM6V0XypMdaVS7tJmGuYFlmH36iIv4t7tVqYuLYrNPkhnZ_GPUJvhymBhFupdgb6aU
#
#oidc.dev.home = http://koulis.athenarc.gr:4200/uoa-repository-manager-service/openid_connect_login
#webapp.dev.front = http://koulis.athenarc.gr:4200/landing
oidc.dev.home = http://aleka.athenarc.gr:4200/uoa-repository-manager-service/openid_connect_login
webapp.dev.front = http://aleka.athenarc.gr:4200/landing
#
redis.host = audrey.athenarc.gr
redis.port = 6379
redis.password = E#Szvnidd
#
services.repomanager.usageStatisticsDiagramsBaseURL = https://beta.openaire.eu/stats3/
services.repomanager.usageStatisticsNumbersBaseURL = https://beta.services.openaire.eu/usagestats/datasources/
services.repomanager.usagestats.adminEmail = pkanakakis@di.uoa.gr

View File

@ -1,125 +0,0 @@
infrastructure.name=integration
# Container properties
container.hostname = localhost
container.context=repoManager
container.port = 8080
# IS
ISLookUpService.url = http://node6.t.openaire.research-infrastructures.eu/is/services/isLookUp
ISRegistryService.url = http://node6.t.openaire.research-infrastructures.eu/is/services/isRegistry
ISSNService.url = http://node6.t.openaire.research-infrastructures.eu/is/services/isSN
#ISLookUpService.url = http://localhost:9190/is/services/isLookUp
#ISRegistryService.url = http://localhost:9190/is/services/isRegistry
#ISSNService.url = http://localhost:9190/is/services/isSN
# LDAP
services.users.ldap.address = 194.177.192.119
services.users.ldap.port = 389
services.users.ldap.username = cn=admin,dc=openaire,dc=eu
services.users.ldap.password = serenata
services.users.ldap.usersDN = ou=users,dc=openaire,dc=eu
#services.repo-manager.repository.testing.mode = true
ValidatorService.url=http://adonis.athenarc.gr:8080/validator-service/services/validatorWebService
# Broker Service
services.broker.url = http://broker1-dev-dnet.d4science.org
#services.broker.url = http://beta.lbs.openaire.eu
#services.broker.url = http://localhost
services.broker.port = 8080
#services.broker.port = 9090
services.broker.api = api/
services.broker.openaire = openaireBroker
#
# Configuration file classpath
configurationFileClassPath=classpath:application-context.xml
api.baseAddress=https://dev-openaire.d4science.org/openaire
#api.baseAddress=http://beta.services.openaire.eu:8080/openaire
service.repository-rest-api.baseUrl = http://localhost:8080
# the address where validator is running and is accessible from the controllers of the web
services.repo-manager.baseUrl = http://${container.hostname}:${container.port}/${container.context}
# base address for soap web services
transport.soap.baseAddress = http://${container.hostname}:${container.port}/${container.context}
transport.soap.force.local.address = false
# the email of the administrator
# he will receive all the automatic bug reports and feedback created
services.repo-manager.adminEmail = pkanakakis@di.uoa.gr
# if set to true, getRepositories will return dummy repositories
services.repo-manager.repository.testing.mode = false
services.repo-manager.deploy.environment = development
# the mailhost for the mail service
services.validator.mail.host = smtp.gmail.com
# the port where the mail service is running
services.validator.mail.port = 465
# the address that appears in the from field in the mails send by the validator
services.validator.mail.fromAddress = no-reply@openaire.eu
# the reply-to field value in the mails send by the validator
services.validator.mail.replyToAddress = no-reply@openaire.eu
# the username of the account used to login in the mail server
services.validator.mail.username = test.openaire@gmail.com
# the password of the account used to login in the mail server
services.validator.mail.password = ^($*@$)*!$
# if authentication should take place
# if set to false username and password is not needed
services.validator.mail.authenticate = true
# is set to yes then all mails will not be sent to their targets but to the address specified in services.validator.mail.overrideEmail
services.validator.mail.override = false
# if set to true then no mails are send, they are only logged as a debug message
services.validator.mail.logonly = false
# the mode used for the mails send by the validator
services.validator.mail.mode = ssl
# used by eu.dnetlib.utils.MailLibrary to control debuggin messages
services.validator.mail.debug = false
# if services.validator.mail.override is true then all mails will be send only to this address
services.validator.mail.overrideEmail = pkanakakis@di.uoa.gr
# a comma-seperated list of address that will receive all mails about validations and repo registrations
services.validator.mail.specialRecipients = pkanakakis@di.uoa.gr
# a comma-seperated list of addresses that have the ability to register repos without the need for validation and registration
services.validator.repoRegistration.override = pkanakakis@di.uoa.gr
repomanager.db.driverClassName = org.postgresql.Driver
repomanager.db.url = jdbc:postgresql://194.177.192.119:5432/repomanager
repomanager.db.username = dnet
repomanager.db.password = dnetPwd
services.repomanager.analyticsURL = http://analytics.openaire.eu/addsite.php?
topic_types.url = https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:topic_types.json
#oidc.issuer = https://aai.openminted.eu/oidc/
#oidc.id = 24e83176-1312-4ba3-bc0b-ffeebea1603e
#oidc.secret = U_gLOupYu2trYIOwfxGgZkkZoOHG_zGfaViOUsXcZ7qVQuF1rcJeQYKIDX1TY3z27CIoHaqq9ht2rmAiUmBRYQ
oidc.issuer = https://aai.openaire.eu/oidc/
oidc.id = 767422b9-5461-4807-a80a-f9a2072d3a7d
oidc.secret = AMQtGlbTXNjwjhF0st28LmM6V0XypMdaVS7tJmGuYFlmH36iIv4t7tVqYuLYrNPkhnZ_GPUJvhymBhFupdgb6aU
#oidc.dev.home = http://194.177.192.121:8380/repomanager-service-dev/openid_connect_login
#webapp.dev.front = http://194.177.192.121:3000
oidc.dev.home = http://audrey.athenarc.gr:8380/repomanager-service-dev/openid_connect_login
webapp.dev.front = http://audrey.athenarc.gr:3000/dashboard
redis.host = aleka.athenarc.gr
redis.port = 6379
redis.password = E#Szvnidd
services.repomanager.usageStatisticsDiagramsBaseURL = https://beta.openaire.eu/stats3/
services.repomanager.usageStatisticsNumbersBaseURL = https://beta.services.openaire.eu/usagestats/datasources/
#services.repomanager.usagestats.adminEmail = repositoryusagestats@openaire.eu
services.repomanager.usagestats.adminEmail = pkanakakis@di.uoa.gr

View File

@ -18,7 +18,7 @@
<!--<bean id="webexpressionHandler" <!--<bean id="webexpressionHandler"
class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>--> class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>-->
<!-- <security:global-method-security pre-post-annotations="enabled" proxy-target-class="true" authentication-manager-ref="authenticationManager"/>--> <security:global-method-security pre-post-annotations="enabled" proxy-target-class="true" authentication-manager-ref="authenticationManager"/>
<security:http auto-config="false" use-expressions="true" <security:http auto-config="false" use-expressions="true"
disable-url-rewriting="true" entry-point-ref="authenticationEntryPoint" disable-url-rewriting="true" entry-point-ref="authenticationEntryPoint"
@ -26,10 +26,12 @@
<security:custom-filter before="PRE_AUTH_FILTER" ref="openIdConnectAuthenticationFilter" /> <security:custom-filter before="PRE_AUTH_FILTER" ref="openIdConnectAuthenticationFilter" />
<security:logout /> <security:logout logout-url="/openid_logout" invalidate-session="true"
delete-cookies="openAIRESession" logout-success-url="${webapp.dev.front}"/>
</security:http> </security:http>
<bean id="authenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint" > <bean id="authenticationEntryPoint" class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint" >
<constructor-arg type="java.lang.String" value="/openid_connect_login"/> <constructor-arg type="java.lang.String" value="/openid_connect_login"/>
</bean> </bean>

View File

@ -49,7 +49,8 @@
<value>classpath*:/gr/**/springContext-*.properties</value> <value>classpath*:/gr/**/springContext-*.properties</value>
<value>classpath*:/eu/**/springContext-*.properties</value> <value>classpath*:/eu/**/springContext-*.properties</value>
<value>classpath*:/eu/dnetlib/repo/manager/service/email-texts.properties</value> <value>classpath*:/application.properties</value>
<value>classpath*:/email-texts.properties</value>
<value>classpath*:dnet-site-wizard.properties</value> <value>classpath*:dnet-site-wizard.properties</value>
<value>classpath*:dnet-site-override.properties</value> <value>classpath*:dnet-site-override.properties</value>

View File

@ -18,8 +18,6 @@
class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/> class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/>
<context:annotation-config/> <context:annotation-config/>
<context:property-placeholder location="classpath*:/eu/**/application.properties" />
<context:component-scan base-package="eu.dnetlib.repo.manager.service.controllers"/>
<mvc:annotation-driven /> <mvc:annotation-driven />
</beans> </beans>