Skip to content
Snippets Groups Projects

Tmf 674 feature

Closed Labros Papadopoulos requested to merge tmf-674-feature into develop
2 files
+ 25
36
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -55,22 +55,14 @@ public class GeographicSiteManagementApiController implements GeographicSiteMana
}
}
@PreAuthorize("hasAnyAuthority('ROLE_USER', 'ROLE_ADMIN')")
@PreAuthorize("hasAnyAuthority('ROLE_USER', 'ROLE_TESTBED_PROVIDER')")
@Override
public ResponseEntity<GeographicSite> retrieveGeographicSite(Principal principal, @PathVariable("id") String id) {
try {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if ( id.equals( "myuser" ) ) {
log.debug("principal= " + principal.toString());
Individual ind = individualRepoService.findByUsername(principal.getName());
GeographicSite gs= geographicSiteManagementService.findGeographicSiteByRelatedPartyId(ind.getId());
if (gs==null) {
gs =new GeographicSite();
GeographicSite gs= geographicSiteManagementService.findGeographicSiteByRelatedPartyId(id);
if (gs==null) {
gs =new GeographicSite();
GeographicSubAddressValue geographicSubAddressValue=new GeographicSubAddressValue();
GeographicAddressValue geographicAddressValue=new GeographicAddressValue();
geographicAddressValue.setGeographicSubAddress(geographicSubAddressValue);
@@ -78,15 +70,8 @@ public class GeographicSiteManagementApiController implements GeographicSiteMana
List<PlaceRefOrValue> placeRefOrValues=new ArrayList<>();
placeRefOrValues.add(placeRefOrValue);
gs.setPlace(placeRefOrValues);
}
return new ResponseEntity<GeographicSite>(gs,HttpStatus.OK);
} else if ( authentication.getAuthorities().contains( new SimpleGrantedAuthority( UserRoleType.ROLE_ADMIN.getValue() ) ) ){
return new ResponseEntity<GeographicSite>(geographicSiteManagementService.findGeographicSiteByUUID(id), HttpStatus.OK);
}else {
return new ResponseEntity< GeographicSite >(HttpStatus.FORBIDDEN );
}
return new ResponseEntity<GeographicSite>(gs,HttpStatus.OK);
} catch (Exception e) {
log.error(COULD_NOT_SERIALIZE, e);
@@ -94,7 +79,7 @@ public class GeographicSiteManagementApiController implements GeographicSiteMana
}
}
@PreAuthorize("hasAnyAuthority('ROLE_USER')" )
@PreAuthorize("hasAnyAuthority('ROLE_USER','ROLE_TESTBED_PROVIDER')" )
@Override
public ResponseEntity<GeographicSite> createGeographicSite(
@Parameter(description = "The geographic site to be created", required = true) @Valid @RequestBody GeographicSite geographicSite
@@ -113,7 +98,7 @@ public class GeographicSiteManagementApiController implements GeographicSiteMana
}
}
@PreAuthorize("hasAnyAuthority('ROLE_USER')" )
@PreAuthorize("hasAnyAuthority('ROLE_USER','ROLE_TESTBED_PROVIDER')" )
@Override
public ResponseEntity<Void> deleteGeographicSite(
@Parameter(description = "Identifier of the geographic site", required = true) @PathVariable("id") String id) {
@@ -128,26 +113,16 @@ public class GeographicSiteManagementApiController implements GeographicSiteMana
}
@PreAuthorize("hasAnyAuthority('ROLE_USER')" )
@PreAuthorize("hasAnyAuthority('ROLE_USER','ROLE_TESTBED_PROVIDER')" )
@Override
public ResponseEntity<GeographicSite> patchGeographicalSite(Principal principal,
@Parameter(description = "Identifier of the ServiceOrder", required = true) @PathVariable("id") String id,
@Parameter(description = "The ServiceOrder to be updated", required = true) @Valid @RequestBody GeographicSite geographicSite) {
try{
GeographicSite c;
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if ( id.equals( "myuser" ) ) {
log.debug("principal= " + principal.toString());
Individual ind = individualRepoService.findByUsername(principal.getName());
GeographicSite gs = geographicSiteManagementService.findGeographicSiteByRelatedPartyId(ind.getId());
c = geographicSiteManagementService.updateGeographicSite(gs.getUuid(), geographicSite);
}else{
c = geographicSiteManagementService.updateGeographicSite(id, geographicSite);
GeographicSite c=geographicSiteManagementService.findGeographicSiteByRelatedPartyId(id);
c = geographicSiteManagementService.updateGeographicSite(c.getUuid(), geographicSite);
return new ResponseEntity<>(c, HttpStatus.OK);
}
return new ResponseEntity<>(c, HttpStatus.OK);
}catch (Exception e){
log.error(COULD_NOT_SERIALIZE, e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
Loading