Minor improvements to error checkups

This commit is contained in:
George Kalampokis 2020-09-14 18:09:57 +03:00
parent 13f41dfd8b
commit 4cc44814e2
4 changed files with 10 additions and 5 deletions

View File

@ -48,8 +48,12 @@ public class TagController extends BaseController {
//ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query);
/*List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getTags(externalUrlCriteria, type);
TagExternalSourcesModel researchersExternalSourcesModel = new TagExternalSourcesModel().fromExternalItem(remoteRepos);*/
List<Tag> tags = this.getApiContext().getOperationsContext().getElasticRepository().getDatasetRepository().query(new DatasetCriteria()).stream().map(Dataset::getTags).flatMap(Collection::stream).filter(StreamDistinctBy.distinctByKey(Tag::getId)).collect(Collectors.toList());
if (this.getApiContext().getOperationsContext().getElasticRepository().getDatasetRepository().exists()) {
List<Tag> tags = this.getApiContext().getOperationsContext().getElasticRepository().getDatasetRepository().query(new DatasetCriteria()).stream().map(Dataset::getTags).flatMap(Collection::stream).filter(StreamDistinctBy.distinctByKey(Tag::getId)).collect(Collectors.toList());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tag>>().payload(tags).status(ApiMessageCode.NO_MESSAGE));
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tag>>().payload(tags).status(ApiMessageCode.NO_MESSAGE));
} else {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ResponseItem<List<Tag>>().status(ApiMessageCode.ERROR_MESSAGE).message("Elastic Services are not available"));
}
}
}

View File

@ -168,7 +168,7 @@ public class DatasetManager {
QueryableList<eu.eudat.data.entities.Dataset> authItems;
if (!datasetTableRequest.getCriteria().getIsPublic()) {
if (principal.getId() == null) {
throw new UnauthorisedException();
throw new UnauthorisedException("You are not allowed to access those datasets");
}
if (datasetTableRequest.getCriteria().getRole() != null)
roles.add(datasetTableRequest.getCriteria().getRole());

View File

@ -20,7 +20,6 @@
"src/assets",
"src/favicon.ico",
{ "glob": "**/*", "input": "node_modules/tinymce", "output": "/tinymce/" }
],
"styles": [
"src/styles.scss",

View File

@ -48,7 +48,9 @@ export class AuthService extends BaseService {
return principal;
}
const principalJson = localStorage.getItem('principal');
if (!principalJson) { return null; }
if (principalJson === null || principalJson === undefined) {
return null;
}
let principalObj = JSON.parse(principalJson) as Principal;
principalObj.expiresAt = new Date(principalObj.expiresAt);
if (principalObj.expiresAt < new Date()) {