Removed unnecessary log message from LocalDB, logging Sync

This commit is contained in:
Kai S. K. Engelbart 2019-12-21 18:29:59 +01:00
parent 34e9dc9e8b
commit 7212e10d54
2 changed files with 19 additions and 25 deletions

View File

@ -1,7 +1,9 @@
package envoy.client; package envoy.client;
import java.io.StringWriter;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger;
import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity; import javax.ws.rs.client.Entity;
@ -11,6 +13,7 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller; import javax.xml.bind.Marshaller;
import envoy.client.util.EnvoyLog;
import envoy.exception.EnvoyException; import envoy.exception.EnvoyException;
import envoy.schema.ObjectFactory; import envoy.schema.ObjectFactory;
import envoy.schema.Sync; import envoy.schema.Sync;
@ -20,7 +23,7 @@ import envoy.schema.User;
* Project: <strong>envoy-client</strong><br> * Project: <strong>envoy-client</strong><br>
* File: <strong>Client.java</strong><br> * File: <strong>Client.java</strong><br>
* Created: <strong>28 Sep 2019</strong><br> * Created: <strong>28 Sep 2019</strong><br>
* *
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @author Maximilian K&auml;fer * @author Maximilian K&auml;fer
* @author Leon Hofmeister * @author Leon Hofmeister
@ -33,10 +36,12 @@ public class Client {
private User sender, recipient; private User sender, recipient;
private boolean online = false; private boolean online = false;
private static final Logger logger = EnvoyLog.getLogger(Client.class.getSimpleName());
/** /**
* Initializes the client. At this state, the client user has yet to be * Initializes the client. At this state, the client user has yet to be
* initialized, which can be done by calling {@link Client#onlineInit(String)}. * initialized, which can be done by calling {@link Client#onlineInit(String)}.
* *
* @param config The {@link Config} instance to use in this client * @param config The {@link Config} instance to use in this client
* @since Envoy v0.2-alpha * @since Envoy v0.2-alpha
*/ */
@ -44,7 +49,7 @@ public class Client {
/** /**
* Enters the online mode by acquiring a user ID from the server. * Enters the online mode by acquiring a user ID from the server.
* *
* @param userName the name of the client user * @param userName the name of the client user
* @throws EnvoyException if the online mode could not be entered or the request * @throws EnvoyException if the online mode could not be entered or the request
* failed for some other reason * failed for some other reason
@ -88,7 +93,7 @@ public class Client {
/** /**
* Returns a {@link User} with a specific id by name. * Returns a {@link User} with a specific id by name.
* *
* @param name - the name of the {@link User} * @param name - the name of the {@link User}
* @return a {@link User} with the specified name * @return a {@link User} with the specified name
* @throws EnvoyException if the server does not return the requested ID * @throws EnvoyException if the server does not return the requested ID
@ -146,7 +151,7 @@ public class Client {
* Users: <br> * Users: <br>
* Updating UserStatus of all users in LocalDB. (Server sends all users with * Updating UserStatus of all users in LocalDB. (Server sends all users with
* their updated UserStatus to the client.) <br> * their updated UserStatus to the client.) <br>
* *
* @param userId the id of the {@link Client} who sends the {@link Sync} * @param userId the id of the {@link Client} who sends the {@link Sync}
* @param sync the sync object (yet to be converted from java class to * @param sync the sync object (yet to be converted from java class to
* sync.xml) * sync.xml)
@ -163,7 +168,9 @@ public class Client {
jc = JAXBContext.newInstance("envoy.schema"); jc = JAXBContext.newInstance("envoy.schema");
Marshaller m = jc.createMarshaller(); Marshaller m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.marshal(sync, System.out); StringWriter stringWriter = new StringWriter();
m.marshal(sync, stringWriter);
logger.fine("Sending sync:\n" + stringWriter.toString());
} catch (JAXBException e) { } catch (JAXBException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -180,7 +187,7 @@ public class Client {
/** /**
* Sets the client user which is used to send messages. * Sets the client user which is used to send messages.
* *
* @param sender the client user to set * @param sender the client user to set
* @since Envoy v0.2-alpha * @since Envoy v0.2-alpha
*/ */
@ -194,7 +201,7 @@ public class Client {
/** /**
* Sets the recipient. * Sets the recipient.
* *
* @param recipient the recipient to set * @param recipient the recipient to set
* @since Envoy v0.1-alpha * @since Envoy v0.1-alpha
*/ */

View File

@ -1,16 +1,8 @@
package envoy.client; package envoy.client;
import java.io.File; import java.io.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeConfigurationException;
@ -20,11 +12,8 @@ import envoy.client.event.EventBus;
import envoy.client.event.MessageCreationEvent; import envoy.client.event.MessageCreationEvent;
import envoy.client.util.EnvoyLog; import envoy.client.util.EnvoyLog;
import envoy.exception.EnvoyException; import envoy.exception.EnvoyException;
import envoy.schema.Message; import envoy.schema.*;
import envoy.schema.Message.Metadata.MessageState; import envoy.schema.Message.Metadata.MessageState;
import envoy.schema.ObjectFactory;
import envoy.schema.Sync;
import envoy.schema.User;
/** /**
* Project: <strong>envoy-client</strong><br> * Project: <strong>envoy-client</strong><br>
@ -249,10 +238,8 @@ public class LocalDB {
// Updating UserStatus of all users in LocalDB // Updating UserStatus of all users in LocalDB
for (User user : returnSync.getUsers()) for (User user : returnSync.getUsers())
for (Chat chat : getChats()) for (Chat chat : getChats())
if (user.getID() == chat.getRecipient().getID()) { if (user.getID() == chat.getRecipient().getID())
chat.getRecipient().setStatus(user.getStatus()); chat.getRecipient().setStatus(user.getStatus());
logger.info(chat.getRecipient().getStatus().toString());
}
sync.getMessages().clear(); sync.getMessages().clear();
sync.getUsers().clear(); sync.getUsers().clear();