use of org.eclipse.sw360.datahandler.thrift.vendors.Vendor in project sw360portal by sw360.
the class VendorController method getVendors.
@RequestMapping(value = VENDORS_URL, method = RequestMethod.GET)
public ResponseEntity<Resources<Resource<Vendor>>> getVendors(OAuth2Authentication oAuth2Authentication) {
List<Vendor> vendors = vendorService.getVendors();
List<Resource<Vendor>> vendorResources = new ArrayList<>();
for (Vendor vendor : vendors) {
Vendor embeddedVendor = restControllerHelper.convertToEmbeddedVendor(vendor.getFullname());
Resource<Vendor> vendorResource = new Resource<>(embeddedVendor);
vendorResources.add(vendorResource);
}
Resources<Resource<Vendor>> resources = new Resources<>(vendorResources);
return new ResponseEntity<>(resources, HttpStatus.OK);
}
use of org.eclipse.sw360.datahandler.thrift.vendors.Vendor in project sw360portal by sw360.
the class VendorController method createVendor.
@PreAuthorize("hasAuthority('WRITE')")
@RequestMapping(value = VENDORS_URL, method = RequestMethod.POST)
public ResponseEntity createVendor(OAuth2Authentication oAuth2Authentication, @RequestBody Vendor vendor) throws URISyntaxException {
vendor = vendorService.createVendor(vendor);
HalResource<Vendor> halResource = createHalVendor(vendor);
URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(vendor.getId()).toUri();
return ResponseEntity.created(location).body(halResource);
}
Aggregations