SlideShare a Scribd company logo
1 of 12
Download to read offline
Creating a Facebook Clone - Part XXVI
@Controller
@RequestMapping("/post")
@RestController
public class PostWebService {
@Autowired
private PostService posts;
@ExceptionHandler(PermissionException.class)
@ResponseStatus(value=HttpStatus.FORBIDDEN)
public @ResponseBody
ErrorDAO handlePermissionException(PermissionException e) {
return new ErrorDAO(e.getMessage(), 0);
}
@RequestMapping(method=RequestMethod.GET, value="/list")
public List<PostDAO> postsOf(
@RequestHeader(name="auth", required=true) String auth,
@RequestParam(name="user", required=true) String user,
@RequestParam(name="page") int page,
@RequestParam(name="size") int size) {
PostWebService
@Controller
@RequestMapping("/post")
@RestController
public class PostWebService {
@Autowired
private PostService posts;
@ExceptionHandler(PermissionException.class)
@ResponseStatus(value=HttpStatus.FORBIDDEN)
public @ResponseBody
ErrorDAO handlePermissionException(PermissionException e) {
return new ErrorDAO(e.getMessage(), 0);
}
@RequestMapping(method=RequestMethod.GET, value="/list")
public List<PostDAO> postsOf(
@RequestHeader(name="auth", required=true) String auth,
@RequestParam(name="user", required=true) String user,
@RequestParam(name="page") int page,
@RequestParam(name="size") int size) {
PostWebService
@Controller
@RequestMapping("/post")
@RestController
public class PostWebService {
@Autowired
private PostService posts;
@ExceptionHandler(PermissionException.class)
@ResponseStatus(value=HttpStatus.FORBIDDEN)
public @ResponseBody
ErrorDAO handlePermissionException(PermissionException e) {
return new ErrorDAO(e.getMessage(), 0);
}
@RequestMapping(method=RequestMethod.GET, value="/list")
public List<PostDAO> postsOf(
@RequestHeader(name="auth", required=true) String auth,
@RequestParam(name="user", required=true) String user,
@RequestParam(name="page") int page,
@RequestParam(name="size") int size) {
PostWebService
public @ResponseBody
ErrorDAO handlePermissionException(PermissionException e) {
return new ErrorDAO(e.getMessage(), 0);
}
@RequestMapping(method=RequestMethod.GET, value="/list")
public List<PostDAO> postsOf(
@RequestHeader(name="auth", required=true) String auth,
@RequestParam(name="user", required=true) String user,
@RequestParam(name="page") int page,
@RequestParam(name="size") int size) {
return posts.postsOf(auth, user, page, size);
}
@RequestMapping(method=RequestMethod.GET, value="/feed")
public List<PostDAO> newsfeed(
@RequestHeader(name="auth", required=true) String authToken,
@RequestParam(name="page") int page,
@RequestParam(name="size") int size) {
return posts.newsfeed(authToken, page, size);
}
@RequestMapping(value="/new", method=RequestMethod.POST)
public String post(
PostWebService
@RequestParam(name="size") int size) {
return posts.newsfeed(authToken, page, size);
}
@RequestMapping(value="/new", method=RequestMethod.POST)
public String post(
@RequestHeader(name="auth", required=true) String auth,
@RequestBody PostDAO pd) {
return posts.post(auth, pd);
}
@RequestMapping(value="/comment", method=RequestMethod.POST)
public String comment(
@RequestHeader(name="auth", required=true) String auth,
@RequestBody CommentDAO cd) throws PermissionException {
return posts.comment(auth, cd.getPostId(), cd);
}
@RequestMapping(value="/like", method=RequestMethod.GET)
public String like(
@RequestHeader(name="auth", required=true) String auth,
@RequestParam String postId) {
posts.like(auth, postId);
return "OK";
PostWebService
@Controller
@RequestMapping("/media")
@RestController
public class MediaWebService {
@Autowired
private MediaService medias;
@ExceptionHandler(PermissionException.class)
@ResponseStatus(value=HttpStatus.FORBIDDEN)
public @ResponseBody
ErrorDAO handlePermissionException(PermissionException e) {
return new ErrorDAO(e.getMessage(), 0);
}
@RequestMapping(value="/public/{id:.+}", method=RequestMethod.GET)
public ResponseEntity<byte[]> getPublic(@PathVariable("id") String id)
throws PermissionException {
MediaDAO av = medias.getPublicMedia(id);
if(av != null) {
return ResponseEntity.ok().
MediaWebService
@Controller
@RequestMapping("/media")
@RestController
public class MediaWebService {
@Autowired
private MediaService medias;
@ExceptionHandler(PermissionException.class)
@ResponseStatus(value=HttpStatus.FORBIDDEN)
public @ResponseBody
ErrorDAO handlePermissionException(PermissionException e) {
return new ErrorDAO(e.getMessage(), 0);
}
@RequestMapping(value="/public/{id:.+}", method=RequestMethod.GET)
public ResponseEntity<byte[]> getPublic(@PathVariable("id") String id)
throws PermissionException {
MediaDAO av = medias.getPublicMedia(id);
if(av != null) {
return ResponseEntity.ok().
MediaWebService
@ResponseStatus(value=HttpStatus.FORBIDDEN)
public @ResponseBody
ErrorDAO handlePermissionException(PermissionException e) {
return new ErrorDAO(e.getMessage(), 0);
}
@RequestMapping(value="/public/{id:.+}", method=RequestMethod.GET)
public ResponseEntity<byte[]> getPublic(@PathVariable("id") String id)
throws PermissionException {
MediaDAO av = medias.getPublicMedia(id);
if(av != null) {
return ResponseEntity.ok().
contentType(MediaType.valueOf(av.getMimeType())).
contentLength(av.getData().length).
body(av.getData());
}
return ResponseEntity.notFound().build();
}
@RequestMapping(value="/all/{id:.+}", method=RequestMethod.GET)
public ResponseEntity<byte[]> getAll(
@RequestHeader(name="auth", required=true) String auth,
@PathVariable("id") String id)
throws PermissionException {
MediaWebService
@ResponseStatus(value=HttpStatus.FORBIDDEN)
public @ResponseBody
ErrorDAO handlePermissionException(PermissionException e) {
return new ErrorDAO(e.getMessage(), 0);
}
@RequestMapping(value="/public/{id:.+}", method=RequestMethod.GET)
public ResponseEntity<byte[]> getPublic(@PathVariable("id") String id)
throws PermissionException {
MediaDAO av = medias.getPublicMedia(id);
if(av != null) {
return ResponseEntity.ok().
contentType(MediaType.valueOf(av.getMimeType())).
contentLength(av.getData().length).
body(av.getData());
}
return ResponseEntity.notFound().build();
}
@RequestMapping(value="/all/{id:.+}", method=RequestMethod.GET)
public ResponseEntity<byte[]> getAll(
@RequestHeader(name="auth", required=true) String auth,
@PathVariable("id") String id)
throws PermissionException {
MediaWebService
contentLength(av.getData().length).
body(av.getData());
}
return ResponseEntity.notFound().build();
}
@RequestMapping(value="/all/{id:.+}", method=RequestMethod.GET)
public ResponseEntity<byte[]> getAll(
@RequestHeader(name="auth", required=true) String auth,
@PathVariable("id") String id)
throws PermissionException {
MediaDAO av = medias.getMedia(auth, id);
if(av != null) {
return ResponseEntity.ok().
contentType(MediaType.valueOf(av.getMimeType())).
contentLength(av.getData().length).
body(av.getData());
}
return ResponseEntity.notFound().build();
}
@RequestMapping(method=RequestMethod.POST, value="/upload")
public @ResponseBody
String upload(
MediaWebService
MediaDAO av = medias.getMedia(auth, id);
if(av != null) {
return ResponseEntity.ok().
contentType(MediaType.valueOf(av.getMimeType())).
contentLength(av.getData().length).
body(av.getData());
}
return ResponseEntity.notFound().build();
}
@RequestMapping(method=RequestMethod.POST, value="/upload")
public @ResponseBody
String upload(
@RequestHeader(name="auth", required=true) String auth,
@RequestParam(name="file", required=true) MultipartFile file,
@RequestParam("role") String role,
@RequestParam("visibility") String visibility)
throws IOException {
return medias.storeMedia(auth, file.getBytes(), file.
getContentType(),
role, visibility, file.getName());
}
}
MediaWebService

More Related Content

Similar to Creating a Facebook Clone - Part XXVI.pdf

softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EEAlexis Hassler
 
Javaone 2010
Javaone 2010Javaone 2010
Javaone 2010Hien Luu
 
Easy rest service using PHP reflection api
Easy rest service using PHP reflection apiEasy rest service using PHP reflection api
Easy rest service using PHP reflection apiMatthieu Aubry
 
Creating a Facebook Clone - Part XXVII.pdf
Creating a Facebook Clone - Part XXVII.pdfCreating a Facebook Clone - Part XXVII.pdf
Creating a Facebook Clone - Part XXVII.pdfShaiAlmog1
 
Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門Ryosuke Uchitate
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC AnnotationsJordan Silva
 
Neues aus dem Tindergarten: Auswertung "privater" APIs mit Apache Ignite
Neues aus dem Tindergarten: Auswertung "privater" APIs mit Apache IgniteNeues aus dem Tindergarten: Auswertung "privater" APIs mit Apache Ignite
Neues aus dem Tindergarten: Auswertung "privater" APIs mit Apache IgniteQAware GmbH
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasyJBug Italy
 
Creating a Facebook Clone - Part XXIV - Transcript.pdf
Creating a Facebook Clone - Part XXIV - Transcript.pdfCreating a Facebook Clone - Part XXIV - Transcript.pdf
Creating a Facebook Clone - Part XXIV - Transcript.pdfShaiAlmog1
 
Android Testing
Android TestingAndroid Testing
Android TestingEvan Lin
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo Ali Parmaksiz
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web developmentJohannes Brodwall
 
Vaadin Flow framework in a nutshell
Vaadin Flow framework in a nutshellVaadin Flow framework in a nutshell
Vaadin Flow framework in a nutshellVMware Tanzu
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsGuy Nir
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologyDaniel Knell
 

Similar to Creating a Facebook Clone - Part XXVI.pdf (20)

softshake 2014 - Java EE
softshake 2014 - Java EEsoftshake 2014 - Java EE
softshake 2014 - Java EE
 
Javaone 2010
Javaone 2010Javaone 2010
Javaone 2010
 
Easy rest service using PHP reflection api
Easy rest service using PHP reflection apiEasy rest service using PHP reflection api
Easy rest service using PHP reflection api
 
Creating a Facebook Clone - Part XXVII.pdf
Creating a Facebook Clone - Part XXVII.pdfCreating a Facebook Clone - Part XXVII.pdf
Creating a Facebook Clone - Part XXVII.pdf
 
Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門Form認証で学ぶSpring Security入門
Form認証で学ぶSpring Security入門
 
Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC Annotations
 
Neues aus dem Tindergarten: Auswertung "privater" APIs mit Apache Ignite
Neues aus dem Tindergarten: Auswertung "privater" APIs mit Apache IgniteNeues aus dem Tindergarten: Auswertung "privater" APIs mit Apache Ignite
Neues aus dem Tindergarten: Auswertung "privater" APIs mit Apache Ignite
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
 
Creating a Facebook Clone - Part XXIV - Transcript.pdf
Creating a Facebook Clone - Part XXIV - Transcript.pdfCreating a Facebook Clone - Part XXIV - Transcript.pdf
Creating a Facebook Clone - Part XXIV - Transcript.pdf
 
JavaCro'15 - GWT integration with Vaadin - Peter Lehto
JavaCro'15 - GWT integration with Vaadin - Peter LehtoJavaCro'15 - GWT integration with Vaadin - Peter Lehto
JavaCro'15 - GWT integration with Vaadin - Peter Lehto
 
Android Testing
Android TestingAndroid Testing
Android Testing
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo A GWT Application with MVP Pattern Deploying to CloudFoundry using  Spring Roo
A GWT Application with MVP Pattern Deploying to CloudFoundry using Spring Roo
 
Spring4 whats up doc?
Spring4 whats up doc?Spring4 whats up doc?
Spring4 whats up doc?
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web development
 
Vaadin Flow framework in a nutshell
Vaadin Flow framework in a nutshellVaadin Flow framework in a nutshell
Vaadin Flow framework in a nutshell
 
Geb qa fest2017
Geb qa fest2017Geb qa fest2017
Geb qa fest2017
 
Spring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topicsSpring 3.x - Spring MVC - Advanced topics
Spring 3.x - Spring MVC - Advanced topics
 
Symfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technologySymfony2 Building on Alpha / Beta technology
Symfony2 Building on Alpha / Beta technology
 

More from ShaiAlmog1

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...ShaiAlmog1
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfShaiAlmog1
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfShaiAlmog1
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfShaiAlmog1
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfShaiAlmog1
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfShaiAlmog1
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfShaiAlmog1
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfShaiAlmog1
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfShaiAlmog1
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfShaiAlmog1
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfShaiAlmog1
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfShaiAlmog1
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfCreating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfCreating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfShaiAlmog1
 

More from ShaiAlmog1 (20)

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdf
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdf
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdf
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdf
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdf
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdf
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdf
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdf
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdf
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdf
 
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfCreating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdf
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
 
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfCreating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdf
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf
 

Recently uploaded

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformWSO2
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaWSO2
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAnitaRaj43
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMKumar Satyam
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Modernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using BallerinaModernizing Legacy Systems Using Ballerina
Modernizing Legacy Systems Using Ballerina
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 

Creating a Facebook Clone - Part XXVI.pdf

  • 1. Creating a Facebook Clone - Part XXVI
  • 2. @Controller @RequestMapping("/post") @RestController public class PostWebService { @Autowired private PostService posts; @ExceptionHandler(PermissionException.class) @ResponseStatus(value=HttpStatus.FORBIDDEN) public @ResponseBody ErrorDAO handlePermissionException(PermissionException e) { return new ErrorDAO(e.getMessage(), 0); } @RequestMapping(method=RequestMethod.GET, value="/list") public List<PostDAO> postsOf( @RequestHeader(name="auth", required=true) String auth, @RequestParam(name="user", required=true) String user, @RequestParam(name="page") int page, @RequestParam(name="size") int size) { PostWebService
  • 3. @Controller @RequestMapping("/post") @RestController public class PostWebService { @Autowired private PostService posts; @ExceptionHandler(PermissionException.class) @ResponseStatus(value=HttpStatus.FORBIDDEN) public @ResponseBody ErrorDAO handlePermissionException(PermissionException e) { return new ErrorDAO(e.getMessage(), 0); } @RequestMapping(method=RequestMethod.GET, value="/list") public List<PostDAO> postsOf( @RequestHeader(name="auth", required=true) String auth, @RequestParam(name="user", required=true) String user, @RequestParam(name="page") int page, @RequestParam(name="size") int size) { PostWebService
  • 4. @Controller @RequestMapping("/post") @RestController public class PostWebService { @Autowired private PostService posts; @ExceptionHandler(PermissionException.class) @ResponseStatus(value=HttpStatus.FORBIDDEN) public @ResponseBody ErrorDAO handlePermissionException(PermissionException e) { return new ErrorDAO(e.getMessage(), 0); } @RequestMapping(method=RequestMethod.GET, value="/list") public List<PostDAO> postsOf( @RequestHeader(name="auth", required=true) String auth, @RequestParam(name="user", required=true) String user, @RequestParam(name="page") int page, @RequestParam(name="size") int size) { PostWebService
  • 5. public @ResponseBody ErrorDAO handlePermissionException(PermissionException e) { return new ErrorDAO(e.getMessage(), 0); } @RequestMapping(method=RequestMethod.GET, value="/list") public List<PostDAO> postsOf( @RequestHeader(name="auth", required=true) String auth, @RequestParam(name="user", required=true) String user, @RequestParam(name="page") int page, @RequestParam(name="size") int size) { return posts.postsOf(auth, user, page, size); } @RequestMapping(method=RequestMethod.GET, value="/feed") public List<PostDAO> newsfeed( @RequestHeader(name="auth", required=true) String authToken, @RequestParam(name="page") int page, @RequestParam(name="size") int size) { return posts.newsfeed(authToken, page, size); } @RequestMapping(value="/new", method=RequestMethod.POST) public String post( PostWebService
  • 6. @RequestParam(name="size") int size) { return posts.newsfeed(authToken, page, size); } @RequestMapping(value="/new", method=RequestMethod.POST) public String post( @RequestHeader(name="auth", required=true) String auth, @RequestBody PostDAO pd) { return posts.post(auth, pd); } @RequestMapping(value="/comment", method=RequestMethod.POST) public String comment( @RequestHeader(name="auth", required=true) String auth, @RequestBody CommentDAO cd) throws PermissionException { return posts.comment(auth, cd.getPostId(), cd); } @RequestMapping(value="/like", method=RequestMethod.GET) public String like( @RequestHeader(name="auth", required=true) String auth, @RequestParam String postId) { posts.like(auth, postId); return "OK"; PostWebService
  • 7. @Controller @RequestMapping("/media") @RestController public class MediaWebService { @Autowired private MediaService medias; @ExceptionHandler(PermissionException.class) @ResponseStatus(value=HttpStatus.FORBIDDEN) public @ResponseBody ErrorDAO handlePermissionException(PermissionException e) { return new ErrorDAO(e.getMessage(), 0); } @RequestMapping(value="/public/{id:.+}", method=RequestMethod.GET) public ResponseEntity<byte[]> getPublic(@PathVariable("id") String id) throws PermissionException { MediaDAO av = medias.getPublicMedia(id); if(av != null) { return ResponseEntity.ok(). MediaWebService
  • 8. @Controller @RequestMapping("/media") @RestController public class MediaWebService { @Autowired private MediaService medias; @ExceptionHandler(PermissionException.class) @ResponseStatus(value=HttpStatus.FORBIDDEN) public @ResponseBody ErrorDAO handlePermissionException(PermissionException e) { return new ErrorDAO(e.getMessage(), 0); } @RequestMapping(value="/public/{id:.+}", method=RequestMethod.GET) public ResponseEntity<byte[]> getPublic(@PathVariable("id") String id) throws PermissionException { MediaDAO av = medias.getPublicMedia(id); if(av != null) { return ResponseEntity.ok(). MediaWebService
  • 9. @ResponseStatus(value=HttpStatus.FORBIDDEN) public @ResponseBody ErrorDAO handlePermissionException(PermissionException e) { return new ErrorDAO(e.getMessage(), 0); } @RequestMapping(value="/public/{id:.+}", method=RequestMethod.GET) public ResponseEntity<byte[]> getPublic(@PathVariable("id") String id) throws PermissionException { MediaDAO av = medias.getPublicMedia(id); if(av != null) { return ResponseEntity.ok(). contentType(MediaType.valueOf(av.getMimeType())). contentLength(av.getData().length). body(av.getData()); } return ResponseEntity.notFound().build(); } @RequestMapping(value="/all/{id:.+}", method=RequestMethod.GET) public ResponseEntity<byte[]> getAll( @RequestHeader(name="auth", required=true) String auth, @PathVariable("id") String id) throws PermissionException { MediaWebService
  • 10. @ResponseStatus(value=HttpStatus.FORBIDDEN) public @ResponseBody ErrorDAO handlePermissionException(PermissionException e) { return new ErrorDAO(e.getMessage(), 0); } @RequestMapping(value="/public/{id:.+}", method=RequestMethod.GET) public ResponseEntity<byte[]> getPublic(@PathVariable("id") String id) throws PermissionException { MediaDAO av = medias.getPublicMedia(id); if(av != null) { return ResponseEntity.ok(). contentType(MediaType.valueOf(av.getMimeType())). contentLength(av.getData().length). body(av.getData()); } return ResponseEntity.notFound().build(); } @RequestMapping(value="/all/{id:.+}", method=RequestMethod.GET) public ResponseEntity<byte[]> getAll( @RequestHeader(name="auth", required=true) String auth, @PathVariable("id") String id) throws PermissionException { MediaWebService
  • 11. contentLength(av.getData().length). body(av.getData()); } return ResponseEntity.notFound().build(); } @RequestMapping(value="/all/{id:.+}", method=RequestMethod.GET) public ResponseEntity<byte[]> getAll( @RequestHeader(name="auth", required=true) String auth, @PathVariable("id") String id) throws PermissionException { MediaDAO av = medias.getMedia(auth, id); if(av != null) { return ResponseEntity.ok(). contentType(MediaType.valueOf(av.getMimeType())). contentLength(av.getData().length). body(av.getData()); } return ResponseEntity.notFound().build(); } @RequestMapping(method=RequestMethod.POST, value="/upload") public @ResponseBody String upload( MediaWebService
  • 12. MediaDAO av = medias.getMedia(auth, id); if(av != null) { return ResponseEntity.ok(). contentType(MediaType.valueOf(av.getMimeType())). contentLength(av.getData().length). body(av.getData()); } return ResponseEntity.notFound().build(); } @RequestMapping(method=RequestMethod.POST, value="/upload") public @ResponseBody String upload( @RequestHeader(name="auth", required=true) String auth, @RequestParam(name="file", required=true) MultipartFile file, @RequestParam("role") String role, @RequestParam("visibility") String visibility) throws IOException { return medias.storeMedia(auth, file.getBytes(), file. getContentType(), role, visibility, file.getName()); } } MediaWebService