Page MenuHomec4science

ServerAppStandalone.java
No OneTemporary

File Metadata

Created
Tue, Jan 7, 01:21

ServerAppStandalone.java

import java.io.IOException;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import database.DBconnectorServer;
import database.DBconnectorServerStandalone;
import utils.ServerProperties;
import framework.RequestHandler;
import framework.reply.ReplyDecryptionRaw;
import framework.request.RequestDecryptionRaw;
public class ServerAppStandalone {
private static final Logger LOGGER = Logger.getLogger(ServerAppStandalone.class.getName());
public static void main(String[] args) {
ServerProperties props = new ServerProperties("config/config_server.fry.properties");
DBconnectorServer connectServer = new DBconnectorServer(props.getConfigSPU());
DBconnectorServerStandalone connect = new DBconnectorServerStandalone(props.getConfigSPU());
// fetch all requests
LinkedList<RequestDecryptionRaw> requests = null;
try {
requests = connect.getRequests();
} catch (SQLException e) {
LOGGER.log(Level.SEVERE, null, e);
}
if (requests != null) {
// process requests
ReplyDecryptionRaw[] replies = new ReplyDecryptionRaw[requests.size()];
RequestHandler handler = new RequestHandler(connectServer, props.getCurve());
for (int i = 0; i < requests.size(); i++) {
RequestDecryptionRaw rqt = requests.get(i);
int patientId = rqt.getPatientId();
long timestamp = rqt.getTimestamp();
String rqtSerial = rqt.getRequestSerialized();
try {
replies[i] = handler.handleDecryptionRequestParsed(patientId, timestamp, rqtSerial);
} catch (SQLException | IOException e) {
LOGGER.log(Level.SEVERE, e.getMessage());
LOGGER.log(Level.SEVERE, null, e);
replies[i] = new ReplyDecryptionRaw(rqt.getPatientId(), timestamp, "");
}
}
// insert replies
try {
connect.insertReplies(replies);
} catch (SQLException e) {
LOGGER.log(Level.SEVERE, null, e);
}
}
}
}

Event Timeline