Example #1
0
 /**
  * <创建备份计划>
  *
  * @return
  * @see [类、类#方法、类#成员]
  */
 public String createBackupVmPlan() {
   long beginRunTime = 0;
   if (logger.isDebugEnabled()) {
     beginRunTime = System.currentTimeMillis();
     logger.debug("enter createBackupVmPlan method.");
   }
   java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("HH:mm");
   ControlPanelUser controlPanelUser =
       (ControlPanelUser) super.getSession().getAttribute(Constants.LOGIN_CURRENTUSER);
   if (controlPanelUser == null) {
     super.fillActionResult(Constants.OPTIONS_TIMEOUT);
     return null;
   }
   String result = null;
   String vmId = controlPanelUser.getVmId();
   String operateObject = "VM[vmId:" + vmId + "]";
   try {
     vssp = Utils.strutsJson2Object(VmSnapShotPlan.class);
     Date dtime = sdf.parse(planTime);
     Time time = new Time(dtime.getTime());
     vssp.setPlanTime(time);
     vssp.setModifyUser(controlPanelUser.getId());
     vssp.setVmId(controlPanelUser.getVmId());
     VmSnapShotPlanVO vsspVO = facade.getBackupVmPlanByVmId(vmId);
     if (vsspVO != null) {
       vssp.setId(vsspVO.getId());
       if (0 == vssp.getPlanType()) {
         vssp.setPlanTime(vsspVO.getPlanTime());
         vssp.setPlanDate(vsspVO.getPlanDate());
       }
     }
     result = facade.createBackupVmPlanByVmId(vssp);
     facade.insertOperationLog(
         controlPanelUser, "创建备份计划成功", "创建备份计划", Constants.RESULT_SUCESS, operateObject);
   } catch (Exception e) {
     facade.insertOperationLog(
         controlPanelUser,
         "创建备份计划出现错误:" + e.getMessage(),
         "创建备份计划",
         Constants.RESULT_FAILURE,
         operateObject);
     dealThrow(
         new HsCloudException(Constants.VM_BACKUP_PLAN_ERROR, "createBackupVmPlan异常", logger, e),
         "000");
     return null;
   }
   if (result != null) {
     super.fillActionResult(Constants.VM_BACKUP_PLAN_ERROR);
   } else {
     super.fillActionResult(Constants.OPTIONS_SUCCESS);
   }
   if (logger.isDebugEnabled()) {
     long takeTime = System.currentTimeMillis() - beginRunTime;
     logger.debug("exit createBackupVmPlan method.takeTime:" + takeTime + "ms");
   }
   return null;
 }
Example #2
0
 /** 重置密码 */
 public void resetPassword() {
   long beginRunTime = 0;
   if (logger.isDebugEnabled()) {
     beginRunTime = System.currentTimeMillis();
     logger.debug("enter resetPassword method.");
   }
   try {
     ControlPanelUser currentUser = (ControlPanelUser) super.getCurrentLoginUser();
     facade.modifyPassword(oldPassword, newPassword, currentUser.getId());
     fillActionResult(true);
   } catch (HsCloudException hse) {
     dealThrow(hse, "");
   }
   if (logger.isDebugEnabled()) {
     long takeTime = System.currentTimeMillis() - beginRunTime;
     logger.debug("exit resetPassword method.takeTime:" + takeTime + "ms");
   }
 }