@Override public List<ILocationMatch> match(Topology topology) throws LocationMatchingException { List<ILocationMatch> matched = Lists.newArrayList(); try { // get all enabled orchestrators List<Orchestrator> enabledOrchestrators = orchestratorService.getAll(); if (CollectionUtils.isEmpty(enabledOrchestrators)) { return matched; } Map<String, Orchestrator> orchestratorMap = AlienUtils.fromListToMap(enabledOrchestrators, "id", true); List<Location> locations = locationService.getOrchestratorsLocations(orchestratorMap.keySet()); for (Location location : locations) { matched.add( new LocationMatch(location, orchestratorMap.get(location.getOrchestratorId()), null)); } // filter on supported artifacts locationMatchNodeFilter.filter(matched, topology); return matched; } catch (Exception e) { throw new LocationMatchingException( "Failed to match topology <" + topology.getId() + "> against locations. ", e); } }
@ApiOperation( value = "Update the name of an existing location.", authorizations = {@Authorization("ADMIN")}) @RequestMapping( value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) @PreAuthorize("hasAuthority('ADMIN')") @Audit public RestResponse<Void> update( @ApiParam(value = "Id of the orchestrator for which the location is defined.") @PathVariable String orchestratorId, @ApiParam(value = "Id of the location to update", required = true) @PathVariable String id, @ApiParam( value = "Location update request, representing the fields to updates and their new values.", required = true) @Valid @NotEmpty @RequestBody UpdateLocationRequest updateRequest) { Location location = locationService.getOrFail(id); String currentName = location.getName(); ReflectionUtil.mergeObject(updateRequest, location); locationService.ensureNameUnicityAndSave(location, currentName); return RestResponseBuilder.<Void>builder().build(); }