mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-11-22 16:23:20 +00:00
Module Server : correction d'un bug empêchant la persistance des données runtime, comme les comptes connectés
This commit is contained in:
parent
5217b6f782
commit
eb6f37f9d3
@ -52,7 +52,13 @@ public class FileAccountDao implements IAccountDao {
|
|||||||
* @return La première correspondance trouvée, ou {@code null} si aucune correspondance n'a pu être faite.
|
* @return La première correspondance trouvée, ou {@code null} si aucune correspondance n'a pu être faite.
|
||||||
*/
|
*/
|
||||||
private AccountEntry lookupMatchingEntry(Account account, Collection<AccountEntry> entries){
|
private AccountEntry lookupMatchingEntry(Account account, Collection<AccountEntry> entries){
|
||||||
return entries.stream().filter(accountEntry -> accountEntry.getUsername().equals(account.getUsername())).findFirst().orElse(null);
|
return entries.stream()
|
||||||
|
.filter(accountEntry ->
|
||||||
|
accountEntry != null
|
||||||
|
&& account != null
|
||||||
|
&& accountEntry.getUsername().equals(account.getUsername()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,6 +16,17 @@ import java.io.IOException;
|
|||||||
//TODO ajouter logs
|
//TODO ajouter logs
|
||||||
@WebServlet(name = "QueryServlet", urlPatterns = "/")
|
@WebServlet(name = "QueryServlet", urlPatterns = "/")
|
||||||
public class QueryServlet extends HttpServlet {
|
public class QueryServlet extends HttpServlet {
|
||||||
|
|
||||||
|
private final IMessageToolFactory messageToolFactory;
|
||||||
|
private final IMessageHandler msgHandler;
|
||||||
|
|
||||||
|
public QueryServlet() {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this.messageToolFactory = new GSonMessageToolFactory();
|
||||||
|
this.msgHandler = new SimpleMessageHandler();
|
||||||
|
}
|
||||||
|
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
executeServletProcess(request, response);
|
executeServletProcess(request, response);
|
||||||
}
|
}
|
||||||
@ -25,8 +36,6 @@ public class QueryServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void executeServletProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
private void executeServletProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
IMessageToolFactory messageToolFactory = new GSonMessageToolFactory();
|
|
||||||
IMessageHandler msgHandler = new SimpleMessageHandler();
|
|
||||||
|
|
||||||
if (request.getQueryString() != null && !request.getQueryString().isEmpty() && request.getParameter("message")!=null) {
|
if (request.getQueryString() != null && !request.getQueryString().isEmpty() && request.getParameter("message")!=null) {
|
||||||
try {
|
try {
|
||||||
@ -34,7 +43,10 @@ public class QueryServlet extends HttpServlet {
|
|||||||
|
|
||||||
response.getWriter().write(messageToolFactory.getObjectFormatter(Message.class).format(resp));
|
response.getWriter().write(messageToolFactory.getObjectFormatter(Message.class).format(resp));
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
response.getWriter().write(String.format("%s : %s", e.getClass().getName(), e.getMessage()));
|
response.getWriter().write(String.format("%s : %s", e.getClass().getName(), e.getMessage()));
|
||||||
|
response.getWriter().write("StackTrace :");
|
||||||
|
e.printStackTrace(response.getWriter());
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
response.getWriter().write("Query message was not correctly made : "+request.getQueryString());
|
response.getWriter().write("Query message was not correctly made : "+request.getQueryString());
|
||||||
|
Loading…
Reference in New Issue
Block a user