Package healthwatcher.view.command

Source Code of healthwatcher.view.command.UpdateEmployeeData

package healthwatcher.view.command;

import healthwatcher.model.employee.Employee;
import healthwatcher.view.IFacade;

import java.io.PrintWriter;

import lib.exceptions.InvalidSessionException;
import lib.util.HTMLCode;

public class UpdateEmployeeData extends Command {

  public UpdateEmployeeData(IFacade f) {
    super(f);
    // TODO Auto-generated constructor stub
  }

  public void execute() throws Exception {
    PrintWriter out = response.getWriter();

    String name = request.getInput("name");
    // String password = request.getParameter("password");
    String newPassword = request.getInput("newPassword");
    Employee employee = null;

    try {
      if (! request.isAuthorized()) {
        throw new InvalidSessionException();
      }

      employee = (Employee) request.get(Login.EMPLOYEE);

      employee.setName(name);
      if (!newPassword.equals("")) {
        employee.setPassword(newPassword);
      }

      out.println(HTMLCode.htmlPageAdministrator("Operation executed",
          "Employee updated"));

    } catch (Exception e) {
      out.println(lib.util.HTMLCode.errorPage(e.getMessage()));
      e.printStackTrace(out);
    }finally {out.close();}
  }
}
TOP

Related Classes of healthwatcher.view.command.UpdateEmployeeData

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.