Creating a Facebook Clone - Part XXXVIII.pdfShaiAlmog1
The document discusses the implementation of posts, media, and comments for a Facebook clone application. Key points include:
- A Post entity supports one media file per post, comments, likes, and attachments through relationships to other entities.
- The PostDAO converts Post entities to plain Java objects for transferring data to and from the client.
- The PostService allows creating and sharing posts to friends' newsfeeds through repositories for posts, users, newsfeeds, comments, and media.
- The MediaService supports getting media attachments by ID, checking permissions and returning file data and metadata.
Creating a Facebook Clone - Part XVIII.pdfShaiAlmog1
This document discusses the Media class and MediaDAO class used for storing media data in a database. The Media class defines fields for the media id, filename, date, role, mime type, visibility, owner, and data. The MediaDAO class is used to transfer data between the Media entity and database. It includes fields for each property in Media and methods for getting and setting the field values.
Creating a Facebook Clone - Part XXXVIII.pdfShaiAlmog1
The document discusses the implementation of posts, media, and comments for a Facebook clone application. Key points include:
- A Post entity supports one media file per post, comments, likes, and attachments through relationships to other entities.
- The PostDAO converts Post entities to plain Java objects for transferring data to and from the client.
- The PostService allows creating and sharing posts to friends' newsfeeds through repositories for posts, users, newsfeeds, comments, and media.
- The MediaService supports getting media attachments by ID, checking permissions and returning file data and metadata.
Creating a Facebook Clone - Part XVIII.pdfShaiAlmog1
This document discusses the Media class and MediaDAO class used for storing media data in a database. The Media class defines fields for the media id, filename, date, role, mime type, visibility, owner, and data. The MediaDAO class is used to transfer data between the Media entity and database. It includes fields for each property in Media and methods for getting and setting the field values.
Creating a Whatsapp Clone - Part III.pdfShaiAlmog1
The document defines a ChatContact class that implements PropertyBusinessObject and represents contacts in a messaging app. It includes properties for contact details like id, name, photo, groups, and messaging metadata. Methods set up indexing and image processing for the photo property.
Creating a Facebook Clone - Part XX - Transcript.pdfShaiAlmog1
The document discusses the implementation of a Notification entity class that maps to database table and represents notifications for a social media user. The Notification class uses annotations like @Id, @ManyToOne and has fields for the notification ID, associated user, text, reaction details, date, whether it was read, and post/comment IDs. Getter and setter methods are also implemented.
Creating a Facebook Clone - Part XIX - Transcript.pdfShaiAlmog1
The document describes the implementation of a Post entity and related classes for the backend of a Facebook clone. It includes:
1) A Post entity with fields like user, date, title, content, visibility, styling, comments, and likes.
2) Post, Comment, and related DAO classes to transfer data to and from clients.
3) PostRepository and CommentRepository interfaces extending CrudRepository for database operations.
4) Methods in PostRepository like findPostsByUser() and findAllPostsByUser() to retrieve posts by user with paging support.
Presentation Android Architecture ComponentsAttract Group
The document introduces several Android Architecture Components: Lifecycle, LiveData, ViewModel, and Room. Lifecycle allows observing activity and fragment lifecycles. LiveData allows updating UI when underlying data changes. ViewModel stores UI-related data that survives configuration changes. Room provides an abstraction layer over SQLite to allow for more robust database access.
The Duck Teaches Learn to debug from the masters. Local to production- kill ...ShaiAlmog1
The document outlines an agenda for a workshop on debugging techniques. The workshop covers installing tools, flow and breakpoints debugging, watching variables, Kubernetes debugging, and developer observability. Key techniques discussed include tracepoints, memory debugging, exception breakpoints, object marking, and logs, snapshots, and metrics for observability. The goal is to teach practical debugging skills that can be applied at scale in production environments like Kubernetes.
Creating a Whatsapp Clone - Part III.pdfShaiAlmog1
The document defines a ChatContact class that implements PropertyBusinessObject and represents contacts in a messaging app. It includes properties for contact details like id, name, photo, groups, and messaging metadata. Methods set up indexing and image processing for the photo property.
Creating a Facebook Clone - Part XX - Transcript.pdfShaiAlmog1
The document discusses the implementation of a Notification entity class that maps to database table and represents notifications for a social media user. The Notification class uses annotations like @Id, @ManyToOne and has fields for the notification ID, associated user, text, reaction details, date, whether it was read, and post/comment IDs. Getter and setter methods are also implemented.
Creating a Facebook Clone - Part XIX - Transcript.pdfShaiAlmog1
The document describes the implementation of a Post entity and related classes for the backend of a Facebook clone. It includes:
1) A Post entity with fields like user, date, title, content, visibility, styling, comments, and likes.
2) Post, Comment, and related DAO classes to transfer data to and from clients.
3) PostRepository and CommentRepository interfaces extending CrudRepository for database operations.
4) Methods in PostRepository like findPostsByUser() and findAllPostsByUser() to retrieve posts by user with paging support.
Presentation Android Architecture ComponentsAttract Group
The document introduces several Android Architecture Components: Lifecycle, LiveData, ViewModel, and Room. Lifecycle allows observing activity and fragment lifecycles. LiveData allows updating UI when underlying data changes. ViewModel stores UI-related data that survives configuration changes. Room provides an abstraction layer over SQLite to allow for more robust database access.
The Duck Teaches Learn to debug from the masters. Local to production- kill ...ShaiAlmog1
The document outlines an agenda for a workshop on debugging techniques. The workshop covers installing tools, flow and breakpoints debugging, watching variables, Kubernetes debugging, and developer observability. Key techniques discussed include tracepoints, memory debugging, exception breakpoints, object marking, and logs, snapshots, and metrics for observability. The goal is to teach practical debugging skills that can be applied at scale in production environments like Kubernetes.
The document describes code for implementing the server-side functionality of a WhatsApp clone. It includes classes for representing users, messages, and server connections. The Server class initializes user and message data from files, handles login/signup, and establishes a websocket connection for real-time messaging. It can send and receive messages when connected, or queue messages when offline.
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Speck&Tech
ABSTRACT: A prima vista, un mattoncino Lego e la backdoor XZ potrebbero avere in comune il fatto di essere entrambi blocchi di costruzione, o dipendenze di progetti creativi e software. La realtà è che un mattoncino Lego e il caso della backdoor XZ hanno molto di più di tutto ciò in comune.
Partecipate alla presentazione per immergervi in una storia di interoperabilità, standard e formati aperti, per poi discutere del ruolo importante che i contributori hanno in una comunità open source sostenibile.
BIO: Sostenitrice del software libero e dei formati standard e aperti. È stata un membro attivo dei progetti Fedora e openSUSE e ha co-fondato l'Associazione LibreItalia dove è stata coinvolta in diversi eventi, migrazioni e formazione relativi a LibreOffice. In precedenza ha lavorato a migrazioni e corsi di formazione su LibreOffice per diverse amministrazioni pubbliche e privati. Da gennaio 2020 lavora in SUSE come Software Release Engineer per Uyuni e SUSE Manager e quando non segue la sua passione per i computer e per Geeko coltiva la sua curiosità per l'astronomia (da cui deriva il suo nickname deneb_alpha).
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfChart Kalyan
A Mix Chart displays historical data of numbers in a graphical or tabular form. The Kalyan Rajdhani Mix Chart specifically shows the results of a sequence of numbers over different periods.
OpenID AuthZEN Interop Read Out - AuthorizationDavid Brossard
During Identiverse 2024 and EIC 2024, members of the OpenID AuthZEN WG got together and demoed their authorization endpoints conforming to the AuthZEN API
Digital Marketing Trends in 2024 | Guide for Staying AheadWask
https://www.wask.co/ebooks/digital-marketing-trends-in-2024
Feeling lost in the digital marketing whirlwind of 2024? Technology is changing, consumer habits are evolving, and staying ahead of the curve feels like a never-ending pursuit. This e-book is your compass. Dive into actionable insights to handle the complexities of modern marketing. From hyper-personalization to the power of user-generated content, learn how to build long-term relationships with your audience and unlock the secrets to success in the ever-shifting digital landscape.
Project Management Semester Long Project - Acuityjpupo2018
Acuity is an innovative learning app designed to transform the way you engage with knowledge. Powered by AI technology, Acuity takes complex topics and distills them into concise, interactive summaries that are easy to read & understand. Whether you're exploring the depths of quantum mechanics or seeking insight into historical events, Acuity provides the key information you need without the burden of lengthy texts.
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceIndexBug
Imagine a world where machines not only perform tasks but also learn, adapt, and make decisions. This is the promise of Artificial Intelligence (AI), a technology that's not just enhancing our lives but revolutionizing entire industries.
5th LF Energy Power Grid Model Meet-up SlidesDanBrown980551
5th Power Grid Model Meet-up
It is with great pleasure that we extend to you an invitation to the 5th Power Grid Model Meet-up, scheduled for 6th June 2024. This event will adopt a hybrid format, allowing participants to join us either through an online Mircosoft Teams session or in person at TU/e located at Den Dolech 2, Eindhoven, Netherlands. The meet-up will be hosted by Eindhoven University of Technology (TU/e), a research university specializing in engineering science & technology.
Power Grid Model
The global energy transition is placing new and unprecedented demands on Distribution System Operators (DSOs). Alongside upgrades to grid capacity, processes such as digitization, capacity optimization, and congestion management are becoming vital for delivering reliable services.
Power Grid Model is an open source project from Linux Foundation Energy and provides a calculation engine that is increasingly essential for DSOs. It offers a standards-based foundation enabling real-time power systems analysis, simulations of electrical power grids, and sophisticated what-if analysis. In addition, it enables in-depth studies and analysis of the electrical power grid’s behavior and performance. This comprehensive model incorporates essential factors such as power generation capacity, electrical losses, voltage levels, power flows, and system stability.
Power Grid Model is currently being applied in a wide variety of use cases, including grid planning, expansion, reliability, and congestion studies. It can also help in analyzing the impact of renewable energy integration, assessing the effects of disturbances or faults, and developing strategies for grid control and optimization.
What to expect
For the upcoming meetup we are organizing, we have an exciting lineup of activities planned:
-Insightful presentations covering two practical applications of the Power Grid Model.
-An update on the latest advancements in Power Grid -Model technology during the first and second quarters of 2024.
-An interactive brainstorming session to discuss and propose new feature requests.
-An opportunity to connect with fellow Power Grid Model enthusiasts and users.
HCL Notes and Domino License Cost Reduction in the World of DLAUpanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-notes-and-domino-license-cost-reduction-in-the-world-of-dlau/
The introduction of DLAU and the CCB & CCX licensing model caused quite a stir in the HCL community. As a Notes and Domino customer, you may have faced challenges with unexpected user counts and license costs. You probably have questions on how this new licensing approach works and how to benefit from it. Most importantly, you likely have budget constraints and want to save money where possible. Don’t worry, we can help with all of this!
We’ll show you how to fix common misconfigurations that cause higher-than-expected user counts, and how to identify accounts which you can deactivate to save money. There are also frequent patterns that can cause unnecessary cost, like using a person document instead of a mail-in for shared mailboxes. We’ll provide examples and solutions for those as well. And naturally we’ll explain the new licensing model.
Join HCL Ambassador Marc Thomas in this webinar with a special guest appearance from Franz Walder. It will give you the tools and know-how to stay on top of what is going on with Domino licensing. You will be able lower your cost through an optimized configuration and keep it low going forward.
These topics will be covered
- Reducing license cost by finding and fixing misconfigurations and superfluous accounts
- How do CCB and CCX licenses really work?
- Understanding the DLAU tool and how to best utilize it
- Tips for common problem areas, like team mailboxes, functional/test users, etc
- Practical examples and best practices to implement right away
Programming Foundation Models with DSPy - Meetup SlidesZilliz
Prompting language models is hard, while programming language models is easy. In this talk, I will discuss the state-of-the-art framework DSPy for programming foundation models with its powerful optimizers and runtime constraint system.
Ivanti’s Patch Tuesday breakdown goes beyond patching your applications and brings you the intelligence and guidance needed to prioritize where to focus your attention first. Catch early analysis on our Ivanti blog, then join industry expert Chris Goettl for the Patch Tuesday Webinar Event. There we’ll do a deep dive into each of the bulletins and give guidance on the risks associated with the newly-identified vulnerabilities.
Driving Business Innovation: Latest Generative AI Advancements & Success StorySafe Software
Are you ready to revolutionize how you handle data? Join us for a webinar where we’ll bring you up to speed with the latest advancements in Generative AI technology and discover how leveraging FME with tools from giants like Google Gemini, Amazon, and Microsoft OpenAI can supercharge your workflow efficiency.
During the hour, we’ll take you through:
Guest Speaker Segment with Hannah Barrington: Dive into the world of dynamic real estate marketing with Hannah, the Marketing Manager at Workspace Group. Hear firsthand how their team generates engaging descriptions for thousands of office units by integrating diverse data sources—from PDF floorplans to web pages—using FME transformers, like OpenAIVisionConnector and AnthropicVisionConnector. This use case will show you how GenAI can streamline content creation for marketing across the board.
Ollama Use Case: Learn how Scenario Specialist Dmitri Bagh has utilized Ollama within FME to input data, create custom models, and enhance security protocols. This segment will include demos to illustrate the full capabilities of FME in AI-driven processes.
Custom AI Models: Discover how to leverage FME to build personalized AI models using your data. Whether it’s populating a model with local data for added security or integrating public AI tools, find out how FME facilitates a versatile and secure approach to AI.
We’ll wrap up with a live Q&A session where you can engage with our experts on your specific use cases, and learn more about optimizing your data workflows with AI.
This webinar is ideal for professionals seeking to harness the power of AI within their data management systems while ensuring high levels of customization and security. Whether you're a novice or an expert, gain actionable insights and strategies to elevate your data processes. Join us to see how FME and AI can revolutionize how you work with data!
2. @Service
public class NotificationService {
@Autowired
private NotificationRepository notifications;
public void sendNotification(User u, NotificationDAO nd) {
Notification n = new Notification();
n.setDate(System.currentTimeMillis());
n.setReaction(nd.getReaction());
n.setReactionColor(nd.getReactionColor());
n.setText(nd.getText());
n.setUser(u);
n.setWasRead(nd.isWasRead());
notifications.save(n);
}
public List<NotificationDAO> listNotifications(String authtoken,
int page, int amount) {
Page<Notification> notificationsPage = notifications.
findNotificationsForUser(
authtoken, PageRequest.of(page, amount,
NotificationService
3. @Service
public class NotificationService {
@Autowired
private NotificationRepository notifications;
public void sendNotification(User u, NotificationDAO nd) {
Notification n = new Notification();
n.setDate(System.currentTimeMillis());
n.setReaction(nd.getReaction());
n.setReactionColor(nd.getReactionColor());
n.setText(nd.getText());
n.setUser(u);
n.setWasRead(nd.isWasRead());
notifications.save(n);
}
public List<NotificationDAO> listNotifications(String authtoken,
int page, int amount) {
Page<Notification> notificationsPage = notifications.
findNotificationsForUser(
authtoken, PageRequest.of(page, amount,
NotificationService
4. @Service
public class NotificationService {
@Autowired
private NotificationRepository notifications;
public void sendNotification(User u, NotificationDAO nd) {
Notification n = new Notification();
n.setDate(System.currentTimeMillis());
n.setReaction(nd.getReaction());
n.setReactionColor(nd.getReactionColor());
n.setText(nd.getText());
n.setUser(u);
n.setWasRead(nd.isWasRead());
notifications.save(n);
}
public List<NotificationDAO> listNotifications(String authtoken,
int page, int amount) {
Page<Notification> notificationsPage = notifications.
findNotificationsForUser(
authtoken, PageRequest.of(page, amount,
NotificationService
5. public void sendNotification(User u, NotificationDAO nd) {
Notification n = new Notification();
n.setDate(System.currentTimeMillis());
n.setReaction(nd.getReaction());
n.setReactionColor(nd.getReactionColor());
n.setText(nd.getText());
n.setUser(u);
n.setWasRead(nd.isWasRead());
notifications.save(n);
}
public List<NotificationDAO> listNotifications(String authtoken,
int page, int amount) {
Page<Notification> notificationsPage = notifications.
findNotificationsForUser(
authtoken, PageRequest.of(page, amount,
Sort.by(Sort.Direction.DESC, "date")));
List<NotificationDAO> resp = new ArrayList<>();
for(Notification c : notificationsPage) {
resp.add(c.getDAO());
}
return resp;
}
}
NotificationService
6. public void sendNotification(User u, NotificationDAO nd) {
Notification n = new Notification();
n.setDate(System.currentTimeMillis());
n.setReaction(nd.getReaction());
n.setReactionColor(nd.getReactionColor());
n.setText(nd.getText());
n.setUser(u);
n.setWasRead(nd.isWasRead());
notifications.save(n);
}
public List<NotificationDAO> listNotifications(String authtoken,
int page, int amount) {
Page<Notification> notificationsPage = notifications.
findNotificationsForUser(
authtoken, PageRequest.of(page, amount,
Sort.by(Sort.Direction.DESC, "date")));
List<NotificationDAO> resp = new ArrayList<>();
for(Notification c : notificationsPage) {
resp.add(c.getDAO());
}
return resp;
}
}
NotificationService
7. public void sendNotification(User u, NotificationDAO nd) {
Notification n = new Notification();
n.setDate(System.currentTimeMillis());
n.setReaction(nd.getReaction());
n.setReactionColor(nd.getReactionColor());
n.setText(nd.getText());
n.setUser(u);
n.setWasRead(nd.isWasRead());
notifications.save(n);
}
public List<NotificationDAO> listNotifications(String authtoken,
int page, int amount) {
Page<Notification> notificationsPage = notifications.
findNotificationsForUser(
authtoken, PageRequest.of(page, amount,
Sort.by(Sort.Direction.DESC, "date")));
List<NotificationDAO> resp = new ArrayList<>();
for(Notification c : notificationsPage) {
resp.add(c.getDAO());
}
return resp;
}
}
NotificationService
8. @Service
public class MediaService {
@Autowired
private MediaRepository media;
@Autowired
private UserRepository user;
public String storeMedia(String authtoken, byte[] data,
String mimeType, String role, String visibility,
String filename) {
User u = user.findByAuthtoken(authtoken).get(0);
Media m = new Media();
m.setData(data);
m.setOwner(u);
m.setDate(System.currentTimeMillis());
m.setFilename(filename);
m.setMimeType(mimeType);
m.setRole(role);
MediaService
9. @Service
public class MediaService {
@Autowired
private MediaRepository media;
@Autowired
private UserRepository user;
public String storeMedia(String authtoken, byte[] data,
String mimeType, String role, String visibility,
String filename) {
User u = user.findByAuthtoken(authtoken).get(0);
Media m = new Media();
m.setData(data);
m.setOwner(u);
m.setDate(System.currentTimeMillis());
m.setFilename(filename);
m.setMimeType(mimeType);
m.setRole(role);
MediaService
10. @Service
public class MediaService {
@Autowired
private MediaRepository media;
@Autowired
private UserRepository user;
public String storeMedia(String authtoken, byte[] data,
String mimeType, String role, String visibility,
String filename) {
User u = user.findByAuthtoken(authtoken).get(0);
Media m = new Media();
m.setData(data);
m.setOwner(u);
m.setDate(System.currentTimeMillis());
m.setFilename(filename);
m.setMimeType(mimeType);
m.setRole(role);
MediaService
11. private MediaRepository media;
@Autowired
private UserRepository user;
public String storeMedia(String authtoken, byte[] data,
String mimeType, String role, String visibility,
String filename) {
User u = user.findByAuthtoken(authtoken).get(0);
Media m = new Media();
m.setData(data);
m.setOwner(u);
m.setDate(System.currentTimeMillis());
m.setFilename(filename);
m.setMimeType(mimeType);
m.setRole(role);
m.setVisibility(visibility);
media.save(m);
return m.getId();
}
public MediaDAO getPublicMedia(String id) throws PermissionException {
Media m = media.findById(id).get();
if(VisibilityConstants.isPublic(m.getVisibility())) {
MediaService
12. m.setVisibility(visibility);
media.save(m);
return m.getId();
}
public MediaDAO getPublicMedia(String id) throws PermissionException {
Media m = media.findById(id).get();
if(VisibilityConstants.isPublic(m.getVisibility())) {
return m.getDAO();
}
throw new PermissionException(
"Media item belongs to a user that isn't a friend");
}
public MediaDAO getMedia(String authToken, String id) throws
PermissionException {
Media m = media.findById(id).get();
if(VisibilityConstants.isPublic(m.getVisibility())) {
return m.getDAO();
}
if(!m.getOwner().getAuthtoken().equals(authToken)) {
if(!m.getOwner().isFriendByToken(authToken)) {
throw new PermissionException(
"Media item belongs to a user that isn't a friend");
MediaService
13. return m.getId();
}
public MediaDAO getPublicMedia(String id) throws PermissionException {
Media m = media.findById(id).get();
if(VisibilityConstants.isPublic(m.getVisibility())) {
return m.getDAO();
}
throw new PermissionException(
"Media item belongs to a user that isn't a friend");
}
public MediaDAO getMedia(String authToken, String id) throws
PermissionException {
Media m = media.findById(id).get();
if(VisibilityConstants.isPublic(m.getVisibility())) {
return m.getDAO();
}
if(!m.getOwner().getAuthtoken().equals(authToken)) {
if(!m.getOwner().isFriendByToken(authToken)) {
throw new PermissionException(
"Media item belongs to a user that isn't a friend");
}
}
MediaService
public enum VisibilityConstants {
PUBLIC("public"), FRIENDS("friends");
private String str;
private VisibilityConstants(String str) {
this.str = str;
}
public String asString() {
return str;
}
public static boolean isPublic(String s) {
return s == null || s.equalsIgnoreCase(PUBLIC.asString());
}
}
14. return m.getId();
}
public MediaDAO getPublicMedia(String id) throws PermissionException {
Media m = media.findById(id).get();
if(VisibilityConstants.isPublic(m.getVisibility())) {
return m.getDAO();
}
throw new PermissionException(
"Media item belongs to a user that isn't a friend");
}
public MediaDAO getMedia(String authToken, String id) throws
PermissionException {
Media m = media.findById(id).get();
if(VisibilityConstants.isPublic(m.getVisibility())) {
return m.getDAO();
}
if(!m.getOwner().getAuthtoken().equals(authToken)) {
if(!m.getOwner().isFriendByToken(authToken)) {
throw new PermissionException(
"Media item belongs to a user that isn't a friend");
}
}
MediaService
public class PermissionException extends Exception {
public PermissionException(String message) {
super(message);
}
}
15. public MediaDAO getPublicMedia(String id) throws PermissionException {
Media m = media.findById(id).get();
if(VisibilityConstants.isPublic(m.getVisibility())) {
return m.getDAO();
}
throw new PermissionException(
"Media item belongs to a user that isn't a friend");
}
public MediaDAO getMedia(String authToken, String id) throws
PermissionException {
Media m = media.findById(id).get();
if(VisibilityConstants.isPublic(m.getVisibility())) {
return m.getDAO();
}
if(!m.getOwner().getAuthtoken().equals(authToken)) {
if(!m.getOwner().isFriendByToken(authToken)) {
throw new PermissionException(
"Media item belongs to a user that isn't a friend");
}
}
return m.getDAO();
}
}
MediaService
16. public MediaDAO getPublicMedia(String id) throws PermissionException {
Media m = media.findById(id).get();
if(VisibilityConstants.isPublic(m.getVisibility())) {
return m.getDAO();
}
throw new PermissionException(
"Media item belongs to a user that isn't a friend");
}
public MediaDAO getMedia(String authToken, String id) throws
PermissionException {
Media m = media.findById(id).get();
if(VisibilityConstants.isPublic(m.getVisibility())) {
return m.getDAO();
}
if(!m.getOwner().getAuthtoken().equals(authToken)) {
if(!m.getOwner().isFriendByToken(authToken)) {
throw new PermissionException(
"Media item belongs to a user that isn't a friend");
}
}
return m.getDAO();
}
}
MediaService
17. public MediaDAO getPublicMedia(String id) throws PermissionException {
Media m = media.findById(id).get();
if(VisibilityConstants.isPublic(m.getVisibility())) {
return m.getDAO();
}
throw new PermissionException(
"Media item belongs to a user that isn't a friend");
}
public MediaDAO getMedia(String authToken, String id) throws
PermissionException {
Media m = media.findById(id).get();
if(VisibilityConstants.isPublic(m.getVisibility())) {
return m.getDAO();
}
if(!m.getOwner().getAuthtoken().equals(authToken)) {
if(!m.getOwner().isFriendByToken(authToken)) {
throw new PermissionException(
"Media item belongs to a user that isn't a friend");
}
}
return m.getDAO();
}
}
MediaService