String comparison for NULL equity
This commit is contained in:
parent
02a532e2d1
commit
df23be95ae
23
pom.xml
23
pom.xml
|
@ -298,6 +298,29 @@
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>cz.habarta.typescript-generator</groupId>
|
||||||
|
<artifactId>typescript-generator-maven-plugin</artifactId>
|
||||||
|
<version>2.1.406</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>java to typeScript</id>
|
||||||
|
<goals>
|
||||||
|
<goal>generate</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<jsonLibrary>jackson2</jsonLibrary>
|
||||||
|
<outputFileType>implementationFile</outputFileType>
|
||||||
|
<mapClasses>asClasses</mapClasses>
|
||||||
|
<classPatterns>
|
||||||
|
<pattern>eu.dnetlib.domain.functionality.validator.*</pattern>
|
||||||
|
</classPatterns>
|
||||||
|
<outputFile>target/operation.ts</outputFile>
|
||||||
|
<outputKind>module</outputKind>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<finalName>uoa-repository-manager-service</finalName>
|
<finalName>uoa-repository-manager-service</finalName>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
|
@ -48,13 +48,13 @@ public class PiWikController {
|
||||||
|
|
||||||
@RequestMapping(value = "/getPiwikSiteForRepo/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/getPiwikSiteForRepo/{repositoryId}" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repositoryId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repositoryId).registeredBy==null) and hasRole('ROLE_USER'))")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repositoryId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repositoryId).registeredBy=='null') and hasRole('ROLE_USER'))")
|
||||||
public PiwikInfo getPiwikSiteForRepo(@PathVariable("repositoryId") String repositoryId) {
|
public PiwikInfo getPiwikSiteForRepo(@PathVariable("repositoryId") String repositoryId) {
|
||||||
return piWikService.getPiwikSiteForRepo(repositoryId);
|
return piWikService.getPiwikSiteForRepo(repositoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/savePiwikInfo" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
@RequestMapping(value = "/savePiwikInfo" , method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#piwikInfo.repositoryId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#piwikInfo.repositoryId).registeredBy==null) and hasRole('ROLE_USER'))")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#piwikInfo.repositoryId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#piwikInfo.repositoryId).registeredBy=='null') and hasRole('ROLE_USER'))")
|
||||||
public PiwikInfo savePiwikInfo(@RequestBody PiwikInfo piwikInfo) {
|
public PiwikInfo savePiwikInfo(@RequestBody PiwikInfo piwikInfo) {
|
||||||
return piWikService.savePiwikInfo(piwikInfo);
|
return piWikService.savePiwikInfo(piwikInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,10 @@ public class RepositoryController {
|
||||||
@RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET,
|
@RequestMapping(value = "/getRepositoryById/{id}", method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PostAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((returnObject.registeredBy==authentication.userInfo.email or returnObject.registeredBy==null) and hasRole('ROLE_USER'))")
|
@PostAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((returnObject.registeredBy=='null' or returnObject.registeredBy==authentication.userInfo.email) and hasRole('ROLE_USER'))")
|
||||||
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException,ResourceNotFoundException {
|
public Repository getRepositoryById(@PathVariable("id") String id) throws JSONException,ResourceNotFoundException {
|
||||||
return repositoryService.getRepositoryById(id);
|
Repository repo = repositoryService.getRepositoryById(id);
|
||||||
|
return repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET,
|
@RequestMapping(value = "/getRepositoryAggregations/{id}", method = RequestMethod.GET,
|
||||||
|
@ -106,7 +107,7 @@ public class RepositoryController {
|
||||||
@RequestMapping(value = "/getRepositoryInterface/{id}", method = RequestMethod.GET,
|
@RequestMapping(value = "/getRepositoryInterface/{id}", method = RequestMethod.GET,
|
||||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PostAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#id).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#id).registeredBy==null ) and hasRole('ROLE_USER'))")
|
@PostAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#id).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#id).registeredBy=='null' ) and hasRole('ROLE_USER'))")
|
||||||
public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) throws JSONException {
|
public List<RepositoryInterface> getRepositoryInterface(@PathVariable("id") String id) throws JSONException {
|
||||||
return repositoryService.getRepositoryInterface(id);
|
return repositoryService.getRepositoryInterface(id);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +115,7 @@ public class RepositoryController {
|
||||||
@RequestMapping(value = "/addRepository", method = RequestMethod.POST,
|
@RequestMapping(value = "/addRepository", method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((#repository.registeredBy==authentication.userInfo.email or returnObject.registeredBy==null) and hasRole('ROLE_USER'))")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((#repository.registeredBy==authentication.userInfo.email or returnObject.registeredBy=='null') and hasRole('ROLE_USER'))")
|
||||||
public Repository addRepository(@RequestParam("datatype") String datatype,
|
public Repository addRepository(@RequestParam("datatype") String datatype,
|
||||||
@RequestBody Repository repository) throws Exception {
|
@RequestBody Repository repository) throws Exception {
|
||||||
|
|
||||||
|
@ -145,7 +146,7 @@ public class RepositoryController {
|
||||||
@RequestMapping(value = "/updateRepository", method = RequestMethod.POST,
|
@RequestMapping(value = "/updateRepository", method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((#repository.registeredBy==authentication.userInfo.email or #repository.registeredBy==null) and hasRole('ROLE_USER'))")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((#repository.registeredBy==authentication.userInfo.email or #repository.registeredBy=='null') and hasRole('ROLE_USER'))")
|
||||||
public Repository updateRepository(@RequestBody Repository repository,Authentication authentication) throws Exception {
|
public Repository updateRepository(@RequestBody Repository repository,Authentication authentication) throws Exception {
|
||||||
return repositoryService.updateRepository(repository, authentication);
|
return repositoryService.updateRepository(repository, authentication);
|
||||||
}
|
}
|
||||||
|
@ -160,7 +161,7 @@ public class RepositoryController {
|
||||||
@RequestMapping(value = "/addInterface", method = RequestMethod.POST,
|
@RequestMapping(value = "/addInterface", method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repoId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repoId).registeredBy==null) and hasRole('ROLE_USER'))")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repoId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repoId).registeredBy=='null') and hasRole('ROLE_USER'))")
|
||||||
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
public RepositoryInterface addRepositoryInterface(@RequestParam("datatype") String datatype,
|
||||||
@RequestParam("repoId") String repoId,
|
@RequestParam("repoId") String repoId,
|
||||||
@RequestParam("registeredBy") String registeredBy,
|
@RequestParam("registeredBy") String registeredBy,
|
||||||
|
@ -217,7 +218,7 @@ public class RepositoryController {
|
||||||
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
|
@RequestMapping(value = "/updateRepositoryInterface", method = RequestMethod.POST,
|
||||||
consumes = MediaType.APPLICATION_JSON_VALUE)
|
consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repoId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repoId).registeredBy==null) and hasRole('ROLE_USER'))")
|
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_PROVIDE_ADMIN') or ((@repositoryService.getRepositoryById(#repoId).registeredBy==authentication.userInfo.email or @repositoryService.getRepositoryById(#repoId).registeredBy=='null') and hasRole('ROLE_USER'))")
|
||||||
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId,
|
public RepositoryInterface updateRepositoryInterface(@RequestParam("repoId") String repoId,
|
||||||
@RequestParam("registeredBy") String registeredBy,
|
@RequestParam("registeredBy") String registeredBy,
|
||||||
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
@RequestBody RepositoryInterface repositoryInterface) throws Exception {
|
||||||
|
|
|
@ -49,6 +49,7 @@ public class DashboardServiceImpl implements DashboardService {
|
||||||
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?
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
List<AggregationDetails> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId(),0,20);
|
List<AggregationDetails> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId(),0,20);
|
||||||
for(AggregationDetails aggregationDetails: aggregationDetailsList) {
|
for(AggregationDetails aggregationDetails: aggregationDetailsList) {
|
||||||
if(aggregationDetails.getIndexedVersion()) {
|
if(aggregationDetails.getIndexedVersion()) {
|
||||||
|
@ -57,6 +58,9 @@ public class DashboardServiceImpl implements DashboardService {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
|
||||||
|
System.out.println("Got repo aggregations in "+ (end-start)+"ms");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
|
@ -248,12 +248,20 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
requestFilter.setRegisteredby(userEmail);
|
requestFilter.setRegisteredby(userEmail);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
|
||||||
|
System.out.println("POST request finished in " + (end-start)+"ms");
|
||||||
|
start=System.currentTimeMillis();
|
||||||
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
|
List<Repository> repos = Converter.jsonToRepositoryList(new JSONObject(rs));
|
||||||
|
end=System.currentTimeMillis();
|
||||||
|
System.out.println("Converting json to repo list finished in " + (end-start)+"ms");
|
||||||
|
start=System.currentTimeMillis();
|
||||||
for (Repository r : repos)
|
for (Repository r : repos)
|
||||||
this.updateRepositoryInfo(r);
|
this.updateRepositoryInfo(r);
|
||||||
|
end=System.currentTimeMillis();
|
||||||
|
System.out.println("Updating "+repos.size()+" repository infos in " + (end-start)+"ms");
|
||||||
return repos;
|
return repos;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
LOGGER.debug("Exception on getRepositoriesOfUser" , e);
|
LOGGER.debug("Exception on getRepositoriesOfUser" , e);
|
||||||
|
@ -300,12 +308,21 @@ public class RepositoryServiceImpl implements RepositoryService {
|
||||||
List<AggregationDetails> aggregationHistory = new ArrayList<>();
|
List<AggregationDetails> aggregationHistory = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
String rs = restTemplate.postForObject(uriComponents.toUri(),requestFilter, String.class);
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
|
||||||
|
System.out.println("Aggregations request through rest template took " + (end-start)+"ms");
|
||||||
JSONObject repository = new JSONObject(rs);
|
JSONObject repository = new JSONObject(rs);
|
||||||
|
|
||||||
if(repository.getJSONArray("datasourceInfo").length() == 0)
|
if(repository.getJSONArray("datasourceInfo").length() == 0)
|
||||||
return aggregationHistory;
|
return aggregationHistory;
|
||||||
|
|
||||||
|
start = System.currentTimeMillis();
|
||||||
aggregationHistory.addAll(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
|
aggregationHistory.addAll(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
|
||||||
|
end = System.currentTimeMillis();
|
||||||
|
|
||||||
|
System.out.println("Getting aggregations history from json " + (end-start)+"ms");
|
||||||
return aggregationHistory.size() == 0? aggregationHistory : aggregationHistory.stream()
|
return aggregationHistory.size() == 0? aggregationHistory : aggregationHistory.stream()
|
||||||
.sorted(Comparator.comparing(AggregationDetails::getDate).reversed())
|
.sorted(Comparator.comparing(AggregationDetails::getDate).reversed())
|
||||||
.limit(size)
|
.limit(size)
|
||||||
|
|
Loading…
Reference in New Issue