Advertisement
ballchaichana

temp

Sep 18th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.60 KB | None | 0 0
  1. package th.in.oneauth.servlet;
  2.  
  3. import java.io.IOException;
  4. import javax.servlet.ServletException;
  5. import javax.servlet.annotation.WebServlet;
  6. import javax.servlet.http.HttpServlet;
  7. import javax.servlet.http.HttpServletRequest;
  8. import javax.servlet.http.HttpServletResponse;
  9.  
  10. import com.google.gson.JsonObject;
  11.  
  12. import th.in.oneauthen.object.SftpProfileDB;
  13. import th.in.oneauthen.object.SignatureProfileDB;
  14. import th.in.oneauthen.object.UserUidDB;
  15. import th.in.oneauthen.object.DAO.SftpProfileDAO;
  16. import th.in.oneauthen.object.DAO.SignatureProfileDAO;
  17.  
  18.  
  19. @WebServlet("/signature")
  20. public class SignatureProfileServlet extends HttpServlet {
  21.     private static final long serialVersionUID = 1L;
  22.     public static final String PROFILE_NAME = "profilename";
  23.     public static final String Month_session = "24";
  24.     public static final String Year_session = "2561";
  25.     public static final String SIGNING_URL = "dashboard.jsp?reqp=signing";
  26.    
  27.     public static String SFTP_ADDRESS  = "sftpAddress";
  28.     public static String SFTP_PORT = "8080";
  29.     public static String SFTP_USERNAME = "username";
  30.     public static String SFTP_PASSWORD = "password";
  31.     public static String TARGETDIR = "targetDir";
  32.    
  33.     public static String PARAM_ACTION = "action";
  34.     public static final String PARAM_ACTION_DELTE = "delete";
  35.     public static final String PARAM_ACTION_EDIT = "edit";
  36.    
  37.     public static final String SESSION_PARAM_MONTH = "month";
  38.     public static final String SESSION_PARAM_YEAR = "year";
  39.        
  40.  
  41.  
  42.  
  43.     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  44.         // TODO Auto-generated method stub
  45.         String profilename = request.getParameter(PROFILE_NAME);
  46.        
  47.         UserUidDB userIdForProfile = (UserUidDB) request.getSession().getAttribute(LoginServlet.SESSION_PARAM_USER);
  48.         int ownerId =userIdForProfile.getUserId();
  49.        
  50.         String month = request.getParameter(Month_session);
  51.         String year = request.getParameter(Year_session);
  52.        
  53.         request.getSession().setAttribute(SESSION_PARAM_MONTH,month);
  54.         request.getSession().setAttribute(SESSION_PARAM_MONTH,year);
  55.        
  56.         SignatureProfileDB delProfile = new SignatureProfileDAO().findByNameAndUserUID(profilename, ownerId);
  57.         SignatureProfileDAO a = new SignatureProfileDAO();
  58.         delProfile.getProfileID();
  59. //      try {
  60. //          a.remove(delProfile.getProfileID());
  61. //      } catch (Exception e1) {
  62. //           System.out.println("kuyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy");
  63. //          e1.printStackTrace();
  64. //      }
  65.         request.getSession().setAttribute("profileName", profilename);//profile name
  66.         request.getRequestDispatcher(SIGNING_URL).forward(request, response);
  67.        
  68.        
  69.        
  70. //
  71. //     
  72. //      String ipSftp = request.getParameter(SFTP_ADDRESS);
  73. //      String sftpPortStr = request.getParameter(SFTP_PORT);
  74. //      int sftpPort = Integer.parseInt("8080");   
  75. //      String profileSftp = request.getParameter(SFTP_USERNAME);
  76. //      String keyPin = request.getParameter(SFTP_PASSWORD);
  77. //      String locationSign = request.getParameter(TARGETDIR);
  78. //     
  79. //     
  80. //             
  81. //      //save in DB signatureprofileDB
  82. //      SftpProfileDAO sftpProfile = new SftpProfileDAO();
  83. //      SftpProfileDB setSftpProfile = new SftpProfileDB();
  84. //      setSftpProfile.setSftpAddress("192.168.1.254");
  85. //      setSftpProfile.setSftpDir("C//ballza");
  86. //      setSftpProfile.setSftpPort(443);
  87. //      setSftpProfile.setSftpUserName("chaichana");
  88. //      setSftpProfile.setSftpPassword("chaichana2538");
  89. //      setSftpProfile.setProfileID(delProfile);
  90. //     
  91. //      try {
  92. //          sftpProfile .save(setSftpProfile);
  93. //      } catch (Exception e) {
  94. //          // TODO Auto-generated catch block
  95. //          e.printStackTrace();
  96. //      }
  97. //     
  98.  
  99.        
  100.        
  101.     }
  102.  
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement