small change
This commit is contained in:
parent
86628a59a7
commit
a94473be49
|
@ -2,7 +2,6 @@ package eu.eudat.service.lock;
|
||||||
|
|
||||||
import eu.eudat.model.Lock;
|
import eu.eudat.model.Lock;
|
||||||
import eu.eudat.model.persist.LockPersist;
|
import eu.eudat.model.persist.LockPersist;
|
||||||
import eu.eudat.query.lookup.LockLookup;
|
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
import gr.cite.tools.exception.MyForbiddenException;
|
import gr.cite.tools.exception.MyForbiddenException;
|
||||||
import gr.cite.tools.exception.MyNotFoundException;
|
import gr.cite.tools.exception.MyNotFoundException;
|
||||||
|
|
|
@ -157,18 +157,17 @@ public class LockController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@PostMapping("target/status/{id}")
|
@GetMapping("target/status/{id}")
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<Boolean>> getLocked(@PathVariable("id") UUID targetId) throws Exception {
|
public @ResponseBody Boolean getLocked(@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);
|
||||||
|
|
||||||
boolean locked = this.lockService.isLocked(targetId);
|
return this.lockService.isLocked(targetId);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Boolean>().status(ApiMessageCode.SUCCESS_MESSAGE).message("locked").payload(locked));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@PostMapping("target/unlock/{id}")
|
@DeleteMapping("target/unlock/{id}")
|
||||||
public @ResponseBody ResponseEntity<ResponseItem<String>> unlock(@PathVariable("id") UUID targetId) throws Exception {
|
public @ResponseBody ResponseEntity<ResponseItem<String>> 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);
|
this.lockService.unlock(targetId);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload("Lock Removed"));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload("Lock Removed"));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Injectable } from '@angular/core';
|
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 { Observable, throwError } from 'rxjs';
|
||||||
import { Lock, LockModel, LockPersist } from '@app/core/model/lock/lock.model';
|
import { Lock, LockModel, LockPersist } from '@app/core/model/lock/lock.model';
|
||||||
import { ConfigurationService } from '../configuration/configuration.service';
|
import { ConfigurationService } from '../configuration/configuration.service';
|
||||||
|
@ -50,14 +50,14 @@ export class LockService {
|
||||||
catchError((error: any) => throwError(error)));
|
catchError((error: any) => throwError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//ToDo change Parameters
|
checkLockStatus(targetId: Guid): Observable<Boolean> {
|
||||||
checkLockStatus(targetId: Guid): Observable<boolean> {
|
return this.http.get<Boolean>(`${this.apiBase}/target/status/${targetId}`)
|
||||||
return this.http.get(`${this.apiBase}/target/status/${targetId}`, { headers: this.headers });
|
.pipe(catchError((error: any) => throwError(error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//ToDo change Parameters
|
|
||||||
unlockTarget(targetId: Guid): Observable<any> {
|
unlockTarget(targetId: Guid): Observable<any> {
|
||||||
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<Lock> {
|
getSingleWithTarget(targetId: Guid, reqFields: string[] = []): Observable<Lock> {
|
||||||
|
|
Loading…
Reference in New Issue