diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/TagController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/TagController.java index 029e1ba08..e7acb4f09 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/TagController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/TagController.java @@ -48,8 +48,12 @@ public class TagController extends BaseController { //ExternalUrlCriteria externalUrlCriteria = new ExternalUrlCriteria(query); /*List> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getTags(externalUrlCriteria, type); TagExternalSourcesModel researchersExternalSourcesModel = new TagExternalSourcesModel().fromExternalItem(remoteRepos);*/ - List 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 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>().payload(tags).status(ApiMessageCode.NO_MESSAGE)); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().payload(tags).status(ApiMessageCode.NO_MESSAGE)); + } else { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ResponseItem>().status(ApiMessageCode.ERROR_MESSAGE).message("Elastic Services are not available")); + } } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index e03b0e0ce..c3f137c9f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -168,7 +168,7 @@ public class DatasetManager { QueryableList 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()); diff --git a/dmp-frontend/angular.json b/dmp-frontend/angular.json index e1f7ce661..208b96dd7 100644 --- a/dmp-frontend/angular.json +++ b/dmp-frontend/angular.json @@ -20,7 +20,6 @@ "src/assets", "src/favicon.ico", { "glob": "**/*", "input": "node_modules/tinymce", "output": "/tinymce/" } - ], "styles": [ "src/styles.scss", diff --git a/dmp-frontend/src/app/core/services/auth/auth.service.ts b/dmp-frontend/src/app/core/services/auth/auth.service.ts index d871e6db7..6a1a91484 100644 --- a/dmp-frontend/src/app/core/services/auth/auth.service.ts +++ b/dmp-frontend/src/app/core/services/auth/auth.service.ts @@ -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()) {