diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/lock/LockService.java b/dmp-backend/core/src/main/java/eu/eudat/service/lock/LockService.java index 32e603ad8..eadb08c56 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/lock/LockService.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/lock/LockService.java @@ -2,7 +2,6 @@ package eu.eudat.service.lock; import eu.eudat.model.Lock; import eu.eudat.model.persist.LockPersist; -import eu.eudat.query.lookup.LockLookup; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyForbiddenException; import gr.cite.tools.exception.MyNotFoundException; diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/LockController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/LockController.java index bc2bbcbe6..7049d1d37 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/LockController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/LockController.java @@ -157,18 +157,17 @@ public class LockController { } @Transactional - @PostMapping("target/status/{id}") - public @ResponseBody ResponseEntity> getLocked(@PathVariable("id") UUID targetId) throws Exception { - this.authService.authorizeAtLeastOneForce(targetId != null ? List.of(new OwnedResource(targetId)) : null, Permission.BrowseDmp); + @GetMapping("target/status/{id}") + public @ResponseBody Boolean getLocked(@PathVariable("id") UUID targetId) throws Exception { + this.authService.authorizeAtLeastOneForce(targetId != null ? List.of(new OwnedResource(targetId)) : null, Permission.BrowseLock); - boolean locked = this.lockService.isLocked(targetId); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("locked").payload(locked)); + return this.lockService.isLocked(targetId); } @Transactional - @PostMapping("target/unlock/{id}") + @DeleteMapping("target/unlock/{id}") public @ResponseBody ResponseEntity> unlock(@PathVariable("id") UUID targetId) throws Exception { - this.authService.authorizeAtLeastOneForce(targetId != null ? List.of(new OwnedResource(targetId)) : null, Permission.BrowseDmp); + this.authService.authorizeAtLeastOneForce(targetId != null ? List.of(new OwnedResource(targetId)) : null, Permission.BrowseLock); this.lockService.unlock(targetId); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload("Lock Removed")); diff --git a/dmp-frontend/src/app/core/services/lock/lock.service.ts b/dmp-frontend/src/app/core/services/lock/lock.service.ts index 42b5d16d2..9f689c039 100644 --- a/dmp-frontend/src/app/core/services/lock/lock.service.ts +++ b/dmp-frontend/src/app/core/services/lock/lock.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { HttpHeaders, HttpClient } from '@angular/common/http'; +import { HttpHeaders, HttpClient, HttpResponse } from '@angular/common/http'; import { Observable, throwError } from 'rxjs'; import { Lock, LockModel, LockPersist } from '@app/core/model/lock/lock.model'; import { ConfigurationService } from '../configuration/configuration.service'; @@ -50,14 +50,14 @@ export class LockService { catchError((error: any) => throwError(error))); } - //ToDo change Parameters - checkLockStatus(targetId: Guid): Observable { - return this.http.get(`${this.apiBase}/target/status/${targetId}`, { headers: this.headers }); + checkLockStatus(targetId: Guid): Observable { + return this.http.get(`${this.apiBase}/target/status/${targetId}`) + .pipe(catchError((error: any) => throwError(error))); } - //ToDo change Parameters unlockTarget(targetId: Guid): Observable { - return this.http.delete(`${this.apiBase}/target/unlock/${targetId}`, { headers: this.headers }); + return this.http.delete(`${this.apiBase}/target/unlock/${targetId}`) + .pipe(catchError((error: any) => throwError(error))); } getSingleWithTarget(targetId: Guid, reqFields: string[] = []): Observable {