Search in sources :

Example 1 with Metadata

use of eu.einfracentral.domain.Metadata in project resource-catalogue by madgeek-arc.

the class InfraServiceController method setActive.

@PatchMapping(path = "publish/{id}/{version}", produces = { MediaType.APPLICATION_JSON_VALUE })
@PreAuthorize("hasRole('ROLE_ADMIN')")
public ResponseEntity<InfraService> setActive(@PathVariable String id, @PathVariable String version, @RequestParam boolean active, @RequestParam Boolean latest, @ApiIgnore Authentication auth) throws ResourceNotFoundException {
    InfraService service = infraService.get(id, version);
    service.setActive(active);
    service.setLatest(latest);
    Metadata metadata = service.getMetadata();
    metadata.setModifiedBy("system");
    metadata.setModifiedAt(String.valueOf(System.currentTimeMillis()));
    service.setMetadata(metadata);
    if (active) {
        logger.info("User '{}' set InfraService '{}' with id: {} as active", auth.getName(), service.getService().getName(), service.getService().getId());
    } else {
        logger.info("User '{}' set InfraService '{}' with id: {} as inactive", auth.getName(), service.getService().getName(), service.getService().getId());
    }
    return ResponseEntity.ok(infraService.update(service, auth));
}
Also used : InfraService(eu.einfracentral.domain.InfraService) Metadata(eu.einfracentral.domain.Metadata) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

InfraService (eu.einfracentral.domain.InfraService)1 Metadata (eu.einfracentral.domain.Metadata)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1