use of org.springframework.security.oauth.examples.sparklr.PhotoInfo in project spring-security-oauth by spring-projects.
the class PhotoController method getJsonPhotos.
@RequestMapping(value = "/photos", params = "format=json")
@ResponseBody
public ResponseEntity<String> getJsonPhotos(@RequestParam(required = false) String callback) throws Exception {
Collection<PhotoInfo> photos = photoService.getPhotosForCurrentUser();
StringBuilder out = new StringBuilder();
if (callback != null) {
out.append(callback);
out.append("( ");
}
out.append("{ \"photos\" : [ ");
Iterator<PhotoInfo> photosIt = photos.iterator();
while (photosIt.hasNext()) {
PhotoInfo photo = photosIt.next();
out.append(String.format("{ \"id\" : \"%s\" , \"name\" : \"%s\" }", photo.getId(), photo.getName()));
if (photosIt.hasNext()) {
out.append(" , ");
}
}
out.append("] }");
if (callback != null) {
out.append(" )");
}
HttpHeaders headers = new HttpHeaders();
headers.set("Content-Type", "application/json");
return new ResponseEntity<String>(out.toString(), headers, HttpStatus.OK);
}
use of org.springframework.security.oauth.examples.sparklr.PhotoInfo in project spring-security-oauth by spring-projects.
the class WebMvcConfig method createPhoto.
private PhotoInfo createPhoto(String id, String userId) {
PhotoInfo photo = new PhotoInfo();
photo.setId(id);
photo.setName("photo" + id + ".jpg");
photo.setUserId(userId);
photo.setResourceURL("/org/springframework/security/oauth/examples/sparklr/impl/resources/" + photo.getName());
return photo;
}
use of org.springframework.security.oauth.examples.sparklr.PhotoInfo in project spring-security-oauth by spring-projects.
the class WebMvcConfig method photoServices.
@Bean
public PhotoServiceImpl photoServices() {
List<PhotoInfo> photos = new ArrayList<PhotoInfo>();
photos.add(createPhoto("1", "marissa"));
photos.add(createPhoto("2", "paul"));
photos.add(createPhoto("3", "marissa"));
photos.add(createPhoto("4", "paul"));
photos.add(createPhoto("5", "marissa"));
photos.add(createPhoto("6", "paul"));
PhotoServiceImpl photoServices = new PhotoServiceImpl();
photoServices.setPhotos(photos);
return photoServices;
}
Aggregations