Advertisement
ballchaichana

temp

Sep 19th, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.74 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.     public static final String URL_DASHBORD = "dashboard.jsp";
  27.    
  28.     public static String SFTP_ADDRESS  = "sftpAddress";
  29.     public static String SFTP_PORT = "8080";
  30.     public static String SFTP_USERNAME = "username";
  31.     public static String SFTP_PASSWORD = "password";
  32.     public static String TARGETDIR = "targetDir";
  33.    
  34.     public static String PARAM_ACTION = "action";
  35.  
  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.  
  57.         PARAM_ACTION ="selectProfile";
  58.         switch (PARAM_ACTION) {
  59.         case "delete":
  60.             SignatureProfileDB delProfile = new SignatureProfileDAO().findByNameAndUserUID(profilename, ownerId);
  61.             SignatureProfileDAO selectDel = new SignatureProfileDAO();
  62.             try {
  63.                 selectDel.remove(delProfile.getProfileID());
  64.                 request.getRequestDispatcher(URL_DASHBORD).forward(request, response);
  65.         } catch (Exception e1) {
  66.              System.out.println("Error can not delete :"+delProfile.getProfileName());
  67.             e1.printStackTrace();
  68.         }
  69.             break;
  70.         case "selectProfile":
  71.             request.getSession().setAttribute("profileName", profilename);//profile name
  72.             request.getRequestDispatcher(SIGNING_URL).forward(request, response);
  73.             break;
  74.         }
  75.        
  76.        
  77.        
  78. //
  79. //     
  80. //      String ipSftp = request.getParameter(SFTP_ADDRESS);
  81. //      String sftpPortStr = request.getParameter(SFTP_PORT);
  82. //      int sftpPort = Integer.parseInt("8080");   
  83. //      String profileSftp = request.getParameter(SFTP_USERNAME);
  84. //      String keyPin = request.getParameter(SFTP_PASSWORD);
  85. //      String locationSign = request.getParameter(TARGETDIR);
  86. //     
  87. //     
  88. //             
  89. //      //save in DB signatureprofileDB
  90. //      SftpProfileDAO sftpProfile = new SftpProfileDAO();
  91. //      SftpProfileDB setSftpProfile = new SftpProfileDB();
  92. //      setSftpProfile.setSftpAddress("192.168.1.254");
  93. //      setSftpProfile.setSftpDir("C//ballza");
  94. //      setSftpProfile.setSftpPort(443);
  95. //      setSftpProfile.setSftpUserName("chaichana");
  96. //      setSftpProfile.setSftpPassword("chaichana2538");
  97. //      setSftpProfile.setProfileID(delProfile);
  98. //     
  99. //      try {
  100. //          sftpProfile .save(setSftpProfile);
  101. //      } catch (Exception e) {
  102. //          // TODO Auto-generated catch block
  103. //          e.printStackTrace();
  104. //      }
  105. //     
  106.  
  107.        
  108.        
  109.     }
  110.  
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement