Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vF #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

vF #11

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .metadata/.log
Original file line number Diff line number Diff line change
@@ -1727,3 +1727,68 @@ org.eclipse.wst.xml.core.internal.document.StructuredDocumentRegionManagementExc
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
!SESSION 2023-05-13 04:24:33.504 -----------------------------------------------
eclipse.buildId=4.26.0.20221201-1200
java.version=17.0.5
java.vendor=Eclipse Adoptium
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=fr_FR
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

!ENTRY ch.qos.logback.classic 1 0 2023-05-13 04:24:37.868
!MESSAGE Activated before the state location was initialized. Retry after the state location is initialized.

!ENTRY org.eclipse.core.resources 2 10035 2023-05-13 04:24:49.967
!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.

!ENTRY ch.qos.logback.classic 1 0 2023-05-13 04:25:30.449
!MESSAGE Logback config file: C:\Users\Simofatt\workspace3\.metadata\.plugins\org.eclipse.m2e.logback\logback.2.1.0.20221015-0744.xml

!ENTRY org.eclipse.jface 2 0 2023-05-13 04:25:32.953
!MESSAGE Keybinding conflicts occurred. They may interfere with normal accelerator operation.
!SUBENTRY 1 org.eclipse.jface 2 0 2023-05-13 04:25:32.953
!MESSAGE A conflict occurred for CTRL+SHIFT+T:
Binding(CTRL+SHIFT+T,
ParameterizedCommand(Command(org.eclipse.jdt.ui.navigate.open.type,Open Type,
Open a type in a Java editor,
Category(org.eclipse.ui.category.navigate,Navigate,null,true),
WorkbenchHandlerServiceHandler("org.eclipse.jdt.ui.navigate.open.type"),
,,true),null),
org.eclipse.ui.defaultAcceleratorConfiguration,
org.eclipse.ui.contexts.window,,,system)
Binding(CTRL+SHIFT+T,
ParameterizedCommand(Command(org.eclipse.lsp4e.symbolinworkspace,Go to Symbol in Workspace,
,
Category(org.eclipse.lsp4e.category,Language Servers,null,true),
WorkbenchHandlerServiceHandler("org.eclipse.lsp4e.symbolinworkspace"),
,,true),null),
org.eclipse.ui.defaultAcceleratorConfiguration,
org.eclipse.ui.contexts.window,,,system)
!SUBENTRY 1 org.eclipse.jface 2 0 2023-05-13 04:25:32.953
!MESSAGE A conflict occurred for ALT+SHIFT+R:
Binding(ALT+SHIFT+R,
ParameterizedCommand(Command(org.eclipse.jdt.ui.edit.text.java.rename.element,Rename - Refactoring ,
Rename the selected element,
Category(org.eclipse.jdt.ui.category.refactoring,Refactor - Java,Java Refactoring Actions,true),
WorkbenchHandlerServiceHandler("org.eclipse.jdt.ui.edit.text.java.rename.element"),
,,true),null),
org.eclipse.ui.defaultAcceleratorConfiguration,
org.eclipse.ui.contexts.window,,,system)
Binding(ALT+SHIFT+R,
ParameterizedCommand(Command(org.eclipse.ui.edit.rename,Rename,
Rename the selected item,
Category(org.eclipse.ui.category.file,File,null,true),
WorkbenchHandlerServiceHandler("org.eclipse.ui.edit.rename"),
,,true),null),
org.eclipse.ui.defaultAcceleratorConfiguration,
org.eclipse.ui.contexts.window,,,system)

!ENTRY org.eclipse.egit.ui 2 0 2023-05-13 04:25:38.335
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\Simofatt'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

