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

View File

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