Implemented AddContact mechanism on the server
(currently unfinished an not working see stack trace for current problem)
This commit is contained in:
		| @@ -10,6 +10,7 @@ import envoy.server.data.ConfigItem; | |||||||
| import envoy.server.database.PersistenceManager; | import envoy.server.database.PersistenceManager; | ||||||
| import envoy.server.net.ObjectMessageProcessor; | import envoy.server.net.ObjectMessageProcessor; | ||||||
| import envoy.server.net.ObjectMessageReader; | import envoy.server.net.ObjectMessageReader; | ||||||
|  | import envoy.server.processors.ContactOperationProcessor; | ||||||
| import envoy.server.processors.ContactsRequestProcesor; | import envoy.server.processors.ContactsRequestProcesor; | ||||||
| import envoy.server.processors.IdGeneratorRequestProcessor; | import envoy.server.processors.IdGeneratorRequestProcessor; | ||||||
| import envoy.server.processors.LoginCredentialProcessor; | import envoy.server.processors.LoginCredentialProcessor; | ||||||
| @@ -44,6 +45,7 @@ public class Startup { | |||||||
| 		processors.add(new UserStatusChangeProcessor()); | 		processors.add(new UserStatusChangeProcessor()); | ||||||
| 		processors.add(new IdGeneratorRequestProcessor()); | 		processors.add(new IdGeneratorRequestProcessor()); | ||||||
| 		processors.add(new ContactsRequestProcesor()); | 		processors.add(new ContactsRequestProcesor()); | ||||||
|  | 		processors.add(new ContactOperationProcessor()); | ||||||
| 		Server server = new Server(8080, () -> new ObjectMessageReader(), new ObjectMessageProcessor(processors)); | 		Server server = new Server(8080, () -> new ObjectMessageReader(), new ObjectMessageProcessor(processors)); | ||||||
|  |  | ||||||
| 		initializeCurrentMessageId(); | 		initializeCurrentMessageId(); | ||||||
|   | |||||||
| @@ -3,7 +3,17 @@ package envoy.server.data; | |||||||
| import java.util.Date; | import java.util.Date; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| import javax.persistence.*; | import javax.persistence.CascadeType; | ||||||
|  | import javax.persistence.Entity; | ||||||
|  | import javax.persistence.GeneratedValue; | ||||||
|  | import javax.persistence.GenerationType; | ||||||
|  | import javax.persistence.Id; | ||||||
|  | import javax.persistence.NamedQueries; | ||||||
|  | import javax.persistence.NamedQuery; | ||||||
|  | import javax.persistence.OneToMany; | ||||||
|  | import javax.persistence.Table; | ||||||
|  | import javax.persistence.Temporal; | ||||||
|  | import javax.persistence.TemporalType; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * This class serves as a way to let Hibernate communicate with the server |  * This class serves as a way to let Hibernate communicate with the server | ||||||
|   | |||||||
| @@ -194,7 +194,9 @@ public class PersistenceManager { | |||||||
| 	 * @return the contacts of this User - currently everyone using Envoy | 	 * @return the contacts of this User - currently everyone using Envoy | ||||||
| 	 * @since Envoy Server Standalone v0.1-alpha | 	 * @since Envoy Server Standalone v0.1-alpha | ||||||
| 	 */ | 	 */ | ||||||
| 	public List<User> getContacts(User user) { return entityManager.createQuery("FROM User").getResultList(); } | 	public List<User> getContacts(User user) { | ||||||
|  | 		return entityManager.createNamedQuery("getContactsOfUser").setParameter("user", user).getResultList(); | ||||||
|  | 	} | ||||||
| 	// TODO current solution gets all users, not just contacts. Should be changed to | 	// TODO current solution gets all users, not just contacts. Should be changed to | ||||||
| 	// entityManager.createNamedQuery("getContactsOfUser").setParameter("user", | 	// entityManager.createNamedQuery("getContactsOfUser").setParameter("user", | ||||||
| 	// user).getResultList(); | 	// user).getResultList(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 DieGurke
					DieGurke