!ENTRY org.eclipse.jst.jsp.core 4 4 2023-05-13 04:25:41.326
!MESSAGE A workspace crash was detected. The previous session did not exit normally. Not using saved taglib indexes.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
#MyEclipse Usage Data
#Tue May 09 06:57:23 CEST 2023
#Sat May 13 04:26:39 CEST 2023
bundle/com.genuitec.eclipse.tm4e.languageconfiguration=-1
misc/arch=x86_64
bundle/com.genuitec.eclipse.startup.workspace=297
bundle/com.genuitec.eclipse.theming.ui=297
bundle/com.genuitec.eclipse.theming.elevation.win32=-1
bundle/com.genuitec.eclipse.startup.workspace=298
bundle/com.genuitec.eclipse.theming.ui=298
devstyle/state/editorColor/Eclipse_Standard=1
bundle/com.genuitec.eclipse.theming.elevation.win32=-1
view/org.eclipse.ui.console.ConsoleView=184
bundle/com.genuitec.eclipse.theming.css=-1
editor/org.eclipse.wst.css.core.csssource.source=170
bundle/com.genuitec.eclipse.codetogether.ui.client=322
view/org.eclipse.ui.navigator.ProjectExplorer=1174
misc/timestamp=9 mai 2023, 04\:57\:23
bundle/com.genuitec.eclipse.codetogether.ui.client=323
view/org.eclipse.ui.navigator.ProjectExplorer=1175
misc/timestamp=13 mai 2023, 02\:26\:39
editor/org.eclipse.jdt.ui.CompilationUnitEditor=3745
bundle/com.genuitec.eclipse.theming.scrollbar=297
bundle/com.genuitec.eclipse.lsp4e=322
bundle/com.genuitec.eclipse.codetogether.ui=322
bundle/com.genuitec.eclipse.lsp4e=323
bundle/com.genuitec.eclipse.theming.scrollbar=298
bundle/com.genuitec.eclipse.codetogether.ui=323
devstyle/state/iconsColor/primary=1
bundle/com.genuitec.eclipse.theming.base=297
bundle/com.genuitec.eclipse.inlinesearch=297
bundle/com.genuitec.eclipse.codetogether.patches=322
bundle/com.genuitec.eclipse.monitor=297
bundle/com.genuitec.eclipse.theming.base=298
bundle/com.genuitec.eclipse.inlinesearch=298
bundle/com.genuitec.eclipse.codetogether.patches=323
bundle/com.genuitec.eclipse.monitor=298
devstyle/state/enabled=1
editor/org.eclipse.jdt.ui.ClassFileEditor=6
bundle/com.genuitec.eclipse.webclipse.evergreen=297
bundle/com.genuitec.eclipse.webclipse.evergreen=298
bundle/com.genuitec.eclipse.news=-1
bundle/com.genuitec.eclipse.theming.scrollbar.win=-1
misc/period=753170800
misc/period=753230801
bundle/com.genuitec.eclipse.theming.icon.designer=-1
bundle/com.genuitec.eclipse.codetogether.epl=95
bundle/com.genuitec.eclipse.codetogether.api=-1
devstyle/state/inlinesearch=1
bundle/com.genuitec.eclipse.ui.common.platform=322
misc/count=322
bundle/com.genuitec.eclipse.ui.common.platform=323
misc/count=323
bundle/com.genuitec.eclipse.codetogether.cm=-1
editor/org.eclipse.ui.DefaultTextEditor=2
editor/org.eclipse.ui.browser.editor=1
bundle/com.genuitec.eclipse.meexplorer=297
bundle/com.genuitec.eclipse.meexplorer=298
misc/productType/devstyle=1
misc/os=win32
bundle/com.genuitec.eclipse.meexplorer.jdt=297
bundle/com.genuitec.eclipse.webicons=322
bundle/com.genuitec.eclipse.meexplorer.jdt=298
bundle/com.genuitec.eclipse.webicons=323
misc/core_version=<unknown>
editor/org.eclipse.jst.jsp.core.jspsource.source=879
editor/org.eclipse.jst.jsp.core.jspsource.source=880
view/org.eclipse.ui.views.ContentOutline=2
bundle/com.genuitec.eclipse.core.common.rss=20
misc/installmode/stable=0
@@ -52,8 +52,8 @@ devstyle/state/editorColor/Darkest_Dark=1
bundle/com.genuitec.eclipse.codetogether.webicons=-1
bundle/com.genuitec.eclipse.genericeditor=20
misc/ws=win32
bundle/com.genuitec.eclipse.patches=322
bundle/com.genuitec.eclipse.startup=297
bundle/com.genuitec.eclipse.patches=323
bundle/com.genuitec.eclipse.startup=298
view/org.eclipse.search.ui.views.SearchView=3
devstyle/state/workbenchColor/Dark_Windows_11=1
bundle/com.genuitec.eclipse.theming.base.win=-1
@@ -62,12 +62,12 @@ misc/product/org.eclipse.epp.package.jee.product=1
misc/installmode/standalone=0
misc/locale=fr_FR
misc/workspace_hash=-781576413
perspective/org.eclipse.jst.j2ee.J2EEPerspective=33
perspective/org.eclipse.jst.j2ee.J2EEPerspective=34
view/org.eclipse.ui.views.AllMarkersView=2
editor/org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart=14
bundle/com.genuitec.eclipse.theming.epl=-1
bundle/com.genuitec.eclipsecolortheme.api=322
bundle/com.genuitec.eclipse.codetogether.core=322
bundle/com.genuitec.eclipsecolortheme.api=323
bundle/com.genuitec.eclipse.codetogether.core=323
view/org.eclipse.wst.server.ui.ServersView=38
bundle/com.genuitec.eclipse.theming.core=297
bundle/com.genuitec.eclipse.core.common.platform=322
bundle/com.genuitec.eclipse.theming.core=298
bundle/com.genuitec.eclipse.core.common.platform=323
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
package comm.octest.servlets;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.NoSuchAlgorithmException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.Part;

