Merge branch 'develop'
This commit is contained in:
commit
401de371b2
|
@ -5,5 +5,5 @@
|
||||||
## Install and run:
|
## Install and run:
|
||||||
- Run **git clone** and then **cd uoa-repository-manager-service**.
|
- Run **git clone** and then **cd uoa-repository-manager-service**.
|
||||||
- Provide all not-set or redacted configurations, inside the **src/main/resources/application.properties** file.
|
- Provide all not-set or redacted configurations, inside the **src/main/resources/application.properties** file.
|
||||||
- Build the app with: `mvn clean install -s <settings-file>`
|
- Build the app with: `mvn clean install`
|
||||||
- Run the app with: `java -jar ./target/uoa-repository-manager-service.jar`
|
- Run the app with: `java -jar ./target/uoa-repository-manager-service.jar`
|
||||||
|
|
29
pom.xml
29
pom.xml
|
@ -64,6 +64,11 @@
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.solr</groupId>
|
||||||
|
<artifactId>solr-solrj</artifactId>
|
||||||
|
<version>9.1.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>eu.dnetlib.dhp</groupId>
|
<groupId>eu.dnetlib.dhp</groupId>
|
||||||
|
@ -362,6 +367,30 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>dnet45-bootstrap-snapshot</id>
|
||||||
|
<name>D-Net 45 Bootstrap Snapshot</name>
|
||||||
|
<url>https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-bootstrap-snapshot</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
<layout>default</layout>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>dnet45-bootstrap-release</id>
|
||||||
|
<name>D-Net 45 Bootstrap Release</name>
|
||||||
|
<url>https://maven.research-infrastructures.eu/nexus/content/repositories/dnet45-bootstrap-release</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
<layout>default</layout>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>dnet-deps</id>
|
<id>dnet-deps</id>
|
||||||
<name>dnet-dependencies</name>
|
<name>dnet-dependencies</name>
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class AsyncConfiguration implements AsyncConfigurer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleUncaughtException(Throwable throwable, Method method, Object... objects) {
|
public void handleUncaughtException(Throwable throwable, Method method, Object... objects) {
|
||||||
//logger.error("Async error", throwable);
|
logger.error("Async error", throwable);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,22 +55,21 @@ public class DashboardController {
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||||
public CollectionMonitorSummary getCollectionMonitorSummary(
|
public CollectionMonitorSummary getCollectionMonitorSummary(
|
||||||
@PathVariable("repoId") String repoId,
|
@PathVariable("repoId") String repoId,
|
||||||
@RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException {
|
@RequestParam(name = "size", required = false, defaultValue = "20") int summarySize) throws JSONException {
|
||||||
|
|
||||||
|
List<AggregationInfo> aggregationInfoList = aggregationService.getRepositoryAggregations(repoId);
|
||||||
|
|
||||||
List<AggregationInfo> aggregationInfo = aggregationService.getRepositoryAggregations(repoId, 0, size);
|
|
||||||
CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary();
|
CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary();
|
||||||
collectionMonitorSummary.setAggregationInfo(aggregationInfo);
|
// Set the "aggregationInfo" for the first <number of> requested aggregations, in order to create a "summary".
|
||||||
size = 0;
|
collectionMonitorSummary.setAggregationInfo(aggregationInfoList.subList(0, Math.min(summarySize, aggregationInfoList.size())));
|
||||||
do {
|
|
||||||
aggregationInfo = aggregationService.getRepositoryAggregations(repoId, size, size + 50);
|
// Search for the last indexed version and set the "collectionMonitorSummary".
|
||||||
for (AggregationInfo aggregationDetail : aggregationInfo) {
|
for ( AggregationInfo aggregationInfo : aggregationInfoList ) {
|
||||||
if (aggregationDetail.isIndexedVersion()) {
|
if ( aggregationInfo.isIndexedVersion() ) {
|
||||||
collectionMonitorSummary.setLastIndexedVersion(aggregationDetail);
|
collectionMonitorSummary.setLastIndexedVersion(aggregationInfo);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
size += 30;
|
}
|
||||||
} while (aggregationInfo.size() != 0 && collectionMonitorSummary.getLastIndexedVersion() == null);
|
|
||||||
|
|
||||||
return collectionMonitorSummary;
|
return collectionMonitorSummary;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -63,7 +62,7 @@ public class RepositoryController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<RepositorySnippet> getRepositoriesByCountry(@PathVariable("country") String country,
|
public List<RepositorySnippet> getRepositoriesByCountry(@PathVariable("country") String country,
|
||||||
@PathVariable("mode") String mode,
|
@PathVariable("mode") String mode,
|
||||||
@RequestParam(value = "managed", required = false) Boolean managed) throws JSONException, IOException {
|
@RequestParam(value = "managed", required = false) Boolean managed) {
|
||||||
return repositoryService.getRepositoriesByCountry(country, mode, managed);
|
return repositoryService.getRepositoriesByCountry(country, mode, managed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +82,7 @@ public class RepositoryController {
|
||||||
public void updateRepositoriesTerms(@RequestBody List<RepositoryTerms> repositoriesTerms) throws Exception {
|
public void updateRepositoriesTerms(@RequestBody List<RepositoryTerms> repositoriesTerms) throws Exception {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (repositoriesTerms != null) {
|
if (repositoriesTerms != null) {
|
||||||
for (RepositoryTerms terms : repositoriesTerms) {
|
for (RepositoryTerms terms : repositoriesTerms) {
|
||||||
Repository repository = repositoryService.getRepositoryById(terms.getId());
|
Repository repository = repositoryService.getRepositoryById(terms.getId());
|
||||||
repository.setConsentTermsOfUse(terms.getConsentTermsOfUse());
|
repository.setConsentTermsOfUse(terms.getConsentTermsOfUse());
|
||||||
repository.setFullTextDownload(terms.getFullTextDownload());
|
repository.setFullTextDownload(terms.getFullTextDownload());
|
||||||
|
@ -104,7 +103,7 @@ public class RepositoryController {
|
||||||
@RequestParam("requestSortBy") String requestSortBy,
|
@RequestParam("requestSortBy") String requestSortBy,
|
||||||
@RequestParam("order") String order,
|
@RequestParam("order") String order,
|
||||||
@PathVariable("page") int page,
|
@PathVariable("page") int page,
|
||||||
@PathVariable("size") int pageSize) throws Exception {
|
@PathVariable("size") int pageSize) {
|
||||||
|
|
||||||
return repositoryService.searchRegisteredRepositories(country, typology, englishName, officialName, requestSortBy, order, page, pageSize);
|
return repositoryService.searchRegisteredRepositories(country, typology, englishName, officialName, requestSortBy, order, page, pageSize);
|
||||||
}
|
}
|
||||||
|
@ -113,13 +112,13 @@ public class RepositoryController {
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PostAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id) or (returnObject.registeredby==null and hasAuthority('REGISTERED_USER'))")
|
@PostAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id) or (returnObject.registeredby==null and hasAuthority('REGISTERED_USER'))")
|
||||||
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException, ResourceNotFoundException {
|
public Repository getRepositoryById(@PathVariable("id") String id) throws ResourceNotFoundException {
|
||||||
Repository repo = repositoryService.getRepositoryById(id);
|
Repository repo = repositoryService.getRepositoryById(id);
|
||||||
|
|
||||||
if (repo != null)
|
if (repo != null)
|
||||||
logger.info("Returning repository " + repo.getId() + " registered by " + repo.getRegisteredby());
|
logger.info("Returning repository {} registered by {}", repo.getId(), repo.getRegisteredby());
|
||||||
else
|
else
|
||||||
logger.info("Requested repository " + id + " not found");
|
logger.info("Requested repository {} not found", id);
|
||||||
return repo;
|
return repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +141,7 @@ public class RepositoryController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
|
public List<Repository> getRepositoriesByName(@PathVariable("name") String name,
|
||||||
@PathVariable("page") String page,
|
@PathVariable("page") String page,
|
||||||
@PathVariable("size") String size) throws JSONException {
|
@PathVariable("size") String size) {
|
||||||
return repositoryService.getRepositoriesByName(name, page, size);
|
return repositoryService.getRepositoriesByName(name, page, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +149,7 @@ public class RepositoryController {
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PostAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id) or (@repositoryService.getRepositoryById(#id).registeredby==null and hasAuthority('REGISTERED_USER'))")
|
@PostAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#id) or (@repositoryService.getRepositoryById(#id).registeredby==null and hasAuthority('REGISTERED_USER'))")
|
||||||
public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) throws JSONException {
|
public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) {
|
||||||
return repositoryService.getRepositoryInterface(id);
|
return repositoryService.getRepositoryInterface(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +159,7 @@ public class RepositoryController {
|
||||||
// @PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority(@authorizationService.convertRepoIdToRoleId(#repository.id)) or hasAuthority(@authorizationService.convertRepoIdToRoleId(returnObject.id)))")
|
// @PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or (hasAuthority(@authorizationService.convertRepoIdToRoleId(#repository.id)) or hasAuthority(@authorizationService.convertRepoIdToRoleId(returnObject.id)))")
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER')")
|
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER')")
|
||||||
public Repository addRepository(@RequestParam("datatype") String datatype,
|
public Repository addRepository(@RequestParam("datatype") String datatype,
|
||||||
@RequestBody Repository repository) throws Exception {
|
@RequestBody Repository repository) {
|
||||||
|
|
||||||
return repositoryService.addRepository(datatype, repository);
|
return repositoryService.addRepository(datatype, repository);
|
||||||
}
|
}
|
||||||
|
@ -193,7 +192,7 @@ public class RepositoryController {
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#repository.id)")
|
@PreAuthorize("hasAuthority('SUPER_ADMINISTRATOR') or hasAuthority('CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or @authorizationService.isMemberOf(#repository.id)")
|
||||||
public Repository updateRepository(@RequestBody Repository repository, Authentication authentication) throws Exception {
|
public Repository updateRepository(@RequestBody Repository repository, Authentication authentication) {
|
||||||
return repositoryService.updateRepository(repository, authentication);
|
return repositoryService.updateRepository(repository, authentication);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +260,7 @@ public class RepositoryController {
|
||||||
@RequestMapping(value = "/getListLatestUpdate/{mode}", method = RequestMethod.GET,
|
@RequestMapping(value = "/getListLatestUpdate/{mode}", method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) throws JSONException {
|
public Map<String, String> getListLatestUpdate(@PathVariable("mode") String mode) {
|
||||||
return repositoryService.getListLatestUpdate(mode);
|
return repositoryService.getListLatestUpdate(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,109 +1,108 @@
|
||||||
package eu.dnetlib.repo.manager.controllers;
|
//package eu.dnetlib.repo.manager.controllers;
|
||||||
|
//
|
||||||
import eu.dnetlib.repo.manager.domain.dto.Role;
|
//import eu.dnetlib.repo.manager.domain.dto.Role;
|
||||||
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
//import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
||||||
import eu.dnetlib.repo.manager.service.security.AuthoritiesUpdater;
|
//import eu.dnetlib.repo.manager.service.security.AuthoritiesUpdater;
|
||||||
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
//import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
||||||
import eu.dnetlib.repo.manager.service.security.RoleMappingService;
|
//import eu.dnetlib.repo.manager.service.security.RoleMappingService;
|
||||||
import eu.dnetlib.repo.manager.utils.JsonUtils;
|
//import eu.dnetlib.repo.manager.utils.JsonUtils;
|
||||||
import io.swagger.annotations.ApiOperation;
|
//import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
//import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
//import org.springframework.http.ResponseEntity;
|
||||||
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.*;
|
||||||
|
//
|
||||||
import javax.ws.rs.core.MediaType;
|
//import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
//import javax.ws.rs.core.Response;
|
||||||
import java.util.Collection;
|
//import java.util.Collection;
|
||||||
|
//
|
||||||
//@RestController
|
////@RestController
|
||||||
//@RequestMapping(value = "/role-management")
|
////@RequestMapping(value = "/role-management")
|
||||||
//@Api(description = "Role Management", value = "role-management")
|
////@Api(description = "Role Management", value = "role-management")
|
||||||
public class UserRoleController {
|
//public class UserRoleController {
|
||||||
|
//
|
||||||
private final AaiRegistryService aaiRegistryService;
|
// private final AaiRegistryService aaiRegistryService;
|
||||||
private final AuthoritiesUpdater authoritiesUpdater;
|
// private final AuthoritiesUpdater authoritiesUpdater;
|
||||||
private final RoleMappingService roleMappingService;
|
// private final RoleMappingService roleMappingService;
|
||||||
private final AuthorizationService authorizationService;
|
// private final AuthorizationService authorizationService;
|
||||||
|
//
|
||||||
@Autowired
|
// @Autowired
|
||||||
UserRoleController(AaiRegistryService aaiRegistryService,
|
// UserRoleController(AaiRegistryService aaiRegistryService,
|
||||||
AuthoritiesUpdater authoritiesUpdater,
|
// AuthoritiesUpdater authoritiesUpdater,
|
||||||
RoleMappingService roleMappingService,
|
// RoleMappingService roleMappingService,
|
||||||
AuthorizationService authorizationService) {
|
// AuthorizationService authorizationService) {
|
||||||
this.aaiRegistryService = aaiRegistryService;
|
// this.aaiRegistryService = aaiRegistryService;
|
||||||
this.authoritiesUpdater = authoritiesUpdater;
|
// this.authoritiesUpdater = authoritiesUpdater;
|
||||||
this.roleMappingService = roleMappingService;
|
// this.roleMappingService = roleMappingService;
|
||||||
this.authorizationService = authorizationService;
|
// this.authorizationService = authorizationService;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Get the role with the given id.
|
// * Get the role with the given id.
|
||||||
**/
|
// **/
|
||||||
@RequestMapping(method = RequestMethod.GET, path = "/role/{id}")
|
// @RequestMapping(method = RequestMethod.GET, path = "/role/{id}")
|
||||||
// @PreAuthorize("hasAnyAuthority('REGISTERED_USER', 'SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
//// @PreAuthorize("hasAnyAuthority('REGISTERED_USER', 'SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
||||||
public Response getRole(@RequestParam(value = "type", defaultValue = "datasource") String type, @PathVariable("id") String id) {
|
// public Response getRole(@RequestParam(value = "type", defaultValue = "datasource") String type, @PathVariable("id") String id) {
|
||||||
int roleId = aaiRegistryService.getCouId(type, id);
|
// int roleId = aaiRegistryService.getCouId(type, id);
|
||||||
return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role id is: " + roleId).toString()).type(MediaType.APPLICATION_JSON).build();
|
// return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role id is: " + roleId).toString()).type(MediaType.APPLICATION_JSON).build();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Create a new role with the given name and description.
|
// * Create a new role with the given name and description.
|
||||||
**/
|
// **/
|
||||||
@RequestMapping(method = RequestMethod.POST, path = "/role")
|
// @RequestMapping(method = RequestMethod.POST, path = "/role")
|
||||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR')")
|
// @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR')")
|
||||||
public Response createRole(@RequestBody Role role) {
|
// public Response createRole(@RequestBody Role role) {
|
||||||
aaiRegistryService.createRole(role);
|
// aaiRegistryService.createRole(role);
|
||||||
return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role has been created").toString()).type(MediaType.APPLICATION_JSON).build();
|
// return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role has been created").toString()).type(MediaType.APPLICATION_JSON).build();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Subscribe to a type(Community, etc.) with id(ee, egi, etc.)
|
// * Subscribe to a type(Community, etc.) with id(ee, egi, etc.)
|
||||||
*/
|
// */
|
||||||
@ApiOperation(value = "subscribe")
|
// @ApiOperation(value = "subscribe")
|
||||||
@RequestMapping(method = RequestMethod.POST, path = "/subscribe/{type}/{id}")
|
// @RequestMapping(method = RequestMethod.POST, path = "/subscribe/{type}/{id}")
|
||||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
// @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
||||||
public Response subscribe(@PathVariable("type") String type, @PathVariable("id") String id) {
|
// public Response subscribe(@PathVariable("type") String type, @PathVariable("id") String id) {
|
||||||
Integer coPersonId = aaiRegistryService.getCoPersonIdByIdentifier();
|
// Integer coPersonId = aaiRegistryService.getCoPersonIdByIdentifier();
|
||||||
if (coPersonId == null) {
|
// if (coPersonId == null) {
|
||||||
coPersonId = aaiRegistryService.getCoPersonIdByEmail();
|
// coPersonId = aaiRegistryService.getCoPersonIdsByEmail();
|
||||||
}
|
// }
|
||||||
Integer couId = aaiRegistryService.getCouId(type, id);
|
// Integer couId = aaiRegistryService.getCouId(type, id);
|
||||||
if (couId != null) {
|
// if (couId != null) {
|
||||||
Integer role = aaiRegistryService.getRoleId(coPersonId, couId);
|
// aaiRegistryService.assignMemberRole(coPersonId, couId);
|
||||||
aaiRegistryService.assignMemberRole(coPersonId, couId, role);
|
//
|
||||||
|
// // Add role to current authorities
|
||||||
// Add role to current authorities
|
// authoritiesUpdater.addRole(roleMappingService.convertRepoIdToAuthority(id));
|
||||||
authoritiesUpdater.addRole(roleMappingService.convertRepoIdToAuthority(id));
|
//
|
||||||
|
// return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role has been assigned").toString()).type(MediaType.APPLICATION_JSON).build();
|
||||||
return Response.status(HttpStatus.OK.value()).entity(JsonUtils.createResponse("Role has been assigned").toString()).type(MediaType.APPLICATION_JSON).build();
|
// } else {
|
||||||
} else {
|
// return Response.status(HttpStatus.NOT_FOUND.value()).entity(JsonUtils.createResponse("Role has not been found").toString()).type(MediaType.APPLICATION_JSON).build();
|
||||||
return Response.status(HttpStatus.NOT_FOUND.value()).entity(JsonUtils.createResponse("Role has not been found").toString()).type(MediaType.APPLICATION_JSON).build();
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// /////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
// /////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////
|
//
|
||||||
|
// @RequestMapping(method = RequestMethod.GET, path = "/users/couid/{id}")
|
||||||
@RequestMapping(method = RequestMethod.GET, path = "/users/couid/{id}")
|
// @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
||||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR')")
|
// public ResponseEntity<String> getUsersByCouId(@PathVariable("id") Integer id) {
|
||||||
public ResponseEntity<String> getUsersByCouId(@PathVariable("id") Integer id) {
|
//// calls.getUserByCoId()
|
||||||
// calls.getUserByCoId()
|
// return ResponseEntity.ok(aaiRegistryService.getUsersByCouId(id).toString());
|
||||||
return ResponseEntity.ok(aaiRegistryService.getUsersByCouId(id).toString());
|
// }
|
||||||
}
|
//
|
||||||
|
//
|
||||||
|
// @RequestMapping(method = RequestMethod.GET, path = "/users/{email}/roles")
|
||||||
@RequestMapping(method = RequestMethod.GET, path = "/users/{email}/roles")
|
// @PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER') and authentication.userInfo.email==#email")
|
||||||
@PreAuthorize("hasAnyAuthority('SUPER_ADMINISTRATOR', 'CONTENT_PROVIDER_DASHBOARD_ADMINISTRATOR') or hasAuthority('REGISTERED_USER') and authentication.userInfo.email==#email")
|
// public ResponseEntity<Collection<String>> getRolesByEmail(@PathVariable("email") String email) {
|
||||||
public ResponseEntity<Collection<String>> getRolesByEmail(@PathVariable("email") String email) {
|
// return ResponseEntity.ok(authorizationService.getUserRolesByEmail(email));
|
||||||
return ResponseEntity.ok(authorizationService.getUserRolesByEmail(email));
|
// }
|
||||||
}
|
//
|
||||||
|
//
|
||||||
|
// @RequestMapping(method = RequestMethod.GET, path = "/user/roles/my")
|
||||||
@RequestMapping(method = RequestMethod.GET, path = "/user/roles/my")
|
// @PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
// public ResponseEntity<Collection<String>> getRoleNames() {
|
||||||
public ResponseEntity<Collection<String>> getRoleNames() {
|
// return ResponseEntity.ok(authorizationService.getUserRoles());
|
||||||
return ResponseEntity.ok(authorizationService.getUserRoles());
|
// }
|
||||||
}
|
//
|
||||||
|
//}
|
||||||
}
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import eu.dnetlib.repo.manager.domain.Tuple;
|
||||||
import eu.dnetlib.repo.manager.domain.broker.*;
|
import eu.dnetlib.repo.manager.domain.broker.*;
|
||||||
import eu.dnetlib.repo.manager.exception.BrokerException;
|
import eu.dnetlib.repo.manager.exception.BrokerException;
|
||||||
import org.apache.commons.lang.NotImplementedException;
|
import org.apache.commons.lang.NotImplementedException;
|
||||||
import org.json.JSONException;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -17,8 +16,6 @@ import org.springframework.core.ParameterizedTypeReference;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.LinkedMultiValueMap;
|
|
||||||
import org.springframework.util.MultiValueMap;
|
|
||||||
import org.springframework.web.client.RestClientException;
|
import org.springframework.web.client.RestClientException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.util.UriComponents;
|
import org.springframework.web.util.UriComponents;
|
||||||
|
@ -27,6 +24,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -52,7 +50,7 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
|
|
||||||
private HttpHeaders httpHeaders;
|
private HttpHeaders httpHeaders;
|
||||||
|
|
||||||
private HashMap<String, Term> topics = new HashMap<>();
|
private final HashMap<String, Term> topics = new HashMap<>();
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void initDnetTopicsMap() {
|
private void initDnetTopicsMap() {
|
||||||
|
@ -78,7 +76,7 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatasourcesBroker getDatasourcesOfUser(String user, String includeShared, String includeByOthers) throws JSONException {
|
public DatasourcesBroker getDatasourcesOfUser(String user, String includeShared, String includeByOthers) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
DatasourcesBroker ret = new DatasourcesBroker();
|
DatasourcesBroker ret = new DatasourcesBroker();
|
||||||
try {
|
try {
|
||||||
|
@ -96,7 +94,7 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
logger.error("Exception on getDatasourcesOfUser", e);
|
logger.error("Exception on getDatasourcesOfUser", e);
|
||||||
}
|
}
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
System.out.println("Getting datasources of user in " + (end - start) + "ms");
|
logger.debug("Getting datasources of user in " + (end - start) + "ms");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,14 +127,15 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
|
|
||||||
final String service = "/events/{page}/{pageSize}";
|
final String service = "/events/{page}/{pageSize}";
|
||||||
|
|
||||||
|
long pageNum = Long.parseLong(page);
|
||||||
|
advQueryObject.setPage(pageNum);
|
||||||
|
|
||||||
Map<String, Long> uriParams = new HashMap<>();
|
Map<String, Long> uriParams = new HashMap<>();
|
||||||
uriParams.put("page", Long.parseLong(page));
|
uriParams.put("page", pageNum);
|
||||||
uriParams.put("pageSize", Long.parseLong(size));
|
uriParams.put("pageSize", Long.parseLong(size));
|
||||||
|
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service);
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service);
|
||||||
|
|
||||||
MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
|
|
||||||
advQueryObject.setPage(Long.parseLong(page));
|
|
||||||
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, httpHeaders);
|
HttpEntity<AdvQueryObject> entity = new HttpEntity<>(advQueryObject, httpHeaders);
|
||||||
ResponseEntity<EventsPage> resp;
|
ResponseEntity<EventsPage> resp;
|
||||||
try {
|
try {
|
||||||
|
@ -144,8 +143,7 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
builder.buildAndExpand(uriParams).encode().toUri(),
|
builder.buildAndExpand(uriParams).encode().toUri(),
|
||||||
HttpMethod.POST,
|
HttpMethod.POST,
|
||||||
entity,
|
entity,
|
||||||
new ParameterizedTypeReference<EventsPage>() {
|
new ParameterizedTypeReference<EventsPage>() {}
|
||||||
}
|
|
||||||
);
|
);
|
||||||
} catch (RestClientException e) {
|
} catch (RestClientException e) {
|
||||||
throw new BrokerException(e);
|
throw new BrokerException(e);
|
||||||
|
@ -171,8 +169,7 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
// sort the collection by the second field of the tuple which is size
|
// sort the collection by the second field of the tuple which is size
|
||||||
entries.sort((e1, e2) -> (int) (e2.getFirst().getSize() - e1.getFirst().getSize()));
|
entries.sort((e1, e2) -> (int) (e2.getFirst().getSize() - e1.getFirst().getSize()));
|
||||||
long stop = System.currentTimeMillis();
|
long stop = System.currentTimeMillis();
|
||||||
System.out.println("getDatasourcesOfUserType returned in " + (stop - start) + "ms ");
|
logger.debug("getDatasourcesOfUserType returned in " + (stop - start) + "ms ");
|
||||||
|
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +177,7 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
public EventsPage showEvents(String datasourceName,
|
public EventsPage showEvents(String datasourceName,
|
||||||
String topic,
|
String topic,
|
||||||
String page,
|
String page,
|
||||||
String size) throws BrokerException, JSONException {
|
String size) throws BrokerException {
|
||||||
|
|
||||||
final String service = "/events";
|
final String service = "/events";
|
||||||
|
|
||||||
|
@ -209,14 +206,14 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
|
|
||||||
final String service = "/subscriptions";
|
final String service = "/subscriptions";
|
||||||
|
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
URI uri = UriComponentsBuilder.fromHttpUrl(openairePath + service)
|
||||||
.queryParam("email", userEmail);
|
.queryParam("email", userEmail).build().encode().toUri();
|
||||||
|
|
||||||
logger.debug("{}", builder.build().encode().toUri());
|
logger.debug("{}", uri);
|
||||||
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
ResponseEntity<Map<String, List<SimpleSubscriptionDesc>>> resp;
|
||||||
try {
|
try {
|
||||||
resp = restTemplate.exchange(
|
resp = restTemplate.exchange(
|
||||||
builder.build().encode().toUri(),
|
uri,
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
null,
|
null,
|
||||||
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() {
|
new ParameterizedTypeReference<Map<String, List<SimpleSubscriptionDesc>>>() {
|
||||||
|
@ -228,10 +225,9 @@ public class BrokerServiceImpl implements BrokerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) throws BrokerException {
|
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) { //throws BrokerException {
|
||||||
Map<String, List<SimpleSubscriptionDesc>> subscriptionsOfUser = getSimpleSubscriptionsOfUser(userEmail);
|
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
// return null;
|
//Map<String, List<SimpleSubscriptionDesc>> subscriptionsOfUser = getSimpleSubscriptionsOfUser(userEmail);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -39,41 +39,50 @@ public class DashboardServiceImpl implements DashboardService {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<RepositorySnippet> repositoriesOfUser = repositoryService.getRepositoriesSnippetsOfUser(userEmail, page, size);
|
List<RepositorySnippet> repositoriesOfUser = repositoryService.getRepositoriesSnippetsOfUser(userEmail, page, size);
|
||||||
for (RepositorySnippet repository : repositoriesOfUser) {
|
for (RepositorySnippet repository : repositoriesOfUser)
|
||||||
|
{
|
||||||
|
String repoId = repository.getId();
|
||||||
|
String repoOfficialName = repository.getOfficialname();
|
||||||
|
|
||||||
RepositorySummaryInfo repositorySummaryInfo = new RepositorySummaryInfo();
|
RepositorySummaryInfo repositorySummaryInfo = new RepositorySummaryInfo();
|
||||||
repositorySummaryInfo.setId(repository.getId());
|
repositorySummaryInfo.setId(repoId);
|
||||||
repositorySummaryInfo.setRepositoryName(repository.getOfficialname());
|
repositorySummaryInfo.setRepositoryName(repoOfficialName);
|
||||||
repositorySummaryInfo.setLogoURL(repository.getLogoUrl());
|
repositorySummaryInfo.setLogoURL(repository.getLogoUrl());
|
||||||
|
|
||||||
//TODO getRepositoryAggregations returns only the 20 more recent items. Is it positive that we will find an indexed version there?
|
//TODO getRepositoryAggregations returns only the 20 more recent items. Is it positive that we will find an indexed version there?
|
||||||
|
boolean isIndexedVersionFound = false;
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
List<AggregationInfo> aggregationInfoList = aggregationService.getRepositoryAggregations(repository.getId(), 0, 20);
|
List<AggregationInfo> aggregationInfoList = aggregationService.getRepositoryAggregations(repoId, 0, 20);
|
||||||
for (AggregationInfo aggregationInfo : aggregationInfoList) {
|
for (AggregationInfo aggregationInfo : aggregationInfoList) {
|
||||||
if (aggregationInfo.isIndexedVersion()) {
|
if (aggregationInfo.isIndexedVersion()) {
|
||||||
repositorySummaryInfo.setRecordsCollected(aggregationInfo.getNumberOfRecords());
|
repositorySummaryInfo.setRecordsCollected(aggregationInfo.getNumberOfRecords());
|
||||||
repositorySummaryInfo.setLastIndexedVersion(DateUtils.toDate(aggregationInfo.getDate()));
|
repositorySummaryInfo.setLastIndexedVersion(DateUtils.toDate(aggregationInfo.getDate()));
|
||||||
|
isIndexedVersionFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
System.out.println("Got repo aggregations in " + (end - start) + "ms");
|
if ( isIndexedVersionFound )
|
||||||
|
logger.debug("Got repo aggregations in " + (end - start) + "ms");
|
||||||
|
else
|
||||||
|
logger.warn("Could not find repo aggregations, after " + (end - start) + "ms!");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MetricsInfo metricsInfo = repositoryService.getMetricsInfoForRepository(repository.getId());
|
MetricsInfo metricsInfo = repositoryService.getMetricsInfoForRepository(repoId);
|
||||||
repositorySummaryInfo.setTotalDownloads(metricsInfo.getMetricsNumbers().getTotalDownloads());
|
repositorySummaryInfo.setTotalDownloads(metricsInfo.getMetricsNumbers().getTotalDownloads());
|
||||||
repositorySummaryInfo.setTotalViews(metricsInfo.getMetricsNumbers().getTotalViews());
|
repositorySummaryInfo.setTotalViews(metricsInfo.getMetricsNumbers().getTotalViews());
|
||||||
} catch (RepositoryServiceException e) {
|
} catch (RepositoryServiceException e) {
|
||||||
logger.error("Exception getting metrics info for repository: " + repository.getId(), e);
|
logger.error("Exception getting metrics info for repository: {}, {} ", repoId, repoOfficialName, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<BrowseEntry> events = brokerService.getTopicsForDatasource(repository.getOfficialname());
|
List<BrowseEntry> events = brokerService.getTopicsForDatasource(repoOfficialName);
|
||||||
Long totalEvents = 0L;
|
Long totalEvents = 0L;
|
||||||
for (BrowseEntry browseEntry : events)
|
for (BrowseEntry browseEntry : events)
|
||||||
totalEvents += browseEntry.getSize();
|
totalEvents += browseEntry.getSize();
|
||||||
repositorySummaryInfo.setEnrichmentEvents(totalEvents);
|
repositorySummaryInfo.setEnrichmentEvents(totalEvents);
|
||||||
} catch (BrokerException e) {
|
} catch (BrokerException e) {
|
||||||
logger.error("Exception getting broker events for repository: " + repository.getId(), e);
|
logger.error("Exception getting broker events for repository: {}, {} ", repoId, repoOfficialName, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
repositorySummaryInfoList.add(repositorySummaryInfo);
|
repositorySummaryInfoList.add(repositorySummaryInfo);
|
||||||
|
|
|
@ -32,38 +32,38 @@ public interface EmailUtils {
|
||||||
void sendUserRegistrationEmail(Repository repository, Authentication authentication);
|
void sendUserRegistrationEmail(Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication);
|
void sendAdminRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication);
|
void sendUserRegisterInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
|
||||||
|
|
||||||
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
|
/****SUCCESSFUL REGISTRATION RESULTS EMAILS****/
|
||||||
@Async
|
@Async
|
||||||
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
void sendUserRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
void sendAdminRegistrationResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
/****FAILURE REGISTRATION RESULTS EMAILS****/
|
/****FAILURE REGISTRATION RESULTS EMAILS****/
|
||||||
@Async
|
@Async
|
||||||
void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
void sendUserRegistrationResultsFailureEmail(String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
void sendAdminRegistrationResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
/****SUCCESSFUL UPDATE RESULTS EMAILS****/
|
/****SUCCESSFUL UPDATE RESULTS EMAILS****/
|
||||||
@Async
|
@Async
|
||||||
void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
void sendUserUpdateResultsSuccessEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
void sendAdminUpdateResultsSuccessEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
/****FAILURE UPDATE RESULTS EMAILS****/
|
/****FAILURE UPDATE RESULTS EMAILS****/
|
||||||
@Async
|
@Async
|
||||||
void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
void sendUserUpdateResultsFailureEmail(String issuer, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, Repository repository, Authentication authentication);
|
void sendAdminUpdateResultsFailureEmail(String issuerEmail, String jobId, RepositoryInterface repositoryInterface, String desiredCompatibility, Repository repository, Authentication authentication);
|
||||||
|
|
||||||
/****FAILURE UPDATE INTERFACE COMPLIANCE****/
|
/****FAILURE UPDATE INTERFACE COMPLIANCE****/
|
||||||
@Async
|
@Async
|
||||||
|
@ -91,10 +91,10 @@ public interface EmailUtils {
|
||||||
void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication);
|
void sendUserUpdateRepositoryInfoEmail(Repository repository, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication);
|
void sendAdminUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, Authentication authentication);
|
void sendUserUpdateInterfaceEmail(Repository repository, String comment, RepositoryInterface repositoryInterface, String desiredCompatibility, Authentication authentication);
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation);
|
void sendSubmitJobForValidationEmail(Authentication authentication, JobForValidation jobForValidation);
|
||||||
|
@ -102,6 +102,7 @@ public interface EmailUtils {
|
||||||
@Async
|
@Async
|
||||||
void sendUponJobCompletion(String repoId,
|
void sendUponJobCompletion(String repoId,
|
||||||
String repoInterfaceId,
|
String repoInterfaceId,
|
||||||
|
String compatibility,
|
||||||
int scoreUsage,
|
int scoreUsage,
|
||||||
int scoreContent,
|
int scoreContent,
|
||||||
boolean isSuccess,
|
boolean isSuccess,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6,7 +6,6 @@ import eu.dnetlib.repo.manager.exception.ResourceConflictException;
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||||
import eu.dnetlib.repo.manager.repository.InterfaceComplianceRequestsRepository;
|
import eu.dnetlib.repo.manager.repository.InterfaceComplianceRequestsRepository;
|
||||||
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
||||||
import org.json.JSONException;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
@ -50,7 +49,7 @@ public class InterfaceComplianceService {
|
||||||
List<User> repositoryAdmins = authorizationService.getAdminsOfRepo(request.getRepositoryId());
|
List<User> repositoryAdmins = authorizationService.getAdminsOfRepo(request.getRepositoryId());
|
||||||
emailUtils.sendUserUpdateInterfaceComplianceFailure(repositoryAdmins.stream().map(User::getEmail).collect(Collectors.toList()), repo, iFace, request);
|
emailUtils.sendUserUpdateInterfaceComplianceFailure(repositoryAdmins.stream().map(User::getEmail).collect(Collectors.toList()), repo, iFace, request);
|
||||||
emailUtils.sendAdminUpdateInterfaceComplianceFailure(repo, iFace, request);
|
emailUtils.sendAdminUpdateInterfaceComplianceFailure(repo, iFace, request);
|
||||||
} catch (JSONException | ResourceNotFoundException e) {
|
} catch (ResourceNotFoundException e) {
|
||||||
logger.error("Error", e);
|
logger.error("Error", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +58,7 @@ public class InterfaceComplianceService {
|
||||||
|
|
||||||
private Set<InterfaceComplianceRequest> getOutdated() {
|
private Set<InterfaceComplianceRequest> getOutdated() {
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.add(Calendar.DATE, -7);
|
calendar.add(Calendar.DATE, -7); // 7-days-old
|
||||||
return this.repository.findAllBySubmissionDateBefore(calendar.getTime());
|
return this.repository.findAllBySubmissionDateBefore(calendar.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
String dateFrom,
|
String dateFrom,
|
||||||
String dateTo,
|
String dateTo,
|
||||||
String validationStatus,
|
String validationStatus,
|
||||||
String includeJobsTotal) throws JSONException, ValidatorServiceException {
|
String includeJobsTotal) throws ValidatorServiceException, NumberFormatException {
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
// FIXME: this is a hack for CRIS Jan Dvorak Validator, should be implemented properly //
|
||||||
|
@ -95,7 +95,6 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() <= 50)) {
|
|| (job.getValidationType().equals("U") && job.getContentJobStatus().equals("none") && job.getUsageJobStatus().equals("finished") && job.getUsageJobScore() <= 50)) {
|
||||||
job.setValidationStatus("failed");
|
job.setValidationStatus("failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +139,6 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
return retJobs;
|
return retJobs;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getJobsTotalNumberOfUser(String user, String jobType, String validationStatus) throws ValidatorServiceException {
|
private int getJobsTotalNumberOfUser(String user, String jobType, String validationStatus) throws ValidatorServiceException {
|
||||||
|
@ -166,13 +164,12 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StoredJob getJobSummary(String jobId,
|
public StoredJob getJobSummary(String jobId, String groupBy) {
|
||||||
String groupBy) throws JSONException {
|
|
||||||
logger.debug("Getting job summary with id : " + jobId);
|
logger.debug("Getting job summary with id : " + jobId);
|
||||||
StoredJob job = null;
|
StoredJob job = null;
|
||||||
try {
|
try {
|
||||||
job = getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
|
job = getValidationService().getStoredJob(Integer.parseInt(jobId), groupBy);
|
||||||
} catch (ValidatorServiceException e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -189,4 +186,5 @@ public class MonitorServiceImpl implements MonitorService {
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,12 +226,12 @@ public class PiWikServiceImpl implements PiWikService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getTotal() {
|
public Integer getTotal() {
|
||||||
return new JdbcTemplate(dataSource).queryForObject(GET_PIWIK_SITES_TOTAL, new Object[]{}, Integer.class);
|
return new JdbcTemplate(dataSource).queryForObject(GET_PIWIK_SITES_TOTAL, Integer.class, new Object[]{});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getValidated(boolean validated) {
|
public Integer getValidated(boolean validated) {
|
||||||
String finalizedQuery = GET_PIWIK_SITES_TOTAL + " where validated = ?";
|
String finalizedQuery = GET_PIWIK_SITES_TOTAL + " where validated = ?";
|
||||||
return new JdbcTemplate(dataSource).queryForObject(finalizedQuery, new Object[]{validated}, Integer.class);
|
return new JdbcTemplate(dataSource).queryForObject(finalizedQuery, Integer.class, validated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package eu.dnetlib.repo.manager.service;
|
package eu.dnetlib.repo.manager.service;
|
||||||
|
|
||||||
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||||
import eu.dnetlib.repo.manager.domain.*;
|
import eu.dnetlib.repo.manager.domain.*;
|
||||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -16,45 +16,43 @@ public interface RepositoryService {
|
||||||
// TODO: move this elsewhere
|
// TODO: move this elsewhere
|
||||||
Country[] getCountries();
|
Country[] getCountries();
|
||||||
|
|
||||||
List<Repository> getRepositories(List<String> ids) throws JSONException;
|
List<Repository> getRepositories(List<String> ids);
|
||||||
|
|
||||||
List<Repository> getRepositories(List<String> ids, int page, int size) throws JSONException;
|
List<Repository> getRepositories(List<String> ids, int page, int size);
|
||||||
|
|
||||||
List<RepositorySnippet> getRepositoriesSnippets(List<String> ids) throws Exception;
|
List<RepositorySnippet> getRepositoriesSnippets(List<String> ids) throws Exception;
|
||||||
|
|
||||||
List<RepositorySnippet> getRepositoriesSnippets(List<String> ids, int page, int size) throws Exception;
|
List<RepositorySnippet> getRepositoriesSnippets(List<String> ids, int page, int size) throws Exception;
|
||||||
|
|
||||||
List<RepositorySnippet> getRepositoriesByCountry(String country, String mode, Boolean managed) throws JSONException, IOException;
|
List<RepositorySnippet> getRepositoriesByCountry(String country, String mode, Boolean managed);
|
||||||
|
|
||||||
// TODO: remove?
|
// TODO: remove?
|
||||||
List<Repository> getRepositoriesOfUser(String page, String size) throws JSONException, IOException;
|
List<Repository> getRepositoriesOfUser(String page, String size);
|
||||||
|
|
||||||
// TODO: remove?
|
// TODO: remove?
|
||||||
List<Repository> getRepositoriesOfUser(String userEmail,
|
List<Repository> getRepositoriesOfUser(String userEmail, String page, String size);
|
||||||
String page,
|
|
||||||
String size) throws JSONException, IOException;
|
|
||||||
|
|
||||||
List<RepositorySnippet> getRepositoriesSnippetsOfUser(String page, String size) throws Exception;
|
List<RepositorySnippet> getRepositoriesSnippetsOfUser(String page, String size);
|
||||||
|
|
||||||
List<RepositorySnippet> getRepositoriesSnippetsOfUser(String userEmail, String page, String size) throws Exception;
|
List<RepositorySnippet> getRepositoriesSnippetsOfUser(String userEmail, String page, String size);
|
||||||
|
|
||||||
RepositorySnippet getRepositorySnippetById(String id) throws JSONException, ResourceNotFoundException;
|
RepositorySnippet getRepositorySnippetById(String id) throws ResourceNotFoundException;
|
||||||
|
|
||||||
Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException;
|
Repository getRepositoryById(String id) throws ResourceNotFoundException;
|
||||||
|
|
||||||
List<Repository> getRepositoriesByName(String name,
|
List<Repository> getRepositoriesByName(String name,
|
||||||
String page,
|
String page,
|
||||||
String size) throws JSONException;
|
String size);
|
||||||
|
|
||||||
List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
||||||
String officialName, String requestSortBy, String order,
|
String officialName, String requestSortBy, String order,
|
||||||
int page, int pageSize) throws Exception;
|
int page, int pageSize);
|
||||||
|
|
||||||
Integer getTotalRegisteredRepositories();
|
Integer getTotalRegisteredRepositories();
|
||||||
|
|
||||||
List<RepositoryInterface> getRepositoryInterface(String id) throws JSONException;
|
List<RepositoryInterface> getRepositoryInterface(String id);
|
||||||
|
|
||||||
Repository addRepository(String datatype, Repository repository) throws Exception;
|
Repository addRepository(String datatype, Repository repository);
|
||||||
|
|
||||||
void deleteRepositoryInterface(String id, String registeredBy);
|
void deleteRepositoryInterface(String id, String registeredBy);
|
||||||
|
|
||||||
|
@ -70,11 +68,9 @@ public interface RepositoryService {
|
||||||
|
|
||||||
List<Timezone> getTimezones();
|
List<Timezone> getTimezones();
|
||||||
|
|
||||||
Repository updateRepository(Repository repository, Authentication authentication) throws Exception;
|
Repository updateRepository(Repository repository, Authentication authentication);
|
||||||
|
|
||||||
List<String> getUrlsOfUserRepos(String user_email,
|
List<String> getUrlsOfUserRepos(String userEmail, String page, String size);
|
||||||
String page,
|
|
||||||
String size);
|
|
||||||
|
|
||||||
Map<String, String> getCompatibilityClasses(String mode);
|
Map<String, String> getCompatibilityClasses(String mode);
|
||||||
|
|
||||||
|
@ -86,7 +82,7 @@ public interface RepositoryService {
|
||||||
|
|
||||||
Map<String, String> getListLatestUpdate(String mode);
|
Map<String, String> getListLatestUpdate(String mode);
|
||||||
|
|
||||||
RepositoryInterface updateRepositoryInterface(String repoId, String comment, RepositoryInterface repositoryInterface, String desiredCompatibilityLevel) throws Exception;
|
RepositoryInterface updateRepositoryInterface(String repoId, String comment, RepositoryInterface repositoryInterface, String desiredCompatibilityLevel) throws ResourceNotFoundException, ValidatorServiceException;
|
||||||
|
|
||||||
void updateInterfaceCompliance(String repositoryId, String repositoryInterfaceId, String compliance);
|
void updateInterfaceCompliance(String repositoryId, String repositoryInterfaceId, String compliance);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,24 +4,20 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
||||||
import eu.dnetlib.domain.enabling.Vocabulary;
|
import eu.dnetlib.domain.enabling.Vocabulary;
|
||||||
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
import eu.dnetlib.domain.functionality.validator.JobForValidation;
|
||||||
import eu.dnetlib.repo.manager.domain.*;
|
import eu.dnetlib.repo.manager.domain.*;
|
||||||
import eu.dnetlib.repo.manager.domain.dto.Role;
|
|
||||||
import eu.dnetlib.repo.manager.domain.dto.User;
|
import eu.dnetlib.repo.manager.domain.dto.User;
|
||||||
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
import eu.dnetlib.repo.manager.exception.RepositoryServiceException;
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||||
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
||||||
import eu.dnetlib.repo.manager.service.security.AuthoritiesUpdater;
|
|
||||||
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
import eu.dnetlib.repo.manager.service.security.AuthorizationService;
|
||||||
import eu.dnetlib.repo.manager.service.security.RoleMappingService;
|
import eu.dnetlib.repo.manager.service.security.RoleMappingService;
|
||||||
import eu.dnetlib.repo.manager.utils.Converter;
|
import eu.dnetlib.repo.manager.utils.Converter;
|
||||||
import eu.dnetlib.repo.manager.utils.DateUtils;
|
import eu.dnetlib.repo.manager.utils.DateUtils;
|
||||||
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;
|
||||||
import org.json.JSONException;
|
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -34,13 +30,11 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.util.UriComponents;
|
import org.springframework.web.util.UriComponents;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
@ -53,7 +47,6 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
private final RoleMappingService roleMappingService;
|
private final RoleMappingService roleMappingService;
|
||||||
private final AaiRegistryService registryCalls;
|
private final AaiRegistryService registryCalls;
|
||||||
private final AuthoritiesUpdater authoritiesUpdater;
|
|
||||||
private final RestTemplate restTemplate;
|
private final RestTemplate restTemplate;
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
private final VocabularyLoader vocabularyLoader;
|
private final VocabularyLoader vocabularyLoader;
|
||||||
|
@ -88,11 +81,9 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
public RepositoryServiceImpl(AuthorizationService authorizationService,
|
public RepositoryServiceImpl(AuthorizationService authorizationService,
|
||||||
RoleMappingService roleMappingService,
|
RoleMappingService roleMappingService,
|
||||||
AaiRegistryService registryCalls,
|
AaiRegistryService registryCalls,
|
||||||
AuthoritiesUpdater authoritiesUpdater,
|
|
||||||
VocabularyLoader vocabularyLoader,
|
VocabularyLoader vocabularyLoader,
|
||||||
RestTemplate restTemplate,
|
RestTemplate restTemplate,
|
||||||
ObjectMapper objectMapper,
|
ObjectMapper objectMapper,
|
||||||
// Converter converter,
|
|
||||||
@Lazy EmailUtils emailUtils,
|
@Lazy EmailUtils emailUtils,
|
||||||
@Lazy ValidatorService validatorService,
|
@Lazy ValidatorService validatorService,
|
||||||
@Lazy PiWikService piWikService,
|
@Lazy PiWikService piWikService,
|
||||||
|
@ -100,7 +91,6 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
this.roleMappingService = roleMappingService;
|
this.roleMappingService = roleMappingService;
|
||||||
this.registryCalls = registryCalls;
|
this.registryCalls = registryCalls;
|
||||||
this.authoritiesUpdater = authoritiesUpdater;
|
|
||||||
this.vocabularyLoader = vocabularyLoader;
|
this.vocabularyLoader = vocabularyLoader;
|
||||||
this.piWikService = piWikService;
|
this.piWikService = piWikService;
|
||||||
this.emailUtils = emailUtils;
|
this.emailUtils = emailUtils;
|
||||||
|
@ -136,7 +126,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
httpHeaders = new HttpHeaders();
|
httpHeaders = new HttpHeaders();
|
||||||
httpHeaders.setContentType(MediaType.valueOf(MediaType.APPLICATION_JSON_VALUE));
|
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
for (String vocName : vocabularyNames) {
|
for (String vocName : vocabularyNames) {
|
||||||
vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT));
|
vocabularyMap.put(vocName, vocabularyLoader.getVocabulary(vocName, Locale.ENGLISH, Locale.ROOT));
|
||||||
|
@ -161,7 +151,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
// and the "requestFilter.setId(repoId)" should return only one result at a time, thus,
|
// and the "requestFilter.setId(repoId)" should return only one result at a time, thus,
|
||||||
// another way for paging must be implemented.
|
// another way for paging must be implemented.
|
||||||
@Override
|
@Override
|
||||||
public List<Repository> getRepositories(List<String> ids) throws JSONException {
|
public List<Repository> getRepositories(List<String> ids) {
|
||||||
return getRepositories(ids, 0, 10);
|
return getRepositories(ids, 0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +180,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
// and the "requestFilter.setId(repoId)" should return only one result at a time, thus,
|
// and the "requestFilter.setId(repoId)" should return only one result at a time, thus,
|
||||||
// another way for paging must be implemented.
|
// another way for paging must be implemented.
|
||||||
@Override
|
@Override
|
||||||
public List<RepositorySnippet> getRepositoriesSnippets(List<String> ids) throws Exception {
|
public List<RepositorySnippet> getRepositoriesSnippets(List<String> ids) {
|
||||||
return getRepositoriesSnippets(ids, 0, 10);
|
return getRepositoriesSnippets(ids, 0, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,8 +188,8 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
// and the "requestFilter.setId(repoId)" should return only one result at a time, thus,
|
// and the "requestFilter.setId(repoId)" should return only one result at a time, thus,
|
||||||
// another way for paging must be implemented.
|
// another way for paging must be implemented.
|
||||||
@Override
|
@Override
|
||||||
public List<RepositorySnippet> getRepositoriesSnippets(List<String> ids, int page, int size) throws Exception {
|
public List<RepositorySnippet> getRepositoriesSnippets(List<String> ids, int page, int size) {
|
||||||
List<RepositorySnippet> resultSet;
|
List<RepositorySnippet> resultSet = null;
|
||||||
List<DatasourceDetails> datasourceDetailsList = new ArrayList<>();
|
List<DatasourceDetails> datasourceDetailsList = new ArrayList<>();
|
||||||
|
|
||||||
// here page should be 0
|
// here page should be 0
|
||||||
|
@ -208,7 +198,6 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
for (String repoId : ids) {
|
for (String repoId : ids) {
|
||||||
requestFilter.setId(repoId);
|
requestFilter.setId(repoId);
|
||||||
|
|
||||||
DatasourceResponse rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, DatasourceResponse.class);
|
DatasourceResponse rs = restTemplate.postForObject(uriComponents.toUri(), requestFilter, DatasourceResponse.class);
|
||||||
if (rs == null) {
|
if (rs == null) {
|
||||||
logger.error("The \"DatasourceResponse\" is null!");
|
logger.error("The \"DatasourceResponse\" is null!");
|
||||||
|
@ -217,15 +206,18 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resultSet = objectMapper.readValue(objectMapper.writeValueAsString(datasourceDetailsList),
|
try {
|
||||||
objectMapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class));
|
resultSet = objectMapper.readValue(objectMapper.writeValueAsString(datasourceDetailsList),
|
||||||
|
objectMapper.getTypeFactory().constructCollectionType(List.class, RepositorySnippet.class));
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("resultSet: {}", objectMapper.writeValueAsString(resultSet));
|
logger.debug("resultSet: {}", objectMapper.writeValueAsString(resultSet));
|
||||||
|
}
|
||||||
|
resultSet.parallelStream().forEach(repositorySnippet -> {
|
||||||
|
repositorySnippet.setPiwikInfo(piWikService.getPiwikSiteForRepo(repositorySnippet.getId()));
|
||||||
|
});
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
logger.error("Error deserializing.", e);
|
||||||
}
|
}
|
||||||
resultSet.parallelStream().forEach(repositorySnippet -> {
|
|
||||||
repositorySnippet.setPiwikInfo(piWikService.getPiwikSiteForRepo(repositorySnippet.getId()));
|
|
||||||
});
|
|
||||||
return resultSet;
|
return resultSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +225,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
@Override
|
@Override
|
||||||
public List<RepositorySnippet> getRepositoriesByCountry(String country,
|
public List<RepositorySnippet> getRepositoriesByCountry(String country,
|
||||||
String mode,
|
String mode,
|
||||||
Boolean managed) throws IOException {
|
Boolean managed) {
|
||||||
logger.debug("Getting repositories by country!");
|
logger.debug("Getting repositories by country!");
|
||||||
int page = 0;
|
int page = 0;
|
||||||
int size = 100;
|
int size = 100;
|
||||||
|
@ -256,7 +248,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
public List<RepositorySnippet> searchRegisteredRepositories(String country, String typology, String englishName,
|
||||||
String officialName, String requestSortBy, String order, int page, int pageSize) throws Exception {
|
String officialName, String requestSortBy, String order, int page, int pageSize) {
|
||||||
|
|
||||||
logger.debug("Searching registered repositories");
|
logger.debug("Searching registered repositories");
|
||||||
|
|
||||||
|
@ -289,7 +281,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Repository> getRepositoriesOfUser(String page, String size) throws JSONException {
|
public List<Repository> getRepositoriesOfUser(String page, String size) {
|
||||||
logger.debug("Retrieving repositories of authenticated user : {}",
|
logger.debug("Retrieving repositories of authenticated user : {}",
|
||||||
((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail());
|
((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail());
|
||||||
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles());
|
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRoles());
|
||||||
|
@ -297,19 +289,19 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Repository> getRepositoriesOfUser(String userEmail, String page, String size) throws JSONException {
|
public List<Repository> getRepositoriesOfUser(String userEmail, String page, String size) {
|
||||||
logger.debug("Retrieving repositories of authenticated user : {}", userEmail);
|
logger.debug("Retrieving repositories of authenticated user : {}", userEmail);
|
||||||
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRolesByEmail(userEmail));
|
Collection<String> repoIds = roleMappingService.getRepoIdsByRoleIds(authorizationService.getUserRolesByEmail(userEmail));
|
||||||
return getRepositories(new ArrayList<>(repoIds));
|
return getRepositories(new ArrayList<>(repoIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RepositorySnippet> getRepositoriesSnippetsOfUser(String page, String size) throws Exception {
|
public List<RepositorySnippet> getRepositoriesSnippetsOfUser(String page, String size) {
|
||||||
return getRepositoriesSnippetsOfUser(null, page, size);
|
return getRepositoriesSnippetsOfUser(null, page, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RepositorySnippet> getRepositoriesSnippetsOfUser(String userEmail, String page, String size) throws Exception {
|
public List<RepositorySnippet> getRepositoriesSnippetsOfUser(String userEmail, String page, String size) {
|
||||||
int from = Integer.parseInt(page) * Integer.parseInt(size);
|
int from = Integer.parseInt(page) * Integer.parseInt(size);
|
||||||
int to = from + Integer.parseInt(size);
|
int to = from + Integer.parseInt(size);
|
||||||
List<String> repoIds = new ArrayList<>();
|
List<String> repoIds = new ArrayList<>();
|
||||||
|
@ -363,7 +355,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
@Override
|
@Override
|
||||||
public List<Repository> getRepositoriesByName(String name,
|
public List<Repository> getRepositoriesByName(String name,
|
||||||
String page,
|
String page,
|
||||||
String size) throws JSONException {
|
String size) {
|
||||||
|
|
||||||
logger.debug("Retrieving repositories with official name : {}", name);
|
logger.debug("Retrieving repositories with official name : {}", name);
|
||||||
UriComponents uriComponents = searchDatasourceUri("0", "100");
|
UriComponents uriComponents = searchDatasourceUri("0", "100");
|
||||||
|
@ -402,7 +394,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Repository addRepository(String datatype, Repository repository) throws Exception {
|
public Repository addRepository(String datatype, Repository repository) {
|
||||||
|
|
||||||
logger.debug("storing '{}' repository with id: {}", datatype, repository.getId());
|
logger.debug("storing '{}' repository with id: {}", datatype, repository.getId());
|
||||||
|
|
||||||
|
@ -433,32 +425,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
this.latentUpdate(repository, SecurityContextHolder.getContext().getAuthentication());
|
this.latentUpdate(repository, SecurityContextHolder.getContext().getAuthentication());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move the following code elsewhere (creation and assignment of role to user) ??
|
authorizationService.createAndAssignRoleToAuthenticatedUser(repository.getId(), repository.getOfficialname());
|
||||||
// Create new role
|
|
||||||
String newRoleName = roleMappingService.getRoleIdByRepoId(repository.getId());
|
|
||||||
Role newRole = new Role(newRoleName, repository.getOfficialname());
|
|
||||||
Integer couId = null;
|
|
||||||
try {
|
|
||||||
couId = registryCalls.createRole(newRole);
|
|
||||||
} catch (HttpClientErrorException e) {
|
|
||||||
couId = registryCalls.getCouId(newRoleName);
|
|
||||||
if (couId == null) {
|
|
||||||
logger.error(String.format("Could not create role '%s'", newRoleName), e);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(String.format("Could not create role '%s'", newRoleName), e);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign new role to the user that created it
|
|
||||||
Integer coPersonId = registryCalls.getCoPersonIdByIdentifier();
|
|
||||||
if (couId != null) {
|
|
||||||
Integer role = registryCalls.getRoleId(coPersonId, couId);
|
|
||||||
registryCalls.assignMemberRole(coPersonId, couId, role);
|
|
||||||
|
|
||||||
// Add role to current user authorities
|
|
||||||
authoritiesUpdater.addRole(roleMappingService.convertRepoIdToAuthority(repository.getId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
@ -486,7 +453,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Repository updateRepository(Repository repository, Authentication authentication) throws Exception {
|
public Repository updateRepository(Repository repository, Authentication authentication) {
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
UriComponents uriComponents = UriComponentsBuilder
|
||||||
.fromHttpUrl(baseAddress + "/ds/update/")
|
.fromHttpUrl(baseAddress + "/ds/update/")
|
||||||
.build()
|
.build()
|
||||||
|
@ -507,7 +474,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeRepository(Repository repository, Authentication authentication) throws Exception {
|
private void storeRepository(Repository repository, Authentication authentication) {
|
||||||
|
|
||||||
Date utilDate = new Date();
|
Date utilDate = new Date();
|
||||||
Timestamp date = new Timestamp(utilDate.getTime());
|
Timestamp date = new Timestamp(utilDate.getTime());
|
||||||
|
@ -550,13 +517,12 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
RepositoryInterface repositoryInterface,
|
RepositoryInterface repositoryInterface,
|
||||||
String desiredCompatibilityLevel) throws Exception {
|
String desiredCompatibilityLevel) throws Exception {
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
Repository e = this.getRepositoryById(repoId);
|
Repository repo = this.getRepositoryById(repoId);
|
||||||
repositoryInterface = fillInterfaceFields(e, repositoryInterface, datatype);
|
repositoryInterface = fillInterfaceFields(repo, repositoryInterface, datatype);
|
||||||
|
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
UriComponents uriComponents = UriComponentsBuilder
|
||||||
.fromHttpUrl(baseAddress + "/ds/api/add/")
|
.fromHttpUrl(baseAddress + "/ds/api/add/")
|
||||||
.build()
|
.build().encode();
|
||||||
.encode();
|
|
||||||
|
|
||||||
HttpEntity<RepositoryInterface> httpEntity = new HttpEntity<>(repositoryInterface, httpHeaders);
|
HttpEntity<RepositoryInterface> httpEntity = new HttpEntity<>(repositoryInterface, httpHeaders);
|
||||||
restTemplate.postForObject(uriComponents.toUri(), httpEntity, String.class);
|
restTemplate.postForObject(uriComponents.toUri(), httpEntity, String.class);
|
||||||
|
@ -564,15 +530,17 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
// Explicitly update validation set (updating the interface does not allow updating the set value)
|
// Explicitly update validation set (updating the interface does not allow updating the set value)
|
||||||
this.updateValidationSet(repoId, repositoryInterface.getId(), repositoryInterface.getAccessSet());
|
this.updateValidationSet(repoId, repositoryInterface.getId(), repositoryInterface.getAccessSet());
|
||||||
|
|
||||||
emailUtils.sendAdminRegisterInterfaceEmail(e, comment, repositoryInterface, authentication);
|
emailUtils.sendAdminRegisterInterfaceEmail(repo, comment, repositoryInterface, desiredCompatibilityLevel, authentication);
|
||||||
emailUtils.sendUserRegisterInterfaceEmail(e, comment, repositoryInterface, authentication);
|
emailUtils.sendUserRegisterInterfaceEmail(repo, comment, repositoryInterface, desiredCompatibilityLevel, authentication);
|
||||||
|
|
||||||
if (desiredCompatibilityLevel != null && (repositoryInterface.getCompatibility() == null || !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel))) {
|
String prevCompatibilityLevel = repositoryInterface.getCompatibility();
|
||||||
|
if ( (desiredCompatibilityLevel != null)
|
||||||
|
&& ((prevCompatibilityLevel == null) || ! prevCompatibilityLevel.equals(desiredCompatibilityLevel))) {
|
||||||
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);
|
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);
|
||||||
interfaceComplianceService.create(request);
|
interfaceComplianceService.create(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
submitInterfaceValidation(e, getAuthenticatedUser().getEmail(), repositoryInterface, false, repositoryInterface.getCompatibility());
|
submitInterfaceValidation(repo, getAuthenticatedUser().getEmail(), repositoryInterface, false, desiredCompatibilityLevel);
|
||||||
|
|
||||||
return repositoryInterface;
|
return repositoryInterface;
|
||||||
}
|
}
|
||||||
|
@ -581,7 +549,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
public RepositoryInterface updateRepositoryInterface(String repoId,
|
public RepositoryInterface updateRepositoryInterface(String repoId,
|
||||||
String comment,
|
String comment,
|
||||||
RepositoryInterface repositoryInterface,
|
RepositoryInterface repositoryInterface,
|
||||||
String desiredCompatibilityLevel) throws Exception {
|
String desiredCompatibilityLevel) throws ResourceNotFoundException, ValidatorServiceException {
|
||||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
Repository repository = this.getRepositoryById(repoId);
|
Repository repository = this.getRepositoryById(repoId);
|
||||||
if (repositoryInterface.getId() != null) {
|
if (repositoryInterface.getId() != null) {
|
||||||
|
@ -593,8 +561,8 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
this.updateValidationSet(repoId, repositoryInterface.getId(), repositoryInterface.getAccessSet());
|
this.updateValidationSet(repoId, repositoryInterface.getId(), repositoryInterface.getAccessSet());
|
||||||
|
|
||||||
emailUtils.sendAdminUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication);
|
emailUtils.sendAdminUpdateInterfaceEmail(repository, comment, repositoryInterface, desiredCompatibilityLevel, authentication);
|
||||||
emailUtils.sendUserUpdateInterfaceEmail(repository, comment, repositoryInterface, authentication);
|
emailUtils.sendUserUpdateInterfaceEmail(repository, comment, repositoryInterface, desiredCompatibilityLevel, authentication);
|
||||||
|
|
||||||
if (desiredCompatibilityLevel != null && (repositoryInterface.getCompatibility() == null || !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel))) {
|
if (desiredCompatibilityLevel != null && (repositoryInterface.getCompatibility() == null || !repositoryInterface.getCompatibility().equals(desiredCompatibilityLevel))) {
|
||||||
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);
|
InterfaceComplianceRequest request = new InterfaceComplianceRequest(repoId, repositoryInterface.getId(), desiredCompatibilityLevel);
|
||||||
|
@ -704,8 +672,8 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
RequestFilter requestFilter = new RequestFilter();
|
RequestFilter requestFilter = new RequestFilter();
|
||||||
requestFilter.setRegisteredby(userEmail);
|
requestFilter.setRegisteredby(userEmail);
|
||||||
Object result = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String[].class);
|
String[] result = restTemplate.postForObject(uriComponents.toUri(), requestFilter, String[].class);
|
||||||
return (result != null) ? Collections.singletonList(result.toString()) : null;
|
return (result != null) ? Arrays.asList(result) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vocabulary getVocabulary(String vocName) {
|
private Vocabulary getVocabulary(String vocName) {
|
||||||
|
@ -721,7 +689,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
public Map<String, String> getCompatibilityClasses(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> retMap = new HashMap<>();
|
||||||
|
|
||||||
Map<String, String> compatibilityClasses = this.getVocabulary("dnet:compatibilityLevel").getAsMap();
|
Map<String, String> compatibilityClasses = this.getVocabulary("dnet:compatibilityLevel").getAsMap();
|
||||||
boolean foundData = false;
|
boolean foundData = false;
|
||||||
|
@ -756,7 +724,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
|
|
||||||
logger.debug("Getting datasource classes for mode: {}", mode);
|
logger.debug("Getting datasource classes for mode: {}", mode);
|
||||||
|
|
||||||
Map<String, String> retMap = new HashMap<String, String>();
|
Map<String, String> retMap = new HashMap<>();
|
||||||
|
|
||||||
// TODO: refactor (remove?)
|
// TODO: refactor (remove?)
|
||||||
for (Map.Entry<String, String> entry : this.getVocabulary("dnet:datasource_typologies").getAsMap().entrySet()) {
|
for (Map.Entry<String, String> entry : this.getVocabulary("dnet:datasource_typologies").getAsMap().entrySet()) {
|
||||||
|
@ -850,7 +818,7 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
return Collections.singletonMap("lastCollectionDate", DateUtils.toString(getRepositoryInterface("openaire____::" + mode).get(0).getLastCollectionDate()));
|
return Collections.singletonMap("lastCollectionDate", DateUtils.toString(getRepositoryInterface("openaire____::" + mode).get(0).getLastCollectionDate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateValidationSet(String repositoryId, String repositoryInterfaceId, String validationSet) throws Exception {
|
private void updateValidationSet(String repositoryId, String repositoryInterfaceId, String validationSet) {
|
||||||
UriComponents uriComponents = UriComponentsBuilder
|
UriComponents uriComponents = UriComponentsBuilder
|
||||||
.fromHttpUrl(baseAddress + "/ds/api/oaiset")
|
.fromHttpUrl(baseAddress + "/ds/api/oaiset")
|
||||||
.queryParam("dsId", repositoryId)
|
.queryParam("dsId", repositoryId)
|
||||||
|
@ -994,22 +962,19 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> getRoleIdsFromUserRoles(String userEmail) {
|
private List<String> getRoleIdsFromUserRoles(String userEmail) {
|
||||||
Integer coPersonId = registryCalls.getCoPersonIdByEmail(userEmail);
|
List<Integer> coPersonId = registryCalls.getCoPersonIdsByEmail(userEmail);
|
||||||
JsonArray roles;
|
JsonArray roles;
|
||||||
ArrayList<String> roleIds = new ArrayList<>();
|
ArrayList<String> roleIds = new ArrayList<>();
|
||||||
ArrayList<Integer> couIds = new ArrayList<>();
|
ArrayList<Integer> couIds = new ArrayList<>();
|
||||||
if (coPersonId != null) {
|
if (coPersonId != null) {
|
||||||
roles = registryCalls.getRolesWithStatus(coPersonId, AaiRegistryService.RoleStatus.ACTIVE);
|
roles = registryCalls.getRolesWithStatus(coPersonId, AaiRegistryService.RoleStatus.ACTIVE);
|
||||||
for (JsonElement role : roles) {
|
for (JsonElement role : roles) {
|
||||||
JsonObject object = role.getAsJsonObject();
|
JsonElement couId = role.getAsJsonObject().get("CouId");
|
||||||
if (object.get("CouId") == null) {
|
if (couId != null)
|
||||||
continue;
|
couIds.add(couId.getAsInt());
|
||||||
}
|
|
||||||
couIds.add(object.get("CouId").getAsInt());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
roleIds.addAll(registryCalls.getCouNames(couIds).values());
|
roleIds.addAll(registryCalls.getCouNames(couIds).values());
|
||||||
|
|
||||||
}
|
}
|
||||||
return roleIds;
|
return roleIds;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,22 +95,20 @@ public class SushiliteServiceImpl implements SushiliteService {
|
||||||
Customer customer = reportResponseWrapper.getReportResponse().getReportWrapper().getReport().getCustomer();
|
Customer customer = reportResponseWrapper.getReportResponse().getReportWrapper().getReport().getCustomer();
|
||||||
List<ReportItem> allReportItems = customer.getReportItems();
|
List<ReportItem> allReportItems = customer.getReportItems();
|
||||||
|
|
||||||
if ( allReportItems != null) {
|
if ( allReportItems != null ) {
|
||||||
try {
|
try {
|
||||||
int totalItems = allReportItems.size();
|
int totalItems = allReportItems.size();
|
||||||
int size = Integer.parseInt(pageSize);
|
int size = Integer.parseInt(pageSize);
|
||||||
int offset = (Integer.parseInt(page) * size);
|
int offset = (Integer.parseInt(page) * size);
|
||||||
|
if ( offset < totalItems ) {
|
||||||
if (offset < totalItems ) {
|
|
||||||
int upperIndex = (offset + size);
|
int upperIndex = (offset + size);
|
||||||
if (upperIndex > totalItems) {
|
if ( upperIndex > totalItems ) {
|
||||||
upperIndex = totalItems;
|
upperIndex = totalItems;
|
||||||
}
|
}
|
||||||
requestedItemList = allReportItems.subList(offset, upperIndex);
|
requestedItemList = allReportItems.subList(offset, upperIndex);
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
logger.debug("Exception on getReportResults - trying to cast strings to integers", e);
|
logger.error("Exception on getReportResults - trying to cast strings to integers", e);
|
||||||
//emailUtils.reportException(e);
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,7 +185,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ruleSet != null){
|
if (ruleSet != null) {
|
||||||
for (int ruleId : job.getRules()) {
|
for (int ruleId : job.getRules()) {
|
||||||
if (ruleSet.getContentRulesIds().contains(ruleId))
|
if (ruleSet.getContentRulesIds().contains(ruleId))
|
||||||
contentRules.add(ruleId);
|
contentRules.add(ruleId);
|
||||||
|
@ -210,16 +210,13 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
@Override
|
@Override
|
||||||
public List<String> getSetsOfRepository(String url) {
|
public List<String> getSetsOfRepository(String url) {
|
||||||
logger.debug("Getting sets of repository with url : {}", url);
|
logger.debug("Getting sets of repository with url : {}", url);
|
||||||
|
|
||||||
List<String> sets = null;
|
List<String> sets = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sets = OaiTools.getSetsOfRepo(url);
|
sets = OaiTools.getSetsOfRepo(url);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Exception on getSetsOfRepository", e);
|
logger.error("Exception on getSetsOfRepository", e);
|
||||||
}
|
}
|
||||||
|
return sets; // It may be null.
|
||||||
return sets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -239,13 +236,16 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
RuleSet ruleSet = null;
|
RuleSet ruleSet = null;
|
||||||
try {
|
try {
|
||||||
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
for (List<RuleSet> ruleSets : this.rulesetMap.values()) {
|
||||||
for (RuleSet rSet : ruleSets)
|
for ( RuleSet rSet : ruleSets ) {
|
||||||
if (rSet.getGuidelinesAcronym().equals(acronym)) {
|
if ( rSet.getGuidelinesAcronym().equals(acronym) ) {
|
||||||
ruleSet = rSet;
|
ruleSet = rSet;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if ( ruleSet != null )
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return ruleSet;
|
return ruleSet; // It may be null.
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error getting ruleset", e);
|
logger.error("Error getting ruleset", e);
|
||||||
return null;
|
return null;
|
||||||
|
@ -310,10 +310,11 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(String repoId, String interfaceId, String jobId, String issuerEmail, boolean isUpdate, boolean isSuccess, int scoreUsage, int scoreContent) throws Exception {
|
public void onComplete(String repoId, String interfaceId, String jobId, String issuerEmail, boolean isUpdate, boolean isSuccess, int scoreUsage, int scoreContent) throws Exception {
|
||||||
emailUtils.sendUponJobCompletion(repoId,interfaceId,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId);
|
|
||||||
InterfaceComplianceRequestId requestId = InterfaceComplianceRequestId.of(repoId, interfaceId);
|
InterfaceComplianceRequestId requestId = InterfaceComplianceRequestId.of(repoId, interfaceId);
|
||||||
Optional<InterfaceComplianceRequest> request = interfaceComplianceService.getById(requestId);
|
Optional<InterfaceComplianceRequest> request = interfaceComplianceService.getById(requestId);
|
||||||
|
String compatibility = null;
|
||||||
if (request.isPresent()) {
|
if (request.isPresent()) {
|
||||||
|
compatibility = request.get().getDesiredCompatibilityLevel();
|
||||||
logger.info("Changing compatibility level. Request: {}", request);
|
logger.info("Changing compatibility level. Request: {}", request);
|
||||||
|
|
||||||
if (scoreContent > 50) {
|
if (scoreContent > 50) {
|
||||||
|
@ -321,6 +322,7 @@ public class ValidatorServiceImpl implements ValidatorService {
|
||||||
}
|
}
|
||||||
interfaceComplianceService.delete(requestId);
|
interfaceComplianceService.delete(requestId);
|
||||||
}
|
}
|
||||||
|
emailUtils.sendUponJobCompletion(repoId,interfaceId,compatibility,scoreUsage,scoreContent,isSuccess,isUpdate,issuerEmail, jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,28 +11,36 @@ import java.util.Map;
|
||||||
public interface AaiRegistryService {
|
public interface AaiRegistryService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1.1 Get CoPersonId by authenticated user's Email
|
* 1.1 Get CoPersonId List by authenticated user's Email
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer getCoPersonIdByEmail();
|
List<Integer> getCoPersonIdsByEmail();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1.2 Get CoPersonId by Email
|
* 1.2 Get CoPersonId List by Email
|
||||||
*
|
|
||||||
* @param email
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Integer getCoPersonIdByEmail(String email);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 1. Get CoPersonId List by Email
|
|
||||||
*
|
*
|
||||||
* @param email
|
* @param email
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Integer> getCoPersonIdsByEmail(String email);
|
List<Integer> getCoPersonIdsByEmail(String email);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1.3 Get a list of User Identifiers by Email
|
||||||
|
*
|
||||||
|
* @param email
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<String> getUserIdentifiersByEmail(String email);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 1.3 Get a list of User Identifiers by Email
|
||||||
|
*
|
||||||
|
* @param coPersonId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<String> getUserIdentifiersByCoPersonId(Integer coPersonId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 2. Get CoPersonId by AAI identifier
|
* 2. Get CoPersonId by AAI identifier
|
||||||
*
|
*
|
||||||
|
@ -97,6 +105,14 @@ public interface AaiRegistryService {
|
||||||
*/
|
*/
|
||||||
JsonArray getRolesWithStatus(Integer coPersonId, RoleStatus status);
|
JsonArray getRolesWithStatus(Integer coPersonId, RoleStatus status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 5.3 Get User non admin active roles
|
||||||
|
*
|
||||||
|
* @param coPersonIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
JsonArray getRolesWithStatus(List<Integer> coPersonIds, RoleStatus status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 6. Get Role id of User base on couId.
|
* 6. Get Role id of User base on couId.
|
||||||
*
|
*
|
||||||
|
@ -188,9 +204,8 @@ public interface AaiRegistryService {
|
||||||
*
|
*
|
||||||
* @param coPersonId
|
* @param coPersonId
|
||||||
* @param couId
|
* @param couId
|
||||||
* @param id
|
|
||||||
*/
|
*/
|
||||||
void assignMemberRole(Integer coPersonId, Integer couId, Integer id);
|
void assignMemberRole(Integer coPersonId, Integer couId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 16. Remove a member role from a User
|
* 16. Remove a member role from a User
|
||||||
|
|
|
@ -6,8 +6,8 @@ import com.google.gson.JsonObject;
|
||||||
import com.nimbusds.jose.util.StandardCharset;
|
import com.nimbusds.jose.util.StandardCharset;
|
||||||
import eu.dnetlib.repo.manager.domain.dto.Role;
|
import eu.dnetlib.repo.manager.domain.dto.Role;
|
||||||
import eu.dnetlib.repo.manager.domain.dto.User;
|
import eu.dnetlib.repo.manager.domain.dto.User;
|
||||||
|
import eu.dnetlib.repo.manager.service.aai.registry.utils.HttpUtils;
|
||||||
import eu.dnetlib.repo.manager.service.aai.registry.utils.RegistryUtils;
|
import eu.dnetlib.repo.manager.service.aai.registry.utils.RegistryUtils;
|
||||||
import eu.dnetlib.repo.manager.utils.HttpUtils;
|
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -16,29 +16,24 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class RegistryCalls implements AaiRegistryService {
|
public class RegistryCalls implements AaiRegistryService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(RegistryCalls.class);
|
private static final Logger logger = LoggerFactory.getLogger(RegistryCalls.class);
|
||||||
|
|
||||||
private final String coid;
|
|
||||||
public final HttpUtils httpUtils;
|
public final HttpUtils httpUtils;
|
||||||
public final RegistryUtils jsonUtils;
|
public final RegistryUtils jsonUtils;
|
||||||
|
private final String coid;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RegistryCalls(@Value("${services.provide.aai.registry.coid:2}") String coid,
|
RegistryCalls(HttpUtils httpUtils, RegistryUtils registryUtils, @Value("${services.provide.aai.registry.coid}") String coid) {
|
||||||
HttpUtils httpUtils, RegistryUtils registryUtils) {
|
|
||||||
this.coid = coid;
|
|
||||||
this.httpUtils = httpUtils;
|
this.httpUtils = httpUtils;
|
||||||
this.jsonUtils = registryUtils;
|
this.jsonUtils = registryUtils;
|
||||||
|
this.coid = coid;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String mapType(String type, boolean communityMap) {
|
private String mapType(String type, boolean communityMap) {
|
||||||
|
@ -51,42 +46,51 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getCoPersonIdByEmail() {
|
public List<String> getUserIdentifiersByEmail(String email) {
|
||||||
|
List<String> ids = new ArrayList<>();
|
||||||
|
for (Integer coPersonId : getCoPersonIdsByEmail(email)) {
|
||||||
|
ids.addAll(getUserIdentifiersByCoPersonId(coPersonId));
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getUserIdentifiersByCoPersonId(Integer coPersonId) {
|
||||||
|
List<String> ids = new ArrayList<>();
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("copersonid", coPersonId.toString());
|
||||||
|
|
||||||
|
JsonElement response = httpUtils.get("identifiers.json", params);
|
||||||
|
if (response != null) {
|
||||||
|
JsonArray infos = response.getAsJsonObject().get("Identifiers").getAsJsonArray();
|
||||||
|
infos.forEach(info -> {
|
||||||
|
JsonObject jsonInfo = info.getAsJsonObject();
|
||||||
|
if (!jsonInfo.get("Deleted").getAsBoolean()) {
|
||||||
|
ids.add(jsonInfo.get("Identifier").getAsString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Integer> getCoPersonIdsByEmail() {
|
||||||
try {
|
try {
|
||||||
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
|
||||||
String email = authentication.getUserInfo().getEmail();
|
String email = authentication.getUserInfo().getEmail();
|
||||||
Map<String, String> params = new HashMap<>();
|
return getCoPersonIdsByEmail(email);
|
||||||
params.put("coid", coid);
|
|
||||||
params.put("mail", email);
|
|
||||||
JsonElement response = httpUtils.get("co_people.json", params);
|
|
||||||
return (response != null) ? response.getAsJsonObject().get("CoPeople").getAsJsonArray().get(0).getAsJsonObject().get("Id").getAsInt() : null;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Get User info: An error occurred ", e);
|
logger.error("Get User info: An error occurred ", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer getCoPersonIdByEmail(String email) {
|
|
||||||
Map<String, String> params = new HashMap<>();
|
|
||||||
params.put("coid", coid);
|
|
||||||
params.put("mail", email);
|
|
||||||
JsonElement response = httpUtils.get("co_people.json", params);
|
|
||||||
if (response != null) {
|
|
||||||
JsonArray coPeople = response.getAsJsonObject().get("CoPeople").getAsJsonArray();
|
|
||||||
if (coPeople.size() > 0) {
|
|
||||||
return coPeople.get(0).getAsJsonObject().get("Id").getAsInt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> getCoPersonIdsByEmail(String email) {
|
public List<Integer> getCoPersonIdsByEmail(String email) {
|
||||||
List<Integer> coPersonIds = new ArrayList<>();
|
List<Integer> coPersonIds = new ArrayList<>();
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("coid", coid);
|
|
||||||
params.put("mail", email);
|
params.put("mail", email);
|
||||||
|
params.put("coid", coid);
|
||||||
JsonElement response = httpUtils.get("co_people.json", params);
|
JsonElement response = httpUtils.get("co_people.json", params);
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
JsonArray coPeople = response.getAsJsonObject().get("CoPeople").getAsJsonArray();
|
JsonArray coPeople = response.getAsJsonObject().get("CoPeople").getAsJsonArray();
|
||||||
|
@ -111,8 +115,8 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
|
|
||||||
public Integer getCoPersonIdByIdentifier(String sub) {
|
public Integer getCoPersonIdByIdentifier(String sub) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("coid", coid);
|
|
||||||
params.put("search.identifier", sub);
|
params.put("search.identifier", sub);
|
||||||
|
params.put("coid", coid);
|
||||||
JsonElement response = httpUtils.get("co_people.json", params);
|
JsonElement response = httpUtils.get("co_people.json", params);
|
||||||
return (response != null) ? response.getAsJsonObject().get("CoPeople").getAsJsonArray().get(0).getAsJsonObject().get("Id").getAsInt() : null;
|
return (response != null) ? response.getAsJsonObject().get("CoPeople").getAsJsonArray().get(0).getAsJsonObject().get("Id").getAsInt() : null;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +124,6 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
@Override
|
@Override
|
||||||
public JsonArray getCous(String name) {
|
public JsonArray getCous(String name) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("coid", coid);
|
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
try {
|
try {
|
||||||
params.put("name", URLEncoder.encode(name, StandardCharset.UTF_8.name()).toLowerCase());
|
params.put("name", URLEncoder.encode(name, StandardCharset.UTF_8.name()).toLowerCase());
|
||||||
|
@ -169,10 +172,13 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonArray getRolesWithStatus(Integer coPersonId, RoleStatus status) {
|
public JsonArray getRolesWithStatus(Integer coPersonId, RoleStatus status) {
|
||||||
JsonArray roles = getRoles(coPersonId);
|
return getRolesWithStatus(Collections.singletonList(coPersonId), status);
|
||||||
if (roles == null) {
|
}
|
||||||
roles = new JsonArray();
|
|
||||||
}
|
@Override
|
||||||
|
public JsonArray getRolesWithStatus(List<Integer> coPersonIds, RoleStatus status) {
|
||||||
|
JsonArray roles = new JsonArray();
|
||||||
|
coPersonIds.parallelStream().forEach(coPersonId -> roles.addAll(getRoles(coPersonId)));
|
||||||
JsonArray activeRoles = new JsonArray();
|
JsonArray activeRoles = new JsonArray();
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
for (JsonElement role : roles) {
|
for (JsonElement role : roles) {
|
||||||
|
@ -181,7 +187,6 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert activeRoles != null;
|
|
||||||
return activeRoles;
|
return activeRoles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +230,6 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
@Override
|
@Override
|
||||||
public JsonArray getCouGroups(Integer couId) {
|
public JsonArray getCouGroups(Integer couId) {
|
||||||
Map<String, String> params = new HashMap<>();
|
Map<String, String> params = new HashMap<>();
|
||||||
params.put("coid", coid);
|
|
||||||
params.put("couid", couId.toString());
|
params.put("couid", couId.toString());
|
||||||
JsonElement response = httpUtils.get("co_groups.json", params);
|
JsonElement response = httpUtils.get("co_groups.json", params);
|
||||||
return (response != null) ? response.getAsJsonObject().get("CoGroups").getAsJsonArray() : new JsonArray();
|
return (response != null) ? response.getAsJsonObject().get("CoGroups").getAsJsonArray() : new JsonArray();
|
||||||
|
@ -356,18 +360,15 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void assignMemberRole(Integer coPersonId, Integer couId, Integer id) {
|
public void assignMemberRole(Integer coPersonId, Integer couId) {
|
||||||
if (id != null) {
|
httpUtils.post("co_person_roles.json", jsonUtils.coPersonRoles(coPersonId, couId, "Active"));
|
||||||
httpUtils.put("co_person_roles/" + id.toString() + ".json", jsonUtils.coPersonRoles(coPersonId, couId, "Active"));
|
|
||||||
} else {
|
|
||||||
httpUtils.post("co_person_roles.json", jsonUtils.coPersonRoles(coPersonId, couId, "Active"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeMemberRole(Integer coPersonId, Integer couId, Integer id) {
|
public void removeMemberRole(Integer coPersonId, Integer couId, Integer id) {
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
httpUtils.put("co_person_roles/" + id.toString() + ".json", jsonUtils.coPersonRoles(coPersonId, couId, "Deleted"));
|
httpUtils.put("co_person_roles/" + id + ".json", jsonUtils.coPersonRoles(coPersonId, couId, "Deleted"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +393,7 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
params.put("copersonid", coPersonId.toString());
|
params.put("copersonid", coPersonId.toString());
|
||||||
JsonElement response = httpUtils.get("names.json", params);
|
JsonElement response = httpUtils.get("names.json", params);
|
||||||
JsonObject info = (response != null) ? response.getAsJsonObject().get("Names").getAsJsonArray().get(0).getAsJsonObject() : null;
|
JsonObject info = (response != null) ? response.getAsJsonObject().get("Names").getAsJsonArray().get(0).getAsJsonObject() : null;
|
||||||
if ( info != null ) {
|
if (info != null) {
|
||||||
JsonObject jsonInfo = info.getAsJsonObject();
|
JsonObject jsonInfo = info.getAsJsonObject();
|
||||||
return jsonInfo.get("Given").getAsString() + " " + jsonInfo.get("Family").getAsString();
|
return jsonInfo.get("Given").getAsString() + " " + jsonInfo.get("Family").getAsString();
|
||||||
} else
|
} else
|
||||||
|
@ -427,7 +428,7 @@ public class RegistryCalls implements AaiRegistryService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
httpUtils.delete("co_group_members/" + id.toString() + ".json");
|
httpUtils.delete("co_group_members/" + id + ".json");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.dnetlib.repo.manager.utils;
|
package eu.dnetlib.repo.manager.service.aai.registry.utils;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
@ -9,9 +9,13 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import org.springframework.web.util.UriComponents;
|
||||||
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
@ -48,7 +52,7 @@ public class HttpUtils {
|
||||||
|
|
||||||
public JsonElement get(String path, Map<String, String> params) {
|
public JsonElement get(String path, Map<String, String> params) {
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
String url = registryUrl + path + ((params != null) ? createParams(params) : null);
|
String url = createUrl(registryUrl + path, params);
|
||||||
ResponseEntity<String> responseEntity = restTemplate.exchange
|
ResponseEntity<String> responseEntity = restTemplate.exchange
|
||||||
(url, HttpMethod.GET, new HttpEntity<>(createHeaders(user, password)), String.class);
|
(url, HttpMethod.GET, new HttpEntity<>(createHeaders(user, password)), String.class);
|
||||||
return getResponseEntityAsJsonElement(responseEntity);
|
return getResponseEntityAsJsonElement(responseEntity);
|
||||||
|
@ -57,23 +61,18 @@ public class HttpUtils {
|
||||||
public JsonElement delete(String path) {
|
public JsonElement delete(String path) {
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
String url = registryUrl + path;
|
String url = registryUrl + path;
|
||||||
ResponseEntity<String> responseEntity = restTemplate.exchange
|
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.DELETE, new HttpEntity<>(createHeaders(user, password)), String.class);
|
||||||
(url, HttpMethod.DELETE, new HttpEntity<>(createHeaders(user, password)), String.class);
|
|
||||||
return getResponseEntityAsJsonElement(responseEntity);
|
return getResponseEntityAsJsonElement(responseEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String createUrl(String baseAddress, Map<String, String> params) {
|
||||||
private String createParams(Map<String, String> params) {
|
LinkedMultiValueMap<String, String> multiValueMap = new LinkedMultiValueMap<>();
|
||||||
StringBuilder ret = new StringBuilder("?");
|
params.forEach((k, v) -> multiValueMap.put(k, Collections.singletonList(v)));
|
||||||
int count = 0;
|
UriComponents uriComponents = UriComponentsBuilder
|
||||||
for (Map.Entry<String, String> param : params.entrySet()) {
|
.fromHttpUrl(baseAddress)
|
||||||
ret.append(param.getKey()).append("=").append(param.getValue());
|
.queryParams(multiValueMap)
|
||||||
count++;
|
.build().encode();
|
||||||
if (count != params.entrySet().size()) {
|
return uriComponents.toString();
|
||||||
ret.append("&");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpHeaders createHeaders(String username, String password) {
|
private HttpHeaders createHeaders(String username, String password) {
|
||||||
|
@ -87,12 +86,13 @@ public class HttpUtils {
|
||||||
|
|
||||||
private JsonElement getResponseEntityAsJsonElement(ResponseEntity<String> responseEntity) {
|
private JsonElement getResponseEntityAsJsonElement(ResponseEntity<String> responseEntity) {
|
||||||
|
|
||||||
if ( responseEntity == null )
|
if (responseEntity == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
String responseBody = responseEntity.getBody();
|
String responseBody = responseEntity.getBody();
|
||||||
if ( responseBody != null ) {
|
if (responseBody != null) {
|
||||||
logger.debug(responseBody);
|
logger.trace(responseBody);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new JsonParser().parse(responseBody);
|
return new JsonParser().parse(responseBody);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
|
@ -6,6 +6,8 @@ import eu.dnetlib.repo.manager.domain.dto.Role;
|
||||||
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 java.util.Date;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class RegistryUtils {
|
public class RegistryUtils {
|
||||||
|
|
||||||
|
@ -29,8 +31,11 @@ public class RegistryUtils {
|
||||||
coPersonRole.addProperty("Title", "");
|
coPersonRole.addProperty("Title", "");
|
||||||
coPersonRole.addProperty("O", "Openaire");
|
coPersonRole.addProperty("O", "Openaire");
|
||||||
coPersonRole.addProperty("Status", status);
|
coPersonRole.addProperty("Status", status);
|
||||||
coPersonRole.addProperty("ValidFrom", "");
|
if(status.equals("Active")) {
|
||||||
coPersonRole.addProperty("ValidThrough", "");
|
coPersonRole.addProperty("ValidFrom", new Date().toString());
|
||||||
|
} else {
|
||||||
|
coPersonRole.addProperty("ValidThrough", new Date().toString());
|
||||||
|
}
|
||||||
coPersonRoles.add(coPersonRole);
|
coPersonRoles.add(coPersonRole);
|
||||||
role.addProperty("RequestType", "CoPersonRoles");
|
role.addProperty("RequestType", "CoPersonRoles");
|
||||||
role.addProperty("Version", version);
|
role.addProperty("Version", version);
|
||||||
|
|
|
@ -43,7 +43,7 @@ public interface AuthorizationService {
|
||||||
* @return
|
* @return
|
||||||
* @throws ResourceNotFoundException
|
* @throws ResourceNotFoundException
|
||||||
*/
|
*/
|
||||||
boolean addAdmin(String resourceId, String email) throws ResourceNotFoundException;
|
void addAdmin(String resourceId, String email) throws ResourceNotFoundException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove user from resource admins.
|
* Remove user from resource admins.
|
||||||
|
@ -53,12 +53,20 @@ public interface AuthorizationService {
|
||||||
* @return
|
* @return
|
||||||
* @throws ResourceNotFoundException
|
* @throws ResourceNotFoundException
|
||||||
*/
|
*/
|
||||||
boolean removeAdmin(String resourceId, String email) throws ResourceNotFoundException;
|
void removeAdmin(String resourceId, String email) throws ResourceNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a role based on the resourceId and assigns it to the current user.
|
||||||
|
*
|
||||||
|
* @param resourceId usually the repository Id.
|
||||||
|
* @param roleDescription usually the repository official name.
|
||||||
|
*/
|
||||||
|
void createAndAssignRoleToAuthenticatedUser(String resourceId, String roleDescription);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the roles of the authenticated user.
|
* Returns the roles of the authenticated user.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Collection<String> getUserRoles();
|
Collection<String> getUserRoles();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.dnetlib.repo.manager.service.security;
|
package eu.dnetlib.repo.manager.service.security;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
import eu.dnetlib.repo.manager.domain.dto.Role;
|
||||||
import eu.dnetlib.repo.manager.domain.dto.User;
|
import eu.dnetlib.repo.manager.domain.dto.User;
|
||||||
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
import eu.dnetlib.repo.manager.exception.ResourceNotFoundException;
|
||||||
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
import eu.dnetlib.repo.manager.service.aai.registry.AaiRegistryService;
|
||||||
|
@ -11,6 +12,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -79,49 +81,74 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAdmin(String resourceId, String email) throws ResourceNotFoundException {
|
public void addAdmin(String resourceId, String email) throws ResourceNotFoundException {
|
||||||
Integer coPersonId = aaiRegistryService.getCoPersonIdByEmail(email);
|
String role = roleMappingService.getRoleIdByRepoId(resourceId);
|
||||||
if (coPersonId != null) {
|
Integer couId = aaiRegistryService.getCouId(role);
|
||||||
String role = roleMappingService.getRoleIdByRepoId(resourceId);
|
if (couId == null) {
|
||||||
Integer couId = aaiRegistryService.getCouId(role);
|
throw new ResourceNotFoundException("Cannot find CouId for role: " + role);
|
||||||
if (couId != null) {
|
}
|
||||||
Integer roleId = aaiRegistryService.getRoleId(coPersonId, couId);
|
List<Integer> coPersonIds = aaiRegistryService.getCoPersonIdsByEmail(email);
|
||||||
aaiRegistryService.assignMemberRole(coPersonId, couId, roleId);
|
for (Integer coPersonId : coPersonIds) {
|
||||||
|
assert coPersonId != null;
|
||||||
|
aaiRegistryService.assignMemberRole(coPersonId, couId);
|
||||||
|
|
||||||
// Add role to user current authorities
|
// Add role to user current authorities
|
||||||
authoritiesUpdater.addRole(email, roleMappingService.convertRepoIdToAuthority(resourceId));
|
for (String userId : aaiRegistryService.getUserIdentifiersByEmail(email)) {
|
||||||
|
authoritiesUpdater.addRole(userId, roleMappingService.convertRepoIdToAuthority(resourceId));
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
throw new ResourceNotFoundException("Cannot find CouId for role: " + role);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
throw new ResourceNotFoundException("Cannot find coPersonId for user with email: " + email);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAdmin(String resourceId, String email) throws ResourceNotFoundException {
|
public void removeAdmin(String resourceId, String email) throws ResourceNotFoundException {
|
||||||
Integer coPersonId = aaiRegistryService.getCoPersonIdByEmail(email);
|
String role = roleMappingService.getRoleIdByRepoId(resourceId);
|
||||||
if (coPersonId != null) {
|
Integer couId = aaiRegistryService.getCouId(role);
|
||||||
String role = roleMappingService.getRoleIdByRepoId(resourceId);
|
if (couId == null) {
|
||||||
Integer couId = aaiRegistryService.getCouId(role);
|
throw new ResourceNotFoundException("Cannot find CouId for role: " + role);
|
||||||
Integer roleId = null;
|
}
|
||||||
if (couId != null) {
|
List<Integer> coPersonIds = aaiRegistryService.getCoPersonIdsByEmail(email);
|
||||||
roleId = aaiRegistryService.getRoleId(coPersonId, couId);
|
for (Integer coPersonId : coPersonIds) {
|
||||||
}
|
assert coPersonId != null;
|
||||||
if (couId != null && roleId != null) {
|
Integer roleId = aaiRegistryService.getRoleId(coPersonId, couId);
|
||||||
|
if (roleId != null) {
|
||||||
aaiRegistryService.removeMemberRole(coPersonId, couId, roleId);
|
aaiRegistryService.removeMemberRole(coPersonId, couId, roleId);
|
||||||
|
|
||||||
// Remove role from user current authorities
|
// Remove role from user current authorities
|
||||||
authoritiesUpdater.removeRole(email, roleMappingService.convertRepoIdToAuthority(resourceId));
|
for (String userId : aaiRegistryService.getUserIdentifiersByEmail(email)) {
|
||||||
|
authoritiesUpdater.removeRole(userId, roleMappingService.convertRepoIdToAuthority(resourceId));
|
||||||
return true;
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ResourceNotFoundException("Cannot find CouId for role: " + role);
|
logger.error("Cannot find RoleId for role: {}", role);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
throw new ResourceNotFoundException("Cannot find coPersonId for user with email: " + email);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createAndAssignRoleToAuthenticatedUser(String resourceId, String roleDescription) {
|
||||||
|
// Create new role
|
||||||
|
String newRoleName = roleMappingService.getRoleIdByRepoId(resourceId);
|
||||||
|
Role newRole = new Role(newRoleName, roleDescription);
|
||||||
|
|
||||||
|
Integer couId;
|
||||||
|
try {
|
||||||
|
couId = aaiRegistryService.createRole(newRole);
|
||||||
|
} catch (HttpClientErrorException e) {
|
||||||
|
couId = aaiRegistryService.getCouId(newRoleName);
|
||||||
|
if (couId == null) {
|
||||||
|
logger.error(String.format("Could not create role '%s'", newRoleName), e);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(String.format("Could not create role '%s'", newRoleName), e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign new role to the current authenticated user
|
||||||
|
Integer coPersonId = aaiRegistryService.getCoPersonIdByIdentifier();
|
||||||
|
if (couId != null) {
|
||||||
|
aaiRegistryService.assignMemberRole(coPersonId, couId);
|
||||||
|
|
||||||
|
// Add role to current user authorities
|
||||||
|
authoritiesUpdater.addRole(roleMappingService.convertRepoIdToAuthority(resourceId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,17 +158,17 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
||||||
UserInfo userInfo = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo();
|
UserInfo userInfo = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo();
|
||||||
roles = getUserRolesByEmail(userInfo.getEmail());
|
roles = getUserRolesByEmail(userInfo.getEmail());
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isTraceEnabled()) {
|
||||||
logger.debug("User Roles: {}", String.join(",", roles));
|
logger.trace("User Roles: {}", String.join(",", roles));
|
||||||
}
|
}
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> getUserRolesByEmail(String email) {
|
public Collection<String> getUserRolesByEmail(String email) {
|
||||||
int coPersonId = aaiRegistryService.getCoPersonIdByEmail(email);
|
List<Integer> coPersonIds = aaiRegistryService.getCoPersonIdsByEmail(email);
|
||||||
List<Integer> list = new ArrayList<>();
|
List<Integer> list = new ArrayList<>();
|
||||||
for (JsonElement element : aaiRegistryService.getRolesWithStatus(coPersonId, AaiRegistryService.RoleStatus.ACTIVE)) {
|
for (JsonElement element : aaiRegistryService.getRolesWithStatus(coPersonIds, AaiRegistryService.RoleStatus.ACTIVE)) {
|
||||||
if (element.getAsJsonObject().get("CouId") != null) {
|
if (element.getAsJsonObject().get("CouId") != null) {
|
||||||
list.add(element.getAsJsonObject().get("CouId").getAsInt());
|
list.add(element.getAsJsonObject().get("CouId").getAsInt());
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -22,13 +21,11 @@ public class Converter {
|
||||||
public static List<String> readFile(String filename) {
|
public static List<String> readFile(String filename) {
|
||||||
String line;
|
String line;
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
try {
|
try ( BufferedReader br = new BufferedReader(new InputStreamReader(Objects.requireNonNull(Converter.class.getResourceAsStream("/eu/**/" + filename)))) )
|
||||||
InputStream in = Converter.class.getResourceAsStream("/eu/**/" + filename);
|
{
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(in)); // It may throw an NPE.
|
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
list.add(line.trim());
|
list.add(line.trim());
|
||||||
}
|
}
|
||||||
br.close();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error opening file!", e);
|
logger.error("Error opening file!", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
package eu.dnetlib.repo.manager.utils;
|
|
||||||
|
|
||||||
public class DatasourceManagerClient {
|
|
||||||
//
|
|
||||||
}
|
|
|
@ -25,7 +25,7 @@ public class OaiTools {
|
||||||
disableSslVerification();
|
disableSslVerification();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(OaiTools.class);
|
private static final Logger logger = LoggerFactory.getLogger(OaiTools.class);
|
||||||
|
|
||||||
public static List<String> getSetsOfRepo(String baseUrl) throws Exception {
|
public static List<String> getSetsOfRepo(String baseUrl) throws Exception {
|
||||||
try {
|
try {
|
||||||
|
@ -36,8 +36,8 @@ public class OaiTools {
|
||||||
List<Set> sets = new ArrayList<>(setList.asList());
|
List<Set> sets = new ArrayList<>(setList.asList());
|
||||||
while (token != null) {
|
while (token != null) {
|
||||||
setList = harvester.listSets(token);
|
setList = harvester.listSets(token);
|
||||||
token = setList.getResumptionToken();
|
|
||||||
sets.addAll(setList.asList());
|
sets.addAll(setList.asList());
|
||||||
|
token = setList.getResumptionToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> ret = new ArrayList<String>();
|
List<String> ret = new ArrayList<String>();
|
||||||
|
|
|
@ -15,11 +15,11 @@ spring:
|
||||||
|
|
||||||
services:
|
services:
|
||||||
provide:
|
provide:
|
||||||
dev-machine: 88.197.53.71
|
dev-machine: 88.197.53.71 # VM-71
|
||||||
aai:
|
aai:
|
||||||
baseURL: https://aai.openaire.eu
|
baseURL: https://aai.openaire.eu
|
||||||
oidc:
|
oidc:
|
||||||
domain: .openaire.eu
|
domain: .openaire.eu # use empty value for local, otherwise: ".openaire.eu"
|
||||||
id: XX
|
id: XX
|
||||||
issuer: ${services.provide.aai.baseURL}/oidc/
|
issuer: ${services.provide.aai.baseURL}/oidc/
|
||||||
redirectURL: http://localhost:${server.port}${server.servlet.context-path}/openid_connect_login
|
redirectURL: http://localhost:${server.port}${server.servlet.context-path}/openid_connect_login
|
||||||
|
@ -37,13 +37,13 @@ services:
|
||||||
broker:
|
broker:
|
||||||
api: api/
|
api: api/
|
||||||
openaire: openaireBroker
|
openaire: openaireBroker
|
||||||
port: 8080
|
port: 443
|
||||||
url: https://broker1-dev-dnet.d4science.org
|
url: https://beta.broker.openaire.eu
|
||||||
clients:
|
clients:
|
||||||
dsm: https://dev-openaire.d4science.org/openaire
|
dsm: https://dev-openaire.d4science.org/openaire
|
||||||
search: https://beta.services.openaire.eu/search/v2/api
|
search: https://beta.services.openaire.eu/search/v2/api
|
||||||
usageEvents: http://beta.lbs.openaire.eu:8080/ajax/summary
|
usageEvents: http://beta.lbs.openaire.eu:8080/ajax/summary
|
||||||
usagestats: https://services.openaire.eu/usagestats
|
usagestats: https://beta.services.openaire.eu/usagestats
|
||||||
db:
|
db:
|
||||||
driverClassName: org.postgresql.Driver
|
driverClassName: org.postgresql.Driver
|
||||||
password: dnetPwd
|
password: dnetPwd
|
||||||
|
|
|
@ -9,7 +9,13 @@
|
||||||
<Root level="info">
|
<Root level="info">
|
||||||
<AppenderRef ref="LogToConsole"/>
|
<AppenderRef ref="LogToConsole"/>
|
||||||
</Root>
|
</Root>
|
||||||
<Logger name="org.springframework.boot" level="error" additivity="false">
|
<Logger name="eu.dnetlib.repo.manager" level="info" additivity="false"> <!-- Make this "debug", to see debug-logs during development. -->
|
||||||
|
<AppenderRef ref="LogToConsole"/>
|
||||||
|
</Logger>
|
||||||
|
<Logger name="org.springframework.boot" level="warn" additivity="false">
|
||||||
|
<AppenderRef ref="LogToConsole"/>
|
||||||
|
</Logger>
|
||||||
|
<Logger name="springfox.documentation" level="warn" additivity="false">
|
||||||
<AppenderRef ref="LogToConsole"/>
|
<AppenderRef ref="LogToConsole"/>
|
||||||
</Logger>
|
</Logger>
|
||||||
</Loggers>
|
</Loggers>
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.mockito.MockitoAnnotations;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ public class PrometheusTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPiwikMetrics() {
|
public void testPiwikMetrics() {
|
||||||
assertTrue(piWikService.getValidated(false).equals(TOTAL - VALIDATED));
|
assertEquals((long) piWikService.getValidated(false), (TOTAL - VALIDATED));
|
||||||
String report = prometheusController.getPiwikMetrics();
|
String report = prometheusController.getPiwikMetrics();
|
||||||
assertTrue(report.contains("provide_repositories_registered_total " + TOTAL));
|
assertTrue(report.contains("provide_repositories_registered_total " + TOTAL));
|
||||||
assertTrue(report.contains("provide_usagecounts_repositories_registered_total " + TOTAL));
|
assertTrue(report.contains("provide_usagecounts_repositories_registered_total " + TOTAL));
|
||||||
|
|
|
@ -40,17 +40,17 @@ class InterfaceComplianceRequestTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private InterfaceComplianceRequestId createRequestId() {
|
private InterfaceComplianceRequestId createRequestId() {
|
||||||
InterfaceComplianceRequestId id = new InterfaceComplianceRequestId();
|
InterfaceComplianceRequestId requestId = new InterfaceComplianceRequestId();
|
||||||
id.setRepositoryId("repository");
|
requestId.setRepositoryId("repository");
|
||||||
id.setInterfaceId("interface");
|
requestId.setInterfaceId("interface");
|
||||||
return id;
|
return requestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private InterfaceComplianceRequest createRequest(String compatibilityLevel) {
|
private InterfaceComplianceRequest createRequest(String compatibilityLevel) {
|
||||||
InterfaceComplianceRequest request = new InterfaceComplianceRequest();
|
InterfaceComplianceRequest request = new InterfaceComplianceRequest();
|
||||||
InterfaceComplianceRequestId id = createRequestId();
|
InterfaceComplianceRequestId requestId = createRequestId();
|
||||||
request.setRepositoryId(id.getRepositoryId());
|
request.setRepositoryId(requestId.getRepositoryId());
|
||||||
request.setInterfaceId(id.getInterfaceId());
|
request.setInterfaceId(requestId.getInterfaceId());
|
||||||
request.setDesiredCompatibilityLevel(compatibilityLevel);
|
request.setDesiredCompatibilityLevel(compatibilityLevel);
|
||||||
request.setSubmissionDate(new Date());
|
request.setSubmissionDate(new Date());
|
||||||
return request;
|
return request;
|
||||||
|
|
Loading…
Reference in New Issue