import comm.octest.beans.Observer;
import comm.octest.beans.User;

@WebServlet(name = "SettingsServlet", value = "/settingsServlet")
@MultipartConfig
public class SettingsServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

public SettingsServlet() {
super();

}

protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

HttpSession session = request.getSession();
String email = (String) session.getAttribute("email");


if (email != null) {
Observer user = new User();
int id_user = (Integer) session.getAttribute("user_id");

try {

List<User> userInfo = user.getInfo(email, id_user);
request.setAttribute("userInfo", userInfo);

} catch (SQLException e) {

e.printStackTrace();
}
this.getServletContext().getRequestDispatcher("/WEB-INF/settings.jsp").forward(request, response);
} else {
response.sendRedirect("registration");
}
}

protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession();
String email_session = (String) session.getAttribute("email");
int id_user2 = (Integer) session.getAttribute("user_id");

String full_name = request.getParameter("full_name");
String email = request.getParameter("email");
String city = request.getParameter("city");
String country = request.getParameter("country");
String password = request.getParameter("password");
int idUserConnected = (Integer) session.getAttribute("user_id");

Part filePart = request.getPart("picture");// "profile_picture" is the name of the input file element in the HTML form

try {
if(filePart != null) {
System.out.println("££££" +filePart) ;

//InputStream fileContent = filePart.getInputStream();


String fileName = filePart.getSubmittedFileName(); // get the filename from the submitted file part
String extension = "";



String uploadPath = "C:/Users/Simofatt/workspace3/test/src/main/webapp/WEB-INF/ressources/uploads/"+id_user2;

//String filePath = request.getServletContext().getRealPath("/") + "WEB-INF\\ressources\\uploads\\" + fileName;
// construct the file path using the web app root path and the "uploads" folder
//String filePath = "/test/src/main/webapp/WEB-INF/ressources/uploads"+fileName ;
//System.out.println("££££" +filePath) ;
//Files.copy(fileContent, Paths.get(filePath), StandardCopyOption.REPLACE_EXISTING); // save the file to disk

FileOutputStream fos = new FileOutputStream(uploadPath);
InputStream is = filePart.getInputStream() ;
byte[] data = new byte[is.available()] ;
is.read(data);
fos.write(data);
fos.close();

}
}catch (Exception e) {
e.printStackTrace() ;
}


//String filePath = request.getServletContext().getRealPath("/") + "uploads/" + fileName;
try {

Observer user = new User();
List<User> userInfo = user.getInfo(email_session, idUserConnected);
int id_user = user.getIdUser(email_session);
user.setId_user(id_user);


if (full_name != null && !full_name.isEmpty()) {
user.setName(full_name);
} else {
user.setName(userInfo.get(0).getName()); // set the current value of name in the database
}
if (email != null && !email.isEmpty()) {
user.setEmail(email);
boolean valide = user.validEmail(email, email_session);
if (valide) {
session.setAttribute("email", email);
}

} else {
user.setEmail(email_session);
}
if (city != null && !city.isEmpty()) {
user.setCity(city);
} else {
user.setCity(userInfo.get(0).getCity());
}
if (country != null && !country.isEmpty()) {
user.setCountry(country);
} else {
user.setCountry(userInfo.get(0).getCountry());
}
if (password != null && !password.isEmpty()) {

try {
String hashPassword = user.hashPassword(password);
user.setPassword(hashPassword);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}

} else {
user.setPassword(userInfo.get(0).getPassword());
}

boolean emailValide = user.updateUserInfo(user, email_session);
System.out.println(emailValide);
System.out.println(userInfo.get(0).getPassword());

if (emailValide) {
response.sendRedirect("settings");
} else {
request.setAttribute("userInfo", userInfo);
this.getServletContext().getRequestDispatcher("/WEB-INF/settings.jsp?error=1").forward(request,
response);
}
} catch (SQLException e) {

e.printStackTrace();
}

}

}
Loading